if(warp)
region_do_warp(reg);
+ if(REGION_IS_ACTIVE(reg) && ioncore_await_focus()==NULL)
+ return;
+
region_set_await_focus(reg);
/*xwindow_do_set_focus(win);*/
XSetInputFocus(ioncore_g.dpy, win, RevertToParent,
void region_maybewarp(WRegion *reg, bool warp)
{
ioncore_g.focus_next=reg;
+ ioncore_g.focus_next_source=IONCORE_FOCUSNEXT_OTHER;
ioncore_g.warp_next=(warp && ioncore_g.warp_enabled);
}
{
ioncore_g.focus_next=NULL;
/* TODO: what if focus isn't set? Should focus_next be reset then? */
- region_do_set_focus(reg, warp);
+ region_do_set_focus(reg, warp && ioncore_g.warp_enabled);
}
*/
void region_pointer_focus_hack(WRegion *reg)
{
- WRegion *act=ioncore_await_focus();
- const WRectangle *g=®ION_GEOM(reg);
- int x, y;
+ WRegion *act;
if(ioncore_g.opmode!=IONCORE_OPMODE_NORMAL)
return;
-
- if(!REGION_IS_ACTIVE(reg) && act==NULL)
- act=ioncore_g.focus_current;
- if(act==NULL || OBJ_IS_BEING_DESTROYED(act))
+ if(ioncore_g.focus_next!=NULL &&
+ ioncore_g.focus_next_source<=IONCORE_FOCUSNEXT_POINTERHACK){
return;
-
- /* Ok, anything under us should not get focus as we're unmapped:
- * Either we don't have the focus, or focus change somewhere else
- * is pending.
- *
- * It might be possible to do the pointer check more efficiently
- * by trying to maintain our internal pointer containment state
- * by tracking Enter/Leave events...
- */
+ }
- xwindow_pointer_pos(region_xwindow(reg), &x, &y);
+ act=ioncore_await_focus();
- if(x>=0 && y>=0 && x<g->w && y<g->h){
- D(fprintf(stderr, "Pointer here and shouldn't alter focus!\n"));
- region_set_focus(act);
+ if((REGION_IS_ACTIVE(reg) && act==NULL) || !region_is_fully_mapped(reg))
+ return;
+
+ if(act==NULL)
+ act=ioncore_g.focus_current;
+
+ if(act==NULL ||
+ OBJ_IS_BEING_DESTROYED(act) ||
+ !region_is_fully_mapped(act) ||
+ region_skip_focus(act)){
+ return;
}
+
+ region_set_focus(act);
+ ioncore_g.focus_next_source=IONCORE_FOCUSNEXT_POINTERHACK;
}