[gimp] app: clean up gimp_controller_keyboard,wheel_scroll()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: clean up gimp_controller_keyboard,wheel_scroll()
- Date: Tue, 22 Nov 2016 18:47:49 +0000 (UTC)
commit fb1dcd023944c29b9e6c85016b97c3f30bb1b58c
Author: Michael Natterer <mitch gimp org>
Date: Tue Nov 22 19:43:51 2016 +0100
app: clean up gimp_controller_keyboard,wheel_scroll()
to not use two nested if()s, and always return the result of
gimp_controller_event() when an event matches.
app/widgets/gimpcontrollerkeyboard.c | 37 ++++++++++++++-------------------
app/widgets/gimpcontrollerwheel.c | 24 ++++++++++------------
2 files changed, 27 insertions(+), 34 deletions(-)
---
diff --git a/app/widgets/gimpcontrollerkeyboard.c b/app/widgets/gimpcontrollerkeyboard.c
index 9f746e7..6b7e5be 100644
--- a/app/widgets/gimpcontrollerkeyboard.c
+++ b/app/widgets/gimpcontrollerkeyboard.c
@@ -40,11 +40,11 @@ typedef struct _KeyboardEvent KeyboardEvent;
struct _KeyboardEvent
{
- const guint keyval;
- const gchar *modifier_string;
- GdkModifierType modifiers;
- const gchar *name;
- const gchar *blurb;
+ const guint keyval;
+ const gchar *modifier_string;
+ GdkModifierType modifiers;
+ const gchar *name;
+ const gchar *blurb;
};
@@ -272,26 +272,21 @@ gimp_controller_keyboard_key_press (GimpControllerKeyboard *keyboard,
*/
for (i = G_N_ELEMENTS (keyboard_events) - 1; i >= 0; i--)
{
- if (keyboard_events[i].keyval == kevent->keyval)
+ if (keyboard_events[i].keyval == kevent->keyval &&
+ (keyboard_events[i].modifiers & kevent->state) ==
+ keyboard_events[i].modifiers)
{
- if ((keyboard_events[i].modifiers & kevent->state) ==
- keyboard_events[i].modifiers)
- {
- GimpControllerEvent controller_event;
- GimpControllerEventTrigger *trigger;
+ GimpControllerEvent controller_event;
+ GimpControllerEventTrigger *trigger;
- trigger = (GimpControllerEventTrigger *) &controller_event;
+ trigger = (GimpControllerEventTrigger *) &controller_event;
- trigger->type = GIMP_CONTROLLER_EVENT_TRIGGER;
- trigger->source = GIMP_CONTROLLER (keyboard);
- trigger->event_id = i;
+ trigger->type = GIMP_CONTROLLER_EVENT_TRIGGER;
+ trigger->source = GIMP_CONTROLLER (keyboard);
+ trigger->event_id = i;
- if (gimp_controller_event (GIMP_CONTROLLER (keyboard),
- &controller_event))
- {
- return TRUE;
- }
- }
+ return gimp_controller_event (GIMP_CONTROLLER (keyboard),
+ &controller_event);
}
}
diff --git a/app/widgets/gimpcontrollerwheel.c b/app/widgets/gimpcontrollerwheel.c
index fb9c126..11779f5 100644
--- a/app/widgets/gimpcontrollerwheel.c
+++ b/app/widgets/gimpcontrollerwheel.c
@@ -271,23 +271,21 @@ gimp_controller_wheel_scroll (GimpControllerWheel *wheel,
*/
for (i = G_N_ELEMENTS (wheel_events) - 1; i >= 0; i--)
{
- if (wheel_events[i].direction == sevent->direction)
+ if (wheel_events[i].direction == sevent->direction &&
+ (wheel_events[i].modifiers & sevent->state) ==
+ wheel_events[i].modifiers)
{
- if ((wheel_events[i].modifiers & sevent->state) ==
- wheel_events[i].modifiers)
- {
- GimpControllerEvent controller_event;
- GimpControllerEventTrigger *trigger;
+ GimpControllerEvent controller_event;
+ GimpControllerEventTrigger *trigger;
- trigger = (GimpControllerEventTrigger *) &controller_event;
+ trigger = (GimpControllerEventTrigger *) &controller_event;
- trigger->type = GIMP_CONTROLLER_EVENT_TRIGGER;
- trigger->source = GIMP_CONTROLLER (wheel);
- trigger->event_id = i;
+ trigger->type = GIMP_CONTROLLER_EVENT_TRIGGER;
+ trigger->source = GIMP_CONTROLLER (wheel);
+ trigger->event_id = i;
- return gimp_controller_event (GIMP_CONTROLLER (wheel),
- &controller_event);
- }
+ return gimp_controller_event (GIMP_CONTROLLER (wheel),
+ &controller_event);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]