From ff154f035fff660bb194b6d93ecc7020f3f36b45 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 30 Mar 2010 12:59:23 +0000 Subject: [PATCH] MGR: Allow updates to continue behind the notification alert svn path=/trunk/boinc/; revision=21028 --- clientgui/BOINCTaskBar.cpp | 49 +++++++++++++++++++++++++++----------- clientgui/BOINCTaskBar.h | 3 +++ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index 22386a8d1d..208cca91fc 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -44,6 +44,7 @@ DEFINE_EVENT_TYPE(wxEVT_TASKBAR_RELOADSKIN) DEFINE_EVENT_TYPE(wxEVT_TASKBAR_REFRESH) +DEFINE_EVENT_TYPE(wxEVT_TASKBAR_NOTIFICATION_ALERT) BEGIN_EVENT_TABLE(CTaskBarIcon, wxTaskBarIconEx) @@ -51,6 +52,7 @@ BEGIN_EVENT_TABLE(CTaskBarIcon, wxTaskBarIconEx) EVT_CLOSE(CTaskBarIcon::OnClose) EVT_TASKBAR_REFRESH(CTaskBarIcon::OnRefresh) EVT_TASKBAR_RELOADSKIN(CTaskBarIcon::OnReloadSkin) + EVT_TASKBAR_NOTIFICATION_ALERT(CTaskBarIcon::OnNotificationAlert) EVT_TASKBAR_LEFT_DCLICK(CTaskBarIcon::OnLButtonDClick) #ifndef __WXMAC__ EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown) @@ -316,6 +318,30 @@ void CTaskBarIcon::OnReloadSkin(CTaskbarEvent& WXUNUSED(event)) { } +void CTaskBarIcon::OnNotificationAlert(CTaskbarEvent& WXUNUSED(event)) { + CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); + wxString strTitle; + + strTitle.Printf( + _("%s Notices"), + pSkinAdvanced->GetApplicationName().c_str() + ); + + // Do not use SafeMessageBox here because we want to continue + // doing periodic RPCs to get messages, get notices, etc. + wxMessageDialog* pDlg = new wxMessageDialog( + NULL, + _("One or more notices are now available for viewing."), + strTitle, + wxOK + ); + pDlg->ShowModal(); + if (pDlg) { + pDlg->Destroy(); + } +} + + void CTaskBarIcon::FireReloadSkin() { CTaskbarEvent event(wxEVT_TASKBAR_RELOADSKIN, this); AddPendingEvent(event); @@ -698,18 +724,16 @@ void CTaskBarIcon::UpdateNoticeStatus() { m_iLastNotificationCount = iNoticeCount; m_dtLastNotificationAlertExecuted = wxDateTime::Now(); - strTitle.Printf( - _("%s Notices"), - pSkinAdvanced->GetApplicationName().c_str() - ); - wxString strMessage = _("One or more notices are now available for viewing."); - if (IsBalloonsSupported()) { // Display balloon + strTitle.Printf( + _("%s Notices"), + pSkinAdvanced->GetApplicationName().c_str() + ); QueueBalloon( m_iconTaskBarNormal, strTitle, - strMessage, + _("One or more notices are now available for viewing."), BALLOONTYPE_INFO ); } else { @@ -723,13 +747,10 @@ void CTaskBarIcon::UpdateNoticeStatus() { // If Manager is now hidden, alert will appear when Manager is shown. int currentTabView = pFrame->GetCurrentViewPage(); if (! (currentTabView & VW_NOTIF)) { - // Do not use SafeMessageBox here because we want to continue - // doing periodic RPCs to get messages, get notices, etc. - wxMessageDialog* pDlg = new wxMessageDialog(NULL, strMessage, strTitle, wxOK); - pDlg->ShowModal(); - if (pDlg) { - pDlg->Destroy(); - } + // Don't run the alert from within the taskbar Refresh event to + // allow updates to continue behind the notification alert + CTaskbarEvent event(wxEVT_TASKBAR_NOTIFICATION_ALERT, this); + AddPendingEvent(event); } } } diff --git a/clientgui/BOINCTaskBar.h b/clientgui/BOINCTaskBar.h index 914882d648..39a52064d5 100644 --- a/clientgui/BOINCTaskBar.h +++ b/clientgui/BOINCTaskBar.h @@ -50,6 +50,7 @@ public: void OnClose(wxCloseEvent& event); void OnRefresh(CTaskbarEvent& event); void OnReloadSkin(CTaskbarEvent& event); + void OnNotificationAlert(CTaskbarEvent& event); void OnNotificationClick(wxTaskBarIconExEvent& event); void OnShutdown(wxTaskBarIconExEvent& event); @@ -139,10 +140,12 @@ public: BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE( wxEVT_TASKBAR_RELOADSKIN, 10100 ) DECLARE_EVENT_TYPE( wxEVT_TASKBAR_REFRESH, 10101 ) +DECLARE_EVENT_TYPE( wxEVT_TASKBAR_NOTIFICATION_ALERT, 10102 ) END_DECLARE_EVENT_TYPES() #define EVT_TASKBAR_RELOADSKIN(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_TASKBAR_RELOADSKIN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), #define EVT_TASKBAR_REFRESH(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_TASKBAR_REFRESH, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), +#define EVT_TASKBAR_NOTIFICATION_ALERT(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_TASKBAR_NOTIFICATION_ALERT, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), #endif