]> Dogcows Code - chaz/openbox/blobdiff - otk/display.cc
missed one capitalization
[chaz/openbox] / otk / display.cc
index af03801ea761c20a08f6905f1898a790843f9da5..cf4e22e33face83d08e9b8c15247a291ad9b6d25 100644 (file)
@@ -41,7 +41,7 @@ extern "C" {
 #  include <unistd.h>
 #endif // HAVE_UNISTD_H
 
-#include "gettext.h"
+#include "../src/gettext.h"
 #define _(str) gettext(str)
 }
 
@@ -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, 127);
+      printf("X Error: %s\n", errtxt);
+      if (e->error_code != BadWindow)
+        abort();
+    }
 #else
-  (void)d;
-  (void)e;
+    (void)d;
+    (void)e;
 #endif
-
+  }
   return false;
 }
 
@@ -128,16 +129,15 @@ DISPLAY environment variable approriately.\n\n"));
 #endif // XINERAMA
 
   // get lock masks that are defined by the display (not constant)
-  XModifierKeymap *modmap;
-
-  modmap = XGetModifierMapping(_display);
-  if (modmap && modmap->max_keypermod > 0) {
+  _modmap = XGetModifierMapping(_display);
+  assert(_modmap);
+  if (_modmap && _modmap->max_keypermod > 0) {
     const int mask_table[] = {
       ShiftMask, LockMask, ControlMask, Mod1Mask,
       Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
     };
     const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
-      modmap->max_keypermod;
+      _modmap->max_keypermod;
     // get the values of the keyboard lock modifiers
     // Note: Caps lock is not retrieved the same way as Scroll and Num lock
     // since it doesn't need to be.
@@ -145,17 +145,15 @@ DISPLAY environment variable approriately.\n\n"));
     const KeyCode scroll_lock = XKeysymToKeycode(_display, XK_Scroll_Lock);
 
     for (size_t cnt = 0; cnt < size; ++cnt) {
-      if (! modmap->modifiermap[cnt]) continue;
+      if (! _modmap->modifiermap[cnt]) continue;
 
-      if (num_lock == modmap->modifiermap[cnt])
-        _num_lock_mask = mask_table[cnt / modmap->max_keypermod];
-      if (scroll_lock == modmap->modifiermap[cnt])
-        _scroll_lock_mask = mask_table[cnt / modmap->max_keypermod];
+      if (num_lock == _modmap->modifiermap[cnt])
+        _num_lock_mask = mask_table[cnt / _modmap->max_keypermod];
+      if (scroll_lock == _modmap->modifiermap[cnt])
+        _scroll_lock_mask = mask_table[cnt / _modmap->max_keypermod];
     }
   }
 
-  if (modmap) XFreeModifiermap(modmap);
-
   _mask_list[0] = 0;
   _mask_list[1] = LockMask;
   _mask_list[2] = _num_lock_mask;
@@ -181,6 +179,8 @@ Display::~Display()
   while (_grab_count > 0)
     ungrab();
 
+  XFreeModifiermap(_modmap);
+  
   for (int i = 0; i < ScreenCount(_display); ++i) {
     delete _rendercontrol_list[i];
     delete _screeninfo_list[i];
@@ -217,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++;
 }
 
@@ -229,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.025727 seconds and 4 git commands to generate.