[gnome-boxes/gnome-3-32] libvirt-machine/properties: Add "3D Acceleration" option
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/gnome-3-32] libvirt-machine/properties: Add "3D Acceleration" option
- Date: Thu, 6 Jun 2019 13:41:21 +0000 (UTC)
commit 3ccadf3e716f2fcf4ff5bf2ef6cc286fa14264ac
Author: Felipe Borges <felipeborges gnome org>
Date: Tue May 21 17:19:38 2019 +0200
libvirt-machine/properties: Add "3D Acceleration" option
The workflow for disabling 3D acceleration introduced in commit
4fb96156 has some issues for users that cannot see the notification
because Boxes crashes before.
There were also reports of users that wanted to Enable the feature
after they disabled it (which wasn't supported by the notification
workflow, since it would stop presenting the notification once the
user would act on it).
Fixes #361
src/box-config.vala | 5 --
src/libvirt-machine-properties.vala | 23 ++++++++++
src/libvirt-machine.vala | 92 +++++++++++++++----------------------
3 files changed, 61 insertions(+), 59 deletions(-)
---
diff --git a/src/box-config.vala b/src/box-config.vala
index 6710c17b..15843b55 100644
--- a/src/box-config.vala
+++ b/src/box-config.vala
@@ -37,11 +37,6 @@
set { keyfile.set_string_list (group, "categories", value); }
}
- public bool tweaked_accel3d {
- get { return get_boolean (group, "tweaked-accel3d", false); }
- set { keyfile.set_boolean (group, "tweaked-accel3d", value); }
- }
-
public int64 access_last_time { set; get; }
public int64 access_first_time { set; get; }
public int64 access_total_time { set; get; } // in seconds
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 6d1bee9d..b9255eb9 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -116,6 +116,8 @@ public string collect_logs () {
add_string_property (ref list, _("Display URL"), machine.display.uri);
}
+ add_3d_acceleration_property (ref list);
+
break;
case PropertiesPage.SYSTEM:
@@ -677,4 +679,25 @@ private void add_run_in_bg_property (ref List<Boxes.Property> list) {
return property;
}
+
+ private void add_3d_acceleration_property (ref List<Boxes.Property> list) {
+ var toggle = new Gtk.Switch ();
+ toggle.halign = Gtk.Align.START;
+ var property = add_property (ref list, _("3D Acceleration"), toggle);
+ property.reboot_required = true;
+
+ machine.bind_property ("acceleration-3d", toggle, "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+
+ machine.supports_accel3d.begin ((source, result) => {
+ try {
+ if (!machine.supports_accel3d.end (result)) {
+ property.label.destroy ();
+ property.widget.destroy ();
+ }
+ } catch (GLib.Error error) {
+ warning (error.message);
+ }
+ });
+ }
}
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 0f1b8290..3b19dbac 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -49,6 +49,42 @@
public bool run_in_bg { get; set; } // If true, machine will never be paused automatically by Boxes.
+ private bool _acceleration_3d;
+ public bool acceleration_3d {
+ get {
+ return _acceleration_3d;
+ }
+
+ set {
+ _acceleration_3d = value;
+
+ GLib.List<GVirConfig.DomainDevice> devices = null;
+ foreach (var device in domain_config.get_devices ()) {
+ if (device is GVirConfig.DomainGraphicsSpice) {
+ var graphics_device = VMConfigurator.create_graphics_device (_acceleration_3d);
+
+ devices.prepend (graphics_device);
+ } else if (device is GVirConfig.DomainVideo) {
+ var video_device = device as GVirConfig.DomainVideo;
+ video_device.set_accel3d (_acceleration_3d);
+
+ devices.prepend (video_device);
+ } else {
+ devices.prepend (device);
+ }
+ }
+
+ devices.reverse ();
+ domain_config.set_devices (devices);
+
+ try {
+ domain.set_config (domain_config);
+ } catch (GLib.Error error) {
+ warning ("Failed to disable 3D Acceleration");
+ }
+ }
+ }
+
public override bool is_local {
get {
// If the URI is prefixed by "qemu" or "qemu+unix" and the domain is "system" of "session" then
it is local.
@@ -245,6 +281,7 @@ else if (force_stopped) {
saved_properties = {
BoxConfig.SavedProperty () { name = "run-in-bg", default_value = false },
+ BoxConfig.SavedProperty () { name = "acceleration-3d", default_value = false },
};
this.config.save_properties (this, saved_properties);
@@ -616,59 +653,6 @@ else if (state == MachineState.SLEEPING) {
}
}
}
-
- /* Some users might have issues with 3D acceleration due to various setups
- * with different video drivers in the host. So we should offer an option
- * to run these VMs without 3D acceleration.
- */
- if (!config.tweaked_accel3d && yield supports_accel3d ()) {
- Boxes.Notification notification = null;
-
- Notification.OKFunc disable_accel3d = () => {
- notification = null;
-
- GLib.List<GVirConfig.DomainDevice> devices = null;
- foreach (var device in domain_config.get_devices ()) {
- if (device is GVirConfig.DomainGraphicsSpice) {
- var graphics_device = VMConfigurator.create_graphics_device (false);
-
- devices.prepend (graphics_device);
- } else if (device is GVirConfig.DomainVideo) {
- var video_device = device as GVirConfig.DomainVideo;
-
- video_device.set_accel3d (false);
- devices.prepend (device);
- } else {
- devices.prepend (device);
- }
- }
-
- devices.reverse ();
- domain_config.set_devices (devices);
-
- try {
- domain.set_config (domain_config);
- config.tweaked_accel3d = true;
- } catch (GLib.Error error) {
- debug ("Failed to disable 3d acceleration!\n");
- }
-
- force_shutdown ();
- };
-
- Notification.DismissFunc dismiss_notification = () => {
- notification = null;
-
- config.tweaked_accel3d = true;
- };
-
- var message = _("Experiencing graphics problems?");
- notification = window.notificationbar.display_for_action (message,
- _("Disable 3D acceleration"),
- (owned) disable_accel3d,
- (owned) dismiss_notification,
- -1);
- }
}
public override void restart () {
@@ -776,7 +760,7 @@ public override async void clone () {
}
}
- private async bool supports_accel3d () {
+ public async bool supports_accel3d () {
var os = yield get_os ();
if (os == null)
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]