We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1106

Summary: Initializing SDL 1.3 (Multimonitor)
Product: SDL Reporter: Sam Lantinga <slouken>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2 CC: vitto.giova
Version: HG 2.0   
Hardware: All   
OS: Windows (All)   

Description Sam Lantinga 2011-01-25 11:02:26 UTC
Alexander Hofmann

On Win32, what's the correct sequence of commands for creating 2 or more
fullscreen Windows?

So far, here's what I got:
- SDL_Init   (of course...)
- SDL_GetNumVideoDisplays()
- Select the appropriate display and Create a Window with specified size
and SDL_WINDOW_FULLSCREEN flag
- Do some tasks and call SDL_ShowWindow

It work's great if all Windows are created with the same size as the
resolution of the desktop of every screen was at the time of
initializing SDL, but when I try to specify some other size (800x600
Pixels e.g. on former 1280x1024 and 1024x768 displays), the first Window
get's positioned correctly, but the second one is initialized at 480
pixels right of the top left corner of the 2. screen (1280-800). A
second problem is, that somehow the Event-Queue gets filled with events
if that happens, and the SDL_PollEvent command never returns from the
first call...

I took a look a the code and as far as I could understand it, the
position of a newly created Window is calculated using the coordinates
of the desktop-position of every display, which is being read on
initialization of SDL - is that correct?

At the moment, my workaround is to set all displays to the desired
resolution prior to SDL initialization using standard Windows-API, is
there any more elegant solution using SDL, or did I miss something?
Comment 1 Sam Lantinga 2011-02-16 03:22:49 UTC
I just did a bunch of work on multi-monitor and fullscreen support on Windows.

The way you set things up changed a little bit.  Create each of your windows with the desired size and the fullscreen flag, and use this macro for the position: SDL_WINDOWPOS_CENTERED_DISPLAY(N), where N is the index of the display you want to create the window on.

e.g.
window = SDL_CreateWindow("Window on Monitor 1",
                          SDL_WINDOWPOS_CENTERED_DISPLAY(1),
                          SDL_WINDOWPOS_CENTERED_DISPLAY(1),
                          640, 480, SDL_WINDOW_FULLSCREEN|SDL_WINDOW_SHOWN);

Can you try the latest snapshot and see if this works for you?
http://www.libsdl.org/tmp/SDL-1.3.zip

Thanks!