diff --git a/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs b/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs index c6dd2c33ad..5e6ff90c95 100644 --- a/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs +++ b/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs @@ -69,6 +69,9 @@ namespace PowerLauncher.Helper [DllImport("user32.DLL", CharSet = CharSet.Unicode)] internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); + [DllImport("shell32.dll")] + public static extern int SHQueryUserNotificationState(out UserNotificationState state); + public static string[] CommandLineToArgvW(string cmdLine) { IntPtr argv = IntPtr.Zero; @@ -242,4 +245,15 @@ namespace PowerLauncher.Helper TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024 APP = 0x8000, } + + internal enum UserNotificationState : int + { + QUNS_NOT_PRESENT = 1, + QUNS_BUSY, + QUNS_RUNNING_D3D_FULL_SCREEN, + QUNS_PRESENTATION_MODE, + QUNS_ACCEPTS_NOTIFICATIONS, + QUNS_QUIET_TIME, + QUNS_APP, + } } diff --git a/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs b/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs index 4c0819f203..612476daff 100644 --- a/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs +++ b/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs @@ -112,6 +112,15 @@ namespace PowerLauncher.Helper public static bool IsWindowFullscreen() { + // First, check to see if a game is fullscreen, if so, we definitely have + // a full-screen window + UserNotificationState state; + if (Marshal.GetExceptionForHR(NativeMethods.SHQueryUserNotificationState(out state)) == null && + state == UserNotificationState.QUNS_RUNNING_D3D_FULL_SCREEN) + { + return true; + } + // get current active window IntPtr hWnd = NativeMethods.GetForegroundWindow();