focus: renew topmost focus policy 17/213617/4 accepted/tizen/unified/20190911.111523 submit/tizen/20190911.042318
authorJunseok, Kim <juns.kim@samsung.com>
Mon, 9 Sep 2019 06:48:54 +0000 (15:48 +0900)
committerJunseok, Kim <juns.kim@samsung.com>
Tue, 10 Sep 2019 08:09:07 +0000 (17:09 +0900)
From now on, device can choice external focus policy via changing focus_policy_ext value in e_config
If focus_policy_ext set to E_FOCUS_EXT_TOP_STACK, then focus alwayls set to topmost visible & focusable window even user click window.
default value of focus_policy_ext is E_FOCUS_EXT_HISTORY

Change-Id: I9f156104cf5931d7ad389b20f84c70b683a625fc

src/bin/e_actions.c
src/bin/e_client.c
src/bin/e_client.h
src/bin/e_comp_object.c
src/bin/e_desk.c
src/bin/e_focus.c
src/bin/e_policy_stack.c

index 8a88a56..041affb 100644 (file)
@@ -1190,8 +1190,11 @@ window_jump_to(const char *params)
         evas_object_raise(ec->frame);
         if (ec->zone != current_zone)
           e_util_pointer_center(ec);
-        ELOGF("FOCUS", "focus set   | window_jump_to", ec);
-        e_client_frame_focus_set(ec, EINA_TRUE);
+        if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+          {
+             ELOGF("FOCUS", "focus set   | window_jump_to", ec);
+             e_client_frame_focus_set(ec, EINA_TRUE);
+          }
         return 1;
      }
    return 0;
@@ -1325,7 +1328,10 @@ ACT_FN_GO(window_zone_move_by, )
 //   e_client_desk_set(ec, e_desk_current_get(zone));
    if (max) e_client_maximize(ec, max);
    if (fullscreen) e_client_fullscreen(ec, fs);
-   ELOGF("FOCUS", "focus set   | window_zone_move_by_action", ec);
+   if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+     {
+        ELOGF("FOCUS", "focus set   | window_zone_move_by_action", ec);
+     }
    e_client_frame_focus_set(ec, EINA_TRUE);
 }
 
index c0a9666..1639200 100644 (file)
@@ -253,9 +253,12 @@ cleanup:
         
         if (!warp_client->lock_focus_out)
           {
-             ELOGF("FOCUS", "focus set   | pointer_warp_to_center", warp_client);
-             e_client_frame_focus_set(warp_client, EINA_TRUE);
-             e_client_focus_latest_set(warp_client);
+             if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+               {
+                  ELOGF("FOCUS", "focus set   | pointer_warp_to_center", warp_client);
+                  e_client_frame_focus_set(warp_client, EINA_TRUE);
+                  e_client_focus_latest_set(warp_client);
+               }
           }
         warp_client = NULL;
      }
@@ -851,6 +854,19 @@ _e_client_focus_can_take(E_Client *ec)
 }
 
 static E_Client *
