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 Lesser 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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser 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.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
28 #include "gdkprivate-x11.h"
29 #include "gdkinternals.h"
32 #include "gdkkeysyms.h"
34 #include "xsettings-client.h"
43 #include "gdkinputprivate.h"
46 #include <X11/XKBlib.h>
49 #include <X11/Xatom.h>
51 typedef struct _GdkIOClosure GdkIOClosure;
52 typedef struct _GdkEventPrivate GdkEventPrivate;
54 #define DOUBLE_CLICK_TIME 250
55 #define TRIPLE_CLICK_TIME 500
56 #define DOUBLE_CLICK_DIST 5
57 #define TRIPLE_CLICK_DIST 5
61 /* Following flag is set for events on the event queue during
62 * translation and cleared afterwards.
64 GDK_EVENT_PENDING = 1 << 0
69 GdkInputFunction function;
70 GdkInputCondition condition;
71 GdkDestroyNotify notify;
75 struct _GdkEventPrivate
82 * Private function declarations
85 static gint gdk_event_apply_filters (XEvent *xevent,
88 static gint gdk_event_translate (GdkEvent *event,
90 gboolean return_exposes);
92 static Bool gdk_event_get_type (Display *display,
97 static gboolean gdk_event_prepare (GSource *source,
99 static gboolean gdk_event_check (GSource *source);
100 static gboolean gdk_event_dispatch (GSource *source,
101 GSourceFunc callback,
104 GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
108 static void gdk_xsettings_watch_cb (Window window,
112 static void gdk_xsettings_notify_cb (const char *name,
113 XSettingsAction action,
114 XSettingsSetting *setting,
117 /* Private variable declarations
120 static int connection_number = 0; /* The file descriptor number of our
121 * connection to the X server. This
122 * is used so that we may determine
123 * when events are pending by using
124 * the "select" system call.
126 static GList *client_filters; /* Filters for client messages */
128 static GSourceFuncs event_funcs = {
135 static GPollFD event_poll_fd;
137 static Window wmspec_check_window = None;
139 static XSettingsClient *xsettings_client;
141 /*********************************************
142 * Functions for maintaining the event queue *
143 *********************************************/
146 gdk_events_init (void)
150 connection_number = ConnectionNumber (gdk_display);
152 g_message ("connection number: %d", connection_number));
155 source = g_source_new (&event_funcs, sizeof (GSource));
156 g_source_set_priority (source, GDK_PRIORITY_EVENTS);
158 event_poll_fd.fd = connection_number;
159 event_poll_fd.events = G_IO_IN;
161 g_source_add_poll (source, &event_poll_fd);
162 g_source_set_can_recurse (source, TRUE);
163 g_source_attach (source, NULL);
165 gdk_add_client_message_filter (gdk_wm_protocols,
166 gdk_wm_protocols_filter, NULL);
168 xsettings_client = xsettings_client_new (gdk_display, DefaultScreen (gdk_display),
169 gdk_xsettings_notify_cb,
170 gdk_xsettings_watch_cb,
175 *--------------------------------------------------------------
178 * Returns if events are pending on the queue.
183 * Returns TRUE if events are pending
187 *--------------------------------------------------------------
191 gdk_events_pending (void)
193 return (gdk_event_queue_find_first() || XPending (gdk_display));
197 *--------------------------------------------------------------
198 * gdk_event_get_graphics_expose
200 * Waits for a GraphicsExpose or NoExpose event
205 * For GraphicsExpose events, returns a pointer to the event
206 * converted into a GdkEvent Otherwise, returns NULL.
210 *-------------------------------------------------------------- */
213 graphics_expose_predicate (Display *display,
217 if (xevent->xany.window == GDK_DRAWABLE_XID (arg) &&
218 (xevent->xany.type == GraphicsExpose ||
219 xevent->xany.type == NoExpose))
226 gdk_event_get_graphics_expose (GdkWindow *window)
231 g_return_val_if_fail (window != NULL, NULL);
233 XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer) window);
235 if (xevent.xany.type == GraphicsExpose)
237 event = gdk_event_new ();
239 if (gdk_event_translate (event, &xevent, TRUE))
242 gdk_event_free (event);
249 gdk_event_apply_filters (XEvent *xevent,
254 GdkFilterReturn result;
260 GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
262 tmp_list = tmp_list->next;
263 result = filter->function (xevent, event, filter->data);
264 if (result != GDK_FILTER_CONTINUE)
268 return GDK_FILTER_CONTINUE;
272 gdk_add_client_message_filter (GdkAtom message_type,
276 GdkClientFilter *filter = g_new (GdkClientFilter, 1);
278 filter->type = message_type;
279 filter->function = func;
282 client_filters = g_list_prepend (client_filters, filter);
285 static GdkAtom wm_state_atom = 0;
286 static GdkAtom wm_desktop_atom = 0;
289 gdk_check_wm_state_changed (GdkWindow *window)
295 GdkAtom *atoms = NULL;
298 GdkAtom maxvert_atom;
299 GdkAtom maxhorz_atom;
300 gboolean found_sticky, found_maxvert, found_maxhorz;
301 GdkWindowState old_state;
303 if (GDK_WINDOW_DESTROYED (window))
306 if (wm_state_atom == 0)
307 wm_state_atom = gdk_atom_intern ("_NET_WM_STATE", FALSE);
309 if (wm_desktop_atom == 0)
310 wm_desktop_atom = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
312 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
313 wm_state_atom, 0, G_MAXLONG,
314 False, XA_ATOM, &type, &format, &nitems,
315 &bytes_after, (guchar **)&atoms);
320 sticky_atom = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE);
321 maxvert_atom = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE);
322 maxhorz_atom = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE);
324 found_sticky = FALSE;
325 found_maxvert = FALSE;
326 found_maxhorz = FALSE;
331 if (atoms[i] == sticky_atom)
333 else if (atoms[i] == maxvert_atom)
334 found_maxvert = TRUE;
335 else if (atoms[i] == maxhorz_atom)
336 found_maxhorz = TRUE;
345 found_sticky = FALSE;
346 found_maxvert = FALSE;
347 found_maxhorz = FALSE;
350 /* For found_sticky to remain TRUE, we have to also be on desktop
358 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
359 wm_desktop_atom, 0, G_MAXLONG,
360 False, XA_CARDINAL, &type, &format, &nitems,
361 &bytes_after, (guchar **)&desktop);
365 if (*desktop != 0xFFFFFFFF)
366 found_sticky = FALSE;
371 old_state = gdk_window_get_state (window);
373 if (old_state & GDK_WINDOW_STATE_STICKY)
376 gdk_synthesize_window_state (window,
377 GDK_WINDOW_STATE_STICKY,
383 gdk_synthesize_window_state (window,
385 GDK_WINDOW_STATE_STICKY);
388 /* Our "maximized" means both vertical and horizontal; if only one,
389 * we don't expose that via GDK
391 if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
393 if (!(found_maxvert && found_maxhorz))
394 gdk_synthesize_window_state (window,
395 GDK_WINDOW_STATE_MAXIMIZED,
400 if (found_maxvert && found_maxhorz)
401 gdk_synthesize_window_state (window,
403 GDK_WINDOW_STATE_MAXIMIZED);
407 #define HAS_FOCUS(window_impl) \
408 ((window_impl)->has_focus || (window_impl)->has_pointer_focus)
411 generate_focus_event (GdkWindow *window,
416 event.type = GDK_FOCUS_CHANGE;
417 event.focus_change.window = window;
418 event.focus_change.send_event = FALSE;
419 event.focus_change.in = in;
421 gdk_event_put (&event);
425 gdk_event_translate (GdkEvent *event,
427 gboolean return_exposes)
431 GdkWindowObject *window_private;
432 GdkWindowImplX11 *window_impl = NULL;
433 static XComposeStatus compose;
438 gint xoffset, yoffset;
442 /* Find the GdkWindow that this event occurred in.
444 * We handle events with window=None
445 * specially - they are generated by XFree86's XInput under
446 * some circumstances.
449 if (xevent->xany.window == None)
451 return_val = _gdk_input_window_none_event (event, xevent);
453 if (return_val >= 0) /* was handled */
459 window = gdk_window_lookup (xevent->xany.window);
460 window_private = (GdkWindowObject *) window;
462 if (_gdk_moveresize_window &&
463 (xevent->xany.type == MotionNotify ||
464 xevent->xany.type == ButtonRelease))
466 _gdk_moveresize_handle_event (xevent);
467 gdk_window_unref (window);
471 if (wmspec_check_window != None &&
472 xevent->xany.window == wmspec_check_window)
474 if (xevent->type == DestroyNotify)
475 wmspec_check_window = None;
477 /* Eat events on this window unless someone had wrapped
478 * it as a foreign window
484 /* FIXME: window might be a GdkPixmap!!! */
487 window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
489 if (xevent->xany.window != GDK_WINDOW_XID (window))
491 g_assert (xevent->xany.window == window_impl->focus_window);
493 switch (xevent->type)
497 xevent->xany.window = GDK_WINDOW_XID (window);
504 gdk_window_ref (window);
507 event->any.window = window;
508 event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
510 if (window_private && GDK_WINDOW_DESTROYED (window))
512 if (xevent->type != DestroyNotify)
517 /* Check for filters for this window
519 GdkFilterReturn result;
520 result = gdk_event_apply_filters (xevent, event,
522 ?window_private->filters
523 :gdk_default_filters);
525 if (result != GDK_FILTER_CONTINUE)
527 return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
532 /* We do a "manual" conversion of the XEvent to a
533 * GdkEvent. The structures are mostly the same so
534 * the conversion is fairly straightforward. We also
535 * optionally print debugging info regarding events
543 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
551 switch (xevent->type)
554 /* Lookup the string corresponding to the given keysym.
557 charcount = XLookupString (&xevent->xkey, buf, 16,
559 event->key.keyval = keysym;
560 event->key.hardware_keycode = xevent->xkey.keycode;
562 if (charcount > 0 && buf[charcount-1] == '\0')
565 buf[charcount] = '\0';
567 #ifdef G_ENABLE_DEBUG
568 if (gdk_debug_flags & GDK_DEBUG_EVENTS)
570 g_message ("key press:\twindow: %ld key: %12s %d",
572 event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)",
575 g_message ("\t\tlength: %4d string: \"%s\"",
578 #endif /* G_ENABLE_DEBUG */
580 /* bits 13 and 14 in the "state" field are the keyboard group */
581 #define KEYBOARD_GROUP_SHIFT 13
582 #define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14))
584 event->key.type = GDK_KEY_PRESS;
585 event->key.window = window;
586 event->key.time = xevent->xkey.time;
587 event->key.state = (GdkModifierType) xevent->xkey.state;
588 event->key.string = g_strdup (buf);
589 event->key.length = charcount;
591 event->key.group = (xevent->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT;
596 /* Lookup the string corresponding to the given keysym.
599 /* Emulate detectable auto-repeat by checking to see
600 * if the next event is a key press with the same
601 * keycode and timestamp, and if so, ignoring the event.
604 if (!_gdk_have_xkb_autorepeat && XPending (gdk_display))
608 XPeekEvent (gdk_display, &next_event);
610 if (next_event.type == KeyPress &&
611 next_event.xkey.keycode == xevent->xkey.keycode &&
612 next_event.xkey.time == xevent->xkey.time)
616 keysym = GDK_VoidSymbol;
617 charcount = XLookupString (&xevent->xkey, buf, 16,
619 event->key.keyval = keysym;
622 g_message ("key release:\t\twindow: %ld key: %12s %d",
624 XKeysymToString (event->key.keyval),
627 event->key.type = GDK_KEY_RELEASE;
628 event->key.window = window;
629 event->key.time = xevent->xkey.time;
630 event->key.state = (GdkModifierType) xevent->xkey.state;
631 event->key.length = 0;
632 event->key.string = NULL;
638 g_message ("button press:\t\twindow: %ld x,y: %d %d button: %d",
639 xevent->xbutton.window,
640 xevent->xbutton.x, xevent->xbutton.y,
641 xevent->xbutton.button));
643 if (window_private &&
644 (window_private->extension_events != 0) &&
645 gdk_input_ignore_core)
651 /* If we get a ButtonPress event where the button is 4 or 5,
652 it's a Scroll event */
653 if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
655 event->scroll.type = GDK_SCROLL;
656 event->scroll.direction = (xevent->xbutton.button == 4) ?
657 GDK_SCROLL_UP : GDK_SCROLL_DOWN;
658 event->scroll.window = window;
659 event->scroll.time = xevent->xbutton.x;
660 event->scroll.x = xevent->xbutton.x + xoffset;
661 event->scroll.y = xevent->xbutton.y + yoffset;
662 event->scroll.x_root = (gfloat)xevent->xbutton.x_root;
663 event->scroll.y_root = (gfloat)xevent->xbutton.y_root;
664 event->scroll.state = (GdkModifierType) xevent->xbutton.state;
665 event->scroll.device = gdk_core_pointer;
669 event->button.type = GDK_BUTTON_PRESS;
670 event->button.window = window;
671 event->button.time = xevent->xbutton.time;
672 event->button.x = xevent->xbutton.x + xoffset;
673 event->button.y = xevent->xbutton.y + yoffset;
674 event->button.x_root = (gfloat)xevent->xbutton.x_root;
675 event->button.y_root = (gfloat)xevent->xbutton.y_root;
676 event->button.axes = NULL;
677 event->button.state = (GdkModifierType) xevent->xbutton.state;
678 event->button.button = xevent->xbutton.button;
679 event->button.device = gdk_core_pointer;
681 gdk_event_button_generate (event);
688 g_message ("button release:\twindow: %ld x,y: %d %d button: %d",
689 xevent->xbutton.window,
690 xevent->xbutton.x, xevent->xbutton.y,
691 xevent->xbutton.button));
693 if (window_private &&
694 (window_private->extension_events != 0) &&
695 gdk_input_ignore_core)
701 /* We treat button presses as scroll wheel events, so ignore the release */
702 if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
708 event->button.type = GDK_BUTTON_RELEASE;
709 event->button.window = window;
710 event->button.time = xevent->xbutton.time;
711 event->button.x = xevent->xbutton.x + xoffset;
712 event->button.y = xevent->xbutton.y + yoffset;
713 event->button.x_root = (gfloat)xevent->xbutton.x_root;
714 event->button.y_root = (gfloat)xevent->xbutton.y_root;
715 event->button.axes = NULL;
716 event->button.state = (GdkModifierType) xevent->xbutton.state;
717 event->button.button = xevent->xbutton.button;
718 event->button.device = gdk_core_pointer;
724 g_message ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s",
725 xevent->xmotion.window,
726 xevent->xmotion.x, xevent->xmotion.y,
727 (xevent->xmotion.is_hint) ? "true" : "false"));
729 if (window_private &&
730 (window_private->extension_events != 0) &&
731 gdk_input_ignore_core)
737 event->motion.type = GDK_MOTION_NOTIFY;
738 event->motion.window = window;
739 event->motion.time = xevent->xmotion.time;
740 event->motion.x = xevent->xmotion.x + xoffset;
741 event->motion.y = xevent->xmotion.y + yoffset;
742 event->motion.x_root = (gfloat)xevent->xmotion.x_root;
743 event->motion.y_root = (gfloat)xevent->xmotion.y_root;
744 event->motion.axes = NULL;
745 event->motion.state = (GdkModifierType) xevent->xmotion.state;
746 event->motion.is_hint = xevent->xmotion.is_hint;
747 event->motion.device = gdk_core_pointer;
753 g_message ("enter notify:\t\twindow: %ld detail: %d subwin: %ld",
754 xevent->xcrossing.window,
755 xevent->xcrossing.detail,
756 xevent->xcrossing.subwindow));
758 /* Handle focusing (in the case where no window manager is running */
760 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
761 xevent->xcrossing.detail != NotifyInferior &&
762 xevent->xcrossing.focus && !window_impl->has_focus)
764 gboolean had_focus = HAS_FOCUS (window_impl);
766 window_impl->has_pointer_focus = TRUE;
768 if (HAS_FOCUS (window_impl) != had_focus)
769 generate_focus_event (window, TRUE);
772 /* Tell XInput stuff about it if appropriate */
773 if (window_private &&
774 !GDK_WINDOW_DESTROYED (window) &&
775 window_private->extension_events != 0)
776 _gdk_input_enter_event (&xevent->xcrossing, window);
778 event->crossing.type = GDK_ENTER_NOTIFY;
779 event->crossing.window = window;
781 /* If the subwindow field of the XEvent is non-NULL, then
782 * lookup the corresponding GdkWindow.
784 if (xevent->xcrossing.subwindow != None)
785 event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
787 event->crossing.subwindow = NULL;
789 event->crossing.time = xevent->xcrossing.time;
790 event->crossing.x = xevent->xcrossing.x + xoffset;
791 event->crossing.y = xevent->xcrossing.y + yoffset;
792 event->crossing.x_root = xevent->xcrossing.x_root;
793 event->crossing.y_root = xevent->xcrossing.y_root;
795 /* Translate the crossing mode into Gdk terms.
797 switch (xevent->xcrossing.mode)
800 event->crossing.mode = GDK_CROSSING_NORMAL;
803 event->crossing.mode = GDK_CROSSING_GRAB;
806 event->crossing.mode = GDK_CROSSING_UNGRAB;
810 /* Translate the crossing detail into Gdk terms.
812 switch (xevent->xcrossing.detail)
815 event->crossing.detail = GDK_NOTIFY_INFERIOR;
818 event->crossing.detail = GDK_NOTIFY_ANCESTOR;
821 event->crossing.detail = GDK_NOTIFY_VIRTUAL;
823 case NotifyNonlinear:
824 event->crossing.detail = GDK_NOTIFY_NONLINEAR;
826 case NotifyNonlinearVirtual:
827 event->crossing.detail = GDK_NOTIFY_NONLINEAR_VIRTUAL;
830 event->crossing.detail = GDK_NOTIFY_UNKNOWN;
834 event->crossing.focus = xevent->xcrossing.focus;
835 event->crossing.state = xevent->xcrossing.state;
841 g_message ("leave notify:\t\twindow: %ld detail: %d subwin: %ld",
842 xevent->xcrossing.window,
843 xevent->xcrossing.detail, xevent->xcrossing.subwindow));
845 /* Handle focusing (in the case where no window manager is running */
847 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
848 xevent->xcrossing.detail != NotifyInferior &&
849 xevent->xcrossing.focus && !window_impl->has_focus)
851 gboolean had_focus = HAS_FOCUS (window_impl);
853 window_impl->has_pointer_focus = FALSE;
855 if (HAS_FOCUS (window_impl) != had_focus)
856 generate_focus_event (window, FALSE);
859 event->crossing.type = GDK_LEAVE_NOTIFY;
860 event->crossing.window = window;
862 /* If the subwindow field of the XEvent is non-NULL, then
863 * lookup the corresponding GdkWindow.
865 if (xevent->xcrossing.subwindow != None)
866 event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
868 event->crossing.subwindow = NULL;
870 event->crossing.time = xevent->xcrossing.time;
871 event->crossing.x = xevent->xcrossing.x + xoffset;
872 event->crossing.y = xevent->xcrossing.y + yoffset;
873 event->crossing.x_root = xevent->xcrossing.x_root;
874 event->crossing.y_root = xevent->xcrossing.y_root;
876 /* Translate the crossing mode into Gdk terms.
878 switch (xevent->xcrossing.mode)
881 event->crossing.mode = GDK_CROSSING_NORMAL;
884 event->crossing.mode = GDK_CROSSING_GRAB;
887 event->crossing.mode = GDK_CROSSING_UNGRAB;
891 /* Translate the crossing detail into Gdk terms.
893 switch (xevent->xcrossing.detail)
896 event->crossing.detail = GDK_NOTIFY_INFERIOR;
899 event->crossing.detail = GDK_NOTIFY_ANCESTOR;
902 event->crossing.detail = GDK_NOTIFY_VIRTUAL;
904 case NotifyNonlinear:
905 event->crossing.detail = GDK_NOTIFY_NONLINEAR;
907 case NotifyNonlinearVirtual:
908 event->crossing.detail = GDK_NOTIFY_NONLINEAR_VIRTUAL;
911 event->crossing.detail = GDK_NOTIFY_UNKNOWN;
915 event->crossing.focus = xevent->xcrossing.focus;
916 event->crossing.state = xevent->xcrossing.state;
920 /* We only care about focus events that indicate that _this_
921 * window (not a ancestor or child) got or lost the focus
925 g_message ("focus in:\t\twindow: %ld", xevent->xfocus.window));
927 if (window && GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
929 gboolean had_focus = HAS_FOCUS (window_impl);
931 switch (xevent->xfocus.detail)
934 case NotifyNonlinear:
936 case NotifyNonlinearVirtual:
937 window_impl->has_focus = TRUE;
940 window_impl->has_pointer_focus = TRUE;
943 case NotifyPointerRoot:
944 case NotifyDetailNone:
948 if (HAS_FOCUS (window_impl) != had_focus)
949 generate_focus_event (window, TRUE);
954 g_message ("focus out:\t\twindow: %ld", xevent->xfocus.window));
956 if (window && GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
958 gboolean had_focus = HAS_FOCUS (window_impl);
960 switch (xevent->xfocus.detail)
963 case NotifyNonlinear:
965 case NotifyNonlinearVirtual:
966 window_impl->has_focus = FALSE;
969 window_impl->has_pointer_focus = FALSE;
972 case NotifyPointerRoot:
973 case NotifyDetailNone:
977 if (HAS_FOCUS (window_impl) != had_focus)
978 generate_focus_event (window, FALSE);
983 /* gdk_keyboard_grab() causes following events. These events confuse
984 * the XIM focus, so ignore them.
986 if (xevent->xfocus.mode == NotifyGrab ||
987 xevent->xfocus.mode == NotifyUngrab)
993 g_message ("keymap notify"));
995 /* Not currently handled */
1001 g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
1002 xevent->xexpose.window, xevent->xexpose.count,
1003 xevent->xexpose.x, xevent->xexpose.y,
1004 xevent->xexpose.width, xevent->xexpose.height,
1005 event->any.send_event ? " (send)" : ""));
1007 GdkRectangle expose_rect;
1009 expose_rect.x = xevent->xexpose.x + xoffset;
1010 expose_rect.y = xevent->xexpose.y + yoffset;
1011 expose_rect.width = xevent->xexpose.width;
1012 expose_rect.height = xevent->xexpose.height;
1016 event->expose.type = GDK_EXPOSE;
1017 event->expose.area = expose_rect;
1018 event->expose.region = gdk_region_rectangle (&expose_rect);
1019 event->expose.window = window;
1020 event->expose.count = xevent->xexpose.count;
1026 _gdk_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
1036 case GraphicsExpose:
1038 GdkRectangle expose_rect;
1041 g_message ("graphics expose:\tdrawable: %ld",
1042 xevent->xgraphicsexpose.drawable));
1044 expose_rect.x = xevent->xgraphicsexpose.x + xoffset;
1045 expose_rect.y = xevent->xgraphicsexpose.y + yoffset;
1046 expose_rect.width = xevent->xgraphicsexpose.width;
1047 expose_rect.height = xevent->xgraphicsexpose.height;
1051 event->expose.type = GDK_EXPOSE;
1052 event->expose.area = expose_rect;
1053 event->expose.region = gdk_region_rectangle (&expose_rect);
1054 event->expose.window = window;
1055 event->expose.count = xevent->xgraphicsexpose.count;
1061 _gdk_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
1071 g_message ("no expose:\t\tdrawable: %ld",
1072 xevent->xnoexpose.drawable));
1074 event->no_expose.type = GDK_NO_EXPOSE;
1075 event->no_expose.window = window;
1079 case VisibilityNotify:
1080 #ifdef G_ENABLE_DEBUG
1081 if (gdk_debug_flags & GDK_DEBUG_EVENTS)
1082 switch (xevent->xvisibility.state)
1084 case VisibilityFullyObscured:
1085 g_message ("visibility notify:\twindow: %ld none",
1086 xevent->xvisibility.window);
1088 case VisibilityPartiallyObscured:
1089 g_message ("visibility notify:\twindow: %ld partial",
1090 xevent->xvisibility.window);
1092 case VisibilityUnobscured:
1093 g_message ("visibility notify:\twindow: %ld full",
1094 xevent->xvisibility.window);
1097 #endif /* G_ENABLE_DEBUG */
1099 event->visibility.type = GDK_VISIBILITY_NOTIFY;
1100 event->visibility.window = window;
1102 switch (xevent->xvisibility.state)
1104 case VisibilityFullyObscured:
1105 event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
1108 case VisibilityPartiallyObscured:
1109 event->visibility.state = GDK_VISIBILITY_PARTIAL;
1112 case VisibilityUnobscured:
1113 event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
1121 g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
1122 xevent->xcreatewindow.window,
1123 xevent->xcreatewindow.x,
1124 xevent->xcreatewindow.y,
1125 xevent->xcreatewindow.width,
1126 xevent->xcreatewindow.height,
1127 xevent->xcreatewindow.border_width,
1128 xevent->xcreatewindow.parent,
1129 xevent->xcreatewindow.override_redirect));
1130 /* not really handled */
1135 g_message ("destroy notify:\twindow: %ld",
1136 xevent->xdestroywindow.window));
1138 event->any.type = GDK_DESTROY;
1139 event->any.window = window;
1141 return_val = window_private && !GDK_WINDOW_DESTROYED (window);
1143 if (window && GDK_WINDOW_XID (window) != GDK_ROOT_WINDOW())
1144 gdk_window_destroy_notify (window);
1149 g_message ("unmap notify:\t\twindow: %ld",
1150 xevent->xmap.window));
1152 event->any.type = GDK_UNMAP;
1153 event->any.window = window;
1155 /* If we are shown (not withdrawn) and get an unmap, it means we
1156 * were iconified in the X sense. If we are withdrawn, and get
1157 * an unmap, it means we hid the window ourselves, so we
1158 * will have already flipped the iconified bit off.
1160 if (window && GDK_WINDOW_IS_MAPPED (window))
1161 gdk_synthesize_window_state (window,
1163 GDK_WINDOW_STATE_ICONIFIED);
1165 if (gdk_xgrab_window == window_private)
1166 gdk_xgrab_window = NULL;
1172 g_message ("map notify:\t\twindow: %ld",
1173 xevent->xmap.window));
1175 event->any.type = GDK_MAP;
1176 event->any.window = window;
1178 /* Unset iconified if it was set */
1179 if (window && (((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_ICONIFIED))
1180 gdk_synthesize_window_state (window,
1181 GDK_WINDOW_STATE_ICONIFIED,
1186 case ReparentNotify:
1188 g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
1189 xevent->xreparent.window,
1190 xevent->xreparent.x,
1191 xevent->xreparent.y,
1192 xevent->xreparent.parent,
1193 xevent->xreparent.override_redirect));
1195 /* Not currently handled */
1199 case ConfigureNotify:
1201 g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
1202 xevent->xconfigure.window,
1203 xevent->xconfigure.x,
1204 xevent->xconfigure.y,
1205 xevent->xconfigure.width,
1206 xevent->xconfigure.height,
1207 xevent->xconfigure.border_width,
1208 xevent->xconfigure.above,
1209 xevent->xconfigure.override_redirect,
1212 : GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD
1213 ? " (discarding child)"
1216 !GDK_WINDOW_DESTROYED (window) &&
1217 (window_private->extension_events != 0))
1218 _gdk_input_configure_event (&xevent->xconfigure, window);
1220 if (!window || GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1224 event->configure.type = GDK_CONFIGURE;
1225 event->configure.window = window;
1226 event->configure.width = xevent->xconfigure.width;
1227 event->configure.height = xevent->xconfigure.height;
1229 if (!xevent->xconfigure.x &&
1230 !xevent->xconfigure.y &&
1231 !GDK_WINDOW_DESTROYED (window))
1235 Window child_window = 0;
1237 gdk_error_trap_push ();
1238 if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window),
1239 GDK_DRAWABLE_XID (window),
1245 if (!gdk_error_trap_pop ())
1247 event->configure.x = tx;
1248 event->configure.y = ty;
1252 gdk_error_trap_pop ();
1256 event->configure.x = xevent->xconfigure.x;
1257 event->configure.y = xevent->xconfigure.y;
1259 window_private->x = event->configure.x;
1260 window_private->y = event->configure.y;
1261 GDK_WINDOW_IMPL_X11 (window_private->impl)->width = xevent->xconfigure.width;
1262 GDK_WINDOW_IMPL_X11 (window_private->impl)->height = xevent->xconfigure.height;
1263 if (window_private->resize_count >= 1)
1265 window_private->resize_count -= 1;
1267 if (window_private->resize_count == 0 &&
1268 window == _gdk_moveresize_window)
1269 _gdk_moveresize_configure_done ();
1274 case PropertyNotify:
1276 gchar *atom = gdk_atom_name (xevent->xproperty.atom);
1277 g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
1278 xevent->xproperty.window,
1279 xevent->xproperty.atom,
1281 atom ? atom : "unknown",
1286 event->property.type = GDK_PROPERTY_NOTIFY;
1287 event->property.window = window;
1288 event->property.atom = xevent->xproperty.atom;
1289 event->property.time = xevent->xproperty.time;
1290 event->property.state = xevent->xproperty.state;
1292 if (wm_state_atom == 0)
1293 wm_state_atom = gdk_atom_intern ("_NET_WM_STATE", FALSE);
1295 if (wm_desktop_atom == 0)
1296 wm_desktop_atom = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
1298 if (event->property.atom == wm_state_atom ||
1299 event->property.atom == wm_desktop_atom)
1301 /* If window state changed, then synthesize those events. */
1302 gdk_check_wm_state_changed (event->property.window);
1307 case SelectionClear:
1309 g_message ("selection clear:\twindow: %ld",
1310 xevent->xproperty.window));
1312 if (_gdk_selection_filter_clear_event (&xevent->xselectionclear))
1314 event->selection.type = GDK_SELECTION_CLEAR;
1315 event->selection.window = window;
1316 event->selection.selection = xevent->xselectionclear.selection;
1317 event->selection.time = xevent->xselectionclear.time;
1324 case SelectionRequest:
1326 g_message ("selection request:\twindow: %ld",
1327 xevent->xproperty.window));
1329 event->selection.type = GDK_SELECTION_REQUEST;
1330 event->selection.window = window;
1331 event->selection.selection = xevent->xselectionrequest.selection;
1332 event->selection.target = xevent->xselectionrequest.target;
1333 event->selection.property = xevent->xselectionrequest.property;
1334 event->selection.requestor = xevent->xselectionrequest.requestor;
1335 event->selection.time = xevent->xselectionrequest.time;
1339 case SelectionNotify:
1341 g_message ("selection notify:\twindow: %ld",
1342 xevent->xproperty.window));
1345 event->selection.type = GDK_SELECTION_NOTIFY;
1346 event->selection.window = window;
1347 event->selection.selection = xevent->xselection.selection;
1348 event->selection.target = xevent->xselection.target;
1349 event->selection.property = xevent->xselection.property;
1350 event->selection.time = xevent->xselection.time;
1354 case ColormapNotify:
1356 g_message ("colormap notify:\twindow: %ld",
1357 xevent->xcolormap.window));
1359 /* Not currently handled */
1366 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1369 g_message ("client message:\twindow: %ld",
1370 xevent->xclient.window));
1372 tmp_list = client_filters;
1375 GdkClientFilter *filter = tmp_list->data;
1376 if (filter->type == xevent->xclient.message_type)
1378 result = (*filter->function) (xevent, event, filter->data);
1382 tmp_list = tmp_list->next;
1387 case GDK_FILTER_REMOVE:
1390 case GDK_FILTER_TRANSLATE:
1393 case GDK_FILTER_CONTINUE:
1394 /* Send unknown ClientMessage's on to Gtk for it to use */
1395 event->client.type = GDK_CLIENT_EVENT;
1396 event->client.window = window;
1397 event->client.message_type = xevent->xclient.message_type;
1398 event->client.data_format = xevent->xclient.format;
1399 memcpy(&event->client.data, &xevent->xclient.data,
1400 sizeof(event->client.data));
1408 g_message ("mapping notify"));
1410 /* Let XLib know that there is a new keyboard mapping.
1412 XRefreshKeyboardMapping (&xevent->xmapping);
1413 ++_gdk_keymap_serial;
1419 ++_gdk_keymap_serial;
1425 /* something else - (e.g., a Xinput event) */
1427 if (window_private &&
1428 !GDK_WINDOW_DESTROYED (window_private) &&
1429 (window_private->extension_events != 0))
1430 return_val = _gdk_input_other_event(event, xevent, window);
1440 if (event->any.window)
1441 gdk_window_ref (event->any.window);
1442 if (((event->any.type == GDK_ENTER_NOTIFY) ||
1443 (event->any.type == GDK_LEAVE_NOTIFY)) &&
1444 (event->crossing.subwindow != NULL))
1445 gdk_window_ref (event->crossing.subwindow);
1449 /* Mark this event as having no resources to be freed */
1450 event->any.window = NULL;
1451 event->any.type = GDK_NOTHING;
1455 gdk_window_unref (window);
1461 gdk_wm_protocols_filter (GdkXEvent *xev,
1465 XEvent *xevent = (XEvent *)xev;
1467 if ((Atom) xevent->xclient.data.l[0] == gdk_wm_delete_window)
1469 /* The delete window request specifies a window
1470 * to delete. We don't actually destroy the
1471 * window because "it is only a request". (The
1472 * window might contain vital data that the
1473 * program does not want destroyed). Instead
1474 * the event is passed along to the program,
1475 * which should then destroy the window.
1478 g_message ("delete window:\t\twindow: %ld",
1479 xevent->xclient.window));
1481 event->any.type = GDK_DELETE;
1483 return GDK_FILTER_TRANSLATE;
1485 else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus)
1487 GdkWindow *win = event->any.window;
1488 Window focus_win = GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->focus_window;
1490 XSetInputFocus (GDK_WINDOW_XDISPLAY (win), focus_win,
1491 RevertToParent, xevent->xclient.data.l[1]);
1493 else if ((Atom) xevent->xclient.data.l[0] == gdk_atom_intern ("_NET_WM_PING", FALSE))
1495 XEvent xev = *xevent;
1497 xev.xclient.window = gdk_root_window;
1498 XSendEvent (gdk_display, gdk_root_window, False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
1501 return GDK_FILTER_REMOVE;
1506 gdk_event_get_type (Display *display,
1513 if (gdk_event_translate (&event, xevent, FALSE))
1515 pred = (GdkPredicate*) arg;
1516 return (* pred->func) (&event, pred->data);
1524 gdk_events_queue (void)
1530 while (!gdk_event_queue_find_first() && XPending (gdk_display))
1532 XNextEvent (gdk_display, &xevent);
1534 switch (xevent.type)
1540 if (XFilterEvent (&xevent, None))
1544 event = gdk_event_new ();
1546 event->any.type = GDK_NOTHING;
1547 event->any.window = NULL;
1548 event->any.send_event = xevent.xany.send_event ? TRUE : FALSE;
1550 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1552 gdk_event_queue_append (event);
1553 node = gdk_queued_tail;
1555 if (gdk_event_translate (event, &xevent, FALSE))
1557 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1561 gdk_event_queue_remove_link (node);
1562 g_list_free_1 (node);
1563 gdk_event_free (event);
1569 gdk_event_prepare (GSource *source,
1574 GDK_THREADS_ENTER ();
1578 retval = (gdk_event_queue_find_first () != NULL) || XPending (gdk_display);
1580 GDK_THREADS_LEAVE ();
1586 gdk_event_check (GSource *source)
1590 GDK_THREADS_ENTER ();
1592 if (event_poll_fd.revents & G_IO_IN)
1593 retval = (gdk_event_queue_find_first () != NULL) || XPending (gdk_display);
1597 GDK_THREADS_LEAVE ();
1603 gdk_event_dispatch (GSource *source,
1604 GSourceFunc callback,
1609 GDK_THREADS_ENTER ();
1612 event = gdk_event_unqueue();
1617 (*gdk_event_func) (event, gdk_event_data);
1619 gdk_event_free (event);
1622 GDK_THREADS_LEAVE ();
1627 /* Sends a ClientMessage to all toplevel client windows */
1629 gdk_event_send_client_message (GdkEvent *event, guint32 xid)
1633 g_return_val_if_fail(event != NULL, FALSE);
1635 /* Set up our event to send, with the exception of its target window */
1636 sev.xclient.type = ClientMessage;
1637 sev.xclient.display = gdk_display;
1638 sev.xclient.format = event->client.data_format;
1639 sev.xclient.window = xid;
1640 memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data));
1641 sev.xclient.message_type = event->client.message_type;
1643 return gdk_send_xevent (xid, False, NoEventMask, &sev);
1646 /* Sends a ClientMessage to all toplevel client windows */
1648 gdk_event_send_client_message_to_all_recurse (XEvent *xev,
1652 static GdkAtom wm_state_atom = GDK_NONE;
1655 unsigned long nitems, after;
1656 unsigned char *data;
1657 Window *ret_children, ret_root, ret_parent;
1658 unsigned int ret_nchildren;
1659 gint old_warnings = gdk_error_warnings;
1660 gboolean send = FALSE;
1661 gboolean found = FALSE;
1665 wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
1667 gdk_error_warnings = FALSE;
1669 XGetWindowProperty (gdk_display, xid, wm_state_atom, 0, 0, False, AnyPropertyType,
1670 &type, &format, &nitems, &after, &data);
1674 gdk_error_warnings = old_warnings;
1686 /* OK, we're all set, now let's find some windows to send this to */
1687 if (XQueryTree (gdk_display, xid, &ret_root, &ret_parent,
1688 &ret_children, &ret_nchildren) != True ||
1691 gdk_error_warnings = old_warnings;
1696 for(i = 0; i < ret_nchildren; i++)
1697 if (gdk_event_send_client_message_to_all_recurse (xev, ret_children[i], level + 1))
1700 XFree (ret_children);
1703 if (send || (!found && (level == 1)))
1705 xev->xclient.window = xid;
1706 gdk_send_xevent (xid, False, NoEventMask, xev);
1709 gdk_error_warnings = old_warnings;
1711 return (send || found);
1715 gdk_event_send_clientmessage_toall (GdkEvent *event)
1718 gint old_warnings = gdk_error_warnings;
1720 g_return_if_fail(event != NULL);
1722 /* Set up our event to send, with the exception of its target window */
1723 sev.xclient.type = ClientMessage;
1724 sev.xclient.display = gdk_display;
1725 sev.xclient.format = event->client.data_format;
1726 memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data));
1727 sev.xclient.message_type = event->client.message_type;
1729 gdk_event_send_client_message_to_all_recurse(&sev, gdk_root_window, 0);
1731 gdk_error_warnings = old_warnings;
1735 *--------------------------------------------------------------
1738 * Flushes the Xlib output buffer and then waits
1739 * until all requests have been received and processed
1740 * by the X server. The only real use for this function
1741 * is in dealing with XShm.
1749 *--------------------------------------------------------------
1755 XSync (gdk_display, False);
1758 static GdkAtom timestamp_prop_atom = 0;
1761 timestamp_predicate (Display *display,
1765 Window xwindow = GPOINTER_TO_UINT (arg);
1767 if (xevent->type == PropertyNotify &&
1768 xevent->xproperty.window == xwindow &&
1769 xevent->xproperty.atom == timestamp_prop_atom)
1776 * gdk_x11_get_server_time:
1777 * @window: a #GdkWindow, used for communication with the server.
1778 * The window must have GDK_PROPERTY_CHANGE_MASK in its
1779 * events mask or a hang will result.
1781 * Routine to get the current X server time stamp.
1783 * Return value: the time stamp.
1786 gdk_x11_get_server_time (GdkWindow *window)
1793 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
1794 g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0);
1796 if (!timestamp_prop_atom)
1797 timestamp_prop_atom = gdk_atom_intern ("GDK_TIMESTAMP_PROP", FALSE);
1799 xdisplay = GDK_WINDOW_XDISPLAY (window);
1800 xwindow = GDK_WINDOW_XWINDOW (window);
1802 XChangeProperty (xdisplay, xwindow,
1803 timestamp_prop_atom, timestamp_prop_atom,
1804 8, PropModeReplace, &c, 1);
1806 XIfEvent (xdisplay, &xevent,
1807 timestamp_predicate, GUINT_TO_POINTER(xwindow));
1809 return xevent.xproperty.time;
1814 gdk_net_wm_supports (GdkAtom property)
1816 static GdkAtom wmspec_check_atom = 0;
1817 static GdkAtom wmspec_supported_atom = 0;
1818 static GdkAtom *atoms = NULL;
1819 static gulong n_atoms = 0;
1827 if (wmspec_check_window != None)
1835 if (atoms[i] == property)
1850 /* This function is very slow on every call if you are not running a
1851 * spec-supporting WM. For now not optimized, because it isn't in
1852 * any critical code paths, but if you used it somewhere that had to
1853 * be fast you want to avoid "GTK is slow with old WMs" complaints.
1854 * Probably at that point the function should be changed to query
1855 * _NET_SUPPORTING_WM_CHECK only once every 10 seconds or something.
1858 if (wmspec_check_atom == 0)
1859 wmspec_check_atom = gdk_atom_intern ("_NET_SUPPORTING_WM_CHECK", FALSE);
1861 if (wmspec_supported_atom == 0)
1862 wmspec_supported_atom = gdk_atom_intern ("_NET_SUPPORTED", FALSE);
1864 XGetWindowProperty (gdk_display, gdk_root_window,
1865 wmspec_check_atom, 0, G_MAXLONG,
1866 False, XA_WINDOW, &type, &format, &nitems,
1867 &bytes_after, (guchar **)&xwindow);
1869 if (type != XA_WINDOW)
1872 gdk_error_trap_push ();
1874 /* Find out if this WM goes away, so we can reset everything. */
1875 XSelectInput (gdk_display, *xwindow,
1876 StructureNotifyMask);
1880 if (gdk_error_trap_pop ())
1886 XGetWindowProperty (gdk_display, gdk_root_window,
1887 wmspec_supported_atom, 0, G_MAXLONG,
1888 False, XA_ATOM, &type, &format, &n_atoms,
1889 &bytes_after, (guchar **)&atoms);
1891 if (type != XA_ATOM)
1894 wmspec_check_window = *xwindow;
1897 /* since wmspec_check_window != None this isn't infinite. ;-) */
1898 return gdk_net_wm_supports (property);
1903 const char *xsettings_name;
1904 const char *gdk_name;
1905 } settings_map[] = {
1906 { "Net/DoubleClickTime", "double-click-timeout" },
1907 { "Net/DragThreshold", "drag-threshold" }
1911 gdk_xsettings_notify_cb (const char *name,
1912 XSettingsAction action,
1913 XSettingsSetting *setting,
1919 new_event.type = GDK_SETTING;
1920 new_event.setting.window = NULL;
1921 new_event.setting.send_event = FALSE;
1922 new_event.setting.name = NULL;
1924 for (i = 0; i < G_N_ELEMENTS (settings_map) ; i++)
1925 if (strcmp (settings_map[i].xsettings_name, name) == 0)
1927 new_event.setting.name = g_strdup (settings_map[i].gdk_name);
1931 if (!new_event.setting.name)
1936 case XSETTINGS_ACTION_NEW:
1937 new_event.setting.action = GDK_SETTING_ACTION_NEW;
1939 case XSETTINGS_ACTION_CHANGED:
1940 new_event.setting.action = GDK_SETTING_ACTION_CHANGED;
1942 case XSETTINGS_ACTION_DELETED:
1943 new_event.setting.action = GDK_SETTING_ACTION_DELETED;
1947 gdk_event_put (&new_event);
1951 check_transform (const gchar *xsettings_name,
1955 if (!g_value_type_transformable (src_type, dest_type))
1957 g_warning ("Cannot tranform xsetting %s of type %s to type %s\n",
1959 g_type_name (src_type),
1960 g_type_name (dest_type));
1968 gdk_setting_get (const gchar *name,
1971 const char *xsettings_name = NULL;
1972 XSettingsResult result;
1973 XSettingsSetting *setting;
1974 gboolean success = FALSE;
1977 for (i = 0; i < G_N_ELEMENTS (settings_map) ; i++)
1978 if (strcmp (settings_map[i].gdk_name, name) == 0)
1980 xsettings_name = settings_map[i].xsettings_name;
1984 if (!xsettings_name)
1987 result = xsettings_client_get_setting (xsettings_client, xsettings_name, &setting);
1988 if (result != XSETTINGS_SUCCESS)
1991 switch (setting->type)
1993 case XSETTINGS_TYPE_INT:
1994 if (check_transform (xsettings_name, G_TYPE_INT, G_VALUE_TYPE (value)))
1996 g_value_set_int (value, setting->data.v_int);
2000 case XSETTINGS_TYPE_STRING:
2001 if (check_transform (xsettings_name, G_TYPE_STRING, G_VALUE_TYPE (value)))
2003 g_value_set_string (value, setting->data.v_string);
2007 case XSETTINGS_TYPE_COLOR:
2008 if (!check_transform (xsettings_name, GDK_TYPE_COLOR, G_VALUE_TYPE (value)))
2013 color.red = setting->data.v_color.red;
2014 color.green = setting->data.v_color.green;
2015 color.blue = setting->data.v_color.blue;
2017 g_value_set_boxed (value, &color);
2024 xsettings_setting_free (setting);
2030 gdk_xsettings_client_event_filter (GdkXEvent *xevent,
2034 if (xsettings_client_process_event (xsettings_client, (XEvent *)xevent))
2035 return GDK_FILTER_REMOVE;
2037 return GDK_FILTER_CONTINUE;
2041 gdk_xsettings_watch_cb (Window window,
2048 gdkwin = gdk_window_lookup (window);
2050 gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, NULL);
2052 gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, NULL);