Signed-off-by: Stephen Chandler Paul <[email protected]>
---
 src/compositor.h      |  8 +++++++
 src/input.c           | 65 +++++++++++++++++++++++++++++++++++++++++++++++++--
 src/libinput-device.c |  7 +++++-
 3 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index f1e4353..91ce7b7 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -425,6 +425,10 @@ struct weston_tablet {
        int32_t hotspot_x, hotspot_y;
        wl_fixed_t x, y;
 
+       enum {
+               WESTON_TOOL_UP = 0,
+               WESTON_TOOL_DOWN = 1,
+       } tool_contact_status;
        int button_count;
 
        struct weston_view *sprite;
@@ -1128,6 +1132,10 @@ void
 notify_tablet_button(struct weston_tablet *tablet, uint32_t time,
                     uint32_t button, enum wl_tablet_button_state state);
 void
+notify_tablet_down(struct weston_tablet *tablet, uint32_t time);
+void
+notify_tablet_up(struct weston_tablet *tablet, uint32_t time);
+void
 notify_tablet_frame(struct weston_tablet *tablet);
 
 void
diff --git a/src/input.c b/src/input.c
index 87e4dd9..62b49ed 100644
--- a/src/input.c
+++ b/src/input.c
@@ -481,6 +481,33 @@ default_grab_tablet_motion(struct weston_tablet_grab *grab,
 }
 
 static void
+default_grab_tablet_down(struct weston_tablet_grab *grab, uint32_t time)
+{
+       struct weston_tablet *tablet = grab->tablet;
+       struct wl_resource *resource;
+       struct wl_list *resource_list = &tablet->focus_resource_list;
+
+       if (!wl_list_empty(resource_list)) {
+               wl_resource_for_each(resource, resource_list)
+                       wl_tablet_send_down(resource, tablet->grab_serial,
+                                           time);
+       }
+}
+
+static void
+default_grab_tablet_up(struct weston_tablet_grab *grab, uint32_t time)
+{
+       struct weston_tablet *tablet = grab->tablet;
+       struct wl_resource *resource;
+       struct wl_list *resource_list = &tablet->focus_resource_list;
+
+       if (!wl_list_empty(resource_list)) {
+               wl_resource_for_each(resource, resource_list)
+                       wl_tablet_send_up(resource, time);
+       }
+}
+
+static void
 default_grab_tablet_button(struct weston_tablet_grab *grab,
                           uint32_t time, uint32_t button,
                           enum wl_tablet_button_state state)
@@ -518,8 +545,8 @@ static struct weston_tablet_grab_interface 
default_tablet_grab_interface = {
        default_grab_tablet_proximity_in,
        default_grab_tablet_proximity_out,
        default_grab_tablet_motion,
-       NULL,
-       NULL,
+       default_grab_tablet_down,
+       default_grab_tablet_up,
        NULL,
        NULL,
        NULL,
@@ -772,6 +799,9 @@ weston_tablet_set_focus(struct weston_tablet *tablet, 
struct weston_view *view,
 
        if (tablet->focus && !wl_list_empty(focus_resource_list)) {
                wl_resource_for_each(resource, focus_resource_list) {
+                       if (tablet->tool_contact_status == WESTON_TOOL_DOWN)
+                               wl_tablet_send_up(resource, time);
+
                        wl_tablet_send_proximity_out(resource, time);
                        wl_tablet_send_frame(resource);
                }
@@ -821,6 +851,11 @@ weston_tablet_set_focus(struct weston_tablet *tablet, 
struct weston_view *view,
                                                    tablet->focus_serial,
                                                    time, tool_resource,
                                                    view->surface->resource);
+
+                       if (tablet->tool_contact_status == WESTON_TOOL_DOWN)
+                               wl_tablet_send_down(resource,
+                                                   tablet->focus_serial,
+                                                   time);
                }
        } else if (tablet->sprite)
                tablet_unmap_sprite(tablet);
@@ -1902,6 +1937,32 @@ notify_tablet_button(struct weston_tablet *tablet, 
uint32_t time,
        grab->interface->button(grab, time, button, state);
 }
 
+WL_EXPORT void
+notify_tablet_down(struct weston_tablet *tablet, uint32_t time)
+{
+       struct weston_tablet_grab *grab = tablet->grab;
+       struct weston_compositor *compositor = tablet->seat->compositor;
+
+       weston_compositor_idle_inhibit(compositor);
+
+       tablet->tool_contact_status = WESTON_TOOL_DOWN;
+
+       grab->interface->down(grab, time);
+}
+
+WL_EXPORT void
+notify_tablet_up(struct weston_tablet *tablet, uint32_t time)
+{
+       struct weston_tablet_grab *grab = tablet->grab;
+       struct weston_compositor *compositor = tablet->seat->compositor;
+
+       weston_compositor_idle_release(compositor);
+
+       tablet->tool_contact_status = WESTON_TOOL_UP;
+
+       grab->interface->up(grab, time);
+}
+
 static void
 pointer_cursor_surface_configure(struct weston_surface *es,
                                 int32_t dx, int32_t dy)
diff --git a/src/libinput-device.c b/src/libinput-device.c
index 2e913bd..6294466 100644
--- a/src/libinput-device.c
+++ b/src/libinput-device.c
@@ -346,7 +346,12 @@ handle_tablet_button(struct libinput_device 
*libinput_device,
        state = (enum wl_tablet_button_state)
                libinput_event_tablet_get_button_state(button_event);
 
-       if (button != BTN_TOUCH)
+       if (button == BTN_TOUCH) {
+               if (state == WL_TABLET_BUTTON_STATE_PRESSED)
+                       notify_tablet_down(tablet, time);
+               else
+                       notify_tablet_up(tablet, time);
+       } else
                notify_tablet_button(tablet, time, button, state);
 }
 
-- 
1.8.5.5

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

Reply via email to