e_focus_policy: implement the E_CLIENT_HOOK_MOUSE_IN/OUT/DOWN callback. 18/297518/1
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 9 Aug 2023 11:58:37 +0000 (20:58 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 21 Aug 2023 07:58:38 +0000 (16:58 +0900)
Thease replace the e_focus_event_mouse funtions below.
e_focus_mouse_in()
e_focus_mouse_out()
e_focus_mouse_down()

Change-Id: I7aade8ea35bdaf97deaa1c329fa556ee5b1df8f6

src/bin/e_client.c
src/bin/e_client.h
src/bin/e_focus_policy_history.c
src/bin/e_focus_policy_topmost.c

index 106223f..5ad2553 100644 (file)
@@ -99,6 +99,11 @@ static Eina_Inlist *_e_client_hooks[] =
    [E_CLIENT_HOOK_TRANSFORM_CHANGE] = NULL,
    [E_CLIENT_HOOK_ACTIVATE_DONE] = NULL,
    [E_CLIENT_HOOK_EVAL_VISIBILITY_END] = NULL,
+//#ifdef REFACTOR_FOCUS_POLICY
+   [E_CLIENT_HOOK_MOUSE_IN] = NULL,
+   [E_CLIENT_HOOK_MOUSE_OUT] = NULL,
+   [E_CLIENT_HOOK_MOUSE_DOWN] = NULL,
+//#endif
 };
 
 static Eina_Inlist *_e_client_intercept_hooks[] =
@@ -4343,8 +4348,13 @@ e_client_mouse_in(E_Client *ec, int x, int y)
    ec->mouse.current.mx = x;
    ec->mouse.current.my = y;
    ec->mouse.in = 1;
+
+#ifdef REFACTOR_FOCUS_POLICY
+   _e_client_hook_call(E_CLIENT_HOOK_MOUSE_IN, ec);
+#else
    if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
      e_focus_event_mouse_in(ec);
+#endif
 }
 
 EINTERN void
@@ -4358,8 +4368,13 @@ e_client_mouse_out(E_Client *ec, int x, int y)
    ec->mouse.current.mx = x;
    ec->mouse.current.my = y;
    ec->mouse.in = 0;
+
+#ifdef REFACTOR_FOCUS_POLICY
+   _e_client_hook_call(E_CLIENT_HOOK_MOUSE_OUT, ec);
+#else
    if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
      e_focus_event_mouse_out(ec);
+#endif
 }
 
 EINTERN void
