summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_chat_int.h2
-rw-r--r--include/m_srmm_int.h1
-rw-r--r--plugins/Scriver/src/tabs.cpp2
-rw-r--r--plugins/TabSRMM/src/chat_tools.cpp4
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp2
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp29
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp4
-rw-r--r--plugins/TabSRMM/src/msgs.h3
-rw-r--r--plugins/TabSRMM/src/sendqueue.h1
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp110
-rw-r--r--src/core/stdmsg/src/msgs.h3
-rw-r--r--src/mir_app/src/chat_tools.cpp2
-rw-r--r--src/mir_app/src/srmm_base.cpp3
13 files changed, 90 insertions, 76 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 664d5d477d..4d7846d4a7 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -45,8 +45,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GC_FAKE_EVENT MEVENT(0xBABABEDA)
-#define TIMERID_FLASHWND 1
-
#define GCW_TABROOM 10
#define GCW_TABPRIVMSG 11
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h
index 28b67984b4..952c1ad035 100644
--- a/include/m_srmm_int.h
+++ b/include/m_srmm_int.h
@@ -230,6 +230,7 @@ public:
bool m_bFGSet, m_bBGSet;
bool m_bInMenu;
COLORREF m_iFG, m_iBG;
+ CTimer timerFlash, timerType;
void ClearLog();
void RedrawLog();
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp
index e024f1d50f..e50c07cff4 100644
--- a/plugins/Scriver/src/tabs.cpp
+++ b/plugins/Scriver/src/tabs.cpp
@@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
+#define TIMERID_FLASHWND 1
+
#define SB_CHAR_WIDTH 40
#define SB_SENDING_WIDTH 25
#define SB_UNICODE_WIDTH 18
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp
index 1e3043a4a4..451d73387c 100644
--- a/plugins/TabSRMM/src/chat_tools.cpp
+++ b/plugins/TabSRMM/src/chat_tools.cpp
@@ -43,7 +43,7 @@ static void __stdcall Chat_DismissPopup(void *pi)
if (g_clistApi.pfnGetEvent(si->hContact, 0))
g_clistApi.pfnRemoveEvent(si->hContact, GC_FAKE_EVENT);
- if (si->pDlg && KillTimer(si->pDlg->GetHwnd(), TIMERID_FLASHWND))
+ if (si->pDlg && si->pDlg->timerFlash.Stop())
FlashWindow(si->pDlg->GetHwnd(), FALSE);
}
@@ -233,7 +233,7 @@ void DoFlashAndSoundWorker(FLASH_PARAMS *p)
dat->m_iFlashIcon = p->hNotifyIcon;
}
dat->m_bCanFlashTab = TRUE;
- SetTimer(si->pDlg->GetHwnd(), TIMERID_FLASHWND, TIMEOUT_FLASHWND, nullptr);
+ si->pDlg->timerFlash.Start(TIMEOUT_FLASHWND);
}
}
if (dat->m_pWnd) {
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 6614834eaf..8b9570c3bb 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -1104,7 +1104,7 @@ void CMsgDialog::DM_EventAdded(WPARAM hContact, LPARAM lParam)
m_iFlashIcon = PluginConfig.g_IconMsgEvent;
break;
}
- SetTimer(m_hwnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, nullptr);
+ timerFlash.Start(TIMEOUT_FLASHWND);
m_bCanFlashTab = true;
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 16ca4dfc45..7a2f921952 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -355,6 +355,9 @@ void CMsgDialog::Init()
m_btnOk.OnClick = Callback(this, &CMsgDialog::onClick_Ok);
m_message.OnChange = Callback(this, &CMsgDialog::onChange_Message);
+
+ timerFlash.OnEvent = Callback(this, &CMsgDialog::onFlash);
+ timerType.OnEvent = Callback(this, &CMsgDialog::onType);
}
CMsgDialog::~CMsgDialog()
@@ -474,7 +477,7 @@ bool CMsgDialog::OnInitDialog()
m_iMultiSplit = g_plugin.getDword("multisplit", 150);
if (m_si == nullptr || m_si->iType == GCW_PRIVMESS) {
m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
- SetTimer(m_hwnd, TIMERID_TYPE, 1000, nullptr);
+ timerType.Start(1000);
}
m_iLastEventType = 0xffffffff;
@@ -618,7 +621,7 @@ bool CMsgDialog::OnInitDialog()
if (m_pContainer->m_flags.m_bCreateMinimized || !m_bActivate || m_pContainer->m_flags.m_bDeferredTabSelect) {
m_iFlashIcon = PluginConfig.g_IconMsgEvent;
- SetTimer(m_hwnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, nullptr);
+ timerFlash.Start(TIMEOUT_FLASHWND);
m_bCanFlashTab = true;
DBEVENTINFO dbei = {};
@@ -1077,6 +1080,18 @@ void CMsgDialog::onChange_Message(CCtrlEdit*)
}
}
+void CMsgDialog::onType(CTimer *)
+{
+ if (m_si == nullptr || m_si->iType == GCW_PRIVMESS)
+ DM_Typing(false);
+}
+
+void CMsgDialog::onFlash(CTimer *)
+{
+ if (m_bCanFlashTab)
+ FlashTab(true);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// resizer proc for the "new" layout.
@@ -2740,16 +2755,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
}
- else if (wParam == TIMERID_FLASHWND) {
- if (m_bCanFlashTab)
- FlashTab(true);
- break;
- }
- else if (wParam == TIMERID_TYPE) {
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS)
- DM_Typing(false);
- break;
- }
break;
case DM_QUERYLASTUNREAD:
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 757a77e74f..fd147b364a 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -2281,7 +2281,7 @@ void CMsgDialog::UpdateWindowState(UINT msg)
UpdateTitle();
m_hTabIcon = m_hTabStatusIcon;
- if (KillTimer(m_hwnd, TIMERID_FLASHWND) || m_iFlashIcon) {
+ if (timerFlash.Stop() || m_iFlashIcon) {
FlashTab(false);
m_bCanFlashTab = FALSE;
m_iFlashIcon = nullptr;
@@ -2298,7 +2298,7 @@ void CMsgDialog::UpdateWindowState(UINT msg)
m_pContainer->m_pMenuBar->configureMenu();
}
else {
- if (KillTimer(m_hwnd, TIMERID_FLASHWND)) {
+ if (timerFlash.Stop()) {
FlashTab(false);
m_bCanFlashTab = false;
}
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 519d1b0e10..5d25322ab6 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -538,6 +538,9 @@ public:
void onClick_CancelAdd(CCtrlButton *);
void onClick_ShowNickList(CCtrlButton *);
+ void onType(CTimer *);
+ void onFlash(CTimer *);
+
void onChange_Message(CCtrlEdit *);
void onDblClick_List(CCtrlListBox *);
diff --git a/plugins/TabSRMM/src/sendqueue.h b/plugins/TabSRMM/src/sendqueue.h
index beaf4acef7..bf73526477 100644
--- a/plugins/TabSRMM/src/sendqueue.h
+++ b/plugins/TabSRMM/src/sendqueue.h
@@ -28,7 +28,6 @@
#define __SENDQUEUE_H
#define TIMERID_MSGSEND 100
-#define TIMERID_TYPE 3
#define TIMERID_AWAYMSG 4
//#define TIMERID_TOOLTIP 5
#define TIMEOUT_TYPEOFF 10000 // send type off after 10 seconds of inactivity
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index b5d16c8452..1420a6d08c 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -22,8 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "statusicon.h"
-#define TIMERID_FLASHWND 1
-#define TIMERID_TYPE 2
#define TIMEOUT_FLASHWND 900
#define TIMEOUT_TYPEOFF 10000 //send type off after 10 seconds of inactivity
#define SB_CHAR_WIDTH 45
@@ -88,6 +86,9 @@ void CMsgDialog::Init()
m_message.OnChange = Callback(this, &CMsgDialog::onChange_Text);
m_splitterY.OnChange = Callback(this, &CMsgDialog::onSplitterY);
+
+ timerFlash.OnEvent = Callback(this, &CMsgDialog::OnFlash);
+ timerType.OnEvent = Callback(this, &CMsgDialog::OnType);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -124,7 +125,7 @@ bool CMsgDialog::OnInitDialog()
m_wOldStatus = m_wStatus;
m_cmdListInd = -1;
m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
- SetTimer(m_hwnd, TIMERID_TYPE, 1000, nullptr);
+ timerType.Start(1000);
GetWindowRect(m_message.GetHwnd(), &m_minEditInit);
m_iSplitterY = g_plugin.getDword(g_dat.bSavePerContact ? m_hContact : 0, "splitterPos", m_minEditInit.bottom - m_minEditInit.top);
@@ -259,7 +260,7 @@ void CMsgDialog::OnDestroy()
else
db_unset(m_hContact, SRMSGMOD, DBSAVEDMSG);
}
- KillTimer(m_hwnd, TIMERID_TYPE);
+
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
@@ -422,6 +423,54 @@ void CMsgDialog::onChange_Text(CCtrlEdit*)
}
}
+void CMsgDialog::OnFlash(CTimer *)
+{
+ FixTabIcons();
+ if (!g_dat.nFlashMax || m_nFlash < 2 * g_dat.nFlashMax)
+ FlashWindow(m_pOwner->GetHwnd(), TRUE);
+ m_nFlash++;
+}
+
+void CMsgDialog::OnType(CTimer*)
+{
+ ShowTime(false);
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - m_nLastTyping > TIMEOUT_TYPEOFF)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
+
+ if (m_bShowTyping) {
+ if (m_nTypeSecs) {
+ m_nTypeSecs--;
+ if (GetForegroundWindow() == m_pOwner->GetHwnd())
+ FixTabIcons();
+ }
+ else {
+ UpdateLastMessage();
+ if (g_dat.bShowTypingWin)
+ FixTabIcons();
+ m_bShowTyping = false;
+ }
+ }
+ else {
+ if (m_nTypeSecs) {
+ wchar_t szBuf[256];
+ wchar_t *szContactName = Clist_GetContactDisplayName(m_hContact);
+ HICON hTyping = Skin_LoadIcon(SKINICON_OTHER_TYPING);
+
+ mir_snwprintf(szBuf, TranslateT("%s is typing a message..."), szContactName);
+ m_nTypeSecs--;
+
+ SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf);
+ SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hTyping);
+ if (g_dat.bShowTypingWin && GetForegroundWindow() != m_pOwner->GetHwnd()) {
+ HICON hIcon = (HICON)SendMessage(m_hwnd, WM_GETICON, ICON_SMALL, 0);
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hTyping);
+ IcoLib_ReleaseIcon(hIcon);
+ }
+ m_bShowTyping = true;
+ }
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
int CMsgDialog::Resizer(UTILRESIZECONTROL *urc)
@@ -658,55 +707,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
RemakeLog();
break;
- case WM_TIMER:
- if (wParam == TIMERID_FLASHWND) {
- FixTabIcons();
- if (!g_dat.nFlashMax || m_nFlash < 2 * g_dat.nFlashMax)
- FlashWindow(m_pOwner->GetHwnd(), TRUE);
- m_nFlash++;
- break;
- }
-
- if (wParam == TIMERID_TYPE) {
- ShowTime(false);
- if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - m_nLastTyping > TIMEOUT_TYPEOFF)
- NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
-
- if (m_bShowTyping) {
- if (m_nTypeSecs) {
- m_nTypeSecs--;
- if (GetForegroundWindow() == m_pOwner->GetHwnd())
- FixTabIcons();
- }
- else {
- UpdateLastMessage();
- if (g_dat.bShowTypingWin)
- FixTabIcons();
- m_bShowTyping = false;
- }
- }
- else {
- if (m_nTypeSecs) {
- wchar_t szBuf[256];
- wchar_t *szContactName = Clist_GetContactDisplayName(m_hContact);
- HICON hTyping = Skin_LoadIcon(SKINICON_OTHER_TYPING);
-
- mir_snwprintf(szBuf, TranslateT("%s is typing a message..."), szContactName);
- m_nTypeSecs--;
-
- SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf);
- SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hTyping);
- if (g_dat.bShowTypingWin && GetForegroundWindow() != m_pOwner->GetHwnd()) {
- HICON hIcon = (HICON)SendMessage(m_hwnd, WM_GETICON, ICON_SMALL, 0);
- SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hTyping);
- IcoLib_ReleaseIcon(hIcon);
- }
- m_bShowTyping = true;
- }
- }
- }
- break;
-
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
@@ -1243,12 +1243,12 @@ bool CMsgDialog::IsActive() const
void CMsgDialog::StartFlash()
{
- ::SetTimer(m_hwnd, TIMERID_FLASHWND, 900, nullptr);
+ timerFlash.Start(1000);
}
void CMsgDialog::StopFlash()
{
- if (::KillTimer(m_hwnd, TIMERID_FLASHWND)) {
+ if (timerFlash.Stop()) {
::FlashWindow(m_pOwner->GetHwnd(), FALSE);
m_nFlash = 0;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 8665599e8e..5e40abf37a 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -68,6 +68,9 @@ class CMsgDialog : public CSrmmBaseDialog
CCtrlBase m_avatar;
CCtrlButton m_btnOk;
+
+ void OnFlash(CTimer *);
+ void OnType(CTimer *);
CTabbedWindow *m_pOwner;
DWORD m_nFlash = 0;
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 682c176aeb..d3069cc44c 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -231,7 +231,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
if (g_clistApi.pfnGetEvent(si->hContact, 0))
g_clistApi.pfnRemoveEvent(si->hContact, GC_FAKE_EVENT);
- if (si->pDlg && KillTimer(si->pDlg->GetHwnd(), TIMERID_FLASHWND))
+ if (si->pDlg && si->pDlg->timerFlash.Stop())
FlashWindow(si->pDlg->GetHwnd(), FALSE);
PUDeletePopup(hWnd);
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 86ca47ce4e..62a4fcb4c2 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -30,6 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
CSrmmBaseDialog::CSrmmBaseDialog(CMPluginBase &pPlugin, int idDialog, SESSION_INFO *si) :
CDlgBase(pPlugin, idDialog),
+ timerFlash(this, 1),
+ timerType(this, 2),
+
m_message(this, IDC_SRMM_MESSAGE),
m_nickList(this, IDC_SRMM_NICKLIST),