Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Monitor changes are not detected during sleep (MacOS at least) #1357

@rcoreilly

Description

@rcoreilly

Describe the bug

If you connect or disconnect monitors (Screens) while your mac laptop is awake, you reliably get monitor change events per this callback:

glfw.SetMonitorCallback(a.MonitorChange)

However, if you close your laptop lid, then disconnect an external monitor, then open the lid and sign in, there are no events forthcoming from glfw to let you know that your monitor configuration is not as it was before.

Furthermore, my attempts to google "mac awake from sleep event" did not return anything useful, although admittedly I did not spend an exhaustive amount of time on this.

Basically, we need to somehow get an event when it wakes up (and after you sign in presumably), and then we could check the current list of monitors against whatever was last saved, and then drive a change event if these are different.

Alternatively, we could just poll the monitors every minute or so, using a "last polled" timestamp that is checked in the event loop (including paint events). Typically a wake from sleep scenario would result in a long interval and thus an immediate update upon awaking.

Ok, that is sufficiently actionable that I will go ahead and implement! :)

How to reproduce

do it.

Example code

No response

Relevant output

No response

Platform

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctly

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions