mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
new feature: shift click PW icon to center foreground window
This commit is contained in:
parent
83e3ef4cc8
commit
984c89e099
3 changed files with 16 additions and 3 deletions
|
@ -947,6 +947,14 @@ namespace PersistentWindows.Common
|
|||
return offscreen;
|
||||
}
|
||||
|
||||
public void CenterWindow(IntPtr hwnd)
|
||||
{
|
||||
IntPtr desktopWindow = User32.GetDesktopWindow();
|
||||
RECT target_rect = new RECT();
|
||||
User32.GetWindowRect(desktopWindow, ref target_rect);
|
||||
User32.MoveWindow(hwnd, target_rect.Left + target_rect.Width / 4, target_rect.Top + target_rect.Height / 4, target_rect.Width / 2, target_rect.Height / 2, true);
|
||||
}
|
||||
|
||||
public bool RecallLastKilledPosition(IntPtr hwnd)
|
||||
{
|
||||
if (deadApps.ContainsKey(curDisplayKey))
|
||||
|
@ -1202,9 +1210,7 @@ namespace PersistentWindows.Common
|
|||
|
||||
if (IsOffScreen(hwnd))
|
||||
{
|
||||
IntPtr desktopWindow = User32.GetDesktopWindow();
|
||||
User32.GetWindowRect(desktopWindow, ref target_rect);
|
||||
User32.MoveWindow(hwnd, target_rect.Left + 50, target_rect.Top + 50, target_rect.Width * 3 / 4, target_rect.Height * 3 / 4, true);
|
||||
CenterWindow(hwnd);
|
||||
Log.Error("fix invisible window \"{0}\"", GetWindowTitle(hwnd));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -622,6 +622,11 @@ namespace PersistentWindows.SystrayShell
|
|||
pwp.RecallLastKilledPosition(pwp.GetForegroundWindow());
|
||||
}
|
||||
|
||||
static public void CenterWindow()
|
||||
{
|
||||
pwp.CenterWindow(pwp.GetForegroundWindow());
|
||||
}
|
||||
|
||||
static public void PauseAutoRestore()
|
||||
{
|
||||
pwp.pauseAutoRestore = true;
|
||||
|
|
|
@ -116,6 +116,8 @@ namespace PersistentWindows.SystrayShell
|
|||
Program.FgWindowToBottom();
|
||||
else if (ctrlKeyPressed > 0 && altKeyPressed == 0 && shiftKeyPressed == 0)
|
||||
Program.RecallLastKilledPosition();
|
||||
else if (ctrlKeyPressed == 0 && altKeyPressed == 0 && shiftKeyPressed > 0)
|
||||
Program.CenterWindow();
|
||||
else if (ctrlKeyPressed == 0 && altKeyPressed == 0 && shiftKeyPressed == 0)
|
||||
//restore unnamed(default) snapshot
|
||||
Program.RestoreSnapshot(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue