ecore_wl2: add events for pointer_constraints 85/298385/2 accepted/tizen/unified/20230907.175326
authorduna.oh <duna.oh@samsung.com>
Wed, 6 Sep 2023 08:32:04 +0000 (17:32 +0900)
committerduna.oh <duna.oh@samsung.com>
Wed, 6 Sep 2023 08:34:03 +0000 (17:34 +0900)
Change-Id: If87c7d93e700c6f7ffeb3f90fcdb91e0696dd590

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2.c
src/lib/ecore_wl2/ecore_wl2_input.c

index 9c341da..3422174 100644 (file)
@@ -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
index 649a058..935f9a8 100644 (file)
@@ -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
 //
                           );
 
index 56dfeff..906dd27 100644 (file)
@@ -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 = {