Skip to content

Commit

Permalink
Fix: Desktop mode window state issues introduced with 10.15 update
Browse files Browse the repository at this point in the history
  • Loading branch information
JosefNemec committed May 5, 2023
1 parent 39e7ff0 commit e24f938
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions source/Playnite/Windows/WindowFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,45 @@ public static class WindowUtils

public static void RestoreWindow(this Window window)
{
// This is the only reliable method that also doesn't result in issues like this:
// https://www.reddit.com/r/playnite/comments/f6d73l/bug_full_screen_ui_wont_respond_to_left_stick/
// Adapted from https://ask.xiaolee.net/questions/1040342

try
{
// This is the only reliable method that also doesn't result in issues like this:
// https://www.reddit.com/r/playnite/comments/f6d73l/bug_full_screen_ui_wont_respond_to_left_stick/
// Adapted from https://ask.xiaolee.net/questions/1040342

// Show() call is needed when restoring from minimized state otherwise restored window will
// not render properly for some reason (will display just black).
// BUT we can't call it always otherwise it will bug out restore if atl-tabbing was
// used in the past for switching windows, see next comment...
if (window.WindowState == WindowState.Minimized || window.Visibility != Visibility.Visible)
if (PlayniteApplication.Current?.Mode == ApplicationMode.Fullscreen)
{
window.Show();
}
// Show() call is needed when restoring from minimized state otherwise restored window will
// not render properly for some reason (will display just black).
// BUT we can't call it always otherwise it will bug out restore if atl-tabbing was
// used in the past for switching windows, see next comment...
if (window.WindowState == WindowState.Minimized || window.Visibility != Visibility.Visible)
{
window.Show();
}

// This needs to be set always otherwise restore will not work if user alt-tabbed out of Playnite.
// Yeah apparently switching windows is something Windows can't do reliably in 2023...
window.WindowState = WindowState.Normal;
if (!window.Activate())
// This needs to be set always otherwise restore will not work if user alt-tabbed out of Playnite.
// Yeah apparently switching windows is something Windows can't do reliably in 2023...
window.WindowState = WindowState.Normal;
if (!window.Activate())
{
window.Topmost = true;
window.Topmost = false;
}
}
else
{
window.Topmost = true;
window.Topmost = false;
window.Show();
if (!window.Activate())
{
window.Topmost = true;
window.Topmost = false;
}

if (window.WindowState == WindowState.Minimized)
{
window.WindowState = WindowState.Normal;
}
}

//Get the process ID for this window's thread
Expand Down

0 comments on commit e24f938

Please sign in to comment.