summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/TabSRMM/src/chat_tools.cpp151
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp4
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp8
-rw-r--r--plugins/TabSRMM/src/msgs.cpp14
-rw-r--r--plugins/TabSRMM/src/msgs.h7
-rw-r--r--plugins/TabSRMM/src/sidebar.cpp2
-rw-r--r--plugins/TabSRMM/src/taskbar.cpp6
7 files changed, 89 insertions, 103 deletions
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp
index 56c23a72c5..612f82a317 100644
--- a/plugins/TabSRMM/src/chat_tools.cpp
+++ b/plugins/TabSRMM/src/chat_tools.cpp
@@ -208,43 +208,42 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
return FALSE;
CMsgDialog *dat = si->pDlg;
-
MCONTACT hContact = si->hContact;
- bool bInactive = true;
- if (dat) {
- if ((dat->GetHwnd() == dat->m_pContainer->m_hwndActive) && GetForegroundWindow() == dat->m_pContainer->m_hwnd)
- bInactive = false;
- }
+
+ int iEvent = gce->iType;
+ bool bInactive = (dat) ? !dat->IsActive() : true;
bool bActiveTab = false;
bool bMustFlash = false;
bool bMustAutoswitch = false;
- int iEvent = gce->iType;
- HWND hWnd = nullptr;
-
- WPARAM wParamForHighLight = 0;
bool bFlagUnread = false;
+
if (bHighlight) {
gce->iType |= GC_EVENT_HIGHLIGHT;
if (Contact_IsHidden(si->hContact) != 0)
Contact_Hide(si->hContact, false);
+
if (bInactive) {
bFlagUnread = true;
DoTrayIcon(si, gce);
}
- if (g_Settings.bCreateWindowOnHighlight && dat == nullptr)
- wParamForHighLight = 1;
-
- if (dat && g_Settings.bAnnoyingHighlight && bInactive && dat->m_pContainer->m_hwnd != GetForegroundWindow()) {
- wParamForHighLight = 2;
- hWnd = dat->GetHwnd();
- }
-
if (dat || !nen_options.iMUCDisable)
DoPopup(si, gce);
if (g_Settings.bFlashWindowHighlight && bInactive)
bMustFlash = true;
+
bMustAutoswitch = true;
+ if (g_Settings.bCreateWindowOnHighlight && dat == nullptr) {
+ Clist_ContactDoubleClicked(hContact);
+ bActiveTab = true;
+ bInactive = bMustAutoswitch = bMustFlash = false;
+ }
+
+ if (dat && g_Settings.bAnnoyingHighlight && bInactive && dat->m_pContainer->m_hwnd != GetForegroundWindow()) {
+ bActiveTab = true;
+ bInactive = bMustAutoswitch = bMustFlash = false;
+ dat->ActivateTab();
+ }
}
else {
// do blinking icons in tray
@@ -281,18 +280,6 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
dat->m_pWnd->Invalidate();
}
- if (1 == wParamForHighLight) {
- Clist_ContactDoubleClicked(hContact);
- bActiveTab = true;
- bInactive = bMustAutoswitch = bMustFlash = false;
- }
-
- if (2 == wParamForHighLight) {
- bActiveTab = true;
- bInactive = bMustAutoswitch = bMustFlash = false;
- SendMessage(hWnd, DM_ACTIVATEME, 0, 0);
- }
-
auto sound = si->getSoundName(iEvent);
if (dat) {
bInactive = dat->m_pContainer->m_hwnd != GetForegroundWindow();
@@ -304,70 +291,68 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
Skin_PlaySound(sound);
// dialog event processing
- if (dat == nullptr)
- return true;
-
- HICON hNotifyIcon = (bManyFix && !bInactive) ? 0 : g_chatApi.getIcon(iEvent);
- BOOL bForcedIcon = (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || hNotifyIcon == g_chatApi.hIcons[ICON_MESSAGE]);
+ if (dat) {
+ HICON hNotifyIcon = (bManyFix && !bInactive) ? 0 : g_chatApi.getIcon(iEvent);
+ BOOL bForcedIcon = (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || hNotifyIcon == g_chatApi.hIcons[ICON_MESSAGE]);
- if ((iEvent & si->iLogTrayFlags) || bForcedIcon) {
- if (!bActiveTab) {
- if (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT])
- dat->m_iFlashIcon = hNotifyIcon;
- else {
- if (dat->m_iFlashIcon != g_chatApi.hIcons[ICON_HIGHLIGHT] && dat->m_iFlashIcon != g_chatApi.hIcons[ICON_MESSAGE])
+ if ((iEvent & si->iLogTrayFlags) || bForcedIcon) {
+ if (!bActiveTab) {
+ if (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT])
dat->m_iFlashIcon = hNotifyIcon;
+ else {
+ if (dat->m_iFlashIcon != g_chatApi.hIcons[ICON_HIGHLIGHT] && dat->m_iFlashIcon != g_chatApi.hIcons[ICON_MESSAGE])
+ dat->m_iFlashIcon = hNotifyIcon;
+ }
+ dat->m_bCanFlashTab = TRUE;
+ dat->timerFlash.Start(TIMEOUT_FLASHWND);
}
- dat->m_bCanFlashTab = TRUE;
- dat->timerFlash.Start(TIMEOUT_FLASHWND);
}
- }
- if (dat->m_pWnd) {
- dat->m_pWnd->updateIcon(hNotifyIcon);
- dat->m_pWnd->setOverlayIcon(hNotifyIcon, true);
- }
+ if (dat->m_pWnd) {
+ dat->m_pWnd->updateIcon(hNotifyIcon);
+ dat->m_pWnd->setOverlayIcon(hNotifyIcon, true);
+ }
- // autoswitch tab..
- if (bMustAutoswitch) {
- if ((IsIconic(dat->m_pContainer->m_hwnd)) && !IsZoomed(dat->m_pContainer->m_hwnd) && PluginConfig.m_bAutoSwitchTabs && dat->m_pContainer->m_hwndActive != dat->GetHwnd()) {
- int iItem = GetTabIndexFromHWND(dat->m_pContainer->m_hwndTabs, dat->GetHwnd());
- if (iItem >= 0) {
- TabCtrl_SetCurSel(dat->m_pContainer->m_hwndTabs, iItem);
- ShowWindow(dat->m_pContainer->m_hwndActive, SW_HIDE);
- dat->m_pContainer->m_hwndActive = dat->GetHwnd();
- dat->m_pContainer->UpdateTitle(dat->m_hContact);
- dat->m_pContainer->m_flags.m_bDeferredTabSelect = true;
+ // autoswitch tab..
+ if (bMustAutoswitch) {
+ if ((IsIconic(dat->m_pContainer->m_hwnd)) && !IsZoomed(dat->m_pContainer->m_hwnd) && PluginConfig.m_bAutoSwitchTabs && dat->m_pContainer->m_hwndActive != dat->GetHwnd()) {
+ int iItem = GetTabIndexFromHWND(dat->m_pContainer->m_hwndTabs, dat->GetHwnd());
+ if (iItem >= 0) {
+ TabCtrl_SetCurSel(dat->m_pContainer->m_hwndTabs, iItem);
+ ShowWindow(dat->m_pContainer->m_hwndActive, SW_HIDE);
+ dat->m_pContainer->m_hwndActive = dat->GetHwnd();
+ dat->m_pContainer->UpdateTitle(dat->m_hContact);
+ dat->m_pContainer->m_flags.m_bDeferredTabSelect = true;
+ }
}
}
- }
- // flash window if it is not focused
- if (bMustFlash && bInactive)
- if (!dat->m_pContainer->m_flags.m_bNoFlash)
- dat->m_pContainer->FlashContainer(1, 0);
-
- if (hNotifyIcon && bInactive && ((iEvent & si->iLogTrayFlags) || bForcedIcon)) {
- if (bMustFlash)
- dat->m_hTabIcon = hNotifyIcon;
- else if (dat->m_iFlashIcon) {
- dat->m_hTabIcon = dat->m_iFlashIcon;
-
- TCITEM item = {};
- item.mask = TCIF_IMAGE;
- item.iImage = 0;
- TabCtrl_SetItem(GetParent(dat->GetHwnd()), dat->m_iTabID, &item);
- }
+ // flash window if it is not focused
+ if (bMustFlash && bInactive)
+ if (!dat->m_pContainer->m_flags.m_bNoFlash)
+ dat->m_pContainer->FlashContainer(1, 0);
+
+ if (hNotifyIcon && bInactive && ((iEvent & si->iLogTrayFlags) || bForcedIcon)) {
+ if (bMustFlash)
+ dat->m_hTabIcon = hNotifyIcon;
+ else if (dat->m_iFlashIcon) {
+ dat->m_hTabIcon = dat->m_iFlashIcon;
+
+ TCITEM item = {};
+ item.mask = TCIF_IMAGE;
+ item.iImage = 0;
+ TabCtrl_SetItem(GetParent(dat->GetHwnd()), dat->m_iTabID, &item);
+ }
- HICON hIcon = (HICON)SendMessage(dat->m_pContainer->m_hwnd, WM_GETICON, ICON_BIG, 0);
- if (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || (hIcon != g_chatApi.hIcons[ICON_MESSAGE] && hIcon != g_chatApi.hIcons[ICON_HIGHLIGHT])) {
- dat->m_pContainer->SetIcon(dat, hNotifyIcon);
- dat->m_pContainer->m_flags.m_bNeedsUpdateTitle = true;
+ HICON hIcon = (HICON)SendMessage(dat->m_pContainer->m_hwnd, WM_GETICON, ICON_BIG, 0);
+ if (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || (hIcon != g_chatApi.hIcons[ICON_MESSAGE] && hIcon != g_chatApi.hIcons[ICON_HIGHLIGHT])) {
+ dat->m_pContainer->SetIcon(dat, hNotifyIcon);
+ dat->m_pContainer->m_flags.m_bNeedsUpdateTitle = true;
+ }
}
- }
-
- if (bMustFlash && bInactive)
- AddUnreadContact(dat->m_hContact);
+ if (bMustFlash && bInactive)
+ AddUnreadContact(dat->m_hContact);
+ }
return true;
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index f60a72c4fa..0350f55db8 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -3192,10 +3192,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_pContainer->InitRedraw();
return 0;
- case DM_ACTIVATEME: // the child window will activate itself
- ActivateTab();
- return 0;
-
case DM_QUERYHCONTACT:
if (lParam)
*(MCONTACT *)lParam = m_hContact;
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 01e98df270..46ec031f75 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -749,6 +749,14 @@ void CMsgDialog::HandlePasteAndSend()
}
/////////////////////////////////////////////////////////////////////////////////////////
+// is window active or not?
+
+bool CMsgDialog::IsActive() const
+{
+ return m_pContainer->IsActive() && m_pContainer->m_hwndActive == m_hwnd;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// read keyboard state and return the state of the modifier keys
void CMsgDialog::KbdState(bool &isShift, bool &isControl, bool &isAlt)
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index fb41fccb5e..1feadb0737 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -106,9 +106,9 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam)
{
MCONTACT hContact = ((CLISTEVENT *)lParam)->hContact;
- HWND hwndExisting = Srmm_FindWindow(hContact);
- if (hwndExisting != nullptr)
- SendMessage(hwndExisting, DM_ACTIVATEME, 0, 0);
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg != nullptr)
+ pDlg->ActivateTab();
else {
wchar_t szName[CONTAINER_NAMELEN + 1];
GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN);
@@ -146,17 +146,17 @@ INT_PTR SendMessageCommand_Worker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar
if (0 == (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND))
return 0;
- HWND hwnd = Srmm_FindWindow(hContact);
- if (hwnd) {
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg) {
if (pszMsg) {
- HWND hEdit = GetDlgItem(hwnd, IDC_SRMM_MESSAGE);
+ HWND hEdit = GetDlgItem(pDlg->GetHwnd(), IDC_SRMM_MESSAGE);
SendMessage(hEdit, EM_SETSEL, -1, GetWindowTextLength(hEdit));
if (isWchar)
SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
else
SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
}
- SendMessage(hwnd, DM_ACTIVATEME, 0, 0);
+ pDlg->ActivateTab();
}
else {
wchar_t szName[CONTAINER_NAMELEN + 1];
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index a67ae4935d..29f7d9f3e1 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -559,6 +559,7 @@ public:
void AddLog() override;
void CloseTab() override;
+ bool IsActive() const override;
void LoadSettings() override;
void SetStatusText(const wchar_t *, HICON) override;
void ShowFilterMenu() override;
@@ -585,11 +586,6 @@ public:
void LogEvent(DBEVENTINFO &dbei);
- bool IsActive() const override
- {
- return m_pContainer->IsActive() && m_pContainer->m_hwndActive == m_hwnd;
- }
-
void DM_OptionsApplied(bool bRemakeLog = true);
void DM_RecalcPictureSize(void);
void DM_ScrollToBottom(WPARAM wParam, LPARAM lParam);
@@ -728,7 +724,6 @@ struct TIconDescW
#define DM_CHECKSIZE (TM_USER+37)
#define DM_FORCEREDRAW (TM_USER+38)
#define DM_QUERYHCONTACT (TM_USER+41)
-#define DM_ACTIVATEME (TM_USER+46)
#define DM_STATUSMASKSET (TM_USER+51)
#define DM_UPDATESTATUSMSG (TM_USER+53)
#define DM_OWNNICKCHANGED (TM_USER+55)
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp
index 1ee5f238fa..3a433f2a19 100644
--- a/plugins/TabSRMM/src/sidebar.cpp
+++ b/plugins/TabSRMM/src/sidebar.cpp
@@ -326,7 +326,7 @@ int CSideBarButton::testCloseButton() const
void CSideBarButton::activateSession() const
{
if (m_dat)
- ::SendMessage(m_dat->GetHwnd(), DM_ACTIVATEME, 0, 0);
+ m_dat->ActivateTab();
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp
index 63afe06305..094cebf30a 100644
--- a/plugins/TabSRMM/src/taskbar.cpp
+++ b/plugins/TabSRMM/src/taskbar.cpp
@@ -494,8 +494,10 @@ LRESULT CALLBACK CProxyWindow::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA
// to the real message window.
if (WA_ACTIVE == wParam) {
if (IsWindow(m_dat->GetHwnd()))
- ::PostMessage(m_dat->GetHwnd(), DM_ACTIVATEME, 0, 0);
- return 0; // no default processing, avoid flickering.
+ m_dat->ActivateTab();
+
+ // no default processing, avoid flickering.
+ return 0;
}
break;