1/* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
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.
8 *
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.
13 *
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.
18 */
19
20/*
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/.
25 */
26
27#ifndef __GDK_EVENTS_H__
28#define __GDK_EVENTS_H__
29
30#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
31#error "Only <gdk/gdk.h> can be included directly."
32#endif
33
34#include <gdk/gdkcolor.h>
35#include <gdk/gdktypes.h>
36#include <gdk/gdkdnd.h>
37#include <gdk/gdkinput.h>
38
39G_BEGIN_DECLS
40
41#define GDK_TYPE_EVENT (gdk_event_get_type ())
42
43#define GDK_PRIORITY_EVENTS (G_PRIORITY_DEFAULT)
44#define GDK_PRIORITY_REDRAW (G_PRIORITY_HIGH_IDLE + 20)
45
46
47typedef struct _GdkEventAny GdkEventAny;
48typedef struct _GdkEventExpose GdkEventExpose;
49typedef struct _GdkEventNoExpose GdkEventNoExpose;
50typedef struct _GdkEventVisibility GdkEventVisibility;
51typedef struct _GdkEventMotion GdkEventMotion;
52typedef struct _GdkEventButton GdkEventButton;
53typedef struct _GdkEventScroll GdkEventScroll;
54typedef struct _GdkEventKey GdkEventKey;
55typedef struct _GdkEventFocus GdkEventFocus;
56typedef struct _GdkEventCrossing GdkEventCrossing;
57typedef struct _GdkEventConfigure GdkEventConfigure;
58typedef struct _GdkEventProperty GdkEventProperty;
59typedef struct _GdkEventSelection GdkEventSelection;
60typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
61typedef struct _GdkEventProximity GdkEventProximity;
62typedef struct _GdkEventClient GdkEventClient;
63typedef struct _GdkEventDND GdkEventDND;
64typedef struct _GdkEventWindowState GdkEventWindowState;
65typedef struct _GdkEventSetting GdkEventSetting;
66typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
67
68typedef union _GdkEvent GdkEvent;
69
70typedef void (*GdkEventFunc) (GdkEvent *event,
71 gpointer data);
72
73/* Event filtering */
74
75typedef void GdkXEvent; /* Can be cast to window system specific
76 * even type, XEvent on X11, MSG on Win32.
77 */
78
79typedef enum {
80 GDK_FILTER_CONTINUE, /* Event not handled, continue processesing */
81 GDK_FILTER_TRANSLATE, /* Native event translated into a GDK event and
82 stored in the "event" structure that was
83 passed in */
84 GDK_FILTER_REMOVE /* Terminate processing, removing event */
85} GdkFilterReturn;
86
87typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
88 GdkEvent *event,
89 gpointer data);
90
91
92/* Event types.
93 * Nothing: No event occurred.
94 * Delete: A window delete event was sent by the window manager.
95 * The specified window should be deleted.
96 * Destroy: A window has been destroyed.
97 * Expose: Part of a window has been uncovered.
98 * NoExpose: Same as expose, but no expose event was generated.
99 * VisibilityNotify: A window has become fully/partially/not obscured.
100 * MotionNotify: The mouse has moved.
101 * ButtonPress: A mouse button was pressed.
102 * ButtonRelease: A mouse button was release.
103 * KeyPress: A key was pressed.
104 * KeyRelease: A key was released.
105 * EnterNotify: A window was entered.
106 * LeaveNotify: A window was exited.
107 * FocusChange: The focus window has changed. (The focus window gets
108 * keyboard events).
109 * Resize: A window has been resized.
110 * Map: A window has been mapped. (It is now visible on the screen).
111 * Unmap: A window has been unmapped. (It is no longer visible on
112 * the screen).
113 * Scroll: A mouse wheel was scrolled either up or down.
114 */
115typedef enum
116{
117 GDK_NOTHING = -1,
118 GDK_DELETE = 0,
119 GDK_DESTROY = 1,
120 GDK_EXPOSE = 2,
121 GDK_MOTION_NOTIFY = 3,
122 GDK_BUTTON_PRESS = 4,
123 GDK_2BUTTON_PRESS = 5,
124 GDK_3BUTTON_PRESS = 6,
125 GDK_BUTTON_RELEASE = 7,
126 GDK_KEY_PRESS = 8,
127 GDK_KEY_RELEASE = 9,
128 GDK_ENTER_NOTIFY = 10,
129 GDK_LEAVE_NOTIFY = 11,
130 GDK_FOCUS_CHANGE = 12,
131 GDK_CONFIGURE = 13,
132 GDK_MAP = 14,
133 GDK_UNMAP = 15,
134 GDK_PROPERTY_NOTIFY = 16,
135 GDK_SELECTION_CLEAR = 17,
136 GDK_SELECTION_REQUEST = 18,
137 GDK_SELECTION_NOTIFY = 19,
138 GDK_PROXIMITY_IN = 20,
139 GDK_PROXIMITY_OUT = 21,
140 GDK_DRAG_ENTER = 22,
141 GDK_DRAG_LEAVE = 23,
142 GDK_DRAG_MOTION = 24,
143 GDK_DRAG_STATUS = 25,
144 GDK_DROP_START = 26,
145 GDK_DROP_FINISHED = 27,
146 GDK_CLIENT_EVENT = 28,
147 GDK_VISIBILITY_NOTIFY = 29,
148 GDK_NO_EXPOSE = 30,
149 GDK_SCROLL = 31,
150 GDK_WINDOW_STATE = 32,
151 GDK_SETTING = 33,
152 GDK_OWNER_CHANGE = 34,
153 GDK_GRAB_BROKEN = 35,
154 GDK_DAMAGE = 36,
155 GDK_EVENT_LAST /* helper variable for decls */
156} GdkEventType;
157
158/* Event masks. (Used to select what types of events a window
159 * will receive).
160 */
161typedef enum
162{
163 GDK_EXPOSURE_MASK = 1 << 1,
164 GDK_POINTER_MOTION_MASK = 1 << 2,
165 GDK_POINTER_MOTION_HINT_MASK = 1 << 3,
166 GDK_BUTTON_MOTION_MASK = 1 << 4,
167 GDK_BUTTON1_MOTION_MASK = 1 << 5,
168 GDK_BUTTON2_MOTION_MASK = 1 << 6,
169 GDK_BUTTON3_MOTION_MASK = 1 << 7,
170 GDK_BUTTON_PRESS_MASK = 1 << 8,
171 GDK_BUTTON_RELEASE_MASK = 1 << 9,
172 GDK_KEY_PRESS_MASK = 1 << 10,
173 GDK_KEY_RELEASE_MASK = 1 << 11,
174 GDK_ENTER_NOTIFY_MASK = 1 << 12,
175 GDK_LEAVE_NOTIFY_MASK = 1 << 13,
176 GDK_FOCUS_CHANGE_MASK = 1 << 14,
177 GDK_STRUCTURE_MASK = 1 << 15,
178 GDK_PROPERTY_CHANGE_MASK = 1 << 16,
179 GDK_VISIBILITY_NOTIFY_MASK = 1 << 17,
180 GDK_PROXIMITY_IN_MASK = 1 << 18,
181 GDK_PROXIMITY_OUT_MASK = 1 << 19,
182 GDK_SUBSTRUCTURE_MASK = 1 << 20,
183 GDK_SCROLL_MASK = 1 << 21,
184 GDK_ALL_EVENTS_MASK = 0x3FFFFE
185} GdkEventMask;
186
187typedef enum
188{
189 GDK_VISIBILITY_UNOBSCURED,
190 GDK_VISIBILITY_PARTIAL,
191 GDK_VISIBILITY_FULLY_OBSCURED
192} GdkVisibilityState;
193
194typedef enum
195{
196 GDK_SCROLL_UP,
197 GDK_SCROLL_DOWN,
198 GDK_SCROLL_LEFT,
199 GDK_SCROLL_RIGHT
200} GdkScrollDirection;
201
202/* Types of enter/leave notifications.
203 * Ancestor:
204 * Virtual:
205 * Inferior:
206 * Nonlinear:
207 * NonlinearVirtual:
208 * Unknown: An unknown type of enter/leave event occurred.
209 */
210typedef enum
211{
212 GDK_NOTIFY_ANCESTOR = 0,
213 GDK_NOTIFY_VIRTUAL = 1,
214 GDK_NOTIFY_INFERIOR = 2,
215 GDK_NOTIFY_NONLINEAR = 3,
216 GDK_NOTIFY_NONLINEAR_VIRTUAL = 4,
217 GDK_NOTIFY_UNKNOWN = 5
218} GdkNotifyType;
219
220/* Enter/leave event modes.
221 * NotifyNormal
222 * NotifyGrab
223 * NotifyUngrab
224 */
225typedef enum
226{
227 GDK_CROSSING_NORMAL,
228 GDK_CROSSING_GRAB,
229 GDK_CROSSING_UNGRAB,
230 GDK_CROSSING_GTK_GRAB,
231 GDK_CROSSING_GTK_UNGRAB,
232 GDK_CROSSING_STATE_CHANGED
233} GdkCrossingMode;
234
235typedef enum
236{
237 GDK_PROPERTY_NEW_VALUE,
238 GDK_PROPERTY_DELETE
239} GdkPropertyState;
240
241typedef enum
242{
243 GDK_WINDOW_STATE_WITHDRAWN = 1 << 0,
244 GDK_WINDOW_STATE_ICONIFIED = 1 << 1,
245 GDK_WINDOW_STATE_MAXIMIZED = 1 << 2,
246 GDK_WINDOW_STATE_STICKY = 1 << 3,
247 GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
248 GDK_WINDOW_STATE_ABOVE = 1 << 5,
249 GDK_WINDOW_STATE_BELOW = 1 << 6
250} GdkWindowState;
251
252typedef enum
253{
254 GDK_SETTING_ACTION_NEW,
255 GDK_SETTING_ACTION_CHANGED,
256 GDK_SETTING_ACTION_DELETED
257} GdkSettingAction;
258
259typedef enum
260{
261 GDK_OWNER_CHANGE_NEW_OWNER,
262 GDK_OWNER_CHANGE_DESTROY,
263 GDK_OWNER_CHANGE_CLOSE
264} GdkOwnerChange;
265
266struct _GdkEventAny
267{
268 GdkEventType type;
269 GdkWindow *window;
270 gint8 send_event;
271};
272
273struct _GdkEventExpose
274{
275 GdkEventType type;
276 GdkWindow *window;
277 gint8 send_event;
278 GdkRectangle area;
279 GdkRegion *region;
280 gint count; /* If non-zero, how many more events follow. */
281};
282
283struct _GdkEventNoExpose
284{
285 GdkEventType type;
286 GdkWindow *window;
287 gint8 send_event;
288};
289
290struct _GdkEventVisibility
291{
292 GdkEventType type;
293 GdkWindow *window;
294 gint8 send_event;
295 GdkVisibilityState state;
296};
297
298struct _GdkEventMotion
299{
300 GdkEventType type;
301 GdkWindow *window;
302 gint8 send_event;
303 guint32 time;
304 gdouble x;
305 gdouble y;
306 gdouble *axes;
307 guint state;
308 gint16 is_hint;
309 GdkDevice *device;
310 gdouble x_root, y_root;
311};
312
313struct _GdkEventButton
314{
315 GdkEventType type;
316 GdkWindow *window;
317 gint8 send_event;
318 guint32 time;
319 gdouble x;
320 gdouble y;
321 gdouble *axes;
322 guint state;
323 guint button;
324 GdkDevice *device;
325 gdouble x_root, y_root;
326};
327
328struct _GdkEventScroll
329{
330 GdkEventType type;
331 GdkWindow *window;
332 gint8 send_event;
333 guint32 time;
334 gdouble x;
335 gdouble y;
336 guint state;
337 GdkScrollDirection direction;
338 GdkDevice *device;
339 gdouble x_root, y_root;
340};
341
342struct _GdkEventKey
343{
344 GdkEventType type;
345 GdkWindow *window;
346 gint8 send_event;
347 guint32 time;
348 guint state;
349 guint keyval;
350 gint length;
351 gchar *string;
352 guint16 hardware_keycode;
353 guint8 group;
354 guint is_modifier : 1;
355};
356
357struct _GdkEventCrossing
358{
359 GdkEventType type;
360 GdkWindow *window;
361 gint8 send_event;
362 GdkWindow *subwindow;
363 guint32 time;
364 gdouble x;
365 gdouble y;
366 gdouble x_root;
367 gdouble y_root;
368 GdkCrossingMode mode;
369 GdkNotifyType detail;
370 gboolean focus;
371 guint state;
372};
373
374struct _GdkEventFocus
375{
376 GdkEventType type;
377 GdkWindow *window;
378 gint8 send_event;
379 gint16 in;
380};
381
382struct _GdkEventConfigure
383{
384 GdkEventType type;
385 GdkWindow *window;
386 gint8 send_event;
387 gint x, y;
388 gint width;
389 gint height;
390};
391
392struct _GdkEventProperty
393{
394 GdkEventType type;
395 GdkWindow *window;
396 gint8 send_event;
397 GdkAtom atom;
398 guint32 time;
399 guint state;
400};
401
402struct _GdkEventSelection
403{
404 GdkEventType type;
405 GdkWindow *window;
406 gint8 send_event;
407 GdkAtom selection;
408 GdkAtom target;
409 GdkAtom property;
410 guint32 time;
411 GdkNativeWindow requestor;
412};
413
414struct _GdkEventOwnerChange
415{
416 GdkEventType type;
417 GdkWindow *window;
418 gint8 send_event;
419 GdkNativeWindow owner;
420 GdkOwnerChange reason;
421 GdkAtom selection;
422 guint32 time;
423 guint32 selection_time;
424};
425
426/* This event type will be used pretty rarely. It only is important
427 for XInput aware programs that are drawing their own cursor */
428
429struct _GdkEventProximity
430{
431 GdkEventType type;
432 GdkWindow *window;
433 gint8 send_event;
434 guint32 time;
435 GdkDevice *device;
436};
437
438struct _GdkEventClient
439{
440 GdkEventType type;
441 GdkWindow *window;
442 gint8 send_event;
443 GdkAtom message_type;
444 gushort data_format;
445 union {
446 char b[20];
447 short s[10];
448 long l[5];
449 } data;
450};
451
452struct _GdkEventSetting
453{
454 GdkEventType type;
455 GdkWindow *window;
456 gint8 send_event;
457 GdkSettingAction action;
458 char *name;
459};
460
461struct _GdkEventWindowState
462{
463 GdkEventType type;
464 GdkWindow *window;
465 gint8 send_event;
466 GdkWindowState changed_mask;
467 GdkWindowState new_window_state;
468};
469
470struct _GdkEventGrabBroken {
471 GdkEventType type;
472 GdkWindow *window;
473 gint8 send_event;
474 gboolean keyboard;
475 gboolean implicit;
476 GdkWindow *grab_window;
477};
478
479/* Event types for DND */
480
481struct _GdkEventDND {
482 GdkEventType type;
483 GdkWindow *window;
484 gint8 send_event;
485 GdkDragContext *context;
486
487 guint32 time;
488 gshort x_root, y_root;
489};
490
491union _GdkEvent
492{
493 GdkEventType type;
494 GdkEventAny any;
495 GdkEventExpose expose;
496 GdkEventNoExpose no_expose;
497 GdkEventVisibility visibility;
498 GdkEventMotion motion;
499 GdkEventButton button;
500 GdkEventScroll scroll;
501 GdkEventKey key;
502 GdkEventCrossing crossing;
503 GdkEventFocus focus_change;
504 GdkEventConfigure configure;
505 GdkEventProperty property;
506 GdkEventSelection selection;
507 GdkEventOwnerChange owner_change;
508 GdkEventProximity proximity;
509 GdkEventClient client;
510 GdkEventDND dnd;
511 GdkEventWindowState window_state;
512 GdkEventSetting setting;
513 GdkEventGrabBroken grab_broken;
514};
515
516GType gdk_event_get_type (void) G_GNUC_CONST;
517
518gboolean gdk_events_pending (void);
519GdkEvent* gdk_event_get (void);
520
521GdkEvent* gdk_event_peek (void);
522#ifndef GDK_DISABLE_DEPRECATED
523GdkEvent* gdk_event_get_graphics_expose (GdkWindow *window);
524#endif
525void gdk_event_put (const GdkEvent *event);
526
527GdkEvent* gdk_event_new (GdkEventType type);
528GdkEvent* gdk_event_copy (const GdkEvent *event);
529void gdk_event_free (GdkEvent *event);
530
531guint32 gdk_event_get_time (const GdkEvent *event);
532gboolean gdk_event_get_state (const GdkEvent *event,
533 GdkModifierType *state);
534gboolean gdk_event_get_coords (const GdkEvent *event,
535 gdouble *x_win,
536 gdouble *y_win);
537gboolean gdk_event_get_root_coords (const GdkEvent *event,
538 gdouble *x_root,
539 gdouble *y_root);
540gboolean gdk_event_get_axis (const GdkEvent *event,
541 GdkAxisUse axis_use,
542 gdouble *value);
543void gdk_event_request_motions (const GdkEventMotion *event);
544void gdk_event_handler_set (GdkEventFunc func,
545 gpointer data,
546 GDestroyNotify notify);
547
548void gdk_event_set_screen (GdkEvent *event,
549 GdkScreen *screen);
550GdkScreen *gdk_event_get_screen (const GdkEvent *event);
551
552void gdk_set_show_events (gboolean show_events);
553gboolean gdk_get_show_events (void);
554
555#ifndef GDK_MULTIHEAD_SAFE
556void gdk_add_client_message_filter (GdkAtom message_type,
557 GdkFilterFunc func,
558 gpointer data);
559
560gboolean gdk_setting_get (const gchar *name,
561 GValue *value);
562#endif /* GDK_MULTIHEAD_SAFE */
563
564G_END_DECLS
565
566#endif /* __GDK_EVENTS_H__ */
567