[gnome-boxes/wip/display-management: 2/2] machine: Prevent displays from overlapping each other



commit 6f4c640d103ca19cf46e2b23052b081a2b397edf
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jul 14 13:27:53 2020 +0200

    machine: Prevent displays from overlapping each other
    
    When a machine display get connected/disconnected, we need to account
    for what's the current_item being shown and only perform the widget
    replacement when the current_item is the one that received those
    signals.
    
    This is not an ideal solution if we later decide to support multiple
    monitors, but it fixes various issues users have now with managing
    multiple machines at the same time.
    
    To reproduce the most common of these issues you need:
    1. Run at least two VMs simultaneously
    2. Restart one VM
    3. Jump to another VM
    4. See the restarting VM take over the display (replacing the
    current one).

 src/machine.vala | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/machine.vala b/src/machine.vala
index ce0e4e40..3bb2d6fa 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -202,10 +202,13 @@ protected void show_display () {
             // Translators: The %s will be expanded with the name of the vm
             window.topbar.status = _("Connecting to %s").printf (name);
 
-            show_id = _display.show.connect ((id) => { show_display (); });
+            show_id = _display.show.connect ((id) => {
+                if (window != null && window.current_item == this)
+                    show_display ();
+            });
 
             hide_id = _display.hide.connect ((id) => {
-                if (window != null)
+                if (window != null && window.current_item == this)
                     window.display_page.remove_display ();
             });
 
@@ -402,7 +405,8 @@ public virtual void disconnect_display () {
             }
         }
 
-        window.display_page.remove_display ();
+        if (window.current_item == this)
+            window.display_page.remove_display ();
         if (!display.should_keep_alive ()) {
             display.disconnect_it ();
             display = null;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]