[virt-tools-list] [PATCH 3/3] virt-viewer-display-spice: Use display monitor property for fullscreen size

Hans de Goede hdegoede at redhat.com
Wed Mar 20 14:05:40 UTC 2013


When a display is pinned to a certain monitor for fullscreen, it will be moved
there when going fullscreen. Currently we use gdk_screen_get_monitor_at_window
to determine which monitor we are on and get the size from that monitor.

But this is racy, sometimes the size_allocate function runs before the move
has finished and we get the size from the wrong monitor:
https://bugzilla.redhat.com/show_bug.cgi?id=918570

Since if the display is pinned to a certain monitor, the display will always
end up on that monitor we can avoid the race by simply using that monitors
size.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/virt-viewer-display-spice.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 1e17ca5..9fadcc6 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -201,7 +201,9 @@ virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self,
     if (self->priv->auto_resize == AUTO_RESIZE_FULLSCREEN) {
         GdkRectangle monitor;
         GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(self));
-        int n = gdk_screen_get_monitor_at_window(screen,
+        int n = virt_viewer_display_get_monitor(VIRT_VIEWER_DISPLAY(self));
+        if (n == -1)
+            n = gdk_screen_get_monitor_at_window(screen,
                                      gtk_widget_get_window(GTK_WIDGET(self)));
         gdk_screen_get_monitor_geometry(screen, n, &monitor);
         disable_display_position = FALSE;
-- 
1.8.1.4




More information about the virt-tools-list mailing list