Rename functions for left handed device configurations
authorStephen Chandler Paul <thatslyude@gmail.com>
Wed, 7 Jan 2015 02:20:22 +0000 (21:20 -0500)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 15 Jan 2015 00:17:57 +0000 (10:17 +1000)
Some devices require more than just flipping around the buttons, such as
tablets.
When it comes to devices like tablets, because the position of the palm rest is
on the right, the entire tablet has to be flipped around in order to be usable
by lefties. As such, this requires that we reverse the coordinates of the
tablets in addition to flipping the buttons on the tablet. As such, renaming
these functions so that they aren't specific to devices where only the buttons
are flipped seems appropriate.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad.c
src/evdev.c
src/evdev.h
src/libinput.c
src/libinput.h
src/libinput.sym
test/pointer.c
test/touch.c
test/touchpad.c
tools/event-debug.c
tools/shared.c

index 7e8306d4b2c209259f4b139227df7622da87cfef..34b107e2725f4ec8f2ea9e3c4ca3c46d067ec224 100644 (file)
@@ -1310,7 +1310,7 @@ tp_change_to_left_handed(struct evdev_device *device)
 {
        struct tp_dispatch *tp = (struct tp_dispatch *)device->dispatch;
 
-       if (device->buttons.want_left_handed == device->buttons.left_handed)
+       if (device->left_handed.want_enabled == device->left_handed.enabled)
                return;
 
        if (tp->buttons.state & 0x3) /* BTN_LEFT|BTN_RIGHT */
@@ -1319,7 +1319,7 @@ tp_change_to_left_handed(struct evdev_device *device)
        /* tapping and clickfinger aren't affected by left-handed config,
         * so checking physical buttons is enough */
 
-       device->buttons.left_handed = device->buttons.want_left_handed;
+       device->left_handed.enabled = device->left_handed.want_enabled;
 }
 
 struct model_lookup_t {
index 2d73d6906ab185f4b76a4978121ba66fbe2d0cee..6edacba6743e015c9b3b3b59d681cc4ceb953f5a 100644 (file)
@@ -119,8 +119,8 @@ evdev_pointer_notify_button(struct evdev_device *device,
                pointer_notify_button(&device->base, time, button, state);
 
                if (state == LIBINPUT_BUTTON_STATE_RELEASED &&
-                   device->buttons.change_to_left_handed)
-                       device->buttons.change_to_left_handed(device);
+                   device->left_handed.change_to_enabled)
+                       device->left_handed.change_to_enabled(device);
 
                if (state == LIBINPUT_BUTTON_STATE_RELEASED &&
                    device->scroll.change_scroll_method)
@@ -822,13 +822,13 @@ evdev_left_handed_has(struct libinput_device *device)
 static void
 evdev_change_to_left_handed(struct evdev_device *device)
 {
-       if (device->buttons.want_left_handed == device->buttons.left_handed)
+       if (device->left_handed.want_enabled == device->left_handed.enabled)
                return;
 
        if (evdev_any_button_down(device))
                return;
 
-       device->buttons.left_handed = device->buttons.want_left_handed;
+       device->left_handed.enabled = device->left_handed.want_enabled;
 }
 
 static enum libinput_config_status
@@ -836,9 +836,9 @@ evdev_left_handed_set(struct libinput_device *device, int left_handed)
 {
        struct evdev_device *evdev_device = (struct evdev_device *)device;
 
-       evdev_device->buttons.want_left_handed = left_handed ? true : false;
+       evdev_device->left_handed.want_enabled = left_handed ? true : false;
 
-       evdev_device->buttons.change_to_left_handed(evdev_device);
+       evdev_device->left_handed.change_to_enabled(evdev_device);
 
        return LIBINPUT_CONFIG_STATUS_SUCCESS;
 }
@@ -850,7 +850,7 @@ evdev_left_handed_get(struct libinput_device *device)
 
        /* return the wanted configuration, even if it hasn't taken
         * effect yet! */
-       return evdev_device->buttons.want_left_handed;
+       return evdev_device->left_handed.want_enabled;
 }
 
 static int
