e_focus_policy_history: implement the focused_ec_changed_listener_add 46/308946/1
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 3 Apr 2024 04:44:26 +0000 (13:44 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 3 Apr 2024 05:32:07 +0000 (14:32 +0900)
This implementation allows it to register the wl_listener which lets
it know when the focused ec has been changed in history policy.

Change-Id: I28f7517304fc35f921204d9b017533c5a2f91549

src/bin/e_focus_policy_history.c

index a8c872b..85b0dec 100644 (file)
@@ -18,6 +18,11 @@ struct _E_Focus_Policy_History_Impl
    Eina_List *focus_stack;
    Eina_List *defer_focus_stack;
 
+   struct
+     {
+        struct wl_signal focused_ec_changed;
+     } events;
+
    struct wl_listener zone_client_add;
    struct wl_listener zone_client_remove;
    struct wl_listener zone_focus_clear;
@@ -540,6 +545,8 @@ _focus_policy_history_cb_client_mouse_down(struct wl_listener *listener, void *d
 static void set_focused_ec(E_Focus_Policy_History *history_policy, E_Client *ec)
 {
    atomic_store(&history_policy->focused_ec, ec);
+
+   wl_signal_emit_mutable(&history_policy->events.focused_ec_changed, ec);
 }
 
 static void
@@ -1286,6 +1293,17 @@ _focus_policy_history_update(E_Focus_Policy_Impl *impl)
    return EINA_TRUE;
 }
 
+static void
+_focus_policy_history_focused_ec_changed_listener_add(E_Focus_Policy_Impl *impl, struct wl_listener *listener)
+{
+   E_Focus_Policy_History *history_policy;
+
+   history_policy = (E_Focus_Policy_History *)impl;
+   EINA_SAFETY_ON_NULL_RETURN(history_policy);
+
+   wl_signal_add(&history_policy->events.focused_ec_changed, listener);
+}
+
 EINTERN E_Focus_Policy_Iface *
 e_focus_policy_iface_history_new(E_Zone* zone)
 {
@@ -1302,12 +1320,15 @@ e_focus_policy_iface_history_new(E_Zone* zone)
 
    history_policy->zone = zone;
 
+   wl_signal_init(&history_policy->events.focused_ec_changed);
+
    E_FOCUS_HISTORY_TRACE(history_policy, NULL);
 
    policy_iface->impl = (E_Focus_Policy_Impl *)history_policy;
    policy_iface->del = _focus_policy_history_del;
    policy_iface->focused_ec_get = _focus_policy_history_focused_ec_get;
    policy_iface->update = _focus_policy_history_update;
+   policy_iface->focused_ec_changed_listener_add = _focus_policy_history_focused_ec_changed_listener_add;
 
    // zone listeners
    history_policy->zone_client_add.notify = _focus_policy_history_cb_zone_client_add;