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, ll, em)
96 #if _F_ADD_EXTRA_COMPOSITE_NAME
97 if (!strcmp(em->name, "comp-tizen") ||
98 !strcmp(em->name, "comp"))
104 if (!strcmp(em->name, "comp"))
113 if (getenv("REDRAW_DEBUG"))
114 ecore_evas_avoid_damage_set(con->bg_ecore_evas, !atoi(getenv("REDRAW_DEBUG")));
116 ecore_evas_avoid_damage_set(con->bg_ecore_evas, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
119 ecore_x_window_lower(con->bg_win);
121 o = evas_object_rectangle_add(con->bg_evas);
122 con->bg_blank_object = o;
123 evas_object_layer_set(o, -100);
124 evas_object_move(o, 0, 0);
125 evas_object_resize(o, con->w, con->h);
126 evas_object_color_set(o, 255, 255, 255, 255);
127 evas_object_name_set(o, "e/desktop/background");
128 evas_object_data_set(o, "e_container", con);
131 con->num = container_num;
133 snprintf(name, sizeof(name), _("Container %d"), con->num);
134 con->name = eina_stringshare_add(name);
136 /* create a scratch window for putting stuff into */
137 con->scratch_win = ecore_x_window_override_new(con->win, 0, 0, 7, 7);
140 for (i = 0; i < 11; i++)
142 con->layers[i].win = ecore_x_window_input_new(con->win, 0, 0, 1, 1);
143 ecore_x_window_lower(con->layers[i].win);
146 ecore_x_window_configure(con->layers[i].win,
147 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
148 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
150 con->layers[i - 1].win, ECORE_X_WINDOW_STACK_ABOVE);
153 /* Put init win on top */
155 ecore_x_window_configure(man->initwin,
156 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
157 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
159 con->layers[10].win, ECORE_X_WINDOW_STACK_ABOVE);
161 /* Put menu win on top */
162 mwin = e_menu_grab_window_get();
164 ecore_x_window_configure(mwin,
165 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
166 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
168 con->layers[10].win, ECORE_X_WINDOW_STACK_ABOVE);
170 /* Put background win at the bottom */
171 ecore_x_window_configure(con->bg_win,
172 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
173 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
175 con->layers[0].win, ECORE_X_WINDOW_STACK_BELOW);
177 screens = (Eina_List *)e_xinerama_screens_get();
181 EINA_LIST_FOREACH(screens, l, scr)
183 e_zone_new(con, scr->screen, scr->escreen, scr->x, scr->y, scr->w, scr->h);
187 e_zone_new(con, 0, 0, 0, 0, con->w, con->h);
192 e_container_show(E_Container *con)
195 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
197 if (con->visible) return;
198 if (!e_config->null_container_win)
199 ecore_evas_show(con->bg_ecore_evas);
200 ecore_x_window_configure(con->bg_win,
201 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
202 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
204 con->layers[0].win, ECORE_X_WINDOW_STACK_BELOW);
205 ecore_x_window_configure(con->event_win,
206 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
207 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
209 con->layers[0].win, ECORE_X_WINDOW_STACK_BELOW);
210 if (con->win != con->manager->win)
211 ecore_x_window_show(con->win);
212 ecore_x_icccm_state_set(con->bg_win, ECORE_X_WINDOW_STATE_HINT_NORMAL);
217 e_container_hide(E_Container *con)
220 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
222 if (!con->visible) return;
223 ecore_evas_hide(con->bg_ecore_evas);
224 if (con->win != con->manager->win)
225 ecore_x_window_hide(con->win);
230 e_container_current_get(E_Manager *man)
234 E_OBJECT_CHECK_RETURN(man, NULL);
235 E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, NULL);
237 EINA_LIST_FOREACH(man->containers, l, con)
240 if (con->visible) return con;
243 /* If no one is available, return the first */
244 if (!man->containers) return NULL;
246 return (E_Container *)eina_list_data_get(l);
250 e_container_number_get(E_Manager *man, int num)
255 E_OBJECT_CHECK_RETURN(man, NULL);
256 E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, NULL);
257 EINA_LIST_FOREACH(man->containers, l, con)
259 if ((int)con->num == num) return con;
265 e_container_move(E_Container *con, int x, int y)
268 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
269 if ((x == con->x) && (y == con->y)) return;
272 if (con->win != con->manager->win)
273 ecore_x_window_move(con->win, con->x, con->y);
274 evas_object_move(con->bg_blank_object, con->x, con->y);
278 e_container_resize(E_Container *con, int w, int h)
281 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
284 if (con->win != con->manager->win)
285 ecore_x_window_resize(con->win, con->w, con->h);
286 ecore_x_window_resize(con->event_win, con->w, con->h);
287 if (!e_config->null_container_win)
288 ecore_evas_resize(con->bg_ecore_evas, con->w, con->h);
289 evas_object_resize(con->bg_blank_object, con->w, con->h);
290 _e_container_resize_handle(con);
294 e_container_move_resize(E_Container *con, int x, int y, int w, int h)
297 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
302 if (con->win != con->manager->win)
303 ecore_x_window_move_resize(con->win, con->x, con->y, con->w, con->h);
304 ecore_x_window_move_resize(con->event_win, con->x, con->y, con->w, con->h);
305 if (!e_config->null_container_win)
306 ecore_evas_resize(con->bg_ecore_evas, con->w, con->h);
307 evas_object_move(con->bg_blank_object, con->x, con->y);
308 evas_object_resize(con->bg_blank_object, con->w, con->h);
309 _e_container_resize_handle(con);
313 e_container_raise(E_Container *con __UNUSED__)
315 // E_OBJECT_CHECK(con);
316 // E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
320 e_container_lower(E_Container *con __UNUSED__)
322 // E_OBJECT_CHECK(con);
323 // E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
327 e_container_zone_at_point_get(E_Container *con, int x, int y)
332 E_OBJECT_CHECK_RETURN(con, NULL);
333 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
334 EINA_LIST_FOREACH(con->zones, l, zone)
336 if (E_INSIDE(x, y, zone->x, zone->y, zone->w, zone->h))
343 e_container_zone_number_get(E_Container *con, int num)
348 E_OBJECT_CHECK_RETURN(con, NULL);
349 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
350 EINA_LIST_FOREACH(con->zones, l, zone)
352 if ((int)zone->num == num) return zone;
358 e_container_zone_id_get(E_Container *con, int id)
363 E_OBJECT_CHECK_RETURN(con, NULL);
364 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
365 EINA_LIST_FOREACH(con->zones, l, zone)
367 if (zone->id == id) return zone;
372 #ifdef _F_USE_DESK_WINDOW_PROFILE_
374 e_container_desk_window_profile_get(E_Container *con,
381 E_OBJECT_CHECK_RETURN(con, NULL);
382 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
384 EINA_LIST_FOREACH(con->zones, l, zone)
386 for (x = 0; x < zone->desk_x_count; x++)
388 for (y = 0; y < zone->desk_y_count; y++)
390 E_Desk *desk = e_desk_at_xy_get(zone, x, y);
391 if ((desk->window_profile) &&
392 strcmp(desk->window_profile, profile) == 0)
404 EAPI E_Container_Shape *
405 e_container_shape_add(E_Container *con)
407 E_Container_Shape *es;
409 E_OBJECT_CHECK_RETURN(con, NULL);
410 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, 0);
412 es = E_OBJECT_ALLOC(E_Container_Shape, E_CONTAINER_SHAPE_TYPE, _e_container_shape_free);
413 E_OBJECT_DEL_SET(es, _e_container_shape_del);
415 con->shapes = eina_list_append(con->shapes, es);
416 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_ADD);
421 e_container_shape_show(E_Container_Shape *es)
424 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
425 if (es->visible) return;
427 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_SHOW);
431 e_container_shape_hide(E_Container_Shape *es)
434 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
435 if (!es->visible) return;
437 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_HIDE);
441 e_container_shape_move(E_Container_Shape *es, int x, int y)
444 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
445 if ((es->x == x) && (es->y == y)) return;
448 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_MOVE);
452 e_container_shape_resize(E_Container_Shape *es, int w, int h)
455 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
458 if ((es->w == w) && (es->h == h)) return;
461 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_RESIZE);
465 e_container_shape_list_get(E_Container *con)
467 E_OBJECT_CHECK_RETURN(con, NULL);
468 E_OBJECT_TYPE_CHECK_RETURN(con, E_CONTAINER_TYPE, NULL);
473 e_container_shape_geometry_get(E_Container_Shape *es, int *x, int *y, int *w, int *h)
476 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
484 e_container_shape_container_get(E_Container_Shape *es)
486 E_OBJECT_CHECK_RETURN(es, NULL);
487 E_OBJECT_TYPE_CHECK_RETURN(es, E_CONTAINER_SHAPE_TYPE, NULL);
492 e_container_shape_change_callback_add(E_Container *con, void (*func)(void *data, E_Container_Shape *es, E_Container_Shape_Change ch), void *data)
494 E_Container_Shape_Callback *cb;
497 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
498 cb = calloc(1, sizeof(E_Container_Shape_Callback));
502 con->shape_change_cb = eina_list_append(con->shape_change_cb, cb);
506 e_container_shape_change_callback_del(E_Container *con, void (*func)(void *data, E_Container_Shape *es, E_Container_Shape_Change ch), void *data)
509 E_Container_Shape_Callback *cb = NULL;
511 /* FIXME: if we call this from within a callback we are in trouble */
513 E_OBJECT_TYPE_CHECK(con, E_CONTAINER_TYPE);
514 EINA_LIST_FOREACH(con->shape_change_cb, l, cb)
516 if ((cb->func == func) && (cb->data == data))
518 con->shape_change_cb = eina_list_remove_list(con->shape_change_cb, l);
526 e_container_shape_rects_get(E_Container_Shape *es)
528 E_OBJECT_CHECK_RETURN(es, NULL);
529 E_OBJECT_TYPE_CHECK_RETURN(es, E_CONTAINER_SHAPE_TYPE, NULL);
534 e_container_shape_rects_set(E_Container_Shape *es, Ecore_X_Rectangle *rects, int num)
540 E_OBJECT_TYPE_CHECK(es, E_CONTAINER_SHAPE_TYPE);
543 E_FREE_LIST(es->shape, free);
546 if ((rects) && (num == 1) &&
549 ((int)rects[0].width == es->w) &&
550 ((int)rects[0].height == es->h))
556 for (i = 0; i < num; i++)
558 r = malloc(sizeof(E_Rect));
563 r->w = rects[i].width;
564 r->h = rects[i].height;
565 es->shape = eina_list_append(es->shape, r);
569 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_RECTS);
573 e_container_shape_solid_rect_set(E_Container_Shape *es, int x, int y, int w, int h)
575 es->solid_rect.x = x;
576 es->solid_rect.y = y;
577 es->solid_rect.w = w;
578 es->solid_rect.h = h;
582 e_container_shape_solid_rect_get(E_Container_Shape *es, int *x, int *y, int *w, int *h)
584 if (x) *x = es->solid_rect.x;
585 if (y) *y = es->solid_rect.y;
586 if (w) *w = es->solid_rect.w;
587 if (h) *h = es->solid_rect.h;
598 * 350 = stuff over fullscreen
599 * 400 = stuff over stuff
600 * 450 = yet more stuff on top
603 e_container_borders_count(E_Container *con)
609 _e_container_layer_map(int layer)
613 if (layer < 0) layer = 0;
614 pos = 1 + (layer / 50);
615 if (pos > 10) pos = 10;
620 e_container_border_add(E_Border *bd)
622 int pos = _e_container_layer_map(bd->layer);
623 bd->zone->container->clients++;
624 bd->zone->container->layers[pos].clients =
625 eina_list_append(bd->zone->container->layers[pos].clients, bd);
626 e_hints_client_list_set();
630 e_container_border_remove(E_Border *bd)
634 if (!bd->zone) return;
635 /* FIXME: Could revert to old behaviour, ->layer is consistent
637 for (i = 0; i < 11; i++)
639 bd->zone->container->layers[i].clients =
640 eina_list_remove(bd->zone->container->layers[i].clients, bd);
642 bd->zone->container->clients--;
644 e_hints_client_list_set();
648 e_container_window_raise(E_Container *con, Ecore_X_Window win, int layer)
650 int pos = _e_container_layer_map(layer);
651 ecore_x_window_configure(win,
652 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
653 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
655 con->layers[pos + 1].win, ECORE_X_WINDOW_STACK_BELOW);
659 e_container_window_lower(E_Container *con, Ecore_X_Window win, int layer)
661 int pos = _e_container_layer_map(layer);
662 ecore_x_window_configure(win,
663 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
664 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
666 con->layers[pos].win, ECORE_X_WINDOW_STACK_ABOVE);
670 e_container_border_raise(E_Border *bd)
672 E_Border *above = NULL;
676 if (!bd->zone) return NULL;
677 /* Remove from old layer */
678 for (i = 0; i < 11; i++)
680 bd->zone->container->layers[i].clients =
681 eina_list_remove(bd->zone->container->layers[i].clients, bd);
684 /* Add to new layer */
685 pos = _e_container_layer_map(bd->layer);
687 ecore_x_window_configure(bd->win,
688 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
689 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
691 bd->zone->container->layers[pos + 1].win, ECORE_X_WINDOW_STACK_BELOW);
693 bd->zone->container->layers[pos].clients =
694 eina_list_append(bd->zone->container->layers[pos].clients, bd);
696 /* Find the window below this one */
697 l = eina_list_data_find_list(bd->zone->container->layers[pos].clients, bd);
698 if (eina_list_prev(l))
699 above = eina_list_data_get(eina_list_prev(l));
702 /* Need to check the layers below */
703 for (i = pos - 1; i >= 0; i--)
705 if ((bd->zone->container->layers[i].clients) &&
706 (l = eina_list_last(bd->zone->container->layers[i].clients)))
708 above = eina_list_data_get(l);
714 e_hints_client_stacking_set();
719 e_container_border_lower(E_Border *bd)
721 E_Border *below = NULL;
725 if (!bd->zone) return NULL;
726 /* Remove from old layer */
727 for (i = 0; i < 11; i++)
729 bd->zone->container->layers[i].clients =
730 eina_list_remove(bd->zone->container->layers[i].clients, bd);
733 /* Add to new layer */
734 pos = _e_container_layer_map(bd->layer);
736 ecore_x_window_configure(bd->win,
737 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
738 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
740 bd->zone->container->layers[pos].win, ECORE_X_WINDOW_STACK_ABOVE);
742 bd->zone->container->layers[pos].clients =
743 eina_list_prepend(bd->zone->container->layers[pos].clients, bd);
745 /* Find the window above this one */
746 l = eina_list_data_find_list(bd->zone->container->layers[pos].clients, bd);
747 if (eina_list_next(l))
748 below = eina_list_data_get(eina_list_next(l));
751 /* Need to check the layers above */
752 for (i = pos + 1; i < 11; i++)
754 if (bd->zone->container->layers[i].clients)
756 below = eina_list_data_get(bd->zone->container->layers[i].clients);
762 e_hints_client_stacking_set();
767 e_container_border_stack_above(E_Border *bd, E_Border *above)
771 if (!bd->zone) return;
772 /* Remove from old layer */
773 for (i = 0; i < 11; i++)
775 bd->zone->container->layers[i].clients =
776 eina_list_remove(bd->zone->container->layers[i].clients, bd);
779 /* Add to new layer */
780 bd->layer = above->layer;
781 pos = _e_container_layer_map(bd->layer);
783 ecore_x_window_configure(bd->win,
784 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
785 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
787 above->win, ECORE_X_WINDOW_STACK_ABOVE);
789 bd->zone->container->layers[pos].clients =
790 eina_list_append_relative(bd->zone->container->layers[pos].clients, bd, above);
794 e_container_border_stack_below(E_Border *bd, E_Border *below)
798 if (!bd->zone) return;
799 /* Remove from old layer */
800 for (i = 0; i < 11; i++)
802 bd->zone->container->layers[i].clients =
803 eina_list_remove(bd->zone->container->layers[i].clients, bd);
806 /* Add to new layer */
807 bd->layer = below->layer;
808 pos = _e_container_layer_map(bd->layer);
810 ecore_x_window_configure(bd->win,
811 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
812 ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
814 below->win, ECORE_X_WINDOW_STACK_BELOW);
816 bd->zone->container->layers[pos].clients =
817 eina_list_prepend_relative(bd->zone->container->layers[pos].clients, bd, below);
820 static E_Border_List *
821 _e_container_border_list_new(E_Container *con)
823 E_Border_List *list = NULL;
828 if (!(list = E_NEW(E_Border_List, 1))) return NULL;
829 list->container = con;
830 e_object_ref(E_OBJECT(list->container));
831 eina_array_step_set(&(list->client_array), sizeof(list->client_array), 256);
832 for (i = 0; i < 11; i++)
834 EINA_LIST_FOREACH(con->layers[i].clients, l, bd)
835 eina_array_push(&(list->client_array), bd);
841 _e_container_border_list_jump(E_Border_List *list, int dir)
845 if ((list->pos < 0) ||
846 (list->pos >= (int)eina_array_count(&(list->client_array))))
848 bd = eina_array_data_get(&(list->client_array), list->pos);
854 e_container_border_list_first(E_Container *con)
856 E_Border_List *list = NULL;
858 list = _e_container_border_list_new(con);
864 e_container_border_list_last(E_Container *con)
866 E_Border_List *list = NULL;
868 list = _e_container_border_list_new(con);
869 list->pos = eina_array_count(&(list->client_array)) - 1;
874 e_container_border_list_next(E_Border_List *list)
876 return _e_container_border_list_jump(list, 1);
880 e_container_border_list_prev(E_Border_List *list)
882 return _e_container_border_list_jump(list, -1);
886 e_container_border_list_free(E_Border_List *list)
888 e_object_unref(E_OBJECT(list->container));
889 eina_array_flush(&(list->client_array));
894 e_container_all_freeze(void)
900 EINA_LIST_FOREACH(e_manager_list(), l, man)
902 EINA_LIST_FOREACH(man->containers, ll, con)
904 evas_event_freeze(con->bg_evas);
910 e_container_all_thaw(void)
916 EINA_LIST_FOREACH(e_manager_list(), l, man)
918 EINA_LIST_FOREACH(man->containers, ll, con)
920 evas_event_thaw(con->bg_evas);
925 /* local subsystem functions */
927 _e_container_free(E_Container *con)
932 ecore_x_window_free(con->scratch_win);
933 ecore_x_window_free(con->event_win);
934 /* We can't use e_object_del here, because border adds a ref to itself
935 * when it is removed, and the ref is never unref'ed */
936 for (i = 0; i < 11; i++)
938 ecore_x_window_free(con->layers[i].win);
939 /* FIXME: had to disable this as it was freeing already freed items during
940 * looping (particularly remember/lock config dialogs). this is just
941 * disabled until we put in some special handling for this
943 EINA_LiST_FOREACH(con->layers[i].clients, l, tmp)
945 e_object_free(E_OBJECT(tmp));
951 E_FREE_LIST(l, e_object_del);
952 con->manager->containers = eina_list_remove(con->manager->containers, con);
953 e_canvas_del(con->bg_ecore_evas);
954 ecore_evas_free(con->bg_ecore_evas);
955 if (con->manager->win != con->win)
957 ecore_x_window_free(con->win);
959 if (con->name) eina_stringshare_del(con->name);
964 _e_container_find_by_event_window(Ecore_X_Window win)
970 EINA_LIST_FOREACH(e_manager_list(), l, man)
972 EINA_LIST_FOREACH(man->containers, ll, con)
974 if (con->event_win == win) return con;
981 _e_container_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
983 Ecore_X_Event_Mouse_In *ev;
988 con = _e_container_find_by_event_window(ev->event_win);
991 bd = e_border_focused_get();
992 if (bd) e_focus_event_mouse_out(bd);
993 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
994 evas_event_feed_mouse_in(con->bg_evas, ev->time, NULL);
996 return ECORE_CALLBACK_PASS_ON;
1000 _e_container_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
1002 Ecore_X_Event_Mouse_Out *ev;
1006 con = _e_container_find_by_event_window(ev->event_win);
1009 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1010 if (ev->mode == ECORE_X_EVENT_MODE_GRAB)
1011 evas_event_feed_mouse_cancel(con->bg_evas, ev->time, NULL);
1012 evas_event_feed_mouse_out(con->bg_evas, ev->time, NULL);
1014 return ECORE_CALLBACK_PASS_ON;
1018 _e_container_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event)
1020 Ecore_Event_Mouse_Button *ev;
1024 con = _e_container_find_by_event_window(ev->event_window);
1027 Evas_Button_Flags flags = EVAS_BUTTON_NONE;
1029 e_bindings_mouse_down_event_handle(E_BINDING_CONTEXT_CONTAINER,
1031 if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
1032 if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
1033 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1034 evas_event_feed_mouse_down(con->bg_evas, ev->buttons, flags, ev->timestamp, NULL);
1036 return ECORE_CALLBACK_PASS_ON;
1040 _e_container_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event)
1042 Ecore_Event_Mouse_Button *ev;
1046 con = _e_container_find_by_event_window(ev->event_window);
1049 evas_event_feed_mouse_up(con->bg_evas, ev->buttons, EVAS_BUTTON_NONE, ev->timestamp, NULL);
1050 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1051 e_bindings_mouse_up_event_handle(E_BINDING_CONTEXT_CONTAINER,
1054 return ECORE_CALLBACK_PASS_ON;
1058 _e_container_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
1060 Ecore_Event_Mouse_Move *ev;
1064 con = _e_container_find_by_event_window(ev->event_window);
1067 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1068 evas_event_feed_mouse_move(con->bg_evas, ev->x, ev->y, ev->timestamp, NULL);
1074 _e_container_cb_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
1076 Ecore_Event_Mouse_Wheel *ev;
1080 con = _e_container_find_by_event_window(ev->event_window);
1083 if (!e_bindings_wheel_event_handle(E_BINDING_CONTEXT_CONTAINER,
1086 ecore_event_evas_modifier_lock_update(con->bg_evas, ev->modifiers);
1087 evas_event_feed_mouse_wheel(con->bg_evas, ev->direction, ev->z, ev->timestamp, NULL);
1090 return ECORE_CALLBACK_PASS_ON;
1094 _e_container_shape_del(E_Container_Shape *es)
1096 _e_container_shape_change_call(es, E_CONTAINER_SHAPE_DEL);
1100 _e_container_shape_free(E_Container_Shape *es)
1102 es->con->shapes = eina_list_remove(es->con->shapes, es);
1103 E_FREE_LIST(es->shape, free);
1108 _e_container_shape_change_call(E_Container_Shape *es, E_Container_Shape_Change ch)
1110 Eina_List *l = NULL;
1111 E_Container_Shape_Callback *cb = NULL;
1113 if ((!es) || (!es->con) || (!es->con->shape_change_cb)) return;
1114 EINA_LIST_FOREACH(es->con->shape_change_cb, l, cb)
1117 cb->func(cb->data, es, ch);
1122 _e_container_cb_zone_sort(const void *data1, const void *data2)
1124 const E_Zone *z1, *z2;
1129 return z2->num - z1->num;
1133 _e_container_resize_handle(E_Container *con)
1135 E_Event_Container_Resize *ev;
1136 Eina_List *l, *screens, *zones = NULL, *ll;
1141 ev = calloc(1, sizeof(E_Event_Container_Resize));
1142 ev->container = con;
1143 e_object_ref(E_OBJECT(con));
1145 e_xinerama_update();
1146 screens = (Eina_List *)e_xinerama_screens_get();
1150 EINA_LIST_FOREACH(con->zones, l, zone)
1151 zones = eina_list_append(zones, zone);
1153 EINA_LIST_FOREACH(screens, l, scr)
1157 printf("@@@ SCREENS: %i %i | %i %i %ix%i\n",
1158 scr->screen, scr->escreen, scr->x, scr->y, scr->w, scr->h);
1159 EINA_LIST_FOREACH(zones, ll, zone)
1161 if (zone->id == scr->escreen) break;
1166 printf("@@@ FOUND ZONE %i %i [%p]\n", zone->num, zone->id, zone);
1167 e_zone_move_resize(zone, scr->x, scr->y, scr->w, scr->h);
1168 zones = eina_list_remove(zones, zone);
1169 con->zones = eina_list_append(con->zones, zone);
1170 zone->num = scr->screen;
1171 e_shelf_zone_move_resize_handle(zone);
1175 zone = e_zone_new(con, scr->screen, scr->escreen,
1176 scr->x, scr->y, scr->w, scr->h);
1177 printf("@@@ NEW ZONE = %p\n", zone);
1180 con->zones = eina_list_sort(con->zones, eina_list_count(con->zones),
1181 _e_container_cb_zone_sort);
1184 E_Zone *spare_zone = NULL;
1186 if (con->zones) spare_zone = con->zones->data;
1188 EINA_LIST_FREE(zones, zone)
1190 Eina_List *shelves, *ll2, *del_shelves;
1195 /* delete any shelves on this zone */
1196 shelves = e_shelf_list();
1198 EINA_LIST_FOREACH(shelves, ll2, es)
1200 if (es->zone == zone)
1201 del_shelves = eina_list_append(del_shelves, es);
1203 E_FREE_LIST(del_shelves, e_object_del);
1204 bl = e_container_border_list_first(zone->container);
1205 while ((bd = e_container_border_list_next(bl)))
1207 if (bd->zone == zone)
1209 if (spare_zone) e_border_zone_set(bd, spare_zone);
1211 printf("EEEK! should not be here - but no\n"
1212 "spare zones exist to move this\n"
1213 "window to!!! help!\n");
1216 e_container_border_list_free(bl);
1217 e_object_del(E_OBJECT(zone));
1220 e_shelf_config_update();
1226 z = e_container_zone_number_get(con, 0);
1229 e_zone_move_resize(z, 0, 0, con->w, con->h);
1230 e_shelf_zone_move_resize_handle(z);
1234 ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL);
1236 for (i = 0; i < 11; i++)
1238 Eina_List *tmp = NULL;
1241 /* Make temporary list as e_border_res_change_geometry_restore
1242 * rearranges the order. */
1243 EINA_LIST_FOREACH(con->layers[i].clients, l, bd)
1244 tmp = eina_list_append(tmp, bd);
1246 EINA_LIST_FOREACH(tmp, l, bd)
1248 e_border_res_change_geometry_save(bd);
1249 e_border_res_change_geometry_restore(bd);
1252 eina_list_free(tmp);
1257 _e_container_event_container_resize_free(void *data __UNUSED__, void *ev)
1259 E_Event_Container_Resize *e;
1262 e_object_unref(E_OBJECT(e->container));