From: duna.oh Date: Wed, 6 Sep 2023 08:32:04 +0000 (+0900) Subject: ecore_wl2: add events for pointer_constraints X-Git-Tag: accepted/tizen/unified/20230907.175326^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F298385%2F2;p=platform%2Fupstream%2Fefl.git ecore_wl2: add events for pointer_constraints Change-Id: If87c7d93e700c6f7ffeb3f90fcdb91e0696dd590 --- diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 9c341da..3422174 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -736,6 +736,17 @@ typedef void (*Ecore_Wl2_Bind_Cb)(struct wl_client *client, void *data, uint32_t /** @internal */ typedef void (*Ecore_Wl2_Unbind_Cb)(struct wl_resource *resource); +// TIZEN_ONLY(20230906) : add events for pointer_constraints +/** @internal */ +typedef struct _Ecore_Wl2_Event_Pointer_Constraints +{ + unsigned int win; + int x; + int y; + Eina_Bool locked; + Eina_Bool confined; +} Ecore_Wl2_Event_Pointer_Constraints; + EAPI extern int ECORE_WL2_EVENT_DISCONNECT; /** @since 1.18 */ EAPI extern int ECORE_WL2_EVENT_CONNECT; /** @since 1.18 */ EAPI extern int ECORE_WL2_EVENT_GLOBAL_ADDED; /** @since 1.17 */ @@ -801,6 +812,9 @@ EAPI extern int ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE; EAPI extern int ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE; // +// TIZEN_ONLY(20230906) : add events for pointer_constraints +EAPI extern int ECORE_WL2_EVENT_POINTER_CONSTRAINTS; +// /** * @internal diff --git a/src/lib/ecore_wl2/ecore_wl2.c b/src/lib/ecore_wl2/ecore_wl2.c index 649a058..935f9a8 100644 --- a/src/lib/ecore_wl2/ecore_wl2.c +++ b/src/lib/ecore_wl2/ecore_wl2.c @@ -80,6 +80,9 @@ EAPI int ECORE_WL2_EVENT_CLIPBOARD_DATA_SELECTED = 0; EAPI int ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE = 0; EAPI int ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE = 0; // +// TIZEN_ONLY(20230906) : add events for pointer_constraints +EAPI int ECORE_WL2_EVENT_POINTER_CONSTRAINTS = 0; +// EAPI int _ecore_wl2_event_window_www = -1; EAPI int _ecore_wl2_event_window_www_drag = -1; @@ -247,6 +250,9 @@ ecore_wl2_init(void) ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE = ecore_event_type_new(); ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE = ecore_event_type_new(); // +// TIZEN_ONLY(20230906) : add events for pointer_constraints + ECORE_WL2_EVENT_POINTER_CONSTRAINTS = ecore_event_type_new(); +// if (!no_session_recovery) no_session_recovery = !!getenv("EFL_NO_WAYLAND_SESSION_RECOVERY"); @@ -344,7 +350,10 @@ ecore_wl2_shutdown(void) ECORE_WL2_EVENT_WINDOW_DESTROY, // TIZEN_ONLY(20211120) ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, - ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE + ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, +// +// TIZEN_ONLY(20230906) : add events for pointer_constraints + ECORE_WL2_EVENT_POINTER_CONSTRAINTS // ); diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 56dfeff..906dd27 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -1294,21 +1294,66 @@ static const struct zwp_relative_pointer_v1_listener _relative_pointer_listener static void _locked_pointer_cb_locked(void *data, struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1 EINA_UNUSED) { - Ecore_Wl2_Input *input = (Ecore_Wl2_Input *)data; + Ecore_Wl2_Input *input; + Ecore_Wl2_Window *window; + Ecore_Wl2_Event_Pointer_Constraints *ev; // For Debug ERR("[locked pointer] locked"); + + input = data; + if (!input) return; input->pointer_locked = EINA_TRUE; + + window = input->focus.pointer; + if (!window) return; + + ev = calloc(1, sizeof(Ecore_Wl2_Event_Pointer_Constraints)); + if (!ev) return; + + ev->win = window->id; + ev->locked = EINA_TRUE; + ev->confined = EINA_FALSE; // default + ev->x = input->pointer.sx; + ev->y = input->pointer.sy; + + ERR("[Locked event] x=%d, y=%d", ev->x, ev->y); + ecore_event_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, ev, NULL, NULL); } static void _locked_pointer_cb_unlocked(void *data, struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1 EINA_UNUSED) { - Ecore_Wl2_Input *input = (Ecore_Wl2_Input *)data; + Ecore_Wl2_Input *input; + Ecore_Wl2_Window *window; + Ecore_Wl2_Event_Pointer_Constraints *ev; // For Debug ERR("[locked pointer] unlocked"); + + input = data; + if (!input) return; input->pointer_locked = EINA_FALSE; + + window = input->focus.pointer; + if (!window) + { + window = input->focus.prev_pointer; + if (!window) + return; + } + + ev = calloc(1, sizeof(Ecore_Wl2_Event_Pointer_Constraints)); + if (!ev) return; + + ev->win = window->id; + ev->locked = EINA_FALSE; + ev->confined = EINA_FALSE; // default + ev->x = input->pointer.sx; + ev->y = input->pointer.sy; + + ERR("[Unlocked event] x=%d, y=%d", ev->x, ev->y); + ecore_event_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, ev, NULL, NULL); } static const struct zwp_locked_pointer_v1_listener _locked_pointer_listener = {