Lines Matching +full:event +full:- +full:touch
2 From: Jeffy Chen <jeffy.chen@rock-chips.com>
4 Subject: [PATCH 32/41] waylandsink: Support pointer and touch
6 Based on weston's client window and simple-egl.
8 Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
9 ---
10 gst-libs/gst/wayland/gstwldisplay.c | 293 ++++++++++++++++++++++++++++
11 gst-libs/gst/wayland/gstwldisplay.h | 4 +
12 gst-libs/gst/wayland/gstwlwindow.c | 17 ++
13 gst-libs/gst/wayland/gstwlwindow.h | 4 +
14 gst-libs/gst/wayland/meson.build | 7 +-
15 5 files changed, 322 insertions(+), 3 deletions(-)
17 diff --git a/gst-libs/gst/wayland/gstwldisplay.c b/gst-libs/gst/wayland/gstwldisplay.c
19 --- a/gst-libs/gst/wayland/gstwldisplay.c
20 +++ b/gst-libs/gst/wayland/gstwldisplay.c
21 @@ -23,6 +23,7 @@
27 #include "fullscreen-shell-unstable-v1-client-protocol.h"
28 #include "linux-dmabuf-unstable-v1-client-protocol.h"
29 @@ -30,6 +31,9 @@
30 #include "xdg-shell-client-protocol.h"
35 +#include <wayland-cursor.h>
39 @@ -41,6 +45,13 @@ typedef struct _GstWlDisplayPrivate
53 @@ -72,6 +83,14 @@ G_DEFINE_TYPE_WITH_CODE (GstWlDisplay, gst_wl_display, G_TYPE_OBJECT,
62 + priv->touch_surface = touch_surface;
68 @@ -88,6 +107,18 @@ gst_wl_display_support_nv12_10le40 (GstWlDisplay * self)
77 + struct wl_touch *touch;
87 @@ -117,6 +148,30 @@ gst_wl_ref_wl_buffer (gpointer key, gpointer value, gpointer user_data)
94 + if (input->touch)
95 + wl_touch_destroy (input->touch);
96 + if (input->pointer)
97 + wl_pointer_destroy (input->pointer);
99 + wl_list_remove (&input->link);
100 + wl_seat_destroy (input->seat);
111 + wl_list_for_each_safe (input, tmp, &priv->input_list, link)
118 @@ -127,6 +182,14 @@ gst_wl_display_finalize (GObject * gobject)
119 if (priv->thread)
120 g_thread_join (priv->thread);
124 + if (priv->cursor_surface)
125 + wl_surface_destroy (priv->cursor_surface);
127 + if (priv->cursor_theme)
128 + wl_cursor_theme_destroy (priv->cursor_theme);
132 g_mutex_lock (&priv->buffers_mutex);
133 @@ -284,6 +347,222 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
145 + if (!priv->default_cursor)
148 + if (!priv->cursor_surface) {
149 + priv->cursor_surface =
150 + wl_compositor_create_surface (priv->compositor);
151 + if (!priv->cursor_surface)
155 + image = priv->default_cursor->images[0];
161 + priv->cursor_surface, image->hotspot_x, image->hotspot_y);
162 + wl_surface_attach (priv->cursor_surface, buffer, 0, 0);
163 + wl_surface_damage (priv->cursor_surface, 0, 0,
164 + image->width, image->height);
165 + wl_surface_commit (priv->cursor_surface);
174 + GstWlDisplay *self = input->display;
179 + /* enter event for a window we've just destroyed */
183 + if (surface != priv->touch_surface) {
184 + /* Ignoring input event from other surfaces */
190 + /* Ignoring input event from subsurface */
194 + input->pointer_focus = window;
204 + if (input->pointer_focus) {
205 + input->pointer_focus = NULL;
223 + window = input->pointer_focus;
228 + gst_wl_window_toplevel_move (window, input->seat, serial);
251 + GstWlDisplay *self = input->display;
256 + /* enter event for a window we've just destroyed */
260 + if (surface != priv->touch_surface) {
261 + /* Ignoring input event from other surfaces */
267 + /* Ignoring input event from subsurface */
271 + gst_wl_window_toplevel_move (window, input->seat, serial);
310 + if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
311 + input->pointer = wl_seat_get_pointer (seat);
312 + wl_pointer_add_listener (input->pointer, &pointer_listener, input);
313 + } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
314 + wl_pointer_destroy (input->pointer);
315 + input->pointer = NULL;
318 + if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) {
319 + input->touch = wl_seat_get_touch (seat);
320 + wl_touch_add_listener (input->touch, &touch_listener, input);
321 + } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
322 + wl_touch_destroy (input->touch);
323 + input->touch = NULL;
343 + input->display = self;
345 + input->seat = wl_registry_bind (priv->registry, id, &wl_seat_interface, 1);
347 + wl_seat_add_listener (input->seat, &seat_listener, input);
348 + wl_seat_set_user_data (input->seat, input);
350 + wl_list_insert (priv->input_list.prev, &input->link);
356 @@ -307,6 +586,18 @@ registry_handle_global (void *data, struct wl_registry *registry,
358 priv->shm = wl_registry_bind (registry, id, &wl_shm_interface, 1);
359 wl_shm_add_listener (priv->shm, &shm_listener, self);
361 + priv->cursor_theme = wl_cursor_theme_load (NULL, 32, priv->shm);
362 + if (!priv->cursor_theme) {
365 + priv->default_cursor =
366 + wl_cursor_theme_get_cursor (priv->cursor_theme, "left_ptr");
367 + if (!priv->default_cursor)
373 priv->viewporter =
375 @@ -400,6 +691,8 @@ gst_wl_display_new_existing (struct wl_display * display,
376 priv->display_wrapper = wl_proxy_create_wrapper (display);
377 priv->own_display = take_ownership;
379 + wl_list_init (&priv->input_list);
381 priv->queue = wl_display_create_queue (priv->display);
382 wl_proxy_set_queue ((struct wl_proxy *) priv->display_wrapper, priv->queue);
383 priv->registry = wl_display_get_registry (priv->display_wrapper);
384 diff --git a/gst-libs/gst/wayland/gstwldisplay.h b/gst-libs/gst/wayland/gstwldisplay.h
386 --- a/gst-libs/gst/wayland/gstwldisplay.h
387 +++ b/gst-libs/gst/wayland/gstwldisplay.h
388 @@ -35,6 +35,10 @@ struct _GstWlDisplay
399 diff --git a/gst-libs/gst/wayland/gstwlwindow.c b/gst-libs/gst/wayland/gstwlwindow.c
401 --- a/gst-libs/gst/wayland/gstwlwindow.c
402 +++ b/gst-libs/gst/wayland/gstwlwindow.c
403 @@ -96,6 +96,19 @@ static void gst_wl_window_finalize (GObject * gobject);
417 + xdg_toplevel_move (priv->xdg_toplevel, seat, serial);
423 @@ -227,6 +240,8 @@ gst_wl_window_new_internal (GstWlDisplay * display, GMutex * render_lock)
424 priv->area_surface = wl_compositor_create_surface (compositor);
425 priv->video_surface = wl_compositor_create_surface (compositor);
427 + gst_wl_display_set_touch_surface (display, priv->area_surface);
429 priv->area_surface_wrapper = wl_proxy_create_wrapper (priv->area_surface);
430 priv->video_surface_wrapper = wl_proxy_create_wrapper (priv->video_surface);
432 @@ -368,6 +383,8 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
436 + wl_surface_set_user_data (priv->area_surface, self);
441 diff --git a/gst-libs/gst/wayland/gstwlwindow.h b/gst-libs/gst/wayland/gstwlwindow.h
443 --- a/gst-libs/gst/wayland/gstwlwindow.h
444 +++ b/gst-libs/gst/wayland/gstwlwindow.h
445 @@ -47,6 +47,10 @@ struct _GstWlWindow
456 diff --git a/gst-libs/gst/wayland/meson.build b/gst-libs/gst/wayland/meson.build
458 --- a/gst-libs/gst/wayland/meson.build
459 +++ b/gst-libs/gst/wayland/meson.build
460 @@ -1,10 +1,11 @@
462 wl_client_dep = dependency('wayland-client', version: wl_req, required: get_option('wayland'))
463 +wl_cursor_dep = dependency('wayland-cursor', version: wl_req, required: get_option('wayland'))
465 wl_protocol_dep = dependency('wayland-protocols', version: wl_req, required: get_option('wayland'))
466 wl_scanner = find_program('wayland-scanner', required: get_option('wayland'))
468 -use_wayland = wl_protocol_dep.found() and wl_client_dep.found() and wl_scanner.found() and libdrm_…
473 @@ -74,7 +75,7 @@ if use_wayland
477 - wl_client_dep, wl_protocol_dep]
481 pkg_name = 'gstreamer-wayland-1.0'
482 @@ -90,7 +91,7 @@ if use_wayland
486 - wl_client_dep, wl_protocol_dep])
489 install_headers(wl_headers, subdir: 'gstreamer-1.0/gst/wayland')
491 --