+_e_client_focus_topmost_focusable_get()
+{
+   E_Client *ec = NULL;
+
+   E_CLIENT_REVERSE_FOREACH(ec)
+     {
+        if (_e_client_focus_can_take(ec))
+          return ec;
+     }
+   return NULL;
+}
+
+static E_Client *
 _e_client_find_next_focus(E_Client *ec)
 {
    Eina_List *l = NULL;
@@ -971,6 +987,16 @@ EINTERN void
 e_client_revert_focus(E_Client *ec)
 {
    E_Client *focus_ec = NULL;
+
+   // check topmost focus policy
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
+     {
+        focus_ec = _e_client_focus_topmost_focusable_get();
+        ELOGF("FOCUS", "focus set   | topmost_focus", focus_ec);
+        e_client_frame_focus_set(focus_ec, EINA_TRUE);
+        return;
+     }
+
    focus_ec = _e_client_revert_focus_get(ec);
 
    if (focus_ec)
@@ -1929,8 +1955,11 @@ _e_client_reset_lost_window(E_Client *ec)
    evas_object_raise(ec->frame);
    if (!ec->lock_focus_out)
      {
-        ELOGF("FOCUS", "focus set   | reset_lost_window", ec);
-        e_client_frame_focus_set(ec, EINA_TRUE);
+        if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+          {
+             ELOGF("FOCUS", "focus set   | reset_lost_window", ec);
+             e_client_frame_focus_set(ec, EINA_TRUE);
+          }
      }
 
    e_client_pointer_warp_to_center(ec);
@@ -2778,8 +2807,11 @@ _e_client_eval(E_Client *ec)
                   ec->cur_mouse_action->func.go(E_OBJECT(ec), NULL);
                   if (e_config->border_raise_on_mouse_action)
                     evas_object_raise(ec->frame);
-                  ELOGF("FOCUS", "focus set   | client eval", ec);
-                  e_client_frame_focus_set(ec, EINA_TRUE);
+                  if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+                    {
+                       ELOGF("FOCUS", "focus set   | client eval", ec);
+                       e_client_frame_focus_set(ec, EINA_TRUE);
+                    }
                }
              ec->changes.visible = 0;
              _e_client_event_show(ec);
@@ -3424,6 +3456,7 @@ _e_client_merge_focus_stack_with_defer_focus(void)
    Eina_Bool inserted = EINA_FALSE;
 
    if (focus_track_frozen > 0) return;
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
 
    if (!focus_stack)
      {
@@ -3475,6 +3508,17 @@ _e_client_focus_calculate(E_Zone *zone)
    EINA_SAFETY_ON_NULL_RETURN(zone);
    if (zone->display_state == E_ZONE_DISPLAY_STATE_OFF) return;
 
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
+     {
+        ec = _e_client_focus_topmost_focusable_get();
+        if (ec)
+          {
+             ELOGF("FOCUS", "focus set | topmost focus calculate", ec);
+             e_client_frame_focus_set(ec, EINA_TRUE);
+          }
+        return;
+     }
+
    if ((!focused) ||
        (focused != eina_list_data_get(focus_stack)) ||
        (!_e_client_focus_can_take(focused)))
@@ -5103,6 +5147,7 @@ e_client_focus_stack_lower(E_Client *ec)
 
    EINA_SAFETY_ON_NULL_RETURN(ec);
    if (focus_track_frozen > 0) return;
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
 
    focus_stack = eina_list_remove(focus_stack, ec);
 
@@ -5124,6 +5169,7 @@ e_client_focus_latest_set(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN(ec);
    if (focus_track_frozen > 0) return;
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
 
    focus_stack = eina_list_remove(focus_stack, ec);
    focus_stack = eina_list_prepend(focus_stack, ec);
@@ -5137,6 +5183,7 @@ e_client_focus_stack_append_current_focused(E_Client *ec)
 
    if (!ec) CRI("ACK");
    if (focus_track_frozen > 0) return;
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
 
    focus_stack = eina_list_remove(focus_stack, ec);
 
@@ -5156,6 +5203,7 @@ E_API void
 e_client_focus_defer_set(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN(ec);
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
 
    defer_focus_stack = eina_list_remove(defer_focus_stack, ec);
    defer_focus_stack = eina_list_prepend(defer_focus_stack, ec);
@@ -5165,6 +5213,7 @@ E_API void
 e_client_focus_defer_unset(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN(ec);
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
 
    defer_focus_stack = eina_list_remove(defer_focus_stack, ec);
 }
@@ -5194,6 +5243,8 @@ e_client_refocus(void)
    E_Client *ec;
    const Eina_List *l;
 
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
+
    EINA_LIST_FOREACH(e_client_focus_stack_get(), l, ec)
      if (ec->desk && ec->desk->visible && (!ec->iconic))
        {
@@ -5239,6 +5290,8 @@ e_client_focus_set_with_pointer(E_Client *ec)
     * expect us to emulate a look of focus but not actually set x input
     * focus as we do - so simply abort any focuse set on such windows */
    /* be strict about accepting focus hint */
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
+
    if ((!ec->icccm.accepts_focus) &&
        (!ec->icccm.take_focus)) return;
    if (ec->lock_focus_out) return;
@@ -5420,7 +5473,8 @@ e_client_activate(E_Client *ec, Eina_Bool just_do_it)
                   else
                     {
                        ELOGF("FOCUS", "focus set   | client activate", focus_ec);
-                       e_client_frame_focus_set(focus_ec, EINA_TRUE);
+                       if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+                         e_client_frame_focus_set(focus_ec, EINA_TRUE);
                     }
                }
              else
index 4ed35a0..8f5411e 100644 (file)
@@ -51,8 +51,8 @@ typedef enum _E_Focus_Policy
 
 typedef enum _E_Focus_Policy_Ext
 {
-   E_FOCUS_EXT_NONE,
    E_FOCUS_EXT_TOP_STACK,
+   E_FOCUS_EXT_HISTORY,
 } E_Focus_Policy_Ext;
 
 typedef enum
index afb5a5e..223601d 100644 (file)
@@ -2414,16 +2414,22 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
         if ((ec->modal) && (ec->modal != ec) &&
             (ec->modal->visible) && (!e_object_is_del(E_OBJECT(ec->modal))))
           {
-             ELOGF("FOCUS", "focus set   | intercept focus to modal", ec->modal);
-             e_client_frame_focus_set(ec->modal, focus);
+             if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+               {
+                  ELOGF("FOCUS", "focus set   | intercept focus to modal", ec->modal);
+                  e_client_frame_focus_set(ec->modal, focus);
+               }
              return;
           }
         else if ((ec->leader) && (ec->leader->modal) &&
                  (ec->leader->modal != ec) && ec->leader->modal->visible &&
                  (!e_object_is_del(E_OBJECT(ec->leader->modal))))
           {
-             ELOGF("FOCUS", "focus set   | intercept focus to leader->modal", ec->leader->modal);
-             e_client_frame_focus_set(ec->leader->modal, focus);
+             if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+               {
+                  ELOGF("FOCUS", "focus set   | intercept focus to leader->modal", ec->leader->modal);
+                  e_client_frame_focus_set(ec->leader->modal, focus);
+               }
              return;
           }
         if (!cw->visible)
index 172eeb1..041ca62 100644 (file)
@@ -483,8 +483,11 @@ e_desk_last_focused_focus(E_Desk *desk)
    focus_ec = e_client_focused_get();
    if (focus_ec)
      {
-        ELOGF("FOCUS", "focus unset | last_focused_focus", focus_ec);
-        e_client_frame_focus_set(focus_ec, EINA_FALSE);
+        if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+          {
+             ELOGF("FOCUS", "focus unset | last_focused_focus", focus_ec);
+             e_client_frame_focus_set(focus_ec, EINA_FALSE);
+          }
      }
 
    return NULL;
@@ -748,8 +751,11 @@ e_desk_flip_end(E_Desk *desk)
               if (e_client_util_ignored_get(ec)) continue;
               if (!e_client_util_desk_visible(ec, desk)) continue;
               if (ec->iconic) continue;
-              ELOGF("FOCUS", "focus set   | desk flip end", ec);
-              e_client_frame_focus_set(ec, EINA_TRUE);
+              if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+                {
+                   ELOGF("FOCUS", "focus set   | desk flip end", ec);
+                   e_client_frame_focus_set(ec, EINA_TRUE);
+                }
               if (e_config->raise_on_revert_focus)
                 evas_object_raise(ec->frame);
               return;
index 3e7247a..bf00959 100644 (file)
@@ -8,12 +8,14 @@
 E_API void
 e_focus_event_mouse_in(E_Client *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->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+          {
+             ELOGF("FOCUS", "focus set   | mouse in", ec);
+             e_client_frame_focus_set(ec, EINA_TRUE);
+          }
      }
    if (e_config->use_auto_raise)
      {
@@ -31,8 +33,11 @@ e_focus_event_mouse_out(E_Client *ec)
           {
              if (ec->focused)
                {
+                  if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+                    {
                   ELOGF("FOCUS", "focus unset | mouse out", ec);
                   e_client_frame_focus_set(ec, EINA_FALSE);
+                    }
                }
           }
      }
@@ -44,8 +49,11 @@ e_focus_event_mouse_down(E_Client *ec)
    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 (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+          {
+             ELOGF("FOCUS", "focus set   | mouse down", ec);
+             e_client_frame_focus_set(ec, EINA_TRUE);
+          }
 
         if (ec->floating)
           evas_object_raise(ec->frame);
index 3ce0b58..e3a9ece 100644 (file)
@@ -170,8 +170,11 @@ _e_policy_stack_fetch_transient(E_Client *ec)
                             new_focus = e_client_transient_child_top_get(ec->parent, EINA_TRUE);
                             if (new_focus)
                               {
-                                 ELOGF("FOCUS", "focus set   | tranient_for fetch", new_focus);
-                                 e_client_frame_focus_set(new_focus, EINA_TRUE);
+                                 if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
+                                   {
+                                      ELOGF("FOCUS", "focus set   | tranient_for fetch", new_focus);
+                                      e_client_frame_focus_set(new_focus, EINA_TRUE);
+                                   }
                               }
                          }
                     }