Signed-off-by: Stephen Chandler Paul <[email protected]>
Reviewed-by: Peter Hutterer <[email protected]>
---
 src/evdev-tablet.c     | 41 ++++++++++++++++++++++++++---------------
 src/evdev-tablet.h     | 13 ++++++-------
 src/libinput-private.h |  5 ++++-
 src/libinput.c         | 10 ++++++++--
 src/libinput.h         | 19 +++++++------------
 5 files changed, 51 insertions(+), 37 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index e6595bc..710e391 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -94,10 +94,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
        assert(tool != LIBINPUT_TOOL_NONE);
 
        if (enabled) {
-               if (tool != tablet->current_tool_type) {
-                       tablet->current_tool_type = tool;
-                       tablet_set_status(tablet, TABLET_TOOL_UPDATED);
-               }
+               tablet->current_tool_type = tool;
                tablet_mark_all_axes_changed(tablet, device);
                tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
                tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
@@ -126,7 +123,8 @@ normalize_tilt(const struct input_absinfo * absinfo) {
 static void
 tablet_check_notify_axes(struct tablet_dispatch *tablet,
                         struct evdev_device *device,
-                        uint32_t time)
+                        uint32_t time,
+                        struct libinput_tool *tool)
 {
        struct libinput_device *base = &device->base;
        bool axis_update_needed = false;
@@ -169,6 +167,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet,
            !tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY))
                tablet_notify_axis(base,
                                   time,
+                                  tool,
                                   tablet->changed_axes,
                                   tablet->axes);
 
