From 0f2bcee0cdad317a86230b43f437e0243165277b Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 29 Jan 2003 08:50:12 +0000 Subject: [PATCH] allow for ignoring x errors. make grab() sunc immediately and ungrab() flush --- otk/display.cc | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/otk/display.cc b/otk/display.cc index 21c348ea..21215e2b 100644 --- a/otk/display.cc +++ b/otk/display.cc @@ -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 + } } -- 2.45.2