st/button: Use ClutterEvent getter methods

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2860>
This commit is contained in:
Carlos Garnacho 2023-08-04 14:22:17 +02:00 committed by Marge Bot
parent a332771562
commit 75c92afa31

View File

@ -186,7 +186,8 @@ st_button_button_press (ClutterActor *actor,
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button);
int button_nr = clutter_event_get_button ((ClutterEvent *) event);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (button_nr);
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
if (priv->press_sequence)
@ -216,7 +217,8 @@ st_button_button_release (ClutterActor *actor,
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button);
int button_nr = clutter_event_get_button ((ClutterEvent *) event);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (button_nr);
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
if (priv->button_mask & mask)
@ -225,11 +227,11 @@ st_button_button_release (ClutterActor *actor,
ClutterActor *target;
gboolean is_click;
stage = clutter_event_get_stage ((ClutterEvent *) event);
stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
target = clutter_stage_get_event_actor (stage, (ClutterEvent *) event);
is_click = priv->grabbed && clutter_actor_contains (actor, target);
st_button_release (button, device, mask, is_click ? event->button : 0, NULL);
st_button_release (button, device, mask, is_click ? button_nr : 0, NULL);
priv->grabbed &= ~mask;
if (priv->grab && priv->grabbed == 0)
@ -253,6 +255,7 @@ st_button_touch_event (ClutterActor *actor,
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (1);
ClutterEventSequence *sequence;
ClutterInputDevice *device;
ClutterEventType event_type;
if (priv->pressed != 0)
return CLUTTER_EVENT_PROPAGATE;
@ -261,20 +264,21 @@ st_button_touch_event (ClutterActor *actor,
device = clutter_event_get_device ((ClutterEvent*) event);
sequence = clutter_event_get_event_sequence ((ClutterEvent*) event);
event_type = clutter_event_type ((ClutterEvent *) event);
if (event->type == CLUTTER_TOUCH_BEGIN && !priv->grab && !priv->press_sequence)
if (event_type == CLUTTER_TOUCH_BEGIN && !priv->grab && !priv->press_sequence)
{
st_button_press (button, device, 0, sequence);
return CLUTTER_EVENT_STOP;
}
else if (event->type == CLUTTER_TOUCH_END &&
else if (event_type == CLUTTER_TOUCH_END &&
priv->device == device &&
priv->press_sequence == sequence)
{
st_button_release (button, device, mask, 0, sequence);
return CLUTTER_EVENT_STOP;
}
else if (event->type == CLUTTER_TOUCH_CANCEL)
else if (event_type == CLUTTER_TOUCH_CANCEL)
{
st_button_fake_release (button);
}
@ -288,13 +292,16 @@ st_button_key_press (ClutterActor *actor,
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
uint32_t keyval;
if (priv->button_mask & ST_BUTTON_ONE)
{
if (event->keyval == CLUTTER_KEY_space ||
event->keyval == CLUTTER_KEY_Return ||
event->keyval == CLUTTER_KEY_KP_Enter ||
event->keyval == CLUTTER_KEY_ISO_Enter)
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
if (keyval == CLUTTER_KEY_space ||
keyval == CLUTTER_KEY_Return ||
keyval == CLUTTER_KEY_KP_Enter ||
keyval == CLUTTER_KEY_ISO_Enter)
{
st_button_press (button, NULL, ST_BUTTON_ONE, NULL);
return TRUE;
@ -310,13 +317,16 @@ st_button_key_release (ClutterActor *actor,
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
uint32_t keyval;
if (priv->button_mask & ST_BUTTON_ONE)
{
if (event->keyval == CLUTTER_KEY_space ||
event->keyval == CLUTTER_KEY_Return ||
event->keyval == CLUTTER_KEY_KP_Enter ||
event->keyval == CLUTTER_KEY_ISO_Enter)
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
if (keyval == CLUTTER_KEY_space ||
keyval == CLUTTER_KEY_Return ||
keyval == CLUTTER_KEY_KP_Enter ||
keyval == CLUTTER_KEY_ISO_Enter)
{
gboolean is_click;