From b3f6de1f373736d9291630d9af2952be34ac927f Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 23 May 2011 16:49:02 +0000 Subject: Fix STR #2627: if an X11 window is externally destroyed, FLTK now reacts coherently either deleting the corresponding FLTK window, or recreating the X11 window. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8723 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl.cxx | 3 ++- src/Fl_x.cxx | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl.cxx b/src/Fl.cxx index 70e1fc7b9..ac58a33f0 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1439,7 +1439,8 @@ void Fl_Window::hide() { # if USE_XFT fl_destroy_xft_draw(ip->xid); # endif - XDestroyWindow(fl_display, ip->xid); + // this test makes sure ip->xid has not been destroyed already + if (ip->xid) XDestroyWindow(fl_display, ip->xid); #elif defined(WIN32) // this little trickery seems to avoid the popup window stacking problem HWND p = GetForegroundWindow(); diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index b9f12826b..1da68a139 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1070,6 +1070,19 @@ int fl_handle(const XEvent& thisevent) if (window) switch (xevent.type) { + case DestroyNotify: { // an X11 window was closed externally from the program + Fl::handle(FL_CLOSE, window); + Fl_X* X = Fl_X::i(window); + if (X) { // indicates the FLTK window was not closed + X->xid = NULL; // indicates the X11 window was already destroyed + window->hide(); + int oldx = window->x(), oldy = window->y(); + window->position(0, 0); + window->position(oldx, oldy); + window->show(); // recreate the X11 window in support of the FLTK window + } + return 1; + } case ClientMessage: { Atom message = fl_xevent->xclient.message_type; const long* data = fl_xevent->xclient.data.l; -- cgit v1.2.3