change focus raising

This commit is contained in:
Julien Danjou 2008-02-09 23:12:40 +01:00
parent 2fad66e23f
commit 72d68b13a3
6 changed files with 19 additions and 18 deletions

View File

@ -172,7 +172,7 @@ client_ban(Client *c)
* \param screen Screen ID * \param screen Screen ID
*/ */
void 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); 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, XSetWindowBorder(globalconf.display, c->win,
globalconf.screens[screen].colors_selected[ColBorder].pixel); globalconf.screens[screen].colors_selected[ColBorder].pixel);
XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime);
if(!from_mouse if(raise)
|| (globalconf.screens[screen].sloppy_focus && globalconf.screens[screen].sloppy_focus_raise))
XRaiseWindow(globalconf.display, c->win); XRaiseWindow(globalconf.display, c->win);
/* since we're dropping EnterWindow events and sometimes the window /* since we're dropping EnterWindow events and sometimes the window
* will appear under the mouse, grabbuttons */ * will appear under the mouse, grabbuttons */
@ -597,7 +596,7 @@ client_unmanage(Client *c)
untag_client(c, tag); untag_client(c, tag);
if(globalconf.focus->client == c) if(globalconf.focus->client == c)
client_focus(NULL, c->screen, False); client_focus(NULL, c->screen, True);
XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win);
window_setstate(c->win, WithdrawnState); window_setstate(c->win, WithdrawnState);
@ -924,7 +923,7 @@ client_maximize(Client *c, Area geometry)
c->m_geometry = c->geometry; c->m_geometry = c->geometry;
if(get_current_layout(c->screen)->arrange != layout_floating) if(get_current_layout(c->screen)->arrange != layout_floating)
client_setfloating(c, True); client_setfloating(c, True);
client_focus(c, c->screen, False); client_focus(c, c->screen, True);
client_resize(c, geometry, False); client_resize(c, geometry, False);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
} }
@ -1054,7 +1053,7 @@ uicb_client_focusnext(int screen, char *arg __attribute__ ((unused)))
if(!c) if(!c)
for(c = globalconf.clients; c && (c->skip || !client_isvisible(c, screen)); c = c->next); for(c = globalconf.clients; c && (c->skip || !client_isvisible(c, screen)); c = c->next);
if(c) if(c)
client_focus(c, screen, False); client_focus(c, screen, True);
} }
/** Send focus to previous client in stack /** Send focus to previous client in stack
@ -1068,7 +1067,7 @@ uicb_client_focusprev(int screen, char *arg __attribute__ ((unused)))
Client *prev; Client *prev;
if((prev = client_find_prev_visible(globalconf.focus->client))) 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 /** Toggle floating state of a client
@ -1118,7 +1117,7 @@ uicb_client_togglescratch(int screen,
{ {
globalconf.scratch.isvisible = !globalconf.scratch.isvisible; globalconf.scratch.isvisible = !globalconf.scratch.isvisible;
if(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; globalconf.screens[globalconf.scratch.client->screen].need_arrange = True;
widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS);
} }

View File

@ -116,7 +116,7 @@ handle_event_buttonpress(XEvent *e)
if((c = client_get_bywin(globalconf.clients, ev->window))) 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 if(CLEANMASK(ev->state) == NoSymbol
&& ev->button == Button1) && ev->button == Button1)
{ {
@ -229,7 +229,9 @@ handle_event_enternotify(XEvent * e)
{ {
window_grabbuttons(get_phys_screen(c->screen), c->win); window_grabbuttons(get_phys_screen(c->screen), c->win);
if(globalconf.screens[c->screen].sloppy_focus) 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 else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) 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++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen) if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen)
client_focus(NULL, screen, False); client_focus(NULL, screen, True);
} }
void void

View File

@ -119,7 +119,7 @@ uicb_focus_history(int screen, char *arg)
c = focus_get_latest_client_for_tags(curtags, i); c = focus_get_latest_client_for_tags(curtags, i);
p_delete(&curtags); p_delete(&curtags);
if(c) 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))) if((c = client_get_byname(globalconf.clients, arg)))
for(tag = curtags; *tag; tag++) for(tag = curtags; *tag; tag++)
if(is_client_tagged(c, *tag)) if(is_client_tagged(c, *tag))
client_focus(c, screen, False); client_focus(c, screen, True);
p_delete(&curtags); p_delete(&curtags);
} }
} }

View File

@ -67,13 +67,13 @@ arrange(int screen)
c->newcomer = False; c->newcomer = False;
client_unban(c); client_unban(c);
if(globalconf.screens[screen].new_get_focus) 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 /* if we have a valid client that could be focused but currently no window
* are focused, then set the focus on this window */ * are focused, then set the focus on this window */
if((c = focus_get_current_client(screen)) && !globalconf.focus->client) 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 */ /* check that the mouse is on a window or not */
if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, if(XQueryPointer(globalconf.display, RootWindow(globalconf.display,

View File

@ -351,7 +351,7 @@ uicb_screen_focus(int screen, char *arg)
if (new_screen > (globalconf.nscreen - 1)) if (new_screen > (globalconf.nscreen - 1))
new_screen = 0; new_screen = 0;
client_focus(NULL, new_screen, False); client_focus(NULL, new_screen, True);
move_mouse_pointer_to_screen(new_screen); move_mouse_pointer_to_screen(new_screen);
} }
@ -383,6 +383,6 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg)
prev_screen = sel->screen; prev_screen = sel->screen;
move_client_to_screen(sel, new_screen, True); move_client_to_screen(sel, new_screen, True);
move_mouse_pointer_to_screen(new_screen); 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -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++) for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++)
if(is_client_tagged(c, tag)) if(is_client_tagged(c, tag))
tag_view_only_byindex(c->screen, i); tag_view_only_byindex(c->screen, i);
client_focus(c, widget->statusbar->screen, False); client_focus(c, widget->statusbar->screen, True);
} }
return; return;