diff options
-rw-r--r-- | include/m_chat_int.h | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 5 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_tools.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_window.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/eventpopups.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 9 | ||||
-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 |
18 files changed, 60 insertions, 36 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index c50ffbd692..5ad09897a2 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -259,6 +259,7 @@ struct CHAT_MANAGER void (*SetActiveSession)(SESSION_INFO *si);
SESSION_INFO* (*GetActiveSession)(void);
+
SESSION_INFO* (*SM_FindSession)(const wchar_t *pszID, const char *pszModule);
HICON (*SM_GetStatusIcon)(SESSION_INFO *si, USERINFO * ui);
BOOL (*SM_PostMessage)(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -448,6 +449,7 @@ public: virtual void AddLog();
virtual void CloseTab() {}
+ virtual bool IsActive() const PURE;
virtual void LoadSettings() PURE;
virtual void RedrawLog() {}
virtual void ScrollToBottom() {}
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index b008fa924b..383dd6cb8e 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1412,7 +1412,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (m_hDbEventFirst == 0)
m_hDbEventFirst = hDbEvent;
if (DbEventIsShown(dbei)) {
- bool bIsActive = GetActiveWindow() == m_hwndParent && GetForegroundWindow() == m_hwndParent && m_pParent->hwndActive == m_hwnd;
+ bool bIsActive = IsActive();
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT))) {
/* store the event when the container is hidden so that clist notifications can be removed */
if (!IsWindowVisible(m_hwndParent) && m_hDbUnreadEventFirst == 0)
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 16c6b6e5d6..2ca2855895 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -90,6 +90,11 @@ public: virtual void LoadSettings() override;
virtual void SetStatusText(const wchar_t*, HICON) override;
+ bool IsActive() const
+ {
+ return GetActiveWindow() == m_hwndParent && GetForegroundWindow() == m_hwndParent && m_pParent->hwndActive == m_hwnd;
+ }
+
void Reattach(HWND hwndContainer);
ParentWindowData *m_pParent;
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index 74a0e7468c..cebe7cb32c 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -168,7 +168,7 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) if (pContainer->dwFlags & CNT_DONTREPORT && IsIconic(pContainer->m_hwnd)) // in tray counts as "minimised"
goto passed;
if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED) {
- if (!IsIconic(pContainer->m_hwnd) && GetForegroundWindow() != pContainer->m_hwnd && GetActiveWindow() != pContainer->m_hwnd)
+ if (!IsIconic(pContainer->m_hwnd) && !pContainer->IsActive())
goto passed;
}
if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) {
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index e7e8faaa9f..9d7c6f9211 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -738,7 +738,7 @@ void CChatRoomDlg::AddLog() DM_AddDivider(); } else { - bool bInactive = (GetForegroundWindow() != m_pContainer->m_hwnd || GetActiveWindow() != m_pContainer->m_hwnd); + bool bInactive = !IsActive(); if (bInactive) DM_AddDivider(); else if (m_pContainer->m_hwndActive != m_hwnd) @@ -1404,7 +1404,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_INPUTLANGCHANGE: - if (PluginConfig.m_bAutoLocaleSupport && GetFocus() == m_message.GetHwnd() && m_pContainer->m_hwndActive == m_hwnd && GetForegroundWindow() == m_pContainer->m_hwnd && GetActiveWindow() == m_pContainer->m_hwnd) { + if (PluginConfig.m_bAutoLocaleSupport && GetFocus() == m_message.GetHwnd() && IsActive()) { DM_SaveLocale(wParam, lParam); m_message.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_message.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD); return 1; diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index c0122e1a2b..75d43b60f5 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -2297,7 +2297,7 @@ void TSAPI ReflashContainer(TContainerData *pContainer) {
DWORD dwStartTime = pContainer->dwFlashingStarted;
- if (GetForegroundWindow() == pContainer->m_hwnd || GetActiveWindow() == pContainer->m_hwnd) // dont care about active windows
+ if (pContainer->IsActive()) // dont care about active windows
return;
if (pContainer->dwFlags & CNT_NOFLASH || pContainer->dwFlashingStarted == 0)
diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index 77857705ce..6fae4bc98e 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -780,7 +780,7 @@ int tabSRMM_ShowPopup(MCONTACT hContact, MEVENT hDbEvent, WORD eventType, int wi goto passed;
if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED)
- if (!IsIconic(pContainer->m_hwnd) && GetForegroundWindow() != pContainer->m_hwnd && GetActiveWindow() != pContainer->m_hwnd)
+ if (!IsIconic(pContainer->m_hwnd) && !pContainer->IsActive())
goto passed;
if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) {
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index ca06a2a07c..b3f471ca0d 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1087,7 +1087,7 @@ void CTabBaseDlg::DM_Typing(bool fForceOff) SendMessage(hwndStatus, SB_SETTEXT, 0, (LPARAM)m_wszStatusBar); SendMessage(hwndStatus, SB_SETICON, 0, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]); } - if (IsIconic(hwndContainer) || GetForegroundWindow() != hwndContainer || GetActiveWindow() != hwndContainer) { + if (IsIconic(hwndContainer) || !IsActive()) { SetWindowText(hwndContainer, m_wszStatusBar); m_pContainer->dwFlags |= CNT_NEED_UPDATETITLE; if (!(m_pContainer->dwFlags & CNT_NOFLASH) && PluginConfig.m_FlashOnMTN) @@ -1223,7 +1223,7 @@ void CTabBaseDlg::DM_EventAdded(WPARAM hContact, LPARAM lParam) DM_AddDivider(); } else if (PluginConfig.m_bUseDividers) { - if ((GetForegroundWindow() != m_pContainer->m_hwnd || GetActiveWindow() != m_pContainer->m_hwnd)) + if (!m_pContainer->IsActive()) DM_AddDivider(); else if (m_pContainer->m_hwndActive != m_hwnd) DM_AddDivider(); @@ -1294,8 +1294,8 @@ void CTabBaseDlg::DM_EventAdded(WPARAM hContact, LPARAM lParam) // flash window if it is not focused if (!bDisableNotify && !bIsStatusChangeEvent) - if ((GetActiveWindow() != m_pContainer->m_hwnd || GetForegroundWindow() != m_pContainer->m_hwnd || m_pContainer->m_hwndActive != m_hwnd) && !(dbei.flags & DBEF_SENT)) { - if (!(m_pContainer->dwFlags & CNT_NOFLASH) && (GetActiveWindow() != m_pContainer->m_hwnd || GetForegroundWindow() != m_pContainer->m_hwnd)) + if (!IsActive() && !(dbei.flags & DBEF_SENT)) { + if (!(m_pContainer->dwFlags & CNT_NOFLASH) && !m_pContainer->IsActive()) FlashContainer(m_pContainer, 1, 0); SendMessage(m_pContainer->m_hwnd, DM_SETICON, (WPARAM)this, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); m_pContainer->dwFlags |= CNT_NEED_UPDATETITLE; diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 604f43ac0b..8929da899f 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2123,7 +2123,7 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) break;
case WM_INPUTLANGCHANGE:
- if (PluginConfig.m_bAutoLocaleSupport && GetFocus() == m_message.GetHwnd() && m_pContainer->m_hwndActive == m_hwnd && GetForegroundWindow() == m_pContainer->m_hwnd && GetActiveWindow() == m_pContainer->m_hwnd) {
+ if (PluginConfig.m_bAutoLocaleSupport && GetFocus() == m_message.GetHwnd() && IsActive()) {
DM_SaveLocale(wParam, lParam);
m_message.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_message.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
return 1;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index ba5aa42fa0..2f659e5233 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -160,7 +160,7 @@ INT_PTR CTabBaseDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case DM_SETLOCALE:
if (m_dwFlags & MWF_WASBACKGROUNDCREATE)
break;
- if (m_pContainer->m_hwndActive == m_hwnd && PluginConfig.m_bAutoLocaleSupport && m_pContainer->m_hwnd == GetForegroundWindow() && m_pContainer->m_hwnd == GetActiveWindow()) {
+ if (PluginConfig.m_bAutoLocaleSupport && IsActive()) {
if (lParam)
m_hkl = (HKL)lParam;
@@ -355,7 +355,7 @@ int TSAPI MessageWindowOpened(MCONTACT hContact, HWND _hwnd) return 0;
}
if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED) {
- if (!IsIconic(pContainer->m_hwnd) && GetForegroundWindow() != pContainer->m_hwnd && GetActiveWindow() != pContainer->m_hwnd)
+ if (!IsIconic(pContainer->m_hwnd) && !pContainer->IsActive())
return 0;
}
if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) {
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 1f75548e90..5d2d65eeb4 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -232,6 +232,10 @@ struct TContainerData void ClearMargins()
{ memset(&mOld, 0xfe, sizeof(mOld));
}
+
+ bool IsActive()
+ { return GetActiveWindow() == m_hwnd && GetForegroundWindow() == m_hwnd;
+ }
};
struct SESSION_INFO;
@@ -380,6 +384,11 @@ public: __forceinline CCtrlRichEdit& GetEntry() { return m_message; }
+ bool IsActive() const override
+ {
+ return m_pContainer->IsActive() && m_pContainer->m_hwndActive == m_hwnd;
+ }
+
HWND DM_CreateClist();
void DM_EventAdded(WPARAM wParam, LPARAM lParam);
void DM_InitRichEdit();
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;
|