[empathy] Don't crash when running in Wayland
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Don't crash when running in Wayland
- Date: Sat, 9 May 2015 18:08:36 +0000 (UTC)
commit 193e853c8b0d3c1222d7565eb209354f460cad9b
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat May 9 09:59:49 2015 -0500
Don't crash when running in Wayland
It's wrong to use X11-specific APIs without checking:
* If GTK+ was compiled with support for X11
* If the application is currently running in X11
libempathy-gtk/empathy-avatar-image.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-avatar-image.c b/libempathy-gtk/empathy-avatar-image.c
index 78a3e5f..1468802 100644
--- a/libempathy-gtk/empathy-avatar-image.c
+++ b/libempathy-gtk/empathy-avatar-image.c
@@ -119,6 +119,19 @@ avatar_image_finalize (GObject *object)
G_OBJECT_CLASS (empathy_avatar_image_parent_class)->finalize (object);
}
+#ifdef GDK_WINDOWING_X11
+static gboolean
+running_in_x11 (void)
+{
+ GdkDisplay* display;
+
+ display = gdk_display_get_default ();
+ if (!display)
+ return FALSE;
+
+ return GDK_IS_X11_DISPLAY (display);
+}
+
static GdkFilterReturn
avatar_image_filter_func (GdkXEvent *gdkxevent,
GdkEvent *event,
@@ -128,6 +141,9 @@ avatar_image_filter_func (GdkXEvent *gdkxevent,
Atom atom;
EmpathyAvatarImagePriv *priv;
+ if (!running_in_x11 ())
+ return GDK_FILTER_CONTINUE;
+
priv = GET_PRIV (data);
if (xevent->type == PropertyNotify) {
@@ -151,6 +167,9 @@ avatar_image_add_filter (EmpathyAvatarImage *avatar_image)
gint mask;
XWindowAttributes attrs;
+ if (!running_in_x11 ())
+ return;
+
mask = PropertyChangeMask;
window = gdk_x11_get_default_root_xwindow ();
@@ -167,6 +186,20 @@ avatar_image_add_filter (EmpathyAvatarImage *avatar_image)
gdk_window_add_filter (NULL, avatar_image_filter_func, avatar_image);
}
+#else
+static GdkFilterReturn
+avatar_image_filter_func (GdkXEvent *gdkxevent,
+ GdkEvent *event,
+ gpointer data)
+{
+ return GDK_FILTER_CONTINUE;
+}
+
+static void
+avatar_image_add_filter (EmpathyAvatarImage *avatar_image)
+{
+}
+#endif
static void
avatar_image_remove_filter (EmpathyAvatarImage *avatar_image)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]