Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Desktop/Fullscreen resolution with multiple monitors  (Read 292 times)

0 Members and 1 Guest are viewing this topic.

Hulgh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Desktop/Fullscreen resolution with multiple monitors
« on: July 02, 2020, 06:27:05 pm »
I tried to use sf::VideoMode::getDesktopMode() to initialize a window with my desktop size, I then get a window size of 4480x1440.
I have one monitor with a resolution of 2560x1440 and another with 1920x1080 so the window covers both monitors.
I modified the example of the window example in the SFML project to output the desktop and fullscreen modes:

Fullscreen modes:
 - 4480x1440x32
 - 1920x1080x32
 - 1680x1050x32
 - 1600x900x32
 - 1440x900x32
 - 1366x768x32
 - 1280x1024x32
 - 1280x800x32
 - 1280x720x32
 - 1024x768x32
 - 800x600x32
 - 720x576x32
 - 720x480x32
 - 640x480x32
...

Desktop mode: 4480x1440x24
 

The determined desktop resolution covers both monitors and the resolution list looks like a mix between the modes of the two monitors.
xrandr gives me the following lists:

Monitor 2560x1440
-----------------
2560x1440
1920x1080
1680x1050
1440x900
1440x576
1440x480
1280x1024
1280x960
1280x800
1280x720
1152x864
1024x768
800x600
720x576
720x480
640x480

Monitor 1920x1080
-----------------
1920x1080
1680x1050
1600x900
1280x1024
1280x800
1280x720
1024x768
800x600
720x576
720x480
640x480
 

I created a branch and modified VideoModeImpl.cpp and after that I get the following:

Fullscreen modes:
 - 2560x1440x32
 - 1920x1080x32
 - 1680x1050x32
 - 1440x900x32
 - 1440x576x32
 - 1440x480x32
 - 1280x1024x32
 - 1280x960x32
 - 1280x800x32
 - 1280x720x32
 - 1152x864x32
 - 1024x768x32
 - 800x600x32
 - 720x576x32
 - 720x480x32
 - 640x480x32
...

Desktop mode: 2560x1440x24
 

See my changes:
https://github.com/SFML/SFML/compare/master...hachmeister:multi-monitor-resolution

Are there some issues with the current implementation or am I missing something here when using SFML?

My system: Debian testing, KDE 5 desktop with NVIDIA GeForce GTX 1060

Hapax

  • Hero Member
  • *****
  • Posts: 3020
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Desktop/Fullscreen resolution with multiple monitors
« Reply #1 on: July 02, 2020, 10:53:51 pm »
Are you saying that you modified it so that the desktop mode is different from the actual desktop mode and ignores the second display?

There may be something wrong if SFML's fullscreen modes is missing the native resolution for that 2560x1440 display, assuming, of course, that it's the primary/default display.
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

Hulgh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Desktop/Fullscreen resolution with multiple monitors
« Reply #2 on: July 03, 2020, 08:07:51 am »
I searched the internet before about this issue and my understanding is, that SFML can not use multiple monitors and uses only the primary display.
Is this wrong?

So my expectation was that I get a window size of 2560x1440 from the getDesktopMode() function. That is also my native desktop resolution of my first screen.
But it gave me a window size of 4480x1440.

xrandr tool shows this screen as primary, just to be sure here the output:

Screen 0: minimum 8 x 8, current 4480 x 1440, maximum 32767 x 32767
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 1920x1080+2560+180 (normal left inverted right x axis y axis) 544mm x 303mm
   1920x1080     60.00*+  59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-0 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+
   1920x1080     60.00    59.94    50.00  
   1680x1050     59.95  
   1440x900      59.89  
   1440x576      50.00  
   1440x480      59.94  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-1 disconnected (normal left inverted right x axis y axis)
 

My knowledge about X11 programming is very limited, but my understanding of the line

int screen = DefaultScreen(display);

is that it reports the primary screen and so I would expect only screen resolutions of this screen from getDesktopMode()/getFullscreenModes()

I looked at the source code of the xrandr tool and modified the SFML code as far as I understand the xrandr tool what is does to find the screen resolutions.

I just say that my expectation is that the getDesktopMode() function should return the native resolution of my primary screen and never a window size that covers multiple monitors.
Maybe I am wrong with my expectation?

Hapax

  • Hero Member
  • *****
  • Posts: 3020
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Desktop/Fullscreen resolution with multiple monitors
« Reply #3 on: July 03, 2020, 09:23:21 pm »
I don't the exact intention for getDesktopMode() but it seems to be quite intuitive to just copy whatever the operating system has defined as its desktop. This would allow, for example, creating a window (not fullscreen) that is the size of both displays (in theory).
The native resolution should be listed in the list given by getFullscreenModes(); it should be the first one, if I remember correctly.

I guess that the one thing you're actually looking for is the current video mode of a single display - a bit like "current fullscreen mode".

With all that said, I'm not 100% sure of getDesktopMode() always returning the entire desktop. Knowing current single display mode would certainly help with "fullscreen window" applications. I'm vaguely remember doing this but can't remember if it was SFML...
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9632
    • View Profile
    • development blog
    • Email
Re: Desktop/Fullscreen resolution with multiple monitors
« Reply #4 on: July 06, 2020, 11:44:33 pm »
As far as I understand it, we're currently just asking X to give us the desktop size. If X is configured to combine the monitors into one surface, than you'll get that returned.

I'm not sure what's the better way to deal with, let the user re-configure X or query the primary monitor resolutions.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Hulgh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Desktop/Fullscreen resolution with multiple monitors
« Reply #5 on: July 07, 2020, 06:14:56 pm »
Ok, getDesktopMode() gives you a resolution that is configured for the desktop. My expectation was that you get the resolution of the primary monitor.

But the list of resolutions of the method getFullscreenModes seems inconsistent to me.
I wouldn't expect the first resolution (4480x1440) in this list, the first resolution I expected was 2560x1440.
And the resolution 1600x900 does not belong in the list for me either, if the resolutions of the primary monitor are displayed there. This resolution belongs to my secondary monitor according to the xrandr tool.