diff --git a/libs/x11/client.c b/libs/x11/client.c index 61f86cc..55455a9 100644 --- a/libs/x11/client.c +++ b/libs/x11/client.c @@ -4,6 +4,13 @@ void prepare_window_size(void) { sp = menupaddingh; vp = (menuposition == 1) ? menupaddingv : - menupaddingv; + bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); + lines = MAX(lines, 0); + reallines = lines; + + lrpad = drw->font->h + textpadding; + mh = (lines + 1) * bh + 2 * menumarginv; // lines + 1 * bh is the menu height + return; } @@ -40,8 +47,16 @@ void set_window(void) { } void set_prop(void) { - if (dockproperty) XChangeProperty(dpy, win, types, XA_ATOM, 32, PropModeReplace, (unsigned char *) &dock, 1); // set dock property - return; + // set properties indicating what spmenu handles + clip = XInternAtom(dpy, "CLIPBOARD", False); + utf8 = XInternAtom(dpy, "UTF8_STRING", False); + types = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + + // set dock property + if (dockproperty) { + dock = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); + XChangeProperty(dpy, win, types, XA_ATOM, 32, PropModeReplace, (unsigned char *) &dock, 1); // set dock property + } } void resizeclient(void) { diff --git a/libs/x11/init.c b/libs/x11/init.c index 8771b71..b07cf75 100644 --- a/libs/x11/init.c +++ b/libs/x11/init.c @@ -7,7 +7,6 @@ void setupdisplay(void) { unsigned int tmp, minstrlen = 0, curstrlen = 0; int numwidthchecks = 100; struct item *item; - XIM xim; Window w, dw, *dws; XWindowAttributes wa; #if USEXINERAMA @@ -16,16 +15,7 @@ void setupdisplay(void) { int a, n, area = 0; #endif - // set properties indicating what spmenu handles - clip = XInternAtom(dpy, "CLIPBOARD", False); - utf8 = XInternAtom(dpy, "UTF8_STRING", False); - types = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); - dock = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); - - // resize client - bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); - lines = MAX(lines, 0); - reallines = lines; + prepare_window_size(); // resize client to image height if deemed necessary #if USEIMAGE @@ -125,18 +115,7 @@ void setupdisplay(void) { setimageopts(); #endif - // input methods - if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { - XSetLocaleModifiers("@im=local"); - if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { - XSetLocaleModifiers("@im="); - if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) - die("XOpenIM failed: could not open input device"); - } - } - - xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, win, XNFocusWindow, win, NULL); + open_xim(); // open xim XMapRaised(dpy, win); diff --git a/libs/x11/init.h b/libs/x11/init.h index b9f2d77..755752d 100644 --- a/libs/x11/init.h +++ b/libs/x11/init.h @@ -1 +1,5 @@ +static Atom clip, utf8, types, dock; +static Display *dpy; +static Window root, parentwin, win; + static void setupdisplay(void); diff --git a/libs/x11/xim.c b/libs/x11/xim.c new file mode 100644 index 0000000..1d1340d --- /dev/null +++ b/libs/x11/xim.c @@ -0,0 +1,16 @@ +void open_xim(void) { + XIM xim; + + // input methods + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { + XSetLocaleModifiers("@im=local"); + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { + XSetLocaleModifiers("@im="); + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) + die("XOpenIM failed: could not open input device"); + } + } + + xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, win, XNFocusWindow, win, NULL); +} diff --git a/libs/x11/xim.h b/libs/x11/xim.h new file mode 100644 index 0000000..e2392d9 --- /dev/null +++ b/libs/x11/xim.h @@ -0,0 +1,3 @@ +static XIC xic; + +static void open_xim(void); diff --git a/spmenu.c b/spmenu.c index 09b242a..2956268 100644 --- a/spmenu.c +++ b/spmenu.c @@ -124,6 +124,7 @@ static int allowkeys = 1; // whether or not to interpret a keypress as an insert #include "libs/schemes.h" #include "libs/arg.h" #include "libs/x11/xrdb.h" +#include "libs/x11/xim.h" #include "libs/x11/key.h" #include "libs/x11/mouse.h" #include "libs/sort.h" @@ -212,12 +213,6 @@ static int ignoreglobalkeys = 0; // should be set in the config file, if 1, the static int ignoreconfmouse = 0; // same for mouse static int ignoreglobalmouse = 0; // same for mouse -// X11 properties -static Atom clip, utf8, types, dock; -static Display *dpy; -static Window root, parentwin, win; -static XIC xic; - // colors static int useargb = 0; static Visual *visual; @@ -273,6 +268,7 @@ static char *(*fstrstr)(const char *, const char *) = cistrstr; #include "libs/img.c" #include "libs/rtl.h" #include "libs/rtl.c" +#include "libs/x11/xim.c" #include "libs/x11/key.c" #include "libs/x11/mouse.c" #include "libs/sort.c"