Dual Monitor Fullscreen mode bug
Needs RevisionPublic

Authored by ceclauson on Feb 5 2017, 1:31 AM.

Details

Reviewers
vladislavbelov
Summary

I use Fedora 23 in a dual monitor configuration, my main monitor is 1366x768, my second is 1920x1080. When I start 0 AD, the full screen appears on my second, larger, monitor, but the size is wrong, as can be seen in the screenshot, and the mouse is detected to be in a location different from where it is, so it is not really playable.

I noticed that in the documentation for SDL_CreateWindow():
https://wiki.libsdl.org/SDL_CreateWindow
it says that if SDL_WINDOW_FULLSCREEN_DESKTOP is used, then the height/width parameters are ignored. I found that setting them to zero fixes the problem, although admittedly I do not have a deep undestanding of why.

My proposed patch is to set these to zero whenever full screen is used. This resolves the issue on my system by moving the full screen to the first monitor where it works normally.

An additional note, I found that alt-tabbing and then reselecting 0 AD is a workaround, and the window will appear on the first screen and work normally. It would seem to be good, though, if the user didn't have to figure this out. :D

Test Plan

Probably have other people try on different platforms/monitor configurations. According to API documentation, though, this should be okay.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 450
Build 727: Vulcan BuildJenkins
Build 726: arc lint + arc unit

Event Timeline

ceclauson created this revision.Feb 5 2017, 1:31 AM
elexis retitled this revision from Possi to Dual Monitor Fullscreen mode bug .Feb 5 2017, 1:49 AM
elexis added a subscriber: elexis.

Missing credits entry for programming.json

source/ps/VideoMode.cpp
1

2017

Vulcan added a subscriber: Vulcan.Feb 5 2017, 2:19 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/313/ for more details.

leper added inline comments.
source/ps/VideoMode.cpp
77

Missing link to upstream bug report and ifdef for only the affected versions.

78

Tabs, not spaces for indentation.

So I have some additional information. Prior to being set to zero in this patch, the values of w and h are 3286 and 1080 respectively, these seem to come from the function GetVideoMode() in
source/lib/sysdep/os/unix/x/x.cpp

The function is:

Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq)
{
	Display* disp = XOpenDisplay(0);
	if(!disp)
		WARN_RETURN(ERR::FAIL);

	int screen = XDefaultScreen(disp);

	/* 2004-07-13
	NOTE: The XDisplayWidth/Height functions don't actually return the current
	display mode - they return the size of the root window. This means that
	users with "Virtual Desktops" bigger than what their monitors/graphics
	card can handle will have to set their 0AD screen resolution manually.

	There's supposed to be an X extension that can give you the actual display
	mode, probably including refresh rate info etc, but it's not worth
	researching and implementing that at this stage.
	*/

	if(xres)
		*xres = XDisplayWidth(disp, screen);
	if(yres)
		*yres = XDisplayHeight(disp, screen);
	if(bpp)
		*bpp = XDefaultDepth(disp, screen);
	if(freq)
		*freq = 0;
	XCloseDisplay(disp);
	return INFO::OK;
}

Maybe the problem has something to do with the note here, or maybe XDefaultScreen() is not getting the screen that SDL wants?

Anyways, from my understanding of the docs for SDL_CreateWindow() it seems like there's no harm in using h=0 w=0 for full screen, but I thought I would present this as well. If anyone has something they would like to try I would be happy to test on my setup.

Thanks :D

This wouldn't be the first bug we have encountered with SDL2, see #3870 for example. Since this isn't "our" bug, it should be reported on the SDL2 bugtracker as leper mentioned, so that we don't have to add a workaround.
Could you write a minimal test case to reproduce the issue and create a ticket, similar to what echotangoecho did in that ticket ( https://bugzilla.libsdl.org/show_bug.cgi?id=3499 ) ?

vladislavbelov requested changes to this revision.Apr 28 2017, 6:14 PM
vladislavbelov added a subscriber: vladislavbelov.

Issues above should be fixed.

Also there is #3652, the issue of the current ticket may depended on monitor selection, could you try to set display to different values?

This revision now requires changes to proceed.Apr 28 2017, 6:14 PM