Skip to content

Commit

Permalink
ignore full screen window
Browse files Browse the repository at this point in the history
  • Loading branch information
TransposonY committed Jan 16, 2018
1 parent 7d25c55 commit 6a021dd
Showing 7 changed files with 83 additions and 0 deletions.
34 changes: 34 additions & 0 deletions GestureSign.Common/Applications/ApplicationManager.cs
Original file line number Diff line number Diff line change
@@ -96,6 +96,11 @@ protected void PointCapture_CaptureStarted(object sender, PointsCapturedEventArg

foreach (IApplication app in _recognizedApplication)
{
if (app is GlobalApp && AppConfig.IgnoreFullScreen && IsFullScreenWindow(CaptureWindow))
{
e.Cancel = true;
return;
}
var userApplication = app as UserApp;
if (userApplication != null)
{
@@ -585,6 +590,35 @@ private List<IAction> ConvertLegacyActions(List<GestureSign.Applications.Action>
return newActions;
}

private bool IsFullScreenWindow(SystemWindow window)
{
var deskWindow = SystemWindow.DesktopWindow;

if (window.HWnd == IntPtr.Zero || window == deskWindow || window == SystemWindow.ShellWindow)
return false;

var desktopRect = deskWindow.Rectangle;
var windowRect = window.Rectangle;

if (windowRect.Left == 0 && windowRect.Top == 0 && windowRect.Right == desktopRect.Right && windowRect.Bottom == desktopRect.Bottom)
{
switch (window.ClassName)
{
case "Windows.UI.Core.CoreWindow":
case "ApplicationFrameWindow":
case "WorkerW":
case "Progman":
case "CanvasWindow":
case "ImmersiveLauncher":
return false;
default:
return true;
}
}

return false;
}

#endregion

#region P/Invoke
12 changes: 12 additions & 0 deletions GestureSign.Common/Configuration/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -177,6 +177,18 @@ public static bool RegisterTouchPad
}
}

public static bool IgnoreFullScreen
{
get
{
return GetValue(nameof(IgnoreFullScreen), true);
}
set
{
SetValue(nameof(IgnoreFullScreen), value);
}
}

static AppConfig()
{
#if uiAccess
3 changes: 3 additions & 0 deletions GestureSign.ControlPanel/Languages/ControlPanel/en.xml
Original file line number Diff line number Diff line change
@@ -237,6 +237,9 @@ Email:[email protected]
<WindowsStartup>
<Header>Start GestureSign on Windows Startup</Header>
</WindowsStartup>
<IgnoreFullScreen>
<Header>Ignore Full Screen Window</Header>
</IgnoreFullScreen>
<ShowTrayIconSwitch>
<Header>Show Tray Icon</Header>
<OnLabel>Show</OnLabel>
3 changes: 3 additions & 0 deletions GestureSign.ControlPanel/Languages/ControlPanel/zh.xml
Original file line number Diff line number Diff line change
@@ -241,6 +241,9 @@
<WindowsStartup>
<Header>开机启动</Header>
</WindowsStartup>
<IgnoreFullScreen>
<Header>全屏下关闭手势识别</Header>
</IgnoreFullScreen>
<ShowTrayIconSwitch>
<Header>任务栏图标</Header>
<OnLabel>显示</OnLabel>
6 changes: 6 additions & 0 deletions GestureSign.ControlPanel/MainWindowControls/Options.cs
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ private void LoadSettings()
ShowTrayIconSwitch.IsChecked = AppConfig.ShowTrayIcon;
SendLogToggleSwitch.IsChecked = AppConfig.SendErrorReport;
TouchPadSwitch.IsChecked = AppConfig.RegisterTouchPad;
IgnoreFullScreenSwitch.IsChecked = AppConfig.IgnoreFullScreen;
if (AppConfig.DrawingButton != MouseActions.None)
{
MouseSwitch.IsChecked = true;
@@ -326,6 +327,11 @@ private void TouchPadSwitch_Click(object sender, RoutedEventArgs e)
AppConfig.RegisterTouchPad = TouchPadSwitch.IsChecked != null && TouchPadSwitch.IsChecked.Value;
}

private void IgnoreFullScreenSwitch_Click(object sender, RoutedEventArgs e)
{
AppConfig.IgnoreFullScreen = IgnoreFullScreenSwitch.IsChecked.GetValueOrDefault();
}

private void InitialTimeoutSwitch_Click(object sender, RoutedEventArgs e)
{
if (InitialTimeoutSwitch.IsChecked.GetValueOrDefault())
9 changes: 9 additions & 0 deletions GestureSign.ControlPanel/MainWindowControls/Options.xaml
Original file line number Diff line number Diff line change
@@ -195,6 +195,15 @@
Click="StartupSwitch_OnClick"
Width="300"
FontWeight="Bold" />
<controls:ToggleSwitch x:Name="IgnoreFullScreenSwitch"
Header="{localization:LocalisedText Options.IgnoreFullScreen.Header}"
OnLabel="{localization:LocalisedText Options.OnLabel}"
OffLabel="{localization:LocalisedText Options.OffLabel}"
Margin="0,10,0,0"
FontSize="14"
Click="IgnoreFullScreenSwitch_Click"
Width="300"
FontWeight="Bold" />
<controls:ToggleSwitch x:Name="ShowTrayIconSwitch"
Header="{localization:LocalisedText Options.ShowTrayIconSwitch.Header}"
OnLabel="{localization:LocalisedText Options.ShowTrayIconSwitch.OnLabel}"
16 changes: 16 additions & 0 deletions ManagedWinapi/Windows/SystemWindow.cs
Original file line number Diff line number Diff line change
@@ -326,6 +326,19 @@ public static SystemWindow DesktopWindow
}
}

/// <summary>
/// Retrieves a handle to the Shell's desktop window.
/// Go to https://msdn.microsoft.com/en-us/library/windows/desktop/ms633512%28v=vs.85%29.aspx for more
/// information
/// </summary>
public static SystemWindow ShellWindow
{
get
{
return new SystemWindow(GetShellWindow());
}
}

/// <summary>
/// Returns all available toplevel windows.
/// </summary>
@@ -1513,6 +1526,9 @@ private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int
[DllImport("user32.dll", SetLastError = false)]
static extern IntPtr GetDesktopWindow();

[DllImport("user32.dll")]
static extern IntPtr GetShellWindow();

[DllImport("user32.dll")]
static extern IntPtr GetDC(IntPtr hWnd);

0 comments on commit 6a021dd

Please sign in to comment.