From a5db87686475595375d9edd4696a7c35e1cc244d Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Tue, 6 Jun 2017 13:14:57 +0200
Subject: [PATCH 1/2] Specify the Wnck version to silence a warning
Otherwise, we get:
dfeet/wnck_utils.py:9: PyGIWarning: Wnck was imported without
specifying a version first. Use gi.require_version('Wnck', '3.0')
before import to ensure that the right version gets loaded.
https://bugzilla.gnome.org/show_bug.cgi?id=783468
---
src/dfeet/wnck_utils.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/dfeet/wnck_utils.py b/src/dfeet/wnck_utils.py
index ff92e726d953..2ba68a6f5db6 100644
--- a/src/dfeet/wnck_utils.py
+++ b/src/dfeet/wnck_utils.py
@@ -3,9 +3,11 @@
# icon information. If the wnck module is not installed we fallback to default
# behvior
+import gi
from gi.repository import Gtk
try:
+ gi.require_version('Wnck', '3.0')
from gi.repository import Wnck
has_libwnck = True
except:
--
2.9.4
From 15668d252ef7a8ff6df43447f36d29f1dc56f773 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Tue, 6 Jun 2017 16:13:45 +0200
Subject: [PATCH 2/2] Assume Wnck is absent on non-X11
Wnck is an X11-only API. While Wnck.Screen.get_default() might have
elegantly returned None in the absence of X11 earlier, we cannot rely
on that behaviour. In fact, the same version of libwnck has started to
crash inside Wnck.Screen.get_default().
Let's not touch Wnck when X11 is absent.
https://bugzilla.gnome.org/show_bug.cgi?id=763615
---
src/dfeet/wnck_utils.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/dfeet/wnck_utils.py b/src/dfeet/wnck_utils.py
index 2ba68a6f5db6..9d103ef9fadb 100644
--- a/src/dfeet/wnck_utils.py
+++ b/src/dfeet/wnck_utils.py
@@ -4,9 +4,15 @@
# behvior
import gi
-from gi.repository import Gtk
+from gi.repository import Gtk, Gdk, GLib
+
+def running_in_x11():
+ display = Gdk.Display.get_default()
+ return display.__gtype__.name == 'GdkX11Display'
try:
+ if not running_in_x11():
+ raise GLib.Error('Wnck is only meant to be used with X11')
gi.require_version('Wnck', '3.0')
from gi.repository import Wnck
has_libwnck = True
@@ -26,7 +32,6 @@ class IconTable(object):
if has_libwnck:
screen = Wnck.Screen.get_default()
- # screen is None under Wayland
if screen is not None:
Wnck.Screen.force_update(screen)
screen.connect('application_opened', self.on_app_open)
--
2.9.4