Multi-monitor window coordinates

Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

See ya!–
? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Hello !

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

That is a good idea. If there is at least a way to inform a programm
which monitor covers which screen coords, the coder can do calculations
on his own, how to, for example, center a window on a monitor.

CU

That sounds like the best route - it would be good to also have a helper
function to have local coordinates for each monitor, too, just to keep the
bases covered.
It would be good to have an enumerate monitors function that takes a list of
SDL_Rects and fills in the values of each monitor’s x and y, as well as the
resolution, like:
int SDL_GetNumMonitors( void );
int SDL_EnumerateMonitors( SDL_Rect **monitor, int num );

int num = SDL_GetNumMonitors();
SDL_Rect MonitorRect[num];
SDL_EnumerateMonitors( &MonitorRect, num );
printf( “Monitor %d is located at %d,%d (resolution: %d, %d)\r\n”, 0,
MonitorRect[0].x, MonitorRect[0].y, MonitorRect[0].w, MonitorRect[0].h );

I don’t know if that’s exactly how the functions would best work, but it’s
just a thought.

Take care,
-OzOn Fri, Jan 7, 2011 at 10:50 AM, Sam Lantinga wrote:

Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

See ya!

-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Message: 3
Message-ID:
? ? ? ?<AANLkTi=AeZGjQgOrqe8bW1g3sf8Hk_s=B-A1xqLM4SS- at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Right now SDL treats each display as a separate object with its own
coordinate system. ?SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. ?Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

My many Windows screensavers use Windows’s unified coordinate system.
It’s very simple code using just the x,y,w,h values that Windows gives
you. This seems to work well on most computers, but I still get
plenty of emails saying that the saver window opens up on only 1
monitor or across 1.5 or 2.5 monitors or just 1 row of pixels is
wrong. It’s all very random. I still don’t know a better or more
universal way to do multiple monitors, but I question its reliability.
I haven’t seen any of these problems on my own computers, so maybe
with all the developers here some of this will get figured out…

And having all the individual monitor coordinate systems is still a
must. Having GUI elements and other things that span monitors would
look really weird.> Date: Fri, 7 Jan 2011 07:50:29 -0800

From: Sam Lantinga
To: SDL
Subject: [SDL] Multi-monitor window coordinates

See ya!

? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC


Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com

I think the suggestion of Alex makes sense due to the fact that monitors can
be in either horizontal or vertical positions and can be even mixed. Also an
advantage of his system is that monitors don’t need to be positioned next to
each other (a thing that might occur if you have multiple machines). At work
we have had up to 13 monitor setups with multiple machines and sometimes
monitors where scrambled (not sure if it needs to be taken into account). On
the other hand why not take these things into account when you can (as is
already the case with the system of Alex). It might be usefull to have one
big rectangle for ease of use but in some occations things might end up
outside some monitor its co?rdinates.

I’ll hope this helps you to advance your great library.

Regards,
SerjanOn Fri, Jan 7, 2011 at 8:14 PM, Terry Welsh wrote:

Message: 3
Date: Fri, 7 Jan 2011 07:50:29 -0800
From: Sam Lantinga
To: SDL
Subject: [SDL] Multi-monitor window coordinates
Message-ID:
<AANLkTi=AeZGjQgOrqe8bW1g3sf8Hk_s=B-A1xqLM4SS- at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

My many Windows screensavers use Windows’s unified coordinate system.
It’s very simple code using just the x,y,w,h values that Windows gives
you. This seems to work well on most computers, but I still get
plenty of emails saying that the saver window opens up on only 1
monitor or across 1.5 or 2.5 monitors or just 1 row of pixels is
wrong. It’s all very random. I still don’t know a better or more
universal way to do multiple monitors, but I question its reliability.
I haven’t seen any of these problems on my own computers, so maybe
with all the developers here some of this will get figured out…

And having all the individual monitor coordinate systems is still a
must. Having GUI elements and other things that span monitors would
look really weird.

See ya!

? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC


Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I suppose it would be better as such (note: SDL’s event pump should be able
to handle the number of monitors and their respective rectangles):

int SDL_GetNumMonitors( void );
int SDL_GetMonitorRect( int monitor, SDL_Rect *rect );

