mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-23 04:52:08 +00:00
Fix fullscreen monitor selection on Windows
When Avalonia cannot resolve a screen from the window visual, fall back to the screen containing the window center before using the primary display. Also place the fullscreen window at the selected screen bounds instead of always using the desktop origin, preventing fullscreen from moving to the primary monitor.
This commit is contained in:
parent
a6af199b24
commit
dc522a0d08
1 changed files with 15 additions and 10 deletions
|
|
@ -2060,6 +2060,20 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
nint hwnd = Window.TryGetPlatformHandle()?.Handle ?? nint.Zero;
|
||||
if (hwnd == nint.Zero) return;
|
||||
|
||||
PixelPoint windowCenter = new(
|
||||
Window.Position.X + (int)(Window.Bounds.Width / 2),
|
||||
Window.Position.Y + (int)(Window.Bounds.Height / 2));
|
||||
|
||||
var screen =
|
||||
Window.Screens.ScreenFromVisual(Window) ??
|
||||
Window.Screens.ScreenFromPoint(windowCenter) ??
|
||||
Window.Screens.Primary;
|
||||
|
||||
if (screen == null)
|
||||
{
|
||||
return; // Can't determine screen size, don't attempt fullscreen
|
||||
}
|
||||
|
||||
// Save current style and placement
|
||||
_savedWindowStyle = Win32NativeInterop.GetWindowLongPtrW(hwnd, Win32NativeInterop.GWL_STYLE);
|
||||
|
||||
|
|
@ -2067,19 +2081,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
Win32NativeInterop.SetWindowLongPtrW(hwnd, Win32NativeInterop.GWL_STYLE,
|
||||
unchecked((nint)(Win32NativeInterop.WS_POPUP | Win32NativeInterop.WS_VISIBLE)));
|
||||
|
||||
Avalonia.Platform.Screen? screen = Window.Screens.ScreenFromVisual(Window);
|
||||
if (screen == null)
|
||||
{
|
||||
screen = Window.Screens.Primary;
|
||||
}
|
||||
if (screen == null)
|
||||
{
|
||||
return; // Can't determine screen size, don't attempt fullscreen
|
||||
}
|
||||
int w = screen.Bounds.Width;
|
||||
int h = screen.Bounds.Height;
|
||||
|
||||
Win32NativeInterop.SetWindowPos(hwnd, nint.Zero, 0, 0, w, h,
|
||||
Win32NativeInterop.SetWindowPos(hwnd, nint.Zero, screen.Bounds.X, screen.Bounds.Y, w, h,
|
||||
Win32NativeInterop.SWP_NOZORDER | Win32NativeInterop.SWP_NOACTIVATE | Win32NativeInterop.SWP_FRAMECHANGED);
|
||||
|
||||
WindowState = WindowState.FullScreen;
|
||||
|
|
|
|||
Loading…
Reference in a new issue