From 0fc3952d68223349c87486b5dee2190ecd66dc1b Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 28 Feb 2014 04:01:58 -0800 Subject: [PATCH] MGR: Fix save and restore of main window position on Mac --- clientgui/AdvancedFrame.cpp | 9 ++++++++- clientgui/BOINCBaseFrame.cpp | 2 +- clientgui/BOINCBaseFrame.h | 5 +++++ clientgui/BOINCGUIApp.cpp | 6 ++++-- clientgui/sg_BoincSimpleFrame.cpp | 14 +++++++++++--- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index 984dab146f..f53f795e59 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -1011,6 +1011,13 @@ void CAdvancedFrame::SaveWindowDimensions() { wxASSERT(pConfig); +#ifdef __WXMAC__ + // See comment in CBOINCGUIApp::ShowApplication() + if (pos.x >= OFFSCREEN_DELTA) { + pos.x -= OFFSCREEN_DELTA; + } +#endif + pConfig->SetPath(strBaseConfigLocation); bool iconized = IsIconized(); @@ -1729,7 +1736,7 @@ void CAdvancedFrame::OnConnect(CFrameEvent& WXUNUSED(event)) { if (!wasVisible) { wxGetApp().ShowApplication(false); } -#ifndef __WXMAC__ // See explanation in ShowApplication() +#ifndef __WXMAC__ // See comment in CBOINCGUIApp::ShowApplication() if (!wasShown) { Hide(); } diff --git a/clientgui/BOINCBaseFrame.cpp b/clientgui/BOINCBaseFrame.cpp index cd3eff0249..eb2e7bda90 100644 --- a/clientgui/BOINCBaseFrame.cpp +++ b/clientgui/BOINCBaseFrame.cpp @@ -317,7 +317,7 @@ void CBOINCBaseFrame::OnClose(wxCloseEvent& event) { // again. Just minimize the window instead. Iconize(); #elif defined(__WXMAC__) - // See explanation in CBOINCGUIApp::ShowApplication(). + // See comment in CBOINCGUIApp::ShowApplication(). wxGetApp().ShowApplication(false); #else Hide(); diff --git a/clientgui/BOINCBaseFrame.h b/clientgui/BOINCBaseFrame.h index 3010c8b390..5207ff9267 100644 --- a/clientgui/BOINCBaseFrame.h +++ b/clientgui/BOINCBaseFrame.h @@ -22,6 +22,11 @@ #pragma interface "BOINCBaseFrame.cpp" #endif +#ifdef __WXMAC__ +#define OFFSCREEN_DELTA 20000 +#endif + + class CFrameEvent; class CFrameAlertEvent; class CBOINCDialUpManager; diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 224a2b1cc8..74e64b2e1e 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -990,6 +990,10 @@ bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) { // Make sure that the new window is going to be visible // on a screen #ifdef __WXMAC__ + // See comment in CBOINCGUIApp::ShowApplication() + if (iLeft >= OFFSCREEN_DELTA) { + iLeft -= OFFSCREEN_DELTA; + } if (!IsWindowOnScreen(iLeft, iTop, iWidth, iHeight)) { iTop = iLeft = 30; } @@ -1250,8 +1254,6 @@ extern void HideThisApp(void); /// true will show the process, false will hide the process. /// #ifdef __WXMAC__ -#define OFFSCREEN_DELTA 20000 - // We can "show" (unhide) the main window when the // application is hidden and it won't be visible. But // if we don't do this under wxCocoa 3.0, the Dock diff --git a/clientgui/sg_BoincSimpleFrame.cpp b/clientgui/sg_BoincSimpleFrame.cpp index 5815c5d959..1d235d6816 100755 --- a/clientgui/sg_BoincSimpleFrame.cpp +++ b/clientgui/sg_BoincSimpleFrame.cpp @@ -308,6 +308,7 @@ bool CSimpleFrame::SaveState() { CBOINCBaseFrame::SaveState(); wxConfigBase* pConfig = wxConfigBase::Get(FALSE); wxString strBaseConfigLocation = wxString(wxT("/Simple")); + wxPoint pos = GetPosition(); wxASSERT(pConfig); @@ -322,8 +323,15 @@ bool CSimpleFrame::SaveState() { // pConfig->SetPath(strBaseConfigLocation); - pConfig->Write(wxT("XPos"), GetPosition().x); - pConfig->Write(wxT("YPos"), GetPosition().y); +#ifdef __WXMAC__ + // See comment in CBOINCGUIApp::ShowApplication() + if (pos.x >= OFFSCREEN_DELTA) { + pos.x -= OFFSCREEN_DELTA; + } +#endif + + pConfig->Write(wxT("XPos"), pos.x); + pConfig->Write(wxT("YPos"), pos.y); return true; } @@ -685,7 +693,7 @@ void CSimpleFrame::OnConnect(CFrameEvent& WXUNUSED(event)) { if (!wasVisible) { wxGetApp().ShowApplication(false); } -#ifndef __WXMAC__ // See explanation in ShowApplication() +#ifndef __WXMAC__ // See comment in CBOINCGUIApp::ShowApplication() if (!wasShown) { Hide(); }