Blame SOURCES/gnome-boxes-fix-mixing-vm-widgets.patch

e98b86
From a9e6da0a18db07b94af30ced5e8c8b56737c9408 Mon Sep 17 00:00:00 2001
e98b86
From: Felipe Borges <felipeborges@gnome.org>
e98b86
Date: Wed, 8 Jul 2020 16:56:02 +0200
e98b86
Subject: [PATCH] machine: Prevent displays from overlapping each other
e98b86
e98b86
When a machine display get connected/disconnected, we need to account
e98b86
for what's the current_item being shown and only perform the widget
e98b86
replacement when the current_item is the one that received those
e98b86
signals.
e98b86
e98b86
This is not an ideal solution if we later decide to support multiple
e98b86
monitors, but it fixes various issues users have now with managing
e98b86
multiple machines at the same time.
e98b86
e98b86
To reproduce the most common of these issues you need:
e98b86
1. Run at least two VMs simultaneously
e98b86
2. Restart one VM
e98b86
3. Jump to another VM
e98b86
4. See the restarting VM take over the display (replacing the
e98b86
current one).
e98b86
---
e98b86
 src/machine.vala | 16 +++++++++++-----
e98b86
 1 file changed, 11 insertions(+), 5 deletions(-)
e98b86
e98b86
diff --git a/src/machine.vala b/src/machine.vala
e98b86
index 795058f2..7526bdd3 100644
e98b86
--- a/src/machine.vala
e98b86
+++ b/src/machine.vala
e98b86
@@ -161,6 +161,7 @@ protected void show_display () {
e98b86
             var widget = display.get_display (0);
e98b86
             widget_remove (widget);
e98b86
             window.display_page.show_display (display, widget);
e98b86
+            window.topbar.status = this.name;
e98b86
             widget.grab_focus ();
e98b86
 
e98b86
             store_auth_credentials ();
e98b86
@@ -203,10 +204,13 @@ protected void show_display () {
e98b86
             // Translators: The %s will be expanded with the name of the vm
e98b86
             window.topbar.status = _("Connecting to %s").printf (name);
e98b86
 
e98b86
-            show_id = _display.show.connect ((id) => { show_display (); });
e98b86
+            show_id = _display.show.connect ((id) => {
e98b86
+                if (window != null && window.current_item == this)
e98b86
+                    show_display ();
e98b86
+            });
e98b86
 
e98b86
             hide_id = _display.hide.connect ((id) => {
e98b86
-                if (window != null)
e98b86
+                if (window != null && window.current_item == this)
e98b86
                     window.display_page.remove_display ();
e98b86
             });
e98b86
 
e98b86
@@ -235,8 +239,9 @@ protected void show_display () {
e98b86
                 }
e98b86
 
e98b86
                 load_screenshot ();
e98b86
-
e98b86
-                disconnect_display ();
e98b86
+		if (!stay_on_display) {
e98b86
+                    disconnect_display ();
e98b86
+                }
e98b86
             });
e98b86
 
e98b86
             need_password_id = _display.notify["need-password"].connect (handle_auth);
e98b86
@@ -402,7 +407,8 @@ public virtual void disconnect_display () {
e98b86
             }
e98b86
         }
e98b86
 
e98b86
-        window.display_page.remove_display ();
e98b86
+        if (window.current_item == this)
e98b86
+            window.display_page.remove_display ();
e98b86
         if (!display.should_keep_alive ()) {
e98b86
             display.disconnect_it ();
e98b86
             display = null;
e98b86
-- 
e98b86
2.28.0
e98b86