2 #include "e_client_intern.h"
4 #define PRI(ec) ((E_Client_Private *)e_object_data_get(E_OBJECT(ec)))
7 EINA_SAFETY_ON_NULL_RETURN(ec); \
8 E_Client_Private *priv = PRI(ec)
10 #define API_ENTRY_VAL(ret) \
11 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ret); \
12 E_Client_Private *priv = PRI(ec)
14 typedef struct _E_Client_Private E_Client_Private;
16 struct _E_Client_Private
20 struct wl_signal destroy;
24 static int _e_client_hooks_delete = 0;
25 static int _e_client_hooks_walking = 0;
27 static int _e_client_intercept_hooks_delete = 0;
28 static int _e_client_intercept_hooks_walking = 0;
30 E_API int E_EVENT_CLIENT_ADD = -1;
31 E_API int E_EVENT_CLIENT_REMOVE = -1;
32 E_API int E_EVENT_CLIENT_ZONE_SET = -1;
33 E_API int E_EVENT_CLIENT_DESK_SET = -1;
34 E_API int E_EVENT_CLIENT_RESIZE = -1;
35 E_API int E_EVENT_CLIENT_MOVE = -1;
36 E_API int E_EVENT_CLIENT_SHOW = -1;
37 E_API int E_EVENT_CLIENT_HIDE = -1;
38 E_API int E_EVENT_CLIENT_ICONIFY = -1;
39 E_API int E_EVENT_CLIENT_UNICONIFY = -1;
40 E_API int E_EVENT_CLIENT_STACK = -1;
41 E_API int E_EVENT_CLIENT_FOCUS_IN = -1;
42 E_API int E_EVENT_CLIENT_FOCUS_OUT = -1;
43 E_API int E_EVENT_CLIENT_PROPERTY = -1;
44 E_API int E_EVENT_CLIENT_FULLSCREEN = -1;
45 E_API int E_EVENT_CLIENT_UNFULLSCREEN = -1;
46 #ifdef _F_ZONE_WINDOW_ROTATION_
47 E_API int E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN = -1;
48 E_API int E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL = -1;
49 E_API int E_EVENT_CLIENT_ROTATION_CHANGE_END = -1;
50 E_API int E_EVENT_CLIENT_ROTATION_GEOMETRY_SET = -1;
52 E_API int E_EVENT_CLIENT_VISIBILITY_CHANGE = -1;
53 E_API int E_EVENT_CLIENT_BUFFER_CHANGE = -1;
54 E_API int E_EVENT_CLIENT_FOCUS_SKIP_SET = -1;
55 E_API int E_EVENT_CLIENT_FOCUS_SKIP_UNSET = -1;
57 static Eina_Hash *clients_hash[E_PIXMAP_TYPE_MAX] = {NULL}; // pixmap->client
59 #ifdef REFACTOR_FOCUS_POLICY
61 static E_Client *focused = NULL;
63 static E_Client *ecmove = NULL;
64 static E_Client *ecresize = NULL;
65 static E_Client *action_client = NULL;
67 #ifdef REFACTOR_FOCUS_POLICY
69 static Eina_List *focus_stack = NULL;
70 static Eina_List *defer_focus_stack = NULL;
73 static Eina_Bool comp_grabbed = EINA_FALSE;
75 static Eina_List *handlers = NULL;
76 static Eina_List *hooks = NULL;
78 static Ecore_Event_Handler *action_handler_mouse = NULL;
79 static Ecore_Timer *action_timer = NULL;
80 static Eina_Rectangle action_orig = {0, 0, 0, 0};
82 static E_Client_Resize_Object_Create_Cb _e_client_resize_object_create_cb = NULL;
84 #ifdef REFACTOR_FOCUS_POLICY
86 static GMutex focused_ec_mutex;
89 EINTERN void e_client_focused_set(E_Client *ec);
90 static void _e_client_transient_for_group_make(E_Client *ec, Eina_List **list);
91 static Evas_Object *_e_client_resize_object_create(E_Client *ec);
92 static void _e_client_resize_object_del(E_Client *ec);
93 static void _e_client_stay_within_canvas(E_Client *ec, int x, int y, int *new_x, int *new_y);
94 static void _e_client_stay_within_canvas_margin(E_Client *ec, int x, int y, int *new_x, int *new_y);
96 static Eina_Inlist *_e_client_hooks[] =
98 [E_CLIENT_HOOK_EVAL_PRE_FETCH] = NULL,
99 [E_CLIENT_HOOK_EVAL_FETCH] = NULL,
100 [E_CLIENT_HOOK_EVAL_PRE_POST_FETCH] = NULL,
101 [E_CLIENT_HOOK_EVAL_POST_FETCH] = NULL,
102 [E_CLIENT_HOOK_EVAL_PRE_FRAME_ASSIGN] = NULL,
103 [E_CLIENT_HOOK_EVAL_POST_FRAME_ASSIGN] = NULL,
104 [E_CLIENT_HOOK_EVAL_PRE_NEW_CLIENT] = NULL,
105 [E_CLIENT_HOOK_EVAL_POST_NEW_CLIENT] = NULL,
106 [E_CLIENT_HOOK_EVAL_END] = NULL,
107 [E_CLIENT_HOOK_FOCUS_SET] = NULL,
108 [E_CLIENT_HOOK_FOCUS_UNSET] = NULL,
109 [E_CLIENT_HOOK_NEW_CLIENT] = NULL,
110 //#ifdef REFACTOR_ZONE_DESK
112 [E_CLIENT_HOOK_DESK_SET] = NULL,
114 [E_CLIENT_HOOK_MOVE_BEGIN] = NULL,
115 [E_CLIENT_HOOK_MOVE_UPDATE] = NULL,
116 [E_CLIENT_HOOK_MOVE_END] = NULL,
117 [E_CLIENT_HOOK_RESIZE_BEGIN] = NULL,
118 [E_CLIENT_HOOK_RESIZE_UPDATE] = NULL,
119 [E_CLIENT_HOOK_RESIZE_END] = NULL,
120 [E_CLIENT_HOOK_FULLSCREEN_PRE] = NULL,
121 //#ifdef REFACTOR_ZONE_DESK
122 [E_CLIENT_HOOK_FULLSCREEN] = NULL,
123 [E_CLIENT_HOOK_UNFULLSCREEN] = NULL,
125 [E_CLIENT_HOOK_DEL] = NULL,
126 [E_CLIENT_HOOK_UNREDIRECT] = NULL,
127 [E_CLIENT_HOOK_REDIRECT] = NULL,
128 #ifdef _F_E_CLIENT_NEW_CLIENT_POST_HOOK_
129 [E_CLIENT_HOOK_NEW_CLIENT_POST] = NULL,
131 [E_CLIENT_HOOK_EVAL_VISIBILITY] = NULL,
132 [E_CLIENT_HOOK_ICONIFY] = NULL,
133 [E_CLIENT_HOOK_UNICONIFY] = NULL,
134 [E_CLIENT_HOOK_AUX_HINT_CHANGE] = NULL,
135 [E_CLIENT_HOOK_WINDOW_ROLE_CHANGE] = NULL,
136 [E_CLIENT_HOOK_TRANSFORM_CHANGE] = NULL,
137 [E_CLIENT_HOOK_ACTIVATE_DONE] = NULL,
138 [E_CLIENT_HOOK_EVAL_VISIBILITY_END] = NULL,
139 //#ifdef REFACTOR_FOCUS_POLICY
140 [E_CLIENT_HOOK_MOUSE_IN] = NULL,
141 [E_CLIENT_HOOK_MOUSE_OUT] = NULL,
142 [E_CLIENT_HOOK_MOUSE_DOWN] = NULL,
143 [E_CLIENT_HOOK_LOWER] = NULL,
144 [E_CLIENT_HOOK_MOVE] = NULL,
145 [E_CLIENT_HOOK_FOCUS_DEFER_SET] = NULL,
146 [E_CLIENT_HOOK_FOCUS_LATEST_SET] = NULL,
148 //#ifdef REFACTOR_ZONE_DESK
149 [E_CLIENT_HOOK_STICK] = NULL,
150 [E_CLIENT_HOOK_UNSTICK] = NULL,
151 [E_CLIENT_HOOK_MAXIMIZE] = NULL,
152 [E_CLIENT_HOOK_UNMAXIMIZE] = NULL,
156 static Eina_Inlist *_e_client_intercept_hooks[] =
158 [E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT] = NULL,
159 [E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT] = NULL,
162 ///////////////////////////////////////////
165 _e_client_hooks_clean(void)
171 for (x = 0; x < E_CLIENT_HOOK_LAST; x++)
172 EINA_INLIST_FOREACH_SAFE(_e_client_hooks[x], l, ch)
174 if (!ch->delete_me) continue;
175 _e_client_hooks[x] = eina_inlist_remove(_e_client_hooks[x], EINA_INLIST_GET(ch));
181 _e_client_hook_call(E_Client_Hook_Point hookpoint, E_Client *ec)
185 e_object_ref(E_OBJECT(ec));
186 _e_client_hooks_walking++;
187 EINA_INLIST_FOREACH(_e_client_hooks[hookpoint], ch)
189 if (ch->delete_me) continue;
190 ch->func(ch->data, ec);
191 if ((hookpoint != E_CLIENT_HOOK_DEL) &&
192 (hookpoint != E_CLIENT_HOOK_MOVE_END) &&
193 (hookpoint != E_CLIENT_HOOK_RESIZE_END) &&
194 (hookpoint != E_CLIENT_HOOK_FOCUS_UNSET) &&
195 e_object_is_del(E_OBJECT(ec)))
198 _e_client_hooks_walking--;
199 if ((_e_client_hooks_walking == 0) && (_e_client_hooks_delete > 0))
200 _e_client_hooks_clean();
201 return !!e_object_unref(E_OBJECT(ec));
204 ///////////////////////////////////////////
207 _e_client_intercept_hooks_clean(void)
210 E_Client_Intercept_Hook *ch;
213 for (x = 0; x < E_CLIENT_INTERCEPT_HOOK_LAST; x++)
214 EINA_INLIST_FOREACH_SAFE(_e_client_intercept_hooks[x], l, ch)
216 if (!ch->delete_me) continue;
217 _e_client_intercept_hooks[x] =
218 eina_inlist_remove(_e_client_intercept_hooks[x], EINA_INLIST_GET(ch));
224 _e_client_intercept_hook_call(E_Client_Intercept_Hook_Point hookpoint, E_Client *ec)
226 E_Client_Intercept_Hook *ch;
227 Eina_Bool ret = EINA_TRUE;
229 if (e_object_is_del(E_OBJECT(ec)))
231 if (hookpoint != E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT)
237 e_object_ref(E_OBJECT(ec));
238 _e_client_intercept_hooks_walking++;
239 EINA_INLIST_FOREACH(_e_client_intercept_hooks[hookpoint], ch)
241 if (ch->delete_me) continue;
242 if (!(ch->func(ch->data, ec)))
248 _e_client_intercept_hooks_walking--;
249 if ((_e_client_intercept_hooks_walking == 0) &&
250 (_e_client_intercept_hooks_delete > 0))
251 _e_client_intercept_hooks_clean();
253 e_object_unref(E_OBJECT(ec));
258 _e_client_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
261 e_object_unref(E_OBJECT(ev->ec));
266 _e_client_event_simple(E_Client *ec, int type)
270 ev = E_NEW(E_Event_Client, 1);
274 e_object_ref(E_OBJECT(ec));
275 ecore_event_add(type, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
279 _e_client_event_add(E_Client *ec)
284 ec->reg_ev.add = EINA_TRUE;
285 ELOGF("COMP", "SEND E_EVENT_CLIENT_ADD event", ec);
286 _e_client_event_simple(ec, E_EVENT_CLIENT_ADD);
290 _e_client_event_remove(E_Client *ec)
295 ec->reg_ev.add = EINA_FALSE;
296 ELOGF("COMP", "SEND E_EVENT_CLIENT_REMOVE event", ec);
297 _e_client_event_simple(ec, E_EVENT_CLIENT_REMOVE);
301 _e_client_event_show(E_Client *ec)
306 ec->reg_ev.show = EINA_TRUE;
307 _e_client_event_simple(ec, E_EVENT_CLIENT_SHOW);
311 _e_client_event_hide(E_Client *ec)
313 if (!ec->reg_ev.show)
316 ec->reg_ev.show = EINA_FALSE;
317 _e_client_event_simple(ec, E_EVENT_CLIENT_HIDE);
321 _e_client_event_property(E_Client *ec, int prop)
323 E_Event_Client_Property *ev;
325 ev = E_NEW(E_Event_Client_Property, 1);
330 e_object_ref(E_OBJECT(ec));
331 ecore_event_add(E_EVENT_CLIENT_PROPERTY, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
334 #ifdef REFACTOR_ZONE_DESK
337 _e_client_event_desk_set_free(void *d EINA_UNUSED, E_Event_Client_Desk_Set *ev)
340 e_object_unref(E_OBJECT(ev->ec));
341 e_object_unref(E_OBJECT(ev->desk));
346 _e_client_event_zone_set_free(void *d EINA_UNUSED, E_Event_Client_Zone_Set *ev)
349 e_object_unref(E_OBJECT(ev->ec));
350 e_object_unref(E_OBJECT(ev->zone));
354 ////////////////////////////////////////////////
357 _e_client_action_input_win_del(void)
359 if (!comp_grabbed) return 0;
361 e_comp_ungrab_input(1, 1);
367 _e_client_action_finish(void)
370 _e_client_action_input_win_del();
372 E_FREE_FUNC(action_timer, ecore_timer_del);
373 E_FREE_FUNC(action_handler_mouse, ecore_event_handler_del);
376 action_client->keyboard_resizing = 0;
378 action_client = NULL;
382 _e_client_transform_point_transform(int cx, int cy, double angle, int x, int y, int *tx, int *ty)
384 double s = sin(angle * M_PI / 180);
385 double c = cos(angle * M_PI / 180);
392 ry = - x * s + y * c;
402 _e_client_transform_geometry_save(E_Client *ec, E_Map *map)
408 for (i = 0; i < 4; i ++)
410 e_map_point_precise_coord_get(map, i,
411 &ec->transform.saved[i].x,
412 &ec->transform.saved[i].y,
413 &ec->transform.saved[i].z);
418 _e_client_transform_resize(E_Client *ec)
422 double dx = 0, dy = 0;
427 if (!ec->transformed) return;
429 if (!e_pixmap_size_get(ec->pixmap, &pw, &ph))
435 cx = ec->client.x + pw / 2;
436 cy = ec->client.y + ph / 2;
438 /* step 1: Rotate resized object and get map points */
439 map = e_map_new_with_direct_render(ec->transform_core.direct_render);
440 e_map_util_points_populate_from_geometry(map,
441 ec->client.x, ec->client.y,
444 e_map_util_rotate(map, ec->transform.angle, cx, cy);
445 e_map_util_zoom(map, ec->transform.zoom, ec->transform.zoom, cx, cy);
447 for (i = 0; i < 4; i++)
448 e_map_point_precise_coord_get(map, i, &px[i], &py[i], NULL);
452 /* step 2: get adjusted values to keep up fixed position according
454 switch (ec->resize_mode)
456 case E_POINTER_RESIZE_R:
457 case E_POINTER_RESIZE_BR:
458 dx = ec->transform.saved[0].x - px[0];
459 dy = ec->transform.saved[0].y - py[0];
461 case E_POINTER_RESIZE_BL:
462 case E_POINTER_RESIZE_B:
463 dx = ec->transform.saved[1].x - px[1];
464 dy = ec->transform.saved[1].y - py[1];
466 case E_POINTER_RESIZE_TL:
467 case E_POINTER_RESIZE_L:
468 dx = ec->transform.saved[2].x - px[2];
469 dy = ec->transform.saved[2].y - py[2];
471 case E_POINTER_RESIZE_T:
472 case E_POINTER_RESIZE_TR:
473 dx = ec->transform.saved[3].x - px[3];
474 dy = ec->transform.saved[3].y - py[3];
480 ec->transform.adjusted.x = dx;
481 ec->transform.adjusted.y = dy;
483 /* step 3: set each points of the quadrangle */
484 map = e_map_new_with_direct_render(ec->transform_core.direct_render);
485 e_map_util_points_populate_from_object_full(map, ec->frame, 0);
487 for (i = 0; i < 4; i++)
488 e_map_point_precise_coord_set(map, i, px[i] + dx, py[i] + dy, 0);
490 e_client_map_set(ec, map);
491 e_client_map_enable_set(ec, EINA_TRUE);
496 _e_client_transform_resize_handle(E_Client *ec)
499 int new_x, new_y, new_w, new_h;
503 Evas_Point current, moveinfo;
506 if (e_object_is_del(E_OBJECT(ec))) return;
507 if (e_client_util_ignored_get(ec)) return;
508 if (!ec->transformed) return;
510 zone = e_comp_zone_find_by_ec(ec);
513 button_id = ec->moveinfo.down.button;
515 org_w = ec->mouse.last_down[button_id - 1].w;
516 org_h = ec->mouse.last_down[button_id - 1].h;
518 new_w = ec->client.w;
519 new_h = ec->client.h;
520 new_x = ec->client.x;
521 new_y = ec->client.y;
523 /* step 1: get center coordinate its' based on original object geometry*/
524 cx = ec->client.x + org_w / 2;
525 cy = ec->client.y + org_h / 2;
527 /* step 2: transform coordinates of mouse position
528 * subtract adjusted value from mouse position is needed */
529 current.x = ec->mouse.current.mx - ec->transform.adjusted.x;
530 current.y = ec->mouse.current.my - ec->transform.adjusted.y;
531 moveinfo.x = ec->moveinfo.down.mx - ec->transform.adjusted.x;
532 moveinfo.y = ec->moveinfo.down.my - ec->transform.adjusted.y;
534 _e_client_transform_point_transform(cx, cy, ec->transform.angle,
535 current.x, current.y,
536 ¤t.x, ¤t.y);
537 _e_client_transform_point_transform(cx, cy, ec->transform.angle,
538 moveinfo.x, moveinfo.y,
539 &moveinfo.x, &moveinfo.y);
541 /* step 3: calculate new size */
542 if ((ec->resize_mode == E_POINTER_RESIZE_TR) ||
543 (ec->resize_mode == E_POINTER_RESIZE_R) ||
544 (ec->resize_mode == E_POINTER_RESIZE_BR))
546 if ((button_id >= 1) && (button_id <= 3))
547 new_w = org_w + (current.x - moveinfo.x);
549 new_w = ec->moveinfo.down.w + (current.x - moveinfo.x);
551 else if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
552 (ec->resize_mode == E_POINTER_RESIZE_L) ||
553 (ec->resize_mode == E_POINTER_RESIZE_BL))
555 if ((button_id >= 1) && (button_id <= 3))
556 new_w = org_w - (current.x - moveinfo.x);
558 new_w = ec->moveinfo.down.w - (current.x - moveinfo.x);
561 if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
562 (ec->resize_mode == E_POINTER_RESIZE_T) ||
563 (ec->resize_mode == E_POINTER_RESIZE_TR))
565 if ((button_id >= 1) && (button_id <= 3))
566 new_h = org_h - (current.y - moveinfo.y);
568 new_h = ec->moveinfo.down.h - (current.y - moveinfo.y);
570 else if ((ec->resize_mode == E_POINTER_RESIZE_BL) ||
571 (ec->resize_mode == E_POINTER_RESIZE_B) ||
572 (ec->resize_mode == E_POINTER_RESIZE_BR))
574 if ((button_id >= 1) && (button_id <= 3))
575 new_h = org_h + (current.y - moveinfo.y);
577 new_h = ec->moveinfo.down.h + (current.y - moveinfo.y);
580 new_w = MIN(new_w, zone->w);
581 new_h = MIN(new_h, zone->h);
583 /* step 4: move to new position */
584 if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
585 (ec->resize_mode == E_POINTER_RESIZE_L) ||
586 (ec->resize_mode == E_POINTER_RESIZE_BL))
587 new_x += (new_w - org_w);
588 if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
589 (ec->resize_mode == E_POINTER_RESIZE_T) ||
590 (ec->resize_mode == E_POINTER_RESIZE_TR))
591 new_y += (new_h - org_h);
593 /* step 5: set geometry to new value */
594 evas_object_geometry_set(ec->frame, new_x, new_y, new_w, new_h);
598 _e_client_transform_resize_begin(E_Client *ec)
601 if (!ec->transformed) return;
603 map = e_client_map_get(ec);
604 _e_client_transform_geometry_save(ec, map);
609 _e_client_transform_resize_end(E_Client *ec)
612 int new_x = 0, new_y = 0;
615 if (!ec->transformed) return;
617 map = e_client_map_get(ec);
620 if (!e_pixmap_size_get(ec->pixmap, &pw, &ph))
626 cx = ec->client.x + pw / 2 + ec->transform.adjusted.x;
627 cy = ec->client.y + ph / 2 + ec->transform.adjusted.y;
629 if (ec->transform.zoom != 1.0)
633 tmp_map = e_map_dup(map);
634 e_map_util_zoom(tmp_map,
635 1 / ec->transform.zoom,
636 1 / ec->transform.zoom,
639 _e_client_transform_geometry_save(ec, tmp_map);
644 _e_client_transform_geometry_save(ec, map);
647 /* move original object to adjusted position after resizing */
648 _e_client_transform_point_transform(cx, cy,
650 ec->transform.saved[0].x,
651 ec->transform.saved[0].y,
653 e_client_util_move_without_frame(ec, new_x, new_y);
654 e_map_util_object_move_sync_set(map, EINA_TRUE);
659 _e_client_transform_move_end(E_Client *ec)
663 double dx, dy, px, py;
666 if (!ec->transformed) return;
668 map = e_client_map_get(ec);
671 if (ec->transform.zoom != 1.0)
673 e_map_point_precise_coord_get(map, 0, &px, &py, NULL);
675 dx = px - ec->transform.saved[0].x;
676 dy = py - ec->transform.saved[0].y;
678 for (i = 0; i < 4; i++)
680 ec->transform.saved[i].x += dx;
681 ec->transform.saved[i].y += dy;
685 _e_client_transform_geometry_save(ec, map);
690 e_client_intercept_hook_focus_revert_call(E_Client *ec)
692 // no need to call the intercept hook if ec is NULL.
693 if (!ec) return EINA_FALSE;
695 if (!_e_client_intercept_hook_call(E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT, ec))
697 ELOGF("FOCUS", "E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT Intercepted.", ec);
705 e_client_check_fully_contain_by_above(E_Client *ec, Eina_Bool check_layer)
707 E_Client *above = NULL;
709 int x = 0, y = 0, w = 0, h = 0;
710 int ax = 0, ay = 0, aw = 0, ah = 0;
712 if (!ec) return NULL;
714 e_client_geometry_get(ec, &x, &y, &w, &h);
716 zone = e_comp_zone_find_by_ec(ec);
718 E_RECTS_CLIP_TO_RECT(x, y, w, h, zone->x, zone->y, zone->w, zone->h);
720 above = e_client_above_get(ec);
724 (above->layer <= ec->layer))
726 above = e_client_above_get(above);
730 if ((!e_object_is_del(E_OBJECT(above))) &&
731 (!e_client_util_ignored_get(above)) &&
733 (!above->iconic || e_policy_visibility_client_is_uniconic(above)) &&
734 (!above->bg_state) &&
736 (!above->visibility.force_obscured) &&
739 e_client_geometry_get(above, &ax, &ay, &aw, &ah);
740 if (E_CONTAINS(ax, ay, aw, ah, x, y, w, h))
743 above = e_client_above_get(above);
750 e_client_check_obscured_by_children_group(E_Client *ec)
752 E_Client *cec = NULL;
753 Eina_List *transients = NULL, *l = NULL;
755 _e_client_transient_for_group_make(ec, &transients);
756 if (!transients) return NULL;
758 EINA_LIST_FOREACH(transients, l, cec)
760 if (E_CONTAINS(cec->x, cec->y, cec->w, cec->h, ec->x, ec->y, ec->w, ec->h))
762 if (!cec->argb) break;
763 if (cec->visibility.opaque > 0) break;
767 eina_list_free(transients);
773 e_client_check_really_iconified(E_Client *ec)
775 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
777 if (!ec->iconic) return EINA_FALSE;
779 return ((!e_policy_visibility_client_is_uniconic(ec) &&
780 !e_policy_visibility_client_is_uniconify_render_running(ec)) ||
781 (e_client_is_iconified_by_client(ec)));
784 #ifdef REFACTOR_FOCUS_POLICY
787 _e_client_focus_can_take_by_vis_obscured(E_Client *ec)
789 switch (ec->visibility.obscured)
791 case E_VISIBILITY_UNKNOWN:
792 if (e_client_check_really_iconified(ec))
795 if (!evas_object_visible_get(ec->frame) &&
796 !eina_list_data_find(defer_focus_stack, ec))
800 case E_VISIBILITY_FULLY_OBSCURED:
801 if (e_client_check_really_iconified(ec))
804 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
806 if (!evas_object_visible_get(ec->frame))
808 ELOGF("FOCUS", "client is hidden, skip focus", ec);
814 case E_VISIBILITY_UNOBSCURED:
815 case E_VISIBILITY_PARTIALLY_OBSCURED:
816 case E_VISIBILITY_PRE_UNOBSCURED:
824 _e_client_focus_can_take(E_Client *ec)
827 E_Client *child_ec = NULL;
828 E_Client *above_ec = NULL;
829 int x = 0, y = 0, w = 0, h = 0;
831 if (!ec) return EINA_FALSE;
832 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
833 if (e_client_util_ignored_get(ec)) return EINA_FALSE;
835 if (!(ec->icccm.accepts_focus || ec->icccm.take_focus)) return EINA_FALSE;
836 if (ec->lock_focus_in || ec->lock_focus_out) return EINA_FALSE;
838 if (!ec->visible) return EINA_FALSE;
839 if (ec->bg_state) return EINA_FALSE;
840 if (ec->visibility.force_obscured) return EINA_FALSE;
841 if (!_e_client_focus_can_take_by_vis_obscured(ec)) return EINA_FALSE;
843 zone = e_comp_zone_find_by_ec(ec);
846 e_client_geometry_get(ec, &x, &y, &w, &h);
847 if (!E_INTERSECTS(zone->x, zone->y, zone->w, zone->h, x, y, w, h))
851 above_ec = e_client_check_fully_contain_by_above(ec, EINA_FALSE);
854 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
856 if (!evas_object_visible_get(above_ec->frame))
860 child_ec = e_client_check_obscured_by_children_group(ec);
861 if (!child_ec) return EINA_FALSE;
862 if (above_ec != child_ec) return EINA_FALSE;
864 if (_e_client_focus_can_take(child_ec))
866 else if (e_client_check_fully_contain_by_above(child_ec, EINA_FALSE))
874 e_client_focus_can_take(E_Client *ec)
876 return _e_client_focus_can_take(ec);
880 _e_client_focus_topmost_focusable_get(void)
884 E_CLIENT_REVERSE_FOREACH(ec)
886 if (_e_client_focus_can_take(ec))
893 _e_client_find_next_focus(E_Client *ec)
896 E_Client *temp_ec = NULL;
898 // call the intercept hook of the revert focus
899 if (e_client_intercept_hook_focus_revert_call(ec))
902 EINA_LIST_FOREACH(focus_stack, l, temp_ec)
904 if (_e_client_focus_can_take(temp_ec))
912 _e_client_revert_focus_get(E_Client *ec)
914 E_Client *pec = NULL, *focus_ec = NULL;
918 if (stopping) return NULL;
920 return _e_client_find_next_focus(NULL);
922 zone = e_comp_zone_find_by_ec(ec);
923 if (!zone) return NULL;
924 desk = e_desk_current_get(zone);
925 if (!desk) return NULL;
926 if (!e_comp_client_zone_is_displaying(ec)) return NULL;
928 if (e_config->focus_policy == E_FOCUS_MOUSE)
930 // set mouse over focus
931 pec = e_client_under_pointer_get(desk, ec);
934 /* no autoraise/revert here because it's probably annoying */
937 focus_ec = _e_client_find_next_focus(ec);
944 _e_client_event_focus_skip_set(E_Client *ec, Eina_Bool by_client)
946 E_Event_Client_Focus_Skip_Set *ev;
948 ev = E_NEW(E_Event_Client_Focus_Skip_Set, 1);
952 ev->by_client = by_client;
953 e_object_ref(E_OBJECT(ec));
955 ecore_event_add(E_EVENT_CLIENT_FOCUS_SKIP_SET, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
959 _e_client_event_focus_skip_unset(E_Client *ec, Eina_Bool by_client)
961 E_Event_Client_Focus_Skip_Unset *ev;
963 ev = E_NEW(E_Event_Client_Focus_Skip_Unset, 1);
967 ev->by_client = by_client;
968 e_object_ref(E_OBJECT(ec));
970 ecore_event_add(E_EVENT_CLIENT_FOCUS_SKIP_UNSET, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
974 e_client_focus_skip_set(E_Client *ec, Eina_Bool skip, Eina_Bool by_client)
980 if (ec->icccm.accepts_focus)
982 ELOGF("TZPOL", "FOCUS|SKIP SET (by_client:%d)", ec, by_client);
983 ec->icccm.accepts_focus = ec->icccm.take_focus = 0;
984 ec->changes.accepts_focus = 1;
987 _e_client_event_focus_skip_set(ec, by_client);
992 if (!ec->icccm.accepts_focus)
994 ELOGF("TZPOL", "FOCUS|SKIP UNSET (by_client:%d)", ec, by_client);
995 ec->icccm.accepts_focus = ec->icccm.take_focus = 1;
996 ec->changes.accepts_focus = 1;
999 _e_client_event_focus_skip_unset(ec, by_client);
1004 #ifdef REFACTOR_FOCUS_POLICY
1007 e_client_revert_focus(E_Client *ec)
1009 E_Client *focus_ec = NULL;
1011 // check topmost focus policy
1012 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
1014 focus_ec = _e_client_focus_topmost_focusable_get();
1015 if (focused == focus_ec) return;
1019 if (!focus_ec->iconic || focus_ec->exp_iconify.buffer_flush)
1021 ELOGF("FOCUS", "focus set | topmost_focus", focus_ec);
1022 if (focused) e_client_frame_focus_set(focused, EINA_FALSE);
1023 e_client_frame_focus_set(focus_ec, EINA_TRUE);
1028 ELOGF("FOCUS", "focus unset | No focusable ec", focused);
1029 e_client_frame_focus_set(focused, EINA_FALSE);
1035 focus_ec = _e_client_revert_focus_get(ec);
1036 if (!focus_ec) return;
1040 e_client_focus_defer_unset(ec);
1041 ELOGF("FOCUS", "focus unset | revert_focus", ec);
1042 e_client_frame_focus_set(ec, EINA_FALSE);
1045 if (!focus_ec->iconic || focus_ec->exp_iconify.buffer_flush)
1047 ELOGF("FOCUS", "focus set | revert_focus", focus_ec);
1048 e_client_frame_focus_set(focus_ec, EINA_TRUE);
1054 e_client_check_above_focused(E_Client *ec)
1056 E_Client *focus = NULL;
1057 E_Client *above = NULL;
1059 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1061 focus = e_client_focused_get();
1062 if (!focus) return EINA_FALSE;
1064 above = e_client_above_get(ec);
1070 above = e_client_above_get(above);
1077 _e_client_private_init(E_Client *ec)
1079 E_Client_Private *priv;
1081 priv = E_NEW(E_Client_Private, 1);
1085 wl_signal_init(&priv->events.destroy);
1087 e_object_data_set(E_OBJECT(ec), priv);
1093 _e_client_private_finish(E_Client *ec)
1095 E_Client_Private *priv;
1098 e_object_data_set(E_OBJECT(ec), NULL);
1104 _e_client_free(E_Client *ec)
1106 e_comp_object_redirected_set(ec->frame, 0);
1107 e_comp_object_render_update_del(ec->frame);
1109 E_OBJECT(ec)->references++;
1110 #ifdef REFACTOR_ZONE_DESK
1114 ec->desk->fullscreen_clients = eina_list_remove(ec->desk->fullscreen_clients, ec);
1115 if (!ec->desk->fullscreen_clients)
1116 e_comp_render_queue();
1120 e_comp->new_clients--;
1122 if (ec->e.state.video_parent && ec->e.state.video_parent_client)
1124 ec->e.state.video_parent_client->e.state.video_child =
1125 eina_list_remove(ec->e.state.video_parent_client->e.state.video_child, ec);
1127 if (ec->e.state.video_child)
1131 EINA_LIST_FREE(ec->e.state.video_child, tmp)
1132 tmp->e.state.video_parent_client = NULL;
1134 E_FREE_FUNC(ec->kill_timer, ecore_timer_del);
1135 E_FREE_LIST(ec->pending_resize, free);
1137 E_FREE_FUNC(ec->map_timer, ecore_timer_del);
1139 ec->transients = eina_list_free(ec->transients);
1140 if (ec->netwm.icons)
1143 for (i = 0; i < ec->netwm.num_icons; i++)
1144 free(ec->netwm.icons[i].data);
1145 E_FREE(ec->netwm.icons);
1147 E_FREE(ec->netwm.extra_types);
1148 eina_stringshare_replace(&ec->border.name, NULL);
1149 eina_stringshare_replace(&ec->bordername, NULL);
1150 eina_stringshare_replace(&ec->icccm.name, NULL);
1151 #if defined(__cplusplus) || defined(c_plusplus)
1152 eina_stringshare_replace(&ec->icccm.cpp_class, NULL);
1154 eina_stringshare_replace(&ec->icccm.class, NULL);
1156 eina_stringshare_replace(&ec->icccm.title, NULL);
1157 eina_stringshare_replace(&ec->icccm.icon_name, NULL);
1158 eina_stringshare_replace(&ec->icccm.machine, NULL);
1159 eina_stringshare_replace(&ec->icccm.window_role, NULL);
1160 if ((ec->icccm.command.argc > 0) && (ec->icccm.command.argv))
1164 for (i = 0; i < ec->icccm.command.argc; i++)
1165 free(ec->icccm.command.argv[i]);
1166 E_FREE(ec->icccm.command.argv);
1168 eina_stringshare_replace(&ec->netwm.name, NULL);
1169 eina_stringshare_replace(&ec->netwm.icon_name, NULL);
1170 eina_stringshare_replace(&ec->internal_icon, NULL);
1171 eina_stringshare_replace(&ec->internal_icon_key, NULL);
1173 #ifdef REFACTOR_FOCUS_POLICY
1174 // This code is executed at E_CLIENT_HOOK_DEL callback at e_focus_policy_history.c
1176 focus_stack = eina_list_remove(focus_stack, ec);
1177 e_client_focus_defer_unset(ec);
1180 E_FREE_FUNC(ec->frame, evas_object_del);
1182 #ifdef REFACTOR_FOCUS_POLICY
1183 // This code is executed at E_CLIENT_HOOK_DEL callback at e_focus_policy_topmost.c and e_focus_policy_history.c
1187 ELOGF("COMP", "CRITICAL. focused is deleted ec.", ec);
1188 ELOGF("FOCUS", "CLIENT FOCUS_SET", NULL);
1189 g_mutex_lock(&focused_ec_mutex);
1191 g_mutex_unlock(&focused_ec_mutex);
1195 E_OBJECT(ec)->references--;
1196 ELOGF("COMP", "CLIENT FREE", ec);
1198 e_uuid_store_entry_del(ec->uuid);
1199 #ifdef REFACTOR_ZONE_DESK
1201 e_desk_client_del(ec->desk, ec);
1204 _e_client_private_finish(ec);
1209 _e_client_del(E_Client *ec)
1216 #ifdef REFACTOR_FOCUS_POLICY
1217 // This code is executed at E_CLIENT_HOOK_DEL callback at e_focus_policy_history.c
1219 focus_stack = eina_list_remove(focus_stack, ec);
1220 e_client_focus_defer_unset(ec);
1222 #ifdef REFACTOR_ZONE_DESK
1224 e_desk_visible_client_iconified_list_remove(ec->desk, ec);
1226 if (ec == e_comp_object_dim_client_get())
1228 INF("[DIM] client deleted\n");
1229 e_comp_object_dim_client_set(NULL);
1232 if (ec->cur_mouse_action)
1234 if (ec->cur_mouse_action->func.end)
1235 ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
1237 if (action_client == ec) _e_client_action_finish();
1241 e_client_comp_hidden_set(ec, 1);
1242 evas_object_pass_events_set(ec->frame, 1);
1244 #ifdef REFACTOR_FOCUS_POLICY
1245 // This code is executed at E_CLIENT_HOOK_DEL callback at e_focus_policy_history.c
1248 e_client_revert_focus(ec);
1251 E_FREE_FUNC(ec->ping_poller, ecore_poller_del);
1253 wl_signal_emit_mutable(&PRI(ec)->events.destroy, ec);
1255 /* must be called before parent/child clear */
1256 _e_client_hook_call(E_CLIENT_HOOK_DEL, ec);
1258 _e_client_event_remove(ec);
1260 ELOGF("COMP", "CLIENT DEL", ec);
1264 ec->parent->transients = eina_list_remove(ec->parent->transients, ec);
1267 EINA_LIST_FREE(ec->transients, child)
1268 child->parent = NULL;
1270 type = e_pixmap_type_get(ec->pixmap);
1271 if (type < E_PIXMAP_TYPE_MAX)
1272 eina_hash_del_by_key(clients_hash[type], &ec->pixmap);
1273 e_comp->clients = eina_list_remove(e_comp->clients, ec);
1274 e_comp_object_render_update_del(ec->frame);
1275 e_comp_post_update_purge(ec);
1276 if (e_pixmap_free(ec->pixmap))
1277 e_pixmap_client_set(ec->pixmap, NULL);
1280 // base_output_resolution
1281 e_client_transform_core_remove(ec, ec->base_output_resolution.transform);
1282 e_util_transform_del(ec->base_output_resolution.transform);
1283 ec->base_output_resolution.transform = NULL;
1284 E_FREE_FUNC(ec->base_output_resolution.hook_subsurf_create, e_comp_wl_hook_del);
1286 #ifdef REFACTOR_ZONE_DESK
1289 e_client_transform_core_remove(ec, ec->desk_zoom.transform);
1290 e_util_transform_del(ec->desk_zoom.transform);
1291 ec->desk_zoom.transform = NULL;
1292 E_FREE_FUNC(ec->desk_zoom.hook_subsurf_create, e_comp_wl_hook_del);
1295 if (ec->transform_core.transform_list)
1297 E_Util_Transform *transform;
1299 EINA_LIST_FREE(ec->transform_core.transform_list, transform)
1301 e_util_transform_unref(transform);
1305 ec->transform_core.result.enable = EINA_FALSE;
1307 #ifdef REFACTOR_ZONE_DESK
1309 e_client_desk_area_set(ec, NULL);
1310 e_util_transform_del(ec->desk_area.transform);
1311 ec->desk_area.transform = NULL;
1314 _e_client_resize_object_del(ec);
1316 e_comp_visibility_calculation_set(EINA_TRUE);
1319 ///////////////////////////////////////////
1322 _e_client_cb_kill_timer(void *data)
1324 E_Client *ec = data;
1326 // dont wait until it's hung -
1329 if (ec->netwm.pid > 1)
1330 kill(ec->netwm.pid, SIGKILL);
1332 ec->kill_timer = NULL;
1333 return ECORE_CALLBACK_CANCEL;
1337 _e_client_cb_ping_poller(void *data)
1342 if (e_object_is_del(E_OBJECT(ec)))
1344 ec->ping_poller = NULL;
1345 return ECORE_CALLBACK_CANCEL;
1353 evas_object_smart_callback_call(ec->frame, "unhung", NULL);
1354 E_FREE_FUNC(ec->kill_timer, ecore_timer_del);
1359 /* if time between last ping and now is greater
1360 * than half the ping interval... */
1361 if ((ecore_loop_time_get() - ec->ping) >
1362 ((e_config->ping_clients_interval *
1363 ecore_poller_poll_interval_get(ECORE_POLLER_CORE)) / 2.0))
1368 evas_object_smart_callback_call(ec->frame, "hung", NULL);
1369 /* FIXME: if below dialog is up - hide it now */
1371 if (ec->delete_requested)
1373 /* FIXME: pop up dialog saying app is hung - kill client, or pid */
1374 e_client_act_kill_begin(ec);
1378 ec->ping_poller = NULL;
1380 return ECORE_CALLBACK_CANCEL;
1383 ///////////////////////////////////////////
1386 _e_client_action_input_win_new(void)
1390 CRI("DOUBLE COMP GRAB! ACK!!!!");
1393 comp_grabbed = e_comp_grab_input(1, 1);
1394 if (!comp_grabbed) _e_client_action_input_win_del();
1395 return comp_grabbed;
1399 _e_client_action_init(E_Client *ec)
1401 action_orig.x = ec->x;
1402 action_orig.y = ec->y;
1403 action_orig.w = ec->w;
1404 action_orig.h = ec->h;
1408 action_client->keyboard_resizing = 0;
1414 _e_client_move_begin(E_Client *ec)
1416 if ((ec->fullscreen) || (ec->lock_user_location))
1419 if (!_e_client_action_input_win_new()) return 0;
1422 _e_client_hook_call(E_CLIENT_HOOK_MOVE_BEGIN, ec);
1425 if (ecmove == ec) ecmove = NULL;
1426 _e_client_action_input_win_del();
1429 if (!ec->lock_user_stacking)
1431 if (e_config->border_raise_on_mouse_action)
1436 e_comp_client_override_add(ec);
1442 _e_client_move_end(E_Client *ec)
1445 _e_client_action_input_win_del();
1446 _e_client_hook_call(E_CLIENT_HOOK_MOVE_END, ec);
1448 if (ec->transformed)
1449 _e_client_transform_move_end(ec);
1452 e_comp_client_override_del(ec);
1459 _e_client_action_move_timeout(void *data EINA_UNUSED)
1461 _e_client_move_end(action_client);
1462 _e_client_action_finish();
1463 return ECORE_CALLBACK_CANCEL;
1467 _e_client_action_move_timeout_add(void)
1469 E_FREE_FUNC(action_timer, ecore_timer_del);
1470 if (e_config->border_keyboard.timeout)
1471 action_timer = ecore_timer_add(e_config->border_keyboard.timeout, _e_client_action_move_timeout, NULL);
1475 _e_client_move_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
1477 if (!comp_grabbed) return ECORE_CALLBACK_RENEW;
1480 ERR("no action_client!");
1482 if (action_client) _e_client_move_end(action_client);
1483 _e_client_action_finish();
1484 return ECORE_CALLBACK_DONE;
1488 _e_client_moveinfo_gather(E_Client *ec, const char *source)
1490 if (e_util_glob_match(source, "mouse,*,1"))
1491 ec->moveinfo.down.button = 1;
1492 else if (e_util_glob_match(source, "mouse,*,2"))
1493 ec->moveinfo.down.button = 2;
1494 else if (e_util_glob_match(source, "mouse,*,3"))
1495 ec->moveinfo.down.button = 3;
1497 ec->moveinfo.down.button = 0;
1498 if ((ec->moveinfo.down.button >= 1) && (ec->moveinfo.down.button <= 3))
1500 ec->moveinfo.down.mx = ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
1501 ec->moveinfo.down.my = ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
1505 ec->moveinfo.down.mx = ec->mouse.current.mx;
1506 ec->moveinfo.down.my = ec->mouse.current.my;
1511 _e_client_move_handle(E_Client *ec)
1515 if ((ec->moveinfo.down.button >= 1) && (ec->moveinfo.down.button <= 3))
1517 x = ec->mouse.last_down[ec->moveinfo.down.button - 1].x +
1518 (ec->mouse.current.mx - ec->moveinfo.down.mx);
1519 y = ec->mouse.last_down[ec->moveinfo.down.button - 1].y +
1520 (ec->mouse.current.my - ec->moveinfo.down.my);
1524 x = ec->moveinfo.down.x +
1525 (ec->mouse.current.mx - ec->moveinfo.down.mx);
1526 y = ec->moveinfo.down.y +
1527 (ec->mouse.current.my - ec->moveinfo.down.my);
1530 if (e_config->screen_limits == E_CLIENT_OFFSCREEN_LIMIT_ALLOW_NONE)
1531 _e_client_stay_within_canvas(ec, x, y, &x, &y);
1534 _e_client_stay_within_canvas_margin(ec, x, y, &x, &y);
1536 evas_object_move(ec->frame, x, y);
1538 if (e_client_transform_core_enable_get(ec))
1540 e_client_transform_core_update(ec);
1544 static Evas_Object *
1545 _e_client_resize_object_rectangle_get(E_Client *ec)
1547 Evas_Object *resize_obj = NULL;
1549 resize_obj = evas_object_rectangle_add(evas_object_evas_get(ec->frame));
1550 EINA_SAFETY_ON_NULL_RETURN_VAL(resize_obj, NULL);
1552 if (e_config->resize_object.customize)
1554 evas_object_color_set(resize_obj,
1555 e_config->resize_object.r,
1556 e_config->resize_object.g,
1557 e_config->resize_object.b,
1558 e_config->resize_object.a);
1561 evas_object_color_set(resize_obj, 128, 128, 128, 100);
1566 static Evas_Object *
1567 _e_client_resize_object_image_get(E_Client *ec)
1570 Evas_Object *resize_obj = NULL;
1572 if (!e_config->resize_object.image_path)
1574 ELOGF("COMP", "NO resize_object image! Make default resize_object", ec);
1578 resize_obj = evas_object_image_add(evas_object_evas_get(ec->frame));
1579 EINA_SAFETY_ON_NULL_RETURN_VAL(resize_obj, NULL);
1581 evas_object_image_file_set(resize_obj, e_config->resize_object.image_path, NULL);
1582 err = evas_object_image_load_error_get(resize_obj);
1583 if (err != EVAS_LOAD_ERROR_NONE)
1585 ELOGF("COMP", "Image load error. path:%s, errno:%d. Make default resize_object",
1586 ec, e_config->resize_object.image_path, err);
1587 evas_object_del(resize_obj);
1592 evas_object_image_fill_set(resize_obj, 0, 0, ec->w, ec->h);
1593 evas_object_image_filled_set(resize_obj, EINA_TRUE);
1595 evas_object_image_border_set(resize_obj,
1596 e_config->resize_object.border_width.l,
1597 e_config->resize_object.border_width.r,
1598 e_config->resize_object.border_width.t,
1599 e_config->resize_object.border_width.b);
1604 return _e_client_resize_object_rectangle_get(ec);
1607 static Evas_Object *
1608 _e_client_resize_object_create(E_Client *ec)
1610 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->frame, NULL);
1612 Evas_Object *resize_obj = NULL;
1614 if (_e_client_resize_object_create_cb)
1615 resize_obj = _e_client_resize_object_create_cb(ec);
1618 if (e_config->resize_object.type == 1) // image object
1620 resize_obj = _e_client_resize_object_image_get(ec);
1624 resize_obj = _e_client_resize_object_rectangle_get(ec);
1627 EINA_SAFETY_ON_NULL_RETURN_VAL(resize_obj, NULL);
1629 evas_object_pass_events_set(resize_obj, EINA_TRUE);
1630 evas_object_layer_set(resize_obj, evas_object_layer_get(ec->frame));
1631 evas_object_stack_above(resize_obj, ec->frame);
1632 evas_object_name_set(resize_obj, "resize_object");
1638 _e_client_resize_object_del(E_Client *ec)
1640 if (ec == NULL) return;
1641 if (ec->manage_resize.resize_obj == NULL) return;
1643 evas_object_hide(ec->manage_resize.resize_obj);
1644 evas_object_del(ec->manage_resize.resize_obj);
1645 ec->manage_resize.resize_obj = NULL;
1649 _e_client_resize_handle(E_Client *ec)
1652 int new_x, new_y, new_w, new_h;
1654 int trans_x = 0, trans_y = 0;
1655 int trans_w = 0, trans_h = 0;
1657 if (ec->transformed)
1659 _e_client_transform_resize_handle(ec);
1668 if ((ec->resize_mode == E_POINTER_RESIZE_TR) ||
1669 (ec->resize_mode == E_POINTER_RESIZE_R) ||
1670 (ec->resize_mode == E_POINTER_RESIZE_BR))
1672 if ((ec->moveinfo.down.button >= 1) &&
1673 (ec->moveinfo.down.button <= 3))
1674 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w +
1675 (ec->mouse.current.mx - ec->moveinfo.down.mx);
1677 w = ec->moveinfo.down.w + (ec->mouse.current.mx - ec->moveinfo.down.mx);
1679 else if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
1680 (ec->resize_mode == E_POINTER_RESIZE_L) ||
1681 (ec->resize_mode == E_POINTER_RESIZE_BL))
1683 if ((ec->moveinfo.down.button >= 1) &&
1684 (ec->moveinfo.down.button <= 3))
1685 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w -
1686 (ec->mouse.current.mx - ec->moveinfo.down.mx);
1688 w = ec->moveinfo.down.w - (ec->mouse.current.mx - ec->moveinfo.down.mx);
1691 if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
1692 (ec->resize_mode == E_POINTER_RESIZE_T) ||
1693 (ec->resize_mode == E_POINTER_RESIZE_TR))
1695 if ((ec->moveinfo.down.button >= 1) &&
1696 (ec->moveinfo.down.button <= 3))
1697 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h -
1698 (ec->mouse.current.my - ec->moveinfo.down.my);
1700 h = ec->moveinfo.down.h - (ec->mouse.current.my - ec->moveinfo.down.my);
1702 else if ((ec->resize_mode == E_POINTER_RESIZE_BL) ||
1703 (ec->resize_mode == E_POINTER_RESIZE_B) ||
1704 (ec->resize_mode == E_POINTER_RESIZE_BR))
1706 if ((ec->moveinfo.down.button >= 1) &&
1707 (ec->moveinfo.down.button <= 3))
1708 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h +
1709 (ec->mouse.current.my - ec->moveinfo.down.my);
1711 h = ec->moveinfo.down.h + (ec->mouse.current.my - ec->moveinfo.down.my);
1716 if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
1717 (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1718 (ec->resize_mode == E_POINTER_RESIZE_L) ||
1719 (ec->resize_mode == E_POINTER_RESIZE_BL))
1721 if ((ec->resize_mode == E_POINTER_RESIZE_L) ||
1722 (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1723 (ec->resize_mode == E_POINTER_RESIZE_T) ||
1724 (ec->resize_mode == E_POINTER_RESIZE_TR))
1731 if (e_config->screen_limits == E_CLIENT_OFFSCREEN_LIMIT_ALLOW_NONE)
1734 zone = e_comp_zone_find_by_ec(ec);
1737 w = MIN(w, zone->w);
1738 h = MIN(h, zone->h);
1741 e_client_resize_limit(ec, &new_w, &new_h);
1743 if (ec->manage_resize.enable_aspect_ratio)
1745 if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
1746 (ec->resize_mode == E_POINTER_RESIZE_L) ||
1747 (ec->resize_mode == E_POINTER_RESIZE_BL) ||
1748 (ec->resize_mode == E_POINTER_RESIZE_TR) ||
1749 (ec->resize_mode == E_POINTER_RESIZE_R) ||
1750 (ec->resize_mode == E_POINTER_RESIZE_BR))
1752 new_h = (int) ec->manage_resize.ah / ec->manage_resize.aw * new_w;
1754 else if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
1755 (ec->resize_mode == E_POINTER_RESIZE_B))
1757 new_w = (int) ec->manage_resize.aw / ec->manage_resize.ah * new_h;
1759 new_h += ec->manage_resize.header_h;
1760 new_h += ec->manage_resize.footer_h;
1763 if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
1764 (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1765 (ec->resize_mode == E_POINTER_RESIZE_L) ||
1766 (ec->resize_mode == E_POINTER_RESIZE_BL))
1767 new_x += (w - new_w);
1768 if ((ec->resize_mode == E_POINTER_RESIZE_L) ||
1769 (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1770 (ec->resize_mode == E_POINTER_RESIZE_T) ||
1771 (ec->resize_mode == E_POINTER_RESIZE_TR))
1772 new_y += (h - new_h);
1774 if (e_config->interactive_resize)
1776 evas_object_geometry_set(ec->frame, new_x, new_y, new_w, new_h);
1780 if (ec->manage_resize.resize_obj == NULL)
1782 ec->manage_resize.resize_obj = _e_client_resize_object_create(ec);
1783 EINA_SAFETY_ON_NULL_RETURN(ec->manage_resize.resize_obj);
1786 if (e_client_transform_core_enable_get(ec))
1788 e_client_transform_core_input_inv_transform(ec, new_x, new_y, &trans_x, &trans_y);
1789 e_client_transform_core_input_inv_transform(ec, new_w, new_h, &trans_w, &trans_h);
1790 evas_object_geometry_set(ec->manage_resize.resize_obj, trans_x, trans_y, trans_w, trans_h);
1793 evas_object_geometry_set(ec->manage_resize.resize_obj, new_x, new_y, new_w, new_h);
1794 evas_object_show(ec->manage_resize.resize_obj);
1796 ec->manage_resize.x = new_x;
1797 ec->manage_resize.y = new_y;
1798 ec->manage_resize.w = new_w;
1799 ec->manage_resize.h = new_h;
1804 _e_client_adjust_size_by_ppu(int size, int start_size, unsigned int ppu)
1806 if (ppu <= 1) return size;
1808 unsigned int remainder = size % ppu;
1809 if (remainder == 0) return size;
1811 int gap = size - start_size;
1812 int new_size = size;
1814 new_size = size + (ppu - remainder);
1816 new_size = size - remainder;
1822 _e_client_adjust_position_by_ppu(int pos, int size, int prev_pos, int prev_size)
1826 if (prev_pos == pos)
1829 new_pos = (prev_pos + prev_size) - size;
1835 _e_client_adjust_geometry_by_resize_ppu(E_Client *ec)
1837 if (ec->manage_resize.unit_size <= 1) return;
1839 ec->manage_resize.w = _e_client_adjust_size_by_ppu(ec->manage_resize.w, ec->w, ec->manage_resize.unit_size);
1840 ec->manage_resize.h = _e_client_adjust_size_by_ppu(ec->manage_resize.h, ec->h, ec->manage_resize.unit_size);
1842 ec->manage_resize.x = _e_client_adjust_position_by_ppu(ec->manage_resize.x, ec->manage_resize.w, ec->x, ec->w);
1843 ec->manage_resize.y = _e_client_adjust_position_by_ppu(ec->manage_resize.y, ec->manage_resize.h, ec->y, ec->h);
1847 _e_client_resize_end(E_Client *ec)
1849 ec->resize_mode = E_POINTER_RESIZE_NONE;
1850 _e_client_action_input_win_del();
1852 _e_client_hook_call(E_CLIENT_HOOK_RESIZE_END, ec);
1854 if (ec->transformed)
1855 _e_client_transform_resize_end(ec);
1858 e_comp_client_override_del(ec);
1862 if (!e_config->interactive_resize)
1864 if (ec->manage_resize.resize_obj)
1866 if (ec->manage_resize.unit_size > 1)
1867 _e_client_adjust_geometry_by_resize_ppu(ec);
1869 e_client_frame_geometry_set(ec,
1870 ec->manage_resize.x,
1871 ec->manage_resize.y,
1872 ec->manage_resize.w,
1873 ec->manage_resize.h);
1874 _e_client_resize_object_del(ec);
1882 _e_client_action_resize_timeout(void *data EINA_UNUSED)
1884 _e_client_resize_end(action_client);
1885 _e_client_action_finish();
1886 return ECORE_CALLBACK_CANCEL;
1890 _e_client_action_resize_timeout_add(void)
1892 E_FREE_FUNC(action_timer, ecore_timer_del);
1893 if (e_config->border_keyboard.timeout)
1894 action_timer = ecore_timer_add(e_config->border_keyboard.timeout, _e_client_action_resize_timeout, NULL);
1898 _e_client_resize_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
1900 if (!comp_grabbed) return ECORE_CALLBACK_RENEW;
1903 ERR("no action_client!");
1905 if (action_client) _e_client_resize_end(action_client);
1906 _e_client_action_finish();
1907 return ECORE_CALLBACK_DONE;
1910 ////////////////////////////////////////////////
1913 _e_client_position_inside_input_rect(E_Client *ec, int tx, int ty)
1916 Eina_Bool res = EINA_FALSE;
1917 Eina_List *list = NULL, *l;
1918 Eina_Rectangle *data;
1920 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1922 e_client_geometry_get(ec, &x, &y, &w, &h);
1923 e_comp_object_input_rect_get(ec->frame, &list);
1926 EINA_LIST_FOREACH(list, l, data)
1928 if ((tx >= x + data->x) && (tx <= x + data->x + data->w) &&
1929 (ty >= y + data->y) && (ty <= y + data->y + data->h))
1935 list = eina_list_free(list);
1939 if ((tx >= x) && (tx <= x + w) &&
1940 (ty >= y) && (ty <= y + h))
1950 _e_client_under_pointer_helper_ignore_client(E_Desk *desk, E_Client *client)
1952 /* If a border was specified which should be excluded from the list
1953 * (because it will be closed shortly for example), skip */
1954 if (e_client_util_ignored_get(client) || (!e_desk_has_ec(desk, client))) return EINA_TRUE;
1955 if (!evas_object_visible_get(client->frame)) return EINA_TRUE;
1956 if (e_policy_client_is_cursor(client)) return EINA_TRUE;
1962 _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y)
1964 E_Client *ec = NULL, *cec;
1966 E_CLIENT_REVERSE_FOREACH(cec)
1968 if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue;
1969 if ((exclude) && (cec == exclude)) continue;
1970 if (!E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h))
1972 /* If the layer is higher, the position of the window is higher
1973 * (always on top vs always below) */
1974 if (!ec || (cec->layer > ec->layer))
1981 _e_client_input_rect_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y)
1983 E_Client *ec = NULL, *cec;
1986 E_CLIENT_REVERSE_FOREACH(cec)
1988 /* If a border was specified which should be excluded from the list
1989 * (because it will be closed shortly for example), skip */
1990 if (e_client_util_ignored_get(cec) || (!e_desk_has_ec(desk, cec))) continue;
1991 if (!evas_object_visible_get(cec->frame)) continue;
1992 if (e_policy_client_is_cursor(cec)) continue;
1993 if ((exclude) && (cec == exclude)) continue;
1994 e_client_geometry_get(cec, &cx, &cy, &cw, &ch);
1995 if (!E_INSIDE(x, y, cx, cy, cw, ch))
1997 /* If the layer is higher, the position of the window is higher
1998 * (always on top vs always below) */
1999 if (ec && (cec->layer <= ec->layer)) continue;
2000 if (_e_client_position_inside_input_rect(cec, x, y))
2008 _e_client_under_pointer_input_helper(E_Desk *desk, int x, int y)
2010 E_Client *ec = NULL, *cec;
2012 E_CLIENT_REVERSE_FOREACH(cec)
2014 if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue;
2016 Eina_List *list = NULL;
2017 Eina_Rectangle *rect;
2018 Eina_Bool inside = EINA_FALSE;
2019 e_comp_object_input_rect_get(cec->frame, &list);
2022 EINA_LIST_FREE(list, rect)
2024 if (E_INSIDE(x, y, rect->x, rect->y, rect->w, rect->h))
2028 else if (E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h))
2033 if (!inside) continue;
2034 /* If the layer is higher, the position of the window is higher
2035 * (always on top vs always below) */
2036 if (!ec || (cec->layer > ec->layer))
2043 ////////////////////////////////////////////////
2046 _e_client_zones_layout_calc(E_Client *ec, int *zx, int *zy, int *zw, int *zh)
2049 E_Zone *zone_above, *zone_below, *zone_left, *zone_right;
2052 zone = e_comp_zone_find_by_ec(ec);
2059 if (eina_list_count(e_comp->zones) == 1)
2068 zone_left = e_comp_zone_xy_get((x - w + 5), y);
2069 zone_right = e_comp_zone_xy_get((x + w + 5), y);
2070 zone_above = e_comp_zone_xy_get(x, (y - h + 5));
2071 zone_below = e_comp_zone_xy_get(x, (y + h + 5));
2073 if (!(zone_above) && (y))
2074 zone_above = e_comp_zone_xy_get(x, (h - 5));
2076 if (!(zone_left) && (x))
2077 zone_left = e_comp_zone_xy_get((x - 5), y);
2080 w = zone_right->x + zone_right->w;
2083 w = zone->x + zone->w;
2086 h = zone_below->y + zone_below->h;
2089 h = zone->y + zone->h;
2091 if ((zone_left) && (zone_right))
2092 w = zone->w + zone_right->x;
2094 if ((zone_above) && (zone_below))
2095 h = zone->h + zone_below->y;
2097 if (x) x -= zone->w;
2098 if (y) y -= zone->h;
2100 if (zx) *zx = x > 0 ? x : 0;
2101 if (zy) *zy = y > 0 ? y : 0;
2107 _e_client_stay_within_canvas(E_Client *ec, int x, int y, int *new_x, int *new_y)
2109 int new_x_max, new_y_max;
2114 zone = e_comp_zone_find_by_ec(ec);
2117 if (new_x) *new_x = x;
2118 if (new_y) *new_y = y;
2122 _e_client_zones_layout_calc(ec, NULL, NULL, &zw, &zh);
2124 new_x_max = zw - ec->w;
2125 new_y_max = zh - ec->h;
2126 lw = ec->w > zw ? EINA_TRUE : EINA_FALSE;
2127 lh = ec->h > zh ? EINA_TRUE : EINA_FALSE;
2161 _e_client_stay_within_canvas_margin(E_Client *ec, int x, int y, int *new_x, int *new_y)
2163 int new_x_max, new_y_max, new_x_min, new_y_min;
2164 int margin_w, margin_h;
2169 zone = e_comp_zone_find_by_ec(ec);
2172 if (new_x) *new_x = x;
2173 if (new_y) *new_y = y;
2180 _e_client_zones_layout_calc(ec, NULL, NULL, &zw, &zh);
2185 new_x_min = (margin_w > cw) ? 0 : -(cw - margin_w);
2186 new_x_max = (margin_w > cw) ? (zw - cw) : (zw - margin_w);
2187 new_y_min = (margin_h > ch) ? 0 : -(ch - margin_h);
2188 new_y_max = (margin_h > ch) ? (zh - ch) : (zh - margin_h);
2192 else if (x <= new_x_min)
2197 else if (y <= new_y_min)
2202 ////////////////////////////////////////////////
2203 #ifdef REFACTOR_ZONE_DESK
2206 _e_client_zone_update(E_Client *ec)
2211 /* still within old zone - leave it there */
2212 zone = e_comp_zone_find_by_ec(ec);
2213 if (zone && E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
2214 zone->x, zone->y, zone->w, zone->h))
2217 /* find a new zone */
2218 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2220 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
2221 zone->x, zone->y, zone->w, zone->h))
2223 e_client_zone_set(ec, zone);
2229 ////////////////////////////////////////////////
2232 _e_client_transform_core_activate_set(E_Client *ec, Eina_Bool set)
2234 if (ec->transform_core.activate == set) return;
2236 ec->transform_core.activate = set;
2240 ec->transform_core.changed = EINA_TRUE;
2241 e_client_transform_core_update(ec);
2245 e_client_map_enable_set(ec, EINA_FALSE);
2250 _e_client_cb_evas_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2252 E_Client *ec = data;
2254 if (stopping) return; //ignore all of this if we're shutting down!
2255 if (e_object_is_del(data)) return; //client is about to die
2256 if (ec->cur_mouse_action)
2258 if (ec->cur_mouse_action->func.end_mouse)
2259 ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", NULL);
2260 else if (ec->cur_mouse_action->func.end)
2261 ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
2262 E_FREE_FUNC(ec->cur_mouse_action, e_object_unref);
2264 if (action_client == ec) _e_client_action_finish();
2266 ec->want_focus = ec->take_focus = 0;
2268 _e_client_transform_core_activate_set(ec, EINA_FALSE);
2270 if (ec->new_client) return;
2271 _e_client_event_hide(ec);
2277 _e_client_cb_evas_shade_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2279 E_Client *ec = data;
2281 if (e_object_is_del(data)) return;
2284 ec->shaded = !(ec->shaded);
2285 ec->changes.shaded = 1;
2286 ec->changes.shading = 1;
2287 e_client_comp_hidden_set(ec, ec->shaded);
2291 _e_client_cb_evas_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2293 E_Client *ec = data;
2297 if (e_object_is_del(data)) return;
2299 ec->pre_res_change.valid = 0;
2301 _e_client_event_simple(ec, E_EVENT_CLIENT_MOVE);
2303 #ifdef REFACTOR_ZONE_DESK
2305 _e_client_zone_update(ec);
2307 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
2308 if ((e_config->transient.move) && (ec->transients))
2310 Eina_List *list = eina_list_clone(ec->transients);
2313 EINA_LIST_FREE(list, child)
2315 if (child->vkbd.vkbd) continue;
2317 evas_object_move(child->frame,
2318 child->x + x - ec->pre_cb.x,
2319 child->y + y - ec->pre_cb.y);
2322 if (ec->moving || (ecmove == ec))
2323 _e_client_hook_call(E_CLIENT_HOOK_MOVE_UPDATE, ec);
2325 if ((!ec->moving) && (ec->transformed))
2327 map = e_client_map_get(ec);
2328 _e_client_transform_geometry_save(ec, map);
2332 ec->pre_cb.x = x; ec->pre_cb.y = y;
2334 #ifdef REFACTOR_FOCUS_POLICY
2335 // This code is executed at E_CLIENT_HOOK_MOVE callback
2336 // at e_focus_policy_topmost.c and at e_focus_policy_history.c
2338 _e_client_hook_call(E_CLIENT_HOOK_MOVE, ec);
2343 zone = e_comp_zone_find_by_ec(ec);
2344 if (zone && !E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
2345 zone->x, zone->y, zone->w, zone->h))
2347 e_client_revert_focus(ec);
2352 e_comp_visibility_calculation_set(EINA_TRUE);
2356 _e_client_cb_evas_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2358 E_Client *ec = data;
2359 Evas_Coord x, y, w, h;
2361 if (e_object_is_del(data)) return;
2363 ec->pre_res_change.valid = 0;
2365 _e_client_event_simple(ec, E_EVENT_CLIENT_RESIZE);
2367 #ifdef REFACTOR_ZONE_DESK
2369 _e_client_zone_update(ec);
2371 evas_object_geometry_get(ec->frame, &x, &y, &w, &h);
2372 if ((e_config->transient.resize) && (ec->transients))
2374 Eina_List *list = eina_list_clone(ec->transients);
2377 EINA_LIST_FREE(list, child)
2379 Evas_Coord nx, ny, nw, nh;
2381 if ((ec->pre_cb.w > 0) && (ec->pre_cb.h > 0))
2383 nx = x + (((child->x - x) * w) / ec->pre_cb.w);
2384 ny = y + (((child->y - y) * h) / ec->pre_cb.h);
2385 nw = (child->w * w) / ec->pre_cb.w;
2386 nh = (child->h * h) / ec->pre_cb.h;
2387 nx += ((nw - child->w) / 2);
2388 ny += ((nh - child->h) / 2);
2389 evas_object_move(child->frame, nx, ny);
2394 if (e_client_util_resizing_get(ec) || (ecresize == ec))
2395 _e_client_hook_call(E_CLIENT_HOOK_RESIZE_UPDATE, ec);
2396 ec->pre_cb.w = w; ec->pre_cb.h = h;
2398 e_client_transform_core_update(ec);
2399 e_comp_visibility_calculation_set(EINA_TRUE);
2403 _e_client_cb_evas_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2405 E_Client *ec = data;
2407 if (e_object_is_del(data)) return;
2409 _e_client_transform_core_activate_set(ec, EINA_TRUE);
2411 _e_client_event_show(ec);
2416 _e_client_cb_evas_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2418 E_Client *ec = data;
2419 E_Comp_Wl_Client_Data *child_cdata = NULL;
2421 if (e_object_is_del(data)) return;
2422 if (ec->layer_block) return;
2423 if (ec->layer_pending) return;
2424 if (e_config->transient.raise && ec->transients)
2426 Eina_List *list = eina_list_clone(ec->transients);
2427 E_Client *child, *below = NULL, *above = NULL;
2428 E_Transient transient_policy;
2430 E_LIST_REVERSE_FREE(list, child)
2432 child_cdata = e_client_cdata_get(child);
2433 if (child_cdata && !child_cdata->mapped)
2435 ELOGF("COMP", "STACK CHANGE CHILD. BUT not mapped. skip. child(ec:%p, win:0x%08zx)", ec, child, e_client_util_win_get(child));
2439 /* Don't stack iconic transients. If the user wants these shown,
2440 * that's another option.
2442 if (child->iconic && e_client_is_iconified_by_client(child)) continue;
2444 transient_policy = e_client_transient_policy_get(child);
2445 if (transient_policy == E_TRANSIENT_ABOVE)
2448 e_client_stack_below(child, below);
2450 e_client_stack_above(child, ec);
2453 else if (transient_policy == E_TRANSIENT_BELOW)
2456 e_client_stack_below(child, above);
2458 e_client_stack_below(child, ec);
2464 if (ec->unredirected_single) return;
2465 _e_client_event_simple(ec, E_EVENT_CLIENT_STACK);
2467 e_comp_visibility_calculation_set(EINA_TRUE);
2470 ////////////////////////////////////////////////
2472 #ifdef REFACTOR_ZONE_DESK
2475 _e_client_maximize(E_Client *ec, E_Maximize max)
2477 int x1, yy1, x2, y2;
2480 int ecx, ecy, ecw, ech;
2481 int desk_x, desk_y, desk_w, desk_h;
2482 Eina_Bool override = ec->maximize_override;
2485 zx = zy = zw = zh = 0;
2486 ec->maximize_override = 1;
2488 zone = e_comp_zone_find_by_ec(ec);
2491 if (ec->desk_area.enable && ec->desk_area.desk_area)
2493 desk_x = ec->desk_area.desk_area->x;
2494 desk_y = ec->desk_area.desk_area->y;
2495 desk_w = ec->desk_area.desk_area->w;
2496 desk_h = ec->desk_area.desk_area->h;
2500 desk_x = ec->desk->geom.x;
2501 desk_y = ec->desk->geom.y;
2502 desk_w = ec->desk->geom.w;
2503 desk_h = ec->desk->geom.h;
2506 switch (max & E_MAXIMIZE_TYPE)
2508 case E_MAXIMIZE_NONE:
2512 case E_MAXIMIZE_FULLSCREEN:
2516 e_client_resize_limit(ec, &w, &h);
2517 /* center x-direction */
2518 x1 = desk_x + (desk_w - w) / 2;
2519 /* center y-direction */
2520 yy1 = desk_y + (desk_h - h) / 2;
2522 switch (max & E_MAXIMIZE_DIRECTION)
2524 case E_MAXIMIZE_BOTH:
2525 e_client_maximized_geometry_set(ec, x1, yy1, w, h);
2528 case E_MAXIMIZE_VERTICAL:
2529 e_client_maximized_geometry_set(ec, ec->x, yy1, ec->w, h);
2532 case E_MAXIMIZE_HORIZONTAL:
2533 e_client_maximized_geometry_set(ec, x1, ec->y, w, ec->h);
2536 case E_MAXIMIZE_LEFT:
2537 e_client_maximized_geometry_set(ec, desk_x, desk_y, w / 2, h);
2540 case E_MAXIMIZE_RIGHT:
2541 e_client_maximized_geometry_set(ec, x1, desk_y, w / 2, h);
2546 case E_MAXIMIZE_SMART:
2547 case E_MAXIMIZE_EXPAND:
2548 if (ec->desk->visible)
2550 // base_output_resolution
2551 if (ec->base_output_resolution.use)
2555 zw = ec->base_output_resolution.w;
2556 zh = ec->base_output_resolution.h;
2560 e_zone_desk_useful_geometry_get(zone, ec->desk, &zx, &zy, &zw, &zh, EINA_TRUE);
2567 x2 = desk_x + desk_w;
2568 y2 = desk_y + desk_h;
2569 e_maximize_client_shelf_fill(ec, &x1, &yy1, &x2, &y2, max);
2576 evas_object_smart_callback_call(ec->frame, "maximize", NULL);
2577 e_comp_object_frame_xy_unadjust(ec->frame, ec->x, ec->y, &ecx, &ecy);
2578 e_comp_object_frame_wh_unadjust(ec->frame, ec->w, ec->h, &ecw, &ech);
2586 if (ecx < zx) // window left not useful coordinates
2588 else if (ecx + ecw > zx + zw) // window right not useful coordinates
2590 else // window normal position
2593 if (ecy < zy) // window top not useful coordinates
2595 else if (ecy + ech > zy + zh) // window bottom not useful coordinates
2596 yy1 = zy + zh - ech;
2597 else // window normal position
2600 switch (max & E_MAXIMIZE_DIRECTION)
2602 case E_MAXIMIZE_BOTH:
2603 e_client_maximized_geometry_set(ec, zx, zy, zw, zh);
2606 case E_MAXIMIZE_VERTICAL:
2607 e_client_maximized_geometry_set(ec, ec->x, zy, ec->w, zh);
2610 case E_MAXIMIZE_HORIZONTAL:
2611 e_client_maximized_geometry_set(ec, zx, ec->y, zw, ec->h);
2614 case E_MAXIMIZE_LEFT:
2615 e_client_maximized_geometry_set(ec, zx, zy, zw / 2, zh);
2618 case E_MAXIMIZE_RIGHT:
2619 e_client_maximized_geometry_set(ec, zx + zw / 2, zy, zw / 2, zh);
2625 case E_MAXIMIZE_FILL:
2628 x2 = desk_x + desk_w;
2629 y2 = desk_y + desk_h;
2631 /* walk through all shelves */
2632 e_maximize_client_shelf_fill(ec, &x1, &yy1, &x2, &y2, max);
2634 /* walk through all windows */
2635 e_maximize_client_client_fill(ec, &x1, &yy1, &x2, &y2, max);
2641 e_client_resize_limit(ec, &w, &h);
2642 /* center x-direction */
2643 x1 = x1 + (pw - w) / 2;
2644 /* center y-direction */
2645 yy1 = yy1 + (ph - h) / 2;
2647 switch (max & E_MAXIMIZE_DIRECTION)
2649 case E_MAXIMIZE_BOTH:
2650 e_client_maximized_geometry_set(ec, x1, yy1, w, h);
2653 case E_MAXIMIZE_VERTICAL:
2654 e_client_maximized_geometry_set(ec, ec->x, yy1, ec->w, h);
2657 case E_MAXIMIZE_HORIZONTAL:
2658 e_client_maximized_geometry_set(ec, x1, ec->y, w, ec->h);
2661 case E_MAXIMIZE_LEFT:
2662 e_client_maximized_geometry_set(ec, desk_x, desk_y, w / 2, h);
2665 case E_MAXIMIZE_RIGHT:
2666 e_client_maximized_geometry_set(ec, x1, desk_y, w / 2, h);
2671 if (ec->maximize_override)
2672 ec->maximize_override = override;
2676 ////////////////////////////////////////////////
2678 _e_client_aux_hint_eval(E_Client *ec)
2682 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2684 E_Comp_Wl_Aux_Hint *hint;
2686 if (cdata && cdata->aux_hint.changed)
2688 _e_client_hook_call(E_CLIENT_HOOK_AUX_HINT_CHANGE, ec);
2690 EINA_LIST_FOREACH_SAFE(cdata->aux_hint.hints, l, ll, hint)
2692 hint->changed = EINA_FALSE;
2695 ELOGF("COMP", "AUX_HINT |Del [%d:%s:%s]", ec, hint->id, hint->hint, hint->val);
2696 if (hint->hint) eina_stringshare_del(hint->hint);
2697 if (hint->val) eina_stringshare_del(hint->val);
2698 cdata->aux_hint.hints = eina_list_remove_list(cdata->aux_hint.hints, l);
2702 cdata->aux_hint.changed = 0;
2706 #ifdef REFACTOR_ZONE_DESK
2709 _e_client_apply_auto_placement(E_Client *ec)
2711 Eina_List *skiplist = NULL;
2712 int new_x, new_y, t = 0;
2714 E_Client *parent_ec;
2717 // intercept auto placement policy
2718 if (!_e_client_intercept_hook_call(E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT, ec))
2720 ELOGF("POL", "Intercepted auto_placement policy.", ec);
2724 int zx = 0, zy = 0, zw = 0, zh = 0;
2726 zone = e_comp_zone_find_by_ec(ec);
2729 e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
2731 unsigned int seed = (unsigned int)time(NULL);
2734 new_x = zx + (rand_r(&seed) % (zw - ec->w));
2738 new_y = zy + (rand_r(&seed) % (zh - ec->h));
2742 e_comp_object_frame_geometry_get(ec->frame, NULL, NULL, &t, NULL);
2744 parent_ec = ec->parent;
2748 new_x = parent_ec->x;
2749 new_y = parent_ec->y;
2751 else if ((e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART) || (e_config->window_placement_policy == E_WINDOW_PLACEMENT_ANTIGADGET))
2754 skiplist = eina_list_append(skiplist, ec);
2756 e_place_desk_region_smart(ec->desk, skiplist,
2757 ec->x, ec->y, ec->w, ec->h,
2760 e_place_zone_region_smart(zone, skiplist,
2761 ec->x, ec->y, ec->w, ec->h,
2764 eina_list_free(skiplist);
2766 else if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_MANUAL)
2769 e_place_zone_manual(zone, ec->w, t, &new_x, &new_y);
2774 e_place_zone_cursor(zone, ec->x, ec->y, ec->w, ec->h,
2778 ELOGF("POL", "Apply auto placement (type:%d). (%d,%d) -> (%d,%d).", ec, type, ec->x, ec->y, new_x, new_y);
2779 e_client_pos_set(ec, new_x, new_y);
2780 ec->changes.pos = 1;
2782 ec->pre_cb.x = ec->x; ec->pre_cb.y = ec->y;
2787 _e_client_eval(E_Client *ec)
2790 unsigned int prop = 0;
2791 #ifdef REFACTOR_ZONE_DESK
2799 if (e_object_is_del(E_OBJECT(ec)))
2801 CRI("_e_client_eval(%p) with deleted border! - %d\n", ec, ec->new_client);
2806 TRACE_DS_BEGIN(CLIENT:EVAL);
2808 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_NEW_CLIENT, ec))
2814 #ifdef REFACTOR_ZONE_DESK
2815 if ((ec->new_client) && (!e_client_util_ignored_get(ec)))
2817 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_NEW_CLIENT, ec))
2824 zone = e_comp_zone_find_by_ec(ec);
2825 if ((ec->new_client) && (!e_client_util_ignored_get(ec)) && (zone))
2827 int zx = 0, zy = 0, zw = 0, zh = 0;
2829 e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
2830 /* enforce wm size hints for initial sizing */
2831 if (e_config->screen_limits == E_CLIENT_OFFSCREEN_LIMIT_ALLOW_NONE)
2833 tw = MIN(ec->w, zone->w);
2834 th = MIN(ec->h, zone->h);
2835 e_client_size_set(ec, tw, th);
2840 e_client_resize_limit(ec, &nw, &nh);
2841 e_client_size_set(ec, nw, nh);
2845 int x = ec->x, y = ec->y;
2846 if (ec->x) e_comp_object_frame_xy_adjust(ec->frame, ec->x, 0, &ec->x, NULL);
2847 if (ec->y) e_comp_object_frame_xy_adjust(ec->frame, 0, ec->y, NULL, &ec->y);
2848 if ((x != ec->x) || (y != ec->y)) ec->changes.pos = 1;
2850 ec->pre_cb.x = ec->x; ec->pre_cb.y = ec->y;
2856 tx = zx + ((zw - ec->w) / 2);
2857 ty = zy + ((zh - ec->h) / 2);
2858 e_client_pos_set(ec, tx, ty);
2860 ec->changes.pos = 1;
2862 ec->pre_cb.x = ec->x; ec->pre_cb.y = ec->y;
2867 eai = e_appinfo_find_with_pid(ec->netwm.pid);
2871 _e_client_apply_auto_placement(ec);
2875 if (e_appinfo_auto_placement_get(eai))
2876 _e_client_apply_auto_placement(ec);
2879 /* Recreate state */
2880 if (ec->e.state.centered)
2882 tx = zx + (zw - ec->w) / 2;
2883 ty = zy + (zh - ec->h) / 2;
2884 e_client_pos_set(ec, tx, ty);
2885 ec->changes.pos = 1;
2888 /* if the explicit geometry request asks for the app to be
2889 * in another zone - well move it there */
2891 E_Zone *zone1 = NULL;
2896 if ((!ec->re_manage) && ((ec->x != x) || (ec->y != y)))
2897 zone1 = e_comp_zone_xy_get(x, y);
2901 zone1 = e_comp_zone_xy_get(ec->x + (ec->w / 2), ec->y + (ec->h / 2));
2904 E_Zone *z2 = e_comp_zone_xy_get(ec->x, ec->y);
2906 if (z2 && (z2 != zone1))
2912 EINA_LIST_FOREACH(e_comp->zones, l, z2)
2916 x = ec->x, y = ec->y, w = ec->w, h = ec->h;
2917 E_RECTS_CLIP_TO_RECT(x, y, w, h, z2->x, z2->y, z2->w, z2->h);
2918 if (w * h == z2->w * z2->h)
2920 /* client fully covering zone */
2924 if ((unsigned)(w * h) > psz)
2935 zone1 = e_comp_zone_xy_get(ec->x, ec->y);
2937 zone1 = e_comp_zone_xy_get(ec->x + ec->w - 1, ec->y);
2939 zone1 = e_comp_zone_xy_get(ec->x + ec->w - 1, ec->y + ec->h - 1);
2941 zone1 = e_comp_zone_xy_get(ec->x, ec->y + ec->h - 1);
2942 if ((zone1) && (zone1 != zone))
2943 e_client_zone_set(ec, zone1);
2947 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_NEW_CLIENT, ec))
2954 /* effect changes to the window border itself */
2955 if ((ec->changes.shading))
2957 /* show at start of unshade (but don't hide until end of shade) */
2958 ec->changes.shading = 0;
2961 if (ec->changes.shaded) send_event = 0;
2962 if ((ec->changes.shaded) && (ec->changes.pos) && (ec->changes.size))
2964 ec->changes.shaded = 0;
2966 else if ((ec->changes.shaded) && (ec->changes.pos))
2968 ec->changes.size = 1;
2969 ec->changes.shaded = 0;
2971 else if ((ec->changes.shaded) && (ec->changes.size))
2973 ec->changes.shaded = 0;
2975 else if (ec->changes.shaded)
2977 ec->changes.shaded = 0;
2980 if (ec->changes.size)
2982 ec->changes.size = 0;
2983 if ((!ec->shaded) && (!ec->shading))
2984 evas_object_resize(ec->frame, ec->w, ec->h);
2986 prop |= E_CLIENT_PROPERTY_SIZE;
2988 if (ec->changes.pos)
2990 ec->changes.tz_position = 0;
2991 ec->changes.pos = 0;
2992 evas_object_move(ec->frame, ec->x, ec->y);
2993 prop |= E_CLIENT_PROPERTY_POS;
2996 if (ec->changes.reset_gravity)
2998 ec->changes.reset_gravity = 0;
2999 prop |= E_CLIENT_PROPERTY_GRAVITY;
3002 if (ec->changes.title)
3004 ec->changes.title = 0;
3005 prop |= E_CLIENT_PROPERTY_TITLE;
3008 if ((ec->changes.visible) && (ec->visible) && (ec->new_client) && (!ec->iconic))
3012 e_input_device_pointer_xy_get(NULL, &x, &y);
3013 if ((!ec->placed) && (!ec->re_manage) &&
3014 (e_config->window_placement_policy == E_WINDOW_PLACEMENT_MANUAL) &&
3015 (!((ec->icccm.transient_for != 0) ||
3017 (!ecmove) && (!ecresize))
3019 /* Set this window into moving state */
3021 ec->cur_mouse_action = e_action_find("window_move");
3022 if (ec->cur_mouse_action)
3024 if ((!ec->cur_mouse_action->func.end_mouse) &&
3025 (!ec->cur_mouse_action->func.end))
3026 ec->cur_mouse_action = NULL;
3027 if (ec->cur_mouse_action)
3030 tx = x - (ec->w >> 1);
3031 e_comp_object_frame_geometry_get(ec->frame, NULL, NULL, &t, NULL);
3033 e_client_pos_set(ec, tx, ty);
3035 ec->changes.pos = 1;
3040 evas_object_show(ec->frame);
3041 if (evas_object_visible_get(ec->frame))
3043 #ifdef REFACTOR_FOCUS_POLICY
3044 // It is useless, Nothing to do.
3046 if (ec->cur_mouse_action)
3048 ec->moveinfo.down.x = ec->x;
3049 ec->moveinfo.down.y = ec->y;
3050 ec->moveinfo.down.w = ec->w;
3051 ec->moveinfo.down.h = ec->h;
3052 ec->mouse.current.mx = x;
3053 ec->mouse.current.my = y;
3054 ec->moveinfo.down.button = 0;
3055 ec->moveinfo.down.mx = x;
3056 ec->moveinfo.down.my = y;
3058 e_object_ref(E_OBJECT(ec->cur_mouse_action));
3059 ec->cur_mouse_action->func.go(E_OBJECT(ec), NULL);
3060 if (e_config->border_raise_on_mouse_action)
3062 if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
3064 ELOGF("FOCUS", "focus set | client eval", ec);
3065 e_client_frame_focus_set(ec, EINA_TRUE);
3069 ec->changes.visible = 0;
3070 _e_client_event_show(ec);
3073 else if ((ec->changes.visible) && (ec->new_client))
3075 ec->changes.visible = 0;
3077 _e_client_event_hide(ec);
3080 if (ec->changes.icon)
3082 ec->changes.icon = 0;
3086 e_comp->new_clients--;
3088 ec->changed = ec->changes.pos || ec->changes.size ||
3089 ec->changes.stack || ec->changes.prop || ec->changes.border ||
3090 ec->changes.reset_gravity || ec->changes.shading || ec->changes.shaded ||
3091 ec->changes.shape || ec->changes.shape_input || ec->changes.icon ||
3092 ec->changes.internal_state ||
3093 ec->changes.need_maximize || ec->changes.need_unmaximize;
3094 ec->changes.stack = 0;
3096 #ifdef REFACTOR_FOCUS_POLICY
3097 // This code executes at E_CLIENT_HOOK_EVAL_END callback at e_focus_policy_topmost.c and e_focus_policy_history.c
3099 zone = e_comp_zone_find_by_ec(ec);
3100 if ((!ec->input_only) && (!ec->iconic) &&
3101 ((!zone) || e_desk_has_ec(e_desk_current_get(zone), ec)) &&
3102 ((ec->take_focus) || (ec->want_focus)))
3108 #if 0 // focus should be set to the top window
3109 e_client_focus_set_with_pointer(ec);
3114 /* focus window by default when it is the only one on desk */
3115 E_Client *ec2 = NULL;
3118 desk = e_zone_desk_find_by_ec(zone, ec);
3119 EINA_LIST_FOREACH(focus_stack, l, ec2)
3121 if (ec == ec2) continue;
3122 if ((!ec2->iconic) && (ec2->visible) &&
3123 ((e_desk_has_ec(desk, ec2)) || ec2->sticky))
3129 e_client_focus_set_with_pointer(ec);
3134 ec->take_focus = ec->want_focus = 0;
3137 if (ec->changes.need_maximize)
3139 E_Maximize max = ec->maximized;
3140 ec->maximized = E_MAXIMIZE_NONE;
3141 e_client_maximize(ec, max);
3142 ec->changes.need_maximize = 0;
3144 else if (ec->changes.need_unmaximize)
3146 e_client_unmaximize(ec, ec->maximized);
3147 ec->changes.need_unmaximize = 0;
3150 if (ec->need_fullscreen)
3152 e_client_fullscreen(ec, e_config->fullscreen_policy);
3153 ec->need_fullscreen = 0;
3156 if (ec->changes.accepts_focus)
3158 if ((!ec->icccm.accepts_focus) && (!ec->icccm.take_focus))
3161 ec->changes.accepts_focus = 0;
3165 if (send_event && prop)
3167 _e_client_event_property(ec, prop);
3170 _e_client_aux_hint_eval(ec);
3172 e_client_transform_core_update(ec);
3173 _e_client_hook_call(E_CLIENT_HOOK_EVAL_END, ec);
3178 #ifdef REFACTOR_ZONE_DESK
3180 e_client_frame_update(E_Client *ec)
3183 _e_client_frame_update(E_Client *ec)
3186 const char *bordername;
3188 #ifdef REFACTOR_ZONE_DESK
3189 EINA_SAFETY_ON_NULL_RETURN(ec);
3190 if (e_object_is_del(E_OBJECT(ec))) return;
3193 ec->border.changed = 0;
3194 if (!e_comp_object_frame_allowed(ec->frame)) return;
3195 if (ec->fullscreen || ec->borderless)
3196 bordername = "borderless";
3197 else if (ec->bordername)
3198 bordername = ec->bordername;
3199 else if (ec->mwm.borderless)
3200 bordername = "borderless";
3201 else if (((ec->icccm.transient_for != 0) || (ec->dialog)) &&
3202 (ec->icccm.min_w == ec->icccm.max_w) &&
3203 (ec->icccm.min_h == ec->icccm.max_h))
3204 bordername = "noresize_dialog";
3205 else if ((ec->icccm.min_w == ec->icccm.max_w) &&
3206 (ec->icccm.min_h == ec->icccm.max_h))
3207 bordername = "noresize";
3208 else if (ec->shaped)
3209 bordername = "shaped";
3210 else if (ec->urgent)
3211 bordername = "urgent";
3212 else if (ec->netwm.state.modal)
3213 bordername = "modal";
3214 else if ((ec->netwm.state.skip_taskbar) ||
3215 (ec->netwm.state.skip_pager))
3216 bordername = "skipped";
3218 else if ((ec->internal) && (ec->icccm.class) &&
3219 (!strncmp(ec->icccm.class, "e_fwin", 6)))
3220 bordername = "internal_fileman";
3223 bordername = e_config->theme_default_border_style;
3224 if (!bordername) bordername = "default";
3226 e_client_border_set(ec, bordername);
3230 _e_client_type_match(E_Client *ec, E_Config_Client_Type *m)
3232 if (!ec || !m) return EINA_FALSE;
3233 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
3235 if ((int)ec->netwm.type != m->window_type)
3238 #if defined(__cplusplus) || defined(c_plusplus)
3241 if (!ec->icccm.cpp_class)
3244 if (!e_util_glob_match(ec->icccm.cpp_class, m->clas))
3250 if (!ec->icccm.class)
3253 if (!e_util_glob_match(ec->icccm.class, m->clas))
3260 if (ec->icccm.name && e_util_glob_match(ec->icccm.name, m->name))
3263 if (ec->icccm.title && e_util_glob_match(ec->icccm.title, m->name))
3266 if (ec->netwm.name && e_util_glob_match(ec->netwm.name, m->name))
3274 _e_client_type_get(E_Client *ec)
3276 E_Config_Client_Type *m;
3280 if (!e_config->client_types) return 0;
3282 EINA_LIST_FOREACH(e_config->client_types, l, m)
3284 if (!_e_client_type_match(ec, m)) continue;
3287 type = m->client_type;
3292 ec->client_type = type;
3294 return ec->client_type;
3298 _e_client_transform_sub_apply(E_Client *ec, E_Client *epc, double zoom)
3300 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
3304 int ox = 0, oy = 0, ow, oh;
3308 EINA_SAFETY_ON_FALSE_RETURN(e_comp_wl_subsurface_check(ec));
3310 e_comp_wl_subsurface_position_get(ec, &ox, &oy);
3311 ow = cdata->width_from_viewport;
3312 oh = cdata->height_from_viewport;
3314 map = e_client_map_get(epc);
3315 e_map_point_coord_get(map, 0, &px, &py, 0);
3318 mx = ox * zoom + px;
3319 my = oy * zoom + py;
3323 map = e_map_new_with_direct_render(ec->transform_core.direct_render);
3324 e_map_util_points_populate_from_geometry(map, mx, my, mw, mh, 0);
3325 e_map_util_object_move_sync_set(map, EINA_TRUE);
3326 e_client_map_set(ec, map);
3327 e_client_map_enable_set(ec, EINA_TRUE);
3329 EINA_LIST_FOREACH(cdata->sub.list, l, subc)
3330 _e_client_transform_sub_apply(subc, ec, zoom);
3331 EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
3332 _e_client_transform_sub_apply(subc, ec, zoom);
3338 _e_client_transient_for_group_make(E_Client *ec, Eina_List **list)
3344 if (!e_config->transient.raise) return;
3346 EINA_LIST_FOREACH(ec->transients, l, child)
3348 if (!child) continue;
3349 if (child->iconic) continue;
3350 if (e_client_transient_policy_get(child) == E_TRANSIENT_ABOVE)
3352 *list = eina_list_prepend(*list, child);
3353 _e_client_transient_for_group_make(child, list);
3359 e_client_transient_child_top_get(E_Client *ec, Eina_Bool consider_focus)
3361 E_Client *top_ec = NULL;
3362 Eina_List *transient_list = NULL;
3364 _e_client_transient_for_group_make(ec, &transient_list);
3368 Eina_List *l = NULL;
3369 E_Client *temp_ec = NULL;
3370 E_Client *temp_ec2 = NULL;
3372 E_CLIENT_REVERSE_FOREACH(temp_ec)
3381 EINA_LIST_FOREACH(transient_list, l, temp_ec2)
3383 if (temp_ec == temp_ec2)
3387 if ((temp_ec2->icccm.accepts_focus) ||
3388 (temp_ec2->icccm.take_focus))
3401 eina_list_free(transient_list);
3406 #ifdef EC_IS_NOT_VISIBLE
3407 # undef EC_IS_NOT_VISIBLE
3409 #define EC_IS_NOT_VISIBLE if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED)
3412 e_client_visibility_touched_check(E_Client *ec)
3416 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
3418 tx = wl_fixed_to_int(e_comp->wl_comp_data->ptr.x);
3419 ty = wl_fixed_to_int(e_comp->wl_comp_data->ptr.y);
3421 return _e_client_position_inside_input_rect(ec, tx, ty);
3425 e_client_visibility_change_notify(E_Client *ec)
3427 EINA_SAFETY_ON_NULL_RETURN(ec);
3429 if (ec->visibility.changed)
3430 _e_client_event_simple(ec, E_EVENT_CLIENT_VISIBILITY_CHANGE);
3432 _e_client_hook_call(E_CLIENT_HOOK_EVAL_VISIBILITY, ec);
3436 e_client_visibility_end_notify(void)
3438 // FIXME: This hook means that the visiblitiy calculation of a zone is done
3439 // at this idle handler.This is a hook for a zone, not for a client.
3440 // Therefore, this hook may be defined as a zone hook,
3441 // ex) E_ZONE_HOOK_EVAL_VISIBILITY_END or E_ZONE_HOOK_EVAL_VISIBILITY_DONE.
3442 _e_client_hook_call(E_CLIENT_HOOK_EVAL_VISIBILITY_END, NULL);
3445 #ifdef REFACTOR_FOCUS_POLICY
3448 _e_client_merge_focus_stack_with_defer_focus(void)
3450 Eina_List *l = NULL;
3451 E_Client *ec = NULL, *defer_ec = NULL;
3452 Eina_Bool find_rel = EINA_FALSE;
3453 Eina_Bool inserted = EINA_FALSE;
3455 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
3459 focus_stack = eina_list_merge(focus_stack, defer_focus_stack);
3463 E_CLIENT_FOREACH(defer_ec)
3465 if (!eina_list_data_find(defer_focus_stack, defer_ec)) continue;
3467 find_rel = EINA_FALSE;
3468 inserted = EINA_FALSE;
3469 focus_stack = eina_list_remove(focus_stack, defer_ec);
3471 EINA_LIST_FOREACH(focus_stack, l, ec)
3473 if (ec == NULL) continue;
3478 find_rel = EINA_TRUE;
3482 if (ec->layer > defer_ec->layer) continue;
3484 focus_stack = eina_list_prepend_relative_list(focus_stack, defer_ec, l);
3485 inserted = EINA_TRUE;
3490 focus_stack = eina_list_append(focus_stack, defer_ec);
3494 defer_focus_stack = eina_list_free(defer_focus_stack);
3499 _e_client_candidate_focus(E_Zone *zone, E_Client *reverted_focus_ec)
3502 E_Client *defered_focus_ec = NULL;
3503 Eina_List *child_list = NULL;
3504 Eina_List *l = NULL;
3505 Eina_Bool child_deferred;
3508 E_CLIENT_REVERSE_FOREACH(ec)
3510 if (!eina_list_data_find(defer_focus_stack, ec)) continue;
3512 if (e_object_is_del(E_OBJECT(ec))) continue;
3513 if (e_client_util_ignored_get(ec)) continue;
3514 if (!e_zone_has_ec(zone, ec)) continue;
3515 desk = e_desk_current_get(zone);
3516 if (!desk) continue;
3517 if (!e_desk_has_ec(desk, ec)) continue;
3519 if (!(ec->icccm.accepts_focus || ec->icccm.take_focus)) continue;
3520 if (ec->lock_focus_in || ec->lock_focus_out) continue;
3521 if (!evas_object_visible_get(ec->frame)) continue;
3522 if (ec->iconic) continue;
3523 if (ec->bg_state) continue;
3525 if (!(cec = e_client_check_obscured_by_children_group(ec)) ||
3526 e_client_check_really_iconified(cec))
3528 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) continue;
3529 if (e_client_check_fully_contain_by_above(ec, EINA_FALSE)) continue;
3532 if (focused && (focused->layer > ec->layer)) continue;
3533 else if (!focused && reverted_focus_ec && (reverted_focus_ec->layer > ec->layer)) continue;
3535 // check transient_for child defered
3536 child_deferred = EINA_FALSE;
3537 child_list = eina_list_clone(ec->transients);
3538 EINA_LIST_FOREACH(child_list, l, cec)
3540 if (e_client_transient_policy_get(cec) == E_TRANSIENT_BELOW) continue;
3541 if (!(cec->icccm.accepts_focus || cec->icccm.take_focus)) continue;
3542 if (eina_list_data_find(defer_focus_stack, cec))
3544 child_deferred = EINA_TRUE;
3548 eina_list_free(child_list);
3549 if (child_deferred) continue;
3551 defered_focus_ec = ec;
3554 return defered_focus_ec;
3558 e_client_focus_calculate(E_Zone *zone)
3560 E_Client *defered_focus_ec = NULL, *reverted_focus_ec = NULL;
3561 E_Client *ec = NULL, *old_focused = NULL;
3563 EINA_SAFETY_ON_NULL_RETURN(zone);
3564 if (!e_zone_is_displaying(zone)) return;
3566 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
3568 ec = _e_client_focus_topmost_focusable_get();
3572 if (!ec) ELOGF("FOCUS", "focus unset | No focusable ec", focused);
3573 e_client_frame_focus_set(focused, EINA_FALSE);
3577 ELOGF("FOCUS", "focus set | topmost focus calculate", ec);
3578 e_client_frame_focus_set(ec, EINA_TRUE);
3585 (focused != eina_list_data_get(focus_stack)) ||
3586 (!_e_client_focus_can_take(focused)))
3588 reverted_focus_ec = _e_client_revert_focus_get(focused);
3589 if (!reverted_focus_ec && focused)
3591 e_client_focus_defer_unset(focused);
3592 old_focused = focused;
3596 defered_focus_ec = _e_client_candidate_focus(zone, reverted_focus_ec);
3598 if (defered_focus_ec)
3600 if (defered_focus_ec != focused)
3602 ELOGF("FOCUS", "focus set | focus calculate (defer_focus)", defered_focus_ec);
3604 e_client_focus_defer_unset(focused);
3605 e_client_frame_focus_set(defered_focus_ec, EINA_TRUE);
3608 e_client_focus_defer_unset(defered_focus_ec);
3610 _e_client_merge_focus_stack_with_defer_focus();
3612 else if(reverted_focus_ec)
3614 if (reverted_focus_ec != focused)
3616 ELOGF("FOCUS", "focus set | focus calculate (revert_focus)", reverted_focus_ec);
3618 e_client_focus_defer_unset(focused);
3619 e_client_frame_focus_set(reverted_focus_ec, EINA_TRUE);
3622 else if (old_focused)
3624 ELOGF("FOCUS", "focus unset | focus calculate", old_focused);
3625 e_client_frame_focus_set(old_focused, EINA_FALSE);
3633 _e_client_transform_core_check_change(E_Client *ec)
3637 Eina_Bool check = EINA_FALSE;
3638 if (!ec) return EINA_FALSE;
3641 evas_object_geometry_get(ec->frame, 0, 0, &w, &h);
3643 // check client position or size change
3644 if (ec->x != ec->transform_core.backup.client_x ||
3645 ec->y != ec->transform_core.backup.client_y ||
3646 ec->w != ec->transform_core.backup.client_w ||
3647 ec->h != ec->transform_core.backup.client_h ||
3648 w != ec->transform_core.backup.frame_w ||
3649 h != ec->transform_core.backup.frame_h ||
3650 ec->argb != ec->transform_core.backup.argb)
3653 ec->transform_core.backup.client_x = ec->x;
3654 ec->transform_core.backup.client_y = ec->y;
3655 ec->transform_core.backup.client_w = ec->w;
3656 ec->transform_core.backup.client_h = ec->h;
3657 ec->transform_core.backup.frame_w = w;
3658 ec->transform_core.backup.frame_h = h;
3659 ec->transform_core.backup.argb = ec->argb;
3662 // check new transform or del transform
3663 if (ec->transform_core.changed)
3666 ec->transform_core.changed = EINA_FALSE;
3669 // check each transform change
3670 if (ec->transform_core.transform_list)
3674 E_Util_Transform *transform;
3676 EINA_LIST_FOREACH_SAFE(ec->transform_core.transform_list, l, l_next, transform)
3678 // del transform check
3679 if (e_util_transform_ref_count_get(transform) <= 1)
3681 ec->transform_core.transform_list = eina_list_remove(ec->transform_core.transform_list, transform);
3682 e_util_transform_unref(transform);
3687 // transform change test
3688 if (e_util_transform_change_get(transform))
3691 e_util_transform_change_unset(transform);
3696 if (e_comp_wl_subsurface_check(ec))
3698 // check parent matrix change
3699 E_Client *parent = e_comp_wl_subsurface_parent_get(ec);
3700 if (parent && parent->transform_core.result.enable)
3702 ec->transform_core.parent.enable = EINA_TRUE;
3704 if (!e_util_transform_matrix_equal_check(&ec->transform_core.parent.matrix,
3705 &parent->transform_core.result.matrix))
3708 ec->transform_core.parent.matrix = parent->transform_core.result.matrix;
3710 if (memcmp(&ec->transform_core.parent.zoom, &parent->transform_core.result.transform.zoom, sizeof(E_Util_Transform_Zoom)) != 0)
3713 ec->transform_core.parent.zoom = parent->transform_core.result.transform.zoom;
3716 else if (ec->transform_core.parent.enable)
3718 ec->transform_core.parent.enable = EINA_FALSE;
3719 e_util_transform_matrix_load_identity(&ec->transform_core.parent.matrix);
3720 ec->transform_core.parent.zoom.zoom_x = 1.0;
3721 ec->transform_core.parent.zoom.zoom_y = 1.0;
3722 ec->transform_core.parent.zoom.cx = 0;
3723 ec->transform_core.parent.zoom.cy = 0;
3732 _e_client_transform_core_boundary_update(E_Client *ec, E_Util_Transform_Rect_Vertex *vertices)
3734 int minx = 99999, miny = 99999;
3735 int maxx = -99999, maxy = -99999;
3740 if (!ec->frame) return;
3741 if (!ec->transform_core.result.enable) return;
3742 if (!vertices) return;
3744 for (i = 0; i < 4; ++i)
3749 e_util_transform_vertices_pos_round_get(vertices, i, &x, &y, 0, 0);
3751 if (x < minx) minx = x;
3752 if (y < miny) miny = y;
3753 if (x > maxx) maxx = x;
3754 if (y > maxy) maxy = y;
3757 ec->transform_core.result.boundary.x = minx;
3758 ec->transform_core.result.boundary.y = miny;
3759 ec->transform_core.result.boundary.w = maxx - minx;
3760 ec->transform_core.result.boundary.h = maxy - miny;
3762 ELOGF("COMP", "[Transform][boundary][%d %d %d %d]",
3764 ec->transform_core.result.boundary.x,
3765 ec->transform_core.result.boundary.y,
3766 ec->transform_core.result.boundary.w,
3767 ec->transform_core.result.boundary.h);
3771 _e_client_transform_core_map_new(Evas_Object *obj,
3772 E_Util_Transform_Rect_Vertex *vertices,
3773 E_Util_Transform *transform,
3774 Eina_Bool direct_render)
3781 map = e_map_new_with_direct_render(direct_render);
3782 EINA_SAFETY_ON_NULL_RETURN_VAL(map, NULL);
3784 e_map_util_points_populate_from_object_full(map, obj, 0);
3785 e_map_util_points_color_set(map, 255, 255, 255, 255);
3787 for (i = 0 ; i < 4 ; ++i)
3792 e_util_transform_vertices_pos_round_get(vertices, i, &x, &y, 0, 0);
3793 e_map_point_coord_set(map, i, x, y, 1.0);
3795 if (transform && e_util_transform_texcoord_flag_get(transform))
3800 e_util_transform_texcoord_get(transform, i, &u, &v);
3801 e_map_point_image_uv_set(map, i, u, v);
3809 _e_client_transform_core_vertices_apply_with_zoom(E_Client *ec,
3811 E_Util_Transform_Rect_Vertex *vertices,
3812 E_Util_Transform *transform,
3813 E_Util_Transform_Zoom zoom)
3821 map = _e_client_transform_core_map_new(obj, vertices, transform,
3822 ec->transform_core.direct_render);
3823 EINA_SAFETY_ON_NULL_RETURN(map);
3825 e_map_util_zoom(map, zoom.zoom_x, zoom.zoom_y, zoom.cx, zoom.cy);
3827 e_comp_object_map_set(obj, map);
3828 e_comp_object_map_enable_set(obj, EINA_TRUE);
3833 evas_object_map_enable_set(obj, EINA_FALSE);
3837 _e_client_transform_core_vertices_apply(E_Client *ec,
3839 E_Util_Transform_Rect_Vertex *vertices,
3840 E_Util_Transform *transform)
3848 map = _e_client_transform_core_map_new(obj, vertices, transform,
3849 ec->transform_core.direct_render);
3850 EINA_SAFETY_ON_NULL_RETURN(map);
3852 e_comp_object_map_set(obj, map);
3853 e_comp_object_map_enable_set(obj, EINA_TRUE);
3858 evas_object_map_enable_set(obj, EINA_FALSE);
3862 _e_client_transform_core_sub_update(E_Client *ec, E_Util_Transform_Rect_Vertex *vertices)
3866 E_Comp_Wl_Client_Data *cdata;
3870 cdata = e_client_cdata_get(ec);
3873 EINA_LIST_FOREACH(cdata->sub.list, l, subc)
3874 e_client_transform_core_update(subc);
3876 EINA_LIST_FOREACH(cdata->sub.below_list, l, subc)
3877 e_client_transform_core_update(subc);
3881 _e_client_cb_hook_shell_surface_ready(void *data EINA_UNUSED, E_Client *ec)
3883 if (EINA_UNLIKELY(!ec))
3886 _e_client_aux_hint_eval(ec);
3889 // FIXME: This function has to be deleted and it remains for the backward compatibility.
3890 // Please find and fix to use e_comp_visibility_calculation_set(EINA_TRUE)
3891 // instead of e_client_visibility_calculate() call at e20 modules.
3893 e_client_visibility_calculate(void)
3895 e_comp_visibility_calculation_set(EINA_TRUE);
3899 e_client_visibility_skip_set(E_Client *ec, Eina_Bool skip)
3903 ELOGF("POL_VIS", "visibility skip set to %d", ec, skip);
3904 ec->visibility.skip = skip;
3908 e_client_post_raise_lower_set(E_Client *ec, Eina_Bool raise_set, Eina_Bool lower_set)
3912 ec->post_raise = raise_set;
3913 ec->post_lower = lower_set;
3917 e_client_first_mapped_get(E_Client *ec)
3919 if (!ec) return EINA_FALSE;
3921 return ec->first_mapped;
3924 EINTERN Eina_Bool e_client_mapped_get(E_Client *ec)
3926 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
3927 EINA_SAFETY_ON_NULL_RETURN_VAL(cdata, EINA_FALSE);
3929 return cdata->mapped;
3933 e_client_mapped_set(E_Client *ec, Eina_Bool set)
3935 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
3936 EINA_SAFETY_ON_NULL_RETURN(cdata);
3938 cdata->mapped = set;
3942 ////////////////////////////////////////////////
3944 e_client_clients_hash_exist()
3948 for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++)
3950 if (eina_hash_population(clients_hash[pix_id]))
3958 e_client_idler_before(Eina_Bool *check_focus)
3963 *check_focus = EINA_FALSE;
3965 if (!e_client_clients_hash_exist()) return;
3967 TRACE_DS_BEGIN(CLIENT:IDLE BEFORE);
3969 EINA_LIST_FOREACH(e_comp->clients, l, ec)
3973 // pass 1 - eval0. fetch properties on new or on change and
3974 // call hooks to decide what to do - maybe move/resize
3975 if (ec->ignored || (!ec->changed)) continue;
3977 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_FETCH, ec)) continue;
3978 /* FETCH is hooked by the compositor to get client hints */
3979 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_FETCH, ec)) continue;
3983 client_type = ec->client_type;
3984 if (client_type != _e_client_type_get(ec))
3985 _e_client_event_property(ec, E_CLIENT_PROPERTY_CLIENT_TYPE);
3988 /* PRE_POST_FETCH calls e_remember apply for new client */
3989 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_POST_FETCH, ec)) continue;
3990 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_FETCH, ec)) continue;
3991 if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_FRAME_ASSIGN, ec)) continue;
3993 _e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_FRAME_ASSIGN, ec);
3995 // pass 2 - show and hide windows needing hide and eval (main eval)
3996 E_CLIENT_FOREACH(ec)
3998 if (e_object_is_del(E_OBJECT(ec))) continue;
4001 // ignored client but needing eval (aux hint) such as remote surfaces
4004 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
4005 if (cdata && cdata->first_commit)
4006 _e_client_aux_hint_eval(ec);
4011 if (ec->changes.visible)
4015 if ((!ec->new_client) &&
4016 (!ec->changes.pos) &&
4017 (!ec->changes.size))
4019 evas_object_show(ec->frame);
4020 ec->changes.visible = !evas_object_visible_get(ec->frame);
4025 evas_object_hide(ec->frame);
4026 ec->changes.visible = 0;
4033 e_comp_visibility_calculation_set(EINA_TRUE);
4034 if (ec->changes.accepts_focus)
4035 *check_focus = EINA_TRUE;
4036 ec->changes.accepts_focus = 0;
4039 if ((ec->changes.visible) && (ec->visible) && (!ec->changed))
4041 evas_object_show(ec->frame);
4042 ec->changes.visible = !evas_object_visible_get(ec->frame);
4043 ec->changed = ec->changes.visible;
4044 e_comp_visibility_calculation_set(EINA_TRUE);
4056 for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++)
4057 clients_hash[pix_id] = eina_hash_pointer_new(NULL);
4059 E_COMP_WL_HOOK_APPEND(hooks, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_client_cb_hook_shell_surface_ready, NULL);
4061 #ifdef REFACTOR_FOCUS_POLICY
4063 g_mutex_init(&focused_ec_mutex);
4066 E_EVENT_CLIENT_ADD = ecore_event_type_new();
4067 E_EVENT_CLIENT_REMOVE = ecore_event_type_new();
4068 E_EVENT_CLIENT_DESK_SET = ecore_event_type_new();
4069 E_EVENT_CLIENT_ZONE_SET = ecore_event_type_new();
4070 E_EVENT_CLIENT_RESIZE = ecore_event_type_new();
4071 E_EVENT_CLIENT_MOVE = ecore_event_type_new();
4072 E_EVENT_CLIENT_SHOW = ecore_event_type_new();
4073 E_EVENT_CLIENT_HIDE = ecore_event_type_new();
4074 E_EVENT_CLIENT_ICONIFY = ecore_event_type_new();
4075 E_EVENT_CLIENT_UNICONIFY = ecore_event_type_new();
4076 E_EVENT_CLIENT_STACK = ecore_event_type_new();
4077 E_EVENT_CLIENT_FOCUS_IN = ecore_event_type_new();
4078 E_EVENT_CLIENT_FOCUS_OUT = ecore_event_type_new();
4079 E_EVENT_CLIENT_PROPERTY = ecore_event_type_new();
4080 E_EVENT_CLIENT_FULLSCREEN = ecore_event_type_new();
4081 E_EVENT_CLIENT_UNFULLSCREEN = ecore_event_type_new();
4082 #ifdef _F_ZONE_WINDOW_ROTATION_
4083 E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN = ecore_event_type_new();
4084 E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL = ecore_event_type_new();
4085 E_EVENT_CLIENT_ROTATION_CHANGE_END = ecore_event_type_new();
4086 E_EVENT_CLIENT_ROTATION_GEOMETRY_SET = ecore_event_type_new();
4088 E_EVENT_CLIENT_VISIBILITY_CHANGE = ecore_event_type_new();
4089 E_EVENT_CLIENT_BUFFER_CHANGE = ecore_event_type_new();
4090 E_EVENT_CLIENT_FOCUS_SKIP_SET = ecore_event_type_new();;
4091 E_EVENT_CLIENT_FOCUS_SKIP_UNSET = ecore_event_type_new();;
4093 return (!!clients_hash[1]);
4097 e_client_shutdown(void)
4100 for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++)
4101 E_FREE_FUNC(clients_hash[pix_id], eina_hash_free);
4103 E_FREE_LIST(hooks, e_comp_wl_hook_del);
4104 E_FREE_LIST(handlers, ecore_event_handler_del);
4106 #ifdef REFACTOR_FOCUS_POLICY
4108 g_mutex_clear(&focused_ec_mutex);
4113 e_client_unignore(E_Client *ec)
4116 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4117 if (!ec->ignored) return;
4120 _e_client_event_add(ec);
4124 e_client_new(E_Pixmap *cp, int first_map, int internal)
4129 type = e_pixmap_type_get(cp);
4130 if (type >= E_PIXMAP_TYPE_MAX) return NULL;
4131 if (eina_hash_find(clients_hash[type], &cp)) return NULL;
4133 ec = E_OBJECT_ALLOC(E_Client, E_CLIENT_TYPE, _e_client_free);
4134 if (!ec) return NULL;
4135 e_object_del_func_set(E_OBJECT(ec), E_OBJECT_CLEANUP_FUNC(_e_client_del));
4137 if (!_e_client_private_init(ec))
4139 e_object_del(E_OBJECT(ec));
4143 uuid_generate(ec->uuid);
4145 ec->focus_policy_override = E_FOCUS_LAST;
4146 e_client_size_set(ec, 1, 1);
4147 ec->internal = internal;
4150 e_pixmap_client_set(cp, ec);
4151 ec->resize_mode = E_POINTER_RESIZE_NONE;
4152 ec->layer = E_LAYER_CLIENT_NORMAL;
4153 ec->first_mapped = EINA_FALSE;
4154 ec->post_raise = EINA_TRUE;
4155 ec->post_lower = EINA_FALSE;
4156 ec->animatable = EINA_TRUE;
4158 /* FIXME: if first_map is 1 then we should ignore the first hide event
4159 * or ensure the window is already hidden and events flushed before we
4160 * create a border for it */
4163 ec->changes.pos = 1;
4165 // needed to be 1 for internal windw and on restart.
4166 // ec->ignore_first_unmap = 2;
4168 ec->offer_resistance = 1;
4170 e_comp->new_clients++;
4172 ec->exp_iconify.by_client = 0;
4173 ec->exp_iconify.not_raise = 0;
4174 ec->exp_iconify.skip_iconify = 0;
4175 ec->exp_iconify.skip_by_remote = 0;
4176 if (e_config->deiconify_approve)
4177 ec->exp_iconify.deiconify_update= 1;
4179 ec->exp_iconify.deiconify_update= 0;
4180 if (e_config->use_buffer_flush)
4181 ec->exp_iconify.buffer_flush = 1;
4183 ec->exp_iconify.buffer_flush = 0;
4185 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
4187 if (!_e_client_hook_call(E_CLIENT_HOOK_NEW_CLIENT, ec))
4189 /* delete the above allocated object */
4190 //e_object_del(E_OBJECT(ec));
4194 _e_client_aux_hint_eval(ec);
4196 ec->icccm.title = NULL;
4197 ec->icccm.name = NULL;
4198 #if defined(__cplusplus) || defined(c_plusplus)
4199 ec->icccm.cpp_class = NULL;
4201 ec->icccm.class = NULL;
4203 ec->icccm.icon_name = NULL;
4204 ec->icccm.machine = NULL;
4205 ec->icccm.min_w = 1;
4206 ec->icccm.min_h = 1;
4207 ec->icccm.max_w = 32767;
4208 ec->icccm.max_h = 32767;
4209 ec->icccm.base_w = 0;
4210 ec->icccm.base_h = 0;
4211 ec->icccm.step_w = -1;
4212 ec->icccm.step_h = -1;
4213 ec->icccm.min_aspect = 0.0;
4214 ec->icccm.max_aspect = 0.0;
4217 ec->netwm.name = NULL;
4218 ec->netwm.icon_name = NULL;
4219 ec->netwm.desktop = 0;
4220 ec->netwm.state.modal = 0;
4221 ec->netwm.state.sticky = 0;
4222 ec->netwm.state.shaded = 0;
4223 ec->netwm.state.hidden = 0;
4224 ec->netwm.state.maximized_v = 0;
4225 ec->netwm.state.maximized_h = 0;
4226 ec->netwm.state.skip_taskbar = 0;
4227 ec->netwm.state.skip_pager = 0;
4228 ec->netwm.state.fullscreen = 0;
4229 ec->netwm.state.stacking = E_STACKING_NONE;
4230 ec->netwm.action.move = 0;
4231 ec->netwm.action.resize = 0;
4232 ec->netwm.action.minimize = 0;
4233 ec->netwm.action.shade = 0;
4234 ec->netwm.action.stick = 0;
4235 ec->netwm.action.maximized_h = 0;
4236 ec->netwm.action.maximized_v = 0;
4237 ec->netwm.action.fullscreen = 0;
4238 ec->netwm.action.change_desktop = 0;
4239 ec->netwm.action.close = 0;
4240 ec->netwm.opacity = 255;
4242 ec->visibility.obscured = E_VISIBILITY_UNKNOWN;
4243 ec->visibility.opaque = -1;
4244 ec->visibility.changed = 0;
4245 ec->visibility.skip = 0;
4246 ec->visibility.last_sent_type = E_VISIBILITY_UNKNOWN;
4248 ec->transform.zoom = 1.0;
4249 ec->transform.angle = 0.0;
4250 ec->transform_core.direct_render = EINA_TRUE;
4251 ec->transform_core.activate = EINA_TRUE;
4253 ec->pointer_enter_sent = EINA_FALSE;
4255 ec->acquire_fence_fd = -1;
4259 e_comp->clients = eina_list_append(e_comp->clients, ec);
4260 eina_hash_add(clients_hash[type], &ec->pixmap, ec);
4262 ELOGF("COMP", "CLIENT ADD. cp:%p, argb:%d, internal:%d, ignored:%d", ec, cp, ec->argb, internal, ec->ignored);
4264 _e_client_event_add(ec);
4265 e_comp_object_client_add(ec);
4268 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_client_cb_evas_show, ec);
4269 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_client_cb_evas_hide, ec);
4270 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_client_cb_evas_move, ec);
4271 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESIZE, _e_client_cb_evas_resize, ec);
4272 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESTACK, _e_client_cb_evas_restack, ec);
4273 evas_object_smart_callback_add(ec->frame, "shade_done", _e_client_cb_evas_shade_done, ec);
4275 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
4277 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
4280 #ifdef REFACTOR_ZONE_DESK
4283 _e_client_zone_update(ec);
4285 e_client_desk_set(ec, e_desk_current_get(e_zone_current_get()));
4288 #ifdef _F_E_CLIENT_NEW_CLIENT_POST_HOOK_
4289 _e_client_hook_call(E_CLIENT_HOOK_NEW_CLIENT_POST, ec);
4292 ec->manage_resize.resize_obj = NULL;
4293 ec->manage_resize.x = ec->manage_resize.y = ec->manage_resize.w = ec->manage_resize.h = 0;
4294 ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
4295 ec->manage_resize.aw = ec->manage_resize.ah = 0;
4296 ec->manage_resize.header_h = 0;
4297 ec->manage_resize.footer_h = 0;
4299 ec->visibility.ignore_geometry = e_config->calc_vis_ignore_geometry;
4304 E_API Eina_Bool e_client_is_internal(E_Client *ec)
4306 E_OBJECT_CHECK_RETURN(ec, EINA_TRUE);
4307 return ec->internal;
4310 #ifdef REFACTOR_ZONE_DESK
4313 e_client_desk_set(E_Client *ec, E_Desk *desk)
4315 E_Event_Client_Desk_Set *ev;
4320 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4321 E_OBJECT_CHECK(desk);
4322 E_OBJECT_TYPE_CHECK(desk, E_DESK_TYPE);
4323 if (e_desk_has_ec(desk, ec)) return;
4327 ec->desk->fullscreen_clients = eina_list_remove(ec->desk->fullscreen_clients, ec);
4328 desk->fullscreen_clients = eina_list_append(desk->fullscreen_clients, ec);
4330 old_desk = ec->desk;
4332 e_desk_client_del(old_desk, ec);
4334 e_desk_client_add(desk, ec);
4335 if (!ec->new_client)
4339 e_comp_object_effect_unclip(ec->frame);
4340 e_comp_object_effect_set(ec->frame, NULL);
4342 if (desk->visible || ec->sticky)
4344 if ((!ec->hidden) && (!ec->iconic))
4345 evas_object_show(ec->frame);
4350 evas_object_hide(ec->frame);
4353 e_client_comp_hidden_set(ec, (!desk->visible) && (!ec->sticky));
4354 e_client_zone_set(ec, desk->zone);
4358 ev = E_NEW(E_Event_Client_Desk_Set, 1);
4363 e_object_ref(E_OBJECT(ec));
4364 ev->desk = old_desk;
4365 e_object_ref(E_OBJECT(old_desk));
4366 ecore_event_add(E_EVENT_CLIENT_DESK_SET, ev, (Ecore_End_Cb)_e_client_event_desk_set_free, NULL);
4369 zone = e_comp_zone_find_by_ec(ec);
4370 if (old_desk->zone == zone)
4372 e_client_res_change_geometry_save(ec);
4373 e_client_res_change_geometry_restore(ec);
4374 ec->pre_res_change.valid = 0;
4378 if (e_config->transient.desktop)
4383 EINA_LIST_FOREACH(ec->transients, l, child)
4384 e_client_desk_set(child, ec->desk);
4387 _e_client_hook_call(E_CLIENT_HOOK_DESK_SET, ec);
4388 evas_object_smart_callback_call(ec->frame, "desk_change", ec);
4390 if (ec->desk->desk_area.enable)
4392 if (!ec->desk_area.desk_area)
4395 eda = e_desk_desk_area_base_get(ec->desk);
4396 e_client_desk_area_set(ec, eda);
4399 e_client_desk_area_enable_set(ec, EINA_TRUE);
4405 e_client_desk_iconify_skip_set(E_Client *ec, Eina_Bool skip)
4408 ec->user_skip_winlist = skip;
4412 e_client_desk_iconify_skip_get(E_Client *ec)
4414 if (!ec) return EINA_FALSE;
4415 return ec->user_skip_winlist;
4419 e_client_comp_grabbed_get(void)
4421 return comp_grabbed;
4425 e_client_action_get(void)
4427 return action_client;
4431 //////////////////////////////////////////////////////////
4434 e_client_mouse_in(E_Client *ec, int x, int y)
4438 if (comp_grabbed) return;
4439 if (e_object_is_del(E_OBJECT(ec))) return;
4440 desk = e_comp_desk_find_by_ec(ec);
4441 if (desk && desk->animate_count) return;
4442 ec->mouse.current.mx = x;
4443 ec->mouse.current.my = y;
4446 #ifdef REFACTOR_FOCUS_POLICY
4447 _e_client_hook_call(E_CLIENT_HOOK_MOUSE_IN, ec);
4449 if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
4450 e_focus_event_mouse_in(ec);
4455 e_client_mouse_out(E_Client *ec, int x, int y)
4459 if (comp_grabbed) return;
4460 if (ec->fullscreen) return;
4461 if (e_object_is_del(E_OBJECT(ec))) return;
4462 desk = e_comp_desk_find_by_ec(ec);
4463 if (desk && desk->animate_count) return;
4465 ec->mouse.current.mx = x;
4466 ec->mouse.current.my = y;
4469 #ifdef REFACTOR_FOCUS_POLICY
4470 _e_client_hook_call(E_CLIENT_HOOK_MOUSE_OUT, ec);
4472 if ((!ec->iconic) && (!e_client_util_ignored_get(ec)))
4473 e_focus_event_mouse_out(ec);
4478 e_client_mouse_wheel(E_Client *ec, Evas_Point *output, E_Binding_Event_Wheel *ev)
4480 EINA_SAFETY_ON_NULL_RETURN(ec);
4481 if (action_client) return;
4482 ec->mouse.current.mx = output->x;
4483 ec->mouse.current.my = output->y;
4487 e_client_mouse_down(E_Client *ec, int button, Evas_Point *output, E_Binding_Event_Mouse_Button *ev)
4489 #ifdef REFACTOR_FOCUS_POLICY
4494 EINA_SAFETY_ON_NULL_RETURN(ec);
4495 if (action_client || ec->iconic || e_client_util_ignored_get(ec)) return;
4496 if ((button >= 1) && (button <= 3))
4498 ec->mouse.last_down[button - 1].mx = output->x;
4499 ec->mouse.last_down[button - 1].my = output->y;
4500 ec->mouse.last_down[button - 1].x = ec->x;
4501 ec->mouse.last_down[button - 1].y = ec->y;
4502 ec->mouse.last_down[button - 1].w = ec->w;
4503 ec->mouse.last_down[button - 1].h = ec->h;
4507 ec->moveinfo.down.x = ec->x;
4508 ec->moveinfo.down.y = ec->y;
4509 ec->moveinfo.down.w = ec->w;
4510 ec->moveinfo.down.h = ec->h;
4512 ec->mouse.current.mx = output->x;
4513 ec->mouse.current.my = output->y;
4514 if ((button >= 1) && (button <= 3))
4516 ec->mouse.last_down[button - 1].mx = output->x;
4517 ec->mouse.last_down[button - 1].my = output->y;
4518 ec->mouse.last_down[button - 1].x = ec->x;
4519 ec->mouse.last_down[button - 1].y = ec->y;
4520 ec->mouse.last_down[button - 1].w = ec->w;
4521 ec->mouse.last_down[button - 1].h = ec->h;
4525 ec->moveinfo.down.x = ec->x;
4526 ec->moveinfo.down.y = ec->y;
4527 ec->moveinfo.down.w = ec->w;
4528 ec->moveinfo.down.h = ec->h;
4530 ec->mouse.current.mx = output->x;
4531 ec->mouse.current.my = output->y;
4533 #ifdef REFACTOR_FOCUS_POLICY
4534 _e_client_hook_call(E_CLIENT_HOOK_MOUSE_DOWN, ec);
4536 focused = e_client_focused_get();
4537 if ((focused) && (ec != focused))
4539 e_focus_event_mouse_down(ec);
4545 e_client_mouse_up(E_Client *ec, int button, Evas_Point *output, E_Binding_Event_Mouse_Button* ev)
4547 EINA_SAFETY_ON_NULL_RETURN(ec);
4548 if (ec->iconic || e_client_util_ignored_get(ec)) return;
4549 if ((button >= 1) && (button <= 3))
4551 ec->mouse.last_up[button - 1].mx = output->x;
4552 ec->mouse.last_up[button - 1].my = output->y;
4553 ec->mouse.last_up[button - 1].x = ec->x;
4554 ec->mouse.last_up[button - 1].y = ec->y;
4556 ec->mouse.current.mx = output->x;
4557 ec->mouse.current.my = output->y;
4558 /* also we don't pass the same params that went in - then again that */
4559 /* should be ok as we are just ending the action if it has an end */
4560 if (ec->cur_mouse_action)
4562 if (ec->cur_mouse_action->func.end_mouse)
4563 ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", ev);
4564 else if (ec->cur_mouse_action->func.end)
4565 ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
4566 e_object_unref(E_OBJECT(ec->cur_mouse_action));
4567 ec->cur_mouse_action = NULL;
4570 if ((button >= 1) && (button <= 3))
4572 ec->mouse.last_up[button - 1].mx = output->x;
4573 ec->mouse.last_up[button - 1].my = output->y;
4574 ec->mouse.last_up[button - 1].x = ec->x;
4575 ec->mouse.last_up[button - 1].y = ec->y;
4580 e_client_stay_within_canvas_margin(E_Client *ec)
4587 _e_client_stay_within_canvas_margin(ec, ec->x, ec->y, &new_x, &new_y);
4589 if ((ec->x != new_x) || (ec->y != new_y))
4590 evas_object_move(ec->frame, new_x, new_y);
4595 e_client_mouse_move(E_Client *ec, Evas_Point *output)
4597 EINA_SAFETY_ON_NULL_RETURN(ec);
4598 if (ec->iconic || e_client_util_ignored_get(ec)) return;
4599 ec->mouse.current.mx = output->x;
4600 ec->mouse.current.my = output->y;
4601 if (e_client_util_moving_get(ec))
4603 _e_client_move_handle(ec);
4605 else if (e_client_util_resizing_get(ec))
4607 _e_client_resize_handle(ec);
4610 ///////////////////////////////////////////////////////
4613 e_client_res_change_geometry_save(E_Client *ec)
4616 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4618 if (ec->pre_res_change.valid) return;
4619 ec->pre_res_change.valid = 1;
4620 ec->pre_res_change.x = ec->x;
4621 ec->pre_res_change.y = ec->y;
4622 ec->pre_res_change.w = ec->w;
4623 ec->pre_res_change.h = ec->h;
4624 ec->pre_res_change.saved.x = ec->saved.x;
4625 ec->pre_res_change.saved.y = ec->saved.y;
4626 ec->pre_res_change.saved.w = ec->saved.w;
4627 ec->pre_res_change.saved.h = ec->saved.h;
4631 e_client_res_change_geometry_restore(E_Client *ec)
4637 unsigned char valid : 1;
4646 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4647 if (!ec->pre_res_change.valid) return;
4648 if (ec->new_client) return;
4650 zone = e_comp_zone_find_by_ec(ec);
4653 memcpy(&pre_res_change, &ec->pre_res_change, sizeof(pre_res_change));
4657 e_client_unfullscreen(ec);
4658 e_client_fullscreen(ec, e_config->fullscreen_policy);
4660 else if (ec->maximized != E_MAXIMIZE_NONE)
4664 max = ec->maximized;
4665 e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
4666 e_client_maximize(ec, max);
4670 int x, y, w, h, zx, zy, zw, zh;
4672 ec->saved.x = ec->pre_res_change.saved.x;
4673 ec->saved.y = ec->pre_res_change.saved.y;
4674 ec->saved.w = ec->pre_res_change.saved.w;
4675 ec->saved.h = ec->pre_res_change.saved.h;
4677 e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
4679 if (ec->saved.w > zw)
4681 if ((ec->saved.x + ec->saved.w) > (zx + zw))
4682 ec->saved.x = zx + zw - ec->saved.w;
4684 if (ec->saved.h > zh)
4686 if ((ec->saved.y + ec->saved.h) > (zy + zh))
4687 ec->saved.y = zy + zh - ec->saved.h;
4689 x = ec->pre_res_change.x;
4690 y = ec->pre_res_change.y;
4691 w = ec->pre_res_change.w;
4692 h = ec->pre_res_change.h;
4697 if ((x + w) > (zx + zw))
4699 if ((y + h) > (zy + zh))
4701 evas_object_geometry_set(ec->frame, x, y, w, h);
4703 memcpy(&ec->pre_res_change, &pre_res_change, sizeof(pre_res_change));
4706 #ifdef REFACTOR_ZONE_DESK
4709 e_client_zone_set(E_Client *ec, E_Zone *zone)
4711 E_Event_Client_Zone_Set *ev;
4714 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4715 E_OBJECT_CHECK(zone);
4716 E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
4717 if (e_zone_has_ec(zone, ec)) return;
4719 ev = E_NEW(E_Event_Client_Zone_Set, 1);
4722 /* if the window does not lie in the new zone, move it so that it does */
4723 if (!E_INTERSECTS(ec->x, ec->y, ec->w, ec->h, zone->x, zone->y, zone->w, zone->h))
4727 x = ec->x, y = ec->y;
4729 /* keep window from hanging off bottom and left */
4730 if (x + ec->w > zone->x + zone->w) x += (zone->x + zone->w) - (x + ec->w);
4731 if (y + ec->h > zone->y + zone->h) y += (zone->y + zone->h) - (y + ec->h);
4733 /* make sure to and left are on screen (if the window is larger than the zone, it will hang off the bottom / right) */
4734 if (x < zone->x) x = zone->x;
4735 if (y < zone->y) y = zone->y;
4737 if (!E_INTERSECTS(x, y, ec->w, ec->h, zone->x, zone->y, zone->w, zone->h))
4739 /* still not in zone at all, so just move it to closest edge */
4740 if (x < zone->x) x = zone->x;
4741 if (x >= zone->x + zone->w) x = zone->x + zone->w - ec->w;
4742 if (y < zone->y) y = zone->y;
4743 if (y >= zone->y + zone->h) y = zone->y + zone->h - ec->h;
4745 evas_object_move(ec->frame, x, y);
4748 // TODO: NEED TO DELETE LINE BELOW
4753 e_object_ref(E_OBJECT(ec));
4755 e_object_ref(E_OBJECT(zone));
4757 ecore_event_add(E_EVENT_CLIENT_ZONE_SET, ev, (Ecore_End_Cb)_e_client_event_zone_set_free, NULL);
4759 // TODO: change all use of e_client_zone_set() to e_zone_client_add()
4760 e_zone_client_add(zone, ec);
4765 e_client_pos_set(E_Client *ec, int x, int y)
4773 e_client_pos_get(E_Client *ec, int *x, int *y)
4789 e_client_size_set(E_Client *ec, int w, int h)
4797 e_client_size_get(E_Client *ec, int *w, int *h)
4813 e_client_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
4821 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4823 if (e_client_transform_core_enable_get(ec))
4825 gx = ec->transform_core.result.boundary.x;
4826 gy = ec->transform_core.result.boundary.y;
4827 gw = ec->transform_core.result.boundary.w;
4828 gh = ec->transform_core.result.boundary.h;
4834 evas_object_geometry_get(ec->frame, &gx, &gy, &gw, &gh);
4835 if (gw == 0 && gh == 0)
4837 /* In this case, there is no image buffer in e_comp_object, thus it
4838 * should return geometry value of ec itself. It usually happens if
4839 * new ec is not mapped yet.
4863 e_client_above_get(const E_Client *ec)
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
4869 if (EINA_INLIST_GET(ec)->next) //check current layer
4871 EINA_INLIST_FOREACH(EINA_INLIST_GET(ec)->next, ec2)
4875 ELOGF("FATAL", "CHECK the ec inlist next", ec);
4878 if (!e_object_is_del(E_OBJECT(ec2)))
4882 if (ec->layer == E_LAYER_CLIENT_CURSOR) return NULL;
4883 if (e_comp_canvas_client_layer_map(ec->layer) == 9999) return NULL;
4885 /* go up the layers until we find one */
4886 for (x = e_comp_canvas_layer_map(ec->layer) + 1; x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x++)
4888 if (!e_comp->layers[x].clients) continue;
4889 EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
4893 ELOGF("FATAL", "EC exist above layer. ec layer_map:%d, cur layer_map:%d",
4894 ec, e_comp_canvas_layer_map(ec->layer), x);
4897 if (!e_object_is_del(E_OBJECT(ec2)))
4905 e_client_below_get(const E_Client *ec)
4910 E_Layer ec_layer, ec_layer_cw;
4913 E_OBJECT_CHECK_RETURN(ec, NULL);
4914 E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, NULL);
4916 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
4917 if (EINA_INLIST_GET(ec)->prev) //check current layer
4919 for (l = EINA_INLIST_GET(ec)->prev; l; l = l->prev)
4921 ec2 = EINA_INLIST_CONTAINER_GET(l, E_Client);
4924 ELOGF("FATAL", "CHECK the ec inlist prev", ec);
4927 if (!e_object_is_del(E_OBJECT(ec2)))
4932 // check layer validation
4933 ec_layer = ec->layer;
4934 if (ec->layer_block || ec->layer_pending)
4936 cw_layer = e_comp_object_layer_get(ec->frame);
4939 ec_layer_cw = e_comp_canvas_layer_map_to(cw_layer);
4940 if (ec_layer != ec_layer_cw)
4942 ELOGF("COMP", "LAYER is not same. USE obj layer! (ec->layer:%d, obj:%d). block:%d, pending:%d)", ec, ec_layer, ec_layer_cw, ec->layer_block, ec->layer_pending);
4943 ec_layer = ec_layer_cw;
4948 if (ec_layer == E_LAYER_CLIENT_DESKTOP) return NULL;
4949 if (e_comp_canvas_client_layer_map(ec_layer) == 9999) return NULL;
4951 /* go down the layers until we find one */
4952 x = e_comp_canvas_layer_map(ec_layer);
4955 for (; x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
4957 if (!e_comp->layers[x].clients) continue;
4958 EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
4962 ELOGF("FATAL", "EC exist below layer. ec layer_map:%d, cur layer_map:%d",
4963 ec, e_comp_canvas_layer_map(ec_layer), x);
4966 if (!e_object_is_del(E_OBJECT(ec2)))
4974 e_client_bottom_get(void)
4977 for (x = e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x++)
4981 if (!e_comp->layers[x].clients) continue;
4982 EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
4983 if (!e_object_is_del(E_OBJECT(ec2)))
4990 e_client_top_get(void)
4993 for (x = e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
4997 if (!e_comp->layers[x].clients) continue;
4998 EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
4999 if (!e_object_is_del(E_OBJECT(ec2)))
5005 EINTERN unsigned int
5006 e_clients_count(void)
5008 return eina_list_count(e_comp->clients);
5013 * Set a callback which will be called just prior to updating the
5014 * move coordinates for a border
5017 e_client_move_intercept_cb_set(E_Client *ec, E_Client_Move_Intercept_Cb cb)
5019 ec->move_intercept_cb = cb;
5022 ///////////////////////////////////////
5024 E_API E_Client_Hook *
5025 e_client_hook_add(E_Client_Hook_Point hookpoint, E_Client_Hook_Cb func, const void *data)
5029 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_CLIENT_HOOK_LAST, NULL);
5030 ch = E_NEW(E_Client_Hook, 1);
5031 if (!ch) return NULL;
5032 ch->hookpoint = hookpoint;
5034 ch->data = (void*)data;
5035 _e_client_hooks[hookpoint] = eina_inlist_append(_e_client_hooks[hookpoint], EINA_INLIST_GET(ch));
5040 e_client_hook_del(E_Client_Hook *ch)
5043 if (_e_client_hooks_walking == 0)
5045 _e_client_hooks[ch->hookpoint] = eina_inlist_remove(_e_client_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
5049 _e_client_hooks_delete++;
5052 ///////////////////////////////////////
5054 E_API E_Client_Intercept_Hook *
5055 e_client_intercept_hook_add(E_Client_Intercept_Hook_Point hookpoint, E_Client_Intercept_Hook_Cb func, const void *data)
5057 E_Client_Intercept_Hook *ch;
5059 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_CLIENT_INTERCEPT_HOOK_LAST, NULL);
5060 ch = E_NEW(E_Client_Intercept_Hook, 1);
5061 if (!ch) return NULL;
5062 ch->hookpoint = hookpoint;
5064 ch->data = (void*)data;
5065 _e_client_intercept_hooks[hookpoint] = eina_inlist_append(_e_client_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
5070 e_client_intercept_hook_del(E_Client_Intercept_Hook *ch)
5075 if (_e_client_intercept_hooks_walking == 0)
5077 _e_client_intercept_hooks[ch->hookpoint] =
5078 eina_inlist_remove(_e_client_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
5082 _e_client_intercept_hooks_delete++;
5085 #ifdef REFACTOR_FOCUS_POLICY
5088 e_client_focus_stack_lower(E_Client *ec)
5090 Eina_List *l = NULL;
5091 E_Client *ec2 = NULL;
5093 EINA_SAFETY_ON_NULL_RETURN(ec);
5095 focus_stack = eina_list_remove(focus_stack, ec);
5097 EINA_LIST_REVERSE_FOREACH(focus_stack, l, ec2)
5099 if (ec2 == NULL) continue;
5100 if (ec2->layer < ec->layer) continue;
5102 focus_stack = eina_list_append_relative_list(focus_stack, ec, l);
5106 focus_stack = eina_list_prepend(focus_stack, ec);
5112 e_client_focus_latest_set(E_Client *ec)
5114 EINA_SAFETY_ON_NULL_RETURN(ec);
5116 #ifdef REFACTOR_FOCUS_POLICY
5117 _e_client_hook_call(E_CLIENT_HOOK_FOCUS_LATEST_SET, ec);
5119 focus_stack = eina_list_remove(focus_stack, ec);
5120 focus_stack = eina_list_prepend(focus_stack, ec);
5124 #ifdef REFACTOR_FOCUS_POLICY
5127 e_client_focus_stack_append_current_focused(E_Client *ec)
5129 Eina_List *l = NULL;
5130 E_Client *temp_ec = NULL;
5132 if (!ec) CRI("ACK");
5134 focus_stack = eina_list_remove(focus_stack, ec);
5136 EINA_LIST_FOREACH(focus_stack, l, temp_ec)
5138 if (temp_ec != focused) continue;
5140 focus_stack = eina_list_append_relative_list(focus_stack, ec, l);
5144 focus_stack = eina_list_prepend(focus_stack, ec);
5150 e_client_focus_defer_set(E_Client *ec)
5152 EINA_SAFETY_ON_NULL_RETURN(ec);
5153 #ifdef REFACTOR_FOCUS_POLICY
5154 _e_client_hook_call(E_CLIENT_HOOK_FOCUS_DEFER_SET, ec);
5156 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
5158 ELOGF("FOCUS", "focus defer set", ec);
5160 defer_focus_stack = eina_list_remove(defer_focus_stack, ec);
5161 defer_focus_stack = eina_list_prepend(defer_focus_stack, ec);
5165 #ifdef REFACTOR_FOCUS_POLICY
5168 e_client_focus_defer_unset(E_Client *ec)
5170 EINA_SAFETY_ON_NULL_RETURN(ec);
5171 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
5173 ELOGF("FOCUS", "focus defer unset", ec);
5175 defer_focus_stack = eina_list_remove(defer_focus_stack, ec);
5179 e_client_focus_defer_clear(void)
5181 if (!defer_focus_stack) return;
5183 ELOGF("FOCUS", "focus defer clear", NULL);
5185 defer_focus_stack = eina_list_free(defer_focus_stack);
5189 e_client_refocus(void)
5195 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
5197 EINA_LIST_FOREACH(e_client_focus_stack_get(), l, ec)
5199 desk = e_comp_desk_find_by_ec(ec);
5200 if (!desk) continue;
5201 if (desk->visible && (!ec->iconic))
5203 g_mutex_lock(&e_comp->input_key_grabs_mutex);
5204 if (e_comp->input_key_grabs || e_comp->input_mouse_grabs)
5206 g_mutex_unlock(&e_comp->input_key_grabs_mutex);
5209 g_mutex_unlock(&e_comp->input_key_grabs_mutex);
5210 ELOGF("FOCUS", "focus set | refocus", ec);
5211 e_client_frame_focus_set(ec, EINA_TRUE);
5219 * Sets the focus to the given client if necessary
5220 * There are 3 cases of different focus_policy-configurations:
5222 * - E_FOCUS_CLICK: just set the focus, the most simple one
5224 * - E_FOCUS_MOUSE: focus is where the mouse is, so try to
5225 * warp the pointer to the window. If this fails (because
5226 * the pointer is already in the window), just set the focus.
5228 * - E_FOCUS_SLOPPY: focus is where the mouse is or on the
5229 * last window which was focused, if the mouse is on the
5230 * desktop. So, we need to look if there is another window
5231 * under the pointer and warp to pointer to the right
5232 * one if so (also, we set the focus afterwards). In case
5233 * there is no window under pointer, the pointer is on the
5234 * desktop and so we just set the focus.
5237 * This function is to be called when setting the focus was not
5238 * explicitly triggered by the user (by moving the mouse or
5239 * clicking for example), but implicitly (by closing a window,
5240 * the last focused window should get focus).
5244 e_client_focus_set_with_pointer(E_Client *ec)
5247 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5248 /* note: this is here as it seems there are enough apps that do not even
5249 * expect us to emulate a look of focus but not actually set x input
5250 * focus as we do - so simply abort any focuse set on such windows */
5251 /* be strict about accepting focus hint */
5252 if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK) return;
5254 if ((!ec->icccm.accepts_focus) &&
5255 (!ec->icccm.take_focus)) return;
5256 if (ec->lock_focus_out) return;
5257 if (ec == focused) return;
5259 TRACE_DS_BEGIN(CLIENT:FOCUS SET WITH POINTER);
5260 ELOGF("FOCUS", "focus set | focus with pointer", ec);
5261 e_client_frame_focus_set(ec, EINA_TRUE);
5263 if (e_config->focus_policy == E_FOCUS_CLICK)
5279 e_client_focused_set(E_Client *ec)
5281 #ifdef REFACTOR_FOCUS_POLICY
5282 E_Client *focused_ec;
5286 ELOGF("FOCUS", "CLIENT FOCUSED_SET : SET", ec);
5288 ELOGF("FOCUS", "CLIENT FOCUSED_SET : UNSET", NULL);
5290 focused_ec = e_comp_focused_ec_get();
5291 if (ec == focused_ec) return;
5293 TRACE_DS_BEGIN(CLIENT:FOCUSED SET);
5295 // unset the current focused_ec if focused_ec is not being deleted
5298 if (!e_object_is_del(E_OBJECT(focused_ec)))
5300 _e_client_hook_call(E_CLIENT_HOOK_FOCUS_UNSET, focused_ec);
5302 if (e_object_ref_get(E_OBJECT(focused_ec)) > 0)
5304 _e_client_event_simple(focused_ec, E_EVENT_CLIENT_FOCUS_OUT);
5305 e_client_urgent_set(focused_ec, focused_ec->icccm.urgent);
5310 // clear the current focused_ec when ec is NULL
5313 zone = e_comp_zone_find_by_ec(focused_ec);
5314 e_zone_focus_clear(zone);
5319 // set the new current focused_ec
5320 _e_client_hook_call(E_CLIENT_HOOK_FOCUS_SET, ec);
5322 // send the client_focuse_in event
5323 _e_client_event_simple(ec, E_EVENT_CLIENT_FOCUS_IN);
5325 #ifdef REFACTOR_ZONE_DESK
5327 // TODO: This is not for focus, but for Window Placement policy.
5328 // Move this code to the better place.
5329 if (ec->sticky && ec->desk && (!ec->desk->visible))
5330 e_client_desk_set(ec, e_desk_current_get(zone));
5335 E_Client *ec2, *ec_unfocus = focused;
5339 if (ec == focused) return;
5341 TRACE_DS_BEGIN(CLIENT:FOCUSED SET);
5343 ELOGF("FOCUS", "CLIENT FOCUS_SET", ec);
5345 g_mutex_lock(&focused_ec_mutex);
5347 g_mutex_unlock(&focused_ec_mutex);
5349 zone = e_comp_zone_find_by_ec(ec);
5353 e_client_urgent_set(ec, 0);
5354 int x, total = zone->desk_x_count * zone->desk_y_count;
5356 for (x = 0; x < total; x++)
5358 E_Desk *desk = zone->desks[x];
5359 /* if there's any fullscreen non-parents on this desk, unfullscreen them */
5360 EINA_LIST_FOREACH_SAFE(desk->fullscreen_clients, l, ll, ec2)
5362 if (ec2 == ec) continue;
5363 if (e_object_is_del(E_OBJECT(ec2))) continue;
5364 /* but only if it's the same desk or one of the clients is sticky */
5365 if ((e_desk_has_ec(desk, ec)) || (ec->sticky || ec2->sticky))
5367 if (!eina_list_data_find(ec->transients, ec2))
5368 e_client_unfullscreen(ec2);
5374 while ((ec_unfocus) && (ec_unfocus->zone))
5376 ec_unfocus->want_focus = ec_unfocus->focused = 0;
5377 if (ec_unfocus->mouse.in && ec && (!e_client_util_is_popup(ec)) &&
5378 (e_config->focus_policy != E_FOCUS_CLICK))
5379 e_client_mouse_out(ec_unfocus, ec_unfocus->x - 1, ec_unfocus->y - 1);
5381 /* if there unfocus client is fullscreen and visible */
5382 if ((ec_unfocus->fullscreen) && (!ec_unfocus->iconic) && (!ec_unfocus->hidden) &&
5383 (ec_unfocus->zone == e_zone_current_get()) &&
5384 ((ec_unfocus->desk == e_desk_current_get(ec_unfocus->zone)) || (ec_unfocus->sticky)))
5386 Eina_Bool have_vis_child = EINA_FALSE;
5388 /* if any of its children are visible */
5389 EINA_LIST_FOREACH(ec_unfocus->transients, l, ec2)
5391 if ((ec2->zone == ec_unfocus->zone) &&
5392 ((ec2->desk == ec_unfocus->desk) ||
5393 (ec2->sticky) || (ec_unfocus->sticky)))
5395 have_vis_child = EINA_TRUE;
5399 /* if no children are visible, unfullscreen */
5400 if ((!e_object_is_del(E_OBJECT(ec_unfocus))) && (!have_vis_child))
5401 e_client_unfullscreen(ec_unfocus);
5404 if (!e_object_is_del(E_OBJECT(ec_unfocus)))
5405 _e_client_hook_call(E_CLIENT_HOOK_FOCUS_UNSET, ec_unfocus);
5406 /* only send event here if we're not being deleted */
5407 if ((!e_object_is_del(E_OBJECT(ec_unfocus))) &&
5408 (e_object_ref_get(E_OBJECT(ec_unfocus)) > 0))
5410 _e_client_event_simple(ec_unfocus, E_EVENT_CLIENT_FOCUS_OUT);
5411 e_client_urgent_set(ec_unfocus, ec_unfocus->icccm.urgent);
5414 e_client_focus_defer_unset(ec_unfocus);
5423 _e_client_hook_call(E_CLIENT_HOOK_FOCUS_SET, ec);
5425 e_client_focus_latest_set(ec);
5427 _e_client_event_simple(ec, E_EVENT_CLIENT_FOCUS_IN);
5429 #ifdef REFACTOR_ZONE_DESK
5431 if (ec->sticky && ec->desk && (!ec->desk->visible))
5432 e_client_desk_set(ec, e_desk_current_get(zone));
5440 e_client_activate(E_Client *ec)
5443 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5445 TRACE_DS_BEGIN(CLIENT:ACTIVATE);
5447 ELOGF("COMP", "Set launching flag..", ec);
5448 ec->launching = EINA_TRUE;
5450 ec->exp_iconify.not_raise = 0;
5454 if (!ec->lock_user_iconify)
5455 e_client_uniconify(ec);
5457 ELOGF("COMP", "Un-Set ICONIFY BY CLIENT", ec);
5458 ec->exp_iconify.by_client = 0;
5459 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
5461 #ifdef REFACTOR_ZONE_DESK
5463 if ((!ec->iconic) && (!ec->sticky))
5465 e_desk_show(ec->desk);
5467 if (!ec->lock_user_stacking)
5469 if (ec->shaded || ec->shading)
5470 e_client_unshade(ec, ec->shade_dir);
5473 #ifdef REFACTOR_FOCUS_POLICY
5474 // This code will be executed at E_CLIENT_HOOK_ACTIVATE_DONE callback at e_focus_policy_history.c
5476 if (!ec->lock_focus_out)
5478 E_Client *focus_ec = NULL;
5479 E_Client *obscured_above = NULL;
5482 focus_ec = e_client_transient_child_top_get(ec, EINA_TRUE);
5488 e_client_focus_latest_set(ec);
5489 e_client_focus_latest_set(focus_ec);
5490 e_client_focus_defer_unset(ec);
5493 obscured_above = e_client_check_fully_contain_by_above(focus_ec, EINA_FALSE);
5494 if (!obscured_above)
5496 if (!e_policy_visibility_client_is_uniconic(ec))
5498 e_client_focus_defer_set(focus_ec);
5499 e_client_focus_latest_set(focus_ec);
5503 if (e_config->focus_policy_ext != E_FOCUS_EXT_TOP_STACK)
5505 ELOGF("FOCUS", "focus set | client activate", focus_ec);
5506 e_client_frame_focus_set(focus_ec, EINA_TRUE);
5512 e_client_focus_defer_set(focus_ec);
5513 e_client_focus_latest_set(focus_ec);
5518 #ifdef REFACTOR_ZONE_DESK
5520 if (!e_client_desk_iconify_skip_get(ec))
5522 e_desk_visible_client_iconified_list_remove_all(ec->desk);
5526 _e_client_hook_call(E_CLIENT_HOOK_ACTIVATE_DONE, ec);
5532 e_client_focused_get(void)
5534 #ifdef REFACTOR_FOCUS_POLICY
5535 return e_comp_focused_ec_get();
5537 E_Client *focused_ec = NULL;
5539 g_mutex_lock(&focused_ec_mutex);
5540 focused_ec = focused;
5541 g_mutex_unlock(&focused_ec_mutex);
5547 #ifdef REFACTOR_FOCUS_POLICY
5550 e_client_focus_stack_get(void)
5556 e_client_defer_focus_stack_get(void)
5558 return defer_focus_stack;
5562 e_client_focus_stack_set(Eina_List *l)
5568 e_client_focus_stack_clear(void)
5570 if (!focus_stack) return;
5572 focus_stack = eina_list_free(focus_stack);
5577 e_client_lost_windows_get(E_Zone *zone)
5579 Eina_List *list = NULL;
5582 int loss_overlap = 5;
5584 E_OBJECT_CHECK_RETURN(zone, NULL);
5585 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, NULL);
5586 EINA_LIST_FOREACH(e_comp->clients, l, ec)
5588 if (!e_zone_has_ec(zone, ec)) continue;
5589 if (e_client_util_ignored_get(ec)) continue;
5591 if (!E_INTERSECTS(zone->x + loss_overlap,
5592 zone->y + loss_overlap,
5593 zone->w - (2 * loss_overlap),
5594 zone->h - (2 * loss_overlap),
5595 ec->x, ec->y, ec->w, ec->h))
5597 list = eina_list_append(list, ec);
5603 ///////////////////////////////////////
5606 e_client_shade(E_Client *ec, E_Direction dir)
5609 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5610 if ((ec->shaded) || (ec->shading) || (ec->fullscreen) ||
5611 ((ec->maximized) && (!e_config->allow_manip))) return;
5612 if (!e_util_strcmp("borderless", ec->bordername)) return;
5613 if (!e_comp_object_frame_allowed(ec->frame)) return;
5617 ec->shade_dir = dir;
5619 evas_object_smart_callback_call(ec->frame, "shaded", (uintptr_t*)dir);
5623 e_client_unshade(E_Client *ec, E_Direction dir)
5626 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5627 if ((!ec->shaded) || (ec->shading))
5633 evas_object_smart_callback_call(ec->frame, "unshaded", (uintptr_t*)dir);
5636 ///////////////////////////////////////
5639 e_client_maximized_geometry_set(E_Client *ec, int x, int y, int w, int h)
5643 ec->maximized_info.x = x;
5644 ec->maximized_info.y = y;
5645 ec->maximized_info.w = w;
5646 ec->maximized_info.h = h;
5648 e_client_frame_geometry_set(ec, x, y, w, h);
5652 e_client_maximized_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
5656 if (x) *x = ec->maximized_info.x;
5657 if (y) *y = ec->maximized_info.y;
5658 if (w) *w = ec->maximized_info.w;
5659 if (h) *h = ec->maximized_info.h;
5663 e_client_maximize_update(E_Client *ec)
5668 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5672 max = ec->maximized;
5674 e_client_maximize(ec, max);
5679 e_client_maximize(E_Client *ec, E_Maximize max)
5681 #ifdef REFACTOR_ZONE_DESK
5683 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5685 if (!(max & E_MAXIMIZE_DIRECTION)) max |= E_MAXIMIZE_BOTH;
5687 if ((ec->shaded) || (ec->shading)) return;
5689 if ((ec->maximized & E_MAXIMIZE_DIRECTION) == (max & E_MAXIMIZE_DIRECTION))
5691 if ((ec->maximized & E_MAXIMIZE_TYPE) == (max & E_MAXIMIZE_TYPE))
5697 ec->changes.need_maximize = 1;
5698 ec->maximized &= ~E_MAXIMIZE_TYPE;
5699 ec->maximized |= max;
5704 // store the E_Maximize value requested
5705 ec->requested_max = max;
5707 // call the maximize hook of a client
5708 _e_client_hook_call(E_CLIENT_HOOK_MAXIMIZE, ec);
5710 // clear the E_Maximize value requested
5711 ec->requested_max = E_MAXIMIZE_NONE;
5713 // store the E_Maximize value
5714 ec->maximized = max;
5715 ec->changes.need_unmaximize = 0;
5717 evas_object_smart_callback_call(ec->frame, "maximize_done", NULL);
5723 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5725 zone = e_comp_zone_find_by_ec(ec);
5727 if (!(max & E_MAXIMIZE_DIRECTION)) max |= E_MAXIMIZE_BOTH;
5729 if ((ec->shaded) || (ec->shading)) return;
5731 if ((ec->maximized & E_MAXIMIZE_DIRECTION) == (max & E_MAXIMIZE_DIRECTION))
5733 if ((ec->maximized & E_MAXIMIZE_TYPE) == (max & E_MAXIMIZE_TYPE))
5739 ec->changes.need_maximize = 1;
5740 ec->maximized &= ~E_MAXIMIZE_TYPE;
5741 ec->maximized |= max;
5746 if (ec->desk_area.enable && ec->desk_area.desk_area)
5748 desk_x = ec->desk_area.desk_area->x;
5749 desk_y = ec->desk_area.desk_area->y;
5753 desk_x = ec->desk->geom.x;
5754 desk_y = ec->desk->geom.y;
5757 evas_object_smart_callback_call(ec->frame, "maximize_pre", NULL);
5760 e_client_unfullscreen(ec);
5761 ec->pre_res_change.valid = 0;
5762 if (!(ec->maximized & E_MAXIMIZE_HORIZONTAL))
5764 /* Horizontal hasn't been set */
5765 ec->saved.x = ec->client.x - desk_x;
5766 ec->saved.w = ec->client.w;
5768 if (!(ec->maximized & E_MAXIMIZE_VERTICAL))
5770 /* Vertical hasn't been set */
5771 ec->saved.y = ec->client.y - desk_y;
5772 ec->saved.h = ec->client.h;
5775 ec->saved.zone = zone->num;
5777 _e_client_maximize(ec, max);
5779 ec->maximized = max;
5780 ec->changes.need_unmaximize = 0;
5782 evas_object_smart_callback_call(ec->frame, "maximize_done", NULL);
5787 e_client_unmaximize(E_Client *ec, E_Maximize max)
5789 #ifdef REFACTOR_ZONE_DESK
5791 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5793 if (!(max & E_MAXIMIZE_DIRECTION))
5795 CRI("BUG: Unmaximize call without direction!");
5800 ec->changes.need_unmaximize = 1;
5805 if ((ec->shaded) || (ec->shading)) return;
5807 /* Remove directions not used */
5808 max &= (ec->maximized & E_MAXIMIZE_DIRECTION);
5809 /* Can only remove existing maximization directions */
5812 evas_object_smart_callback_call(ec->frame, "unmaximize_pre", NULL);
5814 // store the E_Maximize value requested
5815 ec->requested_max = max;
5817 // call the unmaximize hook of a client
5818 _e_client_hook_call(E_CLIENT_HOOK_UNMAXIMIZE, ec);
5820 // clear the E_Maximize value requested
5821 ec->requested_max = E_MAXIMIZE_NONE;
5823 evas_object_smart_callback_call(ec->frame, "unmaximize_done", NULL);
5824 ec->changes.need_unmaximize = 0;
5829 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5831 zone = e_comp_zone_find_by_ec(ec);
5833 if (!(max & E_MAXIMIZE_DIRECTION))
5835 CRI("BUG: Unmaximize call without direction!");
5840 ec->changes.need_unmaximize = 1;
5845 if ((ec->shaded) || (ec->shading)) return;
5847 /* Remove directions not used */
5848 max &= (ec->maximized & E_MAXIMIZE_DIRECTION);
5849 /* Can only remove existing maximization directions */
5852 evas_object_smart_callback_call(ec->frame, "unmaximize_pre", NULL);
5854 if (ec->maximized & E_MAXIMIZE_TYPE)
5856 ec->pre_res_change.valid = 0;
5857 ec->changes.need_maximize = 0;
5859 if ((ec->maximized & E_MAXIMIZE_TYPE) == E_MAXIMIZE_FULLSCREEN)
5861 E_Maximize tmp_max = ec->maximized;
5863 //un-set maximized state for updating frame.
5864 ec->maximized = E_MAXIMIZE_NONE;
5865 _e_client_frame_update(ec);
5866 // re-set maximized state for unmaximize smart callback.
5867 ec->maximized = tmp_max;
5868 evas_object_smart_callback_call(ec->frame, "unfullscreen", NULL);
5869 // un-set maximized state.
5870 ec->maximized = E_MAXIMIZE_NONE;
5871 e_client_util_move_resize_without_frame(ec,
5872 ec->saved.x + zone->x,
5873 ec->saved.y + zone->y,
5874 ec->saved.w, ec->saved.h);
5875 ec->saved.x = ec->saved.y = ec->saved.w = ec->saved.h = 0;
5880 Eina_Bool horiz = EINA_FALSE, vert = EINA_FALSE;
5887 if (max & E_MAXIMIZE_VERTICAL)
5889 /* Remove vertical */
5892 y = ec->saved.y + zone->y;
5893 if ((max & E_MAXIMIZE_VERTICAL) == E_MAXIMIZE_VERTICAL)
5895 ec->maximized &= ~E_MAXIMIZE_VERTICAL;
5896 ec->maximized &= ~E_MAXIMIZE_LEFT;
5897 ec->maximized &= ~E_MAXIMIZE_RIGHT;
5899 if ((max & E_MAXIMIZE_LEFT) == E_MAXIMIZE_LEFT)
5900 ec->maximized &= ~E_MAXIMIZE_LEFT;
5901 if ((max & E_MAXIMIZE_RIGHT) == E_MAXIMIZE_RIGHT)
5902 ec->maximized &= ~E_MAXIMIZE_RIGHT;
5904 if (max & E_MAXIMIZE_HORIZONTAL)
5906 /* Remove horizontal */
5908 x = ec->saved.x + zone->x;
5910 ec->maximized &= ~E_MAXIMIZE_HORIZONTAL;
5913 if (!(ec->maximized & E_MAXIMIZE_DIRECTION))
5915 ec->maximized = E_MAXIMIZE_NONE;
5916 _e_client_frame_update(ec);
5917 evas_object_smart_callback_call(ec->frame, "unmaximize", NULL);
5918 e_client_resize_limit(ec, &w, &h);
5919 e_client_pos_set(ec, x, y);
5920 if ((ec->saved.w != 0) && (ec->saved.h != 0))
5922 if ((w != ec->saved.w) || (h != ec->saved.h))
5924 e_policy_visibility_client_defer_move(ec);
5930 evas_object_smart_callback_call(ec->frame, "unmaximize", NULL);
5931 e_client_resize_limit(ec, &w, &h);
5932 e_client_pos_set(ec, x, y);
5933 if ((ec->saved.w != 0) && (ec->saved.h != 0))
5935 if ((w != ec->saved.w) || (h != ec->saved.h))
5937 e_policy_visibility_client_defer_move(ec);
5942 ec->saved.h = ec->saved.y = 0;
5944 ec->saved.w = ec->saved.x = 0;
5947 evas_object_smart_callback_call(ec->frame, "unmaximize_done", NULL);
5948 ec->changes.need_unmaximize = 0;
5953 e_client_fullscreen(E_Client *ec, E_Fullscreen policy)
5955 #ifdef REFACTOR_ZONE_DESK
5957 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5959 if ((ec->shaded) || (ec->shading) || (ec->fullscreen)) return;
5961 // call the fullscreen_pre hook of a client
5962 _e_client_hook_call(E_CLIENT_HOOK_FULLSCREEN_PRE, ec);
5964 ec->fullscreen_policy = policy;
5966 // call the fullscreen hook of a client
5967 _e_client_hook_call(E_CLIENT_HOOK_FULLSCREEN, ec);
5969 _e_client_event_simple(ec, E_EVENT_CLIENT_FULLSCREEN);
5975 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
5977 zone = e_comp_zone_find_by_ec(ec);
5980 if ((ec->shaded) || (ec->shading) || (ec->fullscreen)) return;
5982 _e_client_hook_call(E_CLIENT_HOOK_FULLSCREEN_PRE, ec);
5984 if (ec->skip_fullscreen) return;
5985 if (!ec->desk->visible) return;
5988 ec->need_fullscreen = 1;
5991 if (e_comp->nocomp_ec && (ec->desk == e_comp->nocomp_ec->desk))
5992 e_comp->nocomp_ec = ec;
5993 ec->desk->fullscreen_clients = eina_list_append(ec->desk->fullscreen_clients, ec);
5994 ec->pre_res_change.valid = 0;
6005 ec->saved.x = ec->client.x - zone->x;
6006 ec->saved.y = ec->client.y - zone->y;
6007 ec->saved.w = ec->client.w;
6008 ec->saved.h = ec->client.h;
6010 ec->saved.maximized = ec->maximized;
6011 ec->saved.zone = zone->num;
6015 e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
6022 ec->saved.layer = ec->layer;
6023 e_client_layer_set(ec, E_LAYER_CLIENT_FULLSCREEN);
6026 if ((eina_list_count(e_comp->zones) > 1) ||
6027 (policy == E_FULLSCREEN_RESIZE))
6029 e_client_frame_geometry_set(ec, zone->x, zone->y, zone->w, zone->h);
6031 else if (policy == E_FULLSCREEN_ZOOM)
6033 /* compositor backends! */
6034 evas_object_smart_callback_call(ec->frame, "fullscreen_zoom", NULL);
6037 if (!e_client_util_ignored_get(ec))
6038 _e_client_frame_update(ec);
6039 ec->fullscreen_policy = policy;
6040 evas_object_smart_callback_call(ec->frame, "fullscreen", NULL);
6042 _e_client_event_simple(ec, E_EVENT_CLIENT_FULLSCREEN);
6047 e_client_unfullscreen(E_Client *ec)
6049 #ifdef REFACTOR_ZONE_DESK
6051 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6053 if ((ec->shaded) || (ec->shading)) return;
6054 if (!ec->fullscreen) return;
6056 // call the unfullscreen hook of a client
6057 _e_client_hook_call(E_CLIENT_HOOK_UNFULLSCREEN, ec);
6059 _e_client_event_simple(ec, E_EVENT_CLIENT_UNFULLSCREEN);
6064 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6066 zone = e_comp_zone_find_by_ec(ec);
6068 if ((ec->shaded) || (ec->shading)) return;
6069 if (!ec->fullscreen) return;
6070 ec->pre_res_change.valid = 0;
6072 ec->need_fullscreen = 0;
6073 ec->desk->fullscreen_clients = eina_list_remove(ec->desk->fullscreen_clients, ec);
6075 if (ec->fullscreen_policy == E_FULLSCREEN_ZOOM)
6076 evas_object_smart_callback_call(ec->frame, "unfullscreen_zoom", NULL);
6078 if (!e_client_util_ignored_get(ec))
6079 _e_client_frame_update(ec);
6080 ec->fullscreen_policy = 0;
6081 evas_object_smart_callback_call(ec->frame, "unfullscreen", NULL);
6082 e_client_util_move_resize_without_frame(ec, zone->x + ec->saved.x,
6083 zone->y + ec->saved.y,
6084 ec->saved.w, ec->saved.h);
6086 if (ec->saved.maximized)
6087 e_client_maximize(ec, (e_config->maximize_policy & E_MAXIMIZE_TYPE) |
6088 ec->saved.maximized);
6090 e_client_layer_set(ec, ec->saved.layer);
6092 _e_client_event_simple(ec, E_EVENT_CLIENT_UNFULLSCREEN);
6094 if (!ec->desk->fullscreen_clients)
6095 e_comp_render_queue();
6099 ///////////////////////////////////////
6100 #ifdef REFACTOR_ZONE_DESK
6102 e_client_is_parent_iconify_by_client(E_Client *ec)
6105 _e_client_is_parent_iconify_by_client(E_Client *ec)
6108 E_Client *parent = ec->parent;
6109 if (!parent) return EINA_FALSE;
6111 if ((parent->exp_iconify.type == E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT) ||
6112 (parent->exp_iconify.type == E_ICONIFIED_TYPE_PARENT_ICONIFY_BY_CLIENT))
6119 e_client_iconify(E_Client *ec)
6122 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6124 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
6125 Eina_Bool iconified_by_client = e_client_is_iconified_by_client(ec);
6127 ELOGF("TZVIS", "ICONIFY |iconic:%d |argb:%d |not_raise:%d |by_client:%d, type:%d",
6128 ec, ec->iconic, ec->argb, (unsigned int)ec->exp_iconify.not_raise,
6129 ec->exp_iconify.by_client, ec->exp_iconify.type);
6131 if (ec->shading || ec->iconic) return;
6132 if (ec->exp_iconify.skip_iconify && !iconified_by_client) return;
6133 if (ec->exp_iconify.skip_by_remote) return;
6134 if (!cdata || !cdata->mapped)
6136 if (!iconified_by_client)
6138 ELOGF("TZVIS", "Not mapped.. So, don't iconify", ec);
6143 ELOGF("TZVIS", "Not mapped.. But, iconify by user request", ec);
6147 TRACE_DS_BEGIN(CLIENT:ICONIFY);
6149 #ifdef REFACTOR_ZONE_DESK
6151 e_comp_wl_remote_surface_image_save(ec);
6154 ec->want_focus = ec->take_focus = 0;
6155 ec->changes.visible = 0;
6157 ec->desk->fullscreen_clients = eina_list_remove(ec->desk->fullscreen_clients, ec);
6158 e_client_comp_hidden_set(ec, 1);
6159 evas_object_hide(ec->frame);
6160 e_client_urgent_set(ec, ec->icccm.urgent);
6162 _e_client_event_simple(ec, E_EVENT_CLIENT_ICONIFY);
6164 if (e_config->transient.iconify)
6167 Eina_List *list = eina_list_clone(ec->transients);
6169 EINA_LIST_FREE(list, child)
6171 if ((child->exp_iconify.type != E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT) &&
6172 (_e_client_is_parent_iconify_by_client(child)))
6174 e_client_iconified_type_set(child, E_ICONIFIED_TYPE_PARENT_ICONIFY_BY_CLIENT);
6175 child->exp_iconify.by_client = 1;
6176 e_policy_client_iconic_state_change_send(child, 1);
6178 e_client_iconify(child);
6184 _e_client_hook_call(E_CLIENT_HOOK_ICONIFY, ec);
6190 e_client_uniconify(E_Client *ec)
6192 #ifdef REFACTOR_ZONE_DESK
6193 E_Comp_Wl_Client_Data *cdata;
6196 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6198 cdata = e_client_cdata_get(ec);
6200 ELOGF("TZVIS", "UNICONIFY|iconic:%d |argb:%d |not_raise:%d |by_client:%d, type:%d |mapped:%d",
6201 ec, ec->iconic, ec->argb, (unsigned int)ec->exp_iconify.not_raise,
6202 ec->exp_iconify.by_client, ec->exp_iconify.type,
6203 cdata ? cdata->mapped : 0);
6205 if (ec->shading || (!ec->iconic)) return;
6207 TRACE_DS_BEGIN(CLIENT:UNICONIFY);
6209 // call the uniconify hook of a client
6210 _e_client_hook_call(E_CLIENT_HOOK_UNICONIFY, ec);
6215 Eina_Bool not_raise;
6218 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6220 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
6222 ELOGF("TZVIS", "UNICONIFY|iconic:%d |argb:%d |not_raise:%d |by_client:%d, type:%d |mapped:%d",
6223 ec, ec->iconic, ec->argb, (unsigned int)ec->exp_iconify.not_raise,
6224 ec->exp_iconify.by_client, ec->exp_iconify.type,
6225 cdata ? cdata->mapped : 0);
6227 if (ec->shading || (!ec->iconic)) return;
6229 TRACE_DS_BEGIN(CLIENT:UNICONIFY);
6231 e_comp_wl_remote_surface_image_save_cancel(ec);
6233 desk = e_desk_current_get(ec->desk->zone);
6234 e_client_desk_set(ec, desk);
6235 not_raise = ec->exp_iconify.not_raise;
6237 ec->exp_iconify.by_client = 0;
6238 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
6240 if (e_config->transient.iconify)
6243 Eina_List *list = eina_list_clone(ec->transients);
6245 EINA_LIST_FREE(list, child)
6247 if (e_client_transient_policy_get(child) == E_TRANSIENT_BELOW)
6249 child->exp_iconify.not_raise = not_raise;
6250 e_client_uniconify(child);
6260 ELOGF("TZVIS", "UNICONIFY|internal object force show", ec);
6261 evas_object_show(ec->frame);
6266 if (e_pixmap_usable_get(ec->pixmap))
6268 if (cdata && cdata->mapped)
6270 ELOGF("TZVIS", "UNICONIFY|object show. frame_visible:%d", ec, evas_object_visible_get(ec->frame));
6271 evas_object_show(ec->frame);
6275 ELOGF("TZVIS", "UNICONIFY|object no show. currently unmapped", ec);
6280 if (!ec->exp_iconify.buffer_flush &&
6281 !ec->exp_iconify.deiconify_update)
6283 if (cdata && cdata->mapped)
6285 ELOGF("TZVIS", "UNICONIFY|object show. no use buffer flush. frame_visible:%d", ec, evas_object_visible_get(ec->frame));
6286 evas_object_show(ec->frame);
6291 e_client_comp_hidden_set(ec, 0);
6292 ec->deskshow = ec->iconic = 0;
6294 #if 0 // focus should be set to the top window not uniconify window
6295 if (ec->pixmap && e_pixmap_usable_get(ec->pixmap))
6296 e_client_frame_focus_set(ec, EINA_TRUE);
6299 _e_client_event_simple(ec, E_EVENT_CLIENT_UNICONIFY);
6301 if (e_config->transient.iconify)
6304 Eina_List *list = eina_list_clone(ec->transients);
6306 EINA_LIST_FREE(list, child)
6308 if (e_client_transient_policy_get(child) == E_TRANSIENT_ABOVE)
6310 if (child->exp_iconify.type == E_ICONIFIED_TYPE_PARENT_ICONIFY_BY_CLIENT)
6311 e_policy_client_iconic_state_change_send(child, 0);
6312 child->exp_iconify.not_raise = not_raise;
6313 e_client_uniconify(child);
6318 _e_client_hook_call(E_CLIENT_HOOK_UNICONIFY, ec);
6320 ec->exp_iconify.not_raise = 0;
6327 e_client_iconified_type_set(E_Client *ec, E_Iconified_Type type)
6330 ec->exp_iconify.type = type;
6333 EINTERN E_Iconified_Type
6334 e_client_iconified_type_get(E_Client *ec)
6336 if (!ec) return E_ICONIFIED_TYPE_NONE;
6337 return ec->exp_iconify.type;
6340 E_API Eina_Bool e_client_is_iconified_by_client(E_Client *ec)
6342 if (!ec) return EINA_FALSE;
6344 if (ec->exp_iconify.type == E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT)
6347 if (ec->exp_iconify.type == E_ICONIFIED_TYPE_DESK_ICONIFY_BY_CLIENT)
6350 if (ec->exp_iconify.type == E_ICONIFIED_TYPE_PARENT_ICONIFY_BY_CLIENT)
6353 if (ec->exp_iconify.by_client)
6355 ELOGF("POL", "CHECK. mismatch value. by_client:%d, type:%d", ec, ec->exp_iconify.by_client, ec->exp_iconify.type);
6362 ///////////////////////////////////////
6365 e_client_urgent_set(E_Client *ec, Eina_Bool urgent)
6368 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6371 if (urgent == ec->urgent) return;
6372 _e_client_event_property(ec, E_CLIENT_PROPERTY_URGENCY);
6373 if (urgent && (!ec->focused) && (!ec->want_focus))
6375 e_comp_object_signal_emit(ec->frame, "e,state,urgent", "e");
6376 ec->urgent = urgent;
6380 e_comp_object_signal_emit(ec->frame, "e,state,not_urgent", "e");
6385 ///////////////////////////////////////
6388 e_client_stick(E_Client *ec)
6390 #ifdef REFACTOR_ZONE_DESK
6392 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6393 if (ec->sticky) return;
6395 // call the stick hook of a client
6396 _e_client_hook_call(E_CLIENT_HOOK_STICK, ec);
6398 // send the sticky property event of a client
6399 _e_client_event_property(ec, E_CLIENT_PROPERTY_STICKY);
6404 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6405 if (ec->sticky) return;
6410 e_client_desk_set(ec, desk);
6411 evas_object_smart_callback_call(ec->frame, "stick", NULL);
6413 if (e_config->transient.desktop)
6416 Eina_List *list = eina_list_clone(ec->transients);
6418 EINA_LIST_FREE(list, child)
6421 evas_object_show(ec->frame);
6425 _e_client_event_property(ec, E_CLIENT_PROPERTY_STICKY);
6430 e_client_unstick(E_Client *ec)
6432 #ifdef REFACTOR_ZONE_DESK
6434 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6436 if (!ec->sticky) return;
6438 // call the unstick hook of a client
6439 _e_client_hook_call(E_CLIENT_HOOK_UNSTICK, ec);
6441 // send the sticky property event of a client
6442 _e_client_event_property(ec, E_CLIENT_PROPERTY_STICKY);
6448 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6449 /* Set the desk before we unstick the client */
6450 if (!ec->sticky) return;
6452 zone = e_comp_zone_find_by_ec(ec);
6453 desk = e_desk_current_get(zone);
6455 ec->hidden = ec->sticky = 0;
6456 e_client_desk_set(ec, desk);
6457 evas_object_smart_callback_call(ec->frame, "unstick", NULL);
6459 if (e_config->transient.desktop)
6462 Eina_List *list = eina_list_clone(ec->transients);
6464 EINA_LIST_FREE(list, child)
6470 _e_client_event_property(ec, E_CLIENT_PROPERTY_STICKY);
6472 e_client_desk_set(ec, e_desk_current_get(zone));
6477 e_client_pinned_set(E_Client *ec, Eina_Bool set)
6481 EINA_SAFETY_ON_NULL_RETURN(ec);
6483 layer = E_LAYER_CLIENT_ABOVE;
6485 layer = E_LAYER_CLIENT_NORMAL;
6487 e_client_layer_set(ec, layer);
6492 ///////////////////////////////////////
6495 e_client_border_set(E_Client *ec, const char *name)
6497 Eina_Stringshare *pborder;
6499 E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
6500 E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
6501 if (!e_comp_object_frame_allowed(ec->frame)) return EINA_FALSE;
6502 if (ec->border.changed)
6503 CRI("CALLING WHEN border.changed SET!");
6505 if (!e_util_strcmp(ec->border.name, name)) return EINA_TRUE;
6506 if (ec->mwm.borderless && name && strcmp(name, "borderless"))
6508 CRI("border change attempted for MWM borderless client!");
6510 pborder = ec->border.name;
6511 ec->border.name = eina_stringshare_add(name);
6512 if (e_comp_object_frame_theme_set(ec->frame, name))
6514 eina_stringshare_del(pborder);
6517 eina_stringshare_del(ec->border.name);
6518 ec->border.name = pborder;
6522 ///////////////////////////////////////
6525 e_client_comp_hidden_set(E_Client *ec, Eina_Bool hidden)
6528 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6531 if (ec->comp_hidden == hidden) return;
6532 ec->comp_hidden = hidden;
6533 evas_object_smart_callback_call(ec->frame, "comp_hidden", NULL);
6536 ///////////////////////////////////////
6539 e_client_act_move_keyboard(E_Client *ec)
6541 EINA_SAFETY_ON_NULL_RETURN(ec);
6543 if (!_e_client_move_begin(ec))
6546 _e_client_action_init(ec);
6547 _e_client_action_move_timeout_add();
6548 if (!_e_client_hook_call(E_CLIENT_HOOK_MOVE_UPDATE, ec)) return;
6549 evas_object_freeze_events_set(ec->frame, 1);
6551 if (!action_handler_mouse)
6552 action_handler_mouse = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _e_client_move_mouse_down, NULL);
6556 e_client_act_resize_keyboard(E_Client *ec)
6558 EINA_SAFETY_ON_NULL_RETURN(ec);
6560 ec->resize_mode = E_POINTER_RESIZE_TL;
6561 ec->keyboard_resizing = 1;
6562 if (!e_client_resize_begin(ec))
6564 ec->keyboard_resizing = 0;
6568 _e_client_action_init(ec);
6569 _e_client_action_resize_timeout_add();
6570 evas_object_freeze_events_set(ec->frame, 1);
6572 if (!action_handler_mouse)
6573 action_handler_mouse = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _e_client_resize_mouse_down, NULL);
6577 e_client_act_move_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev)
6580 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6581 if (e_client_util_resizing_get(ec) || (ec->moving)) return;
6586 snprintf(source, sizeof(source) - 1, "mouse,down,%i", ev->button);
6587 _e_client_moveinfo_gather(ec, source);
6589 if (!_e_client_move_begin(ec))
6592 _e_client_action_init(ec);
6596 e_client_act_move_end(E_Client *ec, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
6599 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6600 if (!ec->moving) return;
6601 _e_client_move_end(ec);
6602 _e_client_action_finish();
6606 e_client_act_resize_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev, E_Pointer_Mode resize_mode)
6609 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6610 if (ec->lock_user_size || ec->shaded || ec->shading) return;
6611 if (e_client_util_resizing_get(ec) || (ec->moving)) return;
6615 snprintf(source, sizeof(source) - 1, "mouse,down,%i", ev->button);
6616 _e_client_moveinfo_gather(ec, source);
6618 if (resize_mode != E_POINTER_RESIZE_NONE)
6620 ec->resize_mode = resize_mode;
6624 /* Use canvas.x, canvas.y of event.
6625 * Transformed coordinates has to be considered for accurate resize_mode
6626 * rather than absolute coordinates. */
6627 if ((ev->canvas.x > (ec->x + ec->w / 5)) &&
6628 (ev->canvas.x < (ec->x + ec->w * 4 / 5)))
6630 if (ev->canvas.y < (ec->y + ec->h / 2)) ec->resize_mode = E_POINTER_RESIZE_T;
6631 else ec->resize_mode = E_POINTER_RESIZE_B;
6633 else if (ev->canvas.x < (ec->x + ec->w / 2))
6635 if ((ev->canvas.y > (ec->y + ec->h / 5)) && (ev->canvas.y < (ec->y + ec->h * 4 / 5))) ec->resize_mode = E_POINTER_RESIZE_L;
6636 else if (ev->canvas.y < (ec->y + ec->h / 2)) ec->resize_mode = E_POINTER_RESIZE_TL;
6637 else ec->resize_mode = E_POINTER_RESIZE_BL;
6641 if ((ev->canvas.y > (ec->y + ec->h / 5)) && (ev->canvas.y < (ec->y + ec->h * 4 / 5))) ec->resize_mode = E_POINTER_RESIZE_R;
6642 else if (ev->canvas.y < (ec->y + ec->h / 2)) ec->resize_mode = E_POINTER_RESIZE_TR;
6643 else ec->resize_mode = E_POINTER_RESIZE_BR;
6647 if (!e_client_resize_begin(ec))
6649 _e_client_action_init(ec);
6653 e_client_act_resize_end(E_Client *ec, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
6656 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6657 if (e_client_util_resizing_get(ec))
6659 _e_client_resize_end(ec);
6660 ec->changes.reset_gravity = 1;
6661 if (!e_object_is_del(E_OBJECT(ec)))
6664 _e_client_action_finish();
6668 e_client_act_menu_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev, int key)
6671 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6675 e_client_act_close_begin(E_Client *ec)
6678 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6679 if (ec->lock_close) return;
6680 if (ec->icccm.delete_request)
6682 ec->delete_requested = 1;
6683 evas_object_smart_callback_call(ec->frame, "delete_request", NULL);
6685 else if (e_config->kill_if_close_not_possible)
6687 e_client_act_kill_begin(ec);
6692 e_client_act_kill_begin(E_Client *ec)
6695 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6696 if (ec->internal) return;
6697 if (ec->lock_close) return;
6698 if ((ec->netwm.pid > 1) && (e_config->kill_process))
6700 kill(ec->netwm.pid, SIGINT);
6701 ec->kill_timer = ecore_timer_add(e_config->kill_timer_wait,
6702 _e_client_cb_kill_timer, ec);
6705 evas_object_smart_callback_call(ec->frame, "kill_request", NULL);
6708 ////////////////////////////////////////////
6711 e_client_ping(E_Client *ec)
6714 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6716 if (!e_config->ping_clients) return;
6718 EINA_SAFETY_ON_TRUE_RETURN(e_object_is_del(E_OBJECT(ec)));
6721 evas_object_smart_callback_call(ec->frame, "ping", NULL);
6722 ec->ping = ecore_loop_time_get();
6723 if (ec->ping_poller) ecore_poller_del(ec->ping_poller);
6724 ec->ping_poller = ecore_poller_add(ECORE_POLLER_CORE,
6725 e_config->ping_clients_interval,
6726 _e_client_cb_ping_poller, ec);
6729 ////////////////////////////////////////////
6731 e_client_cursor_map_apply(E_Client *ec, int rotation, int x, int y)
6733 // TODO: remove(deprecate) this e_client_cursor_map_apply.
6737 e_client_move_cancel(void)
6739 if (!ecmove) return;
6740 if (ecmove->cur_mouse_action)
6745 e_object_ref(E_OBJECT(ec));
6746 if (ec->cur_mouse_action->func.end_mouse)
6747 ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", NULL);
6748 else if (ec->cur_mouse_action->func.end)
6749 ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
6750 e_object_unref(E_OBJECT(ec->cur_mouse_action));
6751 ec->cur_mouse_action = NULL;
6752 e_object_unref(E_OBJECT(ec));
6755 _e_client_move_end(ecmove);
6759 e_client_resize_cancel(void)
6761 if (!ecresize) return;
6762 if (ecresize->cur_mouse_action)
6767 e_object_ref(E_OBJECT(ec));
6768 if (ec->cur_mouse_action->func.end_mouse)
6769 ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", NULL);
6770 else if (ec->cur_mouse_action->func.end)
6771 ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
6772 e_object_unref(E_OBJECT(ec->cur_mouse_action));
6773 ec->cur_mouse_action = NULL;
6774 e_object_unref(E_OBJECT(ec));
6777 _e_client_resize_end(ecresize);
6781 e_client_resize_begin(E_Client *ec)
6783 if ((ec->shaded) || (ec->shading) ||
6784 (ec->fullscreen) || (ec->lock_user_size))
6786 if (!_e_client_action_input_win_new()) goto error;
6788 if (ec->manage_resize.enable_aspect_ratio)
6790 ELOGF("RESIZE", "Set resize aspect ratio.. ratio(%dx%d)", ec, ec->w, ec->h);
6791 ec->manage_resize.aw = ec->w;
6792 ec->manage_resize.ah = ec->h - ec->manage_resize.header_h - ec->manage_resize.footer_h;
6794 _e_client_hook_call(E_CLIENT_HOOK_RESIZE_BEGIN, ec);
6795 if (ec->transformed)
6796 _e_client_transform_resize_begin(ec);
6797 if (!e_client_util_resizing_get(ec))
6799 if (ecresize == ec) ecresize = NULL;
6800 _e_client_action_input_win_del();
6803 if (!ec->lock_user_stacking)
6805 if (e_config->border_raise_on_mouse_action)
6810 e_comp_client_override_add(ec);
6814 ec->resize_mode = E_POINTER_RESIZE_NONE;
6819 ////////////////////////////////////////////
6822 e_client_frame_recalc(E_Client *ec)
6824 EINA_SAFETY_ON_NULL_RETURN(ec);
6825 if (!ec->frame) return;
6826 evas_object_smart_callback_call(ec->frame, "frame_recalc", NULL);
6829 ////////////////////////////////////////////
6832 e_client_signal_move_begin(E_Client *ec, const char *sig, const char *src EINA_UNUSED)
6835 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6837 if (e_client_util_resizing_get(ec) || (ec->moving)) return;
6838 _e_client_moveinfo_gather(ec, sig);
6839 if (!_e_client_move_begin(ec)) return;
6843 e_client_signal_move_end(E_Client *ec, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
6846 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6847 if (!ec->moving) return;
6848 _e_client_move_end(ec);
6852 e_client_signal_resize_begin(E_Client *ec, const char *dir, const char *sig, const char *src EINA_UNUSED)
6854 int resize_mode = E_POINTER_RESIZE_BR;
6857 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6859 if (e_client_util_resizing_get(ec) || (ec->moving)) return;
6860 if (!strcmp(dir, "tl"))
6862 resize_mode = E_POINTER_RESIZE_TL;
6864 else if (!strcmp(dir, "t"))
6866 resize_mode = E_POINTER_RESIZE_T;
6868 else if (!strcmp(dir, "tr"))
6870 resize_mode = E_POINTER_RESIZE_TR;
6872 else if (!strcmp(dir, "r"))
6874 resize_mode = E_POINTER_RESIZE_R;
6876 else if (!strcmp(dir, "br"))
6878 resize_mode = E_POINTER_RESIZE_BR;
6880 else if (!strcmp(dir, "b"))
6882 resize_mode = E_POINTER_RESIZE_B;
6884 else if (!strcmp(dir, "bl"))
6886 resize_mode = E_POINTER_RESIZE_BL;
6888 else if (!strcmp(dir, "l"))
6890 resize_mode = E_POINTER_RESIZE_L;
6892 ec->resize_mode = resize_mode;
6893 _e_client_moveinfo_gather(ec, sig);
6894 if (!e_client_resize_begin(ec))
6899 e_client_signal_resize_end(E_Client *ec, const char *dir EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
6902 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6903 if (!e_client_util_resizing_get(ec)) return;
6904 _e_client_resize_handle(ec);
6905 _e_client_resize_end(ec);
6906 ec->changes.reset_gravity = 1;
6910 ////////////////////////////////////////////
6913 e_client_resize_limit(E_Client *ec, int *w, int *h)
6919 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6921 inc_h = (*h - ec->h > 0);
6923 e_comp_object_frame_wh_unadjust(ec->frame, *w, *h, w, h);
6926 if ((ec->icccm.base_w >= 0) &&
6927 (ec->icccm.base_h >= 0))
6931 tw = *w - ec->icccm.base_w;
6932 th = *h - ec->icccm.base_h;
6935 a = (double)(tw) / (double)(th);
6936 if ((ec->icccm.min_aspect != 0.0) &&
6937 (a < ec->icccm.min_aspect))
6940 tw = th * ec->icccm.min_aspect;
6942 th = tw / ec->icccm.max_aspect;
6943 *w = tw + ec->icccm.base_w;
6944 *h = th + ec->icccm.base_h;
6946 else if ((ec->icccm.max_aspect != 0.0) &&
6947 (a > ec->icccm.max_aspect))
6949 tw = th * ec->icccm.max_aspect;
6950 *w = tw + ec->icccm.base_w;
6955 a = (double)*w / (double)*h;
6956 if ((ec->icccm.min_aspect != 0.0) &&
6957 (a < ec->icccm.min_aspect))
6960 *w = *h * ec->icccm.min_aspect;
6962 *h = *w / ec->icccm.min_aspect;
6964 else if ((ec->icccm.max_aspect != 0.0) &&
6965 (a > ec->icccm.max_aspect))
6966 *w = *h * ec->icccm.max_aspect;
6968 if (ec->icccm.step_w > 0)
6970 if (ec->icccm.base_w >= 0)
6971 *w = ec->icccm.base_w +
6972 (((*w - ec->icccm.base_w) / ec->icccm.step_w) *
6975 *w = ec->icccm.min_w +
6976 (((*w - ec->icccm.min_w) / ec->icccm.step_w) *
6979 if (ec->icccm.step_h > 0)
6981 if (ec->icccm.base_h >= 0)
6982 *h = ec->icccm.base_h +
6983 (((*h - ec->icccm.base_h) / ec->icccm.step_h) *
6986 *h = ec->icccm.min_h +
6987 (((*h - ec->icccm.min_h) / ec->icccm.step_h) *
6994 if ((ec->icccm.max_w > 0) && (*w > ec->icccm.max_w)) *w = ec->icccm.max_w;
6995 else if (*w < ec->icccm.min_w)
6996 *w = ec->icccm.min_w;
6997 if ((ec->icccm.max_h > 0) && (*h > ec->icccm.max_h)) *h = ec->icccm.max_h;
6998 else if (*h < ec->icccm.min_h)
6999 *h = ec->icccm.min_h;
7002 e_comp_object_frame_wh_adjust(ec->frame, *w, *h, w, h);
7005 ////////////////////////////////////////////
7010 e_client_under_pointer_get(E_Desk *desk, E_Client *exclude)
7014 /* We need to ensure that we can get the comp window for the
7015 * zone of either the given desk or the desk of the excluded
7016 * window, so return if neither is given */
7018 e_input_device_pointer_xy_get(NULL, &x, &y);
7020 e_input_device_pointer_xy_get(NULL, &x, &y);
7026 desk = exclude->desk;
7030 desk = e_desk_current_get(exclude->zone);
7032 desk = e_desk_current_get(e_zone_current_get());
7036 return desk ? _e_client_under_pointer_helper(desk, exclude, x, y) : NULL;
7039 E_API E_Client *e_client_under_position_get(E_Desk *desk, int x, int y, E_Client *exclude)
7041 if (!desk) return NULL;
7043 return _e_client_under_pointer_helper(desk, exclude, x, y);
7046 E_API E_Client *e_client_under_position_input_get(E_Desk *desk, int x, int y)
7048 if (!desk) return NULL;
7050 return _e_client_under_pointer_input_helper(desk, x, y);
7054 e_client_input_rect_under_pointer_get(E_Desk *desk, E_Client *exclude)
7058 /* We need to ensure that we can get the comp window for the
7059 * zone of either the given desk or the desk of the excluded
7060 * window, so return if neither is given */
7062 e_input_device_pointer_xy_get(NULL, &x, &y);
7064 e_input_device_pointer_xy_get(NULL, &x, &y);
7070 desk = exclude->desk;
7074 desk = e_desk_current_get(exclude->zone);
7076 desk = e_desk_current_get(e_zone_current_get());
7080 return desk ? _e_client_input_rect_under_pointer_helper(desk, exclude, x, y) : NULL;
7083 ////////////////////////////////////////////
7085 ////////////////////////////////////////////
7088 e_client_redirected_set(E_Client *ec, Eina_Bool set)
7090 EINA_SAFETY_ON_NULL_RETURN(ec);
7091 if (ec->input_only) return;
7093 if (ec->redirected == set) return;
7096 e_client_frame_recalc(ec);
7097 if (!_e_client_hook_call(E_CLIENT_HOOK_REDIRECT, ec)) return;
7101 if (!_e_client_hook_call(E_CLIENT_HOOK_UNREDIRECT, ec)) return;
7103 e_comp_object_redirected_set(ec->frame, set);
7104 ec->redirected = !!set;
7107 ////////////////////////////////////////////
7110 e_client_is_stacking(const E_Client *ec)
7112 return e_comp->layers[e_comp_canvas_layer_map(ec->layer)].obj == ec->frame;
7115 ////////////////////////////////////////////
7118 e_client_transform_update(E_Client *ec)
7120 if (e_client_util_resizing_get(ec))
7121 _e_client_transform_resize(ec);
7124 ////////////////////////////////////////////
7127 e_client_transform_apply(E_Client *ec, double angle, double zoom, int cx, int cy)
7130 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
7134 if (e_comp_wl_subsurface_check(ec))
7137 /* check if it's different with current state */
7138 if ((ec->transform.angle == angle) &&
7139 (ec->transform.zoom == zoom) &&
7140 (ec->transform.center.x == cx) &&
7141 (ec->transform.center.y == cy))
7144 /* use previous value if any required value is invalid */
7146 angle = ec->transform.angle;
7148 zoom = ec->transform.zoom;
7149 if (!E_INSIDE(cx, cy,
7150 ec->client.x, ec->client.y,
7151 ec->client.w, ec->client.h))
7153 cx = ec->transform.center.x;
7154 cy = ec->transform.center.y;
7157 if ((angle == 0) && (zoom == 1.0))
7159 e_client_transform_clear(ec);
7163 map = e_map_new_with_direct_render(ec->transform_core.direct_render);
7164 e_map_util_points_populate_from_object_full(map, ec->frame, 0);
7166 e_map_util_rotate(map, angle, cx, cy);
7167 _e_client_transform_geometry_save(ec, map);
7169 e_map_util_zoom(map, zoom, zoom, cx, cy);
7171 e_map_util_object_move_sync_set(map, EINA_TRUE);
7172 e_client_map_set(ec, map);
7173 e_client_map_enable_set(ec, EINA_TRUE);
7175 EINA_LIST_FOREACH(cdata->sub.list, l, subc)
7176 _e_client_transform_sub_apply(subc, ec, zoom);
7177 EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
7178 _e_client_transform_sub_apply(subc, ec, zoom);
7182 ec->transform.zoom = zoom;
7183 ec->transform.angle = angle;
7184 ec->transform.center.x = cx;
7185 ec->transform.center.y = cy;
7186 ec->transformed = EINA_TRUE;
7189 ////////////////////////////////////////////
7192 e_client_transform_clear(E_Client *ec)
7194 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
7198 e_client_map_enable_set(ec, EINA_FALSE);
7199 e_client_map_set(ec, NULL);
7201 EINA_LIST_FOREACH(cdata->sub.list, l, subc)
7202 _e_client_transform_sub_apply(subc, ec, 1.0);
7203 EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
7204 _e_client_transform_sub_apply(subc, ec, 1.0);
7206 ec->transform.zoom = 1.0;
7207 ec->transform.angle = 0.0;
7208 ec->transformed = EINA_FALSE;
7212 e_client_transform_core_enable_get(E_Client *ec)
7214 if (!ec) return EINA_FALSE;
7215 return ec->transform_core.result.enable;
7219 e_client_transform_core_add(E_Client *ec, E_Util_Transform *transform)
7222 if (!transform) return;
7224 // duplication check
7225 if (ec->transform_core.transform_list &&
7226 eina_list_data_find(ec->transform_core.transform_list, transform) == transform)
7231 ec->transform_core.transform_list = eina_list_append(ec->transform_core.transform_list, transform);
7232 ec->transform_core.changed = EINA_TRUE;
7233 e_util_transform_ref(transform);
7234 // e_client_transform_core_update(ec);
7238 e_client_transform_core_remove(E_Client *ec, E_Util_Transform *transform)
7241 if (!transform) return;
7243 if (ec->transform_core.transform_list &&
7244 eina_list_data_find(ec->transform_core.transform_list, transform) == transform)
7246 ec->transform_core.transform_list = eina_list_remove(ec->transform_core.transform_list, transform);
7247 e_util_transform_unref(transform);
7248 ec->transform_core.changed = EINA_TRUE;
7251 e_client_transform_core_update(ec);
7255 e_client_transform_core_update(E_Client *ec)
7258 if (ec->new_client) return;
7259 if (!_e_client_transform_core_check_change(ec)) return;
7260 if (!ec->transform_core.activate) return;
7262 if (ec->transform_core.transform_list || ec->transform_core.parent.enable)
7264 E_Util_Transform_Rect source_rect;
7265 E_Util_Transform_Matrix matrix, boundary_matrix;
7266 E_Util_Transform_Zoom zoom;
7268 Eina_Bool background;
7269 E_Util_Transform *temp_trans;
7272 ec->transform_core.result.enable = EINA_TRUE;
7273 e_util_transform_rect_client_rect_get(&source_rect, ec);
7274 e_util_transform_init(&ec->transform_core.result.transform);
7276 // 2. merge transform
7277 EINA_LIST_FOREACH(ec->transform_core.transform_list, l, temp_trans)
7279 e_util_transform_merge(&ec->transform_core.result.transform, temp_trans);
7281 zoom = ec->transform_core.result.transform.zoom;
7283 // 2.5 check viewport
7284 if (e_util_transform_viewport_flag_get(&ec->transform_core.result.transform))
7286 int vx = 0, vy = 0, vw = 0, vh = 0;
7287 e_util_transform_viewport_get(&ec->transform_core.result.transform, &vx, &vy, &vw, &vh);
7288 e_util_transform_rect_init(&source_rect, vx, vy, vw, vh);
7291 // 3. apply background transform
7292 matrix = e_util_transform_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
7294 if (e_util_transform_bg_transform_flag_get(&ec->transform_core.result.transform))
7296 boundary_matrix = e_util_transform_bg_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
7297 background = EINA_TRUE;
7301 background = EINA_FALSE;
7302 boundary_matrix = matrix;
7305 if (background != ec->transform_core.background)
7309 e_comp_object_transform_bg_set(ec->frame, EINA_TRUE);
7313 e_comp_object_transform_bg_set(ec->frame, EINA_FALSE);
7316 ec->transform_core.background = background;
7319 // 3.1 if 24bit window then set transp rect
7324 e_util_transform_rotation_round_get(&ec->transform_core.result.transform, 0, 0, &angle);
7327 if (angle == 0) // when transform angle is 0, 90, 180, 270, 360. then set transp rect
7328 e_comp_object_transform_transp_set(ec->frame, EINA_TRUE);
7330 e_comp_object_transform_transp_set(ec->frame, EINA_FALSE);
7333 e_comp_object_transform_transp_set(ec->frame, EINA_FALSE);
7335 // 3.5 parent matrix multiply
7336 if (ec->transform_core.parent.enable)
7338 matrix = e_util_transform_matrix_multiply(&ec->transform_core.parent.matrix,
7340 boundary_matrix = e_util_transform_matrix_multiply(&ec->transform_core.parent.matrix,
7343 ec->transform_core.result.transform.use_zoom = EINA_TRUE;
7344 zoom.zoom_x *= ec->transform_core.parent.zoom.zoom_x;
7345 zoom.zoom_y *= ec->transform_core.parent.zoom.zoom_y;
7346 zoom.cx += ec->transform_core.parent.zoom.cx;
7347 zoom.cy += ec->transform_core.parent.zoom.cy;
7350 // 4. apply matrix to vertices
7351 ec->transform_core.result.matrix = matrix;
7352 ec->transform_core.result.inv_matrix = e_util_transform_matrix_inverse_get(&matrix);
7353 ec->transform_core.result.vertices = e_util_transform_rect_to_vertices(&source_rect);
7354 ec->transform_core.result.boundary.vertices = e_util_transform_rect_to_vertices(&source_rect);
7355 ec->transform_core.result.vertices = e_util_transform_matrix_multiply_rect_vertex(&matrix,
7356 &ec->transform_core.result.vertices);
7357 ec->transform_core.result.boundary.vertices = e_util_transform_matrix_multiply_rect_vertex(&boundary_matrix,
7358 &ec->transform_core.result.boundary.vertices);
7359 ec->transform_core.result.transform.zoom = zoom;
7361 // 5. apply vertices
7362 if (ec->transform_core.result.transform.use_zoom)
7364 // TODO: apply zoom values to vertices
7365 e_comp_object_transform_transp_vertices_set_with_zoom(ec->frame, &ec->transform_core.result.vertices,
7366 ec->transform_core.result.transform.zoom);
7367 e_comp_object_transform_bg_vertices_set_with_zoom(ec->frame, &ec->transform_core.result.boundary.vertices,
7368 ec->transform_core.result.transform.zoom);
7369 _e_client_transform_core_boundary_update(ec, &ec->transform_core.result.boundary.vertices);
7370 _e_client_transform_core_vertices_apply_with_zoom(ec, ec->frame, &ec->transform_core.result.vertices, &ec->transform_core.result.transform,
7371 ec->transform_core.result.transform.zoom);
7375 e_comp_object_transform_transp_vertices_set(ec->frame, &ec->transform_core.result.vertices);
7376 e_comp_object_transform_bg_vertices_set(ec->frame, &ec->transform_core.result.boundary.vertices);
7377 _e_client_transform_core_boundary_update(ec, &ec->transform_core.result.boundary.vertices);
7378 _e_client_transform_core_vertices_apply(ec, ec->frame, &ec->transform_core.result.vertices, &ec->transform_core.result.transform);
7381 // 6. subsurface update
7382 _e_client_transform_core_sub_update(ec, &ec->transform_core.result.vertices);
7384 if (!e_object_is_del(E_OBJECT(ec)))
7385 _e_client_hook_call(E_CLIENT_HOOK_TRANSFORM_CHANGE, ec);
7389 if (ec->transform_core.result.enable)
7391 ec->transform_core.result.enable = EINA_FALSE;
7392 _e_client_transform_core_vertices_apply(ec, ec->frame, NULL, NULL);
7393 e_comp_object_transform_bg_set(ec->frame, EINA_FALSE);
7394 ec->transform_core.background = EINA_FALSE;
7395 e_comp_object_transform_transp_set(ec->frame, EINA_FALSE);
7396 _e_client_transform_core_sub_update(ec, NULL);
7398 if (!e_object_is_del(E_OBJECT(ec)))
7399 _e_client_hook_call(E_CLIENT_HOOK_TRANSFORM_CHANGE, ec);
7403 e_comp_visibility_calculation_set(EINA_TRUE);
7407 e_client_transform_core_transform_count_get(E_Client *ec)
7410 if (!ec->transform_core.transform_list) return 0;
7411 return eina_list_count(ec->transform_core.transform_list);
7414 E_API E_Util_Transform*
7415 e_client_transform_core_transform_get(E_Client *ec, int index)
7417 if (!ec) return NULL;
7418 if (!ec->transform_core.transform_list) return NULL;
7419 if (index < 0 || index >= e_client_transform_core_transform_count_get(ec))
7422 return (E_Util_Transform*)eina_list_nth(ec->transform_core.transform_list, index);
7426 e_client_transform_core_input_transform(E_Client *ec, int x, int y, int *out_x, int *out_y)
7428 E_Util_Transform_Vertex vertex, result_vertex;
7431 if (!e_client_transform_core_enable_get(ec)) return;
7433 e_util_transform_vertex_init(&vertex, x, y, 0.0, 1.0);
7435 result_vertex = e_util_transform_matrix_multiply_vertex(&ec->transform_core.result.inv_matrix, &vertex);
7436 e_util_transform_vertex_pos_round_get(&result_vertex, out_x, out_y, NULL, NULL);
7440 e_client_transform_core_input_inv_transform(E_Client *ec, int x, int y, int *out_x, int *out_y)
7442 E_Util_Transform_Vertex vertex, result_vertex;
7445 if (!e_client_transform_core_enable_get(ec)) return;
7447 e_util_transform_vertex_init(&vertex, x, y, 0.0, 1.0);
7449 result_vertex = e_util_transform_matrix_multiply_vertex(&ec->transform_core.result.matrix, &vertex);
7450 e_util_transform_vertex_pos_round_get(&result_vertex, out_x, out_y, NULL, NULL);
7454 e_client_transform_core_input_inv_rect_transform(E_Client *ec, int x, int y, int *out_x, int *out_y)
7458 if (!e_client_transform_core_enable_get(ec)) return;
7459 e_client_geometry_get(ec, NULL, NULL, &gw, &gh);
7461 e_util_transform_matrix_inv_rect_coords_get(&ec->transform_core.result.transform,
7462 &ec->transform_core.result.vertices,
7464 x, y, out_x, out_y);
7468 e_client_transform_core_direct_render_set(E_Client *ec, Eina_Bool set)
7470 EINA_SAFETY_ON_NULL_RETURN(ec);
7472 if (ec->transform_core.direct_render == set) return;
7474 ec->transform_core.direct_render = set;
7475 ec->transform_core.changed = EINA_TRUE;
7477 e_client_transform_core_update(ec);
7481 e_client_pixmap_change(E_Client *ec, E_Pixmap *newcp)
7483 E_Pixmap_Type oldtype, newtype;
7486 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
7487 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->pixmap, NULL);
7488 EINA_SAFETY_ON_NULL_RETURN_VAL(newcp, NULL);
7492 oldtype = e_pixmap_type_get(oldcp);
7493 if (oldtype >= E_PIXMAP_TYPE_MAX) return NULL;
7495 newtype = e_pixmap_type_get(newcp);
7496 if (newtype >= E_PIXMAP_TYPE_MAX) return NULL;
7498 if (eina_hash_find(clients_hash[oldtype], &oldcp))
7499 eina_hash_del_by_key(clients_hash[oldtype], &oldcp);
7500 e_pixmap_client_set(oldcp, NULL);
7503 e_pixmap_client_set(newcp, ec);
7505 eina_hash_add(clients_hash[newtype], &newcp, ec);
7511 e_client_window_role_set(E_Client *ec, const char *role)
7513 EINA_SAFETY_ON_NULL_RETURN(ec);
7515 if (eina_stringshare_replace(&ec->icccm.window_role, role))
7516 _e_client_hook_call(E_CLIENT_HOOK_WINDOW_ROLE_CHANGE, ec);
7520 e_client_key_send(E_Client *ec, int keycode, Eina_Bool pressed, Ecore_Device *dev, unsigned int time)
7524 res = e_comp_wl_key_send(ec, keycode, pressed, dev, time);
7530 e_client_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, unsigned int time)
7534 res = e_comp_wl_key_cancel(ec, keycode, dev, time);
7540 e_client_touch_send(E_Client *ec, int idx, int x, int y, Eina_Bool pressed, Ecore_Device *dev, double radius_x, double radius_y, double pressure, double angle, unsigned int time)
7544 res = e_comp_wl_touch_send(ec, idx, x, y, pressed, dev, radius_x, radius_y, pressure, angle, time);
7550 e_client_touch_update_send(E_Client *ec, int idx, int x, int y, Ecore_Device *dev, double radius_x, double radius_y, double pressure, double angle, unsigned int time)
7554 res = e_comp_wl_touch_update_send(ec, idx, x, y, dev, radius_x, radius_y, pressure, angle, time);
7560 e_client_touch_cancel_send(E_Client *ec)
7564 res = e_comp_wl_touch_cancel_send(ec);
7570 e_client_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, unsigned int time)
7574 res = e_comp_wl_mouse_button_send(ec, buttons, pressed, dev, time);
7580 e_client_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time)
7584 res = e_comp_wl_mouse_move_send(ec, x, y, dev, time);
7590 e_client_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, unsigned int time)
7594 res = e_comp_wl_mouse_wheel_send(ec, direction, z, dev, time);
7600 e_client_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time)
7604 res = e_comp_wl_mouse_in_send(ec, x, y, dev, time);
7610 e_client_mouse_out_send(E_Client *ec, Ecore_Device *dev, unsigned int time)
7614 res = e_comp_wl_mouse_out_send(ec, dev, time);
7620 e_client_video_client_has(E_Client *ec)
7622 return e_comp_wl_video_subsurface_has(ec);
7626 e_client_normal_client_has(E_Client *ec)
7628 return e_comp_wl_normal_subsurface_has(ec);
7632 e_client_cursor_hide(E_Client *ec)
7634 return e_comp_wl_cursor_hide(ec);
7638 e_client_visibility_force_obscured_set(E_Client *ec, Eina_Bool set)
7642 ELOGF("TZVIS", "VIS_FORCE_OBSCURED :%d", ec, set);
7644 ec->visibility.force_obscured = set;
7645 e_comp_visibility_calculation_set(EINA_TRUE);
7648 EINTERN E_Capture_Save_State
7649 e_client_image_save(E_Client *ec, const char *dir, const char *name, E_Capture_Client_Save_End_Cb func_end, void *data, Eina_Bool skip_child)
7651 return e_comp_wl_capture_client_image_save(ec, dir, name, func_end, data, skip_child);
7655 _e_client_base_output_resolution_hook_subsurf_create(void *data, E_Client *subc)
7657 E_Client *ec, *parent;
7663 ec->base_output_resolution.use = 0;
7664 ec->base_output_resolution.w = 0;
7665 ec->base_output_resolution.h = 0;
7666 if (ec->base_output_resolution.transform)
7668 e_client_transform_core_remove(ec, ec->base_output_resolution.transform);
7669 E_FREE_FUNC(ec->base_output_resolution.transform, e_util_transform_del);
7670 ELOGF("POL_APPINFO", "Cancel TRANSFORM for subsurface", ec);
7673 /* Update transform for toplevel surface.
7674 * The transform of subsurface will be updated by its parent accordingly. */
7675 parent = e_comp_wl_topmost_parent_get(ec);
7678 parent->transform_core.changed = EINA_TRUE;
7679 e_client_transform_core_update(parent);
7682 /* TODO: Do we need to apply it again if subsurface is destroyed? */
7686 _e_client_base_output_resolution_set(E_Client *ec, int width, int height)
7689 ec->base_output_resolution.use = 1;
7690 ec->base_output_resolution.w = width;
7691 ec->base_output_resolution.h = height;
7692 ec->base_output_resolution.transform = e_util_transform_new();
7693 e_util_transform_role_set(ec->base_output_resolution.transform, "base_output_resolution");
7694 e_client_transform_core_add(ec, ec->base_output_resolution.transform);
7696 if (!ec->base_output_resolution.hook_subsurf_create)
7698 ec->base_output_resolution.hook_subsurf_create =
7699 e_comp_wl_hook_add(E_COMP_WL_HOOK_SUBSURFACE_CREATE,
7700 _e_client_base_output_resolution_hook_subsurf_create,
7706 e_client_base_output_resolution_transform_adjust(E_Client *ec)
7710 EINA_SAFETY_ON_NULL_RETURN(ec);
7711 if (!ec->base_output_resolution.use) return;
7712 if (!ec->base_output_resolution.transform) return;
7714 desk = e_comp_desk_find_by_ec(ec);
7715 EINA_SAFETY_ON_NULL_RETURN(desk);
7717 ELOGF("POL_APPINFO", "Apply TRANSFORM... desk:(%dx%d), ec:(%dx%d)",
7718 ec, desk->geom.w, desk->geom.h, ec->w, ec->h);
7720 e_util_transform_scale(ec->base_output_resolution.transform,
7721 (double)desk->geom.w /(double)ec->base_output_resolution.w,
7722 (double)desk->geom.h /(double)ec->base_output_resolution.h,
7724 e_client_transform_core_update(ec);
7728 e_client_base_output_resolution_update(E_Client *ec)
7730 E_Appinfo *eai = NULL;
7731 int configured_width, configured_height;
7735 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
7737 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
7738 if (ec->base_output_resolution.use) return EINA_TRUE;
7740 /* Check whether it's subsurface or not
7741 * The resolution of subsurface will follow the resolution of its toplevel surface.
7742 * Transform for subsurface will be applied when toplevel surface does by
7743 * implementation of e_client_transform_core.
7745 if (e_comp_wl_subsurface_check(ec))
7748 desk = e_comp_desk_find_by_ec(ec);
7749 EINA_SAFETY_ON_NULL_RETURN_VAL(desk, EINA_FALSE);
7751 configured_width = e_config->configured_output_resolution.w;
7752 configured_height = e_config->configured_output_resolution.h;
7756 ELOGF("POL_APPINFO", "NO PID... USE configured_output_resolution(%d,%d) pid:%d", ec,
7757 configured_width, configured_height, ec->netwm.pid);
7758 goto use_configured;
7761 eai = e_appinfo_find_with_pid(ec->netwm.pid);
7764 ELOGF("POL_APPINFO", "NO APPINFO... USE configured_output_resolution(%d,%d) pid:%d", ec,
7765 configured_width, configured_height, ec->netwm.pid);
7766 goto use_configured;
7769 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7771 ELOGF("POL_APPINFO", "NO BASE SCREEN RESOLUTION... USE configured_output_resolution(%d,%d) pid:%d", ec,
7772 configured_width, configured_height, ec->netwm.pid);
7773 goto use_configured;
7776 if ((width == 0) && (height == 0))
7778 ELOGF("POL_APPINFO", "SKIP SET BASE SCREEN RESOLUTION... base_output_resolution size:(%d,%d) pid:%d", ec, width, height, ec->netwm.pid);
7782 if ((desk->geom.w == width) && (desk->geom.h == height))
7784 ELOGF("POL_APPINFO", "SKIP SET BASE SCREEN RESOLUTION... base_output_resolution is same with desk size:(%d,%d), pid:%d", ec, width, height, ec->netwm.pid);
7788 /* set the base_output_resolution of the e_client */
7789 _e_client_base_output_resolution_set(ec, width, height);
7791 ELOGF("POL_APPINFO", "USE base_output_resolution(%d,%d) pid:%d", ec, width, height, ec->netwm.pid);
7797 if ((desk->geom.w == configured_width) && (desk->geom.h == configured_height))
7799 ELOGF("POL_APPINFO", "SKIP use configured_output_resolution (same with desk size:(%d,%d), pid:%d)", ec, configured_width, configured_height, ec->netwm.pid);
7803 /* set the base_output_resolution of the e_client as a default */
7804 _e_client_base_output_resolution_set(ec, configured_width, configured_height);
7811 e_client_base_output_resolution_useful_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
7816 E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
7818 zone = e_comp_zone_find_by_ec(ec);
7819 EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
7821 e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
7828 if (ec->base_output_resolution.use)
7830 if (w) *w = ec->base_output_resolution.w;
7831 if (h) *h = ec->base_output_resolution.h;
7838 e_client_base_output_resolution_desk_useful_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h, Eina_Bool consider_obstacle_area)
7843 E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
7845 zone = e_comp_zone_find_by_ec(ec);
7846 EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
7848 e_zone_desk_useful_geometry_get(zone, ec->desk, &zx, &zy, &zw, &zh, consider_obstacle_area);
7855 if (ec->base_output_resolution.use)
7857 // TODO: Consider obstacle area
7858 if (w) *w = ec->base_output_resolution.w;
7859 if (h) *h = ec->base_output_resolution.h;
7865 /* change the base_output_resolution of the bind_ec by checking the base_output_resolution of provider_ec's appinfo */
7867 e_client_base_output_resolution_rsm_update(E_Client *bind_ec, E_Client *provider_ec)
7869 E_Appinfo *epai = NULL;
7870 int configured_width, configured_height;
7872 E_Desk *bind_ec_desk;
7874 EINA_SAFETY_ON_NULL_RETURN_VAL(bind_ec, EINA_FALSE);
7875 EINA_SAFETY_ON_NULL_RETURN_VAL(provider_ec, EINA_FALSE);
7877 bind_ec_desk = e_comp_desk_find_by_ec(bind_ec);
7878 EINA_SAFETY_ON_NULL_RETURN_VAL(bind_ec_desk, EINA_FALSE);
7880 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
7882 configured_width = e_config->configured_output_resolution.w;
7883 configured_height = e_config->configured_output_resolution.h;
7885 if (bind_ec->base_output_resolution.use)
7887 ELOGF("POL_APPINFO", "DELETE EXISTED BINDER BASE SCREEN RESOLUTION... base_output_resolution is same with desk size:(%d,%d), bind_pid:%d", bind_ec,
7888 bind_ec->base_output_resolution.w, bind_ec->base_output_resolution.h, bind_ec->netwm.pid);
7890 bind_ec->base_output_resolution.use = 0;
7891 bind_ec->base_output_resolution.w = 0;
7892 bind_ec->base_output_resolution.h = 0;
7893 e_client_transform_core_remove(bind_ec, bind_ec->base_output_resolution.transform);
7894 E_FREE_FUNC(bind_ec->base_output_resolution.transform, e_util_transform_del);
7897 if (!provider_ec->netwm.pid)
7899 ELOGF("POL_APPINFO", "NO PROVIDER PID... USE configured_output_resolution(%d,%d) provider_pid:%d", provider_ec,
7900 configured_width, configured_height, provider_ec->netwm.pid);
7901 goto use_configured;
7904 epai = e_appinfo_find_with_pid(provider_ec->netwm.pid);
7907 ELOGF("POL_APPINFO", "NO PROVIDER APPINFO... USE configured_output_resolution(%d,%d) provider_pid:%d", provider_ec,
7908 configured_width, configured_height, provider_ec->netwm.pid);
7909 goto use_configured;
7912 if (!e_appinfo_base_output_resolution_get(epai, &width, &height))
7914 ELOGF("POL_APPINFO", "NO PROVIDER APPINFO BASE SCREEN RESOLUTION... USE configured_output_resolution(%d,%d) provider_pid:%d", provider_ec,
7915 configured_width, configured_height, provider_ec->netwm.pid);
7916 goto use_configured;
7919 if ((width == 0) && (height == 0))
7921 ELOGF("POL_APPINFO", "NO PROVIDER WIDTH and HEIGHT... SKIP base_output_resolution due to size:(%d,%d) provider_pid:%d", provider_ec,
7922 width, height, provider_ec->netwm.pid);
7926 if ((bind_ec_desk->geom.w == width) && (bind_ec_desk->geom.h == height))
7928 ELOGF("POL_APPINFO", "SKIP SET BINDER BASE SCREEN RESOLUTION... base_output_resolution is same with desk size:(%d,%d), bind_pid:%d", bind_ec,
7929 width, height, bind_ec->netwm.pid);
7933 /* set the base_output_resolution of the e_client */
7934 _e_client_base_output_resolution_set(bind_ec, width, height);
7935 e_client_base_output_resolution_transform_adjust(bind_ec);
7937 ELOGF("POL_APPINFO", "USE BINDER base_output_resolution(%d,%d) bind_pid:%d", bind_ec, width, height, bind_ec->netwm.pid);
7943 if ((bind_ec_desk->geom.w == configured_width) && (bind_ec_desk->geom.h == configured_height))
7945 ELOGF("POL_APPINFO", "SKIP BINDER use configured_output_resolution (same with desk size:(%d,%d), bind_pid:%d)", bind_ec,
7946 configured_width, configured_height, bind_ec->netwm.pid);
7950 /* set the base_output_resolution of the e_client as a default */
7951 _e_client_base_output_resolution_set(bind_ec, configured_width, configured_height);
7957 /* tizen_move_resize */
7959 e_client_pending_geometry_has(E_Client *ec)
7961 if (!eina_list_count(ec->surface_sync.pending_geometry))
7964 return ec->surface_sync.wait_commit;
7968 e_client_pending_geometry_flush(E_Client *ec)
7970 E_Client_Pending_Geometry *geo;
7972 if (!eina_list_count(ec->surface_sync.pending_geometry))
7974 EINA_LIST_FREE(ec->surface_sync.pending_geometry, geo)
7978 ec->surface_sync.wait_commit = EINA_FALSE;
7979 ELOGF("POSSIZE", "pending geometry has flushed", ec);
7984 e_client_pending_geometry_last_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
7987 E_Client_Pending_Geometry *geo;
7993 EINA_LIST_REVERSE_FOREACH(ec->surface_sync.pending_geometry, l, geo)
8009 e_client_frame_focus_set(E_Client *ec, Eina_Bool focus)
8012 evas_object_focus_set(ec->frame, focus);
8016 e_client_frame_geometry_set(E_Client *ec, int x, int y, int w, int h)
8020 if (ec->internal || ec->input_only)
8022 evas_object_geometry_set(ec->frame, x, y, w, h);
8026 if ((ec->w != w) || (ec->h != h))
8028 ELOGF("POSSIZE", "Set move_after_resize. old(%d,%d,%dx%d), new(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h, x, y, w, h);
8029 ec->move_after_resize = EINA_TRUE;
8031 e_client_pos_set(ec, x, y);
8032 evas_object_resize(ec->frame, w, h);
8035 evas_object_geometry_set(ec->frame, x, y, w, h);
8040 e_client_util_move_resize_without_frame(E_Client *ec, int x, int y, int w, int h)
8044 if (ec->internal || ec->input_only)
8046 e_client_util_move_without_frame(ec, x, y);
8047 e_client_util_resize_without_frame(ec, w, h);
8051 if ((ec->w != w) || (ec->h != h))
8053 ELOGF("POSSIZE", "Set move_after_resize. old(%d,%d,%dx%d), new(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h, x, y, w, h);
8054 ec->move_after_resize = EINA_TRUE;
8056 e_comp_object_frame_xy_adjust(ec->frame, x, y, &x, &y);
8057 e_client_pos_set(ec, x, y);
8058 e_client_util_resize_without_frame(ec, w, h);
8062 e_client_util_move_without_frame(ec, x, y);
8063 e_client_util_resize_without_frame(ec, w, h);
8069 e_client_layer_set(E_Client *ec,
8072 E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
8073 E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
8074 if (!ec->frame) return EINA_FALSE;
8076 if (e_comp_canvas_client_layer_map(layer) == 9999)
8077 return EINA_FALSE; //invalid layer is not allowed
8079 if (ec->desk_area.enable)
8081 if (e_client_layer_set_by_desk_area(ec, layer))
8083 // restack according to desk group rule
8084 e_desk_area_ec_rearrange(ec->desk_area.desk_area, ec);
8088 ec->desk_area.layer_backup = layer;
8090 evas_object_layer_set(ec->frame, layer);
8091 if (ec->layer != layer)
8093 /* check exceptional case */
8094 if ((ec->fullscreen) &&
8095 (ec->saved.layer != layer))
8097 ELOGF("LAYER", "(%d) fail to backup at saved.layer for fullscreen", ec, layer);
8100 // if e_comp_object fail to change ec->layer due to ec->layer_pending or block
8101 // leave log and apply ec->layer according to set
8102 // as a result it restores back to given layer when pending or block is free
8103 ELOGF("LAYER", "change layer from %d to %d if in case layer pending(%d) or block(%d)",
8104 ec, ec->layer, layer, ec->layer_pending, ec->layer_block);
8105 if (ec->layer_pending || ec->layer_block)
8116 e_client_layer_get(E_Client *ec)
8120 E_OBJECT_CHECK_RETURN(ec, E_LAYER_BOTTOM);
8121 E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, E_LAYER_BOTTOM);
8122 if (!ec->frame) return E_LAYER_BOTTOM;
8124 layer = evas_object_layer_get(ec->frame);
8125 if (ec->layer != layer)
8127 /* client could be on temperory layer while pending or block,
8128 * in that case, client restores back to ec->layer after pending/block finish */
8129 if (ec->layer_block || ec->layer_pending)
8132 /* otherwise, client is on unexpected layer */
8133 ELOGF("LAYER", "layer dismatch ec->layer %d | evas obj layer %d ",
8134 ec, ec->layer, layer);
8136 if (e_comp_canvas_client_layer_map(layer) == 9999)
8137 return E_LAYER_BOTTOM; //not on E_LAYER_CLIENT
8144 _e_client_desk_area_original_layer_save(E_Client *ec, E_Layer layer)
8147 E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
8148 ec->desk_area.layer_backup = layer;
8152 e_client_layer_set_by_desk_area(E_Client *ec, E_Layer layer)
8158 if (!ec) return EINA_FALSE;
8159 if (!ec->frame) return EINA_FALSE;
8160 if (!ec->desk_area.enable) return EINA_FALSE;
8161 if (!ec->desk_area.desk_area) return EINA_FALSE;
8163 eda = ec->desk_area.desk_area;
8165 // save original layer
8166 _e_client_desk_area_original_layer_save(ec, layer);
8168 // get desk_area layer
8169 edg_layer = (E_Layer)e_desk_area_layer_get(eda);
8170 org_layer = e_client_desk_area_original_layer_get(ec);
8172 ELOGF("EDG", "layer_set by desk_area... layer:%d, org_layer:%d, new_layer:%d", ec, layer, org_layer, edg_layer);
8173 if (org_layer == edg_layer)
8179 evas_object_layer_set(ec->frame, edg_layer);
8180 if (edg_layer == ec->layer)
8188 e_client_desk_area_original_layer_restore(E_Client *ec)
8192 // Do we need to check ec->desk_area.enable?
8193 // if ec->desk_area.enable is true, then e_client_layer_set calls
8194 // e_desk_area_ec_layer_set(). that's too bad. :(
8195 // so, we MUST make a policy for ordering of the desk group layer restore
8196 // and the desk group enable.
8197 if (ec->desk_area.enable) return;
8198 e_client_layer_set(ec, ec->desk_area.layer_backup);
8202 e_client_desk_area_original_layer_get(E_Client *ec)
8204 if (!ec) return E_LAYER_DESKTOP;
8206 if (ec->desk_area.enable)
8207 return ec->desk_area.layer_backup;
8213 e_client_desk_area_client_layer_set(E_Client *ec, E_Desk_Area_Client_Layer edgc_layer)
8215 E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
8216 E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
8217 if ((edgc_layer < E_DESK_AREA_CLIENT_LAYER_DESKTOP) ||
8218 (edgc_layer >= E_DESK_AREA_CLIENT_LAYER_MAX))
8221 ec->desk_area.edgc_layer = edgc_layer;
8225 EINTERN E_Desk_Area_Client_Layer
8226 e_client_desk_area_client_layer_get(E_Client *ec)
8228 E_OBJECT_CHECK_RETURN(ec, E_DESK_AREA_CLIENT_LAYER_DESKTOP);
8230 return ec->desk_area.edgc_layer;
8234 e_client_desk_area_enable_set(E_Client *ec, Eina_Bool enable)
8236 E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
8237 E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
8239 ec->desk_area.enable = enable;
8241 ELOGF("EDG", "Desk group enable set to %d", ec, enable);
8244 if (!ec->desk_area.transform)
8246 ec->desk_area.transform = e_util_transform_new();
8247 e_util_transform_role_set(ec->desk_area.transform, "desk_area");
8252 if (ec->desk_area.transform)
8254 e_util_transform_del(ec->desk_area.transform);
8255 ec->desk_area.transform = NULL;
8259 e_desk_area_ec_update(ec->desk_area.desk_area, ec);
8264 e_client_desk_area_set(E_Client *ec, E_Desk_Area *eda)
8266 E_Desk_Area *old_edg;
8268 if (!ec) return EINA_FALSE;
8270 #if 0 // if this is removed.. then below if (eda != old_edg) is removed also...
8271 if (ec->desk_area.desk_area == eda)
8275 ELOGF("EDG", "Desk Group Set (new:%p, old:%p)", ec, eda, ec->desk_area.desk_area);
8276 old_edg = ec->desk_area.desk_area;
8278 e_desk_area_ec_remove(old_edg, ec);
8280 ec->desk_area.desk_area = eda;
8281 e_desk_area_ec_add(eda, ec);
8283 #if 0 // if this is removed.. then above if (ec->desk_area.desk_area == eda) is removed also...
8287 e_desk_area_ec_update(eda, ec);
8288 e_desk_area_ec_rearrange(ec->desk_area.desk_area, ec);
8295 _raise_between_sibling_under_parent(E_Client *ec)
8297 ELOGF("POL", "RAISE child window between sibling. So, stack below under the parent (win:%zx, ec:%p)", ec, e_client_util_win_get(ec->parent), ec->parent);
8298 e_client_stack_below(ec, ec->parent);
8302 _raise_between_sibling_on_parent(E_Client *ec)
8304 E_Client *top_child = NULL;
8305 top_child = e_client_transient_child_top_get(ec->parent, EINA_FALSE);
8308 ELOGF("POL", "RAISE child window... Stack above on the parent (win:%zx, ec:%p)", ec, e_client_util_win_get(ec->parent), ec->parent);
8309 e_client_stack_above(ec, ec->parent);
8313 if (top_child != ec)
8315 ELOGF("POL", "RAISE child window between sibling... Stack above on the top child (win:%zx, ec:%p)", ec, e_client_util_win_get(top_child), top_child);
8316 e_client_stack_above(ec, top_child);
8319 ELOGF("POL", "RAISE child window between sibling... already on the top. STAY", ec);
8324 _raise_belong_to_parent(E_Client *ec)
8326 if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
8327 _raise_between_sibling_under_parent(ec);
8329 _raise_between_sibling_on_parent(ec);
8333 e_client_raise(E_Client *ec)
8337 if (ec->desk_area.enable)
8340 eda = ec->desk_area.desk_area;
8343 e_desk_area_ec_raise(eda, ec);
8348 if (ec->parent && e_client_is_belong_to_parent(ec))
8349 _raise_belong_to_parent(ec);
8351 evas_object_raise(ec->frame);
8355 _e_client_transient_for_below_group_make(E_Client *ec, Eina_List **list)
8357 // list : Head is the bottommost child
8363 EINA_LIST_REVERSE_FOREACH(ec->transients, l, child)
8365 if (!child) continue;
8366 if (e_client_transient_policy_get(child) != E_TRANSIENT_BELOW) continue;
8367 if (!e_client_is_belong_to_parent(child)) continue;
8369 *list = eina_list_prepend(*list, child);
8370 _e_client_transient_for_group_make(child, list);
8375 e_client_transient_child_bottom_get(E_Client *ec)
8377 E_Client *bottom_ec = NULL;
8378 Eina_List *transient_below_list = NULL;
8379 Eina_List *l = NULL;
8381 _e_client_transient_for_below_group_make(ec, &transient_below_list);
8383 if (transient_below_list)
8385 E_Client *temp_ec = NULL;
8386 E_Client *temp_ec2 = NULL;
8388 E_CLIENT_FOREACH(temp_ec)
8390 if (bottom_ec) break;
8398 EINA_LIST_FOREACH(transient_below_list, l, temp_ec2)
8400 if (temp_ec == temp_ec2)
8402 bottom_ec = temp_ec2;
8407 eina_list_free(transient_below_list);
8413 _lower_between_sibling_under_parent(E_Client *ec)
8415 E_Client *bottom_child = NULL;
8416 bottom_child = e_client_transient_child_bottom_get(ec->parent);
8419 ELOGF("POL", "LOWER child window between sibling... Stack below under the parent (win:%zx, ec:%p)", ec, e_client_util_win_get(ec->parent), ec->parent);
8420 e_client_stack_below(ec, ec->parent);
8424 if (bottom_child != ec)
8426 ELOGF("POL", "LOWER child window between sibling... Stack below under the bottom child (win:%zx, ec:%p)", ec, e_client_util_win_get(bottom_child), bottom_child);
8427 e_client_stack_below(ec, bottom_child);
8430 ELOGF("POL", "LOWER child window between sibling... already under the bottom. STAY", ec);
8435 _lower_between_sibling_on_parent(E_Client *ec)
8437 ELOGF("POL", "LOWER child window between sibling... So, stack above on the parent (win:%zx, ec:%p)", ec, e_client_util_win_get(ec->parent), ec->parent);
8438 e_client_stack_above(ec, ec->parent);
8442 _lower_belong_to_parent(E_Client *ec)
8444 if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
8445 _lower_between_sibling_under_parent(ec);
8447 _lower_between_sibling_on_parent(ec);
8451 e_client_lower(E_Client *ec)
8455 if (ec->desk_area.enable)
8458 eda = ec->desk_area.desk_area;
8461 e_desk_area_ec_lower(eda, ec);
8462 #ifdef REFACTOR_FOCUS_POLICY
8463 _e_client_hook_call(E_CLIENT_HOOK_LOWER, ec);
8469 if (ec->parent && e_client_is_belong_to_parent(ec))
8470 _lower_belong_to_parent(ec);
8472 evas_object_lower(ec->frame);
8474 #ifdef REFACTOR_FOCUS_POLICY
8475 _e_client_hook_call(E_CLIENT_HOOK_LOWER, ec);
8480 e_client_stack_above(E_Client *ec, E_Client *above)
8483 if (!ec->frame) return;
8485 if (!above->frame) return;
8487 if (ec->desk_area.enable)
8490 eda = ec->desk_area.desk_area;
8493 e_desk_area_ec_stack_above(eda, ec, above);
8498 evas_object_stack_above(ec->frame, above->frame);
8502 e_client_stack_below(E_Client *ec, E_Client *below)
8505 if (!ec->frame) return;
8507 if (!below->frame) return;
8509 if (ec->desk_area.enable)
8512 eda = ec->desk_area.desk_area;
8515 e_desk_area_ec_stack_below(eda, ec, below);
8520 evas_object_stack_below(ec->frame, below->frame);
8524 e_client_show_pending_set(E_Client *ec)
8528 ec->show_pending.count++;
8529 ELOGF("E_CLIENT", "SET show_pending. (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
8530 return ec->show_pending.count;
8534 e_client_show_pending_unset(E_Client *ec)
8537 if (ec->show_pending.count <= 0) return 0;
8539 ec->show_pending.count--;
8540 ELOGF("E_CLIENT", "UNSET show_pending. (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
8541 if (ec->show_pending.count == 0 && ec->show_pending.running)
8543 ec->show_pending.running = EINA_FALSE;
8546 ELOGF("E_CLIENT", "evas_object_show by unset show_pending", ec);
8547 evas_object_show(ec->frame);
8548 //e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
8553 return ec->show_pending.count;
8557 _e_client_surface_tree_foreach_helper(E_Client *ec, E_Client_Surface_Tree_Foreach func, void *data)
8561 Eina_Bool res = EINA_TRUE;
8562 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
8567 EINA_LIST_FOREACH_SAFE(cdata->sub.below_list, l, ll, subc)
8569 res = _e_client_surface_tree_foreach_helper(subc, func, data);
8576 res = func(data, ec);
8579 EINA_LIST_FOREACH_SAFE(cdata->sub.list, l, ll, subc)
8581 res = _e_client_surface_tree_foreach_helper(subc,
8594 e_client_surface_tree_foreach(E_Client *ec, E_Client_Surface_Tree_Foreach func, void *data)
8596 EINA_SAFETY_ON_NULL_RETURN(ec);
8597 EINA_SAFETY_ON_NULL_RETURN(func);
8599 _e_client_surface_tree_foreach_helper(ec, func, data);
8602 EINTERN E_Comp_Wl_Client_Data *
8603 e_client_cdata_new(E_Client *ec)
8605 E_Comp_Wl_Client_Data *cdata;
8607 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
8609 if (!(cdata = E_NEW(E_Comp_Wl_Client_Data, 1)))
8611 ERR("Could not allocate new E_Comp_Wl_Client_Data structure");
8614 ec->comp_data = cdata;
8620 e_client_cdata_free(E_Client *ec)
8622 EINA_SAFETY_ON_NULL_RETURN(ec);
8623 if (!ec->comp_data) return;
8625 E_FREE(ec->comp_data);
8628 EINTERN E_Comp_Wl_Client_Data *
8629 e_client_cdata_get(E_Client *ec)
8631 if (!ec) return NULL;
8633 return ec->comp_data;
8637 e_client_map_set(E_Client *ec, E_Map *em)
8639 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8641 return e_map_set_to_comp_object(em, ec->frame);
8645 e_client_map_get(const E_Client *ec)
8647 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
8649 return e_map_get_from_comp_object(ec->frame);
8653 e_client_map_enable_set(E_Client *ec, Eina_Bool enable)
8655 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8656 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->frame, EINA_FALSE);
8658 evas_object_map_enable_set(ec->frame, enable);
8664 e_client_belong_to_parent_set(E_Client *ec, Eina_Bool set)
8667 ec->belong_to_parent = set;
8671 e_client_is_belong_to_parent(E_Client *ec)
8673 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8674 return ec->belong_to_parent;
8678 e_client_transient_policy_set(E_Client *ec, E_Transient policy)
8681 ec->transient_policy = policy;
8685 e_client_transient_policy_get(E_Client *ec)
8687 if (!ec) return E_TRANSIENT_ABOVE;
8688 return ec->transient_policy;
8692 e_client_resize_object_create_cb_set(E_Client_Resize_Object_Create_Cb cb)
8694 if (_e_client_resize_object_create_cb && cb)
8695 CRI("ATTEMPTING TO OVERWRITE EXISTING CLIENT RESIZE OBJECT CREATE HOOK!!!");
8696 _e_client_resize_object_create_cb = cb;
8700 e_client_resize_unit_size_set(E_Client *ec, unsigned int unit_size)
8704 // FYI, we consider 0 and 1 to be the same value as a default unit size.
8705 ec->manage_resize.unit_size = unit_size;
8709 e_client_desk_zoom_enable_set(E_Client *ec, Eina_Bool enable)
8712 ec->desk_zoom.enable = enable;
8716 e_client_desk_zoom_enable_get(E_Client *ec)
8718 if (!ec) return EINA_FALSE;
8719 return ec->desk_zoom.enable;
8723 e_client_layout_apply(E_Client *ec, Eina_Bool apply)
8726 ec->apply_layout = apply;
8730 e_client_is_layout_apply(E_Client *ec)
8732 if (!ec) return EINA_FALSE;
8733 return ec->apply_layout;
8737 e_client_from_surface_resource(struct wl_resource *surface_resource)
8739 EINA_SAFETY_ON_NULL_RETURN_VAL(surface_resource, NULL);
8741 return e_comp_wl_util_client_from_surface_resource(surface_resource);
8745 e_client_fps_update(E_Client *ec)
8750 EINA_SAFETY_ON_NULL_RETURN(ec);
8752 if (!ec->fps.enabled) return;
8754 tim = ecore_time_get();
8756 dt = tim - ec->fps.frametimes[0];
8758 ec->fps.frametimes[0] = tim;
8762 if (ec->fps.lapse == 0.0)
8764 ec->fps.lapse = tim;
8765 ec->fps.flapse = ec->fps.cframes;
8767 else if ((tim - ec->fps.lapse) >= 0.5)
8769 ec->fps.fps = (ec->fps.cframes - ec->fps.flapse) /
8770 (tim - ec->fps.lapse);
8771 ec->fps.lapse = tim;
8772 ec->fps.flapse = ec->fps.cframes;
8778 e_client_fps_get(E_Client *ec, double *fps)
8780 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8782 if (ec->fps.old_fps == ec->fps.fps)
8785 if (ec->fps.fps > 0.0)
8788 ec->fps.old_fps = ec->fps.fps;
8796 e_client_fps_enable(E_Client *ec, Eina_Bool enable)
8798 EINA_SAFETY_ON_NULL_RETURN(ec);
8800 ec->fps.enabled = enable;
8804 e_client_explicit_sync_get(E_Client *ec)
8806 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8808 return ec->explicit_sync;
8812 e_client_explicit_sync_set(E_Client *ec, Eina_Bool enable)
8814 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8816 ec->explicit_sync = enable;
8822 e_client_explicit_sync_acquire_fence_fd_get(E_Client *ec)
8824 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, -1);
8826 return ec->acquire_fence_fd;
8830 e_client_explicit_sync_acquire_fence_fd_set(E_Client *ec, int fd)
8832 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
8834 ec->acquire_fence_fd = fd;
8839 #ifdef REFACTOR_ZONE_DESK
8841 e_client_intercept_hook_auto_placement_call(E_Client *ec)
8843 // no need to call the intercept hook if ec is NULL.
8844 if (!ec) return EINA_FALSE;
8846 if (!_e_client_intercept_hook_call(E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT, ec))
8848 ELOGF("FOCUS", "E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT Intercepted.", ec);
8856 e_client_iconify_event_send(E_Client *ec)
8858 EINA_SAFETY_ON_NULL_RETURN(ec);
8860 _e_client_event_simple(ec, E_EVENT_CLIENT_ICONIFY);
8864 e_client_uniconify_event_send(E_Client *ec)
8866 EINA_SAFETY_ON_NULL_RETURN(ec);
8868 _e_client_event_simple(ec, E_EVENT_CLIENT_UNICONIFY);
8873 e_client_destroy_listener_add(E_Client *ec, struct wl_listener *listener)
8876 wl_signal_add(&priv->events.destroy, listener);
8879 EINTERN struct wl_listener *
8880 e_client_destroy_listener_get(E_Client *ec, wl_notify_func_t notify)
8882 API_ENTRY_VAL(NULL);
8883 return wl_signal_get(&priv->events.destroy, notify);