Skip to content
Open
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
3 changes: 3 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 "TapControl.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);
}
UpdateTap();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3340,6 +3342,7 @@ static void CleanStartMenuDLL( void )
}
ResetHotCorners();
UpdateTaskBars(TASKBAR_CLEAR);
StopTap();
g_WinStartButton=NULL;
for (id_taskbar_map::const_iterator it=g_TaskbarInfos.begin();it!=g_TaskbarInfos.end();++it)
{
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="TapControl.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="TapControl.h" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\Setup\OpenShell.ico" />
Expand Down
8 changes: 7 additions & 1 deletion 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="TapControl.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="TapControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Resource Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -204,4 +210,4 @@
<Filter>Resource Files</Filter>
</Text>
</ItemGroup>
</Project>
</Project>
89 changes: 89 additions & 0 deletions Src/StartMenu/StartMenuDLL/TapControl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include "stdafx.h"
#include "../StartMenuHelper/ExplorerTap.h"
#include "TapControl.h"
#include "Settings.h"
#include "LogManager.h"
#include "ResourceHelper.h"

using UpdateExplorerTap_t = decltype(&UpdateExplorerTap);
using StopExplorerTap_t = decltype(&StopExplorerTap);

static HMODULE g_explorerTapModule = NULL;
static UpdateExplorerTap_t g_updateExplorerTap = NULL;
static StopExplorerTap_t g_stopExplorerTap = NULL;

#ifdef _WIN64
#define TAP_HELPER_NAME L"StartMenuHelper64.dll"
#else
#define TAP_HELPER_NAME L"StartMenuHelper32.dll"
#endif

static bool LoadExplorerTap()
{
if (g_explorerTapModule)
return true;

// Prefer a helper next to StartMenuDLL for local development builds
wchar_t path[MAX_PATH];
GetModuleFileName(g_Instance, path, _countof(path));
PathRemoveFileSpec(path);
PathAppend(path, TAP_HELPER_NAME);

auto module = LoadLibrary(path);

// Fall-back to System32 (standard location for installed versions).
if (!module)
module = LoadLibraryEx(TAP_HELPER_NAME, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);

if (!module)
{
LogToFile(STARTUP_LOG, L"TapControl: unable to load TAP helper 0x%08X", GetLastError());
return false;
}

auto update = (UpdateExplorerTap_t)GetProcAddress(module, "UpdateExplorerTap");
auto stop = (StopExplorerTap_t)GetProcAddress(module, "StopExplorerTap");
if (!update || !stop)
{
LogToFile(STARTUP_LOG, L"TapControl: TAP helper exports are unavailable");
FreeLibrary(module);
return false;
}

g_explorerTapModule = module;
g_updateExplorerTap = update;
g_stopExplorerTap = stop;
return true;
}

void UpdateTap()
{
if (!IsWin11())
return;

ExplorerTapSettings settings{};
settings.startButtonEnabled = GetSettingBool(L"EnableStartButton");
settings.startButtonAllTaskbars = GetSettingBool(L"AllTaskbars");

// Start on first enable if the helper was not needed at startup.
if (settings.startButtonEnabled)
LoadExplorerTap();

if (g_updateExplorerTap)
g_updateExplorerTap(&settings);
}

void StopTap()
{
if (g_stopExplorerTap)
g_stopExplorerTap();

// Drop only StartMenuDLL's explicit reference. XAML Diagnostics owns the TAP
// module reference for the diagnostics session after a successful connection.
if (g_explorerTapModule)
FreeLibrary(g_explorerTapModule);

g_explorerTapModule = NULL;
g_updateExplorerTap = NULL;
g_stopExplorerTap = NULL;
}
9 changes: 9 additions & 0 deletions Src/StartMenu/StartMenuDLL/TapControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

// Windows 11 draws the native Taskbar and Start button in XAML.
// These helpers control our TAP mechanism that allows to do changes in the XAML tree.

// Send updated settings to the TAP.
void UpdateTap();
// Stop the TAP and clean up resources.
void StopTap();
Loading