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/.
27 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
28 #error "Only <gdk/gdk.h> can be included directly."
31 #ifndef __GDK_EVENTS_H__
32 #define __GDK_EVENTS_H__
34 #include <gdk/gdkcolor.h>
35 #include <gdk/gdktypes.h>
36 #include <gdk/gdkdnd.h>
37 #include <gdk/gdkdevice.h>
41 #define GDK_TYPE_EVENT (gdk_event_get_type ())
44 * GDK_PRIORITY_EVENTS:
46 * This is the priority that events from the X server are given in the
47 * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
49 #define GDK_PRIORITY_EVENTS (G_PRIORITY_DEFAULT)
52 * GDK_PRIORITY_REDRAW:
54 * This is the priority that the idle handler processing window updates
56 * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
58 #define GDK_PRIORITY_REDRAW (G_PRIORITY_HIGH_IDLE + 20)
61 typedef struct _GdkEventAny GdkEventAny;
62 typedef struct _GdkEventExpose GdkEventExpose;
63 typedef struct _GdkEventNoExpose GdkEventNoExpose;
64 typedef struct _GdkEventVisibility GdkEventVisibility;
65 typedef struct _GdkEventMotion GdkEventMotion;
66 typedef struct _GdkEventButton GdkEventButton;
67 typedef struct _GdkEventScroll GdkEventScroll;
68 typedef struct _GdkEventKey GdkEventKey;
69 typedef struct _GdkEventFocus GdkEventFocus;
70 typedef struct _GdkEventCrossing GdkEventCrossing;
71 typedef struct _GdkEventConfigure GdkEventConfigure;
72 typedef struct _GdkEventProperty GdkEventProperty;
73 typedef struct _GdkEventSelection GdkEventSelection;
74 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
75 typedef struct _GdkEventProximity GdkEventProximity;
76 typedef struct _GdkEventClient GdkEventClient;
77 typedef struct _GdkEventDND GdkEventDND;
78 typedef struct _GdkEventWindowState GdkEventWindowState;
79 typedef struct _GdkEventSetting GdkEventSetting;
80 typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
82 typedef union _GdkEvent GdkEvent;
86 * @event: the #GdkEvent to process.
87 * @data: user data set when the event handler was installed with
88 * gdk_event_handler_set().
90 * Specifies the type of function passed to gdk_event_handler_set() to
91 * handle all GDK events.
93 typedef void (*GdkEventFunc) (GdkEvent *event,
101 * Used to represent native events (<type>XEvent</type>s for the X11
102 * backend, <type>MSG</type>s for Win32).
104 typedef void GdkXEvent; /* Can be cast to window system specific
105 * even type, XEvent on X11, MSG on Win32.
110 * @GDK_FILTER_CONTINUE: event not handled, continue processing.
111 * @GDK_FILTER_TRANSLATE: native event translated into a GDK event and stored
112 * in the <literal>event</literal> structure that was passed in.
113 * @GDK_FILTER_REMOVE: event handled, terminate processing.
115 * Specifies the result of applying a #GdkFilterFunc to a native event.
118 GDK_FILTER_CONTINUE, /* Event not handled, continue processesing */
119 GDK_FILTER_TRANSLATE, /* Native event translated into a GDK event and
120 stored in the "event" structure that was
122 GDK_FILTER_REMOVE /* Terminate processing, removing event */
127 * @xevent: the native event to filter.
128 * @event: the GDK event to which the X event will be translated.
129 * @data: user data set when the filter was installed.
131 * Specifies the type of function used to filter native events before they are
132 * converted to GDK events.
134 * When a filter is called, @event is unpopulated, except for
135 * <literal>event->window</literal>. The filter may translate the native
136 * event to a GDK event and store the result in @event, or handle it without
137 * translation. If the filter translates the event and processing should
138 * continue, it should return %GDK_FILTER_TRANSLATE.
140 * Returns: a #GdkFilterReturn value.
142 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
149 * @GDK_NOTHING: a special code to indicate a null event.
150 * @GDK_DELETE: the window manager has requested that the toplevel window be
151 * hidden or destroyed, usually when the user clicks on a special icon in the
153 * @GDK_DESTROY: the window has been destroyed.
154 * @GDK_EXPOSE: all or part of the window has become visible and needs to be
156 * @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
157 * @GDK_BUTTON_PRESS: a mouse button has been pressed.
158 * @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
159 * within a short period of time). Note that each click also generates a
160 * %GDK_BUTTON_PRESS event.
161 * @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
162 * of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
163 * @GDK_BUTTON_RELEASE: a mouse button has been released.
164 * @GDK_KEY_PRESS: a key has been pressed.
165 * @GDK_KEY_RELEASE: a key has been released.
166 * @GDK_ENTER_NOTIFY: the pointer has entered the window.
167 * @GDK_LEAVE_NOTIFY: the pointer has left the window.
168 * @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the window.
169 * @GDK_CONFIGURE: the size, position or stacking order of the window has changed.
170 * Note that GTK+ discards these events for %GDK_WINDOW_CHILD windows.
171 * @GDK_MAP: the window has been mapped.
172 * @GDK_UNMAP: the window has been unmapped.
173 * @GDK_PROPERTY_NOTIFY: a property on the window has been changed or deleted.
174 * @GDK_SELECTION_CLEAR: the application has lost ownership of a selection.
175 * @GDK_SELECTION_REQUEST: another application has requested a selection.
176 * @GDK_SELECTION_NOTIFY: a selection has been received.
177 * @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
178 * surface (e.g. a touchscreen or graphics tablet).
179 * @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
181 * @GDK_DRAG_ENTER: the mouse has entered the window while a drag is in progress.
182 * @GDK_DRAG_LEAVE: the mouse has left the window while a drag is in progress.
183 * @GDK_DRAG_MOTION: the mouse has moved in the window while a drag is in
185 * @GDK_DRAG_STATUS: the status of the drag operation initiated by the window
187 * @GDK_DROP_START: a drop operation onto the window has started.
188 * @GDK_DROP_FINISHED: the drop operation initiated by the window has completed.
189 * @GDK_CLIENT_EVENT: a message has been received from another application.
190 * @GDK_VISIBILITY_NOTIFY: the window visibility status has changed.
191 * @GDK_NO_EXPOSE: indicates that the source region was completely available
192 * when parts of a drawable were copied. This is not very useful.
193 * @GDK_SCROLL: the scroll wheel was turned
194 * @GDK_WINDOW_STATE: the state of a window has changed. See #GdkWindowState
195 * for the possible window states
196 * @GDK_SETTING: a setting has been modified.
197 * @GDK_OWNER_CHANGE: the owner of a selection has changed. This event type
199 * @GDK_GRAB_BROKEN: a pointer or keyboard grab was broken. This event type
201 * @GDK_DAMAGE: the content of the window has been changed. This event type
203 * @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18
205 * Specifies the type of the event.
207 * Do not confuse these events with the signals that GTK+ widgets emit.
208 * Although many of these events result in corresponding signals being emitted,
209 * the events are often transformed or filtered along the way.
217 GDK_MOTION_NOTIFY = 3,
218 GDK_BUTTON_PRESS = 4,
219 GDK_2BUTTON_PRESS = 5,
220 GDK_3BUTTON_PRESS = 6,
221 GDK_BUTTON_RELEASE = 7,
224 GDK_ENTER_NOTIFY = 10,
225 GDK_LEAVE_NOTIFY = 11,
226 GDK_FOCUS_CHANGE = 12,
230 GDK_PROPERTY_NOTIFY = 16,
231 GDK_SELECTION_CLEAR = 17,
232 GDK_SELECTION_REQUEST = 18,
233 GDK_SELECTION_NOTIFY = 19,
234 GDK_PROXIMITY_IN = 20,
235 GDK_PROXIMITY_OUT = 21,
238 GDK_DRAG_MOTION = 24,
239 GDK_DRAG_STATUS = 25,
241 GDK_DROP_FINISHED = 27,
242 GDK_CLIENT_EVENT = 28,
243 GDK_VISIBILITY_NOTIFY = 29,
246 GDK_WINDOW_STATE = 32,
248 GDK_OWNER_CHANGE = 34,
249 GDK_GRAB_BROKEN = 35,
251 GDK_EVENT_LAST /* helper variable for decls */
256 GDK_VISIBILITY_UNOBSCURED,
257 GDK_VISIBILITY_PARTIAL,
258 GDK_VISIBILITY_FULLY_OBSCURED
259 } GdkVisibilityState;
267 } GdkScrollDirection;
269 /* Types of enter/leave notifications.
275 * Unknown: An unknown type of enter/leave event occurred.
279 GDK_NOTIFY_ANCESTOR = 0,
280 GDK_NOTIFY_VIRTUAL = 1,
281 GDK_NOTIFY_INFERIOR = 2,
282 GDK_NOTIFY_NONLINEAR = 3,
283 GDK_NOTIFY_NONLINEAR_VIRTUAL = 4,
284 GDK_NOTIFY_UNKNOWN = 5
287 /* Enter/leave event modes.
297 GDK_CROSSING_GTK_GRAB,
298 GDK_CROSSING_GTK_UNGRAB,
299 GDK_CROSSING_STATE_CHANGED
304 GDK_PROPERTY_NEW_VALUE,
310 GDK_WINDOW_STATE_WITHDRAWN = 1 << 0,
311 GDK_WINDOW_STATE_ICONIFIED = 1 << 1,
312 GDK_WINDOW_STATE_MAXIMIZED = 1 << 2,
313 GDK_WINDOW_STATE_STICKY = 1 << 3,
314 GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
315 GDK_WINDOW_STATE_ABOVE = 1 << 5,
316 GDK_WINDOW_STATE_BELOW = 1 << 6
321 GDK_SETTING_ACTION_NEW,
322 GDK_SETTING_ACTION_CHANGED,
323 GDK_SETTING_ACTION_DELETED
328 GDK_OWNER_CHANGE_NEW_OWNER,
329 GDK_OWNER_CHANGE_DESTROY,
330 GDK_OWNER_CHANGE_CLOSE
340 struct _GdkEventExpose
346 cairo_region_t *region;
347 gint count; /* If non-zero, how many more events follow. */
350 struct _GdkEventNoExpose
357 struct _GdkEventVisibility
362 GdkVisibilityState state;
365 struct _GdkEventMotion
377 gdouble x_root, y_root;
380 struct _GdkEventButton
392 gdouble x_root, y_root;
395 struct _GdkEventScroll
404 GdkScrollDirection direction;
406 gdouble x_root, y_root;
419 guint16 hardware_keycode;
421 guint is_modifier : 1;
424 struct _GdkEventCrossing
429 GdkWindow *subwindow;
435 GdkCrossingMode mode;
436 GdkNotifyType detail;
441 struct _GdkEventFocus
449 struct _GdkEventConfigure
459 struct _GdkEventProperty
469 struct _GdkEventSelection
478 GdkNativeWindow requestor;
481 struct _GdkEventOwnerChange
486 GdkNativeWindow owner;
487 GdkOwnerChange reason;
490 guint32 selection_time;
493 /* This event type will be used pretty rarely. It only is important
494 for XInput aware programs that are drawing their own cursor */
496 struct _GdkEventProximity
505 struct _GdkEventClient
510 GdkAtom message_type;
519 struct _GdkEventSetting
524 GdkSettingAction action;
528 struct _GdkEventWindowState
533 GdkWindowState changed_mask;
534 GdkWindowState new_window_state;
537 struct _GdkEventGrabBroken {
543 GdkWindow *grab_window;
546 /* Event types for DND */
548 struct _GdkEventDND {
552 GdkDragContext *context;
555 gshort x_root, y_root;
562 GdkEventExpose expose;
563 GdkEventNoExpose no_expose;
564 GdkEventVisibility visibility;
565 GdkEventMotion motion;
566 GdkEventButton button;
567 GdkEventScroll scroll;
569 GdkEventCrossing crossing;
570 GdkEventFocus focus_change;
571 GdkEventConfigure configure;
572 GdkEventProperty property;
573 GdkEventSelection selection;
574 GdkEventOwnerChange owner_change;
575 GdkEventProximity proximity;
576 GdkEventClient client;
578 GdkEventWindowState window_state;
579 GdkEventSetting setting;
580 GdkEventGrabBroken grab_broken;
583 GType gdk_event_get_type (void) G_GNUC_CONST;
585 gboolean gdk_events_pending (void);
586 GdkEvent* gdk_event_get (void);
588 GdkEvent* gdk_event_peek (void);
589 void gdk_event_put (const GdkEvent *event);
591 GdkEvent* gdk_event_new (GdkEventType type);
592 GdkEvent* gdk_event_copy (const GdkEvent *event);
593 void gdk_event_free (GdkEvent *event);
595 guint32 gdk_event_get_time (const GdkEvent *event);
596 gboolean gdk_event_get_state (const GdkEvent *event,
597 GdkModifierType *state);
598 gboolean gdk_event_get_coords (const GdkEvent *event,
601 gboolean gdk_event_get_root_coords (const GdkEvent *event,
604 gboolean gdk_event_get_axis (const GdkEvent *event,
607 void gdk_event_set_device (GdkEvent *event,
609 GdkDevice* gdk_event_get_device (const GdkEvent *event);
610 void gdk_event_request_motions (const GdkEventMotion *event);
612 gboolean gdk_events_get_distance (GdkEvent *event1,
615 gboolean gdk_events_get_angle (GdkEvent *event1,
618 gboolean gdk_events_get_center (GdkEvent *event1,
623 void gdk_event_handler_set (GdkEventFunc func,
625 GDestroyNotify notify);
627 void gdk_event_set_screen (GdkEvent *event,
629 GdkScreen *gdk_event_get_screen (const GdkEvent *event);
631 void gdk_set_show_events (gboolean show_events);
632 gboolean gdk_get_show_events (void);
634 #ifndef GDK_MULTIHEAD_SAFE
636 gboolean gdk_setting_get (const gchar *name,
638 void gdk_add_client_message_filter (GdkAtom message_type,
641 gboolean gdk_event_send_client_message (GdkEvent *event,
642 GdkNativeWindow winid);
643 void gdk_event_send_clientmessage_toall (GdkEvent *event);
645 #endif /* GDK_MULTIHEAD_SAFE */
647 gboolean gdk_event_send_client_message_for_display (GdkDisplay *display,
649 GdkNativeWindow winid);
653 #endif /* __GDK_EVENTS_H__ */