@@ -863,14 +863,14 @@ int
 evdev_init_left_handed(struct evdev_device *device,
                       void (*change_to_left_handed)(struct evdev_device *))
 {
-       device->buttons.config_left_handed.has = evdev_left_handed_has;
-       device->buttons.config_left_handed.set = evdev_left_handed_set;
-       device->buttons.config_left_handed.get = evdev_left_handed_get;
-       device->buttons.config_left_handed.get_default = evdev_left_handed_get_default;
-       device->base.config.left_handed = &device->buttons.config_left_handed;
-       device->buttons.left_handed = false;
-       device->buttons.want_left_handed = false;
-       device->buttons.change_to_left_handed = change_to_left_handed;
+       device->left_handed.config.has = evdev_left_handed_has;
+       device->left_handed.config.set = evdev_left_handed_set;
+       device->left_handed.config.get = evdev_left_handed_get;
+       device->left_handed.config.get_default = evdev_left_handed_get_default;
+       device->base.config.left_handed = &device->left_handed.config;
+       device->left_handed.enabled = false;
+       device->left_handed.want_enabled = false;
+       device->left_handed.change_to_enabled = change_to_left_handed;
 
        return 0;
 }
@@ -1064,7 +1064,7 @@ fallback_dispatch_create(struct libinput_device *device)
 
        dispatch->interface = &fallback_interface;
 
-       if (evdev_device->buttons.want_left_handed &&
+       if (evdev_device->left_handed.want_enabled &&
            evdev_init_left_handed(evdev_device,
                                   evdev_change_to_left_handed) == -1) {
                free(dispatch);
@@ -1477,7 +1477,7 @@ evdev_configure_device(struct evdev_device *device)
                         has_button ? " button" : "");
 
                /* want left-handed config option */
-               device->buttons.want_left_handed = true;
+               device->left_handed.want_enabled = true;
                /* want natural-scroll config option */
                device->scroll.natural_scrolling_enabled = true;
        }
index 2171c5adf2a31e25429f35f7b4206a0639e74c4a..0f2c5acc0ac17424e385f0980ab57fd6cdcaab1b 100644 (file)
@@ -144,15 +144,15 @@ struct evdev_device {
        uint8_t key_count[KEY_CNT];
 
        struct {
-               struct libinput_device_config_left_handed config_left_handed;
+               struct libinput_device_config_left_handed config;
                /* left-handed currently enabled */
-               bool left_handed;
+               bool enabled;
                /* set during device init if we want left_handed config,
                 * used at runtime to delay the effect until buttons are up */
-               bool want_left_handed;
+               bool want_enabled;
                /* Checks if buttons are down and commits the setting */
-               void (*change_to_left_handed)(struct evdev_device *device);
-       } buttons;
+               void (*change_to_enabled)(struct evdev_device *device);
+       } left_handed;
 
        int dpi; /* HW resolution */
        struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
