[mutter/wip/carlosg/pad-ring-strip-action-labels: 8/9] core: Refactor strip/ring direction guessing in action handling
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/pad-ring-strip-action-labels: 8/9] core: Refactor strip/ring direction guessing in action handling
- Date: Mon, 20 Sep 2021 12:22:00 +0000 (UTC)
commit 7c828ef500292658f5f5255a89a38e90b63a21ad
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jul 16 13:00:06 2021 +0200
core: Refactor strip/ring direction guessing in action handling
Make it all happen in meta_pad_action_mapper_handle_action(), since
we'll need better handling here than just "return FALSE".
src/core/meta-pad-action-mapper.c | 74 ++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c
index 88634c32cb..5b479a67d5 100644
--- a/src/core/meta-pad-action-mapper.c
+++ b/src/core/meta-pad-action-mapper.c
@@ -581,34 +581,6 @@ meta_pad_action_mapper_handle_button (MetaPadActionMapper *mapper,
}
}
-static gboolean
-meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
- ClutterInputDevice *pad,
- MetaPadActionType action,
- guint number,
- MetaPadDirection direction,
- guint mode)
-{
- GSettings *settings;
- gboolean handled = FALSE;
- char *accel;
-
- settings = lookup_pad_action_settings (pad, action, number, direction, mode);
- accel = g_settings_get_string (settings, "keybinding");
-
- if (accel && *accel)
- {
- meta_pad_action_mapper_emulate_keybinding (mapper, accel, TRUE);
- meta_pad_action_mapper_emulate_keybinding (mapper, accel, FALSE);
- handled = TRUE;
- }
-
- g_object_unref (settings);
- g_free (accel);
-
- return handled;
-}
-
static gboolean
meta_pad_action_mapper_get_action_direction (MetaPadActionMapper *mapper,
const ClutterEvent *event,
@@ -660,12 +632,44 @@ meta_pad_action_mapper_get_action_direction (MetaPadActionMapper *mapper,
return has_direction;
}
+static gboolean
+meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
+ ClutterInputDevice *pad,
+ const ClutterEvent *event,
+ MetaPadActionType action,
+ guint number,
+ guint mode)
+{
+ MetaPadDirection direction = = META_PAD_DIRECTION_NONE;
+ GSettings *settings;
+ gboolean handled = FALSE;
+ char *accel;
+
+ if (!meta_pad_action_mapper_get_action_direction (mapper,
+ event, &direction))
+ return FALSE;
+
+ settings = lookup_pad_action_settings (pad, action, number, direction, mode);
+ accel = g_settings_get_string (settings, "keybinding");
+
+ if (accel && *accel)
+ {
+ meta_pad_action_mapper_emulate_keybinding (mapper, accel, TRUE);
+ meta_pad_action_mapper_emulate_keybinding (mapper, accel, FALSE);
+ handled = TRUE;
+ }
+
+ g_object_unref (settings);
+ g_free (accel);
+
+ return handled;
+}
+
gboolean
meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper,
const ClutterEvent *event)
{
ClutterInputDevice *pad;
- MetaPadDirection direction = META_PAD_DIRECTION_NONE;
pad = clutter_event_get_source_device ((ClutterEvent *) event);
@@ -676,22 +680,14 @@ meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper,
return meta_pad_action_mapper_handle_button (mapper, pad,
&event->pad_button);
case CLUTTER_PAD_RING:
- if (!meta_pad_action_mapper_get_action_direction (mapper,
- event, &direction))
- return FALSE;
- return meta_pad_action_mapper_handle_action (mapper, pad,
+ return meta_pad_action_mapper_handle_action (mapper, pad, event,
META_PAD_ACTION_RING,
event->pad_ring.ring_number,
- direction,
event->pad_ring.mode);
case CLUTTER_PAD_STRIP:
- if (!meta_pad_action_mapper_get_action_direction (mapper,
- event, &direction))
- return FALSE;
- return meta_pad_action_mapper_handle_action (mapper, pad,
+ return meta_pad_action_mapper_handle_action (mapper, pad, event,
META_PAD_ACTION_STRIP,
event->pad_strip.strip_number,
- direction,
event->pad_strip.mode);
default:
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]