When it comes to a window frame, a tablet tool and cursor act almost identical; they click things, drag things, etc. The tool type and extra axes don't serve any use in the context of a window frame, so tablet pointers share the frame_pointer structures used for the mouse pointer.
Signed-off-by: Stephen Chandler Paul <[email protected]> --- clients/window.c | 15 +++++++++++++++ shared/cairo-util.h | 4 ++++ shared/frame.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/clients/window.c b/clients/window.c index 6001b55..727e3f0 100644 --- a/clients/window.c +++ b/clients/window.c @@ -2445,6 +2445,20 @@ frame_touch_up_handler(struct widget *widget, frame_handle_status(frame, input, time, THEME_LOCATION_CLIENT_AREA); } +static int +frame_tablet_motion_handler(struct widget *widget, struct tablet *tablet, + float x, float y, uint32_t time, void *data) +{ + struct window_frame *frame = data; + enum theme_location location; + + location = frame_tablet_motion(frame->frame, tablet, x, y); + if (frame_status(frame->frame) & FRAME_STATUS_REPAINT) + widget_schedule_redraw(frame->widget); + + return frame_get_pointer_image_for_location(data, location); +} + struct widget * window_frame_create(struct window *window, void *data) { @@ -2472,6 +2486,7 @@ window_frame_create(struct window *window, void *data) widget_set_button_handler(frame->widget, frame_button_handler); widget_set_touch_down_handler(frame->widget, frame_touch_down_handler); widget_set_touch_up_handler(frame->widget, frame_touch_up_handler); + widget_set_tablet_motion_handler(frame->widget, frame_tablet_motion_handler); window->frame = frame; diff --git a/shared/cairo-util.h b/shared/cairo-util.h index 4493b0d..87cd287 100644 --- a/shared/cairo-util.h +++ b/shared/cairo-util.h @@ -210,6 +210,10 @@ frame_touch_down(struct frame *frame, void *data, int32_t id, int x, int y); void frame_touch_up(struct frame *frame, void *data, int32_t id); +/* May set FRAME_STATUS_REPAINT */ +enum theme_location +frame_tablet_motion(struct frame *frame, void *pointer, int x, int y); + void frame_repaint(struct frame *frame, cairo_t *cr); diff --git a/shared/frame.c b/shared/frame.c index 53f3f5f..cd05677 100644 --- a/shared/frame.c +++ b/shared/frame.c @@ -837,6 +837,44 @@ frame_touch_up(struct frame *frame, void *data, int32_t id) } } +enum theme_location +frame_tablet_motion(struct frame *frame, void *data, int x, int y) +{ + struct frame_pointer *tablet_pointer = frame_pointer_get(frame, data); + struct frame_button *button, + *prev_button = tablet_pointer->hover_button; + enum theme_location location; + + location = theme_get_location(frame->theme, tablet_pointer->x, + tablet_pointer->y, frame->width, + frame->height, + frame->flags & FRAME_FLAG_MAXIMIZED ? + THEME_FRAME_MAXIMIZED : 0); + + if (!tablet_pointer) + return location; + + tablet_pointer->x = x; + tablet_pointer->y = y; + + button = frame_find_button(frame, x, y); + + if (prev_button) { + if (prev_button == button) + /* The button hasn't changed so we're done here */ + return location; + else + frame_button_leave(prev_button, tablet_pointer); + } + + if (button) + frame_button_enter(button); + + tablet_pointer->hover_button = button; + + return location; +} + void frame_repaint(struct frame *frame, cairo_t *cr) { -- 1.8.5.5 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