@@ -332,7 +332,7 @@ static inline uint32_t
 evdev_to_left_handed(struct evdev_device *device,
                     uint32_t button)
 {
-       if (device->buttons.left_handed) {
+       if (device->left_handed.enabled) {
                if (button == BTN_LEFT)
                        return BTN_RIGHT;
                else if (button == BTN_RIGHT)
index 00ab5f21dbc70d2870cae58d8a9cf57efc874492..6f45405e9613d97991babd3f48d33989f5aa2ea9 100644 (file)
@@ -1599,7 +1599,7 @@ libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput
 }
 
 LIBINPUT_EXPORT int
-libinput_device_config_buttons_has_left_handed(struct libinput_device *device)
+libinput_device_config_left_handed_is_available(struct libinput_device *device)
 {
        if (!device->config.left_handed)
                return 0;
@@ -1608,28 +1608,28 @@ libinput_device_config_buttons_has_left_handed(struct libinput_device *device)
 }
 
 LIBINPUT_EXPORT enum libinput_config_status
-libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
-                                              int left_handed)
+libinput_device_config_left_handed_set(struct libinput_device *device,
+                                      int left_handed)
 {
-       if (!libinput_device_config_buttons_has_left_handed(device))
+       if (!libinput_device_config_left_handed_is_available(device))
                return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
 
        return device->config.left_handed->set(device, left_handed);
 }
 
 LIBINPUT_EXPORT int
-libinput_device_config_buttons_get_left_handed(struct libinput_device *device)
+libinput_device_config_left_handed_get(struct libinput_device *device)
 {
-       if (!libinput_device_config_buttons_has_left_handed(device))
+       if (!libinput_device_config_left_handed_is_available(device))
                return 0;
 
        return device->config.left_handed->get(device);
 }
 
 LIBINPUT_EXPORT int
-libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device)
+libinput_device_config_left_handed_get_default(struct libinput_device *device)
 {
-       if (!libinput_device_config_buttons_has_left_handed(device))
+       if (!libinput_device_config_left_handed_is_available(device))
                return 0;
 
        return device->config.left_handed->get_default(device);
index 276660b97286cf7e47ada2b3d0267bea009c90f7..dbc4b2e244c27efb310a68ef2b59ac17b498bcfb 100644 (file)
@@ -2102,33 +2102,32 @@ libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput
 /**
  * @ingroup config
  *
- * Check if a device has a button configuration that supports left-handed
- * usage.
+ * Check if a device has a configuration that supports left-handed usage.
  *
  * @param device The device to configure
  * @return Non-zero if the device can be set to left-handed, or zero
  * otherwise
  *
- * @see libinput_device_config_buttons_set_left_handed
- * @see libinput_device_config_buttons_get_left_handed
- * @see libinput_device_config_buttons_get_default_left_handed
+ * @see libinput_device_config_left_handed_set
+ * @see libinput_device_config_left_handed_get
+ * @see libinput_device_config_left_handed_get_default
  */
 int
-libinput_device_config_buttons_has_left_handed(struct libinput_device *device);
+libinput_device_config_left_handed_is_available(struct libinput_device *device);
 
 /**
  * @ingroup config
  *
- * Set the left-handed configuration of the device. A device in left-handed
- * mode sends a left button event instead of the right button and vice
- * versa.
+ * Set the left-handed configuration of the device. For example, a pointing
+ * device may reverse it's buttons and send a right button click when the
+ * left button is pressed, and vice versa.
  *
- * The exact button behavior is device-dependent. On a mouse and most
- * pointing devices, left and right buttons are swapped but the middle
- * button is unmodified. On a touchpad, physical buttons (if present) are
- * swapped. On a clickpad, the top and bottom software-emulated buttons are
- * swapped where present, the main area of the touchpad remains a left
- * button. Tapping and clickfinger behavior is not affected by this setting.
+ * The exact behavior is device-dependent. On a mouse and most pointing
+ * devices, left and right buttons are swapped but the middle button is
+ * unmodified. On a touchpad, physical buttons (if present) are swapped. On a
+ * clickpad, the top and bottom software-emulated buttons are swapped where
+ * present, the main area of the touchpad remains a left button. Tapping and
+ * clickfinger behavior is not affected by this setting.
  *
  * Changing the left-handed configuration of a device may not take effect
  * until all buttons have been logically released.
@@ -2137,13 +2136,13 @@ libinput_device_config_buttons_has_left_handed(struct libinput_device *device);
  * @param left_handed Zero to disable, non-zero to enable left-handed mode
  * @return A configuration status code
  *
- * @see libinput_device_config_buttons_has_left_handed
- * @see libinput_device_config_buttons_get_left_handed
- * @see libinput_device_config_buttons_get_default_left_handed
+ * @see libinput_device_config_left_handed_is_available
+ * @see libinput_device_config_left_handed_get
+ * @see libinput_device_config_left_handed_get_default
  */
 enum libinput_config_status
-libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
-                                              int left_handed);
+libinput_device_config_left_handed_set(struct libinput_device *device,
+                                      int left_handed);
 
 /**
  * @ingroup config
@@ -2154,12 +2153,12 @@ libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
  * @return Zero if the device is in right-handed mode, non-zero if the
  * device is in left-handed mode
  *
- * @see libinput_device_config_buttons_has_left_handed
- * @see libinput_device_config_buttons_set_left_handed
- * @see libinput_device_config_buttons_get_default_left_handed
+ * @see libinput_device_config_left_handed_is_available
+ * @see libinput_device_config_left_handed_set
+ * @see libinput_device_config_left_handed_get_default
  */
 int
