From c22430a11505a89d764ff50dcb90473ed213f8d5 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 25 Jan 2008 23:43:16 +0100 Subject: [PATCH] fix handling of window raisings --- client.c | 15 +++++++++------ client.h | 2 +- event.c | 6 +++--- focus.c | 4 ++-- layout.c | 17 ++--------------- layout.h | 1 - screen.c | 4 ++-- widgets/tasklist.c | 2 +- 8 files changed, 20 insertions(+), 31 deletions(-) diff --git a/client.c b/client.c index 47d64675..973c98e5 100644 --- a/client.c +++ b/client.c @@ -170,7 +170,7 @@ client_ban(Client *c) * \param screen Screen ID */ void -focus(Client *c, int screen) +focus(Client *c, int screen, Bool from_mouse) { int phys_screen = get_phys_screen(screen); @@ -187,15 +187,18 @@ focus(Client *c, int screen) if(globalconf.focus->client) client_unfocus(globalconf.focus->client); - /* save sel in focus history */ if(c) { + /* save sel in focus history */ focus_add_client(c); XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel); XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime); - restack(screen); + if(!from_mouse + || !globalconf.screens[screen].sloppy_focus + || globalconf.screens[screen].sloppy_focus_raise) + XRaiseWindow(globalconf.display, c->win); } else XSetInputFocus(globalconf.display, @@ -499,7 +502,7 @@ client_unmanage(Client *c) untag_client(c, tag); if(globalconf.focus->client == c) - focus(NULL, c->screen); + focus(NULL, c->screen, False); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); window_setstate(c->win, WithdrawnState); @@ -943,7 +946,7 @@ uicb_client_focusnext(int screen, char *arg __attribute__ ((unused))) if(!c) for(c = globalconf.clients; c && (c->skip || !client_isvisible(c, screen)); c = c->next); if(c) - focus(c, screen); + focus(c, screen, False); } /** Send focus to previous client in stack @@ -957,7 +960,7 @@ uicb_client_focusprev(int screen, char *arg __attribute__ ((unused))) Client *prev; if((prev = client_find_prev_visible(globalconf.focus->client))) - focus(prev, screen); + focus(prev, screen, False); } /** Toggle floating state of a client diff --git a/client.h b/client.h index 931a09e4..0f3222c2 100644 --- a/client.h +++ b/client.h @@ -27,7 +27,7 @@ Bool client_isvisible(Client *, int); Client * get_client_bywin(Client *, Window); Client * get_client_byname(Client *, char *); -void focus(Client *, int); +void focus(Client *, int, Bool); void client_ban(Client *); void client_unban(Client *); void client_manage(Window, XWindowAttributes *, int); diff --git a/event.c b/event.c index 6303514c..fa48df37 100644 --- a/event.c +++ b/event.c @@ -117,7 +117,7 @@ handle_event_buttonpress(XEvent *e) if((c = get_client_bywin(globalconf.clients, ev->window))) { - focus(c, c->screen); + focus(c, c->screen, False); if(CLEANMASK(ev->state) == NoSymbol && ev->button == Button1) { @@ -230,7 +230,7 @@ handle_event_enternotify(XEvent * e) { window_grabbuttons(get_phys_screen(c->screen), c->win, False); if(globalconf.screens[c->screen].sloppy_focus) - focus(c, c->screen); + focus(c, c->screen, True); } else for(screen = 0; screen < ScreenCount(e->xany.display); screen++) @@ -297,7 +297,7 @@ handle_event_leavenotify(XEvent * e) for(screen = 0; screen < ScreenCount(e->xany.display); screen++) if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen) - focus(NULL, screen); + focus(NULL, screen, False); } void diff --git a/focus.c b/focus.c index 3463c019..8da4dd2c 100644 --- a/focus.c +++ b/focus.c @@ -120,7 +120,7 @@ uicb_focus_history(int screen, char *arg) c = focus_get_latest_client_for_tags(curtags, i); p_delete(&curtags); if(c) - focus(c, screen); + focus(c, screen, False); } } } @@ -137,7 +137,7 @@ uicb_focus_client_byname(int screen, char *arg) if((c = get_client_byname(globalconf.clients, arg))) for(tag = curtags; *tag; tag++) if(is_client_tagged(c, *tag)) - focus(c, screen); + focus(c, screen, False); p_delete(&curtags); } } diff --git a/layout.c b/layout.c index 3f02b6bb..2de63aea 100644 --- a/layout.c +++ b/layout.c @@ -75,7 +75,7 @@ arrange(int screen) c->newcomer = False; client_unban(c); if(globalconf.screens[screen].new_get_focus) - focus(c, screen); + focus(c, screen, False); } layout_raise_floatings(screen); @@ -83,7 +83,7 @@ arrange(int screen) /* if we have a valid client that could be focused but currently no window * are focused, then set the focus on this window */ if((c = focus_get_current_client(screen)) && !globalconf.focus->client) - focus(c, screen); + focus(c, screen, False); /* reset status */ globalconf.screens[screen].need_arrange = False; @@ -135,19 +135,6 @@ loadawesomeprops(int screen) p_delete(&prop); } -void -restack(int screen) -{ - Client *sel = globalconf.focus->client; - - if(!sel) - return; - - if(!globalconf.screens[screen].sloppy_focus - || globalconf.screens[screen].sloppy_focus_raise) - XRaiseWindow(globalconf.display, sel->win); -} - void saveawesomeprops(int screen) { diff --git a/layout.h b/layout.h index 9a81c39e..59326ce3 100644 --- a/layout.h +++ b/layout.h @@ -42,7 +42,6 @@ DO_SLIST(Layout, layout, p_delete); int layout_refresh(void); Layout * get_current_layout(int); -void restack(int); void loadawesomeprops(int); void saveawesomeprops(int); diff --git a/screen.c b/screen.c index 89194df7..fc61056a 100644 --- a/screen.c +++ b/screen.c @@ -353,7 +353,7 @@ uicb_screen_focus(int screen, char *arg) if (new_screen > (globalconf.nscreen - 1)) new_screen = 0; - focus(focus_get_current_client(new_screen), new_screen); + focus(NULL, new_screen, False); move_mouse_pointer_to_screen(new_screen); } @@ -385,6 +385,6 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg) prev_screen = sel->screen; move_client_to_screen(sel, new_screen, True); move_mouse_pointer_to_screen(new_screen); - focus(sel, sel->screen); + focus(sel, sel->screen, False); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 350dea6f..d19ca148 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -210,7 +210,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev) for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++) if(is_client_tagged(c, tag)) tag_view_only_byindex(c->screen, i); - focus(c, widget->statusbar->screen); + focus(c, widget->statusbar->screen, False); } return;