summaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test.c')
-rw-r--r--test.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..715c62b
--- /dev/null
+++ b/test.c
@@ -0,0 +1,141 @@
+#include "xas.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/Xatom.h> /* XA_CARDINAL */
+
+int
+main(int argc, char **argv)
+{
+ Display *xdpy;
+ int xscreen;
+ Window xwin_root;
+ Atom atom, atom2;
+ XasContext *xas_ctx;
+ XasCookie cookie, cookie2, cookie3, cookie4;
+ XWindowAttributes wattr;
+
+ if ((xdpy = XOpenDisplay(getenv("DISPLAY"))) == NULL)
+ {
+ fprintf(stderr, "failed to open DISPLAY\n");
+ exit(-1);
+ }
+
+ xscreen = DefaultScreen(xdpy);
+ xwin_root = RootWindow(xdpy, xscreen);
+
+ xas_ctx = xas_context_new(xdpy);
+
+ atom = XInternAtom(xdpy, "_NET_CURRENT_DESKTOP", False);
+ atom2 = XInternAtom(xdpy, "_NET_NUMBER_OF_DESKTOPS", False);
+
+ cookie = xas_get_property(xas_ctx,
+ xwin_root,
+ atom,
+ 0, 1L,
+ False,
+ XA_CARDINAL);
+
+ /* Whack this in, in attempt to mess things up */
+ XGetWindowAttributes(xdpy, xwin_root, &wattr);
+ XSync(xdpy, False);
+
+ cookie2 = xas_get_property(xas_ctx,
+ xwin_root,
+ atom2,
+ 0, 1L,
+ False,
+ XA_CARDINAL);
+
+ cookie3 = xas_get_window_attributes(xas_ctx, xwin_root);
+
+ cookie4 = xas_get_geometry(xas_ctx, (Drawable)xwin_root);
+
+ /* Make sure all our queued requested get processed by server */
+ XSync(xdpy, False);
+
+ { /* Now grab various results */
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytesafter;
+ int *result;
+
+ XasWindowAttributes *attr;
+
+ int x_return;
+ int y_return;
+ unsigned int width_return;
+ unsigned int height_return;
+ unsigned int border_width_return;
+ unsigned int depth_return;
+
+ int err;
+ char msg[255];
+
+ xas_get_property_reply(xas_ctx,
+ cookie,
+ &actual_type,
+ &actual_format,
+ &nitems,
+ &bytesafter,
+ (unsigned char**)&result,
+ NULL);
+
+ printf("got %li vs %li %li items, looks like %i\n",
+ XA_CARDINAL, actual_type, nitems, *result);
+
+ xas_get_property_reply(xas_ctx,
+ cookie2,
+ &actual_type,
+ &actual_format,
+ &nitems,
+ &bytesafter,
+ (unsigned char**)&result,
+ NULL);
+
+ printf("got %li vs %li %li items, looks like %i\n",
+ XA_CARDINAL, actual_type, nitems, *result);
+
+
+ attr = xas_get_window_attributes_reply(xas_ctx, cookie3, &err);
+
+ if (attr)
+ {
+ printf("got window attr ok..\n");
+ XFree(attr);
+ }
+
+ if (xas_get_geometry_reply (xas_ctx, cookie4,
+ &x_return,
+ &y_return,
+ &width_return,
+ &height_return,
+ &border_width_return,
+ &depth_return,
+ &err))
+ {
+ printf("xas_get_geometry_reply() success, x:%i, y%i, width:%i, height:%i, border:%i, depth:%i\n",
+ x_return,
+ y_return,
+ width_return,
+ height_return,
+ border_width_return,
+ depth_return);
+ }
+ else
+ {
+ printf("xas_get_geometry_reply() failed.");
+ if (err)
+ {
+ XGetErrorText(xdpy, err, msg, sizeof(msg));
+ printf(" Error was (%i) :'%s'\n", err, msg);
+ }
+ else
+ printf("No Error set\n");
+ }
+ }
+
+ return 0;
+}