Discussion:
[Xcb] [PATCH demo 1/1] make xcb/demo compile again.
Christian Linhart
2017-03-18 09:55:06 UTC
Permalink
The reasoning behind this change is to prepare xcb/demo as
a place to be used for test-suites.

The changes are loosely based on patches posted by William Swanson
on Nov 17, 2012.

Signed-off-by: Christian Linhart <***@demorecorder.com>
---
Makefile.am | 6 +++---
tests/flames.c | 16 +++++++++++-----
tests/julia.c | 16 ++++++++++++----
3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 7521af0..0f0f715 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,25 +18,25 @@ hypnomoire_SOURCES = hypnomoire.c reply_formats.c reply_formats.h
xcbdpyinfo_SOURCES = xcbdpyinfo.c

xcb_test_CFLAGS = $(XCBAUX_CFLAGS)
xcb_test_LDADD = $(XCBAUX_LIBS) -lpthread
xcb_test_SOURCES = xcb-test.c reply_formats.c reply_formats.h

dpms_CFLAGS = $(XCBDPMS_CFLAGS)
-dpms_LDADD = $(XCBDPMS_LIBS)
+dpms_LDADD = $(XCBDPMS_LIBS) $(XCB_LIBS)
dpms_SOURCES = dpms.c

rendertest_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRENDER_CFLAGS)
rendertest_LDADD = $(XCBAUX_LIBS) $(XCBRENDER_LIBS)
rendertest_SOURCES = rendertest.c

xcbrandr_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRANDR_CFLAGS)
xcbrandr_LDADD = $(XCBAUX_LIBS) $(XCBRANDR_LIBS)
xcbrandr_SOURCES = xcbrandr.c

xcbxf86dri_CFLAGS = $(XCBXF86DRI_CFLAGS)
-xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS)
+xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS) $(XCB_LIBS)
xcbxf86dri_SOURCES = xcbxf86dri.c

xcbxvinfo_CFLAGS = $(XCBXV_CFLAGS)
-xcbxvinfo_LDADD = $(XCBXV_LIBS)
+xcbxvinfo_LDADD = $(XCBXV_LIBS) $(XCB_LIBS)
xcbxvinfo_SOURCES = xcbxvinfo.c
diff --git a/tests/flames.c b/tests/flames.c
index 89e93cf..391c7ed 100644
--- a/tests/flames.c
+++ b/tests/flames.c
@@ -28,16 +28,17 @@
#include <unistd.h>

#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
+#include <xcb/xcb_event.h>

-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>

#define XCB_ALL_PLANES ~0
#include <xcb/xcb_icccm.h>

/* some defines for the flame */
#define HSPREAD 26
@@ -72,24 +73,29 @@ typedef struct
/* the flame arrays */
int ws;
unsigned int *flame;
unsigned int *flame2;

}flame;

-static xcb_atom_t get_atom (xcb_connection_t *connection, const char *atomName);
static void title_set (flame *f, const char *title);
static int ilog2 (unsigned int n);
static void flame_set_palette (flame *f);
static void flame_set_flame_zero (flame *f);
static void flame_set_random_flame_base (flame *f);
static void flame_modify_flame_base (flame *f);
static void flame_process_flame (flame *f);
static void flame_draw_flame (flame *f);

+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
flame *
flame_init ()
{
flame *f;
xcb_screen_t *screen;
xcb_gcontext_t gc = { 0 };
int screen_nbr;
@@ -211,21 +217,21 @@ main ()
printf ("Can't initialize global data\nExiting...\n");
return -1;
}

flame_set_flame_zero (f);
flame_set_random_flame_base (f);

