[virt-tools-list] [PATCH v2 5/5] virt-manager: add opengl graphics option

Marc-André Lureau marcandre.lureau at redhat.com
Fri Mar 4 11:31:55 UTC 2016


From: Marc-André Lureau <marcandre.lureau at gmail.com>

Add a OpenGl checkbox to the Spice graphics option.

Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
---
 ui/gfxdetails.ui          | 29 +++++++++++++++++++++++++++++
 virtManager/details.py    |  9 +++++++--
 virtManager/domain.py     |  5 ++++-
 virtManager/gfxdetails.py | 11 ++++++++---
 4 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index 85dbac6..87c50f9 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -363,5 +363,34 @@
         <property name="top_attach">0</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkLabel" id="label3">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">OpenGL</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">8</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkCheckButton" id="graphics-opengl">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="xalign">0.05000000074505806</property>
+        <property name="yalign">0.55000001192092896</property>
+        <property name="draw_indicator">True</property>
+        <signal name="toggled" handler="on_graphics_opengl_toggled" swapped="no"/>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="top_attach">8</property>
+      </packing>
+    </child>
   </object>
 </interface>
diff --git a/virtManager/details.py b/virtManager/details.py
index 050ff26..99dcb6e 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -90,6 +90,7 @@ EDIT_GFX_KEYMAP,
 EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
+EDIT_GFX_OPENGL,
 
 EDIT_VIDEO_MODEL,
 
@@ -104,7 +105,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 45)
+) = range(1, 46)
 
 
 # Columns in hw list model
@@ -376,6 +377,8 @@ class vmmDetails(vmmGObjectUI):
             lambda *x: self.enable_apply(x, EDIT_GFX_TYPE))
         self.gfxdetails.connect("changed-port",
             lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
+        self.gfxdetails.connect("changed-opengl",
+            lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
         self.gfxdetails.connect("changed-tlsport",
             lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
         self.gfxdetails.connect("changed-address",
@@ -2130,7 +2133,7 @@ class vmmDetails(vmmGObjectUI):
 
     def config_graphics_apply(self, devobj):
         (gtype, port,
-         tlsport, addr, passwd, keymap) = self.gfxdetails.get_values()
+         tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
         kwargs = {}
 
@@ -2142,6 +2145,8 @@ class vmmDetails(vmmGObjectUI):
             kwargs["keymap"] = keymap
         if self.edited(EDIT_GFX_PORT):
             kwargs["port"] = port
+        if self.edited(EDIT_GFX_OPENGL):
+            kwargs["gl"] = gl
         if self.edited(EDIT_GFX_TLSPORT):
             kwargs["tlsport"] = tlsport
         if self.edited(EDIT_GFX_TYPE):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 33535af..61311b7 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -826,7 +826,8 @@ class vmmDomain(vmmLibvirtObject):
 
     def define_graphics(self, devobj, do_hotplug,
         listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
-        passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL):
+        passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
+        gl=_SENTINEL):
         xmlobj = self._make_xmlobj_to_define()
         editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
         if not editdev:
@@ -844,6 +845,8 @@ class vmmDomain(vmmLibvirtObject):
             editdev.keymap = keymap
         if gtype != _SENTINEL:
             editdev.type = gtype
+        if gl != _SENTINEL:
+            editdev.gl = gl
 
         if do_hotplug:
             self.hotplug(device=editdev)
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index 0ae76c9..9548065 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -35,6 +35,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
         "changed-type": (GObject.SignalFlags.RUN_FIRST, None, []),
         "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
         "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
+        "changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
     }
 
     def __init__(self, vm, builder, topwin):
@@ -54,6 +55,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
             "on_graphics_tlsport_changed": lambda ignore: self.emit("changed-tlsport"),
             "on_graphics_port_changed": lambda ignore: self.emit("changed-port"),
             "on_graphics_keymap_changed": lambda ignore: self.emit("changed-keymap"),
+            "on_graphics_opengl_toggled": lambda ignore: self.emit("changed-opengl"),
         })
 
         self._init_ui()
@@ -143,7 +145,9 @@ class vmmGraphicsDetails(vmmGObjectUI):
         if not self.widget("graphics-password-chk").get_active():
             passwd = None
 
-        return gtype, port, tlsport, addr, passwd, keymap
+        gl = self.widget("graphics-opengl").get_active()
+
+        return gtype, port, tlsport, addr, passwd, keymap, gl
 
     def set_dev(self, gfx):
         self.reset_state()
@@ -188,6 +192,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 
         if is_spice:
             set_port("graphics-tlsport", gfx.tlsPort)
+            self.widget("graphics-opengl").set_active(gfx.gl)
 
         if is_sdl:
             title = _("Local SDL Window")
@@ -208,13 +213,13 @@ class vmmGraphicsDetails(vmmGObjectUI):
     def _show_rows_from_type(self):
         hide_all = ["graphics-xauth", "graphics-display", "graphics-address",
             "graphics-password-box", "graphics-keymap", "graphics-port-box",
-            "graphics-tlsport-box"]
+            "graphics-tlsport-box", "graphics-opengl"]
 
         gtype = uiutil.get_list_selection(self.widget("graphics-type"))
         sdl_rows = ["graphics-xauth", "graphics-display"]
         vnc_rows = ["graphics-password-box", "graphics-address",
             "graphics-port-box", "graphics-keymap"]
-        spice_rows = vnc_rows[:] + ["graphics-tlsport-box"]
+        spice_rows = vnc_rows[:] + ["graphics-tlsport-box", "graphics-opengl"]
 
         rows = []
         if gtype == "sdl":
-- 
2.5.0




More information about the virt-tools-list mailing list