compositor: 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:30:13 +02:00
parent 17191d5a6c
commit 71fb87a9f2
2 changed files with 47 additions and 28 deletions

View File

@ -318,17 +318,20 @@ meta_dnd_wayland_maybe_handle_event (MetaDnd *dnd,
{
MetaWaylandDataDevice *data_device = data_device_from_dnd (dnd);
MetaDndPrivate *priv = meta_dnd_get_instance_private (dnd);
ClutterEventType event_type;
if (!meta_wayland_data_device_get_current_grab (data_device))
return;
g_warn_if_fail (priv->dnd_during_modal);
if (event->type == CLUTTER_MOTION)
event_type = clutter_event_type (event);
if (event_type == CLUTTER_MOTION)
meta_dnd_wayland_on_motion_event (dnd, event);
else if (event->type == CLUTTER_BUTTON_RELEASE)
else if (event_type == CLUTTER_BUTTON_RELEASE)
meta_dnd_wayland_on_button_released (dnd, event);
else if (event->type == CLUTTER_KEY_PRESS)
else if (event_type == CLUTTER_KEY_PRESS)
meta_dnd_wayland_on_key_pressed (dnd, event);
}

View File

@ -542,10 +542,10 @@ process_mouse_move_resize_grab (MetaWindowDrag *window_drag,
ClutterKeyEvent *event)
{
/* don't care about releases, but eat them, don't end grab */
if (event->type == CLUTTER_KEY_RELEASE)
if (clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_RELEASE)
return TRUE;
if (event->keyval == CLUTTER_KEY_Escape)
if (clutter_event_get_key_symbol ((ClutterEvent *) event) == CLUTTER_KEY_Escape)
{
MetaTileMode tile_mode;
@ -592,17 +592,22 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
MetaEdgeResistanceFlags flags;
gboolean handled;
MetaRectangle frame_rect;
ClutterModifierType modifiers;
uint32_t keyval;
int x, y;
int incr;
handled = FALSE;
/* don't care about releases, but eat them, don't end grab */
if (event->type == CLUTTER_KEY_RELEASE)
if (clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_RELEASE)
return TRUE;
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
modifiers = clutter_event_get_state ((ClutterEvent *) event);
/* don't end grab on modifier key presses */
if (is_modifier (event->keyval))
if (is_modifier (keyval))
return TRUE;
meta_window_get_frame_rect (window, &frame_rect);
@ -611,7 +616,7 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
flags = META_EDGE_RESISTANCE_KEYBOARD_OP | META_EDGE_RESISTANCE_WINDOWS;
if ((event->modifier_state & CLUTTER_SHIFT_MASK) != 0)
if ((modifiers & CLUTTER_SHIFT_MASK) != 0)
flags |= META_EDGE_RESISTANCE_SNAP;
#define SMALL_INCREMENT 1
@ -619,12 +624,12 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
if (flags & META_EDGE_RESISTANCE_SNAP)
incr = 1;
else if (event->modifier_state & CLUTTER_CONTROL_MASK)
else if (modifiers & CLUTTER_CONTROL_MASK)
incr = SMALL_INCREMENT;
else
incr = NORMAL_INCREMENT;
if (event->keyval == CLUTTER_KEY_Escape)
if (keyval == CLUTTER_KEY_Escape)
{
/* End move and restore to original state. If the window was a
* maximized window that had been "shaken loose" we need to
@ -647,7 +652,7 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
* Shift + arrow to snap is sort of a hidden feature. This way
* people using just arrows shouldn't get too frustrated.
*/
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_KP_Home:
case CLUTTER_KEY_KP_Prior:
@ -665,7 +670,7 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
break;
}
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_KP_Home:
case CLUTTER_KEY_KP_End:
@ -711,15 +716,18 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
{
MetaGrabOp op, unconstrained;
gboolean handled;
uint32_t keyval;
op = (window_drag->grab_op & ~META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED);
unconstrained = (window_drag->grab_op & META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED);
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
handled = FALSE;
switch (op)
{
case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_Up:
case CLUTTER_KEY_KP_Up:
@ -745,7 +753,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
break;
case META_GRAB_OP_KEYBOARD_RESIZING_S:
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_Left:
case CLUTTER_KEY_KP_Left:
@ -761,7 +769,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
break;
case META_GRAB_OP_KEYBOARD_RESIZING_N:
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_Left:
case CLUTTER_KEY_KP_Left:
@ -777,7 +785,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
break;
case META_GRAB_OP_KEYBOARD_RESIZING_W:
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_Up:
case CLUTTER_KEY_KP_Up:
@ -793,7 +801,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
break;
case META_GRAB_OP_KEYBOARD_RESIZING_E:
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_Up:
case CLUTTER_KEY_KP_Up:
@ -842,18 +850,23 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
int width, height;
MetaEdgeResistanceFlags flags;
MetaGravity gravity;
ClutterModifierType modifiers;
uint32_t keyval;
handled = FALSE;
/* don't care about releases, but eat them, don't end grab */
if (event->type == CLUTTER_KEY_RELEASE)
if (clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_RELEASE)
return TRUE;
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
modifiers = clutter_event_get_state ((ClutterEvent *) event);
/* don't end grab on modifier key presses */
if (is_modifier (event->keyval))
if (is_modifier (keyval))
return TRUE;
if (event->keyval == CLUTTER_KEY_Escape)
if (keyval == CLUTTER_KEY_Escape)
{
/* End resize and restore to original state. */
meta_window_move_resize_frame (window_drag->effective_grab_window,
@ -880,7 +893,7 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
flags = META_EDGE_RESISTANCE_KEYBOARD_OP;
if ((event->modifier_state & CLUTTER_SHIFT_MASK) != 0)
if ((modifiers & CLUTTER_SHIFT_MASK) != 0)
flags |= META_EDGE_RESISTANCE_SNAP;
#define SMALL_INCREMENT 1
@ -891,7 +904,7 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
height_inc = 1;
width_inc = 1;
}
else if (event->modifier_state & CLUTTER_CONTROL_MASK)
else if (modifiers & CLUTTER_CONTROL_MASK)
{
width_inc = SMALL_INCREMENT;
height_inc = SMALL_INCREMENT;
@ -910,7 +923,7 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
if (window->size_hints.height_inc > 1)
height_inc = window->size_hints.height_inc;
switch (event->keyval)
switch (keyval)
{
case CLUTTER_KEY_Up:
case CLUTTER_KEY_KP_Up:
@ -1664,6 +1677,7 @@ process_pointer_event (MetaWindowDrag *window_drag,
MetaEdgeResistanceFlags flags;
MetaWindow *window;
gfloat x, y;
int button;
window = window_drag->effective_grab_window;
if (!window)
@ -1673,7 +1687,7 @@ process_pointer_event (MetaWindowDrag *window_drag,
if (window_drag->leading_touch_sequence != sequence)
return;
switch (event->type)
switch (clutter_event_type (event))
{
case CLUTTER_BUTTON_PRESS:
/* This is the keybinding or menu case where we've
@ -1690,8 +1704,10 @@ process_pointer_event (MetaWindowDrag *window_drag,
if (window_drag->leading_touch_sequence)
return;
if (event->button.button == 1 ||
event->button.button == (unsigned int) meta_prefs_get_mouse_button_resize ())
button = clutter_event_get_button (event);
if (button == 1 ||
button == (unsigned int) meta_prefs_get_mouse_button_resize ())
end_grab_op (window_drag, event);
break;
@ -1733,11 +1749,11 @@ static gboolean
on_window_drag_event (MetaWindowDrag *window_drag,
ClutterEvent *event)
{
switch (event->type)
switch (clutter_event_type (event))
{
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
process_key_event (window_drag, &event->key);
process_key_event (window_drag, (ClutterKeyEvent *) event);
break;
default:
process_pointer_event (window_drag, event);