# include <unistd.h>
#endif // HAVE_UNISTD_H
-#include "gettext.h"
+#include "../src/gettext.h"
#define _(str) gettext(str)
}
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;
}
}
+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++;
}
{
if (_grab_count == 0) return;
_grab_count--;
- if (_grab_count == 0)
+ if (_grab_count == 0) {
XUngrabServer(_display);
+ XFlush(_display); // ungrab as soon as possible
+ }
}