4 * An OpenGL based 'interactive canvas' library.
6 * Authored By Matthew Allum <mallum@openedhand.com>
8 * Copyright (C) 2006 OpenedHand
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
24 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
25 #error "Only <clutter/clutter.h> can be included directly."
28 #ifndef __CLUTTER_EVENT_H__
29 #define __CLUTTER_EVENT_H__
31 #include <clutter/clutter-types.h>
32 #include <clutter/clutter-input-device.h>
36 #define CLUTTER_TYPE_EVENT (clutter_event_get_type ())
39 * CLUTTER_PRIORITY_EVENTS:
41 * Priority for event handling.
45 #define CLUTTER_PRIORITY_EVENTS (G_PRIORITY_DEFAULT)
48 * CLUTTER_CURRENT_TIME:
50 * Default value for "now".
54 #define CLUTTER_CURRENT_TIME (0L)
57 * CLUTTER_EVENT_PROPAGATE:
59 * Continues the propagation of an event; this macro should be
60 * used in event-related signals.
64 #define CLUTTER_EVENT_PROPAGATE (FALSE)
69 * Stops the propagation of an event; this macro should be used
70 * in event-related signals.
74 #define CLUTTER_EVENT_STOP (TRUE)
77 * CLUTTER_BUTTON_PRIMARY:
79 * The primary button of a pointer device.
81 * This is typically the left mouse button in a right-handed
82 * mouse configuration.
86 #define CLUTTER_BUTTON_PRIMARY (1)
89 * CLUTTER_BUTTON_MIDDLE:
91 * The middle button of a pointer device.
95 #define CLUTTER_BUTTON_MIDDLE (2)
98 * CLUTTER_BUTTON_SECONDARY:
100 * The secondary button of a pointer device.
102 * This is typically the right mouse button in a right-handed
103 * mouse configuration.
107 #define CLUTTER_BUTTON_SECONDARY (3)
109 typedef struct _ClutterAnyEvent ClutterAnyEvent;
110 typedef struct _ClutterButtonEvent ClutterButtonEvent;
111 typedef struct _ClutterKeyEvent ClutterKeyEvent;
112 typedef struct _ClutterMotionEvent ClutterMotionEvent;
113 typedef struct _ClutterScrollEvent ClutterScrollEvent;
114 typedef struct _ClutterStageStateEvent ClutterStageStateEvent;
115 typedef struct _ClutterCrossingEvent ClutterCrossingEvent;
116 typedef struct _ClutterTouchEvent ClutterTouchEvent;
119 * ClutterEventSequence:
121 * The <structname>ClutterEventSequence</structname> structure is an opaque
122 * type used to denote the event sequence of a touch event.
126 typedef struct _ClutterEventSequence ClutterEventSequence;
132 * @flags: event flags
133 * @source: event source actor
135 * Common members for a #ClutterEvent
139 struct _ClutterAnyEvent
141 ClutterEventType type;
143 ClutterEventFlags flags;
145 ClutterActor *source;
152 * @flags: event flags
153 * @stage: event source stage
154 * @source: event source actor
155 * @modifier_state: key modifiers
156 * @keyval: raw key value
157 * @hardware_keycode: raw hardware key value
158 * @unicode_value: Unicode representation
159 * @device: reserved for future use
165 struct _ClutterKeyEvent
167 ClutterEventType type;
169 ClutterEventFlags flags;
171 ClutterActor *source;
173 ClutterModifierType modifier_state;
175 guint16 hardware_keycode;
176 gunichar unicode_value;
177 ClutterInputDevice *device;
181 * ClutterButtonEvent:
184 * @flags: event flags
185 * @stage: event source stage
186 * @source: event source actor
187 * @x: event X coordinate, relative to the stage
188 * @y: event Y coordinate, relative to the stage
189 * @modifier_state: button modifiers
190 * @button: event button
191 * @click_count: number of button presses within the default time
193 * @axes: reserved for future use
194 * @device: reserved for future use
198 * The event coordinates are relative to the stage that received the
199 * event, and can be transformed into actor-relative coordinates by
200 * using clutter_actor_transform_stage_point().
204 struct _ClutterButtonEvent
206 ClutterEventType type;
208 ClutterEventFlags flags;
210 ClutterActor *source;
214 ClutterModifierType modifier_state;
217 gdouble *axes; /* Future use */
218 ClutterInputDevice *device;
222 * ClutterCrossingEvent:
225 * @flags: event flags
226 * @stage: event source stage
227 * @source: event source actor
228 * @x: event X coordinate
229 * @y: event Y coordinate
230 * @related: actor related to the crossing
231 * @device: reserved for future use
233 * Event for the movement of the pointer across different actors
237 struct _ClutterCrossingEvent
239 ClutterEventType type;
241 ClutterEventFlags flags;
243 ClutterActor *source;
247 ClutterInputDevice *device;
248 ClutterActor *related;
252 * ClutterMotionEvent:
255 * @flags: event flags
256 * @stage: event source stage
257 * @source: event source actor
258 * @x: event X coordinate
259 * @y: event Y coordinate
260 * @modifier_state: button modifiers
261 * @axes: reserved for future use
262 * @device: reserved for future use
264 * Event for the pointer motion
268 struct _ClutterMotionEvent
270 ClutterEventType type;
272 ClutterEventFlags flags;
274 ClutterActor *source;
278 ClutterModifierType modifier_state;
279 gdouble *axes; /* Future use */
280 ClutterInputDevice *device;
284 * ClutterScrollEvent:
287 * @flags: event flags
288 * @stage: event source stage
289 * @source: event source actor
290 * @x: event X coordinate
291 * @y: event Y coordinate
292 * @direction: direction of the scrolling
293 * @modifier_state: button modifiers
294 * @axes: reserved for future use
295 * @device: reserved for future use
297 * Scroll wheel (or similar device) event
301 struct _ClutterScrollEvent
303 ClutterEventType type;
305 ClutterEventFlags flags;
307 ClutterActor *source;
311 ClutterScrollDirection direction;
312 ClutterModifierType modifier_state;
313 gdouble *axes; /* future use */
314 ClutterInputDevice *device;
318 * ClutterStageStateEvent:
321 * @flags: event flags
322 * @stage: event source stage
323 * @source: event source actor (unused)
324 * @changed_mask: bitwise OR of the changed flags
325 * @new_state: bitwise OR of the current state flags
327 * Event signalling a change in the #ClutterStage state.
331 struct _ClutterStageStateEvent
333 ClutterEventType type;
335 ClutterEventFlags flags;
337 ClutterActor *source; /* XXX: should probably be the stage itself */
339 ClutterStageState changed_mask;
340 ClutterStageState new_state;
347 * @flags: event flags
348 * @stage: event source stage
349 * @source: event source actor (unused)
350 * @x: the X coordinate of the pointer, relative to the stage
351 * @y: the Y coordinate of the pointer, relative to the stage
352 * @sequence: the event sequence that this event belongs to
353 * @modifier_state: (type ClutterModifierType): a bit-mask representing the state
354 * of modifier keys (e.g. Control, Shift, and Alt) and the pointer
355 * buttons. See #ClutterModifierType
357 * @device: the device that originated the event
359 * Used for touch events.
361 * The @type field will be one of %CLUTTER_TOUCH_BEGIN, %CLUTTER_TOUCH_END,
362 * %CLUTTER_TOUCH_UPDATE, or %CLUTTER_TOUCH_CANCEL.
364 * Touch events are grouped into sequences; each touch sequence will begin
365 * with a %CLUTTER_TOUCH_BEGIN event, progress with %CLUTTER_TOUCH_UPDATE
366 * events, and end either with a %CLUTTER_TOUCH_END event or with a
367 * %CLUTTER_TOUCH_CANCEL event.
369 * With multi-touch capable devices there can be multiple event sequence
370 * running at the same time.
374 struct _ClutterTouchEvent
376 ClutterEventType type;
378 ClutterEventFlags flags;
380 ClutterActor *source;
384 ClutterEventSequence *sequence;
385 ClutterModifierType modifier_state;
386 gdouble *axes; /* reserved */
387 ClutterInputDevice *device;
393 * Generic event wrapper.
400 ClutterEventType type;
403 ClutterButtonEvent button;
405 ClutterMotionEvent motion;
406 ClutterScrollEvent scroll;
407 ClutterStageStateEvent stage_state;
408 ClutterCrossingEvent crossing;
409 ClutterTouchEvent touch;
412 GType clutter_event_get_type (void) G_GNUC_CONST;
414 gboolean clutter_events_pending (void);
415 ClutterEvent * clutter_event_get (void);
416 ClutterEvent * clutter_event_peek (void);
417 void clutter_event_put (const ClutterEvent *event);
419 ClutterEvent * clutter_event_new (ClutterEventType type);
420 ClutterEvent * clutter_event_copy (const ClutterEvent *event);
421 void clutter_event_free (ClutterEvent *event);
423 ClutterEventType clutter_event_type (const ClutterEvent *event);
424 void clutter_event_set_flags (ClutterEvent *event,
425 ClutterEventFlags flags);
426 ClutterEventFlags clutter_event_get_flags (const ClutterEvent *event);
427 void clutter_event_set_time (ClutterEvent *event,
429 guint32 clutter_event_get_time (const ClutterEvent *event);
430 void clutter_event_set_state (ClutterEvent *event,
431 ClutterModifierType state);
432 ClutterModifierType clutter_event_get_state (const ClutterEvent *event);
433 void clutter_event_set_device (ClutterEvent *event,
434 ClutterInputDevice *device);
435 ClutterInputDevice * clutter_event_get_device (const ClutterEvent *event);
436 void clutter_event_set_source_device (ClutterEvent *event,
437 ClutterInputDevice *device);
439 ClutterInputDevice * clutter_event_get_source_device (const ClutterEvent *event);
440 void clutter_event_set_source (ClutterEvent *event,
441 ClutterActor *actor);
442 ClutterActor * clutter_event_get_source (const ClutterEvent *event);
443 void clutter_event_set_stage (ClutterEvent *event,
444 ClutterStage *stage);
445 ClutterStage * clutter_event_get_stage (const ClutterEvent *event);
447 gint clutter_event_get_device_id (const ClutterEvent *event);
448 ClutterInputDeviceType clutter_event_get_device_type (const ClutterEvent *event);
450 void clutter_event_set_coords (ClutterEvent *event,
453 void clutter_event_get_coords (const ClutterEvent *event,
456 CLUTTER_AVAILABLE_IN_1_12
457 void clutter_event_get_position (const ClutterEvent *event,
458 ClutterPoint *position);
459 CLUTTER_AVAILABLE_IN_1_12
460 float clutter_event_get_distance (const ClutterEvent *source,
461 const ClutterEvent *target);
462 CLUTTER_AVAILABLE_IN_1_12
463 double clutter_event_get_angle (const ClutterEvent *source,
464 const ClutterEvent *target);
466 gdouble * clutter_event_get_axes (const ClutterEvent *event,
469 CLUTTER_AVAILABLE_IN_1_12
470 gboolean clutter_event_has_shift_modifier (const ClutterEvent *event);
471 CLUTTER_AVAILABLE_IN_1_12
472 gboolean clutter_event_has_control_modifier (const ClutterEvent *event);
474 void clutter_event_set_key_symbol (ClutterEvent *event,
476 guint clutter_event_get_key_symbol (const ClutterEvent *event);
477 void clutter_event_set_key_code (ClutterEvent *event,
479 guint16 clutter_event_get_key_code (const ClutterEvent *event);
480 void clutter_event_set_key_unicode (ClutterEvent *event,
481 guint32 key_unicode);
482 guint32 clutter_event_get_key_unicode (const ClutterEvent *event);
484 void clutter_event_set_button (ClutterEvent *event,
486 guint32 clutter_event_get_button (const ClutterEvent *event);
487 guint clutter_event_get_click_count (const ClutterEvent *event);
489 void clutter_event_set_related (ClutterEvent *event,
490 ClutterActor *actor);
491 ClutterActor * clutter_event_get_related (const ClutterEvent *event);
493 void clutter_event_set_scroll_direction (ClutterEvent *event,
494 ClutterScrollDirection direction);
495 ClutterScrollDirection clutter_event_get_scroll_direction (const ClutterEvent *event);
496 CLUTTER_AVAILABLE_IN_1_10
497 void clutter_event_set_scroll_delta (ClutterEvent *event,
500 CLUTTER_AVAILABLE_IN_1_10
501 void clutter_event_get_scroll_delta (const ClutterEvent *event,
505 CLUTTER_AVAILABLE_IN_1_10
506 ClutterEventSequence * clutter_event_get_event_sequence (const ClutterEvent *event);
508 guint32 clutter_keysym_to_unicode (guint keyval);
509 CLUTTER_AVAILABLE_IN_1_10
510 guint clutter_unicode_to_keysym (guint32 wc);
512 guint32 clutter_get_current_event_time (void);
513 const ClutterEvent * clutter_get_current_event (void);
517 #endif /* __CLUTTER_EVENT_H__ */