How to get notification when monitor disconnected?


#1

Hi folks, I have an app that has multiple windows, one of which can be set to fullscreen on a secondary monitor. Is there a way I can get notified when the monitor is disconnected, so that I can automatically reposition the window?


#2

On Windows you would check for WM_DEVICECHANGED but JUCE doesn’t do that (except for audio device notifications). Unless there is some other piece of code I don’t know about.

It could be added fairly easily, not sure about OSX or Linux.

RE:


#3

Ok, thanks. I was just wondering if there was already a Juce way to do it. I’d also need to do it for OSX.


#4

Maybe JUCE has support for this already.

If you look at juce::Desktop there is a way to enumerate the display areas. I would set a breakpoint in Desktop::refresh() and see if it gets triggered when a display device is unplugged.


#5

It looks like Component::parentSizeChanged is called when the component is a top level window and the screen size has changed. So that works. Thanks.