]> Dogcows Code - chaz/openbox/commitdiff
allow for ignoring x errors.
authorDana Jansens <danakj@orodu.net>
Wed, 29 Jan 2003 08:50:12 +0000 (08:50 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 29 Jan 2003 08:50:12 +0000 (08:50 +0000)
make grab() sunc immediately and ungrab() flush

otk/display.cc

index 21c348eab3ef2af4ca82044c069e1458d41d81d5..21215e2b7ff51ad026287d8f0b6ccdd1418ce17d 100644 (file)
@@ -52,21 +52,22 @@ Display *display = (Display*) 0;
 
 static int xerrorHandler(::Display *d, XErrorEvent *e)
 {
+  if (!display->ignoreErrors()) {
 #ifdef DEBUG
-  char errtxt[128];
-
-  //if (e->error_code != BadWindow)
-  {
-    XGetErrorText(d, e->error_code, errtxt, 128);
-    printf("X Error: %s\n", errtxt);
-    if (e->error_code != BadWindow)
-      abort();
-  }
+    char errtxt[128];
+
+    //if (e->error_code != BadWindow)
+    {
+      XGetErrorText(d, e->error_code, errtxt, 128);
+      printf("X Error: %s\n", errtxt);
+      if (e->error_code != BadWindow)
+        abort();
+    }
 #else
-  (void)d;
-  (void)e;
+    (void)d;
+    (void)e;
 #endif
-
+  }
   return false;
 }
 
@@ -216,10 +217,19 @@ const RenderControl *Display::renderControl(int snum) const
 }
 
 
+void Display::setIgnoreErrors(bool t)
+{
+  _ignore_errors = t;
+  // sync up so that anything already sent is/isn't ignored!
+  XSync(_display, false);
+}
+
 void Display::grab()
 {
-  if (_grab_count == 0)
+  if (_grab_count == 0) {
     XGrabServer(_display);
+    XSync(_display, false); // make sure it kicks in
+  }
   _grab_count++;
 }
 
@@ -228,8 +238,10 @@ void Display::ungrab()
 {
   if (_grab_count == 0) return;
   _grab_count--;
-  if (_grab_count == 0)
+  if (_grab_count == 0) {
     XUngrabServer(_display);
+    XFlush(_display); // ungrab as soon as possible
+  }
 }
 
 
This page took 0.026658 seconds and 4 git commands to generate.