1 #include "e_policy_wl_intern.h"
2 #include "e_policy_intern.h"
3 #include "e_appinfo_intern.h"
4 #include "services/e_service_quickpanel_intern.h"
5 #include "services/e_service_volume_intern.h"
6 #include "services/e_service_lockscreen_intern.h"
7 #include "services/e_service_indicator_intern.h"
8 #include "services/e_service_cbhm_intern.h"
9 #include "services/e_service_scrsaver_intern.h"
10 #include "services/e_service_softkey_intern.h"
11 #include "services/e_service_launcher_intern.h"
12 #include "services/e_service_taskbar_intern.h"
13 #include "services/e_service_kvm_intern.h"
14 #include "e_policy_wl_display_intern.h"
15 #include "e_policy_conformant_intern.h"
16 #include "e_policy_visibility_intern.h"
17 #include "e_subsurface_watcher_intern.h"
18 #include "e_client_intern.h"
19 #include "e_subsurface_watcher_intern.h"
20 #include "e_comp_wl_data_intern.h"
21 #include "e_comp_wl_intern.h"
22 #include "e_comp_wl_subsurface_intern.h"
23 #include "e_comp_intern.h"
24 #include "e_privilege_intern.h"
25 #include "e_magnifier_intern.h"
26 #include "e_hints_intern.h"
27 #include "e_comp_object_intern.h"
28 #include "e_zone_intern.h"
29 #include "e_config_intern.h"
30 #include "e_security_intern.h"
31 #include "e_utils_intern.h"
32 #include "e_screensaver_intern.h"
33 #include "e_hwc_window_intern.h"
35 #include <device/display.h>
36 #include <wayland-server.h>
37 #include <tizen-extension-server-protocol.h>
38 #include <tizen-launch-server-protocol.h>
39 #include <tzsh_server.h>
41 typedef enum _Tzsh_Srv_Role
43 TZSH_SRV_ROLE_UNKNOWN = -1,
45 TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT,
46 TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU,
47 TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU,
48 TZSH_SRV_ROLE_LOCKSCREEN,
49 TZSH_SRV_ROLE_INDICATOR,
50 TZSH_SRV_ROLE_SCREENSAVER_MNG,
51 TZSH_SRV_ROLE_SCREENSAVER,
53 TZSH_SRV_ROLE_SOFTKEY,
54 TZSH_SRV_ROLE_MAGNIFIER,
55 TZSH_SRV_ROLE_LAUNCHER,
56 TZSH_SRV_ROLE_TASKBAR,
61 typedef enum _Tzsh_Client_Handle_Type
63 TZSH_CLIENT_HANDLE_TYPE_NONE = 0,
64 TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL = 1,
65 TZSH_CLIENT_HANDLE_TYPE_SHARED_WIDGET_LAUNCH = 2,
66 TZSH_CLIENT_HANDLE_TYPE_SOFTKEY = 3,
67 } Tzsh_Client_Handle_Type;
69 typedef enum _Tzsh_Type
71 TZSH_TYPE_UNKNOWN = 0,
76 typedef enum _Tzlaunch_Effect_Type
78 TZLAUNCH_EFFECT_TYPE_LAUNCH = 0,
79 TZLAUNCH_EFFECT_TYPE_DEPTH_IN
80 } Tzlaunch_Effect_Type;
82 typedef struct _E_Policy_Wl_Tzpol
84 struct wl_resource *res_tzpol; /* tizen_policy_interface */
85 Eina_List *psurfs; /* list of E_Policy_Wl_Surface */
90 typedef struct _E_Policy_Wl_Tz_Dpy_Pol
92 struct wl_resource *res_tz_dpy_pol;
93 Eina_List *dpy_surfs; // list of E_Policy_Wl_Dpy_Surface
94 } E_Policy_Wl_Tz_Dpy_Pol;
96 typedef struct _E_Policy_Wl_Tzsh
98 struct wl_resource *res_tzsh; /* tizen_ws_shell_interface */
99 Eina_List *service_list;
100 Eina_List *client_list;
103 typedef struct _E_Policy_Wl_Tzsh_Srv
105 E_Policy_Wl_Tzsh *tzsh;
106 struct wl_resource *res_tzsh_srv;
113 } E_Policy_Wl_Tzsh_Srv;
115 typedef struct _E_Policy_Wl_Tzsh_Client
117 E_Policy_Wl_Tzsh *tzsh;
118 struct wl_resource *res_tzsh_client;
119 Tzsh_Client_Handle_Type handle_type;
125 } E_Policy_Wl_Tzsh_Client;
127 typedef struct _E_Policy_Wl_Tzsh_Client_Data_Quickpanel
129 E_Quickpanel_Type type;
130 } E_Policy_Wl_Tzsh_Client_Data_Quickpanel;
132 typedef struct _E_Policy_Wl_Tzsh_Client_Data_Softkey
135 } E_Policy_Wl_Tzsh_Client_Data_Softkey;
137 typedef struct _E_Policy_Wl_Tzsh_Region
139 E_Policy_Wl_Tzsh *tzsh;
140 struct wl_resource *res_tzsh_reg;
142 struct wl_listener destroy_listener;
143 } E_Policy_Wl_Tzsh_Region;
145 typedef struct _E_Policy_Wl_Tzsh_Extension
148 E_Policy_Wl_Tzsh_Ext_Hook_Cb cb;
149 } E_Policy_Wl_Tzsh_Extension;
151 typedef struct _E_Policy_Wl_Surface
153 struct wl_resource *surf;
154 E_Policy_Wl_Tzpol *tzpol;
158 Eina_Bool pending_notilv;
160 Eina_List *vislist; /* list of tizen_visibility_interface resources */
161 Eina_List *poslist; /* list of tizen_position_inteface resources */
162 Eina_Bool is_background;
163 } E_Policy_Wl_Surface;
165 typedef struct _E_Policy_Wl_Dpy_Surface
167 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
168 struct wl_resource *surf;
172 } E_Policy_Wl_Dpy_Surface;
174 typedef struct _E_Policy_Wl_Tzlaunch_Effect
176 struct wl_resource *res_tzlaunch_effect; /* tizen_launch_effect */
177 Eina_List *splash_list; /* list of E_Policy_Wl_Tzlaunch_Splash */
178 } E_Policy_Wl_Tzlaunch_Effect;
180 typedef struct _E_Policy_Wl_Tzlaunch_Splash
182 struct wl_resource *res_tzlaunch_splash; /* tizen_launch_image */
183 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect; /* launcher */
185 const char *path; /* image resource path */
186 uint32_t type; /* 0: image, 1: edc */
187 uint32_t indicator; /* 0: off, 1: on */
188 uint32_t angle; /* 0, 90, 180, 270 : rotation angle */
191 Evas_Object *obj; /* launch screen image */
192 E_Pixmap *ep; /* pixmap for launch screen client */
193 E_Client *ec; /* client for launch screen image */
194 Ecore_Timer *timeout; /* launch screen image hide timer */
195 Evas_Object *indicator_obj; /* plug object of indicator */
197 Eina_Bool valid; /* validation check */
199 E_Comp_Object_Content_Type content_type; /* type of content */
201 Eina_Bool custom_effect_callee; /* custom effect enabled */
203 } E_Policy_Wl_Tzlaunch_Splash;
205 typedef struct _E_Policy_Wl_Tzlaunch_Effect_Info
207 uint32_t pid; /* pid */
208 int effect_type; /* effect_type */
209 } E_Policy_Wl_Tzlaunch_Effect_Info;
211 typedef struct _E_Policy_Wl_Tzlaunch_Appinfo
213 struct wl_resource *res_tzlaunch_appinfo; /* tizen_launch_appinfo */
214 } E_Policy_Wl_Tzlaunch_Appinfo;
216 typedef enum _Launch_Img_File_type
218 LAUNCH_IMG_FILE_TYPE_ERROR = -1,
219 LAUNCH_IMG_FILE_TYPE_IMAGE = 0,
220 LAUNCH_IMG_FILE_TYPE_EDJ
221 } Launch_Img_File_type;
223 typedef struct _E_Policy_Wl_Tz_Indicator
225 struct wl_resource *res_tz_indicator;
227 } E_Policy_Wl_Tz_Indicator;
229 typedef struct _E_Policy_Wl_Tz_Clipboard
231 struct wl_resource *res_tz_clipboard;
233 } E_Policy_Wl_Tz_Clipboard;
235 typedef struct _E_Policy_Wl
237 Eina_List *globals; /* list of wl_global */
238 Eina_Hash *tzpols; /* list of E_Policy_Wl_Tzpol */
240 Eina_List *tz_dpy_pols; /* list of E_Policy_Wl_Tz_Dpy_Pol */
241 Eina_List *pending_vis; /* list of clients that have pending visibility change*/
243 /* tizen_ws_shell_interface */
244 Eina_List *tzshs; /* list of E_Policy_Wl_Tzsh */
245 Eina_List *tzsh_srvs; /* list of E_Policy_Wl_Tzsh_Srv */
246 Eina_List *tzsh_clients; /* list of E_Policy_Wl_Tzsh_Client */
247 E_Policy_Wl_Tzsh_Srv *srvs[TZSH_SRV_ROLE_MAX]; /* list of registered E_Policy_Wl_Tzsh_Srv */
248 Eina_List *tz_indicators;
249 Eina_List *tz_clipboards; /* list of E_Policy_Wl_Tz_Clipboard */
251 /* tizen_launch_effect_interface */
252 Eina_List *tzlaunch_effect; /* list of E_Policy_Wl_Tzlaunch_Effect */
253 Eina_List *tzlaunch_effect_info; /* list of E_Policy_Wl_Tzlaunch_Effect_Info */
254 /* tizen_launch_appinfo_interface */
255 Eina_List *tzlaunch_appinfo; /* list of E_Policy_Wl_Tzlaunch_Appinfo */
256 /* tizen_ws_shell_interface ver_2 */
257 Eina_List *tzsh_extensions; /* list of E_Policy_Wl_Tzsh_Extension */
260 typedef struct _E_Tzsh_QP_Event
266 static E_Policy_Wl *polwl = NULL;
268 static Eina_List *handlers = NULL;
269 static Eina_List *polwl_hooks_ec = NULL;
270 static Eina_List *hooks_cw = NULL;
271 static Eina_List *hooks_co = NULL;
272 static struct wl_resource *_scrsaver_mng_res = NULL; // TODO
273 static struct wl_resource *_indicator_srv_res = NULL;
275 static int _e_policy_wl_hooks_delete = 0;
276 static int _e_policy_wl_hooks_walking = 0;
278 static Eina_Inlist *_e_policy_wl_hooks[] =
280 [E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET] = NULL,
283 EINTERN int E_EVENT_POLICY_INDICATOR_STATE_CHANGE = -1;
284 EINTERN int E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = -1;
285 EINTERN int E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = -1;
287 enum _E_Policy_Hint_Type
289 E_POLICY_HINT_USER_GEOMETRY = 0,
290 E_POLICY_HINT_FIXED_RESIZE = 1,
291 E_POLICY_HINT_DEICONIFY_UPDATE = 2,
292 E_POLICY_HINT_ICONIFY = 3,
293 E_POLICY_HINT_ABOVE_LOCKSCREEN = 4,
294 E_POLICY_HINT_GESTURE_DISABLE = 5,
295 E_POLICY_HINT_EFFECT_DISABLE = 6,
296 E_POLICY_HINT_MSG_USE = 7,
297 E_COMP_HINT_ALWAYS_SELECTIVE = 8,
298 E_POLICY_HINT_DEPENDENT_ROTATION = 9,
299 E_POLICY_HINT_ROT_RENDER_NOPENDING = 10,
300 E_POLICY_HINT_ICONIFY_BUFFER_FLUSH = 11,
301 E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP = 12,
302 E_POLICY_HINT_BELONG_TO_PARENT = 13,
303 E_POLICY_HINT_RESIZE_ASPECT_RATIO = 14,
304 E_POLICY_HINT_DECORATION_SIZE_HEADER = 15,
305 E_POLICY_HINT_DECORATION_SIZE_FOOTER = 16,
306 E_POLICY_HINT_VISIBILITY_IGNORE_GEOMETRY= 17,
307 E_POLICY_HINT_RESIZE_PPU = 18,
308 E_POLICY_HINT_DECORATION_SIZE_SHADOW_TOP = 19,
309 E_POLICY_HINT_DECORATION_SIZE_SHADOW_BOTTOM = 20,
310 E_POLICY_HINT_DECORATION_SIZE_SHADOW_LEFT = 21,
311 E_POLICY_HINT_DECORATION_SIZE_SHADOW_RIGHT = 22,
314 static const char *hint_names[] =
316 "wm.policy.win.user.geometry",
317 "wm.policy.win.fixed.resize",
318 "wm.policy.win.deiconify.update",
319 "wm.policy.win.iconify",
320 "wm.policy.win.above.lock",
321 "wm.policy.win.gesture.disable",
322 "wm.policy.win.effect.disable",
323 "wm.policy.win.msg.use",
324 "wm.comp.win.always.selective.mode",
325 "wm.policy.win.rot.dependent",
326 "wm.policy.win.rot.render.nopending",
327 "wm.policy.win.iconify.buffer.flush",
328 "wm.policy.win.transient_for.always_on_top",
329 "wm.policy.win.belong_to_parent",
330 "wm.policy.win.resize_aspect_ratio",
331 "wm.policy.win.decoration.size.header",
332 "wm.policy.win.decoration.size.footer",
333 "wm.policy.win.visibility.ignore_geometry",
334 "wm.policy.win.resize.ppu",
335 "wm.policy.win.decoration.size.shadow.top",
336 "wm.policy.win.decoration.size.shadow.bottom",
337 "wm.policy.win.decoration.size.shadow.left",
338 "wm.policy.win.decoration.size.shadow.right",
341 static void _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf);
342 static void _e_policy_wl_tzsh_srv_state_broadcast(E_Policy_Wl_Tzsh_Srv *tzsh_srv, Eina_Bool reg);
343 static Eina_Bool _e_policy_wl_e_client_is_valid(E_Client *ec);
344 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);
345 static void _e_policy_wl_tzsh_srv_del(E_Policy_Wl_Tzsh_Srv *tzsh_srv);
346 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);
347 static void _e_policy_wl_tzsh_client_del(E_Policy_Wl_Tzsh_Client *tzsh_client);
348 static void _e_policy_wl_background_state_set(E_Policy_Wl_Surface *psurf, Eina_Bool state);
350 static void _e_policy_wl_tzlaunch_effect_type_sync(E_Client *ec);
351 static int _e_policy_wl_tzlaunch_effect_type_get(const char* effect_type);
352 static void _e_policy_wl_tzlaunch_effect_type_unset(uint32_t pid);
354 static void _launch_effect_hide(uint32_t pid);
355 static void _launch_effect_client_del(E_Client *ec);
356 static void _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash);
358 // --------------------------------------------------------
360 // --------------------------------------------------------
363 _e_policy_wl_hooks_clean()
365 E_Policy_Wl_Hook *epwh = NULL;
366 Eina_Inlist *l = NULL;
369 for (x = 0; x < E_POLICY_WL_HOOK_LAST; x++)
371 EINA_INLIST_FOREACH_SAFE(_e_policy_wl_hooks[x], l, epwh)
373 if (!epwh->delete_me) continue;
374 _e_policy_wl_hooks[x] = eina_inlist_remove(_e_policy_wl_hooks[x], EINA_INLIST_GET(epwh));
381 _e_policy_wl_hook_call(E_Policy_Wl_Hook_Point hookpoint, pid_t pid)
383 E_Policy_Wl_Hook *epwh = NULL;
385 _e_policy_wl_hooks_walking++;
386 EINA_INLIST_FOREACH(_e_policy_wl_hooks[hookpoint], epwh)
388 if (epwh->delete_me) continue;
389 epwh->func(epwh->data, pid);
391 _e_policy_wl_hooks_walking--;
393 if ((_e_policy_wl_hooks_walking == 0) && (_e_policy_wl_hooks_delete > 0))
394 _e_policy_wl_hooks_clean();
397 E_API E_Policy_Wl_Hook *
398 e_policy_wl_hook_add(E_Policy_Wl_Hook_Point hookpoint, E_Policy_Wl_Hook_Cb func, const void *data)
400 E_Policy_Wl_Hook *epwh = NULL;
402 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0, NULL);
403 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_POLICY_WL_HOOK_LAST, NULL);
405 epwh = E_NEW(E_Policy_Wl_Hook, 1);
406 EINA_SAFETY_ON_NULL_RETURN_VAL(epwh, NULL);
408 epwh->hookpoint = hookpoint;
410 epwh->data = (void *)data;
411 _e_policy_wl_hooks[hookpoint] = eina_inlist_append(_e_policy_wl_hooks[hookpoint], EINA_INLIST_GET(epwh));
417 e_policy_wl_hook_del(E_Policy_Wl_Hook *epwh)
420 if (_e_policy_wl_hooks_walking == 0)
422 _e_policy_wl_hooks[epwh->hookpoint] = eina_inlist_remove(_e_policy_wl_hooks[epwh->hookpoint], EINA_INLIST_GET(epwh));
426 _e_policy_wl_hooks_delete++;
429 // --------------------------------------------------------
431 // --------------------------------------------------------
433 _e_policy_wl_tzpol_background_state_check(pid_t pid)
435 E_Policy_Wl_Tzpol *tzpol;
437 Eina_Bool bg_state = EINA_FALSE;
442 it = eina_hash_iterator_data_new(polwl->tzpols);
443 EINA_ITERATOR_FOREACH(it, tzpol)
445 if (tzpol->pid == pid)
449 bg_state = EINA_TRUE;
454 eina_iterator_free(it);
459 static E_Policy_Wl_Tzpol *
460 _e_policy_wl_tzpol_add(struct wl_client *client, struct wl_resource *res_tzpol)
462 E_Policy_Wl_Tzpol *tzpol;
465 tzpol = E_NEW(E_Policy_Wl_Tzpol, 1);
466 EINA_SAFETY_ON_NULL_RETURN_VAL(tzpol, NULL);
468 eina_hash_add(polwl->tzpols, &res_tzpol, tzpol);
470 tzpol->res_tzpol = res_tzpol;
472 wl_client_get_credentials(client, &pid, NULL, NULL);
475 tzpol->bg_state = _e_policy_wl_tzpol_background_state_check(pid);
481 _e_policy_wl_tzpol_del(void *data)
483 E_Policy_Wl_Tzpol *tzpol;
484 E_Policy_Wl_Surface *psurf;
486 tzpol = (E_Policy_Wl_Tzpol *)data;
488 EINA_LIST_FREE(tzpol->psurfs, psurf)
490 _e_policy_wl_surf_del(psurf);
493 memset(tzpol, 0x0, sizeof(E_Policy_Wl_Tzpol));
497 static E_Policy_Wl_Tzpol *
498 _e_policy_wl_tzpol_get(struct wl_resource *res_tzpol)
500 return (E_Policy_Wl_Tzpol *)eina_hash_find(polwl->tzpols, &res_tzpol);
503 static E_Policy_Wl_Surface *
504 _e_policy_wl_tzpol_surf_find(E_Policy_Wl_Tzpol *tzpol, E_Client *ec)
507 E_Policy_Wl_Surface *psurf;
509 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
519 _e_policy_wl_surf_is_valid(E_Policy_Wl_Surface *psurf)
521 E_Policy_Wl_Tzpol *tzpol;
522 E_Policy_Wl_Surface *psurf2;
526 it = eina_hash_iterator_data_new(polwl->tzpols);
527 EINA_ITERATOR_FOREACH(it, tzpol)
528 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf2)
532 eina_iterator_free(it);
536 eina_iterator_free(it);
541 // --------------------------------------------------------
543 // --------------------------------------------------------
546 _print_tzsh_service_info(void)
548 E_Policy_Wl_Tzsh_Srv *tzsh_srv = NULL;
552 ELOGF("TZSH", "================ TZSH SERVICE LIST ================", NULL);
553 EINA_LIST_FOREACH(polwl->tzsh_srvs, l, tzsh_srv)
555 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);
558 ELOGF("TZSH", "---------------------------------------------------", NULL);
562 _print_tzsh_client_info(void)
564 E_Policy_Wl_Tzsh_Client *tzsh_client = NULL;
568 ELOGF("TZSH", "================ TZSH CLIENT LIST ================", NULL);
569 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
571 ELOGF("TZSH", "[%d] tzsh_client(%p). tzsh:%p", tzsh_client->ec, i, tzsh_client, tzsh_client->tzsh);
574 ELOGF("TZSH", "---------------------------------------------------", NULL);
578 static E_Policy_Wl_Tzsh *
579 _e_policy_wl_tzsh_add(struct wl_resource *res_tzsh)
581 E_Policy_Wl_Tzsh *tzsh;
583 tzsh = E_NEW(E_Policy_Wl_Tzsh, 1);
584 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh, NULL);
586 ELOGF("TZSH", "NEW tzsh:%p, res_tzsh:%p", NULL, tzsh, res_tzsh);
588 tzsh->res_tzsh = res_tzsh;
590 polwl->tzshs = eina_list_append(polwl->tzshs, tzsh);
593 _print_tzsh_service_info();
594 _print_tzsh_client_info();
601 _e_policy_wl_tzsh_del(E_Policy_Wl_Tzsh *tzsh)
603 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
604 E_Policy_Wl_Tzsh_Client *tzsh_client;
607 polwl->tzshs = eina_list_remove(polwl->tzshs, tzsh);
609 EINA_LIST_FOREACH_SAFE(polwl->tzsh_srvs, l, ll, tzsh_srv)
611 if (tzsh_srv->tzsh != tzsh) continue;
612 _e_policy_wl_tzsh_srv_del(tzsh_srv);
615 if (tzsh->service_list)
617 EINA_LIST_FOREACH_SAFE(tzsh->service_list, l, ll, tzsh_srv)
619 _e_policy_wl_tzsh_srv_del(tzsh_srv);
621 eina_list_free(tzsh->service_list);
622 tzsh->service_list = NULL;
625 EINA_LIST_FOREACH_SAFE(polwl->tzsh_clients, l, ll, tzsh_client)
627 if (tzsh_client->tzsh != tzsh) continue;
628 _e_policy_wl_tzsh_client_del(tzsh_client);
631 if (tzsh->client_list)
633 EINA_LIST_FOREACH_SAFE(tzsh->client_list, l, ll, tzsh_client)
635 _e_policy_wl_tzsh_client_del(tzsh_client);
637 eina_list_free(tzsh->client_list);
638 tzsh->client_list = NULL;
642 _print_tzsh_service_info();
643 _print_tzsh_client_info();
646 ELOGF("TZSH", "FREE tzsh:%p", NULL, tzsh);
648 memset(tzsh, 0x0, sizeof(E_Policy_Wl_Tzsh));
652 /* notify current registered services to the client */
654 _e_policy_wl_tzsh_registered_srv_send(E_Policy_Wl_Tzsh *tzsh)
658 for (i = 0; i < TZSH_SRV_ROLE_MAX; i++)
660 if (!polwl->srvs[i]) continue;
662 tizen_ws_shell_send_service_register
663 (tzsh->res_tzsh, polwl->srvs[i]->name);
668 _e_policy_wl_tzsh_srv_cb_client_zone_set(void *data, int type EINA_UNUSED, void *event)
670 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
671 E_Event_Client_Zone_Set *ev;
676 if (tzsh_srv->ec != ev->ec)
679 if (tzsh_srv->zone == ev->zone)
682 ELOGF("TZSH", "Change Zone | e_policy_wl_tzsh_srv %p old(%p) new(%p)",
683 tzsh_srv->ec, tzsh_srv, tzsh_srv->zone, ev->zone);
685 tzsh_srv->zone = ev->zone;
688 return ECORE_CALLBACK_PASS_ON;
691 // --------------------------------------------------------
692 // E_Policy_Wl_Tzsh_Srv
693 // --------------------------------------------------------
694 static E_Policy_Wl_Tzsh_Srv *
695 _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)
697 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
699 tzsh_srv = E_NEW(E_Policy_Wl_Tzsh_Srv, 1);
700 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_srv, NULL);
702 tzsh_srv->tzsh = tzsh;
703 tzsh_srv->res_tzsh_srv = res_tzsh_srv;
704 tzsh_srv->role = role;
705 tzsh_srv->name = eina_stringshare_add(name);
708 tzsh_srv->zone = e_comp_zone_find_by_ec(ec);
709 e_object_ref(E_OBJECT(ec));
710 tzsh_srv->tzsh->service_list = eina_list_append(tzsh_srv->tzsh->service_list, tzsh_srv);
712 polwl->srvs[role] = tzsh_srv;
713 polwl->tzsh_srvs = eina_list_append(polwl->tzsh_srvs, tzsh_srv);
715 ELOGF("TZSH", "CREATE tzsh_srv:%p, res_tzsh_srv:%p", ec, tzsh_srv, res_tzsh_srv);
718 _print_tzsh_service_info();
721 _e_policy_wl_tzsh_srv_state_broadcast(tzsh_srv, EINA_TRUE);
723 E_LIST_HANDLER_APPEND(tzsh_srv->events, E_EVENT_CLIENT_ZONE_SET, _e_policy_wl_tzsh_srv_cb_client_zone_set, tzsh_srv);
729 _e_policy_wl_tzsh_srv_del(E_Policy_Wl_Tzsh_Srv *tzsh_srv)
731 E_FREE_LIST(tzsh_srv->events, ecore_event_handler_del);
733 polwl->tzsh_srvs = eina_list_remove(polwl->tzsh_srvs, tzsh_srv);
736 _print_tzsh_service_info();
739 if (tzsh_srv->tzsh && tzsh_srv->tzsh->service_list)
740 tzsh_srv->tzsh->service_list = eina_list_remove(tzsh_srv->tzsh->service_list, tzsh_srv);
742 if (polwl->srvs[tzsh_srv->role] == tzsh_srv)
743 polwl->srvs[tzsh_srv->role] = NULL;
745 _e_policy_wl_tzsh_srv_state_broadcast(tzsh_srv, EINA_FALSE);
748 eina_stringshare_del(tzsh_srv->name);
750 if (tzsh_srv->role == TZSH_SRV_ROLE_INDICATOR)
755 if (ec && ec->internal)
757 e_pixmap_win_id_del(tzsh_srv->ep);
758 e_object_del(E_OBJECT(ec));
761 _indicator_srv_res = NULL;
763 else if (tzsh_srv->role == TZSH_SRV_ROLE_SOFTKEY)
765 E_Client *softkey_ec = NULL;
767 softkey_ec = tzsh_srv->ec;
770 e_service_softkey_client_unset(softkey_ec);
773 else if (tzsh_srv->role == TZSH_SRV_ROLE_MAGNIFIER)
775 E_Client *magnifier_ec = NULL;
777 magnifier_ec = tzsh_srv->ec;
780 e_magnifier_owner_unset(magnifier_ec);
784 else if (tzsh_srv->role == TZSH_SRV_ROLE_LAUNCHER)
786 E_Client *launcher_ec = NULL;
788 launcher_ec = tzsh_srv->ec;
791 e_service_launcher_client_unset(launcher_ec);
795 ELOGF("TZSH", "FREE tzsh_srv:%p", tzsh_srv->ec, tzsh_srv);
799 e_object_unref(E_OBJECT(tzsh_srv->ec));
803 if (tzsh_srv->res_tzsh_srv)
804 wl_resource_set_user_data(tzsh_srv->res_tzsh_srv, NULL);
806 memset(tzsh_srv, 0x0, sizeof(E_Policy_Wl_Tzsh_Srv));
811 _e_policy_wl_tzsh_srv_role_get(const char *name)
813 Tzsh_Srv_Role role = TZSH_SRV_ROLE_UNKNOWN;
815 if (!e_util_strcmp(name, "volume" )) role = TZSH_SRV_ROLE_VOLUME;
816 else if (!e_util_strcmp(name, "quickpanel_system_default")) role = TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT;
817 else if (!e_util_strcmp(name, "quickpanel_context_menu" )) role = TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU;
818 else if (!e_util_strcmp(name, "quickpanel_apps_menu" )) role = TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU;
819 else if (!e_util_strcmp(name, "lockscreen" )) role = TZSH_SRV_ROLE_LOCKSCREEN;
820 else if (!e_util_strcmp(name, "indicator" )) role = TZSH_SRV_ROLE_INDICATOR;
821 else if (!e_util_strcmp(name, "screensaver_manager" )) role = TZSH_SRV_ROLE_SCREENSAVER_MNG;
822 else if (!e_util_strcmp(name, "screensaver" )) role = TZSH_SRV_ROLE_SCREENSAVER;
823 else if (!e_util_strcmp(name, "cbhm" )) role = TZSH_SRV_ROLE_CBHM;
824 else if (!e_util_strcmp(name, "softkey" )) role = TZSH_SRV_ROLE_SOFTKEY;
825 else if (!e_util_strcmp(name, "magnifier" )) role = TZSH_SRV_ROLE_MAGNIFIER;
826 else if (!e_util_strcmp(name, "launcher" )) role = TZSH_SRV_ROLE_LAUNCHER;
827 else if (!e_util_strcmp(name, "taskbar" )) role = TZSH_SRV_ROLE_TASKBAR;
828 else if (!e_util_strcmp(name, "KVM" )) role = TZSH_SRV_ROLE_KVM;
833 /* broadcast state of registered service to all subscribers */
835 _e_policy_wl_tzsh_srv_state_broadcast(E_Policy_Wl_Tzsh_Srv *tzsh_srv, Eina_Bool reg)
837 E_Policy_Wl_Tzsh *tzsh;
840 EINA_LIST_FOREACH(polwl->tzshs, l, tzsh)
842 if (tzsh_srv->tzsh == tzsh)
846 tizen_ws_shell_send_service_register
847 (tzsh->res_tzsh, tzsh_srv->name);
849 tizen_ws_shell_send_service_unregister
850 (tzsh->res_tzsh, tzsh_srv->name);
854 // --------------------------------------------------------
855 // E_Policy_Wl_Tzsh_Client
856 // --------------------------------------------------------
858 _e_policy_wl_tzsh_client_cb_client_zone_set(void *data, int type EINA_UNUSED, void *event)
860 E_Policy_Wl_Tzsh_Client *tzsh_client;
861 E_Event_Client_Zone_Set *ev;
866 if (tzsh_client->ec != ev->ec)
869 if (tzsh_client->zone == ev->zone)
872 ELOGF("TZSH", "Change Zone | e_policy_wl_tzsh_client %p old(%p) new(%p)",
873 tzsh_client->ec, tzsh_client, tzsh_client->zone, ev->zone);
875 tzsh_client->zone = ev->zone;
878 return ECORE_CALLBACK_PASS_ON;
881 static E_Policy_Wl_Tzsh_Client *
882 _e_policy_wl_tzsh_client_add(E_Policy_Wl_Tzsh *tzsh, struct wl_resource *res_tzsh_client, E_Pixmap *ep, E_Client *ec)
884 E_Policy_Wl_Tzsh_Client *tzsh_client;
886 tzsh_client = E_NEW(E_Policy_Wl_Tzsh_Client, 1);
887 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client, NULL);
889 tzsh_client->tzsh = tzsh;
890 tzsh_client->res_tzsh_client = res_tzsh_client;
891 tzsh_client->ep = ep;
892 tzsh_client->ec = ec;
893 tzsh_client->zone = e_comp_zone_find_by_ec(ec);
894 tzsh_client->tzsh->client_list = eina_list_append(tzsh_client->tzsh->client_list, tzsh_client);
896 polwl->tzsh_clients = eina_list_append(polwl->tzsh_clients, tzsh_client);
898 E_LIST_HANDLER_APPEND(tzsh_client->events, E_EVENT_CLIENT_ZONE_SET, _e_policy_wl_tzsh_client_cb_client_zone_set, tzsh_client);
901 _print_tzsh_client_info();
908 _e_policy_wl_tzsh_client_del(E_Policy_Wl_Tzsh_Client *tzsh_client)
910 if (!tzsh_client) return;
912 E_FREE_LIST(tzsh_client->events, ecore_event_handler_del);
914 if (tzsh_client->tzsh && tzsh_client->tzsh->client_list)
915 tzsh_client->tzsh->client_list = eina_list_remove(tzsh_client->tzsh->client_list, tzsh_client);
917 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
920 polwl->tzsh_clients = eina_list_remove(polwl->tzsh_clients, tzsh_client);
922 _print_tzsh_client_info();
925 if (tzsh_client->res_tzsh_client)
926 wl_resource_set_user_data(tzsh_client->res_tzsh_client, NULL);
928 memset(tzsh_client, 0x0, sizeof(E_Policy_Wl_Tzsh_Client));
932 static E_Policy_Wl_Tzsh_Extension*
933 _e_policy_wl_tzsh_extension_get(const char *name)
935 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
938 EINA_LIST_FOREACH(polwl->tzsh_extensions, l, tzsh_ext)
940 if (strcmp(tzsh_ext->name, name)) continue;
949 // --------------------------------------------------------
950 // E_Policy_Wl_Surface
951 // --------------------------------------------------------
952 static E_Policy_Wl_Surface *
953 _e_policy_wl_surf_add(E_Client *ec, struct wl_resource *res_tzpol)
955 E_Comp_Wl_Client_Data *cdata;
956 E_Policy_Wl_Surface *psurf = NULL;
957 E_Policy_Wl_Tzpol *tzpol;
959 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
960 EINA_SAFETY_ON_NULL_RETURN_VAL(tzpol, NULL);
962 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
963 if (psurf) return psurf;
965 psurf = E_NEW(E_Policy_Wl_Surface, 1);
966 EINA_SAFETY_ON_NULL_RETURN_VAL(psurf, NULL);
968 psurf->tzpol = tzpol;
969 psurf->cp = ec->pixmap;
971 psurf->pid = ec->netwm.pid;
973 cdata = e_client_cdata_get(ec);
974 if (wl_resource_get_client(cdata->surface) == wl_resource_get_client(res_tzpol))
975 psurf->surf = cdata->surface;
977 tzpol->psurfs = eina_list_append(tzpol->psurfs, psurf);
980 _e_policy_wl_background_state_set(psurf, EINA_TRUE);
986 _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf)
988 eina_list_free(psurf->vislist);
989 eina_list_free(psurf->poslist);
991 memset(psurf, 0x0, sizeof(E_Policy_Wl_Surface));
996 _e_policy_wl_surf_client_set(E_Client *ec)
998 E_Policy_Wl_Tzpol *tzpol;
999 E_Policy_Wl_Surface *psurf;
1002 it = eina_hash_iterator_data_new(polwl->tzpols);
1003 EINA_ITERATOR_FOREACH(it, tzpol)
1005 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
1008 if ((psurf->ec) && (psurf->ec != ec))
1011 "CRI ERR!!|s:%8p|tzpol:%8p|ps:%8p|new_ec:%8p|new_cp:%8p",
1023 eina_iterator_free(it);
1029 _e_policy_wl_e_pixmap_get_from_id(struct wl_client *client, uint32_t id)
1033 struct wl_resource *res_surf;
1035 res_surf = wl_client_get_object(client, id);
1038 ERR("Could not get surface resource");
1042 ec = e_client_from_surface_resource(res_surf);
1045 ERR("Could not get surface's user data");
1049 /* check E_Pixmap */
1050 cp = e_pixmap_find(E_PIXMAP_TYPE_WL, (uintptr_t)res_surf);
1051 if (cp != ec->pixmap)
1054 "CRI ERR!!|cp2:%8p|ec2:%8p|res_surf:%8p",
1057 e_pixmap_client_get(cp),
1066 _e_policy_wl_e_client_is_valid(E_Client *ec)
1070 Eina_Bool del = EINA_FALSE;
1071 Eina_Bool found = EINA_FALSE;
1073 EINA_LIST_FOREACH(e_comp->clients, l, ec2)
1077 if (e_object_is_del(E_OBJECT(ec2)))
1084 return ((!del) && (found));
1088 _e_policy_wl_e_clients_find_by_pid(pid_t pid)
1091 Eina_List *clients = NULL, *l;
1093 EINA_LIST_FOREACH(e_comp->clients, l, ec)
1095 if (e_object_is_del(E_OBJECT(ec))) continue;
1096 if (ec->netwm.pid != pid) continue;
1097 clients = eina_list_append(clients, ec);
1103 // --------------------------------------------------------
1105 // --------------------------------------------------------
1107 _tzvis_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzvis)
1109 wl_resource_destroy(res_tzvis);
1112 static const struct tizen_visibility_interface _tzvis_iface =
1114 _tzvis_iface_cb_destroy
1118 _tzvis_iface_cb_vis_destroy(struct wl_resource *res_tzvis)
1120 E_Policy_Wl_Surface *psurf;
1123 psurf = wl_resource_get_user_data(res_tzvis);
1124 EINA_SAFETY_ON_NULL_RETURN(psurf);
1126 r = _e_policy_wl_surf_is_valid(psurf);
1129 psurf->vislist = eina_list_remove(psurf->vislist, res_tzvis);
1133 _tzpol_iface_cb_vis_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
1136 E_Policy_Wl_Surface *psurf;
1137 struct wl_resource *res_tzvis;
1139 ec = e_client_from_surface_resource(surf);
1140 EINA_SAFETY_ON_NULL_RETURN(ec);
1142 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
1143 EINA_SAFETY_ON_NULL_RETURN(psurf);
1145 res_tzvis = wl_resource_create(client,
1146 &tizen_visibility_interface,
1147 wl_resource_get_version(res_tzpol),
1151 wl_client_post_no_memory(client);
1155 wl_resource_set_implementation(res_tzvis,
1158 _tzvis_iface_cb_vis_destroy);
1160 psurf->vislist = eina_list_append(psurf->vislist, res_tzvis);
1162 if (eina_list_data_find(polwl->pending_vis, ec))
1164 e_policy_wl_visibility_send(ec, ec->visibility.obscured);
1169 e_policy_wl_visibility_send(E_Client *ec, int vis)
1171 E_Comp_Wl_Client_Data *cdata;
1172 E_Policy_Wl_Tzpol *tzpol;
1173 E_Policy_Wl_Surface *psurf;
1174 struct wl_resource *res_tzvis;
1179 Eina_Bool sent = EINA_FALSE;
1181 int sent_vis = E_VISIBILITY_UNKNOWN;
1183 EINA_SAFETY_ON_TRUE_RETURN(vis == E_VISIBILITY_UNKNOWN);
1184 if (ec && (ec->visibility.last_sent_type == vis))
1187 win = e_client_util_win_get(ec);
1189 it = eina_hash_iterator_data_new(polwl->tzpols);
1190 EINA_ITERATOR_FOREACH(it, tzpol)
1191 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1193 ec2 = e_pixmap_client_get(psurf->cp);
1194 if (ec2 != ec) continue;
1196 EINA_LIST_FOREACH(psurf->vislist, ll, res_tzvis)
1198 // below code is workaround for checking visibility by display off or not
1199 if (e_comp_client_zone_is_displaying(ec))
1200 e_policy_aux_message_send(ec, "dpms_wm", "on", NULL);
1202 e_policy_aux_message_send(ec, "dpms_wm", "off", NULL);
1204 ver = wl_resource_get_version(res_tzvis);
1207 if (vis == E_VISIBILITY_PRE_UNOBSCURED)
1211 ec->visibility.last_sent_type = vis;
1212 tizen_visibility_send_changed(res_tzvis, vis, 0);
1219 if ((vis >= E_VISIBILITY_UNOBSCURED) && (vis <= E_VISIBILITY_FULLY_OBSCURED))
1221 ec->visibility.last_sent_type = vis;
1222 tizen_visibility_send_notify(res_tzvis, vis);
1228 cdata = e_client_cdata_get(ec);
1229 if (cdata && cdata->mapped)
1231 _launch_effect_hide(ec->netwm.pid);
1235 "SEND |win:0x%08zx|res_tzvis:%8p|ver:%d|sent_vis:%d|pid:%d|cdata:%8p|title:%s, name:%s",
1241 ec->netwm.pid, cdata, ec->icccm.title, ec->netwm.name);
1245 eina_iterator_free(it);
1247 polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
1249 polwl->pending_vis = eina_list_append(polwl->pending_vis, ec);
1253 e_policy_wl_iconify_state_supported_get(E_Client *ec)
1255 E_Policy_Wl_Tzpol *tzpol;
1256 E_Policy_Wl_Surface *psurf;
1260 Eina_Bool found = EINA_FALSE;
1262 it = eina_hash_iterator_data_new(polwl->tzpols);
1263 EINA_ITERATOR_FOREACH(it, tzpol)
1264 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1266 ec2 = e_pixmap_client_get(psurf->cp);
1273 eina_iterator_free(it);
1279 e_policy_wl_iconify_state_change_send(E_Client *ec, int iconic)
1281 E_Policy_Wl_Tzpol *tzpol;
1282 E_Policy_Wl_Surface *psurf;
1287 if (ec->exp_iconify.skip_iconify) return;
1288 if (ec->exp_iconify.skip_by_remote) return;
1290 if (e_config->transient.iconify)
1292 E_Comp_Wl_Client_Data *cdata;
1294 Eina_List *list = eina_list_clone(ec->transients);
1296 EINA_LIST_FREE(list, child)
1298 cdata = e_client_cdata_get(child);
1299 if (cdata && !cdata->mapped) continue;
1301 if ((child->iconic == ec->iconic) &&
1302 (e_client_is_iconified_by_client(child) == e_client_is_iconified_by_client(ec)))
1303 e_policy_wl_iconify_state_change_send(child, iconic);
1308 it = eina_hash_iterator_data_new(polwl->tzpols);
1309 EINA_ITERATOR_FOREACH(it, tzpol)
1310 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1312 ec2 = e_pixmap_client_get(psurf->cp);
1313 if (ec2 != ec) continue;
1314 if (!psurf->surf) continue;
1316 tizen_policy_send_iconify_state_changed(tzpol->res_tzpol, psurf->surf, iconic, 1);
1318 "SEND |iconic:%d |argb:%d |sur:%p",
1320 iconic, ec->argb, psurf->surf);
1321 ec->exp_iconify.last_sent_iconic = iconic;
1324 eina_iterator_free(it);
1327 // --------------------------------------------------------
1329 // --------------------------------------------------------
1331 _tzpos_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpos)
1333 wl_resource_destroy(res_tzpos);
1337 _tzpos_iface_cb_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpos, int32_t x, int32_t y)
1340 E_Policy_Wl_Surface *psurf;
1343 psurf = wl_resource_get_user_data(res_tzpos);
1344 EINA_SAFETY_ON_NULL_RETURN(psurf);
1346 ec = e_pixmap_client_get(psurf->cp);
1347 EINA_SAFETY_ON_NULL_RETURN(ec);
1348 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1350 if (e_policy_client_is_keyboard(ec))
1352 ELOGF("TZPOL", "Keyboard pos set (%d, %d). No operation. return.", ec, x, y);
1356 desk = e_comp_desk_find_by_ec(ec);
1357 EINA_SAFETY_ON_NULL_RETURN(desk);
1359 if (!ec->lock_client_location)
1361 if (e_client_pending_geometry_has(ec))
1363 // if there is geometry pending list, add move job at the end of the list.
1364 // so client to be applied new position at the same time with the pending requests
1365 // pending geometries are flushed when 'wl surface commit' and matched serial are delivered.
1367 e_client_pending_geometry_last_geometry_get(ec, NULL, NULL, &w, &h);
1368 e_comp_wl_commit_sync_client_geometry_add(ec, ec->surface_sync.serial, x, y, w, h);
1372 ec->client.x = desk->geom.x + x;
1373 ec->client.y = desk->geom.y + y;
1374 e_client_pos_set(ec, ec->client.x, ec->client.y);
1376 ec->changes.pos = 1;
1378 ec->changes.tz_position = 1;
1382 e_policy_hook_call(E_POLICY_HOOK_CLIENT_POSITION_SET, ec);
1385 static const struct tizen_position_interface _tzpos_iface =
1387 _tzpos_iface_cb_destroy,
1388 _tzpos_iface_cb_set,
1392 _tzpol_iface_cb_pos_destroy(struct wl_resource *res_tzpos)
1394 E_Policy_Wl_Surface *psurf;
1397 psurf = wl_resource_get_user_data(res_tzpos);
1398 EINA_SAFETY_ON_NULL_RETURN(psurf);
1400 r = _e_policy_wl_surf_is_valid(psurf);
1403 psurf->poslist = eina_list_remove(psurf->poslist, res_tzpos);
1407 _tzpol_iface_cb_pos_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
1410 E_Policy_Wl_Surface *psurf;
1411 struct wl_resource *res_tzpos;
1413 ec = e_client_from_surface_resource(surf);
1414 EINA_SAFETY_ON_NULL_RETURN(ec);
1416 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
1417 EINA_SAFETY_ON_NULL_RETURN(psurf);
1419 res_tzpos = wl_resource_create(client,
1420 &tizen_position_interface,
1421 wl_resource_get_version(res_tzpol),
1425 wl_client_post_no_memory(client);
1429 wl_resource_set_implementation(res_tzpos,
1432 _tzpol_iface_cb_pos_destroy);
1434 psurf->poslist = eina_list_append(psurf->poslist, res_tzpos);
1436 // if ec's pos is not same to client's geometry (ec->comp_data->shell.window),
1437 // then send tizen_position changed event
1440 if ((ec->x != ec->comp_data->shell.window.x) ||
1441 (ec->y != ec->comp_data->shell.window.y))
1442 e_policy_wl_position_send(ec);
1447 e_policy_wl_position_send(E_Client *ec)
1449 E_Policy_Wl_Tzpol *tzpol;
1450 E_Policy_Wl_Surface *psurf;
1451 struct wl_resource *res_tzpos;
1456 EINA_SAFETY_ON_NULL_RETURN(ec);
1458 win = e_client_util_win_get(ec);
1460 it = eina_hash_iterator_data_new(polwl->tzpols);
1461 EINA_ITERATOR_FOREACH(it, tzpol)
1462 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1464 if (e_pixmap_client_get(psurf->cp) != ec) continue;
1466 EINA_LIST_FOREACH(psurf->poslist, ll, res_tzpos)
1468 tizen_position_send_changed(res_tzpos, ec->client.x, ec->client.y);
1470 "SEND |win:0x%08zx|res_tzpos:%8p|ec->x:%d, ec->y:%d, ec->client.x:%d, ec->client.y:%d",
1475 ec->client.x, ec->client.y);
1478 eina_iterator_free(it);
1481 // --------------------------------------------------------
1482 // stack: activate, raise, lower
1483 // --------------------------------------------------------
1486 e_policy_wl_activate(E_Client *ec)
1488 EINA_SAFETY_ON_NULL_RETURN(ec);
1489 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1491 ELOGF("TZPOL", "REAL ACTIVATE", ec);
1493 e_policy_visibility_client_lower_job_cancel(ec);
1495 if ((!starting) && (!ec->focused))
1497 if (!e_policy_visibility_client_activate(ec))
1499 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1500 e_policy_wl_iconify_state_change_send(ec, 0);
1502 if (!ec->visibility.force_obscured)
1503 e_client_activate(ec);
1508 if (!ec->lock_user_stacking)
1512 if (e_policy_client_is_lockscreen(ec))
1513 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
1515 e_policy_stack_check_above_lockscreen(ec, ec->layer);
1519 _tzpol_iface_cb_activate(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1522 E_Comp_Wl_Client_Data *cdata;
1524 ec = e_client_from_surface_resource(surf);
1525 EINA_SAFETY_ON_NULL_RETURN(ec);
1526 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1528 ELOGF("TZPOL", "ACTIVATE", ec);
1531 e_policy_stack_transient_child_raise(ec);
1533 e_policy_hook_call(E_POLICY_HOOK_CLIENT_ACTIVE_REQ, ec);
1535 ec->post_lower = EINA_FALSE;
1536 cdata = e_client_cdata_get(ec);
1537 if (cdata && !cdata->mapped)
1539 if (e_config->raise_before_show)
1542 ec->post_raise = EINA_TRUE;
1544 e_policy_wl_activate(ec);
1548 e_policy_wl_stack_changed_send(E_Client *ec)
1550 E_Client *above = NULL;
1551 E_Client *below = NULL;
1555 above = e_client_above_get(ec);
1558 if ((!e_object_is_del(E_OBJECT(above))) &&
1559 (!e_client_util_ignored_get(above)) &&
1564 above = e_client_above_get(above);
1567 below = e_client_below_get(ec);
1570 if ((!e_object_is_del(E_OBJECT(below))) &&
1571 (!e_client_util_ignored_get(below)) &&
1576 below = e_client_below_get(below);
1579 if (above) above_pid = above->netwm.pid;
1580 if (below) below_pid = below->netwm.pid;
1582 ELOGF("TZPOL", "Send stack_changed by activate_below. above(win:%zx, pid:%d), below(win:%zx, pid:%d)",
1583 ec, e_client_util_win_get(above), above_pid, e_client_util_win_get(below), below_pid);
1586 e_policy_aux_message_send_from_int(ec, "stack_changed", "activate_below", 2, above_pid, below_pid);
1591 _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)
1593 E_Client *ec = NULL;
1594 E_Client *below_ec = NULL;
1595 E_Client *parent_ec = NULL;
1596 E_Client *focus_ec = NULL;
1597 E_Comp_Wl_Client_Data *cdata;
1598 Eina_Bool check_ancestor = EINA_FALSE;
1599 Eina_Bool intercepted = EINA_FALSE;
1601 ec = e_pixmap_find_client_by_res_id(res_id);
1602 EINA_SAFETY_ON_NULL_RETURN(ec);
1603 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1605 below_ec = e_pixmap_find_client_by_res_id(below_res_id);
1606 EINA_SAFETY_ON_NULL_RETURN(below_ec);
1607 EINA_SAFETY_ON_NULL_RETURN(below_ec->frame);
1610 "ACTIVATE_BELOW|win:0x%08zx(res_id:%d)|below_win:0x%08zx(res_id:%d)",
1611 NULL, e_client_util_win_get(ec), res_id, e_client_util_win_get(below_ec), below_res_id);
1613 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_ACTIVATE_BELOW,
1617 ELOGF("TZPOL", "ACTIVATE_BELOW|Handled by Intercept function", ec);
1621 if (ec->layer > below_ec->layer) return;
1623 parent_ec = ec->parent;
1626 if (parent_ec == below_ec)
1628 check_ancestor = EINA_TRUE;
1631 parent_ec = parent_ec->parent;
1633 if (check_ancestor) return;
1635 if ((!starting) && (!ec->focused))
1637 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1638 e_policy_wl_iconify_state_change_send(ec, 0);
1640 e_client_uniconify(ec);
1643 e_policy_stack_below(ec, below_ec);
1645 cdata = e_client_cdata_get(ec);
1646 if (cdata && !cdata->mapped)
1648 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1649 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1652 e_policy_wl_stack_changed_send(ec);
1655 focus_ec = e_client_focused_get();
1656 if (focus_ec == below_ec)
1657 e_client_focus_latest_set(ec);
1661 _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)
1663 E_Client *ec = NULL;
1664 E_Comp_Wl_Client_Data *cdata;
1665 E_Client *above_ec = NULL;
1666 E_Client *parent_ec = NULL;
1667 Eina_Bool check_ancestor = EINA_FALSE;
1668 Eina_Bool intercepted = EINA_FALSE;
1670 ec = e_pixmap_find_client_by_res_id(res_id);
1671 EINA_SAFETY_ON_NULL_RETURN(ec);
1672 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1674 above_ec = e_pixmap_find_client_by_res_id(above_res_id);
1675 EINA_SAFETY_ON_NULL_RETURN(above_ec);
1676 EINA_SAFETY_ON_NULL_RETURN(above_ec->frame);
1679 "ACTIVATE_ABOVE|win:0x%08zx(res_id:%d)|above_win:0x%08zx(res_id:%d)",
1680 NULL, e_client_util_win_get(ec), res_id, e_client_util_win_get(above_ec), above_res_id);
1682 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_ACTIVATE_ABOVE,
1686 ELOGF("TZPOL", "ACTIVATE_ABOVE|Handled by Intercept function", ec);
1690 if (ec->layer < above_ec->layer) return;
1693 parent_ec = above_ec->parent;
1696 if (parent_ec == ec)
1698 check_ancestor = EINA_TRUE;
1701 parent_ec = parent_ec->parent;
1703 if (check_ancestor) return;
1705 if (ec->parent && (ec->parent == above_ec))
1707 if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
1709 ELOGF("TZPOL", "ACTIVATE_ABOVE|Denied. Above is transient_below parent", ec);
1716 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1717 e_policy_wl_iconify_state_change_send(ec, 0);
1719 e_client_uniconify(ec);
1722 e_policy_stack_above(ec, above_ec);
1724 cdata = e_client_cdata_get(ec);
1725 if (cdata && !cdata->mapped)
1727 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1728 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1733 _tzpol_iface_cb_raise(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1736 E_Comp_Wl_Client_Data *cdata;
1738 ec = e_client_from_surface_resource(surf);
1739 EINA_SAFETY_ON_NULL_RETURN(ec);
1740 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1742 ELOGF("TZPOL", "RAISE", ec);
1745 e_policy_stack_transient_child_raise(ec);
1747 e_policy_hook_call(E_POLICY_HOOK_CLIENT_RAISE_REQ, ec);
1751 cdata = e_client_cdata_get(ec);
1752 if (cdata && !cdata->mapped)
1754 if (e_config->raise_before_show)
1756 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1757 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1761 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_TRUE, EINA_FALSE);
1762 e_client_post_raise_lower_set(ec, EINA_TRUE, EINA_FALSE);
1766 e_policy_hook_call(E_POLICY_HOOK_CLIENT_RAISE_REQ_DONE, ec);
1770 _tzpol_iface_cb_lower(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1772 E_Client *ec = NULL;
1773 E_Comp_Wl_Client_Data *cdata;
1775 ec = e_client_from_surface_resource(surf);
1776 EINA_SAFETY_ON_NULL_RETURN(ec);
1777 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1779 ELOGF("TZPOL", "LOWER", ec);
1782 e_policy_stack_transient_child_lower(ec);
1784 e_policy_hook_call(E_POLICY_HOOK_CLIENT_LOWER_REQ, ec);
1786 if (e_policy_visibility_client_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);
1800 _tzpol_iface_cb_lower_by_res_id(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t res_id)
1802 E_Client *ec = NULL;
1803 E_Comp_Wl_Client_Data *cdata;
1805 ec = e_pixmap_find_client_by_res_id(res_id);
1806 EINA_SAFETY_ON_NULL_RETURN(ec);
1807 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1809 ELOGF("TZPOL", "LOWER by res id:%d", ec, res_id);
1812 e_policy_stack_transient_child_lower(ec);
1816 cdata = e_client_cdata_get(ec);
1817 if (cdata && !cdata->mapped)
1819 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_TRUE);
1820 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_TRUE);
1824 // --------------------------------------------------------
1826 // --------------------------------------------------------
1828 _tzpol_iface_cb_focus_skip_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1832 ec = e_client_from_surface_resource(surf);
1833 EINA_SAFETY_ON_NULL_RETURN(ec);
1835 e_client_focus_skip_set(ec, EINA_TRUE, EINA_TRUE);
1839 _tzpol_iface_cb_focus_skip_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1843 ec = e_client_from_surface_resource(surf);
1844 EINA_SAFETY_ON_NULL_RETURN(ec);
1846 e_client_focus_skip_set(ec, EINA_FALSE, EINA_TRUE);
1849 // --------------------------------------------------------
1851 // --------------------------------------------------------
1853 _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)
1856 E_Comp_Wl_Client_Data *cdata;
1858 EINA_SAFETY_ON_NULL_RETURN(role);
1860 ec = e_client_from_surface_resource(surf);
1861 EINA_SAFETY_ON_NULL_RETURN(ec);
1862 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1864 ELOGF("TZPOL", "ROLE SET (role:%s)", ec, role);
1865 e_client_window_role_set(ec, role);
1867 /* TODO: support multiple roles */
1868 if (!e_util_strcmp("tv-volume-popup", role))
1870 e_client_layer_set(ec, E_LAYER_CLIENT_NOTIFICATION_LOW);
1871 ec->lock_client_location = 1;
1873 else if (!e_util_strcmp("e_demo", role))
1875 e_client_layer_set(ec, E_LAYER_CLIENT_NOTIFICATION_HIGH);
1876 ec->lock_client_location = 1;
1878 else if (!e_util_strcmp("cbhm", role))
1880 cdata = e_client_cdata_get(ec);
1882 e_comp_wl->selection.cbhm = cdata->surface;
1884 else if (!e_util_strcmp("wl_pointer-cursor", role))
1886 ELOGF("TZPOL", "Set CURSOR role", ec);
1887 e_client_layer_set(ec, E_LAYER_CLIENT_CURSOR);
1888 ec->is_cursor = EINA_TRUE;
1889 e_client_desk_iconify_skip_set(ec, EINA_TRUE);
1894 _tzpol_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t type)
1897 E_Window_Type win_type;
1899 ec = e_client_from_surface_resource(surf);
1900 EINA_SAFETY_ON_NULL_RETURN(ec);
1904 /* TODO: support other types */
1905 case TIZEN_POLICY_WIN_TYPE_TOPLEVEL:
1906 win_type = E_WINDOW_TYPE_NORMAL;
1907 if (ec->layer != E_LAYER_CLIENT_NORMAL)
1909 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
1913 case TIZEN_POLICY_WIN_TYPE_NOTIFICATION:
1914 win_type = E_WINDOW_TYPE_NOTIFICATION;
1917 case TIZEN_POLICY_WIN_TYPE_UTILITY:
1918 win_type = E_WINDOW_TYPE_UTILITY;
1921 case TIZEN_POLICY_WIN_TYPE_DIALOG:
1922 win_type = E_WINDOW_TYPE_DIALOG;
1925 case TIZEN_POLICY_WIN_TYPE_DESKTOP:
1926 win_type = E_WINDOW_TYPE_DESKTOP;
1927 e_client_desk_iconify_skip_set(ec, EINA_TRUE);
1928 if (ec->layer != E_LAYER_CLIENT_DESKTOP)
1930 e_client_layer_set(ec, E_LAYER_CLIENT_DESKTOP);
1938 "TYPE_SET |win:0x%08zx|s:%8p|res_tzpol:%8p|tizen_win_type:%d, e_win_type:%d",
1940 e_client_util_win_get(ec),
1945 ec->netwm.type = win_type;
1947 e_policy_hook_call(E_POLICY_HOOK_CLIENT_TYPE_SET, ec);
1951 // --------------------------------------------------------
1953 // --------------------------------------------------------
1955 _tzpol_iface_cb_conformant_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
1959 ec = e_client_from_surface_resource(surf);
1960 EINA_SAFETY_ON_NULL_RETURN(ec);
1962 e_policy_conformant_client_add(ec, res_tzpol);
1966 _tzpol_iface_cb_conformant_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1970 ec = e_client_from_surface_resource(surf);
1971 EINA_SAFETY_ON_NULL_RETURN(ec);
1973 e_policy_conformant_client_del(ec);
1977 _tzpol_iface_cb_conformant_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
1981 ec = e_client_from_surface_resource(surf);
1982 EINA_SAFETY_ON_NULL_RETURN(ec);
1984 tizen_policy_send_conformant(res_tzpol, surf, e_policy_conformant_client_check(ec));
1987 // --------------------------------------------------------
1988 // notification level
1989 // --------------------------------------------------------
1991 _tzpol_notilv_set(E_Client *ec, int lv)
1998 case 0: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
1999 case 1: ly = E_LAYER_CLIENT_NOTIFICATION_NORMAL; break;
2000 case 2: ly = E_LAYER_CLIENT_NOTIFICATION_TOP; break;
2001 case -1: ly = E_LAYER_CLIENT_NORMAL; break;
2002 case 10: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
2003 case 20: ly = E_LAYER_CLIENT_NOTIFICATION_NORMAL; break;
2004 case 30: ly = E_LAYER_CLIENT_NOTIFICATION_HIGH; break;
2005 case 40: ly = E_LAYER_CLIENT_NOTIFICATION_TOP; break;
2006 default: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
2009 #ifdef REFACTOR_DESK_AREA
2010 cur_ly = e_client_layer_get(ec);
2012 if (e_config->use_desk_area)
2013 cur_ly = e_client_desk_area_original_layer_get(ec);
2015 cur_ly = e_client_layer_get(ec);
2020 if (ly == E_LAYER_CLIENT_NORMAL)
2021 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_LAYER, 0);
2023 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_LAYER, 1);
2025 e_client_layer_set(ec, ly);
2027 e_policy_hook_call(E_POLICY_HOOK_CLIENT_NOTILAYER_SET, ec);
2031 _tzpol_iface_cb_notilv_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t lv)
2034 E_Policy_Wl_Surface *psurf;
2039 ec = e_client_from_surface_resource(surf);
2040 EINA_SAFETY_ON_NULL_RETURN(ec);
2042 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
2043 EINA_SAFETY_ON_NULL_RETURN(psurf);
2045 wl_client_get_credentials(client, &pid, &uid, NULL);
2046 res = e_security_privilege_check(pid, uid,
2047 E_PRIVILEGE_NOTIFICATION_LEVEL_SET);
2051 "Privilege Check Failed! DENY set_notification_level",
2054 tizen_policy_send_notification_done
2058 TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
2062 ELOGF("TZPOL", "NOTI_LEVEL|level:%d", ec, lv);
2063 _tzpol_notilv_set(ec, lv);
2067 tizen_policy_send_notification_done
2068 (res_tzpol, surf, lv, TIZEN_POLICY_ERROR_STATE_NONE);
2070 if (e_policy_client_is_lockscreen(ec))
2071 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
2073 e_policy_stack_check_above_lockscreen(ec, ec->layer);
2077 e_policy_wl_notification_level_fetch(E_Client *ec)
2080 E_Policy_Wl_Surface *psurf;
2081 E_Policy_Wl_Tzpol *tzpol;
2084 Eina_Bool changed_stack = EINA_FALSE;
2086 EINA_SAFETY_ON_NULL_RETURN(ec);
2089 EINA_SAFETY_ON_NULL_RETURN(cp);
2091 // TODO: use pending_notilv_list instead of loop
2092 it = eina_hash_iterator_data_new(polwl->tzpols);
2093 EINA_ITERATOR_FOREACH(it, tzpol)
2094 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
2096 if (psurf->cp != cp) continue;
2097 if (!psurf->pending_notilv) continue;
2099 psurf->pending_notilv = EINA_FALSE;
2100 _tzpol_notilv_set(ec, psurf->notilv);
2101 changed_stack = EINA_TRUE;
2103 eina_iterator_free(it);
2105 if (changed_stack && e_policy_client_is_lockscreen(ec))
2106 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
2109 // --------------------------------------------------------
2111 // --------------------------------------------------------
2113 _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)
2115 E_Client *ec, *parent_ec;
2116 E_Comp_Wl_Client_Data *cdata, *p_cdata;
2119 "TF_SET |res_tzpol:%8p|parent_id:%8d |child_id:%8d",
2120 NULL, res_tzpol, parent_id, child_id);
2122 ec = e_pixmap_find_client_by_res_id(child_id);
2123 EINA_SAFETY_ON_NULL_RETURN(ec);
2124 cdata = e_client_cdata_get(ec);
2126 parent_ec = e_pixmap_find_client_by_res_id(parent_id);
2127 EINA_SAFETY_ON_NULL_RETURN(parent_ec);
2128 p_cdata = e_client_cdata_get(parent_ec);
2131 " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
2132 NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL));
2134 e_policy_stack_transient_for_set(ec, parent_ec);
2135 tizen_policy_send_transient_for_done(res_tzpol, child_id);
2139 _tzpol_iface_cb_transient_for_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t child_id)
2144 "TF_UNSET |res_tzpol:%8p|child:%d",
2145 NULL, res_tzpol, child_id);
2147 ec = e_pixmap_find_client_by_res_id(child_id);
2148 EINA_SAFETY_ON_NULL_RETURN(ec);
2150 e_policy_stack_transient_for_set(ec, NULL);
2151 tizen_policy_send_transient_for_done(res_tzpol, child_id);
2154 // --------------------------------------------------------
2155 // window screen mode
2156 // --------------------------------------------------------
2158 _tzpol_iface_cb_win_scrmode_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
2165 ec = e_client_from_surface_resource(surf);
2166 EINA_SAFETY_ON_NULL_RETURN(ec);
2168 wl_client_get_credentials(client, &pid, &uid, NULL);
2169 res = e_security_privilege_check(pid, uid,
2170 E_PRIVILEGE_SCREEN_MODE_SET);
2174 "Privilege Check Failed! DENY set_screen_mode",
2177 tizen_policy_send_window_screen_mode_done
2181 TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
2185 ELOGF("TZPOL", "SCR_MODE |mode:%d", ec, mode);
2187 e_policy_display_screen_mode_set(ec, mode);
2188 e_policy_wl_win_scrmode_apply();
2190 tizen_policy_send_window_screen_mode_done
2191 (res_tzpol, surf, mode, TIZEN_POLICY_ERROR_STATE_NONE);
2195 e_policy_wl_win_scrmode_apply(void)
2197 e_policy_display_screen_mode_apply();
2200 // --------------------------------------------------------
2202 // --------------------------------------------------------
2204 static const struct wl_subsurface_interface _tzpol_subsurface_fake_impl;
2207 _tzpol_iface_cb_subsurf_place_below_parent(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *subsurf)
2209 if (wl_resource_instance_of(subsurf, &wl_subsurface_interface, &_tzpol_subsurface_fake_impl))
2212 e_comp_wl_subsurface_resource_place_below_parent(subsurf);
2216 _tzpol_iface_cb_subsurf_stand_alone_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *subsurf)
2218 if (wl_resource_instance_of(subsurf, &wl_subsurface_interface, &_tzpol_subsurface_fake_impl))
2221 e_comp_wl_subsurface_resource_stand_alone_mode_set(subsurf);
2225 _tzpol_subsurface_fake_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
2227 wl_resource_destroy(resource);
2231 _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)
2236 _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)
2241 _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)
2246 _tzpol_subsurface_fake_cb_sync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
2251 _tzpol_subsurface_fake_cb_desync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
2255 static const struct wl_subsurface_interface _tzpol_subsurface_fake_impl =
2257 _tzpol_subsurface_fake_cb_destroy,
2258 _tzpol_subsurface_fake_cb_position_set,
2259 _tzpol_subsurface_fake_cb_place_above,
2260 _tzpol_subsurface_fake_cb_place_below,
2261 _tzpol_subsurface_fake_cb_sync_set,
2262 _tzpol_subsurface_fake_cb_desync_set,
2266 _tzpol_subsurface_add_with_fake_impl(struct wl_client *client, uint32_t id)
2268 struct wl_resource *resource;
2270 resource = wl_resource_create(client, &wl_subsurface_interface, 1, id);
2274 wl_resource_set_implementation(resource,
2275 &_tzpol_subsurface_fake_impl,
2282 _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface, uint32_t parent_id)
2285 E_Comp_Wl_Client_Data *cdata;
2289 "SUBSURF |wl_surface@%d|parent_id:%d",
2290 NULL, wl_resource_get_id(surface), parent_id);
2292 ec = e_client_from_surface_resource(surface);
2294 epc = e_pixmap_find_client_by_res_id(parent_id);
2296 (e_object_is_del(E_OBJECT(epc))))
2298 ELOGF("TZPOL", "SUBSURF | Invalid parent(%p). "
2299 "Create with fake implementation", ec, epc);
2301 e_subsurface_watcher_invalid_parent_notify(surface);
2303 /* We have to create a subsurface resource here even though it's error case
2304 * because server will send the fatal error when a client destroy a subsurface object.
2305 * Otherwise, server will kill a client by the fatal error.
2307 if (!_tzpol_subsurface_add_with_fake_impl(client, id))
2308 wl_resource_post_no_memory(resource);
2313 /* This check code is for detecting an error case which tries to create
2314 * sub-surface relationship with invalid parent. */
2315 if ((!epc->comp_data) ||
2316 (!epc->comp_data->wl_surface))
2318 ELOGF("TZPOL", "Parent(%p internal? %s) doesn't have comp_data. "
2319 "Possibly it's not the surface created by client. "
2320 "Cannot be the parent of sub-surface.",
2321 ec, epc, epc->internal ? "TRUE" : "FALSE");
2322 wl_resource_post_error(resource,
2323 WL_SUBSURFACE_ERROR_BAD_SURFACE,
2324 "Invalid parent_id@%d. Possibly it's not the "
2325 "surface created by client.(internal? %s) "
2326 "Cannot be the parent of sub-surface.",
2327 parent_id, epc->internal ? "TRUE" : "FALSE");
2331 res = e_comp_wl_subsurface_add(resource, id, surface,
2332 epc->comp_data->wl_surface);
2335 ERR("Failed to add subsurface for surface@%d", wl_resource_get_id(surface));
2339 /* ec's parent comes from another process */
2340 cdata = e_client_cdata_get(ec);
2342 cdata->has_extern_parent = EINA_TRUE;
2346 _tzpol_iface_cb_opaque_state_set(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, int32_t state)
2350 ec = e_client_from_surface_resource(surface);
2351 EINA_SAFETY_ON_NULL_RETURN(ec);
2353 ELOGF("TZPOL", "OPAQUE |opaque_state:%d", ec, state);
2354 if(ec->visibility.opaque == state)
2356 ec->visibility.opaque = state;
2361 // --------------------------------------------------------
2363 // --------------------------------------------------------
2366 e_policy_wl_iconify(E_Client *ec)
2368 EINA_SAFETY_ON_NULL_RETURN(ec);
2369 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
2371 ELOGF("TZPOL", "Set ICONIFY BY CLIENT", ec);
2373 if (e_policy_visibility_client_iconify(ec))
2375 ec->exp_iconify.by_client = 1;
2376 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT);
2379 ec->exp_iconify.by_client = 1;
2380 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT);
2382 e_client_iconify(ec);
2388 e_policy_wl_uniconify(E_Client *ec)
2390 EINA_SAFETY_ON_NULL_RETURN(ec);
2391 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
2393 if (e_policy_visibility_client_uniconify(ec, 1))
2396 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
2397 e_policy_wl_iconify_state_change_send(ec, 0);
2399 if (ec->visibility.force_obscured)
2401 ec->exp_iconify.by_client = 0;
2402 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
2406 e_client_uniconify(ec);
2407 ELOGF("TZPOL", "Un-Set ICONIFY BY CLIENT", ec);
2408 ec->exp_iconify.by_client = 0;
2409 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
2415 _tzpol_iface_cb_iconify(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
2419 ec = e_client_from_surface_resource(surf);
2420 EINA_SAFETY_ON_NULL_RETURN(ec);
2422 ELOGF("TZPOL", "ICONIFY", ec);
2424 e_policy_hook_call(E_POLICY_HOOK_CLIENT_ICONIFY_REQ, ec);
2425 e_policy_wl_iconify(ec);
2429 _tzpol_iface_cb_uniconify(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
2433 ec = e_client_from_surface_resource(surf);
2434 EINA_SAFETY_ON_NULL_RETURN(ec);
2436 ELOGF("TZPOL", "UNICONIFY", ec);
2438 e_policy_hook_call(E_POLICY_HOOK_CLIENT_UNICONIFY_REQ, ec);
2439 e_policy_wl_uniconify(ec);
2443 _e_policy_wl_allowed_aux_hint_send(struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
2447 ec = e_client_from_surface_resource(surf);
2448 EINA_SAFETY_ON_NULL_RETURN(ec);
2450 ELOGF("TZPOL", "SEND |res_tzpol:%8p|id:%d, hint allowed ", ec, res_tzpol, id);
2451 tizen_policy_send_allowed_aux_hint(res_tzpol, surf, id);
2455 _e_policy_wl_aux_hint_apply(E_Client *ec)
2457 E_Comp_Wl_Client_Data *cdata;
2458 E_Comp_Wl_Aux_Hint *hint;
2461 cdata = e_client_cdata_get(ec);
2463 if (!cdata->aux_hint.changed) return;
2465 EINA_LIST_FOREACH(cdata->aux_hint.hints, l, hint)
2467 if (!hint->changed) continue;
2470 if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_USER_GEOMETRY]))
2474 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_FALSE);
2478 if (!strcmp(hint->val, "1"))
2480 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_TRUE);
2482 else if (strcmp(hint->val, "1"))
2484 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_FALSE);
2487 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_FIXED_RESIZE]))
2489 /* TODO: support other aux_hints */
2491 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_DEICONIFY_UPDATE]))
2493 if (!strcmp(hint->val, "1"))
2494 ec->exp_iconify.deiconify_update = EINA_TRUE;
2496 ec->exp_iconify.deiconify_update = EINA_FALSE;
2499 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_GESTURE_DISABLE]))
2503 ec->gesture_disable = EINA_FALSE;
2507 if (atoi(hint->val) == 1)
2509 ec->gesture_disable = EINA_TRUE;
2513 ec->gesture_disable = EINA_FALSE;
2516 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ICONIFY]))
2520 ec->exp_iconify.skip_iconify = 0;
2525 if (!strcmp(hint->val, "disable"))
2527 ec->exp_iconify.skip_iconify = 1;
2530 else if (!strcmp(hint->val, "enable"))
2532 ec->exp_iconify.skip_iconify = 0;
2536 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ABOVE_LOCKSCREEN]))
2538 if ((hint->deleted) ||
2539 (!strcmp(hint->val, "0")))
2541 E_Layer original_layer = ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer;
2542 if (ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set &&
2543 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved)
2545 // restore original layer
2546 if (original_layer != evas_object_layer_get(ec->frame))
2548 Eina_Bool pend = EINA_FALSE;
2549 pend = e_policy_visibility_client_layer_lower(ec, original_layer);
2552 e_client_layer_set(ec, original_layer);
2556 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set = 0;
2557 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved = 0;
2558 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer = 0;
2561 else if (!strcmp(hint->val, "1"))
2563 if (!ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved)
2565 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set = 1;
2566 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved = 0;
2567 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer = ec->layer;
2572 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_EFFECT_DISABLE]))
2574 if ((hint->deleted) ||
2575 (!strcmp(hint->val, "0")))
2577 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_HINT, 0);
2579 else if (!strcmp(hint->val, "1"))
2581 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_HINT, 1);
2584 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_MSG_USE]))
2586 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2587 cdata->aux_hint.use_msg = EINA_FALSE;
2588 else if (!strcmp(hint->val, "1"))
2589 cdata->aux_hint.use_msg = EINA_TRUE;
2591 else if (!strcmp(hint->hint, hint_names[E_COMP_HINT_ALWAYS_SELECTIVE]))
2593 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2595 cdata->never_hwc = EINA_FALSE;
2597 e_hwc_window_never_hwc_set(ec->hwc_window, EINA_FALSE);
2599 else if (!strcmp(hint->val, "1"))
2601 cdata->never_hwc = EINA_TRUE;
2603 e_hwc_window_never_hwc_set(ec->hwc_window, EINA_TRUE);
2606 e_comp_render_queue();
2608 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_DEPENDENT_ROTATION]))
2610 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2611 ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_NORMAL;
2612 else if (!strcmp(hint->val, "1"))
2613 ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_DEPENDENT;
2615 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ROT_RENDER_NOPENDING]))
2617 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2619 ELOGF("ROTATION", "nopending render:0", ec);
2620 ec->e.state.rot.nopending_render = 0;
2622 else if (!strcmp(hint->val, "1"))
2624 ELOGF("ROTATION", "nopending render:1", ec);
2625 ec->e.state.rot.nopending_render = 1;
2628 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_ICONIFY_BUFFER_FLUSH], strlen(hint->hint)))
2630 if (!strncmp(hint->val, "1", 1))
2631 ec->exp_iconify.buffer_flush = EINA_TRUE;
2633 ec->exp_iconify.buffer_flush = EINA_FALSE;
2635 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP], strlen(hint->hint)))
2637 if (!strncmp(hint->val, "1", 1))
2639 ELOGF("TF_SET", "Transient for Always_on_top enabled", ec);
2640 ec->transient_for_always_on_top = EINA_TRUE;
2644 ELOGF("TF_SET", "Transient for Always_on_top disabled", ec);
2645 ec->transient_for_always_on_top = EINA_FALSE;
2648 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_BELONG_TO_PARENT], strlen(hint->hint)))
2650 if (!strncmp(hint->val, "1", 1))
2652 ELOGF("TF_SET", "Set belong_to_parent", ec);
2653 e_client_belong_to_parent_set(ec, EINA_TRUE);
2657 ELOGF("TF_SET", "Unset belong_to_parent", ec);
2658 e_client_belong_to_parent_set(ec, EINA_FALSE);
2661 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_ASPECT_RATIO], strlen(hint->hint)))
2663 if (!strncmp(hint->val, "1", 1))
2665 ELOGF("RESIZE", "Set resize aspect ratio.. ratio(%dx%d)", ec, ec->w, ec->h);
2666 ec->manage_resize.enable_aspect_ratio = EINA_TRUE;
2667 ec->manage_resize.aw = ec->w;
2668 ec->manage_resize.ah = ec->h;
2672 ELOGF("RESIZE", "Unset resize aspect ratio", ec);
2673 ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
2676 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_HEADER], strlen(hint->hint)))
2678 int height = atoi(hint->val);
2681 ELOGF("CSD", "Set decoration HEADER size.. size(%d)", ec, height);
2682 ec->manage_resize.header_h = height;
2686 ELOGF("CSD", "Unset decoration HEADER size", ec);
2687 ec->manage_resize.header_h = 0;
2690 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_FOOTER], strlen(hint->hint)))
2692 int height = atoi(hint->val);
2695 ELOGF("CSD", "Set decoration FOOTER size.. size(%d)", ec, height);
2696 ec->manage_resize.footer_h = height;
2700 ELOGF("CSD", "Unset decoration FOOTER size", ec);
2701 ec->manage_resize.footer_h = 0;
2704 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_VISIBILITY_IGNORE_GEOMETRY], strlen(hint->hint)))
2706 if (!strncmp(hint->val, "1", 1))
2708 ELOGF("POL_VIS", "Set ignore_geometry.. value(%s)", ec, hint->val);
2709 ec->visibility.ignore_geometry = EINA_TRUE;
2713 ELOGF("POL_VIS", "UNSet ignore_geometry.. value(%s)", ec, hint->val);
2714 ec->visibility.ignore_geometry = EINA_FALSE;
2717 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_PPU], strlen(hint->hint)))
2719 int ppu = atoi(hint->val);
2720 if (ppu < 1) ppu = 1;
2722 ELOGF("RESIZE", "Set resize unit. size:%d", ec, ppu);
2723 e_client_resize_unit_size_set(ec, ppu);
2725 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_TOP], strlen(hint->hint)))
2727 int size = atoi(hint->val);
2730 ELOGF("CSD", "Set decoration SHADOW top.. size(%d)", ec, size);
2731 ec->manage_resize.shadow.t = size;
2735 ELOGF("CSD", "Unset decoration SHADOW top", ec);
2736 ec->manage_resize.shadow.t = 0;
2739 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_BOTTOM], strlen(hint->hint)))
2741 int size = atoi(hint->val);
2744 ELOGF("CSD", "Set decoration SHADOW bottom.. size(%d)", ec, size);
2745 ec->manage_resize.shadow.b = size;
2749 ELOGF("CSD", "Unset decoration SHADOW bottom", ec);
2750 ec->manage_resize.shadow.b = 0;
2753 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_LEFT], strlen(hint->hint)))
2755 int size = atoi(hint->val);
2758 ELOGF("CSD", "Set decoration SHADOW left.. size(%d)", ec, size);
2759 ec->manage_resize.shadow.l = size;
2763 ELOGF("CSD", "Unset decoration SHADOW left", ec);
2764 ec->manage_resize.shadow.l = 0;
2767 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_RIGHT], strlen(hint->hint)))
2769 int size = atoi(hint->val);
2772 ELOGF("CSD", "Set decoration SHADOW right.. size(%d)", ec, size);
2773 ec->manage_resize.shadow.r = size;
2777 ELOGF("CSD", "Unset decoration SHADOW right", ec);
2778 ec->manage_resize.shadow.r = 0;
2783 e_policy_hook_call(E_POLICY_HOOK_CLIENT_AUX_HINT_CHANGED, ec);
2787 _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)
2790 Eina_Bool res = EINA_FALSE;
2792 ec = e_client_from_surface_resource(surf);
2793 EINA_SAFETY_ON_NULL_RETURN(ec);
2795 res = e_hints_aux_hint_add(ec, id, name, value);
2797 ELOGF("TZPOL", "HINT_ADD |res_tzpol:%8p|id:%d, name:%s, val:%s, res:%d", ec, res_tzpol, id, name, value, res);
2801 _e_policy_wl_aux_hint_apply(ec);
2802 _e_policy_wl_allowed_aux_hint_send(res_tzpol, surf, id);
2807 _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)
2810 Eina_Bool res = EINA_FALSE;
2812 ec = e_client_from_surface_resource(surf);
2813 EINA_SAFETY_ON_NULL_RETURN(ec);
2815 res = e_hints_aux_hint_change(ec, id, value);
2817 ELOGF("TZPOL", "HINT_CHD |res_tzpol:%8p|id:%d, val:%s, result:%d", ec, res_tzpol, id, value, res);
2821 _e_policy_wl_aux_hint_apply(ec);
2822 _e_policy_wl_allowed_aux_hint_send(res_tzpol, surf, id);
2827 _tzpol_iface_cb_aux_hint_del(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
2830 unsigned int res = -1;
2832 ec = e_client_from_surface_resource(surf);
2833 EINA_SAFETY_ON_NULL_RETURN(ec);
2835 res = e_hints_aux_hint_del(ec, id);
2836 ELOGF("TZPOL", "HINT_DEL |res_tzpol:%8p|id:%d, result:%d", ec, res_tzpol, id, res);
2839 _e_policy_wl_aux_hint_apply(ec);
2843 _tzpol_iface_cb_supported_aux_hints_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
2846 const Eina_List *hints_list;
2848 struct wl_array hints;
2849 const char *hint_name;
2853 ec = e_client_from_surface_resource(surf);
2854 EINA_SAFETY_ON_NULL_RETURN(ec);
2856 hints_list = e_hints_aux_hint_supported_get();
2858 wl_array_init(&hints);
2859 EINA_LIST_FOREACH(hints_list, l, hint_name)
2861 len = strlen(hint_name) + 1;
2862 p = wl_array_add(&hints, len);
2866 strncpy(p, hint_name, len);
2869 tizen_policy_send_supported_aux_hints(res_tzpol, surf, &hints, eina_list_count(hints_list));
2871 "SEND |res_tzpol:%8p|supported_hints size:%d",
2874 eina_list_count(hints_list));
2875 wl_array_release(&hints);
2879 _e_policy_wl_background_state_apply(E_Client *ec, Eina_Bool state)
2884 "BACKGROUND STATE %s for PID(%u), iconic:%d",
2886 state?"SET":"UNSET", ec->netwm.pid, ec->iconic);
2890 ec->bg_state = EINA_TRUE;
2891 evas_object_hide(ec->frame);
2892 e_pixmap_image_clear(ec->pixmap, 1);
2896 ec->bg_state = EINA_FALSE;
2899 E_Comp_Wl_Client_Data *cdata;
2900 cdata = e_client_cdata_get(ec);
2901 if (cdata && cdata->mapped)
2903 evas_object_show(ec->frame);
2904 e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
2910 e_comp_visibility_calculation_set(EINA_TRUE);
2914 _e_policy_wl_background_state_set(E_Policy_Wl_Surface *psurf, Eina_Bool state)
2916 psurf->is_background = state;
2917 ELOGF("TZPOL", "Set psurf(%p)'s background_state to %d", NULL, psurf, state);
2922 _e_policy_wl_background_state_apply(psurf->ec, EINA_TRUE);
2927 _e_policy_wl_background_state_apply(psurf->ec, EINA_FALSE);
2932 _e_policy_wl_tzlaunch_effect_type_sync(E_Client *ec)
2935 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
2937 EINA_SAFETY_ON_NULL_RETURN(ec);
2939 EINA_LIST_FOREACH(polwl->tzlaunch_effect_info, l, effect_info)
2941 if (effect_info->pid == ec->netwm.pid)
2944 "Launchscreen effect type sync | pid (%d) effect_type (%d)",
2945 ec, ec->netwm.pid, effect_info->effect_type);
2946 ec->effect_type = effect_info->effect_type;
2947 _e_policy_wl_tzlaunch_effect_type_unset(ec->netwm.pid);
2954 _e_policy_wl_tzlaunch_effect_type_get(const char * effect_type)
2956 Tzlaunch_Effect_Type type = TZLAUNCH_EFFECT_TYPE_LAUNCH;
2958 if (!e_util_strcmp(effect_type, "launch" )) type = TZLAUNCH_EFFECT_TYPE_LAUNCH;
2959 else if (!e_util_strcmp(effect_type, "depth-in" )) type = TZLAUNCH_EFFECT_TYPE_DEPTH_IN;
2965 _e_policy_wl_tzlaunch_effect_type_unset(uint32_t pid)
2968 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
2970 EINA_LIST_FOREACH(polwl->tzlaunch_effect_info, l, effect_info)
2972 if (effect_info->pid == pid)
2975 "Launchscreen effect type unset | pid (%d)",
2977 polwl->tzlaunch_effect_info = eina_list_remove(polwl->tzlaunch_effect_info, effect_info);
2978 memset(effect_info, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Effect_Info));
2979 E_FREE(effect_info);
2986 _e_policy_wl_tzpol_background_state_set(E_Policy_Wl_Tzpol *tzpol, Eina_Bool bg_state, pid_t pid)
2989 E_Policy_Wl_Surface *psurf;
2993 tzpol->bg_state = bg_state;
2994 ELOGF("TZPOL", "Set tzpol(%p)'s background_state to %d", NULL, tzpol, bg_state);
2996 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
2998 if (psurf->pid == pid)
3000 if (psurf->is_background == bg_state)
3003 _e_policy_wl_background_state_set(psurf, bg_state);
3009 _e_policy_wl_tzpols_background_state_set(Eina_Bool bg_state, pid_t pid)
3011 E_Policy_Wl_Tzpol *tzpol;
3014 it = eina_hash_iterator_data_new(polwl->tzpols);
3015 EINA_ITERATOR_FOREACH(it, tzpol)
3017 if (tzpol->pid == pid)
3019 _e_policy_wl_tzpol_background_state_set(tzpol, bg_state, pid);
3022 eina_iterator_free(it);
3026 _tzpol_iface_cb_background_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t pid)
3028 E_Policy_Wl_Tzpol *tzpol;
3030 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3031 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3033 ELOGF("TZPOL", "Register PID(%u) for BACKGROUND STATE res_tzpol:%p tzpol:%p", NULL, pid, res_tzpol, tzpol);
3035 _e_policy_wl_tzpols_background_state_set(EINA_TRUE, pid);
3039 _tzpol_iface_cb_background_state_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t pid)
3041 E_Policy_Wl_Tzpol *tzpol;
3043 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3044 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3046 ELOGF("TZPOL", "Unregister PID(%u) for BACKGROUND STATE res_tzpol:%p tzpol:%p", NULL, pid, res_tzpol, tzpol);
3048 _e_policy_wl_tzpols_background_state_set(EINA_FALSE, pid);
3052 _e_policy_wl_floating_mode_apply(E_Client *ec, Eina_Bool floating)
3054 if (ec->floating == floating) return;
3056 ec->floating = floating;
3057 ec->lock_client_location = EINA_FALSE;
3063 ec->floating_saved_layer = ec->layer;
3064 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
3068 e_client_layer_set(ec, ec->floating_saved_layer);
3076 _tzpol_iface_cb_floating_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
3080 ec = e_client_from_surface_resource(surf);
3081 EINA_SAFETY_ON_NULL_RETURN(ec);
3083 ELOGF("TZPOL", "FLOATING Set", ec);
3085 _e_policy_wl_floating_mode_apply(ec, EINA_TRUE);
3089 _tzpol_iface_cb_floating_mode_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
3093 ec = e_client_from_surface_resource(surf);
3094 EINA_SAFETY_ON_NULL_RETURN(ec);
3096 ELOGF("TZPOL", "FLOATING Unset", ec);
3098 e_client_pending_geometry_flush(ec);
3100 _e_policy_wl_floating_mode_apply(ec, EINA_FALSE);
3104 _tzpol_iface_cb_stack_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
3108 ec = e_client_from_surface_resource(surf);
3109 EINA_SAFETY_ON_NULL_RETURN(ec);
3111 ELOGF("TZPOL", "STACK Mode Set. mode:%d", ec, mode);
3115 if (mode == TIZEN_POLICY_STACK_MODE_ABOVE)
3117 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
3119 else if (mode == TIZEN_POLICY_STACK_MODE_BELOW)
3121 e_client_layer_set(ec, E_LAYER_CLIENT_BELOW);
3125 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
3129 e_policy_hook_call(E_POLICY_HOOK_CLIENT_STACK_MODE_SET, ec);
3133 // --------------------------------------------------------
3134 // E_Policy_Wl_Tz_Dpy_Pol
3135 // --------------------------------------------------------
3136 static E_Policy_Wl_Tz_Dpy_Pol *
3137 _e_policy_wl_tz_dpy_pol_add(struct wl_resource *res_tz_dpy_pol)
3139 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3141 tz_dpy_pol = E_NEW(E_Policy_Wl_Tz_Dpy_Pol, 1);
3142 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_dpy_pol, NULL);
3144 tz_dpy_pol->res_tz_dpy_pol = res_tz_dpy_pol;
3146 polwl->tz_dpy_pols = eina_list_append(polwl->tz_dpy_pols, tz_dpy_pol);
3152 _e_policy_wl_tz_dpy_pol_del(E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol)
3154 E_Policy_Wl_Dpy_Surface *dpy_surf;
3156 EINA_SAFETY_ON_NULL_RETURN(tz_dpy_pol);
3158 polwl->tz_dpy_pols = eina_list_remove(polwl->tz_dpy_pols, tz_dpy_pol);
3160 EINA_LIST_FREE(tz_dpy_pol->dpy_surfs, dpy_surf)
3168 static E_Policy_Wl_Tz_Dpy_Pol *
3169 _e_policy_wl_tz_dpy_pol_get(struct wl_resource *res_tz_dpy_pol)
3172 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3174 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3176 if (tz_dpy_pol->res_tz_dpy_pol == res_tz_dpy_pol)
3183 // --------------------------------------------------------
3184 // E_Policy_Wl_Dpy_Surface
3185 // --------------------------------------------------------
3186 static E_Policy_Wl_Dpy_Surface *
3187 _e_policy_wl_dpy_surf_find(E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol, E_Client *ec)
3190 E_Policy_Wl_Dpy_Surface *dpy_surf;
3192 EINA_LIST_FOREACH(tz_dpy_pol->dpy_surfs, l, dpy_surf)
3194 if (dpy_surf->ec == ec)
3201 static E_Policy_Wl_Dpy_Surface *
3202 _e_policy_wl_dpy_surf_add(E_Client *ec, struct wl_resource *res_tz_dpy_pol)
3204 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol = NULL;
3205 E_Policy_Wl_Dpy_Surface *dpy_surf = NULL;
3206 E_Comp_Wl_Client_Data *cdata;
3208 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_get(res_tz_dpy_pol);
3209 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_dpy_pol, NULL);
3211 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3215 dpy_surf = E_NEW(E_Policy_Wl_Dpy_Surface, 1);
3216 EINA_SAFETY_ON_NULL_RETURN_VAL(dpy_surf, NULL);
3218 cdata = e_client_cdata_get(ec);
3219 dpy_surf->surf = cdata->surface;
3220 dpy_surf->tz_dpy_pol = tz_dpy_pol;
3222 dpy_surf->brightness = -1;
3224 tz_dpy_pol->dpy_surfs = eina_list_append(tz_dpy_pol->dpy_surfs, dpy_surf);
3229 _e_policy_wl_dpy_surf_del(E_Client *ec)
3232 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3233 E_Policy_Wl_Dpy_Surface *dpy_surf;
3235 EINA_SAFETY_ON_NULL_RETURN(ec);
3237 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3239 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3242 tz_dpy_pol->dpy_surfs = eina_list_remove(tz_dpy_pol->dpy_surfs, dpy_surf);
3248 // --------------------------------------------------------
3250 // --------------------------------------------------------
3252 _e_policy_system_brightness_get(int *brightness)
3255 int sys_brightness = -1;
3257 if (!brightness) return EINA_FALSE;
3259 error = device_display_get_brightness(0, &sys_brightness);
3260 if (error != DEVICE_ERROR_NONE)
3266 *brightness = sys_brightness;
3272 _e_policy_system_brightness_set(int brightness)
3281 error = device_display_get_numbers(&num_of_dpy);
3282 if (error != DEVICE_ERROR_NONE)
3288 for (id = 0; id < num_of_dpy; id++)
3290 error = device_display_set_brightness(id, brightness);
3291 if (error != DEVICE_ERROR_NONE)
3303 _e_policy_change_system_brightness(int new_brightness)
3308 if (!e_policy_system_info.brightness.use_client)
3310 // save system brightness
3311 ret = _e_policy_system_brightness_get(&sys_brightness);
3316 e_policy_system_info.brightness.system = sys_brightness;
3319 ret = _e_policy_system_brightness_set(new_brightness);
3324 e_policy_system_info.brightness.client = new_brightness;
3325 e_policy_system_info.brightness.use_client = EINA_TRUE;
3331 _e_policy_restore_system_brightness(void)
3335 if (!e_policy_system_info.brightness.use_client) return EINA_TRUE;
3337 // restore system brightness
3338 ret = _e_policy_system_brightness_set(e_policy_system_info.brightness.system);
3343 e_policy_system_info.brightness.use_client = EINA_FALSE;
3346 // if there are another window which set brighteness, then we change brighteness of it
3347 // if no, then we rollback system brightness
3353 e_policy_wl_win_brightness_apply(E_Client *ec)
3357 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3358 E_Policy_Wl_Dpy_Surface *dpy_surf = NULL;
3361 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
3362 if (e_object_is_del(E_OBJECT(ec)))
3363 ec_visibility = E_VISIBILITY_FULLY_OBSCURED;
3365 ec_visibility = ec->visibility.obscured;
3367 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3369 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3374 if (!dpy_surf) return EINA_FALSE;
3375 if (!dpy_surf->set) return EINA_FALSE;
3377 // use system brightness
3378 if (dpy_surf->brightness < 0)
3380 ELOGF("TZ_DPY_POL", "Restore system brightness. Win(0x%08zx)'s brightness:%d", ec, e_client_util_win_get(ec), dpy_surf->brightness);
3381 ret = _e_policy_restore_system_brightness();
3385 if (ec_visibility == E_VISIBILITY_UNOBSCURED)
3387 ELOGF("TZ_DPY_POL", "Change system brightness(%d). Win(0x%08zx) is un-obscured", ec, dpy_surf->brightness, e_client_util_win_get(ec));
3388 ret = _e_policy_change_system_brightness(dpy_surf->brightness);
3389 if (!ret) return EINA_FALSE;
3393 ELOGF("TZ_DPY_POL", "Restore system brightness. Win(0x%08zx) is obscured", ec, e_client_util_win_get(ec));
3394 ret = _e_policy_restore_system_brightness();
3395 if (!ret) return EINA_FALSE;
3402 _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)
3405 E_Policy_Wl_Dpy_Surface *dpy_surf;
3410 ec = e_client_from_surface_resource(surf);
3411 EINA_SAFETY_ON_NULL_RETURN(ec);
3413 dpy_surf = _e_policy_wl_dpy_surf_add(ec, res_tz_dpy_pol);
3414 EINA_SAFETY_ON_NULL_RETURN(dpy_surf);
3416 wl_client_get_credentials(client, &pid, &uid, NULL);
3417 res = e_security_privilege_check(pid, uid,
3418 E_PRIVILEGE_BRIGHTNESS_SET);
3422 "Privilege Check Failed! DENY set_brightness",
3425 tizen_display_policy_send_window_brightness_done
3429 TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED);
3432 ELOGF("TZ_DPY_POL", "Set Win(0x%08zx)'s brightness:%d", ec, e_client_util_win_get(ec), brightness);
3433 dpy_surf->set = EINA_TRUE;
3434 dpy_surf->brightness = brightness;
3436 e_policy_wl_win_brightness_apply(ec);
3438 tizen_display_policy_send_window_brightness_done
3439 (res_tz_dpy_pol, surf, brightness, TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE);
3443 _tz_dpy_pol_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
3445 wl_resource_destroy(resource);
3449 _tzpol_iface_cb_subsurf_watcher_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surface)
3453 if (!(ec = e_client_from_surface_resource(surface))) return;
3454 if (e_object_is_del(E_OBJECT(ec))) return;
3456 e_subsurface_watcher_add(client, id, surface);
3460 _tzpol_iface_cb_parent_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
3462 E_Client *ec, *parent_ec;
3465 "PARENT_SET |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3466 NULL, res_tzpol, parent, child);
3468 ec = e_client_from_surface_resource(child);
3469 EINA_SAFETY_ON_NULL_RETURN(ec);
3471 parent_ec = e_client_from_surface_resource(parent);
3472 e_policy_stack_parent_set(ec, parent_ec);
3476 _tzpol_iface_cb_ack_conformant_region(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t serial)
3480 if (!(ec = e_client_from_surface_resource(surface))) return;
3482 e_policy_conformant_client_ack(ec, res_tzpol, serial);
3486 _tzpol_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzpol)
3488 wl_resource_destroy(res_tzpol);
3492 _tzpol_iface_cb_has_video(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t has)
3495 E_Comp_Wl_Client_Data *cdata;
3497 if (!(ec = e_client_from_surface_resource(surface))) return;
3498 if (e_object_is_del(E_OBJECT(ec))) return;
3499 cdata = e_client_cdata_get(ec);
3501 if (cdata->has_video_client == has) return;
3503 ELOGF("TZPOL", "video client has(%d)", ec, has);
3505 cdata->has_video_client = has;
3509 _tzpol_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzpol, int32_t pid, const char *appid)
3511 E_Policy_Wl_Tzpol *tzpol;
3514 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3515 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3517 ELOGF("TZPOL", "Set appid(%s) pid(%d)", NULL, appid, pid);
3519 if (!(eai = e_appinfo_find_with_appid(appid)))
3521 eai = e_appinfo_new();
3522 e_appinfo_appid_set(eai, appid);
3523 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
3525 EINA_SAFETY_ON_NULL_RETURN(eai);
3527 e_appinfo_pid_set(eai, pid);
3531 _tzpol_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3534 E_Comp_Wl_Client_Data *cdata;
3536 ec = e_client_from_surface_resource(surf);
3537 EINA_SAFETY_ON_NULL_RETURN(ec);
3538 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3540 ELOGF("TZPOL", "Prepare SHOW (wait for buffer attach)", ec);
3541 e_client_hide_by_request_set(ec, EINA_FALSE);
3543 cdata = e_client_cdata_get(ec);
3544 if (cdata && !cdata->mapped)
3546 if (e_config->raise_before_show)
3549 ec->post_raise = EINA_FALSE;
3555 _tzpol_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3559 ec = e_client_from_surface_resource(surf);
3560 EINA_SAFETY_ON_NULL_RETURN(ec);
3561 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3563 ELOGF("TZPOL", "Prepare HIDE (wait for NULL buffer attach)", ec);
3564 e_client_hide_by_request_set(ec, EINA_TRUE);
3568 _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)
3570 E_Client *ec, *parent_ec;
3571 E_Comp_Wl_Client_Data *cdata, *p_cdata;
3574 "TF_SET(B) |res_tzpol:%8p|parent_id:%8d |child_id:%8d",
3575 NULL, res_tzpol, parent_id, child_id);
3577 ec = e_pixmap_find_client_by_res_id(child_id);
3578 EINA_SAFETY_ON_NULL_RETURN(ec);
3579 parent_ec = e_pixmap_find_client_by_res_id(parent_id);
3581 cdata = e_client_cdata_get(ec);
3582 p_cdata = e_client_cdata_get(parent_ec);
3584 " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3585 NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL));
3587 e_policy_stack_transient_for_below_set(ec, parent_ec, EINA_TRUE);
3591 _tzpol_iface_cb_set_parent_with_below(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
3593 E_Client *ec, *parent_ec;
3596 "PARENT_SET(B)|res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3597 NULL, res_tzpol, parent, child);
3599 ec = e_client_from_surface_resource(child);
3600 EINA_SAFETY_ON_NULL_RETURN(ec);
3603 parent_ec = e_client_from_surface_resource(parent);
3607 e_policy_stack_transient_for_below_set(ec, parent_ec, EINA_FALSE);
3611 _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)
3615 ec = e_client_from_surface_resource(surf);
3616 EINA_SAFETY_ON_NULL_RETURN(ec);
3617 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3619 ELOGF("TZPOL", "Set Maximize_direction. direction:%d", ec, direction);
3621 if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_NONE)
3623 ec->maximize_dir = E_MAXIMIZE_DIRECTION_NONE;
3624 e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
3628 if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_ALL)
3630 ec->maximize_dir = E_MAXIMIZE_DIRECTION_ALL;
3632 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_LEFT)
3634 ec->maximize_dir = E_MAXIMIZE_DIRECTION_LEFT;
3636 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_RIGHT)
3638 ec->maximize_dir = E_MAXIMIZE_DIRECTION_RIGHT;
3642 ELOGF("TZPOL", "Not supported direction:%d", ec, direction);
3646 e_client_maximize(ec, ec->maximize_type | ec->maximize_dir);
3650 _e_policy_set_pin_mode(E_Client *ec, Eina_Bool pinned)
3652 EINA_SAFETY_ON_NULL_RETURN(ec);
3653 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3655 ELOGF("TZPOL", "Set Pin mode to %d", ec, pinned);
3656 e_client_pinned_set(ec, pinned);
3660 _tzpol_iface_cb_set_pin_mode(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3664 ec = e_client_from_surface_resource(surf);
3665 _e_policy_set_pin_mode(ec, EINA_TRUE);
3669 _tzpol_iface_cb_unset_pin_mode(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3673 ec = e_client_from_surface_resource(surf);
3674 _e_policy_set_pin_mode(ec, EINA_FALSE);
3678 _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)
3685 ec = e_client_from_surface_resource(surf);
3688 desk = e_comp_desk_find_by_ec(ec);
3689 EINA_SAFETY_ON_NULL_RETURN(desk);
3691 unit_w = desk->geom.w / num_cols;
3692 unit_h = desk->geom.h / num_rows;
3694 x = unit_w * column;
3696 w = unit_w * col_span;
3697 h = unit_h * row_span;
3699 // TODO: We may need to adjust the last size if the unit size is not devided exactly
3701 ELOGF("TZPOL", "TIZEN_POLICY_SET_LAYOUT... total_layout(%d,%d) -> unit_size(%dx%d). request(%d,%d,%d,%d) -> geo(%d,%d,%dx%d)",
3702 ec, num_cols, num_rows, unit_w, unit_h, column, row, col_span, row_span, x, y, w, h);
3704 // Apply shadow size (left, right, top, bottom)
3705 x -= ec->manage_resize.shadow.l;
3706 y -= ec->manage_resize.shadow.t;
3707 w = w + ec->manage_resize.shadow.l + ec->manage_resize.shadow.r;
3708 h = h + ec->manage_resize.shadow.t + ec->manage_resize.shadow.b;
3710 ELOGF("TZPOL", "Consider Shadow size(l:%d,r:%d,t:%d,b:%d). new (%d,%d,%dx%d)",
3711 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);
3713 e_client_layout_apply(ec, EINA_TRUE);
3714 e_client_frame_geometry_set(ec, x, y, w, h);
3717 e_client_shell_configure_send(ec, 0, w, h);
3720 // --------------------------------------------------------
3721 // tizen_policy_interface
3722 // --------------------------------------------------------
3723 static const struct tizen_policy_interface _tzpol_iface =
3725 _tzpol_iface_cb_vis_get,
3726 _tzpol_iface_cb_pos_get,
3727 _tzpol_iface_cb_activate,
3728 _tzpol_iface_cb_activate_below_by_res_id,
3729 _tzpol_iface_cb_raise,
3730 _tzpol_iface_cb_lower,
3731 _tzpol_iface_cb_lower_by_res_id,
3732 _tzpol_iface_cb_focus_skip_set,
3733 _tzpol_iface_cb_focus_skip_unset,
3734 _tzpol_iface_cb_role_set,
3735 _tzpol_iface_cb_type_set,
3736 _tzpol_iface_cb_conformant_set,
3737 _tzpol_iface_cb_conformant_unset,
3738 _tzpol_iface_cb_conformant_get,
3739 _tzpol_iface_cb_notilv_set,
3740 _tzpol_iface_cb_transient_for_set,
3741 _tzpol_iface_cb_transient_for_unset,
3742 _tzpol_iface_cb_win_scrmode_set,
3743 _tzpol_iface_cb_subsurf_place_below_parent,
3744 _tzpol_iface_cb_subsurf_stand_alone_set,
3745 _tzpol_iface_cb_subsurface_get,
3746 _tzpol_iface_cb_opaque_state_set,
3747 _tzpol_iface_cb_iconify,
3748 _tzpol_iface_cb_uniconify,
3749 _tzpol_iface_cb_aux_hint_add,
3750 _tzpol_iface_cb_aux_hint_change,
3751 _tzpol_iface_cb_aux_hint_del,
3752 _tzpol_iface_cb_supported_aux_hints_get,
3753 _tzpol_iface_cb_background_state_set,
3754 _tzpol_iface_cb_background_state_unset,
3755 _tzpol_iface_cb_floating_mode_set,
3756 _tzpol_iface_cb_floating_mode_unset,
3757 _tzpol_iface_cb_stack_mode_set,
3758 _tzpol_iface_cb_activate_above_by_res_id,
3759 _tzpol_iface_cb_subsurf_watcher_get,
3760 _tzpol_iface_cb_parent_set,
3761 _tzpol_iface_cb_ack_conformant_region,
3762 _tzpol_iface_cb_destroy,
3763 _tzpol_iface_cb_has_video,
3764 _tzpol_iface_cb_set_appid,
3765 _tzpol_iface_cb_show,
3766 _tzpol_iface_cb_hide,
3767 _tzpol_iface_cb_set_transient_for_below,
3768 _tzpol_iface_cb_set_parent_with_below,
3769 _tzpol_iface_cb_set_maximize_direction,
3770 _tzpol_iface_cb_set_pin_mode,
3771 _tzpol_iface_cb_unset_pin_mode,
3772 _tzpol_iface_cb_set_layout
3776 _tzpol_cb_unbind(struct wl_resource *res_tzpol)
3778 E_Policy_Wl_Tzpol *tzpol;
3780 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3781 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3783 eina_hash_del_by_key(polwl->tzpols, &res_tzpol);
3787 _tzpol_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
3789 E_Policy_Wl_Tzpol *tzpol;
3790 struct wl_resource *res_tzpol;
3792 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
3794 res_tzpol = wl_resource_create(client,
3795 &tizen_policy_interface,
3798 EINA_SAFETY_ON_NULL_GOTO(res_tzpol, err);
3800 tzpol = _e_policy_wl_tzpol_add(client, res_tzpol);
3801 EINA_SAFETY_ON_NULL_GOTO(tzpol, err);
3803 wl_resource_set_implementation(res_tzpol,
3810 ERR("Could not create tizen_policy_interface res: %m");
3811 wl_client_post_no_memory(client);
3814 // --------------------------------------------------------
3815 // tizen_display_policy_interface
3816 // --------------------------------------------------------
3817 static const struct tizen_display_policy_interface _tz_dpy_pol_iface =
3819 _tz_dpy_pol_iface_cb_brightness_set,
3820 _tz_dpy_pol_iface_cb_destroy,
3824 _tz_dpy_pol_cb_unbind(struct wl_resource *res_tz_dpy_pol)
3826 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3828 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_get(res_tz_dpy_pol);
3829 EINA_SAFETY_ON_NULL_RETURN(tz_dpy_pol);
3831 _e_policy_wl_tz_dpy_pol_del(tz_dpy_pol);
3835 _tz_dpy_pol_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
3837 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3838 struct wl_resource *res_tz_dpy_pol;
3840 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
3842 res_tz_dpy_pol = wl_resource_create(client,
3843 &tizen_display_policy_interface,
3846 EINA_SAFETY_ON_NULL_GOTO(res_tz_dpy_pol, err);
3848 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_add(res_tz_dpy_pol);
3849 EINA_SAFETY_ON_NULL_GOTO(tz_dpy_pol, err);
3851 wl_resource_set_implementation(res_tz_dpy_pol,
3854 _tz_dpy_pol_cb_unbind);
3858 ERR("Could not create tizen_display_policy_interface res: %m");
3859 wl_client_post_no_memory(client);
3862 // --------------------------------------------------------
3863 // tizen_ws_shell_interface::service
3864 // --------------------------------------------------------
3866 _tzsh_srv_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_srv)
3868 wl_resource_destroy(res_tzsh_srv);
3872 _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)
3874 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3875 E_Policy_Wl_Tzsh_Region *tzsh_reg;
3877 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
3878 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3880 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
3883 tzsh_reg = wl_resource_get_user_data(res_reg);
3884 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
3886 if ((tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT) ||
3887 (tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU) ||
3888 (tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU))
3890 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3891 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
3893 e_service_quickpanel_region_set(tzsh_srv->ec,
3898 else if (tzsh_srv->role == TZSH_SRV_ROLE_VOLUME)
3899 e_service_volume_region_set(type, angle, tzsh_reg->tiler);
3900 else if (tzsh_srv->role == TZSH_SRV_ROLE_SOFTKEY)
3902 if (e_config->use_softkey_service)
3904 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3905 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
3907 e_service_softkey_handler_region_set(tzsh_srv->ec, angle, tzsh_reg->tiler);
3913 _tzsh_srv_indicator_cb_resource_destroy(struct wl_resource *resource)
3915 if (_indicator_srv_res == resource)
3916 _indicator_srv_res = NULL;
3920 _tzsh_srv_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
3922 _indicator_srv_res = NULL;
3923 wl_resource_destroy(resource);
3926 static const struct tws_service_indicator_interface _tzsh_srv_indicator_iface =
3928 _tzsh_srv_indicator_cb_destroy,
3932 _tzsh_srv_iface_cb_indicator_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
3934 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3935 struct wl_resource *res;
3937 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
3938 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3940 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
3943 res = wl_resource_create(client, &tws_service_indicator_interface, 1, id);
3946 wl_client_post_no_memory(client);
3949 _indicator_srv_res = res;
3951 wl_resource_set_implementation(res, &_tzsh_srv_indicator_iface, tzsh_srv,
3952 _tzsh_srv_indicator_cb_resource_destroy);
3956 _tzsh_srv_qp_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
3958 wl_resource_destroy(resource);
3962 _tzsh_srv_qp_cb_msg(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
3964 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3966 tzsh_srv = wl_resource_get_user_data(resource);
3968 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3969 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3971 #define EC tzsh_srv->ec
3972 EINA_SAFETY_ON_NULL_RETURN(EC);
3976 case TWS_SERVICE_QUICKPANEL_MSG_SHOW:
3977 e_service_quickpanel_show(EC);
3979 case TWS_SERVICE_QUICKPANEL_MSG_HIDE:
3980 e_service_quickpanel_hide(EC);
3983 ERR("Unknown message!! msg %d", msg);
3990 _tzsh_srv_qp_cb_effect_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t type)
3992 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3994 tzsh_srv = wl_resource_get_user_data(resource);
3996 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3997 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3999 #define EC tzsh_srv->ec
4000 EINA_SAFETY_ON_NULL_RETURN(EC);
4001 e_service_quickpanel_effect_type_set(EC, type);
4006 _tzsh_srv_qp_cb_scroll_lock_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t lock)
4008 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4010 tzsh_srv = wl_resource_get_user_data(resource);
4012 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4013 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4015 #define EC tzsh_srv->ec
4016 EINA_SAFETY_ON_NULL_RETURN(EC);
4017 e_service_quickpanel_scroll_lock_set(EC, lock);
4021 static const struct tws_service_quickpanel_interface _tzsh_srv_qp_iface =
4023 _tzsh_srv_qp_cb_destroy,
4024 _tzsh_srv_qp_cb_msg,
4025 _tzsh_srv_qp_cb_effect_type_set,
4026 _tzsh_srv_qp_cb_scroll_lock_set,
4030 _tzsh_srv_iface_cb_quickpanel_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4032 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4033 struct wl_resource *res;
4035 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4036 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4038 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4041 res = wl_resource_create(client,
4042 &tws_service_quickpanel_interface,
4043 wl_resource_get_version(res_tzsh_srv),
4047 wl_client_post_no_memory(client);
4051 wl_resource_set_implementation(res, &_tzsh_srv_qp_iface, tzsh_srv, NULL);
4057 _tzsh_srv_softkey_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4059 wl_resource_destroy(resource);
4063 _tzsh_srv_softkey_cb_msg_send(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4065 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4066 E_Service_Softkey *softkey_service;
4069 tzsh_srv = wl_resource_get_user_data(resource);
4071 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4072 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4074 zone = tzsh_srv->zone;
4075 EINA_SAFETY_ON_NULL_RETURN(zone);
4077 softkey_service = e_service_softkey_get(zone);
4078 EINA_SAFETY_ON_NULL_RETURN(softkey_service);
4082 case TWS_SERVICE_SOFTKEY_MSG_SHOW:
4083 e_service_softkey_show(softkey_service);
4085 case TWS_SERVICE_SOFTKEY_MSG_HIDE:
4086 e_service_softkey_hide(softkey_service);
4089 ERR("Unknown message!! msg %d", msg);
4094 static const struct tws_service_softkey_interface _tzsh_srv_softkey_iface =
4096 _tzsh_srv_softkey_cb_destroy,
4097 _tzsh_srv_softkey_cb_msg_send,
4101 _tzsh_srv_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4103 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4104 E_Service_Softkey *softkey_service = NULL;
4105 struct wl_resource *res;
4107 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4108 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4110 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4113 res = wl_resource_create(client, &tws_service_softkey_interface, 1, id);
4116 wl_client_post_no_memory(client);
4120 ELOGF("TZSH", "[SOFTKEY SERVICE] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
4124 E_Zone *zone = tzsh_srv->zone;
4126 softkey_service = e_service_softkey_get(zone);
4127 ELOGF("TZSH", "[SOFTKEY SERVICE] resource set. res:%p, softkey_service:%p, softkey_ec:%p", NULL, res, softkey_service, tzsh_srv->ec);
4128 if (softkey_service)
4130 e_service_softkey_wl_resource_set(softkey_service, res);
4131 e_service_softkey_restore_visible_request(softkey_service);
4135 wl_resource_set_implementation(res, &_tzsh_srv_softkey_iface, tzsh_srv, NULL);
4139 _tzsh_srv_magnifier_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4141 wl_resource_destroy(resource);
4145 _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)
4147 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4150 tzsh_srv = wl_resource_get_user_data(resource);
4152 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4153 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4154 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4156 ELOGF("TZSH", "[MAGNIFIER] Set Geometry. angle:%d, geo:%d,%d,%dx%d", tzsh_srv->ec, angle, x, y, w, h);
4159 // angle: 0, 90, 180, 270
4160 e_magnifier_zoom_obj_geometry_set(ec, angle, x, y, w, h);
4164 _tzsh_srv_magnifier_cb_ratio_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t ratio)
4166 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4169 tzsh_srv = wl_resource_get_user_data(resource);
4171 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4172 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4173 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4175 ELOGF("TZSH", "[MAGNIFIER] Set Ratio. ratio:%d", tzsh_srv->ec, ratio);
4178 // ratio : 100 ~ 200 (each 10)
4179 e_magnifier_zoom_obj_ratio_set(ec, ratio);
4183 _tzsh_srv_magnifier_cb_enable_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t enable)
4185 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4188 tzsh_srv = wl_resource_get_user_data(resource);
4190 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4191 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4192 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4194 ELOGF("TZSH", "[MAGNIFIER] Set Enable. enable:%d", tzsh_srv->ec, enable);
4199 e_magnifier_show(ec);
4201 e_magnifier_hide(ec);
4204 static const struct tws_service_magnifier_interface _tzsh_srv_magnifier_iface =
4206 _tzsh_srv_magnifier_cb_destroy,
4207 _tzsh_srv_magnifier_cb_zoom_geometry_set,
4208 _tzsh_srv_magnifier_cb_ratio_set,
4209 _tzsh_srv_magnifier_cb_enable_set,
4213 _tzsh_srv_iface_cb_magnifier_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4215 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4216 struct wl_resource *res;
4218 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4219 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4221 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4224 res = wl_resource_create(client, &tws_service_magnifier_interface, 1, id);
4227 wl_client_post_no_memory(client);
4231 ELOGF("TZSH", "[MAGNIFIER] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
4232 wl_resource_set_implementation(res, &_tzsh_srv_magnifier_iface, tzsh_srv, NULL);
4235 //////////////////////////////////////////////////////////////////////////////////////////////////////
4237 _tzsh_srv_scrsaver_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4239 wl_resource_destroy(resource);
4242 static const struct tws_service_screensaver_interface _tzsh_srv_scrsaver_iface =
4244 _tzsh_srv_scrsaver_cb_release
4248 _tzsh_srv_iface_cb_scrsaver_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4250 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4251 struct wl_resource *res;
4253 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4254 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4256 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4259 res = wl_resource_create(client, &tws_service_screensaver_interface, 1, id);
4262 wl_client_post_no_memory(client);
4266 wl_resource_set_implementation(res, &_tzsh_srv_scrsaver_iface, tzsh_srv, NULL);
4270 _tzsh_srv_scrsaver_mng_cb_resource_destroy(struct wl_resource *resource)
4272 if (_scrsaver_mng_res == resource)
4274 _scrsaver_mng_res = NULL;
4275 e_screensaver_disable();
4280 _tzsh_srv_scrsaver_mng_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4282 _scrsaver_mng_res = NULL;
4283 wl_resource_destroy(resource);
4284 e_screensaver_disable();
4288 _tzsh_srv_scrsaver_mng_cb_enable(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4290 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4292 tzsh_srv = wl_resource_get_user_data(resource);
4294 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4295 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4297 e_screensaver_enable();
4301 _tzsh_srv_scrsaver_mng_cb_disable(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4303 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4305 tzsh_srv = wl_resource_get_user_data(resource);
4307 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4308 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4310 e_screensaver_disable();
4314 _tzsh_srv_scrsaver_mng_cb_idle_time_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t time)
4316 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4319 tzsh_srv = wl_resource_get_user_data(resource);
4321 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4322 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4324 /* convert time to seconds (double) from milliseconds (unsigned int) */
4325 timeout = (double)time * 0.001f;
4327 e_screensaver_timeout_set(timeout);
4331 _tzsh_srv_scrsaver_mng_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t type)
4333 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4337 tzsh_srv = wl_resource_get_user_data(resource);
4339 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4340 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4344 case TWS_SERVICE_SCREENSAVER_MANAGER_STATE_TYPE_IDLE_TIMEOUT:
4345 /* convert time to milliseconds (unsigned int) from seconds (double) */
4346 timeout = e_screensaver_timeout_get();
4347 val = (uint32_t)(timeout * 1000);
4353 tws_service_screensaver_manager_send_state_get_done(resource, type, val, 0);
4356 static const struct tws_service_screensaver_manager_interface _tzsh_srv_scrsaver_mng_iface =
4358 _tzsh_srv_scrsaver_mng_cb_destroy,
4359 _tzsh_srv_scrsaver_mng_cb_enable,
4360 _tzsh_srv_scrsaver_mng_cb_disable,
4361 _tzsh_srv_scrsaver_mng_cb_idle_time_set,
4362 _tzsh_srv_scrsaver_mng_cb_state_get
4366 _tzsh_srv_iface_cb_scrsaver_mng_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4368 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4369 struct wl_resource *res;
4371 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4372 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4374 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4377 res = wl_resource_create(client, &tws_service_screensaver_manager_interface, 1, id);
4380 wl_client_post_no_memory(client);
4384 _scrsaver_mng_res = res;
4386 wl_resource_set_implementation(res, &_tzsh_srv_scrsaver_mng_iface, tzsh_srv,
4387 _tzsh_srv_scrsaver_mng_cb_resource_destroy);
4391 _tzsh_srv_cbhm_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4393 wl_resource_destroy(resource);
4397 _tzsh_srv_cbhm_cb_msg(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4399 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4401 tzsh_srv = wl_resource_get_user_data(resource);
4403 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4404 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4406 #define EC tzsh_srv->ec
4407 EINA_SAFETY_ON_NULL_RETURN(EC);
4411 case TWS_SERVICE_CBHM_MSG_SHOW:
4412 e_service_cbhm_show();
4414 case TWS_SERVICE_CBHM_MSG_HIDE:
4415 e_service_cbhm_hide();
4417 case TWS_SERVICE_CBHM_MSG_DATA_SELECTED:
4418 e_service_cbhm_data_selected();
4421 ERR("Unknown message!! msg %d", msg);
4427 static const struct tws_service_cbhm_interface _tzsh_srv_cbhm_iface =
4429 _tzsh_srv_cbhm_cb_destroy,
4430 _tzsh_srv_cbhm_cb_msg
4434 _tzsh_srv_iface_cb_cbhm_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4436 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4437 struct wl_resource *res;
4439 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4440 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4442 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4445 res = wl_resource_create(client, &tws_service_cbhm_interface, 1, id);
4448 wl_client_post_no_memory(client);
4452 wl_resource_set_implementation(res, &_tzsh_srv_cbhm_iface, tzsh_srv, NULL);
4457 _tzsh_srv_iface_cb_launcher_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4459 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4460 struct wl_resource *res;
4462 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4463 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4464 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4466 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4469 res = wl_resource_create(client, &tws_service_launcher_interface, 1, id);
4472 wl_client_post_no_memory(client);
4477 e_service_launcher_resource_set(tzsh_srv->ec, res);
4481 _tzsh_srv_taskbar_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4483 wl_resource_destroy(resource);
4487 _tzsh_srv_taskbar_cb_place_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t place_type)
4489 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4492 tzsh_srv = wl_resource_get_user_data(resource);
4493 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4494 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4497 EINA_SAFETY_ON_NULL_RETURN(ec);
4499 e_service_taskbar_place_type_set(ec, place_type);
4503 _tzsh_srv_taskbar_cb_size_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t width, uint32_t height)
4505 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4508 tzsh_srv = wl_resource_get_user_data(resource);
4509 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4510 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4513 EINA_SAFETY_ON_NULL_RETURN(ec);
4515 e_service_taskbar_size_set(ec, width, height);
4519 _tzsh_srv_taskbar_cb_auto_placement_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t auto_placement)
4521 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4524 tzsh_srv = wl_resource_get_user_data(resource);
4525 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4526 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4529 EINA_SAFETY_ON_NULL_RETURN(ec);
4531 e_service_taskbar_auto_placement_set(ec, auto_placement);
4534 static const struct tws_service_taskbar_interface _tzsh_srv_taskbar_iface =
4536 _tzsh_srv_taskbar_cb_destroy,
4537 _tzsh_srv_taskbar_cb_place_type_set,
4538 _tzsh_srv_taskbar_cb_size_set,
4539 _tzsh_srv_taskbar_cb_auto_placement_set,
4543 _tzsh_srv_iface_cb_taskbar_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4545 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4546 struct wl_resource *res;
4548 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4549 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4550 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4552 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4555 res = wl_resource_create(client,
4556 &tws_service_taskbar_interface,
4561 wl_client_post_no_memory(client);
4565 wl_resource_set_implementation(res, &_tzsh_srv_taskbar_iface, tzsh_srv, NULL);
4569 _tzsh_srv_kvm_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4571 wl_resource_destroy(resource);
4575 _tzsh_srv_kvm_cb_perform_drop(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4577 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4580 tzsh_srv = wl_resource_get_user_data(resource);
4581 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4584 EINA_SAFETY_ON_NULL_RETURN(ec);
4586 if (!e_comp_wl->drag) return;
4588 e_service_kvm_drop_perform(ec);
4592 _tzsh_srv_kvm_cb_cancel_drag(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4594 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4597 tzsh_srv = wl_resource_get_user_data(resource);
4598 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4601 EINA_SAFETY_ON_NULL_RETURN(ec);
4603 if (!e_comp_wl->drag) return;
4605 e_service_kvm_drag_cancel(ec);
4609 _tzsh_srv_kvm_cb_perform_drag_enter(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4611 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4614 tzsh_srv = wl_resource_get_user_data(resource);
4615 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4618 EINA_SAFETY_ON_NULL_RETURN(ec);
4620 if (!e_comp_wl->drag) return;
4622 e_service_kvm_perform_drag_enter(ec);
4626 _tzsh_srv_kvm_cb_perform_drag_leave(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4628 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4631 tzsh_srv = wl_resource_get_user_data(resource);
4632 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4635 EINA_SAFETY_ON_NULL_RETURN(ec);
4637 if (!e_comp_wl->drag) return;
4639 e_service_kvm_perform_drag_leave(ec);
4643 _tzsh_srv_kvm_cb_secondary_selection_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4645 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4648 tzsh_srv = wl_resource_get_user_data(resource);
4649 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4652 EINA_SAFETY_ON_NULL_RETURN(ec);
4654 e_service_kvm_secondary_selection_set(ec, EINA_TRUE);
4658 _tzsh_srv_kvm_cb_secondary_selection_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4660 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4663 tzsh_srv = wl_resource_get_user_data(resource);
4664 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4667 EINA_SAFETY_ON_NULL_RETURN(ec);
4669 e_service_kvm_secondary_selection_set(ec, EINA_FALSE);
4672 static const struct tws_service_kvm_interface _tzsh_srv_kvm_iface =
4674 _tzsh_srv_kvm_cb_destroy,
4675 _tzsh_srv_kvm_cb_perform_drop,
4676 _tzsh_srv_kvm_cb_cancel_drag,
4677 _tzsh_srv_kvm_cb_perform_drag_enter,
4678 _tzsh_srv_kvm_cb_perform_drag_leave,
4679 _tzsh_srv_kvm_cb_secondary_selection_set,
4680 _tzsh_srv_kvm_cb_secondary_selection_unset,
4684 _tzsh_srv_iface_cb_kvm_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4686 E_Service_Kvm *esk = NULL;
4687 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4688 struct wl_resource *res;
4691 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4692 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4693 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4695 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4698 res = wl_resource_create(client,
4699 &tws_service_kvm_interface,
4704 wl_client_post_no_memory(client);
4708 ELOGF("KVM", "multi control resource created, res:%p, tzsh_srv:%p, res_tzsh_srv:%p", NULL, res, tzsh_srv, res_tzsh_srv);
4712 esk = e_service_kvm_service_get(ec);
4716 ELOGF("KVM", "multi control resource set. res:%p, service:%p, ec:%p", NULL, res, esk, ec);
4717 e_service_kvm_wl_resource_set(esk, res);
4720 wl_resource_set_implementation(res, &_tzsh_srv_kvm_iface, tzsh_srv, NULL);
4723 static const struct tws_service_interface _tzsh_srv_iface =
4725 _tzsh_srv_iface_cb_destroy,
4726 _tzsh_srv_iface_cb_region_set,
4727 _tzsh_srv_iface_cb_indicator_get,
4728 _tzsh_srv_iface_cb_quickpanel_get,
4729 _tzsh_srv_iface_cb_scrsaver_mng_get,
4730 _tzsh_srv_iface_cb_scrsaver_get,
4731 _tzsh_srv_iface_cb_cbhm_get,
4732 _tzsh_srv_iface_cb_softkey_get,
4733 _tzsh_srv_iface_cb_magnifier_get,
4734 _tzsh_srv_iface_cb_launcher_get,
4735 _tzsh_srv_iface_cb_taskbar_get,
4736 _tzsh_srv_iface_cb_kvm_get,
4740 _e_policy_wl_tzsh_service_check_privilege(struct wl_client *client, int role)
4742 const char *privilege;
4749 case TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT:
4750 case TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU:
4751 case TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU:
4752 privilege = E_PRIVILEGE_QUICKPANEL_SERVICE;
4754 case TZSH_SRV_ROLE_VOLUME:
4755 privilege = E_PRIVILEGE_VOLUME_SERVICE;
4757 case TZSH_SRV_ROLE_LOCKSCREEN:
4758 privilege = E_PRIVILEGE_LOCKSCREEN_SERVICE;
4760 case TZSH_SRV_ROLE_INDICATOR:
4761 privilege = E_PRIVILEGE_INDICATOR_SERVICE;
4763 case TZSH_SRV_ROLE_SCREENSAVER_MNG:
4764 case TZSH_SRV_ROLE_SCREENSAVER:
4765 privilege = E_PRIVILEGE_SCREENSAVER_SERVICE;
4767 case TZSH_SRV_ROLE_CBHM:
4768 privilege = E_PRIVILEGE_CBHM_SERVICE;
4770 case TZSH_SRV_ROLE_SOFTKEY:
4771 privilege = E_PRIVILEGE_SOFTKEY_SERVICE;
4773 case TZSH_SRV_ROLE_MAGNIFIER:
4774 privilege = E_PRIVILEGE_MAGNIFIER_SERVICE;
4776 case TZSH_SRV_ROLE_LAUNCHER:
4777 privilege = E_PRIVILEGE_LAUNCHER_SERVICE;
4779 case TZSH_SRV_ROLE_TASKBAR:
4780 privilege = E_PRIVILEGE_TASKBAR_SERVICE;
4782 /* TODO: need to check privilege
4783 case TZSH_SRV_ROLE_KVM:
4784 privilege = E_PRIVILEGE_KVM_SERVICE;
4791 wl_client_get_credentials(client, &pid, &uid, NULL);
4792 res = e_security_privilege_check(pid,
4799 _tzsh_cb_srv_destroy(struct wl_resource *res_tzsh_srv)
4801 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4803 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4804 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4806 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4809 _e_policy_wl_tzsh_srv_del(tzsh_srv);
4813 _tzsh_iface_cb_srv_create(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id, const char *name)
4815 E_Policy_Wl_Tzsh *tzsh;
4816 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4817 struct wl_resource *res_tzsh_srv;
4823 role = _e_policy_wl_tzsh_srv_role_get(name);
4824 if (role == TZSH_SRV_ROLE_UNKNOWN)
4826 wl_resource_post_error
4828 WL_DISPLAY_ERROR_INVALID_OBJECT,
4829 "Invalid res_tzsh");
4833 /* check whether client has a privilege */
4834 res = _e_policy_wl_tzsh_service_check_privilege(client, role);
4837 ERR("Could not get privilege of resource: %m");
4838 tizen_ws_shell_send_error(res_tzsh,
4839 TIZEN_WS_SHELL_ERROR_PERMISSION_DENIED);
4843 /* to avoid sending a wayland error after tzsh ERROR_NONE for every cases
4844 * such as invalid object or no memory error, tzsh ERROR_NONE should be sent
4845 * first to clients without privilege problem.
4847 tizen_ws_shell_send_error(res_tzsh, TIZEN_WS_SHELL_ERROR_NONE);
4849 tzsh = wl_resource_get_user_data(res_tzsh);
4852 wl_resource_post_error
4854 WL_DISPLAY_ERROR_INVALID_OBJECT,
4855 "Invalid res_tzsh's user data");
4859 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
4862 if (role == TZSH_SRV_ROLE_INDICATOR)
4863 cp = e_pixmap_new(E_PIXMAP_TYPE_NONE, 0);
4867 wl_resource_post_error
4869 WL_DISPLAY_ERROR_INVALID_OBJECT,
4870 "Invalid surface id");
4875 ec = e_pixmap_client_get(cp);
4878 if (role == TZSH_SRV_ROLE_INDICATOR)
4880 ec = e_client_new(cp, 0, 1);
4881 if (ec) ec->ignored = 1;
4887 if (!_e_policy_wl_e_client_is_valid(ec))
4889 wl_resource_post_error
4891 WL_DISPLAY_ERROR_INVALID_OBJECT,
4892 "Invalid surface id");
4897 res_tzsh_srv = wl_resource_create(client,
4898 &tws_service_interface,
4899 wl_resource_get_version(res_tzsh),
4903 ERR("Could not create tws_service resource: %m");
4904 wl_client_post_no_memory(client);
4908 tzsh_srv = _e_policy_wl_tzsh_srv_add(tzsh,
4916 ERR("Could not create WS_Shell_Service");
4917 wl_client_post_no_memory(client);
4918 wl_resource_destroy(res_tzsh_srv);
4922 wl_resource_set_implementation(res_tzsh_srv,
4925 _tzsh_cb_srv_destroy);
4927 if (tzsh_srv->ec && tzsh_srv->ec->maximized)
4929 tzsh_srv->ec->maximize_type = E_MAXIMIZE_TYPE_FULLSCREEN;
4930 e_client_maximize(tzsh_srv->ec, tzsh_srv->ec->maximize_type | E_MAXIMIZE_BOTH);
4933 if (role == TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT)
4934 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_SYSTEM_DEFAULT);
4935 else if (role == TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU)
4936 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_CONTEXT_MENU);
4937 else if (role == TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU)
4938 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_APPS_MENU);
4939 else if (role == TZSH_SRV_ROLE_VOLUME)
4940 e_service_volume_client_set(tzsh_srv->ec);
4941 else if (role == TZSH_SRV_ROLE_LOCKSCREEN)
4942 e_service_lockscreen_client_set(tzsh_srv->ec);
4943 else if (role == TZSH_SRV_ROLE_SCREENSAVER_MNG)
4944 e_service_scrsaver_client_set(tzsh_srv->ec);
4945 else if (role == TZSH_SRV_ROLE_SCREENSAVER)
4946 e_service_scrsaver_client_set(tzsh_srv->ec);
4947 else if (role == TZSH_SRV_ROLE_INDICATOR)
4948 e_mod_indicator_client_set(tzsh_srv->ec);
4949 else if (role == TZSH_SRV_ROLE_CBHM)
4950 e_service_cbhm_client_set(tzsh_srv->ec);
4951 else if (role == TZSH_SRV_ROLE_SOFTKEY)
4952 e_service_softkey_client_set(tzsh_srv->ec);
4953 else if (role == TZSH_SRV_ROLE_MAGNIFIER)
4956 e_magnifier_owner_set(tzsh_srv->ec);
4958 else if (role == TZSH_SRV_ROLE_LAUNCHER)
4959 e_service_launcher_client_set(tzsh_srv->ec);
4960 else if (role == TZSH_SRV_ROLE_TASKBAR)
4961 e_service_taskbar_client_set(tzsh_srv->ec);
4962 else if (role == TZSH_SRV_ROLE_KVM)
4963 e_service_kvm_client_set(tzsh_srv->ec);
4965 e_client_desk_iconify_skip_set(tzsh_srv->ec, EINA_TRUE);
4968 // --------------------------------------------------------
4969 // tizen_ws_shell common
4970 // --------------------------------------------------------
4972 e_tzsh_extension_add(const char *name, E_Policy_Wl_Tzsh_Ext_Hook_Cb cb)
4974 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
4976 if (_e_policy_wl_tzsh_extension_get(name))
4978 ERR("Already exists the %s extension\n", name);
4982 tzsh_ext = E_NEW(E_Policy_Wl_Tzsh_Extension, 1);
4983 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_ext, EINA_FALSE);
4985 tzsh_ext->name = strndup(name, 512);
4988 polwl->tzsh_extensions = eina_list_append(polwl->tzsh_extensions, tzsh_ext);
4990 "EXTENSION_ADD | name:%s | cb:%p",
4998 e_tzsh_extension_del(const char *name)
5000 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5002 tzsh_ext = _e_policy_wl_tzsh_extension_get(name);
5005 ERR("Cannot find the %s extension\n", name);
5009 polwl->tzsh_extensions = eina_list_remove(polwl->tzsh_extensions, tzsh_ext);
5010 memset(tzsh_ext, 0x0, sizeof(E_Policy_Wl_Tzsh_Extension));
5014 "EXTENSION_DEL | name:%s",
5019 // --------------------------------------------------------
5020 // tizen_ws_shell_interface::region
5021 // --------------------------------------------------------
5023 _tzsh_reg_cb_shell_destroy(struct wl_listener *listener, void *data)
5025 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5027 tzsh_reg = container_of(listener, E_Policy_Wl_Tzsh_Region, destroy_listener);
5028 if (tzsh_reg->destroy_listener.notify)
5030 wl_list_remove(&tzsh_reg->destroy_listener.link);
5031 tzsh_reg->destroy_listener.notify = NULL;
5034 if (tzsh_reg->res_tzsh_reg)
5036 wl_resource_destroy(tzsh_reg->res_tzsh_reg);
5037 tzsh_reg->res_tzsh_reg = NULL;
5042 _tzsh_reg_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_reg)
5044 wl_resource_destroy(res_tzsh_reg);
5048 _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)
5050 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5052 int area_w = 0, area_h = 0;
5054 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5055 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5056 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg->tiler);
5058 eina_tiler_area_size_get(tzsh_reg->tiler, &area_w, &area_h);
5059 src = eina_tiler_new(area_w, area_h);
5060 eina_tiler_tile_size_set(src, 1, 1);
5061 eina_tiler_rect_add(src, &(Eina_Rectangle){x, y, w, h});
5062 eina_tiler_union(tzsh_reg->tiler, src);
5063 eina_tiler_free(src);
5067 _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)
5069 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5071 int area_w = 0, area_h = 0;
5073 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5074 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5075 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg->tiler);
5077 eina_tiler_area_size_get(tzsh_reg->tiler, &area_w, &area_h);
5078 src = eina_tiler_new(area_w, area_h);
5079 eina_tiler_tile_size_set(src, 1, 1);
5080 eina_tiler_rect_add(src, &(Eina_Rectangle){x, y, w, h});
5081 eina_tiler_subtract(tzsh_reg->tiler, src);
5082 eina_tiler_free(src);
5085 static const struct tws_region_interface _tzsh_reg_iface =
5087 _tzsh_reg_iface_cb_destroy,
5088 _tzsh_reg_iface_cb_add,
5089 _tzsh_reg_iface_cb_subtract
5093 _tzsh_reg_cb_destroy(struct wl_resource *res_tzsh_reg)
5095 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5097 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5098 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5100 if (tzsh_reg->destroy_listener.notify)
5102 wl_list_remove(&tzsh_reg->destroy_listener.link);
5103 tzsh_reg->destroy_listener.notify = NULL;
5105 eina_tiler_free(tzsh_reg->tiler);
5111 _tzsh_iface_cb_reg_create(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id)
5113 E_Policy_Wl_Tzsh *tzsh;
5114 E_Policy_Wl_Tzsh_Region *tzsh_reg = NULL;
5115 Eina_Tiler *tz = NULL;
5116 struct wl_resource *res_tzsh_reg;
5119 tzsh = wl_resource_get_user_data(res_tzsh);
5122 wl_resource_post_error
5124 WL_DISPLAY_ERROR_INVALID_OBJECT,
5125 "Invalid res_tzsh's user data");
5129 tzsh_reg = E_NEW(E_Policy_Wl_Tzsh_Region, 1);
5130 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5132 e_zone_useful_geometry_get(e_zone_current_get(),
5133 NULL, NULL, &zw, &zh);
5135 tz = eina_tiler_new(zw, zh);
5136 EINA_SAFETY_ON_NULL_GOTO(tz, err);
5137 tzsh_reg->tiler = tz;
5139 eina_tiler_tile_size_set(tzsh_reg->tiler, 1, 1);
5141 if (!(res_tzsh_reg = wl_resource_create(client,
5142 &tws_region_interface,
5143 wl_resource_get_version(res_tzsh),
5146 ERR("Could not create tws_service resource: %m");
5147 wl_client_post_no_memory(client);
5151 wl_resource_set_implementation(res_tzsh_reg,
5154 _tzsh_reg_cb_destroy);
5156 tzsh_reg->tzsh = tzsh;
5157 tzsh_reg->res_tzsh_reg = res_tzsh_reg;
5158 tzsh_reg->destroy_listener.notify = _tzsh_reg_cb_shell_destroy;
5160 wl_resource_add_destroy_listener(res_tzsh,
5161 &tzsh_reg->destroy_listener);
5165 if (tzsh_reg->tiler) eina_tiler_free(tzsh_reg->tiler);
5169 // --------------------------------------------------------
5170 // tizen_ws_shell_interface::indicator
5171 // --------------------------------------------------------
5173 _e_tzsh_indicator_find_topvisible_client(E_Zone *zone)
5179 o = evas_object_top_get(e_comp->evas);
5180 for (; o; o = evas_object_below_get(o))
5182 ec = evas_object_data_get(o, "E_Client");
5184 /* check e_client and skip e_clients not intersects with zone */
5186 if (e_object_is_del(E_OBJECT(ec))) continue;
5187 if (e_client_util_ignored_get(ec)) continue;
5188 if (!e_zone_has_ec(zone, ec)) continue;
5189 if (!ec->frame) continue;
5191 if (!ec->visible) continue;
5192 if (ec->visibility.skip) continue;
5193 if ((ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) &&
5194 (ec->visibility.obscured != E_VISIBILITY_PARTIALLY_OBSCURED) &&
5195 (!eina_list_data_find(e_comp->launchscrns, ec)))
5198 if (e_comp_wl_subsurface_check(ec)) continue;
5200 e_client_geometry_get(ec, &ex, &ey, &ew, &eh);
5201 if (!E_CONTAINS(ex, ey, ew, eh, zone->x, zone->y, zone->w, zone->h))
5212 e_tzsh_indicator_srv_property_change_send(E_Client *ec, int angle)
5217 if (!_indicator_srv_res)
5219 ELOGF("TZ_IND", "NO indicator service", NULL);
5223 opacity = ec->indicator.opacity_mode;
5225 ELOGF("TZ_IND", "SEND indicator info. angle:%d, opacity:%d", ec, angle, opacity);
5226 tws_service_indicator_send_property_change(_indicator_srv_res, angle, opacity);
5230 e_tzsh_indicator_srv_property_update(E_Client *ec)
5232 E_Client *ec_ind_owner;
5233 if (!_indicator_srv_res) return;
5235 ec_ind_owner = e_mod_indicator_owner_get();
5236 if (ec != ec_ind_owner) return;
5238 if (ec->e.state.rot.ang.next != -1)
5239 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.next);
5241 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.curr);
5245 e_tzsh_indicator_srv_ower_win_update(E_Zone *zone)
5247 E_Client *ec = NULL;
5248 E_Client *ec_cur_owner = NULL;
5251 if (!_indicator_srv_res) return;
5253 ec_cur_owner = e_mod_indicator_owner_get();
5254 ec = _e_tzsh_indicator_find_topvisible_client(zone);
5256 if (ec != ec_cur_owner)
5258 ELOGF("TZ_IND", "Changed OWNER. win:%zx, state:%d, opacity:%d, vtype:%d", NULL, e_client_util_win_get(ec),
5259 ec ? ec->indicator.state:-1, ec ? ec->indicator.opacity_mode:-1, ec ? ec->indicator.visible_type:-1);
5260 e_mod_indicator_owner_set(ec);
5262 if (ec && !ec->e.state.rot.pending_show)
5264 ELOGF("TZ_IND", "Property Update. name:%s curr:%d, next:%d", NULL, ec->icccm.name?:"NULL",
5265 ec->e.state.rot.ang.curr, ec->e.state.rot.ang.next);
5266 e_tzsh_indicator_srv_property_update(ec);
5271 // --------------------------------------------------------
5272 // tizen_ws_shell_interface::quickpanel
5273 // --------------------------------------------------------
5275 _tzsh_client_data_quickpanel_type_set(E_Policy_Wl_Tzsh_Client_Data_Quickpanel *quickpanel_client, E_Quickpanel_Type type)
5277 if (quickpanel_client)
5278 quickpanel_client->type = type;
5281 static E_Quickpanel_Type
5282 _tzsh_client_data_quickpanel_type_get(E_Policy_Wl_Tzsh_Client_Data_Quickpanel *quickpanel_client)
5284 if (!quickpanel_client)
5285 return E_QUICKPANEL_TYPE_UNKNOWN;
5287 return quickpanel_client->type;
5291 _e_tzsh_qp_state_change_send(struct wl_resource *res_tzsh_client, int type, int value)
5293 struct wl_array states;
5294 E_Tzsh_QP_Event *ev;
5296 if (!res_tzsh_client) return;
5298 wl_array_init(&states);
5299 ev = wl_array_add(&states, sizeof(E_Tzsh_QP_Event));
5305 tws_quickpanel_send_state_changed(res_tzsh_client, &states);
5307 wl_array_release(&states);
5311 _e_tzsh_qp_client_data_type_check(E_Policy_Wl_Tzsh_Client *tzsh_client, E_Quickpanel_Type type)
5313 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5318 if (tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL)
5321 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5322 if (!tzsh_client_quickpanel)
5325 if (_tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel) != type)
5332 e_tzsh_qp_state_visible_update(E_Client *ec, Eina_Bool vis, E_Quickpanel_Type type)
5334 E_Policy_Wl_Tzsh_Client *tzsh_client;
5339 if (e_object_is_del(E_OBJECT(ec))) return;
5341 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5343 /* check for type of qp */
5344 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5346 if (!tzsh_client->tzsh) continue;
5347 if (!tzsh_client->ec) continue;
5349 if (tzsh_client->ep == ec->pixmap)
5351 if (tzsh_client->ec != ec)
5354 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5363 val = vis ? TWS_QUICKPANEL_STATE_VALUE_VISIBLE_SHOW : TWS_QUICKPANEL_STATE_VALUE_VISIBLE_HIDE;
5364 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5365 TWS_QUICKPANEL_STATE_TYPE_VISIBILITY,
5372 e_tzsh_qp_state_scrollable_update(E_Client *ec, Eina_Bool scrollable, E_Quickpanel_Type type)
5374 E_Policy_Wl_Tzsh_Client *tzsh_client;
5379 if (e_object_is_del(E_OBJECT(ec))) return;
5381 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5383 /* check for type of qp */
5384 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5386 if (!tzsh_client->tzsh) continue;
5387 if (!tzsh_client->ec) continue;
5389 if (tzsh_client->ep == ec->pixmap)
5391 if (tzsh_client->ec != ec)
5394 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5403 val = scrollable ? TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET : TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET;
5404 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5405 TWS_QUICKPANEL_STATE_TYPE_SCROLLABLE,
5412 e_tzsh_qp_state_orientation_update(E_Client *ec, int ridx, E_Quickpanel_Type type)
5414 E_Policy_Wl_Tzsh_Client *tzsh_client;
5419 if (e_object_is_del(E_OBJECT(ec))) return;
5421 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5423 /* check for type of qp */
5424 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5426 if (!tzsh_client->tzsh) continue;
5427 if (!tzsh_client->ec) continue;
5429 if (tzsh_client->ep == ec->pixmap)
5431 if (tzsh_client->ec != ec)
5434 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5443 val = TWS_QUICKPANEL_STATE_VALUE_ORIENTATION_0 + ridx;
5444 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5445 TWS_QUICKPANEL_STATE_TYPE_ORIENTATION,
5452 _tzsh_qp_iface_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5454 wl_resource_destroy(res_tzsh_qp);
5457 static E_Quickpanel_Type
5458 _e_tzsh_qp_type_get(E_Policy_Wl_Tzsh_Client *tzsh_client)
5460 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5461 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5462 if (!tzsh_client_quickpanel)
5463 return E_QUICKPANEL_TYPE_UNKNOWN;
5465 return _tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel);
5470 _tzsh_qp_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5472 E_Policy_Wl_Tzsh_Client *tzsh_client;
5475 ELOGF("TZ_QUICKPANEL", "Request to Show Quickpanel", NULL);
5477 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5478 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5479 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5480 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5481 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5483 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5484 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5486 ec = tzsh_client->ec;
5488 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5491 e_qp_client_show(ec, qp_type);
5495 _tzsh_qp_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5497 E_Policy_Wl_Tzsh_Client *tzsh_client;
5500 ELOGF("TZ_QUICKPANEL", "Request to Hide Quickpanel", NULL);
5502 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5503 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5504 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5505 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5506 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5508 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5509 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5511 ec = tzsh_client->ec;
5513 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5516 e_qp_client_hide(ec, qp_type);
5520 _tzsh_qp_iface_cb_enable(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5522 E_Policy_Wl_Tzsh_Client *tzsh_client;
5525 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state of Quickpanel to 1", NULL);
5527 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5528 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5529 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5530 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5531 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5533 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5534 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5536 ec = tzsh_client->ec;
5538 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5541 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_SET);
5545 _tzsh_qp_iface_cb_disable(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5547 E_Policy_Wl_Tzsh_Client *tzsh_client;
5550 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state of Quickpanel to 0", NULL);
5552 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5553 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5554 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5555 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5556 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5558 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5559 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5561 ec = tzsh_client->ec;
5563 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5566 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET);
5570 _tzsh_qp_iface_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, int32_t type)
5572 E_Policy_Wl_Tzsh_Client *tzsh_client;
5575 E_Quickpanel_Client_Scroll_State scrollable;
5577 int val = TWS_QUICKPANEL_STATE_VALUE_UNKNOWN;
5579 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5580 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5581 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5582 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5583 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5585 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5586 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5588 ec = tzsh_client->ec;
5590 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5595 case TWS_QUICKPANEL_STATE_TYPE_VISIBILITY:
5596 val = TWS_QUICKPANEL_STATE_VALUE_VISIBLE_HIDE;
5597 vis = e_qp_visible_get(ec, qp_type);
5598 if (vis) val = TWS_QUICKPANEL_STATE_VALUE_VISIBLE_SHOW;
5600 case TWS_QUICKPANEL_STATE_TYPE_SCROLLABLE:
5601 scrollable = e_qp_client_scrollable_state_get(ec, qp_type);
5602 if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET)
5603 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET;
5604 else if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_SET)
5605 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET;
5606 else if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_RETAIN)
5607 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_RETAIN;
5609 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET;
5611 case TWS_QUICKPANEL_STATE_TYPE_ORIENTATION:
5612 ridx = e_qp_orientation_get(ec, qp_type);
5613 val = TWS_QUICKPANEL_STATE_VALUE_ORIENTATION_0 + ridx;
5619 tws_quickpanel_send_state_get_done(res_tzsh_qp, type, val, 0);
5623 _tzsh_qp_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, uint32_t type)
5625 E_Policy_Wl_Tzsh_Client *tzsh_client;
5628 ELOGF("TZ_QUICKPANEL", "Request to Set type of Quickpanel to %d", NULL, type);
5630 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5631 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5632 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5633 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5634 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5636 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5637 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5638 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_quickpanel);
5640 E_Quickpanel_Type qp_type = _tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel);
5641 EINA_SAFETY_ON_TRUE_RETURN(qp_type != E_QUICKPANEL_TYPE_UNKNOWN);
5643 _tzsh_client_data_quickpanel_type_set(tzsh_client_quickpanel, type);
5645 ec = tzsh_client->ec;
5647 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5650 /* Since various types of qp are supported, one ec can be used for handler for
5651 * two or more qp types. So e_qp_client_add function is called at the callback
5652 * of qp_type_set, because it is easy to add the E_QP_Client instance after setting
5653 * of qp type is completed.
5655 e_qp_client_add(ec, type);
5659 _tzsh_qp_iface_cb_scrollable_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, int32_t state)
5661 E_Policy_Wl_Tzsh_Client *tzsh_client;
5664 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state to %d", NULL, state);
5666 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5667 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5668 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5669 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5670 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5672 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5673 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5675 ec = tzsh_client->ec;
5676 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5679 if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET)
5680 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET);
5681 else if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET)
5682 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_SET);
5683 else if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_RETAIN)
5684 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_RETAIN);
5687 static const struct tws_quickpanel_interface _tzsh_qp_iface =
5689 _tzsh_qp_iface_cb_release,
5690 _tzsh_qp_iface_cb_show,
5691 _tzsh_qp_iface_cb_hide,
5692 _tzsh_qp_iface_cb_enable,
5693 _tzsh_qp_iface_cb_disable,
5694 _tzsh_qp_iface_cb_state_get,
5695 _tzsh_qp_iface_cb_type_set,
5696 _tzsh_qp_iface_cb_scrollable_state_set
5700 _tzsh_cb_qp_destroy(struct wl_resource *res_tzsh_qp)
5702 E_Policy_Wl_Tzsh_Client *tzsh_client;
5704 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5705 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5707 E_Quickpanel_Type qp_type =
5708 _tzsh_client_data_quickpanel_type_get((E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data);
5709 e_qp_client_del(tzsh_client->ec, qp_type);
5711 E_FREE(tzsh_client->client_data);
5713 tzsh_client->res_tzsh_client = NULL;
5714 _e_policy_wl_tzsh_client_del(tzsh_client);
5717 static E_Policy_Wl_Tzsh_Client_Data_Quickpanel *
5718 _tzsh_client_data_quickpanel_new(void)
5720 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5722 tzsh_client_quickpanel = E_NEW(E_Policy_Wl_Tzsh_Client_Data_Quickpanel, 1);
5723 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client_quickpanel, NULL);
5725 tzsh_client_quickpanel->type = E_QUICKPANEL_TYPE_UNKNOWN;
5726 return tzsh_client_quickpanel;
5730 _tzsh_iface_cb_qp_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id)
5732 E_Policy_Wl_Tzsh *tzsh;
5733 E_Policy_Wl_Tzsh_Client *tzsh_client;
5734 struct wl_resource *res_tzsh_qp;
5738 tzsh = wl_resource_get_user_data(res_tzsh);
5741 wl_resource_post_error
5743 WL_DISPLAY_ERROR_INVALID_OBJECT,
5744 "Invalid res_tzsh's user data");
5748 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
5751 wl_resource_post_error
5753 WL_DISPLAY_ERROR_INVALID_OBJECT,
5754 "Invalid surface id");
5758 ec = e_pixmap_client_get(cp);
5761 if (!_e_policy_wl_e_client_is_valid(ec))
5763 wl_resource_post_error
5765 WL_DISPLAY_ERROR_INVALID_OBJECT,
5766 "Invalid surface id");
5771 res_tzsh_qp = wl_resource_create(client,
5772 &tws_quickpanel_interface,
5773 wl_resource_get_version(res_tzsh),
5777 ERR("Could not create tws_quickpanel resource: %m");
5778 wl_client_post_no_memory(client);
5782 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_qp, cp, ec);
5785 ERR("Could not create tzsh_client");
5786 wl_client_post_no_memory(client);
5790 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL;
5791 tzsh_client->client_data = _tzsh_client_data_quickpanel_new();
5792 if (!tzsh_client->client_data)
5794 ERR("Could not create tzsh_client");
5795 wl_client_post_no_memory(client);
5799 /* Since various types of qp are supported, one ec can be used for handler for
5800 * two or more qp types. So e_qp_client_add function is called at the callback
5801 * of qp_type_set, because it is easy to add the E_QP_Client instance after setting
5802 * of qp type is completed.
5804 //e_qp_client_add(tzsh->ec);
5806 wl_resource_set_implementation(res_tzsh_qp,
5809 _tzsh_cb_qp_destroy);
5812 static void _tzsh_iface_cb_extension_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, const char *name)
5814 E_Policy_Wl_Tzsh *tzsh;
5815 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5816 struct wl_resource *res_ext;
5818 tzsh = wl_resource_get_user_data(res_tzsh);
5821 wl_resource_post_error
5823 WL_DISPLAY_ERROR_INVALID_OBJECT,
5824 "Invalid res_tzsh's user data");
5828 tzsh_ext = _e_policy_wl_tzsh_extension_get(name);
5831 ERR("Could not find tzsh_extension(%s)", name);
5832 wl_resource_post_error
5834 WL_DISPLAY_ERROR_INVALID_OBJECT,
5835 "unregistered ext:%s", name);
5839 res_ext = tzsh_ext->cb(client, res_tzsh, id);
5842 ERR("Could not create extension(%s) resource", name);
5843 wl_resource_post_error
5845 WL_DISPLAY_ERROR_INVALID_OBJECT,
5846 "Unknown error:%s", name);
5851 // --------------------------------------------------------
5852 // tizen_ws_shell_interface::softkey
5853 // --------------------------------------------------------
5855 _tzsh_softkey_iface_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5857 wl_resource_destroy(res_tzsh_softkey);
5861 _tzsh_softkey_iface_cb_support_check(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5863 E_Policy_Wl_Tzsh_Client *tzsh_client;
5866 ELOGF("TZ_SOFTKEY", "Request to Check supporting softkey", NULL);
5868 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
5869 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5870 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5871 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5873 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5876 if (e_config->use_softkey || e_config->use_softkey_service)
5881 ELOGF("TZ_SOFTKEY", "Send SUPPORT_CHECK_DONE. support:%d", NULL, support);
5882 tws_softkey_send_support_check_done(res_tzsh_softkey, support);
5886 _tzsh_softkey_show(E_Policy_Wl_Tzsh_Client *tzsh_client)
5891 zone = tzsh_client->zone;
5893 ec = tzsh_client->ec;
5896 if (e_config->use_softkey)
5898 E_Policy_Softkey *softkey;
5899 softkey = e_policy_softkey_get(zone);
5902 ELOGF("TZ_SOFTKEY", "SHOW softkey", ec);
5903 e_policy_softkey_show(softkey);
5907 if (e_config->use_softkey_service)
5909 E_Service_Softkey *softkey_service;
5910 softkey_service = e_service_softkey_get(zone);
5911 if (softkey_service)
5913 ELOGF("TZ_SOFTKEY", "Request to SHOW softkey service. (service:%p)", ec, softkey_service);
5914 e_service_softkey_visible_set(softkey_service, 1);
5918 ELOGF("TZ_SOFTKEY", "There is no softkey service. store show request", ec);
5919 e_service_softkey_store_visible_request(ec, 1);
5925 _tzsh_softkey_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5927 E_Policy_Wl_Tzsh_Client *tzsh_client;
5929 ELOGF("TZ_SOFTKEY", "Request to Show softkey", NULL);
5931 if (!e_config->use_softkey && !e_config->use_softkey_service)
5934 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
5935 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5936 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5937 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5939 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5942 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
5943 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
5944 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_data_softkey);
5946 if (tzsh_client_data_softkey->show_state == 1)
5949 tzsh_client_data_softkey->show_state = 1;
5950 _tzsh_softkey_show(tzsh_client);
5954 _tzsh_softkey_hide(E_Policy_Wl_Tzsh_Client *tzsh_client)
5959 zone = tzsh_client->zone;
5961 ec = tzsh_client->ec;
5964 if (e_config->use_softkey)
5966 E_Policy_Softkey *softkey;
5967 softkey = e_policy_softkey_get(zone);
5970 ELOGF("TZ_SOFTKEY", "HIDE softkey", NULL);
5971 e_policy_softkey_hide(softkey);
5975 if (e_config->use_softkey_service)
5977 E_Service_Softkey *softkey_service;
5978 softkey_service = e_service_softkey_get(zone);
5979 if (softkey_service)
5981 ELOGF("TZ_SOFTKEY", "Request to HIDE softkey service. (service:%p)", ec, softkey_service);
5982 e_service_softkey_visible_set(softkey_service, 0);
5986 ELOGF("TZ_SOFTKEY", "There is no softkey service. store hide request", ec);
5987 e_service_softkey_store_visible_request(ec, 0);
5993 _tzsh_softkey_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5995 E_Policy_Wl_Tzsh_Client *tzsh_client;
5997 ELOGF("TZ_SOFTKEY", "Request to Hide softkey", NULL);
5999 if (!e_config->use_softkey && !e_config->use_softkey_service)
6002 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6003 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6004 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6005 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6007 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6010 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6011 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
6012 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_data_softkey);
6014 if (tzsh_client_data_softkey->show_state == 0)
6017 tzsh_client_data_softkey->show_state = 0;
6018 _tzsh_softkey_hide(tzsh_client);
6022 _tzsh_softkey_iface_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey, int32_t type, int32_t val)
6024 E_Policy_Wl_Tzsh_Client *tzsh_client;
6025 E_Policy_Softkey_Expand expand;
6026 E_Policy_Softkey_Opacity opacity;
6028 ELOGF("TZ_SOFTKEY", "Request to Set state (tz_type:%d, tz_val:%d)", NULL, type, val);
6030 if (!e_config->use_softkey && !e_config->use_softkey_service)
6033 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6034 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6035 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6036 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6038 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6041 if (e_config->use_softkey)
6043 E_Policy_Softkey *softkey;
6044 softkey = e_policy_softkey_get(tzsh_client->zone);
6045 if (!softkey) return;
6049 case TWS_SOFTKEY_STATE_EXPAND:
6050 if (val == TWS_SOFTKEY_STATE_EXPAND_ON)
6051 expand = E_POLICY_SOFTKEY_EXPAND_ON;
6053 expand = E_POLICY_SOFTKEY_EXPAND_OFF;
6055 ELOGF("TZ_SOFTKEY", "Set EXPAND state to %d", NULL, expand);
6056 e_policy_softkey_expand_set(softkey, expand);
6059 case TWS_SOFTKEY_STATE_OPACITY:
6060 if (val == TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT)
6061 opacity = E_POLICY_SOFTKEY_OPACITY_TRANSPARENT;
6063 opacity = E_POLICY_SOFTKEY_OPACITY_OPAQUE;
6065 ELOGF("TZ_SOFTKEY", "Set OPACITY state to %d", NULL, opacity);
6066 e_policy_softkey_opacity_set(softkey, opacity);
6074 if (e_config->use_softkey_service)
6076 E_Service_Softkey *softkey_service;
6078 softkey_service = e_service_softkey_get(tzsh_client->zone);
6079 if (!softkey_service) return;
6083 case TWS_SOFTKEY_STATE_EXPAND:
6084 if (val == TWS_SOFTKEY_STATE_EXPAND_ON)
6085 expand = E_POLICY_SOFTKEY_EXPAND_ON;
6087 expand = E_POLICY_SOFTKEY_EXPAND_OFF;
6089 ELOGF("TZ_SOFTKEY", "Request to Change EXPAND state to %d. (service:%p)", NULL, expand, softkey_service);
6090 e_service_softkey_expand_set(softkey_service, expand);
6093 case TWS_SOFTKEY_STATE_OPACITY:
6094 if (val == TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT)
6095 opacity = E_POLICY_SOFTKEY_OPACITY_TRANSPARENT;
6097 opacity = E_POLICY_SOFTKEY_OPACITY_OPAQUE;
6099 ELOGF("TZ_SOFTKEY", "Request to Change OPACITY state to %d. (service:%p)", NULL, opacity, softkey_service);
6100 e_service_softkey_opacity_set(softkey_service, opacity);
6110 _tzsh_softkey_iface_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey, int32_t type)
6112 E_Policy_Wl_Tzsh_Client *tzsh_client;
6113 E_Policy_Softkey_Expand expand;
6114 E_Policy_Softkey_Opacity opacity;
6119 ELOGF("TZ_SOFTKEY", "Request to Get state (tz_type:%d)", NULL, type);
6121 if (!e_config->use_softkey && !e_config->use_softkey_service)
6124 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6125 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6126 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6127 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6128 zone = tzsh_client->zone;
6129 EINA_SAFETY_ON_NULL_RETURN(zone);
6131 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6134 if (e_config->use_softkey)
6136 E_Policy_Softkey *softkey;
6137 softkey = e_policy_softkey_get(zone);
6138 if (!softkey) return;
6142 case TWS_SOFTKEY_STATE_VISIBLE:
6143 visible = e_policy_softkey_visible_get(softkey);
6145 val = TWS_SOFTKEY_STATE_VISIBLE_SHOW;
6147 val = TWS_SOFTKEY_STATE_VISIBLE_HIDE;
6149 ELOGF("TZ_SOFTKEY", "Send current VISIBLE state: %d (tz_val:%d)", NULL, visible, val);
6150 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6153 case TWS_SOFTKEY_STATE_EXPAND:
6154 e_policy_softkey_expand_get(softkey, &expand);
6155 if (expand == E_POLICY_SOFTKEY_EXPAND_ON)
6156 val = TWS_SOFTKEY_STATE_EXPAND_ON;
6158 val = TWS_SOFTKEY_STATE_EXPAND_OFF;
6160 ELOGF("TZ_SOFTKEY", "Send current EXPAND state: %d (tz_val:%d)", NULL, expand, val);
6161 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6164 case TWS_SOFTKEY_STATE_OPACITY:
6165 e_policy_softkey_opacity_get(softkey, &opacity);
6166 if (opacity == E_POLICY_SOFTKEY_OPACITY_TRANSPARENT)
6167 val = TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT;
6169 val = TWS_SOFTKEY_STATE_OPACITY_OPAQUE;
6171 ELOGF("TZ_SOFTKEY", "Send current OPACITY state: %d (tz_val:%d)", NULL, opacity, val);
6172 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6180 if (e_config->use_softkey_service)
6182 E_Service_Softkey *softkey_service;
6183 softkey_service = e_service_softkey_get(zone);
6184 if (!softkey_service) return;
6188 case TWS_SOFTKEY_STATE_VISIBLE:
6189 visible = e_service_softkey_visible_get(softkey_service);
6191 val = TWS_SOFTKEY_STATE_VISIBLE_SHOW;
6193 val = TWS_SOFTKEY_STATE_VISIBLE_HIDE;
6195 ELOGF("TZ_SOFTKEY", "Send service's current VISIBLE state: %d (tz_val:%d)", NULL, visible, val);
6196 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6199 case TWS_SOFTKEY_STATE_EXPAND:
6200 e_service_softkey_expand_get(softkey_service, &expand);
6201 if (expand == E_POLICY_SOFTKEY_EXPAND_ON)
6202 val = TWS_SOFTKEY_STATE_EXPAND_ON;
6204 val = TWS_SOFTKEY_STATE_EXPAND_OFF;
6206 ELOGF("TZ_SOFTKEY", "Send service's current EXPAND state: %d (tz_val:%d)", NULL, expand, val);
6207 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6210 case TWS_SOFTKEY_STATE_OPACITY:
6211 e_service_softkey_opacity_get(softkey_service, &opacity);
6212 if (opacity == E_POLICY_SOFTKEY_OPACITY_TRANSPARENT)
6213 val = TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT;
6215 val = TWS_SOFTKEY_STATE_OPACITY_OPAQUE;
6217 ELOGF("TZ_SOFTKEY", "Send service's current OPACITY state: %d (tz_val:%d)", NULL, opacity, val);
6218 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6227 static const struct tws_softkey_interface _tzsh_softkey_iface =
6229 _tzsh_softkey_iface_cb_release,
6230 _tzsh_softkey_iface_cb_support_check,
6231 _tzsh_softkey_iface_cb_show,
6232 _tzsh_softkey_iface_cb_hide,
6233 _tzsh_softkey_iface_cb_state_set,
6234 _tzsh_softkey_iface_cb_state_get
6237 static E_Policy_Wl_Tzsh_Client_Data_Softkey *
6238 _tzsh_client_data_softkey_new(void)
6240 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6242 tzsh_client_data_softkey = E_NEW(E_Policy_Wl_Tzsh_Client_Data_Softkey, 1);
6243 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client_data_softkey, NULL);
6245 tzsh_client_data_softkey->show_state = 1;
6246 return tzsh_client_data_softkey;
6250 _tzsh_cb_softkey_destroy(struct wl_resource *res_tzsh_softkey)
6252 E_Policy_Wl_Tzsh_Client *tzsh_client;
6254 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6255 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6257 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6258 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
6259 if (tzsh_client_data_softkey)
6261 if (tzsh_client_data_softkey->show_state == 0)
6263 ELOGF("TZ_SOFTKEY", "Request to Show softkey by destroying client", NULL);
6264 _tzsh_softkey_show(tzsh_client);
6267 E_FREE(tzsh_client->client_data);
6269 tzsh_client->res_tzsh_client = NULL;
6270 _e_policy_wl_tzsh_client_del(tzsh_client);
6275 _tzsh_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id)
6277 E_Policy_Wl_Tzsh *tzsh;
6278 E_Policy_Wl_Tzsh_Client *tzsh_client;
6279 struct wl_resource *res_tzsh_softkey;
6285 tzsh = wl_resource_get_user_data(res_tzsh);
6288 wl_resource_post_error
6290 WL_DISPLAY_ERROR_INVALID_OBJECT,
6291 "Invalid res_tzsh's user data");
6295 wl_client_get_credentials(client, &pid, &uid, NULL);
6296 if (!e_security_privilege_check(pid, uid, E_PRIVILEGE_SOFTKEY))
6298 ERR("Could not get privilege of resource: %m");
6299 tizen_ws_shell_send_error(tzsh->res_tzsh, TIZEN_WS_SHELL_ERROR_PERMISSION_DENIED);
6303 tizen_ws_shell_send_error(tzsh->res_tzsh, TIZEN_WS_SHELL_ERROR_NONE);
6305 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
6308 wl_resource_post_error
6310 WL_DISPLAY_ERROR_INVALID_OBJECT,
6311 "Invalid surface id");
6315 ec = e_pixmap_client_get(cp);
6318 if (!_e_policy_wl_e_client_is_valid(ec))
6320 wl_resource_post_error
6322 WL_DISPLAY_ERROR_INVALID_OBJECT,
6323 "Invalid surface id");
6328 res_tzsh_softkey = wl_resource_create(client,
6329 &tws_softkey_interface,
6330 wl_resource_get_version(res_tzsh),
6332 if (!res_tzsh_softkey)
6334 ERR("Could not create tws_softkey resource: %m");
6335 wl_client_post_no_memory(client);
6339 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_softkey, cp, ec);
6342 ERR("Could not create tzsh_client");
6343 wl_client_post_no_memory(client);
6347 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_SOFTKEY;
6348 tzsh_client->client_data = _tzsh_client_data_softkey_new();
6349 if (!tzsh_client->client_data)
6351 ERR("Could not create tzsh_client");
6352 _e_policy_wl_tzsh_client_del(tzsh_client);
6353 wl_resource_destroy(res_tzsh_softkey);
6354 wl_client_post_no_memory(client);
6358 wl_resource_set_implementation(res_tzsh_softkey,
6359 &_tzsh_softkey_iface,
6361 _tzsh_cb_softkey_destroy);
6364 // --------------------------------------------------------
6365 // tizen_ws_shell_interface::shared_widget_launch
6366 // --------------------------------------------------------
6368 e_tzsh_shared_widget_launch_prepare_send(E_Client *callee_ec,
6372 E_Policy_Wl_Tzsh_Client *tzsh_client;
6374 Eina_Bool res = EINA_FALSE;
6376 EINA_SAFETY_ON_NULL_RETURN_VAL(callee_ec, EINA_FALSE);
6377 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(callee_ec)), EINA_FALSE);
6379 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
6381 if (!tzsh_client->tzsh) continue;
6382 if (!tzsh_client->ec) continue;
6383 if (tzsh_client->ec != callee_ec) continue;
6385 tws_shared_widget_launch_send_prepare_shared_widget(tzsh_client->res_tzsh_client,
6397 _tzsh_swl_iface_cb_release(struct wl_client *client,
6398 struct wl_resource *res_tzsh_swl)
6400 ELOGF("TZSH_SWL", "Release", NULL);
6402 wl_resource_destroy(res_tzsh_swl);
6406 _tzsh_swl_iface_cb_prepare_shared_widget_done(struct wl_client *client,
6407 struct wl_resource *res_tzsh_swl,
6408 const char *shared_widget_info,
6412 E_Policy_Wl_Tzsh_Client *tzsh_client;
6414 ELOGF("TZSH_SWL", "Done", NULL);
6416 tzsh_client = wl_resource_get_user_data(res_tzsh_swl);
6417 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6418 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6419 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6420 EINA_SAFETY_ON_NULL_RETURN(eina_list_data_find(polwl->tzsh_clients, tzsh_client));
6422 // send prepare event to caller
6423 e_service_launcher_prepare_send_with_shared_widget_info(tzsh_client->ec,
6429 static const struct tws_shared_widget_launch_interface _tzsh_swl_iface =
6431 _tzsh_swl_iface_cb_release,
6432 _tzsh_swl_iface_cb_prepare_shared_widget_done,
6436 _tzsh_cb_swl_destroy(struct wl_resource *res_tzsh_swl)
6438 E_Policy_Wl_Tzsh_Client *tzsh_client;
6440 ELOGF("TZSH_SWL", "Destroy", NULL);
6442 tzsh_client = wl_resource_get_user_data(res_tzsh_swl);
6443 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6445 e_service_launcher_release_shared_widget_launch(tzsh_client->ec);
6447 tzsh_client->res_tzsh_client = NULL;
6448 _e_policy_wl_tzsh_client_del(tzsh_client);
6452 _tzsh_iface_cb_shared_widget_launch_get(struct wl_client *client,
6453 struct wl_resource *res_tzsh,
6457 E_Policy_Wl_Tzsh *tzsh;
6458 E_Policy_Wl_Tzsh_Client *tzsh_client;
6459 struct wl_resource *res_tzsh_swl;
6463 tzsh = wl_resource_get_user_data(res_tzsh);
6466 wl_resource_post_error
6468 WL_DISPLAY_ERROR_INVALID_OBJECT,
6469 "Invalid res_tzsh's user data");
6473 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
6476 wl_resource_post_error
6478 WL_DISPLAY_ERROR_INVALID_OBJECT,
6479 "Invalid surface id");
6483 ec = e_pixmap_client_get(cp);
6486 if (!_e_policy_wl_e_client_is_valid(ec))
6488 wl_resource_post_error
6490 WL_DISPLAY_ERROR_INVALID_OBJECT,
6491 "Invalid surface id");
6496 res_tzsh_swl = wl_resource_create(client,
6497 &tws_shared_widget_launch_interface,
6498 wl_resource_get_version(res_tzsh),
6502 ERR("Could not create tws_shared_widget_launch resource: %m");
6503 wl_client_post_no_memory(client);
6507 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_swl, cp, ec);
6510 ERR("Could not create tzsh_client");
6511 wl_client_post_no_memory(client);
6515 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_SHARED_WIDGET_LAUNCH;
6517 wl_resource_set_implementation(res_tzsh_swl,
6520 _tzsh_cb_swl_destroy);
6523 // --------------------------------------------------------
6524 // tizen_ws_shell_interface
6525 // --------------------------------------------------------
6527 _tzsh_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh)
6529 wl_resource_destroy(res_tzsh);
6532 static const struct tizen_ws_shell_interface _tzsh_iface =
6534 _tzsh_iface_cb_destroy,
6535 _tzsh_iface_cb_srv_create,
6536 _tzsh_iface_cb_reg_create,
6537 _tzsh_iface_cb_qp_get,
6538 _tzsh_iface_cb_extension_get,
6539 _tzsh_iface_cb_softkey_get,
6540 _tzsh_iface_cb_shared_widget_launch_get,
6544 _tzsh_cb_unbind(struct wl_resource *res_tzsh)
6546 E_Policy_Wl_Tzsh *tzsh;
6548 tzsh = wl_resource_get_user_data(res_tzsh);
6549 EINA_SAFETY_ON_NULL_RETURN(tzsh);
6551 _e_policy_wl_tzsh_del(tzsh);
6555 _tzsh_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
6557 E_Policy_Wl_Tzsh *tzsh;
6558 struct wl_resource *res_tzsh;
6560 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
6562 res_tzsh = wl_resource_create(client,
6563 &tizen_ws_shell_interface,
6566 EINA_SAFETY_ON_NULL_GOTO(res_tzsh, err);
6568 tzsh = _e_policy_wl_tzsh_add(res_tzsh);
6569 EINA_SAFETY_ON_NULL_GOTO(tzsh, err);
6571 wl_resource_set_implementation(res_tzsh,
6576 _e_policy_wl_tzsh_registered_srv_send(tzsh);
6580 ERR("Could not create tizen_ws_shell_interface res: %m");
6581 wl_client_post_no_memory(client);
6584 // --------------------------------------------------------
6585 // tizen_launch_effect_interface
6586 // --------------------------------------------------------
6587 #define SPLASH_GROUP_NAME "effect"
6588 #define SPLASH_CONFIG_CUSTOM_EFFECT_CALLEE "_CUSTOM_EFFECT_CALLEE_"
6591 _launch_effect_hide(uint32_t pid)
6594 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
6595 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6597 if(pid <= 0) return;
6599 EINA_LIST_FOREACH(polwl->tzlaunch_effect, l, tzlaunch_effect)
6601 EINA_LIST_FOREACH(tzlaunch_effect->splash_list, ll, tzlaunch_splash)
6602 if (tzlaunch_splash->pid == pid)
6604 _launch_splash_off(tzlaunch_splash);
6610 _launch_effect_client_del(E_Client *ec)
6613 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
6614 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6616 EINA_LIST_FOREACH(polwl->tzlaunch_effect, l, tzlaunch_effect)
6618 EINA_LIST_FOREACH(tzlaunch_effect->splash_list, ll, tzlaunch_splash)
6619 if (tzlaunch_splash->ec == ec)
6621 _launch_splash_off(tzlaunch_splash);
6627 _launchscreen_splash_cb_indicator_resized(Ecore_Evas *ee)
6629 Evas_Coord_Size size = {0, 0};
6630 Evas_Object *indicator_obj;
6631 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6633 tzlaunch_splash = ecore_evas_data_get(ee, "tzlaunch_splash");
6634 if (!tzlaunch_splash) return;
6636 indicator_obj = tzlaunch_splash->indicator_obj;
6638 ecore_evas_geometry_get(ee, NULL, NULL, &(size.w), &(size.h));
6639 ELOGF("TZPOL", "Launchscreen indicator_obj resized(%d x %d)",
6642 evas_object_size_hint_min_set(indicator_obj, size.w, size.h);
6643 evas_object_size_hint_max_set(indicator_obj, size.w, size.h);
6644 e_comp_object_indicator_size_set(tzlaunch_splash->ec->frame, size.w, size.h);
6648 _launchscreen_splash_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6650 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash = data;
6652 if ((tzlaunch_splash) && (tzlaunch_splash->obj == obj))
6653 tzlaunch_splash->obj = NULL;
6657 _launchscreen_splash_cb_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6659 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash = data;
6661 if ((tzlaunch_splash) && (tzlaunch_splash->obj == obj))
6662 _launch_splash_off(tzlaunch_splash);
6666 _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash)
6668 E_Client *ec = NULL;
6669 Evas_Object *obj = NULL;
6671 if (!tzlaunch_splash->valid) return;
6672 if (!tzlaunch_splash->ec) return;
6674 ec = tzlaunch_splash->ec;
6675 obj = tzlaunch_splash->obj;
6677 tzlaunch_splash->obj = NULL;
6678 tzlaunch_splash->ec = NULL;
6679 tzlaunch_splash->valid = EINA_FALSE;
6680 if (tzlaunch_splash->timeout) ecore_timer_del(tzlaunch_splash->timeout);
6681 tzlaunch_splash->timeout = NULL;
6683 eina_stringshare_del(tzlaunch_splash->appid);
6684 tzlaunch_splash->appid = NULL;
6685 eina_stringshare_del(tzlaunch_splash->path);
6686 tzlaunch_splash->path = NULL;
6690 "Launchscreen hide | pid %d, replaced:%d, tzlaunch_pixmap:%p, ec_pixmap:%p",
6691 ec, tzlaunch_splash->pid, tzlaunch_splash->replaced, tzlaunch_splash->ep, ec->pixmap);
6693 if (tzlaunch_splash->indicator_obj)
6695 e_comp_object_indicator_unswallow(ec->frame, tzlaunch_splash->indicator_obj);
6696 evas_object_del(tzlaunch_splash->indicator_obj);
6697 evas_object_unref(tzlaunch_splash->indicator_obj);
6698 tzlaunch_splash->indicator_obj = NULL;
6702 (ec->pixmap == tzlaunch_splash->ep))
6704 /* case 1: Surface for this pid is not created until timeout or
6705 * launchscreen resource is destroied.
6709 ec->visible = EINA_FALSE;
6710 evas_object_hide(ec->frame);
6711 ec->ignored = EINA_TRUE;
6714 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
6716 e_pixmap_win_id_del(tzlaunch_splash->ep);
6717 e_object_del(E_OBJECT(ec));
6723 if (!e_util_strcmp("wl_pointer-cursor", ec->icccm.window_role))
6725 // if Launchscreen is replaced to cursor, than hide
6726 e_comp_object_content_unset(ec->frame);
6727 ec->visible = EINA_FALSE;
6728 evas_object_hide(ec->frame);
6729 ec->ignored = EINA_TRUE;
6731 else if (!tzlaunch_splash->replaced)
6734 e_comp_wl_feed_focus_in(ec);
6736 /* to send launch,done event to launchscreen client */
6737 if (!e_object_is_del(E_OBJECT(ec)))
6739 if (ec->first_mapped)
6741 ELOGF("LAUNCH", "SHOW real win by replaced splash ec", ec);
6742 e_comp_object_signal_emit(ec->frame, "e,action,launch_real,done", "e");
6744 e_comp_object_signal_emit(ec->frame, "e,action,launch,done", "e");
6748 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
6752 evas_object_unref(obj);
6754 tzlaunch_splash->ep = NULL;
6755 tzlaunch_splash->replaced = EINA_FALSE;
6759 _launchscreen_splash_timeout(void *data)
6761 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6762 tzlaunch_splash = (E_Policy_Wl_Tzlaunch_Splash *)data;
6764 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_splash, 0);
6766 _launch_splash_off(tzlaunch_splash);
6768 return ECORE_CALLBACK_CANCEL;
6772 _launchscreen_splash_setup(E_Policy_Wl_Tzlaunch_Splash *splash,
6773 const char *pfname, uint32_t ftype,
6774 uint32_t depth, uint32_t angle,
6775 uint32_t indicator, const char *effect_type,
6776 const char *theme_type, struct wl_array *options,
6777 struct wl_array *extra_config)
6779 E_Client *ec = NULL;
6780 E_Comp_Object_Content_Type content_type = 0;
6781 Eina_Bool intercepted = EINA_FALSE;
6783 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->ec, EINA_FALSE);
6784 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->ec->frame, EINA_FALSE);
6787 ec->effect_type = _e_policy_wl_tzlaunch_effect_type_get(effect_type);
6790 "Launchscreen setup START| path %s(%d), indicator(%d), angle(%d), effect_type(%s), theme_type(%s)",
6791 ec, pfname, ftype, indicator, angle, effect_type, theme_type);
6793 "Launchscreen setup | options %p extra_config:%p",
6794 ec, options, extra_config);
6796 splash->path = eina_stringshare_add(pfname);
6797 splash->type = ftype;
6798 splash->indicator = indicator;
6799 splash->angle = angle;
6803 /* To configure indicator options */
6804 ec->indicator.state = TIZEN_INDICATOR_STATE_ON;
6805 ec->indicator.visible_type = TIZEN_INDICATOR_VISIBLE_TYPE_SHOWN;
6806 ec->indicator.opacity_mode = TIZEN_INDICATOR_OPACITY_MODE_BG_TRANSPARENT;
6809 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_LAUNCHSCREEN_OBJECT_SETUP,
6811 pfname, ftype, depth,
6812 angle, indicator, options);
6815 splash->obj = e_comp_object_content_get(ec->frame);
6818 "Launchscreen setup | was INTERCEPTED : content(%p)",
6821 else //Do original setup process
6823 if (splash->type == LAUNCH_IMG_FILE_TYPE_IMAGE)
6825 Evas_Load_Error err;
6827 content_type = E_COMP_OBJECT_CONTENT_TYPE_EXT_IMAGE;
6828 splash->obj = evas_object_image_add(e_comp->evas);
6829 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->obj, EINA_FALSE);
6831 evas_object_image_file_set(splash->obj, splash->path, NULL);
6833 err = evas_object_image_load_error_get(splash->obj);
6834 if (err != EVAS_LOAD_ERROR_NONE)
6837 "Launchscreen setup | fail to load image %s : %s",
6838 ec, splash->path, evas_load_error_str(err));
6839 evas_object_del(splash->obj);
6844 evas_object_image_fill_set(splash->obj, 0, 0, e_comp->w, e_comp->h);
6845 evas_object_image_filled_set(splash->obj, EINA_TRUE);
6849 content_type = E_COMP_OBJECT_CONTENT_TYPE_EXT_EDJE;
6850 splash->obj = edje_object_add(e_comp->evas);
6851 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->obj, EINA_FALSE);
6853 if (!edje_object_file_set(splash->obj, splash->path, SPLASH_GROUP_NAME))
6855 Edje_Load_Error err;
6857 err = edje_object_load_error_get(splash->obj);
6859 "Launchscreen setup | fail to load edje %s : %s",
6860 ec, splash->path, edje_load_error_str(err));
6861 evas_object_del(splash->obj);
6867 evas_object_move(splash->obj, 0, 0);
6868 evas_object_resize(splash->obj, e_comp->w, e_comp->h);
6871 if (depth == 32) ec->argb = EINA_TRUE;
6872 else ec->argb = EINA_FALSE;
6873 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6875 //set splash->obj to a content of ec->frame
6876 if (!e_comp_object_content_set(ec->frame, splash->obj, content_type))
6878 ERR("Launchscreen setup | setting comp object content failed ec(%p) obj(%p)",
6885 /* Post job of setup content_type */
6887 //Parse extra config
6888 if ((extra_config) && (extra_config->size))
6892 int size = extra_config->size;
6896 p_char = extra_config->data + len;
6897 len = strlen(p_char) + 1;
6900 if (!e_util_strcmp(p_char, SPLASH_CONFIG_CUSTOM_EFFECT_CALLEE))
6902 //parse next data(appid) from array
6905 p_char = p_char + len;
6906 len = strlen(p_char) + 1;
6909 splash->appid = eina_stringshare_add(p_char);
6910 splash->custom_effect_callee = EINA_TRUE;
6913 "Launchscreen setup | custom effect callee set appid(%s)",
6924 Evas_Object *indicator_obj = NULL;
6925 Eina_Bool ret = EINA_FALSE;
6927 e_mod_indicator_owner_set(ec);
6928 e_tzsh_indicator_srv_property_update(ec);
6930 indicator_obj = ecore_evas_extn_plug_new(e_comp->ee);
6934 "Launchscreen setup | Failed to create ecore_evas_plug for indicator",
6939 if (e_config->indicator_plug_name)
6941 ret = ecore_evas_extn_plug_connect(indicator_obj, e_config->indicator_plug_name, 0, EINA_FALSE);
6946 ee = ecore_evas_object_ecore_evas_get(indicator_obj);
6947 ecore_evas_data_set(ee, "tzlaunch_splash", splash);
6948 ecore_evas_callback_resize_set(ee,
6949 _launchscreen_splash_cb_indicator_resized);
6950 e_comp_object_indicator_swallow(ec->frame, indicator_obj);
6951 evas_object_ref(indicator_obj);
6953 "Launchscreen launch | Succeeded to add indicator object plug_name(%s) indicator_obj(%p)",
6954 ec, e_config->indicator_plug_name, indicator_obj);
6958 evas_object_del(indicator_obj);
6959 indicator_obj = NULL;
6966 "Launchscreen launch | Failed to add indicator object plug_name(%s)",
6967 ec, e_config->indicator_plug_name?:"NO PLUG NAME");
6971 splash->indicator_obj = indicator_obj;
6977 evas_object_ref(splash->obj);
6979 evas_object_event_callback_add(splash->obj,
6981 _launchscreen_splash_cb_del, splash);
6982 evas_object_event_callback_add(splash->obj,
6984 _launchscreen_splash_cb_hide, splash);
6987 splash->valid = EINA_TRUE;
6988 splash->content_type = e_comp_object_content_type_get(ec->frame);
6994 _tzlaunch_splash_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash)
6996 wl_resource_destroy(res_tzlaunch_splash);
7000 _tzlaunch_splash_iface_cb_launch(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash,
7001 const char *pfname, uint32_t ftype,
7002 uint32_t depth, uint32_t angle,
7003 uint32_t indicator, const char *effect_type,
7004 const char *theme_type, struct wl_array *options)
7006 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7007 Eina_Bool res = EINA_FALSE;
7009 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7010 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7012 ELOGF("TZPOL","Launchscreen launch | START", NULL);
7015 res = _launchscreen_splash_setup(tzlaunch_splash,
7018 indicator, effect_type,
7019 theme_type, options, NULL);
7021 ELOGF("TZPOL","Launchscreen launch | END res:%d ", NULL, res);
7025 ERR("Launchscreen launch | Could not complete %s", __FUNCTION__);
7026 if (tzlaunch_splash->obj)
7028 evas_object_del(tzlaunch_splash->obj);
7029 tzlaunch_splash->obj = NULL;
7035 _tzlaunch_splash_iface_cb_owner(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash, uint32_t pid)
7037 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7038 E_Client *pre_ec = NULL, *new_ec = NULL, *old_ec;
7039 Eina_List *clients, *l;
7042 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7043 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7044 EINA_SAFETY_ON_FALSE_RETURN(tzlaunch_splash->valid);
7046 /* use ec was already created */
7047 clients = _e_policy_wl_e_clients_find_by_pid(pid);
7048 EINA_LIST_FOREACH(clients, l, pre_ec)
7050 if (pre_ec == tzlaunch_splash->ec) continue;
7051 if (!pre_ec->ignored) continue;
7052 if (pre_ec->is_cursor) continue;
7054 e_client_geometry_get(new_ec, NULL, NULL, &tw, &th);
7055 if (tw <= 1 || th <= 1)
7056 evas_object_resize(new_ec->frame, e_comp->w, e_comp->h);
7059 eina_list_free(clients);
7061 old_ec = tzlaunch_splash->ec;
7064 if (e_comp_object_content_set(new_ec->frame,
7065 tzlaunch_splash->obj,
7066 tzlaunch_splash->content_type))
7068 e_client_unignore(new_ec);
7069 new_ec->visible = EINA_TRUE;
7070 if (new_ec->new_client)
7071 e_comp->new_clients--;
7072 new_ec->new_client = EINA_FALSE;
7073 new_ec->argb = old_ec->argb;
7074 ELOGF("COMP", "Set argb:%d", new_ec, new_ec->argb);
7075 new_ec->effect_type = old_ec->effect_type;
7076 new_ec->use_splash = EINA_TRUE;
7077 new_ec->icccm.title = eina_stringshare_add("launchscreen");
7079 e_comp->launchscrns = eina_list_append(e_comp->launchscrns, new_ec);
7081 if (tzlaunch_splash->custom_effect_callee)
7083 e_service_launcher_callee_register(new_ec, tzlaunch_splash->appid, tzlaunch_splash->path, SPLASH_GROUP_NAME);
7086 evas_object_show(new_ec->frame);
7087 e_client_raise(new_ec);
7089 tzlaunch_splash->ec = new_ec;
7090 tzlaunch_splash->replaced = EINA_TRUE;
7093 "Launchscreen client changed | old(%p) new(%p) using obj(%p)",
7095 old_ec, new_ec, tzlaunch_splash->obj);
7097 if (tzlaunch_splash->indicator_obj)
7099 e_mod_indicator_owner_set(new_ec);
7100 e_tzsh_indicator_srv_property_update(new_ec);
7101 e_comp_object_indicator_unswallow(old_ec->frame, tzlaunch_splash->indicator_obj);
7102 e_comp_object_indicator_swallow(new_ec->frame, tzlaunch_splash->indicator_obj);
7105 /* delete ec was created for launchscreen */
7106 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, old_ec);
7108 e_pixmap_win_id_del(tzlaunch_splash->ep);
7109 e_object_del(E_OBJECT(old_ec));
7110 tzlaunch_splash->ep = NULL;
7113 ERR("Can't set external content for new_ec(%p)", new_ec);
7117 old_ec->ignored = EINA_FALSE;
7118 old_ec->visible = EINA_TRUE;
7119 if (old_ec->new_client)
7120 e_comp->new_clients--;
7121 old_ec->new_client = EINA_FALSE;
7122 old_ec->icccm.accepts_focus = EINA_TRUE;
7124 if (tzlaunch_splash->custom_effect_callee)
7126 e_service_launcher_callee_register(old_ec, tzlaunch_splash->appid, tzlaunch_splash->path, SPLASH_GROUP_NAME);
7129 evas_object_show(old_ec->frame);
7130 e_client_raise(old_ec);
7133 EC_CHANGED(tzlaunch_splash->ec);
7134 e_comp_visibility_calculation_set(EINA_TRUE);
7136 if (tzlaunch_splash->timeout)
7138 ecore_timer_del(tzlaunch_splash->timeout);
7139 tzlaunch_splash->timeout = NULL;
7141 if (!e_config->launchscreen_without_timer)
7142 tzlaunch_splash->timeout = ecore_timer_add(e_config->launchscreen_timeout, _launchscreen_splash_timeout, tzlaunch_splash);
7144 ELOGF("TZPOL", "Launchscreen img(%d) set owner pid: %d",
7145 tzlaunch_splash->ec,
7146 wl_resource_get_id(res_tzlaunch_splash), pid);
7148 tzlaunch_splash->pid = pid;
7149 tzlaunch_splash->ec->netwm.pid = pid;
7150 tzlaunch_splash->ec->use_splash = EINA_TRUE;
7154 _tzlaunch_splash_iface_cb_launch_v2(struct wl_client *client EINA_UNUSED,
7155 struct wl_resource *res_tzlaunch_splash,
7156 const char *pfname, uint32_t ftype,
7157 uint32_t depth, uint32_t angle,
7158 uint32_t indicator, const char *effect_type,
7159 const char *theme_type, struct wl_array *options,
7160 struct wl_array *extra_config)
7162 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7163 Eina_Bool res = EINA_FALSE;
7165 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7166 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7168 ELOGF("TZPOL","Launchscreen launch_v2 | START", NULL);
7170 res = _launchscreen_splash_setup(tzlaunch_splash,
7173 indicator, effect_type,
7174 theme_type, options, extra_config);
7176 ELOGF("TZPOL","Launchscreen launch_v2 | END res:%d ", NULL, res);
7180 ERR("Launchscreen launch_v2 | Could not complete %s", __FUNCTION__);
7181 if (tzlaunch_splash->obj)
7183 evas_object_del(tzlaunch_splash->obj);
7184 tzlaunch_splash->obj = NULL;
7190 static const struct tizen_launch_splash_interface _tzlaunch_splash_iface =
7192 _tzlaunch_splash_iface_cb_destroy,
7193 _tzlaunch_splash_iface_cb_launch,
7194 _tzlaunch_splash_iface_cb_owner,
7195 _tzlaunch_splash_iface_cb_launch_v2,
7198 static E_Policy_Wl_Tzlaunch_Splash *
7199 _tzlaunch_splash_add(struct wl_resource *res_tzlaunch_effect, struct wl_resource *res_tzlaunch_splash)
7201 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7202 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7204 tzlaunch_splash = E_NEW(E_Policy_Wl_Tzlaunch_Splash, 1);
7205 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash, error);
7207 tzlaunch_effect = wl_resource_get_user_data(res_tzlaunch_effect);
7208 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_effect, error);
7210 tzlaunch_effect->splash_list = eina_list_append(tzlaunch_effect->splash_list, tzlaunch_splash);
7212 tzlaunch_splash->tzlaunch_effect = tzlaunch_effect;
7213 tzlaunch_splash->res_tzlaunch_splash = res_tzlaunch_splash;
7215 tzlaunch_splash->replaced = EINA_FALSE;
7216 tzlaunch_splash->ep = e_pixmap_new(E_PIXMAP_TYPE_EXT_OBJECT, 0);
7217 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash->ep, error);
7218 tzlaunch_splash->ec = e_client_new(tzlaunch_splash->ep, 0, 1);
7219 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash->ec, error);
7221 tzlaunch_splash->ec->icccm.title = eina_stringshare_add("Launchscreen");
7222 tzlaunch_splash->ec->icccm.name = eina_stringshare_add("Launchscreen");
7223 tzlaunch_splash->ec->ignored = EINA_TRUE;
7225 e_comp->launchscrns = eina_list_append(e_comp->launchscrns, tzlaunch_splash->ec);
7227 return tzlaunch_splash;
7229 if (tzlaunch_splash)
7231 ERR("Could not initialize launchscreen client");
7232 if (tzlaunch_splash->ep)
7233 e_pixmap_win_id_del(tzlaunch_splash->ep);
7234 if (tzlaunch_splash->ec)
7235 e_object_del(E_OBJECT(tzlaunch_splash->ec));
7236 E_FREE(tzlaunch_splash);
7243 _tzlaunch_splash_destroy(struct wl_resource *res_tzlaunch_splash)
7245 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7246 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7248 EINA_SAFETY_ON_NULL_RETURN(res_tzlaunch_splash);
7250 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7251 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7253 if (tzlaunch_splash->obj)
7255 evas_object_event_callback_del_full(tzlaunch_splash->obj, EVAS_CALLBACK_DEL, _launchscreen_splash_cb_del, tzlaunch_splash);
7256 evas_object_event_callback_del_full(tzlaunch_splash->obj, EVAS_CALLBACK_HIDE, _launchscreen_splash_cb_hide, tzlaunch_splash);
7259 _launch_splash_off(tzlaunch_splash);
7261 tzlaunch_effect = tzlaunch_splash->tzlaunch_effect;
7262 tzlaunch_effect->splash_list = eina_list_remove(tzlaunch_effect->splash_list, tzlaunch_splash);
7264 eina_stringshare_del(tzlaunch_splash->appid);
7265 eina_stringshare_del(tzlaunch_splash->path);
7266 memset(tzlaunch_splash, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Splash));
7267 E_FREE(tzlaunch_splash);
7271 _tzlaunch_effect_iface_cb_create_splash_img(struct wl_client *client, struct wl_resource *res_tzlaunch_effect, uint32_t id)
7274 E_Policy_Wl_Tzlaunch_Splash *plaunch_splash;
7275 struct wl_resource *res_tzlaunch_splash;
7277 res_tzlaunch_splash = wl_resource_create(client,
7278 &tizen_launch_splash_interface,
7279 wl_resource_get_version(res_tzlaunch_effect),
7281 if (!res_tzlaunch_splash)
7283 wl_resource_post_error
7284 (res_tzlaunch_effect,
7285 WL_DISPLAY_ERROR_INVALID_OBJECT,
7286 "Invalid res_tzlaunch effect's user data");
7290 plaunch_splash = _tzlaunch_splash_add(res_tzlaunch_effect, res_tzlaunch_splash);
7291 EINA_SAFETY_ON_NULL_GOTO(plaunch_splash, err);
7293 ELOGF("TZPOL", "Launchscreen effect create splash img. res_tzlaunch_effect:%p, res_tzlaunch_splash:%p", plaunch_splash->ec, res_tzlaunch_effect, res_tzlaunch_splash);
7295 wl_resource_set_implementation(res_tzlaunch_splash,
7296 &_tzlaunch_splash_iface,
7298 _tzlaunch_splash_destroy);
7303 ERR("Could not create tizen_launch_splash_interface res: %m");
7304 wl_client_post_no_memory(client);
7308 _tzlaunch_effect_iface_cb_type_set(struct wl_client *client, struct wl_resource *res_tzlaunch_effect,
7309 const char *effect_type, uint32_t pid, struct wl_array *options)
7311 Eina_List *clients, *l;
7312 E_Client *_ec = NULL;
7314 int tzlaunch_effect_type = _e_policy_wl_tzlaunch_effect_type_get(effect_type);
7316 clients = _e_policy_wl_e_clients_find_by_pid(pid);
7317 EINA_LIST_FOREACH(clients, l, _ec)
7321 _ec->effect_type = tzlaunch_effect_type;
7324 "Launchscreen effect type set | exist ec | effect (%d) pid (%d)",
7325 _ec, tzlaunch_effect_type, pid);
7328 eina_list_free(clients);
7331 _e_policy_wl_tzlaunch_effect_type_unset(pid);
7334 E_Policy_Wl_Tzlaunch_Effect_Info *tzlaunch_effect_info;
7336 tzlaunch_effect_info = E_NEW(E_Policy_Wl_Tzlaunch_Effect_Info, 1);
7337 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_effect_info);
7338 tzlaunch_effect_info->pid = pid;
7339 tzlaunch_effect_info->effect_type = tzlaunch_effect_type;
7340 polwl->tzlaunch_effect_info = eina_list_append(polwl->tzlaunch_effect_info, tzlaunch_effect_info);
7343 "Launchscreen effect type set | no match ec | effect (%d) pid (%d)",
7344 NULL, tzlaunch_effect_type, pid);
7349 _tzlaunch_effect_iface_cb_type_unset(struct wl_client *client, struct wl_resource *res_tzlaunch_effect,
7352 _e_policy_wl_tzlaunch_effect_type_unset(pid);
7356 _tzlaunch_effect_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
7358 wl_resource_destroy(resource);
7361 static const struct tizen_launch_effect_interface _tzlaunch_effect_iface =
7363 _tzlaunch_effect_iface_cb_create_splash_img,
7364 _tzlaunch_effect_iface_cb_type_set,
7365 _tzlaunch_effect_iface_cb_type_unset,
7366 _tzlaunch_effect_iface_cb_destroy,
7370 _tzlaunch_effect_del(E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect)
7372 E_Policy_Wl_Tzlaunch_Splash *plaunch_splash;
7375 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_effect);
7377 // remove tzlaunch created splash list
7378 EINA_LIST_FOREACH_SAFE(tzlaunch_effect->splash_list, l, ll, plaunch_splash)
7380 if (plaunch_splash->tzlaunch_effect != tzlaunch_effect) continue;
7381 wl_resource_destroy(plaunch_splash->res_tzlaunch_splash);
7385 polwl->tzlaunch_effect = eina_list_remove(polwl->tzlaunch_effect, tzlaunch_effect);
7387 memset(tzlaunch_effect, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Effect));
7388 E_FREE(tzlaunch_effect);
7391 static E_Policy_Wl_Tzlaunch_Effect *
7392 _tzlaunch_effect_add(struct wl_resource *res_tzlaunch_effect)
7394 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7396 tzlaunch_effect = E_NEW(E_Policy_Wl_Tzlaunch_Effect, 1);
7397 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_effect, NULL);
7399 tzlaunch_effect->res_tzlaunch_effect = res_tzlaunch_effect;
7401 polwl->tzlaunch_effect = eina_list_append(polwl->tzlaunch_effect, tzlaunch_effect);
7403 return tzlaunch_effect;
7407 _tzlaunch_effect_cb_unbind(struct wl_resource *res_tzlaunch_effect)
7409 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect = NULL;
7412 EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_effect, l, ll, tzlaunch_effect)
7414 if (tzlaunch_effect->res_tzlaunch_effect != res_tzlaunch_effect) continue;
7415 _tzlaunch_effect_del(tzlaunch_effect);
7421 _tzlaunch_effect_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
7423 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect = NULL;
7424 struct wl_resource *res_tzlaunch_effect;
7426 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
7428 res_tzlaunch_effect = wl_resource_create(client,
7429 &tizen_launch_effect_interface,
7432 EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_effect, err);
7434 tzlaunch_effect = _tzlaunch_effect_add(res_tzlaunch_effect);
7435 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_effect, err);
7437 wl_resource_set_implementation(res_tzlaunch_effect,
7438 &_tzlaunch_effect_iface,
7440 _tzlaunch_effect_cb_unbind);
7445 ERR("Could not create tizen_launch_effect_interface res: %m");
7446 wl_client_post_no_memory(client);
7449 // --------------------------------------------------------
7450 // tizen_launch_appinfo_interface
7451 // --------------------------------------------------------
7453 _tzlaunch_appinfo_iface_cb_register_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7456 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7457 E_Appinfo *eai = NULL;
7459 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7460 if (!tzlaunch_appinfo)
7462 wl_resource_post_error(res_tzlaunch_appinfo,
7463 WL_DISPLAY_ERROR_INVALID_OBJECT,
7464 "Invalid tzlaunch_appinfo's user data");
7470 ELOGF("TZ_APPINFO", "registered pid is invalid. pid:%u", NULL, pid);
7474 eai = e_appinfo_find_with_pid(pid);
7477 eai = e_appinfo_new();
7478 EINA_SAFETY_ON_NULL_RETURN(eai);
7480 if (!e_appinfo_pid_set(eai, pid))
7482 ELOGF("TZ_APPINFO", "failed to set pid is invalid. pid:%u", NULL, pid);
7488 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
7492 _tzlaunch_appinfo_iface_cb_deregister_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7495 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7496 E_Appinfo *eai = NULL;
7498 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7499 if (!tzlaunch_appinfo)
7501 wl_resource_post_error(res_tzlaunch_appinfo,
7502 WL_DISPLAY_ERROR_INVALID_OBJECT,
7503 "Invalid tzlaunch_appinfo's user data");
7507 eai = e_appinfo_find_with_pid(pid);
7508 EINA_SAFETY_ON_NULL_RETURN(eai);
7514 _tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7515 uint32_t pid, const char *appid)
7517 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7518 E_Appinfo *eai = NULL;
7522 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7523 if (!tzlaunch_appinfo)
7525 wl_resource_post_error(res_tzlaunch_appinfo,
7526 WL_DISPLAY_ERROR_INVALID_OBJECT,
7527 "Invalid tzlaunch_appinfo's user data");
7533 ELOGF("TZ_APPINFO", "set pid is invalid. pid:%u", NULL, pid);
7537 eai = e_appinfo_find_with_pid(pid);
7538 EINA_SAFETY_ON_NULL_RETURN(eai);
7540 if (!e_appinfo_appid_set(eai, appid))
7542 ELOGF("TZ_APPINFO", "failed to set appid, appid:%s", NULL, appid);
7546 /* about base output resolution */
7547 if (e_config->configured_output_resolution.use)
7550 // 1. send HOOK with pid
7551 e_policy_wl_base_output_resolution_info_update(pid);
7552 // 2. module must set the base_output_resolution.
7553 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7555 ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
7558 // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
7559 // 3-1. if success, use the base_rescreen_resolution
7560 // 3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
7563 if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
7565 ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
7574 _tzlaunch_appinfo_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo)
7576 wl_resource_destroy(res_tzlaunch_appinfo);
7580 _tzlaunch_appinfo_iface_cb_get_base_output_resolution(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7583 E_Appinfo *eai = NULL;
7584 int width = 0, height = 0;
7588 ELOGF("TZ_APPINFO", "requested pid is invalid. pid:%u", NULL, pid);
7592 eai = e_appinfo_find_with_pid(pid);
7595 ELOGF("TZ_APPINFO", "cannot find pid. pid:%u", NULL, pid);
7599 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7601 ELOGF("TZ_APPINFO", "cannot read size. pid:%u", NULL, pid);
7605 tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
7606 ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
7611 width = e_config->configured_output_resolution.w;
7612 height = e_config->configured_output_resolution.h;
7613 ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
7614 tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
7620 _tzlaunch_appinfo_iface_cb_register_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7623 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7624 E_Appinfo *eai = NULL;
7626 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7627 if (!tzlaunch_appinfo)
7629 wl_resource_post_error(res_tzlaunch_appinfo,
7630 WL_DISPLAY_ERROR_INVALID_OBJECT,
7631 "Invalid tzlaunch_appinfo's user data");
7635 if ((eai = e_appinfo_find_with_appid(appid)))
7637 ELOGF("TZ_APPINFO", "appid:%s is already registered!", NULL, appid);
7641 eai = e_appinfo_new();
7642 EINA_SAFETY_ON_NULL_RETURN(eai);
7644 if (!e_appinfo_appid_set(eai, appid))
7646 ELOGF("TZ_APPINFO", "Failed to register appid:%s", NULL, appid);
7651 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
7655 _tzlaunch_appinfo_iface_cb_deregister_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7658 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7659 E_Appinfo *eai = NULL;
7661 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7662 if (!tzlaunch_appinfo)
7664 wl_resource_post_error(res_tzlaunch_appinfo,
7665 WL_DISPLAY_ERROR_INVALID_OBJECT,
7666 "Invalid tzlaunch_appinfo's user data");
7670 eai = e_appinfo_find_with_appid(appid);
7671 EINA_SAFETY_ON_NULL_RETURN(eai);
7677 _tzlaunch_appinfo_iface_cb_set_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7678 const char *appid, uint32_t pid)
7680 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7681 E_Appinfo *eai = NULL;
7683 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7684 if (!tzlaunch_appinfo)
7686 wl_resource_post_error(res_tzlaunch_appinfo,
7687 WL_DISPLAY_ERROR_INVALID_OBJECT,
7688 "Invalid tzlaunch_appinfo's user data");
7692 eai = e_appinfo_find_with_appid(appid);
7693 EINA_SAFETY_ON_NULL_RETURN(eai);
7695 if (!e_appinfo_pid_set(eai, pid))
7697 ELOGF("TZ_APPINFO", "Failed to set pid:%u for appid:%s", NULL, pid, appid);
7703 _tzlaunch_appinfo_iface_cb_ready_metadata(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7704 const char *appid, uint32_t pid)
7706 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7707 E_Appinfo *eai = NULL;
7708 int width = 0, height = 0;
7710 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7711 if (!tzlaunch_appinfo)
7713 wl_resource_post_error(res_tzlaunch_appinfo,
7714 WL_DISPLAY_ERROR_INVALID_OBJECT,
7715 "Invalid tzlaunch_appinfo's user data");
7719 eai = e_appinfo_find_with_appid(appid);
7720 EINA_SAFETY_ON_NULL_RETURN(eai);
7722 e_appinfo_ready_metadata(eai, pid);
7724 /* about base output resolution */
7725 if (e_config->configured_output_resolution.use)
7727 // 1. send HOOK with pid
7728 e_policy_wl_base_output_resolution_info_update(pid);
7729 // 2. module must set the base_output_resolution.
7730 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7732 ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
7735 // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
7736 // 3-1. if success, use the base_rescreen_resolution
7737 // 3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
7740 if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
7742 ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
7749 _tzlaunch_appinfo_iface_cb_set_auto_placement(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7752 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7753 E_Appinfo *eai = NULL;
7755 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7756 if (!tzlaunch_appinfo)
7758 wl_resource_post_error(res_tzlaunch_appinfo,
7759 WL_DISPLAY_ERROR_INVALID_OBJECT,
7760 "Invalid tzlaunch_appinfo's user data");
7764 eai = e_appinfo_find_with_pid(pid);
7765 EINA_SAFETY_ON_NULL_RETURN(eai);
7767 ELOGF("TZ_APPINFO", "Set auto placement. pid(%d)", NULL, pid);
7768 e_appinfo_auto_placement_set(eai, EINA_TRUE);
7771 static const struct tizen_launch_appinfo_interface _tzlaunch_appinfo_iface =
7773 _tzlaunch_appinfo_iface_cb_destroy,
7774 _tzlaunch_appinfo_iface_cb_register_pid,
7775 _tzlaunch_appinfo_iface_cb_deregister_pid,
7776 _tzlaunch_appinfo_iface_cb_set_appid,
7777 _tzlaunch_appinfo_iface_cb_get_base_output_resolution,
7778 _tzlaunch_appinfo_iface_cb_register_appid,
7779 _tzlaunch_appinfo_iface_cb_deregister_appid,
7780 _tzlaunch_appinfo_iface_cb_set_pid,
7781 _tzlaunch_appinfo_iface_cb_ready_metadata,
7782 _tzlaunch_appinfo_iface_cb_set_auto_placement,
7786 _tzlaunch_appinfo_del(E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo)
7788 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_appinfo);
7790 polwl->tzlaunch_appinfo = eina_list_remove(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
7792 memset(tzlaunch_appinfo, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Appinfo));
7793 E_FREE(tzlaunch_appinfo);
7796 static E_Policy_Wl_Tzlaunch_Appinfo *
7797 _tzlaunch_appinfo_add(struct wl_resource *res_tzlaunch_appinfo)
7799 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo;
7801 tzlaunch_appinfo = E_NEW(E_Policy_Wl_Tzlaunch_Appinfo, 1);
7802 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_appinfo, NULL);
7804 tzlaunch_appinfo->res_tzlaunch_appinfo = res_tzlaunch_appinfo;
7806 polwl->tzlaunch_appinfo = eina_list_append(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
7808 return tzlaunch_appinfo;
7812 _tzlaunch_appinfo_cb_unbind(struct wl_resource *res_tzlaunch_appinfo)
7814 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7817 EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_appinfo, l, ll, tzlaunch_appinfo)
7819 if (tzlaunch_appinfo->res_tzlaunch_appinfo != res_tzlaunch_appinfo) continue;
7820 _tzlaunch_appinfo_del(tzlaunch_appinfo);
7826 _tzlaunch_appinfo_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
7828 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7829 struct wl_resource *res_tzlaunch_appinfo;
7831 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
7833 res_tzlaunch_appinfo = wl_resource_create(client,
7834 &tizen_launch_appinfo_interface,
7837 EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_appinfo, err);
7839 tzlaunch_appinfo = _tzlaunch_appinfo_add(res_tzlaunch_appinfo);
7840 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_appinfo, err);
7842 wl_resource_set_implementation(res_tzlaunch_appinfo,
7843 &_tzlaunch_appinfo_iface,
7845 _tzlaunch_appinfo_cb_unbind);
7850 ERR("Could not create tizen_launch_appinfo_interface res: %m");
7851 wl_client_post_no_memory(client);
7855 e_policy_wl_base_output_resolution_info_update(pid_t pid)
7857 _e_policy_wl_hook_call(E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET, pid);
7861 _e_policy_wl_cb_hook_intercept_show_helper(void *data, E_Client *ec)
7863 E_Policy_Wl_Tzpol *tzpol;
7864 E_Policy_Wl_Surface *psurf;
7866 Eina_Bool ret = EINA_TRUE;
7868 it = eina_hash_iterator_data_new(polwl->tzpols);
7869 EINA_ITERATOR_FOREACH(it, tzpol)
7871 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
7874 if (psurf->is_background)
7877 "BACKGROUND State is On, Deny Show",
7884 eina_iterator_free(it);
7890 _e_policy_wl_cb_scrsaver_on(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
7892 if (_scrsaver_mng_res)
7893 tws_service_screensaver_manager_send_idle(_scrsaver_mng_res);
7894 return ECORE_CALLBACK_PASS_ON;
7898 _e_policy_wl_cb_scrsaver_off(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
7900 if (_scrsaver_mng_res)
7901 tws_service_screensaver_manager_send_active(_scrsaver_mng_res);
7902 return ECORE_CALLBACK_PASS_ON;
7905 // --------------------------------------------------------
7906 // E_Policy_Wl_Tz_Indicator
7907 // --------------------------------------------------------
7908 static E_Policy_Wl_Tz_Indicator *
7909 _e_policy_wl_tz_indicator_add(struct wl_resource *res_tz_indicator)
7911 E_Policy_Wl_Tz_Indicator *tz_indicator;
7913 tz_indicator = E_NEW(E_Policy_Wl_Tz_Indicator, 1);
7914 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, NULL);
7916 tz_indicator->res_tz_indicator = res_tz_indicator;
7918 polwl->tz_indicators = eina_list_append(polwl->tz_indicators, tz_indicator);
7920 return tz_indicator;
7924 _e_policy_wl_tz_indicator_del(E_Policy_Wl_Tz_Indicator *tz_indicator)
7926 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
7928 polwl->tz_indicators = eina_list_remove(polwl->tz_indicators, tz_indicator);
7929 E_FREE(tz_indicator);
7932 static E_Policy_Wl_Tz_Indicator *
7933 _e_policy_wl_tz_indicator_get(struct wl_resource *res_tz_indicator)
7936 E_Policy_Wl_Tz_Indicator *tz_indicator;
7938 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7940 if (tz_indicator->res_tz_indicator == res_tz_indicator)
7941 return tz_indicator;
7946 static E_Policy_Wl_Tz_Indicator *
7947 _e_policy_wl_tz_indicator_get_from_client(E_Client *ec)
7950 E_Policy_Wl_Tz_Indicator *tz_indicator;
7952 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7954 if (eina_list_data_find(tz_indicator->ec_list, ec))
7955 return tz_indicator;
7962 _e_policy_wl_tz_indicator_set_client(struct wl_resource *res_tz_indicator, E_Client *ec)
7964 E_Policy_Wl_Tz_Indicator *tz_indicator = NULL;
7966 tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
7967 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, EINA_FALSE);
7969 if (!eina_list_data_find(tz_indicator->ec_list, ec))
7970 tz_indicator->ec_list = eina_list_append(tz_indicator->ec_list, ec);
7976 _e_policy_wl_tz_indicator_unset_client(E_Client *ec)
7979 E_Policy_Wl_Tz_Indicator *tz_indicator;
7981 EINA_SAFETY_ON_NULL_RETURN(ec);
7983 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7985 if (eina_list_data_find(tz_indicator->ec_list, ec))
7986 tz_indicator->ec_list = eina_list_remove(tz_indicator->ec_list, ec);
7991 _tz_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator)
7993 wl_resource_destroy(res_tz_indicator);
7997 _tz_indicator_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t state)
8000 E_Indicator_State ind_state;
8002 ec = e_client_from_surface_resource(surf);
8003 EINA_SAFETY_ON_NULL_RETURN(ec);
8004 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8006 if (state == TIZEN_INDICATOR_STATE_ON)
8007 ind_state = E_INDICATOR_STATE_ON;
8008 else if (state == TIZEN_INDICATOR_STATE_OFF)
8009 ind_state = E_INDICATOR_STATE_OFF;
8011 ind_state = E_INDICATOR_STATE_UNKNOWN;
8013 ELOGF("TZ_IND", "TZ_STATE:%d, E_STATE:%d", ec, state, ind_state);
8014 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8015 ec->indicator.state = ind_state;
8017 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_STATE_CHANGE);
8021 _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)
8024 E_Indicator_Opacity_Mode op_mode;
8026 ec = e_client_from_surface_resource(surf);
8027 EINA_SAFETY_ON_NULL_RETURN(ec);
8028 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8032 case TIZEN_INDICATOR_OPACITY_MODE_OPAQUE:
8033 op_mode = E_INDICATOR_OPACITY_MODE_OPAQUE;
8036 case TIZEN_INDICATOR_OPACITY_MODE_TRANSLUCENT:
8037 op_mode = E_INDICATOR_OPACITY_MODE_TRANSLUCENT;
8040 case TIZEN_INDICATOR_OPACITY_MODE_TRANSPARENT:
8041 op_mode = E_INDICATOR_OPACITY_MODE_TRANSPARENT;
8044 case TIZEN_INDICATOR_OPACITY_MODE_BG_TRANSPARENT:
8045 op_mode = E_INDICATOR_OPACITY_MODE_BG_TRANSPARENT;
8049 op_mode = E_INDICATOR_OPACITY_MODE_OPAQUE;
8053 ELOGF("TZ_IND", "TZ_OP_MODE:%d, E_OP_MODE:%d", ec, mode, op_mode);
8054 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8056 if (ec->indicator.opacity_mode == op_mode) return;
8058 ec->indicator.opacity_mode = op_mode;
8059 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.curr);
8061 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE);
8065 _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)
8068 E_Indicator_Visible_Type vis_type;
8070 ec = e_client_from_surface_resource(surf);
8071 EINA_SAFETY_ON_NULL_RETURN(ec);
8072 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8074 if (vtype == TIZEN_INDICATOR_VISIBLE_TYPE_SHOWN)
8075 vis_type = E_INDICATOR_VISIBLE_TYPE_SHOWN;
8077 vis_type = E_INDICATOR_VISIBLE_TYPE_HIDDEN;
8079 ELOGF("TZ_IND", "TZ_VIS_TYPE:%d, E_VIS_TYPE:%d", ec, vtype, vis_type);
8080 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8081 ec->indicator.visible_type = vis_type;
8083 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE);
8086 // --------------------------------------------------------
8087 // tizen_indicator_interface
8088 // --------------------------------------------------------
8089 static const struct tizen_indicator_interface _tz_indicator_iface =
8091 _tz_indicator_cb_destroy,
8092 _tz_indicator_cb_state_set,
8093 _tz_indicator_cb_opacity_mode_set,
8094 _tz_indicator_cb_visible_type_set,
8098 _tz_indicator_cb_unbind(struct wl_resource *res_tz_indicator)
8100 E_Policy_Wl_Tz_Indicator *tz_indicator;
8102 tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
8103 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
8105 _e_policy_wl_tz_indicator_del(tz_indicator);
8109 _tz_indicator_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
8111 E_Policy_Wl_Tz_Indicator *tz_indicator_pol;
8112 struct wl_resource *res_tz_indicator;
8114 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8116 res_tz_indicator = wl_resource_create(client,
8117 &tizen_indicator_interface,
8120 EINA_SAFETY_ON_NULL_GOTO(res_tz_indicator, err);
8122 tz_indicator_pol = _e_policy_wl_tz_indicator_add(res_tz_indicator);
8123 EINA_SAFETY_ON_NULL_GOTO(tz_indicator_pol, err);
8125 wl_resource_set_implementation(res_tz_indicator,
8126 &_tz_indicator_iface,
8128 _tz_indicator_cb_unbind);
8132 ERR("Could not create tizen_indicator_interface res: %m");
8133 wl_client_post_no_memory(client);
8137 e_policy_wl_indicator_flick_send(E_Client *ec)
8139 E_Comp_Wl_Client_Data *cdata;
8140 E_Policy_Wl_Tz_Indicator *tz_indicator;
8141 struct wl_resource *surf;
8143 tz_indicator = _e_policy_wl_tz_indicator_get_from_client(ec);
8144 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
8146 cdata = e_client_cdata_get(ec);
8148 surf = cdata->surface;
8152 ELOGF("TZ_IND", "SEND FLICK EVENT", ec);
8153 tizen_indicator_send_flick(tz_indicator->res_tz_indicator, surf, 0);
8157 // --------------------------------------------------------
8158 // E_Policy_Wl_Tz_Clipboard
8159 // --------------------------------------------------------
8160 static E_Policy_Wl_Tz_Clipboard *
8161 _e_policy_wl_tz_clipboard_add(struct wl_resource *res_tz_clipboard)
8163 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8165 tz_clipboard = E_NEW(E_Policy_Wl_Tz_Clipboard, 1);
8166 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_clipboard, NULL);
8168 tz_clipboard->res_tz_clipboard = res_tz_clipboard;
8169 polwl->tz_clipboards = eina_list_append(polwl->tz_clipboards, tz_clipboard);
8171 return tz_clipboard;
8175 _e_policy_wl_tz_clipboard_del(E_Policy_Wl_Tz_Clipboard *tz_clipboard)
8177 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8179 polwl->tz_clipboards = eina_list_remove(polwl->tz_clipboards, tz_clipboard);
8180 E_FREE(tz_clipboard);
8183 static E_Policy_Wl_Tz_Clipboard *
8184 _e_policy_wl_tz_clipboard_get_from_client(E_Client *ec)
8187 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8189 EINA_LIST_FOREACH(polwl->tz_clipboards, l, tz_clipboard)
8191 if (eina_list_data_find(tz_clipboard->ec_list, ec))
8192 return tz_clipboard;
8199 _e_policy_wl_tz_clipboard_set_client(struct wl_resource *res_tz_clipboard, E_Client *ec)
8201 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8203 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8204 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_clipboard, EINA_FALSE);
8206 if (!eina_list_data_find(tz_clipboard->ec_list, ec))
8208 tz_clipboard->ec_list = eina_list_append(tz_clipboard->ec_list, ec);
8214 _e_policy_wl_tz_clipboard_unset_client(E_Client *ec)
8217 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8219 EINA_SAFETY_ON_NULL_RETURN(ec);
8221 EINA_LIST_FOREACH(polwl->tz_clipboards, l, tz_clipboard)
8223 if (eina_list_data_find(tz_clipboard->ec_list, ec))
8225 tz_clipboard->ec_list = eina_list_remove(tz_clipboard->ec_list, ec);
8230 // --------------------------------------------------------
8231 // tizen_clipboard_interface
8232 // --------------------------------------------------------
8234 _tz_clipboard_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard)
8236 wl_resource_destroy(res_tz_clipboard);
8240 _tz_clipboard_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard, struct wl_resource *surf)
8244 ec = e_client_from_surface_resource(surf);
8245 EINA_SAFETY_ON_NULL_RETURN(ec);
8246 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8248 _e_policy_wl_tz_clipboard_set_client(res_tz_clipboard, ec);
8249 e_service_cbhm_parent_set(ec, EINA_TRUE);
8250 e_service_cbhm_show();
8254 _tz_clipboard_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard, struct wl_resource *surf)
8258 ec = e_client_from_surface_resource(surf);
8259 EINA_SAFETY_ON_NULL_RETURN(ec);
8260 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8262 e_service_cbhm_parent_set(ec, EINA_FALSE);
8263 e_service_cbhm_hide();
8267 _tz_clipboard_cb_data_only_set(struct wl_client *client, struct wl_resource *res_tz_clipboard, uint32_t set)
8269 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8270 struct wl_client *_wc;
8271 struct wl_resource *data_res;
8276 E_Client *ec, *found = NULL;
8277 E_Comp_Wl_Client_Data *cdata;
8279 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8280 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8282 if (tz_clipboard->ec_list)
8285 "Unable to set data only mode for wl_client(%p) : "
8291 if (!(data_res = e_comp_wl_data_find_for_client(client)))
8294 "Unable to set data only mode for wl_client(%p) : "
8295 "no wl_data_device resource",
8300 clients = _e_policy_wl_e_clients_find_by_pid(pid);
8303 EINA_LIST_FREE(clients, ec)
8305 if (found) continue;
8306 cdata = e_client_cdata_get(ec);
8307 if (cdata && cdata->surface)
8309 _wc = wl_resource_get_client(cdata->surface);
8319 "Unable to set data only mode for wl_client(%p) : "
8325 /* Privilege Check */
8326 wl_client_get_credentials(client, &pid, &uid, NULL);
8327 res = e_security_privilege_check(pid, uid,
8328 E_PRIVILEGE_DATA_ONLY_SET);
8332 "Privilege Check Failed! DENY data_only_set",
8338 "Set data only mode :%d for wl_client(%p)",
8340 e_comp_wl_data_device_only_set(data_res, !(set == 0));
8341 tizen_clipboard_send_allowed_data_only(res_tz_clipboard, (uint32_t)1);
8345 tizen_clipboard_send_allowed_data_only(res_tz_clipboard, (uint32_t)0);
8348 static const struct tizen_clipboard_interface _tz_clipboard_iface =
8350 _tz_clipboard_cb_destroy,
8351 _tz_clipboard_cb_show,
8352 _tz_clipboard_cb_hide,
8353 _tz_clipboard_cb_data_only_set,
8357 _tz_clipboard_cb_unbind(struct wl_resource *res_tz_clipboard)
8359 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8361 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8362 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8364 _e_policy_wl_tz_clipboard_del(tz_clipboard);
8368 _tz_clipboard_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
8370 E_Policy_Wl_Tz_Clipboard *tz_clipboard_pol;
8371 struct wl_resource *res_tz_clipboard;
8373 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8375 res_tz_clipboard = wl_resource_create(client,
8376 &tizen_clipboard_interface,
8379 EINA_SAFETY_ON_NULL_GOTO(res_tz_clipboard, err);
8381 tz_clipboard_pol = _e_policy_wl_tz_clipboard_add(res_tz_clipboard);
8382 EINA_SAFETY_ON_NULL_GOTO(tz_clipboard_pol, err);
8384 wl_resource_set_implementation(res_tz_clipboard,
8385 &_tz_clipboard_iface,
8387 _tz_clipboard_cb_unbind);
8391 ERR("Could not create tizen_clipboard_interface res: %m");
8392 wl_client_post_no_memory(client);
8396 e_policy_wl_clipboard_data_selected_send(E_Client *ec)
8398 E_Comp_Wl_Client_Data *cdata;
8399 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8401 EINA_SAFETY_ON_NULL_RETURN(ec);
8403 tz_clipboard = _e_policy_wl_tz_clipboard_get_from_client(ec);
8404 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8406 cdata = e_client_cdata_get(ec);
8407 tizen_clipboard_send_data_selected(tz_clipboard->res_tz_clipboard,
8408 cdata ? cdata->surface : NULL);
8412 _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
8416 if (EINA_UNLIKELY(!ec))
8419 e_client_base_output_resolution_update(ec);
8421 e_policy_client_maximize(ec);
8423 e_client_base_output_resolution_transform_adjust(ec);
8425 if (ec->lock_client_size)
8430 e_client_shell_configure_send(ec, 0, w, h);
8434 _e_policy_wl_cb_hook_alpha_change(void *data, E_Client *ec)
8437 if (!ec->argb) return;
8438 if (!ec->transients) return;
8439 if (!e_policy_visibility_client_is_uniconify_render_running(ec)) return;
8442 Eina_List *list = eina_list_clone(ec->transients);
8444 EINA_LIST_FREE(list, child)
8446 if (e_client_transient_policy_get(child) == E_TRANSIENT_BELOW)
8448 ELOGF("POL_VIS", "Uniconify below child(win:%zx, ec:%p) by changing alpha", ec, e_client_util_win_get(child), child);
8449 e_policy_client_uniconify_by_visibility(child);
8455 _e_policy_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
8459 if (e_object_is_del(E_OBJECT(ec))) return;
8460 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
8462 if (ec->manage_resize.resize_obj)
8464 x = ec->manage_resize.x;
8465 y = ec->manage_resize.y;
8466 w = ec->manage_resize.w;
8467 h = ec->manage_resize.h;
8475 e_client_geometry_get(ec, &x, &y, &w, &h);
8478 E_Policy_Wl_Tzpol *tzpol;
8479 E_Policy_Wl_Surface *psurf;
8484 it = eina_hash_iterator_data_new(polwl->tzpols);
8485 EINA_ITERATOR_FOREACH(it, tzpol)
8487 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8489 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8490 if (!psurf->surf) continue;
8492 ver = wl_resource_get_version(tzpol->res_tzpol);
8495 // interactive_resize_done event is supported since ver 10
8499 tizen_policy_send_interactive_resize_done(tzpol->res_tzpol,
8500 psurf->surf, x, y, w, h,
8501 ec->e.state.rot.ang.curr);
8504 eina_iterator_free(it);
8508 _e_policy_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
8510 if (e_object_is_del(E_OBJECT(ec))) return;
8511 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
8518 e_client_geometry_get(ec, &x, &y, &w, &h);
8520 E_Policy_Wl_Tzpol *tzpol;
8521 E_Policy_Wl_Surface *psurf;
8526 it = eina_hash_iterator_data_new(polwl->tzpols);
8527 EINA_ITERATOR_FOREACH(it, tzpol)
8529 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8531 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8532 if (!psurf->surf) continue;
8534 ver = wl_resource_get_version(tzpol->res_tzpol);
8537 // interactive_move_done event is supported since ver 10
8541 tizen_policy_send_interactive_move_done(tzpol->res_tzpol,
8544 ec->e.state.rot.ang.curr);
8547 eina_iterator_free(it);
8551 e_policy_wl_generate_request(E_Client *ec, E_Policy_Wl_Gen_Request type)
8553 E_Comp_Wl_Client_Data *cdata = NULL;
8556 cdata = e_client_cdata_get(ec);
8558 if (!cdata->wl_surface) return;
8560 ELOGF("POL", "Generate operation (type:%d)", ec, type);
8563 case E_POLICY_WL_GENERATE_REQUEST_LOWER:
8564 _tzpol_iface_cb_lower(NULL, NULL, cdata->wl_surface);
8566 case E_POLICY_WL_GENERATE_REQUEST_ACTIVATE:
8567 _tzpol_iface_cb_activate(NULL, NULL, cdata->wl_surface);
8569 case E_POLICY_WL_GENERATE_REQUEST_ICONIFY:
8570 _tzpol_iface_cb_iconify(NULL, NULL, cdata->wl_surface);
8572 case E_POLICY_WL_GENERATE_REQUEST_UNICONIFY:
8573 _tzpol_iface_cb_uniconify(NULL, NULL, cdata->wl_surface);
8581 e_policy_wl_aux_hint_apply(E_Client *ec)
8583 _e_policy_wl_aux_hint_apply(ec);
8586 // --------------------------------------------------------
8588 // --------------------------------------------------------
8590 e_policy_wl_client_add(E_Client *ec)
8592 EINA_SAFETY_ON_NULL_RETURN(ec);
8593 if (!ec->pixmap) return;
8595 _e_policy_wl_surf_client_set(ec);
8596 _e_policy_wl_tzlaunch_effect_type_sync(ec);
8600 e_policy_wl_client_del(E_Client *ec)
8602 EINA_SAFETY_ON_NULL_RETURN(ec);
8603 if (!ec->pixmap) return;
8605 e_policy_wl_pixmap_del(ec->pixmap);
8606 _e_policy_wl_dpy_surf_del(ec);
8607 _e_policy_wl_tz_indicator_unset_client(ec);
8608 _e_policy_wl_tz_clipboard_unset_client(ec);
8609 _launch_effect_client_del(ec);
8611 polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
8615 e_policy_wl_pixmap_del(E_Pixmap *cp)
8617 E_Policy_Wl_Tzpol *tzpol;
8618 E_Policy_Wl_Surface *psurf;
8622 it = eina_hash_iterator_data_new(polwl->tzpols);
8623 EINA_ITERATOR_FOREACH(it, tzpol)
8624 EINA_LIST_FOREACH_SAFE(tzpol->psurfs, l, ll, psurf)
8626 if (psurf->cp != cp) continue;
8627 tzpol->psurfs = eina_list_remove_list(tzpol->psurfs, l);
8628 _e_policy_wl_surf_del(psurf);
8630 eina_iterator_free(it);
8634 e_policy_wl_aux_message_send(E_Client *ec,
8639 E_Comp_Wl_Client_Data *cdata;
8640 E_Policy_Wl_Tzpol *tzpol;
8641 E_Policy_Wl_Surface *psurf;
8644 struct wl_array opt_array;
8649 if (e_object_is_del(E_OBJECT(ec))) return;
8650 cdata = e_client_cdata_get(ec);
8652 if (!cdata->aux_hint.use_msg) return;
8654 wl_array_init(&opt_array);
8655 EINA_LIST_FOREACH(options, l, option)
8657 len = strlen(option) + 1;
8658 p = wl_array_add(&opt_array, len);
8662 strncpy(p, option, len);
8665 it = eina_hash_iterator_data_new(polwl->tzpols);
8666 EINA_ITERATOR_FOREACH(it, tzpol)
8667 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8669 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8670 if (!psurf->surf) continue;
8672 tizen_policy_send_aux_message(tzpol->res_tzpol,
8674 key, val, &opt_array);
8676 "SEND |res_tzpol:%8p|aux message key:%s val:%s opt_count:%d",
8679 key, val, eina_list_count(options));
8681 eina_iterator_free(it);
8682 wl_array_release(&opt_array);
8686 e_policy_wl_aux_hint_init(void)
8689 E_Config_Aux_Hint_Supported *auxhint;
8692 n = (sizeof(hint_names) / sizeof(char *));
8694 for (i = 0; i < n; i++)
8696 e_hints_aux_hint_supported_add(hint_names[i]);
8699 EINA_LIST_FOREACH(e_config->aux_hint_supported, l, auxhint)
8701 if (!auxhint->name) continue;
8702 e_hints_aux_hint_supported_add(auxhint->name);
8709 e_policy_wl_defer_job(void)
8711 struct wl_global *global = NULL;
8712 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8714 if (!e_config->global_object_not_provide.launch_effect)
8716 global = wl_global_create(e_comp_wl->wl.disp,
8717 &tizen_launch_effect_interface,
8720 _tzlaunch_effect_cb_bind);
8721 EINA_SAFETY_ON_NULL_GOTO(global, err);
8723 polwl->globals = eina_list_append(polwl->globals, global);
8726 global = wl_global_create(e_comp_wl->wl.disp,
8727 &tizen_launch_appinfo_interface,
8730 _tzlaunch_appinfo_cb_bind);
8731 EINA_SAFETY_ON_NULL_GOTO(global, err);
8733 polwl->globals = eina_list_append(polwl->globals, global);
8742 e_policy_wl_init(void)
8744 struct wl_global *global;
8746 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
8747 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->wl.disp, EINA_FALSE);
8749 polwl = E_NEW(E_Policy_Wl, 1);
8750 EINA_SAFETY_ON_NULL_RETURN_VAL(polwl, EINA_FALSE);
8752 /* create globals */
8753 global = wl_global_create(e_comp_wl->wl.disp,
8754 &tizen_policy_interface,
8758 EINA_SAFETY_ON_NULL_GOTO(global, err);
8759 polwl->globals = eina_list_append(polwl->globals, global);
8761 global = wl_global_create(e_comp_wl->wl.disp,
8762 &tizen_display_policy_interface,
8765 _tz_dpy_pol_cb_bind);
8766 EINA_SAFETY_ON_NULL_GOTO(global, err);
8767 polwl->globals = eina_list_append(polwl->globals, global);
8769 global = wl_global_create(e_comp_wl->wl.disp,
8770 &tizen_ws_shell_interface,
8775 EINA_SAFETY_ON_NULL_GOTO(global, err);
8776 polwl->globals = eina_list_append(polwl->globals, global);
8778 global = wl_global_create(e_comp_wl->wl.disp,
8779 &tizen_indicator_interface,
8782 _tz_indicator_cb_bind);
8783 EINA_SAFETY_ON_NULL_GOTO(global, err);
8784 polwl->globals = eina_list_append(polwl->globals, global);
8786 global = wl_global_create(e_comp_wl->wl.disp,
8787 &tizen_clipboard_interface,
8790 _tz_clipboard_cb_bind);
8791 EINA_SAFETY_ON_NULL_GOTO(global, err);
8792 polwl->globals = eina_list_append(polwl->globals, global);
8794 polwl->tzpols = eina_hash_pointer_new(_e_policy_wl_tzpol_del);
8796 E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(hooks_co, E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER, _e_policy_wl_cb_hook_intercept_show_helper, NULL);
8798 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_ON, _e_policy_wl_cb_scrsaver_on, NULL);
8799 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_OFF, _e_policy_wl_cb_scrsaver_off, NULL);
8801 E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_policy_wl_cb_hook_shell_surface_ready, NULL);
8802 E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, _e_policy_wl_cb_hook_alpha_change, NULL);
8804 E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_RESIZE_END, _e_policy_wl_client_cb_resize_end, NULL);
8805 E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_MOVE_END, _e_policy_wl_client_cb_move_end, NULL);
8807 E_EVENT_POLICY_INDICATOR_STATE_CHANGE = ecore_event_type_new();
8808 E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = ecore_event_type_new();
8809 E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = ecore_event_type_new();
8811 e_service_softkey_client_remove_handler_add();
8813 e_policy_display_init();
8820 EINA_LIST_FREE(polwl->globals, global)
8821 wl_global_destroy(global);
8829 e_policy_wl_shutdown(void)
8831 E_Policy_Wl_Tzsh *tzsh;
8832 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
8833 E_Policy_Wl_Tzsh_Extension *tzsh_extension;
8834 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
8835 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
8836 E_Policy_Wl_Tz_Indicator *tz_indicator;
8837 struct wl_global *global;
8840 e_policy_display_shutdown();
8842 EINA_SAFETY_ON_NULL_RETURN(polwl);
8844 E_FREE_LIST(polwl_hooks_ec, e_client_hook_del);
8845 E_FREE_LIST(hooks_cw, e_comp_wl_hook_del);
8846 E_FREE_LIST(hooks_co, e_comp_object_intercept_hook_del);
8847 E_FREE_LIST(handlers, ecore_event_handler_del);
8849 e_service_softkey_client_remove_handler_del();
8851 polwl->pending_vis = eina_list_free(polwl->pending_vis);
8853 for (i = 0; i < TZSH_SRV_ROLE_MAX; i++)
8855 tzsh_srv = polwl->srvs[i];
8856 if (!tzsh_srv) continue;
8858 wl_resource_destroy(tzsh_srv->res_tzsh_srv);
8861 EINA_LIST_FREE(polwl->tzshs, tzsh)
8862 wl_resource_destroy(tzsh->res_tzsh);
8864 EINA_LIST_FREE(polwl->tz_dpy_pols, tz_dpy_pol)
8866 E_Policy_Wl_Dpy_Surface *dpy_surf;
8867 EINA_LIST_FREE(tz_dpy_pol->dpy_surfs, dpy_surf)
8871 wl_resource_destroy(tz_dpy_pol->res_tz_dpy_pol);
8874 EINA_LIST_FREE(polwl->tzlaunch_effect_info, effect_info)
8876 E_FREE(effect_info);
8879 EINA_LIST_FREE(polwl->tz_indicators, tz_indicator)
8881 eina_list_free(tz_indicator->ec_list);
8882 wl_resource_destroy(tz_indicator->res_tz_indicator);
8885 EINA_LIST_FREE(polwl->tzsh_extensions, tzsh_extension)
8887 free(tzsh_extension->name);
8890 EINA_LIST_FREE(polwl->globals, global)
8891 wl_global_destroy(global);
8893 E_FREE_FUNC(polwl->tzpols, eina_hash_free);