Merge pull request #108 from JosephMcc/wayland-fix1

xed-utils: Add runtime checks for x11 specific functions
This commit is contained in:
Clement Lefebvre 2017-04-02 11:31:32 +01:00 committed by GitHub
commit 29c744694c
1 changed files with 65 additions and 55 deletions

View File

@ -54,8 +54,6 @@
/* For the workspace/viewport stuff */ /* For the workspace/viewport stuff */
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#endif #endif
@ -655,12 +653,6 @@ xed_utils_get_current_workspace (GdkScreen *screen)
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
GdkWindow *root_win; GdkWindow *root_win;
GdkDisplay *display; GdkDisplay *display;
Atom type;
gint format;
gulong nitems;
gulong bytes_after;
guint *current_desktop;
gint err, result;
guint ret = 0; guint ret = 0;
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0); g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
@ -668,6 +660,15 @@ xed_utils_get_current_workspace (GdkScreen *screen)
root_win = gdk_screen_get_root_window (screen); root_win = gdk_screen_get_root_window (screen);
display = gdk_screen_get_display (screen); display = gdk_screen_get_display (screen);
if (GDK_IS_X11_DISPLAY (display))
{
Atom type;
gint format;
gulong nitems;
gulong bytes_after;
guint *current_desktop;
gint err, result;
gdk_error_trap_push (); gdk_error_trap_push ();
result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win), result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"), gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
@ -686,6 +687,8 @@ xed_utils_get_current_workspace (GdkScreen *screen)
} }
XFree (current_desktop); XFree (current_desktop);
}
return ret; return ret;
#else #else
/* FIXME: on mac etc proably there are native APIs /* FIXME: on mac etc proably there are native APIs
@ -723,6 +726,8 @@ xed_utils_get_window_workspace (GtkWindow *gtkwindow)
window = gtk_widget_get_window (GTK_WIDGET (gtkwindow)); window = gtk_widget_get_window (GTK_WIDGET (gtkwindow));
display = gdk_window_get_display (window); display = gdk_window_get_display (window);
if (GDK_IS_X11_DISPLAY (display))
{
gdk_error_trap_push (); gdk_error_trap_push ();
result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"), gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
@ -741,6 +746,8 @@ xed_utils_get_window_workspace (GtkWindow *gtkwindow)
} }
XFree (workspace); XFree (workspace);
}
return ret; return ret;
#else #else
/* FIXME: on mac etc proably there are native APIs /* FIXME: on mac etc proably there are native APIs
@ -783,6 +790,8 @@ xed_utils_get_current_viewport (GdkScreen *screen,
root_win = gdk_screen_get_root_window (screen); root_win = gdk_screen_get_root_window (screen);
display = gdk_screen_get_display (screen); display = gdk_screen_get_display (screen);
if (GDK_IS_X11_DISPLAY (display))
{
gdk_error_trap_push (); gdk_error_trap_push ();
result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win), result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"), gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"),
@ -804,6 +813,7 @@ xed_utils_get_current_viewport (GdkScreen *screen,
*x = coordinates[0]; *x = coordinates[0];
*y = coordinates[1]; *y = coordinates[1];
XFree (coordinates); XFree (coordinates);
}
#else #else
/* FIXME: on mac etc proably there are native APIs /* FIXME: on mac etc proably there are native APIs
* to get the current workspace etc */ * to get the current workspace etc */