From 0a3b5445792a4826524f4238cc38ed52c1a5471a Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Fri, 18 May 2012 19:09:33 -0400 Subject: [PATCH] desktop: fixed SyncStatusDlg resize bug This commit changes the order of the convenience window move to come before the window resize. It may be possible that before, due to a race condition of window sizing messages, we may have been resizng the window based on the small size. --- desktop/src/SyncStatusDlg.cc | 32 ++++++++++++++++++++------------ desktop/src/SyncStatusDlg.h | 3 +++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/desktop/src/SyncStatusDlg.cc b/desktop/src/SyncStatusDlg.cc index 72eaa0c1..fac4704b 100644 --- a/desktop/src/SyncStatusDlg.cc +++ b/desktop/src/SyncStatusDlg.cc @@ -270,6 +270,8 @@ SyncStatusDlg::SyncStatusDlg(wxWindow *parent, , m_runapp_button(0) , m_syncagain_button(0) , m_killclose_button(0) + , m_details_button(0) + , m_repositioned(false) { wxBusyCursor wait; @@ -628,22 +630,28 @@ void SyncStatusDlg::OnShowDetails(wxCommandEvent &event) m_details_button->SetLabel(_T("Show Details")); } else { + if( !m_repositioned ) { + // try to position the window in a readable spot... + // do this first, so that the resize + wxSize size = GetSize(); + wxPoint pos = GetScreenPosition(); + int screen_height = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); + int new_height = size.GetHeight() + 470; + if( (pos.y + new_height) > screen_height && + new_height < screen_height ) + { + int wiggle_room = screen_height - new_height; + int y = wiggle_room / 2; + Move(pos.x, y); + } + + m_repositioned = true; + } + m_status_edit->Show(); m_details_button->SetLabel(_T("Hide Details")); } m_topsizer->Fit(this); - - // try to position the window in a readable spot - wxSize size = GetSize(); - wxPoint pos = GetScreenPosition(); - int screen_height = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); - if( (pos.y + size.GetHeight()) > screen_height && - size.GetHeight() < screen_height ) - { - int wiggle_room = screen_height - size.GetHeight(); - int y = wiggle_room / 2; - Move(pos.x, y); - } } wxConnectionBase* SyncStatusDlg::OnAcceptConnection(const wxString &topic) diff --git a/desktop/src/SyncStatusDlg.h b/desktop/src/SyncStatusDlg.h index 94c7d6cd..b743446b 100644 --- a/desktop/src/SyncStatusDlg.h +++ b/desktop/src/SyncStatusDlg.h @@ -123,6 +123,9 @@ private: wxButton *m_runapp_button, *m_syncagain_button, *m_killclose_button; wxButton *m_details_button; + // state + bool m_repositioned; + protected: void CreateLayout(); void AddStatusSizer(wxSizer *sizer); -- 2.11.4.GIT