5 * * fix shape callbacks to be able to be safely deleted
6 * * remove duplicate bd->layer -> layers code
10 /* local subsystem functions */
11 static void _e_container_free(E_Container *con);
13 static E_Container *_e_container_find_by_event_window(Ecore_X_Window win);
15 static Eina_Bool _e_container_cb_mouse_in(void *data, int type, void *event);
16 static Eina_Bool _e_container_cb_mouse_out(void *data, int type, void *event);
17 static Eina_Bool _e_container_cb_mouse_down(void *data, int type, void *event);
18 static Eina_Bool _e_container_cb_mouse_up(void *data, int type, void *event);
19 static Eina_Bool _e_container_cb_mouse_move(void *data, int type, void *event);
20 static Eina_Bool _e_container_cb_mouse_wheel(void *data, int type, void *event);
22 static void _e_container_shape_del(E_Container_Shape *es);
23 static void _e_container_shape_free(E_Container_Shape *es);
24 static void _e_container_shape_change_call(E_Container_Shape *es, E_Container_Shape_Change ch);
25 static void _e_container_resize_handle(E_Container *con);
26 static void _e_container_event_container_resize_free(void *data, void *ev);
28 EAPI int E_EVENT_CONTAINER_RESIZE = 0;
29 static Eina_List *handlers = NULL;
31 /* externally accessible functions */
33 e_container_init(void)
35 E_EVENT_CONTAINER_RESIZE = ecore_event_type_new();
37 handlers = eina_list_append(handlers, ecore_event_handler_add(ECORE_X_EVENT_MOUSE_IN, _e_container_cb_mouse_in, NULL));
38 handlers = eina_list_append(handlers, ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT, _e_container_cb_mouse_out, NULL));
39 handlers = eina_list_append(handlers, ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _e_container_cb_mouse_down, NULL));
40 handlers = eina_list_append(handlers, ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _e_container_cb_mouse_up, NULL));
41 handlers = eina_list_append(handlers, ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _e_container_cb_mouse_move, NULL));
42 handlers = eina_list_append(handlers, ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, _e_container_cb_mouse_wheel, NULL));
47 e_container_shutdown(void)
49 E_FREE_LIST(handlers, ecore_event_handler_del);
54 e_container_new(E_Manager *man)
59 Eina_List *l, *screens;
62 static int container_num = 0;
64 con = E_OBJECT_ALLOC(E_Container, E_CONTAINER_TYPE, _e_container_free);
65 if (!con) return NULL;
67 con->manager->containers = eina_list_append(con->manager->containers, con);
68 con->w = con->manager->w;
69 con->h = con->manager->h;
70 con->win = con->manager->win;
72 if (!e_config->null_container_win)
73 con->bg_ecore_evas = e_canvas_new(con->win,
74 0, 0, con->w, con->h, 1, 1,
77 con->bg_ecore_evas = e_canvas_new(con->win,
80 e_canvas_add(con->bg_ecore_evas);
81 con->event_win = ecore_x_window_input_new(con->win, 0, 0, con->w, con->h);
82 ecore_x_window_show(con->event_win);
83 con->bg_evas = ecore_evas_get(con->bg_ecore_evas);
84 ecore_evas_name_class_set(con->bg_ecore_evas, "E", "Background_Window");
85 ecore_evas_title_set(con->bg_ecore_evas, "Enlightenment Background");
86 if (!getenv("EVAS_RENDER_MODE"))
92 // FIXME: major hack. checking in advance for comp. eventully comp
93 // will be rolled into e17 core and this won't be needed
94 EINA_LIST_FOREACH(e_config->modules, l, em)
96 if (!strcmp(em->name, "comp"))
104 if (getenv("REDRAW_DEBUG"))
105 ecore_evas_avoid_damage_set(con->bg_ecore_evas, !atoi(getenv("REDRAW_DEBUG")));
107 ecore_evas_avoid_damage_set(con->bg_ecore_evas, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
110 ecore_x_window_lower(con->bg_win);
112 o = evas_object_rectangle_add(con->bg_evas);
113 con->bg_blank_object = o;
114 evas_object_layer_set(o, -100);
115 evas_object_move(o, 0, 0);
116 evas_object_resize(o, con->w, con->h);
117 evas_object_color_set(o, 255, 255, 255, 255);
118 evas_object_name_set(o, "e/desktop/background");
119 evas_object_data_set(o, "e_container", con);
122 con->num = container_num;
124 snprintf(name, sizeof(name), _("Container %d"), con->num);
125 con->name = eina_stringshare_add(name);
127 /* create a scratch window for putting stuff into */
128 con->scratch_win = ecore_x_window_override_new(con->win, 0, 0, 7, 7);
131 for (i = 0; i < 7; i++)
133 con->layers[i].win = ecore_x_window_input_new(con->win, 0, 0, 1, 1);
134 ecore_x_window_lower(con->layers[i].win);
137 ecore_x_window_configure(con->layers[i].win,
138 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
139 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
141 con->layers[i - 1].win, ECORE_X_WINDOW_STACK_ABOVE);
144 /* Put init win on top */
146 ecore_x_window_configure(man->initwin,
147 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
148 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
150 con->layers[6].win, ECORE_X_WINDOW_STACK_ABOVE);
153 /* Put menu win on top */
154 mwin = e_menu_grab_window_get();
156 ecore_x_window_configure(mwin,
157 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
158 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
160 con->layers[6].win, ECORE_X_WINDOW_STACK_ABOVE);
162 /* Put background win at the bottom */
163 ecore_x_window_configure(con->bg_win,
164 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
165 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
167 con->layers[0].win, ECORE_X_WINDOW_STACK_BELOW);
169 screens = (Eina_List *)e_xinerama_screens_get();
173 EINA_LIST_FOREACH(screens, l, scr)
175 e_zone_new(con, scr->screen, scr->escreen, scr->x, scr->y, scr->w, scr->h);
179 e_zone_new(con, 0, 0, 0, 0, con->w, con->h);
184 e_container_show(E_Container *con)
187 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
189 if (con->visible) return;
190 if (!e_config->null_container_win)
191 ecore_evas_show(con->bg_ecore_evas);
192 ecore_x_window_configure(con->bg_win,
193 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
194 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
196 con->layers[0].win, ECORE_X_WINDOW_STACK_BELOW);
197 ecore_x_window_configure(con->event_win,
198 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
199 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
201 con->layers[0].win, ECORE_X_WINDOW_STACK_BELOW);
202 if (con->win != con->manager->win)
203 ecore_x_window_show(con->win);
204 ecore_x_icccm_state_set(con->bg_win, ECORE_X_WINDOW_STATE_HINT_NORMAL);
209 e_container_hide(E_Container *con)
212 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
214 if (!con->visible) return;
215 ecore_evas_hide(con->bg_ecore_evas);
216 if (con->win != con->manager->win)
217 ecore_x_window_hide(con->win);
222 e_container_current_get(E_Manager *man)
226 E_OBJECT_CHECK_RETURN(man, NULL);
227 E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, NULL);
229 EINA_LIST_FOREACH(man->containers, l, con)
232 if (con->visible) return con;
235 /* If no one is available, return the first */
236 if (!man->containers) return NULL;
238 return (E_Container *)eina_list_data_get(l);
242 e_container_number_get(E_Manager *man, int num)
247 E_OBJECT_CHECK_RETURN(man, NULL);
248 E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, NULL);
249 EINA_LIST_FOREACH(man->containers, l, con)
251 if ((int) con->num == num) return con;
257 e_container_move(E_Container *con, int x, int y)
260 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
261 if ((x == con->x) && (y == con->y)) return;
264 if (con->win != con->manager->win)
265 ecore_x_window_move(con->win, con->x, con->y);
266 evas_object_move(con->bg_blank_object, con->x, con->y);
270 e_container_resize(E_Container *con, int w, int h)
273 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
274 if ((w == con->w) && (h == con->h)) return;
277 if (con->win != con->manager->win)
278 ecore_x_window_resize(con->win, con->w, con->h);
279 ecore_x_window_resize(con->event_win, con->w, con->h);
280 if (!e_config->null_container_win)
281 ecore_evas_resize(con->bg_ecore_evas, con->w, con->h);
282 evas_object_resize(con->bg_blank_object, con->w, con->h);
283 _e_container_resize_handle(con);
287 e_container_move_resize(E_Container *con, int x, int y, int w, int h)
290 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
291 if ((x == con->x) && (y == con->y) && (w == con->w) && (h == con->h)) return;
296 if (con->win != con->manager->win)
297 ecore_x_window_move_resize(con->win, con->x, con->y, con->w, con->h);
298 ecore_x_window_move_resize(con->event_win, con->x, con->y, con->w, con->h);
299 if (!e_config->null_container_win)
300 ecore_evas_resize(con->bg_ecore_evas, con->w, con->h);
301 evas_object_move(con->bg_blank_object, con->x, con->y);
302 evas_object_resize(con->bg_blank_object, con->w, con->h);
303 _e_container_resize_handle(con);
307 e_container_raise(E_Container *con __UNUSED__)
309 // E_OBJECT_CHECK(con);
310 // E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
314 e_container_lower(E_Container *con __UNUSED__)
316 // E_OBJECT_CHECK(con);
317 // E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
321 e_container_zone_at_point_get(E_Container *con, int x, int y)
326 E_OBJECT_CHECK_RETURN(con, NULL);
327 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
328 EINA_LIST_FOREACH(con->zones, l, zone)
330 if (E_INSIDE(x, y, zone->x, zone->y, zone->w, zone->h))
337 e_container_zone_number_get(E_Container *con, int num)
342 E_OBJECT_CHECK_RETURN(con, NULL);
343 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
344 EINA_LIST_FOREACH(con->zones, l, zone)
346 if ((int) zone->num == num) return zone;
352 e_container_zone_id_get(E_Container *con, int id)
357 E_OBJECT_CHECK_RETURN(con, NULL);
358 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
359 EINA_LIST_FOREACH(con->zones, l, zone)
361 if (zone->id == id) return zone;
366 EAPI E_Container_Shape *
367 e_container_shape_add(E_Container *con)
369 E_Container_Shape *es;
371 E_OBJECT_CHECK_RETURN(con, NULL);
372 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, 0);
374 es = E_OBJECT_ALLOC(E_Container_Shape, E_CONTAINER_SHAPE_TYPE, _e_container_shape_free);
375 E_OBJECT_DEL_SET(es, _e_container_shape_del);
377 con->shapes = eina_list_append(con->shapes, es);
378 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_ADD);
383 e_container_shape_show(E_Container_Shape *es)
386 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
387 if (es->visible) return;
389 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_SHOW);
393 e_container_shape_hide(E_Container_Shape *es)
396 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
397 if (!es->visible) return;
399 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_HIDE);
403 e_container_shape_move(E_Container_Shape *es, int x, int y)
406 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
407 if ((es->x == x) && (es->y == y)) return;
410 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_MOVE);
414 e_container_shape_resize(E_Container_Shape *es, int w, int h)
417 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
420 if ((es->w == w) && (es->h == h)) return;
423 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_RESIZE);
427 e_container_shape_list_get(E_Container *con)
429 E_OBJECT_CHECK_RETURN(con, NULL);
430 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
435 e_container_shape_geometry_get(E_Container_Shape *es, int *x, int *y, int *w, int *h)
438 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
446 e_container_shape_container_get(E_Container_Shape *es)
448 E_OBJECT_CHECK_RETURN(es, NULL);
449 E_OBJECT_TYPE_CHECK_RETURN(es, E_CONTAINER_SHAPE_TYPE, NULL);
454 e_container_shape_change_callback_add(E_Container *con, void (*func) (void *data, E_Container_Shape *es, E_Container_Shape_Change ch), void *data)
456 E_Container_Shape_Callback *cb;
459 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
460 cb = calloc(1, sizeof(E_Container_Shape_Callback));
464 con->shape_change_cb = eina_list_append(con->shape_change_cb, cb);
468 e_container_shape_change_callback_del(E_Container *con, void (*func) (void *data, E_Container_Shape *es, E_Container_Shape_Change ch), void *data)
471 E_Container_Shape_Callback *cb = NULL;
473 /* FIXME: if we call this from within a callback we are in trouble */
475 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
476 EINA_LIST_FOREACH(con->shape_change_cb, l, cb)
478 if ((cb->func == func) && (cb->data == data))
480 con->shape_change_cb = eina_list_remove_list(con->shape_change_cb, l);
488 e_container_shape_rects_get(E_Container_Shape *es)
490 E_OBJECT_CHECK_RETURN(es, NULL);
491 E_OBJECT_TYPE_CHECK_RETURN(es, E_CONTAINER_SHAPE_TYPE, NULL);
496 e_container_shape_rects_set(E_Container_Shape *es, Ecore_X_Rectangle *rects, int num)
502 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
505 E_FREE_LIST(es->shape, free);
508 if ((rects) && (num == 1) &&
511 ((int) rects[0].width == es->w) &&
512 ((int) rects[0].height == es->h))
518 for (i = 0; i < num; i++)
520 r = malloc(sizeof(E_Rect));
525 r->w = rects[i].width;
526 r->h = rects[i].height;
527 es->shape = eina_list_append(es->shape, r);
531 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_RECTS);
535 e_container_shape_solid_rect_set(E_Container_Shape *es, int x, int y, int w, int h)
537 es->solid_rect.x = x;
538 es->solid_rect.y = y;
539 es->solid_rect.w = w;
540 es->solid_rect.h = h;
544 e_container_shape_solid_rect_get(E_Container_Shape *es, int *x, int *y, int *w, int *h)
546 if (x) *x = es->solid_rect.x;
547 if (y) *y = es->solid_rect.y;
548 if (w) *w = es->solid_rect.w;
549 if (h) *h = es->solid_rect.h;
558 * 999 = internal on top windows for E
561 e_container_borders_count(E_Container *con)
567 e_container_border_add(E_Border *bd)
571 if (!bd->zone) return;
572 if (bd->layer == 0) pos = 0;
573 else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1;
574 else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2;
575 else if ((bd->layer > 100) && (bd->layer <= 150)) pos = 3;
576 else if ((bd->layer > 150) && (bd->layer <= 200)) pos = 4;
579 bd->zone->container->clients++;
580 bd->zone->container->layers[pos].clients =
581 eina_list_append(bd->zone->container->layers[pos].clients, bd);
582 e_hints_client_list_set();
586 e_container_border_remove(E_Border *bd)
590 if (!bd->zone) return;
591 /* FIXME: Could revert to old behaviour, ->layer is consistent
593 for (i = 0; i < 7; i++)
595 bd->zone->container->layers[i].clients =
596 eina_list_remove(bd->zone->container->layers[i].clients, bd);
598 bd->zone->container->clients--;
600 e_hints_client_list_set();
604 e_container_window_raise(E_Container *con, Ecore_X_Window win, int layer)
608 if (layer <= 0) pos = 0;
609 else if ((layer > 0) && (layer <= 50)) pos = 1;
610 else if ((layer > 50) && (layer <= 100)) pos = 2;
611 else if ((layer > 100) && (layer <= 150)) pos = 3;
612 else if ((layer > 150) && (layer <= 200)) pos = 4;
615 ecore_x_window_configure(win,
616 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
617 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
619 con->layers[pos + 1].win, ECORE_X_WINDOW_STACK_BELOW);
623 e_container_window_lower(E_Container *con, Ecore_X_Window win, int layer)
627 if (layer <= 0) pos = 0;
628 else if ((layer > 0) && (layer <= 50)) pos = 1;
629 else if ((layer > 50) && (layer <= 100)) pos = 2;
630 else if ((layer > 100) && (layer <= 150)) pos = 3;
631 else if ((layer > 150) && (layer <= 200)) pos = 4;
634 ecore_x_window_configure(win,
635 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
636 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
638 con->layers[pos].win, ECORE_X_WINDOW_STACK_ABOVE);
642 e_container_border_raise(E_Border *bd)
644 E_Border *above = NULL;
648 if (!bd->zone) return NULL;
649 /* Remove from old layer */
650 for (i = 0; i < 7; i++)
652 bd->zone->container->layers[i].clients =
653 eina_list_remove(bd->zone->container->layers[i].clients, bd);
656 /* Add to new layer */
657 if (bd->layer <= 0) pos = 0;
658 else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1;
659 else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2;
660 else if ((bd->layer > 100) && (bd->layer <= 150)) pos = 3;
661 else if ((bd->layer > 150) && (bd->layer <= 200)) pos = 4;
664 ecore_x_window_configure(bd->win,
665 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
666 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
668 bd->zone->container->layers[pos + 1].win, ECORE_X_WINDOW_STACK_BELOW);
670 bd->zone->container->layers[pos].clients =
671 eina_list_append(bd->zone->container->layers[pos].clients, bd);
673 /* Find the window below this one */
674 l = eina_list_data_find_list(bd->zone->container->layers[pos].clients, bd);
675 if (eina_list_prev(l))
676 above = eina_list_data_get(eina_list_prev(l));
679 /* Need to check the layers below */
680 for (i = pos - 1; i >= 0; i--)
682 if ((bd->zone->container->layers[i].clients) &&
683 (l = eina_list_last(bd->zone->container->layers[i].clients)))
685 above = eina_list_data_get(l);
691 e_hints_client_stacking_set();
696 e_container_border_lower(E_Border *bd)
698 E_Border *below = NULL;
702 if (!bd->zone) return NULL;
703 /* Remove from old layer */
704 for (i = 0; i < 7; i++)
706 bd->zone->container->layers[i].clients =
707 eina_list_remove(bd->zone->container->layers[i].clients, bd);
710 /* Add to new layer */
711 if (bd->layer <= 0) pos = 0;
712 else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1;
713 else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2;
714 else if ((bd->layer > 100) && (bd->layer <= 150)) pos = 3;
715 else if ((bd->layer > 150) && (bd->layer <= 200)) pos = 4;
718 ecore_x_window_configure(bd->win,
719 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
720 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
722 bd->zone->container->layers[pos].win, ECORE_X_WINDOW_STACK_ABOVE);
724 bd->zone->container->layers[pos].clients =
725 eina_list_prepend(bd->zone->container->layers[pos].clients, bd);
727 /* Find the window above this one */
728 l = eina_list_data_find_list(bd->zone->container->layers[pos].clients, bd);
729 if (eina_list_next(l))
730 below = eina_list_data_get(eina_list_next(l));
733 /* Need to check the layers above */
734 for (i = pos + 1; i < 7; i++)
736 if (bd->zone->container->layers[i].clients)
738 below = eina_list_data_get(bd->zone->container->layers[i].clients);
744 e_hints_client_stacking_set();
749 e_container_border_stack_above(E_Border *bd, E_Border *above)
753 if (!bd->zone) return;
754 /* Remove from old layer */
755 for (i = 0; i < 7; i++)
757 bd->zone->container->layers[i].clients =
758 eina_list_remove(bd->zone->container->layers[i].clients, bd);
761 /* Add to new layer */
762 bd->layer = above->layer;
764 if (bd->layer <= 0) pos = 0;
765 else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1;
766 else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2;
767 else if ((bd->layer > 100) && (bd->layer <= 150)) pos = 3;
768 else if ((bd->layer > 150) && (bd->layer <= 200)) pos = 4;
771 ecore_x_window_configure(bd->win,
772 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
773 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
775 above->win, ECORE_X_WINDOW_STACK_ABOVE);
777 bd->zone->container->layers[pos].clients =
778 eina_list_append_relative(bd->zone->container->layers[pos].clients, bd, above);
782 e_container_border_stack_below(E_Border *bd, E_Border *below)
786 if (!bd->zone) return;
787 /* Remove from old layer */
788 for (i = 0; i < 7; i++)
790 bd->zone->container->layers[i].clients =
791 eina_list_remove(bd->zone->container->layers[i].clients, bd);
794 /* Add to new layer */
795 bd->layer = below->layer;
797 if (bd->layer <= 0) pos = 0;
798 else if ((bd->layer > 0) && (bd->layer <= 50)) pos = 1;
799 else if ((bd->layer > 50) && (bd->layer <= 100)) pos = 2;
800 else if ((bd->layer > 100) && (bd->layer <= 150)) pos = 3;
801 else if ((bd->layer > 150) && (bd->layer <= 200)) pos = 4;
804 ecore_x_window_configure(bd->win,
805 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
806 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
808 below->win, ECORE_X_WINDOW_STACK_BELOW);
810 bd->zone->container->layers[pos].clients =
811 eina_list_prepend_relative(bd->zone->container->layers[pos].clients, bd, below);
814 static E_Border_List *
815 _e_container_border_list_new(E_Container *con)
817 E_Border_List *list = NULL;
822 if (!(list = E_NEW(E_Border_List, 1))) return NULL;
823 list->container = con;
824 e_object_ref(E_OBJECT(list->container));
825 eina_array_step_set(&(list->client_array), sizeof(list->client_array), 256);
826 for (i = 0; i < 7; i++)
828 EINA_LIST_FOREACH(con->layers[i].clients, l, bd)
829 eina_array_push(&(list->client_array), bd);
835 _e_container_border_list_jump(E_Border_List *list, int dir)
839 if ((list->pos < 0) ||
840 (list->pos >= (int)eina_array_count(&(list->client_array))))
842 bd = eina_array_data_get(&(list->client_array), list->pos);
848 e_container_border_list_first(E_Container *con)
850 E_Border_List *list = NULL;
852 list = _e_container_border_list_new(con);
858 e_container_border_list_last(E_Container *con)
860 E_Border_List *list = NULL;
862 list = _e_container_border_list_new(con);
863 list->pos = eina_array_count(&(list->client_array)) - 1;
868 e_container_border_list_next(E_Border_List *list)
870 return _e_container_border_list_jump(list, 1);
874 e_container_border_list_prev(E_Border_List *list)
876 return _e_container_border_list_jump(list, -1);
880 e_container_border_list_free(E_Border_List *list)
882 e_object_unref(E_OBJECT(list->container));
883 eina_array_flush(&(list->client_array));
888 e_container_all_freeze(void)
894 EINA_LIST_FOREACH(e_manager_list(), l, man)
896 EINA_LIST_FOREACH(man->containers, ll, con)
898 evas_event_freeze(con->bg_evas);
904 e_container_all_thaw(void)
910 EINA_LIST_FOREACH(e_manager_list(), l, man)
912 EINA_LIST_FOREACH(man->containers, ll, con)
914 evas_event_thaw(con->bg_evas);
919 /* local subsystem functions */
921 _e_container_free(E_Container *con)
926 ecore_x_window_free(con->scratch_win);
927 ecore_x_window_free(con->event_win);
928 /* We can't use e_object_del here, because border adds a ref to itself
929 * when it is removed, and the ref is never unref'ed */
930 for (i = 0; i < 7; i++)
932 ecore_x_window_free(con->layers[i].win);
933 /* FIXME: had to disable this as it was freeing already freed items during
934 * looping (particularly remember/lock config dialogs). this is just
935 * disabled until we put in some special handling for this
937 EINA_LiST_FOREACH(con->layers[i].clients, l, tmp)
939 e_object_free(E_OBJECT(tmp));
945 E_FREE_LIST(l, e_object_del);
946 con->manager->containers = eina_list_remove(con->manager->containers, con);
947 e_canvas_del(con->bg_ecore_evas);
948 ecore_evas_free(con->bg_ecore_evas);
949 if (con->manager->win != con->win)
951 ecore_x_window_free(con->win);
953 if (con->name) eina_stringshare_del(con->name);
958 _e_container_find_by_event_window(Ecore_X_Window win)
964 EINA_LIST_FOREACH(e_manager_list(), l, man)
966 EINA_LIST_FOREACH(man->containers, ll, con)
968 if (con->event_win == win) return con;
975 _e_container_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
977 Ecore_X_Event_Mouse_In *ev;
982 con = _e_container_find_by_event_window(ev->event_win);
985 bd = e_border_focused_get();
986 if (bd) e_focus_event_mouse_out(bd);
987 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
988 evas_event_feed_mouse_in(con->bg_evas, ev->time, NULL);
990 return ECORE_CALLBACK_PASS_ON;
994 _e_container_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
996 Ecore_X_Event_Mouse_Out *ev;
1000 con = _e_container_find_by_event_window(ev->event_win);
1003 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1004 if (ev->mode == ECORE_X_EVENT_MODE_GRAB)
1005 evas_event_feed_mouse_cancel(con->bg_evas, ev->time, NULL);
1006 evas_event_feed_mouse_out(con->bg_evas, ev->time, NULL);
1008 return ECORE_CALLBACK_PASS_ON;
1012 _e_container_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event)
1014 Ecore_Event_Mouse_Button *ev;
1018 con = _e_container_find_by_event_window(ev->event_window);
1021 Evas_Button_Flags flags = EVAS_BUTTON_NONE;
1023 e_bindings_mouse_down_event_handle(E_BINDING_CONTEXT_CONTAINER,
1025 if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
1026 if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
1027 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1028 evas_event_feed_mouse_down(con->bg_evas, ev->buttons, flags, ev->timestamp, NULL);
1030 return ECORE_CALLBACK_PASS_ON;
1034 _e_container_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event)
1036 Ecore_Event_Mouse_Button *ev;
1040 con = _e_container_find_by_event_window(ev->event_window);
1043 evas_event_feed_mouse_up(con->bg_evas, ev->buttons, EVAS_BUTTON_NONE, ev->timestamp, NULL);
1044 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1045 e_bindings_mouse_up_event_handle(E_BINDING_CONTEXT_CONTAINER,
1048 return ECORE_CALLBACK_PASS_ON;
1052 _e_container_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
1054 Ecore_Event_Mouse_Move *ev;
1058 con = _e_container_find_by_event_window(ev->event_window);
1061 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1062 evas_event_feed_mouse_move(con->bg_evas, ev->x, ev->y, ev->timestamp, NULL);
1068 _e_container_cb_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
1070 Ecore_Event_Mouse_Wheel *ev;
1074 con = _e_container_find_by_event_window(ev->event_window);
1077 if (!e_bindings_wheel_event_handle(E_BINDING_CONTEXT_CONTAINER,
1080 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1081 evas_event_feed_mouse_wheel(con->bg_evas, ev->direction, ev->z, ev->timestamp, NULL);
1084 return ECORE_CALLBACK_PASS_ON;
1088 _e_container_shape_del(E_Container_Shape *es)
1090 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_DEL);
1094 _e_container_shape_free(E_Container_Shape *es)
1096 es->con->shapes = eina_list_remove(es->con->shapes, es);
1097 E_FREE_LIST(es->shape, free);
1102 _e_container_shape_change_call(E_Container_Shape *es, E_Container_Shape_Change ch)
1104 Eina_List *l = NULL;
1105 E_Container_Shape_Callback *cb = NULL;
1107 if ((!es) || (!es->con) || (!es->con->shape_change_cb)) return;
1108 EINA_LIST_FOREACH(es->con->shape_change_cb, l, cb)
1111 cb->func(cb->data, es, ch);
1116 _e_container_resize_handle(E_Container *con)
1118 E_Event_Container_Resize *ev;
1119 Eina_List *l, *screens, *zones = NULL;
1124 ev = calloc(1, sizeof(E_Event_Container_Resize));
1125 ev->container = con;
1126 e_object_ref(E_OBJECT(con));
1128 e_xinerama_update();
1129 screens = (Eina_List *)e_xinerama_screens_get();
1133 EINA_LIST_FOREACH(con->zones, l, zone)
1134 zones = eina_list_append(zones, zone);
1136 EINA_LIST_FOREACH(screens, l, scr)
1138 printf("@@@ SCREENS: %i %i | %i %i %ix%i\n", scr->screen, scr->escreen, scr->x, scr->y, scr->w, scr->h);
1139 zone = e_container_zone_id_get(con, scr->escreen);
1142 printf("@@@ FOUND ZONE %i %i\n", zone->num, zone->id);
1143 e_zone_move_resize(zone, scr->x, scr->y, scr->w, scr->h);
1144 e_shelf_zone_move_resize_handle(zone);
1145 zones = eina_list_remove(zones, zone);
1146 con->zones = eina_list_append(con->zones, zone);
1147 zone->num = scr->screen;
1152 E_Config_Shelf *cf_es;
1154 printf("@@@ container resize handle\n");
1155 zone = e_zone_new(con, scr->screen, scr->escreen, scr->x, scr->y, scr->w, scr->h);
1156 /* find any shelves configured for this zone and add them in */
1157 EINA_LIST_FOREACH(e_config->shelves, ll, cf_es)
1159 if (e_util_container_zone_id_get(cf_es->container, cf_es->zone) == zone)
1160 e_shelf_config_new(zone, cf_es);
1166 E_Zone *spare_zone = NULL;
1169 EINA_LIST_FOREACH(con->zones, ll, spare_zone)
1171 if (eina_list_data_find(zones, spare_zone))
1175 EINA_LIST_FREE(zones, zone)
1177 Eina_List *shelves, *ll, *del_shelves;
1182 /* delete any shelves on this zone */
1183 shelves = e_shelf_list();
1185 EINA_LIST_FOREACH(shelves, ll, es)
1187 if (es->zone == zone)
1188 del_shelves = eina_list_append(del_shelves, es);
1190 E_FREE_LIST(del_shelves, e_object_del);
1191 bl = e_container_border_list_first(zone->container);
1192 while ((bd = e_container_border_list_next(bl)))
1194 if (bd->zone == zone)
1196 if (spare_zone) e_border_zone_set(bd, spare_zone);
1198 printf("EEEK! should not be here - but no\n"
1199 "spare zones exist to move this\n"
1200 "window to!!! help!\n");
1203 e_container_border_list_free(bl);
1204 e_object_del(E_OBJECT(zone));
1212 zone = e_container_zone_number_get(con, 0);
1213 e_zone_move_resize(zone, 0, 0, con->w, con->h);
1214 e_shelf_zone_move_resize_handle(zone);
1217 ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL);
1219 for (i = 0; i < 7; i++)
1221 Eina_List *tmp = NULL;
1224 /* Make temporary list as e_border_res_change_geometry_restore
1225 * rearranges the order. */
1226 EINA_LIST_FOREACH(con->layers[i].clients, l, bd)
1227 tmp = eina_list_append(tmp, bd);
1229 EINA_LIST_FOREACH(tmp, l, bd)
1231 e_border_res_change_geometry_save(bd);
1232 e_border_res_change_geometry_restore(bd);
1235 eina_list_free(tmp);
1240 _e_container_event_container_resize_free(void *data __UNUSED__, void *ev)
1242 E_Event_Container_Resize *e;
1245 e_object_unref(E_OBJECT(e->container));