Detecting multiple monitors

Hi,

I maintain tuxmath and tuxtype. The games have a fullscreen mode and
a 640x480 windowed mode. I recently switched to a dual-monitor
(linux, using Nvidia TwinView) and noticed that the fullscreen mode
spreads across both monitors (as expected, because the combined
monitors appear as one big screen). I’d like to have a fullscreen SDL
game display in just one monitor, ideally leaving the other monitor
usable for other apps, but OK if it just goes black or shows “no input
signal”. I’ve figured out how to get my computer behave as desired,
but I’d like to fix tuxmath and tuxtype so they handle this situation
more intelligently. Is there any way to detect if “fullscreen” is in
fact spread across both monitors?

As a sort of workaround hack, I’ve tried simply testing if the screen
is more than twice as wide as it is tall, and then just passing half
the total width to SDL_SetVideoMode() to see if I could force SDL to
just use one monitor:

// Determine the current resolution: this will be used as the	//

fullscreen resolution, if the user wants
fullscreen. DEBUGMSG(debug_setup, “Current resolution: w %d, h
%d.\n”,videoInfo->current_w,videoInfo->current_h); fs_res_x =
videoInfo->current_w; fs_res_y = videoInfo->current_h;
if (Opts_GetGlobalOpt(FULLSCREEN)) { ? ?//HACK - assume dual
monitors if x > 2y, try to force game to display fullscreen ? ?//on
only one: ? ?if (fs_res_x > 2 * fs_res_y) fs_res_x /= 2;
? ?screen = SDL_SetVideoMode(fs_res_x, fs_res_y, PIXEL_BITS,
SDL_FULLSCREEN | surfaceMode); ? ?if (screen == NULL)
{ fprintf(stderr, “\nWarning: I could not open the display in
fullscreen mode.\n” “The Simple DirectMedia error that occured
was:\n” “%s\n\n”, SDL_GetError()); Opts_SetGlobalOpt(FULLSCREEN,
0); ? ?} }
if (!Opts_GetGlobalOpt(FULLSCREEN)) { ? ?screen =
SDL_SetVideoMode(640, 480, PIXEL_BITS, surfaceMode); }
This worked as desired on my machine, but I’m not at all confident
that it is a proper practice or that it will work for other
dual-monitor scenarios.

What’s the best way to check for this programatically?–
David Bruce

For all your software needs, visit The Apt Store:
deb http://ftp.us.debian.org/debian stable main

On Vie 02 Dic 2011 23:53:48 David Bruce escribi?:

Hi,

I maintain tuxmath and tuxtype. The games have a fullscreen mode and
a 640x480 windowed mode. I recently switched to a dual-monitor
(linux, using Nvidia TwinView) and noticed that the fullscreen mode
spreads across both monitors (as expected, because the combined
monitors appear as one big screen). I’d like to have a fullscreen SDL
game display in just one monitor, ideally leaving the other monitor
usable for other apps, but OK if it just goes black or shows “no input
signal”. I’ve figured out how to get my computer behave as desired,
but I’d like to fix tuxmath and tuxtype so they handle this situation
more intelligently. Is there any way to detect if “fullscreen” is in
fact spread across both monitors?

Are you using SDL 1.3? Do you have a an up to date version later than the one
where this patch was applied? http://bugzilla.libsdl.org/show_bug.cgi?id=1314

Gabriel.

Hi Gabriel,On Sat, Dec 3, 2011 at 7:24 AM, Gabriel Jacobo wrote:

On Vie 02 Dic 2011 23:53:48 David Bruce escribi?:

Hi,

Is there any way to detect if “fullscreen” is in
fact spread across both monitors?

Are you using SDL 1.3? Do you have a an up to date version later than the one
where this patch was applied? http://bugzilla.libsdl.org/show_bug.cgi?id=1314

No, we still use SDL 1.2 but have been considering migrating to 1.3
"when we get around to it". My desktop machine runs Debian Sid, which
has SDL 1.2.14. Of course, the programs are distributed as source on
linux, and might be built with slightly different versions on
different distros and platforms.

This issue is something I never really considered until I changed my
own desktop to a dual-monitor setup. I’m just wondering if there is a
known, recommended way for SDL game developers to handle the
possibility of dual monitors when creating a fullscreen app. I didn’t
find any clear solutions with google.

Also - sorry about the pasted code with incorrect linebreaks in my first email.

Thanks,


David Bruce

For all your software needs, visit The Apt Store:
deb http://ftp.us.debian.org/debian stable main