[PATCH] Add XCB unit tests

Julien Danjou julien at danjou.info
Thu Jan 29 06:37:47 PST 2009


Signed-off-by: Julien Danjou <julien at danjou.info>
---
 configure.in                    |    1 +
 test/Makefile.am                |   38 ++++++++++-
 test/test-launchee-xcb.c        |   76 ++++++++++++++++++++
 test/test-launcher-xcb.c        |  144 +++++++++++++++++++++++++++++++++++++++
 test/test-monitor-xcb.c         |  137 +++++++++++++++++++++++++++++++++++++
 test/test-send-xmessage-xcb.c   |   60 ++++++++++++++++
 test/test-watch-xmessages-xcb.c |  117 +++++++++++++++++++++++++++++++
 test/test-watch-xmessages.c     |   14 ++--
 8 files changed, 579 insertions(+), 8 deletions(-)
 create mode 100644 test/test-launchee-xcb.c
 create mode 100644 test/test-launcher-xcb.c
 create mode 100644 test/test-monitor-xcb.c
 create mode 100644 test/test-send-xmessage-xcb.c
 create mode 100644 test/test-watch-xmessages-xcb.c

diff --git a/configure.in b/configure.in
index dad1c2f..398efa0 100644
--- a/configure.in
+++ b/configure.in
@@ -91,6 +91,7 @@ if test "x$with_xcb" = "xyes"; then
         [AC_MSG_ERROR([Cannot find xcb-atom])])
     AC_DEFINE([HAVE_XCB],1,[Defined to use xcb])
 fi
+AM_CONDITIONAL(WITH_XCB, test "x$with_xcb" = "xyes")
 
 LIBSN_CFLAGS="$X_CFLAGS $xcb_CFLAGS $xcb_aux_CFLAGS $xcb_event_CFLAGS $xcb_atom_CFLAGS"
 LIBSN_LIBS=" $xcb_LIBS $xcb_aux_LIBS $xcb_event_LIBS $xcb_atom_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
diff --git a/test/Makefile.am b/test/Makefile.am
index 9bd3bcf..88d066d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,13 +1,27 @@
 
 INCLUDES=$(LIBSN_CFLAGS) -I$(top_srcdir) -DSN_API_NOT_YET_FROZEN=1
 
-noinst_PROGRAMS=				\
+
+XLIB_TEST=					\
 	test-launcher				\
 	test-launchee				\
 	test-monitor				\
 	test-send-xmessage			\
 	test-watch-xmessages
 
+XCB_TEST=					\
+	test-send-xmessage-xcb			\
+	test-monitor-xcb			\
+	test-launchee-xcb			\
+	test-launcher-xcb			\
+	test-watch-xmessages-xcb
+
+if WITH_XCB
+noinst_PROGRAMS=$(XLIB_TEST) $(XCB_TEST)
+else
+noinst_PROGRAMS=$(XLIB_TEST)
+endif
+
 test_launcher_SOURCES= test-launcher.c
 
 test_launcher_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
@@ -28,4 +42,26 @@ test_watch_xmessages_SOURCES= test-watch-xmessages.c
 
 test_watch_xmessages_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
 
+if WITH_XCB
+test_watch_xmessages_xcb_SOURCES= test-watch-xmessages-xcb.c
+
+test_watch_xmessages_xcb_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
+
+test_send_xmessage_xcb_SOURCES= test-send-xmessage-xcb.c
+
+test_send_xmessage_xcb_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
+
+test_monitor_xcb_SOURCES= test-monitor-xcb.c
+
+test_monitor_xcb_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
+
+test_launchee_xcb_SOURCES= test-launchee-xcb.c
+
+test_launchee_xcb_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
+
+test_launcher_xcb_SOURCES= test-launcher-xcb.c
+
+test_launcher_xcb_LDADD= $(LIBSN_LIBS) $(top_builddir)/libsn/libstartup-notification-1.la
+endif
+
 EXTRA_DIST=test-boilerplate.h
