WindowHelper.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Runtime.InteropServices; 6 7 namespace Microsoft.CmdPal.UI.Helpers; 8 9 internal sealed partial class WindowHelper 10 { 11 public static bool IsWindowFullscreen() 12 { 13 UserNotificationState state; 14 15 // https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ne-shellapi-query_user_notification_state 16 if (Marshal.GetExceptionForHR(NativeMethods.SHQueryUserNotificationState(out state)) is null) 17 { 18 if (state == UserNotificationState.QUNS_RUNNING_D3D_FULL_SCREEN || 19 state == UserNotificationState.QUNS_BUSY || 20 state == UserNotificationState.QUNS_PRESENTATION_MODE) 21 { 22 return true; 23 } 24 } 25 26 return false; 27 } 28 }