| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#include <config.h> |
| 27 |
#include <libsn/sn.h> |
| 28 |
#include <libsn/sn-xmessages.h> |
| 29 |
#include <libsn/sn-internals.h> |
| 30 |
|
| 31 |
#include <xcb/xcb_aux.h> |
| 32 |
|
| 33 |
#include "test-boilerplate.h" |
| 34 |
|
| 35 |
static void |
| 36 |
message_func (SnDisplay *display, |
| 37 |
const char *message_type, |
| 38 |
const char *message, |
| 39 |
void *user_data) |
| 40 |
{ |
| 41 |
char *prefix; |
| 42 |
char **names; |
| 43 |
char **values; |
| 44 |
int i; |
| 45 |
|
| 46 |
#if 0 |
| 47 |
printf ("raw %s: %s\n", |
| 48 |
message_type, message); |
| 49 |
#endif |
| 50 |
|
| 51 |
prefix = NULL; |
| 52 |
names = NULL; |
| 53 |
values = NULL; |
| 54 |
|
| 55 |
if (sn_internal_unserialize_message (message, |
| 56 |
&prefix, &names, &values)) |
| 57 |
{ |
| 58 |
printf (" %s:\n", prefix); |
| 59 |
|
| 60 |
i = 0; |
| 61 |
while (names && names[i]) |
| 62 |
{ |
| 63 |
printf (" '%s' = '%s'\n", names[i], values[i]); |
| 64 |
|
| 65 |
++i; |
| 66 |
} |
| 67 |
|
| 68 |
sn_internal_strfreev (names); |
| 69 |
sn_internal_strfreev (values); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
int |
| 74 |
main (int argc, char **argv) |
| 75 |
{ |
| 76 |
xcb_connection_t *xconnection; |
| 77 |
SnDisplay *display; |
| 78 |
|
| 79 |
if (argc != 3) |
| 80 |
{ |
| •81 |
fprintf (stderr, "arguments must be type and begin type (as names) of events to watch\n"); |
| 82 |
return 1; |
| 83 |
} |
| 84 |
|
| 85 |
int screen; |
| 86 |
xconnection = xcb_connect (NULL, &screen); |
| 87 |
if (xconnection == NULL) |
| 88 |
{ |
| 89 |
fprintf (stderr, "Could not open display\n"); |
| 90 |
return 1; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
xcb_screen_t *s = xcb_aux_get_screen (xconnection, screen); |
| 96 |
const uint32_t select_input_val[] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; |
| 97 |
xcb_change_window_attributes (xconnection, s->root, XCB_CW_EVENT_MASK, |
| 98 |
select_input_val); |
| 99 |
|
| 100 |
display = sn_xcb_display_new (xconnection, NULL, NULL); |
| 101 |
|
| 102 |
sn_internal_add_xmessage_func (display, screen, |
| 103 |
argv[1], argv[2], |
| 104 |
message_func, |
| 105 |
NULL, NULL); |
| 106 |
|
| 107 |
while (TRUE) |
| 108 |
{ |
| 109 |
xcb_generic_event_t *xevent = xcb_wait_for_event (xconnection); |
| 110 |
|
| 111 |
sn_xcb_display_process_event (display, xevent); |
| 112 |
|
| 113 |
free (xevent); |
| 114 |
} |
| 115 |
|
| 116 |
return 0; |
| 117 |
} |