discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=b246cc27ee7407cef1a6b0b8abeb9e4d70cda8d7

commit b246cc27ee7407cef1a6b0b8abeb9e4d70cda8d7
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Fri Aug 18 15:52:52 2017 -0400

    handle focus reverting correctly when using desk flip all actions
    
    perform the focus revert once the last desk has finished flipping and based
    on all available visible windows
    
    fix T3495
---
 src/bin/e_actions.c | 17 +++++++++++------
 src/bin/e_desk.c    | 33 +++++++++++++++++++++++++++++----
 src/bin/e_zone.h    |  1 +
 3 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c
index 2e356edd2..406b0b632 100644
--- a/src/bin/e_actions.c
+++ b/src/bin/e_actions.c
@@ -1544,12 +1544,17 @@ ACT_FN_GO(desk_linear_flip_to, )
 }
 
 #define DESK_ACTION_ALL(zone, act) \
-   E_Zone *zone; \
-   const Eina_List *lz; \
-   \
-   EINA_LIST_FOREACH(e_comp->zones, lz, zone) { \
-      act; \
-   }
+   do { \
+     E_Zone *zone; \
+     const Eina_List *lz; \
+     \
+     EINA_LIST_FOREACH(e_comp->zones, lz, zone) { \
+        { \
+           zone->desk_flip_sync = 1; \
+           act; \
+        } \
+     } \
+   } while (0)
 
 /***************************************************************************/
 ACT_FN_GO(desk_linear_flip_to_screen, )
diff --git a/src/bin/e_desk.c b/src/bin/e_desk.c
index 83f746e66..5d1c41276 100644
--- a/src/bin/e_desk.c
+++ b/src/bin/e_desk.c
@@ -401,7 +401,9 @@ e_desk_last_focused_focus(E_Desk *desk)
    EINA_LIST_FOREACH(e_client_focus_stack_get(), l, ec)
      {
         if ((!ec->iconic) && (evas_object_visible_get(ec->frame) || 
ec->changes.visible) &&
-            ((ec->desk == desk) || ((ec->zone == desk->zone) && ec->sticky)) &&
+            ((desk &&
+            ((ec->desk == desk) || ((ec->zone == desk->zone) && ec->sticky))) 
||
+            ((!desk) && ec->desk->visible)) &&
             (ec->icccm.accepts_focus || ec->icccm.take_focus) &&
             (ec->netwm.type != E_WINDOW_TYPE_DOCK) &&
             (ec->netwm.type != E_WINDOW_TYPE_TOOLBAR) &&
@@ -617,6 +619,7 @@ e_desk_flip_end(E_Desk *desk)
 {
    E_Event_Desk_After_Show *ev;
    E_Client *ec;
+   Eina_Bool do_global_focus = EINA_FALSE;
 
    ev = E_NEW(E_Event_Desk_After_Show, 1);
    ev->desk = desk;
@@ -625,6 +628,21 @@ e_desk_flip_end(E_Desk *desk)
                    _e_desk_event_desk_after_show_free, NULL);
 
    e_comp_shape_queue();
+   if (desk->zone->desk_flip_sync)
+     {
+        Eina_List *l;
+        E_Zone *zone;
+        Eina_Bool sync = EINA_FALSE;
+
+        EINA_LIST_FOREACH(e_comp->zones, l, zone)
+          {
+             if (zone != desk->zone)
+               sync |= zone->desk_flip_sync;
+          }
+        do_global_focus = !sync;
+        desk->zone->desk_flip_sync = 0;
+        if (!do_global_focus) return;
+     }
    if (!e_config->focus_last_focused_per_desktop) return;
    if ((e_config->focus_policy == E_FOCUS_MOUSE) ||
        (e_config->focus_policy == E_FOCUS_SLOPPY))
@@ -633,10 +651,17 @@ e_desk_flip_end(E_Desk *desk)
         /* only set focus/warp pointer if currently focused window
          * is on same screen (user hasn't switched screens during transition)
          */
-        if (ec && ec->desk && (ec->desk->zone != desk->zone)) return;
+        if (do_global_focus)
+          {
+             if (ec && e_client_util_desk_visible(ec, ec->desk)) return;
+          }
+        else
+          {
+             if (ec && ec->desk && (ec->desk->zone != desk->zone)) return;
+          }
      }
    if (starting) return;
-   ec = e_desk_last_focused_focus(desk);
+   ec = e_desk_last_focused_focus(do_global_focus ? NULL : desk);
    if ((e_config->focus_policy != E_FOCUS_MOUSE) && (!ec))
      {
         /* we didn't previously have a focused window on this desk
@@ -648,7 +673,7 @@ e_desk_flip_end(E_Desk *desk)
            {
               /* start with top and go down... */
               if (e_client_util_ignored_get(ec)) continue;
-              if (!e_client_util_desk_visible(ec, desk)) continue;
+              if (!evas_object_visible_get(ec->frame)) continue;
               if (ec->iconic) continue;
               evas_object_focus_set(ec->frame, 1);
               if (e_config->raise_on_revert_focus)
diff --git a/src/bin/e_zone.h b/src/bin/e_zone.h
index f3c3eaa6c..f3eb3f329 100644
--- a/src/bin/e_zone.h
+++ b/src/bin/e_zone.h
@@ -94,6 +94,7 @@ struct _E_Zone
    Eina_Bool useful_geometry_changed : 1;
    Eina_Bool useful_geometry_dirty : 1;
    Eina_Bool      stowed : 1;
+   Eina_Bool desk_flip_sync : 1;
 };
 
 struct _E_Event_Zone_Generic

-- 


Reply via email to