summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/StatusManager/src/ks_main.cpp22
-rw-r--r--plugins/StatusManager/src/ss_main.cpp17
2 files changed, 14 insertions, 25 deletions
diff --git a/plugins/StatusManager/src/ks_main.cpp b/plugins/StatusManager/src/ks_main.cpp
index 561af26ac2..1abd2aa1ba 100644
--- a/plugins/StatusManager/src/ks_main.cpp
+++ b/plugins/StatusManager/src/ks_main.cpp
@@ -31,8 +31,6 @@ static HANDLE hStatusChangeHook = nullptr;
static HANDLE hCSStatusChangeHook = nullptr;
static HANDLE hCSStatusChangeExHook = nullptr;
-static HWND hMessageWindow = nullptr;
-
static UINT_PTR checkConnectionTimerId = 0;
static UINT_PTR afterCheckTimerId = 0;
static UINT_PTR processAckTimerId = 0;
@@ -65,7 +63,7 @@ INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam);
static int ProcessPopup(int reason, LPARAM lParam);
LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-static uint32_t CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+static LRESULT CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
// options.c
extern int KeepStatusOptionsInit(WPARAM wparam, LPARAM);
@@ -80,8 +78,7 @@ void KSUnloadOptions()
UnhookEvent(hCSStatusChangeExHook);
hProtoAckHook = hStatusChangeHook = hCSStatusChangeHook = hCSStatusChangeExHook = nullptr;
- if (IsWindow(hMessageWindow))
- DestroyWindow(hMessageWindow);
+ mir_unsubclassWindow(Miranda_GetSystemWindow()->GetHwnd(), MessageWndProc);
if (StartTimer(IDT_CHECKCONTIN, -1, FALSE))
WSACleanup();
@@ -112,12 +109,8 @@ int KSLoadOptions()
if (ServiceExists(ME_CS_STATUSCHANGE))
hCSStatusChangeHook = HookEvent(ME_CS_STATUSCHANGE, CSStatusChange);
hCSStatusChangeExHook = HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChangeEx);
- if (KSPlugin.getByte(SETTING_CHECKAPMRESUME, 0)) {
- if (!IsWindow(hMessageWindow)) {
- hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);
- SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc);
- }
- }
+ if (KSPlugin.getByte(SETTING_CHECKAPMRESUME, 0))
+ mir_subclassWindow(Miranda_GetSystemWindow()->GetHwnd(), MessageWndProc);
retryCount = 0;
}
@@ -996,7 +989,7 @@ INT_PTR AnnounceStatusChangeService(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// window for suspend
-static uint32_t CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static TProtoSettings *ps = nullptr;
@@ -1004,7 +997,7 @@ static uint32_t CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lP
case WM_POWERBROADCAST:
switch (wParam) {
case PBT_APMSUSPEND:
- log_info(0, "KeepStatus: suspend state detected: %08X %08X", wParam, lParam);
+ log_info(0, "KeepStatus: suspend state detected");
if (ps == nullptr) {
ps = new TProtoSettings(protoList);
for (auto &it : *ps)
@@ -1041,7 +1034,7 @@ static uint32_t CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lP
break;
}
- return TRUE;
+ return mir_callNextSubclass(hwnd, MessageWndProc, msg, wParam, lParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1057,7 +1050,6 @@ static int onShutdown(WPARAM, LPARAM)
int KSModuleLoaded(WPARAM, LPARAM)
{
- hMessageWindow = nullptr;
KSLoadOptions();
hEvents[0] = HookEvent(ME_OPT_INITIALISE, KeepStatusOptionsInit);
diff --git a/plugins/StatusManager/src/ss_main.cpp b/plugins/StatusManager/src/ss_main.cpp
index 1b5ba8e0c1..8820699781 100644
--- a/plugins/StatusManager/src/ss_main.cpp
+++ b/plugins/StatusManager/src/ss_main.cpp
@@ -23,13 +23,12 @@ CFakePlugin SSPlugin(SSMODULENAME);
static HANDLE hServices[3], hEvents[3];
static UINT_PTR setStatusTimerId = 0;
+static LRESULT CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
/////////////////////////////////////////////////////////////////////////////////////////
static HANDLE hProtoAckHook, hCSStatusChangeHook, hStatusChangeHook;
-static HWND hMessageWindow;
-
static uint8_t showDialogOnStartup = 0;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -308,8 +307,7 @@ static int OnShutdown(WPARAM, LPARAM)
if (SSPlugin.getByte(SETTING_SETWINSTATE, 0))
db_set_b(0, MODULE_CLIST, SETTING_WINSTATE, (uint8_t)state);
- if (hMessageWindow)
- DestroyWindow(hMessageWindow);
+ mir_unsubclassWindow(Miranda_GetSystemWindow()->GetHwnd(), MessageWndProc);
ShutdownConfirmDialog();
protoList.destroy();
@@ -317,11 +315,11 @@ static int OnShutdown(WPARAM, LPARAM)
}
/* Window proc for poweroff event */
-static uint32_t CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM)
+static LRESULT CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_ENDSESSION:
- log_debug(0, "WM_ENDSESSION");
+ log_debug(0, "WM_ENDSESSION: %d", (int)wParam);
if (wParam) {
log_debug(0, "WM_ENDSESSION: calling exit");
OnShutdown(0, 0);
@@ -330,7 +328,7 @@ static uint32_t CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM)
break;
}
- return TRUE;
+ return mir_callNextSubclass(hwnd, MessageWndProc, msg, wParam, lParam);
}
int SSModuleLoaded(WPARAM, LPARAM)
@@ -342,9 +340,8 @@ int SSModuleLoaded(WPARAM, LPARAM)
/* shutdown hook for normal shutdown */
hEvents[1] = HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit);
hEvents[2] = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
- /* message window for poweroff */
- hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);
- SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc);
+
+ mir_subclassWindow(Miranda_GetSystemWindow()->GetHwnd(), MessageWndProc);
GetProfile(-1, protoList);