wayland: Use ClutterEvent getter methods

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
Carlos Garnacho 2023-08-04 12:33:33 +02:00
parent 71fb87a9f2
commit 64490c3489
16 changed files with 170 additions and 100 deletions

View File

@ -524,7 +524,7 @@ static gboolean
keyboard_drag_grab_key (MetaWaylandKeyboardGrab *grab, keyboard_drag_grab_key (MetaWaylandKeyboardGrab *grab,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if (event->key.keyval == CLUTTER_KEY_Escape) if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_Escape)
{ {
MetaWaylandDragGrab *drag_grab; MetaWaylandDragGrab *drag_grab;

View File

@ -501,17 +501,18 @@ default_grab_key (MetaWaylandKeyboardGrab *grab,
const ClutterEvent *event) const ClutterEvent *event)
{ {
MetaWaylandKeyboard *keyboard = grab->keyboard; MetaWaylandKeyboard *keyboard = grab->keyboard;
gboolean is_press = event->type == CLUTTER_KEY_PRESS; gboolean is_press = clutter_event_type (event) == CLUTTER_KEY_PRESS;
guint32 code = 0; guint32 code = 0;
/* Ignore autorepeat events, as autorepeat in Wayland is done on the client /* Ignore autorepeat events, as autorepeat in Wayland is done on the client
* side. */ * side. */
if (event->key.flags & CLUTTER_EVENT_FLAG_REPEATED) if (clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_REPEATED)
return FALSE; return FALSE;
code = clutter_event_get_event_code (event); code = clutter_event_get_event_code (event);
return meta_wayland_keyboard_broadcast_key (keyboard, event->key.time, return meta_wayland_keyboard_broadcast_key (keyboard,
clutter_event_get_time (event),
code, is_press); code, is_press);
} }
@ -624,9 +625,13 @@ void
meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard, meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
const ClutterKeyEvent *event) const ClutterKeyEvent *event)
{ {
gboolean is_press = event->type == CLUTTER_KEY_PRESS; gboolean is_press = clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_PRESS;
uint32_t evdev_code, hardware_keycode;
if (!update_pressed_keys (&keyboard->pressed_keys, event->evdev_code, is_press)) evdev_code = clutter_event_get_event_code ((ClutterEvent *) event);
hardware_keycode = clutter_event_get_key_code ((ClutterEvent *) event);
if (!update_pressed_keys (&keyboard->pressed_keys, evdev_code, is_press))
return; return;
/* If we get a key event but still have pending modifier state /* If we get a key event but still have pending modifier state
@ -637,29 +642,35 @@ meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
notify_modifiers (keyboard); notify_modifiers (keyboard);
keyboard->mods_changed = xkb_state_update_key (keyboard->xkb_info.state, keyboard->mods_changed = xkb_state_update_key (keyboard->xkb_info.state,
event->hardware_keycode, hardware_keycode,
is_press ? XKB_KEY_DOWN : XKB_KEY_UP); is_press ? XKB_KEY_DOWN : XKB_KEY_UP);
keyboard->mods_changed |= kbd_a11y_apply_mask (keyboard); keyboard->mods_changed |= kbd_a11y_apply_mask (keyboard);
} }
gboolean gboolean
meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard, meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
const ClutterKeyEvent *event) const ClutterKeyEvent *event)
{ {
#ifdef WITH_VERBOSE_MODE #ifdef WITH_VERBOSE_MODE
gboolean is_press = event->type == CLUTTER_KEY_PRESS; gboolean is_press =
clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_PRESS;
#endif #endif
gboolean handled; gboolean handled;
ClutterEventFlags flags;
uint32_t hardware_keycode;
flags = clutter_event_get_flags ((ClutterEvent *) event);
hardware_keycode = clutter_event_get_key_code ((ClutterEvent *) event);
/* Synthetic key events are for autorepeat. Ignore those, as /* Synthetic key events are for autorepeat. Ignore those, as
* autorepeat in Wayland is done on the client side. */ * autorepeat in Wayland is done on the client side. */
if ((event->flags & CLUTTER_EVENT_FLAG_SYNTHETIC) && if ((flags & CLUTTER_EVENT_FLAG_SYNTHETIC) &&
!(event->flags & CLUTTER_EVENT_FLAG_INPUT_METHOD)) !(flags & CLUTTER_EVENT_FLAG_INPUT_METHOD))
return FALSE; return FALSE;
meta_verbose ("Handling key %s event code %d", meta_verbose ("Handling key %s event code %d",
is_press ? "press" : "release", is_press ? "press" : "release",
event->hardware_keycode); hardware_keycode);
handled = notify_key (keyboard, (const ClutterEvent *) event); handled = notify_key (keyboard, (const ClutterEvent *) event);

View File

@ -43,7 +43,7 @@ handle_hold_begin (MetaWaylandPointer *pointer,
serial = wl_display_next_serial (seat->wl_display); serial = wl_display_next_serial (seat->wl_display);
fingers = clutter_event_get_touchpad_gesture_finger_count (event); fingers = clutter_event_get_touchpad_gesture_finger_count (event);
pointer_client->active_touchpad_gesture = event->type; pointer_client->active_touchpad_gesture = clutter_event_type (event);
wl_resource_for_each (resource, &pointer_client->hold_gesture_resources) wl_resource_for_each (resource, &pointer_client->hold_gesture_resources)
{ {
@ -85,7 +85,8 @@ handle_hold_end (MetaWaylandPointer *pointer,
seat = meta_wayland_pointer_get_seat (pointer); seat = meta_wayland_pointer_get_seat (pointer);
serial = wl_display_next_serial (seat->wl_display); serial = wl_display_next_serial (seat->wl_display);
if (event->touchpad_hold.phase == CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL) if (clutter_event_get_gesture_phase (event) ==
CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL)
cancelled = TRUE; cancelled = TRUE;
broadcast_end (pointer, serial, broadcast_end (pointer, serial,
@ -97,13 +98,13 @@ gboolean
meta_wayland_pointer_gesture_hold_handle_event (MetaWaylandPointer *pointer, meta_wayland_pointer_gesture_hold_handle_event (MetaWaylandPointer *pointer,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if (event->type != CLUTTER_TOUCHPAD_HOLD) if (clutter_event_type (event) != CLUTTER_TOUCHPAD_HOLD)
return FALSE; return FALSE;
if (!pointer->focus_client) if (!pointer->focus_client)
return FALSE; return FALSE;
switch (event->touchpad_hold.phase) switch (clutter_event_get_gesture_phase (event))
{ {
case CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN: case CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN:
handle_hold_begin (pointer, event); handle_hold_begin (pointer, event);

View File

@ -47,7 +47,7 @@ handle_pinch_begin (MetaWaylandPointer *pointer,
serial = wl_display_next_serial (seat->wl_display); serial = wl_display_next_serial (seat->wl_display);
fingers = clutter_event_get_touchpad_gesture_finger_count (event); fingers = clutter_event_get_touchpad_gesture_finger_count (event);
pointer_client->active_touchpad_gesture = event->type; pointer_client->active_touchpad_gesture = clutter_event_type (event);
wl_resource_for_each (resource, &pointer_client->pinch_gesture_resources) wl_resource_for_each (resource, &pointer_client->pinch_gesture_resources)
{ {
@ -113,7 +113,8 @@ handle_pinch_end (MetaWaylandPointer *pointer,
seat = meta_wayland_pointer_get_seat (pointer); seat = meta_wayland_pointer_get_seat (pointer);
serial = wl_display_next_serial (seat->wl_display); serial = wl_display_next_serial (seat->wl_display);
if (event->touchpad_pinch.phase == CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL) if (clutter_event_get_gesture_phase (event) ==
CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL)
cancelled = TRUE; cancelled = TRUE;
broadcast_end (pointer, serial, broadcast_end (pointer, serial,
@ -125,13 +126,13 @@ gboolean
meta_wayland_pointer_gesture_pinch_handle_event (MetaWaylandPointer *pointer, meta_wayland_pointer_gesture_pinch_handle_event (MetaWaylandPointer *pointer,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if (event->type != CLUTTER_TOUCHPAD_PINCH) if (clutter_event_type (event) != CLUTTER_TOUCHPAD_PINCH)
return FALSE; return FALSE;
if (!pointer->focus_client) if (!pointer->focus_client)
return FALSE; return FALSE;
switch (event->touchpad_pinch.phase) switch (clutter_event_get_gesture_phase (event))
{ {
case CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN: case CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN:
handle_pinch_begin (pointer, event); handle_pinch_begin (pointer, event);

View File

@ -47,7 +47,7 @@ handle_swipe_begin (MetaWaylandPointer *pointer,
serial = wl_display_next_serial (seat->wl_display); serial = wl_display_next_serial (seat->wl_display);
fingers = clutter_event_get_touchpad_gesture_finger_count (event); fingers = clutter_event_get_touchpad_gesture_finger_count (event);
pointer_client->active_touchpad_gesture = event->type; pointer_client->active_touchpad_gesture = clutter_event_type (event);
wl_resource_for_each (resource, &pointer_client->swipe_gesture_resources) wl_resource_for_each (resource, &pointer_client->swipe_gesture_resources)
{ {
@ -109,7 +109,8 @@ handle_swipe_end (MetaWaylandPointer *pointer,
seat = meta_wayland_pointer_get_seat (pointer); seat = meta_wayland_pointer_get_seat (pointer);
serial = wl_display_next_serial (seat->wl_display); serial = wl_display_next_serial (seat->wl_display);
if (event->touchpad_swipe.phase == CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL) if (clutter_event_get_gesture_phase (event) ==
CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL)
cancelled = TRUE; cancelled = TRUE;
broadcast_end (pointer, serial, broadcast_end (pointer, serial,
@ -121,13 +122,13 @@ gboolean
meta_wayland_pointer_gesture_swipe_handle_event (MetaWaylandPointer *pointer, meta_wayland_pointer_gesture_swipe_handle_event (MetaWaylandPointer *pointer,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if (event->type != CLUTTER_TOUCHPAD_SWIPE) if (clutter_event_type (event) != CLUTTER_TOUCHPAD_SWIPE)
return FALSE; return FALSE;
if (!pointer->focus_client) if (!pointer->focus_client)
return FALSE; return FALSE;
switch (event->touchpad_swipe.phase) switch (clutter_event_get_gesture_phase (event))
{ {
case CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN: case CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN:
handle_swipe_begin (pointer, event); handle_swipe_begin (pointer, event);

View File

@ -392,16 +392,15 @@ meta_wayland_pointer_send_motion (MetaWaylandPointer *pointer,
{ {
struct wl_resource *resource; struct wl_resource *resource;
uint32_t time; uint32_t time;
float sx, sy; float x, y, sx, sy;
if (!pointer->focus_client) if (!pointer->focus_client)
return; return;
time = clutter_event_get_time (event); time = clutter_event_get_time (event);
clutter_event_get_coords (event, &x, &y);
meta_wayland_surface_get_relative_coordinates (pointer->focus_surface, meta_wayland_surface_get_relative_coordinates (pointer->focus_surface,
event->motion.x, x, y, &sx, &sy);
event->motion.y,
&sx, &sy);
wl_resource_for_each (resource, &pointer->focus_client->pointer_resources) wl_resource_for_each (resource, &pointer->focus_client->pointer_resources)
{ {
@ -681,14 +680,18 @@ void
meta_wayland_pointer_update (MetaWaylandPointer *pointer, meta_wayland_pointer_update (MetaWaylandPointer *pointer,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if ((event->type == CLUTTER_MOTION || ClutterEventType event_type;
event->type == CLUTTER_ENTER ||
event->type == CLUTTER_LEAVE) && event_type = clutter_event_type (event);
if ((event_type == CLUTTER_MOTION ||
event_type == CLUTTER_ENTER ||
event_type == CLUTTER_LEAVE) &&
!clutter_event_get_event_sequence (event)) !clutter_event_get_event_sequence (event))
{ {
repick_for_event (pointer, event); repick_for_event (pointer, event);
if (event->type == CLUTTER_ENTER) if (event_type == CLUTTER_ENTER)
{ {
MetaWindow *focus_window = NULL; MetaWindow *focus_window = NULL;
ClutterInputDevice *device; ClutterInputDevice *device;
@ -713,9 +716,9 @@ meta_wayland_pointer_update (MetaWaylandPointer *pointer,
} }
} }
if (event->type == CLUTTER_MOTION || if (event_type == CLUTTER_MOTION ||
event->type == CLUTTER_BUTTON_PRESS || event_type == CLUTTER_BUTTON_PRESS ||
event->type == CLUTTER_BUTTON_RELEASE) event_type == CLUTTER_BUTTON_RELEASE)
{ {
pointer->button_count = count_buttons (event); pointer->button_count = count_buttons (event);
} }
@ -741,7 +744,7 @@ handle_button_event (MetaWaylandPointer *pointer,
{ {
gboolean implicit_grab; gboolean implicit_grab;
implicit_grab = (event->type == CLUTTER_BUTTON_PRESS) && (pointer->button_count == 1); implicit_grab = (clutter_event_type (event) == CLUTTER_BUTTON_PRESS) && (pointer->button_count == 1);
if (implicit_grab) if (implicit_grab)
{ {
pointer->grab_button = clutter_event_get_button (event); pointer->grab_button = clutter_event_get_button (event);
@ -770,6 +773,7 @@ handle_scroll_event (MetaWaylandPointer *pointer,
enum wl_pointer_axis_source source = -1; enum wl_pointer_axis_source source = -1;
MetaWaylandPointerClient *client; MetaWaylandPointerClient *client;
gboolean is_discrete_event = FALSE, is_value120_event = FALSE; gboolean is_discrete_event = FALSE, is_value120_event = FALSE;
ClutterScrollFinishFlags finish_flags;
if (clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_POINTER_EMULATED) if (clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_POINTER_EMULATED)
return; return;
@ -778,7 +782,7 @@ handle_scroll_event (MetaWaylandPointer *pointer,
if (!client) if (!client)
return; return;
switch (event->scroll.scroll_source) switch (clutter_event_get_scroll_source (event))
{ {
case CLUTTER_SCROLL_SOURCE_WHEEL: case CLUTTER_SCROLL_SOURCE_WHEEL:
source = WL_POINTER_AXIS_SOURCE_WHEEL; source = WL_POINTER_AXIS_SOURCE_WHEEL;
@ -844,6 +848,8 @@ handle_scroll_event (MetaWaylandPointer *pointer,
return; return;
} }
finish_flags = clutter_event_get_scroll_finish_flags (event);
wl_resource_for_each (resource, &client->pointer_resources) wl_resource_for_each (resource, &client->pointer_resources)
{ {
int client_version = wl_resource_get_version (resource); int client_version = wl_resource_get_version (resource);
@ -876,7 +882,7 @@ handle_scroll_event (MetaWaylandPointer *pointer,
wl_pointer_send_axis (resource, clutter_event_get_time (event), wl_pointer_send_axis (resource, clutter_event_get_time (event),
WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value); WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value);
if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL) && if ((finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL) &&
client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
wl_pointer_send_axis_stop (resource, wl_pointer_send_axis_stop (resource,
clutter_event_get_time (event), clutter_event_get_time (event),
@ -905,7 +911,7 @@ handle_scroll_event (MetaWaylandPointer *pointer,
wl_pointer_send_axis (resource, clutter_event_get_time (event), wl_pointer_send_axis (resource, clutter_event_get_time (event),
WL_POINTER_AXIS_VERTICAL_SCROLL, y_value); WL_POINTER_AXIS_VERTICAL_SCROLL, y_value);
if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_VERTICAL) && if ((finish_flags & CLUTTER_SCROLL_FINISHED_VERTICAL) &&
client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
wl_pointer_send_axis_stop (resource, wl_pointer_send_axis_stop (resource,
clutter_event_get_time (event), clutter_event_get_time (event),
@ -919,7 +925,7 @@ gboolean
meta_wayland_pointer_handle_event (MetaWaylandPointer *pointer, meta_wayland_pointer_handle_event (MetaWaylandPointer *pointer,
const ClutterEvent *event) const ClutterEvent *event)
{ {
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_MOTION: case CLUTTER_MOTION:
handle_motion_event (pointer, event); handle_motion_event (pointer, event);

View File

@ -274,8 +274,11 @@ static gboolean
event_is_synthesized_crossing (const ClutterEvent *event) event_is_synthesized_crossing (const ClutterEvent *event)
{ {
ClutterInputDevice *device; ClutterInputDevice *device;
ClutterEventType event_type;
if (event->type != CLUTTER_ENTER && event->type != CLUTTER_LEAVE) event_type = clutter_event_type (event);
if (event_type != CLUTTER_ENTER && event_type != CLUTTER_LEAVE)
return FALSE; return FALSE;
device = clutter_event_get_source_device (event); device = clutter_event_get_source_device (event);
@ -325,7 +328,7 @@ meta_wayland_seat_update (MetaWaylandSeat *seat,
!event_is_synthesized_crossing (event)) !event_is_synthesized_crossing (event))
return; return;
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_MOTION: case CLUTTER_MOTION:
case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_PRESS:
@ -359,17 +362,21 @@ gboolean
meta_wayland_seat_handle_event (MetaWaylandSeat *seat, meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
const ClutterEvent *event) const ClutterEvent *event)
{ {
ClutterEventType event_type;
if (!(clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_INPUT_METHOD) && if (!(clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_INPUT_METHOD) &&
!event_from_supported_hardware_device (seat, event)) !event_from_supported_hardware_device (seat, event))
return FALSE; return FALSE;
if (event->type == CLUTTER_BUTTON_PRESS || event_type = clutter_event_type (event);
event->type == CLUTTER_TOUCH_BEGIN)
if (event_type == CLUTTER_BUTTON_PRESS ||
event_type == CLUTTER_TOUCH_BEGIN)
{ {
meta_wayland_text_input_handle_event (seat->text_input, event); meta_wayland_text_input_handle_event (seat->text_input, event);
} }
switch (event->type) switch (event_type)
{ {
case CLUTTER_MOTION: case CLUTTER_MOTION:
case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_PRESS:

View File

@ -177,7 +177,7 @@ meta_wayland_tablet_manager_update (MetaWaylandTabletManager *manager,
if (!tablet_seat) if (!tablet_seat)
return; return;
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_PROXIMITY_IN: case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT: case CLUTTER_PROXIMITY_OUT:
@ -207,7 +207,7 @@ meta_wayland_tablet_manager_handle_event (MetaWaylandTabletManager *manager,
if (!tablet_seat) if (!tablet_seat)
return CLUTTER_EVENT_PROPAGATE; return CLUTTER_EVENT_PROPAGATE;
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_PROXIMITY_IN: case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT: case CLUTTER_PROXIMITY_OUT:

View File

@ -203,12 +203,17 @@ void
meta_wayland_tablet_pad_group_update (MetaWaylandTabletPadGroup *group, meta_wayland_tablet_pad_group_update (MetaWaylandTabletPadGroup *group,
const ClutterEvent *event) const ClutterEvent *event)
{ {
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_PAD_BUTTON_PRESS: case CLUTTER_PAD_BUTTON_PRESS:
case CLUTTER_PAD_BUTTON_RELEASE: case CLUTTER_PAD_BUTTON_RELEASE:
if (meta_wayland_tablet_pad_group_is_mode_switch_button (group, event->pad_button.button)) if (meta_wayland_tablet_pad_group_is_mode_switch_button (group,
group->current_mode = event->pad_button.mode; clutter_event_get_button (event)))
{
clutter_event_get_pad_details (event, NULL,
&group->current_mode,
NULL, NULL);
}
break; break;
default: default:
break; break;
@ -220,11 +225,13 @@ handle_pad_ring_event (MetaWaylandTabletPadGroup *group,
const ClutterEvent *event) const ClutterEvent *event)
{ {
MetaWaylandTabletPadRing *ring; MetaWaylandTabletPadRing *ring;
uint32_t number;
if (event->type != CLUTTER_PAD_RING) if (clutter_event_type (event) != CLUTTER_PAD_RING)
return FALSE; return FALSE;
ring = g_list_nth_data (group->rings, event->pad_ring.ring_number); clutter_event_get_pad_details (event, &number, NULL, NULL, NULL);
ring = g_list_nth_data (group->rings, number);
if (!ring) if (!ring)
return FALSE; return FALSE;
@ -237,11 +244,13 @@ handle_pad_strip_event (MetaWaylandTabletPadGroup *group,
const ClutterEvent *event) const ClutterEvent *event)
{ {
MetaWaylandTabletPadStrip *strip; MetaWaylandTabletPadStrip *strip;
uint32_t number;
if (event->type != CLUTTER_PAD_STRIP) if (clutter_event_type (event) != CLUTTER_PAD_STRIP)
return FALSE; return FALSE;
strip = g_list_nth_data (group->strips, event->pad_strip.strip_number); clutter_event_get_pad_details (event, &number, NULL, NULL, NULL);
strip = g_list_nth_data (group->strips, number);
if (!strip) if (!strip)
return FALSE; return FALSE;
@ -285,9 +294,10 @@ meta_wayland_tablet_pad_group_handle_event (MetaWaylandTabletPadGroup *group,
{ {
case CLUTTER_PAD_BUTTON_PRESS: case CLUTTER_PAD_BUTTON_PRESS:
case CLUTTER_PAD_BUTTON_RELEASE: case CLUTTER_PAD_BUTTON_RELEASE:
if (meta_wayland_tablet_pad_group_is_mode_switch_button (group, event->pad_button.button)) if (meta_wayland_tablet_pad_group_is_mode_switch_button (group,
clutter_event_get_button (event)))
{ {
if (event->type == CLUTTER_PAD_BUTTON_PRESS) if (clutter_event_type (event) == CLUTTER_PAD_BUTTON_PRESS)
broadcast_group_mode (group, clutter_event_get_time (event)); broadcast_group_mode (group, clutter_event_get_time (event));
return TRUE; return TRUE;
} }

View File

@ -121,13 +121,17 @@ meta_wayland_tablet_pad_ring_handle_event (MetaWaylandTabletPadRing *ring,
enum zwp_tablet_pad_ring_v2_source source; enum zwp_tablet_pad_ring_v2_source source;
gboolean source_known = FALSE; gboolean source_known = FALSE;
struct wl_resource *resource; struct wl_resource *resource;
ClutterInputDevicePadSource ring_source;
double angle;
if (wl_list_empty (focus_resources)) if (wl_list_empty (focus_resources))
return FALSE; return FALSE;
if (event->type != CLUTTER_PAD_RING) if (clutter_event_type (event) != CLUTTER_PAD_RING)
return FALSE; return FALSE;
if (event->pad_ring.ring_source == CLUTTER_INPUT_DEVICE_PAD_SOURCE_FINGER) clutter_event_get_pad_details (event, NULL, NULL, &ring_source, &angle);
if (ring_source == CLUTTER_INPUT_DEVICE_PAD_SOURCE_FINGER)
{ {
source = ZWP_TABLET_PAD_RING_V2_SOURCE_FINGER; source = ZWP_TABLET_PAD_RING_V2_SOURCE_FINGER;
source_known = TRUE; source_known = TRUE;
@ -135,8 +139,6 @@ meta_wayland_tablet_pad_ring_handle_event (MetaWaylandTabletPadRing *ring,
wl_resource_for_each (resource, focus_resources) wl_resource_for_each (resource, focus_resources)
{ {
gdouble angle = event->pad_ring.angle;
if (source_known) if (source_known)
zwp_tablet_pad_ring_v2_send_source (resource, source); zwp_tablet_pad_ring_v2_send_source (resource, source);

View File

@ -121,13 +121,17 @@ meta_wayland_tablet_pad_strip_handle_event (MetaWaylandTabletPadStrip *strip,
enum zwp_tablet_pad_strip_v2_source source; enum zwp_tablet_pad_strip_v2_source source;
gboolean source_known = FALSE; gboolean source_known = FALSE;
struct wl_resource *resource; struct wl_resource *resource;
ClutterInputDevicePadSource strip_source;
double value;
if (wl_list_empty (focus_resources)) if (wl_list_empty (focus_resources))
return FALSE; return FALSE;
if (event->type != CLUTTER_PAD_STRIP) if (clutter_event_type (event) != CLUTTER_PAD_STRIP)
return FALSE; return FALSE;
if (event->pad_strip.strip_source == CLUTTER_INPUT_DEVICE_PAD_SOURCE_FINGER) clutter_event_get_pad_details (event, NULL, NULL, &strip_source, &value);
if (strip_source == CLUTTER_INPUT_DEVICE_PAD_SOURCE_FINGER)
{ {
source = ZWP_TABLET_PAD_STRIP_V2_SOURCE_FINGER; source = ZWP_TABLET_PAD_STRIP_V2_SOURCE_FINGER;
source_known = TRUE; source_known = TRUE;
@ -135,8 +139,6 @@ meta_wayland_tablet_pad_strip_handle_event (MetaWaylandTabletPadStrip *strip,
wl_resource_for_each (resource, focus_resources) wl_resource_for_each (resource, focus_resources)
{ {
gdouble value = event->pad_strip.value;
if (source_known) if (source_known)
zwp_tablet_pad_strip_v2_send_source (resource, source); zwp_tablet_pad_strip_v2_send_source (resource, source);

View File

@ -304,13 +304,16 @@ handle_pad_button_event (MetaWaylandTabletPad *pad,
enum zwp_tablet_pad_v2_button_state button_state; enum zwp_tablet_pad_v2_button_state button_state;
struct wl_list *focus_resources = &pad->focus_resource_list; struct wl_list *focus_resources = &pad->focus_resource_list;
struct wl_resource *resource; struct wl_resource *resource;
ClutterEventType event_type;
if (wl_list_empty (focus_resources)) if (wl_list_empty (focus_resources))
return FALSE; return FALSE;
if (event->type == CLUTTER_PAD_BUTTON_PRESS) event_type = clutter_event_type (event);
if (event_type == CLUTTER_PAD_BUTTON_PRESS)
button_state = ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED; button_state = ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED;
else if (event->type == CLUTTER_PAD_BUTTON_RELEASE) else if (event_type == CLUTTER_PAD_BUTTON_RELEASE)
button_state = ZWP_TABLET_PAD_V2_BUTTON_STATE_RELEASED; button_state = ZWP_TABLET_PAD_V2_BUTTON_STATE_RELEASED;
else else
return FALSE; return FALSE;
@ -319,7 +322,8 @@ handle_pad_button_event (MetaWaylandTabletPad *pad,
{ {
zwp_tablet_pad_v2_send_button (resource, zwp_tablet_pad_v2_send_button (resource,
clutter_event_get_time (event), clutter_event_get_time (event),
event->pad_button.button, button_state); clutter_event_get_button (event),
button_state);
} }
return TRUE; return TRUE;
@ -336,7 +340,7 @@ meta_wayland_tablet_pad_handle_event_action (MetaWaylandTabletPad *pad,
mapper = display_from_pad (pad)->pad_action_mapper; mapper = display_from_pad (pad)->pad_action_mapper;
if (meta_pad_action_mapper_is_button_grabbed (mapper, device, if (meta_pad_action_mapper_is_button_grabbed (mapper, device,
event->pad_button.button)) clutter_event_get_button (event)))
return TRUE; return TRUE;
return FALSE; return FALSE;

View File

@ -383,7 +383,7 @@ meta_wayland_tablet_seat_update (MetaWaylandTabletSeat *tablet_seat,
device = clutter_event_get_source_device (event); device = clutter_event_get_source_device (event);
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_PROXIMITY_IN: case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT: case CLUTTER_PROXIMITY_OUT:
@ -422,7 +422,7 @@ meta_wayland_tablet_seat_handle_event (MetaWaylandTabletSeat *tablet_seat,
MetaWaylandTabletTool *tool = NULL; MetaWaylandTabletTool *tool = NULL;
MetaWaylandTabletPad *pad = NULL; MetaWaylandTabletPad *pad = NULL;
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_PROXIMITY_IN: case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT: case CLUTTER_PROXIMITY_OUT:

View File

@ -549,14 +549,20 @@ static void
meta_wayland_tablet_tool_account_button (MetaWaylandTabletTool *tool, meta_wayland_tablet_tool_account_button (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if (event->type == CLUTTER_BUTTON_PRESS) ClutterEventType event_type;
int button;
event_type = clutter_event_type (event);
button = clutter_event_get_button (event);
if (event_type == CLUTTER_BUTTON_PRESS)
{ {
tool->pressed_buttons |= 1 << (event->button.button - 1); tool->pressed_buttons |= 1 << (button - 1);
tool->button_count++; tool->button_count++;
} }
else if (event->type == CLUTTER_BUTTON_RELEASE) else if (event_type == CLUTTER_BUTTON_RELEASE)
{ {
tool->pressed_buttons &= ~(1 << (event->button.button - 1)); tool->pressed_buttons &= ~(1 << (button - 1));
tool->button_count--; tool->button_count--;
} }
} }
@ -670,7 +676,7 @@ broadcast_button (MetaWaylandTabletTool *tool,
wl_resource_for_each (resource, &tool->focus_resource_list) wl_resource_for_each (resource, &tool->focus_resource_list)
{ {
zwp_tablet_tool_v2_send_button (resource, tool->button_serial, button, zwp_tablet_tool_v2_send_button (resource, tool->button_serial, button,
event->type == CLUTTER_BUTTON_PRESS ? clutter_event_type (event) == CLUTTER_BUTTON_PRESS ?
ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED : ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED :
ZWP_TABLET_TOOL_V2_BUTTON_STATE_RELEASED); ZWP_TABLET_TOOL_V2_BUTTON_STATE_RELEASED);
} }
@ -683,9 +689,10 @@ broadcast_axis (MetaWaylandTabletTool *tool,
{ {
struct wl_resource *resource; struct wl_resource *resource;
uint32_t value; uint32_t value;
double val; double *axes, val;
val = event->motion.axes[axis]; axes = clutter_event_get_axes (event, NULL);
val = axes[axis];
value = val * TABLET_AXIS_MAX; value = val * TABLET_AXIS_MAX;
wl_resource_for_each (resource, &tool->focus_resource_list) wl_resource_for_each (resource, &tool->focus_resource_list)
@ -712,10 +719,11 @@ broadcast_tilt (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
struct wl_resource *resource; struct wl_resource *resource;
gdouble xtilt, ytilt; double *axes, xtilt, ytilt;
xtilt = event->motion.axes[CLUTTER_INPUT_AXIS_XTILT]; axes = clutter_event_get_axes (event, NULL);
ytilt = event->motion.axes[CLUTTER_INPUT_AXIS_YTILT]; xtilt = axes[CLUTTER_INPUT_AXIS_XTILT];
ytilt = axes[CLUTTER_INPUT_AXIS_YTILT];
wl_resource_for_each (resource, &tool->focus_resource_list) wl_resource_for_each (resource, &tool->focus_resource_list)
{ {
@ -730,9 +738,10 @@ broadcast_rotation (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
struct wl_resource *resource; struct wl_resource *resource;
gdouble rotation; double *axes, rotation;
rotation = event->motion.axes[CLUTTER_INPUT_AXIS_ROTATION]; axes = clutter_event_get_axes (event, NULL);
rotation = axes[CLUTTER_INPUT_AXIS_ROTATION];
wl_resource_for_each (resource, &tool->focus_resource_list) wl_resource_for_each (resource, &tool->focus_resource_list)
{ {
@ -746,10 +755,11 @@ broadcast_wheel (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
struct wl_resource *resource; struct wl_resource *resource;
gdouble angle; double *axes, angle;
gint32 clicks = 0; gint32 clicks = 0;
angle = event->motion.axes[CLUTTER_INPUT_AXIS_WHEEL]; axes = clutter_event_get_axes (event, NULL);
angle = axes[CLUTTER_INPUT_AXIS_WHEEL];
/* FIXME: Perform proper angle-to-clicks accumulation elsewhere */ /* FIXME: Perform proper angle-to-clicks accumulation elsewhere */
if (angle > 0.01) if (angle > 0.01)
@ -805,15 +815,21 @@ static void
handle_button_event (MetaWaylandTabletTool *tool, handle_button_event (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
ClutterEventType event_type;
int button;
if (!tool->focus_surface) if (!tool->focus_surface)
return; return;
if (event->type == CLUTTER_BUTTON_PRESS && tool->button_count == 1) event_type = clutter_event_type (event);
button = clutter_event_get_button (event);
if (event_type == CLUTTER_BUTTON_PRESS && tool->button_count == 1)
clutter_event_get_coords (event, &tool->grab_x, &tool->grab_y); clutter_event_get_coords (event, &tool->grab_x, &tool->grab_y);
if (event->type == CLUTTER_BUTTON_PRESS && event->button.button == 1) if (event_type == CLUTTER_BUTTON_PRESS && button == 1)
broadcast_down (tool, event); broadcast_down (tool, event);
else if (event->type == CLUTTER_BUTTON_RELEASE && event->button.button == 1) else if (event_type == CLUTTER_BUTTON_RELEASE && button == 1)
broadcast_up (tool, event); broadcast_up (tool, event);
else else
broadcast_button (tool, event); broadcast_button (tool, event);
@ -825,7 +841,7 @@ void
meta_wayland_tablet_tool_update (MetaWaylandTabletTool *tool, meta_wayland_tablet_tool_update (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_PRESS:
case CLUTTER_BUTTON_RELEASE: case CLUTTER_BUTTON_RELEASE:
@ -864,7 +880,7 @@ gboolean
meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool, meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_PROXIMITY_IN: case CLUTTER_PROXIMITY_IN:
/* We don't have much info here to make anything useful out of it, /* We don't have much info here to make anything useful out of it,

View File

@ -814,12 +814,16 @@ gboolean
meta_wayland_text_input_update (MetaWaylandTextInput *text_input, meta_wayland_text_input_update (MetaWaylandTextInput *text_input,
const ClutterEvent *event) const ClutterEvent *event)
{ {
ClutterEventType event_type;
if (!text_input->surface || if (!text_input->surface ||
!clutter_input_focus_is_focused (text_input->input_focus)) !clutter_input_focus_is_focused (text_input->input_focus))
return FALSE; return FALSE;
if (event->type == CLUTTER_KEY_PRESS || event_type = clutter_event_type (event);
event->type == CLUTTER_KEY_RELEASE)
if (event_type == CLUTTER_KEY_PRESS ||
event_type == CLUTTER_KEY_RELEASE)
return clutter_input_focus_filter_event (text_input->input_focus, event); return clutter_input_focus_filter_event (text_input->input_focus, event);
return FALSE; return FALSE;
@ -829,21 +833,24 @@ gboolean
meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input, meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input,
const ClutterEvent *event) const ClutterEvent *event)
{ {
ClutterEventType event_type;
gboolean retval; gboolean retval;
if (!text_input->surface || if (!text_input->surface ||
!clutter_input_focus_is_focused (text_input->input_focus)) !clutter_input_focus_is_focused (text_input->input_focus))
return FALSE; return FALSE;
if ((event->type == CLUTTER_KEY_PRESS || event_type = clutter_event_type (event);
event->type == CLUTTER_KEY_RELEASE) &&
if ((event_type == CLUTTER_KEY_PRESS ||
event_type == CLUTTER_KEY_RELEASE) &&
clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_INPUT_METHOD) clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_INPUT_METHOD)
meta_wayland_text_input_focus_flush_done (text_input->input_focus); meta_wayland_text_input_focus_flush_done (text_input->input_focus);
retval = clutter_input_focus_process_event (text_input->input_focus, event); retval = clutter_input_focus_process_event (text_input->input_focus, event);
if (event->type == CLUTTER_BUTTON_PRESS || if (event_type == CLUTTER_BUTTON_PRESS ||
event->type == CLUTTER_TOUCH_BEGIN) event_type == CLUTTER_TOUCH_BEGIN)
{ {
MetaWaylandSurface *surface = NULL; MetaWaylandSurface *surface = NULL;
MetaBackend *backend; MetaBackend *backend;

View File

@ -223,10 +223,12 @@ meta_wayland_touch_update (MetaWaylandTouch *touch,
{ {
MetaWaylandTouchInfo *touch_info; MetaWaylandTouchInfo *touch_info;
ClutterEventSequence *sequence; ClutterEventSequence *sequence;
ClutterEventType event_type;
sequence = clutter_event_get_event_sequence (event); sequence = clutter_event_get_event_sequence (event);
event_type = clutter_event_type (event);
if (event->type == CLUTTER_TOUCH_BEGIN) if (event_type == CLUTTER_TOUCH_BEGIN)
{ {
MetaWaylandSurface *surface = NULL; MetaWaylandSurface *surface = NULL;
MetaBackend *backend; MetaBackend *backend;
@ -256,15 +258,15 @@ meta_wayland_touch_update (MetaWaylandTouch *touch,
if (!touch_info) if (!touch_info)
return; return;
if (event->type != CLUTTER_TOUCH_BEGIN && if (event_type != CLUTTER_TOUCH_BEGIN &&
!touch_info->begin_delivered) !touch_info->begin_delivered)
{ {
g_hash_table_remove (touch->touches, sequence); g_hash_table_remove (touch->touches, sequence);
return; return;
} }
if (event->type == CLUTTER_TOUCH_BEGIN || if (event_type == CLUTTER_TOUCH_BEGIN ||
event->type == CLUTTER_TOUCH_END) event_type == CLUTTER_TOUCH_END)
{ {
MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (touch); MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (touch);
@ -439,7 +441,7 @@ gboolean
meta_wayland_touch_handle_event (MetaWaylandTouch *touch, meta_wayland_touch_handle_event (MetaWaylandTouch *touch,
const ClutterEvent *event) const ClutterEvent *event)
{ {
switch (event->type) switch (clutter_event_type (event))
{ {
case CLUTTER_TOUCH_BEGIN: case CLUTTER_TOUCH_BEGIN:
handle_touch_begin (touch, event); handle_touch_begin (touch, event);