e_comp_object: use e_zone_focused_client_set to set focused state of client 12/320612/1
authorJunseok Kim <juns.kim@samsung.com>
Tue, 11 Feb 2025 07:19:51 +0000 (16:19 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 5 Mar 2025 05:00:11 +0000 (14:00 +0900)
Change-Id: I0e73e4adc1ebe17a82cb0012e7d7ed5e3fb469cf

src/bin/compmgr/e_comp_object.c
src/bin/core/e_client.c
src/bin/core/e_client_intern.h
src/bin/core/e_zone.c
src/bin/windowmgr/e_policy_zone.c

index df4632f5ad03e45343503adf42bffb09152338fb..9d1f7caa7947471311e027af3445595c41f39012 100644 (file)
@@ -131,9 +131,6 @@ static Eina_Bool _damage_trace = EINA_FALSE;
 static Eina_List *_damage_trace_objs = NULL;
 static Eina_List *_damage_trace_post_objs = NULL;
 
-/* sekrit functionzzz */
-EINTERN void e_client_focused_set(E_Client *ec);
-
 /* emitted every time a new noteworthy comp object is added */
 EINTERN int E_EVENT_COMP_OBJECT_ADD = -1;
 
@@ -1943,8 +1940,15 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
 {
    E_Comp_Object *cw = data;
    E_Client *ec;
+   E_Zone *zone;
 
    ec = cw->ec;
+   zone = e_comp_zone_find_by_ec(ec);
+   if (!zone)
+     {
+        ERR("intercept_focus:: zone is NULL");
+        zone = e_zone_current_get();
+     }
    /* note: this is here as it seems there are enough apps that do not even
     * expect us to emulate a look of focus but not actually set x input
     * focus as we do - so simply abort any focus set on such windows */
@@ -1955,8 +1959,8 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
      {
         if (!focus)
           {
-             if (e_client_focused_get() == ec)
-                e_client_focused_set(NULL);
+             if (e_zone_focused_client_get(zone) == ec)
+                e_zone_focused_client_set(zone, NULL);
 
              ELOGF("FOCUS", "FOCUS UNSET | evas_object(%p) (frame:%p)", ec, obj, ec->frame);
              evas_object_focus_set(obj, focus);
@@ -2005,6 +2009,7 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
              e_client_focus_latest_set(ec);
 
              ELOGF("FOCUS", "FOCUS SET to MODAL (ec:%p, win:0x%08zx, frame:%p)", ec, modal_child, e_client_util_win_get(modal_child), modal_child->frame);
+             // FIXME : check why the modal_child should use evas_object_focus_set
              //e_client_focused_set(modal_child);
              evas_object_focus_set(modal_child->frame, focus);
              return;
@@ -2017,12 +2022,12 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
                EC_CHANGED(ec);
              return;
           }
-        e_client_focused_set(ec);
+        e_zone_focused_client_set(zone, ec);
      }
    else
      {
-        if (e_client_focused_get() == ec)
-          e_client_focused_set(NULL);
+        if (e_zone_focused_client_get(zone) == ec)
+          e_zone_focused_client_set(zone, NULL);
      }
 
    if (focus)
index 8f395e12b6436e7e2ccb59361f490fdf46aeb1d3..9dadb6c5c618e3ee60c3086e30091f51c54b5895 100644 (file)
@@ -23,7 +23,6 @@
 #include "e_compositor_intern.h"
 #include "e_view_intern.h"
 #include "e_view_client_intern.h"
-#include "e_policy_zone_intern.h"
 #include "e_comp_canvas_intern.h"
 #include "e_hwc_window_intern.h"
 #include "e_canvas_intern.h"
@@ -196,7 +195,6 @@ static Eina_Rectangle action_orig = {0, 0, 0, 0};
 
 static E_Client_Resize_Object_Create_Cb _e_client_resize_object_create_cb = NULL;
 
-EINTERN void e_client_focused_set(E_Client *ec);
 static void _e_client_transient_for_group_make(E_Client *ec, Eina_List **list);
 static Evas_Object *_e_client_resize_object_create(E_Client *ec);
 static void _e_client_resize_object_del(E_Client *ec);
@@ -4137,47 +4135,20 @@ e_client_focus_defer_set(E_Client *ec)
 EINTERN void
 e_client_focused_set(E_Client *ec)
 {
-   E_Client *focused_ec;
    E_Zone *zone;
 
-   if (ec)
-     ELOGF("FOCUS", "CLIENT FOCUSED_SET : SET", ec);
-   else
-     ELOGF("FOCUS", "CLIENT FOCUSED_SET : UNSET", NULL);
-
-  focused_ec = e_comp_focused_ec_get();
-  if (ec == focused_ec) return;
-
-   TRACE_DS_BEGIN(CLIENT:FOCUSED SET);
-
-   // unset the current focused_ec if focused_ec is not being deleted
-   if (focused_ec)
-     {
-       if (!e_object_is_del(E_OBJECT(focused_ec)))
-         {
-            // FIXME: Remove focus_unset event of client.
-            //        Instead, make zone focus_unset event and use it.
-            wl_signal_emit(&PRI(focused_ec)->events.focus_unset, NULL);
-            _e_client_hook_call(E_CLIENT_HOOK_FOCUS_UNSET, focused_ec);
-
-            if (e_object_ref_get(E_OBJECT(focused_ec)) > 0)
-              {
-                 _e_client_event_simple(focused_ec, E_EVENT_CLIENT_FOCUS_OUT);
-              }
-         }
-     }
+   EINA_SAFETY_ON_NULL_RETURN(ec);
 
-   // clear the current focused_ec when ec is NULL
-   if (!ec)
+   zone = e_comp_zone_find_by_ec(ec);
+   if (!zone)
      {
-        zone = e_comp_zone_find_by_ec(focused_ec);
-        E_Policy_Zone *policy_zone = e_comp_screen_policy_zone_get(zone);
-        e_policy_zone_focus_clear(policy_zone);
-
-        TRACE_DS_END();
+        ELOGF("FOCUS", "E_Client(%p):%s: Couldn't find zone", ec, ec, e_client_icccm_title_get(ec));
         return;
      }
 
+   ELOGF("FOCUS", "CLIENT FOCUSED_SET", ec);
+   TRACE_DS_BEGIN(CLIENT:FOCUSED SET);
+
    // FIXME: Remove focus_set event of client.
    //        Instead, make zone focus_set event and use it.
    // set the new current focused_ec
@@ -4190,6 +4161,38 @@ e_client_focused_set(E_Client *ec)
    TRACE_DS_END();
 }
 
+EINTERN void
+e_client_focused_unset(E_Client *ec)
+{
+   E_Zone *zone;
+
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   if (e_object_is_del(E_OBJECT(ec))) return;
+
+   zone = e_comp_zone_find_by_ec(ec);
+   if (!zone)
+     {
+        ELOGF("FOCUS", "E_Client(%p):%s: Couldn't find zone", ec, ec, e_client_icccm_title_get(ec));
+        return;
+     }
+
+   ELOGF("FOCUS", "CLIENT FOCUSED_UNSET", ec);
+   TRACE_DS_BEGIN(CLIENT:FOCUSED UNSET);
+
+   // FIXME: Remove focus_unset event of client.
+   //        Instead, make zone focus_unset event and use it.
+   wl_signal_emit(&PRI(ec)->events.focus_unset, NULL);
+   _e_client_hook_call(E_CLIENT_HOOK_FOCUS_UNSET, ec);
+
+   if (e_object_ref_get(E_OBJECT(ec)) > 0)
+     {
+        _e_client_event_simple(ec, E_EVENT_CLIENT_FOCUS_OUT);
+     }
+
+   TRACE_DS_END();
+   return;
+}
+
 EINTERN void
 e_client_activate(E_Client *ec)
 {
index 9fef2213e929874ee0617cdb95cf84b676d3f759..48b10b955ebe7e5008bcc9ff92b54a9b9df3710c 100644 (file)
@@ -19,6 +19,8 @@ EINTERN void      e_client_shutdown(void);
 
 EINTERN void          e_client_idler_before(Eina_Bool *check_focus);
 EINTERN unsigned int  e_clients_count(void);
+EINTERN void          e_client_focused_set(E_Client *ec);
+EINTERN void          e_client_focused_unset(E_Client *ec);
 EINTERN void          e_client_activate(E_Client *ec);
 EINTERN Eina_List    *e_client_lost_windows_get(E_Zone *zone);
 EINTERN void          e_client_layout_set(E_Client *ec, uint32_t num_cols, uint32_t num_rows, uint32_t column_id, uint32_t row_id, uint32_t col_span, uint32_t row_span);
index e9f612911f51997425738613033df46fef596086..dc8ae0128b64806c6d568cf93d8e18c002deda32 100644 (file)
@@ -1141,7 +1141,7 @@ e_zone_focused_client_get(E_Zone *zone)
 
    wl_signal_emit(&PRI(zone)->events.focused_client_get, &focused_ec);
 
-   ELOGF("ZONE", "Focused client get: %p", focused_ec, focused_ec);
+   ELOGF("ZONE", "Zone(%d):%p Focused client get: %p", focused_ec, zone->id, zone, focused_ec);
    return focused_ec;
 }
 
@@ -1150,9 +1150,9 @@ e_zone_focused_client_set(E_Zone *zone, E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN(zone);
 
-   wl_signal_emit(&PRI(zone)->events.focused_client_set, ec);
-
    ELOGF("ZONE", "Focused client set: %p", ec, ec);
+
+   wl_signal_emit(&PRI(zone)->events.focused_client_set, ec);
    return;
 }
 
index c5eed688b6eec32bd20a216d2ec0815db5f95135..7094b4dbde8e0b87b30b6b9db999a69237dad87c 100644 (file)
@@ -770,13 +770,25 @@ _e_policy_zone_cb_focused_client_get(struct wl_listener *listener, void *data)
 static void
 _e_policy_zone_cb_focused_client_set(struct wl_listener *listener, void *data)
 {
-   //E_Policy_Zone *policy_zone;
-   //E_Zone *zone;
+   E_Policy_Zone *policy_zone;
+   E_Zone *zone;
+   E_Client *ec, *focused_ec;
+
+   policy_zone = wl_container_of(listener, policy_zone, focused_client_set);
+   zone = policy_zone->zone;
+   ec = (E_Client *)data;
 
-   //policy_zone = wl_container_of(listener, policy_zone, focused_client_set);
-   //zone = policy_zone->zone;
+   focused_ec = e_zone_focused_client_get(zone);
+   if (ec && (ec == focused_ec)) return;
+
+   if (focused_ec)
+     {
+        e_client_focused_unset(focused_ec);
+        e_policy_zone_focus_clear(policy_zone);
+     }
 
-   // TODO:: Need to impl
+   if (ec)
+     e_client_focused_set(ec);
 
    return;
 }