diff options
Diffstat (limited to 'src/sxwm.c')
| -rw-r--r-- | src/sxwm.c | 41 |
1 files changed, 29 insertions, 12 deletions
@@ -42,6 +42,7 @@ int clean_mask(int mask); /* void close_focused(void); */ /* void dec_gaps(void); */ void startup_exec(void); +Window find_toplevel(Window w); /* void focus_next(void); */ /* void focus_prev(void); */ int get_monitor_for(Client *c); @@ -249,7 +250,8 @@ void change_workspace(int ws) tile(); if (workspaces[current_ws]) { focused = workspaces[current_ws]; - XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime); + Window focused_win = find_toplevel(focused->win); + XSetInputFocus(dpy, focused_win, RevertToPointerRoot, CurrentTime); if (user_config.warp_cursor) { warp_cursor(focused); } @@ -323,6 +325,29 @@ void startup_exec(void) } } +Window find_toplevel(Window w) +{ + Window root = None; + Window parent; + Window *kids; + unsigned nkids; + + while (True) { + if (w == root) { + break; + } + if (XQueryTree(dpy, w, &root, &parent, &kids, &nkids) == 0) { + break; + } + XFree(kids); + if (parent == root || parent == None) { + break; + } + w = parent; + } + return w; +} + void focus_next(void) { if (!focused || !workspaces[current_ws]) { @@ -586,6 +611,8 @@ void hdl_button(XEvent *xev) { XButtonEvent *e = &xev->xbutton; Window w = (e->subwindow != None) ? e->subwindow : e->window; + w = find_toplevel(w); + XAllowEvents(dpy, ReplayPointer, e->time); if (!w) { return; @@ -1403,17 +1430,14 @@ void reload_config(void) } grab_keys(); XUngrabButton(dpy, AnyButton, AnyModifier, root); - - XGrabButton(dpy, Button1, 0, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, - GrabModeAsync, None, None); XGrabButton(dpy, Button1, user_config.modkey, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(dpy, Button1, user_config.modkey | ShiftMask, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(dpy, Button3, user_config.modkey, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); - XSync(dpy, False); + XSync(dpy, False); tile(); update_borders(); } @@ -1561,13 +1585,6 @@ void setup(void) StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | KeyPressMask | PropertyChangeMask); - /* this is to grab the buttons for: - * focusing, - * moving, - * swapping, - * resizing - * windows in that order. - */ XGrabButton(dpy, Button1, user_config.modkey, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(dpy, Button1, user_config.modkey | ShiftMask, root, True, |