- xcb_atom_t deleteWindowAtom = xcb_atom_get(f->xcb.c, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(f->xcb.c, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(f->xcb.c, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(f->xcb.c, "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 (f->xcb.c, wmprotocolsAtom, f->xcb.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (f->xcb.c, f->xcb.draw, wmprotocolsAtom, 1, &deleteWindowAtom);

bool finished = false;
while (!finished)
{
if ((e = xcb_poll_for_event (f->xcb.c)))
{
switch (XCB_EVENT_RESPONSE_TYPE(e))
diff --git a/tests/julia.c b/tests/julia.c
index 75468ce..eefd829 100644
--- a/tests/julia.c
+++ b/tests/julia.c
@@ -5,17 +5,19 @@
#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>
+#include <xcb/xcb_event.h>
+
#define XCB_ALL_PLANES ~0

-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>

#include "julia.h"

#define W_W 640
#define W_H 480

@@ -116,14 +118,20 @@ draw_julia (Data *datap)
datap->palette[c]);
}

xcb_image_put (datap->conn, datap->draw, datap->gc, datap->image,
0, 0, 0);
}

+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
int
main (int argc, char *argv[])
{
Data data;
xcb_screen_t *screen;
xcb_drawable_t win;
xcb_drawable_t rect;
@@ -182,21 +190,21 @@ main (int argc, char *argv[])
XCB_COLORMAP_ALLOC_NONE,
data.cmap,
data.draw,
screen->root_visual);

palette_julia (&data);

- xcb_atom_t deleteWindowAtom = xcb_atom_get(data.conn, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(data.conn, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(data.conn, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(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, wmprotocolsAtom, data.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (data.conn, data.draw, wmprotocolsAtom, 1, &deleteWindowAtom);

xcb_flush (data.conn);

bool finished = false;
while (!finished)
{
xcb_generic_event_t *e;
--
2.1.4
Bart Massey
2017-03-18 15:34:42 UTC
Permalink
Nice! Thanks
Post by Christian Linhart
The reasoning behind this change is to prepare xcb/demo as
a place to be used for test-suites.
The changes are loosely based on patches posted by William Swanson
on Nov 17, 2012.
---
Makefile.am | 6 +++---
tests/flames.c | 16 +++++++++++-----
tests/julia.c | 16 ++++++++++++----
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7521af0..0f0f715 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,25 +18,25 @@ hypnomoire_SOURCES = hypnomoire.c reply_formats.c reply_formats.h
xcbdpyinfo_SOURCES = xcbdpyinfo.c
xcb_test_CFLAGS = $(XCBAUX_CFLAGS)
xcb_test_LDADD = $(XCBAUX_LIBS) -lpthread
xcb_test_SOURCES = xcb-test.c reply_formats.c reply_formats.h
dpms_CFLAGS = $(XCBDPMS_CFLAGS)
-dpms_LDADD = $(XCBDPMS_LIBS)
+dpms_LDADD = $(XCBDPMS_LIBS) $(XCB_LIBS)
dpms_SOURCES = dpms.c
rendertest_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRENDER_CFLAGS)
rendertest_LDADD = $(XCBAUX_LIBS) $(XCBRENDER_LIBS)
rendertest_SOURCES = rendertest.c
xcbrandr_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRANDR_CFLAGS)
xcbrandr_LDADD = $(XCBAUX_LIBS) $(XCBRANDR_LIBS)
xcbrandr_SOURCES = xcbrandr.c
xcbxf86dri_CFLAGS = $(XCBXF86DRI_CFLAGS)
-xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS)
+xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS) $(XCB_LIBS)
xcbxf86dri_SOURCES = xcbxf86dri.c
xcbxvinfo_CFLAGS = $(XCBXV_CFLAGS)
-xcbxvinfo_LDADD = $(XCBXV_LIBS)
+xcbxvinfo_LDADD = $(XCBXV_LIBS) $(XCB_LIBS)
xcbxvinfo_SOURCES = xcbxvinfo.c
diff --git a/tests/flames.c b/tests/flames.c
index 89e93cf..391c7ed 100644
--- a/tests/flames.c
+++ b/tests/flames.c
@@ -28,16 +28,17 @@
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
+#include <xcb/xcb_event.h>
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#define XCB_ALL_PLANES ~0
#include <xcb/xcb_icccm.h>
/* some defines for the flame */
#define HSPREAD 26
@@ -72,24 +73,29 @@ typedef struct
/* the flame arrays */
int ws;
unsigned int *flame;
unsigned int *flame2;
}flame;
-static xcb_atom_t get_atom (xcb_connection_t *connection, const char *atomName);
static void title_set (flame *f, const char *title);
static int ilog2 (unsigned int n);
static void flame_set_palette (flame *f);
static void flame_set_flame_zero (flame *f);
static void flame_set_random_flame_base (flame *f);
static void flame_modify_flame_base (flame *f);
static void flame_process_flame (flame *f);
static void flame_draw_flame (flame *f);
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
flame *
flame_init ()
{
flame *f;
xcb_screen_t *screen;
xcb_gcontext_t gc = { 0 };
int screen_nbr;
@@ -211,21 +217,21 @@ main ()
printf ("Can't initialize global data\nExiting...\n");
return -1;
}
flame_set_flame_zero (f);
flame_set_random_flame_base (f);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(f->xcb.c,
"WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(f->xcb.c, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(f->xcb.c, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(f->xcb.c, "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 (f->xcb.c, wmprotocolsAtom, f->xcb.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (f->xcb.c, f->xcb.draw, wmprotocolsAtom, 1,
&deleteWindowAtom);
bool finished = false;
while (!finished)
{
if ((e = xcb_poll_for_event (f->xcb.c)))
{
switch (XCB_EVENT_RESPONSE_TYPE(e))
diff --git a/tests/julia.c b/tests/julia.c
index 75468ce..eefd829 100644
--- a/tests/julia.c
+++ b/tests/julia.c
@@ -5,17 +5,19 @@
#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>
+#include <xcb/xcb_event.h>
+
#define XCB_ALL_PLANES ~0
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#include "julia.h"
#define W_W 640
#define W_H 480
@@ -116,14 +118,20 @@ draw_julia (Data *datap)
datap->palette[c]);
}
xcb_image_put (datap->conn, datap->draw, datap->gc, datap->image,
0, 0, 0);
}
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
int
main (int argc, char *argv[])
{
Data data;
xcb_screen_t *screen;
xcb_drawable_t win;
xcb_drawable_t rect;
@@ -182,21 +190,21 @@ main (int argc, char *argv[])
XCB_COLORMAP_ALLOC_NONE,
data.cmap,
data.draw,
screen->root_visual);
palette_julia (&data);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(data.conn,
"WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(data.conn, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(data.conn, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(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, wmprotocolsAtom, data.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (data.conn, data.draw, wmprotocolsAtom, 1,
&deleteWindowAtom);
xcb_flush (data.conn);
bool finished = false;
while (!finished)
{
xcb_generic_event_t *e;
--
2.1.4
_______________________________________________
Xcb mailing list
https://lists.freedesktop.org/mailman/listinfo/xcb
Uli Schlachter
2017-03-19 08:19:52 UTC
Permalink
"make compile again" sounds like it does not really need much review.
Post by Christian Linhart
The reasoning behind this change is to prepare xcb/demo as
a place to be used for test-suites.
I like that idea. Sounds like I should re-find my tests that I wrote for
some changes.
Post by Christian Linhart
The changes are loosely based on patches posted by William Swanson
on Nov 17, 2012.
---
Makefile.am | 6 +++---
tests/flames.c | 16 +++++++++++-----
tests/julia.c | 16 ++++++++++++----
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7521af0..0f0f715 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,25 +18,25 @@ hypnomoire_SOURCES = hypnomoire.c reply_formats.c reply_formats.h
xcbdpyinfo_SOURCES = xcbdpyinfo.c
xcb_test_CFLAGS = $(XCBAUX_CFLAGS)
xcb_test_LDADD = $(XCBAUX_LIBS) -lpthread
xcb_test_SOURCES = xcb-test.c reply_formats.c reply_formats.h
dpms_CFLAGS = $(XCBDPMS_CFLAGS)
-dpms_LDADD = $(XCBDPMS_LIBS)
+dpms_LDADD = $(XCBDPMS_LIBS) $(XCB_LIBS)
dpms_SOURCES = dpms.c
rendertest_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRENDER_CFLAGS)
rendertest_LDADD = $(XCBAUX_LIBS) $(XCBRENDER_LIBS)
rendertest_SOURCES = rendertest.c
xcbrandr_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRANDR_CFLAGS)
xcbrandr_LDADD = $(XCBAUX_LIBS) $(XCBRANDR_LIBS)
xcbrandr_SOURCES = xcbrandr.c
xcbxf86dri_CFLAGS = $(XCBXF86DRI_CFLAGS)
-xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS)
+xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS) $(XCB_LIBS)
xcbxf86dri_SOURCES = xcbxf86dri.c
xcbxvinfo_CFLAGS = $(XCBXV_CFLAGS)
-xcbxvinfo_LDADD = $(XCBXV_LIBS)
+xcbxvinfo_LDADD = $(XCBXV_LIBS) $(XCB_LIBS)
xcbxvinfo_SOURCES = xcbxvinfo.c
diff --git a/tests/flames.c b/tests/flames.c
index 89e93cf..391c7ed 100644
--- a/tests/flames.c
+++ b/tests/flames.c
@@ -28,16 +28,17 @@
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
+#include <xcb/xcb_event.h>
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#define XCB_ALL_PLANES ~0
#include <xcb/xcb_icccm.h>
/* some defines for the flame */
#define HSPREAD 26
@@ -72,24 +73,29 @@ typedef struct
/* the flame arrays */
int ws;
unsigned int *flame;
unsigned int *flame2;
}flame;
-static xcb_atom_t get_atom (xcb_connection_t *connection, const char *atomName);
static void title_set (flame *f, const char *title);
static int ilog2 (unsigned int n);
static void flame_set_palette (flame *f);
static void flame_set_flame_zero (flame *f);
static void flame_set_random_flame_base (flame *f);
static void flame_modify_flame_base (flame *f);
static void flame_process_flame (flame *f);
static void flame_draw_flame (flame *f);
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
flame *
flame_init ()
{
flame *f;
xcb_screen_t *screen;
xcb_gcontext_t gc = { 0 };
int screen_nbr;
@@ -211,21 +217,21 @@ main ()
printf ("Can't initialize global data\nExiting...\n");
return -1;
}
flame_set_flame_zero (f);
flame_set_random_flame_base (f);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(f->xcb.c, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(f->xcb.c, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(f->xcb.c, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(f->xcb.c, "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 (f->xcb.c, wmprotocolsAtom, f->xcb.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (f->xcb.c, f->xcb.draw, wmprotocolsAtom, 1, &deleteWindowAtom);
bool finished = false;
while (!finished)
{
if ((e = xcb_poll_for_event (f->xcb.c)))
{
switch (XCB_EVENT_RESPONSE_TYPE(e))
diff --git a/tests/julia.c b/tests/julia.c
index 75468ce..eefd829 100644
--- a/tests/julia.c
+++ b/tests/julia.c
@@ -5,17 +5,19 @@
#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>
+#include <xcb/xcb_event.h>
+
#define XCB_ALL_PLANES ~0
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#include "julia.h"
#define W_W 640
#define W_H 480
@@ -116,14 +118,20 @@ draw_julia (Data *datap)
datap->palette[c]);
}
xcb_image_put (datap->conn, datap->draw, datap->gc, datap->image,
0, 0, 0);
}
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
int
main (int argc, char *argv[])
{
Data data;
xcb_screen_t *screen;
xcb_drawable_t win;
xcb_drawable_t rect;
@@ -182,21 +190,21 @@ main (int argc, char *argv[])
XCB_COLORMAP_ALLOC_NONE,
data.cmap,
data.draw,
screen->root_visual);
palette_julia (&data);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(data.conn, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(data.conn, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(data.conn, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(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, wmprotocolsAtom, data.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (data.conn, data.draw, wmprotocolsAtom, 1, &deleteWindowAtom);
xcb_flush (data.conn);
bool finished = false;
while (!finished)
{
xcb_generic_event_t *e;
--
"Are you preparing for another war, Plutarch?" I ask.
"Oh, not now. Now we're in that sweet period where everyone agrees that our
recent horrors should never be repeated," he says. "But collective
thinking is
usually short-lived. We're fickle, stupid beings with poor memories and
a great
gift for self-destruction.
Christian Linhart
2017-03-20 13:11:10 UTC
Permalink
Hi Uli and all,
Post by Uli Schlachter
"make compile again" sounds like it does not really need much review.
Yes, I think so, too.
Just the minimal changes to make it compile, so we can add our testcases.
Post by Uli Schlachter
Post by Christian Linhart
The reasoning behind this change is to prepare xcb/demo as
a place to be used for test-suites.
I like that idea. Sounds like I should re-find my tests that I wrote for
some changes.
That'd be great.

How should we organize the testcases there?

There is already a "test" subdirectory.

But maybe we should make subdirectories in there to get more structure.
E.g. one subdirectory per extension?

What do you think?

***

My brother Arthur will write some testcases for the xinput extension
the next two weeks.

This means that this will be quite some code in a short time.
How should we proceed with that?

He can post his patches, or we can set up an extra repo where his changes will be available for review.
Then he'll post just a link to that repo.

Cheers,

Chris
Post by Uli Schlachter
Post by Christian Linhart
The changes are loosely based on patches posted by William Swanson
on Nov 17, 2012.
---
Makefile.am | 6 +++---
tests/flames.c | 16 +++++++++++-----
tests/julia.c | 16 ++++++++++++----
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7521af0..0f0f715 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,25 +18,25 @@ hypnomoire_SOURCES = hypnomoire.c reply_formats.c reply_formats.h
xcbdpyinfo_SOURCES = xcbdpyinfo.c
xcb_test_CFLAGS = $(XCBAUX_CFLAGS)
xcb_test_LDADD = $(XCBAUX_LIBS) -lpthread
xcb_test_SOURCES = xcb-test.c reply_formats.c reply_formats.h
dpms_CFLAGS = $(XCBDPMS_CFLAGS)
-dpms_LDADD = $(XCBDPMS_LIBS)
+dpms_LDADD = $(XCBDPMS_LIBS) $(XCB_LIBS)
dpms_SOURCES = dpms.c
rendertest_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRENDER_CFLAGS)
rendertest_LDADD = $(XCBAUX_LIBS) $(XCBRENDER_LIBS)
rendertest_SOURCES = rendertest.c
xcbrandr_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRANDR_CFLAGS)
xcbrandr_LDADD = $(XCBAUX_LIBS) $(XCBRANDR_LIBS)
xcbrandr_SOURCES = xcbrandr.c
xcbxf86dri_CFLAGS = $(XCBXF86DRI_CFLAGS)
-xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS)
+xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS) $(XCB_LIBS)
xcbxf86dri_SOURCES = xcbxf86dri.c
xcbxvinfo_CFLAGS = $(XCBXV_CFLAGS)
-xcbxvinfo_LDADD = $(XCBXV_LIBS)
+xcbxvinfo_LDADD = $(XCBXV_LIBS) $(XCB_LIBS)
xcbxvinfo_SOURCES = xcbxvinfo.c
diff --git a/tests/flames.c b/tests/flames.c
index 89e93cf..391c7ed 100644
--- a/tests/flames.c
+++ b/tests/flames.c
@@ -28,16 +28,17 @@
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
+#include <xcb/xcb_event.h>
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#define XCB_ALL_PLANES ~0
#include <xcb/xcb_icccm.h>
/* some defines for the flame */
#define HSPREAD 26
@@ -72,24 +73,29 @@ typedef struct
/* the flame arrays */
int ws;
unsigned int *flame;
unsigned int *flame2;
}flame;
-static xcb_atom_t get_atom (xcb_connection_t *connection, const char *atomName);
static void title_set (flame *f, const char *title);
static int ilog2 (unsigned int n);
static void flame_set_palette (flame *f);
static void flame_set_flame_zero (flame *f);
static void flame_set_random_flame_base (flame *f);
static void flame_modify_flame_base (flame *f);
static void flame_process_flame (flame *f);
static void flame_draw_flame (flame *f);
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
flame *
flame_init ()
{
flame *f;
xcb_screen_t *screen;
xcb_gcontext_t gc = { 0 };
int screen_nbr;
@@ -211,21 +217,21 @@ main ()
printf ("Can't initialize global data\nExiting...\n");
return -1;
}
flame_set_flame_zero (f);
flame_set_random_flame_base (f);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(f->xcb.c, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(f->xcb.c, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(f->xcb.c, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(f->xcb.c, "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 (f->xcb.c, wmprotocolsAtom, f->xcb.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (f->xcb.c, f->xcb.draw, wmprotocolsAtom, 1, &deleteWindowAtom);
bool finished = false;
while (!finished)
{
if ((e = xcb_poll_for_event (f->xcb.c)))
{
switch (XCB_EVENT_RESPONSE_TYPE(e))
diff --git a/tests/julia.c b/tests/julia.c
index 75468ce..eefd829 100644
--- a/tests/julia.c
+++ b/tests/julia.c
@@ -5,17 +5,19 @@
#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>
+#include <xcb/xcb_event.h>
+
#define XCB_ALL_PLANES ~0
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#include "julia.h"
#define W_W 640
#define W_H 480
@@ -116,14 +118,20 @@ draw_julia (Data *datap)
datap->palette[c]);
}
xcb_image_put (datap->conn, datap->draw, datap->gc, datap->image,
0, 0, 0);
}
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
int
main (int argc, char *argv[])
{
Data data;
xcb_screen_t *screen;
xcb_drawable_t win;
xcb_drawable_t rect;
@@ -182,21 +190,21 @@ main (int argc, char *argv[])
XCB_COLORMAP_ALLOC_NONE,
data.cmap,
data.draw,
screen->root_visual);
palette_julia (&data);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(data.conn, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(data.conn, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(data.conn, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(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, wmprotocolsAtom, data.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (data.conn, data.draw, wmprotocolsAtom, 1, &deleteWindowAtom);
xcb_flush (data.conn);
bool finished = false;
while (!finished)
{
xcb_generic_event_t *e;
Eric Anholt
2017-03-20 17:48:17 UTC
Permalink
Post by Christian Linhart
Hi Uli and all,
Post by Uli Schlachter
"make compile again" sounds like it does not really need much review.
Yes, I think so, too.
Just the minimal changes to make it compile, so we can add our testcases.
Post by Uli Schlachter
Post by Christian Linhart
The reasoning behind this change is to prepare xcb/demo as
a place to be used for test-suites.
I like that idea. Sounds like I should re-find my tests that I wrote for
some changes.
That'd be great.
How should we organize the testcases there?
There is already a "test" subdirectory.
But maybe we should make subdirectories in there to get more structure.
E.g. one subdirectory per extension?
What do you think?
***
My brother Arthur will write some testcases for the xinput extension
the next two weeks.
This means that this will be quite some code in a short time.
How should we proceed with that?
He can post his patches, or we can set up an extra repo where his changes will be available for review.
Then he'll post just a link to that repo.
Are these tests going in here going to be useful as X server regression
tests? I've wondered where the right home would be for little X
regression tests, and would like to get more into piglit for keeping the
X server working.

If they are regression tests, xcb/demo does seem like a funny place for
them. Maybe a new xcb/tests forked from demo?
Christian Linhart
2017-03-20 18:34:25 UTC
Permalink
Post by Eric Anholt
[...]
Are these tests going in here going to be useful as X server regression
tests? I've wondered where the right home would be for little X
regression tests, and would like to get more into piglit for keeping the
X server working.
These tests will primarily be aimed at testing whether the xcb protocol-definitions are correct,
and whether the generator generates correct code.
The tests should be usable as regression tests for that.

But, as a nice side-effect, they'll do some X-Server testing, too.
Because if you (ideally) test all aspects of the protocol, you'll also get quite a good test-coverage for the X-server. So you definitely got your intuition right about that.

It is not yet clear how far we'll get though with that test suite.
Post by Eric Anholt
If they are regression tests, xcb/demo does seem like a funny place for
them. Maybe a new xcb/tests forked from demo?
Yes, we could do that mid term.
Forking from demo seems to be a good idea. (and then cleaning up to leave only the regression tests)
Short term I suggest to use xcb/demo and see how far we'll get.

BTW, who has the right to create new repos such as xcb/test?
And how long does it usually take to get attention from them?
(or do I have the rights and I am just not aware of it?)

I know that I have commit rights to at least xcb/proto and xcb/libxcb.
But I guess this does not include the right to create new repos...

Cheers,

Chris
Post by Eric Anholt
_______________________________________________
Xcb mailing list
https://lists.freedesktop.org/mailman/listinfo/xcb
Eric Anholt
2017-03-30 15:53:21 UTC
Permalink
Post by Christian Linhart
Post by Eric Anholt
[...]
Are these tests going in here going to be useful as X server regression
tests? I've wondered where the right home would be for little X
regression tests, and would like to get more into piglit for keeping the
X server working.
These tests will primarily be aimed at testing whether the xcb protocol-definitions are correct,
and whether the generator generates correct code.
The tests should be usable as regression tests for that.
But, as a nice side-effect, they'll do some X-Server testing, too.
Because if you (ideally) test all aspects of the protocol, you'll also get quite a good test-coverage for the X-server. So you definitely got your intuition right about that.
It is not yet clear how far we'll get though with that test suite.
Post by Eric Anholt
If they are regression tests, xcb/demo does seem like a funny place for
them. Maybe a new xcb/tests forked from demo?
Yes, we could do that mid term.
Forking from demo seems to be a good idea. (and then cleaning up to leave only the regression tests)
Short term I suggest to use xcb/demo and see how far we'll get.
BTW, who has the right to create new repos such as xcb/test?
And how long does it usually take to get attention from them?
(or do I have the rights and I am just not aware of it?)
I know that I have commit rights to at least xcb/proto and xcb/libxcb.
But I guess this does not include the right to create new repos...
https://bugs.freedesktop.org/enter_bug.cgi?product=freedesktop.org is
how you get it done.
Christian Linhart
2017-03-31 06:26:40 UTC
Permalink
Hi Eric and all,

I have thought a bit about xcb/test.
I suggest the following:

* do xcb/test as a fresh project ( i.e. not clone xcb/demo)
* And use a regression test framework for it.
I propose to use cppunit. ( https://cgit.freedesktop.org/libreoffice/cppunit/ )
* As far as possible, the tests should run and check themselves automatically without manual intervention needed.
Ideally, we'll succeed to have everything running automatically, of course.

What do you think?

Chris

P.S.: Thank you for the info for how to start the process of creating a new project.
I'll do that soon.
Post by Eric Anholt
Post by Christian Linhart
Post by Eric Anholt
[...]
Are these tests going in here going to be useful as X server regression
tests? I've wondered where the right home would be for little X
regression tests, and would like to get more into piglit for keeping the
X server working.
These tests will primarily be aimed at testing whether the xcb protocol-definitions are correct,
and whether the generator generates correct code.
The tests should be usable as regression tests for that.
But, as a nice side-effect, they'll do some X-Server testing, too.
Because if you (ideally) test all aspects of the protocol, you'll also get quite a good test-coverage for the X-server. So you definitely got your intuition right about that.
It is not yet clear how far we'll get though with that test suite.
Post by Eric Anholt
If they are regression tests, xcb/demo does seem like a funny place for
them. Maybe a new xcb/tests forked from demo?
Yes, we could do that mid term.
Forking from demo seems to be a good idea. (and then cleaning up to leave only the regression tests)
Short term I suggest to use xcb/demo and see how far we'll get.
BTW, who has the right to create new repos such as xcb/test?
And how long does it usually take to get attention from them?
(or do I have the rights and I am just not aware of it?)
I know that I have commit rights to at least xcb/proto and xcb/libxcb.
But I guess this does not include the right to create new repos...
https://bugs.freedesktop.org/enter_bug.cgi?product=freedesktop.org is
how you get it done.
_______________________________________________
Xcb mailing list
https://lists.freedesktop.org/mailman/listinfo/xcb
Eric Anholt
2017-03-31 20:25:29 UTC
Permalink
Post by Christian Linhart
Hi Eric and all,
I have thought a bit about xcb/test.
* do xcb/test as a fresh project ( i.e. not clone xcb/demo)
* And use a regression test framework for it.
I propose to use cppunit. ( https://cgit.freedesktop.org/libreoffice/cppunit/ )
* As far as possible, the tests should run and check themselves automatically without manual intervention needed.
Ideally, we'll succeed to have everything running automatically, of course.
What do you think?
Chris
P.S.: Thank you for the info for how to start the process of creating a new project.
I'll do that soon.
For running the X Test Suite and rendercheck, I'm using piglit as a
testing framework. What you get from that is the ability to write some
python to generate a list of test binaries to be run, a framework that
executes them, collects their results, and lets you compare results
between runs (including image captures, for rendering tests).

Comparison is of more relevance to GL implementations where you may not
ever pass all your tests, than to unit tests for things like the XCB or
the X Server where we intend to actually be entirely correct according
to our tests. The downside is that the piglit framework moves pretty
fast and our X stuff frequently gets broken.

For smaller tests, I've been basically satisfied with just bare binaries
with assert()s, like the X Server's test/misc.c.
Uli Schlachter
2017-04-01 09:56:38 UTC
Permalink
Hi,
[...]
Post by Eric Anholt
Post by Christian Linhart
* And use a regression test framework for it.
I propose to use cppunit. ( https://cgit.freedesktop.org/libreoffice/cppunit/ )
[...]
Post by Eric Anholt
For running the X Test Suite and rendercheck, I'm using piglit as a
testing framework.
[...]
Post by Eric Anholt
For smaller tests, I've been basically satisfied with just bare binaries
with assert()s, like the X Server's test/misc.c.
just some small 5c: libxcb already has some tests and uses "check" for
them, see https://cgit.freedesktop.org/xcb/libxcb/tree/tests

Cheers,
Uli
--
"In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move."
Christian Linhart
2017-04-01 13:42:46 UTC
Permalink
Hi Uli and Eric,

Thank you for your input.

The current tests in libxcb run without display connection as far as I can tell.
Maybe this should remain this way?
E.g. if "make check" is called from a batch-job on a build-server, then it won't have a display connection.

If we create a real testsuite, it might become quite large. Maybe that'll be inconvenient as part of libxcb.
In that case xcb/test might make sense.
On the other hand, if it is included in libxcb, then it'll be run more likely before making a release, and it'll be updated more likely.
What do you think?

The test-framework "check" is lightweight and seems to be easy to use, which is good.
This is better than using bare asserts.
No sure how well this works with larger test suites.
"check" is only one headerfile, which is nice because it can be included in the project, and we'll not have to add an outside dependency.

Piglit seems to be too heavyweight and complicated.
The complexity may be warranted for OpenGL, but we won't need that.
And they are changing stuff all the time, which is suboptimal because it takes energy away which could be used for writing testcases.
So, we seem to have pretty much the same intuition about it, Erik.

Comparing with reference data is also possible with asserts. Just call a comparison function from an assert.

Cppunit is a bit like "check" in that it provides a convenient way to write asserts that don't crash but are just reported.
In addition to that it also provides user-interfaces that let you run only certain testcases of a suite. (There are GUI and text user interfaces.)
I am not sure whether "check" provides that.
Also, like "check", everything runs in one executable. This takes away complexity, which is generally good.
My intuition tells me that cppunit is suitable for larger testsuites than "check".
But I don't know "check" well enough, so I am not sure.

So, I guess that the open questions are:
* "check" vs cppunit
* enhance the testsuite in xcb/libxcb, or create a new project xcb/test?

What do you think?

Chris
Post by Uli Schlachter
Hi,
[...]
Post by Eric Anholt
Post by Christian Linhart
* And use a regression test framework for it.
I propose to use cppunit. ( https://cgit.freedesktop.org/libreoffice/cppunit/ )
[...]
Post by Eric Anholt
For running the X Test Suite and rendercheck, I'm using piglit as a
testing framework.
[...]
Post by Eric Anholt
For smaller tests, I've been basically satisfied with just bare binaries
with assert()s, like the X Server's test/misc.c.
just some small 5c: libxcb already has some tests and uses "check" for
them, see https://cgit.freedesktop.org/xcb/libxcb/tree/tests
Cheers,
Uli
Christian Linhart
2017-04-01 05:34:05 UTC
Permalink
Hi Eric and all,

Thank you for describing piglit.
I also think that piglit is an overkill for the xcb-test.
And the lack of API-stability is suboptimal.[1]

I think assert-based is a good direction, but cppunit improves that in a lightweight and easy-to-use way:
The CPPUNIT_ASSERT does not terminate the program but just outputs an error message, and continues running the subsequent tests.
You can run the whole testsuite as a single executable, and select individual testcases etc.
There are GUI-based and text-based user interfaces for the same test-suite.
Also, there's no mix of programming languages, which makes stuff easier in general. (Everything is C/C++.)

Good point about the need for data comparisons.
I guess that an easy way would be to just call a comparison function in a cppunit assert:
like: CPPUNIT_ASSERT( IsPixmapEqualToPNG(pixmap, "test123-ref1.png") );

Chris

[1] We need to think economical here, too.
Everybody's time is valuable, and when we are more efficient we can write more testcases or improve xcb.
Post by Eric Anholt
Post by Christian Linhart
Hi Eric and all,
I have thought a bit about xcb/test.
* do xcb/test as a fresh project ( i.e. not clone xcb/demo)
* And use a regression test framework for it.
I propose to use cppunit. ( https://cgit.freedesktop.org/libreoffice/cppunit/ )
* As far as possible, the tests should run and check themselves automatically without manual intervention needed.
Ideally, we'll succeed to have everything running automatically, of course.
What do you think?
Chris
P.S.: Thank you for the info for how to start the process of creating a new project.
I'll do that soon.
For running the X Test Suite and rendercheck, I'm using piglit as a
testing framework. What you get from that is the ability to write some
python to generate a list of test binaries to be run, a framework that
executes them, collects their results, and lets you compare results
between runs (including image captures, for rendering tests).
Comparison is of more relevance to GL implementations where you may not
ever pass all your tests, than to unit tests for things like the XCB or
the X Server where we intend to actually be entirely correct according
to our tests. The downside is that the piglit framework moves pretty
fast and our X stuff frequently gets broken.
For smaller tests, I've been basically satisfied with just bare binaries
with assert()s, like the X Server's test/misc.c.
_______________________________________________
Xcb mailing list
https://lists.freedesktop.org/mailman/listinfo/xcb
Christian Linhart
2017-05-13 09:18:53 UTC
Permalink
I have pushed this now.
The discussion revealed that this does not need a review. (and it had plenty of time for a review if somebody though this would be necessary)

Chris
Post by Christian Linhart
The reasoning behind this change is to prepare xcb/demo as
a place to be used for test-suites.
The changes are loosely based on patches posted by William Swanson
on Nov 17, 2012.
---
Makefile.am | 6 +++---
tests/flames.c | 16 +++++++++++-----
tests/julia.c | 16 ++++++++++++----
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7521af0..0f0f715 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,25 +18,25 @@ hypnomoire_SOURCES = hypnomoire.c reply_formats.c reply_formats.h
xcbdpyinfo_SOURCES = xcbdpyinfo.c
xcb_test_CFLAGS = $(XCBAUX_CFLAGS)
xcb_test_LDADD = $(XCBAUX_LIBS) -lpthread
xcb_test_SOURCES = xcb-test.c reply_formats.c reply_formats.h
dpms_CFLAGS = $(XCBDPMS_CFLAGS)
-dpms_LDADD = $(XCBDPMS_LIBS)
+dpms_LDADD = $(XCBDPMS_LIBS) $(XCB_LIBS)
dpms_SOURCES = dpms.c
rendertest_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRENDER_CFLAGS)
rendertest_LDADD = $(XCBAUX_LIBS) $(XCBRENDER_LIBS)
rendertest_SOURCES = rendertest.c
xcbrandr_CFLAGS = $(XCBAUX_CFLAGS) $(XCBRANDR_CFLAGS)
xcbrandr_LDADD = $(XCBAUX_LIBS) $(XCBRANDR_LIBS)
xcbrandr_SOURCES = xcbrandr.c
xcbxf86dri_CFLAGS = $(XCBXF86DRI_CFLAGS)
-xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS)
+xcbxf86dri_LDADD = $(XCBXF86DRI_LIBS) $(XCB_LIBS)
xcbxf86dri_SOURCES = xcbxf86dri.c
xcbxvinfo_CFLAGS = $(XCBXV_CFLAGS)
-xcbxvinfo_LDADD = $(XCBXV_LIBS)
+xcbxvinfo_LDADD = $(XCBXV_LIBS) $(XCB_LIBS)
xcbxvinfo_SOURCES = xcbxvinfo.c
diff --git a/tests/flames.c b/tests/flames.c
index 89e93cf..391c7ed 100644
--- a/tests/flames.c
+++ b/tests/flames.c
@@ -28,16 +28,17 @@
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
+#include <xcb/xcb_event.h>
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#define XCB_ALL_PLANES ~0
#include <xcb/xcb_icccm.h>
/* some defines for the flame */
#define HSPREAD 26
@@ -72,24 +73,29 @@ typedef struct
/* the flame arrays */
int ws;
unsigned int *flame;
unsigned int *flame2;
}flame;
-static xcb_atom_t get_atom (xcb_connection_t *connection, const char *atomName);
static void title_set (flame *f, const char *title);
static int ilog2 (unsigned int n);
static void flame_set_palette (flame *f);
static void flame_set_flame_zero (flame *f);
static void flame_set_random_flame_base (flame *f);
static void flame_modify_flame_base (flame *f);
static void flame_process_flame (flame *f);
static void flame_draw_flame (flame *f);
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
flame *
flame_init ()
{
flame *f;
xcb_screen_t *screen;
xcb_gcontext_t gc = { 0 };
int screen_nbr;
@@ -211,21 +217,21 @@ main ()
printf ("Can't initialize global data\nExiting...\n");
return -1;
}
flame_set_flame_zero (f);
flame_set_random_flame_base (f);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(f->xcb.c, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(f->xcb.c, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(f->xcb.c, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(f->xcb.c, "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 (f->xcb.c, wmprotocolsAtom, f->xcb.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (f->xcb.c, f->xcb.draw, wmprotocolsAtom, 1, &deleteWindowAtom);
bool finished = false;
while (!finished)
{
if ((e = xcb_poll_for_event (f->xcb.c)))
{
switch (XCB_EVENT_RESPONSE_TYPE(e))
diff --git a/tests/julia.c b/tests/julia.c
index 75468ce..eefd829 100644
--- a/tests/julia.c
+++ b/tests/julia.c
@@ -5,17 +5,19 @@
#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>
+#include <xcb/xcb_event.h>
+
#define XCB_ALL_PLANES ~0
-/* Needed for xcb_set_wm_protocols() */
+/* Needed for xcb_icccm_set_wm_protocols() */
#include <xcb/xcb_icccm.h>
#include "julia.h"
#define W_W 640
#define W_H 480
@@ -116,14 +118,20 @@ draw_julia (Data *datap)
datap->palette[c]);
}
xcb_image_put (datap->conn, datap->draw, datap->gc, datap->image,
0, 0, 0);
}
+static xcb_atom_t get_atom(xcb_connection_t* c, const char *name)
+{
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, strlen(name), name);
+ return xcb_intern_atom_reply(c, cookie, NULL)->atom;
+}
+
int
main (int argc, char *argv[])
{
Data data;
xcb_screen_t *screen;
xcb_drawable_t win;
xcb_drawable_t rect;
@@ -182,21 +190,21 @@ main (int argc, char *argv[])
XCB_COLORMAP_ALLOC_NONE,
data.cmap,
data.draw,
screen->root_visual);
palette_julia (&data);
- xcb_atom_t deleteWindowAtom = xcb_atom_get(data.conn, "WM_DELETE_WINDOW");
- xcb_atom_t wmprotocolsAtom = xcb_atom_get(data.conn, "WM_PROTOCOLS");
+ xcb_atom_t deleteWindowAtom = get_atom(data.conn, "WM_DELETE_WINDOW");
+ xcb_atom_t wmprotocolsAtom = get_atom(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, wmprotocolsAtom, data.draw, 1, &deleteWindowAtom);
+ xcb_icccm_set_wm_protocols (data.conn, data.draw, wmprotocolsAtom, 1, &deleteWindowAtom);
xcb_flush (data.conn);
bool finished = false;
while (!finished)
{
xcb_generic_event_t *e;
Loading...