-libinput_device_config_buttons_get_left_handed(struct libinput_device *device);
+libinput_device_config_left_handed_get(struct libinput_device *device);
 
 /**
  * @ingroup config
@@ -2170,12 +2169,12 @@ libinput_device_config_buttons_get_left_handed(struct libinput_device *device);
  * @return Zero if the device is in right-handed mode by default, or non-zero
  * if the device is in left-handed mode by default
  *
- * @see libinput_device_config_buttons_has_left_handed
- * @see libinput_device_config_buttons_set_left_handed
- * @see libinput_device_config_buttons_get_left_handed
+ * @see libinput_device_config_left_handed_is_available
+ * @see libinput_device_config_left_handed_set
+ * @see libinput_device_config_left_handed_get
  */
 int
-libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device);
+libinput_device_config_left_handed_get_default(struct libinput_device *device);
 
 /**
  * @ingroup config
index f1fa306c68ec3f120f4110bf5d22608c291eeaea..018578d646ee386c869595cde8533c2408988f51 100644 (file)
@@ -7,10 +7,10 @@ global:
        libinput_device_config_accel_get_speed;
        libinput_device_config_accel_is_available;
        libinput_device_config_accel_set_speed;
-       libinput_device_config_buttons_get_default_left_handed;
-       libinput_device_config_buttons_get_left_handed;
-       libinput_device_config_buttons_has_left_handed;
-       libinput_device_config_buttons_set_left_handed;
+       libinput_device_config_left_handed_get_default;
+       libinput_device_config_left_handed_get;
+       libinput_device_config_left_handed_is_available;
+       libinput_device_config_left_handed_set;
        libinput_device_config_calibration_get_default_matrix;
        libinput_device_config_calibration_get_matrix;
        libinput_device_config_calibration_has_matrix;
index 1af4f3850f48abf8efb52144c3c2e11509cd2380..45e0d57e04f828bbae31ab1b1caa9c1f39d2c6f5 100644 (file)
@@ -577,13 +577,13 @@ START_TEST(pointer_left_handed_defaults)
        struct libinput_device *d = dev->libinput_device;
        int rc;
 
-       rc = libinput_device_config_buttons_has_left_handed(d);
+       rc = libinput_device_config_left_handed_is_available(d);
        ck_assert_int_ne(rc, 0);
 
-       rc = libinput_device_config_buttons_get_left_handed(d);
+       rc = libinput_device_config_left_handed_get(d);
        ck_assert_int_eq(rc, 0);
 
-       rc = libinput_device_config_buttons_get_default_left_handed(d);
+       rc = libinput_device_config_left_handed_get_default(d);
        ck_assert_int_eq(rc, 0);
 }
 END_TEST
@@ -595,7 +595,7 @@ START_TEST(pointer_left_handed)
        struct libinput *li = dev->libinput;
        enum libinput_config_status status;
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_drain_events(li);
@@ -645,7 +645,7 @@ START_TEST(pointer_left_handed_during_click)
        libinput_dispatch(li);
 
        /* Change while button is down, expect correct release event */
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_button_click(dev, BTN_LEFT, 0);
@@ -670,7 +670,7 @@ START_TEST(pointer_left_handed_during_click_multiple_buttons)
        litest_button_click(dev, BTN_LEFT, 1);
        libinput_dispatch(li);
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        /* No left-handed until all buttons were down */
index 5c9b72a89734b355e90f8e60112903fbedcd46b4..29890a41a6c32155d5abf3a3f54e99993d640455 100644 (file)
@@ -408,16 +408,16 @@ START_TEST(touch_no_left_handed)
        enum libinput_config_status status;
        int rc;
 
-       rc = libinput_device_config_buttons_has_left_handed(d);
+       rc = libinput_device_config_left_handed_is_available(d);
        ck_assert_int_eq(rc, 0);
 
-       rc = libinput_device_config_buttons_get_left_handed(d);
+       rc = libinput_device_config_left_handed_get(d);
        ck_assert_int_eq(rc, 0);
 
