Преглед на файлове

Fix wrong position when restoring window by fixing timing issue #227

Ruben преди 3 месеца
родител
ревизия
a7e4131585
променени са 1 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 7 3
      src/PicView.Avalonia.Win32/WindowImpl/Win32Window.cs

+ 7 - 3
src/PicView.Avalonia.Win32/WindowImpl/Win32Window.cs

@@ -15,6 +15,7 @@ public static class Win32Window
     public static async Task Fullscreen(Window window, MainViewModel vm, bool saveSettings = true)
     {
         IsChangingWindowState = true;
+        
         // Save window size, so that restoring it will return to the same size and position
         WindowResizing.SaveSize(window);
 
@@ -45,7 +46,8 @@ public static class Win32Window
         // Fixes https://github.com/Ruben2776/PicView/issues/226
         await WindowFunctions.ResizeAndFixRenderingError(vm);
 
-        IsChangingWindowState = false;
+        Dispatcher.UIThread.Post(() => IsChangingWindowState = false, DispatcherPriority.Background);
+
 
         if (saveSettings)
         {
@@ -80,7 +82,8 @@ public static class Win32Window
         vm.MainWindow.IsFullscreen.Value = false;
         vm.MainWindow.CanResize.Value = false;
 
-        IsChangingWindowState = false;
+        Dispatcher.UIThread.Post(() => IsChangingWindowState = false, DispatcherPriority.Background);
+
         if (saveSettings)
         {
             await SaveSettingsAsync().ConfigureAwait(false);
@@ -130,7 +133,8 @@ public static class Win32Window
 
         await WindowResizing.SetSizeAsync(vm);
 
-        IsChangingWindowState = false;
+        Dispatcher.UIThread.Post(() => IsChangingWindowState = false, DispatcherPriority.Background);
+
 
         if (saveSettings)
         {