X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fdisplay.cc;h=cf4e22e33face83d08e9b8c15247a291ad9b6d25;hb=02b63185a22e64edaed916daa8559d769eb7bc5f;hp=367ee3ebbc9d76884d0925b5dc7870595feaf874;hpb=9a64438a5a53624e5f5c7c3dbb5123e246693e5e;p=chaz%2Fopenbox diff --git a/otk/display.cc b/otk/display.cc index 367ee3eb..cf4e22e3 100644 --- a/otk/display.cc +++ b/otk/display.cc @@ -6,7 +6,6 @@ #include "display.hh" #include "screeninfo.hh" -#include "gccache.hh" #include "rendercontrol.hh" #include "util.hh" @@ -42,7 +41,7 @@ extern "C" { # include #endif // HAVE_UNISTD_H -#include "gettext.h" +#include "../src/gettext.h" #define _(str) gettext(str) } @@ -53,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; } @@ -85,8 +85,7 @@ Display::Display() _scroll_lock_mask(0), _grab_count(0), _screeninfo_list(0), - _rendercontrol_list(0), - _gccache((GCCache*) 0) + _rendercontrol_list(0) { int junk; (void)junk; @@ -130,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. @@ -147,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; @@ -175,17 +171,16 @@ DISPLAY environment variable approriately.\n\n")); _screeninfo_list[i] = new ScreenInfo(i); _rendercontrol_list[i] = RenderControl::getRenderControl(i); } - - _gccache = new GCCache(ScreenCount(_display)); } Display::~Display() { - delete _gccache; while (_grab_count > 0) ungrab(); + XFreeModifiermap(_modmap); + for (int i = 0; i < ScreenCount(_display); ++i) { delete _rendercontrol_list[i]; delete _screeninfo_list[i]; @@ -222,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++; } @@ -234,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 + } }