Re: [PATCH v2 weston 05/13] tablet: handle tablet cursors in the compositor
On Sat, Apr 30, 2016 at 05:58:32PM +0800, Jonas Ådahl wrote: > On Wed, Feb 03, 2016 at 03:28:09PM +1000, Peter Hutterer wrote: > > From: Stephen Chandler Paul> > > > The tablet is given a separate cursor. Most tablet interaction is an > > absolute > > interaction and shouldn't need a cursor at all, but usually the cursor is > > used > > to indicate the type of virtual tool currently assigned. > > > > Co-authored-by: Peter Hutterer > > Signed-off-by: Stephen Chandler Paul > > Signed-off-by: Peter Hutterer > > --- > > src/compositor.c | 6 +++ > > src/compositor.h | 13 + > > src/input.c | 157 > > ++- > > 3 files changed, 175 insertions(+), 1 deletion(-) > > > > diff --git a/src/compositor.c b/src/compositor.c > > index cbdb14c..f419818 100644 > > --- a/src/compositor.c > > +++ b/src/compositor.c > > @@ -1866,6 +1866,7 @@ weston_view_unmap(struct weston_view *view) > > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > > struct weston_keyboard *keyboard = > > weston_seat_get_keyboard(seat); > > + struct weston_tablet_tool *tool; > > > > if (keyboard && keyboard->focus == view->surface) > > weston_keyboard_set_focus(keyboard, NULL); > > @@ -1873,6 +1874,11 @@ weston_view_unmap(struct weston_view *view) > > weston_pointer_clear_focus(pointer); > > if (touch && touch->focus == view) > > weston_touch_set_focus(touch, NULL); > > + > > + wl_list_for_each(tool, >tablet_tool_list, link) { > > + if (tool->focus == view) > > + weston_tablet_tool_set_focus(tool, NULL, 0); > > + } > > Hmm. Should this be part of some other patch? I don't think so since we don't need to worry about weston_views until now. The cursor stuff adds the views, so we need unmap them correctly. Cheers, Peter ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH v2 weston 05/13] tablet: handle tablet cursors in the compositor
On Wed, Feb 03, 2016 at 03:28:09PM +1000, Peter Hutterer wrote: > From: Stephen Chandler Paul> > The tablet is given a separate cursor. Most tablet interaction is an absolute > interaction and shouldn't need a cursor at all, but usually the cursor is used > to indicate the type of virtual tool currently assigned. > > Co-authored-by: Peter Hutterer > Signed-off-by: Stephen Chandler Paul > Signed-off-by: Peter Hutterer > --- > src/compositor.c | 6 +++ > src/compositor.h | 13 + > src/input.c | 157 > ++- > 3 files changed, 175 insertions(+), 1 deletion(-) > > diff --git a/src/compositor.c b/src/compositor.c > index cbdb14c..f419818 100644 > --- a/src/compositor.c > +++ b/src/compositor.c > @@ -1866,6 +1866,7 @@ weston_view_unmap(struct weston_view *view) > struct weston_pointer *pointer = weston_seat_get_pointer(seat); > struct weston_keyboard *keyboard = > weston_seat_get_keyboard(seat); > + struct weston_tablet_tool *tool; > > if (keyboard && keyboard->focus == view->surface) > weston_keyboard_set_focus(keyboard, NULL); > @@ -1873,6 +1874,11 @@ weston_view_unmap(struct weston_view *view) > weston_pointer_clear_focus(pointer); > if (touch && touch->focus == view) > weston_touch_set_focus(touch, NULL); > + > + wl_list_for_each(tool, >tablet_tool_list, link) { > + if (tool->focus == view) > + weston_tablet_tool_set_focus(tool, NULL, 0); > + } Hmm. Should this be part of some other patch? > } > } > > diff --git a/src/compositor.h b/src/compositor.h > index 784a70d..7960325 100644 > --- a/src/compositor.h > +++ b/src/compositor.h > @@ -470,6 +470,12 @@ struct weston_tablet_tool { > > int button_count; > bool tip_is_down; > + > + int32_t hotspot_x, hotspot_y; > + struct weston_view *sprite; > + struct wl_listener sprite_destroy_listener; > + > + wl_fixed_t x, y; > }; > > struct weston_tablet { > @@ -580,6 +586,13 @@ void > weston_tablet_tool_end_grab(struct weston_tablet_tool *tool); > > void > +weston_tablet_tool_clamp(struct weston_tablet_tool *tool, > + wl_fixed_t *fx, wl_fixed_t *fy); > +void > +weston_tablet_tool_cursor_move(struct weston_tablet_tool *tool, > +wl_fixed_t x, wl_fixed_t y); > + > +void > wl_data_device_set_keyboard_focus(struct weston_seat *seat); > > int > diff --git a/src/input.c b/src/input.c > index 006ab5a..fc74856 100644 > --- a/src/input.c > +++ b/src/input.c > @@ -974,7 +974,13 @@ static void > default_grab_tablet_tool_proximity_out(struct weston_tablet_tool_grab *grab, > uint32_t time) > { > - weston_tablet_tool_set_focus(grab->tool, NULL, time); > + struct weston_tablet_tool *tool = grab->tool; > + > + weston_tablet_tool_set_focus(tool, NULL, time); > + > + /* Hide the cursor */ > + if (weston_surface_is_mapped(tool->sprite->surface)) > + weston_surface_unmap(tool->sprite->surface); > } > > static void > @@ -989,6 +995,8 @@ default_grab_tablet_tool_motion(struct > weston_tablet_tool_grab *grab, > struct wl_resource *resource; > struct wl_list *resource_list = >focus_resource_list; > > + weston_tablet_tool_cursor_move(tool, x, y); > + > current_view = weston_compositor_pick_view(tool->seat->compositor, > x, y, , ); > if (current_view != tool->focus) > @@ -1126,6 +1134,29 @@ static struct weston_tablet_tool_grab_interface > default_tablet_tool_grab_interfa > default_grab_tablet_tool_cancel, > }; > > +static void > +tablet_tool_unmap_sprite(struct weston_tablet_tool *tool) > +{ > + if (weston_surface_is_mapped(tool->sprite->surface)) > + weston_surface_unmap(tool->sprite->surface); > + > + wl_list_remove(>sprite_destroy_listener.link); > + tool->sprite->surface->configure = NULL; > + tool->sprite->surface->configure_private = NULL; > + weston_view_destroy(tool->sprite); > + tool->sprite = NULL; > +} > + > +static void > +tablet_tool_handle_sprite_destroy(struct wl_listener *listener, void *data) > +{ > + struct weston_tablet_tool *tool = > + container_of(listener, struct weston_tablet_tool, > + sprite_destroy_listener); > + > + tool->sprite = NULL; > +} > + > WL_EXPORT struct weston_tablet_tool * > weston_tablet_tool_create(void) > { > @@ -1138,6 +1169,9 @@ weston_tablet_tool_create(void) > wl_list_init(>resource_list); > wl_list_init(>focus_resource_list); > > + wl_list_init(>sprite_destroy_listener.link); > +
Re: [PATCH v2 weston 05/13] tablet: handle tablet cursors in the compositor
I don't understand this, it seems very redundant with what you propose to put into the compositor. As far as I can tell, you already require the compositor to hide the cursor when the tool leaves proximity and to choose the last-set cursor when a tool enters proximity. Seems to me your proximity_out handler therefore does not have to do anything, and toytoolkit does not have to remember any cursors. The client, if it wants, can set the cursor on proximity-in. Or not set it. Whatever. It this is wrong them I am very confused as to why you had to add so much code to the compositor to manager per-tool cursors. You could instead just reuse the seat cursor, since you seem to have the client setting the cursor on every proximity-in and out. On Tue, Feb 2, 2016 at 9:28 PM, Peter Huttererwrote: > From: Stephen Chandler Paul > > The tablet is given a separate cursor. Most tablet interaction is an > absolute > interaction and shouldn't need a cursor at all, but usually the cursor is > used > to indicate the type of virtual tool currently assigned. > > Co-authored-by: Peter Hutterer > Signed-off-by: Stephen Chandler Paul > Signed-off-by: Peter Hutterer > --- > src/compositor.c | 6 +++ > src/compositor.h | 13 + > src/input.c | 157 > ++- > 3 files changed, 175 insertions(+), 1 deletion(-) > > diff --git a/src/compositor.c b/src/compositor.c > index cbdb14c..f419818 100644 > --- a/src/compositor.c > +++ b/src/compositor.c > @@ -1866,6 +1866,7 @@ weston_view_unmap(struct weston_view *view) > struct weston_pointer *pointer = > weston_seat_get_pointer(seat); > struct weston_keyboard *keyboard = > weston_seat_get_keyboard(seat); > + struct weston_tablet_tool *tool; > > if (keyboard && keyboard->focus == view->surface) > weston_keyboard_set_focus(keyboard, NULL); > @@ -1873,6 +1874,11 @@ weston_view_unmap(struct weston_view *view) > weston_pointer_clear_focus(pointer); > if (touch && touch->focus == view) > weston_touch_set_focus(touch, NULL); > + > + wl_list_for_each(tool, >tablet_tool_list, link) { > + if (tool->focus == view) > + weston_tablet_tool_set_focus(tool, NULL, > 0); > + } > } > } > > diff --git a/src/compositor.h b/src/compositor.h > index 784a70d..7960325 100644 > --- a/src/compositor.h > +++ b/src/compositor.h > @@ -470,6 +470,12 @@ struct weston_tablet_tool { > > int button_count; > bool tip_is_down; > + > + int32_t hotspot_x, hotspot_y; > + struct weston_view *sprite; > + struct wl_listener sprite_destroy_listener; > + > + wl_fixed_t x, y; > }; > > struct weston_tablet { > @@ -580,6 +586,13 @@ void > weston_tablet_tool_end_grab(struct weston_tablet_tool *tool); > > void > +weston_tablet_tool_clamp(struct weston_tablet_tool *tool, > +wl_fixed_t *fx, wl_fixed_t *fy); > +void > +weston_tablet_tool_cursor_move(struct weston_tablet_tool *tool, > + wl_fixed_t x, wl_fixed_t y); > + > +void > wl_data_device_set_keyboard_focus(struct weston_seat *seat); > > int > diff --git a/src/input.c b/src/input.c > index 006ab5a..fc74856 100644 > --- a/src/input.c > +++ b/src/input.c > @@ -974,7 +974,13 @@ static void > default_grab_tablet_tool_proximity_out(struct weston_tablet_tool_grab > *grab, >uint32_t time) > { > - weston_tablet_tool_set_focus(grab->tool, NULL, time); > + struct weston_tablet_tool *tool = grab->tool; > + > + weston_tablet_tool_set_focus(tool, NULL, time); > + > + /* Hide the cursor */ > + if (weston_surface_is_mapped(tool->sprite->surface)) > + weston_surface_unmap(tool->sprite->surface); > } > > static void > @@ -989,6 +995,8 @@ default_grab_tablet_tool_motion(struct > weston_tablet_tool_grab *grab, > struct wl_resource *resource; > struct wl_list *resource_list = >focus_resource_list; > > + weston_tablet_tool_cursor_move(tool, x, y); > + > current_view = weston_compositor_pick_view(tool->seat->compositor, >x, y, , ); > if (current_view != tool->focus) > @@ -1126,6 +1134,29 @@ static struct weston_tablet_tool_grab_interface > default_tablet_tool_grab_interfa > default_grab_tablet_tool_cancel, > }; > > +static void > +tablet_tool_unmap_sprite(struct weston_tablet_tool *tool) > +{ > + if (weston_surface_is_mapped(tool->sprite->surface)) > + weston_surface_unmap(tool->sprite->surface); > + > + wl_list_remove(>sprite_destroy_listener.link); > +
[PATCH v2 weston 05/13] tablet: handle tablet cursors in the compositor
From: Stephen Chandler PaulThe tablet is given a separate cursor. Most tablet interaction is an absolute interaction and shouldn't need a cursor at all, but usually the cursor is used to indicate the type of virtual tool currently assigned. Co-authored-by: Peter Hutterer Signed-off-by: Stephen Chandler Paul Signed-off-by: Peter Hutterer --- src/compositor.c | 6 +++ src/compositor.h | 13 + src/input.c | 157 ++- 3 files changed, 175 insertions(+), 1 deletion(-) diff --git a/src/compositor.c b/src/compositor.c index cbdb14c..f419818 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1866,6 +1866,7 @@ weston_view_unmap(struct weston_view *view) struct weston_pointer *pointer = weston_seat_get_pointer(seat); struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); + struct weston_tablet_tool *tool; if (keyboard && keyboard->focus == view->surface) weston_keyboard_set_focus(keyboard, NULL); @@ -1873,6 +1874,11 @@ weston_view_unmap(struct weston_view *view) weston_pointer_clear_focus(pointer); if (touch && touch->focus == view) weston_touch_set_focus(touch, NULL); + + wl_list_for_each(tool, >tablet_tool_list, link) { + if (tool->focus == view) + weston_tablet_tool_set_focus(tool, NULL, 0); + } } } diff --git a/src/compositor.h b/src/compositor.h index 784a70d..7960325 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -470,6 +470,12 @@ struct weston_tablet_tool { int button_count; bool tip_is_down; + + int32_t hotspot_x, hotspot_y; + struct weston_view *sprite; + struct wl_listener sprite_destroy_listener; + + wl_fixed_t x, y; }; struct weston_tablet { @@ -580,6 +586,13 @@ void weston_tablet_tool_end_grab(struct weston_tablet_tool *tool); void +weston_tablet_tool_clamp(struct weston_tablet_tool *tool, +wl_fixed_t *fx, wl_fixed_t *fy); +void +weston_tablet_tool_cursor_move(struct weston_tablet_tool *tool, + wl_fixed_t x, wl_fixed_t y); + +void wl_data_device_set_keyboard_focus(struct weston_seat *seat); int diff --git a/src/input.c b/src/input.c index 006ab5a..fc74856 100644 --- a/src/input.c +++ b/src/input.c @@ -974,7 +974,13 @@ static void default_grab_tablet_tool_proximity_out(struct weston_tablet_tool_grab *grab, uint32_t time) { - weston_tablet_tool_set_focus(grab->tool, NULL, time); + struct weston_tablet_tool *tool = grab->tool; + + weston_tablet_tool_set_focus(tool, NULL, time); + + /* Hide the cursor */ + if (weston_surface_is_mapped(tool->sprite->surface)) + weston_surface_unmap(tool->sprite->surface); } static void @@ -989,6 +995,8 @@ default_grab_tablet_tool_motion(struct weston_tablet_tool_grab *grab, struct wl_resource *resource; struct wl_list *resource_list = >focus_resource_list; + weston_tablet_tool_cursor_move(tool, x, y); + current_view = weston_compositor_pick_view(tool->seat->compositor, x, y, , ); if (current_view != tool->focus) @@ -1126,6 +1134,29 @@ static struct weston_tablet_tool_grab_interface default_tablet_tool_grab_interfa default_grab_tablet_tool_cancel, }; +static void +tablet_tool_unmap_sprite(struct weston_tablet_tool *tool) +{ + if (weston_surface_is_mapped(tool->sprite->surface)) + weston_surface_unmap(tool->sprite->surface); + + wl_list_remove(>sprite_destroy_listener.link); + tool->sprite->surface->configure = NULL; + tool->sprite->surface->configure_private = NULL; + weston_view_destroy(tool->sprite); + tool->sprite = NULL; +} + +static void +tablet_tool_handle_sprite_destroy(struct wl_listener *listener, void *data) +{ + struct weston_tablet_tool *tool = + container_of(listener, struct weston_tablet_tool, +sprite_destroy_listener); + + tool->sprite = NULL; +} + WL_EXPORT struct weston_tablet_tool * weston_tablet_tool_create(void) { @@ -1138,6 +1169,9 @@ weston_tablet_tool_create(void) wl_list_init(>resource_list); wl_list_init(>focus_resource_list); + wl_list_init(>sprite_destroy_listener.link); + tool->sprite_destroy_listener.notify = tablet_tool_handle_sprite_destroy; + wl_list_init(>focus_view_listener.link); tool->focus_view_listener.notify = tablet_tool_focus_view_destroyed; @@ -1156,12 +1190,57 @@ weston_tablet_tool_destroy(struct weston_tablet_tool *tool) {