e_focus_policy_history: Correct order of the focus history when appending 65/309165/3
authorJunseok Kim <juns.kim@samsung.com>
Fri, 5 Apr 2024 02:13:46 +0000 (11:13 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Fri, 5 Apr 2024 08:45:33 +0000 (08:45 +0000)
In the previous patch, we fixed an issue where the order of focus history was incorrect.

The original purpose of the patch was to append a new client after a client with a higher layer after the focused client.
However, there was a problem that the wrong condition of the previous patch
caused the new client to be placed at the beginning of the focus history.
This is a patch that fixes this problem.

Change-Id: Id5730028308004e482c751200e53bc33368d8696

src/bin/e_focus_policy_history.c

index f0a35bb..72c0fde 100644 (file)
@@ -957,20 +957,33 @@ _e_focus_policy_history_focus_stack_append_current_focused(E_Focus_Policy_Histor
 {
    Eina_List *l = NULL;
    E_Client *focused_ec, *temp_ec = NULL;
+   Eina_Bool find_focus = EINA_FALSE;
 
    focused_ec = history_policy->focused_ec;
-   history_policy->focus_stack = eina_list_remove(history_policy->focus_stack, ec);
 
    EINA_LIST_FOREACH(history_policy->focus_stack, l, temp_ec)
      {
-        if (temp_ec != focused_ec) continue;
-        if (temp_ec->layer > ec->layer) continue;
+        if (temp_ec == ec) return;
+        if (temp_ec == focused_ec)
+          {
+             find_focus = EINA_TRUE;
+             continue;
+          }
+        else if (find_focus)
+          {
+             if (temp_ec->layer > ec->layer) continue;
 
-        history_policy->focus_stack = eina_list_append_relative_list(history_policy->focus_stack, ec, l);
-        return;
+             history_policy->focus_stack = eina_list_remove(history_policy->focus_stack, ec);
+             history_policy->focus_stack = eina_list_prepend_relative_list(history_policy->focus_stack, ec, l);
+             return;
+          }
      }
 
-   history_policy->focus_stack = eina_list_prepend(history_policy->focus_stack, ec);
+   history_policy->focus_stack = eina_list_remove(history_policy->focus_stack, ec);
+   if (find_focus)
+     history_policy->focus_stack = eina_list_append(history_policy->focus_stack, ec);
+   else
+     history_policy->focus_stack = eina_list_prepend(history_policy->focus_stack, ec);
 }
 
 static void