X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Feventh.c;h=861007f4b06eb3da7564797025408f39a993be1b;hp=5e1e1fe81d9439dafebb3e4b77548b6ec725e68f;hb=HEAD;hpb=803afbc1cd633f6c025bcd9537e9b7e9aedadd0d diff --git a/ioncore/eventh.c b/ioncore/eventh.c index 5e1e1fe..861007f 100644 --- a/ioncore/eventh.c +++ b/ioncore/eventh.c @@ -1,12 +1,9 @@ /* * ion/ioncore/eventh.c * - * Copyright (c) Tuomo Valkonen 1999-2007. + * Copyright (c) Tuomo Valkonen 1999-2009. * - * Ion is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. + * See the included file LICENSE for details. */ #include @@ -63,7 +60,7 @@ bool ioncore_handle_event(XEvent *ev) ioncore_handle_property(&(ev->xproperty)); break; CASE_EVENT(FocusIn) - ioncore_handle_focus_in(&(ev->xfocus), FALSE); + ioncore_handle_focus_in(&(ev->xfocus)); break; CASE_EVENT(FocusOut) ioncore_handle_focus_out(&(ev->xfocus)); @@ -305,14 +302,19 @@ void ioncore_handle_expose(const XExposeEvent *ev) /*{{{ Enter window, focus */ -static void do_handle_enter_window(XEvent *ev) +void ioncore_handle_enter_window(XEvent *ev) { XEnterWindowEvent *eev=&(ev->xcrossing); WRegion *reg=NULL; - if(ioncore_g.input_mode!=IONCORE_INPUTMODE_NORMAL) + if(ioncore_g.input_mode!=IONCORE_INPUTMODE_NORMAL || + ioncore_g.no_mousefocus){ return; - + } + + if(eev->mode!=NotifyNormal && !ioncore_g.warp_enabled) + return; + reg=XWINDOW_REGION_OF_T(eev->window, WRegion); if(reg==NULL) @@ -323,7 +325,12 @@ static void do_handle_enter_window(XEvent *ev) if(region_skip_focus(reg)) return; - + + if(ioncore_g.focus_next!=NULL && + ioncore_g.focus_next_sourcedetail==NotifyPointer) return; - if(ev->window==region_root_of(reg)){ /* OBJ_IS(reg, WRootWin) */ - D(fprintf(stderr, "scr-in %d %d %d\n", ROOTWIN_OF(reg)->xscr, - ev->mode, ev->detail)); - if((ev->detail==NotifyPointerRoot || ev->detail==NotifyDetailNone) && - pointer_in_root(ev->window) && ioncore_g.focus_next==NULL){ - /* Restore focus */ - if(!skip) - region_set_focus(reg); - return; - } - } - /* Input contexts */ if(OBJ_IS(reg, WWindow)){ wwin=(WWindow*)reg; @@ -409,6 +394,25 @@ void ioncore_handle_focus_in(const XFocusChangeEvent *ev, bool skip) netwm_set_active(reg); region_got_focus(reg); + + if(ioncore_g.focus_next!=NULL && + ioncore_g.focus_next_sourcedetail==NotifyPointerRoot || ev->detail==NotifyDetailNone) + && ev->window==region_root_of(reg) /* OBJ_IS(reg, WRootWin) */){ + /* Restore focus if it was returned to a root window and we don't + * know of a pending focus change. + */ + if(pointer_in_root(ev->window)){ + region_set_focus(reg); + ioncore_g.focus_next_source=IONCORE_FOCUSNEXT_FALLBACK; + } + }else{ + /* Something got the focus, don't use fallback. */ + ioncore_g.focus_next=NULL; + } } @@ -496,7 +500,7 @@ void ioncore_handle_buttonpress(XEvent *ev) ioncore_handle_grabs(ev); break; CASE_EVENT(FocusIn) - ioncore_handle_focus_in(&(ev->xfocus), FALSE); + ioncore_handle_focus_in(&(ev->xfocus)); break; CASE_EVENT(FocusOut) ioncore_handle_focus_out(&(ev->xfocus));