From d2956abda23789b0615630b6bd7fe6047d725e45 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Sat, 2 Oct 2021 04:33:43 +0300 Subject: [PATCH] Right click on Win+X moves mouse to "Desktop" entry --- CHANGELOG.md | 6 ++++ ExplorerPatcher/ExplorerPatcher.rc | 8 ++--- ExplorerPatcher/dllmain.c | 48 ++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18549ce..11b9b0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ This document includes the same release notes as in the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section on GitHub. +## 22000.194.0.22 + +Tested on build: 22000.194. + +* When the taskbar is located at the bottom of the screen, opening the power user menu (`Win`+`X`) now automatically highlights the "Desktop" entry in the list. Also, the menu items can be activated either with left click, either with right click. Thus, this enables a behavior where you can double click the Start button with the right mouse button in order to quickly show the desktop (thanks to @Gaurav-Original-ClassicShellTester for the suggestion) + ## 22000.194.0.21 Tested on build: 22000.194. diff --git a/ExplorerPatcher/ExplorerPatcher.rc b/ExplorerPatcher/ExplorerPatcher.rc index 444cb38..0821bb5 100644 --- a/ExplorerPatcher/ExplorerPatcher.rc +++ b/ExplorerPatcher/ExplorerPatcher.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 22000,194,0,21 - PRODUCTVERSION 22000,194,0,21 + FILEVERSION 22000,194,0,22 + PRODUCTVERSION 22000,194,0,22 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "VALINET Solutions SRL" VALUE "FileDescription", "ExplorerPatcher" - VALUE "FileVersion", "22000.194.0.21" + VALUE "FileVersion", "22000.194.0.22" VALUE "InternalName", "ExplorerPatcher.dll" VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved." VALUE "OriginalFilename", "ExplorerPatcher.dll" VALUE "ProductName", "ExplorerPatcher" - VALUE "ProductVersion", "22000.194.0.21" + VALUE "ProductVersion", "22000.194.0.22" END END BLOCK "VarFileInfo" diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index a56686b..5014a5b 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -29,6 +29,9 @@ #include "StartMenu.h" #include "GUI.h" +#define WINX_ADJUST_X 5 +#define WINX_ADJUST_Y 5 + #define SB_MICA_EFFECT_SUBCLASS_OFFSET 0x5C70 #define SB_INIT1 0x26070 #define SB_INIT2 0x252C0 @@ -356,6 +359,51 @@ INT64 CLauncherTipContextMenu_ShowLauncherTipContextMenuHook( if (pt) { point = *pt; + BOOL bBottom, bRight; + POINT dPt = GetDefaultWinXPosition(FALSE, &bBottom, &bRight); + if (bBottom) + { + HMONITOR hMonitor = MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY); + MONITORINFO mi; + mi.cbSize = sizeof(MONITORINFO); + GetMonitorInfo(hMonitor, &mi); + UINT dpiX, dpiY; + HRESULT hr = GetDpiForMonitor( + hMonitor, + MDT_DEFAULT, + &dpiX, + &dpiY + ); + double dx = dpiX / 96.0, dy = dpiY / 96.0; + BOOL xo = FALSE, yo = FALSE; + if (point.x - WINX_ADJUST_X * dx < mi.rcMonitor.left) + { + xo = TRUE; + } + if (point.y + WINX_ADJUST_Y * dy > mi.rcMonitor.bottom) + { + yo = TRUE; + } + POINT ptCursor; + GetCursorPos(&ptCursor); + if (xo) + { + ptCursor.x += (WINX_ADJUST_X * 2) * dx; + } + else + { + point.x -= WINX_ADJUST_X * dx; + } + if (yo) + { + ptCursor.y -= (WINX_ADJUST_Y * 2) * dy; + } + else + { + point.y += WINX_ADJUST_Y * dy; + } + SetCursorPos(ptCursor.x, ptCursor.y); + } } else {