wx.Display behaves weirdly after disconnecting one of displays

Hi,

Imagine following scenario, performed on Windows 7 x32:

1. wx application is up and running, opening windows and dialogs on a computer that has 2 displays attached.
2. User disconnects (using windows display property) one of his displays
(wx application is now displayed on the other display, and everything looks fine)
4. Now it tries to open new dialog and dialog __ini__ contains the following code:

         dispIndex = wx.Display_GetFromWindow(self.GetParent())
         if dispIndex == wx.NOT_FOUND:
             #Parent was displayed on deattached display or not found at all?
             dispIndex = 0
         disp = wx.Display(dispIndex)
         rect = disp.GetClientArea()

Question is, why rect has x,y,width and height all set to 0?
Code above is used to limit dialog boundaries, so it's resized to fit the screen. If wx.Display::GetClientArea() returns empty rect, well.. dialog ends up having size 0 and being modal which successfully locks up whole application.

There's sample application in the attachment, you can use to see this problem. Dialog that recalculates its size (one started with lower button) will not appear after deattaching second display and lock application.

Please advise how can I notify wx.Display class that display configuration has been changed and how can I get correct result from GetClientArea() call.

Regards,

Adam.

displayProblem.py (3.33 KB)

Hello again,

For the sake of clarity: I'm using Python 2.6 and wxPython 2.9.2.3 msw.

The issue seems to be fixed in wxPython 2.9.3.1, so you can ignore this thread safely.

Just some more details if any other soul using older wxPython runs into this issue finds this thread:

This ticket from wxWidgets seems to be related: http://trac.wxwidgets.org/ticket/4582
Looks like the list of displays (monitors) is cached by wxWidgets, but it says that display rectangle and client rectangle is not cached. Apparently it gets corrupted after a display is disconnected.

Best regards,

Adam.

W dniu 2012-03-01 13:25, Adam Bielański pisze:

···

Hi,

Imagine following scenario, performed on Windows 7 x32:

1. wx application is up and running, opening windows and dialogs on a computer that has 2 displays attached.
2. User disconnects (using windows display property) one of his displays
(wx application is now displayed on the other display, and everything looks fine)
4. Now it tries to open new dialog and dialog __ini__ contains the following code:

        dispIndex = wx.Display_GetFromWindow(self.GetParent())
        if dispIndex == wx.NOT_FOUND:
            #Parent was displayed on deattached display or not found at all?
            dispIndex = 0
        disp = wx.Display(dispIndex)
        rect = disp.GetClientArea()

Question is, why rect has x,y,width and height all set to 0?
Code above is used to limit dialog boundaries, so it's resized to fit the screen. If wx.Display::GetClientArea() returns empty rect, well.. dialog ends up having size 0 and being modal which successfully locks up whole application.

There's sample application in the attachment, you can use to see this problem. Dialog that recalculates its size (one started with lower button) will not appear after deattaching second display and lock application.

Please advise how can I notify wx.Display class that display configuration has been changed and how can I get correct result from GetClientArea() call.

Regards,

Adam.