From c6fb27e56df635eb50372d7341bd696b6b3ea72a Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 28 Mar 2011 09:28:05 +0000 Subject: Mac OS: added field subwindow to Fl_X class that is true if this is a subwindow. Useful when deleting a window because subwindows share their xid with their parent window (unlike under MSWIn or Xlib), so subwindows should not delete their xid. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8540 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/mac.H | 1 + src/Fl_cocoa.mm | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/FL/mac.H b/FL/mac.H index 6fcd18ce8..be64d8ddb 100644 --- a/FL/mac.H +++ b/FL/mac.H @@ -155,6 +155,7 @@ public: static void *get_carbon_function(const char *name); private: static void relink(Fl_Window*, Fl_Window*); + bool subwindow; }; extern struct Fl_XMap { diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index bab8ce6bd..9cc07d83d 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1895,6 +1895,7 @@ void Fl_X::make(Fl_Window* w) Fl_Group::current(0); // our subwindow needs this structure to know about its clipping. Fl_X* x = new Fl_X; + x->subwindow = true; x->other_xid = 0; x->region = 0; x->subRegion = 0; @@ -1994,6 +1995,7 @@ void Fl_X::make(Fl_Window* w) const char *name = w->label(); Fl_X* x = new Fl_X; + x->subwindow = false; x->other_xid = 0; // room for doublebuffering image map. On OS X this is only used by overlay windows x->region = 0; x->subRegion = 0; @@ -2572,16 +2574,8 @@ void Fl_X::relink(Fl_Window *w, Fl_Window *wp) { } void Fl_X::destroy() { - if (w && !w->parent() && xid) { - /* Fix for STR #2595: don't delete the xid of a subwindow because it is shared - with the xid of its parent window. - The link from subwindow to parent may have been removed already. - This algorithm makes sure that none of the windows of the window list uses this xid. - Is there a better algorithm ? - */ - for (Fl_X *xo = Fl_X::first; xo; xo = xo->next) { - if (xo->xid == xid) return; - } + // subwindows share their xid with their parent window, so should not close it + if (!subwindow && w && !w->parent() && xid) { [[(NSWindow *)xid contentView] release]; [(NSWindow *)xid close]; } -- cgit v1.2.3