[Xcb] adding testcases to xcb/demo, my brother will write testcases for xinput for two weeks. (Re: [PATCH demo 1/1] make xcb/demo compile again.)

Christian Linhart chris at DemoRecorder.com
Mon Mar 20 13:11:10 UTC 2017


Hi Uli and all,

On 2017-03-19 09:19, Uli Schlachter wrote:
> "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.
>
> On 18.03.2017 10:55, Christian Linhart wrote:
>> 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

>
>> The changes are loosely based on patches posted by William Swanson
>> on Nov 17, 2012.
>>
>> Signed-off-by: Christian Linhart <chris at 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;
>>
>



More information about the Xcb mailing list