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