clutter: Make ClutterEvent structs private

All ClutterEvent users have been changed to use getter methods
instead of direct field access. We may now make the ClutterEvent
union/structs entirely opaque by moving the definitions out of
public headers.

All future usage of ClutterEvent data should be done through
getter methods.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
Carlos Garnacho 2023-08-03 23:18:06 +02:00
parent ba4795a5f9
commit 46cb355799
2 changed files with 240 additions and 460 deletions

View File

@ -34,6 +34,246 @@
#include <math.h>
struct _ClutterAnyEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
};
struct _ClutterKeyEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterModifierType modifier_state;
uint32_t keyval;
uint16_t hardware_keycode;
gunichar unicode_value;
uint32_t evdev_code;
ClutterInputDevice *device;
};
struct _ClutterButtonEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
float x;
float y;
ClutterModifierType modifier_state;
uint32_t button;
double *axes; /* Future use */
ClutterInputDevice *device;
uint32_t evdev_code;
};
struct _ClutterProximityEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterInputDevice *device;
};
struct _ClutterCrossingEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
float x;
float y;
ClutterInputDevice *device;
ClutterEventSequence *sequence;
ClutterActor *source;
ClutterActor *related;
};
struct _ClutterMotionEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
float x;
float y;
ClutterModifierType modifier_state;
double *axes; /* Future use */
ClutterInputDevice *device;
int64_t time_us;
double dx;
double dy;
double dx_unaccel;
double dy_unaccel;
double dx_constrained;
double dy_constrained;
};
struct _ClutterScrollEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
float x;
float y;
ClutterScrollDirection direction;
ClutterModifierType modifier_state;
double *axes; /* future use */
ClutterInputDevice *device;
ClutterScrollSource scroll_source;
ClutterScrollFinishFlags finish_flags;
};
struct _ClutterTouchEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
float x;
float y;
ClutterEventSequence *sequence;
ClutterModifierType modifier_state;
double *axes; /* reserved */
ClutterInputDevice *device;
};
struct _ClutterTouchpadPinchEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterTouchpadGesturePhase phase;
float x;
float y;
float dx;
float dy;
float dx_unaccel;
float dy_unaccel;
float angle_delta;
float scale;
uint32_t n_fingers;
};
struct _ClutterTouchpadSwipeEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterTouchpadGesturePhase phase;
uint32_t n_fingers;
float x;
float y;
float dx;
float dy;
float dx_unaccel;
float dy_unaccel;
};
struct _ClutterTouchpadHoldEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterTouchpadGesturePhase phase;
uint32_t n_fingers;
float x;
float y;
};
struct _ClutterPadButtonEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
uint32_t button;
uint32_t group;
ClutterInputDevice *device;
uint32_t mode;
};
struct _ClutterPadStripEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterInputDevice *device;
ClutterInputDevicePadSource strip_source;
uint32_t strip_number;
uint32_t group;
double value;
uint32_t mode;
};
struct _ClutterPadRingEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterInputDevice *device;
ClutterInputDevicePadSource ring_source;
uint32_t ring_number;
uint32_t group;
double angle;
uint32_t mode;
};
struct _ClutterDeviceEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
ClutterInputDevice *device;
};
struct _ClutterIMEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
char *text;
int32_t offset;
int32_t anchor;
uint32_t len;
ClutterPreeditResetMode mode;
};
union _ClutterEvent
{
/*< private >*/
ClutterEventType type;
ClutterAnyEvent any;
ClutterButtonEvent button;
ClutterKeyEvent key;
ClutterMotionEvent motion;
ClutterScrollEvent scroll;
ClutterCrossingEvent crossing;
ClutterTouchEvent touch;
ClutterTouchpadPinchEvent touchpad_pinch;
ClutterTouchpadSwipeEvent touchpad_swipe;
ClutterTouchpadHoldEvent touchpad_hold;
ClutterProximityEvent proximity;
ClutterPadButtonEvent pad_button;
ClutterPadStripEvent pad_strip;
ClutterPadRingEvent pad_ring;
ClutterDeviceEvent device;
ClutterIMEvent im;
};
typedef struct _ClutterEventPrivate {
ClutterEvent base;

View File

@ -109,466 +109,6 @@ typedef struct _ClutterPadRingEvent ClutterPadRingEvent;
typedef struct _ClutterDeviceEvent ClutterDeviceEvent;
typedef struct _ClutterIMEvent ClutterIMEvent;
/**
* ClutterAnyEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @source: event source actor
*
* Common members for a #ClutterEvent
*/
struct _ClutterAnyEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
};
/**
* ClutterKeyEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @modifier_state: key modifiers
* @keyval: raw key value
* @hardware_keycode: raw hardware key value
* @unicode_value: Unicode representation
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Key event
*/
struct _ClutterKeyEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterModifierType modifier_state;
guint keyval;
guint16 hardware_keycode;
gunichar unicode_value;
uint32_t evdev_code;
ClutterInputDevice *device;
};
/**
* ClutterButtonEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @x: event X coordinate, relative to the stage
* @y: event Y coordinate, relative to the stage
* @modifier_state: button modifiers
* @button: event button
* @axes: reserved for future use
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Button event.
*
* The event coordinates are relative to the stage that received the
* event, and can be transformed into actor-relative coordinates by
* using clutter_actor_transform_stage_point().
*/
struct _ClutterButtonEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
gfloat x;
gfloat y;
ClutterModifierType modifier_state;
guint32 button;
gdouble *axes; /* Future use */
ClutterInputDevice *device;
uint32_t evdev_code;
};
/**
* ClutterProximityEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Event for tool proximity in tablet devices8
*/
struct _ClutterProximityEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterInputDevice *device;
};
/**
* ClutterCrossingEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @x: event X coordinate
* @y: event Y coordinate
* @related: actor related to the crossing
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Event for the movement of the pointer across different actors
*/
struct _ClutterCrossingEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
gfloat x;
gfloat y;
ClutterInputDevice *device;
ClutterEventSequence *sequence;
ClutterActor *source;
ClutterActor *related;
};
/**
* ClutterMotionEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @x: event X coordinate
* @y: event Y coordinate
* @modifier_state: button modifiers
* @axes: reserved for future use
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Event for the pointer motion
*/
struct _ClutterMotionEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
gfloat x;
gfloat y;
ClutterModifierType modifier_state;
gdouble *axes; /* Future use */
ClutterInputDevice *device;
int64_t time_us;
double dx;
double dy;
double dx_unaccel;
double dy_unaccel;
double dx_constrained;
double dy_constrained;
};
/**
* ClutterScrollEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @x: event X coordinate
* @y: event Y coordinate
* @direction: direction of the scrolling
* @modifier_state: button modifiers
* @axes: reserved for future use
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
* @scroll_source: the source of scroll events. This field is available since 1.26
* @finish_flags: the axes that were stopped in this event. This field is available since 1.26
*
* Scroll wheel (or similar device) event
*/
struct _ClutterScrollEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
gfloat x;
gfloat y;
ClutterScrollDirection direction;
ClutterModifierType modifier_state;
gdouble *axes; /* future use */
ClutterInputDevice *device;
ClutterScrollSource scroll_source;
ClutterScrollFinishFlags finish_flags;
};
/**
* ClutterTouchEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
* @sequence: the event sequence that this event belongs to
* @modifier_state: (type ClutterModifierType): a bit-mask representing the state
* of modifier keys (e.g. Control, Shift, and Alt) and the pointer
* buttons. See #ClutterModifierType
* @axes: reserved
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Used for touch events.
*
* The @type field will be one of %CLUTTER_TOUCH_BEGIN, %CLUTTER_TOUCH_END,
* %CLUTTER_TOUCH_UPDATE, or %CLUTTER_TOUCH_CANCEL.
*
* Touch events are grouped into sequences; each touch sequence will begin
* with a %CLUTTER_TOUCH_BEGIN event, progress with %CLUTTER_TOUCH_UPDATE
* events, and end either with a %CLUTTER_TOUCH_END event or with a
* %CLUTTER_TOUCH_CANCEL event.
*
* With multi-touch capable devices there can be multiple event sequence
* running at the same time.
*/
struct _ClutterTouchEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
gfloat x;
gfloat y;
ClutterEventSequence *sequence;
ClutterModifierType modifier_state;
gdouble *axes; /* reserved */
ClutterInputDevice *device;
};
/**
* ClutterTouchpadPinchEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @phase: the current phase of the gesture
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
* @dx: movement delta of the pinch focal point in the X axis
* @dy: movement delta of the pinch focal point in the Y axis
* @dx_unaccel: unaccelerated movement delta of the pinch focal
* point in the X axis
* @dy_unaccel: unaccelerated movement delta of the pinch focal
* point in the Y axis
* @angle_delta: angle delta in degrees, clockwise rotations are
* represented by positive deltas
* @scale: the current scale
*
* Used for touchpad pinch gesture events.
*
* The current state of the gesture will be determined by the @phase field.
*
* Each event with phase %CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN
* will report a @scale of 1.0, all later phases in the gesture
* report the current scale relative to the initial 1.0 value
* (eg. 0.5 being half the size, 2.0 twice as big).4
*/
struct _ClutterTouchpadPinchEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterTouchpadGesturePhase phase;
gfloat x;
gfloat y;
gfloat dx;
gfloat dy;
gfloat dx_unaccel;
gfloat dy_unaccel;
gfloat angle_delta;
gfloat scale;
guint n_fingers;
};
/**
* ClutterTouchpadSwipeEvent
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @phase: the current phase of the gesture
* @n_fingers: the number of fingers triggering the swipe
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
* @dx: movement delta of the swipe center point in the X axis
* @dy: movement delta of the swipe center point in the Y axis
* @dx_unaccel: unaccelerated movement delta of the swipe center
* point in the X axis
* @dy_unaccel: unaccelerated movement delta of the swipe center
* point in the Y axis
*
* Used for touchpad swipe gesture events.
*
* The current state of the gesture will be determined by the @phase field.4
*/
struct _ClutterTouchpadSwipeEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterTouchpadGesturePhase phase;
guint n_fingers;
gfloat x;
gfloat y;
gfloat dx;
gfloat dy;
gfloat dx_unaccel;
gfloat dy_unaccel;
};
/**
* ClutterTouchpadHoldEvent
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @phase: the current phase of the gesture
* @n_fingers: the number of fingers triggering the swipe
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
*
* Used for touchpad hold gesture events.
*
* The current state of the gesture will be determined by the @phase field.
*
* A hold gesture starts when the user places one or many fingers on the
* touchpad and ends when all fingers are lifted. It is cancelled when the
* finger(s) move past a certain threshold.
* Unlike swipe and pinch, @phase can only be
* CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN, CLUTTER_TOUCHPAD_GESTURE_PHASE_END and
* CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL.
*/
struct _ClutterTouchpadHoldEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterTouchpadGesturePhase phase;
uint32_t n_fingers;
float x;
float y;
};
struct _ClutterPadButtonEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
guint32 button;
guint32 group;
ClutterInputDevice *device;
guint32 mode;
};
struct _ClutterPadStripEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterInputDevice *device;
ClutterInputDevicePadSource strip_source;
guint32 strip_number;
guint32 group;
gdouble value;
guint32 mode;
};
struct _ClutterPadRingEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterInputDevice *device;
ClutterInputDevicePadSource ring_source;
guint32 ring_number;
guint32 group;
gdouble angle;
guint32 mode;
};
struct _ClutterDeviceEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterInputDevice *device;
};
struct _ClutterIMEvent
{
ClutterEventType type;
uint32_t time;
ClutterEventFlags flags;
char *text;
int32_t offset;
int32_t anchor;
uint32_t len;
ClutterPreeditResetMode mode;
};
/**
* ClutterEvent:
*
* User and window system events
*
* The events usually come from the windowing backend, but can also
* be synthesized by Clutter itself or by the application code.
*/
union _ClutterEvent
{
/*< private >*/
ClutterEventType type;
ClutterAnyEvent any;
ClutterButtonEvent button;
ClutterKeyEvent key;
ClutterMotionEvent motion;
ClutterScrollEvent scroll;
ClutterCrossingEvent crossing;
ClutterTouchEvent touch;
ClutterTouchpadPinchEvent touchpad_pinch;
ClutterTouchpadSwipeEvent touchpad_swipe;
ClutterTouchpadHoldEvent touchpad_hold;
ClutterProximityEvent proximity;
ClutterPadButtonEvent pad_button;
ClutterPadStripEvent pad_strip;
ClutterPadRingEvent pad_ring;
ClutterDeviceEvent device;
ClutterIMEvent im;
};
/**
* ClutterEventFilterFunc:
* @event: the event that is going to be emitted