[gedit] Do runtime checks for X11 specific calls
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Do runtime checks for X11 specific calls
- Date: Fri, 5 Apr 2013 13:32:47 +0000 (UTC)
commit 825fb2adf7cda03b45b860373f4b79080c265459
Author: Alexander Larsson <alexl redhat com>
Date: Fri Apr 5 15:27:13 2013 +0200
Do runtime checks for X11 specific calls
This means gedit doesn't break when using e.g. the broadway backend.
gedit/gedit-app-x11.c | 7 ++++-
gedit/gedit-utils.c | 62 ++++++++++++++++++++++++++----------------------
2 files changed, 40 insertions(+), 29 deletions(-)
---
diff --git a/gedit/gedit-app-x11.c b/gedit/gedit-app-x11.c
index 037dace..6ee415c 100644
--- a/gedit/gedit-app-x11.c
+++ b/gedit/gedit-app-x11.c
@@ -22,6 +22,10 @@
#include "gedit-app-x11.h"
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
#define GEDIT_APP_X11_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_APP_X11,
GeditAppX11Private))
G_DEFINE_TYPE (GeditAppX11, gedit_app_x11, GEDIT_TYPE_APP)
@@ -69,7 +73,8 @@ gedit_app_add_platform_data (GApplication *app,
* "_NET_WM_USER_TIME_WINDOW" one since that's what we're doing
* here...
*/
- if (!g_getenv ("DESKTOP_STARTUP_ID") && g_getenv ("DISPLAY"))
+ if (!g_getenv ("DESKTOP_STARTUP_ID") && g_getenv ("DISPLAY") &&
+ GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
{
gchar *startup_id;
Display *display;
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index f4f08f9..5ca8fc5 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -843,21 +843,24 @@ gedit_utils_get_window_workspace (GtkWindow *gtkwindow)
window = gtk_widget_get_window (GTK_WIDGET (gtkwindow));
display = gdk_window_get_display (window);
- gdk_error_trap_push ();
- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
- gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
- &bytes_after, (gpointer) &workspace);
- err = gdk_error_trap_pop ();
-
- if (err != Success || result != Success)
- return ret;
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ gdk_error_trap_push ();
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display,
"_NET_WM_DESKTOP"),
+ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+ &bytes_after, (gpointer) &workspace);
+ err = gdk_error_trap_pop ();
+
+ if (err != Success || result != Success)
+ return ret;
- if (type == XA_CARDINAL && format == 32 && nitems > 0)
- ret = workspace[0];
+ if (type == XA_CARDINAL && format == 32 && nitems > 0)
+ ret = workspace[0];
- XFree (workspace);
- return ret;
+ XFree (workspace);
+ return ret;
+ }
#else
/* FIXME: on mac etc proably there are native APIs
* to get the current workspace etc */
@@ -900,25 +903,28 @@ gedit_utils_get_current_viewport (GdkScreen *screen,
root_win = gdk_screen_get_root_window (screen);
display = gdk_screen_get_display (screen);
- gdk_error_trap_push ();
- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
- gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"),
- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
- &bytes_after, (void*) &coordinates);
- err = gdk_error_trap_pop ();
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ gdk_error_trap_push ();
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
+ gdk_x11_get_xatom_by_name_for_display (display,
"_NET_DESKTOP_VIEWPORT"),
+ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+ &bytes_after, (void*) &coordinates);
+ err = gdk_error_trap_pop ();
- if (err != Success || result != Success)
- return;
+ if (err != Success || result != Success)
+ return;
- if (type != XA_CARDINAL || format != 32 || nitems < 2)
- {
+ if (type != XA_CARDINAL || format != 32 || nitems < 2)
+ {
+ XFree (coordinates);
+ return;
+ }
+
+ *x = coordinates[0];
+ *y = coordinates[1];
XFree (coordinates);
- return;
}
-
- *x = coordinates[0];
- *y = coordinates[1];
- XFree (coordinates);
#else
/* FIXME: on mac etc proably there are native APIs
* to get the current workspace etc */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]