mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
unify maximize/minimize procedure, remove dry run test code
This commit is contained in:
parent
4bceca33e6
commit
6619f7c205
2 changed files with 13 additions and 29 deletions
|
@ -90,7 +90,6 @@ namespace PersistentWindows.Common
|
|||
public bool restoringFromMem = false; // automatic restore from memory or snapshot
|
||||
public bool restoringFromDB = false; // manual restore from DB
|
||||
public bool restoringSnapshot = false; // implies restoringFromMem
|
||||
public bool dryRun = false; // only capturre, no actual restore
|
||||
public bool showDesktop = false; // show desktop when display changes
|
||||
public int fixZorder = 1; // 1 means restore z-order only for snapshot; 2 means restore z-order for all; 0 means no z-order restore at all
|
||||
public int fixZorderMethod = 5; // bit i represent restore method for pass i
|
||||
|
@ -3022,9 +3021,6 @@ namespace PersistentWindows.Common
|
|||
|
||||
if (IsTaskBar(hWnd))
|
||||
{
|
||||
if (dryRun)
|
||||
continue;
|
||||
|
||||
bool changed_edge = MoveTaskBar(hWnd, rect);
|
||||
bool changed_width = false;
|
||||
if (!remoteSession || restoringFromDB || restoringSnapshot)
|
||||
|
@ -3037,7 +3033,6 @@ namespace PersistentWindows.Common
|
|||
|
||||
changeIconText($"Restore {GetWindowTitle(hWnd)}");
|
||||
|
||||
if (!dryRun)
|
||||
{
|
||||
if (prevDisplayMetrics.IsMinimized)
|
||||
{
|
||||
|
@ -3079,7 +3074,7 @@ namespace PersistentWindows.Common
|
|||
|
||||
bool need_move_window = true;
|
||||
bool restore_fullscreen = false;
|
||||
if (prevDisplayMetrics.IsFullScreen && !prevDisplayMetrics.IsMinimized && !dryRun)
|
||||
if (prevDisplayMetrics.IsFullScreen && !prevDisplayMetrics.IsMinimized)
|
||||
{
|
||||
if (curDisplayMetrics.IsMinimized)
|
||||
{
|
||||
|
@ -3096,16 +3091,21 @@ namespace PersistentWindows.Common
|
|||
if (curDisplayMetrics.NeedUpdateWindowPlacement)
|
||||
{
|
||||
// recover NormalPosition (the workspace position prior to snap)
|
||||
if (windowPlacement.ShowCmd == ShowWindowCommands.Maximize && !dryRun)
|
||||
if (windowPlacement.ShowCmd == ShowWindowCommands.Maximize)
|
||||
{
|
||||
// When restoring maximized windows, it occasionally switches res and when the maximized setting is restored
|
||||
// the window thinks it's maximized, but does not eat all the real estate. So we'll temporarily unmaximize then
|
||||
// re-apply that
|
||||
//restore maximized window to correct monitor
|
||||
windowPlacement.ShowCmd = ShowWindowCommands.Normal;
|
||||
User32.SetWindowPlacement(hWnd, ref windowPlacement);
|
||||
windowPlacement.ShowCmd = ShowWindowCommands.Maximize;
|
||||
}
|
||||
else if (prevDisplayMetrics.IsFullScreen && !prevDisplayMetrics.IsMinimized && !dryRun)
|
||||
else if (prevDisplayMetrics.IsMinimized)
|
||||
{
|
||||
//restore minimized window button to correct taskbar
|
||||
windowPlacement.ShowCmd = ShowWindowCommands.Normal;
|
||||
User32.SetWindowPlacement(hWnd, ref windowPlacement);
|
||||
windowPlacement.ShowCmd = ShowWindowCommands.ShowMinimized;
|
||||
}
|
||||
else if (prevDisplayMetrics.IsFullScreen)
|
||||
{
|
||||
Log.Error("recover full screen window {0}", GetWindowTitle(hWnd));
|
||||
long style = User32.GetWindowLong(hWnd, User32.GWL_STYLE);
|
||||
|
@ -3132,24 +3132,14 @@ namespace PersistentWindows.Common
|
|||
}
|
||||
}
|
||||
|
||||
if (!dryRun && need_move_window)
|
||||
if (need_move_window)
|
||||
{
|
||||
if (prevDisplayMetrics.IsMinimized)
|
||||
{
|
||||
windowPlacement.ShowCmd = ShowWindowCommands.Normal;
|
||||
}
|
||||
success &= User32.SetWindowPlacement(hWnd, ref windowPlacement);
|
||||
|
||||
if (prevDisplayMetrics.IsMinimized)
|
||||
{
|
||||
windowPlacement.ShowCmd = ShowWindowCommands.ShowMinimized;
|
||||
success &= User32.SetWindowPlacement(hWnd, ref windowPlacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// recover previous screen position
|
||||
if (!dryRun && !prevDisplayMetrics.IsMinimized)
|
||||
if (!prevDisplayMetrics.IsMinimized)
|
||||
{
|
||||
if (need_move_window)
|
||||
{
|
||||
|
@ -3348,7 +3338,6 @@ namespace PersistentWindows.Common
|
|||
|
||||
if (!String.IsNullOrEmpty(curDisplayMetrics.ProcessExePath))
|
||||
{
|
||||
if (!dryRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace PersistentWindows.SystrayShell
|
|||
int halt_restore = 0; //seconds to wait before trying restore again, due to frequent monitor config changes
|
||||
string ignore_process = "";
|
||||
int debug_process = 0;
|
||||
bool dry_run = false; //dry run mode without real restore, for debug purpose only
|
||||
bool fix_zorder = false;
|
||||
bool fix_zorder_specified = false;
|
||||
bool show_desktop = false; //show desktop when display changes
|
||||
|
@ -181,9 +180,6 @@ namespace PersistentWindows.SystrayShell
|
|||
case "-notification=1":
|
||||
notification = true;
|
||||
break;
|
||||
case "-dry_run":
|
||||
dry_run = true;
|
||||
break;
|
||||
case "-fix_zorder=0":
|
||||
fix_zorder = false;
|
||||
fix_zorder_specified = true;
|
||||
|
@ -262,7 +258,6 @@ namespace PersistentWindows.SystrayShell
|
|||
systrayForm.upgradeNoticeMenuItem.Text = "Enable upgrade notice";
|
||||
|
||||
pwp.icon = IdleIcon;
|
||||
pwp.dryRun = dry_run;
|
||||
if (fix_zorder_specified)
|
||||
{
|
||||
if (fix_zorder)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue