1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 #include "gdkprivate.h"
24 #include "gdkkeysyms.h"
34 typedef struct _GdkIOClosure GdkIOClosure;
35 typedef struct _GdkEventPrivate GdkEventPrivate;
37 #define DOUBLE_CLICK_TIME 250
38 #define TRIPLE_CLICK_TIME 500
39 #define DOUBLE_CLICK_DIST 5
40 #define TRIPLE_CLICK_DIST 5
43 /* Following flag is set for events on the event queue during
44 * translation and cleared afterwards.
46 GDK_EVENT_PENDING = 1 << 0
49 struct _GdkIOClosure {
50 GdkInputFunction function;
51 GdkInputCondition condition;
52 GdkDestroyNotify notify;
56 struct _GdkEventPrivate {
62 * Private function declarations
65 static GdkEvent *gdk_event_new (void);
66 static gint gdk_event_apply_filters (XEvent *xevent,
69 static gint gdk_event_translate (GdkEvent *event,
72 static Bool gdk_event_get_type (Display *display,
76 static void gdk_events_queue (void);
77 static GdkEvent *gdk_event_unqueue (void);
79 static gboolean gdk_event_prepare (gpointer source_data,
80 GTimeVal *current_time,
82 static gboolean gdk_event_check (gpointer source_data,
83 GTimeVal *current_time);
84 static gboolean gdk_event_dispatch (gpointer source_data,
85 GTimeVal *current_time,
88 static void gdk_synthesize_click (GdkEvent *event,
91 GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
95 /* Private variable declarations
98 static int connection_number = 0; /* The file descriptor number of our
99 * connection to the X server. This
100 * is used so that we may determine
101 * when events are pending by using
102 * the "select" system call.
104 static guint32 button_click_time[2]; /* The last 2 button click times. Used
105 * to determine if the latest button click
106 * is part of a double or triple click.
108 static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses.
109 * Also used to determine if the latest button
110 * click is part of a double or triple click.
112 static guint button_number[2]; /* The last 2 buttons to be pressed.
114 static GdkEventFunc event_func; /* Callback for events */
115 static gpointer event_data;
116 static GDestroyNotify event_notify;
118 static GList *client_filters; /* Filters for client messages */
120 /* FIFO's for event queue, and for events put back using
123 static GList *queued_events = NULL;
124 static GList *queued_tail = NULL;
126 static GSourceFuncs event_funcs = {
130 (GDestroyNotify)g_free
133 GPollFD event_poll_fd;
135 /*********************************************
136 * Functions for maintaining the event queue *
137 *********************************************/
139 /*************************************************************
140 * gdk_event_queue_find_first:
141 * Find the first event on the queue that is not still
146 * Pointer to the list node for that event, or NULL
147 *************************************************************/
150 gdk_event_queue_find_first (void)
152 GList *tmp_list = queued_events;
156 GdkEventPrivate *event = queued_events->data;
157 if (!(event->flags & GDK_EVENT_PENDING))
164 /*************************************************************
165 * gdk_event_queue_remove_link:
166 * Remove a specified list node from the event queue.
168 * node: Node to remove.
170 *************************************************************/
173 gdk_event_queue_remove_link (GList *node)
176 node->prev->next = node->next;
178 queued_events = node->next;
181 node->next->prev = node->prev;
183 queued_tail = node->prev;
187 /*************************************************************
188 * gdk_event_queue_append:
189 * Append an event onto the tail of the event queue.
191 * event: Event to append.
193 *************************************************************/
196 gdk_event_queue_append (GdkEvent *event)
198 queued_tail = g_list_append(queued_tail, event);
201 queued_events = queued_tail;
203 queued_tail = queued_tail->next;
207 gdk_events_init (void)
209 connection_number = ConnectionNumber (gdk_display);
211 g_message ("connection number: %d", connection_number));
213 g_source_add (GDK_PRIORITY_EVENTS, TRUE, &event_funcs, NULL, NULL, NULL);
215 event_poll_fd.fd = connection_number;
216 event_poll_fd.events = G_IO_IN;
218 g_main_add_poll (&event_poll_fd, GDK_PRIORITY_EVENTS);
220 button_click_time[0] = 0;
221 button_click_time[1] = 0;
222 button_window[0] = NULL;
223 button_window[1] = NULL;
224 button_number[0] = -1;
225 button_number[1] = -1;
227 gdk_add_client_message_filter (gdk_wm_protocols,
228 gdk_wm_protocols_filter, NULL);
232 *--------------------------------------------------------------
235 * Returns if events are pending on the queue.
240 * Returns TRUE if events are pending
244 *--------------------------------------------------------------
248 gdk_events_pending (void)
250 return (gdk_event_queue_find_first() || XPending (gdk_display));
254 *--------------------------------------------------------------
255 * gdk_event_get_graphics_expose
257 * Waits for a GraphicsExpose or NoExpose event
262 * For GraphicsExpose events, returns a pointer to the event
263 * converted into a GdkEvent Otherwise, returns NULL.
267 *-------------------------------------------------------------- */
270 graphics_expose_predicate (Display *display,
274 GdkWindowPrivate *private = (GdkWindowPrivate *)arg;
276 g_return_val_if_fail (private != NULL, False);
278 if ((xevent->xany.window == private->xwindow) &&
279 ((xevent->xany.type == GraphicsExpose) ||
280 (xevent->xany.type == NoExpose)))
287 gdk_event_get_graphics_expose (GdkWindow *window)
292 g_return_val_if_fail (window != NULL, NULL);
294 XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer)window);
296 if (xevent.xany.type == GraphicsExpose)
298 event = gdk_event_new ();
300 if (gdk_event_translate (event, &xevent))
303 gdk_event_free (event);
309 /************************
310 * Exposure compression *
311 ************************/
314 * The following implements simple exposure compression. It is
315 * modelled after the way Xt does exposure compression - in
316 * particular compress_expose = XtExposeCompressMultiple.
317 * It compress consecutive sequences of exposure events,
318 * but not sequences that cross other events. (This is because
319 * if it crosses a ConfigureNotify, we could screw up and
320 * mistakenly compress the exposures generated for the new
321 * size - could we just check for ConfigureNotify?)
323 * Xt compresses to a region / bounding rectangle, we compress
324 * to two rectangles, and try find the two rectangles of minimal
325 * area for this - this is supposed to handle the typical
326 * L-shaped regions generated by OpaqueMove.
329 /* Given three rectangles, find the two rectangles that cover
330 * them with the smallest area.
333 gdk_add_rect_to_rects (GdkRectangle *rect1,
335 GdkRectangle *new_rect)
337 GdkRectangle t1, t2, t3;
338 gint size1, size2, size3;
340 gdk_rectangle_union (rect1, rect2, &t1);
341 gdk_rectangle_union (rect1, new_rect, &t2);
342 gdk_rectangle_union (rect2, new_rect, &t3);
344 size1 = t1.width * t1.height + new_rect->width * new_rect->height;
345 size2 = t2.width * t2.height + rect2->width * rect2->height;
346 size3 = t1.width * t1.height + rect1->width * rect1->height;
367 typedef struct _GdkExposeInfo GdkExposeInfo;
369 struct _GdkExposeInfo {
371 gboolean seen_nonmatching;
375 expose_predicate (Display *display, XEvent *xevent, XPointer arg)
377 GdkExposeInfo *info = (GdkExposeInfo *)arg;
379 if (xevent->xany.type != Expose)
381 info->seen_nonmatching = TRUE;
384 if (info->seen_nonmatching || (xevent->xany.window != info->window))
391 gdk_compress_exposures (XEvent *xevent, GdkWindow *window)
397 GdkRectangle tmp_rect;
399 GdkFilterReturn result;
403 info.window = xevent->xany.window;
404 info.seen_nonmatching = FALSE;
406 rect1.x = xevent->xexpose.x;
407 rect1.y = xevent->xexpose.y;
408 rect1.width = xevent->xexpose.width;
409 rect1.height = xevent->xexpose.height;
415 if (!XCheckIfEvent (gdk_display,
422 XIfEvent (gdk_display,
427 /* We apply filters here, and if it was filtered, completely
430 result = gdk_event_apply_filters (xevent, &event,
432 ((GdkWindowPrivate *)window)->filters
433 : gdk_default_filters);
435 if (result != GDK_FILTER_CONTINUE)
437 if (result == GDK_FILTER_TRANSLATE)
438 gdk_event_put (&event);
444 rect2.x = tmp_event.xexpose.x;
445 rect2.y = tmp_event.xexpose.y;
446 rect2.width = tmp_event.xexpose.width;
447 rect2.height = tmp_event.xexpose.height;
453 tmp_rect.x = tmp_event.xexpose.x;
454 tmp_rect.y = tmp_event.xexpose.y;
455 tmp_rect.width = tmp_event.xexpose.width;
456 tmp_rect.height = tmp_event.xexpose.height;
458 gdk_add_rect_to_rects (&rect1, &rect2, &tmp_rect);
461 count = tmp_event.xexpose.count;
466 gdk_rectangle_union (&rect1, &rect2, &tmp_rect);
468 if ((tmp_rect.width * tmp_rect.height) <
469 2 * (rect1.height * rect1.width +
470 rect2.height * rect2.width))
479 event.expose.type = GDK_EXPOSE;
480 event.expose.window = window;
481 event.expose.area.x = rect2.x;
482 event.expose.area.y = rect2.y;
483 event.expose.area.width = rect2.width;
484 event.expose.area.height = rect2.height;
485 event.expose.count = 0;
487 gdk_event_put (&event);
490 xevent->xexpose.count = nrects - 1;
491 xevent->xexpose.x = rect1.x;
492 xevent->xexpose.y = rect1.y;
493 xevent->xexpose.width = rect1.width;
494 xevent->xexpose.height = rect1.height;
497 /*************************************************************
498 * gdk_event_handler_set:
501 * func: Callback function to be called for each event.
502 * data: Data supplied to the function
503 * notify: function called when function is no longer needed
506 *************************************************************/
509 gdk_event_handler_set (GdkEventFunc func,
511 GDestroyNotify notify)
513 if (event_func && event_notify)
514 (*event_notify) (event_data);
518 event_notify = notify;
522 *--------------------------------------------------------------
525 * Gets the next event.
530 * If an event is waiting that we care about, returns
531 * a pointer to that event, to be freed with gdk_event_free.
532 * Otherwise, returns NULL.
536 *--------------------------------------------------------------
544 return gdk_event_unqueue();
548 *--------------------------------------------------------------
551 * Gets the next event.
556 * If an event is waiting that we care about, returns
557 * a copy of that event, but does not remove it from
558 * the queue. The pointer is to be freed with gdk_event_free.
559 * Otherwise, returns NULL.
563 *--------------------------------------------------------------
567 gdk_event_peek (void)
571 tmp_list = gdk_event_queue_find_first ();
574 return gdk_event_copy (tmp_list->data);
580 gdk_event_put (GdkEvent *event)
584 g_return_if_fail (event != NULL);
586 new_event = gdk_event_copy (event);
588 gdk_event_queue_append (new_event);
592 *--------------------------------------------------------------
595 * Copy a event structure into new storage.
598 * "event" is the event struct to copy.
601 * A new event structure. Free it with gdk_event_free.
604 * The reference count of the window in the event is increased.
606 *--------------------------------------------------------------
609 static GMemChunk *event_chunk;
614 GdkEventPrivate *new_event;
616 if (event_chunk == NULL)
617 event_chunk = g_mem_chunk_new ("events",
618 sizeof (GdkEventPrivate),
622 new_event = g_chunk_new (GdkEventPrivate, event_chunk);
623 new_event->flags = 0;
625 return (GdkEvent *)new_event;
629 gdk_event_copy (GdkEvent *event)
633 g_return_val_if_fail (event != NULL, NULL);
635 new_event = gdk_event_new ();
638 gdk_window_ref (new_event->any.window);
640 switch (event->any.type)
643 case GDK_KEY_RELEASE:
644 new_event->key.string = g_strdup (event->key.string);
647 case GDK_ENTER_NOTIFY:
648 case GDK_LEAVE_NOTIFY:
649 if (event->crossing.subwindow != NULL)
650 gdk_window_ref (event->crossing.subwindow);
655 case GDK_DRAG_MOTION:
656 case GDK_DRAG_STATUS:
658 case GDK_DROP_FINISHED:
659 gdk_drag_context_ref (event->dnd.context);
671 *--------------------------------------------------------------
674 * Free a event structure obtained from gdk_event_copy. Do not use
675 * with other event structures.
678 * "event" is the event struct to free.
683 * The reference count of the window in the event is decreased and
684 * might be freed, too.
686 *-------------------------------------------------------------- */
689 gdk_event_free (GdkEvent *event)
691 g_assert (event_chunk != NULL);
692 g_return_if_fail (event != NULL);
694 if (event->any.window)
695 gdk_window_unref (event->any.window);
697 switch (event->any.type)
700 case GDK_KEY_RELEASE:
701 g_free (event->key.string);
704 case GDK_ENTER_NOTIFY:
705 case GDK_LEAVE_NOTIFY:
706 if (event->crossing.subwindow != NULL)
707 gdk_window_unref (event->crossing.subwindow);
712 case GDK_DRAG_MOTION:
713 case GDK_DRAG_STATUS:
715 case GDK_DROP_FINISHED:
716 gdk_drag_context_unref (event->dnd.context);
724 g_mem_chunk_free (event_chunk, event);
728 *--------------------------------------------------------------
729 * gdk_event_get_time:
730 * Get the timestamp from an event.
734 * The event's time stamp, if it has one, otherwise
736 *--------------------------------------------------------------
740 gdk_event_get_time (GdkEvent *event)
745 case GDK_MOTION_NOTIFY:
746 return event->motion.time;
747 case GDK_BUTTON_PRESS:
748 case GDK_2BUTTON_PRESS:
749 case GDK_3BUTTON_PRESS:
750 case GDK_BUTTON_RELEASE:
751 return event->button.time;
753 case GDK_KEY_RELEASE:
754 return event->key.time;
755 case GDK_ENTER_NOTIFY:
756 case GDK_LEAVE_NOTIFY:
757 return event->crossing.time;
758 case GDK_PROPERTY_NOTIFY:
759 return event->property.time;
760 case GDK_SELECTION_CLEAR:
761 case GDK_SELECTION_REQUEST:
762 case GDK_SELECTION_NOTIFY:
763 return event->selection.time;
764 case GDK_PROXIMITY_IN:
765 case GDK_PROXIMITY_OUT:
766 return event->proximity.time;
769 case GDK_DRAG_MOTION:
770 case GDK_DRAG_STATUS:
772 case GDK_DROP_FINISHED:
773 return event->dnd.time;
774 default: /* use current time */
778 return GDK_CURRENT_TIME;
782 *--------------------------------------------------------------
783 * gdk_set_show_events
785 * Turns on/off the showing of events.
788 * "show_events" is a boolean describing whether or
789 * not to show the events gdk receives.
794 * When "show_events" is TRUE, calls to "gdk_event_get"
795 * will output debugging informatin regarding the event
796 * received to stdout.
798 *--------------------------------------------------------------
802 gdk_set_show_events (int show_events)
805 gdk_debug_flags |= GDK_DEBUG_EVENTS;
807 gdk_debug_flags &= ~GDK_DEBUG_EVENTS;
811 gdk_get_show_events (void)
813 return gdk_debug_flags & GDK_DEBUG_EVENTS;
817 gdk_io_destroy (gpointer data)
819 GdkIOClosure *closure = data;
822 closure->notify (closure->data);
828 gdk_io_invoke (GIOChannel *source,
829 GIOCondition condition,
832 GdkIOClosure *closure = data;
833 GdkInputCondition gdk_cond = 0;
835 if (condition & (G_IO_IN | G_IO_PRI))
836 gdk_cond |= GDK_INPUT_READ;
837 if (condition & G_IO_OUT)
838 gdk_cond |= GDK_INPUT_WRITE;
839 if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
840 gdk_cond |= GDK_INPUT_EXCEPTION;
842 if (closure->condition & gdk_cond)
843 closure->function (closure->data, g_io_channel_unix_get_fd (source), gdk_cond);
849 gdk_input_add_full (gint source,
850 GdkInputCondition condition,
851 GdkInputFunction function,
853 GdkDestroyNotify destroy)
856 GdkIOClosure *closure = g_new (GdkIOClosure, 1);
858 GIOCondition cond = 0;
860 closure->function = function;
861 closure->condition = condition;
862 closure->notify = destroy;
863 closure->data = data;
865 if (condition & GDK_INPUT_READ)
866 cond |= (G_IO_IN | G_IO_PRI);
867 if (condition & GDK_INPUT_WRITE)
869 if (condition & GDK_INPUT_EXCEPTION)
870 cond |= G_IO_ERR|G_IO_HUP|G_IO_NVAL;
872 channel = g_io_channel_unix_new (source);
873 result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond,
875 closure, gdk_io_destroy);
876 g_io_channel_unref (channel);
882 gdk_input_add (gint source,
883 GdkInputCondition condition,
884 GdkInputFunction function,
887 return gdk_input_add_full (source, condition, function, data, NULL);
891 gdk_input_remove (gint tag)
893 g_source_remove (tag);
897 gdk_event_apply_filters (XEvent *xevent,
901 GdkEventFilter *filter;
903 GdkFilterReturn result;
909 filter = (GdkEventFilter *)tmp_list->data;
911 result = (*filter->function)(xevent, event, filter->data);
912 if (result != GDK_FILTER_CONTINUE)
915 tmp_list = tmp_list->next;
918 return GDK_FILTER_CONTINUE;
922 gdk_add_client_message_filter (GdkAtom message_type,
926 GdkClientFilter *filter = g_new (GdkClientFilter, 1);
928 filter->type = message_type;
929 filter->function = func;
932 client_filters = g_list_prepend (client_filters, filter);
936 gdk_event_translate (GdkEvent *event,
941 GdkWindowPrivate *window_private;
942 static XComposeStatus compose;
946 static gchar* buf = NULL;
947 static gint buf_len= 0;
955 /* Find the GdkWindow that this event occurred in.
957 * We handle events with window=None
958 * specially - they are generated by XFree86's XInput under
959 * some circumstances.
962 if ((xevent->xany.window == None) &&
963 gdk_input_vtable.window_none_event)
965 return_val = gdk_input_vtable.window_none_event (event,xevent);
967 if (return_val >= 0) /* was handled */
973 window = gdk_window_lookup (xevent->xany.window);
974 window_private = (GdkWindowPrivate *) window;
977 gdk_window_ref (window);
979 event->any.window = window;
980 event->any.send_event = xevent->xany.send_event;
982 if (window_private && window_private->destroyed)
984 if (xevent->type != DestroyNotify)
989 /* Check for filters for this window
991 GdkFilterReturn result;
992 result = gdk_event_apply_filters (xevent, event,
994 ?window_private->filters
995 :gdk_default_filters);
997 if (result != GDK_FILTER_CONTINUE)
999 return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
1004 if (window == NULL && gdk_xim_window && xevent->type == KeyPress &&
1005 !((GdkWindowPrivate *) gdk_xim_window)->destroyed)
1008 * If user presses a key in Preedit or Status window, keypress event
1009 * is sometimes sent to these windows. These windows are not managed
1010 * by GDK, so we redirect KeyPress event to xim_window.
1012 * If someone want to use the window whitch is not managed by GDK
1013 * and want to get KeyPress event, he/she must register the filter
1014 * function to gdk_default_filters to intercept the event.
1017 GdkFilterReturn result;
1019 window = gdk_xim_window;
1020 window_private = (GdkWindowPrivate *) window;
1021 gdk_window_ref (window);
1022 event->any.window = window;
1025 g_message ("KeyPress event is redirected to xim_window: %#lx",
1026 xevent->xany.window));
1028 result = gdk_event_apply_filters (xevent, event,
1029 window_private->filters);
1030 if (result != GDK_FILTER_CONTINUE)
1031 return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
1036 g_message ("Got event for unknown window: %#lx\n", xevent->xany.window);
1038 /* We do a "manual" conversion of the XEvent to a
1039 * GdkEvent. The structures are mostly the same so
1040 * the conversion is fairly straightforward. We also
1041 * optionally print debugging info regarding events
1047 switch (xevent->type)
1050 /* Lookup the string corresponding to the given keysym.
1057 buf = g_new (gchar, buf_len);
1059 keysym = GDK_VoidSymbol;
1061 if (gdk_xim_ic && gdk_xim_ic->xic)
1065 /* Clear keyval. Depending on status, may not be set */
1066 charcount = XmbLookupString(gdk_xim_ic->xic,
1067 &xevent->xkey, buf, buf_len-1,
1069 if (status == XBufferOverflow)
1071 /* alloc adequate size of buffer */
1073 g_message("XIM: overflow (required %i)", charcount));
1075 while (buf_len <= charcount)
1077 buf = (gchar *) g_realloc (buf, buf_len);
1079 charcount = XmbLookupString (gdk_xim_ic->xic,
1080 &xevent->xkey, buf, buf_len-1,
1083 if (status == XLookupNone)
1090 charcount = XLookupString (&xevent->xkey, buf, buf_len,
1093 charcount = XLookupString (&xevent->xkey, buf, 16,
1096 event->key.keyval = keysym;
1098 if (charcount > 0 && buf[charcount-1] == '\0')
1101 buf[charcount] = '\0';
1103 /* Print debugging info. */
1105 #ifdef G_ENABLE_DEBUG
1106 if (gdk_debug_flags & GDK_DEBUG_EVENTS)
1108 g_message ("key press:\twindow: %ld key: %12s %d",
1109 xevent->xkey.window,
1110 event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)",
1113 g_message ("\t\tlength: %4d string: \"%s\"",
1116 #endif /* G_ENABLE_DEBUG */
1118 event->key.type = GDK_KEY_PRESS;
1119 event->key.window = window;
1120 event->key.time = xevent->xkey.time;
1121 event->key.state = (GdkModifierType) xevent->xkey.state;
1122 event->key.string = g_strdup (buf);
1123 event->key.length = charcount;
1128 /* Lookup the string corresponding to the given keysym.
1134 buf = g_new (gchar, buf_len);
1137 keysym = GDK_VoidSymbol;
1138 charcount = XLookupString (&xevent->xkey, buf, 16,
1140 event->key.keyval = keysym;
1142 /* Print debugging info.
1145 g_message ("key release:\t\twindow: %ld key: %12s %d",
1146 xevent->xkey.window,
1147 XKeysymToString (event->key.keyval),
1148 event->key.keyval));
1150 event->key.type = GDK_KEY_RELEASE;
1151 event->key.window = window;
1152 event->key.time = xevent->xkey.time;
1153 event->key.state = (GdkModifierType) xevent->xkey.state;
1154 event->key.length = 0;
1155 event->key.string = NULL;
1160 /* Print debugging info.
1163 g_message ("button press:\t\twindow: %ld x,y: %d %d button: %d",
1164 xevent->xbutton.window,
1165 xevent->xbutton.x, xevent->xbutton.y,
1166 xevent->xbutton.button));
1168 if (window_private &&
1169 (window_private->extension_events != 0) &&
1170 gdk_input_ignore_core)
1176 event->button.type = GDK_BUTTON_PRESS;
1177 event->button.window = window;
1178 event->button.time = xevent->xbutton.time;
1179 event->button.x = xevent->xbutton.x;
1180 event->button.y = xevent->xbutton.y;
1181 event->button.x_root = (gfloat)xevent->xbutton.x_root;
1182 event->button.y_root = (gfloat)xevent->xbutton.y_root;
1183 event->button.pressure = 0.5;
1184 event->button.xtilt = 0;
1185 event->button.ytilt = 0;
1186 event->button.state = (GdkModifierType) xevent->xbutton.state;
1187 event->button.button = xevent->xbutton.button;
1188 event->button.source = GDK_SOURCE_MOUSE;
1189 event->button.deviceid = GDK_CORE_POINTER;
1191 if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
1192 (event->button.window == button_window[1]) &&
1193 (event->button.button == button_number[1]))
1195 gdk_synthesize_click (event, 3);
1197 button_click_time[1] = 0;
1198 button_click_time[0] = 0;
1199 button_window[1] = NULL;
1200 button_window[0] = 0;
1201 button_number[1] = -1;
1202 button_number[0] = -1;
1204 else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
1205 (event->button.window == button_window[0]) &&
1206 (event->button.button == button_number[0]))
1208 gdk_synthesize_click (event, 2);
1210 button_click_time[1] = button_click_time[0];
1211 button_click_time[0] = event->button.time;
1212 button_window[1] = button_window[0];
1213 button_window[0] = event->button.window;
1214 button_number[1] = button_number[0];
1215 button_number[0] = event->button.button;
1219 button_click_time[1] = 0;
1220 button_click_time[0] = event->button.time;
1221 button_window[1] = NULL;
1222 button_window[0] = event->button.window;
1223 button_number[1] = -1;
1224 button_number[0] = event->button.button;
1230 /* Print debugging info.
1233 g_message ("button release:\twindow: %ld x,y: %d %d button: %d",
1234 xevent->xbutton.window,
1235 xevent->xbutton.x, xevent->xbutton.y,
1236 xevent->xbutton.button));
1238 if (window_private &&
1239 (window_private->extension_events != 0) &&
1240 gdk_input_ignore_core)
1246 event->button.type = GDK_BUTTON_RELEASE;
1247 event->button.window = window;
1248 event->button.time = xevent->xbutton.time;
1249 event->button.x = xevent->xbutton.x;
1250 event->button.y = xevent->xbutton.y;
1251 event->button.x_root = (gfloat)xevent->xbutton.x_root;
1252 event->button.y_root = (gfloat)xevent->xbutton.y_root;
1253 event->button.pressure = 0.5;
1254 event->button.xtilt = 0;
1255 event->button.ytilt = 0;
1256 event->button.state = (GdkModifierType) xevent->xbutton.state;
1257 event->button.button = xevent->xbutton.button;
1258 event->button.source = GDK_SOURCE_MOUSE;
1259 event->button.deviceid = GDK_CORE_POINTER;
1264 /* Print debugging info.
1267 g_message ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s",
1268 xevent->xmotion.window,
1269 xevent->xmotion.x, xevent->xmotion.y,
1270 (xevent->xmotion.is_hint) ? "true" : "false"));
1272 if (window_private &&
1273 (window_private->extension_events != 0) &&
1274 gdk_input_ignore_core)
1280 event->motion.type = GDK_MOTION_NOTIFY;
1281 event->motion.window = window;
1282 event->motion.time = xevent->xmotion.time;
1283 event->motion.x = xevent->xmotion.x;
1284 event->motion.y = xevent->xmotion.y;
1285 event->motion.x_root = (gfloat)xevent->xmotion.x_root;
1286 event->motion.y_root = (gfloat)xevent->xmotion.y_root;
1287 event->motion.pressure = 0.5;
1288 event->motion.xtilt = 0;
1289 event->motion.ytilt = 0;
1290 event->motion.state = (GdkModifierType) xevent->xmotion.state;
1291 event->motion.is_hint = xevent->xmotion.is_hint;
1292 event->motion.source = GDK_SOURCE_MOUSE;
1293 event->motion.deviceid = GDK_CORE_POINTER;
1298 /* Print debugging info.
1301 g_message ("enter notify:\t\twindow: %ld detail: %d subwin: %ld",
1302 xevent->xcrossing.window,
1303 xevent->xcrossing.detail,
1304 xevent->xcrossing.subwindow));
1306 /* Tell XInput stuff about it if appropriate */
1307 if (window_private &&
1308 !window_private->destroyed &&
1309 (window_private->extension_events != 0) &&
1310 gdk_input_vtable.enter_event)
1311 gdk_input_vtable.enter_event (&xevent->xcrossing, window);
1313 event->crossing.type = GDK_ENTER_NOTIFY;
1314 event->crossing.window = window;
1316 /* If the subwindow field of the XEvent is non-NULL, then
1317 * lookup the corresponding GdkWindow.
1319 if (xevent->xcrossing.subwindow != None)
1320 event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
1322 event->crossing.subwindow = NULL;
1324 event->crossing.time = xevent->xcrossing.time;
1325 event->crossing.x = xevent->xcrossing.x;
1326 event->crossing.y = xevent->xcrossing.y;
1327 event->crossing.x_root = xevent->xcrossing.x_root;
1328 event->crossing.y_root = xevent->xcrossing.y_root;
1330 /* Translate the crossing mode into Gdk terms.
1332 switch (xevent->xcrossing.mode)
1335 event->crossing.mode = GDK_CROSSING_NORMAL;
1338 event->crossing.mode = GDK_CROSSING_GRAB;
1341 event->crossing.mode = GDK_CROSSING_UNGRAB;
1345 /* Translate the crossing detail into Gdk terms.
1347 switch (xevent->xcrossing.detail)
1349 case NotifyInferior:
1350 event->crossing.detail = GDK_NOTIFY_INFERIOR;
1352 case NotifyAncestor:
1353 event->crossing.detail = GDK_NOTIFY_ANCESTOR;
1356 event->crossing.detail = GDK_NOTIFY_VIRTUAL;
1358 case NotifyNonlinear:
1359 event->crossing.detail = GDK_NOTIFY_NONLINEAR;
1361 case NotifyNonlinearVirtual:
1362 event->crossing.detail = GDK_NOTIFY_NONLINEAR_VIRTUAL;
1365 event->crossing.detail = GDK_NOTIFY_UNKNOWN;
1369 event->crossing.focus = xevent->xcrossing.focus;
1370 event->crossing.state = xevent->xcrossing.state;
1375 /* Print debugging info.
1378 g_message ("leave notify:\t\twindow: %ld detail: %d subwin: %ld",
1379 xevent->xcrossing.window,
1380 xevent->xcrossing.detail, xevent->xcrossing.subwindow));
1382 event->crossing.type = GDK_LEAVE_NOTIFY;
1383 event->crossing.window = window;
1385 /* If the subwindow field of the XEvent is non-NULL, then
1386 * lookup the corresponding GdkWindow.
1388 if (xevent->xcrossing.subwindow != None)
1389 event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
1391 event->crossing.subwindow = NULL;
1393 event->crossing.time = xevent->xcrossing.time;
1394 event->crossing.x = xevent->xcrossing.x;
1395 event->crossing.y = xevent->xcrossing.y;
1396 event->crossing.x_root = xevent->xcrossing.x_root;
1397 event->crossing.y_root = xevent->xcrossing.y_root;
1399 /* Translate the crossing mode into Gdk terms.
1401 switch (xevent->xcrossing.mode)
1404 event->crossing.mode = GDK_CROSSING_NORMAL;
1407 event->crossing.mode = GDK_CROSSING_GRAB;
1410 event->crossing.mode = GDK_CROSSING_UNGRAB;
1414 /* Translate the crossing detail into Gdk terms.
1416 switch (xevent->xcrossing.detail)
1418 case NotifyInferior:
1419 event->crossing.detail = GDK_NOTIFY_INFERIOR;
1421 case NotifyAncestor:
1422 event->crossing.detail = GDK_NOTIFY_ANCESTOR;
1425 event->crossing.detail = GDK_NOTIFY_VIRTUAL;
1427 case NotifyNonlinear:
1428 event->crossing.detail = GDK_NOTIFY_NONLINEAR;
1430 case NotifyNonlinearVirtual:
1431 event->crossing.detail = GDK_NOTIFY_NONLINEAR_VIRTUAL;
1434 event->crossing.detail = GDK_NOTIFY_UNKNOWN;
1438 event->crossing.focus = xevent->xcrossing.focus;
1439 event->crossing.state = xevent->xcrossing.state;
1445 /* We only care about focus events that indicate that _this_
1446 * window (not a ancestor or child) got or lost the focus
1448 switch (xevent->xfocus.detail)
1450 case NotifyAncestor:
1451 case NotifyInferior:
1452 case NotifyNonlinear:
1453 /* Print debugging info.
1456 g_message ("focus %s:\t\twindow: %ld",
1457 (xevent->xany.type == FocusIn) ? "in" : "out",
1458 xevent->xfocus.window));
1460 /* gdk_keyboard_grab() causes following events. These events confuse
1461 * the XIM focus, so ignore them.
1463 if (xevent->xfocus.mode == NotifyGrab ||
1464 xevent->xfocus.mode == NotifyUngrab)
1467 event->focus_change.type = GDK_FOCUS_CHANGE;
1468 event->focus_change.window = window;
1469 event->focus_change.in = (xevent->xany.type == FocusIn);
1478 /* Print debugging info.
1481 g_message ("keymap notify"));
1483 /* Not currently handled */
1488 /* Print debugging info.
1491 g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d",
1492 xevent->xexpose.window, xevent->xexpose.count,
1493 xevent->xexpose.x, xevent->xexpose.y,
1494 xevent->xexpose.width, xevent->xexpose.height));
1495 gdk_compress_exposures (xevent, window);
1497 event->expose.type = GDK_EXPOSE;
1498 event->expose.window = window;
1499 event->expose.area.x = xevent->xexpose.x;
1500 event->expose.area.y = xevent->xexpose.y;
1501 event->expose.area.width = xevent->xexpose.width;
1502 event->expose.area.height = xevent->xexpose.height;
1503 event->expose.count = xevent->xexpose.count;
1507 case GraphicsExpose:
1508 /* Print debugging info.
1511 g_message ("graphics expose:\tdrawable: %ld",
1512 xevent->xgraphicsexpose.drawable));
1514 event->expose.type = GDK_EXPOSE;
1515 event->expose.window = window;
1516 event->expose.area.x = xevent->xgraphicsexpose.x;
1517 event->expose.area.y = xevent->xgraphicsexpose.y;
1518 event->expose.area.width = xevent->xgraphicsexpose.width;
1519 event->expose.area.height = xevent->xgraphicsexpose.height;
1520 event->expose.count = xevent->xexpose.count;
1525 /* Print debugging info.
1528 g_message ("no expose:\t\tdrawable: %ld",
1529 xevent->xnoexpose.drawable));
1531 event->no_expose.type = GDK_NO_EXPOSE;
1532 event->no_expose.window = window;
1536 case VisibilityNotify:
1537 /* Print debugging info.
1539 #ifdef G_ENABLE_DEBUG
1540 if (gdk_debug_flags & GDK_DEBUG_EVENTS)
1541 switch (xevent->xvisibility.state)
1543 case VisibilityFullyObscured:
1544 g_message ("visibility notify:\twindow: %ld none",
1545 xevent->xvisibility.window);
1547 case VisibilityPartiallyObscured:
1548 g_message ("visibility notify:\twindow: %ld partial",
1549 xevent->xvisibility.window);
1551 case VisibilityUnobscured:
1552 g_message ("visibility notify:\twindow: %ld full",
1553 xevent->xvisibility.window);
1556 #endif /* G_ENABLE_DEBUG */
1558 event->visibility.type = GDK_VISIBILITY_NOTIFY;
1559 event->visibility.window = window;
1561 switch (xevent->xvisibility.state)
1563 case VisibilityFullyObscured:
1564 event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
1567 case VisibilityPartiallyObscured:
1568 event->visibility.state = GDK_VISIBILITY_PARTIAL;
1571 case VisibilityUnobscured:
1572 event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
1579 /* Not currently handled */
1583 /* Print debugging info.
1586 g_message ("destroy notify:\twindow: %ld",
1587 xevent->xdestroywindow.window));
1589 event->any.type = GDK_DESTROY;
1590 event->any.window = window;
1592 return_val = window_private && !window_private->destroyed;
1594 if(window && window_private->xwindow != GDK_ROOT_WINDOW())
1595 gdk_window_destroy_notify (window);
1599 /* Print debugging info.
1602 g_message ("unmap notify:\t\twindow: %ld",
1603 xevent->xmap.window));
1605 event->any.type = GDK_UNMAP;
1606 event->any.window = window;
1608 if (gdk_xgrab_window == window_private)
1609 gdk_xgrab_window = NULL;
1614 /* Print debugging info.
1617 g_message ("map notify:\t\twindow: %ld",
1618 xevent->xmap.window));
1620 event->any.type = GDK_MAP;
1621 event->any.window = window;
1625 case ReparentNotify:
1626 /* Print debugging info.
1629 g_message ("reparent notify:\twindow: %ld",
1630 xevent->xreparent.window));
1632 /* Not currently handled */
1636 case ConfigureNotify:
1637 /* Print debugging info.
1639 while ((XPending (gdk_display) > 0) &&
1640 XCheckTypedWindowEvent(gdk_display, xevent->xany.window,
1641 ConfigureNotify, xevent))
1643 GdkFilterReturn result;
1646 g_message ("configure notify discarded:\twindow: %ld",
1647 xevent->xconfigure.window));
1649 result = gdk_event_apply_filters (xevent, event,
1651 ?window_private->filters
1652 :gdk_default_filters);
1654 /* If the result is GDK_FILTER_REMOVE, there will be
1655 * trouble, but anybody who filtering the Configure events
1656 * better know what they are doing
1658 if (result != GDK_FILTER_CONTINUE)
1660 return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
1663 /*XSync (gdk_display, 0);*/
1668 g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d",
1669 xevent->xconfigure.window,
1670 xevent->xconfigure.x,
1671 xevent->xconfigure.y,
1672 xevent->xconfigure.width,
1673 xevent->xconfigure.height,
1674 xevent->xconfigure.border_width,
1675 xevent->xconfigure.above,
1676 xevent->xconfigure.override_redirect));
1678 if (!window_private->destroyed &&
1679 (window_private->extension_events != 0) &&
1680 gdk_input_vtable.configure_event)
1681 gdk_input_vtable.configure_event (&xevent->xconfigure, window);
1683 if (window_private->window_type == GDK_WINDOW_CHILD)
1687 event->configure.type = GDK_CONFIGURE;
1688 event->configure.window = window;
1689 event->configure.width = xevent->xconfigure.width;
1690 event->configure.height = xevent->xconfigure.height;
1692 if (!xevent->xconfigure.x &&
1693 !xevent->xconfigure.y &&
1694 !window_private->destroyed)
1698 Window child_window = 0;
1700 if (!XTranslateCoordinates (window_private->xdisplay,
1701 window_private->xwindow,
1706 g_warning ("GdkWindow %ld doesn't share root windows display?",
1707 window_private->xwindow);
1708 event->configure.x = tx;
1709 event->configure.y = ty;
1713 event->configure.x = xevent->xconfigure.x;
1714 event->configure.y = xevent->xconfigure.y;
1716 window_private->x = event->configure.x;
1717 window_private->y = event->configure.y;
1718 window_private->width = xevent->xconfigure.width;
1719 window_private->height = xevent->xconfigure.height;
1720 if (window_private->resize_count > 1)
1721 window_private->resize_count -= 1;
1725 case PropertyNotify:
1726 /* Print debugging info.
1729 g_message ("property notify:\twindow: %ld",
1730 xevent->xproperty.window));
1732 event->property.type = GDK_PROPERTY_NOTIFY;
1733 event->property.window = window;
1734 event->property.atom = xevent->xproperty.atom;
1735 event->property.time = xevent->xproperty.time;
1736 event->property.state = xevent->xproperty.state;
1740 case SelectionClear:
1742 g_message ("selection clear:\twindow: %ld",
1743 xevent->xproperty.window));
1745 event->selection.type = GDK_SELECTION_CLEAR;
1746 event->selection.window = window;
1747 event->selection.selection = xevent->xselectionclear.selection;
1748 event->selection.time = xevent->xselectionclear.time;
1752 case SelectionRequest:
1754 g_message ("selection request:\twindow: %ld",
1755 xevent->xproperty.window));
1757 event->selection.type = GDK_SELECTION_REQUEST;
1758 event->selection.window = window;
1759 event->selection.selection = xevent->xselectionrequest.selection;
1760 event->selection.target = xevent->xselectionrequest.target;
1761 event->selection.property = xevent->xselectionrequest.property;
1762 event->selection.requestor = xevent->xselectionrequest.requestor;
1763 event->selection.time = xevent->xselectionrequest.time;
1767 case SelectionNotify:
1769 g_message ("selection notify:\twindow: %ld",
1770 xevent->xproperty.window));
1773 event->selection.type = GDK_SELECTION_NOTIFY;
1774 event->selection.window = window;
1775 event->selection.selection = xevent->xselection.selection;
1776 event->selection.target = xevent->xselection.target;
1777 event->selection.property = xevent->xselection.property;
1778 event->selection.time = xevent->xselection.time;
1782 case ColormapNotify:
1783 /* Print debugging info.
1786 g_message ("colormap notify:\twindow: %ld",
1787 xevent->xcolormap.window));
1789 /* Not currently handled */
1796 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1798 /* Print debugging info.
1801 g_message ("client message:\twindow: %ld",
1802 xevent->xclient.window));
1804 tmp_list = client_filters;
1807 GdkClientFilter *filter = tmp_list->data;
1808 if (filter->type == xevent->xclient.message_type)
1810 result = (*filter->function) (xevent, event, filter->data);
1814 tmp_list = tmp_list->next;
1819 case GDK_FILTER_REMOVE:
1822 case GDK_FILTER_TRANSLATE:
1825 case GDK_FILTER_CONTINUE:
1826 /* Send unknown ClientMessage's on to Gtk for it to use */
1827 event->client.type = GDK_CLIENT_EVENT;
1828 event->client.window = window;
1829 event->client.message_type = xevent->xclient.message_type;
1830 event->client.data_format = xevent->xclient.format;
1831 memcpy(&event->client.data, &xevent->xclient.data,
1832 sizeof(event->client.data));
1839 /* Print debugging info.
1842 g_message ("mapping notify"));
1844 /* Let XLib know that there is a new keyboard mapping.
1846 XRefreshKeyboardMapping (&xevent->xmapping);
1851 /* something else - (e.g., a Xinput event) */
1853 if (window_private &&
1854 !window_private->destroyed &&
1855 (window_private->extension_events != 0) &&
1856 gdk_input_vtable.other_event)
1857 return_val = gdk_input_vtable.other_event(event, xevent, window);
1866 if (event->any.window)
1867 gdk_window_ref (event->any.window);
1868 if (((event->any.type == GDK_ENTER_NOTIFY) ||
1869 (event->any.type == GDK_LEAVE_NOTIFY)) &&
1870 (event->crossing.subwindow != NULL))
1871 gdk_window_ref (event->crossing.subwindow);
1875 /* Mark this event as having no resources to be freed */
1876 event->any.window = NULL;
1877 event->any.type = GDK_NOTHING;
1881 gdk_window_unref (window);
1887 gdk_wm_protocols_filter (GdkXEvent *xev,
1891 XEvent *xevent = (XEvent *)xev;
1893 if ((Atom) xevent->xclient.data.l[0] == gdk_wm_delete_window)
1895 /* The delete window request specifies a window
1896 * to delete. We don't actually destroy the
1897 * window because "it is only a request". (The
1898 * window might contain vital data that the
1899 * program does not want destroyed). Instead
1900 * the event is passed along to the program,
1901 * which should then destroy the window.
1904 g_message ("delete window:\t\twindow: %ld",
1905 xevent->xclient.window));
1907 event->any.type = GDK_DELETE;
1909 return GDK_FILTER_TRANSLATE;
1911 else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus)
1915 return GDK_FILTER_REMOVE;
1920 gdk_event_get_type (Display *display,
1927 if (gdk_event_translate (&event, xevent))
1929 pred = (GdkPredicate*) arg;
1930 return (* pred->func) (&event, pred->data);
1938 gdk_events_queue (void)
1944 while (!gdk_event_queue_find_first() && XPending (gdk_display))
1949 XNextEvent (gdk_display, &xevent);
1951 switch (xevent.type)
1957 w = GDK_WINDOW_XWINDOW (gdk_xim_window);
1961 if (XFilterEvent (&xevent, w))
1964 XNextEvent (gdk_display, &xevent);
1967 event = gdk_event_new ();
1969 event->any.type = GDK_NOTHING;
1970 event->any.window = NULL;
1971 event->any.send_event = FALSE;
1972 event->any.send_event = xevent.xany.send_event;
1974 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1976 gdk_event_queue_append (event);
1979 if (gdk_event_translate (event, &xevent))
1981 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1985 gdk_event_queue_remove_link (node);
1986 g_list_free_1 (node);
1987 gdk_event_free (event);
1993 gdk_event_prepare (gpointer source_data,
1994 GTimeVal *current_time,
1999 GDK_THREADS_ENTER ();
2003 retval = (gdk_event_queue_find_first () != NULL) || XPending (gdk_display);
2005 GDK_THREADS_LEAVE ();
2011 gdk_event_check (gpointer source_data,
2012 GTimeVal *current_time)
2016 GDK_THREADS_ENTER ();
2018 if (event_poll_fd.revents & G_IO_IN)
2019 retval = (gdk_event_queue_find_first () != NULL) || XPending (gdk_display);
2023 GDK_THREADS_LEAVE ();
2029 gdk_event_unqueue (void)
2031 GdkEvent *event = NULL;
2034 tmp_list = gdk_event_queue_find_first ();
2038 event = tmp_list->data;
2039 gdk_event_queue_remove_link (tmp_list);
2040 g_list_free_1 (tmp_list);
2047 gdk_event_dispatch (gpointer source_data,
2048 GTimeVal *current_time,
2053 GDK_THREADS_ENTER ();
2056 event = gdk_event_unqueue();
2061 (*event_func) (event, event_data);
2063 gdk_event_free (event);
2066 GDK_THREADS_LEAVE ();
2072 gdk_synthesize_click (GdkEvent *event,
2075 GdkEvent temp_event;
2077 g_return_if_fail (event != NULL);
2079 temp_event = *event;
2080 temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS;
2082 gdk_event_put (&temp_event);
2085 /* Sends a ClientMessage to all toplevel client windows */
2087 gdk_event_send_client_message (GdkEvent *event, guint32 xid)
2091 g_return_val_if_fail(event != NULL, FALSE);
2093 /* Set up our event to send, with the exception of its target window */
2094 sev.xclient.type = ClientMessage;
2095 sev.xclient.display = gdk_display;
2096 sev.xclient.format = event->client.data_format;
2097 sev.xclient.window = xid;
2098 memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data));
2099 sev.xclient.message_type = event->client.message_type;
2101 return gdk_send_xevent (xid, False, NoEventMask, &sev);
2104 /* Sends a ClientMessage to all toplevel client windows */
2106 gdk_event_send_client_message_to_all_recurse (XEvent *xev,
2110 static GdkAtom wm_state_atom = GDK_NONE;
2114 unsigned long nitems, after;
2115 unsigned char *data;
2117 Window *ret_children, ret_root, ret_parent;
2118 unsigned int ret_nchildren;
2121 gboolean send = FALSE;
2122 gboolean found = FALSE;
2125 wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
2128 XGetWindowProperty (gdk_display, xid, wm_state_atom, 0, 0, False, AnyPropertyType,
2129 &type, &format, &nitems, &after, &data);
2144 /* OK, we're all set, now let's find some windows to send this to */
2145 if (XQueryTree(gdk_display, xid, &ret_root, &ret_parent,
2146 &ret_children, &ret_nchildren) != True)
2152 for(i = 0; i < ret_nchildren; i++)
2153 if (gdk_event_send_client_message_to_all_recurse(xev, ret_children[i], level + 1))
2156 XFree(ret_children);
2159 if (send || (!found && (level == 1)))
2161 xev->xclient.window = xid;
2162 gdk_send_xevent (xid, False, NoEventMask, xev);
2165 return (send || found);
2169 gdk_event_send_clientmessage_toall (GdkEvent *event)
2172 gint old_warnings = gdk_error_warnings;
2174 g_return_if_fail(event != NULL);
2176 /* Set up our event to send, with the exception of its target window */
2177 sev.xclient.type = ClientMessage;
2178 sev.xclient.display = gdk_display;
2179 sev.xclient.format = event->client.data_format;
2180 memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data));
2181 sev.xclient.message_type = event->client.message_type;
2183 gdk_event_send_client_message_to_all_recurse(&sev, gdk_root_window, 0);
2185 gdk_error_warnings = old_warnings;
2189 *--------------------------------------------------------------
2192 * Flushes the Xlib output buffer and then waits
2193 * until all requests have been received and processed
2194 * by the X server. The only real use for this function
2195 * is in dealing with XShm.
2203 *--------------------------------------------------------------
2206 void gdk_flush (void)
2208 XSync (gdk_display, False);