<div dir="ltr">I don't think it should be possible for the tablet focus to be different than the pointer focus, so most of this should not be necessary.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 5, 2015 at 8:31 PM, Peter Hutterer <span dir="ltr"><<a href="mailto:peter.hutterer@who-t.net" target="_blank">peter.hutterer@who-t.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Stephen Chandler Paul <<a href="mailto:thatslyude@gmail.com">thatslyude@gmail.com</a>><br>
<br>
Closely modelled after the pointer focus handling<br>
<br>
Co-authored-by: Peter Hutterer <<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>><br>
Signed-off-by: Stephen Chandler Paul <<a href="mailto:thatslyude@gmail.com">thatslyude@gmail.com</a>><br>
Signed-off-by: Peter Hutterer <<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>><br>
---<br>
src/compositor.h | 10 +++++++<br>
src/input.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
2 files changed, 92 insertions(+)<br>
<br>
diff --git a/src/compositor.h b/src/compositor.h<br>
index 50c7034..7725c27 100644<br>
--- a/src/compositor.h<br>
+++ b/src/compositor.h<br>
@@ -370,8 +370,14 @@ struct weston_touch {<br>
struct weston_tablet_tool {<br>
struct weston_seat *seat;<br>
enum zwp_tablet_tool1_type type;<br>
+ struct weston_tablet *current_tablet;<br>
<br>
struct wl_list resource_list;<br>
+ struct wl_list focus_resource_list;<br>
+ struct weston_view *focus;<br>
+ struct wl_listener focus_view_listener;<br>
+ struct wl_listener focus_resource_listener;<br>
+ uint32_t focus_serial;<br>
<br>
struct wl_list link;<br>
<br>
@@ -466,6 +472,10 @@ struct weston_tablet_tool *<br>
weston_tablet_tool_create(void);<br>
void<br>
weston_tablet_tool_destroy(struct weston_tablet_tool *tool);<br>
+void<br>
+weston_tablet_tool_set_focus(struct weston_tablet_tool *tool,<br>
+ struct weston_view *view,<br>
+ uint32_t time);<br>
<br>
void<br>
wl_data_device_set_keyboard_focus(struct weston_seat *seat);<br>
diff --git a/src/input.c b/src/input.c<br>
index 8814d34..e9688c5 100644<br>
--- a/src/input.c<br>
+++ b/src/input.c<br>
@@ -126,6 +126,26 @@ touch_focus_resource_destroyed(struct wl_listener *listener, void *data)<br>
}<br>
<br>
static void<br>
+tablet_tool_focus_view_destroyed(struct wl_listener *listener, void *data)<br>
+{<br>
+ struct weston_tablet_tool *tool =<br>
+ container_of(listener, struct weston_tablet_tool,<br>
+ focus_view_listener);<br>
+<br>
+ weston_tablet_tool_set_focus(tool, NULL, 0);<br>
+}<br>
+<br>
+static void<br>
+tablet_tool_focus_resource_destroyed(struct wl_listener *listener, void *data)<br>
+{<br>
+ struct weston_tablet_tool *tool =<br>
+ container_of(listener, struct weston_tablet_tool,<br>
+ focus_resource_listener);<br>
+<br>
+ weston_tablet_tool_set_focus(tool, NULL, 0);<br>
+}<br>
+<br>
+static void<br>
move_resources(struct wl_list *destination, struct wl_list *source)<br>
{<br>
wl_list_insert_list(destination, source);<br>
@@ -670,6 +690,61 @@ weston_tablet_destroy(struct weston_tablet *tablet)<br>
free(tablet);<br>
}<br>
<br>
+WL_EXPORT void<br>
+weston_tablet_tool_set_focus(struct weston_tablet_tool *tool,<br>
+ struct weston_view *view,<br>
+ uint32_t time)<br>
+{<br>
+ struct wl_list *focus_resource_list;<br>
+ struct wl_resource *resource;<br>
+ struct weston_seat *seat = tool->seat;<br>
+<br>
+ focus_resource_list = &tool->focus_resource_list;<br>
+ if (tool->focus && !wl_list_empty(focus_resource_list)) {<br>
+ wl_resource_for_each(resource, focus_resource_list) {<br>
+ zwp_tablet_tool1_send_proximity_out(resource);<br>
+ zwp_tablet_tool1_send_frame(resource, time);<br>
+ }<br>
+<br>
+ move_resources(&tool->resource_list, focus_resource_list);<br>
+ }<br>
+<br>
+ if (find_resource_for_view(&tool->resource_list, view)) {<br>
+ struct wl_client *surface_client =<br>
+ wl_resource_get_client(view->surface->resource);<br>
+<br>
+ move_resources_for_client(focus_resource_list,<br>
+ &tool->resource_list,<br>
+ surface_client);<br>
+<br>
+ tool->focus_serial = wl_display_next_serial(seat->compositor->wl_display);<br>
+ wl_resource_for_each(resource, focus_resource_list) {<br>
+ struct wl_resource *tr;<br>
+<br>
+ tr = wl_resource_find_for_client(&tool->current_tablet->resource_list,<br>
+ surface_client);<br>
+<br>
+ zwp_tablet_tool1_send_proximity_in(resource, tool->focus_serial,<br>
+ tr, view->surface->resource);<br>
+ zwp_tablet_tool1_send_frame(resource, time);<br>
+ }<br>
+ }<br>
+<br>
+ wl_list_remove(&tool->focus_view_listener.link);<br>
+ wl_list_init(&tool->focus_view_listener.link);<br>
+ wl_list_remove(&tool->focus_resource_listener.link);<br>
+ wl_list_init(&tool->focus_resource_listener.link);<br>
+<br>
+ if (view)<br>
+ wl_signal_add(&view->destroy_signal,<br>
+ &tool->focus_view_listener);<br>
+ if (view && view->surface->resource)<br>
+ wl_resource_add_destroy_listener(view->surface->resource,<br>
+ &tool->focus_resource_listener);<br>
+ tool->focus = view;<br>
+ tool->focus_view_listener.notify = tablet_tool_focus_view_destroyed;<br>
+}<br>
+<br>
WL_EXPORT struct weston_tablet_tool *<br>
weston_tablet_tool_create(void)<br>
{<br>
@@ -680,6 +755,13 @@ weston_tablet_tool_create(void)<br>
return NULL;<br>
<br>
wl_list_init(&tool->resource_list);<br>
+ wl_list_init(&tool->focus_resource_list);<br>
+<br>
+ wl_list_init(&tool->focus_view_listener.link);<br>
+ tool->focus_view_listener.notify = tablet_tool_focus_view_destroyed;<br>
+<br>
+ wl_list_init(&tool->focus_resource_listener.link);<br>
+ tool->focus_resource_listener.notify = tablet_tool_focus_resource_destroyed;<br>
<br>
return tool;<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.3<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div>