From c9c2324e4f13e66c75d886f94dbacac1e28b191f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 May 2025 17:25:26 +0300 Subject: fixes #5009 ("Pin to desktop" option doesn't work in all modern Windows) --- plugins/Clist_modern/src/cluiframes.cpp | 35 +-- plugins/Clist_modern/src/init.cpp | 1 - plugins/Clist_modern/src/modern_clcopts.cpp | 28 +- plugins/Clist_modern/src/modern_clistmod.cpp | 23 +- plugins/Clist_modern/src/modern_clui.cpp | 58 +--- plugins/Clist_modern/src/modern_commonprototypes.h | 3 +- plugins/Clist_modern/src/modern_defsettings.h | 1 - plugins/Clist_modern/src/modern_docking.cpp | 337 --------------------- plugins/Clist_modern/src/modern_global_structure.h | 1 - plugins/Clist_modern/src/modern_static_clui.h | 2 +- plugins/Clist_modern/src/modern_utils.cpp | 24 ++ plugins/Clist_modern/src/resource.h | 1 - 12 files changed, 57 insertions(+), 457 deletions(-) delete mode 100644 plugins/Clist_modern/src/modern_docking.cpp (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/cluiframes.cpp b/plugins/Clist_modern/src/cluiframes.cpp index 746247f164..b980f7b9cf 100644 --- a/plugins/Clist_modern/src/cluiframes.cpp +++ b/plugins/Clist_modern/src/cluiframes.cpp @@ -138,17 +138,10 @@ int SetAlpha(uint8_t Alpha) HWND hwnd = F.OwnerWindow; long l = GetWindowLongPtr(hwnd, GWL_EXSTYLE); if (!(l & WS_EX_LAYERED)) { - HWND parent = nullptr; - if (g_CluiData.fOnDesktop) { - HWND hProgMan = FindWindow(L"Progman", nullptr); - if (IsWindow(hProgMan)) - parent = hProgMan; - } - CLUI_ShowWindowMod(hwnd, SW_HIDE); SetParent(hwnd, nullptr); SetWindowLongPtr(hwnd, GWL_EXSTYLE, l | WS_EX_LAYERED); - SetParent(hwnd, parent); + SetParent(hwnd, nullptr); if (l&WS_VISIBLE) CLUI_ShowWindowMod(hwnd, SW_SHOW); } SetLayeredWindowAttributes(hwnd, g_CluiData.dwKeyColor, Alpha, LWA_ALPHA | LWA_COLORKEY); @@ -174,21 +167,14 @@ int CLUIFrames_ActivateSubContainers(BOOL active) { for (int i = 0; i < g_nFramesCount; i++) { FRAMEWND &F = g_pfwFrames[i]; - if (active && !F.floating && F.OwnerWindow != (HWND)nullptr && F.OwnerWindow != (HWND)-2 && F.visible && !F.needhide) { - if (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT)) { - SetWindowPos(F.OwnerWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - SetWindowPos(F.OwnerWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - } - else SetWindowPos(F.OwnerWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); - } + if (active && !F.floating && F.OwnerWindow != (HWND)nullptr && F.OwnerWindow != (HWND)-2 && F.visible && !F.needhide) + SetWindowPos(F.OwnerWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); } return 0; } int CLUIFrames_SetParentForContainers(HWND parent) { - g_CluiData.fOnDesktop = (parent && parent != g_clistApi.hwndContactList); - for (int i = 0; i < g_nFramesCount; i++) { FRAMEWND &F = g_pfwFrames[i]; if (!F.floating && F.OwnerWindow != (HWND)nullptr && F.OwnerWindow != (HWND)-2 && F.visible && !F.needhide) { @@ -218,11 +204,7 @@ int CLUIFrames_OnShowHide(int mode) if (mode != SW_HIDE) { SetWindowPos(F.OwnerWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - if (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT)) { - SetWindowPos(F.OwnerWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - SetWindowPos(F.OwnerWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - } - else SetWindowPos(F.OwnerWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); + SetWindowPos(F.OwnerWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); } } @@ -1348,9 +1330,6 @@ static int _us_DoCollapseFrame(WPARAM wParam, LPARAM lParam) if (FrameId >= 0 && FrameId < g_nFramesCount) { // do not collapse/uncollapse client/locked/invisible frames if (g_pfwFrames[FrameId].align == alClient && !(g_pfwFrames[FrameId].Locked || (!g_pfwFrames[FrameId].visible) || g_pfwFrames[FrameId].floating)) { - if (Clist_IsDocked()) - return 0; - if (g_CluiData.fDocked || !g_CluiData.fAutoSize) { RECT rc; GetWindowRect(g_clistApi.hwndContactList, &rc); @@ -2988,12 +2967,6 @@ static HWND CreateSubContainerWindow(HWND parent, int x, int y, int width, int h { HWND hwnd = CreateWindowEx(WS_EX_LAYERED, CLUIFrameSubContainerClassName, L"SubContainerWindow", WS_POPUP | (!g_CluiData.fLayered ? WS_BORDER : 0), x, y, width, height, parent, nullptr, g_plugin.getInst(), nullptr); SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) & ~(WS_CAPTION | WS_BORDER)); - if (g_CluiData.fOnDesktop) { - HWND hProgMan = FindWindow(L"Progman", nullptr); - if (IsWindow(hProgMan)) - SetParent(hwnd, hProgMan); - } - return hwnd; } diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index 799f0f12a6..16ee18c048 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -207,7 +207,6 @@ static HRESULT SubclassClistInterface() g_clistApi.pfnProcessExternalMessages = cli_ProcessExternalMessages; g_clistApi.pfnAddEvent = cli_AddEvent; g_clistApi.pfnFreeEvent = cli_RemoveEvent; - g_clistApi.pfnDocking_ProcessWindowMessage = Docking_ProcessWindowMessage; return S_OK; } diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 528efe806b..abb187115b 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -936,7 +936,7 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP } //====== End of Non-Layered Mode ===== CheckDlgButton(hwndDlg, IDC_FADEINOUT, db_get_b(0, "CLUI", "FadeInOut", SETTING_FADEIN_DEFAULT)); - CheckDlgButton(hwndDlg, IDC_ONDESKTOP, g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT)); + SendDlgItemMessage(hwndDlg, IDC_FRAMESSPIN, UDM_SETRANGE, 0, MAKELONG(50, 0)); SendDlgItemMessage(hwndDlg, IDC_CAPTIONSSPIN, UDM_SETRANGE, 0, MAKELONG(50, 0)); SendDlgItemMessage(hwndDlg, IDC_FRAMESSPIN, UDM_SETPOS, 0, db_get_dw(0, "CLUIFrames", "GapBetweenFrames", SETTING_GAPFRAMES_DEFAULT)); @@ -1013,12 +1013,6 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP CheckDlgButton(hwndDlg, IDC_LAYERENGINE, BST_CHECKED); } } - else if (LOWORD(wParam) == IDC_ONDESKTOP && IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)) { - CheckDlgButton(hwndDlg, IDC_ONTOP, BST_UNCHECKED); - } - else if (LOWORD(wParam) == IDC_ONTOP && IsDlgButtonChecked(hwndDlg, IDC_ONTOP)) { - CheckDlgButton(hwndDlg, IDC_ONDESKTOP, BST_UNCHECKED); - } else if (LOWORD(wParam) == IDC_TOOLWND) { EnableWindow(GetDlgItem(hwndDlg, IDC_MIN2TRAY), BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_TOOLWND)); } @@ -1072,7 +1066,6 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP db_unset(0, "ModernData", "EnableLayering"); } g_CluiData.dwKeyColor = db_get_dw(0, "ModernSettings", "KeyColor", (uint32_t)SETTING_KEYCOLOR_DEFAULT); - g_plugin.setByte("OnDesktop", (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)); Clist::bOnTop = IsDlgButtonChecked(hwndDlg, IDC_ONTOP); SetWindowPos(g_clistApi.hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); db_set_b(0, "CLUI", "DragToScroll", (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_DRAGTOSCROLL)); @@ -1095,21 +1088,11 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP g_bChangingMode = true; - if (IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)) { - HWND hProgMan = FindWindow(L"Progman", nullptr); - if (IsWindow(hProgMan)) { - SetParent(g_clistApi.hwndContactList, hProgMan); - Sync(CLUIFrames_SetParentForContainers, (HWND)hProgMan); - g_CluiData.fOnDesktop = true; - } - } - else { - if (GetParent(g_clistApi.hwndContactList)) { - SetParent(g_clistApi.hwndContactList, nullptr); - Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); - } - g_CluiData.fOnDesktop = false; + if (GetParent(g_clistApi.hwndContactList)) { + SetParent(g_clistApi.hwndContactList, nullptr); + Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); } + AniAva_UpdateParent(); db_set_b(0, "CLUI", "FadeInOut", (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT)); g_CluiData.fSmoothAnimation = IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT) != 0; @@ -1124,7 +1107,6 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP Clist::bTransparent = IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT); Clist::iAlpha = SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_GETPOS, 0, 0); Clist::iAutoAlpha = SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_GETPOS, 0, 0); - g_plugin.setByte("OnDesktop", (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)); ske_LoadSkinFromDB(); CLUI_UpdateLayeredMode(); diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index 2a3e5da2ba..cba1eb9792 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -127,7 +127,6 @@ int CListMod_ContactListShutdownProc(WPARAM, LPARAM) HRESULT PreLoadContactListModule() { /* Global data initialization */ - g_CluiData.fOnDesktop = false; g_CluiData.dwKeyColor = RGB(255, 0, 255); g_CluiData.bCurrentAlpha = 255; @@ -180,7 +179,7 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) if (IsIconic(hWnd) || !IsWindowVisible(hWnd)) return GWVS_HIDDEN; - if (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT) || !Clist::bBringToFront) + if (!Clist::bBringToFront) return GWVS_VISIBLE; HWND hwndFocused = GetFocus(); @@ -220,7 +219,7 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) GetWindowRect(hWnd, &rc); RECT rcMonitor = { 0 }; - Docking_GetMonitorRectFromWindow(hWnd, &rcMonitor); + GetMonitorRectFromWindow(hWnd, &rcMonitor); rc.top = rc.top < rcMonitor.top ? rcMonitor.top : rc.top; rc.left = rc.left < rcMonitor.left ? rcMonitor.left : rc.left; @@ -336,19 +335,13 @@ int cliShowHide(bool bAlwaysShow) Sync(CLUIFrames_ActivateSubContainers, TRUE); CLUI_ShowWindowMod(g_clistApi.hwndContactList, SW_RESTORE); - if (!g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT)) { - Sync(CLUIFrames_OnShowHide, 1); //TO BE PROXIED - SetWindowPos(g_clistApi.hwndContactList, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - g_bCalledFromShowHide = 1; - if (!Clist::bOnTop) - SetWindowPos(g_clistApi.hwndContactList, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); - g_bCalledFromShowHide = 0; - } - else { + Sync(CLUIFrames_OnShowHide, 1); //TO BE PROXIED + SetWindowPos(g_clistApi.hwndContactList, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + g_bCalledFromShowHide = 1; + if (!Clist::bOnTop) SetWindowPos(g_clistApi.hwndContactList, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); - Sync(CLUIFrames_OnShowHide, 1); - SetForegroundWindow(g_clistApi.hwndContactList); - } + g_bCalledFromShowHide = 0; + g_plugin.setByte("State", SETTING_STATE_NORMAL); RECT rcWindow; diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 500f7ca2d6..ec29f6c318 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -683,15 +683,6 @@ void CLUI_ChangeWindowMode() } SetWindowText(g_clistApi.hwndContactList, titleText); - // < -> - // 1 - If visible store it and hide - if (g_CluiData.fLayered && (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT))) { - SetParent(g_clistApi.hwndContactList, nullptr); - Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); - UpdateWindow(g_clistApi.hwndContactList); - g_CluiData.fOnDesktop = false; - } - // 5 - TODO Apply Style oldStyleEx = curStyleEx = GetWindowLongPtr(g_clistApi.hwndContactList, GWL_EXSTYLE); oldStyle = curStyle = GetWindowLongPtr(g_clistApi.hwndContactList, GWL_STYLE); @@ -716,23 +707,9 @@ void CLUI_ChangeWindowMode() else SetMenu(g_clistApi.hwndContactList, g_clistApi.hMenuMain); - if (g_CluiData.fLayered && (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT))) - ske_UpdateWindowImage(); - // 6 - Pin to desktop mode - if (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT)) { - HWND hProgMan = FindWindow(L"Progman", nullptr); - if (IsWindow(hProgMan)) { - SetParent(g_clistApi.hwndContactList, hProgMan); - Sync(CLUIFrames_SetParentForContainers, (HWND)hProgMan); - g_CluiData.fOnDesktop = true; - } - } - else { - SetParent(g_clistApi.hwndContactList, nullptr); - Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); - g_CluiData.fOnDesktop = false; - } + SetParent(g_clistApi.hwndContactList, nullptr); + Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); // 7 - if it was visible - show if (storedVisMode) { @@ -751,7 +728,7 @@ void CLUI_ChangeWindowMode() int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); h = (h < v) ? h : v; HRGN hRgn1 = CreateRoundRectRgn(0, 0, (r.right - r.left + 1), (r.bottom - r.top + 1), h, h); - if (db_get_b(0, "CLC", "RoundCorners", SETTING_ROUNDCORNERS_DEFAULT) && !Clist_IsDocked()) + if (db_get_b(0, "CLC", "RoundCorners", SETTING_ROUNDCORNERS_DEFAULT)) SetWindowRgn(g_clistApi.hwndContactList, hRgn1, 1); else { DeleteObject(hRgn1); @@ -808,7 +785,7 @@ int CLUI_HideBehindEdge() //Need to be moved out of screen bShowEventStarted = 0; //1. get work area rectangle - Docking_GetMonitorRectFromWindow(g_clistApi.hwndContactList, &rcScreen); + GetMonitorRectFromWindow(g_clistApi.hwndContactList, &rcScreen); //SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen,FALSE); //2. move out int bordersize = wBehindEdgeBorderSize; @@ -848,7 +825,7 @@ int CLUI_ShowFromBehindEdge() // Need to be moved out of screen // 1. get work area rectangle RECT rcScreen; - Docking_GetMonitorRectFromWindow(g_clistApi.hwndContactList, &rcScreen); + GetMonitorRectFromWindow(g_clistApi.hwndContactList, &rcScreen); // 2. move out RECT rcWindow; @@ -1693,12 +1670,10 @@ LRESULT CLUI::OnSizingMoving(UINT msg, WPARAM wParam, LPARAM lParam) CheckFramesPos(&rc); Sync(CLUIFrames_OnMoving, m_hWnd, &rc); if (!IsIconic(m_hWnd)) { - if (!Clist_IsDocked()) { // if g_CluiData.fDocked, dont remember pos (except for width) - g_plugin.setDword("Height", (uint32_t)(rc.bottom - rc.top)); - g_plugin.setDword("x", (uint32_t)rc.left); - g_plugin.setDword("y", (uint32_t)rc.top); - } + g_plugin.setDword("Height", (uint32_t)(rc.bottom - rc.top)); g_plugin.setDword("Width", (uint32_t)(rc.right - rc.left)); + g_plugin.setDword("x", (uint32_t)rc.left); + g_plugin.setDword("y", (uint32_t)rc.top); } } return TRUE; @@ -1730,14 +1705,11 @@ LRESULT CLUI::OnSizingMoving(UINT msg, WPARAM wParam, LPARAM lParam) } // if g_CluiData.fDocked, dont remember pos (except for width) - if (!Clist_IsDocked()) { - g_plugin.setDword("Height", (uint32_t)(rc.bottom - rc.top)); - g_plugin.setDword("x", (uint32_t)rc.left); - g_plugin.setDword("y", (uint32_t)rc.top); - } - else SetWindowRgn(m_hWnd, nullptr, 0); + g_plugin.setDword("Height", (uint32_t)(rc.bottom - rc.top)); g_plugin.setDword("Width", (uint32_t)(rc.right - rc.left)); - + g_plugin.setDword("x", (uint32_t)rc.left); + g_plugin.setDword("y", (uint32_t)rc.top); + if (!g_CluiData.fLayered) { HRGN hRgn1; RECT r; @@ -1747,7 +1719,7 @@ LRESULT CLUI::OnSizingMoving(UINT msg, WPARAM wParam, LPARAM lParam) int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); h = (h < v) ? h : v; hRgn1 = CreateRoundRectRgn(0, 0, (r.right - r.left + 1), (r.bottom - r.top + 1), h, h); - if (db_get_b(0, "CLC", "RoundCorners", SETTING_ROUNDCORNERS_DEFAULT) && !Clist_IsDocked()) + if (db_get_b(0, "CLC", "RoundCorners", SETTING_ROUNDCORNERS_DEFAULT)) SetWindowRgn(m_hWnd, hRgn1, FALSE); else { DeleteObject(hRgn1); @@ -2239,8 +2211,6 @@ LRESULT CLUI::OnSysCommand(UINT msg, WPARAM wParam, LPARAM lParam) } DefWindowProc(m_hWnd, msg, wParam, lParam); - if (g_plugin.getByte("OnDesktop", SETTING_ONDESKTOP_DEFAULT)) - Sync(CLUIFrames_ActivateSubContainers, TRUE); return FALSE; } @@ -2282,7 +2252,7 @@ LRESULT CLUI::OnListSizeChangeNotify(NMCLISTCONTROL *pnmc) rcWindow = rcSizingRect; else GetWindowRect(m_hWnd, &rcWindow); - if (!g_CluiData.fAutoSize || g_clistApi.hwndContactTree == nullptr || Clist_IsDocked()) + if (!g_CluiData.fAutoSize || g_clistApi.hwndContactTree == nullptr) return FALSE; maxHeight = db_get_b(0, "CLUI", "MaxSizeHeight", SETTING_MAXSIZEHEIGHT_DEFAULT); diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index d84b89c2a3..bd108c3770 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -152,7 +152,6 @@ int SetAlpha(uint8_t Alpha); /* others TODO: move above */ -int Docking_ProcessWindowMessage(WPARAM wParam, LPARAM lParam); void DrawBackGround(HWND hwnd, HDC mhdc, HBITMAP hBmpBackground, COLORREF bkColour, uint32_t backgroundBmpUse); HRESULT BackgroundsLoadModule(); int BackgroundsUnloadModule(); @@ -181,7 +180,7 @@ INT_PTR ToggleHideOffline(WPARAM wParam, LPARAM lParam); INT_PTR SetUseGroups(WPARAM wParam, LPARAM lParam); //contact.c INT_PTR ToggleSounds(WPARAM wParam, LPARAM lParam); //contact.c void ClcOptionsChanged(); //clc.c -void Docking_GetMonitorRectFromWindow(HWND hWnd, RECT *rc); //Docking.c +void GetMonitorRectFromWindow(HWND hWnd, RECT *rc); //Docking.c void DrawAvatarImageWithGDIp(HDC hDestDC, int x, int y, uint32_t width, uint32_t height, HBITMAP hbmp, int x1, int y1, uint32_t width1, uint32_t height1, uint32_t flag, uint8_t alpha); //gdiplus.cpp void InitGdiPlus(); //gdiplus.cpp void ShutdownGdiPlus(); //gdiplus.cpp diff --git a/plugins/Clist_modern/src/modern_defsettings.h b/plugins/Clist_modern/src/modern_defsettings.h index 469ae95f19..868484cf14 100644 --- a/plugins/Clist_modern/src/modern_defsettings.h +++ b/plugins/Clist_modern/src/modern_defsettings.h @@ -35,7 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SETTING_THINBORDER_DEFAULT 0 #define SETTING_NOBORDER_DEFAULT 0 #define SETTING_WINDOWSHADOW_DEFAULT 0 -#define SETTING_ONDESKTOP_DEFAULT 0 #define SETTING_DISABLEWORKINGSET_DEFAULT 1 #define SETTING_ALWAYSVISICON_DEFAULT 0 diff --git a/plugins/Clist_modern/src/modern_docking.cpp b/plugins/Clist_modern/src/modern_docking.cpp deleted file mode 100644 index 55d04d6e58..0000000000 --- a/plugins/Clist_modern/src/modern_docking.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (C) 2012-25 Miranda NG team (https://miranda-ng.org), -Copyright (c) 2000-08 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" -#include "modern_sync.h" - -#define WM_DOCKCALLBACK (WM_USER+121) -#define WM_CREATEDOCKED (WM_USER+122) -#define EDGESENSITIVITY 3 - -#define DOCKED_NONE 0 -#define DOCKED_LEFT 1 -#define DOCKED_RIGHT 2 - -BOOL LockSubframeMoving = 0; -static int TempDock = 0; -static int dock_drag_dx = 0; -static int dock_drag_dy = 0; - -static void Docking_GetMonitorRectFromPoint(POINT pt, RECT *rc) -{ - MONITORINFO monitorInfo; - HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always returns a valid value - monitorInfo.cbSize = sizeof(MONITORINFO); - - if (GetMonitorInfo(hMonitor, &monitorInfo)) - { - memcpy(rc, &monitorInfo.rcMonitor, sizeof(RECT)); - return; - } - - // "generic" win95/NT support, also serves as failsafe - rc->left = 0; - rc->top = 0; - rc->bottom = GetSystemMetrics(SM_CYSCREEN); - rc->right = GetSystemMetrics(SM_CXSCREEN); -} - -void Docking_GetMonitorRectFromWindow(HWND hWnd, RECT *rc) -{ - POINT ptWindow; - GetWindowRect(hWnd, rc); - ptWindow.x = rc->left; - ptWindow.y = rc->top; - Docking_GetMonitorRectFromPoint(ptWindow, rc); -} - -static void Docking_AdjustPosition(HWND hwnd, RECT *rcDisplay, RECT *rc) -{ - APPBARDATA abd; - - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = hwnd; - abd.uEdge = g_CluiData.fDocked == DOCKED_LEFT ? ABE_LEFT : ABE_RIGHT; - abd.rc = *rc; - abd.rc.top = rcDisplay->top; - abd.rc.bottom = rcDisplay->bottom; - if (g_CluiData.fDocked == DOCKED_LEFT) { - abd.rc.right = rcDisplay->left + abd.rc.right - abd.rc.left; - abd.rc.left = rcDisplay->left; - } - else { - abd.rc.left = rcDisplay->right - (abd.rc.right - abd.rc.left); - abd.rc.right = rcDisplay->right; - - } - SHAppBarMessage(ABM_SETPOS, &abd); - *rc = abd.rc; -} - -int Docking_IsDocked(WPARAM, LPARAM) -{ - return g_CluiData.fDocked; -} - -int Docking_ProcessWindowMessage(WPARAM wParam, LPARAM lParam) -{ - APPBARDATA abd; - static int draggingTitle; - MSG *msg = (MSG*)wParam; - - if (msg->message == WM_DESTROY) - g_plugin.setByte("Docked", (uint8_t)g_CluiData.fDocked); - - if (!g_CluiData.fDocked && msg->message != WM_CREATE && msg->message != WM_MOVING && msg->message != WM_CREATEDOCKED && msg->message != WM_MOVE && msg->message != WM_SIZE) return 0; - switch (msg->message) { - case WM_CREATE: - //if (GetSystemMetrics(SM_CMONITORS)>1) return 0; - if (g_plugin.getByte("Docked", 0) && db_get_b(0, "CLUI", "DockToSides", SETTING_DOCKTOSIDES_DEFAULT)) - { - PostMessage(msg->hwnd, WM_CREATEDOCKED, 0, 0); - } - draggingTitle = 0; - return 0; - - case WM_CREATEDOCKED: - //we need to post a message just after creation to let main message function do some work - g_CluiData.fDocked = (BOOL)g_plugin.getByte("Docked", 0); - if (IsWindowVisible(msg->hwnd) && !IsIconic(msg->hwnd)) { - RECT rc, rcMonitor; - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = msg->hwnd; - abd.lParam = 0; - abd.uCallbackMessage = WM_DOCKCALLBACK; - SHAppBarMessage(ABM_NEW, &abd); - GetWindowRect(msg->hwnd, &rc); - Docking_GetMonitorRectFromWindow(msg->hwnd, &rcMonitor); - Docking_AdjustPosition(msg->hwnd, &rcMonitor, &rc); - MoveWindow(msg->hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); - g_CluiData.mutexPreventDockMoving = 0; - Sync(CLUIFrames_OnMoving, msg->hwnd, &rc); - g_CluiData.mutexPreventDockMoving = 1; - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - } - break; - case WM_CAPTURECHANGED: - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - return 0; - case WM_ACTIVATE: - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = msg->hwnd; - SHAppBarMessage(ABM_ACTIVATE, &abd); - return 0; - case WM_SIZE: - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_REDRAW_ALL, nullptr); - return 0; - - case WM_WINDOWPOSCHANGED: - { - if (g_CluiData.fDocked) - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - return 0; - } - case WM_MOVING: - { - RECT rcMonitor; - RECT rcWindow; - RECT *rc; - int dx = 0; - POINT ptCursor; - if (g_CluiData.fDocked) return 0; - - // GetMessagePos() is no good, position is always unsigned - GetCursorPos(&ptCursor); - GetWindowRect(msg->hwnd, &rcWindow); - dock_drag_dx = rcWindow.left - ptCursor.x; - dock_drag_dy = rcWindow.top - ptCursor.y; - Docking_GetMonitorRectFromPoint(ptCursor, &rcMonitor); - - if (((ptCursor.x < rcMonitor.left + EDGESENSITIVITY) - || (ptCursor.x >= rcMonitor.right - EDGESENSITIVITY)) - && db_get_b(0, "CLUI", "DockToSides", SETTING_DOCKTOSIDES_DEFAULT)) - { - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = msg->hwnd; - abd.lParam = 0; - abd.uCallbackMessage = WM_DOCKCALLBACK; - SHAppBarMessage(ABM_NEW, &abd); - if (ptCursor.x < rcMonitor.left + EDGESENSITIVITY) g_CluiData.fDocked = DOCKED_LEFT; - else g_CluiData.fDocked = DOCKED_RIGHT; - // TempDock = 1; - GetWindowRect(msg->hwnd, (LPRECT)msg->lParam); - rc = (RECT*)msg->lParam; - if (g_CluiData.fDocked == DOCKED_RIGHT) - dx = (rc->right > rcMonitor.right) ? rc->right - rcMonitor.right : 0; - else - dx = (rc->left < rcMonitor.left) ? rc->left - rcMonitor.left : 0; - OffsetRect(rc, -dx, 0); - Docking_AdjustPosition(msg->hwnd, (LPRECT)&rcMonitor, (LPRECT)msg->lParam); - SendMessage(msg->hwnd, WM_SIZE, 0, 0); - g_CluiData.mutexPreventDockMoving = 0; - Sync(CLUIFrames_OnMoving, msg->hwnd, (LPRECT)msg->lParam); - g_CluiData.mutexPreventDockMoving = 1; - mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); - g_plugin.setByte("Docked", (uint8_t)g_CluiData.fDocked); - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - return TRUE; - } - return 0; - } - case WM_EXITSIZEMOVE: - { - RECT rcMonitor; - RECT rcWindow; - if (TempDock) TempDock = 0; - GetWindowRect(msg->hwnd, &rcWindow); - Docking_GetMonitorRectFromWindow(msg->hwnd, &rcMonitor); - Docking_AdjustPosition(msg->hwnd, &rcMonitor, &rcWindow); - *((LRESULT*)lParam) = TRUE; - g_CluiData.mutexPreventDockMoving = 0; - SetWindowPos(msg->hwnd, nullptr, rcWindow.left, rcWindow.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOSENDCHANGING); - Sync(CLUIFrames_OnMoving, msg->hwnd, &rcWindow); - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr);// -= -= -= - g_CluiData.mutexPreventDockMoving = 1; - return 1; - } - - case WM_MOVE: - { - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_ALT_DRAW, nullptr); - return 0; - } - case WM_SIZING: - { - if (g_CluiData.fDocked) ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - return FALSE; - } - case WM_SHOWWINDOW: - { - if (msg->lParam) - return 0; - if ((msg->wParam && g_CluiData.fDocked < 0) || (!msg->wParam && g_CluiData.fDocked>0)) - g_CluiData.fDocked = -g_CluiData.fDocked; - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = msg->hwnd; - if (msg->wParam) { - RECT rc, rcMonitor; - Docking_GetMonitorRectFromWindow(msg->hwnd, &rcMonitor); - abd.lParam = 0; - abd.uCallbackMessage = WM_DOCKCALLBACK; - SHAppBarMessage(ABM_NEW, &abd); - GetWindowRect(msg->hwnd, &rc); - Docking_AdjustPosition(msg->hwnd, &rcMonitor, &rc); - MoveWindow(msg->hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE); - Sync(CLUIFrames_OnMoving, msg->hwnd, &rc); - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr);// -= -= -= - } - else { - SHAppBarMessage(ABM_REMOVE, &abd); - } - } - return 0; - case WM_NCHITTEST: - { LONG result; - result = DefWindowProc(msg->hwnd, WM_NCHITTEST, msg->wParam, msg->lParam); - if (result == HTSIZE || result == HTTOP || result == HTTOPLEFT || result == HTTOPRIGHT || - result == HTBOTTOM || result == HTBOTTOMRIGHT || result == HTBOTTOMLEFT) { - *((LRESULT*)lParam) = HTCLIENT; return TRUE; - } - if (g_CluiData.fDocked == DOCKED_LEFT && result == HTLEFT) { *((LRESULT*)lParam) = HTCLIENT; return TRUE; } - if (g_CluiData.fDocked == DOCKED_RIGHT && result == HTRIGHT) { *((LRESULT*)lParam) = HTCLIENT; return TRUE; } - - - return 0; - } - case WM_SYSCOMMAND: - if ((msg->wParam & 0xFFF0) != SC_MOVE) return 0; - SetActiveWindow(msg->hwnd); - SetCapture(msg->hwnd); - draggingTitle = 1; - *((LRESULT*)lParam) = 0; - return TRUE; - case WM_MOUSEMOVE: - - if (!draggingTitle) return 0; - { RECT rc; - POINT pt; - GetClientRect(msg->hwnd, &rc); - if (((g_CluiData.fDocked == DOCKED_LEFT || g_CluiData.fDocked == -DOCKED_LEFT) && (short)LOWORD(msg->lParam) > rc.right) || - ((g_CluiData.fDocked == DOCKED_RIGHT || g_CluiData.fDocked == -DOCKED_RIGHT) && (short)LOWORD(msg->lParam) < 0)) { - ReleaseCapture(); - draggingTitle = 0; - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = msg->hwnd; - SHAppBarMessage(ABM_REMOVE, &abd); - g_CluiData.fDocked = 0; - GetCursorPos(&pt); - PostMessage(msg->hwnd, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(pt.x, pt.y)); - SetWindowPos(msg->hwnd, nullptr, pt.x - rc.right / 2, pt.y - GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYSMCAPTION) / 2, g_plugin.getDword("Width", 0), g_plugin.getDword("Height", 0), SWP_NOZORDER); - g_plugin.setByte("Docked", (uint8_t)g_CluiData.fDocked); - // ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - } - return 1; - } - case WM_LBUTTONUP: - if (draggingTitle) { - ReleaseCapture(); - draggingTitle = 0; - } - return 0; - case WM_DOCKCALLBACK: - switch (msg->wParam) { - case ABN_WINDOWARRANGE: - CLUI_ShowWindowMod(msg->hwnd, msg->lParam ? SW_HIDE : SW_SHOW); - { - - RECT rc, rcMonitor; - Docking_GetMonitorRectFromWindow(msg->hwnd, &rcMonitor); - GetWindowRect(msg->hwnd, &rc); - Docking_AdjustPosition(msg->hwnd, &rcMonitor, &rc); - Sync(CLUIFrames_OnMoving, msg->hwnd, &rc); // -= -= -= - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - - g_CluiData.mutexPreventDockMoving = 1; - } - break; - } - return TRUE; - case WM_DESTROY: - if (g_CluiData.fDocked > 0) { - memset(&abd, 0, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.hWnd = msg->hwnd; - SHAppBarMessage(ABM_REMOVE, &abd); - ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, nullptr); - } - return 0; - } - return 0; -} diff --git a/plugins/Clist_modern/src/modern_global_structure.h b/plugins/Clist_modern/src/modern_global_structure.h index 689d06b7de..28cd3507a8 100644 --- a/plugins/Clist_modern/src/modern_global_structure.h +++ b/plugins/Clist_modern/src/modern_global_structure.h @@ -44,7 +44,6 @@ struct CLUIDATA bool bEventAreaEnabled; bool bNotifyActive; bool fDisableSkinEngine; - bool fOnDesktop; bool fSmoothAnimation; bool fLayered; bool fSortOfflineBottom; diff --git a/plugins/Clist_modern/src/modern_static_clui.h b/plugins/Clist_modern/src/modern_static_clui.h index 891dcf53f3..475d389997 100644 --- a/plugins/Clist_modern/src/modern_static_clui.h +++ b/plugins/Clist_modern/src/modern_static_clui.h @@ -62,7 +62,7 @@ int CListMod_HideWindow(HWND hwndContactList, int mode); int CLUIServices_LoadModule(void); INT_PTR CLUIServices_SortList(WPARAM wParam, LPARAM lParam); -void Docking_GetMonitorRectFromWindow(HWND hWnd, RECT *rc); +void GetMonitorRectFromWindow(HWND hWnd, RECT *rc); int EventArea_Create(HWND hCluiWnd); diff --git a/plugins/Clist_modern/src/modern_utils.cpp b/plugins/Clist_modern/src/modern_utils.cpp index 2cea1b9a1a..2210a2c3ab 100644 --- a/plugins/Clist_modern/src/modern_utils.cpp +++ b/plugins/Clist_modern/src/modern_utils.cpp @@ -62,3 +62,27 @@ BOOL DestroyIcon_protect(HICON icon) if (icon) return DestroyIcon(icon); return FALSE; } + +void GetMonitorRectFromWindow(HWND hWnd, RECT *rc) +{ + POINT pt; + GetWindowRect(hWnd, rc); + pt.x = rc->left; + pt.y = rc->top; + + MONITORINFO monitorInfo; + HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always returns a valid value + monitorInfo.cbSize = sizeof(MONITORINFO); + + if (GetMonitorInfoW(hMonitor, &monitorInfo)) { + memcpy(rc, &monitorInfo.rcMonitor, sizeof(RECT)); + return; + } + + // "generic" win95/NT support, also serves as failsafe + rc->left = 0; + rc->top = 0; + rc->bottom = GetSystemMetrics(SM_CYSCREEN); + rc->right = GetSystemMetrics(SM_CXSCREEN); + +} diff --git a/plugins/Clist_modern/src/resource.h b/plugins/Clist_modern/src/resource.h index 8e46e99484..7fd519e3a3 100644 --- a/plugins/Clist_modern/src/resource.h +++ b/plugins/Clist_modern/src/resource.h @@ -250,7 +250,6 @@ #define IDC_HILIGHTMODE2 1659 #define IDC_HILIGHTMODE1 1660 #define IDC_HILIGHTMODE3 1661 -#define IDC_ONDESKTOP 1662 #define IDC_HILIGHTMODE4 1663 #define IDC_USECONNECTINGICON 1761 #define IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK 1761 -- cgit v1.2.3