From 58b04e0a66385a32b1f79996a47210dec2a6d9b8 Mon Sep 17 00:00:00 2001 From: "duna.oh" Date: Sat, 29 Jul 2023 11:25:58 +0900 Subject: [PATCH] ecore_wl2: support zwp_relative_pointer protocol Change-Id: If9d472ec7c6bea9e980687341d550ca65b5bb26d --- packaging/efl.spec | 1 + src/lib/ecore_wl2/ecore_wl2_display.c | 11 +++++++++++ src/lib/ecore_wl2/ecore_wl2_input.c | 34 ++++++++++++++++++++++++++++++++++ src/lib/ecore_wl2/ecore_wl2_private.h | 12 ++++++++++++ src/lib/ecore_wl2/meson.build | 1 + 5 files changed, 59 insertions(+) diff --git a/packaging/efl.spec b/packaging/efl.spec index 266dbac..37a9d6a 100644 --- a/packaging/efl.spec +++ b/packaging/efl.spec @@ -49,6 +49,7 @@ BuildRequires: pkgconfig(tizen-policy-ext-client) BuildRequires: pkgconfig(wtz-foreign-client) BuildRequires: pkgconfig(wtz-screen-client) BuildRequires: pkgconfig(wtz-shell-client) +BuildRequires: pkgconfig(relative-pointer-unstable-v1-client) BuildRequires: wayland-protocols Requires: libwayland-extension-client Requires: libwayland-egl-tizen diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index a0639d4..3af9c3560 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -1070,6 +1070,14 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const wtz_screen_add_listener(ewd->wl.wtz_scr, &_wtz_screen_listener, ewd); } // +// TIZEN_ONLY(20230801) : support zwp relative pointer protocol + else if (!strcmp(interface, "zwp_relative_pointer_manager_v1")) + { + ewd->wl.relative_pointer_manager = + wl_registry_bind(registry, id, + &zwp_relative_pointer_manager_v1_interface, version); + } +// // event: @@ -1174,6 +1182,7 @@ _ecore_wl2_display_globals_cleanup(Ecore_Wl2_Display *ewd) if (ewd->wl.efl_aux_hints) efl_aux_hints_destroy(ewd->wl.efl_aux_hints); if (ewd->wl.efl_hints) efl_hints_destroy(ewd->wl.efl_hints); + // TIZEN_ONLY if (ewd->wl.tz_policy) tizen_policy_destroy(ewd->wl.tz_policy); if (ewd->wl.tz_policy_ext) tizen_policy_ext_destroy(ewd->wl.tz_policy_ext); @@ -1186,6 +1195,8 @@ _ecore_wl2_display_globals_cleanup(Ecore_Wl2_Display *ewd) if (ewd->wl.tz_video) tizen_video_destroy(ewd->wl.tz_video); if (ewd->wl.tz_renderer) tizen_renderer_destroy(ewd->wl.tz_renderer); if (ewd->wl.wtz_scr) wtz_screen_destroy(ewd->wl.wtz_scr); + if (ewd->wl.relative_pointer_manager) + zwp_relative_pointer_manager_v1_destroy(ewd->wl.relative_pointer_manager); // if (ewd->wl.registry) wl_registry_destroy(ewd->wl.registry); diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 88a14d5..40ed4b6 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -1232,6 +1232,29 @@ static const struct wl_pointer_listener _pointer_listener = NULL, /* axis_discrete */ }; +// TIZEN_ONLY(20230801) : support zwp relative pointer protocol +static void +_relative_pointer_cb_relative_motion(void *data, struct zwp_relative_pointer_v1* relative_pointer, + uint32_t ts_high, uint32_t ts_low, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel) +{ + Ecore_Wl2_Input *input; + (void) relative_pointer; + + input = data; + if (!input) return; + + // For Debug + ERR("[relative_pointer] ts_high=%u, ts_low=%u, dx=%d, dy=%d, dx_unaccel=%d, dy_unaccel=%d", + ts_high, ts_low, wl_fixed_to_int(dx), wl_fixed_to_int(dy), wl_fixed_to_int(dx_unaccel), wl_fixed_to_int(dy_unaccel)); + + // TODO: Send Ecore Events +} + +static const struct zwp_relative_pointer_v1_listener _relative_pointer_listener = { + _relative_pointer_cb_relative_motion, +}; +// + static void _keyboard_cb_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int format, int fd, unsigned int size) { @@ -1995,6 +2018,17 @@ _seat_cb_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability wl_pointer_set_user_data(input->wl.pointer, input); wl_pointer_add_listener(input->wl.pointer, &_pointer_listener, input); + // TIZEN_ONLY(20230801) : support zwp relative pointer protocol + if (input->display->wl.relative_pointer_manager) + { + input->wl.relative_pointer = + zwp_relative_pointer_manager_v1_get_relative_pointer( + input->display->wl.relative_pointer_manager, input->wl.pointer); + zwp_relative_pointer_v1_add_listener(input->wl.relative_pointer, + &_relative_pointer_listener, input); + } + // + // TIZEN_ONLY(20171207): add functions to set client's custom cursors if (!input->cursor.surface) { diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 1407090..210a435 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -41,6 +41,10 @@ #include // +// TIZEN_ONLY(20230801) : support zwp relative pointer protocol +#include +// + extern int _ecore_wl2_log_dom; extern Eina_Bool no_session_recovery; @@ -161,6 +165,11 @@ struct _Ecore_Wl2_Display //TIZEN_ONLY(20230312): support wtz_screen struct wtz_screen *wtz_scr; // + + // TIZEN_ONLY(20230801) : support zwp relative pointer protocol + struct zwp_relative_pointer_manager_v1 *relative_pointer_manager; + // + } wl; uint32_t serial; @@ -669,6 +678,9 @@ struct _Ecore_Wl2_Input struct wl_pointer *pointer; struct wl_keyboard *keyboard; struct wl_touch *touch; + // TIZEN_ONLY(20230801) : support zwp relative pointer protocol + struct zwp_relative_pointer_v1 *relative_pointer; + // } wl; struct diff --git a/src/lib/ecore_wl2/meson.build b/src/lib/ecore_wl2/meson.build index 4a7bec2..22246da 100644 --- a/src/lib/ecore_wl2/meson.build +++ b/src/lib/ecore_wl2/meson.build @@ -36,6 +36,7 @@ ecore_wl2_ext_deps += [ dependency('wtz-foreign-client'), dependency('wtz-screen-client'), dependency('wtz-shell-client'), + dependency('relative-pointer-unstable-v1-client'), ] ecore_wl2_src += files([ 'ecore_wl2_tbmsurface.c', -- 2.7.4