diff --git a/checkin_notes b/checkin_notes index bc97f8d05d..81d87c9a7f 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3802,3 +3802,16 @@ David 13 Apr 2006 api/ txf_util.C + +Rom 13 Apr 2006 + - Bug Fix: Adjust the startup sequence on Windows a bit so that the + window doesn't flicker. Another perk is that on startup the + window won't display itself until it can fully deal with user + input. + - Define some basic data types for MINGW and CYGWIN + + clientgui/ + BOINCGUIApp.cpp + MainFrame.cpp, .h + lib/ + boinc_win.h diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 0c24cf9499..9b7727bfcd 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -441,9 +441,6 @@ bool CBOINCGUIApp::OnInit() { #ifdef __WXMAC__ GetCurrentProcess(&psn); ShowHideProcess(&psn, false); -#else - m_pFrame->Show(); - m_pFrame->Show(false); #endif } diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 4421729f0b..c81ae7b001 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -171,6 +171,7 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame) EVT_MENU(ID_HELPBOINC, CMainFrame::OnHelpBOINCWebsite) EVT_MENU(wxID_ABOUT, CMainFrame::OnHelpAbout) EVT_CLOSE(CMainFrame::OnClose) + EVT_SHOW(CMainFrame::OnShow) EVT_MAINFRAME_ALERT(CMainFrame::OnAlert) EVT_MAINFRAME_CONNECT(CMainFrame::OnConnect) EVT_MAINFRAME_INITIALIZED(CMainFrame::OnInitialized) @@ -796,17 +797,8 @@ bool CMainFrame::RestoreState() { wxString strValue = wxEmptyString; long iIndex = 0; long iPageCount = 0; + long iCurrentPage; bool bKeepEnumerating = false; - bool bWindowIconized = false; -#if defined(__WXMSW__) || defined(__WXMAC__) - bool bWindowMaximized = false; -#endif -#ifdef __WXMAC__ - long iTop = 0; - long iLeft = 0; -#endif - long iHeight = 0; - long iWidth = 0; wxASSERT(pConfig); @@ -821,9 +813,6 @@ bool CMainFrame::RestoreState() { // // Restore Frame State // - int iCurrentPage; - - pConfig->SetPath(strBaseConfigLocation); pConfig->Read(wxT("Language"), &m_iSelectedLanguage, 0L); @@ -840,43 +829,6 @@ bool CMainFrame::RestoreState() { m_pNotebook->SetSelection(iCurrentPage); } - pConfig->Read(wxT("WindowIconized"), &bWindowIconized, false); -#if defined(__WXMSW__) || defined(__WXMAC__) - pConfig->Read(wxT("WindowMaximized"), &bWindowMaximized, false); -#endif - pConfig->Read(wxT("Width"), &iWidth, 800); - pConfig->Read(wxT("Height"), &iHeight, 600); - -#ifdef __WXMAC__ - pConfig->Read(wxT("YPos"), &iTop, 30); - pConfig->Read(wxT("XPos"), &iLeft, 30); - - // If the user has changed the arrangement of multiple - // displays, make sure the window title bar is still on-screen. - Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; - InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible - RgnHandle displayRgn = NewRgn(); - CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays - Rect menuRect = ((**GetMainDevice())).gdRect; - menuRect.bottom = GetMBarHeight() + menuRect.top; - RgnHandle menuRgn = NewRgn(); - RectRgn(menuRgn, &menuRect); // Region hidden by menu bar - DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar retion - if (!RectInRgn(&titleRect, displayRgn)) - iTop = iLeft = 30; - DisposeRgn(menuRgn); - DisposeRgn(displayRgn); - - SetSize(iLeft, iTop, iWidth, iHeight); -#else // ! __WXMAC__ - SetSize(-1, -1, iWidth, iHeight); - Iconize(bWindowIconized); -#endif - -#ifdef __WXMSW__ - Maximize(bWindowMaximized); -#endif - // // Restore Page(s) State // @@ -1546,6 +1498,78 @@ void CMainFrame::OnClose(wxCloseEvent& event) { } +void CMainFrame::OnShow(wxShowEvent& event) { + wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnShow - Function Begin")); + static bool bFirstTime = true; + + if (bFirstTime && event.GetShow()) { + bFirstTime = false; + + wxString strBaseConfigLocation = wxString(wxT("/")); + wxConfigBase* pConfig = wxConfigBase::Get(FALSE); + bool bWindowIconized = false; + #if defined(__WXMSW__) || defined(__WXMAC__) + bool bWindowMaximized = false; + #endif + #ifdef __WXMAC__ + long iTop = 0; + long iLeft = 0; + #endif + long iHeight = 0; + long iWidth = 0; + + + wxASSERT(pConfig); + + // + // Restore Frame State + // + + + pConfig->SetPath(strBaseConfigLocation); + + pConfig->Read(wxT("WindowIconized"), &bWindowIconized, false); +#if defined(__WXMSW__) || defined(__WXMAC__) + pConfig->Read(wxT("WindowMaximized"), &bWindowMaximized, false); +#endif + pConfig->Read(wxT("Width"), &iWidth, 800); + pConfig->Read(wxT("Height"), &iHeight, 600); + +#ifdef __WXMAC__ + pConfig->Read(wxT("YPos"), &iTop, 30); + pConfig->Read(wxT("XPos"), &iLeft, 30); + + // If the user has changed the arrangement of multiple + // displays, make sure the window title bar is still on-screen. + Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; + InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible + RgnHandle displayRgn = NewRgn(); + CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays + Rect menuRect = ((**GetMainDevice())).gdRect; + menuRect.bottom = GetMBarHeight() + menuRect.top; + RgnHandle menuRgn = NewRgn(); + RectRgn(menuRgn, &menuRect); // Region hidden by menu bar + DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar retion + if (!RectInRgn(&titleRect, displayRgn)) + iTop = iLeft = 30; + DisposeRgn(menuRgn); + DisposeRgn(displayRgn); + + SetSize(iLeft, iTop, iWidth, iHeight); +#else // ! __WXMAC__ + SetSize(-1, -1, iWidth, iHeight); +#endif + +#ifdef __WXMSW__ + Maximize(bWindowMaximized); +#endif + } + + event.Skip(); + wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnShow - Function End")); +} + + void CMainFrame::OnAlert(CMainFrameAlertEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnAlert - Function Begin")); @@ -1556,6 +1580,11 @@ void CMainFrame::OnAlert(CMainFrameAlertEvent& event) { if ((IsShown() && !event.m_notification_only) || (IsShown() && !pTaskbar->IsBalloonsSupported())) { if (!event.m_notification_only) { int retval = 0; + + if (!IsShown()) { + Show(); + } + retval = ::wxMessageBox(event.m_message, event.m_title, event.m_style, this); if (event.m_alert_event_type == AlertProcessResponse) { event.ProcessResponse(retval); @@ -1595,6 +1624,11 @@ void CMainFrame::OnAlert(CMainFrameAlertEvent& event) { if (IsShown() && !event.m_notification_only) { if (!event.m_notification_only) { int retval = 0; + + if (!IsShown()) { + Show(); + } + retval = ::wxMessageBox(event.m_message, event.m_title, event.m_style, this); if (event.m_alert_event_type == AlertProcessResponse) { event.ProcessResponse(retval); @@ -1637,6 +1671,11 @@ void CMainFrame::OnConnect(CMainFrameEvent&) { pDoc->rpc.acct_mgr_info(ami); if (ami.acct_mgr_url.size() && !ami.have_credentials) { pAMWizard = new CWizardAccountManager(this); + + if (!IsShown()) { + Show(); + } + if (pAMWizard->Run()) { // If successful, hide the main window Hide(); @@ -1646,6 +1685,11 @@ void CMainFrame::OnConnect(CMainFrameEvent&) { } } else if (0 >= pDoc->GetProjectCount()) { pAPWizard = new CWizardAttachProject(this); + + if (!IsShown()) { + Show(); + } + pDoc->rpc.get_project_init_status(pis); strName = wxString(pis.name.c_str(), wxConvUTF8); strURL = wxString(pis.url.c_str(), wxConvUTF8); diff --git a/clientgui/MainFrame.h b/clientgui/MainFrame.h index 7079a5cd25..085d7b24d4 100644 --- a/clientgui/MainFrame.h +++ b/clientgui/MainFrame.h @@ -87,6 +87,7 @@ public: void OnHelpAbout( wxCommandEvent& event ); void OnClose( wxCloseEvent& event ); + void OnShow( wxShowEvent& event ); void OnRefreshState( wxTimerEvent& event ); void OnFrameRender( wxTimerEvent& event ); diff --git a/lib/boinc_win.h b/lib/boinc_win.h index 7d32ef8f1c..0db458bba4 100644 --- a/lib/boinc_win.h +++ b/lib/boinc_win.h @@ -66,6 +66,7 @@ #include #if !defined(__CYGWIN32__) || defined(USE_WINSOCK) + /* If we're not running under CYGWIN use windows networking */ #undef USE_WINSOCK #define USE_WINSOCK 1 @@ -73,6 +74,7 @@ #include #else + /* Under cygwin, curl was probably compiled to use */ #include #include @@ -86,6 +88,7 @@ #define _WINSOCK2_H #define _WININET_H #define _WININETAPI_ + #endif #include @@ -103,9 +106,24 @@ #if !defined(__MINGW32__) && !defined(__CYGWIN32__) #include #endif + #if !defined(__CYGWIN32__) #include +#else + +#ifndef _TCHAR_DEFINED +typedef char TCHAR, *PTCHAR; +typedef unsigned char TBYTE , *PTBYTE ; +#define _TCHAR_DEFINED +#endif /* !_TCHAR_DEFINED */ + +typedef LPSTR LPTCH, PTCH; +typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR; +typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR; +#define __TEXT(quote) quote + #endif + #if !defined(__MINGW32__) && !defined(__CYGWIN32__) #include #endif