-       rc = libinput_device_config_buttons_get_default_left_handed(d);
+       rc = libinput_device_config_left_handed_get_default(d);
        ck_assert_int_eq(rc, 0);
 
-       status = libinput_device_config_buttons_set_left_handed(d, 0);
+       status = libinput_device_config_left_handed_set(d, 0);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
 }
 END_TEST
index dbe16a3a2e73578d217ffa7ff6d52e34a2a3efd8..c5edecc8f010f42bd74b93f93ec29064b39719e2 100644 (file)
@@ -1917,7 +1917,7 @@ START_TEST(touchpad_left_handed)
        struct libinput *li = dev->libinput;
        enum libinput_config_status status;
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_drain_events(li);
@@ -1962,7 +1962,7 @@ START_TEST(touchpad_left_handed_clickpad)
        struct libinput *li = dev->libinput;
        enum libinput_config_status status;
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_drain_events(li);
@@ -2013,7 +2013,7 @@ START_TEST(touchpad_left_handed_clickfinger)
        struct libinput *li = dev->libinput;
        enum libinput_config_status status;
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_drain_events(li);
@@ -2056,7 +2056,7 @@ START_TEST(touchpad_left_handed_tapping)
 
        libinput_device_config_tap_set_enabled(dev->libinput_device,
                                               LIBINPUT_CONFIG_TAP_ENABLED);
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_drain_events(li);
@@ -2087,7 +2087,7 @@ START_TEST(touchpad_left_handed_tapping_2fg)
 
        libinput_device_config_tap_set_enabled(dev->libinput_device,
                                               LIBINPUT_CONFIG_TAP_ENABLED);
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_drain_events(li);
@@ -2123,7 +2123,7 @@ START_TEST(touchpad_left_handed_delayed)
        litest_button_click(dev, BTN_LEFT, 1);
        libinput_dispatch(li);
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_button_click(dev, BTN_LEFT, 0);
@@ -2140,7 +2140,7 @@ START_TEST(touchpad_left_handed_delayed)
        litest_button_click(dev, BTN_LEFT, 1);
        libinput_dispatch(li);
 
-       status = libinput_device_config_buttons_set_left_handed(d, 0);
+       status = libinput_device_config_left_handed_set(d, 0);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_button_click(dev, BTN_RIGHT, 0);
@@ -2173,7 +2173,7 @@ START_TEST(touchpad_left_handed_clickpad_delayed)
        litest_button_click(dev, BTN_LEFT, 1);
        libinput_dispatch(li);
 
-       status = libinput_device_config_buttons_set_left_handed(d, 1);
+       status = libinput_device_config_left_handed_set(d, 1);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_button_click(dev, BTN_LEFT, 0);
@@ -2192,7 +2192,7 @@ START_TEST(touchpad_left_handed_clickpad_delayed)
        litest_button_click(dev, BTN_LEFT, 1);
        libinput_dispatch(li);
 
-       status = libinput_device_config_buttons_set_left_handed(d, 0);
+       status = libinput_device_config_left_handed_set(d, 0);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
 
        litest_button_click(dev, BTN_LEFT, 0);
index 4d845ced2f4d23c07bf3de16602f60aa38c9c1f3..297e47d81ba0aa1df1c8f1dedeb2e390ae8a1676 100644 (file)
@@ -146,7 +146,7 @@ print_device_notify(struct libinput_event *ev)
 
        if (libinput_device_config_tap_get_finger_count((dev)))
            printf(" tap");
-       if (libinput_device_config_buttons_has_left_handed((dev)))
+       if (libinput_device_config_left_handed_is_available((dev)))
            printf(" left");
        if (libinput_device_config_scroll_has_natural_scroll((dev)))
            printf(" scroll-nat");
index 3e1368d1c3dd3595813691392df7069001de2a10..b4f41d0498478d28e58f951fb9997ab073d355ff 100644 (file)
@@ -262,5 +262,5 @@ tools_device_apply_config(struct libinput_device *device,
                libinput_device_config_scroll_set_natural_scroll_enabled(device,
                                                                         options->natural_scroll);
        if (options->left_handed != -1)
-               libinput_device_config_buttons_set_left_handed(device, options->left_handed);
+               libinput_device_config_left_handed_set(device, options->left_handed);
 }