diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-21 19:43:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-21 19:43:22 +0300 |
commit | 49600428c7c70b765432d0d6beb6f3a53f95692d (patch) | |
tree | 886bffe188eeecdca1135361a9027dafe7227496 /src | |
parent | 4d993e1eaaca9cfa1c860aadb75caf8a9df5860d (diff) |
StdMsg: advanced way of updating window's icon/title
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 16 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 18 |
4 files changed, 27 insertions, 13 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index d98eaac7ea..e65ea3f177 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -662,10 +662,12 @@ void CSrmmWindow::UpdateTitle() }
else mir_wstrncpy(newtitle, TranslateT("Message session"), _countof(newtitle));
- wchar_t oldtitle[256];
- GetWindowText(m_pOwner->GetHwnd(), oldtitle, _countof(oldtitle));
- if (mir_wstrcmp(newtitle, oldtitle)) //swt() flickers even if the title hasn't actually changed
- SetWindowText(m_pOwner->GetHwnd(), newtitle);
+ if (this == m_pOwner->CurrPage()) {
+ wchar_t oldtitle[256];
+ GetWindowText(m_pOwner->GetHwnd(), oldtitle, _countof(oldtitle));
+ if (mir_wstrcmp(newtitle, oldtitle)) //swt() flickers even if the title hasn't actually changed
+ SetWindowText(m_pOwner->GetHwnd(), newtitle);
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1389,6 +1391,12 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break;
case DM_UPDATETITLE:
+ if (lParam != 0) {
+ bool bIsMe = (lParam == m_hContact) || (m_bIsMeta && db_mc_getMeta(lParam) == m_hContact);
+ if (!bIsMe)
+ break;
+ }
+
UpdateIcon(wParam);
UpdateTitle();
break;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 36ef8201bb..a3babb94d7 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -225,14 +225,14 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
if (!strcmp(cws->szModule, "CList"))
- Srmm_Broadcast(DM_UPDATETITLE, (WPARAM)cws, 0);
+ Srmm_Broadcast(DM_UPDATETITLE, (WPARAM)cws, hContact);
else if (hContact) {
if (cws->szSetting && !strcmp(cws->szSetting, "Timezone"))
Srmm_Broadcast(DM_NEWTIMEZONE, (WPARAM)cws, 0);
else {
char *szProto = GetContactProto(hContact);
if (szProto && !strcmp(cws->szModule, szProto))
- Srmm_Broadcast(DM_UPDATETITLE, (WPARAM)cws, 0);
+ Srmm_Broadcast(DM_UPDATETITLE, (WPARAM)cws, hContact);
}
}
return 0;
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 6f1875347d..d0f0f8ae3f 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -159,6 +159,8 @@ public: CTabbedWindow();
CTabbedWindow* AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iActivate = -1);
+ CMsgDialog* CurrPage() const;
+
void AddPage(SESSION_INFO*, int insertAt = -1);
void FixTabIcons(CMsgDialog*);
void SetMessageHighlight(CChatRoomDlg*);
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index a1d28f215a..b7cfae1650 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -279,6 +279,11 @@ void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt) m_tab.ActivatePage(indexfound); } +CMsgDialog* CTabbedWindow::CurrPage() const +{ + return (m_pEmbed != nullptr) ? m_pEmbed : (CMsgDialog*)m_tab.GetActivePage(); +} + void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) { if (pDlg == nullptr) @@ -287,7 +292,7 @@ void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) int image = pDlg->GetImageId(); // if tabs are turned off, simply change the window's icon, otherwise set the tab's icon first - if (pDlg != m_pEmbed) { + if (m_pEmbed == nullptr) { int idx = m_tab.GetDlgIndex(pDlg); if (idx == -1) return; @@ -299,14 +304,13 @@ void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) tci.iImage = image; TabCtrl_SetItem(m_tab.GetHwnd(), idx, &tci); } - - // set the container's icon only if we're processing the current page - if (pDlg != m_tab.GetActivePage()) - return; } - Window_FreeIcon_IcoLib(m_hwnd); - Window_SetProtoIcon_IcoLib(m_hwnd, pDlg->GetProto(), pDlg->GetStatus()); + // set the container's icon only if we're processing the current page + if (pDlg == CurrPage()) { + Window_FreeIcon_IcoLib(m_hwnd); + Window_SetProtoIcon_IcoLib(m_hwnd, pDlg->GetProto(), pDlg->GetStatus()); + } } void CTabbedWindow::SaveWindowPosition(bool bUpdateSession) |