diff --git a/test/test-launchee-xcb.c b/test/test-launchee-xcb.c
new file mode 100644
index 0000000..95a7945
--- /dev/null
+++ b/test/test-launchee-xcb.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2009 Julien Danjou <julien at danjou.info>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+#include <libsn/sn.h>
+
+#include "test-boilerplate.h"
+
+int
+main (int argc, char **argv)
+{
+  xcb_connection_t *xconnection;
+  SnDisplay *display;
+  SnLauncheeContext *context;
+  int screen;
+
+  xconnection = xcb_connect (NULL, &screen);
+  if (xconnection == NULL)
+    {
+      fprintf (stderr, "Could not open display\n");
+      return 1;
+    }
+
+  display = sn_xcb_display_new (xconnection,
+                                NULL, NULL);
+
+  context = sn_launchee_context_new_from_environment (display, screen);
+
+  if (context == NULL)
+    {
+      fprintf (stderr, "Failed to get launch feedback info from DESKTOP_LAUNCH_ID/DESKTOP_LAUNCH_WINDOW\n");
+      exit (1);
+    }
+
+  printf ("Launchee started with window ID \"%s\"\n",
+          sn_launchee_context_get_startup_id (context));
+
+  /* simulate startup time */
+  sleep (4);
+
+  printf ("Launchee startup complete\n");
+  sn_launchee_context_complete (context);
+
+  while (TRUE)
+    {
+       xcb_generic_event_t *xevent = xcb_wait_for_event(xconnection);
+
+      sn_xcb_display_process_event (display, xevent);
+
+      free(xevent);
+    }
+
+  return 0;
+}
diff --git a/test/test-launcher-xcb.c b/test/test-launcher-xcb.c
new file mode 100644
index 0000000..ed06ead
--- /dev/null
+++ b/test/test-launcher-xcb.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2002 Julien Danjou <julien at danjou.info>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+#include <libsn/sn.h>
+#include <assert.h>
+
+#include <xcb/xcb_atom.h>
+#include <xcb/xcb_aux.h>
+
+#include "test-boilerplate.h"
+
+static pid_t child_pid = 0;
+
+/* This is a poor way to obtain a timestamp normally (one should be available
+ * to the app from the user clicking on a button or something), but such a
+ * method is not available for this simple test application.
+ */
+xcb_timestamp_t
+slowly_obtain_timestamp (SnDisplay *display)
+{
+  xcb_window_t xwindow;
+  xcb_connection_t *xconnection;
+  xcb_generic_event_t *event;
+  xcb_screen_t *s;
+
+  xconnection = sn_display_get_x_connection (display);
+
+  s = xcb_aux_get_screen(xconnection, 0);
+
+  {
+    uint32_t attrs[] = { 1, XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY };
+    char* name;
+
+    xwindow = xcb_generate_id (xconnection);
+
+    xcb_create_window (xconnection, XCB_COPY_FROM_PARENT, xwindow,
+                       s->root, -100, -100, 1, 1, 0, XCB_COPY_FROM_PARENT,
+                       XCB_COPY_FROM_PARENT, XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
+                       attrs);
+
+    name = "Fake Window";
+
+    xcb_change_property (xconnection, XCB_PROP_MODE_REPLACE,
+                         xwindow, WM_NAME, STRING, 8,
+                         strlen (name), name);
+  }
+
+  xcb_flush (xconnection);
+  event = xcb_wait_for_event (xconnection);
+  xcb_property_notify_event_t *ev = (xcb_property_notify_event_t *) event;
+  xcb_timestamp_t timestamp = ev->time;
+  free (ev);
+
+  xcb_destroy_window (xconnection, xwindow);
+
+  return timestamp;
+}
+
+int
+main (int argc, char **argv)
+{
+  xcb_connection_t *xconnection;
+  SnDisplay *display;
+  SnLauncherContext *context;
+  xcb_timestamp_t timestamp;
+  int screen;
+
+  if (argc < 2)
+    {
+      fprintf (stderr, "must specify command line to launch\n");
+      exit (1);
+    }
+
+  xconnection = xcb_connect (NULL, &screen);
+  if (xconnection == NULL)
+    {
+      fprintf (stderr, "Could not open display\n");
+      return 1;
+    }
+
+  display = sn_xcb_display_new (xconnection,
+                                NULL, NULL);
+
+  context = sn_launcher_context_new (display, screen);
+
+  sn_launcher_context_set_name (context, "Test Launch");
+  sn_launcher_context_set_description (context, "Launching a test program for libsn");
+  sn_launcher_context_set_binary_name (context, argv[1]);
+
+  timestamp = slowly_obtain_timestamp (display);
+  sn_launcher_context_initiate (context,
+                                "test-launcher",
+                                argv[1],
+                                timestamp);
+
+  switch ((child_pid = fork ()))
+    {
+    case -1:
+      fprintf (stderr, "Fork failed: %s\n", strerror (errno));
+      break;
+    case 0:
+      sn_launcher_context_setup_child_process (context);
+      execv (argv[1], argv + 1);
+      fprintf (stderr, "Failed to exec %s: %s\n", argv[1], strerror (errno));
+      _exit (1);
+      break;
+    }
+
+  while (TRUE)
+    {
+      xcb_generic_event_t *xevent = xcb_wait_for_event (xconnection);
+
+      sn_xcb_display_process_event (display, xevent);
+
+      free (xevent);
+    }
+
+  sn_launcher_context_unref (context);
+
+  return 0;
+}
diff --git a/test/test-monitor-xcb.c b/test/test-monitor-xcb.c
new file mode 100644
index 0000000..6ec3300
--- /dev/null
+++ b/test/test-monitor-xcb.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2009 Julien Danjou <julien at danjou.info>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+#include <libsn/sn.h>
+
+#include <xcb/xcb_aux.h>
+
+#include "test-boilerplate.h"
+
+static void
+monitor_event_func (SnMonitorEvent *event,
+                    void            *user_data)
+{
+  SnMonitorContext *context;
+  SnStartupSequence *sequence;
+
+  context = sn_monitor_event_get_context (event);
+  sequence = sn_monitor_event_get_startup_sequence (event);
+
+  switch (sn_monitor_event_get_type (event))
+    {
+    case SN_MONITOR_EVENT_INITIATED:
+    case SN_MONITOR_EVENT_CHANGED:
+      {
+        const char *s;
+
+        if (sn_monitor_event_get_type (event) == SN_MONITOR_EVENT_INITIATED)
+          {
+            printf ("Initiated sequence %s\n",
+                    sn_startup_sequence_get_id (sequence));
+          }
+        else
+          {
+            printf ("Changed sequence %s\n",
+                    sn_startup_sequence_get_id (sequence));
+          }
+
+        s = sn_startup_sequence_get_id (sequence);
+        printf (" id %s\n", s ? s : "(unset)");
+
+        s = sn_startup_sequence_get_name (sequence);
+        printf (" name %s\n", s ? s : "(unset)");
+
+        s = sn_startup_sequence_get_description (sequence);
+        printf (" description %s\n", s ? s : "(unset)");
+
+        printf (" workspace %d\n",
+                sn_startup_sequence_get_workspace (sequence));
+
+        s = sn_startup_sequence_get_binary_name (sequence);
+        printf (" binary name %s\n", s ? s : "(unset)");
+        s = sn_startup_sequence_get_icon_name (sequence);
+        printf (" icon name %s\n", s ? s : "(unset)");
+
+        s = sn_startup_sequence_get_wmclass (sequence);
+        printf (" wm class %s\n", s ? s : "(unset)");
+      }
+      break;
+
+    case SN_MONITOR_EVENT_COMPLETED:
+      printf ("Completed sequence %s\n",
+              sn_startup_sequence_get_id (sequence));
+      break;
+
+    case SN_MONITOR_EVENT_CANCELED:
+      printf ("Canceled sequence %s\n",
+              sn_startup_sequence_get_id (sequence));
+      break;
+    }
+}
+
+int
+main (int argc, char **argv)
+{
+  xcb_connection_t *xconnection;
+  SnDisplay *display;
+  SnMonitorContext *context;
+  int screen;
+
+  xconnection = xcb_connect (NULL, &screen);
+  if (xconnection == NULL)
+    {
+      fprintf (stderr, "Could not open display\n");
+      return 1;
+    }
+
+  /* We have to select for property events on at least one
+   * root window (but not all as INITIATE messages go to
+   * all root windows)
+   */
+  xcb_screen_t *s = xcb_aux_get_screen (xconnection, screen);
+  const uint32_t select_input_val[] = { XCB_EVENT_MASK_PROPERTY_CHANGE };
+  xcb_change_window_attributes (xconnection, s->root, XCB_CW_EVENT_MASK,
+                                select_input_val);
+
+  display = sn_xcb_display_new (xconnection, NULL, NULL);
+
+  context = sn_monitor_context_new (display, screen,
+                                    monitor_event_func,
+                                    NULL, NULL);
+
+  while (TRUE)
+    {
+      xcb_generic_event_t *xevent = xcb_wait_for_event (xconnection);
+
+      sn_xcb_display_process_event (display, xevent);
+
+      free (xevent);
+    }
+
+  sn_monitor_context_unref (context);
+
+  return 0;
+}
diff --git a/test/test-send-xmessage-xcb.c b/test/test-send-xmessage-xcb.c
new file mode 100644
index 0000000..3bb940b
--- /dev/null
+++ b/test/test-send-xmessage-xcb.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2009 Julien Danjou <julien at danjou.info>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+#include <libsn/sn.h>
+#include <libsn/sn-xmessages.h>
+
+#include "test-boilerplate.h"
+
+int
+main (int argc, char **argv)
+{
+  xcb_connection_t *xconnection;
+  SnDisplay *display;
+
+  if (argc != 4)
+    {
+      fprintf (stderr, "Must specify message type, message begin type, and message content as first, second, and third args\n");
+      return 1;
+    }
+
+  int screen;
+  xconnection = xcb_connect (NULL, &screen);
+  if (xconnection == NULL)
+    {
+      fprintf (stderr, "Could not open display\n");
+      return 1;
+    }
+
+  display = sn_xcb_display_new (xconnection, NULL, NULL);
+
+  sn_internal_broadcast_xmessage (display, screen,
+                                  argv[1],
+                                  argv[2],
+                                  argv[3]);
+
+  return 0;
+}
diff --git a/test/test-watch-xmessages-xcb.c b/test/test-watch-xmessages-xcb.c
new file mode 100644
index 0000000..c170d01
--- /dev/null
+++ b/test/test-watch-xmessages-xcb.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2009 Julien Danjou <julien at danjou.info>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+#include <libsn/sn.h>
+#include <libsn/sn-xmessages.h>
+#include <libsn/sn-internals.h>
+
+#include <xcb/xcb_aux.h>
+
+#include "test-boilerplate.h"
+
+static void
+message_func (SnDisplay       *display,
+              const char      *message_type,
+              const char      *message,
+              void            *user_data)
+{
+  char *prefix;
+  char **names;
+  char **values;
+  int i;
+
+#if 0
+  printf ("raw %s: %s\n",
+          message_type, message);
+#endif
+  
+  prefix = NULL;
+  names = NULL;
+  values = NULL;
+
+  if (sn_internal_unserialize_message (message,
+                                       &prefix, &names, &values))
+    {
+      printf (" %s:\n", prefix);
+
+      i = 0;
+      while (names && names[i])
+        {
+          printf ("   '%s' = '%s'\n", names[i], values[i]);
+          
+          ++i;
+        }
+
+      sn_internal_strfreev (names);
+      sn_internal_strfreev (values);
+    }
+}
+
+int
+main (int argc, char **argv)
+{
+  xcb_connection_t *xconnection;
+  SnDisplay *display;
+
+  if (argc != 3)
+    {
+      fprintf (stderr, "arguments must be type and begin type of events to watch\n");
+      return 1;
+    }
+  
+  int screen;
+  xconnection = xcb_connect (NULL, &screen);
+  if (xconnection == NULL)
+    {
+      fprintf (stderr, "Could not open display\n");
+      return 1;
+    }
+
+  /* We have to select for property events on one root window
+   */
+  xcb_screen_t *s = xcb_aux_get_screen (xconnection, screen);
+  const uint32_t select_input_val[] = { XCB_EVENT_MASK_PROPERTY_CHANGE };
+  xcb_change_window_attributes (xconnection, s->root, XCB_CW_EVENT_MASK,
+                                select_input_val);
+  
+  display = sn_xcb_display_new (xconnection, NULL, NULL);
+
+  sn_internal_add_xmessage_func (display, screen,
+                                 argv[1], argv[2],
+                                 message_func,
+                                 NULL, NULL);
+  
+  while (TRUE)
+    {
+      xcb_generic_event_t *xevent = xcb_wait_for_event (xconnection);
+
+      sn_xcb_display_process_event (display, xevent);
+
+      free (xevent);
+    }
+  
+  return 0;
+}
diff --git a/test/test-watch-xmessages.c b/test/test-watch-xmessages.c
index 86ed29e..caba887 100644
--- a/test/test-watch-xmessages.c
+++ b/test/test-watch-xmessages.c
@@ -44,7 +44,7 @@ message_func (SnDisplay       *display,
   printf ("raw %s: %s\n",
           message_type, message);
 #endif
-  
+
   prefix = NULL;
   names = NULL;
   values = NULL;
@@ -58,7 +58,7 @@ message_func (SnDisplay       *display,
       while (names && names[i])
         {
           printf ("   '%s' = '%s'\n", names[i], values[i]);
-          
+
           ++i;
         }
 
@@ -78,7 +78,7 @@ main (int argc, char **argv)
       fprintf (stderr, "arguments must be type and begin type of events to watch\n");
       return 1;
     }
-  
+
   xdisplay = XOpenDisplay (NULL);
   if (xdisplay == NULL)
     {
@@ -88,14 +88,14 @@ main (int argc, char **argv)
 
   if (getenv ("LIBSN_SYNC") != NULL)
     XSynchronize (xdisplay, True);
-  
+
   XSetErrorHandler (x_error_handler);
 
   /* We have to select for property events on one root window
    */
   XSelectInput (xdisplay, DefaultRootWindow (xdisplay),
                 PropertyChangeMask);
-  
+
   display = sn_display_new (xdisplay,
                             error_trap_push,
                             error_trap_pop);
@@ -104,7 +104,7 @@ main (int argc, char **argv)
                                  argv[1], argv[2],
                                  message_func,
                                  NULL, NULL);
-  
+
   while (TRUE)
     {
       XEvent xevent;
@@ -113,6 +113,6 @@ main (int argc, char **argv)
 
       sn_display_process_event (display, &xevent);
     }
-  
+
   return 0;
 }
-- 
1.5.6.5



More information about the xdg mailing list