+
+
+/*{{{ Pointer focus hack */
+
+
+/* This ugly hack tries to prevent focus change, when the pointer is
+ * in a window to be unmapped (or destroyed), and that does not have
+ * the focus, or should not soon have it.
+ */
+void region_pointer_focus_hack(WRegion *reg)
+{
+ WRegion *act;
+
+ if(ioncore_g.opmode!=IONCORE_OPMODE_NORMAL)
+ return;
+
+ if(ioncore_g.focus_next!=NULL &&
+ ioncore_g.focus_next_source<=IONCORE_FOCUSNEXT_POINTERHACK){
+ return;
+ }
+
+ act=ioncore_await_focus();
+
+ 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;
+}
+
+
+/*}}}*/
+