summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_utils.h12
-rw-r--r--libs/win32/mir_app.libbin268168 -> 268504 bytes
-rw-r--r--libs/win64/mir_app.libbin267288 -> 267628 bytes
-rw-r--r--plugins/Scriver/src/msgs.cpp51
-rw-r--r--src/core/stdmsg/src/msgs.cpp119
-rw-r--r--src/mir_app/src/hotkeys.cpp20
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/skin.h3
9 files changed, 138 insertions, 69 deletions
diff --git a/include/m_utils.h b/include/m_utils.h
index 1050964d93..75f5d72f45 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -460,6 +460,18 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Utils_ReplaceVarsW(const wchar_t *szData, MCONTAC
#endif
/////////////////////////////////////////////////////////////////////////////////////////
+// delays execution of the required action
+
+struct MAsyncObject : public MNonCopyable
+{
+ virtual ~MAsyncObject() {}
+
+ virtual void Invoke() = 0;
+};
+
+MIR_APP_DLL(void) Utils_InvokeAsync(MAsyncObject *pObj);
+
+/////////////////////////////////////////////////////////////////////////////////////////
// compatibility functions
#ifndef _WINDOWS
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index fa6af1650c..40e13eaebb 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 23b88a96d5..71bfb54353 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index 62d97ef0fe..80dbe87ee0 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -79,6 +79,39 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct CAutoPpopup : public MAsyncObject
+{
+ MCONTACT hContact;
+ MEVENT hDbEvent;
+
+ CAutoPpopup(MCONTACT _1, MEVENT _2) :
+ hContact(_1),
+ hDbEvent(_2)
+ {}
+
+ void Invoke() override
+ {
+ /* does a window for the contact exist? */
+ HWND hwnd = Srmm_FindWindow(hContact);
+ if (hwnd == nullptr)
+ hwnd = Srmm_FindWindow(db_event_getContact(hDbEvent));
+
+ if (hwnd == nullptr) {
+ /* new message */
+ Skin_PlaySound("AlertMsg");
+ if (IsAutoPopup(hContact)) {
+ (new CMsgDialog(hContact, true))->Show();
+ return;
+ }
+ }
+
+ if (hwnd == nullptr || !IsWindowVisible(GetParent(hwnd)))
+ Srmm_AddEvent(hContact, hDbEvent);
+ }
+};
+
static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
{
if (hContact == 0 || Contact::IsGroupChat(hContact))
@@ -94,23 +127,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
if (dbei.flags & DBEF_SENT || !DbEventIsMessageOrCustom(dbei))
return 0;
- /* does a window for the contact exist? */
- HWND hwnd = Srmm_FindWindow(hContact);
- if (hwnd == nullptr)
- hwnd = Srmm_FindWindow(db_event_getContact(hDbEvent));
-
- if (hwnd == nullptr) {
- /* new message */
- Skin_PlaySound("AlertMsg");
- if (IsAutoPopup(hContact)) {
- (new CMsgDialog(hContact, true))->Show();
- return 0;
- }
- }
-
- if (hwnd == nullptr || !IsWindowVisible(GetParent(hwnd)))
- Srmm_AddEvent(hContact, hDbEvent);
-
+ Utils_InvokeAsync(new CAutoPpopup(hContact, hDbEvent));
return 0;
}
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index 0e9287aca7..e9c3b0df20 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -50,75 +50,94 @@ int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact)
return sendId;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int SRMMStatusToPf2(int status)
{
switch (status) {
- case ID_STATUS_ONLINE: return PF2_ONLINE;
- case ID_STATUS_AWAY: return PF2_SHORTAWAY;
- case ID_STATUS_DND: return PF2_HEAVYDND;
- case ID_STATUS_NA: return PF2_LONGAWAY;
- case ID_STATUS_OCCUPIED: return PF2_LIGHTDND;
- case ID_STATUS_FREECHAT: return PF2_FREECHAT;
- case ID_STATUS_INVISIBLE: return PF2_INVISIBLE;
- case ID_STATUS_OFFLINE: return MODEF_OFFLINE;
+ case ID_STATUS_ONLINE: return PF2_ONLINE;
+ case ID_STATUS_AWAY: return PF2_SHORTAWAY;
+ case ID_STATUS_DND: return PF2_HEAVYDND;
+ case ID_STATUS_NA: return PF2_LONGAWAY;
+ case ID_STATUS_OCCUPIED: return PF2_LIGHTDND;
+ case ID_STATUS_FREECHAT: return PF2_FREECHAT;
+ case ID_STATUS_INVISIBLE: return PF2_INVISIBLE;
+ case ID_STATUS_OFFLINE: return MODEF_OFFLINE;
}
return 0;
}
-static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
+struct CAutoPopup : public MAsyncObject
{
- if (hContact == 0 || Contact::IsGroupChat(hContact))
- return 0;
-
- DB::EventInfo dbei(hDbEvent, false);
- if (!dbei)
- return 0;
+ MCONTACT hContact;
+ MEVENT hDbEvent;
- if (dbei.markedRead() || !DbEventIsShown(dbei))
- return 0;
+ CAutoPopup(MCONTACT _1, MEVENT _2) :
+ hContact(_1),
+ hDbEvent(_2)
+ {}
- bool bPopup = false;
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto && (g_plugin.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto))))
- bPopup = true;
+ void Invoke() override
+ {
+ bool bPopup = false;
+ char *szProto = Proto_GetBaseAccountName(hContact);
+ if (szProto && (g_plugin.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto))))
+ bPopup = true;
+
+ /* does a window for the contact exist? */
+ CTabbedWindow *pContainer = nullptr;
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (!pDlg) {
+ if (bPopup) {
+ pDlg = GetContainer()->AddPage(hContact, nullptr, true);
+ pContainer = pDlg->getOwner();
+ }
- /* does a window for the contact exist? */
- CTabbedWindow *pContainer = nullptr;
- auto *pDlg = Srmm_FindDialog(hContact);
- if (!pDlg) {
- if (bPopup) {
- pDlg = GetContainer()->AddPage(hContact, nullptr, true);
+ Skin_PlaySound("AlertMsg");
+ Srmm_AddEvent(hContact, hDbEvent);
+ }
+ else {
pContainer = pDlg->getOwner();
+ if (bPopup)
+ ShowWindow(pContainer->GetHwnd(), SW_RESTORE);
+
+ if (pContainer->CurrPage() != pDlg)
+ Srmm_AddEvent(hContact, hDbEvent);
}
-
- Skin_PlaySound("AlertMsg");
- Srmm_AddEvent(hContact, hDbEvent);
- }
- else {
- pContainer = pDlg->getOwner();
- if (bPopup)
- ShowWindow(pContainer->GetHwnd(), SW_RESTORE);
- if (pContainer->CurrPage() != pDlg)
- Srmm_AddEvent(hContact, hDbEvent);
+ if (pContainer) {
+ if (bPopup && g_Settings.bTabsEnable && GetForegroundWindow() != pContainer->GetHwnd())
+ g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg));
+
+ if (!g_plugin.bDoNotStealFocus) {
+ SetForegroundWindow(pContainer->GetHwnd());
+ Skin_PlaySound("RecvMsgActive");
+ }
+ else {
+ if (GetForegroundWindow() == GetParent(pContainer->GetHwnd()))
+ Skin_PlaySound("RecvMsgActive");
+ else
+ Skin_PlaySound("RecvMsgInactive");
+ }
+ }
}
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
+{
+ if (hContact == 0 || Contact::IsGroupChat(hContact))
+ return 0;
- if (!pContainer)
+ DB::EventInfo dbei(hDbEvent, false);
+ if (!dbei)
return 0;
- if (bPopup && g_Settings.bTabsEnable && GetForegroundWindow() != pContainer->GetHwnd())
- g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg));
+ if (dbei.markedRead() || !DbEventIsShown(dbei))
+ return 0;
- if (!g_plugin.bDoNotStealFocus) {
- SetForegroundWindow(pContainer->GetHwnd());
- Skin_PlaySound("RecvMsgActive");
- }
- else {
- if (GetForegroundWindow() == GetParent(pContainer->GetHwnd()))
- Skin_PlaySound("RecvMsgActive");
- else
- Skin_PlaySound("RecvMsgInactive");
- }
+ Utils_InvokeAsync(new CAutoPopup(hContact, hDbEvent));
return 0;
}
diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp
index a60cf84fe8..49809e08b3 100644
--- a/src/mir_app/src/hotkeys.cpp
+++ b/src/mir_app/src/hotkeys.cpp
@@ -42,7 +42,7 @@ static int sttCompareHotkeys(const THotkeyItem *p1, const THotkeyItem *p2)
LIST<THotkeyItem> hotkeys(10, sttCompareHotkeys);
uint32_t g_pid = 0, g_hkid = 1;
-HWND g_hwndHotkeyHost = nullptr, g_hwndHkOptions = nullptr;
+HWND g_hwndHkOptions = nullptr;
HANDLE hEvChanged = nullptr;
static BOOL bModuleInitialized = FALSE;
@@ -67,6 +67,15 @@ static void sttWordToModAndVk(uint16_t w, uint8_t *mod, uint8_t *vk)
*vk = LOBYTE(w);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static HWND g_hwndHotkeyHost = nullptr;
+
+MIR_APP_DLL(void) Utils_InvokeAsync(MAsyncObject *pObj)
+{
+ PostMessageW(g_hwndHotkeyHost, WM_INVOKEASYNC, 0, LPARAM(pObj));
+}
+
static LRESULT CALLBACK sttHotkeyHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_HOTKEY && g_hwndHkOptions == nullptr) {
@@ -83,9 +92,18 @@ static LRESULT CALLBACK sttHotkeyHostWndProc(HWND hwnd, UINT msg, WPARAM wParam,
return FALSE;
}
+ if (msg == WM_INVOKEASYNC) {
+ if (auto *pObj = (MAsyncObject *)lParam) {
+ pObj->Invoke();
+ delete pObj;
+ }
+ }
+
return DefWindowProc(hwnd, msg, wParam, lParam);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code == HC_ACTION && !(HIWORD(lParam) & KF_UP) && g_hwndHkOptions == nullptr) {
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index b0cd5e4020..af5b8b0f9f 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -895,3 +895,4 @@ Clist_GroupSaveExpanded @1003 NONAME
??_7CSimpleLogWindow@@6B@ @1012 NONAME
?IsSuitableEvent@CSrmmBaseDialog@@QBE_NABULOGINFO@@@Z @1013 NONAME
?LogChatEvents@CSimpleLogWindow@@EAEXPBULOGINFO@@@Z @1014 NONAME
+?Utils_InvokeAsync@@YGXPAUMAsyncObject@@@Z @1015 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index c5cbd85268..70503f64f2 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -895,3 +895,4 @@ Clist_GroupSaveExpanded @1003 NONAME
??_7CSimpleLogWindow@@6B@ @1012 NONAME
?IsSuitableEvent@CSrmmBaseDialog@@QEBA_NAEBULOGINFO@@@Z @1013 NONAME
?LogChatEvents@CSimpleLogWindow@@EEAAXPEBULOGINFO@@@Z @1014 NONAME
+?Utils_InvokeAsync@@YAXPEAUMAsyncObject@@@Z @1015 NONAME
diff --git a/src/mir_app/src/skin.h b/src/mir_app/src/skin.h
index e6225825a8..8127bf0ccf 100644
--- a/src/mir_app/src/skin.h
+++ b/src/mir_app/src/skin.h
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DBMODULENAME "SkinHotKeys"
#define WM_HOTKEYUNREGISTERED (WM_USER+721)
+#define WM_INVOKEASYNC (WM_USER+722)
enum THotkeyType { HKT_GLOBAL, HKT_LOCAL, HKT_MANUAL };
@@ -65,7 +66,7 @@ struct THotkeyItem
};
extern LIST<THotkeyItem> hotkeys;
-extern HWND g_hwndHkOptions, g_hwndHotkeyHost;
+extern HWND g_hwndHkOptions;
extern uint32_t g_pid, g_hkid;
extern HANDLE hEvChanged;