diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-11-17 11:28:58 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-11-17 11:28:58 +0000 |
| commit | bc66ca62648bf6195dada106ac2ef843b2ff79db (patch) | |
| tree | f0a943598217dfc5a6479fdb81584c8dda24ddfd | |
| parent | eca6b3fd9fa4c2e1b4dbb042ef9a0921fba52238 (diff) | |
Improved support for faulty X11 clients (STR #2385)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7866 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 31 |
2 files changed, 30 insertions, 2 deletions
@@ -1,5 +1,6 @@ CHANGES IN FLTK 1.3.0 + - Improved support for faulty X11 clients (STR #2385) - Fixed xclass support for Fl_Window (STR #2053) - Fixed Caps Lock handling in X11/XIM (STR #2366) - Fixed handling of missing fonts in Xft (STR #2355) diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 568146ce1..89c6d2934 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -804,6 +804,27 @@ static Fl_Window* resize_bug_fix; static char unknown[] = "<unknown>"; const int unknown_len = 10; +extern "C" { + +static int xerror = 0; + +static int ignoreXEvents(Display *display, XErrorEvent *event) { + xerror = 1; + return 0; +} + +static XErrorHandler catchXExceptions() { + xerror = 0; + return ignoreXEvents; +} + +static int wasXExceptionRaised() { + return xerror; +} + +} + + int fl_handle(const XEvent& thisevent) { XEvent xevent = thisevent; @@ -1359,6 +1380,9 @@ int fl_handle(const XEvent& thisevent) case ReparentNotify: { int xpos, ypos; Window junk; + + // on some systems, the ReparentNotify event is not handled as we would expect. + XErrorHandler oldHandler = XSetErrorHandler(catchXExceptions()); //ReparentNotify gives the new position of the window relative to //the new parent. FLTK cares about the position on the root window. @@ -1366,10 +1390,13 @@ int fl_handle(const XEvent& thisevent) XRootWindow(fl_display, fl_screen), xevent.xreparent.x, xevent.xreparent.y, &xpos, &ypos, &junk); + XSetErrorHandler(oldHandler); // tell Fl_Window about it and set flag to prevent echoing: - resize_bug_fix = window; - window->position(xpos, ypos); + if ( !wasXExceptionRaised() ) { + resize_bug_fix = window; + window->position(xpos, ypos); + } break; } } |
