Skip to content

Commit f9c1d34

Browse files
committed
Add additional attempt to restore window size and position as a bypass for some linux compositors (the attempt will be made on all os)
1 parent a12c657 commit f9c1d34

2 files changed

Lines changed: 45 additions & 36 deletions

File tree

src/IronyModManager.Services/ModBaseService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
using System.Threading;
2323
using System.Threading.Tasks;
2424
using AutoMapper;
25-
using CWTools.Common;
2625
using IronyModManager.DI;
2726
using IronyModManager.IO.Common.Mods;
2827
using IronyModManager.IO.Common.Readers;
@@ -619,7 +618,7 @@ protected virtual IEnumerable<IMod> GetInstalledModsInternal(IGame game, bool ig
619618
var installedMods = Reader.Read(Path.Combine(game.UserDirectory, game.ModDescriptorType == ModDescriptorType.DescriptorMod ? Shared.Constants.ModDirectory : Shared.Constants.JsonModDirectory));
620619
if (installedMods?.Count() > 0)
621620
{
622-
var args = new ModParserArgs { BaseSteamDirectory = game.BaseSteamGameDirectory, IsProton = !string.IsNullOrWhiteSpace(game.LinuxProtonVersion), SteamAppId = game.SteamAppId};
621+
var args = new ModParserArgs { BaseSteamDirectory = game.BaseSteamGameDirectory, IsProton = !string.IsNullOrWhiteSpace(game.LinuxProtonVersion), SteamAppId = game.SteamAppId };
623622
installedMods.Where(p => p.Content.Any()).AsParallel().WithDegreeOfParallelism(MaxModsToProcess).ForAll(installedMod =>
624623
{
625624
var mod = Mapper.Map<IMod>(ModParser.Parse(installedMod.Content, MapDescriptorModType(game.ModDescriptorType), args));

src/IronyModManager/Views/MainWindow.xaml.cs

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 01-10-2020
55
//
66
// Last Modified By : Mario
7-
// Last Modified On : 03-11-2024
7+
// Last Modified On : 05-18-2026
88
// ***********************************************************************
99
// <copyright file="MainWindow.xaml.cs" company="Mario">
1010
// Mario
@@ -102,32 +102,6 @@ public MainWindow()
102102

103103
#region Methods
104104

105-
/// <summary>
106-
/// Handles the <see cref="E:Closing" /> event.
107-
/// </summary>
108-
/// <param name="e">The <see cref="CancelEventArgs" /> instance containing the event data.</param>
109-
/// <remarks>A type that derives from <see cref="T:Avalonia.Controls.Window" /> may override <see cref="M:Avalonia.Controls.Window.OnClosing(System.ComponentModel.CancelEventArgs)" />. The
110-
/// overridden method must call <see cref="M:Avalonia.Controls.Window.OnClosing(System.ComponentModel.CancelEventArgs)" /> on the base class if the
111-
/// <see cref="E:Avalonia.Controls.Window.Closing" /> event needs to be raised.</remarks>
112-
protected override void OnClosing(CancelEventArgs e)
113-
{
114-
if (preventShutdown)
115-
{
116-
e.Cancel = true;
117-
shutdownRequested = true;
118-
var locManager = DIResolver.Get<ILocalizationManager>();
119-
var message = locManager.GetResource(LocalizationResources.App.BackgroundOperationMessage);
120-
var id = DIResolver.Get<IIDGenerator>().GetNextId();
121-
ViewModel!.TriggerManualOverlay(id, true, message);
122-
}
123-
else
124-
{
125-
SaveWindowState();
126-
}
127-
128-
base.OnClosing(e);
129-
}
130-
131105
/// <summary>
132106
/// Gets the enter key gestures.
133107
/// </summary>
@@ -323,6 +297,32 @@ protected override void OnActivated(CompositeDisposable disposables)
323297
base.OnActivated(disposables);
324298
}
325299

300+
/// <summary>
301+
/// Handles the <see cref="E:Closing" /> event.
302+
/// </summary>
303+
/// <param name="e">The <see cref="CancelEventArgs" /> instance containing the event data.</param>
304+
/// <remarks>A type that derives from <see cref="T:Avalonia.Controls.Window" /> may override <see cref="M:Avalonia.Controls.Window.OnClosing(System.ComponentModel.CancelEventArgs)" />. The
305+
/// overridden method must call <see cref="M:Avalonia.Controls.Window.OnClosing(System.ComponentModel.CancelEventArgs)" /> on the base class if the
306+
/// <see cref="E:Avalonia.Controls.Window.Closing" /> event needs to be raised.</remarks>
307+
protected override void OnClosing(CancelEventArgs e)
308+
{
309+
if (preventShutdown)
310+
{
311+
e.Cancel = true;
312+
shutdownRequested = true;
313+
var locManager = DIResolver.Get<ILocalizationManager>();
314+
var message = locManager.GetResource(LocalizationResources.App.BackgroundOperationMessage);
315+
var id = DIResolver.Get<IIDGenerator>().GetNextId();
316+
ViewModel!.TriggerManualOverlay(id, true, message);
317+
}
318+
else
319+
{
320+
SaveWindowState();
321+
}
322+
323+
base.OnClosing(e);
324+
}
325+
326326
/// <summary>
327327
/// Called when [property changed].
328328
/// </summary>
@@ -346,19 +346,29 @@ protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T>
346346
private void InitializeComponent()
347347
{
348348
AvaloniaXamlLoader.Load(this);
349+
349350
if (!Design.IsDesignMode)
350351
{
351-
InitWindowSize();
352+
Opened += async (_, _) =>
353+
{
354+
await Dispatcher.UIThread.InvokeAsync(InitWindowSize, DispatcherPriority.Loaded);
355+
};
352356
}
353357

354-
if (WindowState != WindowState.Minimized)
355-
{
356-
ActualState = WindowState;
357-
}
358-
else
358+
InitializeWindowState();
359+
}
360+
361+
/// <summary>
362+
/// Initializes the state of the window.
363+
/// </summary>
364+
private void InitializeWindowState()
365+
{
366+
if (!Design.IsDesignMode)
359367
{
360-
ActualState = WindowState.Normal;
368+
InitWindowSize();
361369
}
370+
371+
ActualState = WindowState != WindowState.Minimized ? WindowState : WindowState.Normal;
362372
}
363373

364374
/// <summary>

0 commit comments

Comments
 (0)