1 #include "e_policy_wl.h"
3 #include "services/e_service_quickpanel.h"
4 #include "services/e_service_volume.h"
5 #include "services/e_service_lockscreen.h"
6 #include "services/e_service_indicator.h"
7 #include "services/e_service_cbhm.h"
8 #include "services/e_service_scrsaver.h"
9 #include "services/e_service_softkey.h"
10 #include "services/e_service_launcher.h"
11 #include "services/e_service_taskbar.h"
12 #include "services/e_service_kvm.h"
13 #include "e_policy_wl_display.h"
14 #include "e_policy_conformant_internal.h"
15 #include "e_policy_visibility.h"
16 #include "e_appinfo.h"
18 #include <device/display.h>
19 #include <wayland-server.h>
20 #include <tizen-extension-server-protocol.h>
21 #include <tizen-launch-server-protocol.h>
22 #include <tzsh_server.h>
24 typedef enum _Tzsh_Srv_Role
26 TZSH_SRV_ROLE_UNKNOWN = -1,
28 TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT,
29 TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU,
30 TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU,
31 TZSH_SRV_ROLE_LOCKSCREEN,
32 TZSH_SRV_ROLE_INDICATOR,
33 TZSH_SRV_ROLE_SCREENSAVER_MNG,
34 TZSH_SRV_ROLE_SCREENSAVER,
36 TZSH_SRV_ROLE_SOFTKEY,
37 TZSH_SRV_ROLE_MAGNIFIER,
38 TZSH_SRV_ROLE_LAUNCHER,
39 TZSH_SRV_ROLE_TASKBAR,
44 typedef enum _Tzsh_Client_Handle_Type
46 TZSH_CLIENT_HANDLE_TYPE_NONE = 0,
47 TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL = 1,
48 TZSH_CLIENT_HANDLE_TYPE_SHARED_WIDGET_LAUNCH = 2,
49 TZSH_CLIENT_HANDLE_TYPE_SOFTKEY = 3,
50 } Tzsh_Client_Handle_Type;
52 typedef enum _Tzsh_Type
54 TZSH_TYPE_UNKNOWN = 0,
59 typedef enum _Tzlaunch_Effect_Type
61 TZLAUNCH_EFFECT_TYPE_LAUNCH = 0,
62 TZLAUNCH_EFFECT_TYPE_DEPTH_IN
63 } Tzlaunch_Effect_Type;
65 typedef struct _E_Policy_Wl_Tzpol
67 struct wl_resource *res_tzpol; /* tizen_policy_interface */
68 Eina_List *psurfs; /* list of E_Policy_Wl_Surface */
73 typedef struct _E_Policy_Wl_Tz_Dpy_Pol
75 struct wl_resource *res_tz_dpy_pol;
76 Eina_List *dpy_surfs; // list of E_Policy_Wl_Dpy_Surface
77 } E_Policy_Wl_Tz_Dpy_Pol;
79 typedef struct _E_Policy_Wl_Tzsh
81 struct wl_resource *res_tzsh; /* tizen_ws_shell_interface */
82 Eina_List *service_list;
83 Eina_List *client_list;
86 typedef struct _E_Policy_Wl_Tzsh_Srv
88 E_Policy_Wl_Tzsh *tzsh;
89 struct wl_resource *res_tzsh_srv;
96 } E_Policy_Wl_Tzsh_Srv;
98 typedef struct _E_Policy_Wl_Tzsh_Client
100 E_Policy_Wl_Tzsh *tzsh;
101 struct wl_resource *res_tzsh_client;
102 Tzsh_Client_Handle_Type handle_type;
108 } E_Policy_Wl_Tzsh_Client;
110 typedef struct _E_Policy_Wl_Tzsh_Client_Data_Quickpanel
112 E_Quickpanel_Type type;
113 } E_Policy_Wl_Tzsh_Client_Data_Quickpanel;
115 typedef struct _E_Policy_Wl_Tzsh_Client_Data_Softkey
118 } E_Policy_Wl_Tzsh_Client_Data_Softkey;
120 typedef struct _E_Policy_Wl_Tzsh_Region
122 E_Policy_Wl_Tzsh *tzsh;
123 struct wl_resource *res_tzsh_reg;
125 struct wl_listener destroy_listener;
126 } E_Policy_Wl_Tzsh_Region;
128 typedef struct _E_Policy_Wl_Tzsh_Extension
131 E_Policy_Wl_Tzsh_Ext_Hook_Cb cb;
132 } E_Policy_Wl_Tzsh_Extension;
134 typedef struct _E_Policy_Wl_Surface
136 struct wl_resource *surf;
137 E_Policy_Wl_Tzpol *tzpol;
141 Eina_Bool pending_notilv;
143 Eina_List *vislist; /* list of tizen_visibility_interface resources */
144 Eina_List *poslist; /* list of tizen_position_inteface resources */
145 Eina_Bool is_background;
146 } E_Policy_Wl_Surface;
148 typedef struct _E_Policy_Wl_Dpy_Surface
150 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
151 struct wl_resource *surf;
155 } E_Policy_Wl_Dpy_Surface;
157 typedef struct _E_Policy_Wl_Tzlaunch_Effect
159 struct wl_resource *res_tzlaunch_effect; /* tizen_launch_effect */
160 Eina_List *splash_list; /* list of E_Policy_Wl_Tzlaunch_Splash */
161 } E_Policy_Wl_Tzlaunch_Effect;
163 typedef struct _E_Policy_Wl_Tzlaunch_Splash
165 struct wl_resource *res_tzlaunch_splash; /* tizen_launch_image */
166 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect; /* launcher */
168 const char *path; /* image resource path */
169 uint32_t type; /* 0: image, 1: edc */
170 uint32_t indicator; /* 0: off, 1: on */
171 uint32_t angle; /* 0, 90, 180, 270 : rotation angle */
174 Evas_Object *obj; /* launch screen image */
175 E_Pixmap *ep; /* pixmap for launch screen client */
176 E_Client *ec; /* client for launch screen image */
177 Ecore_Timer *timeout; /* launch screen image hide timer */
178 Evas_Object *indicator_obj; /* plug object of indicator */
180 Eina_Bool valid; /* validation check */
182 E_Comp_Object_Content_Type content_type; /* type of content */
184 Eina_Bool custom_effect_callee; /* custom effect enabled */
186 } E_Policy_Wl_Tzlaunch_Splash;
188 typedef struct _E_Policy_Wl_Tzlaunch_Effect_Info
190 uint32_t pid; /* pid */
191 int effect_type; /* effect_type */
192 } E_Policy_Wl_Tzlaunch_Effect_Info;
194 typedef struct _E_Policy_Wl_Tzlaunch_Appinfo
196 struct wl_resource *res_tzlaunch_appinfo; /* tizen_launch_appinfo */
197 } E_Policy_Wl_Tzlaunch_Appinfo;
199 typedef enum _Launch_Img_File_type
201 LAUNCH_IMG_FILE_TYPE_ERROR = -1,
202 LAUNCH_IMG_FILE_TYPE_IMAGE = 0,
203 LAUNCH_IMG_FILE_TYPE_EDJ
204 } Launch_Img_File_type;
206 typedef struct _E_Policy_Wl_Tz_Indicator
208 struct wl_resource *res_tz_indicator;
210 } E_Policy_Wl_Tz_Indicator;
212 typedef struct _E_Policy_Wl_Tz_Clipboard
214 struct wl_resource *res_tz_clipboard;
216 } E_Policy_Wl_Tz_Clipboard;
218 typedef struct _E_Policy_Wl
220 Eina_List *globals; /* list of wl_global */
221 Eina_Hash *tzpols; /* list of E_Policy_Wl_Tzpol */
223 Eina_List *tz_dpy_pols; /* list of E_Policy_Wl_Tz_Dpy_Pol */
224 Eina_List *pending_vis; /* list of clients that have pending visibility change*/
226 /* tizen_ws_shell_interface */
227 Eina_List *tzshs; /* list of E_Policy_Wl_Tzsh */
228 Eina_List *tzsh_srvs; /* list of E_Policy_Wl_Tzsh_Srv */
229 Eina_List *tzsh_clients; /* list of E_Policy_Wl_Tzsh_Client */
230 E_Policy_Wl_Tzsh_Srv *srvs[TZSH_SRV_ROLE_MAX]; /* list of registered E_Policy_Wl_Tzsh_Srv */
231 Eina_List *tz_indicators;
232 Eina_List *tz_clipboards; /* list of E_Policy_Wl_Tz_Clipboard */
234 /* tizen_launch_effect_interface */
235 Eina_List *tzlaunch_effect; /* list of E_Policy_Wl_Tzlaunch_Effect */
236 Eina_List *tzlaunch_effect_info; /* list of E_Policy_Wl_Tzlaunch_Effect_Info */
237 /* tizen_launch_appinfo_interface */
238 Eina_List *tzlaunch_appinfo; /* list of E_Policy_Wl_Tzlaunch_Appinfo */
239 /* tizen_ws_shell_interface ver_2 */
240 Eina_List *tzsh_extensions; /* list of E_Policy_Wl_Tzsh_Extension */
243 typedef struct _E_Tzsh_QP_Event
249 static E_Policy_Wl *polwl = NULL;
251 static Eina_List *handlers = NULL;
252 static Eina_List *polwl_hooks_ec = NULL;
253 static Eina_List *hooks_cw = NULL;
254 static Eina_List *hooks_co = NULL;
255 static struct wl_resource *_scrsaver_mng_res = NULL; // TODO
256 static struct wl_resource *_indicator_srv_res = NULL;
258 static int _e_policy_wl_hooks_delete = 0;
259 static int _e_policy_wl_hooks_walking = 0;
261 static Eina_Inlist *_e_policy_wl_hooks[] =
263 [E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET] = NULL,
266 EINTERN int E_EVENT_POLICY_INDICATOR_STATE_CHANGE = -1;
267 EINTERN int E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = -1;
268 EINTERN int E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = -1;
270 enum _E_Policy_Hint_Type
272 E_POLICY_HINT_USER_GEOMETRY = 0,
273 E_POLICY_HINT_FIXED_RESIZE = 1,
274 E_POLICY_HINT_DEICONIFY_UPDATE = 2,
275 E_POLICY_HINT_ICONIFY = 3,
276 E_POLICY_HINT_ABOVE_LOCKSCREEN = 4,
277 E_POLICY_HINT_GESTURE_DISABLE = 5,
278 E_POLICY_HINT_EFFECT_DISABLE = 6,
279 E_POLICY_HINT_MSG_USE = 7,
280 E_COMP_HINT_ALWAYS_SELECTIVE = 8,
281 E_POLICY_HINT_DEPENDENT_ROTATION = 9,
282 E_POLICY_HINT_ROT_RENDER_NOPENDING = 10,
283 E_POLICY_HINT_ICONIFY_BUFFER_FLUSH = 11,
284 E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP = 12,
285 E_POLICY_HINT_BELONG_TO_PARENT = 13,
286 E_POLICY_HINT_RESIZE_ASPECT_RATIO = 14,
287 E_POLICY_HINT_DECORATION_SIZE_HEADER = 15,
288 E_POLICY_HINT_DECORATION_SIZE_FOOTER = 16,
289 E_POLICY_HINT_VISIBILITY_IGNORE_GEOMETRY= 17,
290 E_POLICY_HINT_RESIZE_PPU = 18,
291 E_POLICY_HINT_DECORATION_SIZE_SHADOW_TOP = 19,
292 E_POLICY_HINT_DECORATION_SIZE_SHADOW_BOTTOM = 20,
293 E_POLICY_HINT_DECORATION_SIZE_SHADOW_LEFT = 21,
294 E_POLICY_HINT_DECORATION_SIZE_SHADOW_RIGHT = 22,
297 static const char *hint_names[] =
299 "wm.policy.win.user.geometry",
300 "wm.policy.win.fixed.resize",
301 "wm.policy.win.deiconify.update",
302 "wm.policy.win.iconify",
303 "wm.policy.win.above.lock",
304 "wm.policy.win.gesture.disable",
305 "wm.policy.win.effect.disable",
306 "wm.policy.win.msg.use",
307 "wm.comp.win.always.selective.mode",
308 "wm.policy.win.rot.dependent",
309 "wm.policy.win.rot.render.nopending",
310 "wm.policy.win.iconify.buffer.flush",
311 "wm.policy.win.transient_for.always_on_top",
312 "wm.policy.win.belong_to_parent",
313 "wm.policy.win.resize_aspect_ratio",
314 "wm.policy.win.decoration.size.header",
315 "wm.policy.win.decoration.size.footer",
316 "wm.policy.win.visibility.ignore_geometry",
317 "wm.policy.win.resize.ppu",
318 "wm.policy.win.decoration.size.shadow.top",
319 "wm.policy.win.decoration.size.shadow.bottom",
320 "wm.policy.win.decoration.size.shadow.left",
321 "wm.policy.win.decoration.size.shadow.right",
324 static void _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf);
325 static void _e_policy_wl_tzsh_srv_state_broadcast(E_Policy_Wl_Tzsh_Srv *tzsh_srv, Eina_Bool reg);
326 static Eina_Bool _e_policy_wl_e_client_is_valid(E_Client *ec);
327 static E_Policy_Wl_Tzsh_Srv *_e_policy_wl_tzsh_srv_add(E_Policy_Wl_Tzsh *tzsh, Tzsh_Srv_Role role, struct wl_resource *res_tzsh_srv, const char *name, E_Pixmap *ep, E_Client *ec);
328 static void _e_policy_wl_tzsh_srv_del(E_Policy_Wl_Tzsh_Srv *tzsh_srv);
329 static E_Policy_Wl_Tzsh_Client *_e_policy_wl_tzsh_client_add(E_Policy_Wl_Tzsh *tzsh, struct wl_resource *res_tzsh_client, E_Pixmap *ep, E_Client *ec);
330 static void _e_policy_wl_tzsh_client_del(E_Policy_Wl_Tzsh_Client *tzsh_client);
331 static void _e_policy_wl_background_state_set(E_Policy_Wl_Surface *psurf, Eina_Bool state);
333 static void _e_policy_wl_tzlaunch_effect_type_sync(E_Client *ec);
334 static int _e_policy_wl_tzlaunch_effect_type_get(const char* effect_type);
335 static void _e_policy_wl_tzlaunch_effect_type_unset(uint32_t pid);
337 static void _launch_effect_hide(uint32_t pid);
338 static void _launch_effect_client_del(E_Client *ec);
339 static void _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash);
341 // --------------------------------------------------------
343 // --------------------------------------------------------
346 _e_policy_wl_hooks_clean()
348 E_Policy_Wl_Hook *epwh = NULL;
349 Eina_Inlist *l = NULL;
352 for (x = 0; x < E_POLICY_WL_HOOK_LAST; x++)
354 EINA_INLIST_FOREACH_SAFE(_e_policy_wl_hooks[x], l, epwh)
356 if (!epwh->delete_me) continue;
357 _e_policy_wl_hooks[x] = eina_inlist_remove(_e_policy_wl_hooks[x], EINA_INLIST_GET(epwh));
364 _e_policy_wl_hook_call(E_Policy_Wl_Hook_Point hookpoint, pid_t pid)
366 E_Policy_Wl_Hook *epwh = NULL;
368 _e_policy_wl_hooks_walking++;
369 EINA_INLIST_FOREACH(_e_policy_wl_hooks[hookpoint], epwh)
371 if (epwh->delete_me) continue;
372 epwh->func(epwh->data, pid);
374 _e_policy_wl_hooks_walking--;
376 if ((_e_policy_wl_hooks_walking == 0) && (_e_policy_wl_hooks_delete > 0))
377 _e_policy_wl_hooks_clean();
380 E_API E_Policy_Wl_Hook *
381 e_policy_wl_hook_add(E_Policy_Wl_Hook_Point hookpoint, E_Policy_Wl_Hook_Cb func, const void *data)
383 E_Policy_Wl_Hook *epwh = NULL;
385 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0, NULL);
386 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_POLICY_WL_HOOK_LAST, NULL);
388 epwh = E_NEW(E_Policy_Wl_Hook, 1);
389 EINA_SAFETY_ON_NULL_RETURN_VAL(epwh, NULL);
391 epwh->hookpoint = hookpoint;
393 epwh->data = (void *)data;
394 _e_policy_wl_hooks[hookpoint] = eina_inlist_append(_e_policy_wl_hooks[hookpoint], EINA_INLIST_GET(epwh));
400 e_policy_wl_hook_del(E_Policy_Wl_Hook *epwh)
403 if (_e_policy_wl_hooks_walking == 0)
405 _e_policy_wl_hooks[epwh->hookpoint] = eina_inlist_remove(_e_policy_wl_hooks[epwh->hookpoint], EINA_INLIST_GET(epwh));
409 _e_policy_wl_hooks_delete++;
412 // --------------------------------------------------------
414 // --------------------------------------------------------
416 _e_policy_wl_tzpol_background_state_check(pid_t pid)
418 E_Policy_Wl_Tzpol *tzpol;
420 Eina_Bool bg_state = EINA_FALSE;
425 it = eina_hash_iterator_data_new(polwl->tzpols);
426 EINA_ITERATOR_FOREACH(it, tzpol)
428 if (tzpol->pid == pid)
432 bg_state = EINA_TRUE;
437 eina_iterator_free(it);
442 static E_Policy_Wl_Tzpol *
443 _e_policy_wl_tzpol_add(struct wl_client *client, struct wl_resource *res_tzpol)
445 E_Policy_Wl_Tzpol *tzpol;
448 tzpol = E_NEW(E_Policy_Wl_Tzpol, 1);
449 EINA_SAFETY_ON_NULL_RETURN_VAL(tzpol, NULL);
451 eina_hash_add(polwl->tzpols, &res_tzpol, tzpol);
453 tzpol->res_tzpol = res_tzpol;
455 wl_client_get_credentials(client, &pid, NULL, NULL);
458 tzpol->bg_state = _e_policy_wl_tzpol_background_state_check(pid);
464 _e_policy_wl_tzpol_del(void *data)
466 E_Policy_Wl_Tzpol *tzpol;
467 E_Policy_Wl_Surface *psurf;
469 tzpol = (E_Policy_Wl_Tzpol *)data;
471 EINA_LIST_FREE(tzpol->psurfs, psurf)
473 _e_policy_wl_surf_del(psurf);
476 memset(tzpol, 0x0, sizeof(E_Policy_Wl_Tzpol));
480 static E_Policy_Wl_Tzpol *
481 _e_policy_wl_tzpol_get(struct wl_resource *res_tzpol)
483 return (E_Policy_Wl_Tzpol *)eina_hash_find(polwl->tzpols, &res_tzpol);
486 static E_Policy_Wl_Surface *
487 _e_policy_wl_tzpol_surf_find(E_Policy_Wl_Tzpol *tzpol, E_Client *ec)
490 E_Policy_Wl_Surface *psurf;
492 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
502 _e_policy_wl_surf_is_valid(E_Policy_Wl_Surface *psurf)
504 E_Policy_Wl_Tzpol *tzpol;
505 E_Policy_Wl_Surface *psurf2;
509 it = eina_hash_iterator_data_new(polwl->tzpols);
510 EINA_ITERATOR_FOREACH(it, tzpol)
511 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf2)
515 eina_iterator_free(it);
519 eina_iterator_free(it);
524 // --------------------------------------------------------
526 // --------------------------------------------------------
529 _print_tzsh_service_info(void)
531 E_Policy_Wl_Tzsh_Srv *tzsh_srv = NULL;
535 ELOGF("TZSH", "================ TZSH SERVICE LIST ================", NULL);
536 EINA_LIST_FOREACH(polwl->tzsh_srvs, l, tzsh_srv)
538 ELOGF("TZSH", "[%d] tzsh_service(%p). tzsh:%p, role:%d, name:%s", tzsh_srv->ec, i, tzsh_srv, tzsh_srv->tzsh, tzsh_srv->role, tzsh_srv->name);
541 ELOGF("TZSH", "---------------------------------------------------", NULL);
545 _print_tzsh_client_info(void)
547 E_Policy_Wl_Tzsh_Client *tzsh_client = NULL;
551 ELOGF("TZSH", "================ TZSH CLIENT LIST ================", NULL);
552 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
554 ELOGF("TZSH", "[%d] tzsh_client(%p). tzsh:%p", tzsh_client->ec, i, tzsh_client, tzsh_client->tzsh);
557 ELOGF("TZSH", "---------------------------------------------------", NULL);
561 static E_Policy_Wl_Tzsh *
562 _e_policy_wl_tzsh_add(struct wl_resource *res_tzsh)
564 E_Policy_Wl_Tzsh *tzsh;
566 tzsh = E_NEW(E_Policy_Wl_Tzsh, 1);
567 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh, NULL);
569 tzsh->res_tzsh = res_tzsh;
571 polwl->tzshs = eina_list_append(polwl->tzshs, tzsh);
574 _print_tzsh_service_info();
575 _print_tzsh_client_info();
582 _e_policy_wl_tzsh_del(E_Policy_Wl_Tzsh *tzsh)
584 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
585 E_Policy_Wl_Tzsh_Client *tzsh_client;
588 polwl->tzshs = eina_list_remove(polwl->tzshs, tzsh);
590 if (tzsh->service_list)
592 EINA_LIST_FREE(tzsh->service_list, tzsh_srv)
594 EINA_LIST_FOREACH_SAFE(polwl->tzsh_srvs, l, ll, tzsh_srv)
596 if (tzsh_srv->tzsh != tzsh) continue;
597 _e_policy_wl_tzsh_srv_del(tzsh_srv);
601 tzsh->service_list = NULL;
604 if (tzsh->client_list)
606 EINA_LIST_FREE(tzsh->client_list, tzsh_client)
608 EINA_LIST_FOREACH_SAFE(polwl->tzsh_clients, l, ll, tzsh_client)
610 if (tzsh_client->tzsh != tzsh) continue;
611 _e_policy_wl_tzsh_client_del(tzsh_client);
618 _print_tzsh_service_info();
619 _print_tzsh_client_info();
622 memset(tzsh, 0x0, sizeof(E_Policy_Wl_Tzsh));
626 /* notify current registered services to the client */
628 _e_policy_wl_tzsh_registered_srv_send(E_Policy_Wl_Tzsh *tzsh)
632 for (i = 0; i < TZSH_SRV_ROLE_MAX; i++)
634 if (!polwl->srvs[i]) continue;
636 tizen_ws_shell_send_service_register
637 (tzsh->res_tzsh, polwl->srvs[i]->name);
642 _e_policy_wl_tzsh_srv_cb_client_zone_set(void *data, int type EINA_UNUSED, void *event)
644 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
645 E_Event_Client_Zone_Set *ev;
650 if (tzsh_srv->ec != ev->ec)
653 if (tzsh_srv->zone == ev->zone)
656 ELOGF("TZSH", "Change Zone | e_policy_wl_tzsh_srv %p old(%p) new(%p)",
657 tzsh_srv->ec, tzsh_srv, tzsh_srv->zone, ev->zone);
659 tzsh_srv->zone = ev->zone;
662 return ECORE_CALLBACK_PASS_ON;
665 // --------------------------------------------------------
666 // E_Policy_Wl_Tzsh_Srv
667 // --------------------------------------------------------
668 static E_Policy_Wl_Tzsh_Srv *
669 _e_policy_wl_tzsh_srv_add(E_Policy_Wl_Tzsh *tzsh, Tzsh_Srv_Role role, struct wl_resource *res_tzsh_srv, const char *name, E_Pixmap *ep, E_Client *ec)
671 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
673 tzsh_srv = E_NEW(E_Policy_Wl_Tzsh_Srv, 1);
674 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_srv, NULL);
676 tzsh_srv->tzsh = tzsh;
677 tzsh_srv->res_tzsh_srv = res_tzsh_srv;
678 tzsh_srv->role = role;
679 tzsh_srv->name = eina_stringshare_add(name);
682 tzsh_srv->zone = e_comp_zone_find_by_ec(ec);
683 e_object_ref(E_OBJECT(ec));
684 tzsh_srv->tzsh->service_list = eina_list_append(tzsh_srv->tzsh->service_list, tzsh_srv);
686 polwl->srvs[role] = tzsh_srv;
687 polwl->tzsh_srvs = eina_list_append(polwl->tzsh_srvs, tzsh_srv);
690 _print_tzsh_service_info();
693 _e_policy_wl_tzsh_srv_state_broadcast(tzsh_srv, EINA_TRUE);
695 E_LIST_HANDLER_APPEND(tzsh_srv->events, E_EVENT_CLIENT_ZONE_SET, _e_policy_wl_tzsh_srv_cb_client_zone_set, tzsh_srv);
701 _e_policy_wl_tzsh_srv_del(E_Policy_Wl_Tzsh_Srv *tzsh_srv)
703 E_FREE_LIST(tzsh_srv->events, ecore_event_handler_del);
705 polwl->tzsh_srvs = eina_list_remove(polwl->tzsh_srvs, tzsh_srv);
708 _print_tzsh_service_info();
712 tzsh_srv->tzsh->service_list = eina_list_remove(tzsh_srv->tzsh->service_list, tzsh_srv);
714 if (polwl->srvs[tzsh_srv->role] == tzsh_srv)
715 polwl->srvs[tzsh_srv->role] = NULL;
717 _e_policy_wl_tzsh_srv_state_broadcast(tzsh_srv, EINA_FALSE);
720 eina_stringshare_del(tzsh_srv->name);
722 if (tzsh_srv->role == TZSH_SRV_ROLE_INDICATOR)
727 if (ec && ec->internal)
729 e_pixmap_win_id_del(tzsh_srv->ep);
730 e_object_del(E_OBJECT(ec));
733 _indicator_srv_res = NULL;
735 else if (tzsh_srv->role == TZSH_SRV_ROLE_SOFTKEY)
737 E_Client *softkey_ec = NULL;
739 softkey_ec = tzsh_srv->ec;
742 e_service_softkey_client_unset(softkey_ec);
745 else if (tzsh_srv->role == TZSH_SRV_ROLE_MAGNIFIER)
747 E_Client *magnifier_ec = NULL;
749 magnifier_ec = tzsh_srv->ec;
752 e_magnifier_owner_unset(magnifier_ec);
756 else if (tzsh_srv->role == TZSH_SRV_ROLE_LAUNCHER)
758 E_Client *launcher_ec = NULL;
760 launcher_ec = tzsh_srv->ec;
763 e_service_launcher_client_unset(launcher_ec);
769 e_object_unref(E_OBJECT(tzsh_srv->ec));
772 memset(tzsh_srv, 0x0, sizeof(E_Policy_Wl_Tzsh_Srv));
777 _e_policy_wl_tzsh_srv_role_get(const char *name)
779 Tzsh_Srv_Role role = TZSH_SRV_ROLE_UNKNOWN;
781 if (!e_util_strcmp(name, "volume" )) role = TZSH_SRV_ROLE_VOLUME;
782 else if (!e_util_strcmp(name, "quickpanel_system_default")) role = TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT;
783 else if (!e_util_strcmp(name, "quickpanel_context_menu" )) role = TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU;
784 else if (!e_util_strcmp(name, "quickpanel_apps_menu" )) role = TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU;
785 else if (!e_util_strcmp(name, "lockscreen" )) role = TZSH_SRV_ROLE_LOCKSCREEN;
786 else if (!e_util_strcmp(name, "indicator" )) role = TZSH_SRV_ROLE_INDICATOR;
787 else if (!e_util_strcmp(name, "screensaver_manager" )) role = TZSH_SRV_ROLE_SCREENSAVER_MNG;
788 else if (!e_util_strcmp(name, "screensaver" )) role = TZSH_SRV_ROLE_SCREENSAVER;
789 else if (!e_util_strcmp(name, "cbhm" )) role = TZSH_SRV_ROLE_CBHM;
790 else if (!e_util_strcmp(name, "softkey" )) role = TZSH_SRV_ROLE_SOFTKEY;
791 else if (!e_util_strcmp(name, "magnifier" )) role = TZSH_SRV_ROLE_MAGNIFIER;
792 else if (!e_util_strcmp(name, "launcher" )) role = TZSH_SRV_ROLE_LAUNCHER;
793 else if (!e_util_strcmp(name, "taskbar" )) role = TZSH_SRV_ROLE_TASKBAR;
794 else if (!e_util_strcmp(name, "KVM" )) role = TZSH_SRV_ROLE_KVM;
799 /* broadcast state of registered service to all subscribers */
801 _e_policy_wl_tzsh_srv_state_broadcast(E_Policy_Wl_Tzsh_Srv *tzsh_srv, Eina_Bool reg)
803 E_Policy_Wl_Tzsh *tzsh;
806 EINA_LIST_FOREACH(polwl->tzshs, l, tzsh)
808 if (tzsh_srv->tzsh == tzsh)
812 tizen_ws_shell_send_service_register
813 (tzsh->res_tzsh, tzsh_srv->name);
815 tizen_ws_shell_send_service_unregister
816 (tzsh->res_tzsh, tzsh_srv->name);
820 // --------------------------------------------------------
821 // E_Policy_Wl_Tzsh_Client
822 // --------------------------------------------------------
824 _e_policy_wl_tzsh_client_cb_client_zone_set(void *data, int type EINA_UNUSED, void *event)
826 E_Policy_Wl_Tzsh_Client *tzsh_client;
827 E_Event_Client_Zone_Set *ev;
832 if (tzsh_client->ec != ev->ec)
835 if (tzsh_client->zone == ev->zone)
838 ELOGF("TZSH", "Change Zone | e_policy_wl_tzsh_client %p old(%p) new(%p)",
839 tzsh_client->ec, tzsh_client, tzsh_client->zone, ev->zone);
841 tzsh_client->zone = ev->zone;
844 return ECORE_CALLBACK_PASS_ON;
847 static E_Policy_Wl_Tzsh_Client *
848 _e_policy_wl_tzsh_client_add(E_Policy_Wl_Tzsh *tzsh, struct wl_resource *res_tzsh_client, E_Pixmap *ep, E_Client *ec)
850 E_Policy_Wl_Tzsh_Client *tzsh_client;
852 tzsh_client = E_NEW(E_Policy_Wl_Tzsh_Client, 1);
853 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client, NULL);
855 tzsh_client->tzsh = tzsh;
856 tzsh_client->res_tzsh_client = res_tzsh_client;
857 tzsh_client->ep = ep;
858 tzsh_client->ec = ec;
859 tzsh_client->zone = e_comp_zone_find_by_ec(ec);
860 tzsh_client->tzsh->client_list = eina_list_append(tzsh_client->tzsh->client_list, tzsh_client);
862 polwl->tzsh_clients = eina_list_append(polwl->tzsh_clients, tzsh_client);
864 E_LIST_HANDLER_APPEND(tzsh_client->events, E_EVENT_CLIENT_ZONE_SET, _e_policy_wl_tzsh_client_cb_client_zone_set, tzsh_client);
867 _print_tzsh_client_info();
874 _e_policy_wl_tzsh_client_del(E_Policy_Wl_Tzsh_Client *tzsh_client)
876 if (!tzsh_client) return;
878 E_FREE_LIST(tzsh_client->events, ecore_event_handler_del);
880 if (tzsh_client->tzsh)
881 tzsh_client->tzsh->service_list = eina_list_remove(tzsh_client->tzsh->service_list, tzsh_client);
883 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
886 polwl->tzsh_clients = eina_list_remove(polwl->tzsh_clients, tzsh_client);
888 _print_tzsh_client_info();
891 if (tzsh_client->res_tzsh_client)
892 wl_resource_set_user_data(tzsh_client->res_tzsh_client, NULL);
894 memset(tzsh_client, 0x0, sizeof(E_Policy_Wl_Tzsh_Client));
898 static E_Policy_Wl_Tzsh_Extension*
899 _e_policy_wl_tzsh_extension_get(const char *name)
901 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
904 EINA_LIST_FOREACH(polwl->tzsh_extensions, l, tzsh_ext)
906 if (strcmp(tzsh_ext->name, name)) continue;
915 // --------------------------------------------------------
916 // E_Policy_Wl_Surface
917 // --------------------------------------------------------
918 static E_Policy_Wl_Surface *
919 _e_policy_wl_surf_add(E_Client *ec, struct wl_resource *res_tzpol)
921 E_Comp_Wl_Client_Data *cdata;
922 E_Policy_Wl_Surface *psurf = NULL;
923 E_Policy_Wl_Tzpol *tzpol;
925 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
926 EINA_SAFETY_ON_NULL_RETURN_VAL(tzpol, NULL);
928 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
929 if (psurf) return psurf;
931 psurf = E_NEW(E_Policy_Wl_Surface, 1);
932 EINA_SAFETY_ON_NULL_RETURN_VAL(psurf, NULL);
934 psurf->tzpol = tzpol;
935 psurf->cp = ec->pixmap;
937 psurf->pid = ec->netwm.pid;
939 cdata = e_client_cdata_get(ec);
940 if (wl_resource_get_client(cdata->surface) == wl_resource_get_client(res_tzpol))
941 psurf->surf = cdata->surface;
943 tzpol->psurfs = eina_list_append(tzpol->psurfs, psurf);
946 _e_policy_wl_background_state_set(psurf, EINA_TRUE);
952 _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf)
954 eina_list_free(psurf->vislist);
955 eina_list_free(psurf->poslist);
957 memset(psurf, 0x0, sizeof(E_Policy_Wl_Surface));
962 _e_policy_wl_surf_client_set(E_Client *ec)
964 E_Policy_Wl_Tzpol *tzpol;
965 E_Policy_Wl_Surface *psurf;
968 it = eina_hash_iterator_data_new(polwl->tzpols);
969 EINA_ITERATOR_FOREACH(it, tzpol)
971 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
974 if ((psurf->ec) && (psurf->ec != ec))
977 "CRI ERR!!|s:%8p|tzpol:%8p|ps:%8p|new_ec:%8p|new_cp:%8p",
989 eina_iterator_free(it);
995 _e_policy_wl_e_pixmap_get_from_id(struct wl_client *client, uint32_t id)
999 struct wl_resource *res_surf;
1001 res_surf = wl_client_get_object(client, id);
1004 ERR("Could not get surface resource");
1008 ec = e_client_from_surface_resource(res_surf);
1011 ERR("Could not get surface's user data");
1015 /* check E_Pixmap */
1016 cp = e_pixmap_find(E_PIXMAP_TYPE_WL, (uintptr_t)res_surf);
1017 if (cp != ec->pixmap)
1020 "CRI ERR!!|cp2:%8p|ec2:%8p|res_surf:%8p",
1023 e_pixmap_client_get(cp),
1032 _e_policy_wl_e_client_is_valid(E_Client *ec)
1036 Eina_Bool del = EINA_FALSE;
1037 Eina_Bool found = EINA_FALSE;
1039 EINA_LIST_FOREACH(e_comp->clients, l, ec2)
1043 if (e_object_is_del(E_OBJECT(ec2)))
1050 return ((!del) && (found));
1054 _e_policy_wl_e_clients_find_by_pid(pid_t pid)
1057 Eina_List *clients = NULL, *l;
1059 EINA_LIST_FOREACH(e_comp->clients, l, ec)
1061 if (e_object_is_del(E_OBJECT(ec))) continue;
1062 if (ec->netwm.pid != pid) continue;
1063 clients = eina_list_append(clients, ec);
1069 // --------------------------------------------------------
1071 // --------------------------------------------------------
1073 _tzvis_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzvis)
1075 wl_resource_destroy(res_tzvis);
1078 static const struct tizen_visibility_interface _tzvis_iface =
1080 _tzvis_iface_cb_destroy
1084 _tzvis_iface_cb_vis_destroy(struct wl_resource *res_tzvis)
1086 E_Policy_Wl_Surface *psurf;
1089 psurf = wl_resource_get_user_data(res_tzvis);
1090 EINA_SAFETY_ON_NULL_RETURN(psurf);
1092 r = _e_policy_wl_surf_is_valid(psurf);
1095 psurf->vislist = eina_list_remove(psurf->vislist, res_tzvis);
1099 _tzpol_iface_cb_vis_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
1102 E_Policy_Wl_Surface *psurf;
1103 struct wl_resource *res_tzvis;
1105 ec = e_client_from_surface_resource(surf);
1106 EINA_SAFETY_ON_NULL_RETURN(ec);
1108 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
1109 EINA_SAFETY_ON_NULL_RETURN(psurf);
1111 res_tzvis = wl_resource_create(client,
1112 &tizen_visibility_interface,
1113 wl_resource_get_version(res_tzpol),
1117 wl_client_post_no_memory(client);
1121 wl_resource_set_implementation(res_tzvis,
1124 _tzvis_iface_cb_vis_destroy);
1126 psurf->vislist = eina_list_append(psurf->vislist, res_tzvis);
1128 if (eina_list_data_find(polwl->pending_vis, ec))
1130 e_policy_wl_visibility_send(ec, ec->visibility.obscured);
1135 e_policy_wl_visibility_send(E_Client *ec, int vis)
1137 E_Comp_Wl_Client_Data *cdata;
1138 E_Policy_Wl_Tzpol *tzpol;
1139 E_Policy_Wl_Surface *psurf;
1140 struct wl_resource *res_tzvis;
1145 Eina_Bool sent = EINA_FALSE;
1147 int sent_vis = E_VISIBILITY_UNKNOWN;
1149 EINA_SAFETY_ON_TRUE_RETURN(vis == E_VISIBILITY_UNKNOWN);
1150 if (ec && (ec->visibility.last_sent_type == vis))
1153 win = e_client_util_win_get(ec);
1155 it = eina_hash_iterator_data_new(polwl->tzpols);
1156 EINA_ITERATOR_FOREACH(it, tzpol)
1157 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1159 ec2 = e_pixmap_client_get(psurf->cp);
1160 if (ec2 != ec) continue;
1162 EINA_LIST_FOREACH(psurf->vislist, ll, res_tzvis)
1164 // below code is workaround for checking visibility by display off or not
1165 if (e_comp_client_zone_is_displaying(ec))
1166 e_policy_aux_message_send(ec, "dpms_wm", "on", NULL);
1168 e_policy_aux_message_send(ec, "dpms_wm", "off", NULL);
1170 ver = wl_resource_get_version(res_tzvis);
1173 if (vis == E_VISIBILITY_PRE_UNOBSCURED)
1177 ec->visibility.last_sent_type = vis;
1178 tizen_visibility_send_changed(res_tzvis, vis, 0);
1185 if ((vis >= E_VISIBILITY_UNOBSCURED) && (vis <= E_VISIBILITY_FULLY_OBSCURED))
1187 ec->visibility.last_sent_type = vis;
1188 tizen_visibility_send_notify(res_tzvis, vis);
1194 cdata = e_client_cdata_get(ec);
1195 if (cdata && cdata->mapped)
1197 _launch_effect_hide(ec->netwm.pid);
1201 "SEND |win:0x%08zx|res_tzvis:%8p|ver:%d|sent_vis:%d|pid:%d|cdata:%8p|title:%s, name:%s",
1207 ec->netwm.pid, cdata, ec->icccm.title, ec->netwm.name);
1211 eina_iterator_free(it);
1213 polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
1215 polwl->pending_vis = eina_list_append(polwl->pending_vis, ec);
1219 e_policy_wl_iconify_state_supported_get(E_Client *ec)
1221 E_Policy_Wl_Tzpol *tzpol;
1222 E_Policy_Wl_Surface *psurf;
1226 Eina_Bool found = EINA_FALSE;
1228 it = eina_hash_iterator_data_new(polwl->tzpols);
1229 EINA_ITERATOR_FOREACH(it, tzpol)
1230 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1232 ec2 = e_pixmap_client_get(psurf->cp);
1239 eina_iterator_free(it);
1245 e_policy_wl_iconify_state_change_send(E_Client *ec, int iconic)
1247 E_Policy_Wl_Tzpol *tzpol;
1248 E_Policy_Wl_Surface *psurf;
1253 if (ec->exp_iconify.skip_iconify) return;
1254 if (ec->exp_iconify.skip_by_remote) return;
1256 if (e_config->transient.iconify)
1258 E_Comp_Wl_Client_Data *cdata;
1260 Eina_List *list = eina_list_clone(ec->transients);
1262 EINA_LIST_FREE(list, child)
1264 cdata = e_client_cdata_get(child);
1265 if (cdata && !cdata->mapped) continue;
1267 if ((child->iconic == ec->iconic) &&
1268 (e_client_is_iconified_by_client(child) == e_client_is_iconified_by_client(ec)))
1269 e_policy_wl_iconify_state_change_send(child, iconic);
1274 it = eina_hash_iterator_data_new(polwl->tzpols);
1275 EINA_ITERATOR_FOREACH(it, tzpol)
1276 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1278 ec2 = e_pixmap_client_get(psurf->cp);
1279 if (ec2 != ec) continue;
1280 if (!psurf->surf) continue;
1282 tizen_policy_send_iconify_state_changed(tzpol->res_tzpol, psurf->surf, iconic, 1);
1284 "SEND |iconic:%d |argb:%d |sur:%p",
1286 iconic, ec->argb, psurf->surf);
1287 ec->exp_iconify.last_sent_iconic = iconic;
1290 eina_iterator_free(it);
1293 // --------------------------------------------------------
1295 // --------------------------------------------------------
1297 _tzpos_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpos)
1299 wl_resource_destroy(res_tzpos);
1303 _tzpos_iface_cb_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpos, int32_t x, int32_t y)
1306 E_Policy_Wl_Surface *psurf;
1308 psurf = wl_resource_get_user_data(res_tzpos);
1309 EINA_SAFETY_ON_NULL_RETURN(psurf);
1311 ec = e_pixmap_client_get(psurf->cp);
1312 EINA_SAFETY_ON_NULL_RETURN(ec);
1313 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1315 if (e_policy_client_is_keyboard(ec))
1317 ELOGF("TZPOL", "Keyboard pos set (%d, %d). No operation. return.", ec, x, y);
1321 if (!ec->lock_client_location)
1323 if (e_client_pending_geometry_has(ec))
1325 // if there is geometry pending list, add move job at the end of the list.
1326 // so client to be applied new position at the same time with the pending requests
1327 // pending geometries are flushed when 'wl surface commit' and matched serial are delivered.
1329 e_client_pending_geometry_last_geometry_get(ec, NULL, NULL, &w, &h);
1330 e_comp_wl_commit_sync_client_geometry_add(ec, ec->surface_sync.serial, x, y, w, h);
1334 ec->client.x = ec->desk->geom.x + x;
1335 ec->client.y = ec->desk->geom.y + y;
1336 e_client_pos_set(ec, ec->client.x, ec->client.y);
1338 ec->changes.pos = 1;
1340 ec->changes.tz_position = 1;
1344 e_policy_hook_call(E_POLICY_HOOK_CLIENT_POSITION_SET, ec);
1347 static const struct tizen_position_interface _tzpos_iface =
1349 _tzpos_iface_cb_destroy,
1350 _tzpos_iface_cb_set,
1354 _tzpol_iface_cb_pos_destroy(struct wl_resource *res_tzpos)
1356 E_Policy_Wl_Surface *psurf;
1359 psurf = wl_resource_get_user_data(res_tzpos);
1360 EINA_SAFETY_ON_NULL_RETURN(psurf);
1362 r = _e_policy_wl_surf_is_valid(psurf);
1365 psurf->poslist = eina_list_remove(psurf->poslist, res_tzpos);
1369 _tzpol_iface_cb_pos_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
1372 E_Policy_Wl_Surface *psurf;
1373 struct wl_resource *res_tzpos;
1375 ec = e_client_from_surface_resource(surf);
1376 EINA_SAFETY_ON_NULL_RETURN(ec);
1378 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
1379 EINA_SAFETY_ON_NULL_RETURN(psurf);
1381 res_tzpos = wl_resource_create(client,
1382 &tizen_position_interface,
1383 wl_resource_get_version(res_tzpol),
1387 wl_client_post_no_memory(client);
1391 wl_resource_set_implementation(res_tzpos,
1394 _tzpol_iface_cb_pos_destroy);
1396 psurf->poslist = eina_list_append(psurf->poslist, res_tzpos);
1398 // if ec's pos is not same to client's geometry (ec->comp_data->shell.window),
1399 // then send tizen_position changed event
1402 if ((ec->x != ec->comp_data->shell.window.x) ||
1403 (ec->y != ec->comp_data->shell.window.y))
1404 e_policy_wl_position_send(ec);
1409 e_policy_wl_position_send(E_Client *ec)
1411 E_Policy_Wl_Tzpol *tzpol;
1412 E_Policy_Wl_Surface *psurf;
1413 struct wl_resource *res_tzpos;
1418 EINA_SAFETY_ON_NULL_RETURN(ec);
1420 win = e_client_util_win_get(ec);
1422 it = eina_hash_iterator_data_new(polwl->tzpols);
1423 EINA_ITERATOR_FOREACH(it, tzpol)
1424 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1426 if (e_pixmap_client_get(psurf->cp) != ec) continue;
1428 EINA_LIST_FOREACH(psurf->poslist, ll, res_tzpos)
1430 tizen_position_send_changed(res_tzpos, ec->client.x, ec->client.y);
1432 "SEND |win:0x%08zx|res_tzpos:%8p|ec->x:%d, ec->y:%d, ec->client.x:%d, ec->client.y:%d",
1437 ec->client.x, ec->client.y);
1440 eina_iterator_free(it);
1443 // --------------------------------------------------------
1444 // stack: activate, raise, lower
1445 // --------------------------------------------------------
1448 e_policy_wl_activate(E_Client *ec)
1450 EINA_SAFETY_ON_NULL_RETURN(ec);
1451 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1453 ELOGF("TZPOL", "REAL ACTIVATE", ec);
1455 e_policy_visibility_client_lower_job_cancel(ec);
1457 if ((!starting) && (!ec->focused))
1459 if (!e_policy_visibility_client_activate(ec))
1461 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1462 e_policy_wl_iconify_state_change_send(ec, 0);
1464 if (!ec->visibility.force_obscured)
1465 e_client_activate(ec);
1470 if (!ec->lock_user_stacking)
1474 if (e_policy_client_is_lockscreen(ec))
1475 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
1477 e_policy_stack_check_above_lockscreen(ec, ec->layer);
1481 _tzpol_iface_cb_activate(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1484 E_Comp_Wl_Client_Data *cdata;
1486 ec = e_client_from_surface_resource(surf);
1487 EINA_SAFETY_ON_NULL_RETURN(ec);
1488 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1490 ELOGF("TZPOL", "ACTIVATE", ec);
1493 e_policy_stack_transient_child_raise(ec);
1495 e_policy_hook_call(E_POLICY_HOOK_CLIENT_ACTIVE_REQ, ec);
1497 ec->post_lower = EINA_FALSE;
1498 cdata = e_client_cdata_get(ec);
1499 if (cdata && !cdata->mapped)
1501 if (e_config->raise_before_show)
1504 ec->post_raise = EINA_TRUE;
1506 e_policy_wl_activate(ec);
1510 e_policy_wl_stack_changed_send(E_Client *ec)
1512 E_Client *above = NULL;
1513 E_Client *below = NULL;
1517 above = e_client_above_get(ec);
1520 if ((!e_object_is_del(E_OBJECT(above))) &&
1521 (!e_client_util_ignored_get(above)) &&
1526 above = e_client_above_get(above);
1529 below = e_client_below_get(ec);
1532 if ((!e_object_is_del(E_OBJECT(below))) &&
1533 (!e_client_util_ignored_get(below)) &&
1538 below = e_client_below_get(below);
1541 if (above) above_pid = above->netwm.pid;
1542 if (below) below_pid = below->netwm.pid;
1544 ELOGF("TZPOL", "Send stack_changed by activate_below. above(win:%zx, pid:%d), below(win:%zx, pid:%d)",
1545 ec, e_client_util_win_get(above), above_pid, e_client_util_win_get(below), below_pid);
1548 e_policy_aux_message_send_from_int(ec, "stack_changed", "activate_below", 2, above_pid, below_pid);
1553 _tzpol_iface_cb_activate_below_by_res_id(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t res_id, uint32_t below_res_id)
1555 E_Client *ec = NULL;
1556 E_Client *below_ec = NULL;
1557 E_Client *parent_ec = NULL;
1558 E_Client *focus_ec = NULL;
1559 E_Comp_Wl_Client_Data *cdata;
1560 Eina_Bool check_ancestor = EINA_FALSE;
1561 Eina_Bool intercepted = EINA_FALSE;
1563 ec = e_pixmap_find_client_by_res_id(res_id);
1564 EINA_SAFETY_ON_NULL_RETURN(ec);
1565 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1567 below_ec = e_pixmap_find_client_by_res_id(below_res_id);
1568 EINA_SAFETY_ON_NULL_RETURN(below_ec);
1569 EINA_SAFETY_ON_NULL_RETURN(below_ec->frame);
1572 "ACTIVATE_BELOW|win:0x%08zx(res_id:%d)|below_win:0x%08zx(res_id:%d)",
1573 NULL, e_client_util_win_get(ec), res_id, e_client_util_win_get(below_ec), below_res_id);
1575 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_ACTIVATE_BELOW,
1579 ELOGF("TZPOL", "ACTIVATE_BELOW|Handled by Intercept function", ec);
1583 if (ec->layer > below_ec->layer) return;
1585 parent_ec = ec->parent;
1588 if (parent_ec == below_ec)
1590 check_ancestor = EINA_TRUE;
1593 parent_ec = parent_ec->parent;
1595 if (check_ancestor) return;
1597 if ((!starting) && (!ec->focused))
1599 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1600 e_policy_wl_iconify_state_change_send(ec, 0);
1602 e_client_uniconify(ec);
1605 e_policy_stack_below(ec, below_ec);
1607 cdata = e_client_cdata_get(ec);
1608 if (cdata && !cdata->mapped)
1610 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1611 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1614 e_policy_wl_stack_changed_send(ec);
1617 focus_ec = e_client_focused_get();
1618 if (focus_ec == below_ec)
1619 e_client_focus_latest_set(ec);
1623 _tzpol_iface_cb_activate_above_by_res_id(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t res_id, uint32_t above_res_id)
1625 E_Client *ec = NULL;
1626 E_Comp_Wl_Client_Data *cdata;
1627 E_Client *above_ec = NULL;
1628 E_Client *parent_ec = NULL;
1629 Eina_Bool check_ancestor = EINA_FALSE;
1630 Eina_Bool intercepted = EINA_FALSE;
1632 ec = e_pixmap_find_client_by_res_id(res_id);
1633 EINA_SAFETY_ON_NULL_RETURN(ec);
1634 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1636 above_ec = e_pixmap_find_client_by_res_id(above_res_id);
1637 EINA_SAFETY_ON_NULL_RETURN(above_ec);
1638 EINA_SAFETY_ON_NULL_RETURN(above_ec->frame);
1641 "ACTIVATE_ABOVE|win:0x%08zx(res_id:%d)|above_win:0x%08zx(res_id:%d)",
1642 NULL, e_client_util_win_get(ec), res_id, e_client_util_win_get(above_ec), above_res_id);
1644 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_ACTIVATE_ABOVE,
1648 ELOGF("TZPOL", "ACTIVATE_ABOVE|Handled by Intercept function", ec);
1652 if (ec->layer < above_ec->layer) return;
1655 parent_ec = above_ec->parent;
1658 if (parent_ec == ec)
1660 check_ancestor = EINA_TRUE;
1663 parent_ec = parent_ec->parent;
1665 if (check_ancestor) return;
1667 if (ec->parent && (ec->parent == above_ec))
1669 if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
1671 ELOGF("TZPOL", "ACTIVATE_ABOVE|Denied. Above is transient_below parent", ec);
1678 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1679 e_policy_wl_iconify_state_change_send(ec, 0);
1681 e_client_uniconify(ec);
1684 e_policy_stack_above(ec, above_ec);
1686 cdata = e_client_cdata_get(ec);
1687 if (cdata && !cdata->mapped)
1689 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1690 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1695 _tzpol_iface_cb_raise(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1698 E_Comp_Wl_Client_Data *cdata;
1700 ec = e_client_from_surface_resource(surf);
1701 EINA_SAFETY_ON_NULL_RETURN(ec);
1702 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1704 ELOGF("TZPOL", "RAISE", ec);
1707 e_policy_stack_transient_child_raise(ec);
1709 e_policy_hook_call(E_POLICY_HOOK_CLIENT_RAISE_REQ, ec);
1713 cdata = e_client_cdata_get(ec);
1714 if (cdata && !cdata->mapped)
1716 if (e_config->raise_before_show)
1718 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1719 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1723 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_TRUE, EINA_FALSE);
1724 e_client_post_raise_lower_set(ec, EINA_TRUE, EINA_FALSE);
1728 e_policy_hook_call(E_POLICY_HOOK_CLIENT_RAISE_REQ_DONE, ec);
1732 _tzpol_iface_cb_lower(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1734 E_Client *ec = NULL;
1735 E_Comp_Wl_Client_Data *cdata;
1737 ec = e_client_from_surface_resource(surf);
1738 EINA_SAFETY_ON_NULL_RETURN(ec);
1739 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1741 ELOGF("TZPOL", "LOWER", ec);
1744 e_policy_stack_transient_child_lower(ec);
1746 e_policy_hook_call(E_POLICY_HOOK_CLIENT_LOWER_REQ, ec);
1748 if (e_policy_visibility_client_lower(ec))
1751 cdata = e_client_cdata_get(ec);
1752 if (cdata && !cdata->mapped)
1754 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_TRUE);
1755 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_TRUE);
1760 #ifdef REFACTOR_FOCUS_POLICY
1761 // This code is executed at E_CLIENT_HOOK_LOWER callback
1762 // at e_focus_policy_topmost.c and at e_focus_policy_history.c
1766 if (!e_config->calc_vis_without_effect)
1767 e_client_revert_focus(ec);
1773 _tzpol_iface_cb_lower_by_res_id(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t res_id)
1775 E_Client *ec = NULL;
1776 E_Comp_Wl_Client_Data *cdata;
1778 ec = e_pixmap_find_client_by_res_id(res_id);
1779 EINA_SAFETY_ON_NULL_RETURN(ec);
1780 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1782 ELOGF("TZPOL", "LOWER by res id:%d", ec, res_id);
1785 e_policy_stack_transient_child_lower(ec);
1789 cdata = e_client_cdata_get(ec);
1790 if (cdata && !cdata->mapped)
1792 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_TRUE);
1793 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_TRUE);
1797 // --------------------------------------------------------
1799 // --------------------------------------------------------
1801 _tzpol_iface_cb_focus_skip_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1805 ec = e_client_from_surface_resource(surf);
1806 EINA_SAFETY_ON_NULL_RETURN(ec);
1808 e_client_focus_skip_set(ec, EINA_TRUE, EINA_TRUE);
1812 _tzpol_iface_cb_focus_skip_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1816 ec = e_client_from_surface_resource(surf);
1817 EINA_SAFETY_ON_NULL_RETURN(ec);
1819 e_client_focus_skip_set(ec, EINA_FALSE, EINA_TRUE);
1822 // --------------------------------------------------------
1824 // --------------------------------------------------------
1826 _tzpol_iface_cb_role_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf, const char *role)
1829 E_Comp_Wl_Client_Data *cdata;
1831 EINA_SAFETY_ON_NULL_RETURN(role);
1833 ec = e_client_from_surface_resource(surf);
1834 EINA_SAFETY_ON_NULL_RETURN(ec);
1835 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1837 ELOGF("TZPOL", "ROLE SET (role:%s)", ec, role);
1838 e_client_window_role_set(ec, role);
1840 /* TODO: support multiple roles */
1841 if (!e_util_strcmp("tv-volume-popup", role))
1843 e_client_layer_set(ec, E_LAYER_CLIENT_NOTIFICATION_LOW);
1844 ec->lock_client_location = 1;
1846 else if (!e_util_strcmp("e_demo", role))
1848 e_client_layer_set(ec, E_LAYER_CLIENT_NOTIFICATION_HIGH);
1849 ec->lock_client_location = 1;
1851 else if (!e_util_strcmp("cbhm", role))
1853 cdata = e_client_cdata_get(ec);
1855 e_comp_wl->selection.cbhm = cdata->surface;
1857 else if (!e_util_strcmp("wl_pointer-cursor", role))
1859 ELOGF("TZPOL", "Set CURSOR role", ec);
1860 e_client_layer_set(ec, E_LAYER_CLIENT_CURSOR);
1861 ec->is_cursor = EINA_TRUE;
1862 e_client_desk_iconify_skip_set(ec, EINA_TRUE);
1867 _tzpol_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t type)
1870 E_Window_Type win_type;
1872 ec = e_client_from_surface_resource(surf);
1873 EINA_SAFETY_ON_NULL_RETURN(ec);
1877 /* TODO: support other types */
1878 case TIZEN_POLICY_WIN_TYPE_TOPLEVEL:
1879 win_type = E_WINDOW_TYPE_NORMAL;
1880 if (ec->layer != E_LAYER_CLIENT_NORMAL)
1882 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
1886 case TIZEN_POLICY_WIN_TYPE_NOTIFICATION:
1887 win_type = E_WINDOW_TYPE_NOTIFICATION;
1890 case TIZEN_POLICY_WIN_TYPE_UTILITY:
1891 win_type = E_WINDOW_TYPE_UTILITY;
1894 case TIZEN_POLICY_WIN_TYPE_DIALOG:
1895 win_type = E_WINDOW_TYPE_DIALOG;
1898 case TIZEN_POLICY_WIN_TYPE_DESKTOP:
1899 win_type = E_WINDOW_TYPE_DESKTOP;
1900 e_client_desk_iconify_skip_set(ec, EINA_TRUE);
1901 if (ec->layer != E_LAYER_CLIENT_DESKTOP)
1903 e_client_layer_set(ec, E_LAYER_CLIENT_DESKTOP);
1911 "TYPE_SET |win:0x%08zx|s:%8p|res_tzpol:%8p|tizen_win_type:%d, e_win_type:%d",
1913 e_client_util_win_get(ec),
1918 ec->netwm.type = win_type;
1922 // --------------------------------------------------------
1924 // --------------------------------------------------------
1926 _tzpol_iface_cb_conformant_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
1930 ec = e_client_from_surface_resource(surf);
1931 EINA_SAFETY_ON_NULL_RETURN(ec);
1933 e_policy_conformant_client_add(ec, res_tzpol);
1937 _tzpol_iface_cb_conformant_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1941 ec = e_client_from_surface_resource(surf);
1942 EINA_SAFETY_ON_NULL_RETURN(ec);
1944 e_policy_conformant_client_del(ec);
1948 _tzpol_iface_cb_conformant_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
1952 ec = e_client_from_surface_resource(surf);
1953 EINA_SAFETY_ON_NULL_RETURN(ec);
1955 tizen_policy_send_conformant(res_tzpol, surf, e_policy_conformant_client_check(ec));
1958 // --------------------------------------------------------
1959 // notification level
1960 // --------------------------------------------------------
1962 _tzpol_notilv_set(E_Client *ec, int lv)
1969 case 0: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
1970 case 1: ly = E_LAYER_CLIENT_NOTIFICATION_NORMAL; break;
1971 case 2: ly = E_LAYER_CLIENT_NOTIFICATION_TOP; break;
1972 case -1: ly = E_LAYER_CLIENT_NORMAL; break;
1973 case 10: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
1974 case 20: ly = E_LAYER_CLIENT_NOTIFICATION_NORMAL; break;
1975 case 30: ly = E_LAYER_CLIENT_NOTIFICATION_HIGH; break;
1976 case 40: ly = E_LAYER_CLIENT_NOTIFICATION_TOP; break;
1977 default: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
1980 if (e_config->use_desk_area)
1981 cur_ly = e_client_desk_area_original_layer_get(ec);
1983 cur_ly = e_client_layer_get(ec);
1987 if (ly == E_LAYER_CLIENT_NORMAL)
1988 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_LAYER, 0);
1990 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_LAYER, 1);
1992 e_client_layer_set(ec, ly);
1994 e_policy_hook_call(E_POLICY_HOOK_CLIENT_NOTILAYER_SET, ec);
1998 _tzpol_iface_cb_notilv_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t lv)
2001 E_Policy_Wl_Surface *psurf;
2006 ec = e_client_from_surface_resource(surf);
2007 EINA_SAFETY_ON_NULL_RETURN(ec);
2009 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
2010 EINA_SAFETY_ON_NULL_RETURN(psurf);
2012 wl_client_get_credentials(client, &pid, &uid, NULL);
2013 res = e_security_privilege_check(pid, uid,
2014 E_PRIVILEGE_NOTIFICATION_LEVEL_SET);
2018 "Privilege Check Failed! DENY set_notification_level",
2021 tizen_policy_send_notification_done
2025 TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
2029 ELOGF("TZPOL", "NOTI_LEVEL|level:%d", ec, lv);
2030 _tzpol_notilv_set(ec, lv);
2034 tizen_policy_send_notification_done
2035 (res_tzpol, surf, lv, TIZEN_POLICY_ERROR_STATE_NONE);
2037 if (e_policy_client_is_lockscreen(ec))
2038 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
2040 e_policy_stack_check_above_lockscreen(ec, ec->layer);
2044 e_policy_wl_notification_level_fetch(E_Client *ec)
2047 E_Policy_Wl_Surface *psurf;
2048 E_Policy_Wl_Tzpol *tzpol;
2051 Eina_Bool changed_stack = EINA_FALSE;
2053 EINA_SAFETY_ON_NULL_RETURN(ec);
2056 EINA_SAFETY_ON_NULL_RETURN(cp);
2058 // TODO: use pending_notilv_list instead of loop
2059 it = eina_hash_iterator_data_new(polwl->tzpols);
2060 EINA_ITERATOR_FOREACH(it, tzpol)
2061 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
2063 if (psurf->cp != cp) continue;
2064 if (!psurf->pending_notilv) continue;
2066 psurf->pending_notilv = EINA_FALSE;
2067 _tzpol_notilv_set(ec, psurf->notilv);
2068 changed_stack = EINA_TRUE;
2070 eina_iterator_free(it);
2072 if (changed_stack && e_policy_client_is_lockscreen(ec))
2073 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
2076 // --------------------------------------------------------
2078 // --------------------------------------------------------
2080 _tzpol_iface_cb_transient_for_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t child_id, uint32_t parent_id)
2082 E_Client *ec, *parent_ec;
2083 E_Comp_Wl_Client_Data *cdata, *p_cdata;
2086 "TF_SET |res_tzpol:%8p|parent_id:%8d |child_id:%8d",
2087 NULL, res_tzpol, parent_id, child_id);
2089 ec = e_pixmap_find_client_by_res_id(child_id);
2090 EINA_SAFETY_ON_NULL_RETURN(ec);
2091 cdata = e_client_cdata_get(ec);
2093 parent_ec = e_pixmap_find_client_by_res_id(parent_id);
2094 EINA_SAFETY_ON_NULL_RETURN(parent_ec);
2095 p_cdata = e_client_cdata_get(parent_ec);
2098 " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
2099 NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL));
2101 e_policy_stack_transient_for_set(ec, parent_ec);
2102 tizen_policy_send_transient_for_done(res_tzpol, child_id);
2106 _tzpol_iface_cb_transient_for_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t child_id)
2111 "TF_UNSET |res_tzpol:%8p|child:%d",
2112 NULL, res_tzpol, child_id);
2114 ec = e_pixmap_find_client_by_res_id(child_id);
2115 EINA_SAFETY_ON_NULL_RETURN(ec);
2117 e_policy_stack_transient_for_set(ec, NULL);
2118 tizen_policy_send_transient_for_done(res_tzpol, child_id);
2121 // --------------------------------------------------------
2122 // window screen mode
2123 // --------------------------------------------------------
2125 _tzpol_iface_cb_win_scrmode_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
2132 ec = e_client_from_surface_resource(surf);
2133 EINA_SAFETY_ON_NULL_RETURN(ec);
2135 wl_client_get_credentials(client, &pid, &uid, NULL);
2136 res = e_security_privilege_check(pid, uid,
2137 E_PRIVILEGE_SCREEN_MODE_SET);
2141 "Privilege Check Failed! DENY set_screen_mode",
2144 tizen_policy_send_window_screen_mode_done
2148 TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
2152 ELOGF("TZPOL", "SCR_MODE |mode:%d", ec, mode);
2154 e_policy_display_screen_mode_set(ec, mode);
2155 e_policy_wl_win_scrmode_apply();
2157 tizen_policy_send_window_screen_mode_done
2158 (res_tzpol, surf, mode, TIZEN_POLICY_ERROR_STATE_NONE);
2162 e_policy_wl_win_scrmode_apply(void)
2164 e_policy_display_screen_mode_apply();
2167 // --------------------------------------------------------
2169 // --------------------------------------------------------
2171 static const struct wl_subsurface_interface _tzpol_subsurface_fake_impl;
2174 _tzpol_iface_cb_subsurf_place_below_parent(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *subsurf)
2176 if (wl_resource_instance_of(subsurf, &wl_subsurface_interface, &_tzpol_subsurface_fake_impl))
2179 e_comp_wl_subsurface_resource_place_below_parent(subsurf);
2183 _tzpol_iface_cb_subsurf_stand_alone_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *subsurf)
2185 if (wl_resource_instance_of(subsurf, &wl_subsurface_interface, &_tzpol_subsurface_fake_impl))
2188 e_comp_wl_subsurface_resource_stand_alone_mode_set(subsurf);
2192 _tzpol_subsurface_fake_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
2194 wl_resource_destroy(resource);
2198 _tzpol_subsurface_fake_cb_position_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t x EINA_UNUSED, int32_t y EINA_UNUSED)
2203 _tzpol_subsurface_fake_cb_place_above(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *sibling_resource EINA_UNUSED)
2208 _tzpol_subsurface_fake_cb_place_below(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *sibling_resource EINA_UNUSED)
2213 _tzpol_subsurface_fake_cb_sync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
2218 _tzpol_subsurface_fake_cb_desync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
2222 static const struct wl_subsurface_interface _tzpol_subsurface_fake_impl =
2224 _tzpol_subsurface_fake_cb_destroy,
2225 _tzpol_subsurface_fake_cb_position_set,
2226 _tzpol_subsurface_fake_cb_place_above,
2227 _tzpol_subsurface_fake_cb_place_below,
2228 _tzpol_subsurface_fake_cb_sync_set,
2229 _tzpol_subsurface_fake_cb_desync_set,
2233 _tzpol_subsurface_add_with_fake_impl(struct wl_client *client, uint32_t id)
2235 struct wl_resource *resource;
2237 resource = wl_resource_create(client, &wl_subsurface_interface, 1, id);
2241 wl_resource_set_implementation(resource,
2242 &_tzpol_subsurface_fake_impl,
2249 _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface, uint32_t parent_id)
2252 E_Comp_Wl_Client_Data *cdata;
2256 "SUBSURF |wl_surface@%d|parent_id:%d",
2257 NULL, wl_resource_get_id(surface), parent_id);
2259 ec = e_client_from_surface_resource(surface);
2261 epc = e_pixmap_find_client_by_res_id(parent_id);
2263 (e_object_is_del(E_OBJECT(epc))))
2265 ELOGF("TZPOL", "SUBSURF | Invalid parent(%p). "
2266 "Create with fake implementation", ec, epc);
2267 cdata = e_client_cdata_get(ec);
2269 (cdata->sub.watcher))
2271 tizen_subsurface_watcher_send_message(cdata->sub.watcher,
2272 TIZEN_SUBSURFACE_WATCHER_MSG_PARENT_ID_INVALID);
2275 /* We have to create a subsurface resource here even though it's error case
2276 * because server will send the fatal error when a client destroy a subsurface object.
2277 * Otherwise, server will kill a client by the fatal error.
2279 if (!_tzpol_subsurface_add_with_fake_impl(client, id))
2280 wl_resource_post_no_memory(resource);
2285 /* This check code is for detecting an error case which tries to create
2286 * sub-surface relationship with invalid parent. */
2287 if ((!epc->comp_data) ||
2288 (!epc->comp_data->wl_surface))
2290 ELOGF("TZPOL", "Parent(%p internal? %s) doesn't have comp_data. "
2291 "Possibly it's not the surface created by client. "
2292 "Cannot be the parent of sub-surface.",
2293 ec, epc, epc->internal ? "TRUE" : "FALSE");
2294 wl_resource_post_error(resource,
2295 WL_SUBSURFACE_ERROR_BAD_SURFACE,
2296 "Invalid parent_id@%d. Possibly it's not the "
2297 "surface created by client.(internal? %s) "
2298 "Cannot be the parent of sub-surface.",
2299 parent_id, epc->internal ? "TRUE" : "FALSE");
2303 res = e_comp_wl_subsurface_add(resource, id, surface,
2304 epc->comp_data->wl_surface);
2307 ERR("Failed to add subsurface for surface@%d", wl_resource_get_id(surface));
2311 /* ec's parent comes from another process */
2312 cdata = e_client_cdata_get(ec);
2314 cdata->has_extern_parent = EINA_TRUE;
2318 _tzpol_iface_cb_opaque_state_set(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, int32_t state)
2322 ec = e_client_from_surface_resource(surface);
2323 EINA_SAFETY_ON_NULL_RETURN(ec);
2325 ELOGF("TZPOL", "OPAQUE |opaque_state:%d", ec, state);
2326 if(ec->visibility.opaque == state)
2328 ec->visibility.opaque = state;
2333 // --------------------------------------------------------
2335 // --------------------------------------------------------
2338 e_policy_wl_iconify(E_Client *ec)
2340 EINA_SAFETY_ON_NULL_RETURN(ec);
2341 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
2343 ELOGF("TZPOL", "Set ICONIFY BY CLIENT", ec);
2345 if (e_policy_visibility_client_iconify(ec))
2347 ec->exp_iconify.by_client = 1;
2348 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT);
2351 ec->exp_iconify.by_client = 1;
2352 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT);
2354 e_client_iconify(ec);
2360 e_policy_wl_uniconify(E_Client *ec)
2362 EINA_SAFETY_ON_NULL_RETURN(ec);
2363 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
2365 if (e_policy_visibility_client_uniconify(ec, 1))
2368 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
2369 e_policy_wl_iconify_state_change_send(ec, 0);
2371 if (ec->visibility.force_obscured)
2373 ec->exp_iconify.by_client = 0;
2374 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
2378 e_client_uniconify(ec);
2379 ELOGF("TZPOL", "Un-Set ICONIFY BY CLIENT", ec);
2380 ec->exp_iconify.by_client = 0;
2381 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
2387 _tzpol_iface_cb_iconify(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
2391 ec = e_client_from_surface_resource(surf);
2392 EINA_SAFETY_ON_NULL_RETURN(ec);
2394 ELOGF("TZPOL", "ICONIFY", ec);
2396 e_policy_hook_call(E_POLICY_HOOK_CLIENT_ICONIFY_REQ, ec);
2397 e_policy_wl_iconify(ec);
2401 _tzpol_iface_cb_uniconify(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
2405 ec = e_client_from_surface_resource(surf);
2406 EINA_SAFETY_ON_NULL_RETURN(ec);
2408 ELOGF("TZPOL", "UNICONIFY", ec);
2410 e_policy_hook_call(E_POLICY_HOOK_CLIENT_UNICONIFY_REQ, ec);
2411 e_policy_wl_uniconify(ec);
2415 _e_policy_wl_allowed_aux_hint_send(struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
2419 ec = e_client_from_surface_resource(surf);
2420 EINA_SAFETY_ON_NULL_RETURN(ec);
2422 ELOGF("TZPOL", "SEND |res_tzpol:%8p|id:%d, hint allowed ", ec, res_tzpol, id);
2423 tizen_policy_send_allowed_aux_hint(res_tzpol, surf, id);
2427 _e_policy_wl_aux_hint_apply(E_Client *ec)
2429 E_Comp_Wl_Client_Data *cdata;
2430 E_Comp_Wl_Aux_Hint *hint;
2433 cdata = e_client_cdata_get(ec);
2435 if (!cdata->aux_hint.changed) return;
2437 EINA_LIST_FOREACH(cdata->aux_hint.hints, l, hint)
2439 if (!hint->changed) continue;
2442 if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_USER_GEOMETRY]))
2446 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_FALSE);
2450 if (!strcmp(hint->val, "1"))
2452 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_TRUE);
2454 else if (strcmp(hint->val, "1"))
2456 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_FALSE);
2459 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_FIXED_RESIZE]))
2461 /* TODO: support other aux_hints */
2463 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_DEICONIFY_UPDATE]))
2465 if (!strcmp(hint->val, "1"))
2466 ec->exp_iconify.deiconify_update = EINA_TRUE;
2468 ec->exp_iconify.deiconify_update = EINA_FALSE;
2471 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_GESTURE_DISABLE]))
2475 ec->gesture_disable = EINA_FALSE;
2479 if (atoi(hint->val) == 1)
2481 ec->gesture_disable = EINA_TRUE;
2485 ec->gesture_disable = EINA_FALSE;
2488 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ICONIFY]))
2492 ec->exp_iconify.skip_iconify = 0;
2497 if (!strcmp(hint->val, "disable"))
2499 ec->exp_iconify.skip_iconify = 1;
2502 else if (!strcmp(hint->val, "enable"))
2504 ec->exp_iconify.skip_iconify = 0;
2508 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ABOVE_LOCKSCREEN]))
2510 if ((hint->deleted) ||
2511 (!strcmp(hint->val, "0")))
2513 E_Layer original_layer = ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer;
2514 if (ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set &&
2515 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved)
2517 // restore original layer
2518 if (original_layer != evas_object_layer_get(ec->frame))
2520 Eina_Bool pend = EINA_FALSE;
2521 pend = e_policy_visibility_client_layer_lower(ec, original_layer);
2524 e_client_layer_set(ec, original_layer);
2528 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set = 0;
2529 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved = 0;
2530 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer = 0;
2533 else if (!strcmp(hint->val, "1"))
2535 if (!ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved)
2537 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set = 1;
2538 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved = 0;
2539 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer = ec->layer;
2544 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_EFFECT_DISABLE]))
2546 if ((hint->deleted) ||
2547 (!strcmp(hint->val, "0")))
2549 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_HINT, 0);
2551 else if (!strcmp(hint->val, "1"))
2553 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_HINT, 1);
2556 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_MSG_USE]))
2558 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2559 cdata->aux_hint.use_msg = EINA_FALSE;
2560 else if (!strcmp(hint->val, "1"))
2561 cdata->aux_hint.use_msg = EINA_TRUE;
2563 else if (!strcmp(hint->hint, hint_names[E_COMP_HINT_ALWAYS_SELECTIVE]))
2565 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2566 cdata->never_hwc = EINA_FALSE;
2567 else if (!strcmp(hint->val, "1"))
2568 cdata->never_hwc = EINA_TRUE;
2570 e_comp_render_queue();
2572 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_DEPENDENT_ROTATION]))
2574 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2575 ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_NORMAL;
2576 else if (!strcmp(hint->val, "1"))
2577 ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_DEPENDENT;
2579 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ROT_RENDER_NOPENDING]))
2581 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2583 ELOGF("ROTATION", "nopending render:0", ec);
2584 ec->e.state.rot.nopending_render = 0;
2586 else if (!strcmp(hint->val, "1"))
2588 ELOGF("ROTATION", "nopending render:1", ec);
2589 ec->e.state.rot.nopending_render = 1;
2592 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_ICONIFY_BUFFER_FLUSH], strlen(hint->hint)))
2594 if (!strncmp(hint->val, "1", 1))
2595 ec->exp_iconify.buffer_flush = EINA_TRUE;
2597 ec->exp_iconify.buffer_flush = EINA_FALSE;
2599 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP], strlen(hint->hint)))
2601 if (!strncmp(hint->val, "1", 1))
2603 ELOGF("TF_SET", "Transient for Always_on_top enabled", ec);
2604 ec->transient_for_always_on_top = EINA_TRUE;
2608 ELOGF("TF_SET", "Transient for Always_on_top disabled", ec);
2609 ec->transient_for_always_on_top = EINA_FALSE;
2612 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_BELONG_TO_PARENT], strlen(hint->hint)))
2614 if (!strncmp(hint->val, "1", 1))
2616 ELOGF("TF_SET", "Set belong_to_parent", ec);
2617 e_client_belong_to_parent_set(ec, EINA_TRUE);
2621 ELOGF("TF_SET", "Unset belong_to_parent", ec);
2622 e_client_belong_to_parent_set(ec, EINA_FALSE);
2625 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_ASPECT_RATIO], strlen(hint->hint)))
2627 if (!strncmp(hint->val, "1", 1))
2629 ELOGF("RESIZE", "Set resize aspect ratio.. ratio(%dx%d)", ec, ec->w, ec->h);
2630 ec->manage_resize.enable_aspect_ratio = EINA_TRUE;
2631 ec->manage_resize.aw = ec->w;
2632 ec->manage_resize.ah = ec->h;
2636 ELOGF("RESIZE", "Unset resize aspect ratio", ec);
2637 ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
2640 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_HEADER], strlen(hint->hint)))
2642 int height = atoi(hint->val);
2645 ELOGF("CSD", "Set decoration HEADER size.. size(%d)", ec, height);
2646 ec->manage_resize.header_h = height;
2650 ELOGF("CSD", "Unset decoration HEADER size", ec);
2651 ec->manage_resize.header_h = 0;
2654 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_FOOTER], strlen(hint->hint)))
2656 int height = atoi(hint->val);
2659 ELOGF("CSD", "Set decoration FOOTER size.. size(%d)", ec, height);
2660 ec->manage_resize.footer_h = height;
2664 ELOGF("CSD", "Unset decoration FOOTER size", ec);
2665 ec->manage_resize.footer_h = 0;
2668 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_VISIBILITY_IGNORE_GEOMETRY], strlen(hint->hint)))
2670 if (!strncmp(hint->val, "1", 1))
2672 ELOGF("POL_VIS", "Set ignore_geometry.. value(%s)", ec, hint->val);
2673 ec->visibility.ignore_geometry = EINA_TRUE;
2677 ELOGF("POL_VIS", "UNSet ignore_geometry.. value(%s)", ec, hint->val);
2678 ec->visibility.ignore_geometry = EINA_FALSE;
2681 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_PPU], strlen(hint->hint)))
2683 int ppu = atoi(hint->val);
2684 if (ppu < 1) ppu = 1;
2686 ELOGF("RESIZE", "Set resize unit. size:%d", ec, ppu);
2687 e_client_resize_unit_size_set(ec, ppu);
2689 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_TOP], strlen(hint->hint)))
2691 int size = atoi(hint->val);
2694 ELOGF("CSD", "Set decoration SHADOW top.. size(%d)", ec, size);
2695 ec->manage_resize.shadow.t = size;
2699 ELOGF("CSD", "Unset decoration SHADOW top", ec);
2700 ec->manage_resize.shadow.t = 0;
2703 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_BOTTOM], strlen(hint->hint)))
2705 int size = atoi(hint->val);
2708 ELOGF("CSD", "Set decoration SHADOW bottom.. size(%d)", ec, size);
2709 ec->manage_resize.shadow.b = size;
2713 ELOGF("CSD", "Unset decoration SHADOW bottom", ec);
2714 ec->manage_resize.shadow.b = 0;
2717 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_LEFT], strlen(hint->hint)))
2719 int size = atoi(hint->val);
2722 ELOGF("CSD", "Set decoration SHADOW left.. size(%d)", ec, size);
2723 ec->manage_resize.shadow.l = size;
2727 ELOGF("CSD", "Unset decoration SHADOW left", ec);
2728 ec->manage_resize.shadow.l = 0;
2731 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_RIGHT], strlen(hint->hint)))
2733 int size = atoi(hint->val);
2736 ELOGF("CSD", "Set decoration SHADOW right.. size(%d)", ec, size);
2737 ec->manage_resize.shadow.r = size;
2741 ELOGF("CSD", "Unset decoration SHADOW right", ec);
2742 ec->manage_resize.shadow.r = 0;
2747 e_policy_hook_call(E_POLICY_HOOK_CLIENT_AUX_HINT_CHANGED, ec);
2751 _tzpol_iface_cb_aux_hint_add(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id, const char *name, const char *value)
2754 Eina_Bool res = EINA_FALSE;
2756 ec = e_client_from_surface_resource(surf);
2757 EINA_SAFETY_ON_NULL_RETURN(ec);
2759 res = e_hints_aux_hint_add(ec, id, name, value);
2761 ELOGF("TZPOL", "HINT_ADD |res_tzpol:%8p|id:%d, name:%s, val:%s, res:%d", ec, res_tzpol, id, name, value, res);
2765 _e_policy_wl_aux_hint_apply(ec);
2766 _e_policy_wl_allowed_aux_hint_send(res_tzpol, surf, id);
2771 _tzpol_iface_cb_aux_hint_change(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id, const char *value)
2774 Eina_Bool res = EINA_FALSE;
2776 ec = e_client_from_surface_resource(surf);
2777 EINA_SAFETY_ON_NULL_RETURN(ec);
2779 res = e_hints_aux_hint_change(ec, id, value);
2781 ELOGF("TZPOL", "HINT_CHD |res_tzpol:%8p|id:%d, val:%s, result:%d", ec, res_tzpol, id, value, res);
2785 _e_policy_wl_aux_hint_apply(ec);
2786 _e_policy_wl_allowed_aux_hint_send(res_tzpol, surf, id);
2791 _tzpol_iface_cb_aux_hint_del(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
2794 unsigned int res = -1;
2796 ec = e_client_from_surface_resource(surf);
2797 EINA_SAFETY_ON_NULL_RETURN(ec);
2799 res = e_hints_aux_hint_del(ec, id);
2800 ELOGF("TZPOL", "HINT_DEL |res_tzpol:%8p|id:%d, result:%d", ec, res_tzpol, id, res);
2803 _e_policy_wl_aux_hint_apply(ec);
2807 _tzpol_iface_cb_supported_aux_hints_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
2810 const Eina_List *hints_list;
2812 struct wl_array hints;
2813 const char *hint_name;
2817 ec = e_client_from_surface_resource(surf);
2818 EINA_SAFETY_ON_NULL_RETURN(ec);
2820 hints_list = e_hints_aux_hint_supported_get();
2822 wl_array_init(&hints);
2823 EINA_LIST_FOREACH(hints_list, l, hint_name)
2825 len = strlen(hint_name) + 1;
2826 p = wl_array_add(&hints, len);
2830 strncpy(p, hint_name, len);
2833 tizen_policy_send_supported_aux_hints(res_tzpol, surf, &hints, eina_list_count(hints_list));
2835 "SEND |res_tzpol:%8p|supported_hints size:%d",
2838 eina_list_count(hints_list));
2839 wl_array_release(&hints);
2843 _e_policy_wl_background_state_apply(E_Client *ec, Eina_Bool state)
2848 "BACKGROUND STATE %s for PID(%u), iconic:%d",
2850 state?"SET":"UNSET", ec->netwm.pid, ec->iconic);
2854 ec->bg_state = EINA_TRUE;
2855 evas_object_hide(ec->frame);
2856 e_pixmap_image_clear(ec->pixmap, 1);
2860 ec->bg_state = EINA_FALSE;
2863 E_Comp_Wl_Client_Data *cdata;
2864 cdata = e_client_cdata_get(ec);
2865 if (cdata && cdata->mapped)
2867 evas_object_show(ec->frame);
2868 e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
2874 e_comp_visibility_calculation_set(EINA_TRUE);
2878 _e_policy_wl_background_state_set(E_Policy_Wl_Surface *psurf, Eina_Bool state)
2880 psurf->is_background = state;
2881 ELOGF("TZPOL", "Set psurf(%p)'s background_state to %d", NULL, psurf, state);
2886 _e_policy_wl_background_state_apply(psurf->ec, EINA_TRUE);
2891 _e_policy_wl_background_state_apply(psurf->ec, EINA_FALSE);
2896 _e_policy_wl_tzlaunch_effect_type_sync(E_Client *ec)
2899 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
2901 EINA_SAFETY_ON_NULL_RETURN(ec);
2903 EINA_LIST_FOREACH(polwl->tzlaunch_effect_info, l, effect_info)
2905 if (effect_info->pid == ec->netwm.pid)
2908 "Launchscreen effect type sync | pid (%d) effect_type (%d)",
2909 ec, ec->netwm.pid, effect_info->effect_type);
2910 ec->effect_type = effect_info->effect_type;
2911 _e_policy_wl_tzlaunch_effect_type_unset(ec->netwm.pid);
2918 _e_policy_wl_tzlaunch_effect_type_get(const char * effect_type)
2920 Tzlaunch_Effect_Type type = TZLAUNCH_EFFECT_TYPE_LAUNCH;
2922 if (!e_util_strcmp(effect_type, "launch" )) type = TZLAUNCH_EFFECT_TYPE_LAUNCH;
2923 else if (!e_util_strcmp(effect_type, "depth-in" )) type = TZLAUNCH_EFFECT_TYPE_DEPTH_IN;
2929 _e_policy_wl_tzlaunch_effect_type_unset(uint32_t pid)
2932 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
2934 EINA_LIST_FOREACH(polwl->tzlaunch_effect_info, l, effect_info)
2936 if (effect_info->pid == pid)
2939 "Launchscreen effect type unset | pid (%d)",
2941 polwl->tzlaunch_effect_info = eina_list_remove(polwl->tzlaunch_effect_info, effect_info);
2942 memset(effect_info, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Effect_Info));
2943 E_FREE(effect_info);
2950 _e_policy_wl_tzpol_background_state_set(E_Policy_Wl_Tzpol *tzpol, Eina_Bool bg_state, pid_t pid)
2953 E_Policy_Wl_Surface *psurf;
2957 tzpol->bg_state = bg_state;
2958 ELOGF("TZPOL", "Set tzpol(%p)'s background_state to %d", NULL, tzpol, bg_state);
2960 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
2962 if (psurf->pid == pid)
2964 if (psurf->is_background == bg_state)
2967 _e_policy_wl_background_state_set(psurf, bg_state);
2973 _e_policy_wl_tzpols_background_state_set(Eina_Bool bg_state, pid_t pid)
2975 E_Policy_Wl_Tzpol *tzpol;
2978 it = eina_hash_iterator_data_new(polwl->tzpols);
2979 EINA_ITERATOR_FOREACH(it, tzpol)
2981 if (tzpol->pid == pid)
2983 _e_policy_wl_tzpol_background_state_set(tzpol, bg_state, pid);
2986 eina_iterator_free(it);
2990 _tzpol_iface_cb_background_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t pid)
2992 E_Policy_Wl_Tzpol *tzpol;
2994 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
2995 EINA_SAFETY_ON_NULL_RETURN(tzpol);
2997 ELOGF("TZPOL", "Register PID(%u) for BACKGROUND STATE res_tzpol:%p tzpol:%p", NULL, pid, res_tzpol, tzpol);
2999 _e_policy_wl_tzpols_background_state_set(EINA_TRUE, pid);
3003 _tzpol_iface_cb_background_state_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t pid)
3005 E_Policy_Wl_Tzpol *tzpol;
3007 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3008 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3010 ELOGF("TZPOL", "Unregister PID(%u) for BACKGROUND STATE res_tzpol:%p tzpol:%p", NULL, pid, res_tzpol, tzpol);
3012 _e_policy_wl_tzpols_background_state_set(EINA_FALSE, pid);
3016 _e_policy_wl_floating_mode_apply(E_Client *ec, Eina_Bool floating)
3018 if (ec->floating == floating) return;
3020 ec->floating = floating;
3021 ec->lock_client_location = EINA_FALSE;
3027 ec->floating_saved_layer = ec->layer;
3028 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
3032 e_client_layer_set(ec, ec->floating_saved_layer);
3040 _tzpol_iface_cb_floating_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
3044 ec = e_client_from_surface_resource(surf);
3045 EINA_SAFETY_ON_NULL_RETURN(ec);
3047 ELOGF("TZPOL", "FLOATING Set", ec);
3049 _e_policy_wl_floating_mode_apply(ec, EINA_TRUE);
3053 _tzpol_iface_cb_floating_mode_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
3057 ec = e_client_from_surface_resource(surf);
3058 EINA_SAFETY_ON_NULL_RETURN(ec);
3060 ELOGF("TZPOL", "FLOATING Unset", ec);
3062 e_client_pending_geometry_flush(ec);
3064 _e_policy_wl_floating_mode_apply(ec, EINA_FALSE);
3068 _tzpol_iface_cb_stack_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
3072 ec = e_client_from_surface_resource(surf);
3073 EINA_SAFETY_ON_NULL_RETURN(ec);
3075 ELOGF("TZPOL", "STACK Mode Set. mode:%d", ec, mode);
3079 if (mode == TIZEN_POLICY_STACK_MODE_ABOVE)
3081 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
3083 else if (mode == TIZEN_POLICY_STACK_MODE_BELOW)
3085 e_client_layer_set(ec, E_LAYER_CLIENT_BELOW);
3089 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
3093 e_policy_hook_call(E_POLICY_HOOK_CLIENT_STACK_MODE_SET, ec);
3097 // --------------------------------------------------------
3098 // E_Policy_Wl_Tz_Dpy_Pol
3099 // --------------------------------------------------------
3100 static E_Policy_Wl_Tz_Dpy_Pol *
3101 _e_policy_wl_tz_dpy_pol_add(struct wl_resource *res_tz_dpy_pol)
3103 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3105 tz_dpy_pol = E_NEW(E_Policy_Wl_Tz_Dpy_Pol, 1);
3106 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_dpy_pol, NULL);
3108 tz_dpy_pol->res_tz_dpy_pol = res_tz_dpy_pol;
3110 polwl->tz_dpy_pols = eina_list_append(polwl->tz_dpy_pols, tz_dpy_pol);
3116 _e_policy_wl_tz_dpy_pol_del(E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol)
3118 E_Policy_Wl_Dpy_Surface *dpy_surf;
3120 EINA_SAFETY_ON_NULL_RETURN(tz_dpy_pol);
3122 polwl->tz_dpy_pols = eina_list_remove(polwl->tz_dpy_pols, tz_dpy_pol);
3124 EINA_LIST_FREE(tz_dpy_pol->dpy_surfs, dpy_surf)
3132 static E_Policy_Wl_Tz_Dpy_Pol *
3133 _e_policy_wl_tz_dpy_pol_get(struct wl_resource *res_tz_dpy_pol)
3136 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3138 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3140 if (tz_dpy_pol->res_tz_dpy_pol == res_tz_dpy_pol)
3147 // --------------------------------------------------------
3148 // E_Policy_Wl_Dpy_Surface
3149 // --------------------------------------------------------
3150 static E_Policy_Wl_Dpy_Surface *
3151 _e_policy_wl_dpy_surf_find(E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol, E_Client *ec)
3154 E_Policy_Wl_Dpy_Surface *dpy_surf;
3156 EINA_LIST_FOREACH(tz_dpy_pol->dpy_surfs, l, dpy_surf)
3158 if (dpy_surf->ec == ec)
3165 static E_Policy_Wl_Dpy_Surface *
3166 _e_policy_wl_dpy_surf_add(E_Client *ec, struct wl_resource *res_tz_dpy_pol)
3168 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol = NULL;
3169 E_Policy_Wl_Dpy_Surface *dpy_surf = NULL;
3170 E_Comp_Wl_Client_Data *cdata;
3172 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_get(res_tz_dpy_pol);
3173 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_dpy_pol, NULL);
3175 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3179 dpy_surf = E_NEW(E_Policy_Wl_Dpy_Surface, 1);
3180 EINA_SAFETY_ON_NULL_RETURN_VAL(dpy_surf, NULL);
3182 cdata = e_client_cdata_get(ec);
3183 dpy_surf->surf = cdata->surface;
3184 dpy_surf->tz_dpy_pol = tz_dpy_pol;
3186 dpy_surf->brightness = -1;
3188 tz_dpy_pol->dpy_surfs = eina_list_append(tz_dpy_pol->dpy_surfs, dpy_surf);
3193 _e_policy_wl_dpy_surf_del(E_Client *ec)
3196 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3197 E_Policy_Wl_Dpy_Surface *dpy_surf;
3199 EINA_SAFETY_ON_NULL_RETURN(ec);
3201 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3203 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3206 tz_dpy_pol->dpy_surfs = eina_list_remove(tz_dpy_pol->dpy_surfs, dpy_surf);
3212 // --------------------------------------------------------
3214 // --------------------------------------------------------
3216 _e_policy_system_brightness_get(int *brightness)
3219 int sys_brightness = -1;
3221 if (!brightness) return EINA_FALSE;
3223 error = device_display_get_brightness(0, &sys_brightness);
3224 if (error != DEVICE_ERROR_NONE)
3230 *brightness = sys_brightness;
3236 _e_policy_system_brightness_set(int brightness)
3245 error = device_display_get_numbers(&num_of_dpy);
3246 if (error != DEVICE_ERROR_NONE)
3252 for (id = 0; id < num_of_dpy; id++)
3254 error = device_display_set_brightness(id, brightness);
3255 if (error != DEVICE_ERROR_NONE)
3267 _e_policy_change_system_brightness(int new_brightness)
3272 if (!e_policy_system_info.brightness.use_client)
3274 // save system brightness
3275 ret = _e_policy_system_brightness_get(&sys_brightness);
3280 e_policy_system_info.brightness.system = sys_brightness;
3283 ret = _e_policy_system_brightness_set(new_brightness);
3288 e_policy_system_info.brightness.client = new_brightness;
3289 e_policy_system_info.brightness.use_client = EINA_TRUE;
3295 _e_policy_restore_system_brightness(void)
3299 if (!e_policy_system_info.brightness.use_client) return EINA_TRUE;
3301 // restore system brightness
3302 ret = _e_policy_system_brightness_set(e_policy_system_info.brightness.system);
3307 e_policy_system_info.brightness.use_client = EINA_FALSE;
3310 // if there are another window which set brighteness, then we change brighteness of it
3311 // if no, then we rollback system brightness
3317 e_policy_wl_win_brightness_apply(E_Client *ec)
3321 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3322 E_Policy_Wl_Dpy_Surface *dpy_surf = NULL;
3325 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
3326 if (e_object_is_del(E_OBJECT(ec)))
3327 ec_visibility = E_VISIBILITY_FULLY_OBSCURED;
3329 ec_visibility = ec->visibility.obscured;
3331 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3333 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3338 if (!dpy_surf) return EINA_FALSE;
3339 if (!dpy_surf->set) return EINA_FALSE;
3341 // use system brightness
3342 if (dpy_surf->brightness < 0)
3344 ELOGF("TZ_DPY_POL", "Restore system brightness. Win(0x%08zx)'s brightness:%d", ec, e_client_util_win_get(ec), dpy_surf->brightness);
3345 ret = _e_policy_restore_system_brightness();
3349 if (ec_visibility == E_VISIBILITY_UNOBSCURED)
3351 ELOGF("TZ_DPY_POL", "Change system brightness(%d). Win(0x%08zx) is un-obscured", ec, dpy_surf->brightness, e_client_util_win_get(ec));
3352 ret = _e_policy_change_system_brightness(dpy_surf->brightness);
3353 if (!ret) return EINA_FALSE;
3357 ELOGF("TZ_DPY_POL", "Restore system brightness. Win(0x%08zx) is obscured", ec, e_client_util_win_get(ec));
3358 ret = _e_policy_restore_system_brightness();
3359 if (!ret) return EINA_FALSE;
3366 _tz_dpy_pol_iface_cb_brightness_set(struct wl_client *client, struct wl_resource *res_tz_dpy_pol, struct wl_resource *surf, int32_t brightness)
3369 E_Policy_Wl_Dpy_Surface *dpy_surf;
3374 ec = e_client_from_surface_resource(surf);
3375 EINA_SAFETY_ON_NULL_RETURN(ec);
3377 dpy_surf = _e_policy_wl_dpy_surf_add(ec, res_tz_dpy_pol);
3378 EINA_SAFETY_ON_NULL_RETURN(dpy_surf);
3380 wl_client_get_credentials(client, &pid, &uid, NULL);
3381 res = e_security_privilege_check(pid, uid,
3382 E_PRIVILEGE_BRIGHTNESS_SET);
3386 "Privilege Check Failed! DENY set_brightness",
3389 tizen_display_policy_send_window_brightness_done
3393 TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED);
3396 ELOGF("TZ_DPY_POL", "Set Win(0x%08zx)'s brightness:%d", ec, e_client_util_win_get(ec), brightness);
3397 dpy_surf->set = EINA_TRUE;
3398 dpy_surf->brightness = brightness;
3400 e_policy_wl_win_brightness_apply(ec);
3402 tizen_display_policy_send_window_brightness_done
3403 (res_tz_dpy_pol, surf, brightness, TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE);
3407 _tz_dpy_pol_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
3409 wl_resource_destroy(resource);
3413 _tzpol_iface_cb_subsurf_watcher_destroy(struct wl_resource *resource)
3416 E_Comp_Wl_Client_Data *cdata;
3418 if (!(ec = wl_resource_get_user_data(resource))) return;
3419 cdata = e_client_cdata_get(ec);
3422 cdata->sub.watcher = NULL;
3426 _tzpol_subsurf_watcher_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
3428 wl_resource_destroy(resource);
3431 static const struct tizen_subsurface_watcher_interface _tzpol_subsurf_watcher_iface =
3433 _tzpol_subsurf_watcher_iface_cb_destroy,
3437 _tzpol_iface_cb_subsurf_watcher_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surface)
3440 E_Comp_Wl_Client_Data *cdata;
3441 struct wl_resource *res;
3443 if (!(ec = e_client_from_surface_resource(surface))) return;
3444 if (e_object_is_del(E_OBJECT(ec))) return;
3445 cdata = e_client_cdata_get(ec);
3448 if (!(res = wl_resource_create(client, &tizen_subsurface_watcher_interface, 1, id)))
3450 wl_resource_post_no_memory(res_tzpol);
3454 cdata->sub.watcher = res;
3456 wl_resource_set_implementation(res,
3457 &_tzpol_subsurf_watcher_iface,
3459 _tzpol_iface_cb_subsurf_watcher_destroy);
3463 _tzpol_iface_cb_parent_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
3465 E_Client *ec, *parent_ec;
3468 "PARENT_SET |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3469 NULL, res_tzpol, parent, child);
3471 ec = e_client_from_surface_resource(child);
3472 EINA_SAFETY_ON_NULL_RETURN(ec);
3474 parent_ec = e_client_from_surface_resource(parent);
3475 e_policy_stack_parent_set(ec, parent_ec);
3479 _tzpol_iface_cb_ack_conformant_region(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t serial)
3483 if (!(ec = e_client_from_surface_resource(surface))) return;
3485 e_policy_conformant_client_ack(ec, res_tzpol, serial);
3489 _tzpol_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzpol)
3491 wl_resource_destroy(res_tzpol);
3495 _tzpol_iface_cb_has_video(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t has)
3498 E_Comp_Wl_Client_Data *cdata;
3500 if (!(ec = e_client_from_surface_resource(surface))) return;
3501 if (e_object_is_del(E_OBJECT(ec))) return;
3502 cdata = e_client_cdata_get(ec);
3504 if (cdata->has_video_client == has) return;
3506 ELOGF("TZPOL", "video client has(%d)", ec, has);
3508 cdata->has_video_client = has;
3512 _tzpol_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzpol, int32_t pid, const char *appid)
3514 E_Policy_Wl_Tzpol *tzpol;
3517 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3518 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3520 ELOGF("TZPOL", "Set appid(%s) pid(%d)", NULL, appid, pid);
3522 if (!(eai = e_appinfo_find_with_appid(appid)))
3524 eai = e_appinfo_new();
3525 e_appinfo_appid_set(eai, appid);
3526 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
3528 EINA_SAFETY_ON_NULL_RETURN(eai);
3530 e_appinfo_pid_set(eai, pid);
3534 _tzpol_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3537 E_Comp_Wl_Client_Data *cdata;
3539 ec = e_client_from_surface_resource(surf);
3540 EINA_SAFETY_ON_NULL_RETURN(ec);
3541 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3543 ELOGF("TZPOL", "Prepare SHOW (wait for buffer attach)", ec);
3545 cdata = e_client_cdata_get(ec);
3546 if (cdata && !cdata->mapped)
3548 if (e_config->raise_before_show)
3551 ec->post_raise = EINA_FALSE;
3557 _tzpol_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3561 ec = e_client_from_surface_resource(surf);
3562 EINA_SAFETY_ON_NULL_RETURN(ec);
3563 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3565 ELOGF("TZPOL", "Prepare HIDE (wait for NULL buffer attach)", ec);
3569 _tzpol_iface_cb_set_transient_for_below(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t child_id, uint32_t parent_id)
3571 E_Client *ec, *parent_ec;
3572 E_Comp_Wl_Client_Data *cdata, *p_cdata;
3575 "TF_SET(B) |res_tzpol:%8p|parent_id:%8d |child_id:%8d",
3576 NULL, res_tzpol, parent_id, child_id);
3578 ec = e_pixmap_find_client_by_res_id(child_id);
3579 EINA_SAFETY_ON_NULL_RETURN(ec);
3580 parent_ec = e_pixmap_find_client_by_res_id(parent_id);
3582 cdata = e_client_cdata_get(ec);
3583 p_cdata = e_client_cdata_get(parent_ec);
3585 " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3586 NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL));
3588 e_policy_stack_transient_for_below_set(ec, parent_ec, EINA_TRUE);
3592 _tzpol_iface_cb_set_parent_with_below(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
3594 E_Client *ec, *parent_ec;
3597 "PARENT_SET(B)|res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3598 NULL, res_tzpol, parent, child);
3600 ec = e_client_from_surface_resource(child);
3601 EINA_SAFETY_ON_NULL_RETURN(ec);
3604 parent_ec = e_client_from_surface_resource(parent);
3608 e_policy_stack_transient_for_below_set(ec, parent_ec, EINA_FALSE);
3612 _tzpol_iface_cb_set_maximize_direction(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf, uint32_t direction)
3616 ec = e_client_from_surface_resource(surf);
3617 EINA_SAFETY_ON_NULL_RETURN(ec);
3618 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3620 ELOGF("TZPOL", "Set Maximize_direction. direction:%d", ec, direction);
3622 if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_NONE)
3624 ec->maximize_dir = E_MAXIMIZE_DIRECTION_NONE;
3625 e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
3627 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_ALL)
3629 ec->maximize_dir = E_MAXIMIZE_DIRECTION_ALL;
3630 e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_BOTH);
3632 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_LEFT)
3634 ec->maximize_dir = E_MAXIMIZE_DIRECTION_LEFT;
3635 e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_LEFT);
3637 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_RIGHT)
3639 ec->maximize_dir = E_MAXIMIZE_DIRECTION_RIGHT;
3640 e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_RIGHT);
3644 ELOGF("TZPOL", "Not supported direction:%d", ec, direction);
3649 _e_policy_set_pin_mode(E_Client *ec, Eina_Bool pinned)
3651 EINA_SAFETY_ON_NULL_RETURN(ec);
3652 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3654 ELOGF("TZPOL", "Set Pin mode to %d", ec, pinned);
3655 e_client_pinned_set(ec, pinned);
3659 _tzpol_iface_cb_set_pin_mode(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3663 ec = e_client_from_surface_resource(surf);
3664 _e_policy_set_pin_mode(ec, EINA_TRUE);
3668 _tzpol_iface_cb_unset_pin_mode(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3672 ec = e_client_from_surface_resource(surf);
3673 _e_policy_set_pin_mode(ec, EINA_FALSE);
3677 _tzpol_iface_cb_set_layout(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf, uint32_t num_cols, uint32_t num_rows, uint32_t column, uint32_t row, uint32_t col_span, uint32_t row_span)
3683 ec = e_client_from_surface_resource(surf);
3686 unit_w = ec->desk->geom.w / num_cols;
3687 unit_h = ec->desk->geom.h / num_rows;
3689 x = unit_w * column;
3691 w = unit_w * col_span;
3692 h = unit_h * row_span;
3694 // TODO: We may need to adjust the last size if the unit size is not devided exactly
3696 ELOGF("TZPOL", "TIZEN_POLICY_SET_LAYOUT... total_layout(%d,%d) -> unit_size(%dx%d). request(%d,%d,%d,%d) -> geo(%d,%d,%dx%d)",
3697 ec, num_cols, num_rows, unit_w, unit_h, column, row, col_span, row_span, x, y, w, h);
3699 // Apply shadow size (left, right, top, bottom)
3700 x -= ec->manage_resize.shadow.l;
3701 y -= ec->manage_resize.shadow.t;
3702 w = w + ec->manage_resize.shadow.l + ec->manage_resize.shadow.r;
3703 h = h + ec->manage_resize.shadow.t + ec->manage_resize.shadow.b;
3705 ELOGF("TZPOL", "Consider Shadow size(l:%d,r:%d,t:%d,b:%d). new (%d,%d,%dx%d)",
3706 ec, ec->manage_resize.shadow.l, ec->manage_resize.shadow.r, ec->manage_resize.shadow.t, ec->manage_resize.shadow.b, x, y, w, h);
3708 e_client_layout_apply(ec, EINA_TRUE);
3709 e_client_frame_geometry_set(ec, x, y, w, h);
3713 E_Comp_Wl_Client_Data *cdata;
3714 cdata = e_client_cdata_get(ec);
3715 if (cdata && cdata->shell.configure_send && cdata->shell.surface)
3717 cdata->shell.configure_send(cdata->shell.surface, 0, w, h);
3722 // --------------------------------------------------------
3723 // tizen_policy_interface
3724 // --------------------------------------------------------
3725 static const struct tizen_policy_interface _tzpol_iface =
3727 _tzpol_iface_cb_vis_get,
3728 _tzpol_iface_cb_pos_get,
3729 _tzpol_iface_cb_activate,
3730 _tzpol_iface_cb_activate_below_by_res_id,
3731 _tzpol_iface_cb_raise,
3732 _tzpol_iface_cb_lower,
3733 _tzpol_iface_cb_lower_by_res_id,
3734 _tzpol_iface_cb_focus_skip_set,
3735 _tzpol_iface_cb_focus_skip_unset,
3736 _tzpol_iface_cb_role_set,
3737 _tzpol_iface_cb_type_set,
3738 _tzpol_iface_cb_conformant_set,
3739 _tzpol_iface_cb_conformant_unset,
3740 _tzpol_iface_cb_conformant_get,
3741 _tzpol_iface_cb_notilv_set,
3742 _tzpol_iface_cb_transient_for_set,
3743 _tzpol_iface_cb_transient_for_unset,
3744 _tzpol_iface_cb_win_scrmode_set,
3745 _tzpol_iface_cb_subsurf_place_below_parent,
3746 _tzpol_iface_cb_subsurf_stand_alone_set,
3747 _tzpol_iface_cb_subsurface_get,
3748 _tzpol_iface_cb_opaque_state_set,
3749 _tzpol_iface_cb_iconify,
3750 _tzpol_iface_cb_uniconify,
3751 _tzpol_iface_cb_aux_hint_add,
3752 _tzpol_iface_cb_aux_hint_change,
3753 _tzpol_iface_cb_aux_hint_del,
3754 _tzpol_iface_cb_supported_aux_hints_get,
3755 _tzpol_iface_cb_background_state_set,
3756 _tzpol_iface_cb_background_state_unset,
3757 _tzpol_iface_cb_floating_mode_set,
3758 _tzpol_iface_cb_floating_mode_unset,
3759 _tzpol_iface_cb_stack_mode_set,
3760 _tzpol_iface_cb_activate_above_by_res_id,
3761 _tzpol_iface_cb_subsurf_watcher_get,
3762 _tzpol_iface_cb_parent_set,
3763 _tzpol_iface_cb_ack_conformant_region,
3764 _tzpol_iface_cb_destroy,
3765 _tzpol_iface_cb_has_video,
3766 _tzpol_iface_cb_set_appid,
3767 _tzpol_iface_cb_show,
3768 _tzpol_iface_cb_hide,
3769 _tzpol_iface_cb_set_transient_for_below,
3770 _tzpol_iface_cb_set_parent_with_below,
3771 _tzpol_iface_cb_set_maximize_direction,
3772 _tzpol_iface_cb_set_pin_mode,
3773 _tzpol_iface_cb_unset_pin_mode,
3774 _tzpol_iface_cb_set_layout
3778 _tzpol_cb_unbind(struct wl_resource *res_tzpol)
3780 E_Policy_Wl_Tzpol *tzpol;
3782 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3783 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3785 eina_hash_del_by_key(polwl->tzpols, &res_tzpol);
3789 _tzpol_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
3791 E_Policy_Wl_Tzpol *tzpol;
3792 struct wl_resource *res_tzpol;
3794 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
3796 res_tzpol = wl_resource_create(client,
3797 &tizen_policy_interface,
3800 EINA_SAFETY_ON_NULL_GOTO(res_tzpol, err);
3802 tzpol = _e_policy_wl_tzpol_add(client, res_tzpol);
3803 EINA_SAFETY_ON_NULL_GOTO(tzpol, err);
3805 wl_resource_set_implementation(res_tzpol,
3812 ERR("Could not create tizen_policy_interface res: %m");
3813 wl_client_post_no_memory(client);
3816 // --------------------------------------------------------
3817 // tizen_display_policy_interface
3818 // --------------------------------------------------------
3819 static const struct tizen_display_policy_interface _tz_dpy_pol_iface =
3821 _tz_dpy_pol_iface_cb_brightness_set,
3822 _tz_dpy_pol_iface_cb_destroy,
3826 _tz_dpy_pol_cb_unbind(struct wl_resource *res_tz_dpy_pol)
3828 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3830 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_get(res_tz_dpy_pol);
3831 EINA_SAFETY_ON_NULL_RETURN(tz_dpy_pol);
3833 _e_policy_wl_tz_dpy_pol_del(tz_dpy_pol);
3837 _tz_dpy_pol_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
3839 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3840 struct wl_resource *res_tz_dpy_pol;
3842 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
3844 res_tz_dpy_pol = wl_resource_create(client,
3845 &tizen_display_policy_interface,
3848 EINA_SAFETY_ON_NULL_GOTO(res_tz_dpy_pol, err);
3850 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_add(res_tz_dpy_pol);
3851 EINA_SAFETY_ON_NULL_GOTO(tz_dpy_pol, err);
3853 wl_resource_set_implementation(res_tz_dpy_pol,
3856 _tz_dpy_pol_cb_unbind);
3860 ERR("Could not create tizen_display_policy_interface res: %m");
3861 wl_client_post_no_memory(client);
3864 // --------------------------------------------------------
3865 // tizen_ws_shell_interface::service
3866 // --------------------------------------------------------
3868 _tzsh_srv_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_srv)
3870 wl_resource_destroy(res_tzsh_srv);
3874 _tzsh_srv_iface_cb_region_set(struct wl_client *client, struct wl_resource *res_tzsh_srv, int32_t type, int32_t angle, struct wl_resource *res_reg)
3876 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3877 E_Policy_Wl_Tzsh_Region *tzsh_reg;
3879 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
3880 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3882 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
3885 tzsh_reg = wl_resource_get_user_data(res_reg);
3886 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
3888 if ((tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT) ||
3889 (tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU) ||
3890 (tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU))
3892 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3893 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
3895 e_service_quickpanel_region_set(tzsh_srv->ec,
3900 else if (tzsh_srv->role == TZSH_SRV_ROLE_VOLUME)
3901 e_service_volume_region_set(type, angle, tzsh_reg->tiler);
3902 else if (tzsh_srv->role == TZSH_SRV_ROLE_SOFTKEY)
3904 if (e_config->use_softkey_service)
3906 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3907 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
3909 e_service_softkey_handler_region_set(tzsh_srv->ec, angle, tzsh_reg->tiler);
3915 _tzsh_srv_indicator_cb_resource_destroy(struct wl_resource *resource)
3917 if (_indicator_srv_res == resource)
3918 _indicator_srv_res = NULL;
3922 _tzsh_srv_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
3924 _indicator_srv_res = NULL;
3925 wl_resource_destroy(resource);
3928 static const struct tws_service_indicator_interface _tzsh_srv_indicator_iface =
3930 _tzsh_srv_indicator_cb_destroy,
3934 _tzsh_srv_iface_cb_indicator_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
3936 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3937 struct wl_resource *res;
3939 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
3940 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3942 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
3945 res = wl_resource_create(client, &tws_service_indicator_interface, 1, id);
3948 wl_client_post_no_memory(client);
3951 _indicator_srv_res = res;
3953 wl_resource_set_implementation(res, &_tzsh_srv_indicator_iface, tzsh_srv,
3954 _tzsh_srv_indicator_cb_resource_destroy);
3958 _tzsh_srv_qp_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
3960 wl_resource_destroy(resource);
3964 _tzsh_srv_qp_cb_msg(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
3966 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3968 tzsh_srv = wl_resource_get_user_data(resource);
3970 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3971 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3973 #define EC tzsh_srv->ec
3974 EINA_SAFETY_ON_NULL_RETURN(EC);
3978 case TWS_SERVICE_QUICKPANEL_MSG_SHOW:
3979 e_service_quickpanel_show(EC);
3981 case TWS_SERVICE_QUICKPANEL_MSG_HIDE:
3982 e_service_quickpanel_hide(EC);
3985 ERR("Unknown message!! msg %d", msg);
3992 _tzsh_srv_qp_cb_effect_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t type)
3994 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3996 tzsh_srv = wl_resource_get_user_data(resource);
3998 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3999 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4001 #define EC tzsh_srv->ec
4002 EINA_SAFETY_ON_NULL_RETURN(EC);
4003 e_service_quickpanel_effect_type_set(EC, type);
4008 _tzsh_srv_qp_cb_scroll_lock_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t lock)
4010 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4012 tzsh_srv = wl_resource_get_user_data(resource);
4014 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4015 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4017 #define EC tzsh_srv->ec
4018 EINA_SAFETY_ON_NULL_RETURN(EC);
4019 e_service_quickpanel_scroll_lock_set(EC, lock);
4023 static const struct tws_service_quickpanel_interface _tzsh_srv_qp_iface =
4025 _tzsh_srv_qp_cb_destroy,
4026 _tzsh_srv_qp_cb_msg,
4027 _tzsh_srv_qp_cb_effect_type_set,
4028 _tzsh_srv_qp_cb_scroll_lock_set,
4032 _tzsh_srv_iface_cb_quickpanel_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4034 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4035 struct wl_resource *res;
4037 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4038 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4040 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4043 res = wl_resource_create(client,
4044 &tws_service_quickpanel_interface,
4045 wl_resource_get_version(res_tzsh_srv),
4049 wl_client_post_no_memory(client);
4053 wl_resource_set_implementation(res, &_tzsh_srv_qp_iface, tzsh_srv, NULL);
4059 _tzsh_srv_softkey_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4061 wl_resource_destroy(resource);
4065 _tzsh_srv_softkey_cb_msg_send(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4067 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4068 E_Service_Softkey *softkey_service;
4071 tzsh_srv = wl_resource_get_user_data(resource);
4073 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4074 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4076 zone = tzsh_srv->zone;
4077 EINA_SAFETY_ON_NULL_RETURN(zone);
4079 softkey_service = e_service_softkey_get(zone);
4080 EINA_SAFETY_ON_NULL_RETURN(softkey_service);
4084 case TWS_SERVICE_SOFTKEY_MSG_SHOW:
4085 e_service_softkey_show(softkey_service);
4087 case TWS_SERVICE_SOFTKEY_MSG_HIDE:
4088 e_service_softkey_hide(softkey_service);
4091 ERR("Unknown message!! msg %d", msg);
4096 static const struct tws_service_softkey_interface _tzsh_srv_softkey_iface =
4098 _tzsh_srv_softkey_cb_destroy,
4099 _tzsh_srv_softkey_cb_msg_send,
4103 _tzsh_srv_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4105 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4106 E_Service_Softkey *softkey_service = NULL;
4107 struct wl_resource *res;
4109 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4110 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4112 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4115 res = wl_resource_create(client, &tws_service_softkey_interface, 1, id);
4118 wl_client_post_no_memory(client);
4122 ELOGF("TZSH", "[SOFTKEY SERVICE] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
4126 E_Zone *zone = tzsh_srv->zone;
4128 softkey_service = e_service_softkey_get(zone);
4129 ELOGF("TZSH", "[SOFTKEY SERVICE] resource set. res:%p, softkey_service:%p, softkey_ec:%p", NULL, res, softkey_service, tzsh_srv->ec);
4130 if (softkey_service)
4132 e_service_softkey_wl_resource_set(softkey_service, res);
4133 e_service_softkey_restore_visible_request(softkey_service);
4137 wl_resource_set_implementation(res, &_tzsh_srv_softkey_iface, tzsh_srv, NULL);
4141 _tzsh_srv_magnifier_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4143 wl_resource_destroy(resource);
4147 _tzsh_srv_magnifier_cb_zoom_geometry_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t angle, int32_t x, int32_t y, uint32_t w, uint32_t h)
4149 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4152 tzsh_srv = wl_resource_get_user_data(resource);
4154 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4155 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4156 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4158 ELOGF("TZSH", "[MAGNIFIER] Set Geometry. angle:%d, geo:%d,%d,%dx%d", tzsh_srv->ec, angle, x, y, w, h);
4161 // angle: 0, 90, 180, 270
4162 e_magnifier_zoom_obj_geometry_set(ec, angle, x, y, w, h);
4166 _tzsh_srv_magnifier_cb_ratio_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t ratio)
4168 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4171 tzsh_srv = wl_resource_get_user_data(resource);
4173 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4174 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4175 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4177 ELOGF("TZSH", "[MAGNIFIER] Set Ratio. ratio:%d", tzsh_srv->ec, ratio);
4180 // ratio : 100 ~ 200 (each 10)
4181 e_magnifier_zoom_obj_ratio_set(ec, ratio);
4185 _tzsh_srv_magnifier_cb_enable_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t enable)
4187 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4190 tzsh_srv = wl_resource_get_user_data(resource);
4192 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4193 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4194 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4196 ELOGF("TZSH", "[MAGNIFIER] Set Enable. enable:%d", tzsh_srv->ec, enable);
4201 e_magnifier_show(ec);
4203 e_magnifier_hide(ec);
4206 static const struct tws_service_magnifier_interface _tzsh_srv_magnifier_iface =
4208 _tzsh_srv_magnifier_cb_destroy,
4209 _tzsh_srv_magnifier_cb_zoom_geometry_set,
4210 _tzsh_srv_magnifier_cb_ratio_set,
4211 _tzsh_srv_magnifier_cb_enable_set,
4215 _tzsh_srv_iface_cb_magnifier_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4217 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4218 struct wl_resource *res;
4220 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4221 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4223 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4226 res = wl_resource_create(client, &tws_service_magnifier_interface, 1, id);
4229 wl_client_post_no_memory(client);
4233 ELOGF("TZSH", "[MAGNIFIER] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
4234 wl_resource_set_implementation(res, &_tzsh_srv_magnifier_iface, tzsh_srv, NULL);
4237 //////////////////////////////////////////////////////////////////////////////////////////////////////
4239 _tzsh_srv_scrsaver_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4241 wl_resource_destroy(resource);
4244 static const struct tws_service_screensaver_interface _tzsh_srv_scrsaver_iface =
4246 _tzsh_srv_scrsaver_cb_release
4250 _tzsh_srv_iface_cb_scrsaver_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4252 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4253 struct wl_resource *res;
4255 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4256 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4258 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4261 res = wl_resource_create(client, &tws_service_screensaver_interface, 1, id);
4264 wl_client_post_no_memory(client);
4268 wl_resource_set_implementation(res, &_tzsh_srv_scrsaver_iface, tzsh_srv, NULL);
4272 _tzsh_srv_scrsaver_mng_cb_resource_destroy(struct wl_resource *resource)
4274 if (_scrsaver_mng_res == resource)
4276 _scrsaver_mng_res = NULL;
4277 e_screensaver_disable();
4282 _tzsh_srv_scrsaver_mng_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4284 _scrsaver_mng_res = NULL;
4285 wl_resource_destroy(resource);
4286 e_screensaver_disable();
4290 _tzsh_srv_scrsaver_mng_cb_enable(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4292 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4294 tzsh_srv = wl_resource_get_user_data(resource);
4296 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4297 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4299 e_screensaver_enable();
4303 _tzsh_srv_scrsaver_mng_cb_disable(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4305 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4307 tzsh_srv = wl_resource_get_user_data(resource);
4309 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4310 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4312 e_screensaver_disable();
4316 _tzsh_srv_scrsaver_mng_cb_idle_time_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t time)
4318 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4321 tzsh_srv = wl_resource_get_user_data(resource);
4323 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4324 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4326 /* convert time to seconds (double) from milliseconds (unsigned int) */
4327 timeout = (double)time * 0.001f;
4329 e_screensaver_timeout_set(timeout);
4333 _tzsh_srv_scrsaver_mng_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t type)
4335 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4339 tzsh_srv = wl_resource_get_user_data(resource);
4341 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4342 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4346 case TWS_SERVICE_SCREENSAVER_MANAGER_STATE_TYPE_IDLE_TIMEOUT:
4347 /* convert time to milliseconds (unsigned int) from seconds (double) */
4348 timeout = e_screensaver_timeout_get();
4349 val = (uint32_t)(timeout * 1000);
4355 tws_service_screensaver_manager_send_state_get_done(resource, type, val, 0);
4358 static const struct tws_service_screensaver_manager_interface _tzsh_srv_scrsaver_mng_iface =
4360 _tzsh_srv_scrsaver_mng_cb_destroy,
4361 _tzsh_srv_scrsaver_mng_cb_enable,
4362 _tzsh_srv_scrsaver_mng_cb_disable,
4363 _tzsh_srv_scrsaver_mng_cb_idle_time_set,
4364 _tzsh_srv_scrsaver_mng_cb_state_get
4368 _tzsh_srv_iface_cb_scrsaver_mng_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4370 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4371 struct wl_resource *res;
4373 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4374 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4376 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4379 res = wl_resource_create(client, &tws_service_screensaver_manager_interface, 1, id);
4382 wl_client_post_no_memory(client);
4386 _scrsaver_mng_res = res;
4388 wl_resource_set_implementation(res, &_tzsh_srv_scrsaver_mng_iface, tzsh_srv,
4389 _tzsh_srv_scrsaver_mng_cb_resource_destroy);
4393 _tzsh_srv_cbhm_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4395 wl_resource_destroy(resource);
4399 _tzsh_srv_cbhm_cb_msg(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4401 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4403 tzsh_srv = wl_resource_get_user_data(resource);
4405 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4406 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4408 #define EC tzsh_srv->ec
4409 EINA_SAFETY_ON_NULL_RETURN(EC);
4413 case TWS_SERVICE_CBHM_MSG_SHOW:
4414 e_service_cbhm_show();
4416 case TWS_SERVICE_CBHM_MSG_HIDE:
4417 e_service_cbhm_hide();
4419 case TWS_SERVICE_CBHM_MSG_DATA_SELECTED:
4420 e_service_cbhm_data_selected();
4423 ERR("Unknown message!! msg %d", msg);
4429 static const struct tws_service_cbhm_interface _tzsh_srv_cbhm_iface =
4431 _tzsh_srv_cbhm_cb_destroy,
4432 _tzsh_srv_cbhm_cb_msg
4436 _tzsh_srv_iface_cb_cbhm_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4438 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4439 struct wl_resource *res;
4441 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4442 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4444 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4447 res = wl_resource_create(client, &tws_service_cbhm_interface, 1, id);
4450 wl_client_post_no_memory(client);
4454 wl_resource_set_implementation(res, &_tzsh_srv_cbhm_iface, tzsh_srv, NULL);
4459 _tzsh_srv_iface_cb_launcher_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4461 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4462 struct wl_resource *res;
4464 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4465 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4466 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4468 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4471 res = wl_resource_create(client, &tws_service_launcher_interface, 1, id);
4474 wl_client_post_no_memory(client);
4479 e_service_launcher_resource_set(tzsh_srv->ec, res);
4483 _tzsh_srv_taskbar_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4485 wl_resource_destroy(resource);
4489 _tzsh_srv_taskbar_cb_place_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t place_type)
4491 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4494 tzsh_srv = wl_resource_get_user_data(resource);
4495 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4496 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4499 EINA_SAFETY_ON_NULL_RETURN(ec);
4501 e_service_taskbar_place_type_set(ec, place_type);
4505 _tzsh_srv_taskbar_cb_size_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t width, uint32_t height)
4507 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4510 tzsh_srv = wl_resource_get_user_data(resource);
4511 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4512 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4515 EINA_SAFETY_ON_NULL_RETURN(ec);
4517 e_service_taskbar_size_set(ec, width, height);
4521 _tzsh_srv_taskbar_cb_auto_placement_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t auto_placement)
4523 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4526 tzsh_srv = wl_resource_get_user_data(resource);
4527 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4528 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4531 EINA_SAFETY_ON_NULL_RETURN(ec);
4533 e_service_taskbar_auto_placement_set(ec, auto_placement);
4536 static const struct tws_service_taskbar_interface _tzsh_srv_taskbar_iface =
4538 _tzsh_srv_taskbar_cb_destroy,
4539 _tzsh_srv_taskbar_cb_place_type_set,
4540 _tzsh_srv_taskbar_cb_size_set,
4541 _tzsh_srv_taskbar_cb_auto_placement_set,
4545 _tzsh_srv_iface_cb_taskbar_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4547 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4548 struct wl_resource *res;
4550 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4551 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4552 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4554 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4557 res = wl_resource_create(client,
4558 &tws_service_taskbar_interface,
4563 wl_client_post_no_memory(client);
4567 wl_resource_set_implementation(res, &_tzsh_srv_taskbar_iface, tzsh_srv, NULL);
4571 _tzsh_srv_kvm_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4573 wl_resource_destroy(resource);
4577 _tzsh_srv_kvm_cb_perform_drop(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4579 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4582 tzsh_srv = wl_resource_get_user_data(resource);
4583 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4586 EINA_SAFETY_ON_NULL_RETURN(ec);
4588 if (!e_comp_wl->drag) return;
4590 e_service_kvm_drop_perform(ec);
4594 _tzsh_srv_kvm_cb_cancel_drag(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4596 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4599 tzsh_srv = wl_resource_get_user_data(resource);
4600 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4603 EINA_SAFETY_ON_NULL_RETURN(ec);
4605 if (!e_comp_wl->drag) return;
4607 e_service_kvm_drag_cancel(ec);
4611 _tzsh_srv_kvm_cb_perform_drag_enter(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4613 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4616 tzsh_srv = wl_resource_get_user_data(resource);
4617 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4620 EINA_SAFETY_ON_NULL_RETURN(ec);
4622 if (!e_comp_wl->drag) return;
4624 e_service_kvm_perform_drag_enter(ec);
4628 _tzsh_srv_kvm_cb_perform_drag_leave(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4630 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4633 tzsh_srv = wl_resource_get_user_data(resource);
4634 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4637 EINA_SAFETY_ON_NULL_RETURN(ec);
4639 if (!e_comp_wl->drag) return;
4641 e_service_kvm_perform_drag_leave(ec);
4645 _tzsh_srv_kvm_cb_secondary_selection_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4647 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4650 tzsh_srv = wl_resource_get_user_data(resource);
4651 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4654 EINA_SAFETY_ON_NULL_RETURN(ec);
4656 e_service_kvm_secondary_selection_set(ec, EINA_TRUE);
4660 _tzsh_srv_kvm_cb_secondary_selection_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4662 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4665 tzsh_srv = wl_resource_get_user_data(resource);
4666 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4669 EINA_SAFETY_ON_NULL_RETURN(ec);
4671 e_service_kvm_secondary_selection_set(ec, EINA_FALSE);
4674 static const struct tws_service_kvm_interface _tzsh_srv_kvm_iface =
4676 _tzsh_srv_kvm_cb_destroy,
4677 _tzsh_srv_kvm_cb_perform_drop,
4678 _tzsh_srv_kvm_cb_cancel_drag,
4679 _tzsh_srv_kvm_cb_perform_drag_enter,
4680 _tzsh_srv_kvm_cb_perform_drag_leave,
4681 _tzsh_srv_kvm_cb_secondary_selection_set,
4682 _tzsh_srv_kvm_cb_secondary_selection_unset,
4686 _tzsh_srv_iface_cb_kvm_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4688 E_Service_Kvm *service = NULL;
4689 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4690 struct wl_resource *res;
4693 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4694 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4695 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4697 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4700 res = wl_resource_create(client,
4701 &tws_service_kvm_interface,
4706 wl_client_post_no_memory(client);
4710 ELOGF("KVM", "multi control resource created, res:%p, tzsh_srv:%p, res_tzsh_srv:%p", NULL, res, tzsh_srv, res_tzsh_srv);
4714 service = e_service_kvm_get();
4718 ELOGF("KVM", "multi control resource set. res:%p, service:%p, ec:%p", NULL, res, service, ec);
4719 e_service_kvm_wl_resource_set(service, res);
4722 wl_resource_set_implementation(res, &_tzsh_srv_kvm_iface, tzsh_srv, NULL);
4725 static const struct tws_service_interface _tzsh_srv_iface =
4727 _tzsh_srv_iface_cb_destroy,
4728 _tzsh_srv_iface_cb_region_set,
4729 _tzsh_srv_iface_cb_indicator_get,
4730 _tzsh_srv_iface_cb_quickpanel_get,
4731 _tzsh_srv_iface_cb_scrsaver_mng_get,
4732 _tzsh_srv_iface_cb_scrsaver_get,
4733 _tzsh_srv_iface_cb_cbhm_get,
4734 _tzsh_srv_iface_cb_softkey_get,
4735 _tzsh_srv_iface_cb_magnifier_get,
4736 _tzsh_srv_iface_cb_launcher_get,
4737 _tzsh_srv_iface_cb_taskbar_get,
4738 _tzsh_srv_iface_cb_kvm_get,
4742 _e_policy_wl_tzsh_service_check_privilege(struct wl_client *client, int role)
4744 const char *privilege;
4751 case TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT:
4752 case TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU:
4753 case TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU:
4754 privilege = E_PRIVILEGE_QUICKPANEL_SERVICE;
4756 case TZSH_SRV_ROLE_VOLUME:
4757 privilege = E_PRIVILEGE_VOLUME_SERVICE;
4759 case TZSH_SRV_ROLE_LOCKSCREEN:
4760 privilege = E_PRIVILEGE_LOCKSCREEN_SERVICE;
4762 case TZSH_SRV_ROLE_INDICATOR:
4763 privilege = E_PRIVILEGE_INDICATOR_SERVICE;
4765 case TZSH_SRV_ROLE_SCREENSAVER_MNG:
4766 case TZSH_SRV_ROLE_SCREENSAVER:
4767 privilege = E_PRIVILEGE_SCREENSAVER_SERVICE;
4769 case TZSH_SRV_ROLE_CBHM:
4770 privilege = E_PRIVILEGE_CBHM_SERVICE;
4772 case TZSH_SRV_ROLE_SOFTKEY:
4773 privilege = E_PRIVILEGE_SOFTKEY_SERVICE;
4775 case TZSH_SRV_ROLE_MAGNIFIER:
4776 privilege = E_PRIVILEGE_MAGNIFIER_SERVICE;
4778 case TZSH_SRV_ROLE_LAUNCHER:
4779 privilege = E_PRIVILEGE_LAUNCHER_SERVICE;
4781 case TZSH_SRV_ROLE_TASKBAR:
4782 privilege = E_PRIVILEGE_TASKBAR_SERVICE;
4784 /* TODO: need to check privilege
4785 case TZSH_SRV_ROLE_KVM:
4786 privilege = E_PRIVILEGE_KVM_SERVICE;
4793 wl_client_get_credentials(client, &pid, &uid, NULL);
4794 res = e_security_privilege_check(pid,
4801 _tzsh_cb_srv_destroy(struct wl_resource *res_tzsh_srv)
4803 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4805 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4806 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4808 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4811 _e_policy_wl_tzsh_srv_del(tzsh_srv);
4815 _tzsh_iface_cb_srv_create(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id, const char *name)
4817 E_Policy_Wl_Tzsh *tzsh;
4818 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4819 struct wl_resource *res_tzsh_srv;
4825 role = _e_policy_wl_tzsh_srv_role_get(name);
4826 if (role == TZSH_SRV_ROLE_UNKNOWN)
4828 wl_resource_post_error
4830 WL_DISPLAY_ERROR_INVALID_OBJECT,
4831 "Invalid res_tzsh");
4835 /* check whether client has a privilege */
4836 res = _e_policy_wl_tzsh_service_check_privilege(client, role);
4839 ERR("Could not get privilege of resource: %m");
4840 tizen_ws_shell_send_error(res_tzsh,
4841 TIZEN_WS_SHELL_ERROR_PERMISSION_DENIED);
4845 /* to avoid sending a wayland error after tzsh ERROR_NONE for every cases
4846 * such as invalid object or no memory error, tzsh ERROR_NONE should be sent
4847 * first to clients without privilege problem.
4849 tizen_ws_shell_send_error(res_tzsh, TIZEN_WS_SHELL_ERROR_NONE);
4851 tzsh = wl_resource_get_user_data(res_tzsh);
4854 wl_resource_post_error
4856 WL_DISPLAY_ERROR_INVALID_OBJECT,
4857 "Invalid res_tzsh's user data");
4861 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
4864 if (role == TZSH_SRV_ROLE_INDICATOR)
4865 cp = e_pixmap_new(E_PIXMAP_TYPE_NONE, 0);
4869 wl_resource_post_error
4871 WL_DISPLAY_ERROR_INVALID_OBJECT,
4872 "Invalid surface id");
4877 ec = e_pixmap_client_get(cp);
4880 if (role == TZSH_SRV_ROLE_INDICATOR)
4882 ec = e_client_new(cp, 0, 1);
4883 if (ec) ec->ignored = 1;
4889 if (!_e_policy_wl_e_client_is_valid(ec))
4891 wl_resource_post_error
4893 WL_DISPLAY_ERROR_INVALID_OBJECT,
4894 "Invalid surface id");
4899 res_tzsh_srv = wl_resource_create(client,
4900 &tws_service_interface,
4901 wl_resource_get_version(res_tzsh),
4905 ERR("Could not create tws_service resource: %m");
4906 wl_client_post_no_memory(client);
4910 tzsh_srv = _e_policy_wl_tzsh_srv_add(tzsh,
4918 ERR("Could not create WS_Shell_Service");
4919 wl_client_post_no_memory(client);
4920 wl_resource_destroy(res_tzsh_srv);
4924 wl_resource_set_implementation(res_tzsh_srv,
4927 _tzsh_cb_srv_destroy);
4929 if (tzsh_srv->ec->maximized)
4930 e_client_maximize(ec, E_MAXIMIZE_FULLSCREEN | E_MAXIMIZE_BOTH);
4932 if (role == TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT)
4933 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_SYSTEM_DEFAULT);
4934 else if (role == TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU)
4935 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_CONTEXT_MENU);
4936 else if (role == TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU)
4937 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_APPS_MENU);
4938 else if (role == TZSH_SRV_ROLE_VOLUME)
4939 e_service_volume_client_set(tzsh_srv->ec);
4940 else if (role == TZSH_SRV_ROLE_LOCKSCREEN)
4941 e_service_lockscreen_client_set(tzsh_srv->ec);
4942 else if (role == TZSH_SRV_ROLE_SCREENSAVER_MNG)
4943 e_service_scrsaver_client_set(tzsh_srv->ec);
4944 else if (role == TZSH_SRV_ROLE_SCREENSAVER)
4945 e_service_scrsaver_client_set(tzsh_srv->ec);
4946 else if (role == TZSH_SRV_ROLE_INDICATOR)
4947 e_mod_indicator_client_set(tzsh_srv->ec);
4948 else if (role == TZSH_SRV_ROLE_CBHM)
4949 e_service_cbhm_client_set(tzsh_srv->ec);
4950 else if (role == TZSH_SRV_ROLE_SOFTKEY)
4951 e_service_softkey_client_set(tzsh_srv->ec);
4952 else if (role == TZSH_SRV_ROLE_MAGNIFIER)
4955 e_magnifier_owner_set(tzsh_srv->ec);
4957 else if (role == TZSH_SRV_ROLE_LAUNCHER)
4958 e_service_launcher_client_set(tzsh_srv->ec);
4959 else if (role == TZSH_SRV_ROLE_TASKBAR)
4960 e_service_taskbar_client_set(tzsh_srv->ec);
4961 else if (role == TZSH_SRV_ROLE_KVM)
4962 e_service_kvm_client_set(tzsh_srv->ec);
4964 e_client_desk_iconify_skip_set(tzsh_srv->ec, EINA_TRUE);
4967 // --------------------------------------------------------
4968 // tizen_ws_shell common
4969 // --------------------------------------------------------
4971 e_tzsh_extension_add(const char *name, E_Policy_Wl_Tzsh_Ext_Hook_Cb cb)
4973 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
4975 if (_e_policy_wl_tzsh_extension_get(name))
4977 ERR("Already exists the %s extension\n", name);
4981 tzsh_ext = E_NEW(E_Policy_Wl_Tzsh_Extension, 1);
4982 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_ext, EINA_FALSE);
4984 tzsh_ext->name = strndup(name, 512);
4987 polwl->tzsh_extensions = eina_list_append(polwl->tzsh_extensions, tzsh_ext);
4989 "EXTENSION_ADD | name:%s | cb:%p",
4997 e_tzsh_extension_del(const char *name)
4999 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5001 tzsh_ext = _e_policy_wl_tzsh_extension_get(name);
5004 ERR("Cannot find the %s extension\n", name);
5008 polwl->tzsh_extensions = eina_list_remove(polwl->tzsh_extensions, tzsh_ext);
5009 memset(tzsh_ext, 0x0, sizeof(E_Policy_Wl_Tzsh_Extension));
5013 "EXTENSION_DEL | name:%s",
5018 // --------------------------------------------------------
5019 // tizen_ws_shell_interface::region
5020 // --------------------------------------------------------
5022 _tzsh_reg_cb_shell_destroy(struct wl_listener *listener, void *data)
5024 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5026 tzsh_reg = container_of(listener, E_Policy_Wl_Tzsh_Region, destroy_listener);
5027 if (tzsh_reg->destroy_listener.notify)
5029 wl_list_remove(&tzsh_reg->destroy_listener.link);
5030 tzsh_reg->destroy_listener.notify = NULL;
5033 if (tzsh_reg->res_tzsh_reg)
5035 wl_resource_destroy(tzsh_reg->res_tzsh_reg);
5036 tzsh_reg->res_tzsh_reg = NULL;
5041 _tzsh_reg_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_reg)
5043 wl_resource_destroy(res_tzsh_reg);
5047 _tzsh_reg_iface_cb_add(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_reg, int32_t x, int32_t y, int32_t w, int32_t h)
5049 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5051 int area_w = 0, area_h = 0;
5053 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5054 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5055 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg->tiler);
5057 eina_tiler_area_size_get(tzsh_reg->tiler, &area_w, &area_h);
5058 src = eina_tiler_new(area_w, area_h);
5059 eina_tiler_tile_size_set(src, 1, 1);
5060 eina_tiler_rect_add(src, &(Eina_Rectangle){x, y, w, h});
5061 eina_tiler_union(tzsh_reg->tiler, src);
5062 eina_tiler_free(src);
5066 _tzsh_reg_iface_cb_subtract(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_reg, int32_t x, int32_t y, int32_t w, int32_t h)
5068 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5070 int area_w = 0, area_h = 0;
5072 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5073 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5074 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg->tiler);
5076 eina_tiler_area_size_get(tzsh_reg->tiler, &area_w, &area_h);
5077 src = eina_tiler_new(area_w, area_h);
5078 eina_tiler_tile_size_set(src, 1, 1);
5079 eina_tiler_rect_add(src, &(Eina_Rectangle){x, y, w, h});
5080 eina_tiler_subtract(tzsh_reg->tiler, src);
5081 eina_tiler_free(src);
5084 static const struct tws_region_interface _tzsh_reg_iface =
5086 _tzsh_reg_iface_cb_destroy,
5087 _tzsh_reg_iface_cb_add,
5088 _tzsh_reg_iface_cb_subtract
5092 _tzsh_reg_cb_destroy(struct wl_resource *res_tzsh_reg)
5094 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5096 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5097 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5099 if (tzsh_reg->destroy_listener.notify)
5101 wl_list_remove(&tzsh_reg->destroy_listener.link);
5102 tzsh_reg->destroy_listener.notify = NULL;
5104 eina_tiler_free(tzsh_reg->tiler);
5110 _tzsh_iface_cb_reg_create(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id)
5112 E_Policy_Wl_Tzsh *tzsh;
5113 E_Policy_Wl_Tzsh_Region *tzsh_reg = NULL;
5114 Eina_Tiler *tz = NULL;
5115 struct wl_resource *res_tzsh_reg;
5118 tzsh = wl_resource_get_user_data(res_tzsh);
5121 wl_resource_post_error
5123 WL_DISPLAY_ERROR_INVALID_OBJECT,
5124 "Invalid res_tzsh's user data");
5128 tzsh_reg = E_NEW(E_Policy_Wl_Tzsh_Region, 1);
5129 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5131 e_zone_useful_geometry_get(e_zone_current_get(),
5132 NULL, NULL, &zw, &zh);
5134 tz = eina_tiler_new(zw, zh);
5135 EINA_SAFETY_ON_NULL_GOTO(tz, err);
5136 tzsh_reg->tiler = tz;
5138 eina_tiler_tile_size_set(tzsh_reg->tiler, 1, 1);
5140 if (!(res_tzsh_reg = wl_resource_create(client,
5141 &tws_region_interface,
5142 wl_resource_get_version(res_tzsh),
5145 ERR("Could not create tws_service resource: %m");
5146 wl_client_post_no_memory(client);
5150 wl_resource_set_implementation(res_tzsh_reg,
5153 _tzsh_reg_cb_destroy);
5155 tzsh_reg->tzsh = tzsh;
5156 tzsh_reg->res_tzsh_reg = res_tzsh_reg;
5157 tzsh_reg->destroy_listener.notify = _tzsh_reg_cb_shell_destroy;
5159 wl_resource_add_destroy_listener(res_tzsh,
5160 &tzsh_reg->destroy_listener);
5164 if (tzsh_reg->tiler) eina_tiler_free(tzsh_reg->tiler);
5168 // --------------------------------------------------------
5169 // tizen_ws_shell_interface::indicator
5170 // --------------------------------------------------------
5172 _e_tzsh_indicator_find_topvisible_client(E_Zone *zone)
5178 o = evas_object_top_get(e_comp->evas);
5179 for (; o; o = evas_object_below_get(o))
5181 ec = evas_object_data_get(o, "E_Client");
5183 /* check e_client and skip e_clients not intersects with zone */
5185 if (e_object_is_del(E_OBJECT(ec))) continue;
5186 if (e_client_util_ignored_get(ec)) continue;
5187 if (!e_zone_has_ec(zone, ec)) continue;
5188 if (!ec->frame) continue;
5190 if (!ec->visible) continue;
5191 if (ec->visibility.skip) continue;
5192 if ((ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) &&
5193 (ec->visibility.obscured != E_VISIBILITY_PARTIALLY_OBSCURED) &&
5194 (!eina_list_data_find(e_comp->launchscrns, ec)))
5197 if (e_comp_wl_subsurface_check(ec)) continue;
5199 e_client_geometry_get(ec, &ex, &ey, &ew, &eh);
5200 if (!E_CONTAINS(ex, ey, ew, eh, zone->x, zone->y, zone->w, zone->h))
5211 e_tzsh_indicator_srv_property_change_send(E_Client *ec, int angle)
5216 if (!_indicator_srv_res)
5218 ELOGF("TZ_IND", "NO indicator service", NULL);
5222 opacity = ec->indicator.opacity_mode;
5224 ELOGF("TZ_IND", "SEND indicator info. angle:%d, opacity:%d", ec, angle, opacity);
5225 tws_service_indicator_send_property_change(_indicator_srv_res, angle, opacity);
5229 e_tzsh_indicator_srv_property_update(E_Client *ec)
5231 E_Client *ec_ind_owner;
5232 if (!_indicator_srv_res) return;
5234 ec_ind_owner = e_mod_indicator_owner_get();
5235 if (ec != ec_ind_owner) return;
5237 if (ec->e.state.rot.ang.next != -1)
5238 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.next);
5240 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.curr);
5244 e_tzsh_indicator_srv_ower_win_update(E_Zone *zone)
5246 E_Client *ec = NULL;
5247 E_Client *ec_cur_owner = NULL;
5250 if (!_indicator_srv_res) return;
5252 ec_cur_owner = e_mod_indicator_owner_get();
5253 ec = _e_tzsh_indicator_find_topvisible_client(zone);
5255 if (ec != ec_cur_owner)
5257 ELOGF("TZ_IND", "Changed OWNER. win:%zx, state:%d, opacity:%d, vtype:%d", NULL, e_client_util_win_get(ec),
5258 ec ? ec->indicator.state:-1, ec ? ec->indicator.opacity_mode:-1, ec ? ec->indicator.visible_type:-1);
5259 e_mod_indicator_owner_set(ec);
5261 if (ec && !ec->e.state.rot.pending_show)
5263 ELOGF("TZ_IND", "Property Update. name:%s curr:%d, next:%d", NULL, ec->icccm.name?:"NULL",
5264 ec->e.state.rot.ang.curr, ec->e.state.rot.ang.next);
5265 e_tzsh_indicator_srv_property_update(ec);
5270 // --------------------------------------------------------
5271 // tizen_ws_shell_interface::quickpanel
5272 // --------------------------------------------------------
5274 _tzsh_client_data_quickpanel_type_set(E_Policy_Wl_Tzsh_Client_Data_Quickpanel *quickpanel_client, E_Quickpanel_Type type)
5276 if (quickpanel_client)
5277 quickpanel_client->type = type;
5280 static E_Quickpanel_Type
5281 _tzsh_client_data_quickpanel_type_get(E_Policy_Wl_Tzsh_Client_Data_Quickpanel *quickpanel_client)
5283 if (!quickpanel_client)
5284 return E_QUICKPANEL_TYPE_UNKNOWN;
5286 return quickpanel_client->type;
5290 _e_tzsh_qp_state_change_send(struct wl_resource *res_tzsh_client, int type, int value)
5292 struct wl_array states;
5293 E_Tzsh_QP_Event *ev;
5295 if (!res_tzsh_client) return;
5297 wl_array_init(&states);
5298 ev = wl_array_add(&states, sizeof(E_Tzsh_QP_Event));
5304 tws_quickpanel_send_state_changed(res_tzsh_client, &states);
5306 wl_array_release(&states);
5310 _e_tzsh_qp_client_data_type_check(E_Policy_Wl_Tzsh_Client *tzsh_client, E_Quickpanel_Type type)
5312 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5317 if (tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL)
5320 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5321 if (!tzsh_client_quickpanel)
5324 if (_tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel) != type)
5331 e_tzsh_qp_state_visible_update(E_Client *ec, Eina_Bool vis, E_Quickpanel_Type type)
5333 E_Policy_Wl_Tzsh_Client *tzsh_client;
5338 if (e_object_is_del(E_OBJECT(ec))) return;
5340 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5342 /* check for type of qp */
5343 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5345 if (!tzsh_client->tzsh) continue;
5346 if (!tzsh_client->ec) continue;
5348 if (tzsh_client->ep == ec->pixmap)
5350 if (tzsh_client->ec != ec)
5353 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5362 val = vis ? TWS_QUICKPANEL_STATE_VALUE_VISIBLE_SHOW : TWS_QUICKPANEL_STATE_VALUE_VISIBLE_HIDE;
5363 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5364 TWS_QUICKPANEL_STATE_TYPE_VISIBILITY,
5371 e_tzsh_qp_state_scrollable_update(E_Client *ec, Eina_Bool scrollable, E_Quickpanel_Type type)
5373 E_Policy_Wl_Tzsh_Client *tzsh_client;
5378 if (e_object_is_del(E_OBJECT(ec))) return;
5380 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5382 /* check for type of qp */
5383 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5385 if (!tzsh_client->tzsh) continue;
5386 if (!tzsh_client->ec) continue;
5388 if (tzsh_client->ep == ec->pixmap)
5390 if (tzsh_client->ec != ec)
5393 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5402 val = scrollable ? TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET : TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET;
5403 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5404 TWS_QUICKPANEL_STATE_TYPE_SCROLLABLE,
5411 e_tzsh_qp_state_orientation_update(E_Client *ec, int ridx, E_Quickpanel_Type type)
5413 E_Policy_Wl_Tzsh_Client *tzsh_client;
5418 if (e_object_is_del(E_OBJECT(ec))) return;
5420 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5422 /* check for type of qp */
5423 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5425 if (!tzsh_client->tzsh) continue;
5426 if (!tzsh_client->ec) continue;
5428 if (tzsh_client->ep == ec->pixmap)
5430 if (tzsh_client->ec != ec)
5433 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5442 val = TWS_QUICKPANEL_STATE_VALUE_ORIENTATION_0 + ridx;
5443 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5444 TWS_QUICKPANEL_STATE_TYPE_ORIENTATION,
5451 _tzsh_qp_iface_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5453 wl_resource_destroy(res_tzsh_qp);
5456 static E_Quickpanel_Type
5457 _e_tzsh_qp_type_get(E_Policy_Wl_Tzsh_Client *tzsh_client)
5459 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5460 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5461 if (!tzsh_client_quickpanel)
5462 return E_QUICKPANEL_TYPE_UNKNOWN;
5464 return _tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel);
5469 _tzsh_qp_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5471 E_Policy_Wl_Tzsh_Client *tzsh_client;
5474 ELOGF("TZ_QUICKPANEL", "Request to Show Quickpanel", NULL);
5476 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5477 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5478 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5479 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5480 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5482 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5483 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5485 ec = tzsh_client->ec;
5487 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5490 e_qp_client_show(ec, qp_type);
5494 _tzsh_qp_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5496 E_Policy_Wl_Tzsh_Client *tzsh_client;
5499 ELOGF("TZ_QUICKPANEL", "Request to Hide Quickpanel", NULL);
5501 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5502 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5503 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5504 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5505 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5507 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5508 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5510 ec = tzsh_client->ec;
5512 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5515 e_qp_client_hide(ec, qp_type);
5519 _tzsh_qp_iface_cb_enable(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5521 E_Policy_Wl_Tzsh_Client *tzsh_client;
5524 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state of Quickpanel to 1", NULL);
5526 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5527 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5528 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5529 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5530 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5532 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5533 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5535 ec = tzsh_client->ec;
5537 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5540 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_SET);
5544 _tzsh_qp_iface_cb_disable(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5546 E_Policy_Wl_Tzsh_Client *tzsh_client;
5549 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state of Quickpanel to 0", NULL);
5551 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5552 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5553 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5554 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5555 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5557 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5558 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5560 ec = tzsh_client->ec;
5562 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5565 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET);
5569 _tzsh_qp_iface_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, int32_t type)
5571 E_Policy_Wl_Tzsh_Client *tzsh_client;
5574 E_Quickpanel_Client_Scroll_State scrollable;
5576 int val = TWS_QUICKPANEL_STATE_VALUE_UNKNOWN;
5578 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5579 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5580 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5581 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5582 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5584 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5585 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5587 ec = tzsh_client->ec;
5589 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5594 case TWS_QUICKPANEL_STATE_TYPE_VISIBILITY:
5595 val = TWS_QUICKPANEL_STATE_VALUE_VISIBLE_HIDE;
5596 vis = e_qp_visible_get(ec, qp_type);
5597 if (vis) val = TWS_QUICKPANEL_STATE_VALUE_VISIBLE_SHOW;
5599 case TWS_QUICKPANEL_STATE_TYPE_SCROLLABLE:
5600 scrollable = e_qp_client_scrollable_state_get(ec, qp_type);
5601 if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET)
5602 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET;
5603 else if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_SET)
5604 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET;
5605 else if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_RETAIN)
5606 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_RETAIN;
5608 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET;
5610 case TWS_QUICKPANEL_STATE_TYPE_ORIENTATION:
5611 ridx = e_qp_orientation_get(ec, qp_type);
5612 val = TWS_QUICKPANEL_STATE_VALUE_ORIENTATION_0 + ridx;
5618 tws_quickpanel_send_state_get_done(res_tzsh_qp, type, val, 0);
5622 _tzsh_qp_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, uint32_t type)
5624 E_Policy_Wl_Tzsh_Client *tzsh_client;
5627 ELOGF("TZ_QUICKPANEL", "Request to Set type of Quickpanel to %d", NULL, type);
5629 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5630 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5631 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5632 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5633 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5635 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5636 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5637 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_quickpanel);
5639 E_Quickpanel_Type qp_type = _tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel);
5640 EINA_SAFETY_ON_TRUE_RETURN(qp_type != E_QUICKPANEL_TYPE_UNKNOWN);
5642 _tzsh_client_data_quickpanel_type_set(tzsh_client_quickpanel, type);
5644 ec = tzsh_client->ec;
5646 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5649 /* Since various types of qp are supported, one ec can be used for handler for
5650 * two or more qp types. So e_qp_client_add function is called at the callback
5651 * of qp_type_set, because it is easy to add the E_QP_Client instance after setting
5652 * of qp type is completed.
5654 e_qp_client_add(ec, type);
5658 _tzsh_qp_iface_cb_scrollable_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, int32_t state)
5660 E_Policy_Wl_Tzsh_Client *tzsh_client;
5663 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state to %d", NULL, state);
5665 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5666 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5667 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5668 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5669 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5671 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5672 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5674 ec = tzsh_client->ec;
5675 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5678 if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET)
5679 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET);
5680 else if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET)
5681 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_SET);
5682 else if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_RETAIN)
5683 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_RETAIN);
5686 static const struct tws_quickpanel_interface _tzsh_qp_iface =
5688 _tzsh_qp_iface_cb_release,
5689 _tzsh_qp_iface_cb_show,
5690 _tzsh_qp_iface_cb_hide,
5691 _tzsh_qp_iface_cb_enable,
5692 _tzsh_qp_iface_cb_disable,
5693 _tzsh_qp_iface_cb_state_get,
5694 _tzsh_qp_iface_cb_type_set,
5695 _tzsh_qp_iface_cb_scrollable_state_set
5699 _tzsh_cb_qp_destroy(struct wl_resource *res_tzsh_qp)
5701 E_Policy_Wl_Tzsh_Client *tzsh_client;
5703 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5704 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5706 E_Quickpanel_Type qp_type =
5707 _tzsh_client_data_quickpanel_type_get((E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data);
5708 e_qp_client_del(tzsh_client->ec, qp_type);
5710 E_FREE(tzsh_client->client_data);
5712 tzsh_client->res_tzsh_client = NULL;
5713 _e_policy_wl_tzsh_client_del(tzsh_client);
5716 static E_Policy_Wl_Tzsh_Client_Data_Quickpanel *
5717 _tzsh_client_data_quickpanel_new(void)
5719 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5721 tzsh_client_quickpanel = E_NEW(E_Policy_Wl_Tzsh_Client_Data_Quickpanel, 1);
5722 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client_quickpanel, NULL);
5724 tzsh_client_quickpanel->type = E_QUICKPANEL_TYPE_UNKNOWN;
5725 return tzsh_client_quickpanel;
5729 _tzsh_iface_cb_qp_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id)
5731 E_Policy_Wl_Tzsh *tzsh;
5732 E_Policy_Wl_Tzsh_Client *tzsh_client;
5733 struct wl_resource *res_tzsh_qp;
5737 tzsh = wl_resource_get_user_data(res_tzsh);
5740 wl_resource_post_error
5742 WL_DISPLAY_ERROR_INVALID_OBJECT,
5743 "Invalid res_tzsh's user data");
5747 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
5750 wl_resource_post_error
5752 WL_DISPLAY_ERROR_INVALID_OBJECT,
5753 "Invalid surface id");
5757 ec = e_pixmap_client_get(cp);
5760 if (!_e_policy_wl_e_client_is_valid(ec))
5762 wl_resource_post_error
5764 WL_DISPLAY_ERROR_INVALID_OBJECT,
5765 "Invalid surface id");
5770 res_tzsh_qp = wl_resource_create(client,
5771 &tws_quickpanel_interface,
5772 wl_resource_get_version(res_tzsh),
5776 ERR("Could not create tws_quickpanel resource: %m");
5777 wl_client_post_no_memory(client);
5781 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_qp, cp, ec);
5784 ERR("Could not create tzsh_client");
5785 wl_client_post_no_memory(client);
5789 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL;
5790 tzsh_client->client_data = _tzsh_client_data_quickpanel_new();
5791 if (!tzsh_client->client_data)
5793 ERR("Could not create tzsh_client");
5794 wl_client_post_no_memory(client);
5798 /* Since various types of qp are supported, one ec can be used for handler for
5799 * two or more qp types. So e_qp_client_add function is called at the callback
5800 * of qp_type_set, because it is easy to add the E_QP_Client instance after setting
5801 * of qp type is completed.
5803 //e_qp_client_add(tzsh->ec);
5805 wl_resource_set_implementation(res_tzsh_qp,
5808 _tzsh_cb_qp_destroy);
5811 static void _tzsh_iface_cb_extension_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, const char *name)
5813 E_Policy_Wl_Tzsh *tzsh;
5814 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5815 struct wl_resource *res_ext;
5817 tzsh = wl_resource_get_user_data(res_tzsh);
5820 wl_resource_post_error
5822 WL_DISPLAY_ERROR_INVALID_OBJECT,
5823 "Invalid res_tzsh's user data");
5827 tzsh_ext = _e_policy_wl_tzsh_extension_get(name);
5830 ERR("Could not find tzsh_extension(%s)", name);
5831 wl_resource_post_error
5833 WL_DISPLAY_ERROR_INVALID_OBJECT,
5834 "unregistered ext:%s", name);
5838 res_ext = tzsh_ext->cb(client, res_tzsh, id);
5841 ERR("Could not create extension(%s) resource", name);
5842 wl_resource_post_error
5844 WL_DISPLAY_ERROR_INVALID_OBJECT,
5845 "Unknown error:%s", name);
5850 // --------------------------------------------------------
5851 // tizen_ws_shell_interface::softkey
5852 // --------------------------------------------------------
5854 _tzsh_softkey_iface_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5856 wl_resource_destroy(res_tzsh_softkey);
5860 _tzsh_softkey_iface_cb_support_check(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5862 E_Policy_Wl_Tzsh_Client *tzsh_client;
5865 ELOGF("TZ_SOFTKEY", "Request to Check supporting softkey", NULL);
5867 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
5868 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5869 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5870 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5872 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5875 if (e_config->use_softkey || e_config->use_softkey_service)
5880 ELOGF("TZ_SOFTKEY", "Send SUPPORT_CHECK_DONE. support:%d", NULL, support);
5881 tws_softkey_send_support_check_done(res_tzsh_softkey, support);
5885 _tzsh_softkey_show(E_Policy_Wl_Tzsh_Client *tzsh_client)
5890 zone = tzsh_client->zone;
5892 ec = tzsh_client->ec;
5895 if (e_config->use_softkey)
5897 E_Policy_Softkey *softkey;
5898 softkey = e_policy_softkey_get(zone);
5901 ELOGF("TZ_SOFTKEY", "SHOW softkey", ec);
5902 e_policy_softkey_show(softkey);
5906 if (e_config->use_softkey_service)
5908 E_Service_Softkey *softkey_service;
5909 softkey_service = e_service_softkey_get(zone);
5910 if (softkey_service)
5912 ELOGF("TZ_SOFTKEY", "Request to SHOW softkey service. (service:%p)", ec, softkey_service);
5913 e_service_softkey_visible_set(softkey_service, 1);
5917 ELOGF("TZ_SOFTKEY", "There is no softkey service. store show request", ec);
5918 e_service_softkey_store_visible_request(ec, 1);
5924 _tzsh_softkey_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5926 E_Policy_Wl_Tzsh_Client *tzsh_client;
5928 ELOGF("TZ_SOFTKEY", "Request to Show softkey", NULL);
5930 if (!e_config->use_softkey && !e_config->use_softkey_service)
5933 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
5934 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5935 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5936 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5938 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5941 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
5942 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
5943 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_data_softkey);
5945 if (tzsh_client_data_softkey->show_state == 1)
5948 tzsh_client_data_softkey->show_state = 1;
5949 _tzsh_softkey_show(tzsh_client);
5953 _tzsh_softkey_hide(E_Policy_Wl_Tzsh_Client *tzsh_client)
5958 zone = tzsh_client->zone;
5960 ec = tzsh_client->ec;
5963 if (e_config->use_softkey)
5965 E_Policy_Softkey *softkey;
5966 softkey = e_policy_softkey_get(zone);
5969 ELOGF("TZ_SOFTKEY", "HIDE softkey", NULL);
5970 e_policy_softkey_hide(softkey);
5974 if (e_config->use_softkey_service)
5976 E_Service_Softkey *softkey_service;
5977 softkey_service = e_service_softkey_get(zone);
5978 if (softkey_service)
5980 ELOGF("TZ_SOFTKEY", "Request to HIDE softkey service. (service:%p)", ec, softkey_service);
5981 e_service_softkey_visible_set(softkey_service, 0);
5985 ELOGF("TZ_SOFTKEY", "There is no softkey service. store hide request", ec);
5986 e_service_softkey_store_visible_request(ec, 0);
5992 _tzsh_softkey_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5994 E_Policy_Wl_Tzsh_Client *tzsh_client;
5996 ELOGF("TZ_SOFTKEY", "Request to Hide softkey", NULL);
5998 if (!e_config->use_softkey && !e_config->use_softkey_service)
6001 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6002 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6003 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6004 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6006 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6009 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6010 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
6011 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_data_softkey);
6013 if (tzsh_client_data_softkey->show_state == 0)
6016 tzsh_client_data_softkey->show_state = 0;
6017 _tzsh_softkey_hide(tzsh_client);
6021 _tzsh_softkey_iface_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey, int32_t type, int32_t val)
6023 E_Policy_Wl_Tzsh_Client *tzsh_client;
6024 E_Policy_Softkey_Expand expand;
6025 E_Policy_Softkey_Opacity opacity;
6027 ELOGF("TZ_SOFTKEY", "Request to Set state (tz_type:%d, tz_val:%d)", NULL, type, val);
6029 if (!e_config->use_softkey && !e_config->use_softkey_service)
6032 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6033 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6034 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6035 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6037 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6040 if (e_config->use_softkey)
6042 E_Policy_Softkey *softkey;
6043 softkey = e_policy_softkey_get(tzsh_client->zone);
6044 if (!softkey) return;
6048 case TWS_SOFTKEY_STATE_EXPAND:
6049 if (val == TWS_SOFTKEY_STATE_EXPAND_ON)
6050 expand = E_POLICY_SOFTKEY_EXPAND_ON;
6052 expand = E_POLICY_SOFTKEY_EXPAND_OFF;
6054 ELOGF("TZ_SOFTKEY", "Set EXPAND state to %d", NULL, expand);
6055 e_policy_softkey_expand_set(softkey, expand);
6058 case TWS_SOFTKEY_STATE_OPACITY:
6059 if (val == TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT)
6060 opacity = E_POLICY_SOFTKEY_OPACITY_TRANSPARENT;
6062 opacity = E_POLICY_SOFTKEY_OPACITY_OPAQUE;
6064 ELOGF("TZ_SOFTKEY", "Set OPACITY state to %d", NULL, opacity);
6065 e_policy_softkey_opacity_set(softkey, opacity);
6073 if (e_config->use_softkey_service)
6075 E_Service_Softkey *softkey_service;
6077 softkey_service = e_service_softkey_get(tzsh_client->zone);
6078 if (!softkey_service) return;
6082 case TWS_SOFTKEY_STATE_EXPAND:
6083 if (val == TWS_SOFTKEY_STATE_EXPAND_ON)
6084 expand = E_POLICY_SOFTKEY_EXPAND_ON;
6086 expand = E_POLICY_SOFTKEY_EXPAND_OFF;
6088 ELOGF("TZ_SOFTKEY", "Request to Change EXPAND state to %d. (service:%p)", NULL, expand, softkey_service);
6089 e_service_softkey_expand_set(softkey_service, expand);
6092 case TWS_SOFTKEY_STATE_OPACITY:
6093 if (val == TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT)
6094 opacity = E_POLICY_SOFTKEY_OPACITY_TRANSPARENT;
6096 opacity = E_POLICY_SOFTKEY_OPACITY_OPAQUE;
6098 ELOGF("TZ_SOFTKEY", "Request to Change OPACITY state to %d. (service:%p)", NULL, opacity, softkey_service);
6099 e_service_softkey_opacity_set(softkey_service, opacity);
6109 _tzsh_softkey_iface_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey, int32_t type)
6111 E_Policy_Wl_Tzsh_Client *tzsh_client;
6112 E_Policy_Softkey_Expand expand;
6113 E_Policy_Softkey_Opacity opacity;
6118 ELOGF("TZ_SOFTKEY", "Request to Get state (tz_type:%d)", NULL, type);
6120 if (!e_config->use_softkey && !e_config->use_softkey_service)
6123 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6124 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6125 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6126 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6127 zone = tzsh_client->zone;
6128 EINA_SAFETY_ON_NULL_RETURN(zone);
6130 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6133 if (e_config->use_softkey)
6135 E_Policy_Softkey *softkey;
6136 softkey = e_policy_softkey_get(zone);
6137 if (!softkey) return;
6141 case TWS_SOFTKEY_STATE_VISIBLE:
6142 visible = e_policy_softkey_visible_get(softkey);
6144 val = TWS_SOFTKEY_STATE_VISIBLE_SHOW;
6146 val = TWS_SOFTKEY_STATE_VISIBLE_HIDE;
6148 ELOGF("TZ_SOFTKEY", "Send current VISIBLE state: %d (tz_val:%d)", NULL, visible, val);
6149 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6152 case TWS_SOFTKEY_STATE_EXPAND:
6153 e_policy_softkey_expand_get(softkey, &expand);
6154 if (expand == E_POLICY_SOFTKEY_EXPAND_ON)
6155 val = TWS_SOFTKEY_STATE_EXPAND_ON;
6157 val = TWS_SOFTKEY_STATE_EXPAND_OFF;
6159 ELOGF("TZ_SOFTKEY", "Send current EXPAND state: %d (tz_val:%d)", NULL, expand, val);
6160 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6163 case TWS_SOFTKEY_STATE_OPACITY:
6164 e_policy_softkey_opacity_get(softkey, &opacity);
6165 if (opacity == E_POLICY_SOFTKEY_OPACITY_TRANSPARENT)
6166 val = TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT;
6168 val = TWS_SOFTKEY_STATE_OPACITY_OPAQUE;
6170 ELOGF("TZ_SOFTKEY", "Send current OPACITY state: %d (tz_val:%d)", NULL, opacity, val);
6171 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6179 if (e_config->use_softkey_service)
6181 E_Service_Softkey *softkey_service;
6182 softkey_service = e_service_softkey_get(zone);
6183 if (!softkey_service) return;
6187 case TWS_SOFTKEY_STATE_VISIBLE:
6188 visible = e_service_softkey_visible_get(softkey_service);
6190 val = TWS_SOFTKEY_STATE_VISIBLE_SHOW;
6192 val = TWS_SOFTKEY_STATE_VISIBLE_HIDE;
6194 ELOGF("TZ_SOFTKEY", "Send service's current VISIBLE state: %d (tz_val:%d)", NULL, visible, val);
6195 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6198 case TWS_SOFTKEY_STATE_EXPAND:
6199 e_service_softkey_expand_get(softkey_service, &expand);
6200 if (expand == E_POLICY_SOFTKEY_EXPAND_ON)
6201 val = TWS_SOFTKEY_STATE_EXPAND_ON;
6203 val = TWS_SOFTKEY_STATE_EXPAND_OFF;
6205 ELOGF("TZ_SOFTKEY", "Send service's current EXPAND state: %d (tz_val:%d)", NULL, expand, val);
6206 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6209 case TWS_SOFTKEY_STATE_OPACITY:
6210 e_service_softkey_opacity_get(softkey_service, &opacity);
6211 if (opacity == E_POLICY_SOFTKEY_OPACITY_TRANSPARENT)
6212 val = TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT;
6214 val = TWS_SOFTKEY_STATE_OPACITY_OPAQUE;
6216 ELOGF("TZ_SOFTKEY", "Send service's current OPACITY state: %d (tz_val:%d)", NULL, opacity, val);
6217 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6226 static const struct tws_softkey_interface _tzsh_softkey_iface =
6228 _tzsh_softkey_iface_cb_release,
6229 _tzsh_softkey_iface_cb_support_check,
6230 _tzsh_softkey_iface_cb_show,
6231 _tzsh_softkey_iface_cb_hide,
6232 _tzsh_softkey_iface_cb_state_set,
6233 _tzsh_softkey_iface_cb_state_get
6236 static E_Policy_Wl_Tzsh_Client_Data_Softkey *
6237 _tzsh_client_data_softkey_new(void)
6239 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6241 tzsh_client_data_softkey = E_NEW(E_Policy_Wl_Tzsh_Client_Data_Softkey, 1);
6242 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client_data_softkey, NULL);
6244 tzsh_client_data_softkey->show_state = 1;
6245 return tzsh_client_data_softkey;
6249 _tzsh_cb_softkey_destroy(struct wl_resource *res_tzsh_softkey)
6251 E_Policy_Wl_Tzsh_Client *tzsh_client;
6253 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6254 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6256 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6257 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
6258 if (tzsh_client_data_softkey)
6260 if (tzsh_client_data_softkey->show_state == 0)
6262 ELOGF("TZ_SOFTKEY", "Request to Show softkey by destroying client", NULL);
6263 _tzsh_softkey_show(tzsh_client);
6266 E_FREE(tzsh_client->client_data);
6268 tzsh_client->res_tzsh_client = NULL;
6269 _e_policy_wl_tzsh_client_del(tzsh_client);
6274 _tzsh_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id)
6276 E_Policy_Wl_Tzsh *tzsh;
6277 E_Policy_Wl_Tzsh_Client *tzsh_client;
6278 struct wl_resource *res_tzsh_softkey;
6284 tzsh = wl_resource_get_user_data(res_tzsh);
6287 wl_resource_post_error
6289 WL_DISPLAY_ERROR_INVALID_OBJECT,
6290 "Invalid res_tzsh's user data");
6294 wl_client_get_credentials(client, &pid, &uid, NULL);
6295 if (!e_security_privilege_check(pid, uid, E_PRIVILEGE_SOFTKEY))
6297 ERR("Could not get privilege of resource: %m");
6298 tizen_ws_shell_send_error(tzsh->res_tzsh, TIZEN_WS_SHELL_ERROR_PERMISSION_DENIED);
6302 tizen_ws_shell_send_error(tzsh->res_tzsh, TIZEN_WS_SHELL_ERROR_NONE);
6304 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
6307 wl_resource_post_error
6309 WL_DISPLAY_ERROR_INVALID_OBJECT,
6310 "Invalid surface id");
6314 ec = e_pixmap_client_get(cp);
6317 if (!_e_policy_wl_e_client_is_valid(ec))
6319 wl_resource_post_error
6321 WL_DISPLAY_ERROR_INVALID_OBJECT,
6322 "Invalid surface id");
6327 res_tzsh_softkey = wl_resource_create(client,
6328 &tws_softkey_interface,
6329 wl_resource_get_version(res_tzsh),
6331 if (!res_tzsh_softkey)
6333 ERR("Could not create tws_softkey resource: %m");
6334 wl_client_post_no_memory(client);
6338 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_softkey, cp, ec);
6341 ERR("Could not create tzsh_client");
6342 wl_client_post_no_memory(client);
6346 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_SOFTKEY;
6347 tzsh_client->client_data = _tzsh_client_data_softkey_new();
6348 if (!tzsh_client->client_data)
6350 ERR("Could not create tzsh_client");
6351 _e_policy_wl_tzsh_client_del(tzsh_client);
6352 wl_resource_destroy(res_tzsh_softkey);
6353 wl_client_post_no_memory(client);
6357 wl_resource_set_implementation(res_tzsh_softkey,
6358 &_tzsh_softkey_iface,
6360 _tzsh_cb_softkey_destroy);
6363 // --------------------------------------------------------
6364 // tizen_ws_shell_interface::shared_widget_launch
6365 // --------------------------------------------------------
6367 e_tzsh_shared_widget_launch_prepare_send(E_Client *callee_ec,
6371 E_Policy_Wl_Tzsh_Client *tzsh_client;
6373 Eina_Bool res = EINA_FALSE;
6375 EINA_SAFETY_ON_NULL_RETURN_VAL(callee_ec, EINA_FALSE);
6376 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(callee_ec)), EINA_FALSE);
6378 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
6380 if (!tzsh_client->tzsh) continue;
6381 if (!tzsh_client->ec) continue;
6382 if (tzsh_client->ec != callee_ec) continue;
6384 tws_shared_widget_launch_send_prepare_shared_widget(tzsh_client->res_tzsh_client,
6396 _tzsh_swl_iface_cb_release(struct wl_client *client,
6397 struct wl_resource *res_tzsh_swl)
6399 ELOGF("TZSH_SWL", "Release", NULL);
6401 wl_resource_destroy(res_tzsh_swl);
6405 _tzsh_swl_iface_cb_prepare_shared_widget_done(struct wl_client *client,
6406 struct wl_resource *res_tzsh_swl,
6407 const char *shared_widget_info,
6411 E_Policy_Wl_Tzsh_Client *tzsh_client;
6413 ELOGF("TZSH_SWL", "Done", NULL);
6415 tzsh_client = wl_resource_get_user_data(res_tzsh_swl);
6416 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6417 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6418 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6419 EINA_SAFETY_ON_NULL_RETURN(eina_list_data_find(polwl->tzsh_clients, tzsh_client));
6421 // send prepare event to caller
6422 e_service_launcher_prepare_send_with_shared_widget_info(tzsh_client->ec,
6428 static const struct tws_shared_widget_launch_interface _tzsh_swl_iface =
6430 _tzsh_swl_iface_cb_release,
6431 _tzsh_swl_iface_cb_prepare_shared_widget_done,
6435 _tzsh_cb_swl_destroy(struct wl_resource *res_tzsh_swl)
6437 E_Policy_Wl_Tzsh_Client *tzsh_client;
6439 ELOGF("TZSH_SWL", "Destroy", NULL);
6441 tzsh_client = wl_resource_get_user_data(res_tzsh_swl);
6442 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6444 e_service_launcher_release_shared_widget_launch(tzsh_client->ec);
6446 tzsh_client->res_tzsh_client = NULL;
6447 _e_policy_wl_tzsh_client_del(tzsh_client);
6451 _tzsh_iface_cb_shared_widget_launch_get(struct wl_client *client,
6452 struct wl_resource *res_tzsh,
6456 E_Policy_Wl_Tzsh *tzsh;
6457 E_Policy_Wl_Tzsh_Client *tzsh_client;
6458 struct wl_resource *res_tzsh_swl;
6462 tzsh = wl_resource_get_user_data(res_tzsh);
6465 wl_resource_post_error
6467 WL_DISPLAY_ERROR_INVALID_OBJECT,
6468 "Invalid res_tzsh's user data");
6472 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
6475 wl_resource_post_error
6477 WL_DISPLAY_ERROR_INVALID_OBJECT,
6478 "Invalid surface id");
6482 ec = e_pixmap_client_get(cp);
6485 if (!_e_policy_wl_e_client_is_valid(ec))
6487 wl_resource_post_error
6489 WL_DISPLAY_ERROR_INVALID_OBJECT,
6490 "Invalid surface id");
6495 res_tzsh_swl = wl_resource_create(client,
6496 &tws_shared_widget_launch_interface,
6497 wl_resource_get_version(res_tzsh),
6501 ERR("Could not create tws_shared_widget_launch resource: %m");
6502 wl_client_post_no_memory(client);
6506 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_swl, cp, ec);
6509 ERR("Could not create tzsh_client");
6510 wl_client_post_no_memory(client);
6514 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_SHARED_WIDGET_LAUNCH;
6516 wl_resource_set_implementation(res_tzsh_swl,
6519 _tzsh_cb_swl_destroy);
6522 // --------------------------------------------------------
6523 // tizen_ws_shell_interface
6524 // --------------------------------------------------------
6526 _tzsh_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh)
6528 wl_resource_destroy(res_tzsh);
6531 static const struct tizen_ws_shell_interface _tzsh_iface =
6533 _tzsh_iface_cb_destroy,
6534 _tzsh_iface_cb_srv_create,
6535 _tzsh_iface_cb_reg_create,
6536 _tzsh_iface_cb_qp_get,
6537 _tzsh_iface_cb_extension_get,
6538 _tzsh_iface_cb_softkey_get,
6539 _tzsh_iface_cb_shared_widget_launch_get,
6543 _tzsh_cb_unbind(struct wl_resource *res_tzsh)
6545 E_Policy_Wl_Tzsh *tzsh;
6547 tzsh = wl_resource_get_user_data(res_tzsh);
6548 EINA_SAFETY_ON_NULL_RETURN(tzsh);
6550 _e_policy_wl_tzsh_del(tzsh);
6554 _tzsh_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
6556 E_Policy_Wl_Tzsh *tzsh;
6557 struct wl_resource *res_tzsh;
6559 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
6561 res_tzsh = wl_resource_create(client,
6562 &tizen_ws_shell_interface,
6565 EINA_SAFETY_ON_NULL_GOTO(res_tzsh, err);
6567 tzsh = _e_policy_wl_tzsh_add(res_tzsh);
6568 EINA_SAFETY_ON_NULL_GOTO(tzsh, err);
6570 wl_resource_set_implementation(res_tzsh,
6575 _e_policy_wl_tzsh_registered_srv_send(tzsh);
6579 ERR("Could not create tizen_ws_shell_interface res: %m");
6580 wl_client_post_no_memory(client);
6583 // --------------------------------------------------------
6584 // tizen_launch_effect_interface
6585 // --------------------------------------------------------
6586 #define SPLASH_GROUP_NAME "effect"
6587 #define SPLASH_CONFIG_CUSTOM_EFFECT_CALLEE "_CUSTOM_EFFECT_CALLEE_"
6590 _launch_effect_hide(uint32_t pid)
6593 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
6594 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6596 if(pid <= 0) return;
6598 EINA_LIST_FOREACH(polwl->tzlaunch_effect, l, tzlaunch_effect)
6600 EINA_LIST_FOREACH(tzlaunch_effect->splash_list, ll, tzlaunch_splash)
6601 if (tzlaunch_splash->pid == pid)
6603 _launch_splash_off(tzlaunch_splash);
6609 _launch_effect_client_del(E_Client *ec)
6612 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
6613 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6615 EINA_LIST_FOREACH(polwl->tzlaunch_effect, l, tzlaunch_effect)
6617 EINA_LIST_FOREACH(tzlaunch_effect->splash_list, ll, tzlaunch_splash)
6618 if (tzlaunch_splash->ec == ec)
6620 _launch_splash_off(tzlaunch_splash);
6626 _launchscreen_splash_cb_indicator_resized(Ecore_Evas *ee)
6628 Evas_Coord_Size size = {0, 0};
6629 Evas_Object *indicator_obj;
6630 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6632 tzlaunch_splash = ecore_evas_data_get(ee, "tzlaunch_splash");
6633 if (!tzlaunch_splash) return;
6635 indicator_obj = tzlaunch_splash->indicator_obj;
6637 ecore_evas_geometry_get(ee, NULL, NULL, &(size.w), &(size.h));
6638 ELOGF("TZPOL", "Launchscreen indicator_obj resized(%d x %d)",
6641 evas_object_size_hint_min_set(indicator_obj, size.w, size.h);
6642 evas_object_size_hint_max_set(indicator_obj, size.w, size.h);
6643 e_comp_object_indicator_size_set(tzlaunch_splash->ec->frame, size.w, size.h);
6647 _launchscreen_splash_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6649 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash = data;
6651 if ((tzlaunch_splash) && (tzlaunch_splash->obj == obj))
6652 tzlaunch_splash->obj = NULL;
6656 _launchscreen_splash_cb_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6658 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash = data;
6660 if ((tzlaunch_splash) && (tzlaunch_splash->obj == obj))
6661 _launch_splash_off(tzlaunch_splash);
6665 _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash)
6667 E_Client *ec = NULL;
6668 Evas_Object *obj = NULL;
6670 if (!tzlaunch_splash->valid) return;
6671 if (!tzlaunch_splash->ec) return;
6673 ec = tzlaunch_splash->ec;
6674 obj = tzlaunch_splash->obj;
6676 tzlaunch_splash->obj = NULL;
6677 tzlaunch_splash->ec = NULL;
6678 tzlaunch_splash->valid = EINA_FALSE;
6679 if (tzlaunch_splash->timeout) ecore_timer_del(tzlaunch_splash->timeout);
6680 tzlaunch_splash->timeout = NULL;
6682 eina_stringshare_del(tzlaunch_splash->appid);
6683 tzlaunch_splash->appid = NULL;
6684 eina_stringshare_del(tzlaunch_splash->path);
6685 tzlaunch_splash->path = NULL;
6689 "Launchscreen hide | pid %d, replaced:%d, tzlaunch_pixmap:%p, ec_pixmap:%p",
6690 ec, tzlaunch_splash->pid, tzlaunch_splash->replaced, tzlaunch_splash->ep, ec->pixmap);
6692 if (tzlaunch_splash->indicator_obj)
6694 e_comp_object_indicator_unswallow(ec->frame, tzlaunch_splash->indicator_obj);
6695 evas_object_del(tzlaunch_splash->indicator_obj);
6696 evas_object_unref(tzlaunch_splash->indicator_obj);
6697 tzlaunch_splash->indicator_obj = NULL;
6701 (ec->pixmap == tzlaunch_splash->ep))
6703 /* case 1: Surface for this pid is not created until timeout or
6704 * launchscreen resource is destroied.
6708 ec->visible = EINA_FALSE;
6709 evas_object_hide(ec->frame);
6710 ec->ignored = EINA_TRUE;
6713 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
6715 e_pixmap_win_id_del(tzlaunch_splash->ep);
6716 e_object_del(E_OBJECT(ec));
6722 if (!e_util_strcmp("wl_pointer-cursor", ec->icccm.window_role))
6724 // if Launchscreen is replaced to cursor, than hide
6725 e_comp_object_content_unset(ec->frame);
6726 ec->visible = EINA_FALSE;
6727 evas_object_hide(ec->frame);
6728 ec->ignored = EINA_TRUE;
6730 else if (!tzlaunch_splash->replaced)
6733 e_comp_wl_feed_focus_in(ec);
6735 /* to send launch,done event to launchscreen client */
6736 if (!e_object_is_del(E_OBJECT(ec)))
6738 if (ec->first_mapped)
6740 ELOGF("LAUNCH", "SHOW real win by replaced splash ec", ec);
6741 e_comp_object_signal_emit(ec->frame, "e,action,launch_real,done", "e");
6743 e_comp_object_signal_emit(ec->frame, "e,action,launch,done", "e");
6747 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
6751 evas_object_unref(obj);
6753 tzlaunch_splash->ep = NULL;
6754 tzlaunch_splash->replaced = EINA_FALSE;
6758 _launchscreen_splash_timeout(void *data)
6760 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6761 tzlaunch_splash = (E_Policy_Wl_Tzlaunch_Splash *)data;
6763 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_splash, 0);
6765 _launch_splash_off(tzlaunch_splash);
6767 return ECORE_CALLBACK_CANCEL;
6771 _launchscreen_splash_setup(E_Policy_Wl_Tzlaunch_Splash *splash,
6772 const char *pfname, uint32_t ftype,
6773 uint32_t depth, uint32_t angle,
6774 uint32_t indicator, const char *effect_type,
6775 const char *theme_type, struct wl_array *options,
6776 struct wl_array *extra_config)
6778 E_Client *ec = NULL;
6779 E_Comp_Object_Content_Type content_type = 0;
6780 Eina_Bool intercepted = EINA_FALSE;
6782 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->ec, EINA_FALSE);
6783 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->ec->frame, EINA_FALSE);
6786 ec->effect_type = _e_policy_wl_tzlaunch_effect_type_get(effect_type);
6789 "Launchscreen setup START| path %s(%d), indicator(%d), angle(%d), effect_type(%s), theme_type(%s)",
6790 ec, pfname, ftype, indicator, angle, effect_type, theme_type);
6792 "Launchscreen setup | options %p extra_config:%p",
6793 ec, options, extra_config);
6795 splash->path = eina_stringshare_add(pfname);
6796 splash->type = ftype;
6797 splash->indicator = indicator;
6798 splash->angle = angle;
6802 /* To configure indicator options */
6803 ec->indicator.state = TIZEN_INDICATOR_STATE_ON;
6804 ec->indicator.visible_type = TIZEN_INDICATOR_VISIBLE_TYPE_SHOWN;
6805 ec->indicator.opacity_mode = TIZEN_INDICATOR_OPACITY_MODE_BG_TRANSPARENT;
6808 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_LAUNCHSCREEN_OBJECT_SETUP,
6810 pfname, ftype, depth,
6811 angle, indicator, options);
6814 splash->obj = e_comp_object_content_get(ec->frame);
6817 "Launchscreen setup | was INTERCEPTED : content(%p)",
6820 else //Do original setup process
6822 if (splash->type == LAUNCH_IMG_FILE_TYPE_IMAGE)
6824 Evas_Load_Error err;
6826 content_type = E_COMP_OBJECT_CONTENT_TYPE_EXT_IMAGE;
6827 splash->obj = evas_object_image_add(e_comp->evas);
6828 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->obj, EINA_FALSE);
6830 evas_object_image_file_set(splash->obj, splash->path, NULL);
6832 err = evas_object_image_load_error_get(splash->obj);
6833 if (err != EVAS_LOAD_ERROR_NONE)
6836 "Launchscreen setup | fail to load image %s : %s",
6837 ec, splash->path, evas_load_error_str(err));
6838 evas_object_del(splash->obj);
6843 evas_object_image_fill_set(splash->obj, 0, 0, e_comp->w, e_comp->h);
6844 evas_object_image_filled_set(splash->obj, EINA_TRUE);
6848 content_type = E_COMP_OBJECT_CONTENT_TYPE_EXT_EDJE;
6849 splash->obj = edje_object_add(e_comp->evas);
6850 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->obj, EINA_FALSE);
6852 if (!edje_object_file_set(splash->obj, splash->path, SPLASH_GROUP_NAME))
6854 Edje_Load_Error err;
6856 err = edje_object_load_error_get(splash->obj);
6858 "Launchscreen setup | fail to load edje %s : %s",
6859 ec, splash->path, edje_load_error_str(err));
6860 evas_object_del(splash->obj);
6866 evas_object_move(splash->obj, 0, 0);
6867 evas_object_resize(splash->obj, e_comp->w, e_comp->h);
6870 if (depth == 32) ec->argb = EINA_TRUE;
6871 else ec->argb = EINA_FALSE;
6872 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6874 //set splash->obj to a content of ec->frame
6875 if (!e_comp_object_content_set(ec->frame, splash->obj, content_type))
6877 ERR("Launchscreen setup | setting comp object content failed ec(%p) obj(%p)",
6884 /* Post job of setup content_type */
6886 //Parse extra config
6887 if ((extra_config) && (extra_config->size))
6891 int size = extra_config->size;
6895 p_char = extra_config->data + len;
6896 len = strlen(p_char) + 1;
6899 if (!e_util_strcmp(p_char, SPLASH_CONFIG_CUSTOM_EFFECT_CALLEE))
6901 //parse next data(appid) from array
6904 p_char = p_char + len;
6905 len = strlen(p_char) + 1;
6908 splash->appid = eina_stringshare_add(p_char);
6909 splash->custom_effect_callee = EINA_TRUE;
6912 "Launchscreen setup | custom effect callee set appid(%s)",
6923 Evas_Object *indicator_obj = NULL;
6924 Eina_Bool ret = EINA_FALSE;
6926 e_mod_indicator_owner_set(ec);
6927 e_tzsh_indicator_srv_property_update(ec);
6929 indicator_obj = ecore_evas_extn_plug_new(e_comp->ee);
6933 "Launchscreen setup | Failed to create ecore_evas_plug for indicator",
6938 if (e_config->indicator_plug_name)
6940 ret = ecore_evas_extn_plug_connect(indicator_obj, e_config->indicator_plug_name, 0, EINA_FALSE);
6945 ee = ecore_evas_object_ecore_evas_get(indicator_obj);
6946 ecore_evas_data_set(ee, "tzlaunch_splash", splash);
6947 ecore_evas_callback_resize_set(ee,
6948 _launchscreen_splash_cb_indicator_resized);
6949 e_comp_object_indicator_swallow(ec->frame, indicator_obj);
6950 evas_object_ref(indicator_obj);
6952 "Launchscreen launch | Succeeded to add indicator object plug_name(%s) indicator_obj(%p)",
6953 ec, e_config->indicator_plug_name, indicator_obj);
6957 evas_object_del(indicator_obj);
6958 indicator_obj = NULL;
6965 "Launchscreen launch | Failed to add indicator object plug_name(%s)",
6966 ec, e_config->indicator_plug_name?:"NO PLUG NAME");
6970 splash->indicator_obj = indicator_obj;
6976 evas_object_ref(splash->obj);
6978 evas_object_event_callback_add(splash->obj,
6980 _launchscreen_splash_cb_del, splash);
6981 evas_object_event_callback_add(splash->obj,
6983 _launchscreen_splash_cb_hide, splash);
6986 splash->valid = EINA_TRUE;
6987 splash->content_type = e_comp_object_content_type_get(ec->frame);
6993 _tzlaunch_splash_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash)
6995 wl_resource_destroy(res_tzlaunch_splash);
6999 _tzlaunch_splash_iface_cb_launch(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash,
7000 const char *pfname, uint32_t ftype,
7001 uint32_t depth, uint32_t angle,
7002 uint32_t indicator, const char *effect_type,
7003 const char *theme_type, struct wl_array *options)
7005 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7006 Eina_Bool res = EINA_FALSE;
7008 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7009 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7011 ELOGF("TZPOL","Launchscreen launch | START", NULL);
7014 res = _launchscreen_splash_setup(tzlaunch_splash,
7017 indicator, effect_type,
7018 theme_type, options, NULL);
7020 ELOGF("TZPOL","Launchscreen launch | END res:%d ", NULL, res);
7024 ERR("Launchscreen launch | Could not complete %s", __FUNCTION__);
7025 if (tzlaunch_splash->obj)
7027 evas_object_del(tzlaunch_splash->obj);
7028 tzlaunch_splash->obj = NULL;
7034 _tzlaunch_splash_iface_cb_owner(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash, uint32_t pid)
7036 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7037 E_Client *pre_ec = NULL, *new_ec = NULL, *old_ec;
7038 Eina_List *clients, *l;
7040 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7041 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7042 EINA_SAFETY_ON_FALSE_RETURN(tzlaunch_splash->valid);
7044 /* use ec was already created */
7045 clients = _e_policy_wl_e_clients_find_by_pid(pid);
7046 EINA_LIST_FOREACH(clients, l, pre_ec)
7048 if (pre_ec == tzlaunch_splash->ec) continue;
7049 if (!pre_ec->ignored) continue;
7050 if (pre_ec->is_cursor) continue;
7054 eina_list_free(clients);
7056 old_ec = tzlaunch_splash->ec;
7059 if (e_comp_object_content_set(new_ec->frame,
7060 tzlaunch_splash->obj,
7061 tzlaunch_splash->content_type))
7063 e_client_unignore(new_ec);
7064 new_ec->visible = EINA_TRUE;
7065 if (new_ec->new_client)
7066 e_comp->new_clients--;
7067 new_ec->new_client = EINA_FALSE;
7068 new_ec->argb = old_ec->argb;
7069 ELOGF("COMP", "Set argb:%d", new_ec, new_ec->argb);
7070 new_ec->effect_type = old_ec->effect_type;
7071 new_ec->use_splash = EINA_TRUE;
7072 new_ec->icccm.title = eina_stringshare_add("launchscreen");
7074 e_comp->launchscrns = eina_list_append(e_comp->launchscrns, new_ec);
7076 if (tzlaunch_splash->custom_effect_callee)
7078 e_service_launcher_callee_register(new_ec, tzlaunch_splash->appid, tzlaunch_splash->path, SPLASH_GROUP_NAME);
7081 evas_object_show(new_ec->frame);
7082 e_client_raise(new_ec);
7084 tzlaunch_splash->ec = new_ec;
7085 tzlaunch_splash->replaced = EINA_TRUE;
7088 "Launchscreen client changed | old(%p) new(%p) using obj(%p)",
7090 old_ec, new_ec, tzlaunch_splash->obj);
7092 if (tzlaunch_splash->indicator_obj)
7094 e_mod_indicator_owner_set(new_ec);
7095 e_tzsh_indicator_srv_property_update(new_ec);
7096 e_comp_object_indicator_unswallow(old_ec->frame, tzlaunch_splash->indicator_obj);
7097 e_comp_object_indicator_swallow(new_ec->frame, tzlaunch_splash->indicator_obj);
7100 /* delete ec was created for launchscreen */
7101 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, old_ec);
7103 e_pixmap_win_id_del(tzlaunch_splash->ep);
7104 e_object_del(E_OBJECT(old_ec));
7105 tzlaunch_splash->ep = NULL;
7108 ERR("Can't set external content for new_ec(%p)", new_ec);
7112 old_ec->ignored = EINA_FALSE;
7113 old_ec->visible = EINA_TRUE;
7114 if (old_ec->new_client)
7115 e_comp->new_clients--;
7116 old_ec->new_client = EINA_FALSE;
7117 old_ec->icccm.accepts_focus = EINA_TRUE;
7119 if (tzlaunch_splash->custom_effect_callee)
7121 e_service_launcher_callee_register(old_ec, tzlaunch_splash->appid, tzlaunch_splash->path, SPLASH_GROUP_NAME);
7124 evas_object_show(old_ec->frame);
7125 e_client_raise(old_ec);
7128 EC_CHANGED(tzlaunch_splash->ec);
7129 e_comp_visibility_calculation_set(EINA_TRUE);
7131 if (tzlaunch_splash->timeout)
7133 ecore_timer_del(tzlaunch_splash->timeout);
7134 tzlaunch_splash->timeout = NULL;
7136 if (!e_config->launchscreen_without_timer)
7137 tzlaunch_splash->timeout = ecore_timer_add(e_config->launchscreen_timeout, _launchscreen_splash_timeout, tzlaunch_splash);
7139 ELOGF("TZPOL", "Launchscreen img(%d) set owner pid: %d",
7140 tzlaunch_splash->ec,
7141 wl_resource_get_id(res_tzlaunch_splash), pid);
7143 tzlaunch_splash->pid = pid;
7144 tzlaunch_splash->ec->netwm.pid = pid;
7145 tzlaunch_splash->ec->use_splash = EINA_TRUE;
7149 _tzlaunch_splash_iface_cb_launch_v2(struct wl_client *client EINA_UNUSED,
7150 struct wl_resource *res_tzlaunch_splash,
7151 const char *pfname, uint32_t ftype,
7152 uint32_t depth, uint32_t angle,
7153 uint32_t indicator, const char *effect_type,
7154 const char *theme_type, struct wl_array *options,
7155 struct wl_array *extra_config)
7157 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7158 Eina_Bool res = EINA_FALSE;
7160 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7161 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7163 ELOGF("TZPOL","Launchscreen launch_v2 | START", NULL);
7165 res = _launchscreen_splash_setup(tzlaunch_splash,
7168 indicator, effect_type,
7169 theme_type, options, extra_config);
7171 ELOGF("TZPOL","Launchscreen launch_v2 | END res:%d ", NULL, res);
7175 ERR("Launchscreen launch_v2 | Could not complete %s", __FUNCTION__);
7176 if (tzlaunch_splash->obj)
7178 evas_object_del(tzlaunch_splash->obj);
7179 tzlaunch_splash->obj = NULL;
7185 static const struct tizen_launch_splash_interface _tzlaunch_splash_iface =
7187 _tzlaunch_splash_iface_cb_destroy,
7188 _tzlaunch_splash_iface_cb_launch,
7189 _tzlaunch_splash_iface_cb_owner,
7190 _tzlaunch_splash_iface_cb_launch_v2,
7193 static E_Policy_Wl_Tzlaunch_Splash *
7194 _tzlaunch_splash_add(struct wl_resource *res_tzlaunch_effect, struct wl_resource *res_tzlaunch_splash)
7196 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7197 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7199 tzlaunch_splash = E_NEW(E_Policy_Wl_Tzlaunch_Splash, 1);
7200 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash, error);
7202 tzlaunch_effect = wl_resource_get_user_data(res_tzlaunch_effect);
7203 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_effect, error);
7205 tzlaunch_effect->splash_list = eina_list_append(tzlaunch_effect->splash_list, tzlaunch_splash);
7207 tzlaunch_splash->tzlaunch_effect = tzlaunch_effect;
7208 tzlaunch_splash->res_tzlaunch_splash = res_tzlaunch_splash;
7210 tzlaunch_splash->replaced = EINA_FALSE;
7211 tzlaunch_splash->ep = e_pixmap_new(E_PIXMAP_TYPE_EXT_OBJECT, 0);
7212 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash->ep, error);
7213 tzlaunch_splash->ec = e_client_new(tzlaunch_splash->ep, 0, 1);
7214 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash->ec, error);
7216 tzlaunch_splash->ec->icccm.title = eina_stringshare_add("Launchscreen");
7217 tzlaunch_splash->ec->icccm.name = eina_stringshare_add("Launchscreen");
7218 tzlaunch_splash->ec->ignored = EINA_TRUE;
7220 e_comp->launchscrns = eina_list_append(e_comp->launchscrns, tzlaunch_splash->ec);
7222 return tzlaunch_splash;
7224 if (tzlaunch_splash)
7226 ERR("Could not initialize launchscreen client");
7227 if (tzlaunch_splash->ep)
7228 e_pixmap_win_id_del(tzlaunch_splash->ep);
7229 if (tzlaunch_splash->ec)
7230 e_object_del(E_OBJECT(tzlaunch_splash->ec));
7231 E_FREE(tzlaunch_splash);
7238 _tzlaunch_splash_destroy(struct wl_resource *res_tzlaunch_splash)
7240 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7241 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7243 EINA_SAFETY_ON_NULL_RETURN(res_tzlaunch_splash);
7245 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7246 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7248 if (tzlaunch_splash->obj)
7250 evas_object_event_callback_del_full(tzlaunch_splash->obj, EVAS_CALLBACK_DEL, _launchscreen_splash_cb_del, tzlaunch_splash);
7251 evas_object_event_callback_del_full(tzlaunch_splash->obj, EVAS_CALLBACK_HIDE, _launchscreen_splash_cb_hide, tzlaunch_splash);
7254 _launch_splash_off(tzlaunch_splash);
7256 tzlaunch_effect = tzlaunch_splash->tzlaunch_effect;
7257 tzlaunch_effect->splash_list = eina_list_remove(tzlaunch_effect->splash_list, tzlaunch_splash);
7259 eina_stringshare_del(tzlaunch_splash->appid);
7260 eina_stringshare_del(tzlaunch_splash->path);
7261 memset(tzlaunch_splash, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Splash));
7262 E_FREE(tzlaunch_splash);
7266 _tzlaunch_effect_iface_cb_create_splash_img(struct wl_client *client, struct wl_resource *res_tzlaunch_effect, uint32_t id)
7269 E_Policy_Wl_Tzlaunch_Splash *plaunch_splash;
7270 struct wl_resource *res_tzlaunch_splash;
7272 res_tzlaunch_splash = wl_resource_create(client,
7273 &tizen_launch_splash_interface,
7274 wl_resource_get_version(res_tzlaunch_effect),
7276 if (!res_tzlaunch_splash)
7278 wl_resource_post_error
7279 (res_tzlaunch_effect,
7280 WL_DISPLAY_ERROR_INVALID_OBJECT,
7281 "Invalid res_tzlaunch effect's user data");
7285 plaunch_splash = _tzlaunch_splash_add(res_tzlaunch_effect, res_tzlaunch_splash);
7286 EINA_SAFETY_ON_NULL_GOTO(plaunch_splash, err);
7288 ELOGF("TZPOL", "Launchscreen effect create splash img. res_tzlaunch_effect:%p, res_tzlaunch_splash:%p", plaunch_splash->ec, res_tzlaunch_effect, res_tzlaunch_splash);
7290 wl_resource_set_implementation(res_tzlaunch_splash,
7291 &_tzlaunch_splash_iface,
7293 _tzlaunch_splash_destroy);
7298 ERR("Could not create tizen_launch_splash_interface res: %m");
7299 wl_client_post_no_memory(client);
7303 _tzlaunch_effect_iface_cb_type_set(struct wl_client *client, struct wl_resource *res_tzlaunch_effect,
7304 const char *effect_type, uint32_t pid, struct wl_array *options)
7306 Eina_List *clients, *l;
7307 E_Client *_ec = NULL;
7309 int tzlaunch_effect_type = _e_policy_wl_tzlaunch_effect_type_get(effect_type);
7311 clients = _e_policy_wl_e_clients_find_by_pid(pid);
7312 EINA_LIST_FOREACH(clients, l, _ec)
7316 _ec->effect_type = tzlaunch_effect_type;
7319 "Launchscreen effect type set | exist ec | effect (%d) pid (%d)",
7320 _ec, tzlaunch_effect_type, pid);
7323 eina_list_free(clients);
7326 _e_policy_wl_tzlaunch_effect_type_unset(pid);
7329 E_Policy_Wl_Tzlaunch_Effect_Info *tzlaunch_effect_info;
7331 tzlaunch_effect_info = E_NEW(E_Policy_Wl_Tzlaunch_Effect_Info, 1);
7332 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_effect_info);
7333 tzlaunch_effect_info->pid = pid;
7334 tzlaunch_effect_info->effect_type = tzlaunch_effect_type;
7335 polwl->tzlaunch_effect_info = eina_list_append(polwl->tzlaunch_effect_info, tzlaunch_effect_info);
7338 "Launchscreen effect type set | no match ec | effect (%d) pid (%d)",
7339 NULL, tzlaunch_effect_type, pid);
7344 _tzlaunch_effect_iface_cb_type_unset(struct wl_client *client, struct wl_resource *res_tzlaunch_effect,
7347 _e_policy_wl_tzlaunch_effect_type_unset(pid);
7351 _tzlaunch_effect_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
7353 wl_resource_destroy(resource);
7356 static const struct tizen_launch_effect_interface _tzlaunch_effect_iface =
7358 _tzlaunch_effect_iface_cb_create_splash_img,
7359 _tzlaunch_effect_iface_cb_type_set,
7360 _tzlaunch_effect_iface_cb_type_unset,
7361 _tzlaunch_effect_iface_cb_destroy,
7365 _tzlaunch_effect_del(E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect)
7367 E_Policy_Wl_Tzlaunch_Splash *plaunch_splash;
7370 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_effect);
7372 // remove tzlaunch created splash list
7373 EINA_LIST_FOREACH_SAFE(tzlaunch_effect->splash_list, l, ll, plaunch_splash)
7375 if (plaunch_splash->tzlaunch_effect != tzlaunch_effect) continue;
7376 wl_resource_destroy(plaunch_splash->res_tzlaunch_splash);
7380 polwl->tzlaunch_effect = eina_list_remove(polwl->tzlaunch_effect, tzlaunch_effect);
7382 memset(tzlaunch_effect, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Effect));
7383 E_FREE(tzlaunch_effect);
7386 static E_Policy_Wl_Tzlaunch_Effect *
7387 _tzlaunch_effect_add(struct wl_resource *res_tzlaunch_effect)
7389 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7391 tzlaunch_effect = E_NEW(E_Policy_Wl_Tzlaunch_Effect, 1);
7392 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_effect, NULL);
7394 tzlaunch_effect->res_tzlaunch_effect = res_tzlaunch_effect;
7396 polwl->tzlaunch_effect = eina_list_append(polwl->tzlaunch_effect, tzlaunch_effect);
7398 return tzlaunch_effect;
7402 _tzlaunch_effect_cb_unbind(struct wl_resource *res_tzlaunch_effect)
7404 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect = NULL;
7407 EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_effect, l, ll, tzlaunch_effect)
7409 if (tzlaunch_effect->res_tzlaunch_effect != res_tzlaunch_effect) continue;
7410 _tzlaunch_effect_del(tzlaunch_effect);
7416 _tzlaunch_effect_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
7418 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect = NULL;
7419 struct wl_resource *res_tzlaunch_effect;
7421 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
7423 res_tzlaunch_effect = wl_resource_create(client,
7424 &tizen_launch_effect_interface,
7427 EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_effect, err);
7429 tzlaunch_effect = _tzlaunch_effect_add(res_tzlaunch_effect);
7430 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_effect, err);
7432 wl_resource_set_implementation(res_tzlaunch_effect,
7433 &_tzlaunch_effect_iface,
7435 _tzlaunch_effect_cb_unbind);
7440 ERR("Could not create tizen_launch_effect_interface res: %m");
7441 wl_client_post_no_memory(client);
7444 // --------------------------------------------------------
7445 // tizen_launch_appinfo_interface
7446 // --------------------------------------------------------
7448 _tzlaunch_appinfo_iface_cb_register_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7451 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7452 E_Appinfo *eai = NULL;
7454 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7455 if (!tzlaunch_appinfo)
7457 wl_resource_post_error(res_tzlaunch_appinfo,
7458 WL_DISPLAY_ERROR_INVALID_OBJECT,
7459 "Invalid tzlaunch_appinfo's user data");
7465 ELOGF("TZ_APPINFO", "registered pid is invalid. pid:%u", NULL, pid);
7469 eai = e_appinfo_find_with_pid(pid);
7472 eai = e_appinfo_new();
7473 EINA_SAFETY_ON_NULL_RETURN(eai);
7475 if (!e_appinfo_pid_set(eai, pid))
7477 ELOGF("TZ_APPINFO", "failed to set pid is invalid. pid:%u", NULL, pid);
7483 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
7487 _tzlaunch_appinfo_iface_cb_deregister_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7490 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7491 E_Appinfo *eai = NULL;
7493 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7494 if (!tzlaunch_appinfo)
7496 wl_resource_post_error(res_tzlaunch_appinfo,
7497 WL_DISPLAY_ERROR_INVALID_OBJECT,
7498 "Invalid tzlaunch_appinfo's user data");
7502 eai = e_appinfo_find_with_pid(pid);
7503 EINA_SAFETY_ON_NULL_RETURN(eai);
7509 _tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7510 uint32_t pid, const char *appid)
7512 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7513 E_Appinfo *eai = NULL;
7517 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7518 if (!tzlaunch_appinfo)
7520 wl_resource_post_error(res_tzlaunch_appinfo,
7521 WL_DISPLAY_ERROR_INVALID_OBJECT,
7522 "Invalid tzlaunch_appinfo's user data");
7528 ELOGF("TZ_APPINFO", "set pid is invalid. pid:%u", NULL, pid);
7532 eai = e_appinfo_find_with_pid(pid);
7533 EINA_SAFETY_ON_NULL_RETURN(eai);
7535 if (!e_appinfo_appid_set(eai, appid))
7537 ELOGF("TZ_APPINFO", "failed to set appid, appid:%s", NULL, appid);
7541 /* about base output resolution */
7542 if (e_config->configured_output_resolution.use)
7545 // 1. send HOOK with pid
7546 _e_policy_wl_hook_call(E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET, pid);
7547 // 2. module must set the base_output_resolution.
7548 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7550 ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
7553 // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
7554 // 3-1. if success, use the base_rescreen_resolution
7555 // 3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
7558 if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
7560 ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
7569 _tzlaunch_appinfo_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo)
7571 wl_resource_destroy(res_tzlaunch_appinfo);
7575 _tzlaunch_appinfo_iface_cb_get_base_output_resolution(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7578 E_Appinfo *eai = NULL;
7579 int width = 0, height = 0;
7583 ELOGF("TZ_APPINFO", "requested pid is invalid. pid:%u", NULL, pid);
7587 eai = e_appinfo_find_with_pid(pid);
7590 ELOGF("TZ_APPINFO", "cannot find pid. pid:%u", NULL, pid);
7594 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7596 ELOGF("TZ_APPINFO", "cannot read size. pid:%u", NULL, pid);
7600 tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
7601 ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
7606 width = e_config->configured_output_resolution.w;
7607 height = e_config->configured_output_resolution.h;
7608 ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
7609 tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
7615 _tzlaunch_appinfo_iface_cb_register_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7618 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7619 E_Appinfo *eai = NULL;
7621 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7622 if (!tzlaunch_appinfo)
7624 wl_resource_post_error(res_tzlaunch_appinfo,
7625 WL_DISPLAY_ERROR_INVALID_OBJECT,
7626 "Invalid tzlaunch_appinfo's user data");
7630 if ((eai = e_appinfo_find_with_appid(appid)))
7632 ELOGF("TZ_APPINFO", "appid:%s is already registered!", NULL, appid);
7636 eai = e_appinfo_new();
7637 EINA_SAFETY_ON_NULL_RETURN(eai);
7639 if (!e_appinfo_appid_set(eai, appid))
7641 ELOGF("TZ_APPINFO", "Failed to register appid:%s", NULL, appid);
7646 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
7650 _tzlaunch_appinfo_iface_cb_deregister_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7653 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7654 E_Appinfo *eai = NULL;
7656 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7657 if (!tzlaunch_appinfo)
7659 wl_resource_post_error(res_tzlaunch_appinfo,
7660 WL_DISPLAY_ERROR_INVALID_OBJECT,
7661 "Invalid tzlaunch_appinfo's user data");
7665 eai = e_appinfo_find_with_appid(appid);
7666 EINA_SAFETY_ON_NULL_RETURN(eai);
7672 _tzlaunch_appinfo_iface_cb_set_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7673 const char *appid, uint32_t pid)
7675 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7676 E_Appinfo *eai = NULL;
7678 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7679 if (!tzlaunch_appinfo)
7681 wl_resource_post_error(res_tzlaunch_appinfo,
7682 WL_DISPLAY_ERROR_INVALID_OBJECT,
7683 "Invalid tzlaunch_appinfo's user data");
7687 eai = e_appinfo_find_with_appid(appid);
7688 EINA_SAFETY_ON_NULL_RETURN(eai);
7690 if (!e_appinfo_pid_set(eai, pid))
7692 ELOGF("TZ_APPINFO", "Failed to set pid:%u for appid:%s", NULL, pid, appid);
7698 _tzlaunch_appinfo_iface_cb_ready_metadata(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7699 const char *appid, uint32_t pid)
7701 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7702 E_Appinfo *eai = NULL;
7703 int width = 0, height = 0;
7705 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7706 if (!tzlaunch_appinfo)
7708 wl_resource_post_error(res_tzlaunch_appinfo,
7709 WL_DISPLAY_ERROR_INVALID_OBJECT,
7710 "Invalid tzlaunch_appinfo's user data");
7714 eai = e_appinfo_find_with_appid(appid);
7715 EINA_SAFETY_ON_NULL_RETURN(eai);
7717 e_appinfo_ready_metadata(eai, pid);
7719 /* about base output resolution */
7720 if (e_config->configured_output_resolution.use)
7722 // 1. send HOOK with pid
7723 _e_policy_wl_hook_call(E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET, pid);
7724 // 2. module must set the base_output_resolution.
7725 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7727 ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
7730 // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
7731 // 3-1. if success, use the base_rescreen_resolution
7732 // 3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
7735 if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
7737 ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
7744 _tzlaunch_appinfo_iface_cb_set_auto_placement(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7747 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7748 E_Appinfo *eai = NULL;
7750 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7751 if (!tzlaunch_appinfo)
7753 wl_resource_post_error(res_tzlaunch_appinfo,
7754 WL_DISPLAY_ERROR_INVALID_OBJECT,
7755 "Invalid tzlaunch_appinfo's user data");
7759 eai = e_appinfo_find_with_pid(pid);
7760 EINA_SAFETY_ON_NULL_RETURN(eai);
7762 ELOGF("TZ_APPINFO", "Set auto placement. pid(%d)", NULL, pid);
7763 e_appinfo_auto_placement_set(eai, EINA_TRUE);
7766 static const struct tizen_launch_appinfo_interface _tzlaunch_appinfo_iface =
7768 _tzlaunch_appinfo_iface_cb_destroy,
7769 _tzlaunch_appinfo_iface_cb_register_pid,
7770 _tzlaunch_appinfo_iface_cb_deregister_pid,
7771 _tzlaunch_appinfo_iface_cb_set_appid,
7772 _tzlaunch_appinfo_iface_cb_get_base_output_resolution,
7773 _tzlaunch_appinfo_iface_cb_register_appid,
7774 _tzlaunch_appinfo_iface_cb_deregister_appid,
7775 _tzlaunch_appinfo_iface_cb_set_pid,
7776 _tzlaunch_appinfo_iface_cb_ready_metadata,
7777 _tzlaunch_appinfo_iface_cb_set_auto_placement,
7781 _tzlaunch_appinfo_del(E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo)
7783 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_appinfo);
7785 polwl->tzlaunch_appinfo = eina_list_remove(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
7787 memset(tzlaunch_appinfo, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Appinfo));
7788 E_FREE(tzlaunch_appinfo);
7791 static E_Policy_Wl_Tzlaunch_Appinfo *
7792 _tzlaunch_appinfo_add(struct wl_resource *res_tzlaunch_appinfo)
7794 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo;
7796 tzlaunch_appinfo = E_NEW(E_Policy_Wl_Tzlaunch_Appinfo, 1);
7797 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_appinfo, NULL);
7799 tzlaunch_appinfo->res_tzlaunch_appinfo = res_tzlaunch_appinfo;
7801 polwl->tzlaunch_appinfo = eina_list_append(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
7803 return tzlaunch_appinfo;
7807 _tzlaunch_appinfo_cb_unbind(struct wl_resource *res_tzlaunch_appinfo)
7809 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7812 EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_appinfo, l, ll, tzlaunch_appinfo)
7814 if (tzlaunch_appinfo->res_tzlaunch_appinfo != res_tzlaunch_appinfo) continue;
7815 _tzlaunch_appinfo_del(tzlaunch_appinfo);
7821 _tzlaunch_appinfo_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
7823 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7824 struct wl_resource *res_tzlaunch_appinfo;
7826 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
7828 res_tzlaunch_appinfo = wl_resource_create(client,
7829 &tizen_launch_appinfo_interface,
7832 EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_appinfo, err);
7834 tzlaunch_appinfo = _tzlaunch_appinfo_add(res_tzlaunch_appinfo);
7835 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_appinfo, err);
7837 wl_resource_set_implementation(res_tzlaunch_appinfo,
7838 &_tzlaunch_appinfo_iface,
7840 _tzlaunch_appinfo_cb_unbind);
7845 ERR("Could not create tizen_launch_appinfo_interface res: %m");
7846 wl_client_post_no_memory(client);
7850 _e_policy_wl_cb_hook_intercept_show_helper(void *data, E_Client *ec)
7852 E_Policy_Wl_Tzpol *tzpol;
7853 E_Policy_Wl_Surface *psurf;
7855 Eina_Bool ret = EINA_TRUE;
7857 it = eina_hash_iterator_data_new(polwl->tzpols);
7858 EINA_ITERATOR_FOREACH(it, tzpol)
7860 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
7863 if (psurf->is_background)
7866 "BACKGROUND State is On, Deny Show",
7873 eina_iterator_free(it);
7879 _e_policy_wl_cb_scrsaver_on(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
7881 if (_scrsaver_mng_res)
7882 tws_service_screensaver_manager_send_idle(_scrsaver_mng_res);
7883 return ECORE_CALLBACK_PASS_ON;
7887 _e_policy_wl_cb_scrsaver_off(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
7889 if (_scrsaver_mng_res)
7890 tws_service_screensaver_manager_send_active(_scrsaver_mng_res);
7891 return ECORE_CALLBACK_PASS_ON;
7894 // --------------------------------------------------------
7895 // E_Policy_Wl_Tz_Indicator
7896 // --------------------------------------------------------
7897 static E_Policy_Wl_Tz_Indicator *
7898 _e_policy_wl_tz_indicator_add(struct wl_resource *res_tz_indicator)
7900 E_Policy_Wl_Tz_Indicator *tz_indicator;
7902 tz_indicator = E_NEW(E_Policy_Wl_Tz_Indicator, 1);
7903 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, NULL);
7905 tz_indicator->res_tz_indicator = res_tz_indicator;
7907 polwl->tz_indicators = eina_list_append(polwl->tz_indicators, tz_indicator);
7909 return tz_indicator;
7913 _e_policy_wl_tz_indicator_del(E_Policy_Wl_Tz_Indicator *tz_indicator)
7915 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
7917 polwl->tz_indicators = eina_list_remove(polwl->tz_indicators, tz_indicator);
7918 E_FREE(tz_indicator);
7921 static E_Policy_Wl_Tz_Indicator *
7922 _e_policy_wl_tz_indicator_get(struct wl_resource *res_tz_indicator)
7925 E_Policy_Wl_Tz_Indicator *tz_indicator;
7927 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7929 if (tz_indicator->res_tz_indicator == res_tz_indicator)
7930 return tz_indicator;
7935 static E_Policy_Wl_Tz_Indicator *
7936 _e_policy_wl_tz_indicator_get_from_client(E_Client *ec)
7939 E_Policy_Wl_Tz_Indicator *tz_indicator;
7941 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7943 if (eina_list_data_find(tz_indicator->ec_list, ec))
7944 return tz_indicator;
7951 _e_policy_wl_tz_indicator_set_client(struct wl_resource *res_tz_indicator, E_Client *ec)
7953 E_Policy_Wl_Tz_Indicator *tz_indicator = NULL;
7955 tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
7956 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, EINA_FALSE);
7958 if (!eina_list_data_find(tz_indicator->ec_list, ec))
7959 tz_indicator->ec_list = eina_list_append(tz_indicator->ec_list, ec);
7965 _e_policy_wl_tz_indicator_unset_client(E_Client *ec)
7968 E_Policy_Wl_Tz_Indicator *tz_indicator;
7970 EINA_SAFETY_ON_NULL_RETURN(ec);
7972 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7974 if (eina_list_data_find(tz_indicator->ec_list, ec))
7975 tz_indicator->ec_list = eina_list_remove(tz_indicator->ec_list, ec);
7980 _tz_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator)
7982 wl_resource_destroy(res_tz_indicator);
7986 _tz_indicator_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t state)
7989 E_Indicator_State ind_state;
7991 ec = e_client_from_surface_resource(surf);
7992 EINA_SAFETY_ON_NULL_RETURN(ec);
7993 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
7995 if (state == TIZEN_INDICATOR_STATE_ON)
7996 ind_state = E_INDICATOR_STATE_ON;
7997 else if (state == TIZEN_INDICATOR_STATE_OFF)
7998 ind_state = E_INDICATOR_STATE_OFF;
8000 ind_state = E_INDICATOR_STATE_UNKNOWN;
8002 ELOGF("TZ_IND", "TZ_STATE:%d, E_STATE:%d", ec, state, ind_state);
8003 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8004 ec->indicator.state = ind_state;
8006 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_STATE_CHANGE);
8010 _tz_indicator_cb_opacity_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t mode)
8013 E_Indicator_Opacity_Mode op_mode;
8015 ec = e_client_from_surface_resource(surf);
8016 EINA_SAFETY_ON_NULL_RETURN(ec);
8017 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8021 case TIZEN_INDICATOR_OPACITY_MODE_OPAQUE:
8022 op_mode = E_INDICATOR_OPACITY_MODE_OPAQUE;
8025 case TIZEN_INDICATOR_OPACITY_MODE_TRANSLUCENT:
8026 op_mode = E_INDICATOR_OPACITY_MODE_TRANSLUCENT;
8029 case TIZEN_INDICATOR_OPACITY_MODE_TRANSPARENT:
8030 op_mode = E_INDICATOR_OPACITY_MODE_TRANSPARENT;
8033 case TIZEN_INDICATOR_OPACITY_MODE_BG_TRANSPARENT:
8034 op_mode = E_INDICATOR_OPACITY_MODE_BG_TRANSPARENT;
8038 op_mode = E_INDICATOR_OPACITY_MODE_OPAQUE;
8042 ELOGF("TZ_IND", "TZ_OP_MODE:%d, E_OP_MODE:%d", ec, mode, op_mode);
8043 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8045 if (ec->indicator.opacity_mode == op_mode) return;
8047 ec->indicator.opacity_mode = op_mode;
8048 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.curr);
8050 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE);
8054 _tz_indicator_cb_visible_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t vtype)
8057 E_Indicator_Visible_Type vis_type;
8059 ec = e_client_from_surface_resource(surf);
8060 EINA_SAFETY_ON_NULL_RETURN(ec);
8061 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8063 if (vtype == TIZEN_INDICATOR_VISIBLE_TYPE_SHOWN)
8064 vis_type = E_INDICATOR_VISIBLE_TYPE_SHOWN;
8066 vis_type = E_INDICATOR_VISIBLE_TYPE_HIDDEN;
8068 ELOGF("TZ_IND", "TZ_VIS_TYPE:%d, E_VIS_TYPE:%d", ec, vtype, vis_type);
8069 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8070 ec->indicator.visible_type = vis_type;
8072 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE);
8075 // --------------------------------------------------------
8076 // tizen_indicator_interface
8077 // --------------------------------------------------------
8078 static const struct tizen_indicator_interface _tz_indicator_iface =
8080 _tz_indicator_cb_destroy,
8081 _tz_indicator_cb_state_set,
8082 _tz_indicator_cb_opacity_mode_set,
8083 _tz_indicator_cb_visible_type_set,
8087 _tz_indicator_cb_unbind(struct wl_resource *res_tz_indicator)
8089 E_Policy_Wl_Tz_Indicator *tz_indicator;
8091 tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
8092 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
8094 _e_policy_wl_tz_indicator_del(tz_indicator);
8098 _tz_indicator_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
8100 E_Policy_Wl_Tz_Indicator *tz_indicator_pol;
8101 struct wl_resource *res_tz_indicator;
8103 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8105 res_tz_indicator = wl_resource_create(client,
8106 &tizen_indicator_interface,
8109 EINA_SAFETY_ON_NULL_GOTO(res_tz_indicator, err);
8111 tz_indicator_pol = _e_policy_wl_tz_indicator_add(res_tz_indicator);
8112 EINA_SAFETY_ON_NULL_GOTO(tz_indicator_pol, err);
8114 wl_resource_set_implementation(res_tz_indicator,
8115 &_tz_indicator_iface,
8117 _tz_indicator_cb_unbind);
8121 ERR("Could not create tizen_indicator_interface res: %m");
8122 wl_client_post_no_memory(client);
8126 e_policy_wl_indicator_flick_send(E_Client *ec)
8128 E_Comp_Wl_Client_Data *cdata;
8129 E_Policy_Wl_Tz_Indicator *tz_indicator;
8130 struct wl_resource *surf;
8132 tz_indicator = _e_policy_wl_tz_indicator_get_from_client(ec);
8133 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
8135 cdata = e_client_cdata_get(ec);
8137 surf = cdata->surface;
8141 ELOGF("TZ_IND", "SEND FLICK EVENT", ec);
8142 tizen_indicator_send_flick(tz_indicator->res_tz_indicator, surf, 0);
8146 // --------------------------------------------------------
8147 // E_Policy_Wl_Tz_Clipboard
8148 // --------------------------------------------------------
8149 static E_Policy_Wl_Tz_Clipboard *
8150 _e_policy_wl_tz_clipboard_add(struct wl_resource *res_tz_clipboard)
8152 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8154 tz_clipboard = E_NEW(E_Policy_Wl_Tz_Clipboard, 1);
8155 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_clipboard, NULL);
8157 tz_clipboard->res_tz_clipboard = res_tz_clipboard;
8158 polwl->tz_clipboards = eina_list_append(polwl->tz_clipboards, tz_clipboard);
8160 return tz_clipboard;
8164 _e_policy_wl_tz_clipboard_del(E_Policy_Wl_Tz_Clipboard *tz_clipboard)
8166 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8168 polwl->tz_clipboards = eina_list_remove(polwl->tz_clipboards, tz_clipboard);
8169 E_FREE(tz_clipboard);
8172 static E_Policy_Wl_Tz_Clipboard *
8173 _e_policy_wl_tz_clipboard_get_from_client(E_Client *ec)
8176 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8178 EINA_LIST_FOREACH(polwl->tz_clipboards, l, tz_clipboard)
8180 if (eina_list_data_find(tz_clipboard->ec_list, ec))
8181 return tz_clipboard;
8188 _e_policy_wl_tz_clipboard_set_client(struct wl_resource *res_tz_clipboard, E_Client *ec)
8190 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8192 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8193 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_clipboard, EINA_FALSE);
8195 if (!eina_list_data_find(tz_clipboard->ec_list, ec))
8197 tz_clipboard->ec_list = eina_list_append(tz_clipboard->ec_list, ec);
8203 _e_policy_wl_tz_clipboard_unset_client(E_Client *ec)
8206 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8208 EINA_SAFETY_ON_NULL_RETURN(ec);
8210 EINA_LIST_FOREACH(polwl->tz_clipboards, l, tz_clipboard)
8212 if (eina_list_data_find(tz_clipboard->ec_list, ec))
8214 tz_clipboard->ec_list = eina_list_remove(tz_clipboard->ec_list, ec);
8219 // --------------------------------------------------------
8220 // tizen_clipboard_interface
8221 // --------------------------------------------------------
8223 _tz_clipboard_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard)
8225 wl_resource_destroy(res_tz_clipboard);
8229 _tz_clipboard_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard, struct wl_resource *surf)
8233 ec = e_client_from_surface_resource(surf);
8234 EINA_SAFETY_ON_NULL_RETURN(ec);
8235 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8237 _e_policy_wl_tz_clipboard_set_client(res_tz_clipboard, ec);
8238 e_service_cbhm_parent_set(ec, EINA_TRUE);
8239 e_service_cbhm_show();
8243 _tz_clipboard_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard, struct wl_resource *surf)
8247 ec = e_client_from_surface_resource(surf);
8248 EINA_SAFETY_ON_NULL_RETURN(ec);
8249 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8251 e_service_cbhm_parent_set(ec, EINA_FALSE);
8252 e_service_cbhm_hide();
8256 _tz_clipboard_cb_data_only_set(struct wl_client *client, struct wl_resource *res_tz_clipboard, uint32_t set)
8258 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8259 struct wl_client *_wc;
8260 struct wl_resource *data_res;
8265 E_Client *ec, *found = NULL;
8266 E_Comp_Wl_Client_Data *cdata;
8268 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8269 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8271 if (tz_clipboard->ec_list)
8274 "Unable to set data only mode for wl_client(%p) : "
8280 if (!(data_res = e_comp_wl_data_find_for_client(client)))
8283 "Unable to set data only mode for wl_client(%p) : "
8284 "no wl_data_device resource",
8289 clients = _e_policy_wl_e_clients_find_by_pid(pid);
8292 EINA_LIST_FREE(clients, ec)
8294 if (found) continue;
8295 cdata = e_client_cdata_get(ec);
8296 if (cdata && cdata->surface)
8298 _wc = wl_resource_get_client(cdata->surface);
8308 "Unable to set data only mode for wl_client(%p) : "
8314 /* Privilege Check */
8315 wl_client_get_credentials(client, &pid, &uid, NULL);
8316 res = e_security_privilege_check(pid, uid,
8317 E_PRIVILEGE_DATA_ONLY_SET);
8321 "Privilege Check Failed! DENY data_only_set",
8327 "Set data only mode :%d for wl_client(%p)",
8329 e_comp_wl_data_device_only_set(data_res, !(set == 0));
8330 tizen_clipboard_send_allowed_data_only(res_tz_clipboard, (uint32_t)1);
8334 tizen_clipboard_send_allowed_data_only(res_tz_clipboard, (uint32_t)0);
8337 static const struct tizen_clipboard_interface _tz_clipboard_iface =
8339 _tz_clipboard_cb_destroy,
8340 _tz_clipboard_cb_show,
8341 _tz_clipboard_cb_hide,
8342 _tz_clipboard_cb_data_only_set,
8346 _tz_clipboard_cb_unbind(struct wl_resource *res_tz_clipboard)
8348 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8350 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8351 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8353 _e_policy_wl_tz_clipboard_del(tz_clipboard);
8357 _tz_clipboard_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
8359 E_Policy_Wl_Tz_Clipboard *tz_clipboard_pol;
8360 struct wl_resource *res_tz_clipboard;
8362 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8364 res_tz_clipboard = wl_resource_create(client,
8365 &tizen_clipboard_interface,
8368 EINA_SAFETY_ON_NULL_GOTO(res_tz_clipboard, err);
8370 tz_clipboard_pol = _e_policy_wl_tz_clipboard_add(res_tz_clipboard);
8371 EINA_SAFETY_ON_NULL_GOTO(tz_clipboard_pol, err);
8373 wl_resource_set_implementation(res_tz_clipboard,
8374 &_tz_clipboard_iface,
8376 _tz_clipboard_cb_unbind);
8380 ERR("Could not create tizen_clipboard_interface res: %m");
8381 wl_client_post_no_memory(client);
8385 e_policy_wl_clipboard_data_selected_send(E_Client *ec)
8387 E_Comp_Wl_Client_Data *cdata;
8388 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8390 EINA_SAFETY_ON_NULL_RETURN(ec);
8392 tz_clipboard = _e_policy_wl_tz_clipboard_get_from_client(ec);
8393 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8395 cdata = e_client_cdata_get(ec);
8396 tizen_clipboard_send_data_selected(tz_clipboard->res_tz_clipboard,
8397 cdata ? cdata->surface : NULL);
8401 _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
8403 E_Comp_Wl_Client_Data *cdata;
8405 if (EINA_UNLIKELY(!ec))
8408 e_policy_client_maximize(ec);
8410 e_client_base_output_resolution_transform_adjust(ec);
8412 cdata = e_client_cdata_get(ec);
8413 if ((cdata->shell.configure_send) &&
8414 (cdata->shell.surface))
8417 if (ec->lock_client_size)
8422 cdata->shell.configure_send(cdata->shell.surface, 0, w, h);
8427 _e_policy_wl_cb_hook_alpha_change(void *data, E_Client *ec)
8430 if (!ec->argb) return;
8431 if (!ec->transients) return;
8432 if (!e_policy_visibility_client_is_uniconify_render_running(ec)) return;
8435 Eina_List *list = eina_list_clone(ec->transients);
8437 EINA_LIST_FREE(list, child)
8439 if (e_client_transient_policy_get(child) == E_TRANSIENT_BELOW)
8441 ELOGF("POL_VIS", "Uniconify below child(win:%zx, ec:%p) by changing alpha", ec, e_client_util_win_get(child), child);
8442 e_policy_client_uniconify_by_visibility(child);
8448 _e_policy_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
8452 if (e_object_is_del(E_OBJECT(ec))) return;
8453 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
8455 if (ec->manage_resize.resize_obj)
8457 x = ec->manage_resize.x;
8458 y = ec->manage_resize.y;
8459 w = ec->manage_resize.w;
8460 h = ec->manage_resize.h;
8468 e_client_geometry_get(ec, &x, &y, &w, &h);
8471 E_Policy_Wl_Tzpol *tzpol;
8472 E_Policy_Wl_Surface *psurf;
8477 it = eina_hash_iterator_data_new(polwl->tzpols);
8478 EINA_ITERATOR_FOREACH(it, tzpol)
8480 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8482 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8483 if (!psurf->surf) continue;
8485 ver = wl_resource_get_version(tzpol->res_tzpol);
8488 // interactive_resize_done event is supported since ver 10
8492 tizen_policy_send_interactive_resize_done(tzpol->res_tzpol,
8493 psurf->surf, x, y, w, h,
8494 ec->e.state.rot.ang.curr);
8497 eina_iterator_free(it);
8501 _e_policy_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
8503 if (e_object_is_del(E_OBJECT(ec))) return;
8504 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
8511 e_client_geometry_get(ec, &x, &y, &w, &h);
8513 E_Policy_Wl_Tzpol *tzpol;
8514 E_Policy_Wl_Surface *psurf;
8519 it = eina_hash_iterator_data_new(polwl->tzpols);
8520 EINA_ITERATOR_FOREACH(it, tzpol)
8522 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8524 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8525 if (!psurf->surf) continue;
8527 ver = wl_resource_get_version(tzpol->res_tzpol);
8530 // interactive_move_done event is supported since ver 10
8534 tizen_policy_send_interactive_move_done(tzpol->res_tzpol,
8537 ec->e.state.rot.ang.curr);
8540 eina_iterator_free(it);
8544 e_policy_wl_generate_request(E_Client *ec, E_Policy_Wl_Gen_Request type)
8546 E_Comp_Wl_Client_Data *cdata = NULL;
8549 cdata = e_client_cdata_get(ec);
8551 if (!cdata->wl_surface) return;
8553 ELOGF("POL", "Generate operation (type:%d)", ec, type);
8556 case E_POLICY_WL_GENERATE_REQUEST_LOWER:
8557 _tzpol_iface_cb_lower(NULL, NULL, cdata->wl_surface);
8559 case E_POLICY_WL_GENERATE_REQUEST_ACTIVATE:
8560 _tzpol_iface_cb_activate(NULL, NULL, cdata->wl_surface);
8562 case E_POLICY_WL_GENERATE_REQUEST_ICONIFY:
8563 _tzpol_iface_cb_iconify(NULL, NULL, cdata->wl_surface);
8565 case E_POLICY_WL_GENERATE_REQUEST_UNICONIFY:
8566 _tzpol_iface_cb_uniconify(NULL, NULL, cdata->wl_surface);
8574 e_policy_wl_aux_hint_apply(E_Client *ec)
8576 _e_policy_wl_aux_hint_apply(ec);
8579 // --------------------------------------------------------
8581 // --------------------------------------------------------
8583 e_policy_wl_client_add(E_Client *ec)
8585 EINA_SAFETY_ON_NULL_RETURN(ec);
8586 if (!ec->pixmap) return;
8588 _e_policy_wl_surf_client_set(ec);
8589 _e_policy_wl_tzlaunch_effect_type_sync(ec);
8593 e_policy_wl_client_del(E_Client *ec)
8595 EINA_SAFETY_ON_NULL_RETURN(ec);
8596 if (!ec->pixmap) return;
8598 e_policy_wl_pixmap_del(ec->pixmap);
8599 _e_policy_wl_dpy_surf_del(ec);
8600 _e_policy_wl_tz_indicator_unset_client(ec);
8601 _e_policy_wl_tz_clipboard_unset_client(ec);
8602 _launch_effect_client_del(ec);
8604 polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
8608 e_policy_wl_pixmap_del(E_Pixmap *cp)
8610 E_Policy_Wl_Tzpol *tzpol;
8611 E_Policy_Wl_Surface *psurf;
8615 it = eina_hash_iterator_data_new(polwl->tzpols);
8616 EINA_ITERATOR_FOREACH(it, tzpol)
8617 EINA_LIST_FOREACH_SAFE(tzpol->psurfs, l, ll, psurf)
8619 if (psurf->cp != cp) continue;
8620 tzpol->psurfs = eina_list_remove_list(tzpol->psurfs, l);
8621 _e_policy_wl_surf_del(psurf);
8623 eina_iterator_free(it);
8627 e_policy_wl_aux_message_send(E_Client *ec,
8632 E_Comp_Wl_Client_Data *cdata;
8633 E_Policy_Wl_Tzpol *tzpol;
8634 E_Policy_Wl_Surface *psurf;
8637 struct wl_array opt_array;
8642 if (e_object_is_del(E_OBJECT(ec))) return;
8643 cdata = e_client_cdata_get(ec);
8645 if (!cdata->aux_hint.use_msg) return;
8647 wl_array_init(&opt_array);
8648 EINA_LIST_FOREACH(options, l, option)
8650 len = strlen(option) + 1;
8651 p = wl_array_add(&opt_array, len);
8655 strncpy(p, option, len);
8658 it = eina_hash_iterator_data_new(polwl->tzpols);
8659 EINA_ITERATOR_FOREACH(it, tzpol)
8660 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8662 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8663 if (!psurf->surf) continue;
8665 tizen_policy_send_aux_message(tzpol->res_tzpol,
8667 key, val, &opt_array);
8669 "SEND |res_tzpol:%8p|aux message key:%s val:%s opt_count:%d",
8672 key, val, eina_list_count(options));
8674 eina_iterator_free(it);
8675 wl_array_release(&opt_array);
8679 e_policy_wl_aux_hint_init(void)
8682 E_Config_Aux_Hint_Supported *auxhint;
8685 n = (sizeof(hint_names) / sizeof(char *));
8687 for (i = 0; i < n; i++)
8689 e_hints_aux_hint_supported_add(hint_names[i]);
8692 EINA_LIST_FOREACH(e_config->aux_hint_supported, l, auxhint)
8694 if (!auxhint->name) continue;
8695 e_hints_aux_hint_supported_add(auxhint->name);
8702 e_policy_wl_defer_job(void)
8704 struct wl_global *global = NULL;
8705 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8707 if (!e_config->global_object_not_provide.launch_effect)
8709 global = wl_global_create(e_comp_wl->wl.disp,
8710 &tizen_launch_effect_interface,
8713 _tzlaunch_effect_cb_bind);
8714 EINA_SAFETY_ON_NULL_GOTO(global, err);
8716 polwl->globals = eina_list_append(polwl->globals, global);
8719 global = wl_global_create(e_comp_wl->wl.disp,
8720 &tizen_launch_appinfo_interface,
8723 _tzlaunch_appinfo_cb_bind);
8724 EINA_SAFETY_ON_NULL_GOTO(global, err);
8726 polwl->globals = eina_list_append(polwl->globals, global);
8735 e_policy_wl_init(void)
8737 struct wl_global *global;
8739 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
8740 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->wl.disp, EINA_FALSE);
8742 polwl = E_NEW(E_Policy_Wl, 1);
8743 EINA_SAFETY_ON_NULL_RETURN_VAL(polwl, EINA_FALSE);
8745 /* create globals */
8746 global = wl_global_create(e_comp_wl->wl.disp,
8747 &tizen_policy_interface,
8751 EINA_SAFETY_ON_NULL_GOTO(global, err);
8752 polwl->globals = eina_list_append(polwl->globals, global);
8754 global = wl_global_create(e_comp_wl->wl.disp,
8755 &tizen_display_policy_interface,
8758 _tz_dpy_pol_cb_bind);
8759 EINA_SAFETY_ON_NULL_GOTO(global, err);
8760 polwl->globals = eina_list_append(polwl->globals, global);
8762 global = wl_global_create(e_comp_wl->wl.disp,
8763 &tizen_ws_shell_interface,
8768 EINA_SAFETY_ON_NULL_GOTO(global, err);
8769 polwl->globals = eina_list_append(polwl->globals, global);
8771 global = wl_global_create(e_comp_wl->wl.disp,
8772 &tizen_indicator_interface,
8775 _tz_indicator_cb_bind);
8776 EINA_SAFETY_ON_NULL_GOTO(global, err);
8777 polwl->globals = eina_list_append(polwl->globals, global);
8779 global = wl_global_create(e_comp_wl->wl.disp,
8780 &tizen_clipboard_interface,
8783 _tz_clipboard_cb_bind);
8784 EINA_SAFETY_ON_NULL_GOTO(global, err);
8785 polwl->globals = eina_list_append(polwl->globals, global);
8787 polwl->tzpols = eina_hash_pointer_new(_e_policy_wl_tzpol_del);
8789 E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(hooks_co, E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER, _e_policy_wl_cb_hook_intercept_show_helper, NULL);
8791 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_ON, _e_policy_wl_cb_scrsaver_on, NULL);
8792 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_OFF, _e_policy_wl_cb_scrsaver_off, NULL);
8794 E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_policy_wl_cb_hook_shell_surface_ready, NULL);
8795 E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, _e_policy_wl_cb_hook_alpha_change, NULL);
8797 E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_RESIZE_END, _e_policy_wl_client_cb_resize_end, NULL);
8798 E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_MOVE_END, _e_policy_wl_client_cb_move_end, NULL);
8800 E_EVENT_POLICY_INDICATOR_STATE_CHANGE = ecore_event_type_new();
8801 E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = ecore_event_type_new();
8802 E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = ecore_event_type_new();
8804 e_service_softkey_client_remove_handler_add();
8806 e_policy_display_init();
8813 EINA_LIST_FREE(polwl->globals, global)
8814 wl_global_destroy(global);
8822 e_policy_wl_shutdown(void)
8824 E_Policy_Wl_Tzsh *tzsh;
8825 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
8826 E_Policy_Wl_Tzsh_Extension *tzsh_extension;
8827 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
8828 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
8829 E_Policy_Wl_Tz_Indicator *tz_indicator;
8830 struct wl_global *global;
8833 e_policy_display_shutdown();
8835 EINA_SAFETY_ON_NULL_RETURN(polwl);
8837 E_FREE_LIST(polwl_hooks_ec, e_client_hook_del);
8838 E_FREE_LIST(hooks_cw, e_comp_wl_hook_del);
8839 E_FREE_LIST(hooks_co, e_comp_object_intercept_hook_del);
8840 E_FREE_LIST(handlers, ecore_event_handler_del);
8842 e_service_softkey_client_remove_handler_del();
8844 polwl->pending_vis = eina_list_free(polwl->pending_vis);
8846 for (i = 0; i < TZSH_SRV_ROLE_MAX; i++)
8848 tzsh_srv = polwl->srvs[i];
8849 if (!tzsh_srv) continue;
8851 wl_resource_destroy(tzsh_srv->res_tzsh_srv);
8854 EINA_LIST_FREE(polwl->tzshs, tzsh)
8855 wl_resource_destroy(tzsh->res_tzsh);
8857 EINA_LIST_FREE(polwl->tz_dpy_pols, tz_dpy_pol)
8859 E_Policy_Wl_Dpy_Surface *dpy_surf;
8860 EINA_LIST_FREE(tz_dpy_pol->dpy_surfs, dpy_surf)
8864 wl_resource_destroy(tz_dpy_pol->res_tz_dpy_pol);
8867 EINA_LIST_FREE(polwl->tzlaunch_effect_info, effect_info)
8869 E_FREE(effect_info);
8872 EINA_LIST_FREE(polwl->tz_indicators, tz_indicator)
8874 eina_list_free(tz_indicator->ec_list);
8875 wl_resource_destroy(tz_indicator->res_tz_indicator);
8878 EINA_LIST_FREE(polwl->tzsh_extensions, tzsh_extension)
8880 free(tzsh_extension->name);
8883 EINA_LIST_FREE(polwl->globals, global)
8884 wl_global_destroy(global);
8886 E_FREE_FUNC(polwl->tzpols, eina_hash_free);