Gustavo Sverzut Barbieri wrote:
2009/7/6 manio <ma...@skyboo.net>:
Hello
Finaly i finished a patch for making gadman gadcons for multiple zones. I
did it same as a shelf - i also needed to add a zone property to the config.
One gadcon is changed to list of gadcons. In this way every client has a
proper zone (obtained from parent gadcon) - and the popups shows corrrectly
(for CTRL+ALT+G as well).

Hi manio, follow patch inline with comments:
ok - fixed patch attached :)

regards,
--
manio
jabber/e-mail: ma...@skyboo.net
http://manio.skyboo.net
Index: bin/e_config.c
===================================================================
--- bin/e_config.c	(revision 41251)
+++ bin/e_config.c	(working copy)
@@ -139,6 +139,7 @@
 #define D _e_config_gadcon_edd
    E_CONFIG_VAL(D, T, name, STR);
    E_CONFIG_VAL(D, T, id, INT);
+   E_CONFIG_VAL(D, T, zone, INT);
    E_CONFIG_LIST(D, T, clients, _e_config_gadcon_client_edd);
 
    _e_config_shelf_desk_edd = E_CONFIG_DD_NEW("E_Config_Shelf_Desk", E_Config_Shelf_Desk);
Index: bin/e_config.h
===================================================================
--- bin/e_config.h	(revision 41251)
+++ bin/e_config.h	(working copy)
@@ -446,6 +446,7 @@
 {
    const char *name;
    int         id;
+   int         zone;
    Eina_List  *clients;
 };
 
Index: modules/gadman/e_mod_gadman.h
===================================================================
--- modules/gadman/e_mod_gadman.h	(revision 41251)
+++ modules/gadman/e_mod_gadman.h	(working copy)
@@ -15,6 +15,11 @@
 #define BG_CUSTOM 2
 #define BG_TRANS  3
 
+#define ID_GADMAN_LAYER_BG  114
+#define ID_GADMAN_LAYER_TOP 115
+
+#define MIN_VISIBLE_MARIGIN 20
+
 typedef struct _Manager Manager;
 typedef struct _Config Config;
 
@@ -32,9 +37,9 @@
 
 struct _Manager
 {
-   E_Gadcon    *gc;
+   Eina_List   *gadcons[2];  //0=bg, 1=top
    E_Gadcon    *gc_top;
-   Eina_List   *gadgets;
+   Eina_List   *gadgets[2];  //0=bg, 1=top
    Evas_Object *mover;
    Evas_Object *mover_top;
    Evas_Object *full_bg;
@@ -63,10 +68,11 @@
 void             gadman_shutdown(void);
 E_Gadcon_Client *gadman_gadget_add(E_Gadcon_Client_Class *cc, int ontop);
 void             gadman_gadget_del(E_Gadcon_Client *gcc);
-E_Gadcon_Client *gadman_gadget_place(E_Config_Gadcon_Client *cf, int ontop);
+E_Gadcon_Client *gadman_gadget_place(E_Config_Gadcon_Client *cf, int ontop, E_Zone *zone);
 void             gadman_gadget_edit_start(E_Gadcon_Client *gcc);
 void             gadman_gadget_edit_end(void);
 void             gadman_gadgets_toggle(void);
 void             gadman_update_bg(void);
+E_Gadcon        *gadman_gadcon_get(const E_Zone *zone, int ontop);
 
 #endif
Index: modules/gadman/e_mod_gadman.c
===================================================================
--- modules/gadman/e_mod_gadman.c	(revision 41251)
+++ modules/gadman/e_mod_gadman.c	(working copy)
@@ -12,7 +12,7 @@
 
 static Evas_Object* _create_mover(E_Gadcon *gc);
 static Evas_Object* _get_mover(E_Gadcon_Client *gcc);
-static E_Gadcon* _gadman_gadcon_new(const char* name, int ontop);
+static E_Gadcon* _gadman_gadcon_new(const char* name, int ontop, E_Zone *zone);
 
 static void on_shape_change(void *data, E_Container_Shape *es, E_Container_Shape_Change ch);
 
@@ -45,6 +45,9 @@
 void
 gadman_init(E_Module *m)
 {
+   const Eina_List *l;
+   E_Zone *zone;
+
    /* Create Manager */
    Man = calloc(1, sizeof(Manager));
    if (!Man) return;
@@ -53,7 +56,10 @@
    Man->container = e_container_current_get(e_manager_current_get());
    Man->width = Man->container->w;
    Man->height = Man->container->h;
-   Man->gadgets = NULL;
+   Man->gadcons[0] = NULL;  //bg
+   Man->gadcons[1] = NULL;  //top
+   Man->gadgets[0] = NULL;  //bg
+   Man->gadgets[1] = NULL;  //top
    Man->top_ee = NULL;
    Man->visible = 0;
 
@@ -66,40 +72,53 @@
    /* with this we can trap screen resolution change (a better way?)*/
    e_container_shape_change_callback_add(Man->container, on_shape_change, NULL);
 
-   /* Create Gadcon for background and top */
-   Man->gc = _gadman_gadcon_new("gadman", 0);
-   Man->gc_top = _gadman_gadcon_new("gadman_top", 1);
-
-   /* Create 2 mover objects */
-   Man->mover = _create_mover(Man->gc);
-   Man->mover_top = _create_mover(Man->gc_top);
+   /* iterating through zones - and making gadmans on each */
+   EINA_LIST_FOREACH(Man->container->zones, l, zone)
+     {
+       /* Create Gadcon for background and top */
+       Man->gadcons[0] = eina_list_append(Man->gadcons[0], _gadman_gadcon_new("gadman", 0, zone));
+       Man->gadcons[1] = eina_list_append(Man->gadcons[1], _gadman_gadcon_new("gadman_top", 1, zone));
+     }
 }
 
 void
 gadman_shutdown(void)
 {
+   const Eina_List *l;
+   E_Gadcon *gc;
+
    e_container_shape_change_callback_del(Man->container, on_shape_change, NULL);
 
-   e_gadcon_unpopulate(Man->gc);
-   e_gadcon_unpopulate(Man->gc_top);
+   EINA_LIST_FREE(Man->gadcons[0], gc)
+     {
+       e_gadcon_unpopulate(gc);
+       e_gadcon_custom_del(gc);
 
-   e_gadcon_custom_del(Man->gc);
-   e_gadcon_custom_del(Man->gc_top);
+       /* free gadcons */
+       e_config->gadcons = eina_list_remove(e_config->gadcons, gc);
+       eina_stringshare_del(gc->name);
 
-   /* free gadcons */
-   e_config->gadcons = eina_list_remove(e_config->gadcons, Man->gc);
-   e_config->gadcons = eina_list_remove(e_config->gadcons, Man->gc_top);
-   eina_stringshare_del(Man->gc->name);
-   eina_stringshare_del(Man->gc_top->name);
-   if (Man->gc->config_dialog) e_object_del(E_OBJECT(Man->gc->config_dialog));
+       if (gc->config_dialog) e_object_del(E_OBJECT(gc->config_dialog));
+     }
+   EINA_LIST_FREE(Man->gadcons[1], gc)
+     {
+       e_gadcon_unpopulate(gc);
+       e_gadcon_custom_del(gc);
+
+       /* free gadcons */
+       e_config->gadcons = eina_list_remove(e_config->gadcons, gc);
+       eina_stringshare_del(gc->name);
+
+       if (gc->config_dialog) e_object_del(E_OBJECT(gc->config_dialog));
+     }
+
    if (Man->icon_name) eina_stringshare_del(Man->icon_name);
-   free(Man->gc);
-   free(Man->gc_top);
 
    /* free manager */
    evas_object_del(Man->mover);
    evas_object_del(Man->mover_top);
-   eina_list_free(Man->gadgets);
+   eina_list_free(Man->gadgets[0]);
+   eina_list_free(Man->gadgets[1]);
    if (Man->top_ee)
      {
         e_canvas_del(Man->top_ee);
@@ -112,35 +131,42 @@
 void
 gadman_populate_class(void *data, E_Gadcon *gc, const E_Gadcon_Client_Class *cc)
 {
-   Eina_List *l;
+   const Eina_List *l;
+   E_Config_Gadcon_Client *cf_gcc;
 
-   for (l = gc->cf->clients; l; l = l->next)
+   EINA_LIST_FOREACH(gc->cf->clients, l, cf_gcc)
      {
-        E_Config_Gadcon_Client *cf_gcc;
-
-        if (!(cf_gcc = l->data)) continue;
-        if (cf_gcc->name && cc->name && !strcmp(cf_gcc->name, cc->name))
-         gadman_gadget_place(cf_gcc, (int)data);
+        if (cf_gcc->name && cc->name && !strcmp(cf_gcc->name, cc->name) && (gc->cf->zone == gc->zone->id))
+          gadman_gadget_place(cf_gcc, (int)data, gc->zone);
      }
 }
 
+E_Gadcon *
+gadman_gadcon_get(const E_Zone *zone, int ontop)
+{
+   const Eina_List *l;
+   E_Gadcon *gc;
+
+   EINA_LIST_FOREACH(Man->gadcons[ontop], l, gc)
+     if (gc->zone == zone) return gc;
+   return NULL;
+}
+
 E_Gadcon_Client *
-gadman_gadget_place(E_Config_Gadcon_Client *cf, int ontop)
+gadman_gadget_place(E_Config_Gadcon_Client *cf, int ontop, E_Zone *zone)
 {
+   const Eina_List *l;
    E_Gadcon *gc;
    E_Gadcon_Client *gcc;
    E_Gadcon_Client_Class *cc = NULL;
-   Eina_List *l = NULL;
 
    if (!cf->name) return NULL;
 
-   if (ontop) gc = Man->gc_top;
-   else gc = Man->gc;
+   gc = gadman_gadcon_get(zone, ontop);
 
    /* Find provider */
-   for (l = e_gadcon_provider_list(); l; l = l->next) 
+   EINA_LIST_FOREACH(e_gadcon_provider_list(), l, cc)
      {
-        cc = l->data;
         if (!strcmp(cc->name, cf->name))
           break;
         else
@@ -154,7 +180,7 @@
    gcc->cf = cf;
    gcc->client_class = cc;
 
-   Man->gadgets = eina_list_append(Man->gadgets, gcc);
+   Man->gadgets[ontop] = eina_list_append(Man->gadgets[ontop], gcc);
 
    //printf("Place Gadget %s (style: %s id: %s) (gadcon: %s)\n", gcc->name, cf->style, cf->id, gc->name);
 
@@ -180,7 +206,7 @@
 
    _apply_widget_position(gcc);
 
-   if (gcc->gadcon == Man->gc_top)
+   if (gcc->gadcon->id == ID_GADMAN_LAYER_TOP)
      edje_object_signal_emit(gcc->o_frame, "e,state,visibility,hide", "e");
 
    evas_object_show(gcc->o_frame);
@@ -196,10 +222,7 @@
    E_Gadcon *gc;
    int w, h;
 
-   if (ontop)
-     gc = Man->gc_top;
-   else
-     gc = Man->gc;
+   gc = gadman_gadcon_get(e_util_zone_current_get(e_manager_current_get()), ontop);
 
    /* Create Config_Gadcon_Client */
    cf = e_gadcon_client_config_new(gc, cc->name);
@@ -210,7 +233,7 @@
    cf->geom.size_h = DEFAULT_SIZE_H;
 
    /* Place the new gadget */
-   gcc = gadman_gadget_place(cf, ontop);
+   gcc = gadman_gadget_place(cf, ontop, gc->zone);
 
    /* Respect Aspect */
    evas_object_geometry_get(gcc->o_frame, NULL, NULL, &w, &h);
@@ -229,9 +252,9 @@
 }
 
 void
-gadman_gadget_remove(E_Gadcon_Client *gcc)
+gadman_gadget_remove(E_Gadcon_Client *gcc, int ontop)
 {
-   Man->gadgets = eina_list_remove(Man->gadgets, gcc);
+   Man->gadgets[ontop] = eina_list_remove(Man->gadgets[ontop], gcc);
 
    edje_object_part_unswallow(gcc->o_frame, gcc->o_base);
    evas_object_del(gcc->o_frame);
@@ -245,7 +268,9 @@
 void
 gadman_gadget_del(E_Gadcon_Client *gcc)
 {
-   Man->gadgets = eina_list_remove(Man->gadgets, gcc);
+   /* checking where the client belong (bg/top) */
+   int ontop = (int) (gcc->gadcon->id == ID_GADMAN_LAYER_TOP);
+   Man->gadgets[ontop] = eina_list_remove(Man->gadgets[ontop], gcc);
 
    edje_object_part_unswallow(gcc->o_frame, gcc->o_base);
    evas_object_del(gcc->o_frame);
@@ -282,11 +307,16 @@
 void
 gadman_gadget_edit_end(void)
 {
+   const Eina_List *l;
+   E_Gadcon *gc;
+
    evas_object_hide(Man->mover);
    evas_object_hide(Man->mover_top);
 
-   Man->gc->editing = 0;
-   Man->gc_top->editing = 0;
+   EINA_LIST_FOREACH(Man->gadcons[0], l, gc)
+     gc->editing = 0;
+   EINA_LIST_FOREACH(Man->gadcons[1], l, gc)
+     gc->editing = 0;
 
    if (current) _save_widget_position(current);
 }
@@ -294,7 +324,8 @@
 void
 gadman_gadgets_show(void)
 {
-   Eina_List *l = NULL;
+   const Eina_List *l;
+   E_Gadcon_Client *gcc;
 
    Man->visible = 1;
    ecore_evas_show(Man->top_ee);
@@ -317,12 +348,9 @@
 	                        "e,state,visibility,show,custom,now", "e");
      }
 
-   for (l = Man->gadgets; l; l = l->next)
+   /* Showing top gadgets */
+   EINA_LIST_FOREACH(Man->gadgets[1], l, gcc)
      {
-	E_Gadcon_Client *gcc;
-
-	if (!(gcc = l->data)) continue;
-	if (gcc->gadcon != Man->gc_top) continue;
 	if (Man->conf->anim_gad)
 	  edje_object_signal_emit(gcc->o_frame,
 	                          "e,state,visibility,show", "e");
@@ -335,7 +363,8 @@
 void
 gadman_gadgets_hide(void)
 {
-   Eina_List *l = NULL;
+   const Eina_List *l;
+   E_Gadcon_Client *gcc;
 
    Man->visible = 0;
 
@@ -354,12 +383,9 @@
 	                       "e,state,visibility,hide,custom,now", "e");
      }
 
-   for (l = Man->gadgets; l; l = l->next)
+   /* Hiding top gadgets */
+   EINA_LIST_FOREACH(Man->gadgets[1], l, gcc)
      {
-        E_Gadcon_Client *gcc;
-
-	if (!(gcc = l->data)) continue;
-	if (gcc->gadcon != Man->gc_top) continue;
 	if (Man->conf->anim_gad)
 	  edje_object_signal_emit(gcc->o_frame,
 	                          "e,state,visibility,hide", "e");
@@ -428,10 +454,11 @@
 
 /* Internals */
 static E_Gadcon*
-_gadman_gadcon_new(const char* name, int ontop)
+_gadman_gadcon_new(const char* name, int ontop, E_Zone *zone)
 {
+   const Eina_List *l;
    E_Gadcon *gc;
-   Eina_List *l = NULL;
+   E_Config_Gadcon *cg;
 
    /* Create Gadcon */
    gc = E_OBJECT_ALLOC(E_Gadcon, E_GADCON_TYPE, NULL);
@@ -444,9 +471,12 @@
    /* Create ecore fullscreen window */
    if (ontop)
      {
-        Man->top_ee = e_canvas_new(e_config->evas_engine_popups,
-                                   Man->container->win, 0, 0, 0, 0, 1, 1,
-                                   &(Man->top_win));
+        if (!Man->top_ee)
+        {
+          Man->top_ee = e_canvas_new(e_config->evas_engine_popups,
+                                     Man->container->win, 0, 0, 0, 0, 1, 1,
+                                     &(Man->top_win));
+        }
 
         if (Man->use_composite)
           {
@@ -469,6 +499,7 @@
 
         /* create full background object */
         Man->full_bg = edje_object_add(gc->evas);
+
         e_theme_edje_object_set(Man->full_bg, "base/theme/gadman",
                                 "e/gadman/full_bg");
         edje_object_signal_callback_add(Man->full_bg, "mouse,down,*",
@@ -490,11 +521,11 @@
         e_drop_xdnd_register_set(Man->container->bg_win, 1);
      }
 
-   e_gadcon_zone_set(gc, e_zone_current_get(Man->container));
+   e_gadcon_zone_set(gc, zone);
    e_gadcon_util_menu_attach_func_set(gc, _attach_menu, NULL);
    e_gadcon_populate_callback_set(gc, gadman_populate_class, (void*)ontop);
 
-   gc->id = 114 + ontop; // TODO what's this ??????? 114 is a random number
+   gc->id = ID_GADMAN_LAYER_BG + ontop;
    gc->edje.o_parent = NULL;
    gc->edje.swallow_name = NULL;
    gc->shelf = NULL;
@@ -507,12 +538,9 @@
 
    /* Search for existing gadcon config */
    gc->cf = NULL;
-   for (l = e_config->gadcons; l; l=l->next)
+   EINA_LIST_FOREACH(e_config->gadcons, l, cg)
      {
-        E_Config_Gadcon *cg;
-
-        if (!(cg = l->data)) continue;
-        if (!strcmp(cg->name, name))
+        if (!strcmp(cg->name, name) && (cg->zone == zone->id))
           {
              gc->cf = cg;
              break;
@@ -525,6 +553,7 @@
         gc->cf = E_NEW(E_Config_Gadcon, 1);
         gc->cf->name = eina_stringshare_add(name);
         gc->cf->id = gc->id;
+        gc->cf->zone = zone->id;
         gc->cf->clients = NULL;
         e_config->gadcons = eina_list_append(e_config->gadcons, gc->cf);
         e_config_save_queue();
@@ -532,6 +561,13 @@
 
    e_gadcon_custom_new(gc);
 
+   /* Create mover objects */
+   if (!ontop && !Man->mover)    Man->mover = _create_mover(gc);
+   if (ontop && !Man->mover_top) Man->mover_top = _create_mover(gc);
+
+   /* Assigning top gadcon - needed in gadman_update_bg() */
+   if (ontop && !Man->gc_top)    Man->gc_top = gc;
+
    return gc;
 }
 
@@ -588,7 +624,7 @@
 static Evas_Object *
 _get_mover(E_Gadcon_Client *gcc)
 {
-   if (gcc->gadcon == Man->gc_top)
+   if (gcc->gadcon->id == ID_GADMAN_LAYER_TOP)
      return Man->mover_top;
    else
      return Man->mover;
@@ -612,26 +648,30 @@
 _apply_widget_position(E_Gadcon_Client *gcc)
 {
    int x, y, w, h;
+   E_Zone *zone;
 
    x = gcc->cf->geom.pos_x * Man->width;
    y = gcc->cf->geom.pos_y * Man->height;
    w = gcc->cf->geom.size_w * Man->width;
    h = gcc->cf->geom.size_h * Man->height;
 
+   /* Obtain zone from parent gadcon */
+   zone = gcc->gadcon->zone;
+
    /* Respect min sizes */
    if (h < gcc->min.h) h = gcc->min.h;
    if (w < gcc->min.w) w = gcc->min.w;
    if (h < 1) h = 100;
    if (w < 1) w = 100;
 
-   /* Respect screen margin */
-   if (x < 0) x = 0;
-   if (y < 0) y = 0;
-   if (x > Man->width) x = 0;
-   if (y > Man->height) y = 0;
+   /* Respect zone marigin */
+   if (x < zone->x) x = zone->x;
+   if (y < zone->y) y = zone->y;
+   if (x > (zone->x + zone->w)) x = zone->x;
+   if (y > (zone->y + zone->h)) y = zone->y;
 
-   if ((y + h) > Man->height) h = (Man->height - y);
-   if ((x + w) > Man->width) w = (Man->width - x);
+   if ((y + h) > (zone->y + zone->h + MIN_VISIBLE_MARIGIN)) h = ((zone->y + zone->h + MIN_VISIBLE_MARIGIN) - y);
+   if ((x + w) > (zone->x + zone->w + MIN_VISIBLE_MARIGIN)) w = ((zone->x + zone->w + MIN_VISIBLE_MARIGIN) - x);
 
    evas_object_move(gcc->o_frame, x, y);
    evas_object_resize(gcc->o_frame, w, h);
@@ -709,7 +749,7 @@
    e_menu_item_label_set(mi, _("Always on desktop"));
    e_menu_item_radio_set(mi, 1);
    e_menu_item_radio_group_set(mi, 2);
-   if (gcc->gadcon == Man->gc)
+   if (gcc->gadcon->id == ID_GADMAN_LAYER_BG)
      e_menu_item_toggle_set(mi, 1);
    e_menu_item_callback_set(mi, on_menu_layer_bg, gcc);
 
@@ -721,7 +761,7 @@
    e_menu_item_label_set(mi, buf);
    e_menu_item_radio_set(mi, 1);
    e_menu_item_radio_group_set(mi, 2);
-   if (gcc->gadcon == Man->gc_top)
+   if (gcc->gadcon->id == ID_GADMAN_LAYER_TOP)
      e_menu_item_toggle_set(mi, 1);
    e_menu_item_callback_set(mi, on_menu_layer_top, gcc);
 
@@ -799,7 +839,9 @@
 static void
 on_shape_change(void *data, E_Container_Shape *es, E_Container_Shape_Change ch)
 {
-   Eina_List *l = NULL;
+   const Eina_List *l, *g;
+   E_Gadcon *gc;
+   E_Config_Gadcon_Client *cf_gcc;
    E_Container  *con;
 
    con = e_container_shape_container_get(es);
@@ -810,22 +852,18 @@
    Man->height = con->h;
 
    /* ReStart gadgets */
-   e_gadcon_unpopulate(Man->gc);
-   e_gadcon_unpopulate(Man->gc_top);
-   for (l = Man->gc->cf->clients; l; l = l->next)
+
+   EINA_LIST_FOREACH(Man->gadcons[0], g, gc)
      {
-        E_Config_Gadcon_Client *cf_gcc;
-
-        if (!(cf_gcc = l->data)) continue;
-        gadman_gadget_place(cf_gcc, 0);
+        e_gadcon_unpopulate(gc);
+        EINA_LIST_FOREACH(gc->cf->clients, l, cf_gcc)
+          gadman_gadget_place(cf_gcc, 0, gc->zone);
      }
-
-   for (l = Man->gc_top->cf->clients; l; l = l->next)
+   EINA_LIST_FOREACH(Man->gadcons[1], g, gc)
      {
-        E_Config_Gadcon_Client *cf_gcc;
-
-        if (!(cf_gcc = l->data)) continue;
-        gadman_gadget_place(cf_gcc, 1);
+        e_gadcon_unpopulate(gc);
+        EINA_LIST_FOREACH(gc->cf->clients, l, cf_gcc)
+          gadman_gadget_place(cf_gcc, 1, gc->zone);
      }
 }
 
@@ -926,16 +964,28 @@
 static void
 on_menu_layer_bg(void *data, E_Menu *m, E_Menu_Item *mi)
 {
+   const Eina_List *l;
    E_Config_Gadcon_Client *cf;
+   E_Gadcon_Client *gcc;
+   E_Gadcon *gc;
 
    if (!current) return;
    cf = current->cf;
+   gcc = data;
 
-   gadman_gadget_remove(current);
-   current = gadman_gadget_place(cf, 0);
+   gadman_gadget_remove(current, 1);
+   current = gadman_gadget_place(cf, 0, gcc->gadcon->zone);
 
-   Man->gc_top->cf->clients = eina_list_remove(Man->gc_top->cf->clients, cf);
-   Man->gc->cf->clients = eina_list_append(Man->gc->cf->clients, cf);
+   EINA_LIST_FOREACH(Man->gadcons[0], l, gc)
+     {
+        if (gc->zone != current->gadcon->zone) continue;
+        gc->cf->clients = eina_list_append(gc->cf->clients, cf);
+     }
+   EINA_LIST_FOREACH(Man->gadcons[1], l, gc)
+     {
+        if (gc->zone != current->gadcon->zone) continue;
+        gc->cf->clients = eina_list_remove(gc->cf->clients, cf);
+     }
 
    e_config_save_queue();
 }
@@ -943,16 +993,28 @@
 static void
 on_menu_layer_top(void *data, E_Menu *m, E_Menu_Item *mi)
 {
+   const Eina_List *l;
    E_Config_Gadcon_Client *cf;
+   E_Gadcon_Client *gcc;
+   E_Gadcon *gc;
 
    if (!current) return;
    cf = current->cf;
+   gcc = data;
 
-   gadman_gadget_remove(current);
-   current = gadman_gadget_place(cf, 1);
+   gadman_gadget_remove(current, 0);
+   current = gadman_gadget_place(cf, 1, gcc->gadcon->zone);
 
-   Man->gc->cf->clients = eina_list_remove(Man->gc->cf->clients, cf);
-   Man->gc_top->cf->clients = eina_list_append(Man->gc_top->cf->clients, cf);
+   EINA_LIST_FOREACH(Man->gadcons[0], l, gc)
+     {
+        if (gc->zone != current->gadcon->zone) continue;
+        gc->cf->clients = eina_list_remove(gc->cf->clients, cf);
+     }
+   EINA_LIST_FOREACH(Man->gadcons[1], l, gc)
+     {
+        if (gc->zone != current->gadcon->zone) continue;
+        gc->cf->clients = eina_list_append(gc->cf->clients, cf);
+     }
 
    e_config_save_queue();
 
@@ -988,9 +1050,10 @@
 
    ev = event_info;
 
-   if (Man->gc->editing) gadman_gadget_edit_end();
+   gcc = data;
 
-   gcc = data;
+   if (gcc->gadcon->editing) gadman_gadget_edit_end();
+
    current = gcc;
 
    if (ev->button == 5)
@@ -1225,9 +1288,32 @@
    /* DRAG_STOP */
    if (action == DRAG_STOP)
      {
-	current->moving = 0;
+        E_Config_Gadcon_Client *cf;
+        E_Zone *dst_zone = NULL;
+        E_Gadcon *dst_gadcon;
+        int ontop, gx, gy;
+
+        current->moving = 0;
         dx = dy = 0;
-        _save_widget_position(current);
+
+        /* checking if zone was changed for dragged gadget */
+        evas_object_geometry_get(current->o_frame, &gx, &gy, NULL, NULL);
+        dst_zone = e_container_zone_at_point_get(e_container_current_get(e_manager_current_get()), gx, gy);
+        if (dst_zone && (current->gadcon->zone != dst_zone))
+          {
+             cf = current->cf;
+             ontop = (int) (current->gadcon->id == ID_GADMAN_LAYER_TOP);
+
+             current->gadcon->cf->clients = eina_list_remove(current->gadcon->cf->clients, cf);
+             dst_gadcon = gadman_gadcon_get(dst_zone, ontop);
+             if (dst_gadcon)
+               {
+                  dst_gadcon->cf->clients = eina_list_append(dst_gadcon->cf->clients, cf);
+                  e_config_save_queue();
+               }
+          }
+        else
+          _save_widget_position(current);
         return;
      }
 

------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to