|
19 | 19 | using System.Windows;
|
20 | 20 | using System.Windows.Input;
|
21 | 21 | using System.Windows.Interop;
|
| 22 | +using System.Windows.Media; |
22 | 23 | using System.Windows.Media.Animation;
|
23 | 24 | using QuickLook.Common.ExtensionMethods;
|
24 | 25 | using QuickLook.Common.Helpers;
|
25 | 26 | using QuickLook.Common.Plugin;
|
26 | 27 | using QuickLook.Helpers;
|
27 |
| -using Brush = System.Windows.Media.Brush; |
28 |
| -using FontFamily = System.Windows.Media.FontFamily; |
29 |
| -using Size = System.Windows.Size; |
30 | 28 |
|
31 | 29 | namespace QuickLook
|
32 | 30 | {
|
@@ -58,10 +56,12 @@ internal ViewerWindow()
|
58 | 56 |
|
59 | 57 | // bring the window to top when users click in the client area.
|
60 | 58 | // the non-client area is handled by the WndProc inside OnSourceInitialized().
|
61 |
| - PreviewMouseDown += (sender, e) => this.BringToFront(false); |
| 59 | + // This is buggy for Windows 7 and 8: https://github.com/QL-Win/QuickLook/issues/644#issuecomment-628921704 |
| 60 | + if (App.IsWin10) |
| 61 | + PreviewMouseDown += (sender, e) => this.BringToFront(false); |
62 | 62 |
|
63 | 63 | windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;
|
64 |
| - |
| 64 | + |
65 | 65 | Topmost = SettingHelper.Get("Topmost", false);
|
66 | 66 | buttonTop.Tag = Topmost ? "Top" : "Auto";
|
67 | 67 |
|
@@ -108,20 +108,25 @@ protected override void OnSourceInitialized(EventArgs e)
|
108 | 108 | {
|
109 | 109 | base.OnSourceInitialized(e);
|
110 | 110 |
|
111 |
| - this.SetNoactivate(); |
| 111 | + // The non-focusable trick is buggy for Windows 7 and 8 |
| 112 | + // https://github.com/QL-Win/QuickLook/issues/644#issuecomment-628921704 |
| 113 | + if (App.IsWin10) |
| 114 | + { |
| 115 | + this.SetNoactivate(); |
112 | 116 |
|
113 |
| - HwndSource.FromHwnd(new WindowInteropHelper(this).Handle)?.AddHook( |
114 |
| - (IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) => |
115 |
| - { |
116 |
| - switch (msg) |
| 117 | + HwndSource.FromHwnd(new WindowInteropHelper(this).Handle)?.AddHook( |
| 118 | + (IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) => |
117 | 119 | {
|
118 |
| - case 0x0112: // WM_SYSCOMMAND |
119 |
| - this.BringToFront(false); |
120 |
| - break; |
121 |
| - } |
122 |
| - |
123 |
| - return IntPtr.Zero; |
124 |
| - }); |
| 120 | + switch (msg) |
| 121 | + { |
| 122 | + case 0x0112: // WM_SYSCOMMAND |
| 123 | + this.BringToFront(false); |
| 124 | + break; |
| 125 | + } |
| 126 | + |
| 127 | + return IntPtr.Zero; |
| 128 | + }); |
| 129 | + } |
125 | 130 | }
|
126 | 131 |
|
127 | 132 | public override void OnApplyTemplate()
|
|
0 commit comments