Fix screen resize race

When an external monitor is connected or disconnected, about 25% of the
time an activity does not resize correctly; a size-changed signal occurs
but the workarea geometry has not changed.

Underlying problem is an update race in get_monitor_workarea, so the fix
is to call get_monitor_geometry for obtaining the width and height.

Can be reproduced easily without an external monitor by switching
display panel resolution repeatedly;

    xrandr --output eDP1 --mode 1024x768
    xrandr --output eDP1 --mode 1366x768

Part of a fix for https://bugs.sugarlabs.org/ticket/4968
This commit is contained in:
James Cameron 2016-11-09 12:07:31 +11:00 committed by Ignacio Rodríguez
parent 99130b0263
commit a6e62a52b6
No known key found for this signature in database
GPG Key ID: 56C1623CF182C6B0

View File

@ -626,12 +626,12 @@ class Activity(Window, Gtk.Container):
def _adapt_window_to_screen(self):
screen = Gdk.Screen.get_default()
workarea = screen.get_monitor_workarea(screen.get_number())
rect = screen.get_monitor_geometry(screen.get_number())
geometry = Gdk.Geometry()
geometry.max_width = geometry.base_width = geometry.min_width = \
workarea.width
rect.width
geometry.max_height = geometry.base_height = geometry.min_height = \
workarea.height
rect.height
geometry.width_inc = geometry.height_inc = geometry.min_aspect = \
geometry.max_aspect = 1
hints = Gdk.WindowHints(Gdk.WindowHints.ASPECT |