e_client: deprecate some values of icccm in E_Client
[platform/upstream/enlightenment.git] / src / bin / e_client.c
1 #include "e.h"
2 #include "e_client_intern.h"
3
4 #define PRI(ec) ((E_Client_Private *)e_object_data_get(E_OBJECT(ec)))
5
6 #define API_ENTRY \
7    EINA_SAFETY_ON_NULL_RETURN(ec); \
8    E_Client_Private *priv = PRI(ec)
9
10 #define API_ENTRY_VAL(ret) \
11    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ret); \
12    E_Client_Private *priv = PRI(ec)
13
14 typedef struct _E_Client_Private E_Client_Private;
15
16 struct _E_Client_Private
17 {
18    struct
19      {
20         struct wl_signal eval_pre_fetch;
21         struct wl_signal eval_fetch;
22         struct wl_signal eval_pre_post_fetch;
23         struct wl_signal eval_post_fetch;
24         struct wl_signal eval_pre_frame_assign;
25         struct wl_signal eval_post_frame_assign;
26         struct wl_signal eval_pre_new_client;
27         struct wl_signal eval_post_new_client;
28         struct wl_signal eval_visibility;
29         struct wl_signal eval_visibility_end;
30         struct wl_signal eval_end;
31
32         struct wl_signal move_begin;
33         struct wl_signal move_update;
34         struct wl_signal move_end;
35         struct wl_signal move_resize_begin;
36         struct wl_signal move_resize_update;
37         struct wl_signal move_resize_end;
38
39         struct wl_signal destroy;
40         struct wl_signal new_client;
41         struct wl_signal new_client_post;
42
43         struct wl_signal unredirect;
44         struct wl_signal redirect;
45
46         struct wl_signal aux_hint_change;
47         struct wl_signal window_role_change;
48         struct wl_signal transform_change;
49         struct wl_signal activate_done;
50
51         struct wl_signal mouse_in;
52         struct wl_signal mouse_out;
53         struct wl_signal mouse_down;
54
55         struct wl_signal focus_set;
56         struct wl_signal focus_unset;
57         struct wl_signal focus_defer_set;
58         struct wl_signal focus_latest_set;
59
60         struct wl_signal iconify;
61         struct wl_signal uniconify;
62         struct wl_signal maximize;
63         struct wl_signal unmaximize;
64         struct wl_signal fullscreen_pre;
65         struct wl_signal fullscreen;
66         struct wl_signal unfullscreen;
67
68         struct wl_signal move;
69
70         struct wl_signal layer_set;
71         struct wl_signal raise;
72         struct wl_signal lower;
73         struct wl_signal stack_below;
74         struct wl_signal stack_above;
75         struct wl_signal stack_transient_for_done;
76
77         struct wl_signal stick;
78         struct wl_signal unstick;
79      } events;
80
81    Eina_Bool hide_by_request;
82 };
83
84 static int _e_client_hooks_delete = 0;
85 static int _e_client_hooks_walking = 0;
86
87 static int _e_client_intercept_hooks_delete = 0;
88 static int _e_client_intercept_hooks_walking = 0;
89
90 E_API int E_EVENT_CLIENT_ADD = -1;
91 E_API int E_EVENT_CLIENT_REMOVE = -1;
92 E_API int E_EVENT_CLIENT_ZONE_SET = -1;
93 E_API int E_EVENT_CLIENT_DESK_SET = -1;
94 E_API int E_EVENT_CLIENT_RESIZE = -1;
95 E_API int E_EVENT_CLIENT_MOVE = -1;
96 E_API int E_EVENT_CLIENT_SHOW = -1;
97 E_API int E_EVENT_CLIENT_HIDE = -1;
98 E_API int E_EVENT_CLIENT_ICONIFY = -1;
99 E_API int E_EVENT_CLIENT_UNICONIFY = -1;
100 E_API int E_EVENT_CLIENT_STACK = -1;
101 E_API int E_EVENT_CLIENT_FOCUS_IN = -1;
102 E_API int E_EVENT_CLIENT_FOCUS_OUT = -1;
103 E_API int E_EVENT_CLIENT_PROPERTY = -1;
104 E_API int E_EVENT_CLIENT_FULLSCREEN = -1;
105 E_API int E_EVENT_CLIENT_UNFULLSCREEN = -1;
106 #ifdef _F_ZONE_WINDOW_ROTATION_
107 E_API int E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN = -1;
108 E_API int E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL = -1;
109 E_API int E_EVENT_CLIENT_ROTATION_CHANGE_END = -1;
110 E_API int E_EVENT_CLIENT_ROTATION_GEOMETRY_SET = -1;
111 #endif
112 E_API int E_EVENT_CLIENT_VISIBILITY_CHANGE = -1;
113 E_API int E_EVENT_CLIENT_BUFFER_CHANGE = -1;
114 E_API int E_EVENT_CLIENT_FOCUS_SKIP_SET = -1;
115 E_API int E_EVENT_CLIENT_FOCUS_SKIP_UNSET = -1;
116
117 static Eina_Hash *clients_hash[E_PIXMAP_TYPE_MAX] = {NULL}; // pixmap->client
118
119 static E_Client *ecmove = NULL;
120 static E_Client *ecresize = NULL;
121 static E_Client *action_client = NULL;
122
123 static Eina_Bool comp_grabbed = EINA_FALSE;
124
125 static Eina_List *handlers = NULL;
126 static Eina_List *hooks = NULL;
127
128 static Ecore_Event_Handler *action_handler_mouse = NULL;
129 static Ecore_Timer *action_timer = NULL;
130 static Eina_Rectangle action_orig = {0, 0, 0, 0};
131
132 static E_Client_Resize_Object_Create_Cb _e_client_resize_object_create_cb = NULL;
133
134 EINTERN void e_client_focused_set(E_Client *ec);
135 static void _e_client_transient_for_group_make(E_Client *ec, Eina_List **list);
136 static Evas_Object *_e_client_resize_object_create(E_Client *ec);
137 static void _e_client_resize_object_del(E_Client *ec);
138 static void _e_client_stay_within_canvas(E_Client *ec, int x, int y, int *new_x, int *new_y);
139 static void _e_client_stay_within_canvas_margin(E_Client *ec, int x, int y, int *new_x, int *new_y);
140
141 static Eina_Inlist *_e_client_hooks[] =
142 {
143    [E_CLIENT_HOOK_EVAL_PRE_FETCH] = NULL,
144    [E_CLIENT_HOOK_EVAL_FETCH] = NULL,
145    [E_CLIENT_HOOK_EVAL_PRE_POST_FETCH] = NULL,
146    [E_CLIENT_HOOK_EVAL_POST_FETCH] = NULL,
147    [E_CLIENT_HOOK_EVAL_PRE_FRAME_ASSIGN] = NULL,
148    [E_CLIENT_HOOK_EVAL_POST_FRAME_ASSIGN] = NULL,
149    [E_CLIENT_HOOK_EVAL_PRE_NEW_CLIENT] = NULL,
150    [E_CLIENT_HOOK_EVAL_POST_NEW_CLIENT] = NULL,
151    [E_CLIENT_HOOK_EVAL_END] = NULL,
152    [E_CLIENT_HOOK_FOCUS_SET] = NULL,
153    [E_CLIENT_HOOK_FOCUS_UNSET] = NULL,
154    [E_CLIENT_HOOK_NEW_CLIENT] = NULL,
155    [E_CLIENT_HOOK_MOVE_BEGIN] = NULL,
156    [E_CLIENT_HOOK_MOVE_UPDATE] = NULL,
157    [E_CLIENT_HOOK_MOVE_END] = NULL,
158    [E_CLIENT_HOOK_RESIZE_BEGIN] = NULL,
159    [E_CLIENT_HOOK_RESIZE_UPDATE] = NULL,
160    [E_CLIENT_HOOK_RESIZE_END] = NULL,
161    [E_CLIENT_HOOK_FULLSCREEN_PRE] = NULL,
162    [E_CLIENT_HOOK_DEL] = NULL,
163    [E_CLIENT_HOOK_UNREDIRECT] = NULL,
164    [E_CLIENT_HOOK_REDIRECT] = NULL,
165 #ifdef _F_E_CLIENT_NEW_CLIENT_POST_HOOK_
166    [E_CLIENT_HOOK_NEW_CLIENT_POST] = NULL,
167 #endif
168    [E_CLIENT_HOOK_EVAL_VISIBILITY] = NULL,
169    [E_CLIENT_HOOK_ICONIFY] = NULL,
170    [E_CLIENT_HOOK_UNICONIFY] = NULL,
171    [E_CLIENT_HOOK_AUX_HINT_CHANGE] = NULL,
172    [E_CLIENT_HOOK_WINDOW_ROLE_CHANGE] = NULL,
173    [E_CLIENT_HOOK_TRANSFORM_CHANGE] = NULL,
174    [E_CLIENT_HOOK_ACTIVATE_DONE] = NULL,
175    [E_CLIENT_HOOK_EVAL_VISIBILITY_END] = NULL,
176 };
177
178 static Eina_Inlist *_e_client_intercept_hooks[] =
179 {
180    [E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT] = NULL,
181    [E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT] = NULL,
182 };
183
184 ///////////////////////////////////////////
185
186 static void
187 _e_client_hooks_clean(void)
188 {
189    Eina_Inlist *l;
190    E_Client_Hook *ch;
191    unsigned int x;
192
193    for (x = 0; x < E_CLIENT_HOOK_LAST; x++)
194      EINA_INLIST_FOREACH_SAFE(_e_client_hooks[x], l, ch)
195        {
196           if (!ch->delete_me) continue;
197           _e_client_hooks[x] = eina_inlist_remove(_e_client_hooks[x], EINA_INLIST_GET(ch));
198           free(ch);
199        }
200 }
201
202 static Eina_Bool
203 _e_client_hook_call(E_Client_Hook_Point hookpoint, E_Client *ec)
204 {
205    E_Client_Hook *ch;
206
207    e_object_ref(E_OBJECT(ec));
208    _e_client_hooks_walking++;
209    EINA_INLIST_FOREACH(_e_client_hooks[hookpoint], ch)
210      {
211         if (ch->delete_me) continue;
212         ch->func(ch->data, ec);
213         if ((hookpoint != E_CLIENT_HOOK_DEL) &&
214           (hookpoint != E_CLIENT_HOOK_MOVE_END) &&
215           (hookpoint != E_CLIENT_HOOK_RESIZE_END) &&
216           (hookpoint != E_CLIENT_HOOK_FOCUS_UNSET) &&
217           e_object_is_del(E_OBJECT(ec)))
218           break;
219      }
220    _e_client_hooks_walking--;
221    if ((_e_client_hooks_walking == 0) && (_e_client_hooks_delete > 0))
222      _e_client_hooks_clean();
223    return !!e_object_unref(E_OBJECT(ec));
224 }
225
226 ///////////////////////////////////////////
227
228 static void
229 _e_client_intercept_hooks_clean(void)
230 {
231    Eina_Inlist *l;
232    E_Client_Intercept_Hook *ch;
233    unsigned int x;
234
235    for (x = 0; x < E_CLIENT_INTERCEPT_HOOK_LAST; x++)
236      EINA_INLIST_FOREACH_SAFE(_e_client_intercept_hooks[x], l, ch)
237        {
238           if (!ch->delete_me) continue;
239           _e_client_intercept_hooks[x] =
240              eina_inlist_remove(_e_client_intercept_hooks[x], EINA_INLIST_GET(ch));
241           free(ch);
242        }
243 }
244
245 static Eina_Bool
246 _e_client_intercept_hook_call(E_Client_Intercept_Hook_Point hookpoint, E_Client *ec)
247 {
248    E_Client_Intercept_Hook *ch;
249    Eina_Bool ret = EINA_TRUE;
250
251    if (e_object_is_del(E_OBJECT(ec)))
252      {
253         if (hookpoint != E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT)
254           {
255              return ret;
256           }
257      }
258
259    e_object_ref(E_OBJECT(ec));
260    _e_client_intercept_hooks_walking++;
261    EINA_INLIST_FOREACH(_e_client_intercept_hooks[hookpoint], ch)
262      {
263         if (ch->delete_me) continue;
264         if (!(ch->func(ch->data, ec)))
265           {
266              ret = EINA_FALSE;
267              break;
268           }
269      }
270    _e_client_intercept_hooks_walking--;
271    if ((_e_client_intercept_hooks_walking == 0) &&
272        (_e_client_intercept_hooks_delete > 0))
273      _e_client_intercept_hooks_clean();
274
275    e_object_unref(E_OBJECT(ec));
276    return ret;
277 }
278
279 static void
280 _e_client_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
281 {
282    UNREFD(ev->ec, 3);
283    e_object_unref(E_OBJECT(ev->ec));
284    free(ev);
285 }
286
287 static void
288 _e_client_event_simple(E_Client *ec, int type)
289 {
290    E_Event_Client *ev;
291
292    ev = E_NEW(E_Event_Client, 1);
293    if (!ev) return;
294    ev->ec = ec;
295    REFD(ec, 3);
296    e_object_ref(E_OBJECT(ec));
297    ecore_event_add(type, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
298 }
299
300 static void
301 _e_client_event_add(E_Client *ec)
302 {
303    if (ec->reg_ev.add)
304      return;
305
306    ec->reg_ev.add = EINA_TRUE;
307    ELOGF("COMP", "SEND E_EVENT_CLIENT_ADD event", ec);
308    _e_client_event_simple(ec, E_EVENT_CLIENT_ADD);
309 }
310
311 static void
312 _e_client_event_remove(E_Client *ec)
313 {
314    if (!ec->reg_ev.add)
315      return;
316
317    ec->reg_ev.add = EINA_FALSE;
318    ELOGF("COMP", "SEND E_EVENT_CLIENT_REMOVE event", ec);
319    _e_client_event_simple(ec, E_EVENT_CLIENT_REMOVE);
320 }
321
322 static void
323 _e_client_event_show(E_Client *ec)
324 {
325    if (ec->reg_ev.show)
326      return;
327
328    ec->reg_ev.show = EINA_TRUE;
329    _e_client_event_simple(ec, E_EVENT_CLIENT_SHOW);
330 }
331
332 static void
333 _e_client_event_hide(E_Client *ec)
334 {
335    if (!ec->reg_ev.show)
336      return;
337
338    ec->reg_ev.show = EINA_FALSE;
339    _e_client_event_simple(ec, E_EVENT_CLIENT_HIDE);
340 }
341
342 static void
343 _e_client_event_property(E_Client *ec, int prop)
344 {
345    E_Event_Client_Property *ev;
346
347    ev = E_NEW(E_Event_Client_Property, 1);
348    if (!ev) return;
349    ev->ec = ec;
350    ev->property = prop;
351    REFD(ec, 33);
352    e_object_ref(E_OBJECT(ec));
353    ecore_event_add(E_EVENT_CLIENT_PROPERTY, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
354 }
355
356 ////////////////////////////////////////////////
357
358 static int
359 _e_client_action_input_win_del(void)
360 {
361    if (!comp_grabbed) return 0;
362
363    e_comp_ungrab_input(1, 1);
364    comp_grabbed = 0;
365    return 1;
366 }
367
368 static void
369 _e_client_action_finish(void)
370 {
371    if (comp_grabbed)
372      _e_client_action_input_win_del();
373
374    E_FREE_FUNC(action_timer, ecore_timer_del);
375    E_FREE_FUNC(action_handler_mouse, ecore_event_handler_del);
376    if (action_client)
377      {
378         action_client->keyboard_resizing = 0;
379      }
380    action_client = NULL;
381 }
382
383 static void
384 _e_client_transform_point_transform(int cx, int cy, double angle, int x, int y, int *tx, int *ty)
385 {
386    double s = sin(angle * M_PI / 180);
387    double c = cos(angle * M_PI / 180);
388    int rx, ry;
389
390    x -= cx;
391    y -= cy;
392
393    rx = x * c + y * s;
394    ry = - x * s + y * c;
395
396    rx += cx;
397    ry += cy;
398
399    *tx = rx;
400    *ty = ry;
401 }
402
403 static void
404 _e_client_transform_geometry_save(E_Client *ec, E_Map *map)
405 {
406    int i;
407
408    if (!map) return;
409
410    for (i = 0; i < 4; i ++)
411      {
412         e_map_point_precise_coord_get(map, i,
413                                       &ec->transform.saved[i].x,
414                                       &ec->transform.saved[i].y,
415                                       &ec->transform.saved[i].z);
416      }
417 }
418
419 static void
420 _e_client_transform_resize(E_Client *ec)
421 {
422    E_Map *map;
423    int cx, cy;
424    double dx = 0, dy = 0;
425    double px[4], py[4];
426    int pw, ph;
427    int i;
428
429    if (!ec->transformed) return;
430
431    if (!e_pixmap_size_get(ec->pixmap, &pw, &ph))
432      {
433         pw = ec->client.w;
434         ph = ec->client.h;
435      }
436
437    cx = ec->client.x + pw / 2;
438    cy = ec->client.y + ph / 2;
439
440    /* step 1: Rotate resized object and get map points */
441    map = e_map_new_with_direct_render(ec->transform_core.direct_render);
442    e_map_util_points_populate_from_geometry(map,
443                                             ec->client.x, ec->client.y,
444                                             pw, ph,
445                                             0);
446    e_map_util_rotate(map, ec->transform.angle, cx, cy);
447    e_map_util_zoom(map, ec->transform.zoom, ec->transform.zoom, cx, cy);
448
449    for (i = 0; i < 4; i++)
450      e_map_point_precise_coord_get(map, i, &px[i], &py[i], NULL);
451
452    e_map_free(map);
453
454    /* step 2: get adjusted values to keep up fixed position according
455     * to resize mode */
456    switch (ec->resize_mode)
457      {
458       case E_POINTER_RESIZE_R:
459       case E_POINTER_RESIZE_BR:
460          dx = ec->transform.saved[0].x - px[0];
461          dy = ec->transform.saved[0].y - py[0];
462          break;
463       case E_POINTER_RESIZE_BL:
464       case E_POINTER_RESIZE_B:
465          dx = ec->transform.saved[1].x - px[1];
466          dy = ec->transform.saved[1].y - py[1];
467          break;
468       case E_POINTER_RESIZE_TL:
469       case E_POINTER_RESIZE_L:
470          dx = ec->transform.saved[2].x - px[2];
471          dy = ec->transform.saved[2].y - py[2];
472          break;
473       case E_POINTER_RESIZE_T:
474       case E_POINTER_RESIZE_TR:
475          dx = ec->transform.saved[3].x - px[3];
476          dy = ec->transform.saved[3].y - py[3];
477          break;
478       default:
479          break;
480      }
481
482    ec->transform.adjusted.x = dx;
483    ec->transform.adjusted.y = dy;
484
485    /* step 3: set each points of the quadrangle */
486    map = e_map_new_with_direct_render(ec->transform_core.direct_render);
487    e_map_util_points_populate_from_object_full(map, ec->frame, 0);
488
489    for (i = 0; i < 4; i++)
490       e_map_point_precise_coord_set(map, i, px[i] + dx, py[i] + dy, 0);
491
492    e_client_map_set(ec, map);
493    e_client_map_enable_set(ec, EINA_TRUE);
494    e_map_free(map);
495 }
496
497 static void
498 _e_client_transform_resize_handle(E_Client *ec)
499 {
500
501    int new_x, new_y, new_w, new_h;
502    int org_w, org_h;
503    int button_id;
504    int cx, cy;
505    Evas_Point current, moveinfo;
506    E_Zone *zone;
507
508    if (e_object_is_del(E_OBJECT(ec))) return;
509    if (e_client_util_ignored_get(ec)) return;
510    if (!ec->transformed) return;
511
512    zone = e_comp_zone_find_by_ec(ec);
513    if (!zone) return;
514
515    button_id = ec->moveinfo.down.button;
516
517    org_w = ec->mouse.last_down[button_id - 1].w;
518    org_h = ec->mouse.last_down[button_id - 1].h;
519
520    new_w = ec->client.w;
521    new_h = ec->client.h;
522    new_x = ec->client.x;
523    new_y = ec->client.y;
524
525    /* step 1: get center coordinate its' based on original object geometry*/
526    cx = ec->client.x + org_w / 2;
527    cy = ec->client.y + org_h / 2;
528
529    /* step 2: transform coordinates of mouse position
530     * subtract adjusted value from mouse position is needed */
531    current.x = ec->mouse.current.mx - ec->transform.adjusted.x;
532    current.y = ec->mouse.current.my - ec->transform.adjusted.y;
533    moveinfo.x = ec->moveinfo.down.mx - ec->transform.adjusted.x;
534    moveinfo.y = ec->moveinfo.down.my - ec->transform.adjusted.y;
535
536    _e_client_transform_point_transform(cx, cy, ec->transform.angle,
537                                        current.x, current.y,
538                                        &current.x, &current.y);
539    _e_client_transform_point_transform(cx, cy, ec->transform.angle,
540                                        moveinfo.x, moveinfo.y,
541                                        &moveinfo.x, &moveinfo.y);
542
543    /* step 3: calculate new size */
544    if ((ec->resize_mode == E_POINTER_RESIZE_TR) ||
545        (ec->resize_mode == E_POINTER_RESIZE_R) ||
546        (ec->resize_mode == E_POINTER_RESIZE_BR))
547      {
548         if ((button_id >= 1) && (button_id <= 3))
549           new_w = org_w + (current.x - moveinfo.x);
550         else
551           new_w = ec->moveinfo.down.w + (current.x - moveinfo.x);
552      }
553    else if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
554             (ec->resize_mode == E_POINTER_RESIZE_L) ||
555             (ec->resize_mode == E_POINTER_RESIZE_BL))
556      {
557         if ((button_id >= 1) && (button_id <= 3))
558           new_w = org_w - (current.x - moveinfo.x);
559         else
560           new_w = ec->moveinfo.down.w - (current.x - moveinfo.x);
561      }
562
563    if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
564        (ec->resize_mode == E_POINTER_RESIZE_T) ||
565        (ec->resize_mode == E_POINTER_RESIZE_TR))
566      {
567         if ((button_id >= 1) && (button_id <= 3))
568           new_h = org_h - (current.y - moveinfo.y);
569         else
570           new_h = ec->moveinfo.down.h - (current.y - moveinfo.y);
571      }
572    else if ((ec->resize_mode == E_POINTER_RESIZE_BL) ||
573             (ec->resize_mode == E_POINTER_RESIZE_B) ||
574             (ec->resize_mode == E_POINTER_RESIZE_BR))
575      {
576         if ((button_id >= 1) && (button_id <= 3))
577           new_h = org_h + (current.y - moveinfo.y);
578         else
579           new_h = ec->moveinfo.down.h + (current.y - moveinfo.y);
580      }
581
582    new_w = MIN(new_w, zone->w);
583    new_h = MIN(new_h, zone->h);
584
585    /* step 4: move to new position */
586    if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
587        (ec->resize_mode == E_POINTER_RESIZE_L) ||
588        (ec->resize_mode == E_POINTER_RESIZE_BL))
589      new_x += (new_w - org_w);
590    if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
591        (ec->resize_mode == E_POINTER_RESIZE_T) ||
592        (ec->resize_mode == E_POINTER_RESIZE_TR))
593      new_y += (new_h - org_h);
594
595    /* step 5: set geometry to new value */
596    evas_object_geometry_set(ec->frame, new_x, new_y, new_w, new_h);
597 }
598
599 void
600 _e_client_transform_resize_begin(E_Client *ec)
601 {
602    E_Map *map;
603    if (!ec->transformed) return;
604
605    map = e_client_map_get(ec);
606    _e_client_transform_geometry_save(ec, map);
607    e_map_free(map);
608 }
609
610 void
611 _e_client_transform_resize_end(E_Client *ec)
612 {
613    E_Map *map;
614    int new_x = 0, new_y = 0;
615    int cx, cy, pw, ph;
616
617    if (!ec->transformed) return;
618
619    map = e_client_map_get(ec);
620    if (!map) return;
621
622    if (!e_pixmap_size_get(ec->pixmap, &pw, &ph))
623      {
624         pw = ec->client.w;
625         ph = ec->client.h;
626      }
627
628    cx = ec->client.x + pw / 2 + ec->transform.adjusted.x;
629    cy = ec->client.y + ph / 2 + ec->transform.adjusted.y;
630
631    if (ec->transform.zoom != 1.0)
632      {
633         E_Map *tmp_map;
634
635         tmp_map = e_map_dup(map);
636         e_map_util_zoom(tmp_map,
637                            1 / ec->transform.zoom,
638                            1 / ec->transform.zoom,
639                            cx, cy);
640
641         _e_client_transform_geometry_save(ec, tmp_map);
642         e_map_free(tmp_map);
643      }
644    else
645      {
646         _e_client_transform_geometry_save(ec, map);
647      }
648
649    /* move original object to adjusted position after resizing */
650    _e_client_transform_point_transform(cx, cy,
651                                        ec->transform.angle,
652                                        ec->transform.saved[0].x,
653                                        ec->transform.saved[0].y,
654                                        &new_x, &new_y);
655    e_client_util_move_without_frame(ec, new_x, new_y);
656    e_map_util_object_move_sync_set(map, EINA_TRUE);
657    e_map_free(map);
658 }
659
660 static void
661 _e_client_transform_move_end(E_Client *ec)
662 {
663
664    int i;
665    double dx, dy, px, py;
666    E_Map *map;
667
668    if (!ec->transformed) return;
669
670    map = e_client_map_get(ec);
671    if (!map) return;
672
673    if (ec->transform.zoom != 1.0)
674      {
675         e_map_point_precise_coord_get(map, 0, &px, &py, NULL);
676
677         dx = px - ec->transform.saved[0].x;
678         dy = py - ec->transform.saved[0].y;
679
680         for (i = 0; i < 4; i++)
681           {
682              ec->transform.saved[i].x += dx;
683              ec->transform.saved[i].y += dy;
684           }
685      }
686    else
687      _e_client_transform_geometry_save(ec, map);
688    e_map_free(map);
689 }
690
691 EINTERN Eina_Bool
692 e_client_intercept_hook_focus_revert_call(E_Client *ec)
693 {
694   // no need to call the intercept hook if ec is NULL.
695   if (!ec) return EINA_FALSE;
696
697   if (!_e_client_intercept_hook_call(E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT, ec))
698     {
699        ELOGF("FOCUS", "E_CLIENT_INTERCEPT_HOOK_FOCUS_REVERT Intercepted.", ec);
700        return EINA_TRUE;
701     }
702
703   return EINA_FALSE;
704 }
705
706 EINTERN E_Client *
707 e_client_check_fully_contain_by_above(E_Client *ec, Eina_Bool check_layer)
708 {
709    E_Client *above = NULL;
710    E_Zone *zone = NULL;
711    int x = 0, y = 0, w = 0, h = 0;
712    int ax = 0, ay = 0, aw = 0, ah = 0;
713
714    if (!ec) return NULL;
715
716    e_client_geometry_get(ec, &x, &y, &w, &h);
717
718    zone = e_comp_zone_find_by_ec(ec);
719    if (zone)
720      E_RECTS_CLIP_TO_RECT(x, y, w, h, zone->x, zone->y, zone->w, zone->h);
721
722    above = e_client_above_get(ec);
723    while (above)
724      {
725         if ((check_layer) &&
726             (above->layer <= ec->layer))
727           {
728              above = e_client_above_get(above);
729              continue;
730           }
731
732         if ((!e_object_is_del(E_OBJECT(above))) &&
733             (!e_client_util_ignored_get(above)) &&
734             (above->visible) &&
735             (!above->iconic || e_policy_visibility_client_is_uniconic(above)) &&
736             (!above->bg_state) &&
737             (!above->argb) &&
738             (!above->visibility.force_obscured) &&
739             (above->frame))
740           {
741              e_client_geometry_get(above, &ax, &ay, &aw, &ah);
742              if (E_CONTAINS(ax, ay, aw, ah, x, y, w, h))
743                break;
744           }
745         above = e_client_above_get(above);
746      }
747
748    return above;
749 }
750
751 EINTERN E_Client *
752 e_client_check_obscured_by_children_group(E_Client *ec)
753 {
754    E_Client *cec = NULL;
755    Eina_List *transients = NULL, *l = NULL;
756
757    _e_client_transient_for_group_make(ec, &transients);
758    if (!transients) return NULL;
759
760    EINA_LIST_FOREACH(transients, l, cec)
761      {
762         if (E_CONTAINS(cec->x, cec->y, cec->w, cec->h, ec->x, ec->y, ec->w, ec->h))
763           {
764             if (!cec->argb) break;
765             if (cec->visibility.opaque > 0) break;
766           }
767      }
768
769    eina_list_free(transients);
770
771    return cec;
772 }
773
774 EINTERN Eina_Bool
775 e_client_check_really_iconified(E_Client *ec)
776 {
777    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
778
779    if (!ec->iconic) return EINA_FALSE;
780
781    return ((!e_policy_visibility_client_is_uniconic(ec) &&
782             !e_policy_visibility_client_is_uniconify_render_running(ec)) ||
783            (e_client_is_iconified_by_client(ec)));
784 }
785
786 static void
787 _e_client_event_focus_skip_set(E_Client *ec, Eina_Bool by_client)
788 {
789    E_Event_Client_Focus_Skip_Set *ev;
790
791    ev = E_NEW(E_Event_Client_Focus_Skip_Set, 1);
792    if (!ev) return;
793
794    ev->ec = ec;
795    ev->by_client = by_client;
796    e_object_ref(E_OBJECT(ec));
797
798    ecore_event_add(E_EVENT_CLIENT_FOCUS_SKIP_SET, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
799 }
800
801 static void
802 _e_client_event_focus_skip_unset(E_Client *ec, Eina_Bool by_client)
803 {
804    E_Event_Client_Focus_Skip_Unset *ev;
805
806    ev = E_NEW(E_Event_Client_Focus_Skip_Unset, 1);
807    if (!ev) return;
808
809    ev->ec = ec;
810    ev->by_client = by_client;
811    e_object_ref(E_OBJECT(ec));
812
813    ecore_event_add(E_EVENT_CLIENT_FOCUS_SKIP_UNSET, ev, (Ecore_End_Cb)_e_client_event_simple_free, NULL);
814 }
815
816 E_API void
817 e_client_focus_skip_set(E_Client *ec, Eina_Bool skip, Eina_Bool by_client)
818 {
819    if (!ec) return;
820
821    if (skip)
822      {
823         if (ec->icccm.accepts_focus)
824           {
825              ELOGF("TZPOL", "FOCUS|SKIP SET (by_client:%d)", ec, by_client);
826              ec->icccm.accepts_focus = ec->icccm.take_focus = 0;
827              ec->changes.accepts_focus = 1;
828              EC_CHANGED(ec);
829
830              _e_client_event_focus_skip_set(ec, by_client);
831           }
832      }
833    else
834      {
835         if (!ec->icccm.accepts_focus)
836           {
837              ELOGF("TZPOL", "FOCUS|SKIP UNSET (by_client:%d)", ec, by_client);
838              ec->icccm.accepts_focus = ec->icccm.take_focus = 1;
839              ec->changes.accepts_focus = 1;
840              EC_CHANGED(ec);
841
842              _e_client_event_focus_skip_unset(ec, by_client);
843           }
844      }
845 }
846
847 EINTERN Eina_Bool
848 e_client_check_above_focused(E_Client *ec)
849 {
850    E_Client *focus = NULL;
851    E_Client *above = NULL;
852
853    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
854
855    focus = e_client_focused_get();
856    if (!focus) return EINA_FALSE;
857
858    above = e_client_above_get(ec);
859    while (above)
860      {
861         if (above == focus)
862           return EINA_TRUE;
863
864         above = e_client_above_get(above);
865      }
866
867    return EINA_FALSE;
868 }
869
870 static Eina_Bool
871 _e_client_private_init(E_Client *ec)
872 {
873    E_Client_Private *priv;
874
875    priv = E_NEW(E_Client_Private, 1);
876    if (!priv)
877      return EINA_FALSE;
878
879    wl_signal_init(&priv->events.eval_pre_fetch);
880    wl_signal_init(&priv->events.eval_fetch);
881    wl_signal_init(&priv->events.eval_pre_post_fetch);
882    wl_signal_init(&priv->events.eval_post_fetch);
883    wl_signal_init(&priv->events.eval_pre_frame_assign);
884    wl_signal_init(&priv->events.eval_post_frame_assign);
885    wl_signal_init(&priv->events.eval_pre_new_client);
886    wl_signal_init(&priv->events.eval_post_new_client);
887    wl_signal_init(&priv->events.eval_visibility);
888    wl_signal_init(&priv->events.eval_visibility_end);
889    wl_signal_init(&priv->events.eval_end);
890    wl_signal_init(&priv->events.move_begin);
891    wl_signal_init(&priv->events.move_update);
892    wl_signal_init(&priv->events.move_end);
893    wl_signal_init(&priv->events.move_resize_begin);
894    wl_signal_init(&priv->events.move_resize_update);
895    wl_signal_init(&priv->events.move_resize_end);
896    wl_signal_init(&priv->events.destroy);
897    wl_signal_init(&priv->events.new_client);
898    wl_signal_init(&priv->events.new_client_post);
899    wl_signal_init(&priv->events.unredirect);
900    wl_signal_init(&priv->events.redirect);
901    wl_signal_init(&priv->events.aux_hint_change);
902    wl_signal_init(&priv->events.window_role_change);
903    wl_signal_init(&priv->events.transform_change);
904    wl_signal_init(&priv->events.activate_done);
905    wl_signal_init(&priv->events.mouse_in);
906    wl_signal_init(&priv->events.mouse_out);
907    wl_signal_init(&priv->events.mouse_down);
908    wl_signal_init(&priv->events.focus_set);
909    wl_signal_init(&priv->events.focus_unset);
910    wl_signal_init(&priv->events.focus_defer_set);
911    wl_signal_init(&priv->events.focus_latest_set);
912    wl_signal_init(&priv->events.iconify);
913    wl_signal_init(&priv->events.uniconify);
914    wl_signal_init(&priv->events.maximize);
915    wl_signal_init(&priv->events.unmaximize);
916    wl_signal_init(&priv->events.fullscreen_pre);
917    wl_signal_init(&priv->events.fullscreen);
918    wl_signal_init(&priv->events.unfullscreen);
919    wl_signal_init(&priv->events.move);
920    wl_signal_init(&priv->events.layer_set);
921    wl_signal_init(&priv->events.raise);
922    wl_signal_init(&priv->events.lower);
923    wl_signal_init(&priv->events.stack_below);
924    wl_signal_init(&priv->events.stack_above);
925    wl_signal_init(&priv->events.stack_transient_for_done);
926    wl_signal_init(&priv->events.stick);
927    wl_signal_init(&priv->events.unstick);
928
929    e_object_data_set(E_OBJECT(ec), priv);
930
931    return EINA_TRUE;
932 }
933
934 static void
935 _e_client_private_finish(E_Client *ec)
936 {
937    E_Client_Private *priv;
938
939    priv = PRI(ec);
940    e_object_data_set(E_OBJECT(ec), NULL);
941
942    free(priv);
943 }
944
945 static void
946 _e_client_free(E_Client *ec)
947 {
948    g_rec_mutex_lock(&e_comp->ec_list_mutex);
949
950    e_comp_object_redirected_set(ec->frame, 0);
951    e_comp_object_render_update_del(ec->frame);
952
953    E_OBJECT(ec)->references++;
954
955    if (ec->new_client)
956      e_comp->new_clients--;
957
958    if (ec->e.state.video_parent && ec->e.state.video_parent_client)
959      {
960         ec->e.state.video_parent_client->e.state.video_child =
961           eina_list_remove(ec->e.state.video_parent_client->e.state.video_child, ec);
962      }
963    if (ec->e.state.video_child)
964      {
965         E_Client *tmp;
966
967         EINA_LIST_FREE(ec->e.state.video_child, tmp)
968           tmp->e.state.video_parent_client = NULL;
969      }
970    E_FREE_FUNC(ec->kill_timer, ecore_timer_del);
971
972    E_FREE_FUNC(ec->map_timer, ecore_timer_del);
973
974    ec->transients = eina_list_free(ec->transients);
975    eina_stringshare_replace(&ec->border.name, NULL);
976    eina_stringshare_replace(&ec->bordername, NULL);
977    eina_stringshare_replace(&ec->icccm.name, NULL);
978 #if defined(__cplusplus) || defined(c_plusplus)
979    eina_stringshare_replace(&ec->icccm.cpp_class, NULL);
980 #else
981    eina_stringshare_replace(&ec->icccm.class, NULL);
982 #endif
983    eina_stringshare_replace(&ec->icccm.title, NULL);
984    eina_stringshare_replace(&ec->icccm.window_role, NULL);
985    eina_stringshare_replace(&ec->netwm.name, NULL);
986    eina_stringshare_replace(&ec->internal_icon, NULL);
987    eina_stringshare_replace(&ec->internal_icon_key, NULL);
988
989    E_FREE_FUNC(ec->frame, evas_object_del);
990
991    E_OBJECT(ec)->references--;
992    ELOGF("COMP", "CLIENT FREE", ec);
993
994    e_uuid_store_entry_del(ec->uuid);
995
996    _e_client_private_finish(ec);
997    free(ec);
998
999    g_rec_mutex_unlock(&e_comp->ec_list_mutex);
1000 }
1001
1002 static void
1003 _e_client_del(E_Client *ec)
1004 {
1005    E_Client *child;
1006    E_Pixmap_Type type;
1007
1008    g_rec_mutex_lock(&e_comp->ec_list_mutex);
1009
1010    ec->changed = 0;
1011
1012    if (ec == e_comp_object_dim_client_get())
1013      {
1014         INF("[DIM] client deleted\n");
1015         e_comp_object_dim_client_set(NULL);
1016      }
1017
1018    if (ec->cur_mouse_action)
1019      {
1020         if (ec->cur_mouse_action->func.end)
1021           ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
1022      }
1023    if (action_client == ec) _e_client_action_finish();
1024
1025    if (!stopping)
1026      {
1027         e_client_comp_hidden_set(ec, 1);
1028         evas_object_pass_events_set(ec->frame, 1);
1029      }
1030
1031    E_FREE_FUNC(ec->ping_poller, ecore_poller_del);
1032
1033    wl_signal_emit_mutable(&PRI(ec)->events.destroy, NULL);
1034
1035    /* must be called before parent/child clear */
1036    _e_client_hook_call(E_CLIENT_HOOK_DEL, ec);
1037
1038    _e_client_event_remove(ec);
1039
1040    ELOGF("COMP", "CLIENT DEL", ec);
1041
1042    if (ec->parent)
1043      {
1044         ec->parent->transients = eina_list_remove(ec->parent->transients, ec);
1045         ec->parent = NULL;
1046      }
1047    EINA_LIST_FREE(ec->transients, child)
1048      child->parent = NULL;
1049
1050    type = e_pixmap_type_get(ec->pixmap);
1051    if (type < E_PIXMAP_TYPE_MAX)
1052      eina_hash_del_by_key(clients_hash[type], &ec->pixmap);
1053    e_comp->clients = eina_list_remove(e_comp->clients, ec);
1054    e_comp_object_render_update_del(ec->frame);
1055    e_comp_post_update_purge(ec);
1056    if (e_pixmap_free(ec->pixmap))
1057      e_pixmap_client_set(ec->pixmap, NULL);
1058    ec->pixmap = NULL;
1059
1060    // base_output_resolution
1061    e_util_transform_del(ec->base_output_resolution.transform);
1062    ec->base_output_resolution.transform = NULL;
1063    E_FREE_FUNC(ec->base_output_resolution.hook_subsurf_create, e_comp_wl_hook_del);
1064
1065    if (ec->transform_core.transform_list)
1066      {
1067         E_Util_Transform *transform;
1068
1069         EINA_LIST_FREE(ec->transform_core.transform_list, transform)
1070           {
1071              e_util_transform_unref(transform);
1072           }
1073      }
1074
1075    ec->transform_core.result.enable = EINA_FALSE;
1076
1077    _e_client_resize_object_del(ec);
1078
1079    e_comp_visibility_calculation_set(EINA_TRUE);
1080
1081    g_rec_mutex_unlock(&e_comp->ec_list_mutex);
1082 }
1083
1084 ///////////////////////////////////////////
1085
1086 static Eina_Bool
1087 _e_client_cb_kill_timer(void *data)
1088 {
1089    E_Client *ec = data;
1090
1091 // dont wait until it's hung -
1092 //   if (ec->hung)
1093 //     {
1094    if (ec->netwm.pid > 1)
1095      kill(ec->netwm.pid, SIGKILL);
1096 //     }
1097    ec->kill_timer = NULL;
1098    return ECORE_CALLBACK_CANCEL;
1099 }
1100
1101 static Eina_Bool
1102 _e_client_cb_ping_poller(void *data)
1103 {
1104    E_Client *ec;
1105
1106    ec = data;
1107    if (e_object_is_del(E_OBJECT(ec)))
1108      {
1109         ec->ping_poller = NULL;
1110         return ECORE_CALLBACK_CANCEL;
1111      }
1112
1113    if (ec->ping_ok)
1114      {
1115         if (ec->hung)
1116           {
1117              ec->hung = 0;
1118              evas_object_smart_callback_call(ec->frame, "unhung", NULL);
1119              E_FREE_FUNC(ec->kill_timer, ecore_timer_del);
1120           }
1121      }
1122    else
1123      {
1124         /* if time between last ping and now is greater
1125          * than half the ping interval... */
1126         if ((ecore_loop_time_get() - ec->ping) >
1127             ((e_config->ping_clients_interval *
1128               ecore_poller_poll_interval_get(ECORE_POLLER_CORE)) / 2.0))
1129           {
1130              if (!ec->hung)
1131                {
1132                   ec->hung = 1;
1133                   evas_object_smart_callback_call(ec->frame, "hung", NULL);
1134                   /* FIXME: if below dialog is up - hide it now */
1135                }
1136              if (ec->delete_requested)
1137                {
1138                   /* FIXME: pop up dialog saying app is hung - kill client, or pid */
1139                   e_client_act_kill_begin(ec);
1140                }
1141           }
1142      }
1143    ec->ping_poller = NULL;
1144    e_client_ping(ec);
1145    return ECORE_CALLBACK_CANCEL;
1146 }
1147
1148 ///////////////////////////////////////////
1149
1150 static int
1151 _e_client_action_input_win_new(void)
1152 {
1153    if (comp_grabbed)
1154      {
1155         CRI("DOUBLE COMP GRAB! ACK!!!!");
1156         return 1;
1157      }
1158    comp_grabbed = e_comp_grab_input(1, 1);
1159    if (!comp_grabbed) _e_client_action_input_win_del();
1160    return comp_grabbed;
1161 }
1162
1163 static void
1164 _e_client_action_init(E_Client *ec)
1165 {
1166    action_orig.x = ec->x;
1167    action_orig.y = ec->y;
1168    action_orig.w = ec->w;
1169    action_orig.h = ec->h;
1170
1171    if (action_client)
1172      {
1173         action_client->keyboard_resizing = 0;
1174      }
1175    action_client = ec;
1176 }
1177
1178 static int
1179 _e_client_move_begin(E_Client *ec)
1180 {
1181    if ((ec->fullscreen) || (ec->lock_user_location))
1182      return 0;
1183
1184    if (!_e_client_action_input_win_new()) return 0;
1185    ec->moving = 1;
1186    ecmove = ec;
1187
1188    wl_signal_emit_mutable(&PRI(ec)->events.move_begin, NULL);
1189    _e_client_hook_call(E_CLIENT_HOOK_MOVE_BEGIN, ec);
1190    if (!ec->moving)
1191      {
1192         if (ecmove == ec) ecmove = NULL;
1193         _e_client_action_input_win_del();
1194         return 0;
1195      }
1196    if (!ec->lock_user_stacking)
1197      {
1198         if (e_config->border_raise_on_mouse_action)
1199           e_client_raise(ec);
1200      }
1201
1202    if (e_comp->hwc)
1203      e_comp_client_override_add(ec);
1204
1205    return 1;
1206 }
1207
1208 static int
1209 _e_client_move_end(E_Client *ec)
1210 {
1211    ec->moving = 0;
1212    _e_client_action_input_win_del();
1213
1214    wl_signal_emit_mutable(&PRI(ec)->events.move_end, NULL);
1215    _e_client_hook_call(E_CLIENT_HOOK_MOVE_END, ec);
1216
1217    if (ec->transformed)
1218      _e_client_transform_move_end(ec);
1219
1220    if (e_comp->hwc)
1221      e_comp_client_override_del(ec);
1222
1223    ecmove = NULL;
1224    return 1;
1225 }
1226
1227 static Eina_Bool
1228 _e_client_action_move_timeout(void *data EINA_UNUSED)
1229 {
1230    _e_client_move_end(action_client);
1231    _e_client_action_finish();
1232    return ECORE_CALLBACK_CANCEL;
1233 }
1234
1235 static void
1236 _e_client_action_move_timeout_add(void)
1237 {
1238    E_FREE_FUNC(action_timer, ecore_timer_del);
1239    if (e_config->border_keyboard.timeout)
1240      action_timer = ecore_timer_add(e_config->border_keyboard.timeout, _e_client_action_move_timeout, NULL);
1241 }
1242
1243 static Eina_Bool
1244 _e_client_move_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
1245 {
1246    if (!comp_grabbed) return ECORE_CALLBACK_RENEW;
1247
1248    if (!action_client)
1249      ERR("no action_client!");
1250
1251    if (action_client) _e_client_move_end(action_client);
1252    _e_client_action_finish();
1253    return ECORE_CALLBACK_DONE;
1254 }
1255
1256 static void
1257 _e_client_moveinfo_gather(E_Client *ec, const char *source)
1258 {
1259    if (e_util_glob_match(source, "mouse,*,1"))
1260      ec->moveinfo.down.button = 1;
1261    else if (e_util_glob_match(source, "mouse,*,2"))
1262      ec->moveinfo.down.button = 2;
1263    else if (e_util_glob_match(source, "mouse,*,3"))
1264      ec->moveinfo.down.button = 3;
1265    else
1266      ec->moveinfo.down.button = 0;
1267    if ((ec->moveinfo.down.button >= 1) && (ec->moveinfo.down.button <= 3))
1268      {
1269         ec->moveinfo.down.mx = ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
1270         ec->moveinfo.down.my = ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
1271      }
1272    else
1273      {
1274         ec->moveinfo.down.mx = ec->mouse.current.mx;
1275         ec->moveinfo.down.my = ec->mouse.current.my;
1276      }
1277 }
1278
1279 static void
1280 _e_client_move_handle(E_Client *ec)
1281 {
1282    int x, y;
1283
1284    if ((ec->moveinfo.down.button >= 1) && (ec->moveinfo.down.button <= 3))
1285      {
1286         x = ec->mouse.last_down[ec->moveinfo.down.button - 1].x +
1287            (ec->mouse.current.mx - ec->moveinfo.down.mx);
1288         y = ec->mouse.last_down[ec->moveinfo.down.button - 1].y +
1289            (ec->mouse.current.my - ec->moveinfo.down.my);
1290      }
1291    else
1292      {
1293         x = ec->moveinfo.down.x +
1294            (ec->mouse.current.mx - ec->moveinfo.down.mx);
1295         y = ec->moveinfo.down.y +
1296            (ec->mouse.current.my - ec->moveinfo.down.my);
1297      }
1298
1299    if (e_config->screen_limits == E_CLIENT_OFFSCREEN_LIMIT_ALLOW_NONE)
1300      _e_client_stay_within_canvas(ec, x, y, &x, &y);
1301
1302    if (ec->floating)
1303      _e_client_stay_within_canvas_margin(ec, x, y, &x, &y);
1304
1305    evas_object_move(ec->frame, x, y);
1306
1307    if (e_client_transform_core_enable_get(ec))
1308      {
1309         e_client_transform_core_update(ec);
1310      }
1311 }
1312
1313 static Evas_Object *
1314 _e_client_resize_object_rectangle_get(E_Client *ec)
1315 {
1316    Evas_Object *resize_obj = NULL;
1317
1318    resize_obj = evas_object_rectangle_add(evas_object_evas_get(ec->frame));
1319    EINA_SAFETY_ON_NULL_RETURN_VAL(resize_obj, NULL);
1320
1321    if (e_config->resize_object.customize)
1322      {
1323         evas_object_color_set(resize_obj,
1324                               e_config->resize_object.r,
1325                               e_config->resize_object.g,
1326                               e_config->resize_object.b,
1327                               e_config->resize_object.a);
1328      }
1329    else
1330      evas_object_color_set(resize_obj, 128, 128, 128, 100);
1331
1332    return resize_obj;
1333 }
1334
1335 static Evas_Object *
1336 _e_client_resize_object_image_get(E_Client *ec)
1337 {
1338    int err;
1339    Evas_Object *resize_obj = NULL;
1340
1341    if (!e_config->resize_object.image_path)
1342      {
1343         ELOGF("COMP", "NO resize_object image! Make default resize_object", ec);
1344         goto get_rectangle;
1345      }
1346
1347    resize_obj = evas_object_image_add(evas_object_evas_get(ec->frame));
1348    EINA_SAFETY_ON_NULL_RETURN_VAL(resize_obj, NULL);
1349
1350    evas_object_image_file_set(resize_obj, e_config->resize_object.image_path, NULL);
1351    err = evas_object_image_load_error_get(resize_obj);
1352    if (err != EVAS_LOAD_ERROR_NONE)
1353      {
1354         ELOGF("COMP", "Image load error. path:%s, errno:%d. Make default resize_object",
1355               ec, e_config->resize_object.image_path, err);
1356         evas_object_del(resize_obj);
1357         resize_obj = NULL;
1358         goto get_rectangle;
1359      }
1360
1361    evas_object_image_fill_set(resize_obj, 0, 0, ec->w, ec->h);
1362    evas_object_image_filled_set(resize_obj, EINA_TRUE);
1363
1364    evas_object_image_border_set(resize_obj,
1365                                 e_config->resize_object.border_width.l,
1366                                 e_config->resize_object.border_width.r,
1367                                 e_config->resize_object.border_width.t,
1368                                 e_config->resize_object.border_width.b);
1369
1370    return resize_obj;
1371
1372 get_rectangle:
1373    return _e_client_resize_object_rectangle_get(ec);
1374 }
1375
1376 static Evas_Object *
1377 _e_client_resize_object_create(E_Client *ec)
1378 {
1379    EINA_SAFETY_ON_NULL_RETURN_VAL(ec->frame, NULL);
1380
1381    Evas_Object *resize_obj = NULL;
1382
1383    if (_e_client_resize_object_create_cb)
1384      resize_obj = _e_client_resize_object_create_cb(ec);
1385    else
1386      {
1387         if (e_config->resize_object.type == 1) // image object
1388           {
1389              resize_obj = _e_client_resize_object_image_get(ec);
1390           }
1391         else // rectangle
1392           {
1393              resize_obj = _e_client_resize_object_rectangle_get(ec);
1394           }
1395      }
1396    EINA_SAFETY_ON_NULL_RETURN_VAL(resize_obj, NULL);
1397
1398    evas_object_pass_events_set(resize_obj, EINA_TRUE);
1399    evas_object_layer_set(resize_obj, evas_object_layer_get(ec->frame));
1400    evas_object_stack_above(resize_obj, ec->frame);
1401    evas_object_name_set(resize_obj, "resize_object");
1402
1403    return resize_obj;
1404 }
1405
1406 static void
1407 _e_client_resize_object_del(E_Client *ec)
1408 {
1409    if (ec == NULL) return;
1410    if (ec->manage_resize.resize_obj == NULL) return;
1411
1412    evas_object_hide(ec->manage_resize.resize_obj);
1413    evas_object_del(ec->manage_resize.resize_obj);
1414    ec->manage_resize.resize_obj = NULL;
1415 }
1416
1417 static void
1418 _e_client_resize_handle(E_Client *ec)
1419 {
1420    int x, y, w, h;
1421    int new_x, new_y, new_w, new_h;
1422    int tw, th;
1423    int trans_x = 0, trans_y = 0;
1424    int trans_w = 0, trans_h = 0;
1425
1426    if (ec->transformed)
1427      {
1428         _e_client_transform_resize_handle(ec);
1429         return;
1430      }
1431
1432    x = ec->x;
1433    y = ec->y;
1434    w = ec->w;
1435    h = ec->h;
1436
1437    if ((ec->resize_mode == E_POINTER_RESIZE_TR) ||
1438        (ec->resize_mode == E_POINTER_RESIZE_R) ||
1439        (ec->resize_mode == E_POINTER_RESIZE_BR))
1440      {
1441         if ((ec->moveinfo.down.button >= 1) &&
1442             (ec->moveinfo.down.button <= 3))
1443           w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w +
1444             (ec->mouse.current.mx - ec->moveinfo.down.mx);
1445         else
1446           w = ec->moveinfo.down.w + (ec->mouse.current.mx - ec->moveinfo.down.mx);
1447      }
1448    else if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
1449             (ec->resize_mode == E_POINTER_RESIZE_L) ||
1450             (ec->resize_mode == E_POINTER_RESIZE_BL))
1451      {
1452         if ((ec->moveinfo.down.button >= 1) &&
1453             (ec->moveinfo.down.button <= 3))
1454           w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w -
1455             (ec->mouse.current.mx - ec->moveinfo.down.mx);
1456         else
1457           w = ec->moveinfo.down.w - (ec->mouse.current.mx - ec->moveinfo.down.mx);
1458      }
1459
1460    if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
1461        (ec->resize_mode == E_POINTER_RESIZE_T) ||
1462        (ec->resize_mode == E_POINTER_RESIZE_TR))
1463      {
1464         if ((ec->moveinfo.down.button >= 1) &&
1465             (ec->moveinfo.down.button <= 3))
1466           h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h -
1467             (ec->mouse.current.my - ec->moveinfo.down.my);
1468         else
1469           h = ec->moveinfo.down.h - (ec->mouse.current.my - ec->moveinfo.down.my);
1470      }
1471    else if ((ec->resize_mode == E_POINTER_RESIZE_BL) ||
1472             (ec->resize_mode == E_POINTER_RESIZE_B) ||
1473             (ec->resize_mode == E_POINTER_RESIZE_BR))
1474      {
1475         if ((ec->moveinfo.down.button >= 1) &&
1476             (ec->moveinfo.down.button <= 3))
1477           h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h +
1478             (ec->mouse.current.my - ec->moveinfo.down.my);
1479         else
1480           h = ec->moveinfo.down.h + (ec->mouse.current.my - ec->moveinfo.down.my);
1481      }
1482    tw = ec->w;
1483    th = ec->h;
1484
1485    if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
1486        (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1487        (ec->resize_mode == E_POINTER_RESIZE_L) ||
1488        (ec->resize_mode == E_POINTER_RESIZE_BL))
1489      x += (tw - w);
1490    if ((ec->resize_mode == E_POINTER_RESIZE_L) ||
1491        (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1492        (ec->resize_mode == E_POINTER_RESIZE_T) ||
1493        (ec->resize_mode == E_POINTER_RESIZE_TR))
1494      y += (th - h);
1495
1496    new_x = x;
1497    new_y = y;
1498    new_w = w;
1499    new_h = h;
1500    if (e_config->screen_limits == E_CLIENT_OFFSCREEN_LIMIT_ALLOW_NONE)
1501      {
1502         E_Zone *zone;
1503         zone = e_comp_zone_find_by_ec(ec);
1504         if (zone)
1505           {
1506              w = MIN(w, zone->w);
1507              h = MIN(h, zone->h);
1508           }
1509      }
1510    e_client_resize_limit(ec, &new_w, &new_h);
1511
1512    if (ec->manage_resize.enable_aspect_ratio)
1513      {
1514         if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
1515             (ec->resize_mode == E_POINTER_RESIZE_L) ||
1516             (ec->resize_mode == E_POINTER_RESIZE_BL) ||
1517             (ec->resize_mode == E_POINTER_RESIZE_TR) ||
1518             (ec->resize_mode == E_POINTER_RESIZE_R) ||
1519             (ec->resize_mode == E_POINTER_RESIZE_BR))
1520           {
1521              new_h = (int) ec->manage_resize.ah / ec->manage_resize.aw * new_w;
1522           }
1523         else if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
1524                  (ec->resize_mode == E_POINTER_RESIZE_B))
1525           {
1526              new_w = (int) ec->manage_resize.aw / ec->manage_resize.ah * new_h;
1527           }
1528           new_h += ec->manage_resize.header_h;
1529           new_h += ec->manage_resize.footer_h;
1530      }
1531
1532    if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
1533        (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1534        (ec->resize_mode == E_POINTER_RESIZE_L) ||
1535        (ec->resize_mode == E_POINTER_RESIZE_BL))
1536      new_x += (w - new_w);
1537    if ((ec->resize_mode == E_POINTER_RESIZE_L) ||
1538        (ec->resize_mode == E_POINTER_RESIZE_TL) ||
1539        (ec->resize_mode == E_POINTER_RESIZE_T) ||
1540        (ec->resize_mode == E_POINTER_RESIZE_TR))
1541      new_y += (h - new_h);
1542
1543    if (e_config->interactive_resize)
1544      {
1545         evas_object_geometry_set(ec->frame, new_x, new_y, new_w, new_h);
1546      }
1547    else
1548      {
1549         if (ec->manage_resize.resize_obj == NULL)
1550           {
1551              ec->manage_resize.resize_obj = _e_client_resize_object_create(ec);
1552              EINA_SAFETY_ON_NULL_RETURN(ec->manage_resize.resize_obj);
1553           }
1554
1555         if (e_client_transform_core_enable_get(ec))
1556           {
1557              e_client_transform_core_input_inv_transform(ec, new_x, new_y, &trans_x, &trans_y);
1558              e_client_transform_core_input_inv_transform(ec, new_w, new_h, &trans_w, &trans_h);
1559              evas_object_geometry_set(ec->manage_resize.resize_obj, trans_x, trans_y, trans_w, trans_h);
1560           }
1561         else
1562           evas_object_geometry_set(ec->manage_resize.resize_obj, new_x, new_y, new_w, new_h);
1563         evas_object_show(ec->manage_resize.resize_obj);
1564
1565         ec->manage_resize.x = new_x;
1566         ec->manage_resize.y = new_y;
1567         ec->manage_resize.w = new_w;
1568         ec->manage_resize.h = new_h;
1569      }
1570 }
1571
1572 static int
1573 _e_client_adjust_size_by_ppu(int size, int start_size, unsigned int ppu)
1574 {
1575    if (ppu <= 1) return size;
1576
1577    unsigned int remainder = size % ppu;
1578    if (remainder == 0) return size;
1579
1580    int gap = size - start_size;
1581    int new_size = size;
1582    if (gap > 0)
1583      new_size = size + (ppu - remainder);
1584    else
1585      new_size = size - remainder;
1586
1587    return new_size;
1588 }
1589
1590 static int
1591 _e_client_adjust_position_by_ppu(int pos, int size, int prev_pos, int prev_size)
1592 {
1593    int new_pos = 0;
1594
1595    if (prev_pos == pos)
1596      new_pos = pos;
1597    else
1598      new_pos = (prev_pos + prev_size) - size;
1599
1600    return new_pos;
1601 }
1602
1603 static void
1604 _e_client_adjust_geometry_by_resize_ppu(E_Client *ec)
1605 {
1606    if (ec->manage_resize.unit_size <= 1) return;
1607
1608    ec->manage_resize.w = _e_client_adjust_size_by_ppu(ec->manage_resize.w, ec->w, ec->manage_resize.unit_size);
1609    ec->manage_resize.h = _e_client_adjust_size_by_ppu(ec->manage_resize.h, ec->h, ec->manage_resize.unit_size);
1610
1611    ec->manage_resize.x = _e_client_adjust_position_by_ppu(ec->manage_resize.x, ec->manage_resize.w, ec->x, ec->w);
1612    ec->manage_resize.y = _e_client_adjust_position_by_ppu(ec->manage_resize.y, ec->manage_resize.h, ec->y, ec->h);
1613 }
1614
1615 static int
1616 _e_client_resize_end(E_Client *ec)
1617 {
1618    ec->resize_mode = E_POINTER_RESIZE_NONE;
1619    _e_client_action_input_win_del();
1620
1621    wl_signal_emit_mutable(&PRI(ec)->events.move_resize_end, NULL);
1622    _e_client_hook_call(E_CLIENT_HOOK_RESIZE_END, ec);
1623
1624    if (ec->transformed)
1625      _e_client_transform_resize_end(ec);
1626
1627    if (e_comp->hwc)
1628      e_comp_client_override_del(ec);
1629
1630    ecresize = NULL;
1631
1632    if (!e_config->interactive_resize)
1633      {
1634         if (ec->manage_resize.resize_obj)
1635           {
1636              if (ec->manage_resize.unit_size > 1)
1637                _e_client_adjust_geometry_by_resize_ppu(ec);
1638
1639              e_client_frame_geometry_set(ec,
1640                                          ec->manage_resize.x,
1641                                          ec->manage_resize.y,
1642                                          ec->manage_resize.w,
1643                                          ec->manage_resize.h);
1644              _e_client_resize_object_del(ec);
1645           }
1646      }
1647
1648    return 1;
1649 }
1650
1651 static Eina_Bool
1652 _e_client_action_resize_timeout(void *data EINA_UNUSED)
1653 {
1654    _e_client_resize_end(action_client);
1655    _e_client_action_finish();
1656    return ECORE_CALLBACK_CANCEL;
1657 }
1658
1659 static void
1660 _e_client_action_resize_timeout_add(void)
1661 {
1662    E_FREE_FUNC(action_timer, ecore_timer_del);
1663    if (e_config->border_keyboard.timeout)
1664      action_timer = ecore_timer_add(e_config->border_keyboard.timeout, _e_client_action_resize_timeout, NULL);
1665 }
1666
1667 static Eina_Bool
1668 _e_client_resize_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
1669 {
1670    if (!comp_grabbed) return ECORE_CALLBACK_RENEW;
1671
1672    if (!action_client)
1673      ERR("no action_client!");
1674
1675    if (action_client) _e_client_resize_end(action_client);
1676    _e_client_action_finish();
1677    return ECORE_CALLBACK_DONE;
1678 }
1679
1680 ////////////////////////////////////////////////
1681
1682 static Eina_Bool
1683 _e_client_position_inside_input_rect(E_Client *ec, int tx, int ty)
1684 {
1685    int x, y, w, h;
1686    Eina_Bool res = EINA_FALSE;
1687    Eina_List *list = NULL, *l;
1688    Eina_Rectangle *data;
1689
1690    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1691
1692    e_client_geometry_get(ec, &x, &y, &w, &h);
1693    e_comp_object_input_rect_get(ec->frame, &list);
1694    if (list)
1695      {
1696         EINA_LIST_FOREACH(list, l, data)
1697           {
1698              if ((tx >= x + data->x) && (tx <= x + data->x + data->w) &&
1699                  (ty >= y + data->y) && (ty <= y + data->y + data->h))
1700                {
1701                   res = EINA_TRUE;
1702                   break;
1703                }
1704           }
1705         list = eina_list_free(list);
1706      }
1707    else
1708      {
1709         if ((tx >= x) && (tx <= x + w) &&
1710             (ty >= y) && (ty <= y + h))
1711           {
1712              res = EINA_TRUE;
1713           }
1714      }
1715
1716    return res;
1717 }
1718
1719 static Eina_Bool
1720 _e_client_under_pointer_helper_ignore_client(E_Desk *desk, E_Client *client)
1721 {
1722    /* If a border was specified which should be excluded from the list
1723     * (because it will be closed shortly for example), skip */
1724    if (e_client_util_ignored_get(client) || (!e_desk_has_ec(desk, client))) return EINA_TRUE;
1725    if (!evas_object_visible_get(client->frame)) return EINA_TRUE;
1726    if (e_policy_client_is_cursor(client)) return EINA_TRUE;
1727    if (e_comp_wl->drag_client == client) return EINA_TRUE;
1728
1729    return EINA_FALSE;
1730 }
1731
1732 static E_Client *
1733 _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y)
1734 {
1735    E_Client *ec = NULL, *cec;
1736
1737    E_CLIENT_REVERSE_FOREACH(cec)
1738      {
1739         if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue;
1740         if ((exclude) && (cec == exclude)) continue;
1741         if (!E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h))
1742           continue;
1743         /* If the layer is higher, the position of the window is higher
1744          * (always on top vs always below) */
1745         if (!ec || (cec->layer > ec->layer))
1746           ec = cec;
1747      }
1748    return ec;
1749 }
1750
1751 static E_Client *
1752 _e_client_under_pointer_input_helper(E_Desk *desk, int x, int y)
1753 {
1754    E_Client *ec = NULL, *cec;
1755
1756    E_CLIENT_REVERSE_FOREACH(cec)
1757      {
1758         if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue;
1759
1760         Eina_List *list = NULL;
1761         Eina_Rectangle *rect;
1762         Eina_Bool inside = EINA_FALSE;
1763         e_comp_object_input_rect_get(cec->frame, &list);
1764         if (list)
1765           {
1766              EINA_LIST_FREE(list, rect)
1767                {
1768                   if (E_INSIDE(x, y, rect->x, rect->y, rect->w, rect->h))
1769                     inside = EINA_TRUE;
1770                }
1771           }
1772         else if (E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h))
1773           {
1774              inside = EINA_TRUE;
1775           }
1776
1777         if (!inside) continue;
1778         /* If the layer is higher, the position of the window is higher
1779          * (always on top vs always below) */
1780         if (!ec || (cec->layer > ec->layer))
1781           ec = cec;
1782      }
1783
1784    return ec;
1785 }
1786
1787 ////////////////////////////////////////////////
1788
1789 static void
1790 _e_client_zones_layout_calc(E_Client *ec, int *zx, int *zy, int *zw, int *zh)
1791 {
1792    int x, y, w, h;
1793    E_Zone *zone_above, *zone_below, *zone_left, *zone_right;
1794    E_Zone *zone;
1795
1796    zone = e_comp_zone_find_by_ec(ec);
1797    if (!zone) return;
1798    x = zone->x;
1799    y = zone->y;
1800    w = zone->w;
1801    h = zone->h;
1802
1803    if (eina_list_count(e_comp->zones) == 1)
1804      {
1805         if (zx) *zx = x;
1806         if (zy) *zy = y;
1807         if (zw) *zw = w;
1808         if (zh) *zh = h;
1809         return;
1810      }
1811
1812    zone_left = e_comp_zone_xy_get((x - w + 5), y);
1813    zone_right = e_comp_zone_xy_get((x + w + 5), y);
1814    zone_above = e_comp_zone_xy_get(x, (y - h + 5));
1815    zone_below = e_comp_zone_xy_get(x, (y + h + 5));
1816
1817    if (!(zone_above) && (y))
1818      zone_above = e_comp_zone_xy_get(x, (h - 5));
1819
1820    if (!(zone_left) && (x))
1821      zone_left = e_comp_zone_xy_get((x - 5), y);
1822
1823    if (zone_right)
1824      w = zone_right->x + zone_right->w;
1825
1826    if (zone_left)
1827      w = zone->x + zone->w;
1828
1829    if (zone_below)
1830      h = zone_below->y + zone_below->h;
1831
1832    if (zone_above)
1833      h = zone->y + zone->h;
1834
1835    if ((zone_left) && (zone_right))
1836      w = zone->w + zone_right->x;
1837
1838    if ((zone_above) && (zone_below))
1839      h = zone->h + zone_below->y;
1840
1841    if (x) x -= zone->w;
1842    if (y) y -= zone->h;
1843
1844    if (zx) *zx = x > 0 ? x : 0;
1845    if (zy) *zy = y > 0 ? y : 0;
1846    if (zw) *zw = w;
1847    if (zh) *zh = h;
1848 }
1849
1850 static void
1851 _e_client_stay_within_canvas(E_Client *ec, int x, int y, int *new_x, int *new_y)
1852 {
1853    int new_x_max, new_y_max;
1854    int zw, zh;
1855    Eina_Bool lw, lh;
1856    E_Zone *zone;
1857
1858    zone = e_comp_zone_find_by_ec(ec);
1859    if (!zone)
1860      {
1861         if (new_x) *new_x = x;
1862         if (new_y) *new_y = y;
1863         return;
1864      }
1865
1866    _e_client_zones_layout_calc(ec, NULL, NULL, &zw, &zh);
1867
1868    new_x_max = zw - ec->w;
1869    new_y_max = zh - ec->h;
1870    lw = ec->w > zw ? EINA_TRUE : EINA_FALSE;
1871    lh = ec->h > zh ? EINA_TRUE : EINA_FALSE;
1872
1873    if (lw)
1874      {
1875         if (x <= new_x_max)
1876           *new_x = new_x_max;
1877         else if (x >= 0)
1878           *new_x = 0;
1879      }
1880    else
1881      {
1882         if (x >= new_x_max)
1883           *new_x = new_x_max;
1884         else if (x <= 0)
1885           *new_x = 0;
1886      }
1887
1888    if (lh)
1889      {
1890         if (y <= new_y_max)
1891           *new_y = new_y_max;
1892         else if (y >= 0)
1893           *new_y = 0;
1894      }
1895    else
1896      {
1897         if (y >= new_y_max)
1898           *new_y = new_y_max;
1899         else if (y <= 0)
1900           *new_y = 0;
1901      }
1902 }
1903
1904 static void
1905 _e_client_stay_within_canvas_margin(E_Client *ec, int x, int y, int *new_x, int *new_y)
1906 {
1907    int new_x_max, new_y_max, new_x_min, new_y_min;
1908    int margin_w, margin_h;
1909    int zw, zh;
1910    int cw, ch;
1911    E_Zone *zone;
1912
1913    zone = e_comp_zone_find_by_ec(ec);
1914    if (!zone)
1915      {
1916         if (new_x) *new_x = x;
1917         if (new_y) *new_y = y;
1918         return;
1919      }
1920
1921    cw = ec->w;
1922    ch = ec->h;
1923
1924    _e_client_zones_layout_calc(ec, NULL, NULL, &zw, &zh);
1925
1926    margin_w = zw/3;
1927    margin_h = zh/10;
1928
1929    new_x_min = (margin_w > cw) ? 0 : -(cw - margin_w);
1930    new_x_max = (margin_w > cw) ? (zw - cw) : (zw - margin_w);
1931    new_y_min = (margin_h > ch) ? 0 : -(ch - margin_h);
1932    new_y_max = (margin_h > ch) ? (zh - ch) : (zh - margin_h);
1933
1934    if (x >= new_x_max)
1935      *new_x = new_x_max;
1936    else if (x <= new_x_min)
1937      *new_x = new_x_min;
1938
1939    if (y >= new_y_max)
1940      *new_y = new_y_max;
1941    else if (y <= new_y_min)
1942      *new_y = new_y_min;
1943
1944 }
1945
1946 ////////////////////////////////////////////////
1947
1948 static void
1949 _e_client_transform_core_activate_set(E_Client *ec, Eina_Bool set)
1950 {
1951    if (ec->transform_core.activate == set) return;
1952
1953    ec->transform_core.activate = set;
1954
1955    if (set)
1956      {
1957         if (ec->transform_core.result.enable)
1958           e_client_map_enable_set(ec, EINA_TRUE);
1959      }
1960    else
1961      {
1962         e_client_map_enable_set(ec, EINA_FALSE);
1963      }
1964 }
1965
1966 static void
1967 _e_client_cb_evas_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1968 {
1969    E_Client *ec = data;
1970
1971    if (stopping) return; //ignore all of this if we're shutting down!
1972    if (e_object_is_del(data)) return; //client is about to die
1973    if (ec->cur_mouse_action)
1974      {
1975         if (ec->cur_mouse_action->func.end_mouse)
1976           ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", NULL);
1977         else if (ec->cur_mouse_action->func.end)
1978           ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
1979         E_FREE_FUNC(ec->cur_mouse_action, e_object_unref);
1980      }
1981    if (action_client == ec) _e_client_action_finish();
1982
1983    ec->want_focus = ec->take_focus = 0;
1984
1985    _e_client_transform_core_activate_set(ec, EINA_FALSE);
1986
1987    if (ec->new_client) return;
1988    _e_client_event_hide(ec);
1989
1990    EC_CHANGED(ec);
1991 }
1992
1993 static void
1994 _e_client_cb_evas_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1995 {
1996    E_Client *ec = data;
1997    E_Map *map;
1998    Evas_Coord x, y;
1999
2000    if (e_object_is_del(data)) return;
2001
2002    ec->pre_res_change.valid = 0;
2003
2004    _e_client_event_simple(ec, E_EVENT_CLIENT_MOVE);
2005
2006    evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
2007    if ((e_config->transient.move) && (ec->transients))
2008      {
2009         Eina_List *list = eina_list_clone(ec->transients);
2010         E_Client *child;
2011
2012         EINA_LIST_FREE(list, child)
2013           {
2014              if (child->vkbd.vkbd) continue;
2015
2016              evas_object_move(child->frame,
2017                               child->x + x - ec->pre_cb.x,
2018                               child->y + y - ec->pre_cb.y);
2019           }
2020      }
2021    if (ec->moving || (ecmove == ec))
2022      {
2023         wl_signal_emit_mutable(&PRI(ec)->events.move_resize_update, NULL);
2024         _e_client_hook_call(E_CLIENT_HOOK_MOVE_UPDATE, ec);
2025      }
2026
2027    if ((!ec->moving) && (ec->transformed))
2028      {
2029         map = e_client_map_get(ec);
2030         _e_client_transform_geometry_save(ec, map);
2031         e_map_free(map);
2032      }
2033
2034    ec->pre_cb.x = x; ec->pre_cb.y = y;
2035
2036    wl_signal_emit_mutable(&PRI(ec)->events.move, NULL);
2037
2038    e_comp_visibility_calculation_set(EINA_TRUE);
2039 }
2040
2041 static void
2042 _e_client_cb_evas_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2043 {
2044    E_Client *ec = data;
2045    Evas_Coord x, y, w, h;
2046
2047    if (e_object_is_del(data)) return;
2048
2049    ec->pre_res_change.valid = 0;
2050
2051    _e_client_event_simple(ec, E_EVENT_CLIENT_RESIZE);
2052
2053    evas_object_geometry_get(ec->frame, &x, &y, &w, &h);
2054    if ((e_config->transient.resize) && (ec->transients))
2055      {
2056         Eina_List *list = eina_list_clone(ec->transients);
2057         E_Client *child;
2058
2059         EINA_LIST_FREE(list, child)
2060           {
2061              Evas_Coord nx, ny, nw, nh;
2062
2063              if ((ec->pre_cb.w > 0) && (ec->pre_cb.h > 0))
2064                {
2065                   nx = x + (((child->x - x) * w) / ec->pre_cb.w);
2066                   ny = y + (((child->y - y) * h) / ec->pre_cb.h);
2067                   nw = (child->w * w) / ec->pre_cb.w;
2068                   nh = (child->h * h) / ec->pre_cb.h;
2069                   nx += ((nw - child->w) / 2);
2070                   ny += ((nh - child->h) / 2);
2071                   evas_object_move(child->frame, nx, ny);
2072                }
2073           }
2074      }
2075
2076    if (e_client_util_resizing_get(ec) || (ecresize == ec))
2077      {
2078          wl_signal_emit_mutable(&PRI(ec)->events.move_resize_update, NULL);
2079         _e_client_hook_call(E_CLIENT_HOOK_RESIZE_UPDATE, ec);
2080      }
2081    ec->pre_cb.w = w; ec->pre_cb.h = h;
2082
2083    e_client_transform_core_update(ec);
2084    e_comp_visibility_calculation_set(EINA_TRUE);
2085 }
2086
2087 static void
2088 _e_client_cb_evas_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2089 {
2090    E_Client *ec = data;
2091
2092    if (e_object_is_del(data)) return;
2093
2094    _e_client_transform_core_activate_set(ec, EINA_TRUE);
2095
2096    _e_client_event_show(ec);
2097    EC_CHANGED(ec);
2098 }
2099
2100 static void
2101 _e_client_cb_evas_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2102 {
2103    E_Client *ec = data;
2104    E_Comp_Wl_Client_Data *child_cdata = NULL;
2105
2106    if (e_object_is_del(data)) return;
2107    if (ec->layer_block) return;
2108    if (ec->layer_pending) return;
2109    if (e_config->transient.raise && ec->transients)
2110      {
2111         Eina_List *list = eina_list_clone(ec->transients);
2112         E_Client *child, *below = NULL, *above = NULL;
2113         E_Transient transient_policy;
2114
2115         E_LIST_REVERSE_FREE(list, child)
2116           {
2117              child_cdata = e_client_cdata_get(child);
2118              if (child_cdata && !child_cdata->mapped)
2119                {
2120                   ELOGF("COMP", "STACK CHANGE CHILD. BUT not mapped. skip. child(ec:%p, win:0x%08zx)", ec, child, e_client_util_win_get(child));
2121                   continue;
2122                }
2123
2124              /* Don't stack iconic transients. If the user wants these shown,
2125               * that's another option.
2126               */
2127              if (child->iconic && e_client_is_iconified_by_client(child)) continue;
2128
2129              transient_policy = e_client_transient_policy_get(child);
2130              if (transient_policy == E_TRANSIENT_ABOVE)
2131                {
2132                   if (below)
2133                     e_client_stack_below(child, below);
2134                   else
2135                     e_client_stack_above(child, ec);
2136                   below = child;
2137                }
2138              else if (transient_policy == E_TRANSIENT_BELOW)
2139                {
2140                   if (above)
2141                     e_client_stack_below(child, above);
2142                   else
2143                     e_client_stack_below(child, ec);
2144                   above = child;
2145                }
2146
2147           }
2148      }
2149    if (ec->unredirected_single) return;
2150    _e_client_event_simple(ec, E_EVENT_CLIENT_STACK);
2151
2152    e_comp_visibility_calculation_set(EINA_TRUE);
2153 }
2154
2155 ////////////////////////////////////////////////
2156 static void
2157 _e_client_aux_hint_eval(E_Client *ec)
2158 {
2159    if (!ec) return;
2160
2161    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2162    Eina_List *l, *ll;
2163    E_Comp_Wl_Aux_Hint *hint;
2164
2165    if (cdata && cdata->aux_hint.changed)
2166      {
2167         wl_signal_emit_mutable(&PRI(ec)->events.aux_hint_change, NULL);
2168         _e_client_hook_call(E_CLIENT_HOOK_AUX_HINT_CHANGE, ec);
2169
2170         EINA_LIST_FOREACH_SAFE(cdata->aux_hint.hints, l, ll, hint)
2171           {
2172              hint->changed = EINA_FALSE;
2173              if (hint->deleted)
2174                {
2175                   ELOGF("COMP", "AUX_HINT |Del [%d:%s:%s]", ec, hint->id, hint->hint, hint->val);
2176                   if (hint->hint) eina_stringshare_del(hint->hint);
2177                   if (hint->val) eina_stringshare_del(hint->val);
2178                   cdata->aux_hint.hints = eina_list_remove_list(cdata->aux_hint.hints, l);
2179                   E_FREE(hint);
2180                }
2181           }
2182         cdata->aux_hint.changed = 0;
2183      }
2184 }
2185
2186 static void
2187 _e_client_eval(E_Client *ec)
2188 {
2189    int send_event = 1;
2190    unsigned int prop = 0;
2191    int tx, ty;
2192
2193    if (e_object_is_del(E_OBJECT(ec)))
2194      {
2195         CRI("_e_client_eval(%p) with deleted border! - %d\n", ec, ec->new_client);
2196         ec->changed = 0;
2197         return;
2198      }
2199
2200    TRACE_DS_BEGIN(CLIENT:EVAL);
2201
2202    wl_signal_emit_mutable(&PRI(ec)->events.eval_pre_new_client, NULL);
2203    if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_NEW_CLIENT, ec))
2204      {
2205         TRACE_DS_END();
2206         return;
2207      }
2208
2209    if ((ec->new_client) && (!e_client_util_ignored_get(ec)))
2210      {
2211         wl_signal_emit_mutable(&PRI(ec)->events.eval_post_new_client, NULL);
2212         if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_NEW_CLIENT, ec))
2213           {
2214              TRACE_DS_END();
2215              return;
2216           }
2217      }
2218
2219    if (ec->changes.size)
2220      {
2221         ec->changes.size = 0;
2222         evas_object_resize(ec->frame, ec->w, ec->h);
2223
2224         prop |= E_CLIENT_PROPERTY_SIZE;
2225      }
2226    if (ec->changes.pos)
2227      {
2228         ec->changes.tz_position = 0;
2229         ec->changes.pos = 0;
2230         evas_object_move(ec->frame, ec->x, ec->y);
2231         prop |= E_CLIENT_PROPERTY_POS;
2232      }
2233
2234    if (ec->changes.reset_gravity)
2235      {
2236         ec->changes.reset_gravity = 0;
2237         prop |= E_CLIENT_PROPERTY_GRAVITY;
2238      }
2239
2240    if (ec->changes.title)
2241      {
2242         ec->changes.title = 0;
2243         prop |= E_CLIENT_PROPERTY_TITLE;
2244      }
2245
2246    if ((ec->changes.visible) && (ec->visible) && (ec->new_client) && (!ec->iconic))
2247      {
2248         int x, y;
2249
2250         e_input_device_pointer_xy_get(NULL, &x, &y);
2251         if ((!ec->placed) && (!ec->re_manage) &&
2252             (e_config->window_placement_policy == E_WINDOW_PLACEMENT_MANUAL) &&
2253             (!((ec->icccm.transient_for != 0) ||
2254                (ec->dialog))) &&
2255             (!ecmove) && (!ecresize))
2256           {
2257              /* Set this window into moving state */
2258
2259              ec->cur_mouse_action = e_action_find("window_move");
2260              if (ec->cur_mouse_action)
2261                {
2262                   if ((!ec->cur_mouse_action->func.end_mouse) &&
2263                       (!ec->cur_mouse_action->func.end))
2264                     ec->cur_mouse_action = NULL;
2265                   if (ec->cur_mouse_action)
2266                     {
2267                        int t;
2268                        tx = x - (ec->w >> 1);
2269                        e_comp_object_frame_geometry_get(ec->frame, NULL, NULL, &t, NULL);
2270                        ty = y - (t >> 1);
2271                        e_client_pos_set(ec, tx, ty);
2272                        EC_CHANGED(ec);
2273                        ec->changes.pos = 1;
2274                     }
2275                }
2276           }
2277
2278         evas_object_show(ec->frame);
2279         if (evas_object_visible_get(ec->frame))
2280           {
2281              ec->changes.visible = 0;
2282              _e_client_event_show(ec);
2283           }
2284      }
2285    else if ((ec->changes.visible) && (ec->new_client))
2286      {
2287         ec->changes.visible = 0;
2288         if (!ec->iconic)
2289           _e_client_event_hide(ec);
2290      }
2291
2292    if (ec->changes.icon)
2293      {
2294         ec->changes.icon = 0;
2295      }
2296
2297    if (ec->new_client)
2298      e_comp->new_clients--;
2299    ec->new_client = 0;
2300    ec->changed = ec->changes.pos || ec->changes.size ||
2301                  ec->changes.stack || ec->changes.prop || ec->changes.border ||
2302                  ec->changes.reset_gravity ||
2303                  ec->changes.shape || ec->changes.shape_input || ec->changes.icon ||
2304                  ec->changes.internal_state ||
2305                  ec->changes.need_maximize || ec->changes.need_unmaximize;
2306    ec->changes.stack = 0;
2307
2308    if (ec->changes.need_maximize)
2309      {
2310         E_Maximize max = ec->maximized;
2311         ec->maximized = E_MAXIMIZE_NONE;
2312         e_client_maximize(ec, max);
2313         ec->changes.need_maximize = 0;
2314      }
2315    else if (ec->changes.need_unmaximize)
2316      {
2317         e_client_unmaximize(ec, ec->maximized);
2318         ec->changes.need_unmaximize = 0;
2319      }
2320
2321    if (ec->need_fullscreen)
2322      {
2323         e_client_fullscreen(ec, e_config->fullscreen_policy);
2324         ec->need_fullscreen = 0;
2325      }
2326
2327    if (ec->changes.accepts_focus)
2328      {
2329         if ((!ec->icccm.accepts_focus) && (!ec->icccm.take_focus))
2330           {
2331              if (!ec->focused)
2332                ec->changes.accepts_focus = 0;
2333           }
2334      }
2335
2336    if (send_event && prop)
2337      {
2338         _e_client_event_property(ec, prop);
2339      }
2340
2341    _e_client_aux_hint_eval(ec);
2342
2343    e_client_transform_core_update(ec);
2344
2345    wl_signal_emit_mutable(&PRI(ec)->events.eval_end, NULL);
2346    _e_client_hook_call(E_CLIENT_HOOK_EVAL_END, ec);
2347
2348    TRACE_DS_END();
2349 }
2350
2351 EINTERN void
2352 e_client_frame_update(E_Client *ec)
2353 {
2354    const char *bordername;
2355
2356    EINA_SAFETY_ON_NULL_RETURN(ec);
2357    if (e_object_is_del(E_OBJECT(ec))) return;
2358
2359    ec->border.changed = 0;
2360    if (!e_comp_object_frame_allowed(ec->frame)) return;
2361    if (ec->fullscreen || ec->borderless)
2362      bordername = "borderless";
2363    else if (ec->bordername)
2364      bordername = ec->bordername;
2365    else if (((ec->icccm.transient_for != 0) || (ec->dialog)) &&
2366             (ec->icccm.min_w == ec->icccm.max_w) &&
2367             (ec->icccm.min_h == ec->icccm.max_h))
2368      bordername = "noresize_dialog";
2369    else if ((ec->icccm.min_w == ec->icccm.max_w) &&
2370             (ec->icccm.min_h == ec->icccm.max_h))
2371      bordername = "noresize";
2372    else if (ec->shaped)
2373      bordername = "shaped";
2374    else if (ec->urgent)
2375      bordername = "urgent";
2376    else if ((ec->netwm.state.skip_taskbar) ||
2377             (ec->netwm.state.skip_pager))
2378      bordername = "skipped";
2379   /*
2380    else if ((ec->internal) && (ec->icccm.class) &&
2381             (!strncmp(ec->icccm.class, "e_fwin", 6)))
2382      bordername = "internal_fileman";
2383   */
2384    else
2385      bordername = e_config->theme_default_border_style;
2386    if (!bordername) bordername = "default";
2387
2388    e_client_border_set(ec, bordername);
2389 }
2390
2391 static Eina_Bool
2392 _e_client_type_match(E_Client *ec, E_Config_Client_Type *m)
2393 {
2394    if (!ec || !m) return EINA_FALSE;
2395    if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2396
2397    if ((int)ec->netwm.type != m->window_type)
2398      return EINA_FALSE;
2399
2400 #if defined(__cplusplus) || defined(c_plusplus)
2401    if (m->clas)
2402      {
2403         if (!ec->icccm.cpp_class)
2404           return EINA_FALSE;
2405
2406         if (!e_util_glob_match(ec->icccm.cpp_class, m->clas))
2407           return EINA_FALSE;
2408      }
2409 #else
2410    if (m->clas)
2411      {
2412         if (!ec->icccm.class)
2413           return EINA_FALSE;
2414
2415         if (!e_util_glob_match(ec->icccm.class, m->clas))
2416           return EINA_FALSE;
2417      }
2418 #endif
2419
2420    if (m->name)
2421      {
2422         if (ec->icccm.name && e_util_glob_match(ec->icccm.name, m->name))
2423           return EINA_TRUE;
2424
2425         if (ec->icccm.title && e_util_glob_match(ec->icccm.title, m->name))
2426           return EINA_TRUE;
2427
2428         if (ec->netwm.name && e_util_glob_match(ec->netwm.name, m->name))
2429           return EINA_TRUE;
2430      }
2431
2432    return EINA_FALSE;
2433 }
2434
2435 EINTERN int
2436 e_client_type_update(E_Client *ec)
2437 {
2438    E_Config_Client_Type *m;
2439    Eina_List *l;
2440    int type = 0;
2441
2442    if (!e_config->client_types) return 0;
2443
2444    EINA_LIST_FOREACH(e_config->client_types, l, m)
2445      {
2446         if (!_e_client_type_match(ec, m)) continue;
2447         else
2448           {
2449              type = m->client_type;
2450              break;
2451           }
2452      }
2453
2454    if (ec->client_type != type)
2455      {
2456         ec->client_type = type;
2457         _e_client_event_property(ec, E_CLIENT_PROPERTY_CLIENT_TYPE);
2458      }
2459
2460    return ec->client_type;
2461 }
2462
2463 static void
2464 _e_client_transform_sub_apply(E_Client *ec, E_Client *epc, double zoom)
2465 {
2466    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2467    E_Client *subc;
2468    Eina_List *l;
2469    int px = 0, py = 0;
2470    int ox = 0, oy = 0, ow, oh;
2471    int mx, my, mw, mh;
2472    E_Map *map;
2473
2474    EINA_SAFETY_ON_FALSE_RETURN(e_comp_wl_subsurface_check(ec));
2475
2476    e_comp_wl_subsurface_position_get(ec, &ox, &oy);
2477    ow = cdata->width_from_viewport;
2478    oh = cdata->height_from_viewport;
2479
2480    map = e_client_map_get(epc);
2481    e_map_point_coord_get(map, 0, &px, &py, 0);
2482    e_map_free(map);
2483
2484    mx = ox * zoom + px;
2485    my = oy * zoom + py;
2486    mw = ow * zoom;
2487    mh = oh * zoom;
2488
2489    map = e_map_new_with_direct_render(ec->transform_core.direct_render);
2490    e_map_util_points_populate_from_geometry(map, mx, my, mw, mh, 0);
2491    e_map_util_object_move_sync_set(map, EINA_TRUE);
2492    e_client_map_set(ec, map);
2493    e_client_map_enable_set(ec, EINA_TRUE);
2494
2495    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
2496      _e_client_transform_sub_apply(subc, ec, zoom);
2497    EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
2498      _e_client_transform_sub_apply(subc, ec, zoom);
2499
2500    e_map_free(map);
2501 }
2502
2503 static void
2504 _e_client_transient_for_group_make(E_Client *ec, Eina_List **list)
2505 {
2506    E_Client *child;
2507    Eina_List *l;
2508
2509    if (!ec) return;
2510    if (!e_config->transient.raise) return;
2511
2512    EINA_LIST_FOREACH(ec->transients, l, child)
2513      {
2514         if (!child) continue;
2515         if (child->iconic) continue;
2516         if (e_client_transient_policy_get(child) == E_TRANSIENT_ABOVE)
2517           {
2518              *list = eina_list_prepend(*list, child);
2519              _e_client_transient_for_group_make(child, list);
2520           }
2521      }
2522 }
2523
2524 EINTERN E_Client *
2525 e_client_transient_child_top_get(E_Client *ec, Eina_Bool consider_focus)
2526 {
2527    E_Client *top_ec = NULL;
2528    Eina_List *transient_list = NULL;
2529
2530    _e_client_transient_for_group_make(ec, &transient_list);
2531
2532    if (transient_list)
2533      {
2534         Eina_List *l = NULL;
2535         E_Client *temp_ec = NULL;
2536         E_Client *temp_ec2 = NULL;
2537
2538         E_CLIENT_REVERSE_FOREACH(temp_ec)
2539           {
2540              if (top_ec) break;
2541              if (temp_ec == ec)
2542                {
2543                   top_ec = ec;
2544                   break;
2545                }
2546
2547              EINA_LIST_FOREACH(transient_list, l, temp_ec2)
2548                {
2549                   if (temp_ec == temp_ec2)
2550                     {
2551                        if (consider_focus)
2552                          {
2553                             if ((temp_ec2->icccm.accepts_focus) ||
2554                                 (temp_ec2->icccm.take_focus))
2555                               {
2556                                  top_ec = temp_ec2;
2557                               }
2558                          }
2559                        else
2560                          {
2561                             top_ec = temp_ec2;
2562                          }
2563                        break;
2564                     }
2565                }
2566           }
2567         eina_list_free(transient_list);
2568      }
2569    return top_ec;
2570 }
2571
2572 #ifdef EC_IS_NOT_VISIBLE
2573 # undef EC_IS_NOT_VISIBLE
2574 #endif
2575 #define EC_IS_NOT_VISIBLE if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED)
2576
2577 EINTERN Eina_Bool
2578 e_client_visibility_touched_check(E_Client *ec)
2579 {
2580    int tx, ty;
2581
2582    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
2583
2584    tx = wl_fixed_to_int(e_comp->wl_comp_data->ptr.x);
2585    ty = wl_fixed_to_int(e_comp->wl_comp_data->ptr.y);
2586
2587    return _e_client_position_inside_input_rect(ec, tx, ty);
2588 }
2589
2590 EINTERN void
2591 e_client_visibility_change_notify(E_Client *ec)
2592 {
2593    EINA_SAFETY_ON_NULL_RETURN(ec);
2594
2595    if (ec->visibility.changed)
2596      _e_client_event_simple(ec, E_EVENT_CLIENT_VISIBILITY_CHANGE);
2597
2598    wl_signal_emit_mutable(&PRI(ec)->events.eval_visibility, NULL);
2599    _e_client_hook_call(E_CLIENT_HOOK_EVAL_VISIBILITY, ec);
2600 }
2601
2602 EINTERN void
2603 e_client_visibility_end_notify(void)
2604 {
2605    // FIXME: This hook means that the visiblitiy calculation of a zone is done
2606    //        at this idle handler.This is a hook for a zone, not for a client.
2607    //        Therefore, this hook may be defined as a zone hook,
2608    //        ex) E_ZONE_HOOK_EVAL_VISIBILITY_END or E_ZONE_HOOK_EVAL_VISIBILITY_DONE.
2609    _e_client_hook_call(E_CLIENT_HOOK_EVAL_VISIBILITY_END, NULL);
2610 }
2611
2612 static Eina_Bool
2613 _e_client_transform_core_check_change(E_Client *ec)
2614 {
2615    int w = 0;
2616    int h = 0;
2617    Eina_Bool check = EINA_FALSE;
2618    if (!ec) return EINA_FALSE;
2619
2620    if (ec->frame)
2621      evas_object_geometry_get(ec->frame, 0, 0, &w, &h);
2622
2623    // check client position or size change
2624    if (ec->x != ec->transform_core.backup.client_x ||
2625        ec->y != ec->transform_core.backup.client_y ||
2626        ec->w != ec->transform_core.backup.client_w ||
2627        ec->h != ec->transform_core.backup.client_h ||
2628        w     != ec->transform_core.backup.frame_w ||
2629        h     != ec->transform_core.backup.frame_h ||
2630        ec->argb != ec->transform_core.backup.argb)
2631      {
2632         check = EINA_TRUE;
2633         ec->transform_core.backup.client_x = ec->x;
2634         ec->transform_core.backup.client_y = ec->y;
2635         ec->transform_core.backup.client_w = ec->w;
2636         ec->transform_core.backup.client_h = ec->h;
2637         ec->transform_core.backup.frame_w = w;
2638         ec->transform_core.backup.frame_h = h;
2639         ec->transform_core.backup.argb = ec->argb;
2640      }
2641
2642    // check new transform or del transform
2643    if (ec->transform_core.changed)
2644      {
2645         check = EINA_TRUE;
2646         ec->transform_core.changed = EINA_FALSE;
2647      }
2648
2649    // check each transform change
2650    if (ec->transform_core.transform_list)
2651      {
2652         Eina_List *l;
2653         Eina_List *l_next;
2654         E_Util_Transform *transform;
2655
2656         EINA_LIST_FOREACH_SAFE(ec->transform_core.transform_list, l, l_next, transform)
2657           {
2658              // del transform check
2659              if (e_util_transform_ref_count_get(transform) <= 1)
2660                {
2661                   ec->transform_core.transform_list = eina_list_remove(ec->transform_core.transform_list, transform);
2662                   e_util_transform_unref(transform);
2663                   check = EINA_TRUE;
2664                   continue;
2665                }
2666
2667              // transform change test
2668              if (e_util_transform_change_get(transform))
2669                {
2670                   check = EINA_TRUE;
2671                   e_util_transform_change_unset(transform);
2672                }
2673           }
2674      }
2675
2676    if (e_comp_wl_subsurface_check(ec))
2677      {
2678         // check parent matrix change
2679         E_Client *parent = e_comp_wl_subsurface_parent_get(ec);
2680         if (parent && parent->transform_core.result.enable)
2681           {
2682              ec->transform_core.parent.enable = EINA_TRUE;
2683
2684              if (!e_util_transform_matrix_equal_check(&ec->transform_core.parent.matrix,
2685                                                       &parent->transform_core.result.matrix))
2686                {
2687                   check = EINA_TRUE;
2688                   ec->transform_core.parent.matrix = parent->transform_core.result.matrix;
2689                }
2690              if (memcmp(&ec->transform_core.parent.zoom, &parent->transform_core.result.transform.zoom, sizeof(E_Util_Transform_Zoom)) != 0)
2691                {
2692                   check = EINA_TRUE;
2693                   ec->transform_core.parent.zoom = parent->transform_core.result.transform.zoom;
2694                }
2695           }
2696         else if (ec->transform_core.parent.enable)
2697           {
2698              ec->transform_core.parent.enable = EINA_FALSE;
2699              e_util_transform_matrix_load_identity(&ec->transform_core.parent.matrix);
2700              ec->transform_core.parent.zoom.zoom_x = 1.0;
2701              ec->transform_core.parent.zoom.zoom_y = 1.0;
2702              ec->transform_core.parent.zoom.cx = 0;
2703              ec->transform_core.parent.zoom.cy = 0;
2704              check = EINA_TRUE;
2705           }
2706      }
2707
2708    return check;
2709 }
2710
2711 static void
2712 _e_client_transform_core_boundary_update(E_Client *ec, E_Util_Transform_Rect_Vertex *vertices)
2713 {
2714    int minx = 99999, miny = 99999;
2715    int maxx = -99999, maxy = -99999;
2716    int x, y;
2717    int i;
2718
2719    if (!ec) return;
2720    if (!ec->frame) return;
2721    if (!ec->transform_core.result.enable) return;
2722    if (!vertices) return;
2723
2724    for (i = 0; i < 4; ++i)
2725      {
2726         x = 0;
2727         y = 0;
2728
2729         e_util_transform_vertices_pos_round_get(vertices, i, &x, &y, 0, 0);
2730
2731         if (x < minx) minx = x;
2732         if (y < miny) miny = y;
2733         if (x > maxx) maxx = x;
2734         if (y > maxy) maxy = y;
2735      }
2736
2737    ec->transform_core.result.boundary.x = minx;
2738    ec->transform_core.result.boundary.y = miny;
2739    ec->transform_core.result.boundary.w = maxx - minx;
2740    ec->transform_core.result.boundary.h = maxy - miny;
2741
2742    ELOGF("COMP", "[Transform][boundary][%d %d %d %d]",
2743          ec,
2744          ec->transform_core.result.boundary.x,
2745          ec->transform_core.result.boundary.y,
2746          ec->transform_core.result.boundary.w,
2747          ec->transform_core.result.boundary.h);
2748 }
2749
2750 static E_Map *
2751 _e_client_transform_core_map_new(Evas_Object *obj,
2752                                  E_Util_Transform_Rect_Vertex *vertices,
2753                                  E_Util_Transform *transform,
2754                                  Eina_Bool direct_render)
2755 {
2756    E_Map *map;
2757    int i;
2758    int x, y;
2759    double u, v;
2760
2761    map = e_map_new_with_direct_render(direct_render);
2762    EINA_SAFETY_ON_NULL_RETURN_VAL(map, NULL);
2763
2764    e_map_util_points_populate_from_object_full(map, obj, 0);
2765    e_map_util_points_color_set(map, 255, 255, 255, 255);
2766
2767    for (i = 0 ; i < 4 ; ++i)
2768      {
2769         x = 0;
2770         y = 0;
2771
2772         e_util_transform_vertices_pos_round_get(vertices, i, &x, &y, 0, 0);
2773         e_map_point_coord_set(map, i, x, y, 1.0);
2774
2775         if (transform && e_util_transform_texcoord_flag_get(transform))
2776           {
2777              u = 0.0;
2778              v = 0.0;
2779
2780              e_util_transform_texcoord_get(transform, i, &u, &v);
2781              e_map_point_image_uv_set(map, i, u, v);
2782           }
2783      }
2784
2785    return map;
2786 }
2787
2788 static void
2789 _e_client_transform_core_vertices_apply_with_zoom(E_Client *ec,
2790                                         Evas_Object *obj,
2791                                         E_Util_Transform_Rect_Vertex *vertices,
2792                                         E_Util_Transform *transform,
2793                                         E_Util_Transform_Zoom zoom)
2794 {
2795    E_Map *map = NULL;
2796
2797    if (!obj) return;
2798
2799    if (vertices)
2800      {
2801         map = _e_client_transform_core_map_new(obj, vertices, transform,
2802                                                ec->transform_core.direct_render);
2803         EINA_SAFETY_ON_NULL_RETURN(map);
2804
2805         e_map_util_zoom(map, zoom.zoom_x, zoom.zoom_y, zoom.cx, zoom.cy);
2806
2807         e_comp_object_map_set(obj, map);
2808
2809         if (ec->transform_core.activate)
2810           e_comp_object_map_enable_set(obj, EINA_TRUE);
2811         else
2812           e_comp_object_map_enable_set(obj, EINA_FALSE);
2813
2814         e_map_free(map);
2815      }
2816    else
2817      evas_object_map_enable_set(obj, EINA_FALSE);
2818 }
2819
2820 static void
2821 _e_client_transform_core_vertices_apply(E_Client *ec,
2822                                         Evas_Object *obj,
2823                                         E_Util_Transform_Rect_Vertex *vertices,
2824                                         E_Util_Transform *transform)
2825 {
2826    E_Map *map = NULL;
2827
2828    if (!obj) return;
2829
2830    if (vertices)
2831      {
2832         map = _e_client_transform_core_map_new(obj, vertices, transform,
2833                                                ec->transform_core.direct_render);
2834         EINA_SAFETY_ON_NULL_RETURN(map);
2835
2836         e_comp_object_map_set(obj, map);
2837
2838         if (ec->transform_core.activate)
2839           e_comp_object_map_enable_set(obj, EINA_TRUE);
2840         else
2841           e_comp_object_map_enable_set(obj, EINA_FALSE);
2842
2843         e_map_free(map);
2844      }
2845    else
2846      evas_object_map_enable_set(obj, EINA_FALSE);
2847 }
2848
2849 static void
2850 _e_client_transform_core_sub_update(E_Client *ec, E_Util_Transform_Rect_Vertex *vertices)
2851 {
2852    Eina_List *l;
2853    E_Client *subc;
2854    E_Comp_Wl_Client_Data *cdata;
2855
2856    if (!ec) return;
2857
2858    cdata = e_client_cdata_get(ec);
2859    if (!cdata) return;
2860
2861    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
2862       e_client_transform_core_update(subc);
2863
2864    EINA_LIST_FOREACH(cdata->sub.below_list, l, subc)
2865       e_client_transform_core_update(subc);
2866 }
2867
2868 static void
2869 _e_client_cb_hook_shell_surface_ready(void *data EINA_UNUSED, E_Client *ec)
2870 {
2871    if (EINA_UNLIKELY(!ec))
2872      return;
2873
2874    _e_client_aux_hint_eval(ec);
2875 }
2876
2877 // FIXME: This function has to be deleted and it remains for the backward compatibility.
2878 //        Please find and fix to use e_comp_visibility_calculation_set(EINA_TRUE)
2879 //        instead of e_client_visibility_calculate() call at e20 modules.
2880 E_API void
2881 e_client_visibility_calculate(void)
2882 {
2883    e_comp_visibility_calculation_set(EINA_TRUE);
2884 }
2885
2886 E_API void
2887 e_client_visibility_skip_set(E_Client *ec, Eina_Bool skip)
2888 {
2889    if (!ec) return;
2890
2891    ELOGF("POL_VIS", "visibility skip set to %d", ec, skip);
2892    ec->visibility.skip = skip;
2893 }
2894
2895 E_API void
2896 e_client_post_raise_lower_set(E_Client *ec, Eina_Bool raise_set, Eina_Bool lower_set)
2897 {
2898    if (!ec) return;
2899
2900    ec->post_raise = raise_set;
2901    ec->post_lower = lower_set;
2902 }
2903
2904 E_API Eina_Bool
2905 e_client_first_mapped_get(E_Client *ec)
2906 {
2907    if (!ec) return EINA_FALSE;
2908
2909    return ec->first_mapped;
2910 }
2911
2912 EINTERN Eina_Bool e_client_mapped_get(E_Client *ec)
2913 {
2914    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2915    EINA_SAFETY_ON_NULL_RETURN_VAL(cdata, EINA_FALSE);
2916
2917   return cdata->mapped;
2918 }
2919
2920 EINTERN void
2921 e_client_mapped_set(E_Client *ec, Eina_Bool set)
2922 {
2923    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2924    EINA_SAFETY_ON_NULL_RETURN(cdata);
2925
2926    cdata->mapped = set;
2927 }
2928
2929
2930 ////////////////////////////////////////////////
2931 EINTERN Eina_Bool
2932 e_client_clients_hash_exist()
2933 {
2934   int pix_id;
2935
2936   for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++)
2937     {
2938       if (eina_hash_population(clients_hash[pix_id]))
2939         return EINA_TRUE;
2940     }
2941
2942   return EINA_FALSE;
2943 }
2944
2945 EINTERN void
2946 e_client_idler_before(Eina_Bool *check_focus)
2947 {
2948    const Eina_List *l;
2949    E_Client *ec;
2950
2951    *check_focus = EINA_FALSE;
2952
2953    if (!e_client_clients_hash_exist()) return;
2954
2955    TRACE_DS_BEGIN(CLIENT:IDLE BEFORE);
2956
2957    EINA_LIST_FOREACH(e_comp->clients, l, ec)
2958      {
2959         // pass 1 - eval0. fetch properties on new or on change and
2960         // call hooks to decide what to do - maybe move/resize
2961         if (ec->ignored || (!ec->changed)) continue;
2962
2963         wl_signal_emit_mutable(&PRI(ec)->events.eval_pre_fetch, NULL);
2964         if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_FETCH, ec)) continue;
2965
2966
2967         /* FETCH is hooked by the compositor to get client hints */
2968         wl_signal_emit_mutable(&PRI(ec)->events.eval_fetch, NULL);
2969         if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_FETCH, ec)) continue;
2970
2971         if (ec->new_client)
2972           {
2973              e_client_type_update(ec);
2974           }
2975
2976         /* PRE_POST_FETCH calls e_remember apply for new client */
2977         wl_signal_emit_mutable(&PRI(ec)->events.eval_pre_post_fetch, NULL);
2978         if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_POST_FETCH, ec)) continue;
2979         wl_signal_emit_mutable(&PRI(ec)->events.eval_post_fetch, NULL);
2980         if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_FETCH, ec)) continue;
2981         wl_signal_emit_mutable(&PRI(ec)->events.eval_pre_frame_assign, NULL);
2982         if (!_e_client_hook_call(E_CLIENT_HOOK_EVAL_PRE_FRAME_ASSIGN, ec)) continue;
2983
2984         wl_signal_emit_mutable(&PRI(ec)->events.eval_post_frame_assign, NULL);
2985         _e_client_hook_call(E_CLIENT_HOOK_EVAL_POST_FRAME_ASSIGN, ec);
2986      }
2987    // pass 2 - show and hide windows needing hide and eval (main eval)
2988    E_CLIENT_FOREACH(ec)
2989      {
2990         if (e_object_is_del(E_OBJECT(ec))) continue;
2991         if (ec->ignored)
2992           {
2993              // ignored client but needing eval (aux hint) such as remote surfaces
2994              if (ec->changed)
2995                {
2996                   E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2997                   if (cdata && cdata->first_commit)
2998                     _e_client_aux_hint_eval(ec);
2999                }
3000              continue;
3001           }
3002
3003         if (ec->changes.visible)
3004           {
3005              if (ec->visible)
3006                {
3007                   if ((!ec->new_client) &&
3008                       (!ec->changes.pos) &&
3009                       (!ec->changes.size))
3010                     {
3011                        evas_object_show(ec->frame);
3012                        ec->changes.visible = !evas_object_visible_get(ec->frame);
3013                     }
3014                }
3015              else
3016                {
3017                   evas_object_hide(ec->frame);
3018                   ec->changes.visible = 0;
3019                }
3020           }
3021
3022         if (ec->changed)
3023           {
3024              _e_client_eval(ec);
3025              e_comp_visibility_calculation_set(EINA_TRUE);
3026              if (ec->changes.accepts_focus)
3027                *check_focus = EINA_TRUE;
3028              ec->changes.accepts_focus = 0;
3029           }
3030
3031         if ((ec->changes.visible) && (ec->visible) && (!ec->changed))
3032           {
3033              evas_object_show(ec->frame);
3034              ec->changes.visible = !evas_object_visible_get(ec->frame);
3035              ec->changed = ec->changes.visible;
3036              e_comp_visibility_calculation_set(EINA_TRUE);
3037           }
3038      }
3039
3040    TRACE_DS_END();
3041 }
3042
3043
3044 EINTERN Eina_Bool
3045 e_client_init(void)
3046 {
3047    int pix_id;
3048    for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++)
3049      clients_hash[pix_id] = eina_hash_pointer_new(NULL);
3050
3051    E_COMP_WL_HOOK_APPEND(hooks, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_client_cb_hook_shell_surface_ready, NULL);
3052
3053    E_EVENT_CLIENT_ADD = ecore_event_type_new();
3054    E_EVENT_CLIENT_REMOVE = ecore_event_type_new();
3055    E_EVENT_CLIENT_DESK_SET = ecore_event_type_new();
3056    E_EVENT_CLIENT_ZONE_SET = ecore_event_type_new();
3057    E_EVENT_CLIENT_RESIZE = ecore_event_type_new();
3058    E_EVENT_CLIENT_MOVE = ecore_event_type_new();
3059    E_EVENT_CLIENT_SHOW = ecore_event_type_new();
3060    E_EVENT_CLIENT_HIDE = ecore_event_type_new();
3061    E_EVENT_CLIENT_ICONIFY = ecore_event_type_new();
3062    E_EVENT_CLIENT_UNICONIFY = ecore_event_type_new();
3063    E_EVENT_CLIENT_STACK = ecore_event_type_new();
3064    E_EVENT_CLIENT_FOCUS_IN = ecore_event_type_new();
3065    E_EVENT_CLIENT_FOCUS_OUT = ecore_event_type_new();
3066    E_EVENT_CLIENT_PROPERTY = ecore_event_type_new();
3067    E_EVENT_CLIENT_FULLSCREEN = ecore_event_type_new();
3068    E_EVENT_CLIENT_UNFULLSCREEN = ecore_event_type_new();
3069 #ifdef _F_ZONE_WINDOW_ROTATION_
3070    E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN = ecore_event_type_new();
3071    E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL = ecore_event_type_new();
3072    E_EVENT_CLIENT_ROTATION_CHANGE_END = ecore_event_type_new();
3073    E_EVENT_CLIENT_ROTATION_GEOMETRY_SET = ecore_event_type_new();
3074 #endif
3075    E_EVENT_CLIENT_VISIBILITY_CHANGE = ecore_event_type_new();
3076    E_EVENT_CLIENT_BUFFER_CHANGE = ecore_event_type_new();
3077    E_EVENT_CLIENT_FOCUS_SKIP_SET = ecore_event_type_new();;
3078    E_EVENT_CLIENT_FOCUS_SKIP_UNSET = ecore_event_type_new();;
3079
3080    return (!!clients_hash[1]);
3081 }
3082
3083 EINTERN void
3084 e_client_shutdown(void)
3085 {
3086    int pix_id;
3087    for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++)
3088      E_FREE_FUNC(clients_hash[pix_id], eina_hash_free);
3089
3090    E_FREE_LIST(hooks, e_comp_wl_hook_del);
3091    E_FREE_LIST(handlers, ecore_event_handler_del);
3092
3093 }
3094
3095 E_API void
3096 e_client_unignore(E_Client *ec)
3097 {
3098    E_OBJECT_CHECK(ec);
3099    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
3100    if (!ec->ignored) return;
3101
3102    ec->ignored = 0;
3103    _e_client_event_add(ec);
3104 }
3105
3106 static E_Layer
3107 _e_client_convert_fullscreen_layer(int layer)
3108 {
3109    if (layer <= E_LAYER_CLIENT_NORMAL)
3110      return E_LAYER_CLIENT_NORMAL;
3111    else if (layer <= E_LAYER_CLIENT_ABOVE)
3112      return E_LAYER_CLIENT_ABOVE;
3113    else if (layer <= E_LAYER_CLIENT_EDGE)
3114      return E_LAYER_CLIENT_EDGE;
3115    else
3116      return E_LAYER_CLIENT_FULLSCREEN;
3117 }
3118
3119 E_API E_Client *
3120 e_client_new(E_Pixmap *cp, int first_map, int internal)
3121 {
3122    E_Client *ec;
3123    E_Pixmap_Type type;
3124
3125    type = e_pixmap_type_get(cp);
3126    if (type >= E_PIXMAP_TYPE_MAX) return NULL;
3127    if (eina_hash_find(clients_hash[type], &cp)) return NULL;
3128
3129    ec = E_OBJECT_ALLOC(E_Client, E_CLIENT_TYPE, _e_client_free);
3130    if (!ec) return NULL;
3131    e_object_del_func_set(E_OBJECT(ec), E_OBJECT_CLEANUP_FUNC(_e_client_del));
3132
3133    if (!_e_client_private_init(ec))
3134      {
3135         e_object_del(E_OBJECT(ec));
3136         return NULL;
3137      }
3138
3139    uuid_generate(ec->uuid);
3140
3141    ec->focus_policy_override = E_FOCUS_LAST;
3142    e_client_size_set(ec, 1, 1);
3143    ec->internal = internal;
3144
3145    ec->pixmap = cp;
3146    e_pixmap_client_set(cp, ec);
3147    ec->resize_mode = E_POINTER_RESIZE_NONE;
3148    ec->layer = E_LAYER_CLIENT_NORMAL;
3149    ec->first_mapped = EINA_FALSE;
3150    ec->post_raise = EINA_TRUE;
3151    ec->post_lower = EINA_FALSE;
3152    ec->animatable = EINA_TRUE;
3153    ec->maximize_type = e_config->maximize_policy & E_MAXIMIZE_TYPE;
3154    ec->fullscreen_layer = _e_client_convert_fullscreen_layer(e_config->fullscreen_layer);
3155
3156    /* FIXME: if first_map is 1 then we should ignore the first hide event
3157     * or ensure the window is already hidden and events flushed before we
3158     * create a border for it */
3159    if (first_map)
3160      {
3161         ec->changes.pos = 1;
3162         ec->re_manage = 1;
3163      }
3164    ec->offer_resistance = 1;
3165    ec->new_client = 1;
3166    e_comp->new_clients++;
3167
3168    ec->exp_iconify.by_client = 0;
3169    ec->exp_iconify.not_raise = 0;
3170    ec->exp_iconify.skip_iconify = 0;
3171    ec->exp_iconify.skip_by_remote = 0;
3172    if (e_config->deiconify_approve)
3173      ec->exp_iconify.deiconify_update= 1;
3174    else
3175      ec->exp_iconify.deiconify_update= 0;
3176    if (e_config->use_buffer_flush)
3177      ec->exp_iconify.buffer_flush = 1;
3178    else
3179      ec->exp_iconify.buffer_flush = 0;
3180
3181    e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
3182
3183    wl_signal_emit_mutable(&PRI(ec)->events.new_client, NULL);
3184    if (!_e_client_hook_call(E_CLIENT_HOOK_NEW_CLIENT, ec))
3185      {
3186         /* delete the above allocated object */
3187         //e_object_del(E_OBJECT(ec));
3188         return NULL;
3189      }
3190
3191    _e_client_aux_hint_eval(ec);
3192
3193    ec->icccm.title = NULL;
3194    ec->icccm.name = NULL;
3195 #if defined(__cplusplus) || defined(c_plusplus)
3196    ec->icccm.cpp_class = NULL;
3197 #else
3198    ec->icccm.class = NULL;
3199 #endif
3200    ec->icccm.min_w = 1;
3201    ec->icccm.min_h = 1;
3202    ec->icccm.max_w = 32767;
3203    ec->icccm.max_h = 32767;
3204
3205    ec->netwm.pid = 0;
3206    ec->netwm.name = NULL;
3207    ec->netwm.state.skip_taskbar = 0;
3208    ec->netwm.state.skip_pager = 0;
3209    ec->netwm.opacity = 255;
3210
3211    ec->visibility.obscured = E_VISIBILITY_UNKNOWN;
3212    ec->visibility.opaque = -1;
3213    ec->visibility.changed = 0;
3214    ec->visibility.skip = 0;
3215    ec->visibility.last_sent_type = E_VISIBILITY_UNKNOWN;
3216
3217    ec->transform.zoom = 1.0;
3218    ec->transform.angle = 0.0;
3219    ec->transform_core.direct_render = EINA_TRUE;
3220    ec->transform_core.activate = EINA_TRUE;
3221
3222    ec->pointer_enter_sent = EINA_FALSE;
3223
3224    ec->acquire_fence_fd = -1;
3225
3226    EC_CHANGED(ec);
3227
3228    e_comp->clients = eina_list_append(e_comp->clients, ec);
3229    eina_hash_add(clients_hash[type], &ec->pixmap, ec);
3230
3231    ELOGF("COMP", "CLIENT ADD. cp:%p, argb:%d, internal:%d, ignored:%d", ec, cp, ec->argb, internal, ec->ignored);
3232    if (!ec->ignored)
3233      _e_client_event_add(ec);
3234    e_comp_object_client_add(ec);
3235    if (ec->frame)
3236      {
3237         evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_client_cb_evas_show, ec);
3238         evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_client_cb_evas_hide, ec);
3239         evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_client_cb_evas_move, ec);
3240         evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESIZE, _e_client_cb_evas_resize, ec);
3241         evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESTACK, _e_client_cb_evas_restack, ec);
3242      }
3243
3244    wl_signal_emit_mutable(&PRI(ec)->events.new_client_post, NULL);
3245
3246 #ifdef _F_E_CLIENT_NEW_CLIENT_POST_HOOK_
3247    _e_client_hook_call(E_CLIENT_HOOK_NEW_CLIENT_POST, ec);
3248 #endif
3249
3250    ec->manage_resize.resize_obj = NULL;
3251    ec->manage_resize.x = ec->manage_resize.y = ec->manage_resize.w = ec->manage_resize.h = 0;
3252    ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
3253    ec->manage_resize.aw = ec->manage_resize.ah = 0;
3254    ec->manage_resize.header_h = 0;
3255    ec->manage_resize.footer_h = 0;
3256
3257    ec->visibility.ignore_geometry = e_config->calc_vis_ignore_geometry;
3258
3259    return ec;
3260 }
3261
3262 E_API Eina_Bool e_client_is_internal(E_Client *ec)
3263 {
3264    E_OBJECT_CHECK_RETURN(ec, EINA_TRUE);
3265    return ec->internal;
3266 }
3267
3268 EINTERN void
3269 e_client_desk_iconify_skip_set(E_Client *ec, Eina_Bool skip)
3270 {
3271    if (!ec) return;
3272    ec->user_skip_winlist = skip;
3273 }
3274
3275 EINTERN Eina_Bool
3276 e_client_desk_iconify_skip_get(E_Client *ec)
3277 {
3278    if (!ec) return EINA_FALSE;
3279    return ec->user_skip_winlist;
3280 }
3281
3282 EINTERN Eina_Bool
3283 e_client_comp_grabbed_get(void)
3284 {
3285    return comp_grabbed;
3286 }
3287
3288 EINTERN E_Client *
3289 e_client_action_get(void)
3290 {
3291    return action_client;
3292 }
3293
3294
3295 //////////////////////////////////////////////////////////
3296
3297 EINTERN void
3298 e_client_mouse_in(E_Client *ec, int x, int y)
3299 {
3300    E_Desk *desk;
3301
3302    if (comp_grabbed) return;
3303    if (e_object_is_del(E_OBJECT(ec))) return;
3304    desk = e_comp_desk_find_by_ec(ec);
3305    if (desk && desk->animate_count) return;
3306    ec->mouse.current.mx = x;
3307    ec->mouse.current.my = y;
3308    ec->mouse.in = 1;
3309
3310    wl_signal_emit_mutable(&PRI(ec)->events.mouse_in, NULL);
3311 }
3312
3313 EINTERN void
3314 e_client_mouse_out(E_Client *ec, int x, int y)
3315 {
3316    E_Desk *desk;
3317
3318    if (comp_grabbed) return;
3319    if (ec->fullscreen) return;
3320    if (e_object_is_del(E_OBJECT(ec))) return;
3321    desk = e_comp_desk_find_by_ec(ec);
3322    if (desk && desk->animate_count) return;
3323
3324    ec->mouse.current.mx = x;
3325    ec->mouse.current.my = y;
3326    ec->mouse.in = 0;
3327
3328    wl_signal_emit_mutable(&PRI(ec)->events.mouse_out, NULL);
3329 }
3330
3331 EINTERN void
3332 e_client_mouse_wheel(E_Client *ec, Evas_Point *output, E_Binding_Event_Wheel *ev)
3333 {
3334    EINA_SAFETY_ON_NULL_RETURN(ec);
3335    if (action_client) return;
3336    ec->mouse.current.mx = output->x;
3337    ec->mouse.current.my = output->y;
3338 }
3339
3340 EINTERN void
3341 e_client_mouse_down(E_Client *ec, int button, Evas_Point *output, E_Binding_Event_Mouse_Button *ev)
3342 {
3343    EINA_SAFETY_ON_NULL_RETURN(ec);
3344
3345    if (action_client || ec->iconic || e_client_util_ignored_get(ec)) return;
3346    if ((button >= 1) && (button <= 3))
3347      {
3348         ec->mouse.last_down[button - 1].mx = output->x;
3349         ec->mouse.last_down[button - 1].my = output->y;
3350         ec->mouse.last_down[button - 1].x = ec->x;
3351         ec->mouse.last_down[button - 1].y = ec->y;
3352         ec->mouse.last_down[button - 1].w = ec->w;
3353         ec->mouse.last_down[button - 1].h = ec->h;
3354      }
3355    else
3356      {
3357         ec->moveinfo.down.x = ec->x;
3358         ec->moveinfo.down.y = ec->y;
3359         ec->moveinfo.down.w = ec->w;
3360         ec->moveinfo.down.h = ec->h;
3361      }
3362    ec->mouse.current.mx = output->x;
3363    ec->mouse.current.my = output->y;
3364    if ((button >= 1) && (button <= 3))
3365      {
3366         ec->mouse.last_down[button - 1].mx = output->x;
3367         ec->mouse.last_down[button - 1].my = output->y;
3368         ec->mouse.last_down[button - 1].x = ec->x;
3369         ec->mouse.last_down[button - 1].y = ec->y;
3370         ec->mouse.last_down[button - 1].w = ec->w;
3371         ec->mouse.last_down[button - 1].h = ec->h;
3372      }
3373    else
3374      {
3375         ec->moveinfo.down.x = ec->x;
3376         ec->moveinfo.down.y = ec->y;
3377         ec->moveinfo.down.w = ec->w;
3378         ec->moveinfo.down.h = ec->h;
3379      }
3380    ec->mouse.current.mx = output->x;
3381    ec->mouse.current.my = output->y;
3382
3383    wl_signal_emit_mutable(&PRI(ec)->events.mouse_down, NULL);
3384 }
3385
3386 EINTERN void
3387 e_client_mouse_up(E_Client *ec, int button, Evas_Point *output, E_Binding_Event_Mouse_Button* ev)
3388 {
3389    EINA_SAFETY_ON_NULL_RETURN(ec);
3390    if (ec->iconic || e_client_util_ignored_get(ec)) return;
3391    if ((button >= 1) && (button <= 3))
3392      {
3393         ec->mouse.last_up[button - 1].mx = output->x;
3394         ec->mouse.last_up[button - 1].my = output->y;
3395         ec->mouse.last_up[button - 1].x = ec->x;
3396         ec->mouse.last_up[button - 1].y = ec->y;
3397      }
3398    ec->mouse.current.mx = output->x;
3399    ec->mouse.current.my = output->y;
3400    /* also we don't pass the same params that went in - then again that */
3401    /* should be ok as we are just ending the action if it has an end */
3402    if (ec->cur_mouse_action)
3403      {
3404         if (ec->cur_mouse_action->func.end_mouse)
3405           ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", ev);
3406         else if (ec->cur_mouse_action->func.end)
3407           ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
3408         e_object_unref(E_OBJECT(ec->cur_mouse_action));
3409         ec->cur_mouse_action = NULL;
3410      }
3411
3412    if ((button >= 1) && (button <= 3))
3413      {
3414         ec->mouse.last_up[button - 1].mx = output->x;
3415         ec->mouse.last_up[button - 1].my = output->y;
3416         ec->mouse.last_up[button - 1].x = ec->x;
3417         ec->mouse.last_up[button - 1].y = ec->y;
3418      }
3419 }
3420
3421 E_API void
3422 e_client_stay_within_canvas_margin(E_Client *ec)
3423 {
3424    int new_x = ec->x;
3425    int new_y = ec->y;
3426
3427    if (ec->floating)
3428      {
3429         _e_client_stay_within_canvas_margin(ec, ec->x, ec->y, &new_x, &new_y);
3430
3431         if ((ec->x != new_x) || (ec->y != new_y))
3432           evas_object_move(ec->frame, new_x, new_y);
3433      }
3434 }
3435
3436 EINTERN void
3437 e_client_mouse_move(E_Client *ec, Evas_Point *output)
3438 {
3439    EINA_SAFETY_ON_NULL_RETURN(ec);
3440    if (ec->iconic || e_client_util_ignored_get(ec)) return;
3441    ec->mouse.current.mx = output->x;
3442    ec->mouse.current.my = output->y;
3443    if (e_client_util_moving_get(ec))
3444      {
3445         _e_client_move_handle(ec);
3446      }
3447    else if (e_client_util_resizing_get(ec))
3448      {
3449         _e_client_resize_handle(ec);
3450      }
3451 }
3452 ///////////////////////////////////////////////////////
3453
3454 EINTERN void
3455 e_client_res_change_geometry_save(E_Client *ec)
3456 {
3457    E_OBJECT_CHECK(ec);
3458    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
3459
3460    if (ec->pre_res_change.valid) return;
3461    ec->pre_res_change.valid = 1;
3462    ec->pre_res_change.x = ec->x;
3463    ec->pre_res_change.y = ec->y;
3464    ec->pre_res_change.w = ec->w;
3465    ec->pre_res_change.h = ec->h;
3466    ec->pre_res_change.saved.x = ec->saved.x;
3467    ec->pre_res_change.saved.y = ec->saved.y;
3468    ec->pre_res_change.saved.w = ec->saved.w;
3469    ec->pre_res_change.saved.h = ec->saved.h;
3470 }
3471
3472 EINTERN void
3473 e_client_res_change_geometry_restore(E_Client *ec)
3474 {
3475    E_Zone *zone;
3476
3477    struct
3478    {
3479       unsigned char valid : 1;
3480       int           x, y, w, h;
3481       struct
3482       {
3483          int x, y, w, h;
3484       } saved;
3485    } pre_res_change;
3486
3487    E_OBJECT_CHECK(ec);
3488    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
3489    if (!ec->pre_res_change.valid) return;
3490    if (ec->new_client) return;
3491
3492    zone = e_comp_zone_find_by_ec(ec);
3493    if (!zone) return;
3494
3495    memcpy(&pre_res_change, &ec->pre_res_change, sizeof(pre_res_change));
3496
3497    if (ec->fullscreen)
3498      {
3499         e_client_unfullscreen(ec);
3500         e_client_fullscreen(ec, e_config->fullscreen_policy);
3501      }
3502    else if (ec->maximized != E_MAXIMIZE_NONE)
3503      {
3504         E_Maximize max;
3505
3506         max = ec->maximized;
3507         e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
3508         e_client_maximize(ec, max);
3509      }
3510    else
3511      {
3512         int x, y, w, h, zx, zy, zw, zh;
3513
3514         ec->saved.x = ec->pre_res_change.saved.x;
3515         ec->saved.y = ec->pre_res_change.saved.y;
3516         ec->saved.w = ec->pre_res_change.saved.w;
3517         ec->saved.h = ec->pre_res_change.saved.h;
3518
3519         e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
3520
3521         if (ec->saved.w > zw)
3522           ec->saved.w = zw;
3523         if ((ec->saved.x + ec->saved.w) > (zx + zw))
3524           ec->saved.x = zx + zw - ec->saved.w;
3525
3526         if (ec->saved.h > zh)
3527           ec->saved.h = zh;
3528         if ((ec->saved.y + ec->saved.h) > (zy + zh))
3529           ec->saved.y = zy + zh - ec->saved.h;
3530
3531         x = ec->pre_res_change.x;
3532         y = ec->pre_res_change.y;
3533         w = ec->pre_res_change.w;
3534         h = ec->pre_res_change.h;
3535         if (w > zw)
3536           w = zw;
3537         if (h > zh)
3538           h = zh;
3539         if ((x + w) > (zx + zw))
3540           x = zx + zw - w;
3541         if ((y + h) > (zy + zh))
3542           y = zy + zh - h;
3543         evas_object_geometry_set(ec->frame, x, y, w, h);
3544      }
3545    memcpy(&ec->pre_res_change, &pre_res_change, sizeof(pre_res_change));
3546 }
3547
3548 EINTERN void
3549 e_client_pos_set(E_Client *ec, int x, int y)
3550 {
3551    if (!ec) return;
3552    ec->x = x;
3553    ec->y = y;
3554 }
3555
3556 EINTERN void
3557 e_client_pos_get(E_Client *ec, int *x, int *y)
3558 {
3559    int ex = 0;
3560    int ey = 0;
3561
3562    if (ec)
3563      {
3564         ex = ec->x;
3565         ey = ec->y;
3566      }
3567
3568    if (x) *x = ex;
3569    if (y) *y = ey;
3570 }
3571
3572 E_API void
3573 e_client_size_set(E_Client *ec, int w, int h)
3574 {
3575    if (!ec) return;
3576    ec->w = w;
3577    ec->h = h;
3578 }
3579
3580 E_API void
3581 e_client_size_get(E_Client *ec, int *w, int *h)
3582 {
3583    int ew = 0;
3584    int eh = 0;
3585
3586    if (ec)
3587      {
3588         ew = ec->w;
3589         eh = ec->h;
3590      }
3591
3592    if (w) *w = ew;
3593    if (h) *h = eh;
3594 }
3595
3596 E_API void
3597 e_client_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
3598 {
3599    int gx = 0;
3600    int gy = 0;
3601    int gw = 0;
3602    int gh = 0;
3603
3604    E_OBJECT_CHECK(ec);
3605    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
3606
3607    if (e_client_transform_core_enable_get(ec))
3608      {
3609         gx = ec->transform_core.result.boundary.x;
3610         gy = ec->transform_core.result.boundary.y;
3611         gw = ec->transform_core.result.boundary.w;
3612         gh = ec->transform_core.result.boundary.h;
3613      }
3614    else
3615      {
3616         if (ec->frame)
3617           {
3618              evas_object_geometry_get(ec->frame, &gx, &gy, &gw, &gh);
3619              if (gw == 0 && gh == 0)
3620                {
3621                   /* In this case, there is no image buffer in e_comp_object, thus it
3622                    * should return geometry value of ec itself. It usually happens if
3623                    * new ec is not mapped yet.
3624                    */
3625                   gw = ec->w;
3626                   gh = ec->h;
3627                   gx = ec->x;
3628                   gy = ec->y;
3629                }
3630           }
3631         else
3632           {
3633              gx = ec->x;
3634              gy = ec->y;
3635              gw = ec->w;
3636              gh = ec->h;
3637           }
3638      }
3639
3640    if (x) *x = gx;
3641    if (y) *y = gy;
3642    if (w) *w = gw;
3643    if (h) *h = gh;
3644 }
3645
3646 E_API E_Client *
3647 e_client_above_get(const E_Client *ec)
3648 {
3649    unsigned int x;
3650    E_Client *ec2;
3651
3652    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
3653    if (EINA_INLIST_GET(ec)->next) //check current layer
3654      {
3655         EINA_INLIST_FOREACH(EINA_INLIST_GET(ec)->next, ec2)
3656           {
3657              if (ec == ec2)
3658                {
3659                   ELOGF("FATAL", "CHECK the ec inlist next", ec);
3660                   continue;
3661                }
3662              if (!e_object_is_del(E_OBJECT(ec2)))
3663                return ec2;
3664           }
3665      }
3666    if (ec->layer == E_LAYER_CLIENT_CURSOR) return NULL;
3667    if (e_comp_canvas_client_layer_map(ec->layer) == 9999) return NULL;
3668
3669    g_rec_mutex_lock(&e_comp->ec_list_mutex);
3670    /* go up the layers until we find one */
3671    for (x = e_comp_canvas_layer_map(ec->layer) + 1; x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x++)
3672      {
3673         if (!e_comp->layers[x].clients) continue;
3674         EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
3675           {
3676              if (ec == ec2)
3677                {
3678                   ELOGF("FATAL", "EC exist above layer. ec layer_map:%d, cur layer_map:%d",
3679                         ec, e_comp_canvas_layer_map(ec->layer), x);
3680                   continue;
3681                }
3682              if (!e_object_is_del(E_OBJECT(ec2)))
3683                {
3684                   g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3685                   return ec2;
3686                }
3687           }
3688      }
3689    g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3690
3691    return NULL;
3692 }
3693
3694 E_API E_Client *
3695 e_client_below_get(const E_Client *ec)
3696 {
3697    unsigned int x;
3698    E_Client *ec2;
3699    Eina_Inlist *l;
3700    E_Layer ec_layer, ec_layer_cw;
3701    int cw_layer;
3702
3703    E_OBJECT_CHECK_RETURN(ec, NULL);
3704    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, NULL);
3705
3706    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
3707    if (EINA_INLIST_GET(ec)->prev) //check current layer
3708      {
3709         for (l = EINA_INLIST_GET(ec)->prev; l; l = l->prev)
3710           {
3711              ec2 = EINA_INLIST_CONTAINER_GET(l, E_Client);
3712              if (ec == ec2)
3713                {
3714                   ELOGF("FATAL", "CHECK the ec inlist prev", ec);
3715                   continue;
3716                }
3717              if (!e_object_is_del(E_OBJECT(ec2)))
3718                return ec2;
3719           }
3720      }
3721
3722    // check layer validation
3723    ec_layer = ec->layer;
3724    if (ec->layer_block || ec->layer_pending)
3725      {
3726         cw_layer = e_comp_object_layer_get(ec->frame);
3727         if (cw_layer >= 0)
3728           {
3729              ec_layer_cw = e_comp_canvas_layer_map_to(cw_layer);
3730              if (ec_layer != ec_layer_cw)
3731                {
3732                   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);
3733                   ec_layer = ec_layer_cw;
3734                }
3735           }
3736      }
3737
3738    if (ec_layer == E_LAYER_CLIENT_DESKTOP) return NULL;
3739    if (e_comp_canvas_client_layer_map(ec_layer) == 9999) return NULL;
3740
3741    /* go down the layers until we find one */
3742    x = e_comp_canvas_layer_map(ec_layer);
3743    if (x > 0) x--;
3744
3745    g_rec_mutex_lock(&e_comp->ec_list_mutex);
3746    for (; x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
3747      {
3748         if (!e_comp->layers[x].clients) continue;
3749         EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
3750           {
3751              if (ec == ec2)
3752                {
3753                   ELOGF("FATAL", "EC exist below layer. ec layer_map:%d, cur layer_map:%d",
3754                         ec, e_comp_canvas_layer_map(ec_layer), x);
3755                   continue;
3756                }
3757              if (!e_object_is_del(E_OBJECT(ec2)))
3758                {
3759                   g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3760                   return ec2;
3761                }
3762           }
3763      }
3764    g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3765
3766    return NULL;
3767 }
3768
3769 EINTERN E_Client *
3770 e_client_visible_above_get(E_Client *ec)
3771 {
3772    unsigned int x;
3773    E_Client *ec2;
3774
3775    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
3776    if (EINA_INLIST_GET(ec)->next) //check current layer
3777      {
3778         EINA_INLIST_FOREACH(EINA_INLIST_GET(ec)->next, ec2)
3779           {
3780              if (ec == ec2) continue;
3781              if ((!e_object_is_del(E_OBJECT(ec2))) &&
3782                  (!e_client_util_ignored_get(ec2)) &&
3783                  (ec2->visible) &&
3784                  (ec2->frame))
3785                return ec2;
3786           }
3787      }
3788
3789    if (ec->layer == E_LAYER_CLIENT_CURSOR) return NULL;
3790    if (e_comp_canvas_client_layer_map(ec->layer) == 9999) return NULL;
3791
3792    /* go up the layers until we find one */
3793    for (x = e_comp_canvas_layer_map(ec->layer) + 1; x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x++)
3794      {
3795         if (!e_comp->layers[x].clients) continue;
3796         EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
3797           {
3798              if (ec == ec2) continue;
3799              if ((!e_object_is_del(E_OBJECT(ec2))) &&
3800                  (!e_client_util_ignored_get(ec2)) &&
3801                  (ec2->visible) &&
3802                  (ec2->frame))
3803                return ec2;
3804           }
3805      }
3806
3807    return NULL;
3808 }
3809
3810 EINTERN E_Client *
3811 e_client_visible_below_get(E_Client *ec)
3812 {
3813    unsigned int x;
3814    E_Client *ec2;
3815    Eina_Inlist *l;
3816    E_Layer ec_layer, ec_layer_cw;
3817    int cw_layer;
3818
3819    E_OBJECT_CHECK_RETURN(ec, NULL);
3820    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, NULL);
3821
3822    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
3823    if (EINA_INLIST_GET(ec)->prev) //check current layer
3824      {
3825         for (l = EINA_INLIST_GET(ec)->prev; l; l = l->prev)
3826           {
3827              ec2 = EINA_INLIST_CONTAINER_GET(l, E_Client);
3828              if (ec == ec2) continue;
3829              if ((!e_object_is_del(E_OBJECT(ec2))) &&
3830                  (!e_client_util_ignored_get(ec2)) &&
3831                  (ec2->visible) &&
3832                  (ec2->frame))
3833                return ec2;
3834           }
3835      }
3836
3837    // check layer validation
3838    ec_layer = ec->layer;
3839    if (ec->layer_block || ec->layer_pending)
3840      {
3841         cw_layer = e_comp_object_layer_get(ec->frame);
3842         if (cw_layer >= 0)
3843           {
3844              ec_layer_cw = e_comp_canvas_layer_map_to(cw_layer);
3845              if (ec_layer != ec_layer_cw)
3846                {
3847                   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);
3848                   ec_layer = ec_layer_cw;
3849                }
3850           }
3851      }
3852
3853    /* go down the layers until we find one */
3854    if (e_comp_canvas_layer_map(ec->layer) > e_comp_canvas_layer_map(E_LAYER_MAX)) return NULL;
3855    x = e_comp_canvas_layer_map(ec->layer);
3856    if (x > 0) x--;
3857
3858    for (; x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
3859      {
3860         if (!e_comp->layers[x].clients) continue;
3861         EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
3862           {
3863              if (ec == ec2) continue;
3864              if ((!e_object_is_del(E_OBJECT(ec2))) &&
3865                  (!e_client_util_ignored_get(ec2)) &&
3866                  (ec2->visible) &&
3867                  (ec2->frame))
3868                return ec2;
3869           }
3870      }
3871
3872    return NULL;
3873 }
3874
3875 E_API E_Client *
3876 e_client_bottom_get(void)
3877 {
3878    unsigned int x;
3879    g_rec_mutex_lock(&e_comp->ec_list_mutex);
3880    for (x = e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x++)
3881      {
3882         E_Client *ec2;
3883
3884         if (!e_comp->layers[x].clients) continue;
3885         EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
3886           if (!e_object_is_del(E_OBJECT(ec2)))
3887             {
3888                g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3889                return ec2;
3890             }
3891      }
3892    g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3893
3894    return NULL;
3895 }
3896
3897 E_API E_Client *
3898 e_client_top_get(void)
3899 {
3900    unsigned int x;
3901    g_rec_mutex_lock(&e_comp->ec_list_mutex);
3902    for (x = e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
3903      {
3904         E_Client *ec2;
3905
3906         if (!e_comp->layers[x].clients) continue;
3907         EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
3908           if (!e_object_is_del(E_OBJECT(ec2)))
3909             {
3910                g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3911                return ec2;
3912             }
3913      }
3914    g_rec_mutex_unlock(&e_comp->ec_list_mutex);
3915
3916    return NULL;
3917 }
3918
3919 EINTERN unsigned int
3920 e_clients_count(void)
3921 {
3922    return eina_list_count(e_comp->clients);
3923 }
3924
3925
3926 /**
3927  * Set a callback which will be called just prior to updating the
3928  * move coordinates for a border
3929  */
3930 EINTERN void
3931 e_client_move_intercept_cb_set(E_Client *ec, E_Client_Move_Intercept_Cb cb)
3932 {
3933    ec->move_intercept_cb = cb;
3934 }
3935
3936 ///////////////////////////////////////
3937
3938 E_API E_Client_Hook *
3939 e_client_hook_add(E_Client_Hook_Point hookpoint, E_Client_Hook_Cb func, const void *data)
3940 {
3941    E_Client_Hook *ch;
3942
3943    EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_CLIENT_HOOK_LAST, NULL);
3944    ch = E_NEW(E_Client_Hook, 1);
3945    if (!ch) return NULL;
3946    ch->hookpoint = hookpoint;
3947    ch->func = func;
3948    ch->data = (void*)data;
3949    _e_client_hooks[hookpoint] = eina_inlist_append(_e_client_hooks[hookpoint], EINA_INLIST_GET(ch));
3950    return ch;
3951 }
3952
3953 E_API void
3954 e_client_hook_del(E_Client_Hook *ch)
3955 {
3956    ch->delete_me = 1;
3957    if (_e_client_hooks_walking == 0)
3958      {
3959         _e_client_hooks[ch->hookpoint] = eina_inlist_remove(_e_client_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
3960         free(ch);
3961      }
3962    else
3963      _e_client_hooks_delete++;
3964 }
3965
3966 ///////////////////////////////////////
3967
3968 E_API E_Client_Intercept_Hook *
3969 e_client_intercept_hook_add(E_Client_Intercept_Hook_Point hookpoint, E_Client_Intercept_Hook_Cb func, const void *data)
3970 {
3971    E_Client_Intercept_Hook *ch;
3972
3973    EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_CLIENT_INTERCEPT_HOOK_LAST, NULL);
3974    ch = E_NEW(E_Client_Intercept_Hook, 1);
3975    if (!ch) return NULL;
3976    ch->hookpoint = hookpoint;
3977    ch->func = func;
3978    ch->data = (void*)data;
3979    _e_client_intercept_hooks[hookpoint] = eina_inlist_append(_e_client_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
3980    return ch;
3981 }
3982
3983 E_API void
3984 e_client_intercept_hook_del(E_Client_Intercept_Hook *ch)
3985 {
3986    if (!ch) return;
3987
3988    ch->delete_me = 1;
3989    if (_e_client_intercept_hooks_walking == 0)
3990      {
3991         _e_client_intercept_hooks[ch->hookpoint] =
3992            eina_inlist_remove(_e_client_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
3993         free(ch);
3994      }
3995    else
3996      _e_client_intercept_hooks_delete++;
3997 }
3998
3999 E_API void
4000 e_client_focus_latest_set(E_Client *ec)
4001 {
4002    EINA_SAFETY_ON_NULL_RETURN(ec);
4003
4004    wl_signal_emit_mutable(&PRI(ec)->events.focus_latest_set, NULL);
4005 }
4006
4007 E_API void
4008 e_client_focus_defer_set(E_Client *ec)
4009 {
4010    EINA_SAFETY_ON_NULL_RETURN(ec);
4011
4012    wl_signal_emit_mutable(&PRI(ec)->events.focus_defer_set, NULL);
4013 }
4014
4015 EINTERN void
4016 e_client_focused_set(E_Client *ec)
4017 {
4018    E_Client *focused_ec;
4019    E_Zone *zone;
4020
4021    if (ec)
4022      ELOGF("FOCUS", "CLIENT FOCUSED_SET : SET", ec);
4023    else
4024      ELOGF("FOCUS", "CLIENT FOCUSED_SET : UNSET", NULL);
4025
4026   focused_ec = e_comp_focused_ec_get();
4027   if (ec == focused_ec) return;
4028
4029    TRACE_DS_BEGIN(CLIENT:FOCUSED SET);
4030
4031    // unset the current focused_ec if focused_ec is not being deleted
4032    if (focused_ec)
4033      {
4034        if (!e_object_is_del(E_OBJECT(focused_ec)))
4035          {
4036             // FIXME: Remove focus_unset event of client.
4037             //        Instead, make zone focus_unset event and use it.
4038             wl_signal_emit_mutable(&PRI(focused_ec)->events.focus_unset, NULL);
4039             _e_client_hook_call(E_CLIENT_HOOK_FOCUS_UNSET, focused_ec);
4040
4041             if (e_object_ref_get(E_OBJECT(focused_ec)) > 0)
4042               {
4043                  _e_client_event_simple(focused_ec, E_EVENT_CLIENT_FOCUS_OUT);
4044               }
4045          }
4046      }
4047
4048    // clear the current focused_ec when ec is NULL
4049    if (!ec)
4050      {
4051         zone = e_comp_zone_find_by_ec(focused_ec);
4052         e_zone_focus_clear(zone);
4053         TRACE_DS_END();
4054         return;
4055      }
4056
4057    // FIXME: Remove focus_set event of client.
4058    //        Instead, make zone focus_set event and use it.
4059    // set the new current focused_ec
4060    wl_signal_emit_mutable(&PRI(ec)->events.focus_set, NULL);
4061    _e_client_hook_call(E_CLIENT_HOOK_FOCUS_SET, ec);
4062
4063    // send the client_focuse_in event
4064    _e_client_event_simple(ec, E_EVENT_CLIENT_FOCUS_IN);
4065
4066    TRACE_DS_END();
4067 }
4068
4069 EINTERN void
4070 e_client_activate(E_Client *ec)
4071 {
4072    E_OBJECT_CHECK(ec);
4073    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4074
4075    TRACE_DS_BEGIN(CLIENT:ACTIVATE);
4076
4077    ELOGF("COMP", "Set launching flag..", ec);
4078    ec->launching = EINA_TRUE;
4079
4080    ec->exp_iconify.not_raise = 0;
4081
4082    if (ec->iconic)
4083      {
4084          if (!ec->lock_user_iconify)
4085            e_client_uniconify(ec);
4086      }
4087    ELOGF("COMP", "Un-Set ICONIFY BY CLIENT", ec);
4088    ec->exp_iconify.by_client = 0;
4089    e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
4090
4091    wl_signal_emit_mutable(&PRI(ec)->events.activate_done, NULL);
4092    _e_client_hook_call(E_CLIENT_HOOK_ACTIVATE_DONE, ec);
4093
4094    TRACE_DS_END();
4095 }
4096
4097 E_API E_Client *
4098 e_client_focused_get(void)
4099 {
4100    return e_comp_focused_ec_get();
4101 }
4102
4103 EINTERN Eina_List *
4104 e_client_lost_windows_get(E_Zone *zone)
4105 {
4106    Eina_List *list = NULL;
4107    const Eina_List *l;
4108    E_Client *ec;
4109    int loss_overlap = 5;
4110
4111    E_OBJECT_CHECK_RETURN(zone, NULL);
4112    E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, NULL);
4113    EINA_LIST_FOREACH(e_comp->clients, l, ec)
4114      {
4115         if (!e_zone_has_ec(zone, ec)) continue;
4116         if (e_client_util_ignored_get(ec)) continue;
4117
4118         if (!E_INTERSECTS(zone->x + loss_overlap,
4119                           zone->y + loss_overlap,
4120                           zone->w - (2 * loss_overlap),
4121                           zone->h - (2 * loss_overlap),
4122                           ec->x, ec->y, ec->w, ec->h))
4123           {
4124              list = eina_list_append(list, ec);
4125           }
4126      }
4127    return list;
4128 }
4129
4130 ///////////////////////////////////////
4131
4132 EINTERN void
4133 e_client_maximized_geometry_set(E_Client *ec, int x, int y, int w, int h)
4134 {
4135    if (!ec) return;
4136
4137    ec->maximized_info.x = x;
4138    ec->maximized_info.y = y;
4139    ec->maximized_info.w = w;
4140    ec->maximized_info.h = h;
4141
4142    e_client_frame_geometry_set(ec, x, y, w, h);
4143 }
4144
4145 EINTERN void
4146 e_client_maximized_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
4147 {
4148    if (!ec) return;
4149
4150    if (x) *x = ec->maximized_info.x;
4151    if (y) *y = ec->maximized_info.y;
4152    if (w) *w = ec->maximized_info.w;
4153    if (h) *h = ec->maximized_info.h;
4154 }
4155
4156 EINTERN void
4157 e_client_maximize_update(E_Client *ec)
4158 {
4159    E_Maximize max;
4160
4161    E_OBJECT_CHECK(ec);
4162    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4163
4164    if (ec->maximized)
4165      {
4166         max = ec->maximized;
4167         ec->maximized = 0;
4168         e_client_maximize(ec, max);
4169      }
4170 }
4171
4172 E_API void
4173 e_client_maximize(E_Client *ec, E_Maximize max)
4174 {
4175    E_OBJECT_CHECK(ec);
4176    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4177
4178    if (!(max & E_MAXIMIZE_DIRECTION)) max |= E_MAXIMIZE_BOTH;
4179
4180    if ((ec->maximized & E_MAXIMIZE_DIRECTION) == (max & E_MAXIMIZE_DIRECTION))
4181      {
4182         if ((ec->maximized & E_MAXIMIZE_TYPE) == (max & E_MAXIMIZE_TYPE))
4183           return;
4184      }
4185
4186    if (ec->new_client)
4187      {
4188         ec->changes.need_maximize = 1;
4189         ec->maximized &= ~E_MAXIMIZE_TYPE;
4190         ec->maximized |= max;
4191         EC_CHANGED(ec);
4192         return;
4193      }
4194
4195    if (!ec->fullscreen)
4196      {
4197         // call the maximize hook of a client
4198         wl_signal_emit_mutable(&PRI(ec)->events.maximize, &max);
4199
4200         // store the E_Maximize value
4201         ec->maximized = max;
4202         ec->changes.need_unmaximize = 0;
4203
4204         evas_object_smart_callback_call(ec->frame, "maximize_done", NULL);
4205      }
4206    else
4207      {
4208         // store the E_Maximize value
4209         ec->maximized = max;
4210         ec->changes.need_unmaximize = 0;
4211      }
4212 }
4213
4214 E_API void
4215 e_client_unmaximize(E_Client *ec, E_Maximize max)
4216 {
4217    E_OBJECT_CHECK(ec);
4218    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4219
4220    if (!(max & E_MAXIMIZE_DIRECTION))
4221      {
4222         CRI("BUG: Unmaximize call without direction!");
4223         return;
4224      }
4225    if (ec->new_client)
4226      {
4227         ec->changes.need_unmaximize = 1;
4228         EC_CHANGED(ec);
4229         return;
4230      }
4231
4232    /* Remove directions not used */
4233    max &= (ec->maximized & E_MAXIMIZE_DIRECTION);
4234    /* Can only remove existing maximization directions */
4235    if (!max) return;
4236
4237    if (!ec->fullscreen)
4238      {
4239         evas_object_smart_callback_call(ec->frame, "unmaximize_pre", NULL);
4240
4241         // call the unmaximize hook of a client
4242         wl_signal_emit_mutable(&PRI(ec)->events.unmaximize, &max);
4243
4244         evas_object_smart_callback_call(ec->frame, "unmaximize_done", NULL);
4245      }
4246
4247    ec->maximized = E_MAXIMIZE_NONE;
4248    ec->changes.need_unmaximize = 0;
4249 }
4250
4251 EINTERN void
4252 e_client_fullscreen(E_Client *ec, E_Fullscreen policy)
4253 {
4254    E_OBJECT_CHECK(ec);
4255    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4256
4257    if (ec->fullscreen) return;
4258
4259    // call the fullscreen_pre hook of a client
4260    wl_signal_emit_mutable(&PRI(ec)->events.fullscreen_pre, NULL);
4261    _e_client_hook_call(E_CLIENT_HOOK_FULLSCREEN_PRE, ec);
4262
4263    if (ec->skip_fullscreen) return;
4264    if (ec->new_client)
4265      {
4266         ec->need_fullscreen = 1;
4267         return;
4268      }
4269
4270    ec->saved.layer = ec->layer;
4271    e_client_layer_set(ec, ec->fullscreen_layer);
4272
4273    ec->fullscreen = 1;
4274
4275    // call the fullscreen hook of a client
4276    wl_signal_emit_mutable(&PRI(ec)->events.fullscreen, &policy);
4277
4278    ec->fullscreen_policy = policy;
4279
4280    _e_client_event_simple(ec, E_EVENT_CLIENT_FULLSCREEN);
4281 }
4282
4283 EINTERN void
4284 e_client_unfullscreen(E_Client *ec)
4285 {
4286    E_OBJECT_CHECK(ec);
4287    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4288
4289    ec->need_fullscreen = 0;
4290
4291    if (!ec->fullscreen) return;
4292
4293    ec->fullscreen = 0;
4294
4295    E_Fullscreen policy = ec->fullscreen_policy;
4296
4297    // call the unfullscreen hook of a client
4298    wl_signal_emit_mutable(&PRI(ec)->events.unfullscreen, &policy);
4299
4300    e_client_layer_set(ec, ec->saved.layer);
4301
4302    ec->fullscreen_policy = E_FULLSCREEN_RESIZE;
4303
4304    _e_client_event_simple(ec, E_EVENT_CLIENT_UNFULLSCREEN);
4305 }
4306
4307 ///////////////////////////////////////
4308 EINTERN Eina_Bool
4309 e_client_is_parent_iconify_by_client(E_Client *ec)
4310 {
4311    E_Client *parent = ec->parent;
4312    if (!parent) return EINA_FALSE;
4313
4314    if ((parent->exp_iconify.type == E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT) ||
4315        (parent->exp_iconify.type == E_ICONIFIED_TYPE_PARENT_ICONIFY_BY_CLIENT))
4316      return EINA_TRUE;
4317
4318    return EINA_FALSE;
4319 }
4320
4321 E_API void
4322 e_client_iconify(E_Client *ec)
4323 {
4324    E_OBJECT_CHECK(ec);
4325    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4326
4327    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
4328    Eina_Bool iconified_by_client = e_client_is_iconified_by_client(ec);
4329
4330    ELOGF("TZVIS", "ICONIFY  |iconic:%d  |argb:%d       |not_raise:%d   |by_client:%d, type:%d",
4331          ec, ec->iconic, ec->argb, (unsigned int)ec->exp_iconify.not_raise,
4332          ec->exp_iconify.by_client, ec->exp_iconify.type);
4333
4334    if (ec->iconic) return;
4335    if (ec->exp_iconify.skip_iconify && !iconified_by_client) return;
4336    if (ec->exp_iconify.skip_by_remote) return;
4337    if (!cdata || !cdata->mapped)
4338      {
4339         if (!iconified_by_client)
4340           {
4341              ELOGF("TZVIS", "Not mapped.. So, don't iconify", ec);
4342              return;
4343           }
4344         else
4345           {
4346              ELOGF("TZVIS", "Not mapped.. But, iconify by user request", ec);
4347           }
4348      }
4349
4350    TRACE_DS_BEGIN(CLIENT:ICONIFY);
4351
4352    wl_signal_emit_mutable(&PRI(ec)->events.iconify, NULL);
4353    _e_client_hook_call(E_CLIENT_HOOK_ICONIFY, ec);
4354
4355    TRACE_DS_END();
4356 }
4357
4358 E_API void
4359 e_client_uniconify(E_Client *ec)
4360 {
4361    E_Comp_Wl_Client_Data *cdata;
4362
4363    E_OBJECT_CHECK(ec);
4364    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4365
4366    cdata = e_client_cdata_get(ec);
4367
4368    ELOGF("TZVIS", "UNICONIFY|iconic:%d  |argb:%d       |not_raise:%d  |by_client:%d, type:%d |mapped:%d",
4369          ec, ec->iconic, ec->argb, (unsigned int)ec->exp_iconify.not_raise,
4370          ec->exp_iconify.by_client, ec->exp_iconify.type,
4371          cdata ? cdata->mapped : 0);
4372
4373    if (!ec->iconic) return;
4374
4375    TRACE_DS_BEGIN(CLIENT:UNICONIFY);
4376
4377     // call the uniconify hook of a client
4378    wl_signal_emit_mutable(&PRI(ec)->events.uniconify, NULL);
4379    _e_client_hook_call(E_CLIENT_HOOK_UNICONIFY, ec);
4380
4381    TRACE_DS_END();
4382 }
4383
4384 E_API void
4385 e_client_iconified_type_set(E_Client *ec, E_Iconified_Type type)
4386 {
4387    if (!ec) return;
4388    ec->exp_iconify.type = type;
4389 }
4390
4391 EINTERN E_Iconified_Type
4392 e_client_iconified_type_get(E_Client *ec)
4393 {
4394    if (!ec) return E_ICONIFIED_TYPE_NONE;
4395    return ec->exp_iconify.type;
4396 }
4397
4398 E_API Eina_Bool e_client_is_iconified_by_client(E_Client *ec)
4399 {
4400    if (!ec) return EINA_FALSE;
4401
4402    if (ec->exp_iconify.type == E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT)
4403      return EINA_TRUE;
4404
4405    if (ec->exp_iconify.type == E_ICONIFIED_TYPE_DESK_ICONIFY_BY_CLIENT)
4406      return EINA_TRUE;
4407
4408    if (ec->exp_iconify.type == E_ICONIFIED_TYPE_PARENT_ICONIFY_BY_CLIENT)
4409      return EINA_TRUE;
4410
4411    if (ec->exp_iconify.by_client)
4412      {
4413         ELOGF("POL", "CHECK. mismatch value. by_client:%d, type:%d", ec, ec->exp_iconify.by_client, ec->exp_iconify.type);
4414         return EINA_TRUE;
4415      }
4416
4417    return EINA_FALSE;
4418 }
4419
4420 ///////////////////////////////////////
4421
4422 EINTERN void e_client_hide_by_request_set(E_Client *ec, Eina_Bool set)
4423 {
4424    API_ENTRY;
4425    priv->hide_by_request = set;
4426 }
4427
4428 EINTERN Eina_Bool e_client_hide_by_request_get(E_Client *ec)
4429 {
4430    API_ENTRY_VAL(EINA_FALSE);
4431    return priv->hide_by_request;
4432 }
4433
4434 ///////////////////////////////////////
4435
4436 EINTERN void
4437 e_client_stick(E_Client *ec)
4438 {
4439    E_OBJECT_CHECK(ec);
4440    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4441    if (ec->sticky) return;
4442
4443    // call the stick hook of a client
4444    wl_signal_emit_mutable(&PRI(ec)->events.stick, NULL);
4445
4446    // send the sticky property event of a client
4447    _e_client_event_property(ec, E_CLIENT_PROPERTY_STICKY);
4448 }
4449
4450 EINTERN void
4451 e_client_unstick(E_Client *ec)
4452 {
4453    E_OBJECT_CHECK(ec);
4454    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4455
4456    if (!ec->sticky) return;
4457
4458    // call the unstick hook of a client
4459    wl_signal_emit_mutable(&PRI(ec)->events.unstick, NULL);
4460
4461   // send the sticky property event of a client
4462    _e_client_event_property(ec, E_CLIENT_PROPERTY_STICKY);
4463 }
4464
4465 EINTERN void
4466 e_client_pinned_set(E_Client *ec, Eina_Bool set)
4467 {
4468    E_Layer layer;
4469
4470    EINA_SAFETY_ON_NULL_RETURN(ec);
4471    if (set)
4472      layer = E_LAYER_CLIENT_ABOVE;
4473    else
4474      layer = E_LAYER_CLIENT_NORMAL;
4475
4476    e_client_layer_set(ec, layer);
4477
4478    EC_CHANGED(ec);
4479 }
4480
4481 ///////////////////////////////////////
4482
4483 EINTERN Eina_Bool
4484 e_client_border_set(E_Client *ec, const char *name)
4485 {
4486    Eina_Stringshare *pborder;
4487
4488    E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
4489    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
4490    if (!e_comp_object_frame_allowed(ec->frame)) return EINA_FALSE;
4491    if (ec->border.changed)
4492      CRI("CALLING WHEN border.changed SET!");
4493
4494    if (!e_util_strcmp(ec->border.name, name)) return EINA_TRUE;
4495    pborder = ec->border.name;
4496    ec->border.name = eina_stringshare_add(name);
4497    if (e_comp_object_frame_theme_set(ec->frame, name))
4498      {
4499         eina_stringshare_del(pborder);
4500         return EINA_TRUE;
4501      }
4502    eina_stringshare_del(ec->border.name);
4503    ec->border.name = pborder;
4504    return EINA_FALSE;
4505 }
4506
4507 ///////////////////////////////////////
4508
4509 EINTERN void
4510 e_client_comp_hidden_set(E_Client *ec, Eina_Bool hidden)
4511 {
4512    E_OBJECT_CHECK(ec);
4513    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4514
4515    hidden = !!hidden;
4516    if (ec->comp_hidden == hidden) return;
4517    ec->comp_hidden = hidden;
4518    evas_object_smart_callback_call(ec->frame, "comp_hidden", NULL);
4519 }
4520
4521 ///////////////////////////////////////
4522
4523 EINTERN void
4524 e_client_act_move_keyboard(E_Client *ec)
4525 {
4526    EINA_SAFETY_ON_NULL_RETURN(ec);
4527
4528    if (!_e_client_move_begin(ec))
4529      return;
4530
4531    _e_client_action_init(ec);
4532    _e_client_action_move_timeout_add();
4533
4534    wl_signal_emit_mutable(&PRI(ec)->events.move_update, NULL);
4535    if (!_e_client_hook_call(E_CLIENT_HOOK_MOVE_UPDATE, ec)) return;
4536    evas_object_freeze_events_set(ec->frame, 1);
4537
4538    if (!action_handler_mouse)
4539      action_handler_mouse = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _e_client_move_mouse_down, NULL);
4540 }
4541
4542 EINTERN void
4543 e_client_act_resize_keyboard(E_Client *ec)
4544 {
4545    EINA_SAFETY_ON_NULL_RETURN(ec);
4546
4547    ec->resize_mode = E_POINTER_RESIZE_TL;
4548    ec->keyboard_resizing = 1;
4549    if (!e_client_resize_begin(ec))
4550      {
4551         ec->keyboard_resizing = 0;
4552         return;
4553      }
4554
4555    _e_client_action_init(ec);
4556    _e_client_action_resize_timeout_add();
4557    evas_object_freeze_events_set(ec->frame, 1);
4558
4559    if (!action_handler_mouse)
4560      action_handler_mouse = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _e_client_resize_mouse_down, NULL);
4561 }
4562
4563 EINTERN void
4564 e_client_act_move_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev)
4565 {
4566    E_OBJECT_CHECK(ec);
4567    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4568    if (e_client_util_resizing_get(ec) || (ec->moving)) return;
4569    if (ev)
4570      {
4571         char source[256];
4572
4573         snprintf(source, sizeof(source) - 1, "mouse,down,%i", ev->button);
4574         _e_client_moveinfo_gather(ec, source);
4575      }
4576    if (!_e_client_move_begin(ec))
4577      return;
4578
4579    _e_client_action_init(ec);
4580 }
4581
4582 E_API void
4583 e_client_act_move_end(E_Client *ec, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
4584 {
4585    E_OBJECT_CHECK(ec);
4586    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4587    if (!ec->moving) return;
4588    _e_client_move_end(ec);
4589    _e_client_action_finish();
4590 }
4591
4592 EINTERN void
4593 e_client_act_resize_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev, E_Pointer_Mode resize_mode)
4594 {
4595    E_OBJECT_CHECK(ec);
4596    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4597    if (ec->lock_user_size) return;
4598    if (e_client_util_resizing_get(ec) || (ec->moving)) return;
4599    if (ev)
4600      {
4601         char source[256];
4602         snprintf(source, sizeof(source) - 1, "mouse,down,%i", ev->button);
4603         _e_client_moveinfo_gather(ec, source);
4604
4605         if (resize_mode != E_POINTER_RESIZE_NONE)
4606           {
4607              ec->resize_mode = resize_mode;
4608           }
4609         else
4610           {
4611              /* Use canvas.x, canvas.y of event.
4612               * Transformed coordinates has to be considered for accurate resize_mode
4613               * rather than absolute coordinates. */
4614              if ((ev->canvas.x > (ec->x + ec->w / 5)) &&
4615                  (ev->canvas.x < (ec->x + ec->w * 4 / 5)))
4616                {
4617                   if (ev->canvas.y < (ec->y + ec->h / 2)) ec->resize_mode = E_POINTER_RESIZE_T;
4618                   else ec->resize_mode = E_POINTER_RESIZE_B;
4619                }
4620              else if (ev->canvas.x < (ec->x + ec->w / 2))
4621                {
4622                   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;
4623                   else if (ev->canvas.y < (ec->y + ec->h / 2)) ec->resize_mode = E_POINTER_RESIZE_TL;
4624                   else ec->resize_mode = E_POINTER_RESIZE_BL;
4625                }
4626              else
4627                {
4628                   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;
4629                   else if (ev->canvas.y < (ec->y + ec->h / 2)) ec->resize_mode = E_POINTER_RESIZE_TR;
4630                   else ec->resize_mode = E_POINTER_RESIZE_BR;
4631                }
4632           }
4633      }
4634    if (!e_client_resize_begin(ec))
4635      return;
4636    _e_client_action_init(ec);
4637 }
4638
4639 EINTERN void
4640 e_client_act_resize_end(E_Client *ec, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
4641 {
4642    E_OBJECT_CHECK(ec);
4643    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4644    if (e_client_util_resizing_get(ec))
4645      {
4646         _e_client_resize_end(ec);
4647         ec->changes.reset_gravity = 1;
4648         if (!e_object_is_del(E_OBJECT(ec)))
4649           EC_CHANGED(ec);
4650      }
4651    _e_client_action_finish();
4652 }
4653
4654 EINTERN void
4655 e_client_act_menu_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev, int key)
4656 {
4657    E_OBJECT_CHECK(ec);
4658    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4659 }
4660
4661 EINTERN void
4662 e_client_act_close_begin(E_Client *ec)
4663 {
4664    E_OBJECT_CHECK(ec);
4665    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4666    if (ec->lock_close) return;
4667    if (ec->icccm.delete_request)
4668      {
4669         ec->delete_requested = 1;
4670         evas_object_smart_callback_call(ec->frame, "delete_request", NULL);
4671      }
4672    else if (e_config->kill_if_close_not_possible)
4673      {
4674         e_client_act_kill_begin(ec);
4675      }
4676 }
4677
4678 EINTERN void
4679 e_client_act_kill_begin(E_Client *ec)
4680 {
4681    E_OBJECT_CHECK(ec);
4682    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4683    if (ec->internal) return;
4684    if (ec->lock_close) return;
4685    if ((ec->netwm.pid > 1) && (e_config->kill_process))
4686      {
4687         kill(ec->netwm.pid, SIGINT);
4688         ec->kill_timer = ecore_timer_add(e_config->kill_timer_wait,
4689                                          _e_client_cb_kill_timer, ec);
4690      }
4691    else
4692      evas_object_smart_callback_call(ec->frame, "kill_request", NULL);
4693 }
4694
4695 ////////////////////////////////////////////
4696
4697 EINTERN void
4698 e_client_ping(E_Client *ec)
4699 {
4700    E_OBJECT_CHECK(ec);
4701    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4702
4703    if (!e_config->ping_clients) return;
4704
4705    EINA_SAFETY_ON_TRUE_RETURN(e_object_is_del(E_OBJECT(ec)));
4706
4707    ec->ping_ok = 0;
4708    evas_object_smart_callback_call(ec->frame, "ping", NULL);
4709    ec->ping = ecore_loop_time_get();
4710    if (ec->ping_poller) ecore_poller_del(ec->ping_poller);
4711    ec->ping_poller = ecore_poller_add(ECORE_POLLER_CORE,
4712                                       e_config->ping_clients_interval,
4713                                       _e_client_cb_ping_poller, ec);
4714 }
4715
4716 ////////////////////////////////////////////
4717 E_API void
4718 e_client_cursor_map_apply(E_Client *ec, int rotation, int x, int y)
4719 {
4720    // TODO: remove(deprecate) this e_client_cursor_map_apply.
4721 }
4722
4723 EINTERN void
4724 e_client_move_cancel(void)
4725 {
4726    if (!ecmove) return;
4727    if (ecmove->cur_mouse_action)
4728      {
4729         E_Client *ec;
4730
4731         ec = ecmove;
4732         e_object_ref(E_OBJECT(ec));
4733         if (ec->cur_mouse_action->func.end_mouse)
4734           ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", NULL);
4735         else if (ec->cur_mouse_action->func.end)
4736           ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
4737         e_object_unref(E_OBJECT(ec->cur_mouse_action));
4738         ec->cur_mouse_action = NULL;
4739         e_object_unref(E_OBJECT(ec));
4740      }
4741    else
4742      _e_client_move_end(ecmove);
4743 }
4744
4745 EINTERN void
4746 e_client_resize_cancel(void)
4747 {
4748    if (!ecresize) return;
4749    if (ecresize->cur_mouse_action)
4750      {
4751         E_Client *ec;
4752
4753         ec = ecresize;
4754         e_object_ref(E_OBJECT(ec));
4755         if (ec->cur_mouse_action->func.end_mouse)
4756           ec->cur_mouse_action->func.end_mouse(E_OBJECT(ec), "", NULL);
4757         else if (ec->cur_mouse_action->func.end)
4758           ec->cur_mouse_action->func.end(E_OBJECT(ec), "");
4759         e_object_unref(E_OBJECT(ec->cur_mouse_action));
4760         ec->cur_mouse_action = NULL;
4761         e_object_unref(E_OBJECT(ec));
4762      }
4763    else
4764      _e_client_resize_end(ecresize);
4765 }
4766
4767 EINTERN Eina_Bool
4768 e_client_resize_begin(E_Client *ec)
4769 {
4770    if ((ec->fullscreen) || (ec->lock_user_size))
4771      goto error;
4772    if (!_e_client_action_input_win_new()) goto error;
4773    ecresize = ec;
4774    if (ec->manage_resize.enable_aspect_ratio)
4775      {
4776         ELOGF("RESIZE", "Set resize aspect ratio.. ratio(%dx%d)", ec, ec->w, ec->h);
4777         ec->manage_resize.aw = ec->w;
4778         ec->manage_resize.ah = ec->h - ec->manage_resize.header_h - ec->manage_resize.footer_h;
4779      }
4780
4781    wl_signal_emit_mutable(&PRI(ec)->events.move_begin, NULL);
4782    _e_client_hook_call(E_CLIENT_HOOK_RESIZE_BEGIN, ec);
4783    if (ec->transformed)
4784      _e_client_transform_resize_begin(ec);
4785    if (!e_client_util_resizing_get(ec))
4786      {
4787         if (ecresize == ec) ecresize = NULL;
4788         _e_client_action_input_win_del();
4789         return EINA_FALSE;
4790      }
4791    if (!ec->lock_user_stacking)
4792      {
4793         if (e_config->border_raise_on_mouse_action)
4794           e_client_raise(ec);
4795      }
4796
4797    if (e_comp->hwc)
4798      e_comp_client_override_add(ec);
4799
4800    return EINA_TRUE;
4801 error:
4802    ec->resize_mode = E_POINTER_RESIZE_NONE;
4803    return EINA_FALSE;
4804 }
4805
4806
4807 ////////////////////////////////////////////
4808
4809 EINTERN void
4810 e_client_frame_recalc(E_Client *ec)
4811 {
4812    EINA_SAFETY_ON_NULL_RETURN(ec);
4813    if (!ec->frame) return;
4814    evas_object_smart_callback_call(ec->frame, "frame_recalc", NULL);
4815 }
4816
4817 ////////////////////////////////////////////
4818
4819 EINTERN void
4820 e_client_signal_move_begin(E_Client *ec, const char *sig, const char *src EINA_UNUSED)
4821 {
4822    E_OBJECT_CHECK(ec);
4823    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4824
4825    if (e_client_util_resizing_get(ec) || (ec->moving)) return;
4826    _e_client_moveinfo_gather(ec, sig);
4827    if (!_e_client_move_begin(ec)) return;
4828 }
4829
4830 EINTERN void
4831 e_client_signal_move_end(E_Client *ec, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
4832 {
4833    E_OBJECT_CHECK(ec);
4834    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4835    if (!ec->moving) return;
4836    _e_client_move_end(ec);
4837 }
4838
4839 EINTERN void
4840 e_client_signal_resize_begin(E_Client *ec, const char *dir, const char *sig, const char *src EINA_UNUSED)
4841 {
4842    int resize_mode = E_POINTER_RESIZE_BR;
4843
4844    E_OBJECT_CHECK(ec);
4845    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4846
4847    if (e_client_util_resizing_get(ec) || (ec->moving)) return;
4848    if (!strcmp(dir, "tl"))
4849      {
4850         resize_mode = E_POINTER_RESIZE_TL;
4851      }
4852    else if (!strcmp(dir, "t"))
4853      {
4854         resize_mode = E_POINTER_RESIZE_T;
4855      }
4856    else if (!strcmp(dir, "tr"))
4857      {
4858         resize_mode = E_POINTER_RESIZE_TR;
4859      }
4860    else if (!strcmp(dir, "r"))
4861      {
4862         resize_mode = E_POINTER_RESIZE_R;
4863      }
4864    else if (!strcmp(dir, "br"))
4865      {
4866         resize_mode = E_POINTER_RESIZE_BR;
4867      }
4868    else if (!strcmp(dir, "b"))
4869      {
4870         resize_mode = E_POINTER_RESIZE_B;
4871      }
4872    else if (!strcmp(dir, "bl"))
4873      {
4874         resize_mode = E_POINTER_RESIZE_BL;
4875      }
4876    else if (!strcmp(dir, "l"))
4877      {
4878         resize_mode = E_POINTER_RESIZE_L;
4879      }
4880    ec->resize_mode = resize_mode;
4881    _e_client_moveinfo_gather(ec, sig);
4882    if (!e_client_resize_begin(ec))
4883      return;
4884 }
4885
4886 EINTERN void
4887 e_client_signal_resize_end(E_Client *ec, const char *dir EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
4888 {
4889    E_OBJECT_CHECK(ec);
4890    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4891    if (!e_client_util_resizing_get(ec)) return;
4892    _e_client_resize_handle(ec);
4893    _e_client_resize_end(ec);
4894    ec->changes.reset_gravity = 1;
4895    EC_CHANGED(ec);
4896 }
4897
4898 ////////////////////////////////////////////
4899
4900 EINTERN void
4901 e_client_resize_limit(E_Client *ec, int *w, int *h)
4902 {
4903    E_OBJECT_CHECK(ec);
4904    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
4905
4906    if (ec->frame)
4907      e_comp_object_frame_wh_unadjust(ec->frame, *w, *h, w, h);
4908    if (*h < 1) *h = 1;
4909    if (*w < 1) *w = 1;
4910
4911    if ((ec->icccm.max_w > 0) && (*w > ec->icccm.max_w)) *w = ec->icccm.max_w;
4912    else if (*w < ec->icccm.min_w)
4913      *w = ec->icccm.min_w;
4914    if ((ec->icccm.max_h > 0) && (*h > ec->icccm.max_h)) *h = ec->icccm.max_h;
4915    else if (*h < ec->icccm.min_h)
4916      *h = ec->icccm.min_h;
4917
4918    if (ec->frame)
4919      e_comp_object_frame_wh_adjust(ec->frame, *w, *h, w, h);
4920 }
4921
4922 ////////////////////////////////////////////
4923
4924
4925
4926 EINTERN E_Client *
4927 e_client_under_pointer_get(E_Desk *desk, E_Client *exclude)
4928 {
4929    int x, y;
4930
4931    /* We need to ensure that we can get the comp window for the
4932     * zone of either the given desk or the desk of the excluded
4933     * window, so return if neither is given */
4934    if (desk)
4935      e_input_device_pointer_xy_get(NULL, &x, &y);
4936    else if (exclude)
4937      e_input_device_pointer_xy_get(NULL, &x, &y);
4938    else
4939      return NULL;
4940
4941    if (!desk)
4942      {
4943         desk = exclude->desk;
4944         if (!desk)
4945           {
4946              if (exclude->zone)
4947                desk = e_desk_current_get(exclude->zone);
4948              else
4949                desk = e_desk_current_get(e_zone_current_get());
4950           }
4951      }
4952
4953    return desk ? _e_client_under_pointer_helper(desk, exclude, x, y) : NULL;
4954 }
4955
4956 E_API E_Client *e_client_under_position_get(E_Desk *desk, int x, int y, E_Client *exclude)
4957 {
4958    if (!desk) return NULL;
4959
4960    return _e_client_under_pointer_helper(desk, exclude, x, y);
4961 }
4962
4963 E_API E_Client *e_client_under_position_input_get(E_Desk *desk, int x, int y)
4964 {
4965    if (!desk) return NULL;
4966
4967    return _e_client_under_pointer_input_helper(desk, x, y);
4968 }
4969
4970 ////////////////////////////////////////////
4971
4972 ////////////////////////////////////////////
4973
4974 E_API void
4975 e_client_redirected_set(E_Client *ec, Eina_Bool set)
4976 {
4977    EINA_SAFETY_ON_NULL_RETURN(ec);
4978    if (ec->input_only) return;
4979    set = !!set;
4980    if (ec->redirected == set) return;
4981    if (set)
4982      {
4983         e_client_frame_recalc(ec);
4984
4985         wl_signal_emit_mutable(&PRI(ec)->events.redirect, NULL);
4986         if (!_e_client_hook_call(E_CLIENT_HOOK_REDIRECT, ec)) return;
4987      }
4988    else
4989      {
4990         wl_signal_emit_mutable(&PRI(ec)->events.unredirect, NULL);
4991         if (!_e_client_hook_call(E_CLIENT_HOOK_UNREDIRECT, ec)) return;
4992      }
4993    e_comp_object_redirected_set(ec->frame, set);
4994    ec->redirected = !!set;
4995 }
4996
4997 ////////////////////////////////////////////
4998
4999 E_API void
5000 e_client_transform_update(E_Client *ec)
5001 {
5002    if (e_client_util_resizing_get(ec))
5003      _e_client_transform_resize(ec);
5004 }
5005
5006 ////////////////////////////////////////////
5007
5008 EINTERN void
5009 e_client_transform_apply(E_Client *ec, double angle, double zoom, int cx, int cy)
5010 {
5011    E_Map *map;
5012    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
5013    E_Client *subc;
5014    Eina_List *l;
5015
5016    if (e_comp_wl_subsurface_check(ec))
5017      return;
5018
5019    /* check if it's different with current state */
5020    if ((ec->transform.angle == angle) &&
5021        (ec->transform.zoom == zoom) &&
5022        (ec->transform.center.x == cx) &&
5023        (ec->transform.center.y == cy))
5024      return;
5025
5026    /* use previous value if any required value is invalid */
5027    if (angle == -1.0)
5028      angle = ec->transform.angle;
5029    if (zoom == -1.0)
5030      zoom = ec->transform.zoom;
5031    if (!E_INSIDE(cx, cy,
5032                  ec->client.x, ec->client.y,
5033                  ec->client.w, ec->client.h))
5034      {
5035         cx = ec->transform.center.x;
5036         cy = ec->transform.center.y;
5037      }
5038
5039    if ((angle == 0) && (zoom == 1.0))
5040      {
5041         e_client_transform_clear(ec);
5042         return;
5043      }
5044
5045    map = e_map_new_with_direct_render(ec->transform_core.direct_render);
5046    e_map_util_points_populate_from_object_full(map, ec->frame, 0);
5047
5048    e_map_util_rotate(map, angle, cx, cy);
5049    _e_client_transform_geometry_save(ec, map);
5050
5051    e_map_util_zoom(map, zoom, zoom, cx, cy);
5052
5053    e_map_util_object_move_sync_set(map, EINA_TRUE);
5054    e_client_map_set(ec, map);
5055    e_client_map_enable_set(ec, EINA_TRUE);
5056
5057    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
5058      _e_client_transform_sub_apply(subc, ec, zoom);
5059    EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
5060      _e_client_transform_sub_apply(subc, ec, zoom);
5061
5062    e_map_free(map);
5063
5064    ec->transform.zoom = zoom;
5065    ec->transform.angle = angle;
5066    ec->transform.center.x = cx;
5067    ec->transform.center.y = cy;
5068    ec->transformed = EINA_TRUE;
5069 }
5070
5071 ////////////////////////////////////////////
5072
5073 EINTERN void
5074 e_client_transform_clear(E_Client *ec)
5075 {
5076    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
5077    E_Client *subc;
5078    Eina_List *l;
5079
5080    e_client_map_enable_set(ec, EINA_FALSE);
5081    e_client_map_set(ec, NULL);
5082
5083    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
5084      _e_client_transform_sub_apply(subc, ec, 1.0);
5085    EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
5086      _e_client_transform_sub_apply(subc, ec, 1.0);
5087
5088    ec->transform.zoom = 1.0;
5089    ec->transform.angle = 0.0;
5090    ec->transformed = EINA_FALSE;
5091 }
5092
5093 E_API Eina_Bool
5094 e_client_transform_core_enable_get(E_Client *ec)
5095 {
5096    if (!ec) return EINA_FALSE;
5097    return ec->transform_core.result.enable;
5098 }
5099
5100 E_API void
5101 e_client_transform_core_add(E_Client *ec, E_Util_Transform *transform)
5102 {
5103    if (!ec) return;
5104    if (!transform) return;
5105
5106    // duplication check
5107    if (ec->transform_core.transform_list &&
5108        eina_list_data_find(ec->transform_core.transform_list, transform) == transform)
5109      {
5110         return;
5111      }
5112
5113    ec->transform_core.transform_list = eina_list_append(ec->transform_core.transform_list, transform);
5114    ec->transform_core.changed = EINA_TRUE;
5115    e_util_transform_ref(transform);
5116   // e_client_transform_core_update(ec);
5117 }
5118
5119 E_API void
5120 e_client_transform_core_remove(E_Client *ec, E_Util_Transform *transform)
5121 {
5122    if (!ec) return;
5123    if (!transform) return;
5124
5125    if (ec->transform_core.transform_list &&
5126        eina_list_data_find(ec->transform_core.transform_list, transform) == transform)
5127      {
5128         ec->transform_core.transform_list = eina_list_remove(ec->transform_core.transform_list, transform);
5129         e_util_transform_unref(transform);
5130         ec->transform_core.changed = EINA_TRUE;
5131      }
5132
5133    e_client_transform_core_update(ec);
5134 }
5135
5136 E_API void
5137 e_client_transform_core_update(E_Client *ec)
5138 {
5139    if (!ec) return;
5140    if (ec->new_client) return;
5141    if (!_e_client_transform_core_check_change(ec)) return;
5142
5143    if (ec->transform_core.transform_list || ec->transform_core.parent.enable)
5144      {
5145         E_Util_Transform_Rect source_rect;
5146         E_Util_Transform_Matrix matrix, boundary_matrix;
5147         E_Util_Transform_Zoom zoom;
5148         Eina_List *l;
5149         Eina_Bool background;
5150         E_Util_Transform *temp_trans;
5151
5152         // 1. init state
5153         ec->transform_core.result.enable = EINA_TRUE;
5154         e_util_transform_rect_client_rect_get(&source_rect, ec);
5155         e_util_transform_init(&ec->transform_core.result.transform);
5156
5157         // 2. merge transform
5158         EINA_LIST_FOREACH(ec->transform_core.transform_list, l, temp_trans)
5159           {
5160              e_util_transform_merge(&ec->transform_core.result.transform, temp_trans);
5161           }
5162         zoom = ec->transform_core.result.transform.zoom;
5163
5164         // 2.5 check viewport
5165         if (e_util_transform_viewport_flag_get(&ec->transform_core.result.transform))
5166           {
5167              int vx = 0, vy = 0, vw = 0, vh = 0;
5168              e_util_transform_viewport_get(&ec->transform_core.result.transform, &vx, &vy, &vw, &vh);
5169              e_util_transform_rect_init(&source_rect, vx, vy, vw, vh);
5170           }
5171
5172         // 3. apply background transform
5173         matrix = e_util_transform_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
5174
5175         if (e_util_transform_bg_transform_flag_get(&ec->transform_core.result.transform))
5176           {
5177              boundary_matrix = e_util_transform_bg_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
5178              background = EINA_TRUE;
5179           }
5180         else
5181           {
5182              background = EINA_FALSE;
5183              boundary_matrix = matrix;
5184           }
5185
5186         if (background != ec->transform_core.background)
5187           {
5188              if (background)
5189                {
5190                   e_comp_object_transform_bg_set(ec->frame, EINA_TRUE);
5191                }
5192              else
5193                {
5194                   e_comp_object_transform_bg_set(ec->frame, EINA_FALSE);
5195                }
5196
5197              ec->transform_core.background = background;
5198           }
5199
5200         // 3.1 if 24bit window then set transp rect
5201         if (!ec->argb)
5202           {
5203              int angle = 0;
5204
5205              e_util_transform_rotation_round_get(&ec->transform_core.result.transform, 0, 0, &angle);
5206              angle %= 90;
5207
5208              if (angle == 0) // when transform angle is 0, 90, 180, 270, 360. then set transp rect
5209                e_comp_object_transform_transp_set(ec->frame, EINA_TRUE);
5210              else
5211                e_comp_object_transform_transp_set(ec->frame, EINA_FALSE);
5212           }
5213         else
5214           e_comp_object_transform_transp_set(ec->frame, EINA_FALSE);
5215
5216         // 3.5 parent matrix multiply
5217         if (ec->transform_core.parent.enable)
5218           {
5219              matrix = e_util_transform_matrix_multiply(&ec->transform_core.parent.matrix,
5220                                                        &matrix);
5221              boundary_matrix = e_util_transform_matrix_multiply(&ec->transform_core.parent.matrix,
5222                                                                 &boundary_matrix);
5223
5224              ec->transform_core.result.transform.use_zoom = EINA_TRUE;
5225              zoom.zoom_x *= ec->transform_core.parent.zoom.zoom_x;
5226              zoom.zoom_y *= ec->transform_core.parent.zoom.zoom_y;
5227              zoom.cx += ec->transform_core.parent.zoom.cx;
5228              zoom.cy += ec->transform_core.parent.zoom.cy;
5229           }
5230
5231         // 4. apply matrix to vertices
5232         ec->transform_core.result.matrix = matrix;
5233         ec->transform_core.result.inv_matrix = e_util_transform_matrix_inverse_get(&matrix);
5234         ec->transform_core.result.vertices = e_util_transform_rect_to_vertices(&source_rect);
5235         ec->transform_core.result.boundary.vertices = e_util_transform_rect_to_vertices(&source_rect);
5236         ec->transform_core.result.vertices = e_util_transform_matrix_multiply_rect_vertex(&matrix,
5237                                                                                           &ec->transform_core.result.vertices);
5238         ec->transform_core.result.boundary.vertices = e_util_transform_matrix_multiply_rect_vertex(&boundary_matrix,
5239                                                                                                    &ec->transform_core.result.boundary.vertices);
5240         ec->transform_core.result.transform.zoom = zoom;
5241
5242         // 5. apply vertices
5243         if (ec->transform_core.result.transform.use_zoom)
5244           {
5245              // TODO: apply zoom values to vertices
5246              e_comp_object_transform_transp_vertices_set_with_zoom(ec->frame, &ec->transform_core.result.vertices,
5247                                                                    ec->transform_core.result.transform.zoom);
5248              e_comp_object_transform_bg_vertices_set_with_zoom(ec->frame, &ec->transform_core.result.boundary.vertices,
5249                                                                ec->transform_core.result.transform.zoom);
5250              _e_client_transform_core_boundary_update(ec, &ec->transform_core.result.boundary.vertices);
5251              _e_client_transform_core_vertices_apply_with_zoom(ec, ec->frame, &ec->transform_core.result.vertices, &ec->transform_core.result.transform,
5252                                                                ec->transform_core.result.transform.zoom);
5253           }
5254         else
5255           {
5256              e_comp_object_transform_transp_vertices_set(ec->frame, &ec->transform_core.result.vertices);
5257              e_comp_object_transform_bg_vertices_set(ec->frame, &ec->transform_core.result.boundary.vertices);
5258              _e_client_transform_core_boundary_update(ec, &ec->transform_core.result.boundary.vertices);
5259              _e_client_transform_core_vertices_apply(ec, ec->frame, &ec->transform_core.result.vertices, &ec->transform_core.result.transform);
5260           }
5261
5262         // 6. subsurface update
5263         _e_client_transform_core_sub_update(ec, &ec->transform_core.result.vertices);
5264
5265         if (!e_object_is_del(E_OBJECT(ec)))
5266           {
5267              wl_signal_emit_mutable(&PRI(ec)->events.transform_change, NULL);
5268              _e_client_hook_call(E_CLIENT_HOOK_TRANSFORM_CHANGE, ec);
5269           }
5270      }
5271    else
5272      {
5273         if (ec->transform_core.result.enable)
5274           {
5275              ec->transform_core.result.enable = EINA_FALSE;
5276              _e_client_transform_core_vertices_apply(ec, ec->frame, NULL, NULL);
5277              e_comp_object_transform_bg_set(ec->frame, EINA_FALSE);
5278              ec->transform_core.background = EINA_FALSE;
5279              e_comp_object_transform_transp_set(ec->frame, EINA_FALSE);
5280              _e_client_transform_core_sub_update(ec, NULL);
5281
5282              if (!e_object_is_del(E_OBJECT(ec)))
5283                {
5284                   wl_signal_emit_mutable(&PRI(ec)->events.transform_change, NULL);
5285                   _e_client_hook_call(E_CLIENT_HOOK_TRANSFORM_CHANGE, ec);
5286                }
5287           }
5288      }
5289
5290    e_comp_visibility_calculation_set(EINA_TRUE);
5291 }
5292
5293 E_API int
5294 e_client_transform_core_transform_count_get(E_Client *ec)
5295 {
5296    if (!ec) return 0;
5297    if (!ec->transform_core.transform_list) return 0;
5298    return eina_list_count(ec->transform_core.transform_list);
5299 }
5300
5301 E_API E_Util_Transform*
5302 e_client_transform_core_transform_get(E_Client *ec, int index)
5303 {
5304    if (!ec) return NULL;
5305    if (!ec->transform_core.transform_list) return NULL;
5306    if (index < 0 || index >= e_client_transform_core_transform_count_get(ec))
5307       return NULL;
5308
5309    return (E_Util_Transform*)eina_list_nth(ec->transform_core.transform_list, index);
5310 }
5311
5312 E_API void
5313 e_client_transform_core_input_transform(E_Client *ec, int x, int y, int *out_x, int *out_y)
5314 {
5315    E_Util_Transform_Vertex vertex, result_vertex;
5316
5317    if (!ec) return;
5318    if (!e_client_transform_core_enable_get(ec)) return;
5319
5320    e_util_transform_vertex_init(&vertex, x, y, 0.0, 1.0);
5321
5322    result_vertex = e_util_transform_matrix_multiply_vertex(&ec->transform_core.result.inv_matrix, &vertex);
5323    e_util_transform_vertex_pos_round_get(&result_vertex, out_x, out_y, NULL, NULL);
5324 }
5325
5326 E_API void
5327 e_client_transform_core_input_inv_transform(E_Client *ec, int x, int y, int *out_x, int *out_y)
5328 {
5329    E_Util_Transform_Vertex vertex, result_vertex;
5330
5331    if (!ec) return;
5332    if (!e_client_transform_core_enable_get(ec)) return;
5333
5334    e_util_transform_vertex_init(&vertex, x, y, 0.0, 1.0);
5335
5336    result_vertex = e_util_transform_matrix_multiply_vertex(&ec->transform_core.result.matrix, &vertex);
5337    e_util_transform_vertex_pos_round_get(&result_vertex, out_x, out_y, NULL, NULL);
5338 }
5339
5340 EINTERN void
5341 e_client_transform_core_input_inv_rect_transform(E_Client *ec, int x, int y, int *out_x, int *out_y)
5342 {
5343    int gw = 0, gh = 0;
5344    if (!ec) return;
5345    if (!e_client_transform_core_enable_get(ec)) return;
5346    e_client_geometry_get(ec, NULL, NULL, &gw, &gh);
5347
5348    e_util_transform_matrix_inv_rect_coords_get(&ec->transform_core.result.transform,
5349                                                &ec->transform_core.result.vertices,
5350                                                gw, gh,
5351                                                x, y, out_x, out_y);
5352 }
5353
5354 E_API void
5355 e_client_transform_core_direct_render_set(E_Client *ec, Eina_Bool set)
5356 {
5357    EINA_SAFETY_ON_NULL_RETURN(ec);
5358
5359    if (ec->transform_core.direct_render == set) return;
5360
5361    ec->transform_core.direct_render = set;
5362    ec->transform_core.changed = EINA_TRUE;
5363
5364    e_client_transform_core_update(ec);
5365 }
5366
5367 EINTERN E_Pixmap *
5368 e_client_pixmap_change(E_Client *ec, E_Pixmap *newcp)
5369 {
5370    E_Pixmap_Type oldtype, newtype;
5371    E_Pixmap *oldcp;
5372
5373    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5374    EINA_SAFETY_ON_NULL_RETURN_VAL(ec->pixmap, NULL);
5375    EINA_SAFETY_ON_NULL_RETURN_VAL(newcp, NULL);
5376
5377    oldcp = ec->pixmap;
5378
5379    oldtype = e_pixmap_type_get(oldcp);
5380    if (oldtype >= E_PIXMAP_TYPE_MAX) return NULL;
5381
5382    newtype = e_pixmap_type_get(newcp);
5383    if (newtype >= E_PIXMAP_TYPE_MAX) return NULL;
5384
5385    if (eina_hash_find(clients_hash[oldtype], &oldcp))
5386      eina_hash_del_by_key(clients_hash[oldtype], &oldcp);
5387    e_pixmap_client_set(oldcp, NULL);
5388
5389    ec->pixmap = newcp;
5390    e_pixmap_client_set(newcp, ec);
5391
5392    eina_hash_add(clients_hash[newtype], &newcp, ec);
5393
5394    return oldcp;
5395 }
5396
5397 E_API void
5398 e_client_window_role_set(E_Client *ec, const char *role)
5399 {
5400    EINA_SAFETY_ON_NULL_RETURN(ec);
5401
5402    if (eina_stringshare_replace(&ec->icccm.window_role, role))
5403      {
5404         wl_signal_emit_mutable(&PRI(ec)->events.window_role_change, NULL);
5405         _e_client_hook_call(E_CLIENT_HOOK_WINDOW_ROLE_CHANGE, ec);
5406      }
5407 }
5408
5409 EINTERN Eina_Bool
5410 e_client_key_send(E_Client *ec, int keycode, Eina_Bool pressed, Ecore_Device *dev, unsigned int time)
5411 {
5412    Eina_Bool res;
5413
5414    res = e_comp_wl_key_send(ec, keycode, pressed, dev, time);
5415
5416    return res;
5417 }
5418
5419 EINTERN Eina_Bool
5420 e_client_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, unsigned int time)
5421 {
5422    Eina_Bool res;
5423
5424    res = e_comp_wl_key_cancel(ec, keycode, dev, time);
5425
5426    return res;
5427 }
5428
5429 EINTERN Eina_Bool
5430 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)
5431 {
5432    Eina_Bool res;
5433
5434    res = e_comp_wl_touch_send(ec, idx, x, y, pressed, dev, radius_x, radius_y, pressure, angle, time);
5435
5436    return res;
5437 }
5438
5439 EINTERN Eina_Bool
5440 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)
5441 {
5442    Eina_Bool res;
5443
5444    res = e_comp_wl_touch_update_send(ec, idx, x, y, dev, radius_x, radius_y, pressure, angle, time);
5445
5446    return res;
5447 }
5448
5449 EINTERN Eina_Bool
5450 e_client_touch_cancel_send(E_Client *ec)
5451 {
5452    Eina_Bool res;
5453
5454    res = e_comp_wl_touch_cancel_send(ec);
5455
5456    return res;
5457 }
5458
5459 EINTERN Eina_Bool
5460 e_client_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, unsigned int time)
5461 {
5462    Eina_Bool res;
5463
5464    res = e_comp_wl_mouse_button_send(ec, buttons, pressed, dev, time);
5465
5466    return res;
5467 }
5468
5469 EINTERN Eina_Bool
5470 e_client_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time)
5471 {
5472    Eina_Bool res;
5473
5474    res = e_comp_wl_mouse_move_send(ec, x, y, dev, time);
5475
5476    return res;
5477 }
5478
5479 EINTERN Eina_Bool
5480 e_client_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, unsigned int time)
5481 {
5482    Eina_Bool res;
5483
5484    res = e_comp_wl_mouse_wheel_send(ec, direction, z, dev, time);
5485
5486    return res;
5487 }
5488
5489 EINTERN Eina_Bool
5490 e_client_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time)
5491 {
5492    Eina_Bool res;
5493
5494    res = e_comp_wl_mouse_in_send(ec, x, y, dev, time);
5495
5496    return res;
5497 }
5498
5499 EINTERN Eina_Bool
5500 e_client_mouse_out_send(E_Client *ec, Ecore_Device *dev, unsigned int time)
5501 {
5502    Eina_Bool res;
5503
5504    res = e_comp_wl_mouse_out_send(ec, dev, time);
5505
5506    return res;
5507 }
5508
5509 E_API Eina_Bool
5510 e_client_video_client_has(E_Client *ec)
5511 {
5512    return e_comp_wl_video_subsurface_has(ec);
5513 }
5514
5515 E_API Eina_Bool
5516 e_client_normal_client_has(E_Client *ec)
5517 {
5518    return e_comp_wl_normal_subsurface_has(ec);
5519 }
5520
5521 E_API Eina_Bool
5522 e_client_cursor_hide(E_Client *ec)
5523 {
5524    return e_comp_wl_cursor_hide(ec);
5525 }
5526
5527 E_API void
5528 e_client_visibility_force_obscured_set(E_Client *ec, Eina_Bool set)
5529 {
5530    if (!ec) return;
5531
5532    ELOGF("TZVIS", "VIS_FORCE_OBSCURED :%d", ec, set);
5533
5534    ec->visibility.force_obscured = set;
5535    e_comp_visibility_calculation_set(EINA_TRUE);
5536 }
5537
5538 EINTERN E_Capture_Save_State
5539 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)
5540 {
5541    return e_comp_wl_capture_client_image_save(ec, dir, name, func_end, data, skip_child);
5542 }
5543
5544 static void
5545 _e_client_base_output_resolution_hook_subsurf_create(void *data, E_Client *subc)
5546 {
5547    E_Client *ec, *parent;
5548
5549    ec = data;
5550    if (ec != subc)
5551      return;
5552
5553    ec->base_output_resolution.use = 0;
5554    ec->base_output_resolution.w = 0;
5555    ec->base_output_resolution.h = 0;
5556    if (ec->base_output_resolution.transform)
5557      {
5558         e_client_transform_core_remove(ec, ec->base_output_resolution.transform);
5559         E_FREE_FUNC(ec->base_output_resolution.transform, e_util_transform_del);
5560         ELOGF("POL_APPINFO", "Cancel TRANSFORM for subsurface", ec);
5561      }
5562
5563    /* Update transform for toplevel surface.
5564     * The transform of subsurface will be updated by its parent accordingly. */
5565    parent = e_comp_wl_topmost_parent_get(ec);
5566    if (parent)
5567      {
5568         parent->transform_core.changed = EINA_TRUE;
5569         e_client_transform_core_update(parent);
5570      }
5571
5572    /* TODO: Do we need to apply it again if subsurface is destroyed? */
5573 }
5574
5575 static void
5576 _e_client_base_output_resolution_set(E_Client *ec, int width, int height)
5577 {
5578    if (!ec) return;
5579    ec->base_output_resolution.use = 1;
5580    ec->base_output_resolution.w = width;
5581    ec->base_output_resolution.h = height;
5582    ec->base_output_resolution.transform = e_util_transform_new();
5583    e_util_transform_role_set(ec->base_output_resolution.transform, "base_output_resolution");
5584    e_client_transform_core_add(ec, ec->base_output_resolution.transform);
5585
5586    if (!ec->base_output_resolution.hook_subsurf_create)
5587      {
5588         ec->base_output_resolution.hook_subsurf_create =
5589            e_comp_wl_hook_add(E_COMP_WL_HOOK_SUBSURFACE_CREATE,
5590                               _e_client_base_output_resolution_hook_subsurf_create,
5591                               ec);
5592      }
5593 }
5594
5595 E_API void
5596 e_client_base_output_resolution_transform_adjust(E_Client *ec)
5597 {
5598    E_Desk *desk;
5599
5600    EINA_SAFETY_ON_NULL_RETURN(ec);
5601    if (!ec->base_output_resolution.use) return;
5602    if (!ec->base_output_resolution.transform) return;
5603
5604    desk = e_comp_desk_find_by_ec(ec);
5605    EINA_SAFETY_ON_NULL_RETURN(desk);
5606
5607    ELOGF("POL_APPINFO", "Apply TRANSFORM... desk:(%dx%d), ec:(%dx%d)",
5608          ec, desk->geom.w, desk->geom.h, ec->w, ec->h);
5609
5610    e_util_transform_scale(ec->base_output_resolution.transform,
5611                           (double)desk->geom.w /(double)ec->base_output_resolution.w,
5612                           (double)desk->geom.h /(double)ec->base_output_resolution.h,
5613                           1.0);
5614    e_client_transform_core_update(ec);
5615 }
5616
5617 E_API Eina_Bool
5618 e_client_base_output_resolution_update(E_Client *ec)
5619 {
5620    E_Appinfo *eai = NULL;
5621    int configured_width, configured_height;
5622    int width, height;
5623    E_Desk *desk;
5624
5625    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5626
5627   if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5628   if (ec->base_output_resolution.use) return EINA_TRUE;
5629
5630   /* Check whether it's subsurface or not
5631    * The resolution of subsurface will follow the resolution of its toplevel surface.
5632    * Transform for subsurface will be applied when toplevel surface does by
5633    * implementation of e_client_transform_core.
5634    */
5635   if (e_comp_wl_subsurface_check(ec))
5636     return EINA_FALSE;
5637
5638    desk = e_comp_desk_find_by_ec(ec);
5639    EINA_SAFETY_ON_NULL_RETURN_VAL(desk, EINA_FALSE);
5640
5641   configured_width = e_config->configured_output_resolution.w;
5642   configured_height = e_config->configured_output_resolution.h;
5643
5644   if (!ec->netwm.pid)
5645     {
5646        ELOGF("POL_APPINFO", "NO PID... USE configured_output_resolution(%d,%d) pid:%d", ec,
5647              configured_width, configured_height, ec->netwm.pid);
5648        goto use_configured;
5649     }
5650
5651    eai = e_appinfo_find_with_pid(ec->netwm.pid);
5652    if (!eai)
5653      {
5654         ELOGF("POL_APPINFO", "NO APPINFO... USE configured_output_resolution(%d,%d) pid:%d", ec,
5655               configured_width, configured_height, ec->netwm.pid);
5656         goto use_configured;
5657      }
5658
5659    if (!e_appinfo_base_output_resolution_available_get(eai))
5660      {
5661         ELOGF("POL_APPINFO", "NO AVAILABLE BASE SCREEN RESOLUTION... QUERY base_output_resolution", ec);
5662         e_policy_base_output_resolution_info_update(ec->netwm.pid);
5663      }
5664
5665    if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
5666      {
5667         ELOGF("POL_APPINFO", "NO BASE SCREEN RESOLUTION... USE configured_output_resolution(%d,%d) pid:%d", ec,
5668               configured_width, configured_height, ec->netwm.pid);
5669         goto use_configured;
5670       }
5671
5672    if ((width == 0) && (height == 0))
5673      {
5674         ELOGF("POL_APPINFO", "SKIP SET BASE SCREEN RESOLUTION... base_output_resolution size:(%d,%d) pid:%d", ec, width, height, ec->netwm.pid);
5675         return EINA_TRUE;
5676      }
5677
5678    if ((desk->geom.w == width) && (desk->geom.h == height))
5679      {
5680         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);
5681         return EINA_TRUE;
5682      }
5683
5684    /* set the base_output_resolution of the e_client */
5685    _e_client_base_output_resolution_set(ec, width, height);
5686
5687    ELOGF("POL_APPINFO", "USE base_output_resolution(%d,%d) pid:%d", ec, width, height, ec->netwm.pid);
5688
5689    return EINA_TRUE;
5690
5691 use_configured:
5692
5693    if ((desk->geom.w == configured_width) && (desk->geom.h == configured_height))
5694      {
5695         ELOGF("POL_APPINFO", "SKIP use configured_output_resolution (same with desk size:(%d,%d), pid:%d)", ec, configured_width, configured_height, ec->netwm.pid);
5696      }
5697    else
5698      {
5699         /* set the base_output_resolution of the e_client as a default */
5700         _e_client_base_output_resolution_set(ec, configured_width, configured_height);
5701      }
5702
5703    return EINA_TRUE;
5704 }
5705
5706 E_API Eina_Bool
5707 e_client_base_output_resolution_useful_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
5708 {
5709    int zx, zy, zw, zh;
5710    E_Zone *zone;
5711
5712    E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
5713
5714    zone = e_comp_zone_find_by_ec(ec);
5715    EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
5716
5717    e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
5718
5719    if (x) *x = zx;
5720    if (y) *y = zy;
5721    if (w) *w = zw;
5722    if (h) *h = zh;
5723
5724    if (ec->base_output_resolution.use)
5725      {
5726         if (w) *w = ec->base_output_resolution.w;
5727         if (h) *h = ec->base_output_resolution.h;
5728      }
5729
5730    return EINA_TRUE;
5731 }
5732
5733 E_API Eina_Bool
5734 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)
5735 {
5736    int zx, zy, zw, zh;
5737    E_Zone *zone;
5738
5739    E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
5740
5741    zone = e_comp_zone_find_by_ec(ec);
5742    EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
5743
5744    e_zone_desk_useful_geometry_get(zone, ec->desk, &zx, &zy, &zw, &zh, consider_obstacle_area);
5745
5746    if (x) *x = zx;
5747    if (y) *y = zy;
5748    if (w) *w = zw;
5749    if (h) *h = zh;
5750
5751    if (ec->base_output_resolution.use)
5752      {
5753         // TODO: Consider obstacle area
5754         if (w) *w = ec->base_output_resolution.w;
5755         if (h) *h = ec->base_output_resolution.h;
5756      }
5757
5758    return EINA_TRUE;
5759 }
5760
5761 /* change the base_output_resolution of the bind_ec by checking the base_output_resolution of provider_ec's appinfo */
5762 EINTERN Eina_Bool
5763 e_client_base_output_resolution_rsm_update(E_Client *bind_ec, E_Client *provider_ec)
5764 {
5765    E_Appinfo *epai = NULL;
5766    int configured_width, configured_height;
5767    int width, height;
5768    E_Desk *bind_ec_desk;
5769
5770    EINA_SAFETY_ON_NULL_RETURN_VAL(bind_ec, EINA_FALSE);
5771    EINA_SAFETY_ON_NULL_RETURN_VAL(provider_ec, EINA_FALSE);
5772
5773    bind_ec_desk = e_comp_desk_find_by_ec(bind_ec);
5774    EINA_SAFETY_ON_NULL_RETURN_VAL(bind_ec_desk, EINA_FALSE);
5775
5776   if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5777
5778   configured_width = e_config->configured_output_resolution.w;
5779   configured_height = e_config->configured_output_resolution.h;
5780
5781   if (bind_ec->base_output_resolution.use)
5782     {
5783        ELOGF("POL_APPINFO", "DELETE EXISTED BINDER BASE SCREEN RESOLUTION... base_output_resolution is same with desk size:(%d,%d), bind_pid:%d", bind_ec,
5784              bind_ec->base_output_resolution.w, bind_ec->base_output_resolution.h, bind_ec->netwm.pid);
5785
5786        bind_ec->base_output_resolution.use = 0;
5787        bind_ec->base_output_resolution.w = 0;
5788        bind_ec->base_output_resolution.h = 0;
5789        e_client_transform_core_remove(bind_ec, bind_ec->base_output_resolution.transform);
5790        E_FREE_FUNC(bind_ec->base_output_resolution.transform, e_util_transform_del);
5791     }
5792
5793   if (!provider_ec->netwm.pid)
5794     {
5795        ELOGF("POL_APPINFO", "NO PROVIDER PID... USE configured_output_resolution(%d,%d) provider_pid:%d", provider_ec,
5796              configured_width, configured_height, provider_ec->netwm.pid);
5797        goto use_configured;
5798     }
5799
5800    epai = e_appinfo_find_with_pid(provider_ec->netwm.pid);
5801    if (!epai)
5802      {
5803         ELOGF("POL_APPINFO", "NO PROVIDER APPINFO... USE configured_output_resolution(%d,%d) provider_pid:%d", provider_ec,
5804               configured_width, configured_height, provider_ec->netwm.pid);
5805         goto use_configured;
5806      }
5807
5808    if (!e_appinfo_base_output_resolution_get(epai, &width, &height))
5809      {
5810         ELOGF("POL_APPINFO", "NO PROVIDER APPINFO BASE SCREEN RESOLUTION... USE configured_output_resolution(%d,%d) provider_pid:%d", provider_ec,
5811               configured_width, configured_height, provider_ec->netwm.pid);
5812         goto use_configured;
5813       }
5814
5815    if ((width == 0) && (height == 0))
5816      {
5817         ELOGF("POL_APPINFO", "NO PROVIDER WIDTH and HEIGHT... SKIP base_output_resolution due to size:(%d,%d) provider_pid:%d", provider_ec,
5818              width, height, provider_ec->netwm.pid);
5819         return EINA_TRUE;
5820      }
5821
5822    if ((bind_ec_desk->geom.w == width) && (bind_ec_desk->geom.h == height))
5823      {
5824         ELOGF("POL_APPINFO", "SKIP SET BINDER BASE SCREEN RESOLUTION... base_output_resolution is same with desk size:(%d,%d), bind_pid:%d", bind_ec,
5825             width, height, bind_ec->netwm.pid);
5826         return EINA_TRUE;
5827      }
5828
5829    /* set the base_output_resolution of the e_client */
5830    _e_client_base_output_resolution_set(bind_ec, width, height);
5831    e_client_base_output_resolution_transform_adjust(bind_ec);
5832
5833    ELOGF("POL_APPINFO", "USE BINDER base_output_resolution(%d,%d) bind_pid:%d", bind_ec, width, height, bind_ec->netwm.pid);
5834
5835    return EINA_TRUE;
5836
5837 use_configured:
5838
5839    if ((bind_ec_desk->geom.w == configured_width) && (bind_ec_desk->geom.h == configured_height))
5840      {
5841         ELOGF("POL_APPINFO", "SKIP BINDER use configured_output_resolution (same with desk size:(%d,%d), bind_pid:%d)", bind_ec,
5842              configured_width, configured_height, bind_ec->netwm.pid);
5843      }
5844    else
5845      {
5846         /* set the base_output_resolution of the e_client as a default */
5847         _e_client_base_output_resolution_set(bind_ec, configured_width, configured_height);
5848      }
5849
5850    return EINA_TRUE;
5851 }
5852
5853 /* tizen_move_resize */
5854 EINTERN Eina_Bool
5855 e_client_pending_geometry_has(E_Client *ec)
5856 {
5857    if (!eina_list_count(ec->surface_sync.pending_geometry))
5858      return EINA_FALSE;
5859
5860    return ec->surface_sync.wait_commit;
5861 }
5862
5863 EINTERN void
5864 e_client_pending_geometry_flush(E_Client *ec)
5865 {
5866    E_Client_Pending_Geometry *geo;
5867
5868    if (!eina_list_count(ec->surface_sync.pending_geometry))
5869      {
5870         EINA_LIST_FREE(ec->surface_sync.pending_geometry, geo)
5871           {
5872              E_FREE(geo);
5873           }
5874         ec->surface_sync.wait_commit = EINA_FALSE;
5875         ELOGF("POSSIZE", "pending geometry has flushed", ec);
5876      }
5877 }
5878
5879 EINTERN void
5880 e_client_pending_geometry_last_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
5881 {
5882    Eina_List *l;
5883    E_Client_Pending_Geometry *geo;
5884    int gx = 0;
5885    int gy = 0;
5886    int gw = 0;
5887    int gh = 0;
5888
5889    EINA_LIST_REVERSE_FOREACH(ec->surface_sync.pending_geometry, l, geo)
5890      {
5891         gx = geo->x;
5892         gy = geo->y;
5893         gw = geo->w;
5894         gh = geo->h;
5895         break;
5896      }
5897
5898    if (x) *x = gx;
5899    if (y) *y = gy;
5900    if (w) *w = gw;
5901    if (h) *h = gh;
5902 }
5903
5904 E_API void
5905 e_client_frame_focus_set(E_Client *ec, Eina_Bool focus)
5906 {
5907    if (!ec) return;
5908    evas_object_focus_set(ec->frame, focus);
5909 }
5910
5911 EINTERN void
5912 e_client_frame_geometry_set(E_Client *ec, int x, int y, int w, int h)
5913 {
5914    if (!ec) return;
5915
5916    if (ec->internal || ec->input_only)
5917      {
5918         evas_object_geometry_set(ec->frame, x, y, w, h);
5919      }
5920    else
5921      {
5922         if ((ec->w != w) || (ec->h != h))
5923           {
5924              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);
5925              ec->move_after_resize = EINA_TRUE;
5926
5927              e_client_pos_set(ec, x, y);
5928              evas_object_resize(ec->frame, w, h);
5929           }
5930         else
5931           evas_object_geometry_set(ec->frame, x, y, w, h);
5932      }
5933 }
5934
5935 EAPI void
5936 e_client_util_move_resize_without_frame(E_Client *ec, int x, int y, int w, int h)
5937 {
5938    if (!ec) return;
5939
5940    if (ec->internal || ec->input_only)
5941      {
5942         e_client_util_move_without_frame(ec, x, y);
5943         e_client_util_resize_without_frame(ec, w, h);
5944      }
5945    else
5946      {
5947         if ((ec->w != w) || (ec->h != h))
5948           {
5949              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);
5950              ec->move_after_resize = EINA_TRUE;
5951
5952              e_comp_object_frame_xy_adjust(ec->frame, x, y, &x, &y);
5953              e_client_pos_set(ec, x, y);
5954              e_client_util_resize_without_frame(ec, w, h);
5955           }
5956         else
5957           {
5958              e_client_util_move_without_frame(ec, x, y);
5959              e_client_util_resize_without_frame(ec, w, h);
5960           }
5961      }
5962 }
5963
5964 E_API Eina_Bool
5965 e_client_layer_set(E_Client *ec,
5966                    E_Layer layer)
5967 {
5968    E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
5969    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
5970    if (!ec->frame) return EINA_FALSE;
5971
5972    if (e_comp_canvas_client_layer_map(layer) == 9999)
5973      return EINA_FALSE; //invalid layer is not allowed
5974
5975    if (ec->desk_area.enable)
5976      {
5977         if (e_client_layer_set_by_desk_area(ec, layer))
5978           {
5979              // restack according to desk group rule
5980              e_desk_area_ec_rearrange(ec->desk_area.desk_area, ec);
5981              return EINA_TRUE;
5982           }
5983      }
5984    ec->desk_area.layer_backup = layer;
5985
5986    evas_object_layer_set(ec->frame, layer);
5987    if (ec->layer != layer)
5988      {
5989         /* check exceptional case */
5990         if ((ec->fullscreen) &&
5991             (ec->saved.layer != layer))
5992           {
5993              ELOGF("LAYER", "(%d) fail to backup at saved.layer for fullscreen", ec, layer);
5994              return EINA_FALSE;
5995           }
5996         // if e_comp_object fail to change ec->layer due to ec->layer_pending or block
5997         // leave log and apply ec->layer according to set
5998         // as a result it restores back to given layer when pending or block is free
5999         ELOGF("LAYER", "change layer from %d to %d if in case layer pending(%d) or block(%d)",
6000               ec, ec->layer, layer, ec->layer_pending, ec->layer_block);
6001         if (ec->layer_pending || ec->layer_block)
6002           {
6003              ec->layer = layer;
6004              return EINA_TRUE;
6005           }
6006      }
6007
6008    wl_signal_emit_mutable(&PRI(ec)->events.layer_set, NULL);
6009
6010    return EINA_TRUE;
6011 }
6012
6013 E_API E_Layer
6014 e_client_layer_get(E_Client *ec)
6015 {
6016    short layer;
6017
6018    E_OBJECT_CHECK_RETURN(ec, E_LAYER_BOTTOM);
6019    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, E_LAYER_BOTTOM);
6020    if (!ec->frame) return E_LAYER_BOTTOM;
6021
6022    layer = evas_object_layer_get(ec->frame);
6023    if (ec->layer != layer)
6024      {
6025         /* client could be on temperory layer while pending or block,
6026          * in that case, client restores back to ec->layer after pending/block finish */
6027         if (ec->layer_block || ec->layer_pending)
6028           return ec->layer;
6029
6030         /* otherwise, client is on unexpected layer */
6031         ELOGF("LAYER", "layer dismatch ec->layer %d | evas obj layer %d ",
6032               ec, ec->layer, layer);
6033
6034         if (e_comp_canvas_client_layer_map(layer) == 9999)
6035           return E_LAYER_BOTTOM; //not on E_LAYER_CLIENT
6036      }
6037
6038    return ec->layer;
6039 }
6040
6041 static void
6042 _e_client_desk_area_original_layer_save(E_Client *ec, E_Layer layer)
6043 {
6044    E_OBJECT_CHECK(ec);
6045    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
6046    ec->desk_area.layer_backup = layer;
6047 }
6048
6049 EINTERN Eina_Bool
6050 e_client_layer_set_by_desk_area(E_Client *ec, E_Layer layer)
6051 {
6052    E_Desk_Area *eda;
6053    E_Layer edg_layer;
6054    E_Layer org_layer;
6055
6056    if (!ec) return EINA_FALSE;
6057    if (!ec->frame) return EINA_FALSE;
6058    if (!ec->desk_area.enable) return EINA_FALSE;
6059    if (!ec->desk_area.desk_area) return EINA_FALSE;
6060
6061    eda = ec->desk_area.desk_area;
6062
6063    // save original layer
6064    _e_client_desk_area_original_layer_save(ec, layer);
6065
6066    // get desk_area layer
6067    edg_layer = (E_Layer)e_desk_area_layer_get(eda);
6068    org_layer = e_client_desk_area_original_layer_get(ec);
6069
6070    ELOGF("EDG", "layer_set by desk_area... layer:%d, org_layer:%d, new_layer:%d", ec, layer, org_layer, edg_layer);
6071    if (org_layer == edg_layer)
6072      {
6073         e_client_raise(ec);
6074      }
6075    else
6076      {
6077         evas_object_layer_set(ec->frame, edg_layer);
6078         if (edg_layer == ec->layer)
6079           e_client_raise(ec);
6080      }
6081
6082    return EINA_TRUE;
6083 }
6084
6085 EINTERN void
6086 e_client_desk_area_original_layer_restore(E_Client *ec)
6087 {
6088    if (!ec) return;
6089
6090    // Do we need to check ec->desk_area.enable?
6091    // if ec->desk_area.enable is true, then e_client_layer_set calls
6092    // e_desk_area_ec_edg_layer_set(). that's too bad. :(
6093    // so, we MUST make a policy for ordering of the desk group layer restore
6094    // and the desk group enable.
6095    if (ec->desk_area.enable) return;
6096    e_client_layer_set(ec, ec->desk_area.layer_backup);
6097 }
6098
6099 EINTERN E_Layer
6100 e_client_desk_area_original_layer_get(E_Client *ec)
6101 {
6102    if (!ec) return E_LAYER_DESKTOP;
6103
6104    if (ec->desk_area.enable)
6105      return ec->desk_area.layer_backup;
6106    else
6107      return ec->layer;
6108 }
6109
6110 EINTERN Eina_Bool
6111 e_client_desk_area_client_layer_set(E_Client *ec, E_Desk_Area_Client_Layer edgc_layer)
6112 {
6113    E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
6114    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
6115    if ((edgc_layer < E_DESK_AREA_CLIENT_LAYER_DESKTOP) ||
6116        (edgc_layer >= E_DESK_AREA_CLIENT_LAYER_MAX))
6117      return EINA_FALSE;
6118
6119    ec->desk_area.edgc_layer = edgc_layer;
6120    return EINA_TRUE;
6121 }
6122
6123 EINTERN E_Desk_Area_Client_Layer
6124 e_client_desk_area_client_layer_get(E_Client *ec)
6125 {
6126    E_OBJECT_CHECK_RETURN(ec, E_DESK_AREA_CLIENT_LAYER_DESKTOP);
6127
6128    return ec->desk_area.edgc_layer;
6129 }
6130
6131 //FIXME: use e_desk_area_ec_reassign(eda, ec) instead of this api
6132 E_API Eina_Bool
6133 e_client_desk_area_set(E_Client *ec, E_Desk_Area *eda)
6134 {
6135    E_Desk_Area *old_edg;
6136
6137    if (!ec) return EINA_FALSE;
6138
6139 #if 0 // if this is removed.. then below if (eda != old_edg) is removed also...
6140    if (ec->desk_area.desk_area == eda)
6141      return EINA_TRUE;
6142 #endif
6143
6144    ELOGF("EDG", "Desk Group Set (new:%p, old:%p)", ec, eda, ec->desk_area.desk_area);
6145    old_edg = ec->desk_area.desk_area;
6146    if (old_edg)
6147      e_desk_area_ec_remove(old_edg, ec);
6148
6149    ec->desk_area.desk_area = eda;
6150    e_desk_area_ec_add(eda, ec);
6151
6152 #if 0 // if this is removed.. then above if (ec->desk_area.desk_area == eda) is removed also...
6153    if (eda != old_edg)
6154 #endif
6155      {
6156         e_desk_area_ec_update(eda, ec);
6157         e_desk_area_ec_rearrange(ec->desk_area.desk_area, ec);
6158      }
6159
6160    return EINA_TRUE;
6161 }
6162
6163 static void
6164 _raise_between_sibling_under_parent(E_Client *ec)
6165 {
6166    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);
6167    e_client_stack_below(ec, ec->parent);
6168 }
6169
6170 static void
6171 _raise_between_sibling_on_parent(E_Client *ec)
6172 {
6173    E_Client *top_child = NULL;
6174    top_child = e_client_transient_child_top_get(ec->parent, EINA_FALSE);
6175    if (!top_child)
6176      {
6177         ELOGF("POL", "RAISE child window... Stack above on the parent (win:%zx, ec:%p)", ec, e_client_util_win_get(ec->parent), ec->parent);
6178         e_client_stack_above(ec, ec->parent);
6179      }
6180    else
6181      {
6182         if (top_child != ec)
6183           {
6184              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);
6185              e_client_stack_above(ec, top_child);
6186           }
6187         else
6188           ELOGF("POL", "RAISE child window between sibling... already on the top. STAY", ec);
6189      }
6190 }
6191
6192 static void
6193 _raise_belong_to_parent(E_Client *ec)
6194 {
6195    if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
6196      _raise_between_sibling_under_parent(ec);
6197    else
6198      _raise_between_sibling_on_parent(ec);
6199 }
6200
6201 E_API void
6202 e_client_raise(E_Client *ec)
6203 {
6204    if (!ec) return;
6205
6206    if (ec->desk_area.enable)
6207      {
6208         E_Desk_Area *eda;
6209         eda = ec->desk_area.desk_area;
6210         if (eda)
6211           {
6212              e_desk_area_ec_raise(eda, ec);
6213              return;
6214           }
6215      }
6216
6217    if (ec->parent && e_client_is_belong_to_parent(ec))
6218      _raise_belong_to_parent(ec);
6219    else
6220      evas_object_raise(ec->frame);
6221
6222    wl_signal_emit_mutable(&PRI(ec)->events.raise, NULL);
6223 }
6224
6225 static void
6226 _e_client_transient_for_below_group_make(E_Client *ec, Eina_List **list)
6227 {
6228    // list : Head is the bottommost child
6229    E_Client *child;
6230    Eina_List *l;
6231
6232    if (!ec) return;
6233
6234    EINA_LIST_REVERSE_FOREACH(ec->transients, l, child)
6235      {
6236         if (!child) continue;
6237         if (e_client_transient_policy_get(child) != E_TRANSIENT_BELOW) continue;
6238         if (!e_client_is_belong_to_parent(child)) continue;
6239
6240         *list = eina_list_prepend(*list, child);
6241         _e_client_transient_for_group_make(child, list);
6242      }
6243 }
6244
6245 E_API E_Client *
6246 e_client_transient_child_bottom_get(E_Client *ec)
6247 {
6248    E_Client *bottom_ec = NULL;
6249    Eina_List *transient_below_list = NULL;
6250    Eina_List *l = NULL;
6251
6252    _e_client_transient_for_below_group_make(ec, &transient_below_list);
6253
6254    if (transient_below_list)
6255      {
6256         E_Client *temp_ec = NULL;
6257         E_Client *temp_ec2 = NULL;
6258
6259         E_CLIENT_FOREACH(temp_ec)
6260           {
6261              if (bottom_ec) break;
6262
6263              if (temp_ec == ec)
6264                {
6265                   bottom_ec = ec;
6266                   break;
6267                }
6268
6269              EINA_LIST_FOREACH(transient_below_list, l, temp_ec2)
6270                {
6271                   if (temp_ec == temp_ec2)
6272                     {
6273                        bottom_ec = temp_ec2;
6274                        break;
6275                     }
6276                }
6277           }
6278         eina_list_free(transient_below_list);
6279      }
6280    return bottom_ec;
6281 }
6282
6283 static void
6284 _lower_between_sibling_under_parent(E_Client *ec)
6285 {
6286    E_Client *bottom_child = NULL;
6287    bottom_child = e_client_transient_child_bottom_get(ec->parent);
6288    if (!bottom_child)
6289      {
6290         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);
6291         e_client_stack_below(ec, ec->parent);
6292      }
6293    else
6294      {
6295         if (bottom_child != ec)
6296           {
6297              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);
6298              e_client_stack_below(ec, bottom_child);
6299           }
6300         else
6301           ELOGF("POL", "LOWER child window between sibling... already under the bottom. STAY", ec);
6302      }
6303 }
6304
6305 static void
6306 _lower_between_sibling_on_parent(E_Client *ec)
6307 {
6308    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);
6309    e_client_stack_above(ec, ec->parent);
6310 }
6311
6312 static void
6313 _lower_belong_to_parent(E_Client *ec)
6314 {
6315    if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
6316      _lower_between_sibling_under_parent(ec);
6317    else
6318      _lower_between_sibling_on_parent(ec);
6319 }
6320
6321 E_API void
6322 e_client_lower(E_Client *ec)
6323 {
6324    if (!ec) return;
6325
6326    if (ec->desk_area.enable)
6327      {
6328         E_Desk_Area *eda;
6329         eda = ec->desk_area.desk_area;
6330         if (eda)
6331           {
6332              e_desk_area_ec_lower(eda, ec);
6333
6334              wl_signal_emit_mutable(&PRI(ec)->events.lower, NULL);
6335              return;
6336           }
6337      }
6338
6339    if (ec->parent && e_client_is_belong_to_parent(ec))
6340      _lower_belong_to_parent(ec);
6341    else
6342      evas_object_lower(ec->frame);
6343
6344    wl_signal_emit_mutable(&PRI(ec)->events.lower, NULL);
6345 }
6346
6347 E_API void
6348 e_client_stack_above(E_Client *ec, E_Client *above)
6349 {
6350    if (!ec) return;
6351    if (!ec->frame) return;
6352    if (!above) return;
6353    if (!above->frame) return;
6354
6355    if (ec->desk_area.enable)
6356      {
6357         E_Desk_Area *eda;
6358         eda = ec->desk_area.desk_area;
6359         if (eda)
6360           {
6361              e_desk_area_ec_stack_above(eda, ec, above);
6362              return;
6363           }
6364      }
6365
6366    evas_object_stack_above(ec->frame, above->frame);
6367
6368    wl_signal_emit_mutable(&PRI(ec)->events.stack_above, NULL);
6369 }
6370
6371 E_API void
6372 e_client_stack_below(E_Client *ec, E_Client *below)
6373 {
6374    if (!ec) return;
6375    if (!ec->frame) return;
6376    if (!below) return;
6377    if (!below->frame) return;
6378
6379    if (ec->desk_area.enable)
6380      {
6381         E_Desk_Area *eda;
6382         eda = ec->desk_area.desk_area;
6383         if (eda)
6384           {
6385              e_desk_area_ec_stack_below(eda, ec, below);
6386              return;
6387           }
6388      }
6389
6390    evas_object_stack_below(ec->frame, below->frame);
6391
6392    wl_signal_emit_mutable(&PRI(ec)->events.stack_below, NULL);
6393 }
6394
6395 E_API int
6396 e_client_show_pending_set(E_Client *ec)
6397 {
6398    if (!ec) return 0;
6399
6400    ec->show_pending.count++;
6401    ELOGF("E_CLIENT", "SET show_pending. (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
6402    return ec->show_pending.count;
6403 }
6404
6405 E_API int
6406 e_client_show_pending_unset(E_Client *ec)
6407 {
6408    if (!ec) return 0;
6409    if (ec->show_pending.count <= 0) return 0;
6410
6411    ec->show_pending.count--;
6412    ELOGF("E_CLIENT", "UNSET show_pending. (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
6413    if (ec->show_pending.count == 0 && ec->show_pending.running)
6414      {
6415         ec->show_pending.running = EINA_FALSE;
6416         if (ec->frame)
6417           {
6418              ELOGF("E_CLIENT", "evas_object_show by unset show_pending", ec);
6419              evas_object_show(ec->frame);
6420              //e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
6421              EC_CHANGED(ec);
6422           }
6423      }
6424
6425    return ec->show_pending.count;
6426 }
6427
6428 static Eina_Bool
6429 _e_client_surface_tree_foreach_helper(E_Client *ec, E_Client_Surface_Tree_Foreach func, void *data)
6430 {
6431    E_Client *subc;
6432    Eina_List *l, *ll;
6433    Eina_Bool res = EINA_TRUE;
6434    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
6435
6436    if (!cdata)
6437      return res;
6438
6439    EINA_LIST_FOREACH_SAFE(cdata->sub.below_list, l, ll, subc)
6440      {
6441         res = _e_client_surface_tree_foreach_helper(subc, func, data);
6442         if (!res)
6443           break;
6444      }
6445
6446    if (res)
6447      {
6448         res = func(data, ec);
6449         if (res)
6450           {
6451              EINA_LIST_FOREACH_SAFE(cdata->sub.list, l, ll, subc)
6452                {
6453                   res = _e_client_surface_tree_foreach_helper(subc,
6454                                                               func,
6455                                                               data);
6456                   if (!res)
6457                     break;
6458                }
6459           }
6460      }
6461
6462    return res;
6463 }
6464
6465 E_API void
6466 e_client_surface_tree_foreach(E_Client *ec, E_Client_Surface_Tree_Foreach func, void *data)
6467 {
6468    EINA_SAFETY_ON_NULL_RETURN(ec);
6469    EINA_SAFETY_ON_NULL_RETURN(func);
6470
6471    _e_client_surface_tree_foreach_helper(ec, func, data);
6472 }
6473
6474 EINTERN E_Comp_Wl_Client_Data *
6475 e_client_cdata_new(E_Client *ec)
6476 {
6477    E_Comp_Wl_Client_Data *cdata;
6478
6479    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
6480
6481    if (!(cdata = E_NEW(E_Comp_Wl_Client_Data, 1)))
6482      {
6483         ERR("Could not allocate new E_Comp_Wl_Client_Data structure");
6484         return NULL;
6485      }
6486    ec->comp_data = cdata;
6487
6488    return cdata;
6489 }
6490
6491 EINTERN void
6492 e_client_cdata_free(E_Client *ec)
6493 {
6494   EINA_SAFETY_ON_NULL_RETURN(ec);
6495   if (!ec->comp_data) return;
6496
6497   E_FREE(ec->comp_data);
6498 }
6499
6500 EINTERN E_Comp_Wl_Client_Data *
6501 e_client_cdata_get(E_Client *ec)
6502 {
6503    if (!ec) return NULL;
6504
6505    return ec->comp_data;
6506 }
6507
6508 EINTERN Eina_Bool
6509 e_client_map_set(E_Client *ec, E_Map *em)
6510 {
6511    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6512
6513    return e_map_set_to_comp_object(em, ec->frame);
6514 }
6515
6516 E_API E_Map *
6517 e_client_map_get(const E_Client *ec)
6518 {
6519    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
6520
6521    return e_map_get_from_comp_object(ec->frame);
6522 }
6523
6524 EINTERN Eina_Bool
6525 e_client_map_enable_set(E_Client *ec, Eina_Bool enable)
6526 {
6527    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6528    EINA_SAFETY_ON_NULL_RETURN_VAL(ec->frame, EINA_FALSE);
6529
6530    evas_object_map_enable_set(ec->frame, enable);
6531
6532    return EINA_TRUE;
6533 }
6534
6535 EINTERN void
6536 e_client_belong_to_parent_set(E_Client *ec, Eina_Bool set)
6537 {
6538    if (!ec) return;
6539    ec->belong_to_parent = set;
6540 }
6541
6542 EINTERN Eina_Bool
6543 e_client_is_belong_to_parent(E_Client *ec)
6544 {
6545    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6546    return ec->belong_to_parent;
6547 }
6548
6549 EINTERN void
6550 e_client_transient_policy_set(E_Client *ec, E_Transient policy)
6551 {
6552    if (!ec) return;
6553    ec->transient_policy = policy;
6554 }
6555
6556 E_API E_Transient
6557 e_client_transient_policy_get(E_Client *ec)
6558 {
6559    if (!ec) return E_TRANSIENT_ABOVE;
6560    return ec->transient_policy;
6561 }
6562
6563 EINTERN void
6564 e_client_resize_object_create_cb_set(E_Client_Resize_Object_Create_Cb cb)
6565 {
6566    if (_e_client_resize_object_create_cb && cb)
6567      CRI("ATTEMPTING TO OVERWRITE EXISTING CLIENT RESIZE OBJECT CREATE HOOK!!!");
6568    _e_client_resize_object_create_cb = cb;
6569 }
6570
6571 EINTERN void
6572 e_client_resize_unit_size_set(E_Client *ec, unsigned int unit_size)
6573 {
6574    if (!ec) return;
6575
6576    // FYI, we consider 0 and 1 to be the same value as a default unit size.
6577    ec->manage_resize.unit_size = unit_size;
6578 }
6579
6580 EINTERN void
6581 e_client_desk_zoom_enable_set(E_Client *ec, Eina_Bool enable)
6582 {
6583    if (!ec) return;
6584    ec->desk_zoom.enable = enable;
6585 }
6586
6587 EINTERN Eina_Bool
6588 e_client_desk_zoom_enable_get(E_Client *ec)
6589 {
6590    if (!ec) return EINA_FALSE;
6591    return ec->desk_zoom.enable;
6592 }
6593
6594 EINTERN void
6595 e_client_layout_apply(E_Client *ec, Eina_Bool apply)
6596 {
6597    if (!ec) return;
6598    ec->apply_layout = apply;
6599 }
6600
6601 EINTERN Eina_Bool
6602 e_client_is_layout_apply(E_Client *ec)
6603 {
6604    if (!ec) return EINA_FALSE;
6605    return ec->apply_layout;
6606 }
6607
6608 E_API E_Client *
6609 e_client_from_surface_resource(struct wl_resource *surface_resource)
6610 {
6611    EINA_SAFETY_ON_NULL_RETURN_VAL(surface_resource, NULL);
6612
6613    return e_comp_wl_util_client_from_surface_resource(surface_resource);
6614 }
6615
6616 EINTERN void
6617 e_client_fps_update(E_Client *ec)
6618 {
6619    double dt;
6620    double tim;
6621
6622    EINA_SAFETY_ON_NULL_RETURN(ec);
6623
6624    if (!ec->fps.enabled) return;
6625
6626    tim = ecore_time_get();
6627
6628    dt = tim - ec->fps.frametimes[0];
6629
6630    ec->fps.frametimes[0] = tim;
6631    ec->fps.time += dt;
6632    ec->fps.cframes++;
6633
6634    if (ec->fps.lapse == 0.0)
6635      {
6636         ec->fps.lapse = tim;
6637         ec->fps.flapse = ec->fps.cframes;
6638      }
6639    else if ((tim - ec->fps.lapse) >= 0.5)
6640      {
6641         ec->fps.fps = (ec->fps.cframes - ec->fps.flapse) /
6642                       (tim - ec->fps.lapse);
6643         ec->fps.lapse = tim;
6644         ec->fps.flapse = ec->fps.cframes;
6645         ec->fps.time = 0.0;
6646      }
6647 }
6648
6649 EINTERN Eina_Bool
6650 e_client_fps_get(E_Client *ec, double *fps)
6651 {
6652    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6653
6654    if (ec->fps.old_fps == ec->fps.fps)
6655      return EINA_FALSE;
6656
6657    if (ec->fps.fps > 0.0)
6658      {
6659         *fps = ec->fps.fps;
6660         ec->fps.old_fps = ec->fps.fps;
6661         return EINA_TRUE;
6662      }
6663
6664    return EINA_FALSE;
6665 }
6666
6667 EINTERN void
6668 e_client_fps_enable(E_Client *ec, Eina_Bool enable)
6669 {
6670    EINA_SAFETY_ON_NULL_RETURN(ec);
6671
6672    ec->fps.enabled = enable;
6673 }
6674
6675 EINTERN Eina_Bool
6676 e_client_explicit_sync_get(E_Client *ec)
6677 {
6678    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6679
6680    return ec->explicit_sync;
6681 }
6682
6683 EINTERN Eina_Bool
6684 e_client_explicit_sync_set(E_Client *ec, Eina_Bool enable)
6685 {
6686    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6687
6688    ec->explicit_sync = enable;
6689
6690    return EINA_TRUE;
6691 }
6692
6693 EINTERN int
6694 e_client_explicit_sync_acquire_fence_fd_get(E_Client *ec)
6695 {
6696    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, -1);
6697
6698    return ec->acquire_fence_fd;
6699 }
6700
6701 EINTERN Eina_Bool
6702 e_client_explicit_sync_acquire_fence_fd_set(E_Client *ec, int fd)
6703 {
6704   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
6705
6706   ec->acquire_fence_fd = fd;
6707
6708   return EINA_TRUE;
6709 }
6710
6711 EINTERN Eina_Bool
6712 e_client_intercept_hook_auto_placement_call(E_Client *ec)
6713 {
6714   // no need to call the intercept hook if ec is NULL.
6715   if (!ec) return EINA_FALSE;
6716
6717   if (!_e_client_intercept_hook_call(E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT, ec))
6718     {
6719        ELOGF("FOCUS", "E_CLIENT_INTERCEPT_HOOK_AUTO_PLACEMENT Intercepted.", ec);
6720        return EINA_TRUE;
6721     }
6722
6723   return EINA_FALSE;
6724 }
6725
6726 EINTERN void
6727 e_client_iconify_event_send(E_Client *ec)
6728 {
6729    EINA_SAFETY_ON_NULL_RETURN(ec);
6730
6731    _e_client_event_simple(ec, E_EVENT_CLIENT_ICONIFY);
6732 }
6733
6734 EINTERN void
6735 e_client_uniconify_event_send(E_Client *ec)
6736 {
6737    EINA_SAFETY_ON_NULL_RETURN(ec);
6738
6739    _e_client_event_simple(ec, E_EVENT_CLIENT_UNICONIFY);
6740 }
6741
6742 EINTERN void
6743 e_client_stack_transient_for_done_notify(E_Client *ec)
6744 {
6745    EINA_SAFETY_ON_NULL_RETURN(ec);
6746
6747    wl_signal_emit_mutable(&PRI(ec)->events.stack_transient_for_done, NULL);
6748 }
6749
6750 EINTERN void
6751 e_client_eval_pre_fetch_listener_add(E_Client *ec, struct wl_listener *listener)
6752 {
6753    API_ENTRY;
6754    wl_signal_add(&priv->events.eval_pre_fetch, listener);
6755 }
6756
6757 EINTERN void
6758 e_client_eval_fetch_listener_add(E_Client *ec, struct wl_listener *listener)
6759 {
6760    API_ENTRY;
6761    wl_signal_add(&priv->events.eval_fetch, listener);
6762 }
6763
6764 EINTERN void
6765 e_client_eval_pre_post_fetch_listener_add(E_Client *ec, struct wl_listener *listener)
6766 {
6767    API_ENTRY;
6768    wl_signal_add(&priv->events.eval_pre_post_fetch, listener);
6769 }
6770
6771 EINTERN void
6772 e_client_eval_post_fetch_listener_add(E_Client *ec, struct wl_listener *listener)
6773 {
6774    API_ENTRY;
6775    wl_signal_add(&priv->events.eval_post_fetch, listener);
6776 }
6777
6778 EINTERN void
6779 e_client_eval_pre_frame_assign_listener_add(E_Client *ec, struct wl_listener *listener)
6780 {
6781    API_ENTRY;
6782    wl_signal_add(&priv->events.eval_pre_frame_assign, listener);
6783 }
6784
6785 EINTERN void
6786 e_client_eval_post_frame_assign_listener_add(E_Client *ec, struct wl_listener *listener)
6787 {
6788    API_ENTRY;
6789    wl_signal_add(&priv->events.eval_post_frame_assign, listener);
6790 }
6791
6792 EINTERN void
6793 e_client_eval_pre_new_client_listener_add(E_Client *ec, struct wl_listener *listener)
6794 {
6795    API_ENTRY;
6796    wl_signal_add(&priv->events.eval_pre_new_client, listener);
6797 }
6798
6799 EINTERN void
6800 e_client_eval_post_new_client_listener_add(E_Client *ec, struct wl_listener *listener)
6801 {
6802    API_ENTRY;
6803    wl_signal_add(&priv->events.eval_post_new_client, listener);
6804 }
6805
6806 EINTERN void
6807 e_client_eval_visibility_listener_add(E_Client *ec, struct wl_listener *listener)
6808 {
6809    API_ENTRY;
6810    wl_signal_add(&priv->events.eval_visibility, listener);
6811 }
6812
6813 EINTERN void
6814 e_client_eval_visibility_end_listener_add(E_Client *ec, struct wl_listener *listener)
6815 {
6816    API_ENTRY;
6817    wl_signal_add(&priv->events.eval_visibility_end, listener);
6818 }
6819
6820 EINTERN void
6821 e_client_eval_end_listener_add(E_Client *ec, struct wl_listener *listener)
6822 {
6823    API_ENTRY;
6824    wl_signal_add(&priv->events.eval_end, listener);
6825 }
6826
6827 EINTERN void
6828 e_client_move_begin_listener_add(E_Client *ec, struct wl_listener *listener)
6829 {
6830    API_ENTRY;
6831    wl_signal_add(&priv->events.move_begin, listener);
6832 }
6833
6834 EINTERN void
6835 e_client_move_update_listener_add(E_Client *ec, struct wl_listener *listener)
6836 {
6837    API_ENTRY;
6838    wl_signal_add(&priv->events.move_update, listener);
6839 }
6840
6841 EINTERN void
6842 e_client_move_end_listener_add(E_Client *ec, struct wl_listener *listener)
6843 {
6844    API_ENTRY;
6845    wl_signal_add(&priv->events.move_end, listener);
6846 }
6847
6848 EINTERN void
6849 e_client_move_resize_begin_listener_add(E_Client *ec, struct wl_listener *listener)
6850 {
6851    API_ENTRY;
6852    wl_signal_add(&priv->events.move_resize_begin, listener);
6853 }
6854
6855 EINTERN void
6856 e_client_move_resize_update_listener_add(E_Client *ec, struct wl_listener *listener)
6857 {
6858    API_ENTRY;
6859    wl_signal_add(&priv->events.move_resize_update, listener);
6860 }
6861
6862 EINTERN void
6863 e_client_move_resize_end_listener_add(E_Client *ec, struct wl_listener *listener)
6864 {
6865    API_ENTRY;
6866    wl_signal_add(&priv->events.move_resize_end, listener);
6867 }
6868
6869 EINTERN void
6870 e_client_destroy_listener_add(E_Client *ec, struct wl_listener *listener)
6871 {
6872    API_ENTRY;
6873    wl_signal_add(&priv->events.destroy, listener);
6874 }
6875
6876 EINTERN void
6877 e_client_new_client_listener_add(E_Client *ec, struct wl_listener *listener)
6878 {
6879    API_ENTRY;
6880    wl_signal_add(&priv->events.new_client, listener);
6881 }
6882
6883 EINTERN void
6884 e_client_new_client_post_listener_add(E_Client *ec, struct wl_listener *listener)
6885 {
6886    API_ENTRY;
6887    wl_signal_add(&priv->events.new_client_post, listener);
6888 }
6889
6890 EINTERN void
6891 e_client_unredirect_listener_add(E_Client *ec, struct wl_listener *listener)
6892 {
6893    API_ENTRY;
6894    wl_signal_add(&priv->events.unredirect, listener);
6895 }
6896
6897 EINTERN void
6898 e_client_redirect_listener_add(E_Client *ec, struct wl_listener *listener)
6899 {
6900    API_ENTRY;
6901    wl_signal_add(&priv->events.redirect, listener);
6902 }
6903
6904 EINTERN void
6905 e_client_aux_hint_change_listener_add(E_Client *ec, struct wl_listener *listener)
6906 {
6907    API_ENTRY;
6908    wl_signal_add(&priv->events.aux_hint_change, listener);
6909 }
6910
6911 EINTERN void
6912 e_client_window_role_change_listener_add(E_Client *ec, struct wl_listener *listener)
6913 {
6914    API_ENTRY;
6915    wl_signal_add(&priv->events.window_role_change, listener);
6916 }
6917
6918 EINTERN void
6919 e_client_transform_change_listener_add(E_Client *ec, struct wl_listener *listener)
6920 {
6921    API_ENTRY;
6922    wl_signal_add(&priv->events.transform_change, listener);
6923 }
6924
6925 EINTERN void
6926 e_client_activate_done_listener_add(E_Client *ec, struct wl_listener *listener)
6927 {
6928    API_ENTRY;
6929    wl_signal_add(&priv->events.activate_done, listener);
6930 }
6931
6932 EINTERN void
6933 e_client_mouse_in_listener_add(E_Client *ec, struct wl_listener *listener)
6934 {
6935    API_ENTRY;
6936    wl_signal_add(&priv->events.mouse_in, listener);
6937 }
6938
6939 EINTERN void
6940 e_client_mouse_out_listener_add(E_Client *ec, struct wl_listener *listener)
6941 {
6942    API_ENTRY;
6943    wl_signal_add(&priv->events.mouse_out, listener);
6944 }
6945
6946 EINTERN void
6947 e_client_mouse_down_listener_add(E_Client *ec, struct wl_listener *listener)
6948 {
6949    API_ENTRY;
6950    wl_signal_add(&priv->events.mouse_down, listener);
6951 }
6952
6953 EINTERN void
6954 e_client_focus_set_listener_add(E_Client *ec, struct wl_listener *listener)
6955 {
6956    API_ENTRY;
6957    wl_signal_add(&priv->events.focus_set, listener);
6958 }
6959
6960 EINTERN void
6961 e_client_focus_unset_listener_add(E_Client *ec, struct wl_listener *listener)
6962 {
6963    API_ENTRY;
6964    wl_signal_add(&priv->events.focus_unset, listener);
6965 }
6966
6967 EINTERN void
6968 e_client_focus_defer_set_listener_add(E_Client *ec, struct wl_listener *listener)
6969 {
6970    API_ENTRY;
6971    wl_signal_add(&priv->events.focus_defer_set, listener);
6972 }
6973
6974 EINTERN void
6975 e_client_focus_latest_set_listener_add(E_Client *ec, struct wl_listener *listener)
6976 {
6977    API_ENTRY;
6978    wl_signal_add(&priv->events.focus_latest_set, listener);
6979 }
6980
6981 EINTERN void
6982 e_client_iconify_listener_add(E_Client *ec, struct wl_listener *listener)
6983 {
6984    API_ENTRY;
6985    wl_signal_add(&priv->events.iconify, listener);
6986 }
6987
6988 EINTERN void
6989 e_client_uniconify_listener_add(E_Client *ec, struct wl_listener *listener)
6990 {
6991    API_ENTRY;
6992    wl_signal_add(&priv->events.uniconify, listener);
6993 }
6994
6995 EINTERN void
6996 e_client_maximize_listener_add(E_Client *ec, struct wl_listener *listener)
6997 {
6998    API_ENTRY;
6999    wl_signal_add(&priv->events.maximize, listener);
7000 }
7001
7002 EINTERN void
7003 e_client_unmaximize_listener_add(E_Client *ec, struct wl_listener *listener)
7004 {
7005    API_ENTRY;
7006    wl_signal_add(&priv->events.unmaximize, listener);
7007 }
7008
7009 EINTERN void
7010 e_client_fullscreen_pre_listener_add(E_Client *ec, struct wl_listener *listener)
7011 {
7012    API_ENTRY;
7013    wl_signal_add(&priv->events.fullscreen_pre, listener);
7014 }
7015
7016 EINTERN void
7017 e_client_fullscreen_listener_add(E_Client *ec, struct wl_listener *listener)
7018 {
7019    API_ENTRY;
7020    wl_signal_add(&priv->events.fullscreen, listener);
7021 }
7022
7023 EINTERN void
7024 e_client_unfullscreen_listener_add(E_Client *ec, struct wl_listener *listener)
7025 {
7026    API_ENTRY;
7027    wl_signal_add(&priv->events.unfullscreen, listener);
7028 }
7029
7030 EINTERN void
7031 e_client_move_listener_add(E_Client *ec, struct wl_listener *listener)
7032 {
7033    API_ENTRY;
7034    wl_signal_add(&priv->events.move, listener);
7035 }
7036
7037 EINTERN void
7038 e_client_raise_listener_add(E_Client *ec, struct wl_listener *listener)
7039 {
7040    API_ENTRY;
7041    wl_signal_add(&priv->events.raise, listener);
7042 }
7043
7044 EINTERN void
7045 e_client_lower_listener_add(E_Client *ec, struct wl_listener *listener)
7046 {
7047    API_ENTRY;
7048    wl_signal_add(&priv->events.lower, listener);
7049 }
7050
7051 EINTERN void
7052 e_client_stack_below_listener_add(E_Client *ec, struct wl_listener *listener)
7053 {
7054    API_ENTRY;
7055    wl_signal_add(&priv->events.stack_below, listener);
7056 }
7057
7058 EINTERN void
7059 e_client_stack_above_listener_add(E_Client *ec, struct wl_listener *listener)
7060 {
7061    API_ENTRY;
7062    wl_signal_add(&priv->events.stack_above, listener);
7063 }
7064
7065 EINTERN void
7066 e_client_layer_set_listener_add(E_Client *ec, struct wl_listener *listener)
7067 {
7068    API_ENTRY;
7069    wl_signal_add(&priv->events.layer_set, listener);
7070 }
7071
7072 EINTERN void
7073 e_client_stack_transient_for_done_listener_add(E_Client *ec, struct wl_listener *listener)
7074 {
7075    API_ENTRY;
7076    wl_signal_add(&priv->events.stack_transient_for_done, listener);
7077 }
7078
7079 EINTERN void
7080 e_client_stick_listener_add(E_Client *ec, struct wl_listener *listener)
7081 {
7082    API_ENTRY;
7083    wl_signal_add(&priv->events.stick, listener);
7084 }
7085
7086 EINTERN void
7087 e_client_unstick_listener_add(E_Client *ec, struct wl_listener *listener)
7088 {
7089    API_ENTRY;
7090    wl_signal_add(&priv->events.unstick, listener);
7091 }
7092
7093 EINTERN struct wl_listener *
7094 e_client_destroy_listener_get(E_Client *ec, wl_notify_func_t notify)
7095 {
7096    API_ENTRY_VAL(NULL);
7097    return wl_signal_get(&priv->events.destroy, notify);
7098 }