Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement initial display selection #2669

Merged

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Jan 27, 2025

Resolve #2280, #2575

  1. Engine allows to specify display index in DisplayMode struct. All the code that dealt with getting current display's size or available modes have been adjusted to respect a selected display index.
  2. Config has a new option: "[graphics] display = N", where N is a display index.
  3. Special handling is done in Direct3D renderer, and Software renderer in case SDL created any of the directx drivers: when switching between exclusive fullscreen and windowed mode they will always set exclusive fullscreen on a display where the window was created (regardless of a initial mode). That's a Direct3D requirement (and possible new DirectX too). This may only be resolved by recreating a device, which in turn requires full recreation of all resources - textures etc, - and that's just too much of a hassle in my opinion.
  4. Added a "Display" dropdown list to WinSetup.

winsetup--displayselect

TESTING:

  • - Display mode selection works normally, with all the fullscreen and windowed mode kinds initializing correctly (this may be tested on default display).
  • - Switching windowed/fullscreen works normally.
  • - Dragging a window to another display and switching to a non-exclusive fullscreen and back should keep window on that display.
  • - Dragging a window to another display and switching to a exclusive fullscreen with Direct3D should init exclusive fullscreen on a display where the window was first created.
  • - Winsetup lets select display index. When changing display index, resolution selection will be updated to retrieve available modes from the selected display.

POSSIBLE TODOs:
I noticed in #2280 there's a extra suggestion to add a Editor preference that forces testing on a certain display.

@ivan-mogilko ivan-mogilko force-pushed the 362--selectmonitor branch 2 times, most recently from d880c83 to addad2e Compare January 27, 2025 09:55
@ivan-mogilko
Copy link
Contributor Author

I've tested this on two-monitor system, but please test even if you have 1 monitor, to make sure that basic configuration keeps working, because I had to modify several things in graphics mode init.

@ericoporto
Copy link
Member

ericoporto commented Jan 28, 2025

Testing on Windows 11, just using winsetup to change the initial display, it seems it works. I select 0 and get my primary display and I select 1 and get my secondary display. I think it would make more sense if it was 1 and 2, like it shows in Windows multiple displays settings, where the monitors get assigned a number from 1 to how many they are.

About using the feature, the only curious thing is, if there is an application on the secondary display, the AGS game doesn't seem to load in "focus", while on primary display it seems it always loads in "focus" - by focus here I mean it loads the window or fullscreen below the application that is on secondary display, but also not focused so that the game doesn't start until one clicks the game icon in the start bar.

Edit: would it be possible to add a command line parameter to it? It would take a number, like 1 or 2.

Edit2: shouldn't it have the first parameter in winsetup be default, and default would mean like, the primary display or something?

This apparently fixes an issue when the window is created on secondary monitor, which already has application windows on.
@AlanDrake
Copy link
Contributor

AlanDrake commented Jan 28, 2025

Appears to work as expected.
I have found some unrelated issues though, which I'll write in a new ticket.

EDIT: If I had to nitpick, the default desktop resolution, and available ones, should change when selecting another monitor.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jan 28, 2025

EDIT: If I had to nitpick, the default desktop resolution, and available ones, should change when selecting another monitor.

The list of resolutions is supposed to be refilled, is it not? My both displays support same list of resolutions, so I cannot notice the difference.

@AlanDrake
Copy link
Contributor

AlanDrake commented Jan 28, 2025

The list of resolutions is supposed to be refilled, is it not? My both displays support same list of resolutions, so I cannot notice the difference.

I see a repaint when changing Display index, but the availabel select options remain unchanged from what was loaded at start.

@ivan-mogilko
Copy link
Contributor Author

Pushed a fix, please try again.

@AlanDrake
Copy link
Contributor

Pushed a fix, please try again.

It works now. All good.

@ericoporto
Copy link
Member

ericoporto commented Jan 28, 2025

I had a thinking that once this is merged, the display selection feature is tied to the desktop platforms. While I don't think this will change soon, I wonder if it would be better to have a macro explicitly for this in core/platform.h and then have it set to the AGS desktop macro for now - in this way it would be clear which parts of the code are the way they are because of display selection and not just as a generic desktop thing.

@ericoporto
Copy link
Member

Thanks, that's pretty good. I think this looks fine and we will probably only get larger testing once this hits a game in production.

@ivan-mogilko ivan-mogilko merged commit fae882d into adventuregamestudio:master Jan 29, 2025
21 checks passed
@ivan-mogilko ivan-mogilko deleted the 362--selectmonitor branch January 29, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support some way to set the starting monitor
3 participants