int num = SDL_GetNumMonitors();
SDL_Rect monitor2;
if( SDL_GetMonitorRect( 2, &monitor2 ) )
printf( “Monitor 2: position=%d,%d size=%d,%d\r\n”, monitor2.x,
monitor2.y, monitor2.w, monitor2.h );

So, as an improvement from my original suggestion:

Internally, SDL should be able to track and store information about the
number of monitors and their resolutions. As Serjan noted, ya, this is also
good for irregular monitor setups (maybe two monitors side-by-side and one
monitor above the two).
It would be easy to implement a function that converts coordinates relative
to a monitor rectangle - maybe that should be left on the individual
programmer’s end, though.

This shouldn’t be overly intrustive on SDL’s already implemented API, and is
fairly simple. I have some old code for windows that could be repurposed,
but I’m not overly familiar with linux/mac code for that, though.

Thoughts?On Fri, Jan 7, 2011 at 3:50 PM, SmartUser wrote:

I think the suggestion of Alex makes sense due to the fact that monitors
can be in either horizontal or vertical positions and can be even mixed.
Also an advantage of his system is that monitors don’t need to be positioned
next to each other (a thing that might occur if you have multiple machines).
At work we have had up to 13 monitor setups with multiple machines and
sometimes monitors where scrambled (not sure if it needs to be taken into
account). On the other hand why not take these things into account when you
can (as is already the case with the system of Alex). It might be usefull to
have one big rectangle for ease of use but in some occations things might
end up outside some monitor its co?rdinates.

I’ll hope this helps you to advance your great library.

Regards,
Serjan

On Fri, Jan 7, 2011 at 8:14 PM, Terry Welsh wrote:

Message: 3
Date: Fri, 7 Jan 2011 07:50:29 -0800
From: Sam Lantinga
To: SDL
Subject: [SDL] Multi-monitor window coordinates
Message-ID:
<AANLkTi=AeZGjQgOrqe8bW1g3sf8Hk_s=B-A1xqLM4SS- at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

My many Windows screensavers use Windows’s unified coordinate system.
It’s very simple code using just the x,y,w,h values that Windows gives
you. This seems to work well on most computers, but I still get
plenty of emails saying that the saver window opens up on only 1
monitor or across 1.5 or 2.5 monitors or just 1 row of pixels is
wrong. It’s all very random. I still don’t know a better or more
universal way to do multiple monitors, but I question its reliability.
I haven’t seen any of these problems on my own computers, so maybe
with all the developers here some of this will get figured out…

And having all the individual monitor coordinate systems is still a
must. Having GUI elements and other things that span monitors would
look really weird.

See ya!

? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC


Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

To do this, I think it may be necessary to differentiate between individual display devices and the universal display provided. In addition, I’m not sure all systems support this – NDS has two displays; does it require to use them separately? How about X11?

I frankly feel it’s more effort than it’s worth. No sense bloating SDL up with features that will largely go unused, right? What uses for this are there?------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

This already exists in 1.3, FYI:

http://wiki.libsdl.org/moin.cgi/SDL_GetDisplayBoundsOn Fri, Jan 7, 2011 at 1:37 PM, Alex Barry <alex.barry at gmail.com> wrote:

I suppose it would be better as such (note: SDL’s event pump should be able
to handle the number of monitors and their respective rectangles):
int SDL_GetNumMonitors( void );
int SDL_GetMonitorRect( int monitor, SDL_Rect *rect );
int num = SDL_GetNumMonitors();
SDL_Rect monitor2;
if( SDL_GetMonitorRect( 2, &monitor2 ) )
??printf( “Monitor 2: position=%d,%d size=%d,%d\r\n”, monitor2.x,
monitor2.y, monitor2.w, monitor2.h );
So, as an improvement from my original suggestion:
Internally, SDL should be able to track and store information about the
number of monitors and their resolutions. ?As Serjan noted, ya, this is also
good for irregular monitor setups (maybe two monitors side-by-side and one
monitor above the two).
It would be easy to implement a function that converts coordinates relative
to a monitor rectangle - maybe that should be left on the individual
programmer’s end, though.
This shouldn’t be overly intrustive on SDL’s already implemented API, and is
fairly simple. ?I have some old code for windows that could be repurposed,
but I’m not overly familiar with linux/mac code for that, though.
Thoughts?
On Fri, Jan 7, 2011 at 3:50 PM, SmartUser wrote:

