diff options
author | kraxel <kraxel> | 2006-07-03 12:00:31 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2006-07-03 12:00:31 +0000 |
commit | 8f4db7fb5130a0b327154eddc62b161fb66af688 (patch) | |
tree | cb43a91e2fdd769e7285c8f7fa76e0a4e83173fb /apps-x11.c | |
parent | a27248c91a6a7a48ce794efc4ed51cc9a6e7172b (diff) | |
download | xenwatch-8f4db7fb5130a0b327154eddc62b161fb66af688.tar.gz |
xen screen management tool
Diffstat (limited to 'apps-x11.c')
-rw-r--r-- | apps-x11.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/apps-x11.c b/apps-x11.c new file mode 100644 index 0000000..3ed61dc --- /dev/null +++ b/apps-x11.c @@ -0,0 +1,88 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> +#include <xs.h> + +#include "apps.h" + +/* ------------------------------------------------------------------ */ + +#if 0 +/* check_wm_capability(dpy, root, _NET_SUPPORTED, _NET_WM_whatever); */ +static int +check_wm_capability(Display *dpy, Window root, Atom list, Atom wanted) +{ + Atom type; + int format; + unsigned int i; + unsigned long nitems, bytesafter; + unsigned char *args; + unsigned long *ldata; + char *name; + int retval = -1; + + if (Success != XGetWindowProperty + (dpy, root, list, 0, (65536 / sizeof(long)), False, + AnyPropertyType, &type, &format, &nitems, &bytesafter, &args)) + return -1; + if (type != XA_ATOM) + return -1; + ldata = (unsigned long*)args; + for (i = 0; i < nitems; i++) { + if (ldata[i] == wanted) + retval = 0; + if (debug) { + name = XGetAtomName(dpy,ldata[i]); + fprintf(stderr,"wm cap: %s\n",name); + XFree(name); + } + } + XFree(ldata); + return retval; +} +#endif + +static int +check_atom_present(Display *dpy, Window root, Atom check) +{ + Atom type; + int format; + unsigned long nitems, bytesafter; + unsigned char *args; + + if (Success != XGetWindowProperty + (dpy, root, check, 0, (65536 / sizeof(long)), False, + AnyPropertyType, &type, &format, &nitems, &bytesafter, &args)) + return -1; + if (NULL == args) + return -1; + return 0; +} + +#define INIT_ATOM(dpy,atom) atom = XInternAtom(dpy,#atom,False) +static Atom KWIN_RUNNING; +static Atom _METACITY_SENTINEL; + +void detect_desktop(void) +{ + Display *dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); + Window root = DefaultRootWindow(dpy); + + INIT_ATOM(dpy, KWIN_RUNNING); + INIT_ATOM(dpy, _METACITY_SENTINEL); + + if (0 == check_atom_present(dpy, root, KWIN_RUNNING)) { + fprintf(stderr,"Desktop: KDE\n"); + desktop_type = DESKTOP_KDE; + } + if (0 == check_atom_present(dpy, root, _METACITY_SENTINEL)) { + fprintf(stderr,"Desktop: Gnome\n"); + desktop_type = DESKTOP_GNOME; + } +} |