aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2019-07-20 21:08:30 +0900
committerKazuki Yamaguchi <k@rhe.jp>2019-07-20 21:08:30 +0900
commit1776cf037027d2c11c0d0606d1cda3297778a705 (patch)
tree63a50cfd8674a4050918d702b34927a004457bd2
parent0394bad2130627e5a3fbd189becafd84be2ddda9 (diff)
downloadwf-clock-1776cf037027d2c11c0d0606d1cda3297778a705.tar.gz
use WS_EX_NOACTIVATE extended window style
Maybe this will fix the unfocusing issue. Maybe not. Not sure because I haven't experienced that myself.
-rw-r--r--WarframeClock/Native.cs6
-rw-r--r--WarframeClock/OverlayWindow.xaml.cs5
-rw-r--r--WarframeClock/OverlayWindowBase.cs14
3 files changed, 22 insertions, 3 deletions
diff --git a/WarframeClock/Native.cs b/WarframeClock/Native.cs
index cebe362..c18e3f7 100644
--- a/WarframeClock/Native.cs
+++ b/WarframeClock/Native.cs
@@ -11,6 +11,12 @@ namespace WarframeClock
uint uFlags);
[DllImport("user32.dll")]
+ public static extern int GetWindowLong(IntPtr hwnd, int index);
+
+ [DllImport("user32.dll")]
+ public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
+
+ [DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
diff --git a/WarframeClock/OverlayWindow.xaml.cs b/WarframeClock/OverlayWindow.xaml.cs
index c2030da..20f5eb3 100644
--- a/WarframeClock/OverlayWindow.xaml.cs
+++ b/WarframeClock/OverlayWindow.xaml.cs
@@ -38,6 +38,11 @@ namespace WarframeClock
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(100), DispatcherPriority.Background,
UpdateTimerTick, Dispatcher.CurrentDispatcher);
+ }
+
+ protected override void OnSourceInitialized(EventArgs e)
+ {
+ base.OnSourceInitialized(e);
_updateTimer.Start();
}
diff --git a/WarframeClock/OverlayWindowBase.cs b/WarframeClock/OverlayWindowBase.cs
index 27d06fe..5859e81 100644
--- a/WarframeClock/OverlayWindowBase.cs
+++ b/WarframeClock/OverlayWindowBase.cs
@@ -17,11 +17,19 @@ namespace WarframeClock
_xTopmost = false;
}
- protected bool AdjustOverlay()
+ protected override void OnSourceInitialized(EventArgs e)
{
- if (_windowHandle == IntPtr.Zero)
- _windowHandle = new WindowInteropHelper(this).EnsureHandle();
+ base.OnSourceInitialized(e);
+ _windowHandle = new WindowInteropHelper(this).EnsureHandle();
+
+ const int WS_EX_NOACTIVATE = 0x08000000;
+ const int GWL_EXSTYLE = -20;
+ int exStyle = Native.GetWindowLong(_windowHandle, GWL_EXSTYLE);
+ Native.SetWindowLong(_windowHandle, GWL_EXSTYLE, exStyle | WS_EX_NOACTIVATE);
+ }
+ protected bool AdjustOverlay()
+ {
if (!GetTargetWindow(out var newBounds))
{
if (IsVisible)