Replace deprecated Automake INCLUDES variable with AM_CPPFLAGS
[free-sw/xcb/demo] / tests / julia.c
index 133389c..75468ce 100644 (file)
@@ -2,11 +2,13 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <string.h>
+#include <assert.h>
 
 #include <xcb/xcb.h>
 #include <xcb/shm.h>
 #include <xcb/xcb_aux.h>
 #include <xcb/xcb_image.h>
+#include <xcb/xcb_atom.h>
 #define XCB_ALL_PLANES ~0
 
 /* Needed for xcb_set_wm_protocols() */
@@ -44,22 +46,6 @@ double height = 2.4;
 /* Numbers of colors in the palette */
 int cmax = 316;
 
-static xcb_atom_t
-get_atom (xcb_connection_t *connection, const char *atomName)
-{
-  if (atomName == NULL)
-    return XCB_NONE;
-  xcb_atom_t atom = XCB_NONE;
-  xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection,
-       xcb_intern_atom(connection, 0, strlen(atomName), atomName), NULL);
-  if (reply)
-    {
-      atom = reply->atom;
-      free(reply);
-    }
-  return atom;
-}
-
 void
 palette_julia (Data *datap)
 {
@@ -109,6 +95,8 @@ draw_julia (Data *datap)
                       0, 0, W_W, W_H,
                       XCB_ALL_PLANES, datap->format);
   
+  assert(datap->image);
+
   for (i = 0 ; i < datap->image->width ; i++)
     for (j = 0 ; j < datap->image->height ; j++)
       {
@@ -198,12 +186,13 @@ main (int argc, char *argv[])
 
   palette_julia (&data);
 
-  xcb_atom_t deleteWindowAtom = get_atom(data.conn, "WM_DELETE_WINDOW");
+  xcb_atom_t deleteWindowAtom = xcb_atom_get(data.conn, "WM_DELETE_WINDOW");
+  xcb_atom_t wmprotocolsAtom = xcb_atom_get(data.conn, "WM_PROTOCOLS");
   /* Listen to X client messages in order to be able to pickup
      the "delete window" message that is generated for example
      when someone clicks the top-right X button within the window
      manager decoration (or when user hits ALT-F4). */
-  xcb_set_wm_protocols (data.conn, data.draw, 1, &deleteWindowAtom);
+  xcb_set_wm_protocols (data.conn, wmprotocolsAtom, data.draw, 1, &deleteWindowAtom);
 
   xcb_flush (data.conn); 
 
@@ -213,7 +202,7 @@ main (int argc, char *argv[])
       xcb_generic_event_t *e;
       if (e = xcb_wait_for_event(data.conn))
        {
-          switch (e->response_type & 0x7f)
+          switch (XCB_EVENT_RESPONSE_TYPE(e))
            {
            case XCB_EXPOSE:
              {