e_comp_wl_input: allow cursor warping to hint position requested by inactive window 28/318028/1
authorduna.oh <duna.oh@samsung.com>
Mon, 23 Sep 2024 11:23:18 +0000 (20:23 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 24 Sep 2024 01:45:30 +0000 (10:45 +0900)
In cases where active constraint window doesn't set its cursor hint position,
the cursor will be warped to the hint position provided by the inactive window
requesting it.

< Scenario >
1. The left edge window becomes locked.
2. To release the pointer lock, the left edge window requests warp_pointer,
without setting its cursor hint position.
3. The top edge window sets its cursor hint position because it expects
the cursor to appear from the top rather than the left side.

Change-Id: Ia4ee073bdc30e29d7a844c5c3bf542d46cd1c48c

src/bin/server/e_comp_wl_input.c

index b61a9af7a1ff0e9eff0321f61f06bc71ee9279f1..11dd22909e5263aa03bac2ee961bffb859a115bb 100644 (file)
@@ -76,6 +76,9 @@ static char *_env_e_default_xkb_layout  = NULL;
 static char *_env_e_default_xkb_variant = NULL;
 static char *_env_e_default_xkb_opts    = NULL;
 
+static int constraint_last_hint_x = -1;
+static int constraint_last_hint_y = -1;
+
 static Eina_Bool
 _e_comp_wl_input_is_position_inside_constraint_region(E_Comp_Wl_Pointer_Constraint *constraint,
                                                       wl_fixed_t fx,
@@ -679,10 +682,15 @@ _e_comp_wl_input_pointer_constraint_notify_deactivated(E_Comp_Wl_Pointer_Constra
    if (constraint->ec &&
        constraint->has_hint_set)
      {
-
         INF("Pointer Constraint. Pointer Warp to (%d, %d)", constraint->hint_x, constraint->hint_y);
         e_input_device_pointer_warp(NULL, constraint->hint_x, constraint->hint_y);
      }
+   else if (constraint_last_hint_x != -1 && constraint_last_hint_y != -1)
+     {
+        INF("Pointer Constraint. Pointer Warp to (%d, %d) last_hint_x/y",
+            constraint_last_hint_x, constraint_last_hint_y);
+        e_input_device_pointer_warp(NULL, constraint_last_hint_x, constraint_last_hint_y);
+     }
 }
 
 static void
@@ -777,6 +785,10 @@ _e_comp_wl_input_pointer_constraint_enable(E_Comp_Wl_Data *comp_wl, E_Comp_Wl_Po
      }
 
    constraint->active = EINA_TRUE;
+   constraint->has_hint_set = EINA_FALSE; // reset the value for new lock
+   constraint->is_hint_pending = EINA_FALSE; // reset the value for new lock
+   constraint_last_hint_x = -1;
+   constraint_last_hint_y = -1;
    E_Client *ec = constraint->ec;
    comp_wl->ptr_constraints.activated = EINA_TRUE;
    comp_wl->ptr_constraints.ec = ec;
@@ -899,6 +911,12 @@ _e_comp_wl_input_cb_pointer_constraints_surface_committed(struct wl_listener *li
              WRN("Pointer Constraint. Committed. hint (%d, %d)",
                  constraint->hint_x, constraint->hint_y);
           }
+        if (!constraint->active)
+          {
+             WRN("Pointer Constraint. Committed. constraint not active");
+             constraint_last_hint_x = constraint->hint_x;
+             constraint_last_hint_y = constraint->hint_y;
+          }
      }
 
    if (constraint->is_region_pending)