From 5590e97f4fe5b8956ca45799f48d470ba4f9f52f Mon Sep 17 00:00:00 2001 From: Myned Date: Sat, 6 Jun 2020 18:39:57 -0400 Subject: [PATCH] Fix fullscreen check only returning true if window is focused on Windows by @WarmUpTill --- src/win/advanced-scene-switcher-win.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/win/advanced-scene-switcher-win.cpp b/src/win/advanced-scene-switcher-win.cpp index 7cdfb8a1..35f7ec82 100644 --- a/src/win/advanced-scene-switcher-win.cpp +++ b/src/win/advanced-scene-switcher-win.cpp @@ -105,22 +105,36 @@ pair getCursorPos() return pos; } -// Argument added in lieu of fullscreen bug fix bool isFullscreen(std::string &title) { RECT appBounds; RECT rc; + + HWND hwnd = GetWindow(GetDesktopWindow(), GW_CHILD); + while (hwnd) + { + string wtitle; + if (WindowValid(hwnd) && GetWindowTitle(hwnd, wtitle) && wtitle == title) + break; + + hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); + } + GetWindowRect(GetDesktopWindow(), &rc); - HWND hwnd = GetForegroundWindow(); if (hwnd != GetDesktopWindow() && hwnd != GetShellWindow()) { GetWindowRect(hwnd, &appBounds); - if (rc.bottom == appBounds.bottom && rc.top == appBounds.top && rc.left == appBounds.left - && rc.right == appBounds.right) - { + if + ( + rc.bottom == appBounds.bottom + && rc.top == appBounds.top + && rc.left == appBounds.left + && rc.right == appBounds.right + ) { return true; } } + return false; }