mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
Fix restoring window state when window starts minimized
Only start minimized when starting at Windows start-up
This commit is contained in:
+19
-32
@@ -26,20 +26,7 @@ namespace VRCX
|
|||||||
private int LastLocationY;
|
private int LastLocationY;
|
||||||
private int LastSizeWidth;
|
private int LastSizeWidth;
|
||||||
private int LastSizeHeight;
|
private int LastSizeHeight;
|
||||||
|
private FormWindowState LastWindowStateToRestore = FormWindowState.Normal;
|
||||||
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()
|
public MainForm()
|
||||||
{
|
{
|
||||||
@@ -119,25 +106,28 @@ namespace VRCX
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = WindowState;
|
var state = WindowState;
|
||||||
if (int.TryParse(VRCXStorage.Instance.Get("VRCX_WindowState"), out int v))
|
var startAsMinimized = VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState") == "true";
|
||||||
|
var closeToTray = VRCXStorage.Instance.Get("VRCX_CloseToTray") == "true";
|
||||||
|
if (int.TryParse(VRCXStorage.Instance.Get("VRCX_WindowState"), out var value))
|
||||||
{
|
{
|
||||||
state = (FormWindowState)v;
|
state = (FormWindowState)value;
|
||||||
}
|
}
|
||||||
if (state == FormWindowState.Minimized)
|
if (state == FormWindowState.Minimized)
|
||||||
{
|
{
|
||||||
state = FormWindowState.Normal;
|
state = FormWindowState.Normal;
|
||||||
}
|
}
|
||||||
if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")))
|
// Apply WindowState twice to maximize before minimize
|
||||||
|
WindowState = state;
|
||||||
|
LastWindowStateToRestore = state;
|
||||||
|
|
||||||
|
if (StartupArgs.LaunchArguments.IsStartup && startAsMinimized)
|
||||||
{
|
{
|
||||||
|
if (closeToTray)
|
||||||
|
{
|
||||||
|
BeginInvoke(Hide);
|
||||||
|
return;
|
||||||
|
}
|
||||||
state = FormWindowState.Minimized;
|
state = FormWindowState.Minimized;
|
||||||
}
|
|
||||||
if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")) &&
|
|
||||||
"true".Equals(VRCXStorage.Instance.Get("VRCX_CloseToTray")))
|
|
||||||
{
|
|
||||||
BeginInvoke(Hide);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WindowState = state;
|
WindowState = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,20 +136,17 @@ namespace VRCX
|
|||||||
logger.Error(ex);
|
logger.Error(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
LastWindowStateToRestore = WindowState;
|
|
||||||
|
|
||||||
// 가끔 화면 위치가 안맞음.. 이걸로 해결 될지는 모르겠음
|
|
||||||
Browser.Invalidate();
|
Browser.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Resize(object sender, System.EventArgs e)
|
private void MainForm_Resize(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
LastWindowStateToRestore = WindowState;
|
if (WindowState != FormWindowState.Minimized)
|
||||||
|
LastWindowStateToRestore = WindowState;
|
||||||
|
|
||||||
if (WindowState != FormWindowState.Normal)
|
if (WindowState != FormWindowState.Normal)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
LastSizeWidth = Size.Width;
|
LastSizeWidth = Size.Width;
|
||||||
LastSizeHeight = Size.Height;
|
LastSizeHeight = Size.Height;
|
||||||
|
|
||||||
@@ -200,7 +187,7 @@ namespace VRCX
|
|||||||
VRCXStorage.Instance.Set("VRCX_LocationY", LastLocationY.ToString());
|
VRCXStorage.Instance.Set("VRCX_LocationY", LastLocationY.ToString());
|
||||||
VRCXStorage.Instance.Set("VRCX_SizeWidth", LastSizeWidth.ToString());
|
VRCXStorage.Instance.Set("VRCX_SizeWidth", LastSizeWidth.ToString());
|
||||||
VRCXStorage.Instance.Set("VRCX_SizeHeight", LastSizeHeight.ToString());
|
VRCXStorage.Instance.Set("VRCX_SizeHeight", LastSizeHeight.ToString());
|
||||||
VRCXStorage.Instance.Set("VRCX_WindowState", ((int)WindowState).ToString());
|
VRCXStorage.Instance.Set("VRCX_WindowState", ((int)LastWindowStateToRestore).ToString());
|
||||||
VRCXStorage.Instance.Flush();
|
VRCXStorage.Instance.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ namespace VRCX
|
|||||||
var arguments = new VrcxLaunchArguments();
|
var arguments = new VrcxLaunchArguments();
|
||||||
foreach (var arg in args)
|
foreach (var arg in args)
|
||||||
{
|
{
|
||||||
|
if (arg == VrcxLaunchArguments.IsStartupPrefix)
|
||||||
|
arguments.IsStartup = true;
|
||||||
|
|
||||||
if (arg == VrcxLaunchArguments.IsUpgradePrefix)
|
if (arg == VrcxLaunchArguments.IsUpgradePrefix)
|
||||||
arguments.IsUpgrade = true;
|
arguments.IsUpgrade = true;
|
||||||
|
|
||||||
@@ -95,6 +98,9 @@ namespace VRCX
|
|||||||
|
|
||||||
internal class VrcxLaunchArguments
|
internal class VrcxLaunchArguments
|
||||||
{
|
{
|
||||||
|
public const string IsStartupPrefix = "--startup";
|
||||||
|
public bool IsStartup { get; set; } = false;
|
||||||
|
|
||||||
public const string IsUpgradePrefix = "/Upgrade";
|
public const string IsUpgradePrefix = "/Upgrade";
|
||||||
public bool IsUpgrade { get; set; } = false;
|
public bool IsUpgrade { get; set; } = false;
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -2672,10 +2672,11 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
|
|
||||||
$app.data.vrcxId = '';
|
$app.data.vrcxId = '';
|
||||||
$app.methods.loadVrcxId = async function () {
|
$app.methods.loadVrcxId = async function () {
|
||||||
this.vrcxId = await configRepository.getString(
|
this.vrcxId = await configRepository.getString('VRCX_id', '');
|
||||||
'VRCX_id',
|
if (!this.vrcxId) {
|
||||||
crypto.randomUUID()
|
this.vrcxId = crypto.randomUUID();
|
||||||
);
|
await configRepository.setString('VRCX_id', this.vrcxId);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.updateIsGameRunning = async function (
|
$app.methods.updateIsGameRunning = async function (
|
||||||
@@ -7308,7 +7309,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
$app.data.isStartAsMinimizedState =
|
$app.data.isStartAsMinimizedState =
|
||||||
(await VRCXStorage.Get('VRCX_StartAsMinimizedState')) === 'true';
|
(await VRCXStorage.Get('VRCX_StartAsMinimizedState')) === 'true';
|
||||||
$app.data.isCloseToTray =
|
$app.data.isCloseToTray =
|
||||||
(await VRCXStorage.Get('VRCX_CloseToTray')) === 'true';
|
(await VRCXStorage.Get('VRCX_CloseToTray')) === 'false';
|
||||||
if (await configRepository.getBool('VRCX_CloseToTray')) {
|
if (await configRepository.getBool('VRCX_CloseToTray')) {
|
||||||
// move back to JSON
|
// move back to JSON
|
||||||
$app.data.isCloseToTray =
|
$app.data.isCloseToTray =
|
||||||
|
|||||||
Reference in New Issue
Block a user