summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-03-24 19:20:11 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-03-24 19:20:11 +0300
commit429f6f8dc6e73348426b58b388360ce94507092c (patch)
tree65f7e58d2675e02f067050d1a96ac59451cd2036 /src
parent214a9afdb87700c80af08790b7cb967153cb932d (diff)
StdMsg: flicker optimization, part 2
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/msgs.cpp21
-rw-r--r--src/core/stdmsg/src/stdafx.h2
-rw-r--r--src/mir_core/src/Windows/CCtrlPages.cpp25
3 files changed, 28 insertions, 20 deletions
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index d2b21d2173..68d21de96a 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -81,10 +81,16 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd) {
if (!g_plugin.bDoNotStealFocus) {
- ShowWindow(hwnd, SW_RESTORE);
- SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
- SetForegroundWindow(hwnd);
- Skin_PlaySound("RecvMsgActive");
+ if (!g_Settings.bTabsEnable) {
+ ShowWindow(hwnd, SW_RESTORE);
+ SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
+ SetForegroundWindow(hwnd);
+ Skin_PlaySound("RecvMsgActive");
+ }
+ else {
+ CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg));
+ }
}
else {
if (GetForegroundWindow() == GetParent(hwnd))
@@ -119,6 +125,7 @@ INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *pwszInitialText)
hContact = db_mc_tryMeta(hContact);
HWND hwnd = Srmm_FindWindow(hContact);
+ HWND hwndContainer;
if (hwnd) {
if (pwszInitialText) {
SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, EM_SETSEL, -1, SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, WM_GETTEXTLENGTH, 0, 0));
@@ -126,9 +133,8 @@ INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *pwszInitialText)
mir_free(pwszInitialText);
}
+ hwndContainer = GetParent(hwnd);
if (!g_Settings.bTabsEnable) {
- HWND hwndContainer = GetParent(hwnd);
- ShowWindow(hwndContainer, SW_RESTORE);
SetWindowPos(hwndContainer, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
SetForegroundWindow(hwndContainer);
}
@@ -137,8 +143,9 @@ INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *pwszInitialText)
g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg));
}
}
- else GetContainer()->AddPage(hContact, pwszInitialText, false);
+ else hwndContainer = GetContainer()->AddPage(hContact, pwszInitialText, false)->GetHwnd();
+ ShowWindow(hwndContainer, SW_RESTORE);
return 0;
}
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 2255d06693..10f410c451 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -98,7 +98,7 @@ public:
return GetActiveWindow() == m_hwnd && GetForegroundWindow() == m_hwnd;
}
- CTabbedWindow *AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iActivate = -1);
+ CTabbedWindow *AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iNoActivate = -1);
CMsgDialog *CurrPage() const;
void AddPage(SESSION_INFO*, int insertAt = -1);
diff --git a/src/mir_core/src/Windows/CCtrlPages.cpp b/src/mir_core/src/Windows/CCtrlPages.cpp
index c449014821..11f78c1b21 100644
--- a/src/mir_core/src/Windows/CCtrlPages.cpp
+++ b/src/mir_core/src/Windows/CCtrlPages.cpp
@@ -152,20 +152,21 @@ void CCtrlPages::ActivatePage(int iPage)
if (info == nullptr || info->m_pDlg == nullptr)
return;
- if (m_pActivePage != nullptr)
- ShowWindow(m_pActivePage->GetHwnd(), SW_HIDE);
-
- m_pActivePage = info->m_pDlg;
- if (m_pActivePage->GetHwnd() && info->m_bScheduledResize) {
- RECT rc;
- GetClientRect(m_hwnd, &rc);
- TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
- SetWindowPos(m_pActivePage->GetHwnd(), nullptr, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOZORDER);
- }
+ if (info->m_pDlg != m_pActivePage) {
+ if (m_pActivePage != nullptr)
+ ShowWindow(m_pActivePage->GetHwnd(), SW_HIDE);
- TabCtrl_SetCurSel(m_hwnd, iPage);
- ShowPage(m_pActivePage);
+ m_pActivePage = info->m_pDlg;
+ if (m_pActivePage->GetHwnd() && info->m_bScheduledResize) {
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+ TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
+ SetWindowPos(m_pActivePage->GetHwnd(), nullptr, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+ TabCtrl_SetCurSel(m_hwnd, iPage);
+ ShowPage(m_pActivePage);
+ }
::SendMessage(m_pActivePage->GetHwnd(), WM_MOUSEACTIVATE, 0, 0);
}