I think the suggestion of Alex makes sense due to the fact that monitors
can be in either horizontal or vertical positions and can be even mixed.
Also an advantage of his system is that monitors don’t need to be positioned
next to each other (a thing that might occur if you have multiple machines).
At work we have had up to 13 monitor setups with multiple machines and
sometimes monitors where scrambled (not sure if it needs to be taken into
account). On the other hand why not take these things into account when you
can (as is already the case with the system of Alex).?It might be?usefull to
have one big rectangle for ease of use but in?some occations things might
end up outside some monitor?its?co?rdinates.

I’ll hope this helps you to advance your great library.

Regards,
Serjan

On Fri, Jan 7, 2011 at 8:14 PM, Terry Welsh wrote:

Message: 3
Date: Fri, 7 Jan 2011 07:50:29 -0800
From: Sam Lantinga <@slouken>
To: SDL
Subject: [SDL] Multi-monitor window coordinates
Message-ID:
? ? ? ?<AANLkTi=AeZGjQgOrqe8bW1g3sf8Hk_s=B-A1xqLM4SS- at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Right now SDL treats each display as a separate object with its own
coordinate system. ?SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. ?Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

My many Windows screensavers use Windows’s unified coordinate system.
It’s very simple code using just the x,y,w,h values that Windows gives
you. ?This seems to work well on most computers, but I still get
plenty of emails saying that the saver window opens up on only 1
monitor or across 1.5 or 2.5 monitors or just 1 row of pixels is
wrong. ?It’s all very random. ?I still don’t know a better or more
universal way to do multiple monitors, but I question its reliability.
?I haven’t seen any of these problems on my own computers, so maybe
with all the developers here some of this will get figured out…

And having all the individual monitor coordinate systems is still a
must. ?Having GUI elements and other things that span monitors would
look really weird.

See ya!

? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC


Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Oh wow, silly me. This topic was nearly a year old and I didn’t notice it. :P------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

lol - win. I’m a goof.On Fri, Jan 7, 2011 at 8:18 PM, Sam Lantinga wrote:

This already exists in 1.3, FYI:

http://wiki.libsdl.org/moin.cgi/SDL_GetDisplayBounds

On Fri, Jan 7, 2011 at 1:37 PM, Alex Barry <@Alex_Barry> wrote:

I suppose it would be better as such (note: SDL’s event pump should be
able
to handle the number of monitors and their respective rectangles):
int SDL_GetNumMonitors( void );
int SDL_GetMonitorRect( int monitor, SDL_Rect *rect );
int num = SDL_GetNumMonitors();
SDL_Rect monitor2;
if( SDL_GetMonitorRect( 2, &monitor2 ) )
printf( “Monitor 2: position=%d,%d size=%d,%d\r\n”, monitor2.x,
monitor2.y, monitor2.w, monitor2.h );
So, as an improvement from my original suggestion:
Internally, SDL should be able to track and store information about the
number of monitors and their resolutions. As Serjan noted, ya, this is
also
good for irregular monitor setups (maybe two monitors side-by-side and
one
monitor above the two).
It would be easy to implement a function that converts coordinates
relative
to a monitor rectangle - maybe that should be left on the individual
programmer’s end, though.
This shouldn’t be overly intrustive on SDL’s already implemented API, and
is
fairly simple. I have some old code for windows that could be
repurposed,
but I’m not overly familiar with linux/mac code for that, though.
Thoughts?
On Fri, Jan 7, 2011 at 3:50 PM, SmartUser wrote:

I think the suggestion of Alex makes sense due to the fact that monitors
can be in either horizontal or vertical positions and can be even mixed.
Also an advantage of his system is that monitors don’t need to be
positioned

next to each other (a thing that might occur if you have multiple
machines).

At work we have had up to 13 monitor setups with multiple machines and
sometimes monitors where scrambled (not sure if it needs to be taken
into

account). On the other hand why not take these things into account when
you

can (as is already the case with the system of Alex). It might
be usefull to

have one big rectangle for ease of use but in some occations things
might

