[pitivi] system: Set the xid only when on X11



commit 6edc36b9feab7e40c231d15c577d3796c19524a0
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue May 3 01:09:07 2016 +0200

    system: Set the xid only when on X11
    
    Differential Revision: https://phabricator.freedesktop.org/D984

 pitivi/application.py  |    4 ++--
 pitivi/mainwindow.py   |    7 ++++---
 pitivi/utils/system.py |   12 +++++++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index b1df9e5..647d040 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -174,13 +174,13 @@ class Pitivi(Gtk.Application, Loggable):
         if self.gui:
             # The app is already started and the window already created.
             # Present the already existing window.
-            try:
+            if self.system.has_x11():
                 # TODO: Use present() instead of present_with_time() when
                 # https://bugzilla.gnome.org/show_bug.cgi?id=688830 is fixed.
                 from gi.repository import GdkX11
                 x11_server_time = GdkX11.x11_get_server_time(self.gui.get_window())
                 self.gui.present_with_time(x11_server_time)
-            except ImportError:
+            else:
                 # On Wayland or Quartz (Mac OS X) backend there is no GdkX11,
                 # so just use present() directly here.
                 self.gui.present()
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index aa5fe41..1efac16 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -118,8 +118,8 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
     """
     Pitivi's main window.
 
-    @cvar app: The application object
-    @type app: L{Pitivi}
+    Attributes:
+        app (pitivi.application.Pitivi): The current app.
     """
 
     def __init__(self, app):
@@ -1027,7 +1027,8 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
 
     def _installPlugins(self, details, missingPluginsCallback):
         context = GstPbutils.InstallPluginsContext()
-        context.set_xid(self.window.xid)
+        if self.app.system.has_x11():
+            context.set_xid(self.window.xid)
 
         res = GstPbutils.install_plugins_async(details, context,
                                                missingPluginsCallback)
diff --git a/pitivi/utils/system.py b/pitivi/utils/system.py
index 00ea12c..64c1932 100644
--- a/pitivi/utils/system.py
+++ b/pitivi/utils/system.py
@@ -42,9 +42,19 @@ class System(GObject.Object, Loggable):
     def __init__(self):
         GObject.Object.__init__(self)
         Loggable.__init__(self)
-        self.log("new object " + str(self))
+        self.log("new object %s", self)
         self._reset()
 
+        self._x11 = False
+        try:
+            from gi.repository import GdkX11
+            self._x11 = True
+        except ImportError:
+            pass
+
+    def has_x11(self):
+        return self._x11
+
     def _reset(self):
         self._screensaver_keys = []
         self._sleep_keys = []


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]