2 * Copyright (C) 2008 Novell, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 static GdkAtom my_type;
23 static GdkAtom random_type;
28 GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT);
29 static int counter = 42;
32 event->client.window = NULL;
33 event->client.message_type = my_type;
34 event->client.data_format = 32;
35 event->client.data.l[0] = counter++;
36 for (i = 1; i < 5; i++)
37 event->client.data.l[i] = 0;
39 gdk_screen_broadcast_client_message (gdk_display_get_default_screen (gdk_display_get_default ()), event);
41 gdk_event_free (event);
47 GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT);
48 static int counter = 1;
51 event->client.window = NULL;
52 event->client.message_type = random_type;
53 event->client.data_format = 32;
54 event->client.data.l[0] = counter++;
55 for (i = 1; i < 5; i++)
56 event->client.data.l[i] = 0;
58 gdk_screen_broadcast_client_message (gdk_display_get_default_screen (gdk_display_get_default ()), event);
60 gdk_event_free (event);
63 static GdkFilterReturn
64 filter_func (GdkXEvent *xevent,
68 g_print ("Got matching client message!\n");
69 return GDK_FILTER_REMOVE;
73 main (int argc, char **argv)
79 gtk_init (&argc, &argv);
81 my_type = gdk_atom_intern ("GtkTestClientMessage", FALSE);
82 random_type = gdk_atom_intern (g_strdup_printf ("GtkTestClientMessage-%d",
83 g_rand_int_range (g_rand_new (), 1, 99)),
86 g_print ("using random client message type %s\n", gdk_atom_name (random_type));
88 window = g_object_connect (g_object_new (gtk_window_get_type (),
89 "type", GTK_WINDOW_TOPLEVEL,
90 "title", "testclientmessage",
93 "signal::destroy", gtk_main_quit, NULL,
95 vbox = g_object_new (gtk_vbox_get_type (),
96 "GtkWidget::parent", window,
97 "GtkWidget::visible", TRUE,
99 button = g_object_connect (g_object_new (gtk_button_get_type (),
100 "GtkButton::label", "send known client message",
101 "GtkWidget::parent", vbox,
102 "GtkWidget::visible", TRUE,
104 "signal::clicked", send_known, NULL,
106 button = g_object_connect (g_object_new (gtk_button_get_type (),
107 "GtkButton::label", "send random client message",
108 "GtkWidget::parent", vbox,
109 "GtkWidget::visible", TRUE,
111 "signal::clicked", send_random, NULL,
113 gdk_display_add_client_message_filter (gdk_display_get_default (),
117 gtk_widget_show (window);