end up outside some monitor its co?rdinates.

I’ll hope this helps you to advance your great library.

Regards,
Serjan

On Fri, Jan 7, 2011 at 8:14 PM, Terry Welsh wrote:

Message: 3
Date: Fri, 7 Jan 2011 07:50:29 -0800
From: Sam Lantinga
To: SDL
Subject: [SDL] Multi-monitor window coordinates
Message-ID:
<AANLkTi=AeZGjQgOrqe8bW1g3sf8Hk_s=B-A1xqLM4SS- at mail.gmail.com

Content-Type: text/plain; charset=ISO-8859-1

Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system
with

the upper left of the primary display being 0,0. Windows can be
moved

freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way
to

go, but I wanted to see if anyone had any thoughts on this.

My many Windows screensavers use Windows’s unified coordinate system.
It’s very simple code using just the x,y,w,h values that Windows gives
you. This seems to work well on most computers, but I still get
plenty of emails saying that the saver window opens up on only 1
monitor or across 1.5 or 2.5 monitors or just 1 row of pixels is
wrong. It’s all very random. I still don’t know a better or more
universal way to do multiple monitors, but I question its reliability.
I haven’t seen any of these problems on my own computers, so maybe
with all the developers here some of this will get figured out…

And having all the individual monitor coordinate systems is still a
must. Having GUI elements and other things that span monitors would
look really weird.

See ya!

? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC


Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Nope, it’s current! :)On Fri, Jan 7, 2011 at 5:36 PM, Nathaniel J Fries wrote:

Oh wow, silly me. This topic was nearly a year old and I didn’t notice
it. [image: Razz]


EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Sam Lantinga wrote:

Nope, it’s current! :slight_smile:

  Oh wow, silly me. This topic was nearly a year old and I didn't notice it.

and now I’m feeling retarded.
perhaps I should stay away from the computer when I’m sick. Or at least refrain from posting…> On Fri, Jan 7, 2011 at 5:36 PM, Nathaniel J Fries <@Nathaniel_J_Fries (@Nathaniel_J_Fries)> wrote:


EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

There are only two difficult types of problems in computer science. Cache
invalidation, naming things, and off-by-one errors. ;)________________________________
From: nfries88@yahoo.com (Nathaniel J Fries)
Subject: Re: [SDL] Multi-monitor window coordinates

Sam Lantinga wrote:

Nope, it’s current!

On Fri, Jan 7, 2011 at 5:36 PM, Nathaniel J Fries <> wrote:

Quote:

Oh wow, silly me. This topic was nearly a year old and I didn’t notice it.

and now I’m feeling retarded.
perhaps I should stay away from the computer when I’m sick. Or at least refrain
from posting…


EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

I frankly feel it’s more effort than it’s worth. No sense bloating SDL up
with features that will largely go unused, right? What uses for this are
there?

I’m glad this issue is getting addressed. I recently started playing with SDL
1.3 and hit a nasty issue when trying to switch to full screen mode on my dual
monitor Linux system: my secondary monitor was chosen for full screen, and my
primary monitor was disabled and remained off even after the program exited and
supposedly restored the old settings.

To do this, I think it may be necessary to differentiate between individual
display devices and the universal display provided. In addition, I’m not
sure all systems support this – NDS has two displays; does it require to
use them separately? How about X11?

See here for how X11 handles it:

http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt

In the Xrandr display model the “screen” is the universal display, the “CRTCs"
are the individual (logical) display devices, and the “outputs” are the
physical display devices. The CRTCs can overlap, be side by side, or have
"dead space” separating them". There can be more than one output per CRTC as
well (two monitors displaying identical contents, for example).

I don’t know Windows or Mac programming, but from what people have been saying
in here it seems like they at least provide the special case corresponding to
identically sized CRTCs that are side-by-side. Perhaps the Xrandr display
model is a good generalization to use.

ErisOn Friday 07 January 2011, Nathaniel J Fries wrote:

Okay, it sounds like everybody likes the unified window coordinates.

Thanks!On Fri, Jan 7, 2011 at 7:50 AM, Sam Lantinga <@slouken> wrote:

Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.

Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.

I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.

See ya!

-Sam Lantinga, Founder and President, Galaxy Gameworks LLC


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC