[gnome-boxes] Add Display.should_keep_alive()
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add Display.should_keep_alive()
- Date: Wed, 14 Nov 2012 16:27:15 +0000 (UTC)
commit d23082d9e477f0acaaac88da24ece1e8dc60527c
Author: Alexander Larsson <alexl redhat com>
Date: Fri Nov 9 11:50:36 2012 +0100
Add Display.should_keep_alive()
This returns true if the connection needs to be alive even
when not visible. ATM it returns true for spice displays that
have USB devices connected.
https://bugzilla.gnome.org/show_bug.cgi?id=672268
src/display.vala | 4 ++++
src/spice-display.vala | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/display.vala b/src/display.vala
index 4e19237..3c76bec 100644
--- a/src/display.vala
+++ b/src/display.vala
@@ -22,6 +22,10 @@ private abstract class Boxes.Display: GLib.Object, Boxes.IPropertiesProvider {
public abstract void set_enable_inputs (Gtk.Widget widget, bool enable);
public abstract void set_enable_audio (bool enable);
+ public virtual bool should_keep_alive () {
+ return false;
+ }
+
public abstract void connect_it () throws GLib.Error;
public abstract void disconnect_it ();
diff --git a/src/spice-display.vala b/src/spice-display.vala
index c125c21..1ff2b1a 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -14,6 +14,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
private BoxConfig.SyncProperty[] display_sync_properties;
private BoxConfig.SyncProperty[] gtk_session_sync_properties;
private bool connected;
+ private bool closed;
public bool resize_guest { get; set; }
private void ui_state_changed () {
@@ -101,6 +102,24 @@ private class Boxes.SpiceDisplay: Boxes.Display {
return display;
}
+ private bool has_usb_device_connected () {
+ try {
+ var manager = UsbDeviceManager.get (session);
+ var devs = manager.get_devices ();
+ for (int i = 0; i < devs.length; i++) {
+ var dev = devs[i];
+ if (manager.is_device_connected (dev))
+ return true;
+ }
+ } catch (GLib.Error error) {
+ }
+ return false;
+ }
+
+ public override bool should_keep_alive () {
+ return !closed && has_usb_device_connected ();
+ }
+
public override void set_enable_audio (bool enable) {
session.enable_audio = enable;
}
@@ -175,6 +194,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
private void main_event (ChannelEvent event) {
switch (event) {
case ChannelEvent.CLOSED:
+ closed = true;
disconnected ();
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]