diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-11 16:33:16 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-11 16:33:16 +0300 |
commit | 2b419ed6e80f65138a198f32a3ffe85bf39a5fcb (patch) | |
tree | dbae4aba940cebfffb67d79d9b27501f20476b98 | |
parent | 03445a3f1a04fcff892832b928308d37aeeea3cb (diff) |
GC_CLOSEWINDOW -> CloseTab()
-rw-r--r-- | include/m_chat_int.h | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 4 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 5 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_window.cpp | 94 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_options.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 31 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 7 | ||||
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 4 |
14 files changed, 92 insertions, 73 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 92055eec8b..1c31707f66 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -39,7 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GC_FAKE_EVENT MEVENT(0xBABABEDA)
-#define GC_CLOSEWINDOW (WM_USER+103)
#define GC_GETITEMDATA (WM_USER+104)
#define GC_SETITEMDATA (WM_USER+105)
#define GC_UPDATESTATUSBAR (WM_USER+106)
@@ -429,6 +428,7 @@ public: void ClearLog();
+ virtual void CloseTab(bool bForced = false) PURE;
virtual void UpdateTitle() PURE;
__forceinline bool isChat() const { return m_si != nullptr; }
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 4b1e6006db..740b4ff579 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -1670,10 +1670,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) DestroyMenu(hMenu);
}
break;
-
- case GC_CLOSEWINDOW:
- Close();
- break;
}
return CScriverWindow::DlgProc(uMsg, wParam, lParam);
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index fa0f0a6265..98908c14ee 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -366,6 +366,11 @@ CScriverWindow::CScriverWindow(int iDialog, SESSION_INFO *si) m_autoClose = CLOSE_ON_CANCEL;
}
+void CScriverWindow::CloseTab(bool)
+{
+ Close();
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// status icons processing
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 873fd5ab90..55a97e5a83 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -91,6 +91,8 @@ protected: CScriverWindow(int iDialog, SESSION_INFO* = nullptr);
public:
+ virtual void CloseTab(bool bForced = false) override;
+
ParentWindowData *m_pParent;
int m_minLogBoxHeight, m_minEditBoxHeight;
HWND m_hwndIeview;
@@ -148,6 +150,7 @@ public: virtual void OnInitDialog() override;
virtual void OnDestroy() override;
+
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -190,6 +193,7 @@ public: virtual void OnDestroy() override;
virtual INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
+
virtual void UpdateTitle() override;
void onChange_Message(CCtrlEdit*);
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 219613964d..d688d2ca85 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -595,7 +595,7 @@ LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM w bool isShift, isAlt, isCtrl; mwdat->KbdState(isShift, isCtrl, isAlt); - if (PluginConfig.m_bSoundOnTyping && !isAlt &&!isCtrl&&!(mwdat->m_pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE&&!(wParam == VK_TAB && PluginConfig.m_bAllowTab)) + if (PluginConfig.m_bSoundOnTyping && !isAlt && !isCtrl && !(mwdat->m_pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE && !(wParam == VK_TAB && PluginConfig.m_bAllowTab)) SkinPlaySound("SoundOnTyping"); if (isCtrl && !isAlt && !isShift) { @@ -1950,6 +1950,50 @@ void CChatRoomDlg::onDblClick_List(CCtrlListBox*) ///////////////////////////////////////////////////////////////////////////////////////// +void CChatRoomDlg::CloseTab(bool bForced) +{ + int iTabs = TabCtrl_GetItemCount(m_hwndParent); + if (iTabs == 1 && CMimAPI::m_shutDown == 0) { + SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1); + return; + } + + m_pContainer->iChilds--; + int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd); + + // after closing a tab, we need to activate the tab to the left side of + // the previously open tab. + // normally, this tab has the same index after the deletion of the formerly active tab + // unless, of course, we closed the last (rightmost) tab. + if (!m_pContainer->bDontSmartClose && iTabs > 1 && !bForced) { + if (i == iTabs - 1) + i--; + else + i++; + TabCtrl_SetCurSel(m_hwndParent, i); + + TCITEM item = {}; + item.mask = TCIF_PARAM; + TabCtrl_GetItem(m_hwndParent, i, &item); // retrieve dialog hwnd for the now active tab... + m_pContainer->hwndActive = (HWND)item.lParam; + + RECT rc; + SendMessage(m_pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); + SetWindowPos(m_pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW); + ShowWindow((HWND)item.lParam, SW_SHOW); + SetForegroundWindow(m_pContainer->hwndActive); + SetFocus(m_pContainer->hwndActive); + SendMessage(m_pContainer->hwnd, WM_SIZE, 0, 0); + } + + if (iTabs == 1) + SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1); + else { + PostMessage(m_pContainer->hwnd, WM_SIZE, 0, 0); + DestroyWindow(m_hwnd); + } +} + void CChatRoomDlg::UpdateTitle() { m_wStatus = m_si->wStatus; @@ -2915,53 +2959,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } _dlgReturn(m_hwnd, TRUE); } - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 1); - return 0; - - case GC_CLOSEWINDOW: - { - bool bForced = (lParam == 2); - - int iTabs = TabCtrl_GetItemCount(m_hwndParent); - if (iTabs == 1 && CMimAPI::m_shutDown == 0) { - SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1); - return 1; - } - - m_pContainer->iChilds--; - int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd); - - // after closing a tab, we need to activate the tab to the left side of - // the previously open tab. - // normally, this tab has the same index after the deletion of the formerly active tab - // unless, of course, we closed the last (rightmost) tab. - if (!m_pContainer->bDontSmartClose && iTabs > 1 && !bForced) { - if (i == iTabs - 1) - i--; - else - i++; - TabCtrl_SetCurSel(m_hwndParent, i); - - TCITEM item = {}; - item.mask = TCIF_PARAM; - TabCtrl_GetItem(m_hwndParent, i, &item); // retrieve dialog hwnd for the now active tab... - m_pContainer->hwndActive = (HWND)item.lParam; - - SendMessage(m_pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); - SetWindowPos(m_pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW); - ShowWindow((HWND)item.lParam, SW_SHOW); - SetForegroundWindow(m_pContainer->hwndActive); - SetFocus(m_pContainer->hwndActive); - SendMessage(m_pContainer->hwnd, WM_SIZE, 0, 0); - } - - if (iTabs == 1) - SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1); - else { - PostMessage(m_pContainer->hwnd, WM_SIZE, 0, 0); - DestroyWindow(m_hwnd); - } - } + CloseTab(true); return 0; case DM_SAVESIZE: diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index a2777ce4aa..7dc383a505 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -455,6 +455,8 @@ public: virtual void OnDestroy() override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void CloseTab(bool) override {};
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -496,6 +498,8 @@ public: virtual void OnDestroy() override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void CloseTab(bool bForced = false) override;
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index 9a29883a9d..13b6d7f0af 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -430,7 +430,7 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM g_Settings.bLogIndentEnabled = db_get_b(NULL, CHAT_MODULE, "LogIndentEnabled", 1) != 0; if (b != db_get_b(NULL, CHAT_MODULE, "Tabs", 1)) { - pci->SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE); + pci->SM_BroadcastMessage(NULL, WM_CLOSE, 0, 1, FALSE); g_Settings.bTabsEnable = db_get_b(NULL, CHAT_MODULE, "Tabs", 1) != 0; } else pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 587084f34c..7a5ba87fde 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -270,12 +270,12 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } if (wParam == VK_F4 && isCtrl && !isAlt) { // ctrl-F4 (close tab) - SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0); + pDlg->CloseTab(); return TRUE; } if (wParam == VK_ESCAPE && !isCtrl && !isAlt) { // Esc (close tab) - SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0); + pDlg->CloseTab(); return TRUE; } @@ -352,7 +352,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } if (wParam == 0x57 && isCtrl && !isAlt) { // ctrl-w (close window) - SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0); + pDlg->CloseTab(); return TRUE; } @@ -652,6 +652,9 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR { CHARRANGE sel; + HWND hwndDlg = GetParent(hwnd); + CChatRoomDlg *pDlg = (CChatRoomDlg*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + switch (msg) { case WM_LBUTTONUP: SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); @@ -665,7 +668,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_KEYDOWN: if (wParam == 0x57 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w (close window) - PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0); + pDlg->CloseTab(); return TRUE; } break; @@ -721,7 +724,7 @@ LRESULT CALLBACK CChatRoomDlg::NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM case WM_KEYDOWN: if (wParam == 0x57 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w (close window) - PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0); + si->pDlg->CloseTab(); return TRUE; } break; @@ -881,6 +884,7 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) : void CChatRoomDlg::OnInitDialog() { m_si->pDlg = this; + SetWindowLongPtr(m_hwnd, GWLP_USERDATA, LPARAM(this)); if (g_Settings.bTabsEnable) SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW); @@ -892,12 +896,14 @@ void CChatRoomDlg::OnInitDialog() NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING); - mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc); mir_subclassWindow(m_btnFilter.GetHwnd(), ButtonSubclassProc); mir_subclassWindow(m_btnColor.GetHwnd(), ButtonSubclassProc); mir_subclassWindow(m_btnBkColor.GetHwnd(), ButtonSubclassProc); mir_subclassWindow(m_message.GetHwnd(), MessageSubclassProc); + SetWindowLongPtr(m_log.GetHwnd(), GWLP_USERDATA, LPARAM(this)); + mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc); + SetWindowLongPtr(m_nickList.GetHwnd(), GWLP_USERDATA, LPARAM(m_si)); mir_subclassWindow(m_nickList.GetHwnd(), NicklistSubclassProc); @@ -1207,6 +1213,13 @@ void CChatRoomDlg::SaveWindowPosition(bool bUpdateSession) } } +void CChatRoomDlg::CloseTab(bool) +{ + if (g_Settings.bTabsEnable) + SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this); + Close(); +} + void CChatRoomDlg::UpdateTitle() { wchar_t szTemp[100]; @@ -1494,12 +1507,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) UpdateTitle(); break; - case GC_CLOSEWINDOW: - if (g_Settings.bTabsEnable) - SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this); - Close(); - return 0; - case GC_CHANGEFILTERFLAG: m_iLogFilterFlags = lParam; break; diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 83765176ef..60c2ef2d8f 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -98,6 +98,8 @@ public: virtual void OnDestroy() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+
+ virtual void CloseTab(bool) override {}
virtual void UpdateTitle() override {}
void OnSplitterMoved(CSplitter*);
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 897a1bb93e..758dd5a612 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -204,6 +204,8 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void CloseTab(bool bForced = false) override;
virtual void UpdateTitle() override;
void OnClick_Bold(CCtrlButton*);
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index bcb691f467..40357f92eb 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -147,8 +147,11 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR ScreenToClient(hwnd, &tci.pt); int i = TabCtrl_HitTest(hwnd, &tci); - if (i != -1 && g_Settings.bTabCloseOnDblClick) - PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0); + if (i != -1 && g_Settings.bTabCloseOnDblClick) { + CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)pOwner->m_tab.GetActivePage(); + if (pDlg) + pDlg->CloseTab(); + } } break; diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index c197c92f33..43b6c7791a 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -118,7 +118,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) if (si) {
// is the "toggle visibility option set, so we need to close the window?
if (si->pDlg != nullptr && db_get_b(0, CHAT_MODULE, "ToggleVisibility", 0) == 1 && !cli.pfnGetEvent(hContact, 0) && IsWindowVisible(si->pDlg->GetHwnd()) && !IsIconic(si->pDlg->GetHwnd())) {
- PostMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 0);
+ si->pDlg->CloseTab();
return 1;
}
chatApi.ShowRoom(si);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index b3ffd8fe09..d8cfe40999 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -73,7 +73,7 @@ static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false) db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 1);
+ si->pDlg->CloseTab(true);
DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 2becb12910..d7ac64cd01 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -102,8 +102,6 @@ static int IconsChanged(WPARAM, LPARAM) static int PreShutdown(WPARAM, LPARAM)
{
if (g_Settings != nullptr) {
- chatApi.SM_BroadcastMessage(nullptr, GC_CLOSEWINDOW, 0, 1, FALSE);
-
SM_RemoveAll();
chatApi.MM_RemoveAll();
@@ -284,7 +282,7 @@ static INT_PTR __stdcall stubRoomControl(void *param) SetInitDone(si);
chatApi.SetActiveSession(si);
if (si->pDlg)
- ::SendMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 0);
+ si->pDlg->CloseTab();
break;
case WINDOW_VISIBLE:
|