Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ResourceHelper.h"
#include "LogManager.h"
#include "TouchHelper.h"
#include "Win11StartButton.h"
#include "IatHookHelper.h"
#include "dllmain.h"
#include <uxtheme.h>
Expand Down Expand Up @@ -2643,6 +2644,7 @@ void UpdateTaskBars( TUpdateTaskbar update )
InvalidateRect(taskBar.taskBar,NULL,TRUE);
PostMessage(taskBar.taskBar,WM_THEMECHANGED,0,0);
}
UpdateWin11StartButtonMonitor();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3227,6 +3229,7 @@ if (!g_bTrimHooks)

UpdateTaskBars(TASKBAR_RECREATE_BUTTONS);
UpdateTaskBars(TASKBAR_UPDATE_TEXTURE);
StartWin11StartButtonMonitor();
}

static void RecreateStartButton( size_t taskbarId )
Expand Down Expand Up @@ -3288,6 +3291,8 @@ static DWORD WINAPI ExitThreadProc( void *param )

static void CleanStartMenuDLL( void )
{
StopWin11StartButtonMonitor();

ClearIatHook(g_DwmpBTRHook);
g_DwmpBTRHook=NULL;
ClearIatHook(g_DwmpTWWRHook);
Expand Down Expand Up @@ -3645,6 +3650,16 @@ static LRESULT CALLBACK HookDesktopThreadMouse(int code, WPARAM wParam, LPARAM l
return CallNextHookEx(NULL, code, wParam, lParam);
}

void SetWin11StartButtonMouseHookFallback( bool enable )
{
if (!IsWin11() || !g_TaskBar || !g_StartMenuMsg)
return;

// XAML diagnostics callbacks run on the XAML thread. Mutate the thread-local
// WH_MOUSE hook only from Explorer's taskbar thread through HookDesktopThread.
PostMessage(g_TaskBar, g_StartMenuMsg, MSG_WIN11MOUSEHOOK, enable ? 1 : 0);
}

// WH_GETMESSAGE hook for the taskbar thread
static LRESULT CALLBACK HookDesktopThread( int code, WPARAM wParam, LPARAM lParam )
{
Expand All @@ -3668,6 +3683,20 @@ if (!g_bTrimHooks)
if (msg->message==g_StartMenuMsg && msg->hwnd==g_TaskBar)
{
msg->message=WM_NULL;
if (msg->wParam==MSG_WIN11MOUSEHOOK)
{
if (msg->lParam)
{
if (!g_StartMouseHook)
g_StartMouseHook=SetWindowsHookEx(WH_MOUSE,HookDesktopThreadMouse,NULL,GetCurrentThreadId());
}
else if (g_StartMouseHook)
{
UnhookWindowsHookEx(g_StartMouseHook);
g_StartMouseHook=NULL;
}
return 0;
}
static bool bProcessing; // prevent reentry
if (!bProcessing)
{
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ enum TMenuMsgParam // wParam for the OpenShellMenu.StartMenuMsg message
MSG_REDRAWTASKBAR, // redraw taskbar, lParam is the HWND (NULL for all)
MSG_RELOADSETTINGS, // reloads the settings from the registry
MSG_SETMONITOR, // sets the start screen monitor
MSG_WIN11MOUSEHOOK, // enable/disable the Win11 mouse-hook fallback, lParam is bool
};

STARTMENUAPI extern enum _MINIDUMP_TYPE MiniDumpType;
Expand All @@ -118,6 +119,7 @@ void EnableHotkeys( THotkeys enable );
bool PointAroundStartButton( size_t taskbarId, const CPoint &pt=CPoint(GetMessagePos()) );
void ResetHotCorners( void );
void RedrawTaskbars( void );
void SetWin11StartButtonMouseHookFallback( bool enable );

enum TUpdateTaskbar
{
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TouchHelper.cpp" />
<ClCompile Include="Win11StartButton.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Accessibility.h" />
Expand All @@ -110,6 +111,7 @@
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TouchHelper.h" />
<ClInclude Include="Win11StartButton.h" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\Setup\OpenShell.ico" />
Expand Down
6 changes: 6 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<ClCompile Include="TouchHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Win11StartButton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Accessibility.h">
Expand Down Expand Up @@ -128,6 +131,9 @@
<ClInclude Include="TouchHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Win11StartButton.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Resource Files</Filter>
</ClInclude>
Expand Down
Loading