From a4549ec2b353a0995bcfba17b7d42c047e7c8ee8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 3 Jun 2018 22:35:20 +0300 Subject: fixes #1401 (fixes inactive session detection) --- plugins/TabSRMM/src/chat_tools.cpp | 2 +- plugins/TabSRMM/src/chat_window.cpp | 4 ++-- plugins/TabSRMM/src/container.cpp | 2 +- plugins/TabSRMM/src/eventpopups.cpp | 2 +- plugins/TabSRMM/src/generic_msghandlers.cpp | 8 ++++---- plugins/TabSRMM/src/msgdialog.cpp | 2 +- plugins/TabSRMM/src/msgs.cpp | 4 ++-- plugins/TabSRMM/src/msgs.h | 9 +++++++++ 8 files changed, 21 insertions(+), 12 deletions(-) (limited to 'plugins/TabSRMM/src') 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(); -- cgit v1.2.3