Read window properties without using 'xprop'
This commit is contained in:
parent
f0d6af642e
commit
ee0bda8db3
1 changed files with 26 additions and 12 deletions
|
@ -25,6 +25,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
@ -409,25 +413,35 @@ sokoke_get_desktop (void)
|
||||||
{
|
{
|
||||||
#if HAVE_OSX
|
#if HAVE_OSX
|
||||||
return SOKOKE_DESKTOP_OSX;
|
return SOKOKE_DESKTOP_OSX;
|
||||||
#else
|
#elif defined (GDK_WINDOWING_X11)
|
||||||
static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED;
|
static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED;
|
||||||
if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED))
|
if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED))
|
||||||
{
|
{
|
||||||
/* Are we running in Xfce? */
|
/* Are we running in Xfce? */
|
||||||
gint result;
|
GdkDisplay* display = gdk_display_get_default ();
|
||||||
gchar *out = NULL;
|
Display* xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||||
gchar *err = NULL;
|
Window root_window = RootWindow (xdisplay, 0);
|
||||||
gboolean success = g_spawn_command_line_sync ("xprop -root _DT_SAVE_MODE",
|
Atom save_mode_atom = gdk_x11_get_xatom_by_name ("_DT_SAVE_MODE");
|
||||||
&out, &err, &result, NULL);
|
Atom actual_type;
|
||||||
g_free (err);
|
int actual_format;
|
||||||
if (success && ! result && out != NULL && strstr (out, "xfce4") != NULL)
|
unsigned long n_items, bytes;
|
||||||
desktop = SOKOKE_DESKTOP_XFCE;
|
gchar* value;
|
||||||
else
|
int status = XGetWindowProperty (xdisplay, root_window,
|
||||||
|
save_mode_atom, 0, (~0L),
|
||||||
|
False, AnyPropertyType, &actual_type, &actual_format,
|
||||||
|
&n_items, &bytes, (unsigned char**)&value);
|
||||||
desktop = SOKOKE_DESKTOP_UNKNOWN;
|
desktop = SOKOKE_DESKTOP_UNKNOWN;
|
||||||
g_free (out);
|
if (status == Success)
|
||||||
|
{
|
||||||
|
if (n_items == 6 && !strncmp (value, "xfce4", 6))
|
||||||
|
desktop = SOKOKE_DESKTOP_XFCE;
|
||||||
|
XFree (value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return desktop;
|
return desktop;
|
||||||
|
#else
|
||||||
|
return SOKOKE_DESKTOP_UNKNOWN;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue