raster pushed a commit to branch master.

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

commit 73d305d2a8699f4535403e1820e13a024ea409e3
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Tue Jul 28 13:12:01 2020 +0100

    client - restore to added zone if were there before
    
    rememebr zone randr id where clients were if forced off a zone. if a
    zone is added check clients with that zone id - if they have it then
    restore them there. thbis will get loat if you move those clients
    between zones after they are dumped on the other zone or you change
    their virtual desktop etc.
---
 src/bin/e_client.c      | 10 ++++++--
 src/bin/e_client.h      |  2 ++
 src/bin/e_comp_canvas.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/src/bin/e_client.c b/src/bin/e_client.c
index 3a2716025..c38054812 100644
--- a/src/bin/e_client.c
+++ b/src/bin/e_client.c
@@ -461,19 +461,22 @@ _e_client_revert_focus(E_Client *ec)
 static void
 _e_client_free(E_Client *ec)
 {
+   if (ec->restore_zone_id)
+     {
+        eina_stringshare_del(ec->restore_zone_id);
+        ec->restore_zone_id = NULL;
+     }
    if (ec->pixmap)
      {
         if (e_pixmap_free(ec->pixmap))
           e_pixmap_client_set(ec->pixmap, NULL);
         ec->pixmap = NULL;
      }
-
    if (ec->frame)
      {
         e_comp_object_redirected_set(ec->frame, 0);
         e_comp_object_render_update_del(ec->frame);
      }
-
    E_OBJECT(ec)->references++;
    if (ec->fullscreen)
      {
@@ -2844,6 +2847,8 @@ e_client_desk_set(E_Client *ec, E_Desk *desk)
    E_OBJECT_CHECK(desk);
    E_OBJECT_TYPE_CHECK(desk, E_DESK_TYPE);
    if (ec->desk == desk) return;
+   if (ec->zone)
+     eina_stringshare_replace(&(ec->restore_zone_id), ec->zone->randr2_id);
    if (ec->e.state.profile.use)
      {
         const char *profile = desk->window_profile;
@@ -3431,6 +3436,7 @@ e_client_zone_set(E_Client *ec, E_Zone *zone)
      }
 
    ec->zone = zone;
+   eina_stringshare_replace(&(ec->restore_zone_id), zone->randr2_id);
 
    if ((!ec->desk) || (ec->desk->zone != ec->zone))
      e_client_desk_set(ec, e_desk_current_get(ec->zone));
diff --git a/src/bin/e_client.h b/src/bin/e_client.h
index a3e288d22..6c178819c 100644
--- a/src/bin/e_client.h
+++ b/src/bin/e_client.h
@@ -240,6 +240,8 @@ struct E_Client
    E_Zone *zone;
    E_Desk *desk;
 
+   const char *restore_zone_id;
+
    Ecore_Poller              *ping_poller;
    Ecore_Timer               *kill_timer;
 
diff --git a/src/bin/e_comp_canvas.c b/src/bin/e_comp_canvas.c
index ebf97b07e..d8c1e9f03 100644
--- a/src/bin/e_comp_canvas.c
+++ b/src/bin/e_comp_canvas.c
@@ -264,8 +264,42 @@ _e_comp_cb_mouse_move(void *d EINA_UNUSED, int t 
EINA_UNUSED, Ecore_Event_Mouse_
 ////////////////////////////////////
 
 static Eina_Bool
-_e_comp_cb_zone_change()
+_e_comp_cb_zone_change(void *d EINA_UNUSED, int type, void *event)
 {
+   if (type == E_EVENT_ZONE_ADD)
+     {
+        E_Event_Zone_Add *ev = event;
+        E_Client *ec;
+
+        E_CLIENT_FOREACH(ec)
+          {
+             if (ec->restore_zone_id)
+               {
+                  E_Zone *restore_zone =
+                    e_zone_for_id_get(ec->restore_zone_id);
+                  if ((restore_zone) && (ev->zone) &&
+                      (restore_zone == ev->zone))
+                    {
+                       int dx, dy;
+                       E_Desk *desk;
+
+                       dx = dy = -1;
+                       if (ec->desk)
+                         {
+                            dx = ec->desk->x;
+                            dy = ec->desk->y;
+                         }
+                       e_client_zone_set(ec, restore_zone);
+                       if ((dx >= 0) && (dy >= 0))
+                         {
+                            desk = e_desk_at_xy_get(restore_zone, dx, dy);
+                            if (desk) e_client_desk_set(ec, desk);
+                         }
+                       e_client_res_change_geometry_restore(ec);
+                    }
+               }
+          }
+     }
    e_comp_canvas_update();
    return ECORE_CALLBACK_PASS_ON;
 }
@@ -687,12 +721,37 @@ e_comp_canvas_update(void)
                     {
                        if (ec->zone == zone)
                          {
+                            const char *tmp;
+
+                            if (ec->restore_zone_id)
+                              tmp = eina_stringshare_add(ec->restore_zone_id);
+                            else
+                              tmp = NULL;
                             if (spare_zone)
-                              e_client_zone_set(ec, spare_zone);
+                              {
+                                 int dx, dy;
+                                 E_Desk *desk;
+
+                                 dx = dy = -1;
+                                 if (ec->desk)
+                                   {
+                                      dx = ec->desk->x;
+                                      dy = ec->desk->y;
+                                   }
+                                 e_client_res_change_geometry_save(ec);
+                                 e_client_zone_set(ec, spare_zone);
+                                 if ((dx >= 0) && (dy >= 0))
+                                   {
+                                      desk = e_desk_at_xy_get(spare_zone, dx, 
dy);
+                                      if (desk) e_client_desk_set(ec, desk);
+                                   }
+                              }
                             else
                               printf("EEEK! should not be here - but no\n"
                                      "spare zones exist to move this\n"
                                      "window to!!! help!\n");
+                            eina_stringshare_replace(&(ec->restore_zone_id), 
tmp);
+                            if (tmp) eina_stringshare_del(tmp);
                          }
                     }
                   e_object_del(E_OBJECT(zone));

-- 


Reply via email to