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, see <http://www.gnu.org/licenses/>.
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
26 #error "Only <gdk/gdk.h> can be included directly."
29 #ifndef __GDK_EVENTS_H__
30 #define __GDK_EVENTS_H__
32 #include <gdk/gdkversionmacros.h>
33 #include <gdk/gdkcolor.h>
34 #include <gdk/gdktypes.h>
35 #include <gdk/gdkdnd.h>
36 #include <gdk/gdkdevice.h>
42 * SECTION:event_structs
43 * @Short_description: Data structures specific to each type of event
44 * @Title: Event Structures
46 * The event structs contain data specific to each type of event in GDK.
50 * A common mistake is to forget to set the event mask of a widget so that
51 * the required events are received. See gtk_widget_set_events().
57 #define GDK_TYPE_EVENT (gdk_event_get_type ())
60 * GDK_PRIORITY_EVENTS:
62 * This is the priority that events from the X server are given in the
63 * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
65 #define GDK_PRIORITY_EVENTS (G_PRIORITY_DEFAULT)
68 * GDK_PRIORITY_REDRAW:
70 * This is the priority that the idle handler processing window updates
72 * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
74 #define GDK_PRIORITY_REDRAW (G_PRIORITY_HIGH_IDLE + 20)
77 * GDK_EVENT_PROPAGATE:
79 * Use this macro as the return value for continuing the propagation of
84 #define GDK_EVENT_PROPAGATE (FALSE)
89 * Use this macro as the return value for stopping the propagation of
94 #define GDK_EVENT_STOP (TRUE)
99 * The primary button. This is typically the left mouse button, or the
100 * right button in a left-handed setup.
104 #define GDK_BUTTON_PRIMARY (1)
113 #define GDK_BUTTON_MIDDLE (2)
116 * GDK_BUTTON_SECONDARY:
118 * The secondary button. This is typically the right mouse button, or the
119 * left button in a left-handed setup.
123 #define GDK_BUTTON_SECONDARY (3)
127 typedef struct _GdkEventAny GdkEventAny;
128 typedef struct _GdkEventExpose GdkEventExpose;
129 typedef struct _GdkEventVisibility GdkEventVisibility;
130 typedef struct _GdkEventMotion GdkEventMotion;
131 typedef struct _GdkEventButton GdkEventButton;
132 typedef struct _GdkEventTouch GdkEventTouch;
133 typedef struct _GdkEventScroll GdkEventScroll;
134 typedef struct _GdkEventKey GdkEventKey;
135 typedef struct _GdkEventFocus GdkEventFocus;
136 typedef struct _GdkEventCrossing GdkEventCrossing;
137 typedef struct _GdkEventConfigure GdkEventConfigure;
138 typedef struct _GdkEventProperty GdkEventProperty;
139 typedef struct _GdkEventSelection GdkEventSelection;
140 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
141 typedef struct _GdkEventProximity GdkEventProximity;
142 typedef struct _GdkEventDND GdkEventDND;
143 typedef struct _GdkEventWindowState GdkEventWindowState;
144 typedef struct _GdkEventSetting GdkEventSetting;
145 typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
147 typedef struct _GdkEventSequence GdkEventSequence;
149 typedef union _GdkEvent GdkEvent;
153 * @event: the #GdkEvent to process.
154 * @data: (closure): user data set when the event handler was installed with
155 * gdk_event_handler_set().
157 * Specifies the type of function passed to gdk_event_handler_set() to
158 * handle all GDK events.
160 typedef void (*GdkEventFunc) (GdkEvent *event,
163 /* Event filtering */
168 * Used to represent native events (<type>XEvent</type>s for the X11
169 * backend, <type>MSG</type>s for Win32).
171 typedef void GdkXEvent; /* Can be cast to window system specific
172 * even type, XEvent on X11, MSG on Win32.
177 * @GDK_FILTER_CONTINUE: event not handled, continue processing.
178 * @GDK_FILTER_TRANSLATE: native event translated into a GDK event and stored
179 * in the <literal>event</literal> structure that was passed in.
180 * @GDK_FILTER_REMOVE: event handled, terminate processing.
182 * Specifies the result of applying a #GdkFilterFunc to a native event.
185 GDK_FILTER_CONTINUE, /* Event not handled, continue processesing */
186 GDK_FILTER_TRANSLATE, /* Native event translated into a GDK event and
187 stored in the "event" structure that was
189 GDK_FILTER_REMOVE /* Terminate processing, removing event */
194 * @xevent: the native event to filter.
195 * @event: the GDK event to which the X event will be translated.
196 * @data: user data set when the filter was installed.
198 * Specifies the type of function used to filter native events before they are
199 * converted to GDK events.
201 * When a filter is called, @event is unpopulated, except for
202 * <literal>event->window</literal>. The filter may translate the native
203 * event to a GDK event and store the result in @event, or handle it without
204 * translation. If the filter translates the event and processing should
205 * continue, it should return %GDK_FILTER_TRANSLATE.
207 * Returns: a #GdkFilterReturn value.
209 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
216 * @GDK_NOTHING: a special code to indicate a null event.
217 * @GDK_DELETE: the window manager has requested that the toplevel window be
218 * hidden or destroyed, usually when the user clicks on a special icon in the
220 * @GDK_DESTROY: the window has been destroyed.
221 * @GDK_EXPOSE: all or part of the window has become visible and needs to be
223 * @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
224 * @GDK_BUTTON_PRESS: a mouse button has been pressed.
225 * @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
226 * within a short period of time). Note that each click also generates a
227 * %GDK_BUTTON_PRESS event.
228 * @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
229 * of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
230 * @GDK_BUTTON_RELEASE: a mouse button has been released.
231 * @GDK_KEY_PRESS: a key has been pressed.
232 * @GDK_KEY_RELEASE: a key has been released.
233 * @GDK_ENTER_NOTIFY: the pointer has entered the window.
234 * @GDK_LEAVE_NOTIFY: the pointer has left the window.
235 * @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the window.
236 * @GDK_CONFIGURE: the size, position or stacking order of the window has changed.
237 * Note that GTK+ discards these events for %GDK_WINDOW_CHILD windows.
238 * @GDK_MAP: the window has been mapped.
239 * @GDK_UNMAP: the window has been unmapped.
240 * @GDK_PROPERTY_NOTIFY: a property on the window has been changed or deleted.
241 * @GDK_SELECTION_CLEAR: the application has lost ownership of a selection.
242 * @GDK_SELECTION_REQUEST: another application has requested a selection.
243 * @GDK_SELECTION_NOTIFY: a selection has been received.
244 * @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
245 * surface (e.g. a touchscreen or graphics tablet).
246 * @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
248 * @GDK_DRAG_ENTER: the mouse has entered the window while a drag is in progress.
249 * @GDK_DRAG_LEAVE: the mouse has left the window while a drag is in progress.
250 * @GDK_DRAG_MOTION: the mouse has moved in the window while a drag is in
252 * @GDK_DRAG_STATUS: the status of the drag operation initiated by the window
254 * @GDK_DROP_START: a drop operation onto the window has started.
255 * @GDK_DROP_FINISHED: the drop operation initiated by the window has completed.
256 * @GDK_CLIENT_EVENT: a message has been received from another application.
257 * @GDK_VISIBILITY_NOTIFY: the window visibility status has changed.
258 * @GDK_SCROLL: the scroll wheel was turned
259 * @GDK_WINDOW_STATE: the state of a window has changed. See #GdkWindowState
260 * for the possible window states
261 * @GDK_SETTING: a setting has been modified.
262 * @GDK_OWNER_CHANGE: the owner of a selection has changed. This event type
264 * @GDK_GRAB_BROKEN: a pointer or keyboard grab was broken. This event type
266 * @GDK_DAMAGE: the content of the window has been changed. This event type
268 * @GDK_TOUCH_BEGIN: A new touch event sequence has just started. This event
269 * type was added in 3.4.
270 * @GDK_TOUCH_UPDATE: A touch event sequence has been updated. This event type
272 * @GDK_TOUCH_END: A touch event sequence has finished. This event type
274 * @GDK_TOUCH_CANCEL: A touch event sequence has been canceled. This event type
276 * @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18
278 * Specifies the type of the event.
280 * Do not confuse these events with the signals that GTK+ widgets emit.
281 * Although many of these events result in corresponding signals being emitted,
282 * the events are often transformed or filtered along the way.
290 GDK_MOTION_NOTIFY = 3,
291 GDK_BUTTON_PRESS = 4,
292 GDK_2BUTTON_PRESS = 5,
293 GDK_3BUTTON_PRESS = 6,
294 GDK_BUTTON_RELEASE = 7,
297 GDK_ENTER_NOTIFY = 10,
298 GDK_LEAVE_NOTIFY = 11,
299 GDK_FOCUS_CHANGE = 12,
303 GDK_PROPERTY_NOTIFY = 16,
304 GDK_SELECTION_CLEAR = 17,
305 GDK_SELECTION_REQUEST = 18,
306 GDK_SELECTION_NOTIFY = 19,
307 GDK_PROXIMITY_IN = 20,
308 GDK_PROXIMITY_OUT = 21,
311 GDK_DRAG_MOTION = 24,
312 GDK_DRAG_STATUS = 25,
314 GDK_DROP_FINISHED = 27,
315 GDK_CLIENT_EVENT = 28,
316 GDK_VISIBILITY_NOTIFY = 29,
318 GDK_WINDOW_STATE = 32,
320 GDK_OWNER_CHANGE = 34,
321 GDK_GRAB_BROKEN = 35,
323 GDK_TOUCH_BEGIN = 37,
324 GDK_TOUCH_UPDATE = 38,
326 GDK_TOUCH_CANCEL = 40,
327 GDK_EVENT_LAST /* helper variable for decls */
331 * GdkVisibilityState:
332 * @GDK_VISIBILITY_UNOBSCURED: the window is completely visible.
333 * @GDK_VISIBILITY_PARTIAL: the window is partially visible.
334 * @GDK_VISIBILITY_FULLY_OBSCURED: the window is not visible at all.
336 * Specifies the visiblity status of a window for a #GdkEventVisibility.
340 GDK_VISIBILITY_UNOBSCURED,
341 GDK_VISIBILITY_PARTIAL,
342 GDK_VISIBILITY_FULLY_OBSCURED
343 } GdkVisibilityState;
346 * GdkScrollDirection:
347 * @GDK_SCROLL_UP: the window is scrolled up.
348 * @GDK_SCROLL_DOWN: the window is scrolled down.
349 * @GDK_SCROLL_LEFT: the window is scrolled to the left.
350 * @GDK_SCROLL_RIGHT: the window is scrolled to the right.
351 * @GDK_SCROLL_SMOOTH: the scrolling is determined by the delta values
352 * in #GdkEventScroll. See gdk_event_get_scroll_deltas().
354 * Specifies the direction for #GdkEventScroll.
363 } GdkScrollDirection;
367 * @GDK_NOTIFY_ANCESTOR: the window is entered from an ancestor or
368 * left towards an ancestor.
369 * @GDK_NOTIFY_VIRTUAL: the pointer moves between an ancestor and an
370 * inferior of the window.
371 * @GDK_NOTIFY_INFERIOR: the window is entered from an inferior or
372 * left towards an inferior.
373 * @GDK_NOTIFY_NONLINEAR: the window is entered from or left towards
374 * a window which is neither an ancestor nor an inferior.
375 * @GDK_NOTIFY_NONLINEAR_VIRTUAL: the pointer moves between two windows
376 * which are not ancestors of each other and the window is part of
377 * the ancestor chain between one of these windows and their least
379 * @GDK_NOTIFY_UNKNOWN: an unknown type of enter/leave event occurred.
381 * Specifies the kind of crossing for #GdkEventCrossing.
383 * See the X11 protocol specification of <type>LeaveNotify</type> for
384 * full details of crossing event generation.
388 GDK_NOTIFY_ANCESTOR = 0,
389 GDK_NOTIFY_VIRTUAL = 1,
390 GDK_NOTIFY_INFERIOR = 2,
391 GDK_NOTIFY_NONLINEAR = 3,
392 GDK_NOTIFY_NONLINEAR_VIRTUAL = 4,
393 GDK_NOTIFY_UNKNOWN = 5
398 * @GDK_CROSSING_NORMAL: crossing because of pointer motion.
399 * @GDK_CROSSING_GRAB: crossing because a grab is activated.
400 * @GDK_CROSSING_UNGRAB: crossing because a grab is deactivated.
401 * @GDK_CROSSING_GTK_GRAB: crossing because a GTK+ grab is activated.
402 * @GDK_CROSSING_GTK_UNGRAB: crossing because a GTK+ grab is deactivated.
403 * @GDK_CROSSING_STATE_CHANGED: crossing because a GTK+ widget changed
404 * state (e.g. sensitivity).
405 * @GDK_CROSSING_TOUCH_BEGIN: crossing because a touch sequence has begun,
406 * this event is synthetic as the pointer might have not left the window.
407 * @GDK_CROSSING_TOUCH_END: crossing because a touch sequence has ended,
408 * this event is synthetic as the pointer might have not left the window.
409 * @GDK_CROSSING_DEVICE_SWITCH: crossing because of a device switch (i.e.
410 * a mouse taking control of the pointer after a touch device), this event
411 * is synthetic as the pointer didn't leave the window.
413 * Specifies the crossing mode for #GdkEventCrossing.
420 GDK_CROSSING_GTK_GRAB,
421 GDK_CROSSING_GTK_UNGRAB,
422 GDK_CROSSING_STATE_CHANGED,
423 GDK_CROSSING_TOUCH_BEGIN,
424 GDK_CROSSING_TOUCH_END,
425 GDK_CROSSING_DEVICE_SWITCH
430 * @GDK_PROPERTY_NEW_VALUE: the property value was changed.
431 * @GDK_PROPERTY_DELETE: the property was deleted.
433 * Specifies the type of a property change for a #GdkEventProperty.
437 GDK_PROPERTY_NEW_VALUE,
443 * @GDK_WINDOW_STATE_WITHDRAWN: the window is not shown.
444 * @GDK_WINDOW_STATE_ICONIFIED: the window is minimized.
445 * @GDK_WINDOW_STATE_MAXIMIZED: the window is maximized.
446 * @GDK_WINDOW_STATE_STICKY: the window is sticky.
447 * @GDK_WINDOW_STATE_FULLSCREEN: the window is maximized without
449 * @GDK_WINDOW_STATE_ABOVE: the window is kept above other windows.
450 * @GDK_WINDOW_STATE_BELOW: the window is kept below other windows.
451 * @GDK_WINDOW_STATE_FOCUSED: the window is presented as focused (with active decorations).
453 * Specifies the state of a toplevel window.
457 GDK_WINDOW_STATE_WITHDRAWN = 1 << 0,
458 GDK_WINDOW_STATE_ICONIFIED = 1 << 1,
459 GDK_WINDOW_STATE_MAXIMIZED = 1 << 2,
460 GDK_WINDOW_STATE_STICKY = 1 << 3,
461 GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
462 GDK_WINDOW_STATE_ABOVE = 1 << 5,
463 GDK_WINDOW_STATE_BELOW = 1 << 6,
464 GDK_WINDOW_STATE_FOCUSED = 1 << 7
469 * @GDK_SETTING_ACTION_NEW: a setting was added.
470 * @GDK_SETTING_ACTION_CHANGED: a setting was changed.
471 * @GDK_SETTING_ACTION_DELETED: a setting was deleted.
473 * Specifies the kind of modification applied to a setting in a
478 GDK_SETTING_ACTION_NEW,
479 GDK_SETTING_ACTION_CHANGED,
480 GDK_SETTING_ACTION_DELETED
485 * @GDK_OWNER_CHANGE_NEW_OWNER: some other app claimed the ownership
486 * @GDK_OWNER_CHANGE_DESTROY: the window was destroyed
487 * @GDK_OWNER_CHANGE_CLOSE: the client was closed
489 * Specifies why a selection ownership was changed.
493 GDK_OWNER_CHANGE_NEW_OWNER,
494 GDK_OWNER_CHANGE_DESTROY,
495 GDK_OWNER_CHANGE_CLOSE
500 * @type: the type of the event.
501 * @window: the window which received the event.
502 * @send_event: %TRUE if the event was sent explicitly (e.g. using
503 * <function>XSendEvent</function>).
505 * Contains the fields which are common to all event structs.
506 * Any event pointer can safely be cast to a pointer to a #GdkEventAny to
507 * access these fields.
518 * @type: the type of the event (%GDK_EXPOSE or %GDK_DAMAGE).
519 * @window: the window which received the event.
520 * @send_event: %TRUE if the event was sent explicitly (e.g. using
521 * <function>XSendEvent</function>).
522 * @area: bounding box of @region.
523 * @region: the region that needs to be redrawn.
524 * @count: the number of contiguous %GDK_EXPOSE events following this one.
525 * The only use for this is "exposure compression", i.e. handling all
526 * contiguous %GDK_EXPOSE events in one go, though GDK performs some
527 * exposure compression so this is not normally needed.
529 * Generated when all or part of a window becomes visible and needs to be
532 struct _GdkEventExpose
538 cairo_region_t *region;
539 gint count; /* If non-zero, how many more events follow. */
543 * GdkEventVisibility:
544 * @type: the type of the event (%GDK_VISIBILITY_NOTIFY).
545 * @window: the window which received the event.
546 * @send_event: %TRUE if the event was sent explicitly (e.g. using
547 * <function>XSendEvent</function>).
548 * @state: the new visibility state (%GDK_VISIBILITY_FULLY_OBSCURED,
549 * %GDK_VISIBILITY_PARTIAL or %GDK_VISIBILITY_UNOBSCURED).
551 * Generated when the window visibility status has changed.
553 struct _GdkEventVisibility
558 GdkVisibilityState state;
563 * @type: the type of the event.
564 * @window: the window which received the event.
565 * @send_event: %TRUE if the event was sent explicitly (e.g. using
566 * <function>XSendEvent</function>).
567 * @time: the time of the event in milliseconds.
568 * @x: the x coordinate of the pointer relative to the window.
569 * @y: the y coordinate of the pointer relative to the window.
570 * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
572 * @state: (type GdkModifierType): a bit-mask representing the state of
573 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
574 * buttons. See #GdkModifierType.
575 * @is_hint: set to 1 if this event is just a hint, see the
576 * %GDK_POINTER_MOTION_HINT_MASK value of #GdkEventMask.
577 * @device: the device where the event originated.
578 * @x_root: the x coordinate of the pointer relative to the root of the
580 * @y_root: the y coordinate of the pointer relative to the root of the
583 * Generated when the pointer moves.
585 struct _GdkEventMotion
597 gdouble x_root, y_root;
602 * @type: the type of the event (%GDK_BUTTON_PRESS, %GDK_2BUTTON_PRESS,
603 * %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE).
604 * @window: the window which received the event.
605 * @send_event: %TRUE if the event was sent explicitly (e.g. using
606 * <function>XSendEvent</function>).
607 * @time: the time of the event in milliseconds.
608 * @x: the x coordinate of the pointer relative to the window.
609 * @y: the y coordinate of the pointer relative to the window.
610 * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
612 * @state: (type GdkModifierType): a bit-mask representing the state of
613 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
614 * buttons. See #GdkModifierType.
615 * @button: the button which was pressed or released, numbered from 1 to 5.
616 * Normally button 1 is the left mouse button, 2 is the middle button,
617 * and 3 is the right button. On 2-button mice, the middle button can
618 * often be simulated by pressing both mouse buttons together.
619 * @device: the device where the event originated.
620 * @x_root: the x coordinate of the pointer relative to the root of the
622 * @y_root: the y coordinate of the pointer relative to the root of the
625 * Used for button press and button release events. The
626 * @type field will be one of %GDK_BUTTON_PRESS,
627 * %GDK_2BUTTON_PRESS, %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE,
629 * Double and triple-clicks result in a sequence of events being received.
630 * For double-clicks the order of events will be:
632 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
633 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
634 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
635 * <listitem><para>%GDK_2BUTTON_PRESS</para></listitem>
636 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
638 * Note that the first click is received just like a normal
639 * button press, while the second click results in a %GDK_2BUTTON_PRESS
640 * being received just after the %GDK_BUTTON_PRESS.
642 * Triple-clicks are very similar to double-clicks, except that
643 * %GDK_3BUTTON_PRESS is inserted after the third click. The order of the
646 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
647 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
648 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
649 * <listitem><para>%GDK_2BUTTON_PRESS</para></listitem>
650 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
651 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
652 * <listitem><para>%GDK_3BUTTON_PRESS</para></listitem>
653 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
656 * For a double click to occur, the second button press must occur within
657 * 1/4 of a second of the first. For a triple click to occur, the third
658 * button press must also occur within 1/2 second of the first button press.
660 struct _GdkEventButton
672 gdouble x_root, y_root;
677 * @type: the type of the event (%GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
678 * %GDK_TOUCH_END, %GDK_TOUCH_CANCEL)
679 * @window: the window which received the event
680 * @send_event: %TRUE if the event was sent explicitly (e.g. using
681 * <function>XSendEvent</function>)
682 * @time: the time of the event in milliseconds.
683 * @x: the x coordinate of the pointer relative to the window
684 * @y: the y coordinate of the pointer relative to the window
685 * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
687 * @state: (type GdkModifierType): a bit-mask representing the state of
688 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
689 * buttons. See #GdkModifierType
690 * @sequence: the event sequence that the event belongs to
691 * @emulating_pointer: whether the event should be used for emulating
693 * @device: the device where the event originated
694 * @x_root: the x coordinate of the pointer relative to the root of the
696 * @y_root: the y coordinate of the pointer relative to the root of the
699 * Used for touch events.
700 * @type field will be one of %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
701 * %GDK_TOUCH_END or %GDK_TOUCH_CANCEL.
703 * Touch events are grouped into sequences by means of the @sequence
704 * field, which can also be obtained with gdk_event_get_event_sequence().
705 * Each sequence begins with a %GDK_TOUCH_BEGIN event, followed by
706 * any number of %GDK_TOUCH_UPDATE events, and ends with a %GDK_TOUCH_END
707 * (or %GDK_TOUCH_CANCEL) event. With multitouch devices, there may be
708 * several active sequences at the same time.
710 struct _GdkEventTouch
720 GdkEventSequence *sequence;
721 gboolean emulating_pointer;
723 gdouble x_root, y_root;
728 * @type: the type of the event (%GDK_SCROLL).
729 * @window: the window which received the event.
730 * @send_event: %TRUE if the event was sent explicitly (e.g. using
731 * <function>XSendEvent</function>).
732 * @time: the time of the event in milliseconds.
733 * @x: the x coordinate of the pointer relative to the window.
734 * @y: the y coordinate of the pointer relative to the window.
735 * @state: (type GdkModifierType): a bit-mask representing the state of
736 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
737 * buttons. See #GdkModifierType.
738 * @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
739 * %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT and %GDK_SCROLL_RIGHT).
740 * @device: the device where the event originated.
741 * @x_root: the x coordinate of the pointer relative to the root of the
743 * @y_root: the y coordinate of the pointer relative to the root of the
746 * Generated from button presses for the buttons 4 to 7. Wheel mice are
747 * usually configured to generate button press events for buttons 4 and 5
748 * when the wheel is turned.
750 struct _GdkEventScroll
759 GdkScrollDirection direction;
761 gdouble x_root, y_root;
768 * @type: the type of the event (%GDK_KEY_PRESS or %GDK_KEY_RELEASE).
769 * @window: the window which received the event.
770 * @send_event: %TRUE if the event was sent explicitly (e.g. using
771 * <function>XSendEvent</function>).
772 * @time: the time of the event in milliseconds.
773 * @state: (type GdkModifierType): a bit-mask representing the state of
774 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
775 * buttons. See #GdkModifierType.
776 * @keyval: the key that was pressed or released. See the
777 * <filename><gdk/gdkkeysyms.h></filename> header file for a
778 * complete list of GDK key codes.
779 * @length: the length of @string.
780 * @string: a string containing the an approximation of the text that
781 * would result from this keypress. The only correct way to handle text
782 * input of text is using input methods (see #GtkIMContext), so this
783 * field is deprecated and should never be used.
784 * (gdk_unicode_to_keyval() provides a non-deprecated way of getting
785 * an approximate translation for a key.) The string is encoded in the
786 * encoding of the current locale (Note: this for backwards compatibility:
787 * strings in GTK+ and GDK are typically in UTF-8.) and NUL-terminated.
788 * In some cases, the translation of the key code will be a single
789 * NUL byte, in which case looking at @length is necessary to distinguish
790 * it from the an empty translation.
791 * @hardware_keycode: the raw code of the key that was pressed or released.
792 * @group: the keyboard group.
793 * @is_modifier: a flag that indicates if @hardware_keycode is mapped to a
794 * modifier. Since 2.10
796 * Describes a key press or key release event.
808 guint16 hardware_keycode;
810 guint is_modifier : 1;
815 * @type: the type of the event (%GDK_ENTER_NOTIFY or %GDK_LEAVE_NOTIFY).
816 * @window: the window which received the event.
817 * @send_event: %TRUE if the event was sent explicitly (e.g. using
818 * <function>XSendEvent</function>).
819 * @subwindow: the window that was entered or left.
820 * @time: the time of the event in milliseconds.
821 * @x: the x coordinate of the pointer relative to the window.
822 * @y: the y coordinate of the pointer relative to the window.
823 * @x_root: the x coordinate of the pointer relative to the root of the screen.
824 * @y_root: the y coordinate of the pointer relative to the root of the screen.
825 * @mode: the crossing mode (%GDK_CROSSING_NORMAL, %GDK_CROSSING_GRAB,
826 * %GDK_CROSSING_UNGRAB, %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB or
827 * %GDK_CROSSING_STATE_CHANGED). %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB,
828 * and %GDK_CROSSING_STATE_CHANGED were added in 2.14 and are always synthesized,
830 * @detail: the kind of crossing that happened (%GDK_NOTIFY_INFERIOR,
831 * %GDK_NOTIFY_ANCESTOR, %GDK_NOTIFY_VIRTUAL, %GDK_NOTIFY_NONLINEAR or
832 * %GDK_NOTIFY_NONLINEAR_VIRTUAL).
833 * @focus: %TRUE if @window is the focus window or an inferior.
834 * @state: (type GdkModifierType): a bit-mask representing the state of
835 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
836 * buttons. See #GdkModifierType.
838 * Generated when the pointer enters or leaves a window.
840 struct _GdkEventCrossing
845 GdkWindow *subwindow;
851 GdkCrossingMode mode;
852 GdkNotifyType detail;
859 * @type: the type of the event (%GDK_FOCUS_CHANGE).
860 * @window: the window which received the event.
861 * @send_event: %TRUE if the event was sent explicitly (e.g. using
862 * <function>XSendEvent</function>).
863 * @in: %TRUE if the window has gained the keyboard focus, %FALSE if
864 * it has lost the focus.
866 * Describes a change of keyboard focus.
868 struct _GdkEventFocus
878 * @type: the type of the event (%GDK_CONFIGURE).
879 * @window: the window which received the event.
880 * @send_event: %TRUE if the event was sent explicitly (e.g. using
881 * <function>XSendEvent</function>).
882 * @x: the new x coordinate of the window, relative to its parent.
883 * @y: the new y coordinate of the window, relative to its parent.
884 * @width: the new width of the window.
885 * @height: the new height of the window.
887 * Generated when a window size or position has changed.
889 struct _GdkEventConfigure
901 * @type: the type of the event (%GDK_PROPERTY_NOTIFY).
902 * @window: the window which received the event.
903 * @send_event: %TRUE if the event was sent explicitly (e.g. using
904 * <function>XSendEvent</function>).
905 * @atom: the property that was changed.
906 * @time: the time of the event in milliseconds.
907 * @state: whether the property was changed (%GDK_PROPERTY_NEW_VALUE) or
908 * deleted (%GDK_PROPERTY_DELETE).
910 * Describes a property change on a window.
912 struct _GdkEventProperty
924 * @type: the type of the event (%GDK_SELECTION_CLEAR,
925 * %GDK_SELECTION_NOTIFY or %GDK_SELECTION_REQUEST).
926 * @window: the window which received the event.
927 * @send_event: %TRUE if the event was sent explicitly (e.g. using
928 * <function>XSendEvent</function>).
929 * @selection: the selection.
930 * @target: the target to which the selection should be converted.
931 * @property: the property in which to place the result of the conversion.
932 * @time: the time of the event in milliseconds.
933 * @requestor: the window on which to place @property or %NULL if none.
935 * Generated when a selection is requested or ownership of a selection
936 * is taken over by another client application.
938 struct _GdkEventSelection
947 GdkWindow *requestor;
951 * GdkEventOwnerChange:
952 * @type: the type of the event (%GDK_OWNER_CHANGE).
953 * @window: the window which received the event
954 * @send_event: %TRUE if the event was sent explicitly (e.g. using
955 * <function>XSendEvent</function>)
956 * @owner: the new owner of the selection, or %NULL if there is none
957 * @reason: the reason for the ownership change as a #GdkOwnerChange value
958 * @selection: the atom identifying the selection
959 * @time: the timestamp of the event
960 * @selection_time: the time at which the selection ownership was taken
963 * Generated when the owner of a selection changes. On X11, this
964 * information is only available if the X server supports the XFIXES
969 struct _GdkEventOwnerChange
975 GdkOwnerChange reason;
978 guint32 selection_time;
983 * @type: the type of the event (%GDK_PROXIMITY_IN or %GDK_PROXIMITY_OUT).
984 * @window: the window which received the event.
985 * @send_event: %TRUE if the event was sent explicitly (e.g. using <function>XSendEvent</function>).
986 * @time: the time of the event in milliseconds.
987 * @device: the device where the event originated.
989 * Proximity events are generated when using GDK's wrapper for the
990 * XInput extension. The XInput extension is an add-on for standard X
991 * that allows you to use nonstandard devices such as graphics tablets.
992 * A proximity event indicates that the stylus has moved in or out of
993 * contact with the tablet, or perhaps that the user's finger has moved
994 * in or out of contact with a touch screen.
996 * This event type will be used pretty rarely. It only is important for
997 * XInput aware programs that are drawing their own cursor.
999 struct _GdkEventProximity
1010 * @type: the type of the event (%GDK_SETTING).
1011 * @window: the window which received the event.
1012 * @send_event: %TRUE if the event was sent explicitly (e.g. using
1013 * <function>XSendEvent</function>).
1014 * @action: what happened to the setting (%GDK_SETTING_ACTION_NEW,
1015 * %GDK_SETTING_ACTION_CHANGED or %GDK_SETTING_ACTION_DELETED).
1016 * @name: the name of the setting.
1018 * Generated when a setting is modified.
1020 struct _GdkEventSetting
1025 GdkSettingAction action;
1030 * GdkEventWindowState:
1031 * @type: the type of the event (%GDK_WINDOW_STATE).
1032 * @window: the window which received the event.
1033 * @send_event: %TRUE if the event was sent explicitly (e.g. using
1034 * <function>XSendEvent</function>).
1035 * @changed_mask: mask specifying what flags have changed.
1036 * @new_window_state: the new window state, a combination of
1037 * #GdkWindowState bits.
1039 * Generated when the state of a toplevel window changes.
1041 struct _GdkEventWindowState
1046 GdkWindowState changed_mask;
1047 GdkWindowState new_window_state;
1051 * GdkEventGrabBroken:
1052 * @type: the type of the event (%GDK_GRAB_BROKEN)
1053 * @window: the window which received the event, i.e. the window
1054 * that previously owned the grab
1055 * @send_event: %TRUE if the event was sent explicitly (e.g. using
1056 * <function>XSendEvent</function>).
1057 * @keyboard: %TRUE if a keyboard grab was broken, %FALSE if a pointer
1059 * @implicit: %TRUE if the broken grab was implicit
1060 * @grab_window: If this event is caused by another grab in the same
1061 * application, @grab_window contains the new grab window. Otherwise
1062 * @grab_window is %NULL.
1064 * Generated when a pointer or keyboard grab is broken. On X11, this happens
1065 * when the grab window becomes unviewable (i.e. it or one of its ancestors
1066 * is unmapped), or if the same application grabs the pointer or keyboard
1067 * again. Note that implicit grabs (which are initiated by button presses)
1068 * can also cause #GdkEventGrabBroken events.
1072 struct _GdkEventGrabBroken {
1078 GdkWindow *grab_window;
1083 * @type: the type of the event (%GDK_DRAG_ENTER, %GDK_DRAG_LEAVE,
1084 * %GDK_DRAG_MOTION, %GDK_DRAG_STATUS, %GDK_DROP_START or
1085 * %GDK_DROP_FINISHED).
1086 * @window: the window which received the event.
1087 * @send_event: %TRUE if the event was sent explicitly (e.g. using
1088 * <function>XSendEvent</function>).
1089 * @context: the #GdkDragContext for the current DND operation.
1090 * @time: the time of the event in milliseconds.
1091 * @x_root: the x coordinate of the pointer relative to the root of the
1092 * screen, only set for %GDK_DRAG_MOTION and %GDK_DROP_START.
1093 * @y_root: the y coordinate of the pointer relative to the root of the
1094 * screen, only set for %GDK_DRAG_MOTION and %GDK_DROP_START.
1096 * Generated during DND operations.
1098 struct _GdkEventDND {
1102 GdkDragContext *context;
1105 gshort x_root, y_root;
1111 * The #GdkEvent struct contains a union of all of the event structs,
1112 * and allows access to the data fields in a number of ways.
1114 * The event type is always the first field in all of the event structs, and
1115 * can always be accessed with the following code, no matter what type of
1120 * GdkEventType type;
1122 * type = event->type;
1124 * </informalexample>
1126 * To access other fields of the event structs, the pointer to the event
1127 * can be cast to the appropriate event struct pointer, or the union member
1128 * name can be used. For example if the event type is %GDK_BUTTON_PRESS
1129 * then the x coordinate of the button press can be accessed with:
1135 * x = ((GdkEventButton*)event)->x;
1137 * </informalexample>
1144 * x = event->button.x;
1146 * </informalexample>
1152 GdkEventExpose expose;
1153 GdkEventVisibility visibility;
1154 GdkEventMotion motion;
1155 GdkEventButton button;
1156 GdkEventTouch touch;
1157 GdkEventScroll scroll;
1159 GdkEventCrossing crossing;
1160 GdkEventFocus focus_change;
1161 GdkEventConfigure configure;
1162 GdkEventProperty property;
1163 GdkEventSelection selection;
1164 GdkEventOwnerChange owner_change;
1165 GdkEventProximity proximity;
1167 GdkEventWindowState window_state;
1168 GdkEventSetting setting;
1169 GdkEventGrabBroken grab_broken;
1172 GType gdk_event_get_type (void) G_GNUC_CONST;
1174 gboolean gdk_events_pending (void);
1175 GdkEvent* gdk_event_get (void);
1177 GdkEvent* gdk_event_peek (void);
1178 void gdk_event_put (const GdkEvent *event);
1180 GdkEvent* gdk_event_new (GdkEventType type);
1181 GdkEvent* gdk_event_copy (const GdkEvent *event);
1182 void gdk_event_free (GdkEvent *event);
1184 guint32 gdk_event_get_time (const GdkEvent *event);
1185 gboolean gdk_event_get_state (const GdkEvent *event,
1186 GdkModifierType *state);
1187 gboolean gdk_event_get_coords (const GdkEvent *event,
1190 gboolean gdk_event_get_root_coords (const GdkEvent *event,
1193 GDK_AVAILABLE_IN_3_2
1194 gboolean gdk_event_get_button (const GdkEvent *event,
1196 GDK_AVAILABLE_IN_3_2
1197 gboolean gdk_event_get_click_count (const GdkEvent *event,
1198 guint *click_count);
1199 GDK_AVAILABLE_IN_3_2
1200 gboolean gdk_event_get_keyval (const GdkEvent *event,
1202 GDK_AVAILABLE_IN_3_2
1203 gboolean gdk_event_get_keycode (const GdkEvent *event,
1205 GDK_AVAILABLE_IN_3_2
1206 gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
1207 GdkScrollDirection *direction);
1208 GDK_AVAILABLE_IN_3_4
1209 gboolean gdk_event_get_scroll_deltas (const GdkEvent *event,
1213 gboolean gdk_event_get_axis (const GdkEvent *event,
1214 GdkAxisUse axis_use,
1216 void gdk_event_set_device (GdkEvent *event,
1218 GdkDevice* gdk_event_get_device (const GdkEvent *event);
1219 void gdk_event_set_source_device (GdkEvent *event,
1221 GdkDevice* gdk_event_get_source_device (const GdkEvent *event);
1222 void gdk_event_request_motions (const GdkEventMotion *event);
1223 GDK_AVAILABLE_IN_3_4
1224 gboolean gdk_event_triggers_context_menu (const GdkEvent *event);
1226 gboolean gdk_events_get_distance (GdkEvent *event1,
1229 gboolean gdk_events_get_angle (GdkEvent *event1,
1232 gboolean gdk_events_get_center (GdkEvent *event1,
1237 void gdk_event_handler_set (GdkEventFunc func,
1239 GDestroyNotify notify);
1241 void gdk_event_set_screen (GdkEvent *event,
1243 GdkScreen *gdk_event_get_screen (const GdkEvent *event);
1245 GDK_AVAILABLE_IN_3_4
1246 GdkEventSequence *gdk_event_get_event_sequence (const GdkEvent *event);
1248 void gdk_set_show_events (gboolean show_events);
1249 gboolean gdk_get_show_events (void);
1251 #ifndef GDK_MULTIHEAD_SAFE
1253 gboolean gdk_setting_get (const gchar *name,
1256 #endif /* GDK_MULTIHEAD_SAFE */
1260 #endif /* __GDK_EVENTS_H__ */