@@ -4374,7 +4389,10 @@ e_client_mouse_wheel(E_Client *ec, Evas_Point *output, E_Binding_Event_Wheel *ev
 EINTERN void
 e_client_mouse_down(E_Client *ec, int button, Evas_Point *output, E_Binding_Event_Mouse_Button *ev)
 {
+#ifdef REFACTOR_FOCUS_POLICY
+#else
    E_Client *focused;
+#endif
 
    EINA_SAFETY_ON_NULL_RETURN(ec);
    if (action_client || ec->iconic || e_client_util_ignored_get(ec)) return;
@@ -4415,11 +4433,15 @@ e_client_mouse_down(E_Client *ec, int button, Evas_Point *output, E_Binding_Even
    ec->mouse.current.mx = output->x;
    ec->mouse.current.my = output->y;
 
+#ifdef REFACTOR_FOCUS_POLICY
+   _e_client_hook_call(E_CLIENT_HOOK_MOUSE_DOWN, ec);
+#else
    focused = e_client_focused_get();
    if ((focused) && (ec != focused))
      {
         e_focus_event_mouse_down(ec);
      }
+#endif
 }
 
 EINTERN void
index 38e9094..9311e74 100644 (file)
@@ -271,6 +271,11 @@ typedef enum _E_Client_Hook_Point
    E_CLIENT_HOOK_TRANSFORM_CHANGE,
    E_CLIENT_HOOK_ACTIVATE_DONE,
    E_CLIENT_HOOK_EVAL_VISIBILITY_END,
+//#ifdef REFACTOR_FOCUS_POLICY
+   E_CLIENT_HOOK_MOUSE_IN,
+   E_CLIENT_HOOK_MOUSE_OUT,
+   E_CLIENT_HOOK_MOUSE_DOWN,
+//#endif
    E_CLIENT_HOOK_LAST,
 } E_Client_Hook_Point;
 
index f4531c8..32ea20b 100644 (file)
@@ -8,9 +8,89 @@ struct _E_Focus_Policy_History_Impl
 {
    E_Zone   *zone;
    E_Client *focused_ec;
+
+   Eina_List *ec_hooks;
 };
 
 static void
+_focus_policy_history_hook_cb_client_mouse_in(void *data, E_Client *ec)
+{
+   E_Focus_Policy_History *history_policy;
+
+   history_policy = (E_Focus_Policy_History *)data;
+   if (!history_policy) return;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
+
+   if ((e_config->focus_policy == E_FOCUS_MOUSE) ||
+       (e_config->focus_policy == E_FOCUS_SLOPPY))
+     {
+        ELOGF("FOCUS", "focus set   | mouse in", ec);
+        e_client_frame_focus_set(ec, EINA_TRUE);
+     }
+   if (e_config->use_auto_raise)
+     {
+        if (!ec->lock_user_stacking)
+          e_client_raise(ec);
+     }
+}
+
+static void
+_focus_policy_history_hook_cb_client_mouse_out(void *data, E_Client *ec)
+{
+   E_Focus_Policy_History *history_policy;
+
+   history_policy = (E_Focus_Policy_History *)data;
+   if (!history_policy) return;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
+
+   if (e_config->focus_policy == E_FOCUS_MOUSE)
+     {
+        if (!ec->lock_focus_in)
+          {
+             if (ec->focused)
+               {
+                  ELOGF("FOCUS", "focus unset | mouse out", ec);
+                  e_client_frame_focus_set(ec, EINA_FALSE);
+               }
+          }
+     }
+}
+
+static void
+_focus_policy_history_hook_cb_client_mouse_down(void *data, E_Client *ec)
+{
+   E_Focus_Policy_History *history_policy;
+   E_Client *focused_ec;
+
+   history_policy = (E_Focus_Policy_History *)data;
+   if (!history_policy) return;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+
+   focused_ec = history_policy->focused_ec;
+   if (ec == focused_ec) return;
+
+   if (e_client_focus_policy_click(ec) ||
+       e_config->always_click_to_focus)
+     {
+        ELOGF("FOCUS", "focus set   | mouse down", ec);
+        e_client_frame_focus_set(ec, EINA_TRUE);
+
+        if (ec->floating)
+          e_client_raise(ec);
+     }
+   if (e_config->always_click_to_raise)
+     {
+        if (!ec->lock_user_stacking)
+          e_client_raise(ec);
+     }
+}
+
+static void
 _focus_policy_history_del(E_Focus_Policy_Impl *impl)
 {
    E_Focus_Policy_History *history_policy = (E_Focus_Policy_History *)impl;
@@ -19,6 +99,8 @@ _focus_policy_history_del(E_Focus_Policy_Impl *impl)
 
    ELOGF("FOCUS", "delete history focus policy.", NULL);
 
+   E_FREE_LIST(history_policy->ec_hooks, e_client_hook_del);
+
    E_FREE(history_policy);
 }
 
@@ -65,6 +147,11 @@ e_focus_policy_iface_history_new(E_Zone* zone)
    policy_iface->focused_ec_get = _focus_policy_history_focused_ec_get;
    policy_iface->update = _focus_policy_history_update;
 
+   // e_client hooks
+   E_LIST_HOOK_APPEND(history_policy->ec_hooks, E_CLIENT_HOOK_MOUSE_IN, _focus_policy_history_hook_cb_client_mouse_in, history_policy);
+   E_LIST_HOOK_APPEND(history_policy->ec_hooks, E_CLIENT_HOOK_MOUSE_OUT, _focus_policy_history_hook_cb_client_mouse_out, history_policy);
+   E_LIST_HOOK_APPEND(history_policy->ec_hooks, E_CLIENT_HOOK_MOUSE_DOWN, _focus_policy_history_hook_cb_client_mouse_down, history_policy);
+
    return policy_iface;
 
 fail:
index 697e115..9eb14d8 100644 (file)
@@ -8,15 +8,71 @@ struct _E_Focus_Policy_Topmost_Impl
 {
    E_Zone   *zone;
    E_Client *focused_ec;
+
+   Eina_List *ec_hooks;
 };
 
 static void
+_focus_policy_topmost_hook_cb_client_mouse_in(void *data, E_Client *ec)
+{
+   E_Focus_Policy_Topmost *topmost_policy;
+
+   topmost_policy = (E_Focus_Policy_Topmost *)data;
+   if (!topmost_policy) return;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
+
+   if (e_config->use_auto_raise)
+     {
+        if (!ec->lock_user_stacking)
+          e_client_raise(ec);
+     }
+}
+
+static void
+_focus_policy_topmost_hook_cb_client_mouse_out(void *data, E_Client *ec)
+{
+   // nothing to do
+}
+
+static void
+_focus_policy_topmost_hook_cb_client_mouse_down(void *data, E_Client *ec)
+{
+   E_Focus_Policy_Topmost *topmost_policy;
+   E_Client *focused_ec;
+
+   topmost_policy = (E_Focus_Policy_Topmost *)data;
+   if (!topmost_policy) return;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+
+   focused_ec = topmost_policy->focused_ec;
+   if (ec == focused_ec) return;
+
+   if (e_client_focus_policy_click(ec) ||
+       e_config->always_click_to_focus)
+     {
+        if (ec->floating)
+          e_client_raise(ec);
+     }
+
+   if (e_config->always_click_to_raise)
+     {
+        if (!ec->lock_user_stacking)
+          e_client_raise(ec);
+     }
+}
+
+static void
 _focus_policy_topmost_del(E_Focus_Policy_Impl *impl)
 {
    E_Focus_Policy_Topmost *topmost_policy = (E_Focus_Policy_Topmost *)impl;
 
    if (!topmost_policy) return;
 
+   E_FREE_LIST(topmost_policy->ec_hooks, e_client_hook_del);
+
    E_FREE(topmost_policy);
 }
 
@@ -47,7 +103,6 @@ e_focus_policy_iface_topmost_new(E_Zone* zone)
 {
    E_Focus_Policy_Iface *policy_iface;
    E_Focus_Policy_Topmost *topmost_policy;
-   E_Zone_Hook *zone_hook;
 
    policy_iface = E_NEW(E_Focus_Policy_Iface, 1);
    EINA_SAFETY_ON_NULL_RETURN_VAL(policy_iface, NULL);
@@ -62,6 +117,11 @@ e_focus_policy_iface_topmost_new(E_Zone* zone)
    policy_iface->focused_ec_get = _focus_policy_topmost_focused_ec_get;
    policy_iface->update = _focus_policy_topmost_update;
 
+   // e_client hooks
+   E_LIST_HOOK_APPEND(topmost_policy->ec_hooks, E_CLIENT_HOOK_MOUSE_IN, _focus_policy_topmost_hook_cb_client_mouse_in, topmost_policy);
+   E_LIST_HOOK_APPEND(topmost_policy->ec_hooks, E_CLIENT_HOOK_MOUSE_OUT, _focus_policy_topmost_hook_cb_client_mouse_out, topmost_policy);
+   E_LIST_HOOK_APPEND(topmost_policy->ec_hooks, E_CLIENT_HOOK_MOUSE_DOWN, _focus_policy_topmost_hook_cb_client_mouse_down, topmost_policy);
+
    return policy_iface;
 
 fail: