From 9c2e63fa4ce62cf3e3e847c9548748053c5e166f Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 21 Jul 2005 16:42:16 +0000 Subject: [PATCH] complete repair of minimization and root menu bar svn: r418 --- src/wxmac/src/mac/wx_app.cc | 7 ++++++ src/wxmac/src/mac/wx_frame.cc | 41 ++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/wxmac/src/mac/wx_app.cc b/src/wxmac/src/mac/wx_app.cc index 879d1219e4..e3057303d1 100644 --- a/src/wxmac/src/mac/wx_app.cc +++ b/src/wxmac/src/mac/wx_app.cc @@ -44,6 +44,8 @@ extern Bool doCallPreMouseEvent(wxWindow *in_win, wxWindow *win, wxMouseEvent *e extern WindowPtr MrEdMouseWindow(Point where); extern WindowPtr MrEdKeyWindow(); +extern void wxCheckRootFrame(Bool frame_present); + int wxMenuBarHeight; extern wxApp *wxTheApp; @@ -180,6 +182,11 @@ void wxApp::doMacPreEvent() WindowPtr w; w = FrontNonFloatingWindow(); + wxCheckRootFrame(!!w); + if (!w) { + /* Maybe we just showed the root frame: */ + w = FrontNonFloatingWindow(); + } wxCheckFinishedSounds(); diff --git a/src/wxmac/src/mac/wx_frame.cc b/src/wxmac/src/mac/wx_frame.cc index ccf13ab081..9471d81547 100644 --- a/src/wxmac/src/mac/wx_frame.cc +++ b/src/wxmac/src/mac/wx_frame.cc @@ -460,7 +460,7 @@ void wxFrame::DesignateRootFrame(void) wxRootFrame = this; Show(TRUE); - if (!FrontWindow()) { + if (!FrontNonFloatingWindow()) { ::ShowWindow(win); } } @@ -1005,6 +1005,29 @@ void wxFrame::SetTitle(char* title) } } +void wxCheckRootFrame(Bool frame_present) +{ + if (frame_present) { + /* Hide root frame, if any, in case it's shown */ + if (wxRootFrame) { + wxMacDC *dc; + WindowPtr theMacWindow; + dc = wxRootFrame->MacDC(); + theMacWindow = GetWindowFromPort(dc->macGrafPort()); + ::HideWindow(theMacWindow); + } + } else { + /* If all frames are closed/minimized, it's time for the root window (if any) */ + if (wxRootFrame && !FrontNonFloatingWindow()) { + wxMacDC *dc; + WindowPtr theMacWindow; + dc = wxRootFrame->MacDC(); + theMacWindow = GetWindowFromPort(dc->macGrafPort()); + ::ShowWindow(theMacWindow); + } + } +} + //----------------------------------------------------------------------------- void wxFrame::Show(Bool show) { @@ -1101,13 +1124,7 @@ void wxFrame::Show(Bool show) /* b/c may be optimized for hidden: */ cMacDC->setCurrentUser(NULL); - /* Hide root frame, if any, in case it's shown */ - if (wxRootFrame) { - wxMacDC *dc; - dc = wxRootFrame->MacDC(); - theMacWindow = GetWindowFromPort(dc->macGrafPort()); - ::HideWindow(theMacWindow); - } + wxCheckRootFrame(TRUE); } else { if (cFocusWindow) { ReleaseFocus(); @@ -1132,13 +1149,7 @@ void wxFrame::Show(Bool show) ::HideWindow(theMacWindow); } - /* If all frames are closed, it's time for the root window (if any) */ - if (wxRootFrame && !FrontWindow()) { - wxMacDC *dc; - dc = wxRootFrame->MacDC(); - theMacWindow = GetWindowFromPort(dc->macGrafPort()); - ::ShowWindow(theMacWindow); - } + wxCheckRootFrame(FALSE); } }