[2.x] Event when second monitor is switched on

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Lax
Gnoll
Posts: 659
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 63

[2.x] Event when second monitor is switched on

Post by Lax »

Hi,

is there a way to detect via graphics card event etc. whether a second monitor/tv is swiched on?
I have the issue, then when I have an Ogre application running and my wife does switch on the tv, which is also connected with the graphics card, my PC monitor will become black for a small amount of time and all my MyGUI widgets are placed in the middle of the monitor screen (positions resetted). This is really annoying.
Is there an event, I could attach, to get notified, that a device is switched, or lost/restored? So I could react on that event and re-place all widgets at that time to the correct position again.

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5446
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1348

Re: [2.x] Event when second monitor is switched on

Post by dark_sylinc »

I'm not familiar, but I'd suspect when such thing happen, you'd get at least a window event message that the window has been moved and/or resized; hence you should check if monitor count or desktop resolution has changed from a previous known state (e.g. SDL_GetWindowDisplayIndex, SDL_GetNumVideoDisplays).

If you're using SDL, you should look for event type SDL_WINDOWEVENT, events SDL_WINDOWEVENT_SIZE_CHANGED and SDL_WINDOWEVENT_RESIZED, and SDL_WINDOWEVENT_MOVED

If you're not using SDL, use WindowEventUtilities::addWindowEventListener.

See this tutorial.
User avatar
Zonder
Ogre Magi
Posts: 1172
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 76

Re: [2.x] Event when second monitor is switched on

Post by Zonder »

There are 10 types of people in the world: Those who understand binary, and those who don't...
Lax
Gnoll
Posts: 659
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 63

Re: [2.x] Event when second monitor is switched on

Post by Lax »

See here for Win32 API specific https://stackoverflow.com/questions/598 ... -windows-7
Thanks, sounds promising! I will check this out.

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62