Skip to content

Commit

Permalink
Taskbar auto-hide when maximized v1.1.1 (#1196)
Browse files Browse the repository at this point in the history
* Fixed spanned windows (e.g. Win+right) affecting the sibling monitor taskbar.
  • Loading branch information
m417z authored Nov 3, 2024
1 parent ec00d67 commit 1819258
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mods/taskbar-auto-hide-when-maximized.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id taskbar-auto-hide-when-maximized
// @name Taskbar auto-hide when maximized
// @description When auto-hide is enabled, makes the taskbar auto-hide only when a window is maximized or intersects the taskbar
// @version 1.1
// @version 1.1.1
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand Down Expand Up @@ -107,6 +107,9 @@ enum {
#define EVENT_OBJECT_UNCLOAKED 0x8018
#endif

using IsWindowArranged_t = BOOL(WINAPI*)(HWND hwnd);
IsWindowArranged_t pIsWindowArranged;

// https://devblogs.microsoft.com/oldnewthing/20200302-00/?p=103507
bool IsWindowCloaked(HWND hwnd) {
BOOL isCloaked = FALSE;
Expand Down Expand Up @@ -226,6 +229,11 @@ bool ShouldAlwaysShowTaskbar(HWND hMMTaskbarWnd, HMONITOR monitor) {
return TRUE;
}

if (pIsWindowArranged && pIsWindowArranged(hWnd) &&
MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST) != monitor) {
return TRUE;
}

if (g_settings.mode == Mode::intersected) {
RECT rc;
RECT intersectRect;
Expand Down Expand Up @@ -817,6 +825,12 @@ BOOL Wh_ModInit() {

LoadSettings();

HMODULE hUser32Module = LoadLibrary(L"user32.dll");
if (hUser32Module) {
pIsWindowArranged = (IsWindowArranged_t)GetProcAddress(
hUser32Module, "IsWindowArranged");
}

g_winVersion = GetExplorerVersion();
if (g_winVersion == WinVersion::Unsupported) {
Wh_Log(L"Unsupported Windows version");
Expand Down

0 comments on commit 1819258

Please sign in to comment.