mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
compositor: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
parent
17191d5a6c
commit
71fb87a9f2
@ -318,17 +318,20 @@ meta_dnd_wayland_maybe_handle_event (MetaDnd *dnd,
|
|||||||
{
|
{
|
||||||
MetaWaylandDataDevice *data_device = data_device_from_dnd (dnd);
|
MetaWaylandDataDevice *data_device = data_device_from_dnd (dnd);
|
||||||
MetaDndPrivate *priv = meta_dnd_get_instance_private (dnd);
|
MetaDndPrivate *priv = meta_dnd_get_instance_private (dnd);
|
||||||
|
ClutterEventType event_type;
|
||||||
|
|
||||||
if (!meta_wayland_data_device_get_current_grab (data_device))
|
if (!meta_wayland_data_device_get_current_grab (data_device))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_warn_if_fail (priv->dnd_during_modal);
|
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);
|
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);
|
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);
|
meta_dnd_wayland_on_key_pressed (dnd, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,10 +542,10 @@ process_mouse_move_resize_grab (MetaWindowDrag *window_drag,
|
|||||||
ClutterKeyEvent *event)
|
ClutterKeyEvent *event)
|
||||||
{
|
{
|
||||||
/* don't care about releases, but eat them, don't end grab */
|
/* 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;
|
return TRUE;
|
||||||
|
|
||||||
if (event->keyval == CLUTTER_KEY_Escape)
|
if (clutter_event_get_key_symbol ((ClutterEvent *) event) == CLUTTER_KEY_Escape)
|
||||||
{
|
{
|
||||||
MetaTileMode tile_mode;
|
MetaTileMode tile_mode;
|
||||||
|
|
||||||
@ -592,17 +592,22 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
|
|||||||
MetaEdgeResistanceFlags flags;
|
MetaEdgeResistanceFlags flags;
|
||||||
gboolean handled;
|
gboolean handled;
|
||||||
MetaRectangle frame_rect;
|
MetaRectangle frame_rect;
|
||||||
|
ClutterModifierType modifiers;
|
||||||
|
uint32_t keyval;
|
||||||
int x, y;
|
int x, y;
|
||||||
int incr;
|
int incr;
|
||||||
|
|
||||||
handled = FALSE;
|
handled = FALSE;
|
||||||
|
|
||||||
/* don't care about releases, but eat them, don't end grab */
|
/* 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;
|
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 */
|
/* don't end grab on modifier key presses */
|
||||||
if (is_modifier (event->keyval))
|
if (is_modifier (keyval))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
meta_window_get_frame_rect (window, &frame_rect);
|
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;
|
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;
|
flags |= META_EDGE_RESISTANCE_SNAP;
|
||||||
|
|
||||||
#define SMALL_INCREMENT 1
|
#define SMALL_INCREMENT 1
|
||||||
@ -619,12 +624,12 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
|
|||||||
|
|
||||||
if (flags & META_EDGE_RESISTANCE_SNAP)
|
if (flags & META_EDGE_RESISTANCE_SNAP)
|
||||||
incr = 1;
|
incr = 1;
|
||||||
else if (event->modifier_state & CLUTTER_CONTROL_MASK)
|
else if (modifiers & CLUTTER_CONTROL_MASK)
|
||||||
incr = SMALL_INCREMENT;
|
incr = SMALL_INCREMENT;
|
||||||
else
|
else
|
||||||
incr = NORMAL_INCREMENT;
|
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
|
/* End move and restore to original state. If the window was a
|
||||||
* maximized window that had been "shaken loose" we need to
|
* 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
|
* Shift + arrow to snap is sort of a hidden feature. This way
|
||||||
* people using just arrows shouldn't get too frustrated.
|
* people using just arrows shouldn't get too frustrated.
|
||||||
*/
|
*/
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_KP_Home:
|
case CLUTTER_KEY_KP_Home:
|
||||||
case CLUTTER_KEY_KP_Prior:
|
case CLUTTER_KEY_KP_Prior:
|
||||||
@ -665,7 +670,7 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_KP_Home:
|
case CLUTTER_KEY_KP_Home:
|
||||||
case CLUTTER_KEY_KP_End:
|
case CLUTTER_KEY_KP_End:
|
||||||
@ -711,15 +716,18 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
|
|||||||
{
|
{
|
||||||
MetaGrabOp op, unconstrained;
|
MetaGrabOp op, unconstrained;
|
||||||
gboolean handled;
|
gboolean handled;
|
||||||
|
uint32_t keyval;
|
||||||
|
|
||||||
op = (window_drag->grab_op & ~META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED);
|
op = (window_drag->grab_op & ~META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED);
|
||||||
unconstrained = (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;
|
handled = FALSE;
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
|
case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_Up:
|
case CLUTTER_KEY_Up:
|
||||||
case CLUTTER_KEY_KP_Up:
|
case CLUTTER_KEY_KP_Up:
|
||||||
@ -745,7 +753,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case META_GRAB_OP_KEYBOARD_RESIZING_S:
|
case META_GRAB_OP_KEYBOARD_RESIZING_S:
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_Left:
|
case CLUTTER_KEY_Left:
|
||||||
case CLUTTER_KEY_KP_Left:
|
case CLUTTER_KEY_KP_Left:
|
||||||
@ -761,7 +769,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case META_GRAB_OP_KEYBOARD_RESIZING_N:
|
case META_GRAB_OP_KEYBOARD_RESIZING_N:
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_Left:
|
case CLUTTER_KEY_Left:
|
||||||
case CLUTTER_KEY_KP_Left:
|
case CLUTTER_KEY_KP_Left:
|
||||||
@ -777,7 +785,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case META_GRAB_OP_KEYBOARD_RESIZING_W:
|
case META_GRAB_OP_KEYBOARD_RESIZING_W:
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_Up:
|
case CLUTTER_KEY_Up:
|
||||||
case CLUTTER_KEY_KP_Up:
|
case CLUTTER_KEY_KP_Up:
|
||||||
@ -793,7 +801,7 @@ process_keyboard_resize_grab_op_change (MetaWindowDrag *window_drag,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case META_GRAB_OP_KEYBOARD_RESIZING_E:
|
case META_GRAB_OP_KEYBOARD_RESIZING_E:
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_Up:
|
case CLUTTER_KEY_Up:
|
||||||
case CLUTTER_KEY_KP_Up:
|
case CLUTTER_KEY_KP_Up:
|
||||||
@ -842,18 +850,23 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
|
|||||||
int width, height;
|
int width, height;
|
||||||
MetaEdgeResistanceFlags flags;
|
MetaEdgeResistanceFlags flags;
|
||||||
MetaGravity gravity;
|
MetaGravity gravity;
|
||||||
|
ClutterModifierType modifiers;
|
||||||
|
uint32_t keyval;
|
||||||
|
|
||||||
handled = FALSE;
|
handled = FALSE;
|
||||||
|
|
||||||
/* don't care about releases, but eat them, don't end grab */
|
/* 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;
|
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 */
|
/* don't end grab on modifier key presses */
|
||||||
if (is_modifier (event->keyval))
|
if (is_modifier (keyval))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (event->keyval == CLUTTER_KEY_Escape)
|
if (keyval == CLUTTER_KEY_Escape)
|
||||||
{
|
{
|
||||||
/* End resize and restore to original state. */
|
/* End resize and restore to original state. */
|
||||||
meta_window_move_resize_frame (window_drag->effective_grab_window,
|
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;
|
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;
|
flags |= META_EDGE_RESISTANCE_SNAP;
|
||||||
|
|
||||||
#define SMALL_INCREMENT 1
|
#define SMALL_INCREMENT 1
|
||||||
@ -891,7 +904,7 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
|
|||||||
height_inc = 1;
|
height_inc = 1;
|
||||||
width_inc = 1;
|
width_inc = 1;
|
||||||
}
|
}
|
||||||
else if (event->modifier_state & CLUTTER_CONTROL_MASK)
|
else if (modifiers & CLUTTER_CONTROL_MASK)
|
||||||
{
|
{
|
||||||
width_inc = SMALL_INCREMENT;
|
width_inc = SMALL_INCREMENT;
|
||||||
height_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)
|
if (window->size_hints.height_inc > 1)
|
||||||
height_inc = window->size_hints.height_inc;
|
height_inc = window->size_hints.height_inc;
|
||||||
|
|
||||||
switch (event->keyval)
|
switch (keyval)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_Up:
|
case CLUTTER_KEY_Up:
|
||||||
case CLUTTER_KEY_KP_Up:
|
case CLUTTER_KEY_KP_Up:
|
||||||
@ -1664,6 +1677,7 @@ process_pointer_event (MetaWindowDrag *window_drag,
|
|||||||
MetaEdgeResistanceFlags flags;
|
MetaEdgeResistanceFlags flags;
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
gfloat x, y;
|
gfloat x, y;
|
||||||
|
int button;
|
||||||
|
|
||||||
window = window_drag->effective_grab_window;
|
window = window_drag->effective_grab_window;
|
||||||
if (!window)
|
if (!window)
|
||||||
@ -1673,7 +1687,7 @@ process_pointer_event (MetaWindowDrag *window_drag,
|
|||||||
if (window_drag->leading_touch_sequence != sequence)
|
if (window_drag->leading_touch_sequence != sequence)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (event->type)
|
switch (clutter_event_type (event))
|
||||||
{
|
{
|
||||||
case CLUTTER_BUTTON_PRESS:
|
case CLUTTER_BUTTON_PRESS:
|
||||||
/* This is the keybinding or menu case where we've
|
/* 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)
|
if (window_drag->leading_touch_sequence)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event->button.button == 1 ||
|
button = clutter_event_get_button (event);
|
||||||
event->button.button == (unsigned int) meta_prefs_get_mouse_button_resize ())
|
|
||||||
|
if (button == 1 ||
|
||||||
|
button == (unsigned int) meta_prefs_get_mouse_button_resize ())
|
||||||
end_grab_op (window_drag, event);
|
end_grab_op (window_drag, event);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1733,11 +1749,11 @@ static gboolean
|
|||||||
on_window_drag_event (MetaWindowDrag *window_drag,
|
on_window_drag_event (MetaWindowDrag *window_drag,
|
||||||
ClutterEvent *event)
|
ClutterEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type)
|
switch (clutter_event_type (event))
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_PRESS:
|
case CLUTTER_KEY_PRESS:
|
||||||
case CLUTTER_KEY_RELEASE:
|
case CLUTTER_KEY_RELEASE:
|
||||||
process_key_event (window_drag, &event->key);
|
process_key_event (window_drag, (ClutterKeyEvent *) event);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
process_pointer_event (window_drag, event);
|
process_pointer_event (window_drag, event);
|
||||||
|
Loading…
Reference in New Issue
Block a user