mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 21:15:38 +02:00
yield foreground window when drifting out of browser window
This commit is contained in:
parent
873bec0b32
commit
55e2ff2356
3 changed files with 16 additions and 5 deletions
|
@ -489,7 +489,7 @@ namespace PersistentWindows.Common
|
|||
{
|
||||
if (stay)
|
||||
{
|
||||
if (tiny)
|
||||
if (tiny && Visible)
|
||||
{
|
||||
POINT cursorPos;
|
||||
User32.GetCursorPos(out cursorPos);
|
||||
|
@ -498,7 +498,17 @@ namespace PersistentWindows.Common
|
|||
StartAliveTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
IntPtr fgwnd = GetForegroundWindow();
|
||||
IntPtr cursorWnd = User32.WindowFromPoint(cursorPos);
|
||||
if (cursorWnd != Handle && cursorWnd != fgwnd && User32.GetAncestor(cursorWnd, User32.GetAncestorRoot) != fgwnd)
|
||||
{
|
||||
//yield focus
|
||||
User32.SetForegroundWindow(fgwnd);
|
||||
StartAliveTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (PersistentWindowProcessor.IsBrowserWindow(fgwnd))
|
||||
{
|
||||
IntPtr hCursor = GetCursor();
|
||||
|
|
|
@ -1264,7 +1264,7 @@ namespace PersistentWindows.Common
|
|||
if (IsTaskBar(hwnd))
|
||||
return true;
|
||||
|
||||
if (User32.GetAncestor(hwnd, 1) != desktopWindow)
|
||||
if (User32.GetAncestor(hwnd, User32.GetAncestorParent) != desktopWindow)
|
||||
return false;
|
||||
|
||||
long style = User32.GetWindowLong(hwnd, User32.GWL_STYLE);
|
||||
|
@ -3963,7 +3963,7 @@ namespace PersistentWindows.Common
|
|||
|
||||
public static bool IsDesktopWindow(IntPtr hwnd)
|
||||
{
|
||||
IntPtr root = User32.GetAncestor(hwnd, 2);
|
||||
IntPtr root = User32.GetAncestor(hwnd, User32.GetAncestorRoot);
|
||||
return root == vacantDeskWindow;
|
||||
}
|
||||
|
||||
|
|
|
@ -483,8 +483,9 @@ namespace PersistentWindows.Common.WinApiBridge
|
|||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetAncestor(IntPtr hWnd, uint gaFlags); // I'm too lazy to write an enum for them
|
||||
public const int GetRoot = 2;
|
||||
public const int GetRootOwner = 3;
|
||||
public const int GetAncestorParent = 1;
|
||||
public const int GetAncestorRoot = 2;
|
||||
public const int GetAncestorRootOwner = 3;
|
||||
|
||||
public const int ICON_SMALL = 0;
|
||||
public const int ICON_BIG = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue