osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Changing displays via `CurrentDisplayBindable` doesn't work

Open peppy opened this issue 3 years ago • 2 comments

I was looking to add display selection to osu!, but it using this bindable wasn't working at all.

It looks like the intention of this bindable was to have it settable. I do remember this working in the past.

A quick attempt to make it work is this diff:

diff --git a/osu.Framework/Platform/SDL2DesktopWindow.cs b/osu.Framework/Platform/SDL2DesktopWindow.cs
index 73b5e953d..01436bee8 100644
--- a/osu.Framework/Platform/SDL2DesktopWindow.cs
+++ b/osu.Framework/Platform/SDL2DesktopWindow.cs
@@ -1174,7 +1174,11 @@ public void SetupWindow(FrameworkConfigManager config)
             };
 
             config.BindWith(FrameworkSetting.LastDisplayDevice, windowDisplayIndexBindable);
-            windowDisplayIndexBindable.BindValueChanged(evt => CurrentDisplay = Displays.ElementAtOrDefault((int)evt.NewValue) ?? PrimaryDisplay, true);
+            windowDisplayIndexBindable.BindValueChanged(evt =>
+            {
+                CurrentDisplay = Displays.ElementAtOrDefault((int)evt.NewValue) ?? PrimaryDisplay;
+                pendingWindowState = windowState;
+            }, true);
 
             sizeFullscreen.ValueChanged += evt =>
             {

This should be enough to show why it isn't working, but still has issues with various OS/display modes. At very least this should work reliably on windows.

In my testing so far:

  • Works with macOS windowed, but not borderless or fullscreen
  • Works with seemingly all modes on windows, but may be triggering more mode changes than expected. I've only tested on a VM so it's hard to say without further testing.

Not sure whether I should PR the above to at least have it hooked up, or whether more effort should be spent to ensure it works properly.

peppy avatar Mar 02 '22 06:03 peppy

@Susko3 if you're looking for more platform fixes to make, you're welcome to take this one on 😅

peppy avatar Mar 02 '22 06:03 peppy

I'd start with PRing the above to move the dependent game-side PR along. Always better to have something in place that's at least partially working rather than nothing.

bdach avatar Mar 02 '22 20:03 bdach