forked from speedie/spmenu
make the code a bit more readable
This commit is contained in:
parent
eb83b0376d
commit
7f2ad4b5d6
|
@ -104,10 +104,14 @@ void setupdisplay(void) {
|
||||||
// might be faster in some instances, most of the time unnecessary
|
// might be faster in some instances, most of the time unnecessary
|
||||||
if (!accuratewidth) inputw = MIN(inputw, mw/3);
|
if (!accuratewidth) inputw = MIN(inputw, mw/3);
|
||||||
|
|
||||||
match(); // match entries
|
|
||||||
|
|
||||||
// create menu window and set properties for it
|
// create menu window and set properties for it
|
||||||
create_window(x + sp, y + vp - (menuposition == 1 ? 0 : menuposition == 2 ? borderwidth : borderwidth * 2), mw - 2 * sp - borderwidth * 2, mh);
|
create_window(
|
||||||
|
x + sp,
|
||||||
|
y + vp - (menuposition == 1 ? 0 : menuposition == 2 ? borderwidth : borderwidth * 2),
|
||||||
|
mw - 2 * sp - borderwidth * 2,
|
||||||
|
mh
|
||||||
|
);
|
||||||
|
|
||||||
set_window();
|
set_window();
|
||||||
set_prop();
|
set_prop();
|
||||||
|
|
||||||
|
@ -118,26 +122,30 @@ void setupdisplay(void) {
|
||||||
open_xim(); // open xim
|
open_xim(); // open xim
|
||||||
|
|
||||||
XMapRaised(dpy, win);
|
XMapRaised(dpy, win);
|
||||||
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XGetWindowAttributes(dpy, win, &wa);
|
XGetWindowAttributes(dpy, win, &wa);
|
||||||
|
|
||||||
if (wa.map_state == IsViewable) // must be viewable, otherwise we get a BadMatch error
|
if (wa.map_state == IsViewable) { // must be viewable, otherwise we get a BadMatch error
|
||||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
// embed spmenu inside parent window
|
// embed spmenu inside parent window
|
||||||
if (embed) {
|
if (embed) {
|
||||||
XReparentWindow(dpy, win, parentwin, x, y);
|
XReparentWindow(dpy, win, parentwin, x, y);
|
||||||
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||||
|
|
||||||
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||||
for (i = 0; i < du && dws[i] != win; ++i)
|
for (i = 0; i < du && dws[i] != win; ++i)
|
||||||
XSelectInput(dpy, dws[i], FocusChangeMask);
|
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||||
XFree(dws);
|
XFree(dws);
|
||||||
}
|
}
|
||||||
|
|
||||||
grabfocus();
|
grabfocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize and draw
|
// resize window and draw
|
||||||
drw_resize(drw, mw - 2 * sp - borderwidth * 2, mh);
|
drw_resize(drw, mw - 2 * sp - borderwidth * 2, mh);
|
||||||
|
|
||||||
|
match();
|
||||||
drawmenu();
|
drawmenu();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue