[gnome-boxes/release-3.36.6: 3/7] machine: Prevent displays from overlapping each other




commit 426a1bfbea4e6907bbb46b725144aa720969a27d
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 6dbe4a4f..7526bdd3 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -204,10 +204,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 ();
             });
 
@@ -404,7 +407,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]