@@ -247,11 +246,9 @@ tablet_process_misc(struct tablet_dispatch *tablet,
 {
        switch (e->code) {
        case MSC_SERIAL:
-               if (e->value != (int32_t)tablet->current_tool_serial &&
-                   e->value != -1) {
+               if (e->value != -1)
                        tablet->current_tool_serial = e->value;
-                       tablet_set_status(tablet, TABLET_TOOL_UPDATED);
-               }
+
                break;
        default:
                log_info(device->base.seat->libinput,
@@ -297,6 +294,7 @@ static void
 tablet_notify_button_mask(struct tablet_dispatch *tablet,
                          struct evdev_device *device,
                          uint32_t time,
+                         struct libinput_tool *tool,
                          uint32_t buttons,
                          uint32_t button_base,
                          enum libinput_button_state state)
@@ -316,6 +314,7 @@ tablet_notify_button_mask(struct tablet_dispatch *tablet,
 
                tablet_notify_button(base,
                                     time,
+                                    tool,
                                     num_button + button_base - 1,
                                     state);
        }
@@ -325,6 +324,7 @@ static void
 tablet_notify_buttons(struct tablet_dispatch *tablet,
                      struct evdev_device *device,
                      uint32_t time,
+                     struct libinput_tool *tool,
                      enum libinput_button_state state)
 {
        uint32_t stylus_buttons;
@@ -336,8 +336,13 @@ tablet_notify_buttons(struct tablet_dispatch *tablet,
                stylus_buttons =
                        tablet_get_released_buttons(tablet, stylus_buttons);
 
-       tablet_notify_button_mask(tablet, device, time,
-                                 stylus_buttons, BTN_TOUCH, state);
+       tablet_notify_button_mask(tablet,
+                                 device,
+                                 time,
+                                 tool,
+                                 stylus_buttons,
+                                 BTN_TOUCH,
+                                 state);
 }
 
 static void
@@ -392,24 +397,30 @@ tablet_flush(struct tablet_dispatch *tablet,
 
        if (tablet_has_status(tablet, TABLET_AXES_UPDATED)) {
                sanitize_tablet_axes(tablet);
-               tablet_check_notify_axes(tablet, device, time);
+               tablet_check_notify_axes(tablet, device, time, tool);
                tablet_unset_status(tablet, TABLET_AXES_UPDATED);
        }
 
        if (tablet_has_status(tablet, TABLET_BUTTONS_RELEASED)) {
-               tablet_notify_buttons(tablet, device, time,
+               tablet_notify_buttons(tablet,
+                                     device,
+                                     time,
+                                     tool,
                                      LIBINPUT_BUTTON_STATE_RELEASED);
                tablet_unset_status(tablet, TABLET_BUTTONS_RELEASED);
        }
 
        if (tablet_has_status(tablet, TABLET_BUTTONS_PRESSED)) {
-               tablet_notify_buttons(tablet, device, time,
+               tablet_notify_buttons(tablet,
+                                     device,
+                                     time,
+                                     tool,
                                      LIBINPUT_BUTTON_STATE_PRESSED);
                tablet_unset_status(tablet, TABLET_BUTTONS_PRESSED);
        }
 
        if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
-               tablet_notify_proximity_out(&device->base, time);
+               tablet_notify_proximity_out(&device->base, time, tool);
                tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
                tablet_unset_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
        }
diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h
index e6e66d7..4de4cec 100644
--- a/src/evdev-tablet.h
+++ b/src/evdev-tablet.h
@@ -30,13 +30,12 @@
 enum tablet_status {
        TABLET_NONE = 0,
        TABLET_AXES_UPDATED = 1 << 0,
-       TABLET_TOOL_UPDATED = 1 << 1,
-       TABLET_BUTTONS_PRESSED = 1 << 2,
-       TABLET_BUTTONS_RELEASED = 1 << 3,
-       TABLET_STYLUS_IN_CONTACT = 1 << 4,
-       TABLET_TOOL_LEAVING_PROXIMITY = 1 << 5,
-       TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 6,
-       TABLET_TOOL_ENTERING_PROXIMITY = 1 << 7
+       TABLET_BUTTONS_PRESSED = 1 << 1,
+       TABLET_BUTTONS_RELEASED = 1 << 2,
+       TABLET_STYLUS_IN_CONTACT = 1 << 3,
+       TABLET_TOOL_LEAVING_PROXIMITY = 1 << 4,
+       TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 5,
+       TABLET_TOOL_ENTERING_PROXIMITY = 1 << 6
 };
 
 struct button_state {
diff --git a/src/libinput-private.h b/src/libinput-private.h
index e59fe12..a396d78 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -214,6 +214,7 @@ touch_notify_touch_up(struct libinput_device *device,
 void
 tablet_notify_axis(struct libinput_device *device,
                   uint32_t time,
+                  struct libinput_tool *tool,
                   unsigned char *changed_axes,
                   double *axes);
 
@@ -224,11 +225,13 @@ tablet_notify_proximity_in(struct libinput_device *device,
 
 void
 tablet_notify_proximity_out(struct libinput_device *device,
-                           uint32_t time);
+                           uint32_t time,
+                           struct libinput_tool *tool);
 
 void
 tablet_notify_button(struct libinput_device *device,
                     uint32_t time,
+                    struct libinput_tool *tool,
                     int32_t button,
                     enum libinput_button_state state);
 void
diff --git a/src/libinput.c b/src/libinput.c
index 3726eb5..a00f6b5 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1226,6 +1226,7 @@ touch_notify_frame(struct libinput_device *device,
 void
 tablet_notify_axis(struct libinput_device *device,
                   uint32_t time,
+                  struct libinput_tool *tool,
                   unsigned char *changed_axes,
                   double *axes)
 {
@@ -1237,6 +1238,7 @@ tablet_notify_axis(struct libinput_device *device,
 
        *axis_event = (struct libinput_event_tablet) {
                .time = time,
+               .tool = tool,
                .axes = axes,
        };
 
@@ -1272,7 +1274,8 @@ tablet_notify_proximity_in(struct libinput_device *device,
 
 void
 tablet_notify_proximity_out(struct libinput_device *device,
-                           uint32_t time)
+                           uint32_t time,
+                           struct libinput_tool *tool)
 {
        struct libinput_event_tablet *proximity_out_update_event;
 
@@ -1281,7 +1284,8 @@ tablet_notify_proximity_out(struct libinput_device 
*device,
                return;
 
        *proximity_out_update_event = (struct libinput_event_tablet) {
-               .time = time
+               .time = time,
+               .tool = tool,
        };
 
        post_device_event(device,
@@ -1292,6 +1296,7 @@ tablet_notify_proximity_out(struct libinput_device 
*device,
 void
 tablet_notify_button(struct libinput_device *device,
                     uint32_t time,
+                    struct libinput_tool *tool,
                     int32_t button,
                     enum libinput_button_state state)
 {
@@ -1308,6 +1313,7 @@ tablet_notify_button(struct libinput_device *device,
 
        *button_event = (struct libinput_event_tablet) {
                .time = time,
+               .tool = tool,
                .button = button,
                .state = state,
                .seat_button_count = seat_button_count,
diff --git a/src/libinput.h b/src/libinput.h
index 49162dd..7f8e081 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -918,18 +918,13 @@ libinput_event_tablet_get_y_transformed(struct 
libinput_event_tablet *event,
 /**
  * @ingroup event_tablet
  *
- * Returns the tool that came into proximity for this event.
- * For tablet events that are not of type @ref
- * LIBINPUT_EVENT_TABLET_PROXIMITY_IN, this function returns NULL. By default,
- * the lifetime of each tool will stay valid for as long as it is being used,
- * and is destroyed when another tool comes into proximity. However, the
- * lifetime of the tool may be extended by using libinput_tool_ref() to
- * increment the reference count of the tool. This guarantees that whenever the
- * tool comes back into proximity of the tablet, that the same structure will 
be
- * used to represent the tool.
- *
- * @note It is an application bug to call this function for events other than
- * @ref LIBINPUT_EVENT_TABLET_PROXIMITY_IN.
+ * Returns the tool that was in use during this event.
+ * By default, each tool will stay valid for as long as it is being used, and 
is
+ * destroyed when another tool comes into proximity. However, the lifetime of
+ * the tool may be extended by using libinput_tool_ref() to increment the
+ * reference count of the tool. This guarantees that whenever the tool comes
+ * back into proximity of the tablet, that the same structure will be used to
+ * represent the tool.
  *
  * @note On tablets where the serial number of tools is not reported, each tool
  * cannot be guaranteed to be unique.
-- 
1.8.5.5

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to