e_focus_policy_topmost: implement the focused_ec_changed_listener_add 45/308945/1
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 3 Apr 2024 04:41:41 +0000 (13:41 +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 topmost policy.

Change-Id: I6f1221a26274f8b2a4384b2f36c472b1ee364058

src/bin/e_focus_policy_topmost.c

index ed24f4a..a844899 100644 (file)
@@ -12,6 +12,11 @@ struct _E_Focus_Policy_Topmost_Impl
    E_Zone   *zone;
    E_Client *focused_ec;
 
+   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;
@@ -269,6 +274,8 @@ _focus_policy_topmost_cb_client_mouse_down(struct wl_listener *listener, void *d
 static void set_focused_ec(E_Focus_Policy_Topmost *topmost_policy, E_Client *ec)
 {
    atomic_store(&topmost_policy->focused_ec, ec);
+
+   wl_signal_emit_mutable(&topmost_policy->events.focused_ec_changed, ec);
 }
 
 static void
@@ -624,6 +631,17 @@ _focus_policy_topmost_update(E_Focus_Policy_Impl *impl)
    return EINA_TRUE;
 }
 
+static void
+_focus_policy_topmost_focused_ec_changed_listener_add(E_Focus_Policy_Impl *impl, struct wl_listener *listener)
+{
+   E_Focus_Policy_Topmost *topmost_policy;
+
+   topmost_policy = (E_Focus_Policy_Topmost *)impl;
+   EINA_SAFETY_ON_NULL_RETURN(topmost_policy);
+
+   wl_signal_add(&topmost_policy->events.focused_ec_changed, listener);
+}
+
 EINTERN E_Focus_Policy_Iface *
 e_focus_policy_iface_topmost_new(E_Zone* zone)
 {
@@ -640,10 +658,13 @@ e_focus_policy_iface_topmost_new(E_Zone* zone)
 
    topmost_policy->zone = zone;
 
+   wl_signal_init(&topmost_policy->events.focused_ec_changed);
+
    policy_iface->impl = (E_Focus_Policy_Impl *)topmost_policy;
    policy_iface->del = _focus_policy_topmost_del;
    policy_iface->focused_ec_get = _focus_policy_topmost_focused_ec_get;
    policy_iface->update = _focus_policy_topmost_update;
+   policy_iface->focused_ec_changed_listener_add = _focus_policy_topmost_focused_ec_changed_listener_add;
 
    // zone listeners
    topmost_policy->zone_client_add.notify = _focus_policy_topmost_cb_zone_client_add;