]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/event.c
[svn-upgrade] Integrating new upstream version, ion3 (20070318)
[ion3.git] / ioncore / event.c
index 9a3b95790f4b7e33ac19c296835abc14df5908c9..260d6b01e509c6c0dbb0d2d8021a7f61c3be8632 100644 (file)
@@ -172,24 +172,29 @@ static void skip_enterwindow()
 }
 
 
-void ioncore_flush()
+void ioncore_flushfocus()
 {
-    if(ioncore_g.focus_next!=NULL && 
-       ioncore_g.input_mode==IONCORE_INPUTMODE_NORMAL){
-        bool warp=ioncore_g.warp_next;
-        WRegion *next=ioncore_g.focus_next;
+    WRegion *next;
+    bool warp;
+    
+    if(ioncore_g.input_mode!=IONCORE_INPUTMODE_NORMAL)
+        return;
+        
+    next=ioncore_g.focus_next;
+    warp=ioncore_g.warp_next;
+
+    if(next==NULL)
+        return;
         
-        ioncore_g.focus_next=NULL;
+    ioncore_g.focus_next=NULL;
         
-        region_do_set_focus(next, warp);
+    region_do_set_focus(next, warp);
         
-        /* Just greedily eating it all away that X has to offer
-         * seems to be the best we can do with Xlib.
-         */
+    /* Just greedily eating it all away that X has to offer
+     * seems to be the best we can do with Xlib.
+     */
+    if(warp)
         skip_enterwindow();
-    }
-    
-    XFlush(ioncore_g.dpy);
 }
 
 
@@ -225,12 +230,22 @@ void ioncore_mainloop()
     while(1){
         check_signals();
         mainloop_execute_deferred();
-        ioncore_flush();
-
-        if(QLength(ioncore_g.dpy)>0)
-            ioncore_x_connection_handler(ioncore_g.conn, NULL);
-        else
-            mainloop_select();
+        
+        if(QLength(ioncore_g.dpy)==0){
+            XSync(ioncore_g.dpy, False);
+            
+            if(QLength(ioncore_g.dpy)==0){
+                ioncore_flushfocus();
+                XSync(ioncore_g.dpy, False);
+                
+                if(QLength(ioncore_g.dpy)==0){
+                    mainloop_select();
+                    continue;
+                }
+            }
+        }
+        
+        ioncore_x_connection_handler(ioncore_g.conn, NULL);
     }
 }