mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
Fixed window will never show up again if the window is closed when minimized (#977)
* `Show()` must be called before changing `WindowState`, otherwise the internal state of the window will be messed up. If you don't do this, when the window is closed when minimized, even if you click the tray menu icon, it will never show up. * Remember window state before minimized. If window was maximized before minimized, it should be restore to maximized when `Focus_Window` called.
This commit is contained in:
@@ -25,11 +25,25 @@ namespace VRCX
|
||||
private int LastSizeWidth;
|
||||
private int LastSizeHeight;
|
||||
|
||||
private FormWindowState _LastWindowStateToRestore = FormWindowState.Normal;
|
||||
private FormWindowState LastWindowStateToRestore
|
||||
{
|
||||
get => _LastWindowStateToRestore;
|
||||
set
|
||||
{
|
||||
// Used to restore window state after minimized
|
||||
if (FormWindowState.Minimized != value)
|
||||
{
|
||||
_LastWindowStateToRestore = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
Instance = this;
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
// adding a 5s delay here to avoid excessive writes to disk
|
||||
_saveTimer = new Timer();
|
||||
_saveTimer.Interval = 5000;
|
||||
@@ -129,28 +143,32 @@ namespace VRCX
|
||||
jslogger.Error(ex);
|
||||
}
|
||||
|
||||
LastWindowStateToRestore = WindowState;
|
||||
|
||||
// 가끔 화면 위치가 안맞음.. 이걸로 해결 될지는 모르겠음
|
||||
Browser.Invalidate();
|
||||
}
|
||||
|
||||
private void MainForm_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
LastWindowStateToRestore = WindowState;
|
||||
|
||||
if (WindowState != FormWindowState.Normal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LastSizeWidth = Size.Width;
|
||||
LastSizeHeight = Size.Height;
|
||||
|
||||
|
||||
_saveTimer?.Start();
|
||||
}
|
||||
|
||||
|
||||
private void SaveTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
SaveWindowState();
|
||||
_saveTimer?.Stop();
|
||||
}
|
||||
|
||||
|
||||
private void MainForm_Move(object sender, System.EventArgs e)
|
||||
{
|
||||
if (WindowState != FormWindowState.Normal)
|
||||
@@ -159,7 +177,7 @@ namespace VRCX
|
||||
}
|
||||
LastLocationX = Location.X;
|
||||
LastLocationY = Location.Y;
|
||||
|
||||
|
||||
_saveTimer?.Start();
|
||||
}
|
||||
|
||||
@@ -172,7 +190,7 @@ namespace VRCX
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SaveWindowState()
|
||||
{
|
||||
VRCXStorage.Instance.Set("VRCX_LocationX", LastLocationX.ToString());
|
||||
@@ -203,11 +221,11 @@ namespace VRCX
|
||||
|
||||
public void Focus_Window()
|
||||
{
|
||||
Show();
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
WindowState = LastWindowStateToRestore;
|
||||
}
|
||||
Show();
|
||||
// Focus();
|
||||
Activate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user