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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
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/.
23 */
24
25#ifndef __GDK_EVENTS_PRIVATE_H__
26#define __GDK_EVENTS_PRIVATE_H__
27
28#include <gdk/gdktypes.h>
29#include <gdk/gdkdrag.h>
30#include <gdk/gdkdevice.h>
31#include <gdk/gdkdevicetool.h>
32
33G_BEGIN_DECLS
34
35#define GDK_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_EVENT, GdkEventClass))
36
37typedef struct _GdkEventClass GdkEventClass;
38
39/*< private >
40 * GdkEvent:
41 * @ref_count: the reference count of the event
42 * @event_type: the specialized event type
43 * @surface: the surface of the event
44 * @device: the device of the event
45 * @time: a serial identifier of the event that can be used to order
46 * two events
47 * @flags: event flags
48 *
49 * The abstract type for all windowing system events.
50 */
51struct _GdkEvent
52{
53 GTypeInstance parent_instance;
54
55 grefcount ref_count;
56
57 /* Specialised event type */
58 GdkEventType event_type;
59
60 /* The surface of the event */
61 GdkSurface *surface;
62
63 /* The devices associated to the event */
64 GdkDevice *device;
65
66 guint32 time;
67 guint16 flags;
68};
69
70/*< private >
71 * GdkEventClass:
72 * @finalize: a function called when the last reference held on an event is
73 * released; implementations of GdkEvent must chain up to the parent class
74 *
75 * The base class for events.
76 */
77struct _GdkEventClass
78{
79 GTypeClass parent_class;
80
81 void (* finalize) (GdkEvent *event);
82
83 GdkModifierType (* get_state) (GdkEvent *event);
84 gboolean (* get_position) (GdkEvent *event,
85 double *x,
86 double *y);
87 GdkEventSequence * (* get_sequence) (GdkEvent *event);
88 GdkDeviceTool * (* get_tool) (GdkEvent *event);
89 gboolean (* get_axes) (GdkEvent *event,
90 double **axes,
91 guint *n_axes);
92};
93
94/*
95 * GdkDeleteEvent:
96 *
97 * Generated when a surface is deleted.
98 */
99struct _GdkDeleteEvent
100{
101 GdkEvent parent_instance;
102};
103
104/*
105 * GdkMotionEvent:
106 * @state: (type GdkModifierType): a bit-mask representing the state of
107 * the modifier keys (e.g. Control, Shift and Alt) set during the motion
108 * event. See [flags@Gdk.ModifierType]
109 * @x: the x coordinate of the pointer relative to the surface.
110 * @y: the y coordinate of the pointer relative to the surface.
111 * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
112 * the mouse.
113 * @history: (element-type GdkTimeCoord): a list of time and coordinates
114 * for other motion events that were compressed before delivering the
115 * current event
116 *
117 * Generated when the pointer moves.
118 */
119struct _GdkMotionEvent
120{
121 GdkEvent parent_instance;
122
123 GdkModifierType state;
124 double x;
125 double y;
126 double *axes;
127 GdkDeviceTool *tool;
128 GArray *history; /* <GdkTimeCoord> */
129};
130
131/*
132 * GdkButtonEvent:
133 * @state: (type GdkModifierType): a bit-mask representing the state of
134 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
135 * buttons. See [flags@Gdk.ModifierType]
136 * @button: the button which was pressed or released, numbered from 1 to 5.
137 * Normally button 1 is the left mouse button, 2 is the middle button,
138 * and 3 is the right button. On 2-button mice, the middle button can
139 * often be simulated by pressing both mouse buttons together.
140 * @x: the x coordinate of the pointer relative to the surface.
141 * @y: the y coordinate of the pointer relative to the surface.
142 * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
143 * the mouse.
144 * @tool: a `GdkDeviceTool`
145 *
146 * Used for button press and button release events. The
147 * @type field will be one of %GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE,
148 */
149struct _GdkButtonEvent
150{
151 GdkEvent parent_instance;
152
153 GdkModifierType state;
154 guint button;
155 double x;
156 double y;
157 double *axes;
158 GdkDeviceTool *tool;
159};
160
161/*
162 * GdkTouchEvent:
163 * @state: (type GdkModifierType): a bit-mask representing the state of
164 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
165 * buttons. See [flags@Gdk.ModifierType]
166 * @x: the x coordinate of the pointer relative to the surface
167 * @y: the y coordinate of the pointer relative to the surface
168 * @axes: @x, @y translated to the axes of the event's device, or %NULL
169 * if @device is the mouse
170 * @sequence: the event sequence that the event belongs to
171 * @emulated: whether the event is the result of a pointer emulation
172 *
173 * Used for touch events.
174 * @type field will be one of %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
175 * %GDK_TOUCH_END or %GDK_TOUCH_CANCEL.
176 *
177 * Touch events are grouped into sequences by means of the @sequence
178 * field, which can also be obtained with gdk_event_get_event_sequence().
179 * Each sequence begins with a %GDK_TOUCH_BEGIN event, followed by
180 * any number of %GDK_TOUCH_UPDATE events, and ends with a %GDK_TOUCH_END
181 * (or %GDK_TOUCH_CANCEL) event. With multitouch devices, there may be
182 * several active sequences at the same time.
183 */
184struct _GdkTouchEvent
185{
186 GdkEvent parent_instance;
187
188 GdkModifierType state;
189 double x;
190 double y;
191 double *axes;
192 GdkEventSequence *sequence;
193 gboolean touch_emulating;
194 gboolean pointer_emulated;
195};
196
197/*
198 * GdkScrollEvent:
199 * @x: the x coordinate of the pointer relative to the surface.
200 * @y: the y coordinate of the pointer relative to the surface.
201 * @state: (type GdkModifierType): a bit-mask representing the state of
202 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
203 * buttons. See [flags@Gdk.ModifierType]
204 * @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
205 * %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT, %GDK_SCROLL_RIGHT or
206 * %GDK_SCROLL_SMOOTH).
207 * @delta_x: the x coordinate of the scroll delta
208 * @delta_y: the y coordinate of the scroll delta
209 * @pointer_emulated: whether the scroll event was the result of
210 * a pointer emulation
211 * @tool: a `GdkDeviceTool`
212 * @history: (element-type GdkTimeCoord): array of times and deltas
213 * for other scroll events that were compressed before delivering the
214 * current event
215 *
216 * Generated from button presses for the buttons 4 to 7. Wheel mice are
217 * usually configured to generate button press events for buttons 4 and 5
218 * when the wheel is turned.
219 *
220 * Some GDK backends can also generate “smooth” scroll events, which
221 * can be recognized by the %GDK_SCROLL_SMOOTH scroll direction. For
222 * these, the scroll deltas can be obtained with
223 * gdk_event_get_scroll_deltas().
224 */
225struct _GdkScrollEvent
226{
227 GdkEvent parent_instance;
228
229 GdkModifierType state;
230 GdkScrollDirection direction;
231 double delta_x;
232 double delta_y;
233 gboolean pointer_emulated;
234 gboolean is_stop;
235 GdkDeviceTool *tool;
236 GArray *history; /* <GdkTimeCoord> */
237};
238
239/*
240 * GdkTranslatedKey:
241 * @keyval: the translated key symbol
242 * @consumed: the consumed modifiers
243 * @layout: the keyboard layout
244 * @level: the layout level
245 *
246 * Describes a translated key code.
247 */
248typedef struct {
249 guint keyval;
250 GdkModifierType consumed;
251 guint layout;
252 guint level;
253} GdkTranslatedKey;
254
255/*
256 * GdkKeyEvent:
257 * @state: (type GdkModifierType): a bit-mask representing the state of
258 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
259 * buttons. See [flags@Gdk.ModifierType]
260 * @keycode: the raw code of the key that was pressed or released.
261 * @translated: the result of translating @keycode. First with the full
262 * @state, then while ignoring Caps Lock.
263 *
264 * Describes a key press or key release event.
265 */
266struct _GdkKeyEvent
267{
268 GdkEvent parent_instance;
269
270 GdkModifierType state;
271 guint32 keycode;
272 gboolean key_is_modifier;
273 GdkTranslatedKey translated[2];
274};
275
276/*
277 * GdkCrossingEvent:
278 * @state: (type GdkModifierType): a bit-mask representing the state of
279 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
280 * buttons. See [flags@Gdk.ModifierType]
281 * @mode: the crossing mode (%GDK_CROSSING_NORMAL, %GDK_CROSSING_GRAB,
282 * %GDK_CROSSING_UNGRAB, %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB or
283 * %GDK_CROSSING_STATE_CHANGED). %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB,
284 * and %GDK_CROSSING_STATE_CHANGED were added in 2.14 and are always synthesized,
285 * never native.
286 * @x: the x coordinate of the pointer relative to the surface.
287 * @y: the y coordinate of the pointer relative to the surface.
288 * @detail: the kind of crossing that happened (%GDK_NOTIFY_INFERIOR,
289 * %GDK_NOTIFY_ANCESTOR, %GDK_NOTIFY_VIRTUAL, %GDK_NOTIFY_NONLINEAR or
290 * %GDK_NOTIFY_NONLINEAR_VIRTUAL).
291 * @focus: %TRUE if @surface is the focus surface or an inferior.
292 * @child_surface: the surface that was entered or left.
293 *
294 * Generated when the pointer enters or leaves a surface.
295 */
296struct _GdkCrossingEvent
297{
298 GdkEvent parent_instance;
299
300 GdkModifierType state;
301 GdkCrossingMode mode;
302 double x;
303 double y;
304 GdkNotifyType detail;
305 gboolean focus;
306 GdkSurface *child_surface;
307};
308
309/*
310 * GdkFocusEvent:
311 * @in: %TRUE if the surface has gained the keyboard focus, %FALSE if
312 * it has lost the focus.
313 * @mode: the crossing mode
314 * @detail: the kind of crossing that happened
315 *
316 * Describes a change of keyboard focus.
317 */
318struct _GdkFocusEvent
319{
320 GdkEvent parent_instance;
321
322 gboolean focus_in;
323};
324
325/*
326 * GdkProximityEvent:
327 * @tool: the `GdkDeviceTool` associated to the event
328 *
329 * A proximity event indicates that a tool of a graphic tablet, or similar
330 * devices that report proximity, has moved in or out of contact with the
331 * tablet, or perhaps that the user’s finger has moved in or out of contact
332 * with a touch screen.
333 */
334struct _GdkProximityEvent
335{
336 GdkEvent parent_instance;
337
338 GdkDeviceTool *tool;
339};
340
341/*
342 * GdkGrabBrokenEvent:
343 * @keyboard: %TRUE if a keyboard grab was broken, %FALSE if a pointer
344 * grab was broken
345 * @implicit: %TRUE if the broken grab was implicit
346 * @grab_surface: If this event is caused by another grab in the same
347 * application, @grab_surface contains the new grab surface. Otherwise
348 * @grab_surface is %NULL.
349 *
350 * Generated when a pointer or keyboard grab is broken. On X11, this happens
351 * when the grab surface becomes unviewable (i.e. it or one of its ancestors
352 * is unmapped), or if the same application grabs the pointer or keyboard
353 * again. Note that implicit grabs (which are initiated by button presses)
354 * can also cause `GdkGrabBrokenEvent` events.
355 */
356struct _GdkGrabBrokenEvent
357{
358 GdkEvent parent_instance;
359
360 gboolean keyboard;
361 gboolean implicit;
362 GdkSurface *grab_surface;
363};
364
365/*
366 * GdkDNDEvent:
367 * @drop: the `GdkDrop` for the current DND operation.
368 * @x: the X coordinate of the pointer
369 * @y: the Y coordinate of the pointer
370 *
371 * Generated during DND operations.
372 */
373struct _GdkDNDEvent
374{
375 GdkEvent parent_instance;
376
377 GdkDrop *drop;
378 double x;
379 double y;
380};
381
382/*
383 * GdkTouchpadEvent:
384 * @state: (type GdkModifierType): a bit-mask representing the state of
385 * the modifier keys (e.g. Control, Shift and Alt) and the pointer
386 * buttons. See [flags@Gdk.ModifierType]
387 * @phase: (type GdkTouchpadGesturePhase): the current phase of the gesture
388 * @n_fingers: The number of fingers triggering the pinch
389 * @time: the time of the event in milliseconds
390 * @x: The X coordinate of the pointer
391 * @y: The Y coordinate of the pointer
392 * @dx: Movement delta in the X axis of the swipe focal point
393 * @dy: Movement delta in the Y axis of the swipe focal point
394 * @angle_delta: For pinch events, the angle change in radians, negative angles
395 * denote counter-clockwise movements
396 * @scale: For pinch events, the current scale, relative to that at the time of
397 * the corresponding %GDK_TOUCHPAD_GESTURE_PHASE_BEGIN event
398 *
399 * Generated during touchpad gestures.
400 */
401struct _GdkTouchpadEvent
402{
403 GdkEvent parent_instance;
404
405 GdkEventSequence *sequence;
406 GdkModifierType state;
407 gint8 phase;
408 gint8 n_fingers;
409 double x;
410 double y;
411 double dx;
412 double dy;
413 double angle_delta;
414 double scale;
415};
416
417struct _GdkPadEvent
418{
419 GdkEvent parent_instance;
420
421 guint group;
422 guint mode;
423 guint button;
424 guint index;
425 double value;
426};
427
428void gdk_event_init_types (void);
429
430GdkEvent * gdk_button_event_new (GdkEventType type,
431 GdkSurface *surface,
432 GdkDevice *device,
433 GdkDeviceTool *tool,
434 guint32 time,
435 GdkModifierType state,
436 guint button,
437 double x,
438 double y,
439 double *axes);
440
441GdkEvent * gdk_motion_event_new (GdkSurface *surface,
442 GdkDevice *device,
443 GdkDeviceTool *tool,
444 guint32 time,
445 GdkModifierType state,
446 double x,
447 double y,
448 double *axes);
449
450GdkEvent * gdk_crossing_event_new (GdkEventType type,
451 GdkSurface *surface,
452 GdkDevice *device,
453 guint32 time,
454 GdkModifierType state,
455 double x,
456 double y,
457 GdkCrossingMode mode,
458 GdkNotifyType notify);
459
460GdkEvent * gdk_proximity_event_new (GdkEventType type,
461 GdkSurface *surface,
462 GdkDevice *device,
463 GdkDeviceTool *tool,
464 guint32 time);
465
466GdkEvent * gdk_key_event_new (GdkEventType type,
467 GdkSurface *surface,
468 GdkDevice *device,
469 guint32 time,
470 guint keycode,
471 GdkModifierType modifiers,
472 gboolean is_modifier,
473 GdkTranslatedKey *translated,
474 GdkTranslatedKey *no_lock);
475
476GdkEvent * gdk_focus_event_new (GdkSurface *surface,
477 GdkDevice *device,
478 gboolean focus_in);
479
480GdkEvent * gdk_delete_event_new (GdkSurface *surface);
481
482GdkEvent * gdk_scroll_event_new (GdkSurface *surface,
483 GdkDevice *device,
484 GdkDeviceTool *tool,
485 guint32 time,
486 GdkModifierType state,
487 double delta_x,
488 double delta_y,
489 gboolean is_stop);
490
491GdkEvent * gdk_scroll_event_new_discrete (GdkSurface *surface,
492 GdkDevice *device,
493 GdkDeviceTool *tool,
494 guint32 time,
495 GdkModifierType state,
496 GdkScrollDirection direction,
497 gboolean emulated);
498
499GdkEvent * gdk_touch_event_new (GdkEventType type,
500 GdkEventSequence *sequence,
501 GdkSurface *surface,
502 GdkDevice *device,
503 guint32 time,
504 GdkModifierType state,
505 double x,
506 double y,
507 double *axes,
508 gboolean emulating);
509
510GdkEvent * gdk_touchpad_event_new_swipe (GdkSurface *surface,
511 GdkEventSequence *sequence,
512 GdkDevice *device,
513 guint32 time,
514 GdkModifierType state,
515 GdkTouchpadGesturePhase phase,
516 double x,
517 double y,
518 int n_fingers,
519 double dx,
520 double dy);
521
522GdkEvent * gdk_touchpad_event_new_pinch (GdkSurface *surface,
523 GdkEventSequence *sequence,
524 GdkDevice *device,
525 guint32 time,
526 GdkModifierType state,
527 GdkTouchpadGesturePhase phase,
528 double x,
529 double y,
530 int n_fingers,
531 double dx,
532 double dy,
533 double scale,
534 double angle_delta);
535
536GdkEvent * gdk_touchpad_event_new_hold (GdkSurface *surface,
537 GdkDevice *device,
538 guint32 time,
539 GdkModifierType state,
540 GdkTouchpadGesturePhase phase,
541 double x,
542 double y,
543 int n_fingers);
544
545GdkEvent * gdk_pad_event_new_ring (GdkSurface *surface,
546 GdkDevice *device,
547 guint32 time,
548 guint group,
549 guint index,
550 guint mode,
551 double value);
552
553GdkEvent * gdk_pad_event_new_strip (GdkSurface *surface,
554 GdkDevice *device,
555 guint32 time,
556 guint group,
557 guint index,
558 guint mode,
559 double value);
560
561GdkEvent * gdk_pad_event_new_button (GdkEventType type,
562 GdkSurface *surface,
563 GdkDevice *device,
564 guint32 time,
565 guint group,
566 guint button,
567 guint mode);
568
569GdkEvent * gdk_pad_event_new_group_mode (GdkSurface *surface,
570 GdkDevice *device,
571 guint32 time,
572 guint group,
573 guint mode);
574
575GdkEvent * gdk_dnd_event_new (GdkEventType type,
576 GdkSurface *surface,
577 GdkDevice *device,
578 GdkDrop *drop,
579 guint32 time,
580 double x,
581 double y);
582
583GdkEvent * gdk_grab_broken_event_new (GdkSurface *surface,
584 GdkDevice *device,
585 GdkSurface *grab_surface,
586 gboolean implicit);
587
588GdkTranslatedKey * gdk_key_event_get_translated_key (GdkEvent *event,
589 gboolean no_lock);
590
591typedef enum
592{
593 /* Following flag is set for events on the event queue during
594 * translation and cleared afterwards.
595 */
596 GDK_EVENT_PENDING = 1 << 0,
597
598 /* When we are ready to draw a frame, we pause event delivery,
599 * mark all events in the queue with this flag, and deliver
600 * only those events until we finish the frame.
601 */
602 GDK_EVENT_FLUSHED = 1 << 2
603} GdkEventFlags;
604
605GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
606
607void _gdk_event_emit (GdkEvent *event);
608GList* _gdk_event_queue_find_first (GdkDisplay *display);
609void _gdk_event_queue_remove_link (GdkDisplay *display,
610 GList *node);
611GList* _gdk_event_queue_append (GdkDisplay *display,
612 GdkEvent *event);
613
614void _gdk_event_queue_handle_motion_compression (GdkDisplay *display);
615void gdk_event_queue_handle_scroll_compression (GdkDisplay *display);
616void _gdk_event_queue_flush (GdkDisplay *display);
617
618double * gdk_event_dup_axes (GdkEvent *event);
619
620
621G_END_DECLS
622
623#endif /* __GDK_EVENTS_PRIVATE_H__ */
624

source code of gtk/gdk/gdkeventsprivate.h