diff options
author | George Hazan <ghazan@miranda.im> | 2018-06-03 22:35:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-06-03 22:35:20 +0300 |
commit | a4549ec2b353a0995bcfba17b7d42c047e7c8ee8 (patch) | |
tree | 061300126750e4865ef0bb5b48ddab4bc43d0416 /src | |
parent | 0fae00f05addee2e71081038b6700aa5eaeaf20b (diff) |
fixes #1401 (fixes inactive session detection)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 8 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 8 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 1 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 5 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 28 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 2 |
7 files changed, 31 insertions, 23 deletions
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 51ff5d245e..2bad147761 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -88,13 +88,13 @@ static void OnReplaceSession(SESSION_INFO *si) static void OnFlashHighlight(SESSION_INFO *si, int bInactive) { - if (!bInactive) + if (!bInactive || si->pDlg == nullptr) return; - if (!g_Settings.bTabsEnable && si->pDlg && g_Settings.bFlashWindowHighlight) - si->pDlg->StartFlash(); - if (g_Settings.bTabsEnable && si->pDlg) + if (g_Settings.bTabsEnable) g_pTabDialog->SetMessageHighlight(si->pDlg); + else if (g_Settings.bFlashWindowHighlight) + si->pDlg->StartFlash(); } static void OnFlashWindow(SESSION_INFO *si, int bInactive) diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index bec0e25d12..356e4e2d57 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -1149,7 +1149,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
bool isMessage = (dbei.eventType == EVENTTYPE_MESSAGE), isSent = ((dbei.flags & DBEF_SENT) != 0);
- bool isActive = GetActiveWindow() == m_pOwner->GetHwnd() && GetForegroundWindow() == m_pOwner->GetHwnd();
+ bool isActive = IsActive();
if (DbEventIsShown(&dbei)) {
// Sounds *only* for sent messages, not for custom events
if (isMessage && !isSent) {
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 0a8658f835..90c1210714 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -67,6 +67,14 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return CSuper::DlgProc(uMsg, wParam, lParam);
}
+bool CMsgDialog::IsActive() const
+{
+ if (!g_Settings.bTabsEnable)
+ return true;
+
+ return m_pOwner->m_tab.GetActivePage() == this && m_pOwner->IsActive();
+}
+
void CMsgDialog::StartFlash()
{
::SetTimer(m_hwnd, TIMERID_FLASHWND, 900, nullptr);
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index cf9270de84..2322ca2c99 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -65,6 +65,7 @@ public: virtual int GetImageId() const PURE;
void CloseTab() override;
+ bool IsActive() const override;
void StartFlash();
void StopFlash();
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 805c39b4d0..dbb178d399 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -161,6 +161,11 @@ public: CTabbedWindow();
+ bool IsActive() const
+ {
+ return GetActiveWindow() == m_hwnd && GetForegroundWindow() == m_hwnd;
+ }
+
CTabbedWindow* AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iActivate = -1);
CMsgDialog* CurrPage() const;
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 5c85b8c7e4..995c14ae86 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -334,29 +334,23 @@ void CTabbedWindow::SaveWindowPosition(bool bUpdateSession) void CTabbedWindow::SetMessageHighlight(CMsgDialog *pDlg) { - if (pDlg != nullptr) { - if (m_tab.GetDlgIndex(pDlg) == -1) - return; + if (m_tab.GetDlgIndex(pDlg) == -1) + return; - pDlg->m_si->wState |= GC_EVENT_HIGHLIGHT; - FixTabIcons(pDlg); - if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwnd) - pDlg->StartFlash(); - } - else RedrawWindow(m_tab.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); + pDlg->m_si->wState |= GC_EVENT_HIGHLIGHT; + FixTabIcons(pDlg); + if (g_Settings.bFlashWindowHighlight && pDlg != m_tab.GetActivePage()) + pDlg->StartFlash(); } void CTabbedWindow::SetTabHighlight(CMsgDialog *pDlg) { - if (pDlg != nullptr) { - if (m_tab.GetDlgIndex(pDlg) == -1) - return; + if (m_tab.GetDlgIndex(pDlg) == -1) + return; - FixTabIcons(pDlg); - if (g_Settings.bFlashWindow && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwnd) - pDlg->StartFlash(); - } - else RedrawWindow(m_tab.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); + FixTabIcons(pDlg); + if (g_Settings.bFlashWindow && pDlg != m_tab.GetActivePage()) + pDlg->StartFlash(); } void CTabbedWindow::SetWindowPosition() diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 79c5022557..986e25a4db 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -284,7 +284,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER)
return FALSE;
- BOOL bInactive = si->pDlg == nullptr || !ContainsWindow(GetForegroundWindow(), si->pDlg->GetHwnd());
+ BOOL bInactive = si->pDlg == nullptr || !si->pDlg->IsActive();
int iEvent = gce->iType;
|