From 72d68b13a3c4d09e63bd7daee2bdf0549e1c335d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 9 Feb 2008 23:12:40 +0100 Subject: [PATCH] change focus raising --- client.c | 15 +++++++-------- event.c | 8 +++++--- focus.c | 4 ++-- layout.c | 4 ++-- screen.c | 4 ++-- widgets/tasklist.c | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client.c b/client.c index 80eb3d85..63d369d2 100644 --- a/client.c +++ b/client.c @@ -172,7 +172,7 @@ client_ban(Client *c) * \param screen Screen ID */ void -client_focus(Client *c, int screen, Bool from_mouse) +client_focus(Client *c, int screen, Bool raise) { int phys_screen = get_phys_screen(screen); @@ -200,8 +200,7 @@ client_focus(Client *c, int screen, Bool from_mouse) XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel); XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime); - if(!from_mouse - || (globalconf.screens[screen].sloppy_focus && globalconf.screens[screen].sloppy_focus_raise)) + if(raise) XRaiseWindow(globalconf.display, c->win); /* since we're dropping EnterWindow events and sometimes the window * will appear under the mouse, grabbuttons */ @@ -597,7 +596,7 @@ client_unmanage(Client *c) untag_client(c, tag); if(globalconf.focus->client == c) - client_focus(NULL, c->screen, False); + client_focus(NULL, c->screen, True); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); window_setstate(c->win, WithdrawnState); @@ -924,7 +923,7 @@ client_maximize(Client *c, Area geometry) c->m_geometry = c->geometry; if(get_current_layout(c->screen)->arrange != layout_floating) client_setfloating(c, True); - client_focus(c, c->screen, False); + client_focus(c, c->screen, True); client_resize(c, geometry, False); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); } @@ -1054,7 +1053,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) - client_focus(c, screen, False); + client_focus(c, screen, True); } /** Send focus to previous client in stack @@ -1068,7 +1067,7 @@ uicb_client_focusprev(int screen, char *arg __attribute__ ((unused))) Client *prev; if((prev = client_find_prev_visible(globalconf.focus->client))) - client_focus(prev, screen, False); + client_focus(prev, screen, True); } /** Toggle floating state of a client @@ -1118,7 +1117,7 @@ uicb_client_togglescratch(int screen, { globalconf.scratch.isvisible = !globalconf.scratch.isvisible; if(globalconf.scratch.isvisible) - client_focus(globalconf.scratch.client, screen, False); + client_focus(globalconf.scratch.client, screen, True); globalconf.screens[globalconf.scratch.client->screen].need_arrange = True; widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS); } diff --git a/event.c b/event.c index 159b251f..d0ce38b6 100644 --- a/event.c +++ b/event.c @@ -116,7 +116,7 @@ handle_event_buttonpress(XEvent *e) if((c = client_get_bywin(globalconf.clients, ev->window))) { - client_focus(c, c->screen, False); + client_focus(c, c->screen, True); if(CLEANMASK(ev->state) == NoSymbol && ev->button == Button1) { @@ -229,7 +229,9 @@ handle_event_enternotify(XEvent * e) { window_grabbuttons(get_phys_screen(c->screen), c->win); if(globalconf.screens[c->screen].sloppy_focus) - client_focus(c, c->screen, True); + client_focus(c, c->screen, + (globalconf.screens[c->screen].sloppy_focus + && globalconf.screens[c->screen].sloppy_focus_raise)); } else for(screen = 0; screen < ScreenCount(e->xany.display); screen++) @@ -293,7 +295,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) - client_focus(NULL, screen, False); + client_focus(NULL, screen, True); } void diff --git a/focus.c b/focus.c index bc066be3..ff289dc7 100644 --- a/focus.c +++ b/focus.c @@ -119,7 +119,7 @@ uicb_focus_history(int screen, char *arg) c = focus_get_latest_client_for_tags(curtags, i); p_delete(&curtags); if(c) - client_focus(c, screen, False); + client_focus(c, screen, True); } } } @@ -136,7 +136,7 @@ uicb_focus_client_byname(int screen, char *arg) if((c = client_get_byname(globalconf.clients, arg))) for(tag = curtags; *tag; tag++) if(is_client_tagged(c, *tag)) - client_focus(c, screen, False); + client_focus(c, screen, True); p_delete(&curtags); } } diff --git a/layout.c b/layout.c index 4be1d411..67f6efb1 100644 --- a/layout.c +++ b/layout.c @@ -67,13 +67,13 @@ arrange(int screen) c->newcomer = False; client_unban(c); if(globalconf.screens[screen].new_get_focus) - client_focus(c, screen, False); + client_focus(c, screen, True); } /* 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) - client_focus(c, screen, False); + client_focus(c, screen, True); /* check that the mouse is on a window or not */ if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, diff --git a/screen.c b/screen.c index 4135a88e..fc141ab8 100644 --- a/screen.c +++ b/screen.c @@ -351,7 +351,7 @@ uicb_screen_focus(int screen, char *arg) if (new_screen > (globalconf.nscreen - 1)) new_screen = 0; - client_focus(NULL, new_screen, False); + client_focus(NULL, new_screen, True); move_mouse_pointer_to_screen(new_screen); } @@ -383,6 +383,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); - client_focus(sel, sel->screen, False); + client_focus(sel, sel->screen, True); } // 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 af48bbcf..41316c59 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -246,7 +246,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); - client_focus(c, widget->statusbar->screen, False); + client_focus(c, widget->statusbar->screen, True); } return;