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"
34 #include "e_input_intern.h"
35 #include "e_input_thread_client_intern.h"
37 #include <device/display.h>
38 #include <wayland-server.h>
39 #include <tizen-extension-server-protocol.h>
40 #include <tizen-launch-server-protocol.h>
41 #include <tzsh_server.h>
43 typedef enum _Tzsh_Srv_Role
45 TZSH_SRV_ROLE_UNKNOWN = -1,
47 TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT,
48 TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU,
49 TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU,
50 TZSH_SRV_ROLE_LOCKSCREEN,
51 TZSH_SRV_ROLE_INDICATOR,
52 TZSH_SRV_ROLE_SCREENSAVER_MNG,
53 TZSH_SRV_ROLE_SCREENSAVER,
55 TZSH_SRV_ROLE_SOFTKEY,
56 TZSH_SRV_ROLE_MAGNIFIER,
57 TZSH_SRV_ROLE_LAUNCHER,
58 TZSH_SRV_ROLE_TASKBAR,
63 typedef enum _Tzsh_Client_Handle_Type
65 TZSH_CLIENT_HANDLE_TYPE_NONE = 0,
66 TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL = 1,
67 TZSH_CLIENT_HANDLE_TYPE_SHARED_WIDGET_LAUNCH = 2,
68 TZSH_CLIENT_HANDLE_TYPE_SOFTKEY = 3,
69 } Tzsh_Client_Handle_Type;
71 typedef enum _Tzsh_Type
73 TZSH_TYPE_UNKNOWN = 0,
78 typedef enum _Tzlaunch_Effect_Type
80 TZLAUNCH_EFFECT_TYPE_LAUNCH = 0,
81 TZLAUNCH_EFFECT_TYPE_DEPTH_IN
82 } Tzlaunch_Effect_Type;
84 typedef struct _E_Policy_Wl_Tzpol
86 struct wl_resource *res_tzpol; /* tizen_policy_interface */
87 Eina_List *psurfs; /* list of E_Policy_Wl_Surface */
92 typedef struct _E_Policy_Wl_Tz_Dpy_Pol
94 struct wl_resource *res_tz_dpy_pol;
95 Eina_List *dpy_surfs; // list of E_Policy_Wl_Dpy_Surface
96 } E_Policy_Wl_Tz_Dpy_Pol;
98 typedef struct _E_Policy_Wl_Tzsh
100 struct wl_resource *res_tzsh; /* tizen_ws_shell_interface */
101 Eina_List *service_list;
102 Eina_List *client_list;
105 typedef struct _E_Policy_Wl_Tzsh_Srv
107 E_Policy_Wl_Tzsh *tzsh;
108 struct wl_resource *res_tzsh_srv;
115 } E_Policy_Wl_Tzsh_Srv;
117 typedef struct _E_Policy_Wl_Tzsh_Client
119 E_Policy_Wl_Tzsh *tzsh;
120 struct wl_resource *res_tzsh_client;
121 Tzsh_Client_Handle_Type handle_type;
127 } E_Policy_Wl_Tzsh_Client;
129 typedef struct _E_Policy_Wl_Tzsh_Client_Data_Quickpanel
131 E_Quickpanel_Type type;
132 } E_Policy_Wl_Tzsh_Client_Data_Quickpanel;
134 typedef struct _E_Policy_Wl_Tzsh_Client_Data_Softkey
137 } E_Policy_Wl_Tzsh_Client_Data_Softkey;
139 typedef struct _E_Policy_Wl_Tzsh_Region
141 E_Policy_Wl_Tzsh *tzsh;
142 struct wl_resource *res_tzsh_reg;
144 struct wl_listener destroy_listener;
145 } E_Policy_Wl_Tzsh_Region;
147 typedef struct _E_Policy_Wl_Tzsh_Extension
150 E_Policy_Wl_Tzsh_Ext_Hook_Cb cb;
151 } E_Policy_Wl_Tzsh_Extension;
153 typedef struct _E_Policy_Wl_Surface
155 struct wl_resource *surf;
156 E_Policy_Wl_Tzpol *tzpol;
160 Eina_Bool pending_notilv;
162 Eina_List *vislist; /* list of tizen_visibility_interface resources */
163 Eina_List *poslist; /* list of tizen_position_inteface resources */
164 Eina_Bool is_background;
165 } E_Policy_Wl_Surface;
167 typedef struct _E_Policy_Wl_Dpy_Surface
169 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
170 struct wl_resource *surf;
174 } E_Policy_Wl_Dpy_Surface;
176 typedef struct _E_Policy_Wl_Tzlaunch_Effect
178 struct wl_resource *res_tzlaunch_effect; /* tizen_launch_effect */
179 Eina_List *splash_list; /* list of E_Policy_Wl_Tzlaunch_Splash */
180 } E_Policy_Wl_Tzlaunch_Effect;
182 typedef struct _E_Policy_Wl_Tzlaunch_Splash
184 struct wl_resource *res_tzlaunch_splash; /* tizen_launch_image */
185 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect; /* launcher */
187 const char *path; /* image resource path */
188 uint32_t type; /* 0: image, 1: edc */
189 uint32_t indicator; /* 0: off, 1: on */
190 uint32_t angle; /* 0, 90, 180, 270 : rotation angle */
193 Evas_Object *obj; /* launch screen image */
194 E_Pixmap *ep; /* pixmap for launch screen client */
195 E_Client *ec; /* client for launch screen image */
196 Ecore_Timer *timeout; /* launch screen image hide timer */
197 Evas_Object *indicator_obj; /* plug object of indicator */
199 Eina_Bool valid; /* validation check */
201 E_Comp_Object_Content_Type content_type; /* type of content */
203 Eina_Bool custom_effect_callee; /* custom effect enabled */
205 } E_Policy_Wl_Tzlaunch_Splash;
207 typedef struct _E_Policy_Wl_Tzlaunch_Effect_Info
209 uint32_t pid; /* pid */
210 int effect_type; /* effect_type */
211 } E_Policy_Wl_Tzlaunch_Effect_Info;
213 typedef struct _E_Policy_Wl_Tzlaunch_Appinfo
215 struct wl_resource *res_tzlaunch_appinfo; /* tizen_launch_appinfo */
216 } E_Policy_Wl_Tzlaunch_Appinfo;
218 typedef enum _Launch_Img_File_type
220 LAUNCH_IMG_FILE_TYPE_ERROR = -1,
221 LAUNCH_IMG_FILE_TYPE_IMAGE = 0,
222 LAUNCH_IMG_FILE_TYPE_EDJ
223 } Launch_Img_File_type;
225 typedef struct _E_Policy_Wl_Tz_Indicator
227 struct wl_resource *res_tz_indicator;
229 } E_Policy_Wl_Tz_Indicator;
231 typedef struct _E_Policy_Wl_Tz_Clipboard
233 struct wl_resource *res_tz_clipboard;
235 } E_Policy_Wl_Tz_Clipboard;
237 typedef struct _E_Policy_Wl
239 Eina_List *globals; /* list of wl_global */
240 Eina_Hash *tzpols; /* list of E_Policy_Wl_Tzpol */
242 Eina_List *tz_dpy_pols; /* list of E_Policy_Wl_Tz_Dpy_Pol */
243 Eina_List *pending_vis; /* list of clients that have pending visibility change*/
245 /* tizen_ws_shell_interface */
246 Eina_List *tzshs; /* list of E_Policy_Wl_Tzsh */
247 Eina_List *tzsh_srvs; /* list of E_Policy_Wl_Tzsh_Srv */
248 Eina_List *tzsh_clients; /* list of E_Policy_Wl_Tzsh_Client */
249 E_Policy_Wl_Tzsh_Srv *srvs[TZSH_SRV_ROLE_MAX]; /* list of registered E_Policy_Wl_Tzsh_Srv */
250 Eina_List *tz_indicators;
251 Eina_List *tz_clipboards; /* list of E_Policy_Wl_Tz_Clipboard */
253 /* tizen_launch_effect_interface */
254 Eina_List *tzlaunch_effect; /* list of E_Policy_Wl_Tzlaunch_Effect */
255 Eina_List *tzlaunch_effect_info; /* list of E_Policy_Wl_Tzlaunch_Effect_Info */
256 /* tizen_launch_appinfo_interface */
257 Eina_List *tzlaunch_appinfo; /* list of E_Policy_Wl_Tzlaunch_Appinfo */
258 /* tizen_ws_shell_interface ver_2 */
259 Eina_List *tzsh_extensions; /* list of E_Policy_Wl_Tzsh_Extension */
262 typedef struct _E_Tzsh_QP_Event
268 static E_Policy_Wl *polwl = NULL;
270 static Eina_List *handlers = NULL;
271 static Eina_List *polwl_hooks_ec = NULL;
272 static Eina_List *hooks_cw = NULL;
273 static Eina_List *hooks_co = NULL;
274 static struct wl_resource *_scrsaver_mng_res = NULL; // TODO
275 static struct wl_resource *_indicator_srv_res = NULL;
277 static int _e_policy_wl_hooks_delete = 0;
278 static int _e_policy_wl_hooks_walking = 0;
280 static Eina_Inlist *_e_policy_wl_hooks[] =
282 [E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET] = NULL,
285 EINTERN int E_EVENT_POLICY_INDICATOR_STATE_CHANGE = -1;
286 EINTERN int E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = -1;
287 EINTERN int E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = -1;
289 enum _E_Policy_Hint_Type
291 E_POLICY_HINT_USER_GEOMETRY = 0,
292 E_POLICY_HINT_FIXED_RESIZE = 1,
293 E_POLICY_HINT_DEICONIFY_UPDATE = 2,
294 E_POLICY_HINT_ICONIFY = 3,
295 E_POLICY_HINT_ABOVE_LOCKSCREEN = 4,
296 E_POLICY_HINT_GESTURE_DISABLE = 5,
297 E_POLICY_HINT_EFFECT_DISABLE = 6,
298 E_POLICY_HINT_MSG_USE = 7,
299 E_COMP_HINT_ALWAYS_SELECTIVE = 8,
300 E_POLICY_HINT_DEPENDENT_ROTATION = 9,
301 E_POLICY_HINT_ROT_RENDER_NOPENDING = 10,
302 E_POLICY_HINT_ICONIFY_BUFFER_FLUSH = 11,
303 E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP = 12,
304 E_POLICY_HINT_BELONG_TO_PARENT = 13,
305 E_POLICY_HINT_RESIZE_ASPECT_RATIO = 14,
306 E_POLICY_HINT_DECORATION_SIZE_HEADER = 15,
307 E_POLICY_HINT_DECORATION_SIZE_FOOTER = 16,
308 E_POLICY_HINT_VISIBILITY_IGNORE_GEOMETRY= 17,
309 E_POLICY_HINT_RESIZE_PPU = 18,
310 E_POLICY_HINT_DECORATION_SIZE_SHADOW_TOP = 19,
311 E_POLICY_HINT_DECORATION_SIZE_SHADOW_BOTTOM = 20,
312 E_POLICY_HINT_DECORATION_SIZE_SHADOW_LEFT = 21,
313 E_POLICY_HINT_DECORATION_SIZE_SHADOW_RIGHT = 22,
316 static const char *hint_names[] =
318 "wm.policy.win.user.geometry",
319 "wm.policy.win.fixed.resize",
320 "wm.policy.win.deiconify.update",
321 "wm.policy.win.iconify",
322 "wm.policy.win.above.lock",
323 "wm.policy.win.gesture.disable",
324 "wm.policy.win.effect.disable",
325 "wm.policy.win.msg.use",
326 "wm.comp.win.always.selective.mode",
327 "wm.policy.win.rot.dependent",
328 "wm.policy.win.rot.render.nopending",
329 "wm.policy.win.iconify.buffer.flush",
330 "wm.policy.win.transient_for.always_on_top",
331 "wm.policy.win.belong_to_parent",
332 "wm.policy.win.resize_aspect_ratio",
333 "wm.policy.win.decoration.size.header",
334 "wm.policy.win.decoration.size.footer",
335 "wm.policy.win.visibility.ignore_geometry",
336 "wm.policy.win.resize.ppu",
337 "wm.policy.win.decoration.size.shadow.top",
338 "wm.policy.win.decoration.size.shadow.bottom",
339 "wm.policy.win.decoration.size.shadow.left",
340 "wm.policy.win.decoration.size.shadow.right",
343 static void _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf);
344 static void _e_policy_wl_tzsh_srv_state_broadcast(E_Policy_Wl_Tzsh_Srv *tzsh_srv, Eina_Bool reg);
345 static Eina_Bool _e_policy_wl_e_client_is_valid(E_Client *ec);
346 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);
347 static void _e_policy_wl_tzsh_srv_del(E_Policy_Wl_Tzsh_Srv *tzsh_srv);
348 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);
349 static void _e_policy_wl_tzsh_client_del(E_Policy_Wl_Tzsh_Client *tzsh_client);
350 static void _e_policy_wl_background_state_set(E_Policy_Wl_Surface *psurf, Eina_Bool state);
352 static void _e_policy_wl_tzlaunch_effect_type_sync(E_Client *ec);
353 static int _e_policy_wl_tzlaunch_effect_type_get(const char* effect_type);
354 static void _e_policy_wl_tzlaunch_effect_type_unset(uint32_t pid);
356 static void _launch_effect_hide(uint32_t pid);
357 static void _launch_effect_client_del(E_Client *ec);
358 static void _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash);
360 // --------------------------------------------------------
362 // --------------------------------------------------------
365 _e_policy_wl_hooks_clean()
367 E_Policy_Wl_Hook *epwh = NULL;
368 Eina_Inlist *l = NULL;
371 for (x = 0; x < E_POLICY_WL_HOOK_LAST; x++)
373 EINA_INLIST_FOREACH_SAFE(_e_policy_wl_hooks[x], l, epwh)
375 if (!epwh->delete_me) continue;
376 _e_policy_wl_hooks[x] = eina_inlist_remove(_e_policy_wl_hooks[x], EINA_INLIST_GET(epwh));
383 _e_policy_wl_hook_call(E_Policy_Wl_Hook_Point hookpoint, pid_t pid)
385 E_Policy_Wl_Hook *epwh = NULL;
387 _e_policy_wl_hooks_walking++;
388 EINA_INLIST_FOREACH(_e_policy_wl_hooks[hookpoint], epwh)
390 if (epwh->delete_me) continue;
391 epwh->func(epwh->data, pid);
393 _e_policy_wl_hooks_walking--;
395 if ((_e_policy_wl_hooks_walking == 0) && (_e_policy_wl_hooks_delete > 0))
396 _e_policy_wl_hooks_clean();
399 E_API E_Policy_Wl_Hook *
400 e_policy_wl_hook_add(E_Policy_Wl_Hook_Point hookpoint, E_Policy_Wl_Hook_Cb func, const void *data)
402 E_Policy_Wl_Hook *epwh = NULL;
404 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0, NULL);
405 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_POLICY_WL_HOOK_LAST, NULL);
407 epwh = E_NEW(E_Policy_Wl_Hook, 1);
408 EINA_SAFETY_ON_NULL_RETURN_VAL(epwh, NULL);
410 epwh->hookpoint = hookpoint;
412 epwh->data = (void *)data;
413 _e_policy_wl_hooks[hookpoint] = eina_inlist_append(_e_policy_wl_hooks[hookpoint], EINA_INLIST_GET(epwh));
419 e_policy_wl_hook_del(E_Policy_Wl_Hook *epwh)
422 if (_e_policy_wl_hooks_walking == 0)
424 _e_policy_wl_hooks[epwh->hookpoint] = eina_inlist_remove(_e_policy_wl_hooks[epwh->hookpoint], EINA_INLIST_GET(epwh));
428 _e_policy_wl_hooks_delete++;
431 // --------------------------------------------------------
433 // --------------------------------------------------------
435 _e_policy_wl_tzpol_background_state_check(pid_t pid)
437 E_Policy_Wl_Tzpol *tzpol;
439 Eina_Bool bg_state = EINA_FALSE;
444 it = eina_hash_iterator_data_new(polwl->tzpols);
445 EINA_ITERATOR_FOREACH(it, tzpol)
447 if (tzpol->pid == pid)
451 bg_state = EINA_TRUE;
456 eina_iterator_free(it);
461 static E_Policy_Wl_Tzpol *
462 _e_policy_wl_tzpol_add(struct wl_client *client, struct wl_resource *res_tzpol)
464 E_Policy_Wl_Tzpol *tzpol;
467 tzpol = E_NEW(E_Policy_Wl_Tzpol, 1);
468 EINA_SAFETY_ON_NULL_RETURN_VAL(tzpol, NULL);
470 eina_hash_add(polwl->tzpols, &res_tzpol, tzpol);
472 tzpol->res_tzpol = res_tzpol;
474 wl_client_get_credentials(client, &pid, NULL, NULL);
477 tzpol->bg_state = _e_policy_wl_tzpol_background_state_check(pid);
483 _e_policy_wl_tzpol_del(void *data)
485 E_Policy_Wl_Tzpol *tzpol;
486 E_Policy_Wl_Surface *psurf;
488 tzpol = (E_Policy_Wl_Tzpol *)data;
490 EINA_LIST_FREE(tzpol->psurfs, psurf)
492 _e_policy_wl_surf_del(psurf);
495 memset(tzpol, 0x0, sizeof(E_Policy_Wl_Tzpol));
499 static E_Policy_Wl_Tzpol *
500 _e_policy_wl_tzpol_get(struct wl_resource *res_tzpol)
502 return (E_Policy_Wl_Tzpol *)eina_hash_find(polwl->tzpols, &res_tzpol);
505 static E_Policy_Wl_Surface *
506 _e_policy_wl_tzpol_surf_find(E_Policy_Wl_Tzpol *tzpol, E_Client *ec)
509 E_Policy_Wl_Surface *psurf;
511 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
521 _e_policy_wl_surf_is_valid(E_Policy_Wl_Surface *psurf)
523 E_Policy_Wl_Tzpol *tzpol;
524 E_Policy_Wl_Surface *psurf2;
528 it = eina_hash_iterator_data_new(polwl->tzpols);
529 EINA_ITERATOR_FOREACH(it, tzpol)
530 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf2)
534 eina_iterator_free(it);
538 eina_iterator_free(it);
543 // --------------------------------------------------------
545 // --------------------------------------------------------
548 _print_tzsh_service_info(void)
550 E_Policy_Wl_Tzsh_Srv *tzsh_srv = NULL;
554 ELOGF("TZSH", "================ TZSH SERVICE LIST ================", NULL);
555 EINA_LIST_FOREACH(polwl->tzsh_srvs, l, tzsh_srv)
557 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);
560 ELOGF("TZSH", "---------------------------------------------------", NULL);
564 _print_tzsh_client_info(void)
566 E_Policy_Wl_Tzsh_Client *tzsh_client = NULL;
570 ELOGF("TZSH", "================ TZSH CLIENT LIST ================", NULL);
571 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
573 ELOGF("TZSH", "[%d] tzsh_client(%p). tzsh:%p", tzsh_client->ec, i, tzsh_client, tzsh_client->tzsh);
576 ELOGF("TZSH", "---------------------------------------------------", NULL);
580 static E_Policy_Wl_Tzsh *
581 _e_policy_wl_tzsh_add(struct wl_resource *res_tzsh)
583 E_Policy_Wl_Tzsh *tzsh;
585 tzsh = E_NEW(E_Policy_Wl_Tzsh, 1);
586 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh, NULL);
588 ELOGF("TZSH", "NEW tzsh:%p, res_tzsh:%p", NULL, tzsh, res_tzsh);
590 tzsh->res_tzsh = res_tzsh;
592 polwl->tzshs = eina_list_append(polwl->tzshs, tzsh);
595 _print_tzsh_service_info();
596 _print_tzsh_client_info();
603 _e_policy_wl_tzsh_del(E_Policy_Wl_Tzsh *tzsh)
605 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
606 E_Policy_Wl_Tzsh_Client *tzsh_client;
609 polwl->tzshs = eina_list_remove(polwl->tzshs, tzsh);
611 EINA_LIST_FOREACH_SAFE(polwl->tzsh_srvs, l, ll, tzsh_srv)
613 if (tzsh_srv->tzsh != tzsh) continue;
614 _e_policy_wl_tzsh_srv_del(tzsh_srv);
617 if (tzsh->service_list)
619 EINA_LIST_FOREACH_SAFE(tzsh->service_list, l, ll, tzsh_srv)
621 _e_policy_wl_tzsh_srv_del(tzsh_srv);
623 eina_list_free(tzsh->service_list);
624 tzsh->service_list = NULL;
627 EINA_LIST_FOREACH_SAFE(polwl->tzsh_clients, l, ll, tzsh_client)
629 if (tzsh_client->tzsh != tzsh) continue;
630 _e_policy_wl_tzsh_client_del(tzsh_client);
633 if (tzsh->client_list)
635 EINA_LIST_FOREACH_SAFE(tzsh->client_list, l, ll, tzsh_client)
637 _e_policy_wl_tzsh_client_del(tzsh_client);
639 eina_list_free(tzsh->client_list);
640 tzsh->client_list = NULL;
644 _print_tzsh_service_info();
645 _print_tzsh_client_info();
648 ELOGF("TZSH", "FREE tzsh:%p", NULL, tzsh);
650 memset(tzsh, 0x0, sizeof(E_Policy_Wl_Tzsh));
654 /* notify current registered services to the client */
656 _e_policy_wl_tzsh_registered_srv_send(E_Policy_Wl_Tzsh *tzsh)
660 for (i = 0; i < TZSH_SRV_ROLE_MAX; i++)
662 if (!polwl->srvs[i]) continue;
664 tizen_ws_shell_send_service_register
665 (tzsh->res_tzsh, polwl->srvs[i]->name);
670 _e_policy_wl_tzsh_srv_cb_client_zone_set(void *data, int type EINA_UNUSED, void *event)
672 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
673 E_Event_Client_Zone_Set *ev;
678 if (tzsh_srv->ec != ev->ec)
681 if (tzsh_srv->zone == ev->zone)
684 ELOGF("TZSH", "Change Zone | e_policy_wl_tzsh_srv %p old(%p) new(%p)",
685 tzsh_srv->ec, tzsh_srv, tzsh_srv->zone, ev->zone);
687 tzsh_srv->zone = ev->zone;
690 return ECORE_CALLBACK_PASS_ON;
693 // --------------------------------------------------------
694 // E_Policy_Wl_Tzsh_Srv
695 // --------------------------------------------------------
696 static E_Policy_Wl_Tzsh_Srv *
697 _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)
699 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
701 tzsh_srv = E_NEW(E_Policy_Wl_Tzsh_Srv, 1);
702 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_srv, NULL);
704 tzsh_srv->tzsh = tzsh;
705 tzsh_srv->res_tzsh_srv = res_tzsh_srv;
706 tzsh_srv->role = role;
707 tzsh_srv->name = eina_stringshare_add(name);
710 tzsh_srv->zone = e_comp_zone_find_by_ec(ec);
711 e_object_ref(E_OBJECT(ec));
712 tzsh_srv->tzsh->service_list = eina_list_append(tzsh_srv->tzsh->service_list, tzsh_srv);
714 polwl->srvs[role] = tzsh_srv;
715 polwl->tzsh_srvs = eina_list_append(polwl->tzsh_srvs, tzsh_srv);
717 ELOGF("TZSH", "CREATE tzsh_srv:%p, res_tzsh_srv:%p", ec, tzsh_srv, res_tzsh_srv);
720 _print_tzsh_service_info();
723 _e_policy_wl_tzsh_srv_state_broadcast(tzsh_srv, EINA_TRUE);
725 E_LIST_HANDLER_APPEND(tzsh_srv->events, E_EVENT_CLIENT_ZONE_SET, _e_policy_wl_tzsh_srv_cb_client_zone_set, tzsh_srv);
731 _e_policy_wl_tzsh_srv_del(E_Policy_Wl_Tzsh_Srv *tzsh_srv)
733 E_FREE_LIST(tzsh_srv->events, ecore_event_handler_del);
735 polwl->tzsh_srvs = eina_list_remove(polwl->tzsh_srvs, tzsh_srv);
738 _print_tzsh_service_info();
741 if (tzsh_srv->tzsh && tzsh_srv->tzsh->service_list)
742 tzsh_srv->tzsh->service_list = eina_list_remove(tzsh_srv->tzsh->service_list, tzsh_srv);
744 if (polwl->srvs[tzsh_srv->role] == tzsh_srv)
745 polwl->srvs[tzsh_srv->role] = NULL;
747 _e_policy_wl_tzsh_srv_state_broadcast(tzsh_srv, EINA_FALSE);
750 eina_stringshare_del(tzsh_srv->name);
752 if (tzsh_srv->role == TZSH_SRV_ROLE_INDICATOR)
757 if (ec && ec->internal)
759 e_pixmap_win_id_del(tzsh_srv->ep);
760 e_object_del(E_OBJECT(ec));
763 _indicator_srv_res = NULL;
765 else if (tzsh_srv->role == TZSH_SRV_ROLE_SOFTKEY)
767 E_Client *softkey_ec = NULL;
769 softkey_ec = tzsh_srv->ec;
772 e_service_softkey_client_unset(softkey_ec);
775 else if (tzsh_srv->role == TZSH_SRV_ROLE_MAGNIFIER)
777 E_Client *magnifier_ec = NULL;
779 magnifier_ec = tzsh_srv->ec;
782 e_magnifier_owner_unset(magnifier_ec);
786 else if (tzsh_srv->role == TZSH_SRV_ROLE_LAUNCHER)
788 E_Client *launcher_ec = NULL;
790 launcher_ec = tzsh_srv->ec;
793 e_service_launcher_client_unset(launcher_ec);
797 ELOGF("TZSH", "FREE tzsh_srv:%p", tzsh_srv->ec, tzsh_srv);
801 e_object_unref(E_OBJECT(tzsh_srv->ec));
805 if (tzsh_srv->res_tzsh_srv)
806 wl_resource_set_user_data(tzsh_srv->res_tzsh_srv, NULL);
808 memset(tzsh_srv, 0x0, sizeof(E_Policy_Wl_Tzsh_Srv));
813 _e_policy_wl_tzsh_srv_role_get(const char *name)
815 Tzsh_Srv_Role role = TZSH_SRV_ROLE_UNKNOWN;
817 if (!e_util_strcmp(name, "volume" )) role = TZSH_SRV_ROLE_VOLUME;
818 else if (!e_util_strcmp(name, "quickpanel_system_default")) role = TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT;
819 else if (!e_util_strcmp(name, "quickpanel_context_menu" )) role = TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU;
820 else if (!e_util_strcmp(name, "quickpanel_apps_menu" )) role = TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU;
821 else if (!e_util_strcmp(name, "lockscreen" )) role = TZSH_SRV_ROLE_LOCKSCREEN;
822 else if (!e_util_strcmp(name, "indicator" )) role = TZSH_SRV_ROLE_INDICATOR;
823 else if (!e_util_strcmp(name, "screensaver_manager" )) role = TZSH_SRV_ROLE_SCREENSAVER_MNG;
824 else if (!e_util_strcmp(name, "screensaver" )) role = TZSH_SRV_ROLE_SCREENSAVER;
825 else if (!e_util_strcmp(name, "cbhm" )) role = TZSH_SRV_ROLE_CBHM;
826 else if (!e_util_strcmp(name, "softkey" )) role = TZSH_SRV_ROLE_SOFTKEY;
827 else if (!e_util_strcmp(name, "magnifier" )) role = TZSH_SRV_ROLE_MAGNIFIER;
828 else if (!e_util_strcmp(name, "launcher" )) role = TZSH_SRV_ROLE_LAUNCHER;
829 else if (!e_util_strcmp(name, "taskbar" )) role = TZSH_SRV_ROLE_TASKBAR;
830 else if (!e_util_strcmp(name, "KVM" )) role = TZSH_SRV_ROLE_KVM;
835 /* broadcast state of registered service to all subscribers */
837 _e_policy_wl_tzsh_srv_state_broadcast(E_Policy_Wl_Tzsh_Srv *tzsh_srv, Eina_Bool reg)
839 E_Policy_Wl_Tzsh *tzsh;
842 EINA_LIST_FOREACH(polwl->tzshs, l, tzsh)
844 if (tzsh_srv->tzsh == tzsh)
848 tizen_ws_shell_send_service_register
849 (tzsh->res_tzsh, tzsh_srv->name);
851 tizen_ws_shell_send_service_unregister
852 (tzsh->res_tzsh, tzsh_srv->name);
856 // --------------------------------------------------------
857 // E_Policy_Wl_Tzsh_Client
858 // --------------------------------------------------------
860 _e_policy_wl_tzsh_client_cb_client_zone_set(void *data, int type EINA_UNUSED, void *event)
862 E_Policy_Wl_Tzsh_Client *tzsh_client;
863 E_Event_Client_Zone_Set *ev;
868 if (tzsh_client->ec != ev->ec)
871 if (tzsh_client->zone == ev->zone)
874 ELOGF("TZSH", "Change Zone | e_policy_wl_tzsh_client %p old(%p) new(%p)",
875 tzsh_client->ec, tzsh_client, tzsh_client->zone, ev->zone);
877 tzsh_client->zone = ev->zone;
880 return ECORE_CALLBACK_PASS_ON;
883 static E_Policy_Wl_Tzsh_Client *
884 _e_policy_wl_tzsh_client_add(E_Policy_Wl_Tzsh *tzsh, struct wl_resource *res_tzsh_client, E_Pixmap *ep, E_Client *ec)
886 E_Policy_Wl_Tzsh_Client *tzsh_client;
888 tzsh_client = E_NEW(E_Policy_Wl_Tzsh_Client, 1);
889 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client, NULL);
891 tzsh_client->tzsh = tzsh;
892 tzsh_client->res_tzsh_client = res_tzsh_client;
893 tzsh_client->ep = ep;
894 tzsh_client->ec = ec;
895 tzsh_client->zone = e_comp_zone_find_by_ec(ec);
896 tzsh_client->tzsh->client_list = eina_list_append(tzsh_client->tzsh->client_list, tzsh_client);
898 polwl->tzsh_clients = eina_list_append(polwl->tzsh_clients, tzsh_client);
900 E_LIST_HANDLER_APPEND(tzsh_client->events, E_EVENT_CLIENT_ZONE_SET, _e_policy_wl_tzsh_client_cb_client_zone_set, tzsh_client);
903 _print_tzsh_client_info();
910 _e_policy_wl_tzsh_client_del(E_Policy_Wl_Tzsh_Client *tzsh_client)
912 if (!tzsh_client) return;
914 E_FREE_LIST(tzsh_client->events, ecore_event_handler_del);
916 if (tzsh_client->tzsh && tzsh_client->tzsh->client_list)
917 tzsh_client->tzsh->client_list = eina_list_remove(tzsh_client->tzsh->client_list, tzsh_client);
919 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
922 polwl->tzsh_clients = eina_list_remove(polwl->tzsh_clients, tzsh_client);
924 _print_tzsh_client_info();
927 if (tzsh_client->res_tzsh_client)
928 wl_resource_set_user_data(tzsh_client->res_tzsh_client, NULL);
930 memset(tzsh_client, 0x0, sizeof(E_Policy_Wl_Tzsh_Client));
934 static E_Policy_Wl_Tzsh_Extension*
935 _e_policy_wl_tzsh_extension_get(const char *name)
937 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
940 EINA_LIST_FOREACH(polwl->tzsh_extensions, l, tzsh_ext)
942 if (strcmp(tzsh_ext->name, name)) continue;
951 // --------------------------------------------------------
952 // E_Policy_Wl_Surface
953 // --------------------------------------------------------
954 static E_Policy_Wl_Surface *
955 _e_policy_wl_surf_add(E_Client *ec, struct wl_resource *res_tzpol)
957 E_Comp_Wl_Client_Data *cdata;
958 E_Policy_Wl_Surface *psurf = NULL;
959 E_Policy_Wl_Tzpol *tzpol;
961 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
962 EINA_SAFETY_ON_NULL_RETURN_VAL(tzpol, NULL);
964 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
965 if (psurf) return psurf;
967 psurf = E_NEW(E_Policy_Wl_Surface, 1);
968 EINA_SAFETY_ON_NULL_RETURN_VAL(psurf, NULL);
970 psurf->tzpol = tzpol;
971 psurf->cp = ec->pixmap;
973 psurf->pid = ec->netwm.pid;
975 cdata = e_client_cdata_get(ec);
976 if (wl_resource_get_client(cdata->surface) == wl_resource_get_client(res_tzpol))
977 psurf->surf = cdata->surface;
979 tzpol->psurfs = eina_list_append(tzpol->psurfs, psurf);
982 _e_policy_wl_background_state_set(psurf, EINA_TRUE);
988 _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf)
990 eina_list_free(psurf->vislist);
991 eina_list_free(psurf->poslist);
993 memset(psurf, 0x0, sizeof(E_Policy_Wl_Surface));
998 _e_policy_wl_surf_client_set(E_Client *ec)
1000 E_Policy_Wl_Tzpol *tzpol;
1001 E_Policy_Wl_Surface *psurf;
1004 it = eina_hash_iterator_data_new(polwl->tzpols);
1005 EINA_ITERATOR_FOREACH(it, tzpol)
1007 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
1010 if ((psurf->ec) && (psurf->ec != ec))
1013 "CRI ERR!!|s:%8p|tzpol:%8p|ps:%8p|new_ec:%8p|new_cp:%8p",
1025 eina_iterator_free(it);
1031 _e_policy_wl_e_pixmap_get_from_id(struct wl_client *client, uint32_t id)
1035 struct wl_resource *res_surf;
1037 res_surf = wl_client_get_object(client, id);
1040 ERR("Could not get surface resource");
1044 ec = e_client_from_surface_resource(res_surf);
1047 ERR("Could not get surface's user data");
1051 /* check E_Pixmap */
1052 cp = e_pixmap_find(E_PIXMAP_TYPE_WL, (uintptr_t)res_surf);
1053 if (cp != ec->pixmap)
1056 "CRI ERR!!|cp2:%8p|ec2:%8p|res_surf:%8p",
1059 e_pixmap_client_get(cp),
1068 _e_policy_wl_e_client_is_valid(E_Client *ec)
1072 Eina_Bool del = EINA_FALSE;
1073 Eina_Bool found = EINA_FALSE;
1075 EINA_LIST_FOREACH(e_comp->clients, l, ec2)
1079 if (e_object_is_del(E_OBJECT(ec2)))
1086 return ((!del) && (found));
1090 _e_policy_wl_e_clients_find_by_pid(pid_t pid)
1093 Eina_List *clients = NULL, *l;
1095 EINA_LIST_FOREACH(e_comp->clients, l, ec)
1097 if (e_object_is_del(E_OBJECT(ec))) continue;
1098 if (ec->netwm.pid != pid) continue;
1099 clients = eina_list_append(clients, ec);
1105 // --------------------------------------------------------
1107 // --------------------------------------------------------
1109 _tzvis_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzvis)
1111 wl_resource_destroy(res_tzvis);
1114 static const struct tizen_visibility_interface _tzvis_iface =
1116 _tzvis_iface_cb_destroy
1120 _tzvis_iface_cb_vis_destroy(struct wl_resource *res_tzvis)
1122 E_Policy_Wl_Surface *psurf;
1125 psurf = wl_resource_get_user_data(res_tzvis);
1126 EINA_SAFETY_ON_NULL_RETURN(psurf);
1128 r = _e_policy_wl_surf_is_valid(psurf);
1131 psurf->vislist = eina_list_remove(psurf->vislist, res_tzvis);
1135 _tzpol_iface_cb_vis_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
1138 E_Policy_Wl_Surface *psurf;
1139 struct wl_resource *res_tzvis;
1141 ec = e_client_from_surface_resource(surf);
1142 EINA_SAFETY_ON_NULL_RETURN(ec);
1144 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
1145 EINA_SAFETY_ON_NULL_RETURN(psurf);
1147 res_tzvis = wl_resource_create(client,
1148 &tizen_visibility_interface,
1149 wl_resource_get_version(res_tzpol),
1153 wl_client_post_no_memory(client);
1157 wl_resource_set_implementation(res_tzvis,
1160 _tzvis_iface_cb_vis_destroy);
1162 psurf->vislist = eina_list_append(psurf->vislist, res_tzvis);
1164 if (eina_list_data_find(polwl->pending_vis, ec))
1166 e_policy_wl_visibility_send(ec, e_client_visibility_get(ec));
1171 e_policy_wl_visibility_send(E_Client *ec, int vis)
1173 E_Comp_Wl_Client_Data *cdata;
1174 E_Policy_Wl_Tzpol *tzpol;
1175 E_Policy_Wl_Surface *psurf;
1176 struct wl_resource *res_tzvis;
1181 Eina_Bool sent = EINA_FALSE;
1183 int sent_vis = E_VISIBILITY_UNKNOWN;
1185 EINA_SAFETY_ON_TRUE_RETURN(vis == E_VISIBILITY_UNKNOWN);
1186 if (ec && (ec->visibility.last_sent_type == vis))
1189 win = e_client_util_win_get(ec);
1191 it = eina_hash_iterator_data_new(polwl->tzpols);
1192 EINA_ITERATOR_FOREACH(it, tzpol)
1193 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1195 ec2 = e_pixmap_client_get(psurf->cp);
1196 if (ec2 != ec) continue;
1198 EINA_LIST_FOREACH(psurf->vislist, ll, res_tzvis)
1200 // below code is workaround for checking visibility by display off or not
1201 if (e_comp_client_zone_is_displaying(ec))
1202 e_policy_aux_message_send(ec, "dpms_wm", "on", NULL);
1204 e_policy_aux_message_send(ec, "dpms_wm", "off", NULL);
1206 ver = wl_resource_get_version(res_tzvis);
1209 if (vis == E_VISIBILITY_PRE_UNOBSCURED)
1213 ec->visibility.last_sent_type = vis;
1214 tizen_visibility_send_changed(res_tzvis, vis, 0);
1221 if ((vis >= E_VISIBILITY_UNOBSCURED) && (vis <= E_VISIBILITY_FULLY_OBSCURED))
1223 ec->visibility.last_sent_type = vis;
1224 tizen_visibility_send_notify(res_tzvis, vis);
1230 cdata = e_client_cdata_get(ec);
1231 if (cdata && cdata->mapped)
1233 _launch_effect_hide(ec->netwm.pid);
1237 "SEND |win:0x%08zx|res_tzvis:%8p|ver:%d|sent_vis:%d|pid:%d|cdata:%8p|title:%s, name:%s",
1243 ec->netwm.pid, cdata, ec->icccm.title, ec->netwm.name);
1247 eina_iterator_free(it);
1249 polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
1251 polwl->pending_vis = eina_list_append(polwl->pending_vis, ec);
1255 e_policy_wl_iconify_state_supported_get(E_Client *ec)
1257 E_Policy_Wl_Tzpol *tzpol;
1258 E_Policy_Wl_Surface *psurf;
1262 Eina_Bool found = EINA_FALSE;
1264 it = eina_hash_iterator_data_new(polwl->tzpols);
1265 EINA_ITERATOR_FOREACH(it, tzpol)
1266 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1268 ec2 = e_pixmap_client_get(psurf->cp);
1275 eina_iterator_free(it);
1281 e_policy_wl_iconify_state_change_send(E_Client *ec, int iconic)
1283 E_Policy_Wl_Tzpol *tzpol;
1284 E_Policy_Wl_Surface *psurf;
1289 if (ec->exp_iconify.skip_iconify) return;
1290 if (ec->exp_iconify.skip_by_remote) return;
1292 if (e_config->transient.iconify)
1294 E_Comp_Wl_Client_Data *cdata;
1296 Eina_List *list = eina_list_clone(ec->transients);
1298 EINA_LIST_FREE(list, child)
1300 cdata = e_client_cdata_get(child);
1301 if (cdata && !cdata->mapped) continue;
1303 if ((child->iconic == ec->iconic) &&
1304 (e_client_is_iconified_by_client(child) == e_client_is_iconified_by_client(ec)))
1305 e_policy_wl_iconify_state_change_send(child, iconic);
1310 it = eina_hash_iterator_data_new(polwl->tzpols);
1311 EINA_ITERATOR_FOREACH(it, tzpol)
1312 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1314 ec2 = e_pixmap_client_get(psurf->cp);
1315 if (ec2 != ec) continue;
1316 if (!psurf->surf) continue;
1318 tizen_policy_send_iconify_state_changed(tzpol->res_tzpol, psurf->surf, iconic, 1);
1320 "SEND |iconic:%d |argb:%d |sur:%p",
1322 iconic, ec->argb, psurf->surf);
1323 ec->exp_iconify.last_sent_iconic = iconic;
1326 eina_iterator_free(it);
1329 // --------------------------------------------------------
1331 // --------------------------------------------------------
1333 _tzpos_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpos)
1335 wl_resource_destroy(res_tzpos);
1339 _tzpos_iface_cb_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpos, int32_t x, int32_t y)
1342 E_Policy_Wl_Surface *psurf;
1345 psurf = wl_resource_get_user_data(res_tzpos);
1346 EINA_SAFETY_ON_NULL_RETURN(psurf);
1348 ec = e_pixmap_client_get(psurf->cp);
1349 EINA_SAFETY_ON_NULL_RETURN(ec);
1350 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1352 if (e_policy_client_is_keyboard(ec))
1354 ELOGF("TZPOL", "Keyboard pos set (%d, %d). No operation. return.", ec, x, y);
1358 desk = e_comp_desk_find_by_ec(ec);
1359 EINA_SAFETY_ON_NULL_RETURN(desk);
1361 if (!ec->lock_client_location)
1363 if (e_client_pending_geometry_has(ec))
1365 // if there is geometry pending list, add move job at the end of the list.
1366 // so client to be applied new position at the same time with the pending requests
1367 // pending geometries are flushed when 'wl surface commit' and matched serial are delivered.
1369 e_client_pending_geometry_last_geometry_get(ec, NULL, NULL, &w, &h);
1370 e_comp_wl_commit_sync_client_geometry_add(ec, ec->surface_sync.serial, x, y, w, h);
1374 ec->client.x = desk->geom.x + x;
1375 ec->client.y = desk->geom.y + y;
1376 e_client_pos_set(ec, ec->client.x, ec->client.y);
1378 ec->changes.pos = 1;
1380 ec->changes.tz_position = 1;
1384 e_policy_hook_call(E_POLICY_HOOK_CLIENT_POSITION_SET, ec);
1387 static const struct tizen_position_interface _tzpos_iface =
1389 _tzpos_iface_cb_destroy,
1390 _tzpos_iface_cb_set,
1394 _tzpol_iface_cb_pos_destroy(struct wl_resource *res_tzpos)
1396 E_Policy_Wl_Surface *psurf;
1399 psurf = wl_resource_get_user_data(res_tzpos);
1400 EINA_SAFETY_ON_NULL_RETURN(psurf);
1402 r = _e_policy_wl_surf_is_valid(psurf);
1405 psurf->poslist = eina_list_remove(psurf->poslist, res_tzpos);
1409 _tzpol_iface_cb_pos_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
1412 E_Policy_Wl_Surface *psurf;
1413 struct wl_resource *res_tzpos;
1415 ec = e_client_from_surface_resource(surf);
1416 EINA_SAFETY_ON_NULL_RETURN(ec);
1418 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
1419 EINA_SAFETY_ON_NULL_RETURN(psurf);
1421 res_tzpos = wl_resource_create(client,
1422 &tizen_position_interface,
1423 wl_resource_get_version(res_tzpol),
1427 wl_client_post_no_memory(client);
1431 wl_resource_set_implementation(res_tzpos,
1434 _tzpol_iface_cb_pos_destroy);
1436 psurf->poslist = eina_list_append(psurf->poslist, res_tzpos);
1438 // if ec's pos is not same to client's geometry (ec->comp_data->shell.window),
1439 // then send tizen_position changed event
1442 if ((ec->x != ec->comp_data->shell.window.x) ||
1443 (ec->y != ec->comp_data->shell.window.y))
1444 e_policy_wl_position_send(ec);
1449 e_policy_wl_position_send(E_Client *ec)
1451 E_Policy_Wl_Tzpol *tzpol;
1452 E_Policy_Wl_Surface *psurf;
1453 struct wl_resource *res_tzpos;
1458 EINA_SAFETY_ON_NULL_RETURN(ec);
1460 win = e_client_util_win_get(ec);
1462 it = eina_hash_iterator_data_new(polwl->tzpols);
1463 EINA_ITERATOR_FOREACH(it, tzpol)
1464 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
1466 if (e_pixmap_client_get(psurf->cp) != ec) continue;
1468 EINA_LIST_FOREACH(psurf->poslist, ll, res_tzpos)
1470 tizen_position_send_changed(res_tzpos, ec->client.x, ec->client.y);
1472 "SEND |win:0x%08zx|res_tzpos:%8p|ec->x:%d, ec->y:%d, ec->client.x:%d, ec->client.y:%d",
1477 ec->client.x, ec->client.y);
1480 eina_iterator_free(it);
1483 // --------------------------------------------------------
1484 // stack: activate, raise, lower
1485 // --------------------------------------------------------
1488 e_policy_wl_activate(E_Client *ec)
1490 EINA_SAFETY_ON_NULL_RETURN(ec);
1491 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1493 ELOGF("TZPOL", "REAL ACTIVATE", ec);
1495 e_policy_visibility_client_lower_job_cancel(ec);
1497 if ((!starting) && (!ec->focused))
1499 if (!e_policy_visibility_client_activate(ec))
1501 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1502 e_policy_wl_iconify_state_change_send(ec, 0);
1504 if (!ec->visibility.force_obscured)
1505 e_client_activate(ec);
1510 if (!ec->lock_user_stacking)
1514 if (e_policy_client_is_lockscreen(ec))
1515 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
1517 e_policy_stack_check_above_lockscreen(ec, ec->layer);
1521 _tzpol_iface_cb_activate(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1524 E_Comp_Wl_Client_Data *cdata;
1526 ec = e_client_from_surface_resource(surf);
1527 EINA_SAFETY_ON_NULL_RETURN(ec);
1528 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1530 ELOGF("TZPOL", "ACTIVATE", ec);
1533 e_policy_stack_transient_child_raise(ec);
1535 e_policy_hook_call(E_POLICY_HOOK_CLIENT_ACTIVE_REQ, ec);
1537 ec->post_lower = EINA_FALSE;
1538 cdata = e_client_cdata_get(ec);
1539 if (cdata && !cdata->mapped)
1541 if (e_config->raise_before_show)
1544 ec->post_raise = EINA_TRUE;
1546 e_policy_wl_activate(ec);
1550 e_policy_wl_stack_changed_send(E_Client *ec)
1552 E_Client *above = NULL;
1553 E_Client *below = NULL;
1557 above = e_client_above_get(ec);
1560 if ((!e_object_is_del(E_OBJECT(above))) &&
1561 (!e_client_util_ignored_get(above)) &&
1566 above = e_client_above_get(above);
1569 below = e_client_below_get(ec);
1572 if ((!e_object_is_del(E_OBJECT(below))) &&
1573 (!e_client_util_ignored_get(below)) &&
1578 below = e_client_below_get(below);
1581 if (above) above_pid = above->netwm.pid;
1582 if (below) below_pid = below->netwm.pid;
1584 ELOGF("TZPOL", "Send stack_changed by activate_below. above(win:%zx, pid:%d), below(win:%zx, pid:%d)",
1585 ec, e_client_util_win_get(above), above_pid, e_client_util_win_get(below), below_pid);
1588 e_policy_aux_message_send_from_int(ec, "stack_changed", "activate_below", 2, above_pid, below_pid);
1593 _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)
1595 E_Client *ec = NULL;
1596 E_Client *below_ec = NULL;
1597 E_Client *parent_ec = NULL;
1598 E_Client *focus_ec = NULL;
1599 E_Comp_Wl_Client_Data *cdata;
1600 Eina_Bool check_ancestor = EINA_FALSE;
1601 Eina_Bool intercepted = EINA_FALSE;
1603 ec = e_pixmap_find_client_by_res_id(res_id);
1604 EINA_SAFETY_ON_NULL_RETURN(ec);
1605 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1607 below_ec = e_pixmap_find_client_by_res_id(below_res_id);
1608 EINA_SAFETY_ON_NULL_RETURN(below_ec);
1609 EINA_SAFETY_ON_NULL_RETURN(below_ec->frame);
1612 "ACTIVATE_BELOW|win:0x%08zx(res_id:%d)|below_win:0x%08zx(res_id:%d)",
1613 NULL, e_client_util_win_get(ec), res_id, e_client_util_win_get(below_ec), below_res_id);
1615 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_ACTIVATE_BELOW,
1619 ELOGF("TZPOL", "ACTIVATE_BELOW|Handled by Intercept function", ec);
1623 if (ec->layer > below_ec->layer) return;
1625 parent_ec = ec->parent;
1628 if (parent_ec == below_ec)
1630 check_ancestor = EINA_TRUE;
1633 parent_ec = parent_ec->parent;
1635 if (check_ancestor) return;
1637 if ((!starting) && (!ec->focused))
1639 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1640 e_policy_wl_iconify_state_change_send(ec, 0);
1642 e_client_uniconify(ec);
1645 e_policy_stack_below(ec, below_ec);
1647 cdata = e_client_cdata_get(ec);
1648 if (cdata && !cdata->mapped)
1650 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1651 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1654 e_policy_wl_stack_changed_send(ec);
1657 focus_ec = e_client_focused_get();
1658 if (focus_ec == below_ec)
1659 e_client_focus_latest_set(ec);
1663 _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)
1665 E_Client *ec = NULL;
1666 E_Comp_Wl_Client_Data *cdata;
1667 E_Client *above_ec = NULL;
1668 E_Client *parent_ec = NULL;
1669 Eina_Bool check_ancestor = EINA_FALSE;
1670 Eina_Bool intercepted = EINA_FALSE;
1672 ec = e_pixmap_find_client_by_res_id(res_id);
1673 EINA_SAFETY_ON_NULL_RETURN(ec);
1674 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1676 above_ec = e_pixmap_find_client_by_res_id(above_res_id);
1677 EINA_SAFETY_ON_NULL_RETURN(above_ec);
1678 EINA_SAFETY_ON_NULL_RETURN(above_ec->frame);
1681 "ACTIVATE_ABOVE|win:0x%08zx(res_id:%d)|above_win:0x%08zx(res_id:%d)",
1682 NULL, e_client_util_win_get(ec), res_id, e_client_util_win_get(above_ec), above_res_id);
1684 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_ACTIVATE_ABOVE,
1688 ELOGF("TZPOL", "ACTIVATE_ABOVE|Handled by Intercept function", ec);
1692 if (ec->layer < above_ec->layer) return;
1695 parent_ec = above_ec->parent;
1698 if (parent_ec == ec)
1700 check_ancestor = EINA_TRUE;
1703 parent_ec = parent_ec->parent;
1705 if (check_ancestor) return;
1707 if (ec->parent && (ec->parent == above_ec))
1709 if (e_client_transient_policy_get(ec) == E_TRANSIENT_BELOW)
1711 ELOGF("TZPOL", "ACTIVATE_ABOVE|Denied. Above is transient_below parent", ec);
1718 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
1719 e_policy_wl_iconify_state_change_send(ec, 0);
1721 e_client_uniconify(ec);
1724 e_policy_stack_above(ec, above_ec);
1726 cdata = e_client_cdata_get(ec);
1727 if (cdata && !cdata->mapped)
1729 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1730 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1735 _tzpol_iface_cb_raise(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1738 E_Comp_Wl_Client_Data *cdata;
1740 ec = e_client_from_surface_resource(surf);
1741 EINA_SAFETY_ON_NULL_RETURN(ec);
1742 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1744 ELOGF("TZPOL", "RAISE", ec);
1747 e_policy_stack_transient_child_raise(ec);
1749 e_policy_hook_call(E_POLICY_HOOK_CLIENT_RAISE_REQ, ec);
1753 cdata = e_client_cdata_get(ec);
1754 if (cdata && !cdata->mapped)
1756 if (e_config->raise_before_show)
1758 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_FALSE);
1759 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_FALSE);
1763 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_TRUE, EINA_FALSE);
1764 e_client_post_raise_lower_set(ec, EINA_TRUE, EINA_FALSE);
1768 e_policy_hook_call(E_POLICY_HOOK_CLIENT_RAISE_REQ_DONE, ec);
1772 _tzpol_iface_cb_lower(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1774 E_Client *ec = NULL;
1775 E_Comp_Wl_Client_Data *cdata;
1777 ec = e_client_from_surface_resource(surf);
1778 EINA_SAFETY_ON_NULL_RETURN(ec);
1779 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1781 ELOGF("TZPOL", "LOWER", ec);
1784 e_policy_stack_transient_child_lower(ec);
1786 e_policy_hook_call(E_POLICY_HOOK_CLIENT_LOWER_REQ, ec);
1788 if (e_policy_visibility_client_lower(ec))
1791 cdata = e_client_cdata_get(ec);
1792 if (cdata && !cdata->mapped)
1794 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_TRUE);
1795 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_TRUE);
1802 _tzpol_iface_cb_lower_by_res_id(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t res_id)
1804 E_Client *ec = NULL;
1805 E_Comp_Wl_Client_Data *cdata;
1807 ec = e_pixmap_find_client_by_res_id(res_id);
1808 EINA_SAFETY_ON_NULL_RETURN(ec);
1809 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1811 ELOGF("TZPOL", "LOWER by res id:%d", ec, res_id);
1814 e_policy_stack_transient_child_lower(ec);
1818 cdata = e_client_cdata_get(ec);
1819 if (cdata && !cdata->mapped)
1821 ELOGF("TZPOL", "POST_RAISE_LOWER SET... raise:%d, lower:%d", ec, EINA_FALSE, EINA_TRUE);
1822 e_client_post_raise_lower_set(ec, EINA_FALSE, EINA_TRUE);
1826 // --------------------------------------------------------
1828 // --------------------------------------------------------
1830 _tzpol_iface_cb_focus_skip_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1834 ec = e_client_from_surface_resource(surf);
1835 EINA_SAFETY_ON_NULL_RETURN(ec);
1837 e_client_focus_skip_set(ec, EINA_TRUE, EINA_TRUE);
1841 _tzpol_iface_cb_focus_skip_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1845 ec = e_client_from_surface_resource(surf);
1846 EINA_SAFETY_ON_NULL_RETURN(ec);
1848 e_client_focus_skip_set(ec, EINA_FALSE, EINA_TRUE);
1852 _e_policy_wl_input_thread_cursor_set(void *data)
1854 E_Input_Thread_Request_EClient_Data *ec_data = data;
1855 EINA_SAFETY_ON_NULL_RETURN(ec_data);
1857 INF("[input thread|%s] ec(%p), is_cursor(%d)\n", __func__, ec_data->ec, ec_data->is_cursor);
1858 e_input_thread_client_is_cursor_set(e_input_thread_client_get(ec_data->ec), ec_data->is_cursor);
1861 // --------------------------------------------------------
1863 // --------------------------------------------------------
1865 _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)
1868 E_Comp_Wl_Client_Data *cdata;
1869 E_Input_Thread_Request_EClient_Data ec_data;
1870 memset(&ec_data, 0, sizeof(E_Input_Thread_Request_EClient_Data));
1872 EINA_SAFETY_ON_NULL_RETURN(role);
1874 ec = e_client_from_surface_resource(surf);
1875 EINA_SAFETY_ON_NULL_RETURN(ec);
1876 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
1878 ELOGF("TZPOL", "ROLE SET (role:%s)", ec, role);
1879 e_client_window_role_set(ec, role);
1881 /* TODO: support multiple roles */
1882 if (!e_util_strcmp("tv-volume-popup", role))
1884 e_client_layer_set(ec, E_LAYER_CLIENT_NOTIFICATION_LOW);
1885 ec->lock_client_location = 1;
1887 else if (!e_util_strcmp("e_demo", role))
1889 e_client_layer_set(ec, E_LAYER_CLIENT_NOTIFICATION_HIGH);
1890 ec->lock_client_location = 1;
1892 else if (!e_util_strcmp("cbhm", role))
1894 cdata = e_client_cdata_get(ec);
1896 e_comp_wl->selection.cbhm = cdata->surface;
1898 else if (!e_util_strcmp("wl_pointer-cursor", role))
1900 ELOGF("TZPOL", "Set CURSOR role", ec);
1901 e_client_layer_set(ec, E_LAYER_CLIENT_CURSOR);
1902 ec->is_cursor = EINA_TRUE;
1903 e_client_desk_iconify_skip_set(ec, EINA_TRUE);
1906 ec_data.is_cursor = 1;
1907 INF("[%s] ec(%p), is_cursor(%d)\n", __func__, ec, ec->is_cursor);
1908 e_input_thread_safe_call(_e_policy_wl_input_thread_cursor_set, &ec_data, sizeof(E_Input_Thread_Request_EClient_Data));
1913 _tzpol_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t type)
1916 E_Window_Type win_type;
1918 ec = e_client_from_surface_resource(surf);
1919 EINA_SAFETY_ON_NULL_RETURN(ec);
1923 /* TODO: support other types */
1924 case TIZEN_POLICY_WIN_TYPE_TOPLEVEL:
1925 win_type = E_WINDOW_TYPE_NORMAL;
1926 if (ec->layer != E_LAYER_CLIENT_NORMAL)
1928 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
1932 case TIZEN_POLICY_WIN_TYPE_NOTIFICATION:
1933 win_type = E_WINDOW_TYPE_NOTIFICATION;
1936 case TIZEN_POLICY_WIN_TYPE_UTILITY:
1937 win_type = E_WINDOW_TYPE_UTILITY;
1940 case TIZEN_POLICY_WIN_TYPE_DIALOG:
1941 win_type = E_WINDOW_TYPE_DIALOG;
1944 case TIZEN_POLICY_WIN_TYPE_DESKTOP:
1945 win_type = E_WINDOW_TYPE_DESKTOP;
1946 e_client_desk_iconify_skip_set(ec, EINA_TRUE);
1947 if (ec->layer != E_LAYER_CLIENT_DESKTOP)
1949 e_client_layer_set(ec, E_LAYER_CLIENT_DESKTOP);
1957 "TYPE_SET |win:0x%08zx|s:%8p|res_tzpol:%8p|tizen_win_type:%d, e_win_type:%d",
1959 e_client_util_win_get(ec),
1964 ec->netwm.type = win_type;
1966 e_policy_hook_call(E_POLICY_HOOK_CLIENT_TYPE_SET, ec);
1970 // --------------------------------------------------------
1972 // --------------------------------------------------------
1974 _tzpol_iface_cb_conformant_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
1978 ec = e_client_from_surface_resource(surf);
1979 EINA_SAFETY_ON_NULL_RETURN(ec);
1981 e_policy_conformant_client_add(ec, res_tzpol);
1985 _tzpol_iface_cb_conformant_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
1989 ec = e_client_from_surface_resource(surf);
1990 EINA_SAFETY_ON_NULL_RETURN(ec);
1992 e_policy_conformant_client_del(ec);
1996 _tzpol_iface_cb_conformant_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
2000 ec = e_client_from_surface_resource(surf);
2001 EINA_SAFETY_ON_NULL_RETURN(ec);
2003 tizen_policy_send_conformant(res_tzpol, surf, e_policy_conformant_client_check(ec));
2006 // --------------------------------------------------------
2007 // notification level
2008 // --------------------------------------------------------
2010 _tzpol_notilv_set(E_Client *ec, int lv)
2017 case 0: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
2018 case 1: ly = E_LAYER_CLIENT_NOTIFICATION_NORMAL; break;
2019 case 2: ly = E_LAYER_CLIENT_NOTIFICATION_TOP; break;
2020 case -1: ly = E_LAYER_CLIENT_NORMAL; break;
2021 case 10: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
2022 case 20: ly = E_LAYER_CLIENT_NOTIFICATION_NORMAL; break;
2023 case 30: ly = E_LAYER_CLIENT_NOTIFICATION_HIGH; break;
2024 case 40: ly = E_LAYER_CLIENT_NOTIFICATION_TOP; break;
2025 default: ly = E_LAYER_CLIENT_NOTIFICATION_LOW; break;
2028 #ifdef REFACTOR_DESK_AREA
2029 cur_ly = e_client_layer_get(ec);
2031 cur_ly = e_client_desk_area_original_layer_get(ec);
2036 if (ly == E_LAYER_CLIENT_NORMAL)
2037 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_LAYER, 0);
2039 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_LAYER, 1);
2041 e_client_layer_set(ec, ly);
2043 e_policy_hook_call(E_POLICY_HOOK_CLIENT_NOTILAYER_SET, ec);
2047 _tzpol_iface_cb_notilv_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t lv)
2050 E_Policy_Wl_Surface *psurf;
2055 ec = e_client_from_surface_resource(surf);
2056 EINA_SAFETY_ON_NULL_RETURN(ec);
2058 psurf = _e_policy_wl_surf_add(ec, res_tzpol);
2059 EINA_SAFETY_ON_NULL_RETURN(psurf);
2061 wl_client_get_credentials(client, &pid, &uid, NULL);
2062 res = e_security_privilege_check(pid, uid,
2063 E_PRIVILEGE_NOTIFICATION_LEVEL_SET);
2067 "Privilege Check Failed! DENY set_notification_level",
2070 tizen_policy_send_notification_done
2074 TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
2078 ELOGF("TZPOL", "NOTI_LEVEL|level:%d", ec, lv);
2079 _tzpol_notilv_set(ec, lv);
2083 tizen_policy_send_notification_done
2084 (res_tzpol, surf, lv, TIZEN_POLICY_ERROR_STATE_NONE);
2086 if (e_policy_client_is_lockscreen(ec))
2087 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
2089 e_policy_stack_check_above_lockscreen(ec, ec->layer);
2093 e_policy_wl_notification_level_fetch(E_Client *ec)
2096 E_Policy_Wl_Surface *psurf;
2097 E_Policy_Wl_Tzpol *tzpol;
2100 Eina_Bool changed_stack = EINA_FALSE;
2102 EINA_SAFETY_ON_NULL_RETURN(ec);
2105 EINA_SAFETY_ON_NULL_RETURN(cp);
2107 // TODO: use pending_notilv_list instead of loop
2108 it = eina_hash_iterator_data_new(polwl->tzpols);
2109 EINA_ITERATOR_FOREACH(it, tzpol)
2110 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
2112 if (psurf->cp != cp) continue;
2113 if (!psurf->pending_notilv) continue;
2115 psurf->pending_notilv = EINA_FALSE;
2116 _tzpol_notilv_set(ec, psurf->notilv);
2117 changed_stack = EINA_TRUE;
2119 eina_iterator_free(it);
2121 if (changed_stack && e_policy_client_is_lockscreen(ec))
2122 e_policy_stack_clients_restack_above_lockscreen(ec, EINA_TRUE);
2125 // --------------------------------------------------------
2127 // --------------------------------------------------------
2129 _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)
2131 E_Client *ec, *parent_ec;
2132 E_Comp_Wl_Client_Data *cdata, *p_cdata;
2135 "TF_SET |res_tzpol:%8p|parent_id:%8d |child_id:%8d",
2136 NULL, res_tzpol, parent_id, child_id);
2138 ec = e_pixmap_find_client_by_res_id(child_id);
2139 EINA_SAFETY_ON_NULL_RETURN(ec);
2140 cdata = e_client_cdata_get(ec);
2142 parent_ec = e_pixmap_find_client_by_res_id(parent_id);
2143 EINA_SAFETY_ON_NULL_RETURN(parent_ec);
2144 p_cdata = e_client_cdata_get(parent_ec);
2147 " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
2148 NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL));
2150 e_policy_stack_transient_for_set(ec, parent_ec);
2151 tizen_policy_send_transient_for_done(res_tzpol, child_id);
2155 _tzpol_iface_cb_transient_for_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t child_id)
2160 "TF_UNSET |res_tzpol:%8p|child:%d",
2161 NULL, res_tzpol, child_id);
2163 ec = e_pixmap_find_client_by_res_id(child_id);
2164 EINA_SAFETY_ON_NULL_RETURN(ec);
2166 e_policy_stack_transient_for_set(ec, NULL);
2167 tizen_policy_send_transient_for_done(res_tzpol, child_id);
2170 // --------------------------------------------------------
2171 // window screen mode
2172 // --------------------------------------------------------
2174 _tzpol_iface_cb_win_scrmode_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
2181 ec = e_client_from_surface_resource(surf);
2182 EINA_SAFETY_ON_NULL_RETURN(ec);
2184 wl_client_get_credentials(client, &pid, &uid, NULL);
2185 res = e_security_privilege_check(pid, uid,
2186 E_PRIVILEGE_SCREEN_MODE_SET);
2190 "Privilege Check Failed! DENY set_screen_mode",
2193 tizen_policy_send_window_screen_mode_done
2197 TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
2201 ELOGF("TZPOL", "SCR_MODE |mode:%d", ec, mode);
2203 e_policy_display_screen_mode_set(ec, mode);
2204 e_policy_wl_win_scrmode_apply();
2206 tizen_policy_send_window_screen_mode_done
2207 (res_tzpol, surf, mode, TIZEN_POLICY_ERROR_STATE_NONE);
2211 e_policy_wl_win_scrmode_apply(void)
2213 e_policy_display_screen_mode_apply();
2216 // --------------------------------------------------------
2218 // --------------------------------------------------------
2220 static const struct wl_subsurface_interface _tzpol_subsurface_fake_impl;
2223 _tzpol_iface_cb_subsurf_place_below_parent(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *subsurf)
2225 if (wl_resource_instance_of(subsurf, &wl_subsurface_interface, &_tzpol_subsurface_fake_impl))
2228 e_comp_wl_subsurface_resource_place_below_parent(subsurf);
2232 _tzpol_iface_cb_subsurf_stand_alone_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *subsurf)
2234 if (wl_resource_instance_of(subsurf, &wl_subsurface_interface, &_tzpol_subsurface_fake_impl))
2237 e_comp_wl_subsurface_resource_stand_alone_mode_set(subsurf);
2241 _tzpol_subsurface_fake_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
2243 wl_resource_destroy(resource);
2247 _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)
2252 _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)
2257 _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)
2262 _tzpol_subsurface_fake_cb_sync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
2267 _tzpol_subsurface_fake_cb_desync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
2271 static const struct wl_subsurface_interface _tzpol_subsurface_fake_impl =
2273 _tzpol_subsurface_fake_cb_destroy,
2274 _tzpol_subsurface_fake_cb_position_set,
2275 _tzpol_subsurface_fake_cb_place_above,
2276 _tzpol_subsurface_fake_cb_place_below,
2277 _tzpol_subsurface_fake_cb_sync_set,
2278 _tzpol_subsurface_fake_cb_desync_set,
2282 _tzpol_subsurface_add_with_fake_impl(struct wl_client *client, uint32_t id)
2284 struct wl_resource *resource;
2286 resource = wl_resource_create(client, &wl_subsurface_interface, 1, id);
2290 wl_resource_set_implementation(resource,
2291 &_tzpol_subsurface_fake_impl,
2298 _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface, uint32_t parent_id)
2301 E_Comp_Wl_Client_Data *cdata;
2305 "SUBSURF |wl_surface@%d|parent_id:%d",
2306 NULL, wl_resource_get_id(surface), parent_id);
2308 ec = e_client_from_surface_resource(surface);
2310 epc = e_pixmap_find_client_by_res_id(parent_id);
2312 (e_object_is_del(E_OBJECT(epc))))
2314 ELOGF("TZPOL", "SUBSURF | Invalid parent(%p). "
2315 "Create with fake implementation", ec, epc);
2317 e_subsurface_watcher_invalid_parent_notify(surface);
2319 /* We have to create a subsurface resource here even though it's error case
2320 * because server will send the fatal error when a client destroy a subsurface object.
2321 * Otherwise, server will kill a client by the fatal error.
2323 if (!_tzpol_subsurface_add_with_fake_impl(client, id))
2324 wl_resource_post_no_memory(resource);
2329 /* This check code is for detecting an error case which tries to create
2330 * sub-surface relationship with invalid parent. */
2331 if ((!epc->comp_data) ||
2332 (!epc->comp_data->wl_surface))
2334 ELOGF("TZPOL", "Parent(%p internal? %s) doesn't have comp_data. "
2335 "Possibly it's not the surface created by client. "
2336 "Cannot be the parent of sub-surface.",
2337 ec, epc, epc->internal ? "TRUE" : "FALSE");
2338 wl_resource_post_error(resource,
2339 WL_SUBSURFACE_ERROR_BAD_SURFACE,
2340 "Invalid parent_id@%d. Possibly it's not the "
2341 "surface created by client.(internal? %s) "
2342 "Cannot be the parent of sub-surface.",
2343 parent_id, epc->internal ? "TRUE" : "FALSE");
2347 res = e_comp_wl_subsurface_add(resource, id, surface,
2348 epc->comp_data->wl_surface);
2351 ERR("Failed to add subsurface for surface@%d", wl_resource_get_id(surface));
2355 /* ec's parent comes from another process */
2356 cdata = e_client_cdata_get(ec);
2358 cdata->has_extern_parent = EINA_TRUE;
2362 _tzpol_iface_cb_opaque_state_set(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, int32_t state)
2366 ec = e_client_from_surface_resource(surface);
2367 EINA_SAFETY_ON_NULL_RETURN(ec);
2369 ELOGF("TZPOL", "OPAQUE |opaque_state:%d", ec, state);
2370 if(ec->visibility.opaque == state)
2372 ec->visibility.opaque = state;
2377 // --------------------------------------------------------
2379 // --------------------------------------------------------
2382 e_policy_wl_iconify(E_Client *ec)
2384 EINA_SAFETY_ON_NULL_RETURN(ec);
2385 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
2387 ELOGF("TZPOL", "Set ICONIFY BY CLIENT", ec);
2389 if (e_policy_visibility_client_iconify(ec))
2391 ec->exp_iconify.by_client = 1;
2392 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT);
2395 ec->exp_iconify.by_client = 1;
2396 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_ICONIFY_BY_CLIENT);
2398 e_client_iconify(ec);
2404 e_policy_wl_uniconify(E_Client *ec)
2406 EINA_SAFETY_ON_NULL_RETURN(ec);
2407 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
2409 if (e_policy_visibility_client_uniconify(ec, 1))
2412 if ((ec->iconic) && (!e_client_is_iconified_by_client(ec)))
2413 e_policy_wl_iconify_state_change_send(ec, 0);
2415 if (ec->visibility.force_obscured)
2417 ec->exp_iconify.by_client = 0;
2418 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
2422 e_client_uniconify(ec);
2423 ELOGF("TZPOL", "Un-Set ICONIFY BY CLIENT", ec);
2424 ec->exp_iconify.by_client = 0;
2425 e_client_iconified_type_set(ec, E_ICONIFIED_TYPE_NONE);
2431 _tzpol_iface_cb_iconify(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
2435 ec = e_client_from_surface_resource(surf);
2436 EINA_SAFETY_ON_NULL_RETURN(ec);
2438 ELOGF("TZPOL", "ICONIFY", ec);
2440 e_policy_hook_call(E_POLICY_HOOK_CLIENT_ICONIFY_REQ, ec);
2441 e_policy_wl_iconify(ec);
2445 _tzpol_iface_cb_uniconify(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
2449 ec = e_client_from_surface_resource(surf);
2450 EINA_SAFETY_ON_NULL_RETURN(ec);
2452 ELOGF("TZPOL", "UNICONIFY", ec);
2454 e_policy_hook_call(E_POLICY_HOOK_CLIENT_UNICONIFY_REQ, ec);
2455 e_policy_wl_uniconify(ec);
2459 _e_policy_wl_allowed_aux_hint_send(struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
2463 ec = e_client_from_surface_resource(surf);
2464 EINA_SAFETY_ON_NULL_RETURN(ec);
2466 ELOGF("TZPOL", "SEND |res_tzpol:%8p|id:%d, hint allowed ", ec, res_tzpol, id);
2467 tizen_policy_send_allowed_aux_hint(res_tzpol, surf, id);
2471 _e_policy_wl_aux_hint_apply(E_Client *ec)
2473 E_Comp_Wl_Client_Data *cdata;
2474 E_Comp_Wl_Aux_Hint *hint;
2477 cdata = e_client_cdata_get(ec);
2479 if (!cdata->aux_hint.changed) return;
2481 EINA_LIST_FOREACH(cdata->aux_hint.hints, l, hint)
2483 if (!hint->changed) continue;
2486 if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_USER_GEOMETRY]))
2490 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_FALSE);
2494 if (!strcmp(hint->val, "1"))
2496 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_TRUE);
2498 else if (strcmp(hint->val, "1"))
2500 e_policy_user_geometry_set(ec, E_POLICY_USERGEOM_HINT, EINA_FALSE);
2503 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_FIXED_RESIZE]))
2505 /* TODO: support other aux_hints */
2507 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_DEICONIFY_UPDATE]))
2509 if (!strcmp(hint->val, "1"))
2510 ec->exp_iconify.deiconify_update = EINA_TRUE;
2512 ec->exp_iconify.deiconify_update = EINA_FALSE;
2515 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_GESTURE_DISABLE]))
2519 ec->gesture_disable = EINA_FALSE;
2523 if (atoi(hint->val) == 1)
2525 ec->gesture_disable = EINA_TRUE;
2529 ec->gesture_disable = EINA_FALSE;
2532 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ICONIFY]))
2536 ec->exp_iconify.skip_iconify = 0;
2541 if (!strcmp(hint->val, "disable"))
2543 ec->exp_iconify.skip_iconify = 1;
2546 else if (!strcmp(hint->val, "enable"))
2548 ec->exp_iconify.skip_iconify = 0;
2552 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ABOVE_LOCKSCREEN]))
2554 if ((hint->deleted) ||
2555 (!strcmp(hint->val, "0")))
2557 E_Layer original_layer = ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer;
2558 if (ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set &&
2559 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved)
2561 // restore original layer
2562 if (original_layer != evas_object_layer_get(ec->frame))
2564 Eina_Bool pend = EINA_FALSE;
2565 pend = e_policy_visibility_client_layer_lower(ec, original_layer);
2568 e_client_layer_set(ec, original_layer);
2572 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set = 0;
2573 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved = 0;
2574 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer = 0;
2577 else if (!strcmp(hint->val, "1"))
2579 if (!ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved)
2581 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].set = 1;
2582 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved = 0;
2583 ec->changable_layer[E_CHANGABLE_LAYER_TYPE_ABOVE_NOTIFICATION].saved_layer = ec->layer;
2588 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_EFFECT_DISABLE]))
2590 if ((hint->deleted) ||
2591 (!strcmp(hint->val, "0")))
2593 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_HINT, 0);
2595 else if (!strcmp(hint->val, "1"))
2597 e_policy_animatable_lock(ec, E_POLICY_ANIMATABLE_HINT, 1);
2600 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_MSG_USE]))
2602 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2603 cdata->aux_hint.use_msg = EINA_FALSE;
2604 else if (!strcmp(hint->val, "1"))
2605 cdata->aux_hint.use_msg = EINA_TRUE;
2607 else if (!strcmp(hint->hint, hint_names[E_COMP_HINT_ALWAYS_SELECTIVE]))
2609 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2611 cdata->never_hwc = EINA_FALSE;
2613 e_hwc_window_never_hwc_set(ec->hwc_window, EINA_FALSE);
2615 else if (!strcmp(hint->val, "1"))
2617 cdata->never_hwc = EINA_TRUE;
2619 e_hwc_window_never_hwc_set(ec->hwc_window, EINA_TRUE);
2622 e_comp_render_queue();
2624 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_DEPENDENT_ROTATION]))
2626 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2627 ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_NORMAL;
2628 else if (!strcmp(hint->val, "1"))
2629 ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_DEPENDENT;
2631 else if (!strcmp(hint->hint, hint_names[E_POLICY_HINT_ROT_RENDER_NOPENDING]))
2633 if ((hint->deleted) || (!strcmp(hint->val, "0")))
2635 ELOGF("ROTATION", "nopending render:0", ec);
2636 ec->e.state.rot.nopending_render = 0;
2638 else if (!strcmp(hint->val, "1"))
2640 ELOGF("ROTATION", "nopending render:1", ec);
2641 ec->e.state.rot.nopending_render = 1;
2644 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_ICONIFY_BUFFER_FLUSH], strlen(hint->hint)))
2646 if (!strncmp(hint->val, "1", 1))
2647 ec->exp_iconify.buffer_flush = EINA_TRUE;
2649 ec->exp_iconify.buffer_flush = EINA_FALSE;
2651 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP], strlen(hint->hint)))
2653 if (!strncmp(hint->val, "1", 1))
2655 ELOGF("TF_SET", "Transient for Always_on_top enabled", ec);
2656 ec->transient_for_always_on_top = EINA_TRUE;
2660 ELOGF("TF_SET", "Transient for Always_on_top disabled", ec);
2661 ec->transient_for_always_on_top = EINA_FALSE;
2664 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_BELONG_TO_PARENT], strlen(hint->hint)))
2666 if (!strncmp(hint->val, "1", 1))
2668 ELOGF("TF_SET", "Set belong_to_parent", ec);
2669 e_client_belong_to_parent_set(ec, EINA_TRUE);
2673 ELOGF("TF_SET", "Unset belong_to_parent", ec);
2674 e_client_belong_to_parent_set(ec, EINA_FALSE);
2677 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_ASPECT_RATIO], strlen(hint->hint)))
2679 if (!strncmp(hint->val, "1", 1))
2681 ELOGF("RESIZE", "Set resize aspect ratio.. ratio(%dx%d)", ec, ec->w, ec->h);
2682 ec->manage_resize.enable_aspect_ratio = EINA_TRUE;
2683 ec->manage_resize.aw = ec->w;
2684 ec->manage_resize.ah = ec->h;
2688 ELOGF("RESIZE", "Unset resize aspect ratio", ec);
2689 ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
2692 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_HEADER], strlen(hint->hint)))
2694 int height = atoi(hint->val);
2697 ELOGF("CSD", "Set decoration HEADER size.. size(%d)", ec, height);
2698 ec->manage_resize.header_h = height;
2702 ELOGF("CSD", "Unset decoration HEADER size", ec);
2703 ec->manage_resize.header_h = 0;
2706 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_FOOTER], strlen(hint->hint)))
2708 int height = atoi(hint->val);
2711 ELOGF("CSD", "Set decoration FOOTER size.. size(%d)", ec, height);
2712 ec->manage_resize.footer_h = height;
2716 ELOGF("CSD", "Unset decoration FOOTER size", ec);
2717 ec->manage_resize.footer_h = 0;
2720 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_VISIBILITY_IGNORE_GEOMETRY], strlen(hint->hint)))
2722 if (!strncmp(hint->val, "1", 1))
2724 ELOGF("POL_VIS", "Set ignore_geometry.. value(%s)", ec, hint->val);
2725 ec->visibility.ignore_geometry = EINA_TRUE;
2729 ELOGF("POL_VIS", "UNSet ignore_geometry.. value(%s)", ec, hint->val);
2730 ec->visibility.ignore_geometry = EINA_FALSE;
2733 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_PPU], strlen(hint->hint)))
2735 int ppu = atoi(hint->val);
2736 if (ppu < 1) ppu = 1;
2738 ELOGF("RESIZE", "Set resize unit. size:%d", ec, ppu);
2739 e_client_resize_unit_size_set(ec, ppu);
2741 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_TOP], strlen(hint->hint)))
2743 int size = atoi(hint->val);
2746 ELOGF("CSD", "Set decoration SHADOW top.. size(%d)", ec, size);
2747 ec->manage_resize.shadow.t = size;
2751 ELOGF("CSD", "Unset decoration SHADOW top", ec);
2752 ec->manage_resize.shadow.t = 0;
2755 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_BOTTOM], strlen(hint->hint)))
2757 int size = atoi(hint->val);
2760 ELOGF("CSD", "Set decoration SHADOW bottom.. size(%d)", ec, size);
2761 ec->manage_resize.shadow.b = size;
2765 ELOGF("CSD", "Unset decoration SHADOW bottom", ec);
2766 ec->manage_resize.shadow.b = 0;
2769 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_LEFT], strlen(hint->hint)))
2771 int size = atoi(hint->val);
2774 ELOGF("CSD", "Set decoration SHADOW left.. size(%d)", ec, size);
2775 ec->manage_resize.shadow.l = size;
2779 ELOGF("CSD", "Unset decoration SHADOW left", ec);
2780 ec->manage_resize.shadow.l = 0;
2783 else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_DECORATION_SIZE_SHADOW_RIGHT], strlen(hint->hint)))
2785 int size = atoi(hint->val);
2788 ELOGF("CSD", "Set decoration SHADOW right.. size(%d)", ec, size);
2789 ec->manage_resize.shadow.r = size;
2793 ELOGF("CSD", "Unset decoration SHADOW right", ec);
2794 ec->manage_resize.shadow.r = 0;
2799 e_policy_hook_call(E_POLICY_HOOK_CLIENT_AUX_HINT_CHANGED, ec);
2803 _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)
2806 Eina_Bool res = EINA_FALSE;
2808 ec = e_client_from_surface_resource(surf);
2809 EINA_SAFETY_ON_NULL_RETURN(ec);
2811 res = e_hints_aux_hint_add(ec, id, name, value);
2813 ELOGF("TZPOL", "HINT_ADD |res_tzpol:%8p|id:%d, name:%s, val:%s, res:%d", ec, res_tzpol, id, name, value, res);
2817 _e_policy_wl_aux_hint_apply(ec);
2818 _e_policy_wl_allowed_aux_hint_send(res_tzpol, surf, id);
2823 _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)
2826 Eina_Bool res = EINA_FALSE;
2828 ec = e_client_from_surface_resource(surf);
2829 EINA_SAFETY_ON_NULL_RETURN(ec);
2831 res = e_hints_aux_hint_change(ec, id, value);
2833 ELOGF("TZPOL", "HINT_CHD |res_tzpol:%8p|id:%d, val:%s, result:%d", ec, res_tzpol, id, value, res);
2837 _e_policy_wl_aux_hint_apply(ec);
2838 _e_policy_wl_allowed_aux_hint_send(res_tzpol, surf, id);
2843 _tzpol_iface_cb_aux_hint_del(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
2846 unsigned int res = -1;
2848 ec = e_client_from_surface_resource(surf);
2849 EINA_SAFETY_ON_NULL_RETURN(ec);
2851 res = e_hints_aux_hint_del(ec, id);
2852 ELOGF("TZPOL", "HINT_DEL |res_tzpol:%8p|id:%d, result:%d", ec, res_tzpol, id, res);
2855 _e_policy_wl_aux_hint_apply(ec);
2859 _tzpol_iface_cb_supported_aux_hints_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
2862 const Eina_List *hints_list;
2864 struct wl_array hints;
2865 const char *hint_name;
2869 ec = e_client_from_surface_resource(surf);
2870 EINA_SAFETY_ON_NULL_RETURN(ec);
2872 hints_list = e_hints_aux_hint_supported_get();
2874 wl_array_init(&hints);
2875 EINA_LIST_FOREACH(hints_list, l, hint_name)
2877 len = strlen(hint_name) + 1;
2878 p = wl_array_add(&hints, len);
2882 strncpy(p, hint_name, len);
2885 tizen_policy_send_supported_aux_hints(res_tzpol, surf, &hints, eina_list_count(hints_list));
2887 "SEND |res_tzpol:%8p|supported_hints size:%d",
2890 eina_list_count(hints_list));
2891 wl_array_release(&hints);
2895 _e_policy_wl_background_state_apply(E_Client *ec, Eina_Bool state)
2900 "BACKGROUND STATE %s for PID(%u), iconic:%d",
2902 state?"SET":"UNSET", ec->netwm.pid, ec->iconic);
2906 ec->bg_state = EINA_TRUE;
2907 evas_object_hide(ec->frame);
2908 e_pixmap_image_clear(ec->pixmap, 1);
2912 ec->bg_state = EINA_FALSE;
2915 E_Comp_Wl_Client_Data *cdata;
2916 cdata = e_client_cdata_get(ec);
2917 if (cdata && cdata->mapped)
2919 evas_object_show(ec->frame);
2920 e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
2926 e_comp_visibility_calculation_set(EINA_TRUE);
2930 _e_policy_wl_background_state_set(E_Policy_Wl_Surface *psurf, Eina_Bool state)
2932 psurf->is_background = state;
2933 ELOGF("TZPOL", "Set psurf(%p)'s background_state to %d", NULL, psurf, state);
2938 _e_policy_wl_background_state_apply(psurf->ec, EINA_TRUE);
2943 _e_policy_wl_background_state_apply(psurf->ec, EINA_FALSE);
2948 _e_policy_wl_tzlaunch_effect_type_sync(E_Client *ec)
2951 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
2953 EINA_SAFETY_ON_NULL_RETURN(ec);
2955 EINA_LIST_FOREACH(polwl->tzlaunch_effect_info, l, effect_info)
2957 if (effect_info->pid == ec->netwm.pid)
2960 "Launchscreen effect type sync | pid (%d) effect_type (%d)",
2961 ec, ec->netwm.pid, effect_info->effect_type);
2962 ec->effect_type = effect_info->effect_type;
2963 _e_policy_wl_tzlaunch_effect_type_unset(ec->netwm.pid);
2970 _e_policy_wl_tzlaunch_effect_type_get(const char * effect_type)
2972 Tzlaunch_Effect_Type type = TZLAUNCH_EFFECT_TYPE_LAUNCH;
2974 if (!e_util_strcmp(effect_type, "launch" )) type = TZLAUNCH_EFFECT_TYPE_LAUNCH;
2975 else if (!e_util_strcmp(effect_type, "depth-in" )) type = TZLAUNCH_EFFECT_TYPE_DEPTH_IN;
2981 _e_policy_wl_tzlaunch_effect_type_unset(uint32_t pid)
2984 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
2986 EINA_LIST_FOREACH(polwl->tzlaunch_effect_info, l, effect_info)
2988 if (effect_info->pid == pid)
2991 "Launchscreen effect type unset | pid (%d)",
2993 polwl->tzlaunch_effect_info = eina_list_remove(polwl->tzlaunch_effect_info, effect_info);
2994 memset(effect_info, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Effect_Info));
2995 E_FREE(effect_info);
3002 _e_policy_wl_tzpol_background_state_set(E_Policy_Wl_Tzpol *tzpol, Eina_Bool bg_state, pid_t pid)
3005 E_Policy_Wl_Surface *psurf;
3009 tzpol->bg_state = bg_state;
3010 ELOGF("TZPOL", "Set tzpol(%p)'s background_state to %d", NULL, tzpol, bg_state);
3012 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
3014 if (psurf->pid == pid)
3016 if (psurf->is_background == bg_state)
3019 _e_policy_wl_background_state_set(psurf, bg_state);
3025 _e_policy_wl_tzpols_background_state_set(Eina_Bool bg_state, pid_t pid)
3027 E_Policy_Wl_Tzpol *tzpol;
3030 it = eina_hash_iterator_data_new(polwl->tzpols);
3031 EINA_ITERATOR_FOREACH(it, tzpol)
3033 if (tzpol->pid == pid)
3035 _e_policy_wl_tzpol_background_state_set(tzpol, bg_state, pid);
3038 eina_iterator_free(it);
3042 _tzpol_iface_cb_background_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t pid)
3044 E_Policy_Wl_Tzpol *tzpol;
3046 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3047 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3049 ELOGF("TZPOL", "Register PID(%u) for BACKGROUND STATE res_tzpol:%p tzpol:%p", NULL, pid, res_tzpol, tzpol);
3051 _e_policy_wl_tzpols_background_state_set(EINA_TRUE, pid);
3055 _tzpol_iface_cb_background_state_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t pid)
3057 E_Policy_Wl_Tzpol *tzpol;
3059 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3060 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3062 ELOGF("TZPOL", "Unregister PID(%u) for BACKGROUND STATE res_tzpol:%p tzpol:%p", NULL, pid, res_tzpol, tzpol);
3064 _e_policy_wl_tzpols_background_state_set(EINA_FALSE, pid);
3068 _e_policy_wl_floating_mode_apply(E_Client *ec, Eina_Bool floating)
3070 if (ec->floating == floating) return;
3072 ec->floating = floating;
3073 ec->lock_client_location = EINA_FALSE;
3079 ec->floating_saved_layer = ec->layer;
3080 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
3084 e_client_layer_set(ec, ec->floating_saved_layer);
3092 _tzpol_iface_cb_floating_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
3096 ec = e_client_from_surface_resource(surf);
3097 EINA_SAFETY_ON_NULL_RETURN(ec);
3099 ELOGF("TZPOL", "FLOATING Set", ec);
3101 _e_policy_wl_floating_mode_apply(ec, EINA_TRUE);
3105 _tzpol_iface_cb_floating_mode_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
3109 ec = e_client_from_surface_resource(surf);
3110 EINA_SAFETY_ON_NULL_RETURN(ec);
3112 ELOGF("TZPOL", "FLOATING Unset", ec);
3114 e_client_pending_geometry_flush(ec);
3116 _e_policy_wl_floating_mode_apply(ec, EINA_FALSE);
3120 _tzpol_iface_cb_stack_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
3124 ec = e_client_from_surface_resource(surf);
3125 EINA_SAFETY_ON_NULL_RETURN(ec);
3127 ELOGF("TZPOL", "STACK Mode Set. mode:%d", ec, mode);
3131 if (mode == TIZEN_POLICY_STACK_MODE_ABOVE)
3133 e_client_layer_set(ec, E_LAYER_CLIENT_ABOVE);
3135 else if (mode == TIZEN_POLICY_STACK_MODE_BELOW)
3137 e_client_layer_set(ec, E_LAYER_CLIENT_BELOW);
3141 e_client_layer_set(ec, E_LAYER_CLIENT_NORMAL);
3145 e_policy_hook_call(E_POLICY_HOOK_CLIENT_STACK_MODE_SET, ec);
3149 // --------------------------------------------------------
3150 // E_Policy_Wl_Tz_Dpy_Pol
3151 // --------------------------------------------------------
3152 static E_Policy_Wl_Tz_Dpy_Pol *
3153 _e_policy_wl_tz_dpy_pol_add(struct wl_resource *res_tz_dpy_pol)
3155 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3157 tz_dpy_pol = E_NEW(E_Policy_Wl_Tz_Dpy_Pol, 1);
3158 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_dpy_pol, NULL);
3160 tz_dpy_pol->res_tz_dpy_pol = res_tz_dpy_pol;
3162 polwl->tz_dpy_pols = eina_list_append(polwl->tz_dpy_pols, tz_dpy_pol);
3168 _e_policy_wl_tz_dpy_pol_del(E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol)
3170 E_Policy_Wl_Dpy_Surface *dpy_surf;
3172 EINA_SAFETY_ON_NULL_RETURN(tz_dpy_pol);
3174 polwl->tz_dpy_pols = eina_list_remove(polwl->tz_dpy_pols, tz_dpy_pol);
3176 EINA_LIST_FREE(tz_dpy_pol->dpy_surfs, dpy_surf)
3184 static E_Policy_Wl_Tz_Dpy_Pol *
3185 _e_policy_wl_tz_dpy_pol_get(struct wl_resource *res_tz_dpy_pol)
3188 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3190 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3192 if (tz_dpy_pol->res_tz_dpy_pol == res_tz_dpy_pol)
3199 // --------------------------------------------------------
3200 // E_Policy_Wl_Dpy_Surface
3201 // --------------------------------------------------------
3202 static E_Policy_Wl_Dpy_Surface *
3203 _e_policy_wl_dpy_surf_find(E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol, E_Client *ec)
3206 E_Policy_Wl_Dpy_Surface *dpy_surf;
3208 EINA_LIST_FOREACH(tz_dpy_pol->dpy_surfs, l, dpy_surf)
3210 if (dpy_surf->ec == ec)
3217 static E_Policy_Wl_Dpy_Surface *
3218 _e_policy_wl_dpy_surf_add(E_Client *ec, struct wl_resource *res_tz_dpy_pol)
3220 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol = NULL;
3221 E_Policy_Wl_Dpy_Surface *dpy_surf = NULL;
3222 E_Comp_Wl_Client_Data *cdata;
3224 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_get(res_tz_dpy_pol);
3225 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_dpy_pol, NULL);
3227 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3231 dpy_surf = E_NEW(E_Policy_Wl_Dpy_Surface, 1);
3232 EINA_SAFETY_ON_NULL_RETURN_VAL(dpy_surf, NULL);
3234 cdata = e_client_cdata_get(ec);
3235 dpy_surf->surf = cdata->surface;
3236 dpy_surf->tz_dpy_pol = tz_dpy_pol;
3238 dpy_surf->brightness = -1;
3240 tz_dpy_pol->dpy_surfs = eina_list_append(tz_dpy_pol->dpy_surfs, dpy_surf);
3245 _e_policy_wl_dpy_surf_del(E_Client *ec)
3248 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3249 E_Policy_Wl_Dpy_Surface *dpy_surf;
3251 EINA_SAFETY_ON_NULL_RETURN(ec);
3253 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3255 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3258 tz_dpy_pol->dpy_surfs = eina_list_remove(tz_dpy_pol->dpy_surfs, dpy_surf);
3264 // --------------------------------------------------------
3266 // --------------------------------------------------------
3268 _e_policy_system_brightness_get(int *brightness)
3271 int sys_brightness = -1;
3273 if (!brightness) return EINA_FALSE;
3275 error = device_display_get_brightness(0, &sys_brightness);
3276 if (error != DEVICE_ERROR_NONE)
3282 *brightness = sys_brightness;
3288 _e_policy_system_brightness_set(int brightness)
3297 error = device_display_get_numbers(&num_of_dpy);
3298 if (error != DEVICE_ERROR_NONE)
3304 for (id = 0; id < num_of_dpy; id++)
3306 error = device_display_set_brightness(id, brightness);
3307 if (error != DEVICE_ERROR_NONE)
3319 _e_policy_change_system_brightness(int new_brightness)
3324 if (!e_policy_system_info.brightness.use_client)
3326 // save system brightness
3327 ret = _e_policy_system_brightness_get(&sys_brightness);
3332 e_policy_system_info.brightness.system = sys_brightness;
3335 ret = _e_policy_system_brightness_set(new_brightness);
3340 e_policy_system_info.brightness.client = new_brightness;
3341 e_policy_system_info.brightness.use_client = EINA_TRUE;
3347 _e_policy_restore_system_brightness(void)
3351 if (!e_policy_system_info.brightness.use_client) return EINA_TRUE;
3353 // restore system brightness
3354 ret = _e_policy_system_brightness_set(e_policy_system_info.brightness.system);
3359 e_policy_system_info.brightness.use_client = EINA_FALSE;
3362 // if there are another window which set brighteness, then we change brighteness of it
3363 // if no, then we rollback system brightness
3369 e_policy_wl_win_brightness_apply(E_Client *ec)
3373 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3374 E_Policy_Wl_Dpy_Surface *dpy_surf = NULL;
3377 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
3378 if (e_object_is_del(E_OBJECT(ec)))
3379 ec_visibility = E_VISIBILITY_FULLY_OBSCURED;
3381 ec_visibility = e_client_visibility_get(ec);
3383 EINA_LIST_FOREACH(polwl->tz_dpy_pols, l, tz_dpy_pol)
3385 dpy_surf = _e_policy_wl_dpy_surf_find(tz_dpy_pol, ec);
3390 if (!dpy_surf) return EINA_FALSE;
3391 if (!dpy_surf->set) return EINA_FALSE;
3393 // use system brightness
3394 if (dpy_surf->brightness < 0)
3396 ELOGF("TZ_DPY_POL", "Restore system brightness. Win(0x%08zx)'s brightness:%d", ec, e_client_util_win_get(ec), dpy_surf->brightness);
3397 ret = _e_policy_restore_system_brightness();
3401 if (ec_visibility == E_VISIBILITY_UNOBSCURED)
3403 ELOGF("TZ_DPY_POL", "Change system brightness(%d). Win(0x%08zx) is un-obscured", ec, dpy_surf->brightness, e_client_util_win_get(ec));
3404 ret = _e_policy_change_system_brightness(dpy_surf->brightness);
3405 if (!ret) return EINA_FALSE;
3409 ELOGF("TZ_DPY_POL", "Restore system brightness. Win(0x%08zx) is obscured", ec, e_client_util_win_get(ec));
3410 ret = _e_policy_restore_system_brightness();
3411 if (!ret) return EINA_FALSE;
3418 _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)
3421 E_Policy_Wl_Dpy_Surface *dpy_surf;
3426 ec = e_client_from_surface_resource(surf);
3427 EINA_SAFETY_ON_NULL_RETURN(ec);
3429 dpy_surf = _e_policy_wl_dpy_surf_add(ec, res_tz_dpy_pol);
3430 EINA_SAFETY_ON_NULL_RETURN(dpy_surf);
3432 wl_client_get_credentials(client, &pid, &uid, NULL);
3433 res = e_security_privilege_check(pid, uid,
3434 E_PRIVILEGE_BRIGHTNESS_SET);
3438 "Privilege Check Failed! DENY set_brightness",
3441 tizen_display_policy_send_window_brightness_done
3445 TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED);
3448 ELOGF("TZ_DPY_POL", "Set Win(0x%08zx)'s brightness:%d", ec, e_client_util_win_get(ec), brightness);
3449 dpy_surf->set = EINA_TRUE;
3450 dpy_surf->brightness = brightness;
3452 e_policy_wl_win_brightness_apply(ec);
3454 tizen_display_policy_send_window_brightness_done
3455 (res_tz_dpy_pol, surf, brightness, TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE);
3459 _tz_dpy_pol_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
3461 wl_resource_destroy(resource);
3465 _tzpol_iface_cb_subsurf_watcher_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surface)
3469 if (!(ec = e_client_from_surface_resource(surface))) return;
3470 if (e_object_is_del(E_OBJECT(ec))) return;
3472 e_subsurface_watcher_add(client, id, surface);
3476 _tzpol_iface_cb_parent_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
3478 E_Client *ec, *parent_ec;
3481 "PARENT_SET |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3482 NULL, res_tzpol, parent, child);
3484 ec = e_client_from_surface_resource(child);
3485 EINA_SAFETY_ON_NULL_RETURN(ec);
3487 parent_ec = e_client_from_surface_resource(parent);
3488 e_policy_stack_parent_set(ec, parent_ec);
3492 _tzpol_iface_cb_ack_conformant_region(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t serial)
3496 if (!(ec = e_client_from_surface_resource(surface))) return;
3498 e_policy_conformant_client_ack(ec, res_tzpol, serial);
3502 _tzpol_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzpol)
3504 wl_resource_destroy(res_tzpol);
3508 _tzpol_iface_cb_has_video(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t has)
3511 E_Comp_Wl_Client_Data *cdata;
3513 if (!(ec = e_client_from_surface_resource(surface))) return;
3514 if (e_object_is_del(E_OBJECT(ec))) return;
3515 cdata = e_client_cdata_get(ec);
3517 if (cdata->has_video_client == has) return;
3519 ELOGF("TZPOL", "video client has(%d)", ec, has);
3521 cdata->has_video_client = has;
3525 _tzpol_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzpol, int32_t pid, const char *appid)
3527 E_Policy_Wl_Tzpol *tzpol;
3530 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3531 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3533 ELOGF("TZPOL", "Set appid(%s) pid(%d)", NULL, appid, pid);
3535 if (!(eai = e_appinfo_find_with_appid(appid)))
3537 eai = e_appinfo_new();
3538 e_appinfo_appid_set(eai, appid);
3539 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
3541 EINA_SAFETY_ON_NULL_RETURN(eai);
3543 e_appinfo_pid_set(eai, pid);
3547 _tzpol_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3550 E_Comp_Wl_Client_Data *cdata;
3552 ec = e_client_from_surface_resource(surf);
3553 EINA_SAFETY_ON_NULL_RETURN(ec);
3554 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3556 ELOGF("TZPOL", "Prepare SHOW (wait for buffer attach)", ec);
3557 e_client_hide_by_request_set(ec, EINA_FALSE);
3559 cdata = e_client_cdata_get(ec);
3560 if (cdata && !cdata->mapped)
3562 if (e_config->raise_before_show)
3565 ec->post_raise = EINA_FALSE;
3571 _tzpol_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3575 ec = e_client_from_surface_resource(surf);
3576 EINA_SAFETY_ON_NULL_RETURN(ec);
3577 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3579 ELOGF("TZPOL", "Prepare HIDE (wait for NULL buffer attach)", ec);
3580 e_client_hide_by_request_set(ec, EINA_TRUE);
3584 _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)
3586 E_Client *ec, *parent_ec;
3587 E_Comp_Wl_Client_Data *cdata, *p_cdata;
3590 "TF_SET(B) |res_tzpol:%8p|parent_id:%8d |child_id:%8d",
3591 NULL, res_tzpol, parent_id, child_id);
3593 ec = e_pixmap_find_client_by_res_id(child_id);
3594 EINA_SAFETY_ON_NULL_RETURN(ec);
3595 parent_ec = e_pixmap_find_client_by_res_id(parent_id);
3597 cdata = e_client_cdata_get(ec);
3598 p_cdata = e_client_cdata_get(parent_ec);
3600 " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3601 NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL));
3603 e_policy_stack_transient_for_below_set(ec, parent_ec, EINA_TRUE);
3607 _tzpol_iface_cb_set_parent_with_below(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
3609 E_Client *ec, *parent_ec;
3612 "PARENT_SET(B)|res_tzpol:%8p|parent_surf:%8p|child_surf:%8p",
3613 NULL, res_tzpol, parent, child);
3615 ec = e_client_from_surface_resource(child);
3616 EINA_SAFETY_ON_NULL_RETURN(ec);
3619 parent_ec = e_client_from_surface_resource(parent);
3623 e_policy_stack_transient_for_below_set(ec, parent_ec, EINA_FALSE);
3627 _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)
3631 ec = e_client_from_surface_resource(surf);
3632 EINA_SAFETY_ON_NULL_RETURN(ec);
3633 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3635 ELOGF("TZPOL", "Set Maximize_direction. direction:%d", ec, direction);
3637 if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_NONE)
3639 ec->maximize_dir = E_MAXIMIZE_DIRECTION_NONE;
3640 e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
3644 if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_ALL)
3646 ec->maximize_dir = E_MAXIMIZE_DIRECTION_ALL;
3648 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_LEFT)
3650 ec->maximize_dir = E_MAXIMIZE_DIRECTION_LEFT;
3652 else if (direction == TIZEN_POLICY_MAXIMIZE_DIRECTION_RIGHT)
3654 ec->maximize_dir = E_MAXIMIZE_DIRECTION_RIGHT;
3658 ELOGF("TZPOL", "Not supported direction:%d", ec, direction);
3662 e_client_maximize(ec, ec->maximize_type | ec->maximize_dir);
3666 _e_policy_set_pin_mode(E_Client *ec, Eina_Bool pinned)
3668 EINA_SAFETY_ON_NULL_RETURN(ec);
3669 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3671 ELOGF("TZPOL", "Set Pin mode to %d", ec, pinned);
3672 e_client_pinned_set(ec, pinned);
3676 _tzpol_iface_cb_set_pin_mode(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3680 ec = e_client_from_surface_resource(surf);
3681 _e_policy_set_pin_mode(ec, EINA_TRUE);
3685 _tzpol_iface_cb_unset_pin_mode(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3689 ec = e_client_from_surface_resource(surf);
3690 _e_policy_set_pin_mode(ec, EINA_FALSE);
3694 _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)
3701 ec = e_client_from_surface_resource(surf);
3704 desk = e_comp_desk_find_by_ec(ec);
3705 EINA_SAFETY_ON_NULL_RETURN(desk);
3707 unit_w = desk->geom.w / num_cols;
3708 unit_h = desk->geom.h / num_rows;
3710 x = unit_w * column;
3712 w = unit_w * col_span;
3713 h = unit_h * row_span;
3715 // TODO: We may need to adjust the last size if the unit size is not devided exactly
3717 ELOGF("TZPOL", "TIZEN_POLICY_SET_LAYOUT... total_layout(%d,%d) -> unit_size(%dx%d). request(%d,%d,%d,%d) -> geo(%d,%d,%dx%d)",
3718 ec, num_cols, num_rows, unit_w, unit_h, column, row, col_span, row_span, x, y, w, h);
3720 // Apply shadow size (left, right, top, bottom)
3721 x -= ec->manage_resize.shadow.l;
3722 y -= ec->manage_resize.shadow.t;
3723 w = w + ec->manage_resize.shadow.l + ec->manage_resize.shadow.r;
3724 h = h + ec->manage_resize.shadow.t + ec->manage_resize.shadow.b;
3726 ELOGF("TZPOL", "Consider Shadow size(l:%d,r:%d,t:%d,b:%d). new (%d,%d,%dx%d)",
3727 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);
3729 e_client_layout_apply(ec, EINA_TRUE);
3730 e_client_frame_geometry_set(ec, x, y, w, h);
3733 e_client_shell_configure_send(ec, 0, w, h);
3737 _e_policy_set_modal(E_Client *ec, Eina_Bool modal)
3739 EINA_SAFETY_ON_NULL_RETURN(ec);
3740 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
3742 ELOGF("TZPOL", "Set modal to %d", ec, modal);
3743 e_client_modal_state_set(ec, modal);
3747 _tzpol_iface_cb_set_modal(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3751 ec = e_client_from_surface_resource(surf);
3752 _e_policy_set_modal(ec, EINA_TRUE);
3756 _tzpol_iface_cb_unset_modal(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
3760 ec = e_client_from_surface_resource(surf);
3761 _e_policy_set_modal(ec, EINA_FALSE);
3764 // --------------------------------------------------------
3765 // tizen_policy_interface
3766 // --------------------------------------------------------
3767 static const struct tizen_policy_interface _tzpol_iface =
3769 _tzpol_iface_cb_vis_get,
3770 _tzpol_iface_cb_pos_get,
3771 _tzpol_iface_cb_activate,
3772 _tzpol_iface_cb_activate_below_by_res_id,
3773 _tzpol_iface_cb_raise,
3774 _tzpol_iface_cb_lower,
3775 _tzpol_iface_cb_lower_by_res_id,
3776 _tzpol_iface_cb_focus_skip_set,
3777 _tzpol_iface_cb_focus_skip_unset,
3778 _tzpol_iface_cb_role_set,
3779 _tzpol_iface_cb_type_set,
3780 _tzpol_iface_cb_conformant_set,
3781 _tzpol_iface_cb_conformant_unset,
3782 _tzpol_iface_cb_conformant_get,
3783 _tzpol_iface_cb_notilv_set,
3784 _tzpol_iface_cb_transient_for_set,
3785 _tzpol_iface_cb_transient_for_unset,
3786 _tzpol_iface_cb_win_scrmode_set,
3787 _tzpol_iface_cb_subsurf_place_below_parent,
3788 _tzpol_iface_cb_subsurf_stand_alone_set,
3789 _tzpol_iface_cb_subsurface_get,
3790 _tzpol_iface_cb_opaque_state_set,
3791 _tzpol_iface_cb_iconify,
3792 _tzpol_iface_cb_uniconify,
3793 _tzpol_iface_cb_aux_hint_add,
3794 _tzpol_iface_cb_aux_hint_change,
3795 _tzpol_iface_cb_aux_hint_del,
3796 _tzpol_iface_cb_supported_aux_hints_get,
3797 _tzpol_iface_cb_background_state_set,
3798 _tzpol_iface_cb_background_state_unset,
3799 _tzpol_iface_cb_floating_mode_set,
3800 _tzpol_iface_cb_floating_mode_unset,
3801 _tzpol_iface_cb_stack_mode_set,
3802 _tzpol_iface_cb_activate_above_by_res_id,
3803 _tzpol_iface_cb_subsurf_watcher_get,
3804 _tzpol_iface_cb_parent_set,
3805 _tzpol_iface_cb_ack_conformant_region,
3806 _tzpol_iface_cb_destroy,
3807 _tzpol_iface_cb_has_video,
3808 _tzpol_iface_cb_set_appid,
3809 _tzpol_iface_cb_show,
3810 _tzpol_iface_cb_hide,
3811 _tzpol_iface_cb_set_transient_for_below,
3812 _tzpol_iface_cb_set_parent_with_below,
3813 _tzpol_iface_cb_set_maximize_direction,
3814 _tzpol_iface_cb_set_pin_mode,
3815 _tzpol_iface_cb_unset_pin_mode,
3816 _tzpol_iface_cb_set_layout,
3817 _tzpol_iface_cb_set_modal,
3818 _tzpol_iface_cb_unset_modal,
3822 _tzpol_cb_unbind(struct wl_resource *res_tzpol)
3824 E_Policy_Wl_Tzpol *tzpol;
3826 tzpol = _e_policy_wl_tzpol_get(res_tzpol);
3827 EINA_SAFETY_ON_NULL_RETURN(tzpol);
3829 eina_hash_del_by_key(polwl->tzpols, &res_tzpol);
3833 _tzpol_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
3835 E_Policy_Wl_Tzpol *tzpol;
3836 struct wl_resource *res_tzpol;
3838 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
3840 res_tzpol = wl_resource_create(client,
3841 &tizen_policy_interface,
3844 EINA_SAFETY_ON_NULL_GOTO(res_tzpol, err);
3846 tzpol = _e_policy_wl_tzpol_add(client, res_tzpol);
3847 EINA_SAFETY_ON_NULL_GOTO(tzpol, err);
3849 wl_resource_set_implementation(res_tzpol,
3856 ERR("Could not create tizen_policy_interface res: %m");
3857 wl_client_post_no_memory(client);
3860 // --------------------------------------------------------
3861 // tizen_display_policy_interface
3862 // --------------------------------------------------------
3863 static const struct tizen_display_policy_interface _tz_dpy_pol_iface =
3865 _tz_dpy_pol_iface_cb_brightness_set,
3866 _tz_dpy_pol_iface_cb_destroy,
3870 _tz_dpy_pol_cb_unbind(struct wl_resource *res_tz_dpy_pol)
3872 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3874 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_get(res_tz_dpy_pol);
3875 EINA_SAFETY_ON_NULL_RETURN(tz_dpy_pol);
3877 _e_policy_wl_tz_dpy_pol_del(tz_dpy_pol);
3881 _tz_dpy_pol_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
3883 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
3884 struct wl_resource *res_tz_dpy_pol;
3886 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
3888 res_tz_dpy_pol = wl_resource_create(client,
3889 &tizen_display_policy_interface,
3892 EINA_SAFETY_ON_NULL_GOTO(res_tz_dpy_pol, err);
3894 tz_dpy_pol = _e_policy_wl_tz_dpy_pol_add(res_tz_dpy_pol);
3895 EINA_SAFETY_ON_NULL_GOTO(tz_dpy_pol, err);
3897 wl_resource_set_implementation(res_tz_dpy_pol,
3900 _tz_dpy_pol_cb_unbind);
3904 ERR("Could not create tizen_display_policy_interface res: %m");
3905 wl_client_post_no_memory(client);
3908 // --------------------------------------------------------
3909 // tizen_ws_shell_interface::service
3910 // --------------------------------------------------------
3912 _tzsh_srv_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_srv)
3914 wl_resource_destroy(res_tzsh_srv);
3918 _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)
3920 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3921 E_Policy_Wl_Tzsh_Region *tzsh_reg;
3923 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
3924 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3926 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
3929 tzsh_reg = wl_resource_get_user_data(res_reg);
3930 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
3932 if ((tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT) ||
3933 (tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU) ||
3934 (tzsh_srv->role == TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU))
3936 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3937 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
3939 e_service_quickpanel_region_set(tzsh_srv->ec,
3944 else if (tzsh_srv->role == TZSH_SRV_ROLE_VOLUME)
3945 e_service_volume_region_set(type, angle, tzsh_reg->tiler);
3946 else if (tzsh_srv->role == TZSH_SRV_ROLE_SOFTKEY)
3948 if (e_config->use_softkey_service)
3950 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
3951 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
3953 e_service_softkey_handler_region_set(tzsh_srv->ec, angle, tzsh_reg->tiler);
3959 _tzsh_srv_indicator_cb_resource_destroy(struct wl_resource *resource)
3961 if (_indicator_srv_res == resource)
3962 _indicator_srv_res = NULL;
3966 _tzsh_srv_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
3968 _indicator_srv_res = NULL;
3969 wl_resource_destroy(resource);
3972 static const struct tws_service_indicator_interface _tzsh_srv_indicator_iface =
3974 _tzsh_srv_indicator_cb_destroy,
3978 _tzsh_srv_iface_cb_indicator_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
3980 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
3981 struct wl_resource *res;
3983 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
3984 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
3986 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
3989 res = wl_resource_create(client, &tws_service_indicator_interface, 1, id);
3992 wl_client_post_no_memory(client);
3995 _indicator_srv_res = res;
3997 wl_resource_set_implementation(res, &_tzsh_srv_indicator_iface, tzsh_srv,
3998 _tzsh_srv_indicator_cb_resource_destroy);
4002 _tzsh_srv_qp_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4004 wl_resource_destroy(resource);
4008 _tzsh_srv_qp_cb_msg(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4010 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4012 tzsh_srv = wl_resource_get_user_data(resource);
4014 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4015 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4017 #define EC tzsh_srv->ec
4018 EINA_SAFETY_ON_NULL_RETURN(EC);
4022 case TWS_SERVICE_QUICKPANEL_MSG_SHOW:
4023 e_service_quickpanel_show(EC);
4025 case TWS_SERVICE_QUICKPANEL_MSG_HIDE:
4026 e_service_quickpanel_hide(EC);
4029 ERR("Unknown message!! msg %d", msg);
4036 _tzsh_srv_qp_cb_effect_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t type)
4038 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4040 tzsh_srv = wl_resource_get_user_data(resource);
4042 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4043 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4045 #define EC tzsh_srv->ec
4046 EINA_SAFETY_ON_NULL_RETURN(EC);
4047 e_service_quickpanel_effect_type_set(EC, type);
4052 _tzsh_srv_qp_cb_scroll_lock_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t lock)
4054 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4056 tzsh_srv = wl_resource_get_user_data(resource);
4058 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4059 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4061 #define EC tzsh_srv->ec
4062 EINA_SAFETY_ON_NULL_RETURN(EC);
4063 e_service_quickpanel_scroll_lock_set(EC, lock);
4067 static const struct tws_service_quickpanel_interface _tzsh_srv_qp_iface =
4069 _tzsh_srv_qp_cb_destroy,
4070 _tzsh_srv_qp_cb_msg,
4071 _tzsh_srv_qp_cb_effect_type_set,
4072 _tzsh_srv_qp_cb_scroll_lock_set,
4076 _tzsh_srv_iface_cb_quickpanel_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4078 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4079 struct wl_resource *res;
4081 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4082 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4084 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4087 res = wl_resource_create(client,
4088 &tws_service_quickpanel_interface,
4089 wl_resource_get_version(res_tzsh_srv),
4093 wl_client_post_no_memory(client);
4097 wl_resource_set_implementation(res, &_tzsh_srv_qp_iface, tzsh_srv, NULL);
4103 _tzsh_srv_softkey_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4105 wl_resource_destroy(resource);
4109 _tzsh_srv_softkey_cb_msg_send(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4111 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4112 E_Service_Softkey *softkey_service;
4115 tzsh_srv = wl_resource_get_user_data(resource);
4117 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4118 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4120 zone = tzsh_srv->zone;
4121 EINA_SAFETY_ON_NULL_RETURN(zone);
4123 softkey_service = e_service_softkey_get(zone);
4124 EINA_SAFETY_ON_NULL_RETURN(softkey_service);
4128 case TWS_SERVICE_SOFTKEY_MSG_SHOW:
4129 e_service_softkey_show(softkey_service);
4131 case TWS_SERVICE_SOFTKEY_MSG_HIDE:
4132 e_service_softkey_hide(softkey_service);
4135 ERR("Unknown message!! msg %d", msg);
4140 static const struct tws_service_softkey_interface _tzsh_srv_softkey_iface =
4142 _tzsh_srv_softkey_cb_destroy,
4143 _tzsh_srv_softkey_cb_msg_send,
4147 _tzsh_srv_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4149 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4150 E_Service_Softkey *softkey_service = NULL;
4151 struct wl_resource *res;
4153 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4154 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4156 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4159 res = wl_resource_create(client, &tws_service_softkey_interface, 1, id);
4162 wl_client_post_no_memory(client);
4166 ELOGF("TZSH", "[SOFTKEY SERVICE] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
4170 E_Zone *zone = tzsh_srv->zone;
4172 softkey_service = e_service_softkey_get(zone);
4173 ELOGF("TZSH", "[SOFTKEY SERVICE] resource set. res:%p, softkey_service:%p, softkey_ec:%p", NULL, res, softkey_service, tzsh_srv->ec);
4174 if (softkey_service)
4176 e_service_softkey_wl_resource_set(softkey_service, res);
4177 e_service_softkey_restore_visible_request(softkey_service);
4181 wl_resource_set_implementation(res, &_tzsh_srv_softkey_iface, tzsh_srv, NULL);
4185 _tzsh_srv_magnifier_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4187 wl_resource_destroy(resource);
4191 _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)
4193 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4196 tzsh_srv = wl_resource_get_user_data(resource);
4198 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4199 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4200 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4202 ELOGF("TZSH", "[MAGNIFIER] Set Geometry. angle:%d, geo:%d,%d,%dx%d", tzsh_srv->ec, angle, x, y, w, h);
4205 // angle: 0, 90, 180, 270
4206 e_magnifier_zoom_obj_geometry_set(ec, angle, x, y, w, h);
4210 _tzsh_srv_magnifier_cb_ratio_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t ratio)
4212 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4215 tzsh_srv = wl_resource_get_user_data(resource);
4217 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4218 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4219 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4221 ELOGF("TZSH", "[MAGNIFIER] Set Ratio. ratio:%d", tzsh_srv->ec, ratio);
4224 // ratio : 100 ~ 200 (each 10)
4225 e_magnifier_zoom_obj_ratio_set(ec, ratio);
4229 _tzsh_srv_magnifier_cb_enable_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t enable)
4231 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4234 tzsh_srv = wl_resource_get_user_data(resource);
4236 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4237 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4238 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
4240 ELOGF("TZSH", "[MAGNIFIER] Set Enable. enable:%d", tzsh_srv->ec, enable);
4245 e_magnifier_show(ec);
4247 e_magnifier_hide(ec);
4250 static const struct tws_service_magnifier_interface _tzsh_srv_magnifier_iface =
4252 _tzsh_srv_magnifier_cb_destroy,
4253 _tzsh_srv_magnifier_cb_zoom_geometry_set,
4254 _tzsh_srv_magnifier_cb_ratio_set,
4255 _tzsh_srv_magnifier_cb_enable_set,
4259 _tzsh_srv_iface_cb_magnifier_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4261 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4262 struct wl_resource *res;
4264 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4265 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4267 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4270 res = wl_resource_create(client, &tws_service_magnifier_interface, 1, id);
4273 wl_client_post_no_memory(client);
4277 ELOGF("TZSH", "[MAGNIFIER] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
4278 wl_resource_set_implementation(res, &_tzsh_srv_magnifier_iface, tzsh_srv, NULL);
4281 //////////////////////////////////////////////////////////////////////////////////////////////////////
4283 _tzsh_srv_scrsaver_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4285 wl_resource_destroy(resource);
4288 static const struct tws_service_screensaver_interface _tzsh_srv_scrsaver_iface =
4290 _tzsh_srv_scrsaver_cb_release
4294 _tzsh_srv_iface_cb_scrsaver_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4296 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4297 struct wl_resource *res;
4299 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4300 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4302 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4305 res = wl_resource_create(client, &tws_service_screensaver_interface, 1, id);
4308 wl_client_post_no_memory(client);
4312 wl_resource_set_implementation(res, &_tzsh_srv_scrsaver_iface, tzsh_srv, NULL);
4316 _tzsh_srv_scrsaver_mng_cb_resource_destroy(struct wl_resource *resource)
4318 if (_scrsaver_mng_res == resource)
4320 _scrsaver_mng_res = NULL;
4321 e_screensaver_disable();
4326 _tzsh_srv_scrsaver_mng_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4328 _scrsaver_mng_res = NULL;
4329 wl_resource_destroy(resource);
4330 e_screensaver_disable();
4334 _tzsh_srv_scrsaver_mng_cb_enable(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4336 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4338 tzsh_srv = wl_resource_get_user_data(resource);
4340 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4341 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4343 e_screensaver_enable();
4347 _tzsh_srv_scrsaver_mng_cb_disable(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4349 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4351 tzsh_srv = wl_resource_get_user_data(resource);
4353 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4354 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4356 e_screensaver_disable();
4360 _tzsh_srv_scrsaver_mng_cb_idle_time_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t time)
4362 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4365 tzsh_srv = wl_resource_get_user_data(resource);
4367 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4368 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4370 /* convert time to seconds (double) from milliseconds (unsigned int) */
4371 timeout = (double)time * 0.001f;
4373 e_screensaver_timeout_set(timeout);
4377 _tzsh_srv_scrsaver_mng_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t type)
4379 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4383 tzsh_srv = wl_resource_get_user_data(resource);
4385 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4386 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4390 case TWS_SERVICE_SCREENSAVER_MANAGER_STATE_TYPE_IDLE_TIMEOUT:
4391 /* convert time to milliseconds (unsigned int) from seconds (double) */
4392 timeout = e_screensaver_timeout_get();
4393 val = (uint32_t)(timeout * 1000);
4399 tws_service_screensaver_manager_send_state_get_done(resource, type, val, 0);
4402 static const struct tws_service_screensaver_manager_interface _tzsh_srv_scrsaver_mng_iface =
4404 _tzsh_srv_scrsaver_mng_cb_destroy,
4405 _tzsh_srv_scrsaver_mng_cb_enable,
4406 _tzsh_srv_scrsaver_mng_cb_disable,
4407 _tzsh_srv_scrsaver_mng_cb_idle_time_set,
4408 _tzsh_srv_scrsaver_mng_cb_state_get
4412 _tzsh_srv_iface_cb_scrsaver_mng_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4414 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4415 struct wl_resource *res;
4417 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4418 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4420 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4423 res = wl_resource_create(client, &tws_service_screensaver_manager_interface, 1, id);
4426 wl_client_post_no_memory(client);
4430 _scrsaver_mng_res = res;
4432 wl_resource_set_implementation(res, &_tzsh_srv_scrsaver_mng_iface, tzsh_srv,
4433 _tzsh_srv_scrsaver_mng_cb_resource_destroy);
4437 _tzsh_srv_cbhm_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4439 wl_resource_destroy(resource);
4443 _tzsh_srv_cbhm_cb_msg(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t msg)
4445 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4447 tzsh_srv = wl_resource_get_user_data(resource);
4449 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4450 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4452 #define EC tzsh_srv->ec
4453 EINA_SAFETY_ON_NULL_RETURN(EC);
4457 case TWS_SERVICE_CBHM_MSG_SHOW:
4458 e_service_cbhm_show();
4460 case TWS_SERVICE_CBHM_MSG_HIDE:
4461 e_service_cbhm_hide();
4463 case TWS_SERVICE_CBHM_MSG_DATA_SELECTED:
4464 e_service_cbhm_data_selected();
4467 ERR("Unknown message!! msg %d", msg);
4473 static const struct tws_service_cbhm_interface _tzsh_srv_cbhm_iface =
4475 _tzsh_srv_cbhm_cb_destroy,
4476 _tzsh_srv_cbhm_cb_msg
4480 _tzsh_srv_iface_cb_cbhm_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4482 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4483 struct wl_resource *res;
4485 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4486 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4488 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4491 res = wl_resource_create(client, &tws_service_cbhm_interface, 1, id);
4494 wl_client_post_no_memory(client);
4498 wl_resource_set_implementation(res, &_tzsh_srv_cbhm_iface, tzsh_srv, NULL);
4503 _tzsh_srv_iface_cb_launcher_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4505 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4506 struct wl_resource *res;
4508 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4509 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4510 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4512 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4515 res = wl_resource_create(client, &tws_service_launcher_interface, 1, id);
4518 wl_client_post_no_memory(client);
4523 e_service_launcher_resource_set(tzsh_srv->ec, res);
4527 _tzsh_srv_taskbar_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4529 wl_resource_destroy(resource);
4533 _tzsh_srv_taskbar_cb_place_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t place_type)
4535 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4538 tzsh_srv = wl_resource_get_user_data(resource);
4539 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4540 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4543 EINA_SAFETY_ON_NULL_RETURN(ec);
4545 e_service_taskbar_place_type_set(ec, place_type);
4549 _tzsh_srv_taskbar_cb_size_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t width, uint32_t height)
4551 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4554 tzsh_srv = wl_resource_get_user_data(resource);
4555 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4556 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4559 EINA_SAFETY_ON_NULL_RETURN(ec);
4561 e_service_taskbar_size_set(ec, width, height);
4565 _tzsh_srv_taskbar_cb_auto_placement_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t auto_placement)
4567 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4570 tzsh_srv = wl_resource_get_user_data(resource);
4571 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4572 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4575 EINA_SAFETY_ON_NULL_RETURN(ec);
4577 e_service_taskbar_auto_placement_set(ec, auto_placement);
4580 static const struct tws_service_taskbar_interface _tzsh_srv_taskbar_iface =
4582 _tzsh_srv_taskbar_cb_destroy,
4583 _tzsh_srv_taskbar_cb_place_type_set,
4584 _tzsh_srv_taskbar_cb_size_set,
4585 _tzsh_srv_taskbar_cb_auto_placement_set,
4589 _tzsh_srv_iface_cb_taskbar_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4591 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4592 struct wl_resource *res;
4594 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4595 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4596 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4598 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4601 res = wl_resource_create(client,
4602 &tws_service_taskbar_interface,
4607 wl_client_post_no_memory(client);
4611 wl_resource_set_implementation(res, &_tzsh_srv_taskbar_iface, tzsh_srv, NULL);
4615 _tzsh_srv_kvm_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4617 wl_resource_destroy(resource);
4621 _tzsh_srv_kvm_cb_perform_drop(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4623 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4626 tzsh_srv = wl_resource_get_user_data(resource);
4627 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4630 EINA_SAFETY_ON_NULL_RETURN(ec);
4632 if (!e_comp_wl->drag) return;
4634 e_service_kvm_drop_perform(ec);
4638 _tzsh_srv_kvm_cb_cancel_drag(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4640 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4643 tzsh_srv = wl_resource_get_user_data(resource);
4644 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4647 EINA_SAFETY_ON_NULL_RETURN(ec);
4649 if (!e_comp_wl->drag) return;
4651 e_service_kvm_drag_cancel(ec);
4655 _tzsh_srv_kvm_cb_perform_drag_enter(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4657 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4660 tzsh_srv = wl_resource_get_user_data(resource);
4661 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4664 EINA_SAFETY_ON_NULL_RETURN(ec);
4666 if (!e_comp_wl->drag) return;
4668 e_service_kvm_perform_drag_enter(ec);
4672 _tzsh_srv_kvm_cb_perform_drag_leave(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4674 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4677 tzsh_srv = wl_resource_get_user_data(resource);
4678 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4681 EINA_SAFETY_ON_NULL_RETURN(ec);
4683 if (!e_comp_wl->drag) return;
4685 e_service_kvm_perform_drag_leave(ec);
4689 _tzsh_srv_kvm_cb_secondary_selection_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4691 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4694 tzsh_srv = wl_resource_get_user_data(resource);
4695 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4698 EINA_SAFETY_ON_NULL_RETURN(ec);
4700 e_service_kvm_secondary_selection_set(ec, EINA_TRUE);
4704 _tzsh_srv_kvm_cb_secondary_selection_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
4706 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4709 tzsh_srv = wl_resource_get_user_data(resource);
4710 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4713 EINA_SAFETY_ON_NULL_RETURN(ec);
4715 e_service_kvm_secondary_selection_set(ec, EINA_FALSE);
4718 static const struct tws_service_kvm_interface _tzsh_srv_kvm_iface =
4720 _tzsh_srv_kvm_cb_destroy,
4721 _tzsh_srv_kvm_cb_perform_drop,
4722 _tzsh_srv_kvm_cb_cancel_drag,
4723 _tzsh_srv_kvm_cb_perform_drag_enter,
4724 _tzsh_srv_kvm_cb_perform_drag_leave,
4725 _tzsh_srv_kvm_cb_secondary_selection_set,
4726 _tzsh_srv_kvm_cb_secondary_selection_unset,
4730 _tzsh_srv_iface_cb_kvm_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
4732 E_Service_Kvm *esk = NULL;
4733 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4734 struct wl_resource *res;
4737 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4738 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4739 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
4741 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4744 res = wl_resource_create(client,
4745 &tws_service_kvm_interface,
4750 wl_client_post_no_memory(client);
4754 ELOGF("KVM", "multi control resource created, res:%p, tzsh_srv:%p, res_tzsh_srv:%p", NULL, res, tzsh_srv, res_tzsh_srv);
4758 esk = e_service_kvm_service_get(ec);
4762 ELOGF("KVM", "multi control resource set. res:%p, service:%p, ec:%p", NULL, res, esk, ec);
4763 e_service_kvm_wl_resource_set(esk, res);
4766 wl_resource_set_implementation(res, &_tzsh_srv_kvm_iface, tzsh_srv, NULL);
4769 static const struct tws_service_interface _tzsh_srv_iface =
4771 _tzsh_srv_iface_cb_destroy,
4772 _tzsh_srv_iface_cb_region_set,
4773 _tzsh_srv_iface_cb_indicator_get,
4774 _tzsh_srv_iface_cb_quickpanel_get,
4775 _tzsh_srv_iface_cb_scrsaver_mng_get,
4776 _tzsh_srv_iface_cb_scrsaver_get,
4777 _tzsh_srv_iface_cb_cbhm_get,
4778 _tzsh_srv_iface_cb_softkey_get,
4779 _tzsh_srv_iface_cb_magnifier_get,
4780 _tzsh_srv_iface_cb_launcher_get,
4781 _tzsh_srv_iface_cb_taskbar_get,
4782 _tzsh_srv_iface_cb_kvm_get,
4786 _e_policy_wl_tzsh_service_check_privilege(struct wl_client *client, int role)
4788 const char *privilege;
4795 case TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT:
4796 case TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU:
4797 case TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU:
4798 privilege = E_PRIVILEGE_QUICKPANEL_SERVICE;
4800 case TZSH_SRV_ROLE_VOLUME:
4801 privilege = E_PRIVILEGE_VOLUME_SERVICE;
4803 case TZSH_SRV_ROLE_LOCKSCREEN:
4804 privilege = E_PRIVILEGE_LOCKSCREEN_SERVICE;
4806 case TZSH_SRV_ROLE_INDICATOR:
4807 privilege = E_PRIVILEGE_INDICATOR_SERVICE;
4809 case TZSH_SRV_ROLE_SCREENSAVER_MNG:
4810 case TZSH_SRV_ROLE_SCREENSAVER:
4811 privilege = E_PRIVILEGE_SCREENSAVER_SERVICE;
4813 case TZSH_SRV_ROLE_CBHM:
4814 privilege = E_PRIVILEGE_CBHM_SERVICE;
4816 case TZSH_SRV_ROLE_SOFTKEY:
4817 privilege = E_PRIVILEGE_SOFTKEY_SERVICE;
4819 case TZSH_SRV_ROLE_MAGNIFIER:
4820 privilege = E_PRIVILEGE_MAGNIFIER_SERVICE;
4822 case TZSH_SRV_ROLE_LAUNCHER:
4823 privilege = E_PRIVILEGE_LAUNCHER_SERVICE;
4825 case TZSH_SRV_ROLE_TASKBAR:
4826 privilege = E_PRIVILEGE_TASKBAR_SERVICE;
4828 /* TODO: need to check privilege
4829 case TZSH_SRV_ROLE_KVM:
4830 privilege = E_PRIVILEGE_KVM_SERVICE;
4837 wl_client_get_credentials(client, &pid, &uid, NULL);
4838 res = e_security_privilege_check(pid,
4845 _tzsh_cb_srv_destroy(struct wl_resource *res_tzsh_srv)
4847 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4849 tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
4850 EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
4852 if (!eina_list_data_find(polwl->tzsh_srvs, tzsh_srv))
4855 _e_policy_wl_tzsh_srv_del(tzsh_srv);
4859 _tzsh_iface_cb_srv_create(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id, const char *name)
4861 E_Policy_Wl_Tzsh *tzsh;
4862 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
4863 struct wl_resource *res_tzsh_srv;
4869 role = _e_policy_wl_tzsh_srv_role_get(name);
4870 if (role == TZSH_SRV_ROLE_UNKNOWN)
4872 wl_resource_post_error
4874 WL_DISPLAY_ERROR_INVALID_OBJECT,
4875 "Invalid res_tzsh");
4879 /* check whether client has a privilege */
4880 res = _e_policy_wl_tzsh_service_check_privilege(client, role);
4883 ERR("Could not get privilege of resource: %m");
4884 tizen_ws_shell_send_error(res_tzsh,
4885 TIZEN_WS_SHELL_ERROR_PERMISSION_DENIED);
4889 /* to avoid sending a wayland error after tzsh ERROR_NONE for every cases
4890 * such as invalid object or no memory error, tzsh ERROR_NONE should be sent
4891 * first to clients without privilege problem.
4893 tizen_ws_shell_send_error(res_tzsh, TIZEN_WS_SHELL_ERROR_NONE);
4895 tzsh = wl_resource_get_user_data(res_tzsh);
4898 wl_resource_post_error
4900 WL_DISPLAY_ERROR_INVALID_OBJECT,
4901 "Invalid res_tzsh's user data");
4905 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
4908 if (role == TZSH_SRV_ROLE_INDICATOR)
4909 cp = e_pixmap_new(E_PIXMAP_TYPE_NONE, 0);
4913 wl_resource_post_error
4915 WL_DISPLAY_ERROR_INVALID_OBJECT,
4916 "Invalid surface id");
4921 ec = e_pixmap_client_get(cp);
4924 if (role == TZSH_SRV_ROLE_INDICATOR)
4926 ec = e_client_new(cp, 0, 1);
4927 if (ec) ec->ignored = 1;
4933 if (!_e_policy_wl_e_client_is_valid(ec))
4935 wl_resource_post_error
4937 WL_DISPLAY_ERROR_INVALID_OBJECT,
4938 "Invalid surface id");
4943 res_tzsh_srv = wl_resource_create(client,
4944 &tws_service_interface,
4945 wl_resource_get_version(res_tzsh),
4949 ERR("Could not create tws_service resource: %m");
4950 wl_client_post_no_memory(client);
4954 tzsh_srv = _e_policy_wl_tzsh_srv_add(tzsh,
4962 ERR("Could not create WS_Shell_Service");
4963 wl_client_post_no_memory(client);
4964 wl_resource_destroy(res_tzsh_srv);
4968 wl_resource_set_implementation(res_tzsh_srv,
4971 _tzsh_cb_srv_destroy);
4973 if (tzsh_srv->ec && tzsh_srv->ec->maximized)
4975 tzsh_srv->ec->maximize_type = E_MAXIMIZE_TYPE_FULLSCREEN;
4976 e_client_maximize(tzsh_srv->ec, tzsh_srv->ec->maximize_type | E_MAXIMIZE_BOTH);
4979 if (role == TZSH_SRV_ROLE_QUICKPANEL_SYSTEM_DEFAULT)
4980 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_SYSTEM_DEFAULT);
4981 else if (role == TZSH_SRV_ROLE_QUICKPANEL_CONTEXT_MENU)
4982 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_CONTEXT_MENU);
4983 else if (role == TZSH_SRV_ROLE_QUICKPANEL_APPS_MENU)
4984 e_service_quickpanel_client_add(tzsh_srv->ec, E_SERVICE_QUICKPANEL_TYPE_APPS_MENU);
4985 else if (role == TZSH_SRV_ROLE_VOLUME)
4986 e_service_volume_client_set(tzsh_srv->ec);
4987 else if (role == TZSH_SRV_ROLE_LOCKSCREEN)
4988 e_service_lockscreen_client_set(tzsh_srv->ec);
4989 else if (role == TZSH_SRV_ROLE_SCREENSAVER_MNG)
4990 e_service_scrsaver_client_set(tzsh_srv->ec);
4991 else if (role == TZSH_SRV_ROLE_SCREENSAVER)
4992 e_service_scrsaver_client_set(tzsh_srv->ec);
4993 else if (role == TZSH_SRV_ROLE_INDICATOR)
4994 e_mod_indicator_client_set(tzsh_srv->ec);
4995 else if (role == TZSH_SRV_ROLE_CBHM)
4996 e_service_cbhm_client_set(tzsh_srv->ec);
4997 else if (role == TZSH_SRV_ROLE_SOFTKEY)
4998 e_service_softkey_client_set(tzsh_srv->ec);
4999 else if (role == TZSH_SRV_ROLE_MAGNIFIER)
5002 e_magnifier_owner_set(tzsh_srv->ec);
5004 else if (role == TZSH_SRV_ROLE_LAUNCHER)
5005 e_service_launcher_client_set(tzsh_srv->ec);
5006 else if (role == TZSH_SRV_ROLE_TASKBAR)
5007 e_service_taskbar_client_set(tzsh_srv->ec);
5008 else if (role == TZSH_SRV_ROLE_KVM)
5009 e_service_kvm_client_set(tzsh_srv->ec);
5011 e_client_desk_iconify_skip_set(tzsh_srv->ec, EINA_TRUE);
5014 // --------------------------------------------------------
5015 // tizen_ws_shell common
5016 // --------------------------------------------------------
5018 e_tzsh_extension_add(const char *name, E_Policy_Wl_Tzsh_Ext_Hook_Cb cb)
5020 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5022 if (_e_policy_wl_tzsh_extension_get(name))
5024 ERR("Already exists the %s extension\n", name);
5028 tzsh_ext = E_NEW(E_Policy_Wl_Tzsh_Extension, 1);
5029 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_ext, EINA_FALSE);
5031 tzsh_ext->name = strndup(name, 512);
5034 polwl->tzsh_extensions = eina_list_append(polwl->tzsh_extensions, tzsh_ext);
5036 "EXTENSION_ADD | name:%s | cb:%p",
5044 e_tzsh_extension_del(const char *name)
5046 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5048 tzsh_ext = _e_policy_wl_tzsh_extension_get(name);
5051 ERR("Cannot find the %s extension\n", name);
5055 polwl->tzsh_extensions = eina_list_remove(polwl->tzsh_extensions, tzsh_ext);
5056 memset(tzsh_ext, 0x0, sizeof(E_Policy_Wl_Tzsh_Extension));
5060 "EXTENSION_DEL | name:%s",
5065 // --------------------------------------------------------
5066 // tizen_ws_shell_interface::region
5067 // --------------------------------------------------------
5069 _tzsh_reg_cb_shell_destroy(struct wl_listener *listener, void *data)
5071 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5073 tzsh_reg = container_of(listener, E_Policy_Wl_Tzsh_Region, destroy_listener);
5074 if (tzsh_reg->destroy_listener.notify)
5076 wl_list_remove(&tzsh_reg->destroy_listener.link);
5077 tzsh_reg->destroy_listener.notify = NULL;
5080 if (tzsh_reg->res_tzsh_reg)
5082 wl_resource_destroy(tzsh_reg->res_tzsh_reg);
5083 tzsh_reg->res_tzsh_reg = NULL;
5088 _tzsh_reg_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_reg)
5090 wl_resource_destroy(res_tzsh_reg);
5094 _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)
5096 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5098 int area_w = 0, area_h = 0;
5100 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5101 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5102 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg->tiler);
5104 eina_tiler_area_size_get(tzsh_reg->tiler, &area_w, &area_h);
5105 src = eina_tiler_new(area_w, area_h);
5106 eina_tiler_tile_size_set(src, 1, 1);
5107 eina_tiler_rect_add(src, &(Eina_Rectangle){x, y, w, h});
5108 eina_tiler_union(tzsh_reg->tiler, src);
5109 eina_tiler_free(src);
5113 _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)
5115 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5117 int area_w = 0, area_h = 0;
5119 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5120 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5121 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg->tiler);
5123 eina_tiler_area_size_get(tzsh_reg->tiler, &area_w, &area_h);
5124 src = eina_tiler_new(area_w, area_h);
5125 eina_tiler_tile_size_set(src, 1, 1);
5126 eina_tiler_rect_add(src, &(Eina_Rectangle){x, y, w, h});
5127 eina_tiler_subtract(tzsh_reg->tiler, src);
5128 eina_tiler_free(src);
5131 static const struct tws_region_interface _tzsh_reg_iface =
5133 _tzsh_reg_iface_cb_destroy,
5134 _tzsh_reg_iface_cb_add,
5135 _tzsh_reg_iface_cb_subtract
5139 _tzsh_reg_cb_destroy(struct wl_resource *res_tzsh_reg)
5141 E_Policy_Wl_Tzsh_Region *tzsh_reg;
5143 tzsh_reg = wl_resource_get_user_data(res_tzsh_reg);
5144 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5146 if (tzsh_reg->destroy_listener.notify)
5148 wl_list_remove(&tzsh_reg->destroy_listener.link);
5149 tzsh_reg->destroy_listener.notify = NULL;
5151 eina_tiler_free(tzsh_reg->tiler);
5157 _tzsh_iface_cb_reg_create(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id)
5159 E_Policy_Wl_Tzsh *tzsh;
5160 E_Policy_Wl_Tzsh_Region *tzsh_reg = NULL;
5161 Eina_Tiler *tz = NULL;
5162 struct wl_resource *res_tzsh_reg;
5165 tzsh = wl_resource_get_user_data(res_tzsh);
5168 wl_resource_post_error
5170 WL_DISPLAY_ERROR_INVALID_OBJECT,
5171 "Invalid res_tzsh's user data");
5175 tzsh_reg = E_NEW(E_Policy_Wl_Tzsh_Region, 1);
5176 EINA_SAFETY_ON_NULL_RETURN(tzsh_reg);
5178 e_zone_useful_geometry_get(e_zone_current_get(),
5179 NULL, NULL, &zw, &zh);
5181 tz = eina_tiler_new(zw, zh);
5182 EINA_SAFETY_ON_NULL_GOTO(tz, err);
5183 tzsh_reg->tiler = tz;
5185 eina_tiler_tile_size_set(tzsh_reg->tiler, 1, 1);
5187 if (!(res_tzsh_reg = wl_resource_create(client,
5188 &tws_region_interface,
5189 wl_resource_get_version(res_tzsh),
5192 ERR("Could not create tws_service resource: %m");
5193 wl_client_post_no_memory(client);
5197 wl_resource_set_implementation(res_tzsh_reg,
5200 _tzsh_reg_cb_destroy);
5202 tzsh_reg->tzsh = tzsh;
5203 tzsh_reg->res_tzsh_reg = res_tzsh_reg;
5204 tzsh_reg->destroy_listener.notify = _tzsh_reg_cb_shell_destroy;
5206 wl_resource_add_destroy_listener(res_tzsh,
5207 &tzsh_reg->destroy_listener);
5211 if (tzsh_reg->tiler) eina_tiler_free(tzsh_reg->tiler);
5215 // --------------------------------------------------------
5216 // tizen_ws_shell_interface::indicator
5217 // --------------------------------------------------------
5219 _e_tzsh_indicator_find_topvisible_client(E_Zone *zone)
5225 o = evas_object_top_get(e_comp->evas);
5226 for (; o; o = evas_object_below_get(o))
5228 ec = evas_object_data_get(o, "E_Client");
5230 /* check e_client and skip e_clients not intersects with zone */
5232 if (e_object_is_del(E_OBJECT(ec))) continue;
5233 if (e_client_util_ignored_get(ec)) continue;
5234 if (!e_zone_has_ec(zone, ec)) continue;
5235 if (!ec->frame) continue;
5237 if (!ec->visible) continue;
5238 if (ec->visibility.skip) continue;
5239 if ((e_client_visibility_get(ec) != E_VISIBILITY_UNOBSCURED) &&
5240 (e_client_visibility_get(ec) != E_VISIBILITY_PARTIALLY_OBSCURED) &&
5241 (!eina_list_data_find(e_comp->launchscrns, ec)))
5244 if (e_comp_wl_subsurface_check(ec)) continue;
5246 e_client_geometry_get(ec, &ex, &ey, &ew, &eh);
5247 if (!E_CONTAINS(ex, ey, ew, eh, zone->x, zone->y, zone->w, zone->h))
5258 e_tzsh_indicator_srv_property_change_send(E_Client *ec, int angle)
5263 if (!_indicator_srv_res)
5265 ELOGF("TZ_IND", "NO indicator service", NULL);
5269 opacity = ec->indicator.opacity_mode;
5271 ELOGF("TZ_IND", "SEND indicator info. angle:%d, opacity:%d", ec, angle, opacity);
5272 tws_service_indicator_send_property_change(_indicator_srv_res, angle, opacity);
5276 e_tzsh_indicator_srv_property_update(E_Client *ec)
5278 E_Client *ec_ind_owner;
5279 if (!_indicator_srv_res) return;
5281 ec_ind_owner = e_mod_indicator_owner_get();
5282 if (ec != ec_ind_owner) return;
5284 if (ec->e.state.rot.ang.next != -1)
5285 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.next);
5287 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.curr);
5291 e_tzsh_indicator_srv_ower_win_update(E_Zone *zone)
5293 E_Client *ec = NULL;
5294 E_Client *ec_cur_owner = NULL;
5297 if (!_indicator_srv_res) return;
5299 ec_cur_owner = e_mod_indicator_owner_get();
5300 ec = _e_tzsh_indicator_find_topvisible_client(zone);
5302 if (ec != ec_cur_owner)
5304 ELOGF("TZ_IND", "Changed OWNER. win:%zx, state:%d, opacity:%d, vtype:%d", NULL, e_client_util_win_get(ec),
5305 ec ? ec->indicator.state:-1, ec ? ec->indicator.opacity_mode:-1, ec ? ec->indicator.visible_type:-1);
5306 e_mod_indicator_owner_set(ec);
5308 if (ec && !ec->e.state.rot.pending_show)
5310 ELOGF("TZ_IND", "Property Update. name:%s curr:%d, next:%d", NULL, ec->icccm.name?:"NULL",
5311 ec->e.state.rot.ang.curr, ec->e.state.rot.ang.next);
5312 e_tzsh_indicator_srv_property_update(ec);
5317 // --------------------------------------------------------
5318 // tizen_ws_shell_interface::quickpanel
5319 // --------------------------------------------------------
5321 _tzsh_client_data_quickpanel_type_set(E_Policy_Wl_Tzsh_Client_Data_Quickpanel *quickpanel_client, E_Quickpanel_Type type)
5323 if (quickpanel_client)
5324 quickpanel_client->type = type;
5327 static E_Quickpanel_Type
5328 _tzsh_client_data_quickpanel_type_get(E_Policy_Wl_Tzsh_Client_Data_Quickpanel *quickpanel_client)
5330 if (!quickpanel_client)
5331 return E_QUICKPANEL_TYPE_UNKNOWN;
5333 return quickpanel_client->type;
5337 _e_tzsh_qp_state_change_send(struct wl_resource *res_tzsh_client, int type, int value)
5339 struct wl_array states;
5340 E_Tzsh_QP_Event *ev;
5342 if (!res_tzsh_client) return;
5344 wl_array_init(&states);
5345 ev = wl_array_add(&states, sizeof(E_Tzsh_QP_Event));
5351 tws_quickpanel_send_state_changed(res_tzsh_client, &states);
5353 wl_array_release(&states);
5357 _e_tzsh_qp_client_data_type_check(E_Policy_Wl_Tzsh_Client *tzsh_client, E_Quickpanel_Type type)
5359 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5364 if (tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL)
5367 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5368 if (!tzsh_client_quickpanel)
5371 if (_tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel) != type)
5378 e_tzsh_qp_state_visible_update(E_Client *ec, Eina_Bool vis, E_Quickpanel_Type type)
5380 E_Policy_Wl_Tzsh_Client *tzsh_client;
5385 if (e_object_is_del(E_OBJECT(ec))) return;
5387 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5389 /* check for type of qp */
5390 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5392 if (!tzsh_client->tzsh) continue;
5393 if (!tzsh_client->ec) continue;
5395 if (tzsh_client->ep == ec->pixmap)
5397 if (tzsh_client->ec != ec)
5400 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5409 val = vis ? TWS_QUICKPANEL_STATE_VALUE_VISIBLE_SHOW : TWS_QUICKPANEL_STATE_VALUE_VISIBLE_HIDE;
5410 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5411 TWS_QUICKPANEL_STATE_TYPE_VISIBILITY,
5418 e_tzsh_qp_state_scrollable_update(E_Client *ec, Eina_Bool scrollable, E_Quickpanel_Type type)
5420 E_Policy_Wl_Tzsh_Client *tzsh_client;
5425 if (e_object_is_del(E_OBJECT(ec))) return;
5427 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5429 /* check for type of qp */
5430 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5432 if (!tzsh_client->tzsh) continue;
5433 if (!tzsh_client->ec) continue;
5435 if (tzsh_client->ep == ec->pixmap)
5437 if (tzsh_client->ec != ec)
5440 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5449 val = scrollable ? TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET : TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET;
5450 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5451 TWS_QUICKPANEL_STATE_TYPE_SCROLLABLE,
5458 e_tzsh_qp_state_orientation_update(E_Client *ec, int ridx, E_Quickpanel_Type type)
5460 E_Policy_Wl_Tzsh_Client *tzsh_client;
5465 if (e_object_is_del(E_OBJECT(ec))) return;
5467 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
5469 /* check for type of qp */
5470 if (!_e_tzsh_qp_client_data_type_check(tzsh_client, type))
5472 if (!tzsh_client->tzsh) continue;
5473 if (!tzsh_client->ec) continue;
5475 if (tzsh_client->ep == ec->pixmap)
5477 if (tzsh_client->ec != ec)
5480 "CRI ERR!!|tzsh_client_ep:%8p|tzsh_client_ec:%8p|tzsh_client:%8p|tzsh:%8p",
5489 val = TWS_QUICKPANEL_STATE_VALUE_ORIENTATION_0 + ridx;
5490 _e_tzsh_qp_state_change_send(tzsh_client->res_tzsh_client,
5491 TWS_QUICKPANEL_STATE_TYPE_ORIENTATION,
5498 _tzsh_qp_iface_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5500 wl_resource_destroy(res_tzsh_qp);
5503 static E_Quickpanel_Type
5504 _e_tzsh_qp_type_get(E_Policy_Wl_Tzsh_Client *tzsh_client)
5506 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5507 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5508 if (!tzsh_client_quickpanel)
5509 return E_QUICKPANEL_TYPE_UNKNOWN;
5511 return _tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel);
5516 _tzsh_qp_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5518 E_Policy_Wl_Tzsh_Client *tzsh_client;
5521 ELOGF("TZ_QUICKPANEL", "Request to Show Quickpanel", NULL);
5523 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5524 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5525 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5526 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5527 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5529 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5530 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5532 ec = tzsh_client->ec;
5534 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5537 e_qp_client_show(ec, qp_type);
5541 _tzsh_qp_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5543 E_Policy_Wl_Tzsh_Client *tzsh_client;
5546 ELOGF("TZ_QUICKPANEL", "Request to Hide Quickpanel", NULL);
5548 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5549 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5550 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5551 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5552 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5554 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5555 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5557 ec = tzsh_client->ec;
5559 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5562 e_qp_client_hide(ec, qp_type);
5566 _tzsh_qp_iface_cb_enable(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5568 E_Policy_Wl_Tzsh_Client *tzsh_client;
5571 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state of Quickpanel to 1", NULL);
5573 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5574 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5575 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5576 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5577 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5579 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5580 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5582 ec = tzsh_client->ec;
5584 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5587 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_SET);
5591 _tzsh_qp_iface_cb_disable(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp)
5593 E_Policy_Wl_Tzsh_Client *tzsh_client;
5596 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state of Quickpanel to 0", NULL);
5598 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5599 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5600 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5601 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5602 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5604 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5605 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5607 ec = tzsh_client->ec;
5609 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5612 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET);
5616 _tzsh_qp_iface_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, int32_t type)
5618 E_Policy_Wl_Tzsh_Client *tzsh_client;
5621 E_Quickpanel_Client_Scroll_State scrollable;
5623 int val = TWS_QUICKPANEL_STATE_VALUE_UNKNOWN;
5625 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5626 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5627 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5628 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5629 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5631 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5632 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5634 ec = tzsh_client->ec;
5636 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5641 case TWS_QUICKPANEL_STATE_TYPE_VISIBILITY:
5642 val = TWS_QUICKPANEL_STATE_VALUE_VISIBLE_HIDE;
5643 vis = e_qp_visible_get(ec, qp_type);
5644 if (vis) val = TWS_QUICKPANEL_STATE_VALUE_VISIBLE_SHOW;
5646 case TWS_QUICKPANEL_STATE_TYPE_SCROLLABLE:
5647 scrollable = e_qp_client_scrollable_state_get(ec, qp_type);
5648 if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET)
5649 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET;
5650 else if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_SET)
5651 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET;
5652 else if (scrollable == E_QUICKPANEL_CLIENT_SCROLL_STATE_RETAIN)
5653 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_RETAIN;
5655 val = TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET;
5657 case TWS_QUICKPANEL_STATE_TYPE_ORIENTATION:
5658 ridx = e_qp_orientation_get(ec, qp_type);
5659 val = TWS_QUICKPANEL_STATE_VALUE_ORIENTATION_0 + ridx;
5665 tws_quickpanel_send_state_get_done(res_tzsh_qp, type, val, 0);
5669 _tzsh_qp_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, uint32_t type)
5671 E_Policy_Wl_Tzsh_Client *tzsh_client;
5674 ELOGF("TZ_QUICKPANEL", "Request to Set type of Quickpanel to %d", NULL, type);
5676 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5677 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5678 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5679 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5680 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5682 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5683 tzsh_client_quickpanel = (E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data;
5684 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_quickpanel);
5686 E_Quickpanel_Type qp_type = _tzsh_client_data_quickpanel_type_get(tzsh_client_quickpanel);
5687 EINA_SAFETY_ON_TRUE_RETURN(qp_type != E_QUICKPANEL_TYPE_UNKNOWN);
5689 _tzsh_client_data_quickpanel_type_set(tzsh_client_quickpanel, type);
5691 ec = tzsh_client->ec;
5693 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5696 /* Since various types of qp are supported, one ec can be used for handler for
5697 * two or more qp types. So e_qp_client_add function is called at the callback
5698 * of qp_type_set, because it is easy to add the E_QP_Client instance after setting
5699 * of qp type is completed.
5701 e_qp_client_add(ec, type);
5705 _tzsh_qp_iface_cb_scrollable_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_qp, int32_t state)
5707 E_Policy_Wl_Tzsh_Client *tzsh_client;
5710 ELOGF("TZ_QUICKPANEL", "Request to Set scrollable state to %d", NULL, state);
5712 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5713 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5714 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5715 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5716 EINA_SAFETY_ON_TRUE_RETURN(tzsh_client->handle_type != TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL);
5718 E_Quickpanel_Type qp_type = _e_tzsh_qp_type_get(tzsh_client);
5719 EINA_SAFETY_ON_TRUE_RETURN(qp_type == E_QUICKPANEL_TYPE_UNKNOWN);
5721 ec = tzsh_client->ec;
5722 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5725 if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_UNSET)
5726 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_UNSET);
5727 else if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_SET)
5728 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_SET);
5729 else if (state == TWS_QUICKPANEL_STATE_VALUE_SCROLLABLE_RETAIN)
5730 e_qp_client_scrollable_state_set(ec, qp_type, E_QUICKPANEL_CLIENT_SCROLL_STATE_RETAIN);
5733 static const struct tws_quickpanel_interface _tzsh_qp_iface =
5735 _tzsh_qp_iface_cb_release,
5736 _tzsh_qp_iface_cb_show,
5737 _tzsh_qp_iface_cb_hide,
5738 _tzsh_qp_iface_cb_enable,
5739 _tzsh_qp_iface_cb_disable,
5740 _tzsh_qp_iface_cb_state_get,
5741 _tzsh_qp_iface_cb_type_set,
5742 _tzsh_qp_iface_cb_scrollable_state_set
5746 _tzsh_cb_qp_destroy(struct wl_resource *res_tzsh_qp)
5748 E_Policy_Wl_Tzsh_Client *tzsh_client;
5750 tzsh_client = wl_resource_get_user_data(res_tzsh_qp);
5751 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5753 E_Quickpanel_Type qp_type =
5754 _tzsh_client_data_quickpanel_type_get((E_Policy_Wl_Tzsh_Client_Data_Quickpanel*)tzsh_client->client_data);
5755 e_qp_client_del(tzsh_client->ec, qp_type);
5757 E_FREE(tzsh_client->client_data);
5759 tzsh_client->res_tzsh_client = NULL;
5760 _e_policy_wl_tzsh_client_del(tzsh_client);
5763 static E_Policy_Wl_Tzsh_Client_Data_Quickpanel *
5764 _tzsh_client_data_quickpanel_new(void)
5766 E_Policy_Wl_Tzsh_Client_Data_Quickpanel *tzsh_client_quickpanel;
5768 tzsh_client_quickpanel = E_NEW(E_Policy_Wl_Tzsh_Client_Data_Quickpanel, 1);
5769 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client_quickpanel, NULL);
5771 tzsh_client_quickpanel->type = E_QUICKPANEL_TYPE_UNKNOWN;
5772 return tzsh_client_quickpanel;
5776 _tzsh_iface_cb_qp_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id)
5778 E_Policy_Wl_Tzsh *tzsh;
5779 E_Policy_Wl_Tzsh_Client *tzsh_client;
5780 struct wl_resource *res_tzsh_qp;
5784 tzsh = wl_resource_get_user_data(res_tzsh);
5787 wl_resource_post_error
5789 WL_DISPLAY_ERROR_INVALID_OBJECT,
5790 "Invalid res_tzsh's user data");
5794 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
5797 wl_resource_post_error
5799 WL_DISPLAY_ERROR_INVALID_OBJECT,
5800 "Invalid surface id");
5804 ec = e_pixmap_client_get(cp);
5807 if (!_e_policy_wl_e_client_is_valid(ec))
5809 wl_resource_post_error
5811 WL_DISPLAY_ERROR_INVALID_OBJECT,
5812 "Invalid surface id");
5817 res_tzsh_qp = wl_resource_create(client,
5818 &tws_quickpanel_interface,
5819 wl_resource_get_version(res_tzsh),
5823 ERR("Could not create tws_quickpanel resource: %m");
5824 wl_client_post_no_memory(client);
5828 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_qp, cp, ec);
5831 ERR("Could not create tzsh_client");
5832 wl_client_post_no_memory(client);
5836 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_QUICKPANEL;
5837 tzsh_client->client_data = _tzsh_client_data_quickpanel_new();
5838 if (!tzsh_client->client_data)
5840 ERR("Could not create tzsh_client");
5841 wl_client_post_no_memory(client);
5845 /* Since various types of qp are supported, one ec can be used for handler for
5846 * two or more qp types. So e_qp_client_add function is called at the callback
5847 * of qp_type_set, because it is easy to add the E_QP_Client instance after setting
5848 * of qp type is completed.
5850 //e_qp_client_add(tzsh->ec);
5852 wl_resource_set_implementation(res_tzsh_qp,
5855 _tzsh_cb_qp_destroy);
5858 static void _tzsh_iface_cb_extension_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, const char *name)
5860 E_Policy_Wl_Tzsh *tzsh;
5861 E_Policy_Wl_Tzsh_Extension *tzsh_ext;
5862 struct wl_resource *res_ext;
5864 tzsh = wl_resource_get_user_data(res_tzsh);
5867 wl_resource_post_error
5869 WL_DISPLAY_ERROR_INVALID_OBJECT,
5870 "Invalid res_tzsh's user data");
5874 tzsh_ext = _e_policy_wl_tzsh_extension_get(name);
5877 ERR("Could not find tzsh_extension(%s)", name);
5878 wl_resource_post_error
5880 WL_DISPLAY_ERROR_INVALID_OBJECT,
5881 "unregistered ext:%s", name);
5885 res_ext = tzsh_ext->cb(client, res_tzsh, id);
5888 ERR("Could not create extension(%s) resource", name);
5889 wl_resource_post_error
5891 WL_DISPLAY_ERROR_INVALID_OBJECT,
5892 "Unknown error:%s", name);
5897 // --------------------------------------------------------
5898 // tizen_ws_shell_interface::softkey
5899 // --------------------------------------------------------
5901 _tzsh_softkey_iface_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5903 wl_resource_destroy(res_tzsh_softkey);
5907 _tzsh_softkey_iface_cb_support_check(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5909 E_Policy_Wl_Tzsh_Client *tzsh_client;
5912 ELOGF("TZ_SOFTKEY", "Request to Check supporting softkey", NULL);
5914 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
5915 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5916 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5917 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5919 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5922 if (e_config->use_softkey || e_config->use_softkey_service)
5927 ELOGF("TZ_SOFTKEY", "Send SUPPORT_CHECK_DONE. support:%d", NULL, support);
5928 tws_softkey_send_support_check_done(res_tzsh_softkey, support);
5932 _tzsh_softkey_show(E_Policy_Wl_Tzsh_Client *tzsh_client)
5937 zone = tzsh_client->zone;
5939 ec = tzsh_client->ec;
5942 if (e_config->use_softkey)
5944 E_Policy_Softkey *softkey;
5945 softkey = e_policy_softkey_get(zone);
5948 ELOGF("TZ_SOFTKEY", "SHOW softkey", ec);
5949 e_policy_softkey_show(softkey);
5953 if (e_config->use_softkey_service)
5955 E_Service_Softkey *softkey_service;
5956 softkey_service = e_service_softkey_get(zone);
5957 if (softkey_service)
5959 ELOGF("TZ_SOFTKEY", "Request to SHOW softkey service. (service:%p)", ec, softkey_service);
5960 e_service_softkey_visible_set(softkey_service, 1);
5964 ELOGF("TZ_SOFTKEY", "There is no softkey service. store show request", ec);
5965 e_service_softkey_store_visible_request(ec, 1);
5971 _tzsh_softkey_iface_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
5973 E_Policy_Wl_Tzsh_Client *tzsh_client;
5975 ELOGF("TZ_SOFTKEY", "Request to Show softkey", NULL);
5977 if (!e_config->use_softkey && !e_config->use_softkey_service)
5980 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
5981 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
5982 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
5983 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
5985 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
5988 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
5989 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
5990 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_data_softkey);
5992 if (tzsh_client_data_softkey->show_state == 1)
5995 tzsh_client_data_softkey->show_state = 1;
5996 _tzsh_softkey_show(tzsh_client);
6000 _tzsh_softkey_hide(E_Policy_Wl_Tzsh_Client *tzsh_client)
6005 zone = tzsh_client->zone;
6007 ec = tzsh_client->ec;
6010 if (e_config->use_softkey)
6012 E_Policy_Softkey *softkey;
6013 softkey = e_policy_softkey_get(zone);
6016 ELOGF("TZ_SOFTKEY", "HIDE softkey", NULL);
6017 e_policy_softkey_hide(softkey);
6021 if (e_config->use_softkey_service)
6023 E_Service_Softkey *softkey_service;
6024 softkey_service = e_service_softkey_get(zone);
6025 if (softkey_service)
6027 ELOGF("TZ_SOFTKEY", "Request to HIDE softkey service. (service:%p)", ec, softkey_service);
6028 e_service_softkey_visible_set(softkey_service, 0);
6032 ELOGF("TZ_SOFTKEY", "There is no softkey service. store hide request", ec);
6033 e_service_softkey_store_visible_request(ec, 0);
6039 _tzsh_softkey_iface_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey)
6041 E_Policy_Wl_Tzsh_Client *tzsh_client;
6043 ELOGF("TZ_SOFTKEY", "Request to Hide softkey", NULL);
6045 if (!e_config->use_softkey && !e_config->use_softkey_service)
6048 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6049 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6050 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6051 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6053 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6056 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6057 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
6058 EINA_SAFETY_ON_NULL_RETURN(tzsh_client_data_softkey);
6060 if (tzsh_client_data_softkey->show_state == 0)
6063 tzsh_client_data_softkey->show_state = 0;
6064 _tzsh_softkey_hide(tzsh_client);
6068 _tzsh_softkey_iface_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey, int32_t type, int32_t val)
6070 E_Policy_Wl_Tzsh_Client *tzsh_client;
6071 E_Policy_Softkey_Expand expand;
6072 E_Policy_Softkey_Opacity opacity;
6074 ELOGF("TZ_SOFTKEY", "Request to Set state (tz_type:%d, tz_val:%d)", NULL, type, val);
6076 if (!e_config->use_softkey && !e_config->use_softkey_service)
6079 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6080 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6081 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6082 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6084 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6087 if (e_config->use_softkey)
6089 E_Policy_Softkey *softkey;
6090 softkey = e_policy_softkey_get(tzsh_client->zone);
6091 if (!softkey) return;
6095 case TWS_SOFTKEY_STATE_EXPAND:
6096 if (val == TWS_SOFTKEY_STATE_EXPAND_ON)
6097 expand = E_POLICY_SOFTKEY_EXPAND_ON;
6099 expand = E_POLICY_SOFTKEY_EXPAND_OFF;
6101 ELOGF("TZ_SOFTKEY", "Set EXPAND state to %d", NULL, expand);
6102 e_policy_softkey_expand_set(softkey, expand);
6105 case TWS_SOFTKEY_STATE_OPACITY:
6106 if (val == TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT)
6107 opacity = E_POLICY_SOFTKEY_OPACITY_TRANSPARENT;
6109 opacity = E_POLICY_SOFTKEY_OPACITY_OPAQUE;
6111 ELOGF("TZ_SOFTKEY", "Set OPACITY state to %d", NULL, opacity);
6112 e_policy_softkey_opacity_set(softkey, opacity);
6120 if (e_config->use_softkey_service)
6122 E_Service_Softkey *softkey_service;
6124 softkey_service = e_service_softkey_get(tzsh_client->zone);
6125 if (!softkey_service) return;
6129 case TWS_SOFTKEY_STATE_EXPAND:
6130 if (val == TWS_SOFTKEY_STATE_EXPAND_ON)
6131 expand = E_POLICY_SOFTKEY_EXPAND_ON;
6133 expand = E_POLICY_SOFTKEY_EXPAND_OFF;
6135 ELOGF("TZ_SOFTKEY", "Request to Change EXPAND state to %d. (service:%p)", NULL, expand, softkey_service);
6136 e_service_softkey_expand_set(softkey_service, expand);
6139 case TWS_SOFTKEY_STATE_OPACITY:
6140 if (val == TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT)
6141 opacity = E_POLICY_SOFTKEY_OPACITY_TRANSPARENT;
6143 opacity = E_POLICY_SOFTKEY_OPACITY_OPAQUE;
6145 ELOGF("TZ_SOFTKEY", "Request to Change OPACITY state to %d. (service:%p)", NULL, opacity, softkey_service);
6146 e_service_softkey_opacity_set(softkey_service, opacity);
6156 _tzsh_softkey_iface_cb_state_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh_softkey, int32_t type)
6158 E_Policy_Wl_Tzsh_Client *tzsh_client;
6159 E_Policy_Softkey_Expand expand;
6160 E_Policy_Softkey_Opacity opacity;
6165 ELOGF("TZ_SOFTKEY", "Request to Get state (tz_type:%d)", NULL, type);
6167 if (!e_config->use_softkey && !e_config->use_softkey_service)
6170 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6171 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6172 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6173 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6174 zone = tzsh_client->zone;
6175 EINA_SAFETY_ON_NULL_RETURN(zone);
6177 if (!eina_list_data_find(polwl->tzsh_clients, tzsh_client))
6180 if (e_config->use_softkey)
6182 E_Policy_Softkey *softkey;
6183 softkey = e_policy_softkey_get(zone);
6184 if (!softkey) return;
6188 case TWS_SOFTKEY_STATE_VISIBLE:
6189 visible = e_policy_softkey_visible_get(softkey);
6191 val = TWS_SOFTKEY_STATE_VISIBLE_SHOW;
6193 val = TWS_SOFTKEY_STATE_VISIBLE_HIDE;
6195 ELOGF("TZ_SOFTKEY", "Send 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_policy_softkey_expand_get(softkey, &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 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_policy_softkey_opacity_get(softkey, &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 current OPACITY state: %d (tz_val:%d)", NULL, opacity, val);
6218 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6226 if (e_config->use_softkey_service)
6228 E_Service_Softkey *softkey_service;
6229 softkey_service = e_service_softkey_get(zone);
6230 if (!softkey_service) return;
6234 case TWS_SOFTKEY_STATE_VISIBLE:
6235 visible = e_service_softkey_visible_get(softkey_service);
6237 val = TWS_SOFTKEY_STATE_VISIBLE_SHOW;
6239 val = TWS_SOFTKEY_STATE_VISIBLE_HIDE;
6241 ELOGF("TZ_SOFTKEY", "Send service's current VISIBLE state: %d (tz_val:%d)", NULL, visible, val);
6242 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6245 case TWS_SOFTKEY_STATE_EXPAND:
6246 e_service_softkey_expand_get(softkey_service, &expand);
6247 if (expand == E_POLICY_SOFTKEY_EXPAND_ON)
6248 val = TWS_SOFTKEY_STATE_EXPAND_ON;
6250 val = TWS_SOFTKEY_STATE_EXPAND_OFF;
6252 ELOGF("TZ_SOFTKEY", "Send service's current EXPAND state: %d (tz_val:%d)", NULL, expand, val);
6253 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6256 case TWS_SOFTKEY_STATE_OPACITY:
6257 e_service_softkey_opacity_get(softkey_service, &opacity);
6258 if (opacity == E_POLICY_SOFTKEY_OPACITY_TRANSPARENT)
6259 val = TWS_SOFTKEY_STATE_OPACITY_TRANSPARENT;
6261 val = TWS_SOFTKEY_STATE_OPACITY_OPAQUE;
6263 ELOGF("TZ_SOFTKEY", "Send service's current OPACITY state: %d (tz_val:%d)", NULL, opacity, val);
6264 tws_softkey_send_state_get_done(res_tzsh_softkey, type, val, 0);
6273 static const struct tws_softkey_interface _tzsh_softkey_iface =
6275 _tzsh_softkey_iface_cb_release,
6276 _tzsh_softkey_iface_cb_support_check,
6277 _tzsh_softkey_iface_cb_show,
6278 _tzsh_softkey_iface_cb_hide,
6279 _tzsh_softkey_iface_cb_state_set,
6280 _tzsh_softkey_iface_cb_state_get
6283 static E_Policy_Wl_Tzsh_Client_Data_Softkey *
6284 _tzsh_client_data_softkey_new(void)
6286 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6288 tzsh_client_data_softkey = E_NEW(E_Policy_Wl_Tzsh_Client_Data_Softkey, 1);
6289 EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_client_data_softkey, NULL);
6291 tzsh_client_data_softkey->show_state = 1;
6292 return tzsh_client_data_softkey;
6296 _tzsh_cb_softkey_destroy(struct wl_resource *res_tzsh_softkey)
6298 E_Policy_Wl_Tzsh_Client *tzsh_client;
6300 tzsh_client = wl_resource_get_user_data(res_tzsh_softkey);
6301 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6303 E_Policy_Wl_Tzsh_Client_Data_Softkey *tzsh_client_data_softkey;
6304 tzsh_client_data_softkey = (E_Policy_Wl_Tzsh_Client_Data_Softkey*)tzsh_client->client_data;
6305 if (tzsh_client_data_softkey)
6307 if (tzsh_client_data_softkey->show_state == 0)
6309 ELOGF("TZ_SOFTKEY", "Request to Show softkey by destroying client", NULL);
6310 _tzsh_softkey_show(tzsh_client);
6313 E_FREE(tzsh_client->client_data);
6315 tzsh_client->res_tzsh_client = NULL;
6316 _e_policy_wl_tzsh_client_del(tzsh_client);
6321 _tzsh_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res_tzsh, uint32_t id, uint32_t surf_id)
6323 E_Policy_Wl_Tzsh *tzsh;
6324 E_Policy_Wl_Tzsh_Client *tzsh_client;
6325 struct wl_resource *res_tzsh_softkey;
6331 tzsh = wl_resource_get_user_data(res_tzsh);
6334 wl_resource_post_error
6336 WL_DISPLAY_ERROR_INVALID_OBJECT,
6337 "Invalid res_tzsh's user data");
6341 wl_client_get_credentials(client, &pid, &uid, NULL);
6342 if (!e_security_privilege_check(pid, uid, E_PRIVILEGE_SOFTKEY))
6344 ERR("Could not get privilege of resource: %m");
6345 tizen_ws_shell_send_error(tzsh->res_tzsh, TIZEN_WS_SHELL_ERROR_PERMISSION_DENIED);
6349 tizen_ws_shell_send_error(tzsh->res_tzsh, TIZEN_WS_SHELL_ERROR_NONE);
6351 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
6354 wl_resource_post_error
6356 WL_DISPLAY_ERROR_INVALID_OBJECT,
6357 "Invalid surface id");
6361 ec = e_pixmap_client_get(cp);
6364 if (!_e_policy_wl_e_client_is_valid(ec))
6366 wl_resource_post_error
6368 WL_DISPLAY_ERROR_INVALID_OBJECT,
6369 "Invalid surface id");
6374 res_tzsh_softkey = wl_resource_create(client,
6375 &tws_softkey_interface,
6376 wl_resource_get_version(res_tzsh),
6378 if (!res_tzsh_softkey)
6380 ERR("Could not create tws_softkey resource: %m");
6381 wl_client_post_no_memory(client);
6385 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_softkey, cp, ec);
6388 ERR("Could not create tzsh_client");
6389 wl_client_post_no_memory(client);
6393 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_SOFTKEY;
6394 tzsh_client->client_data = _tzsh_client_data_softkey_new();
6395 if (!tzsh_client->client_data)
6397 ERR("Could not create tzsh_client");
6398 _e_policy_wl_tzsh_client_del(tzsh_client);
6399 wl_resource_destroy(res_tzsh_softkey);
6400 wl_client_post_no_memory(client);
6404 wl_resource_set_implementation(res_tzsh_softkey,
6405 &_tzsh_softkey_iface,
6407 _tzsh_cb_softkey_destroy);
6410 // --------------------------------------------------------
6411 // tizen_ws_shell_interface::shared_widget_launch
6412 // --------------------------------------------------------
6414 e_tzsh_shared_widget_launch_prepare_send(E_Client *callee_ec,
6418 E_Policy_Wl_Tzsh_Client *tzsh_client;
6420 Eina_Bool res = EINA_FALSE;
6422 EINA_SAFETY_ON_NULL_RETURN_VAL(callee_ec, EINA_FALSE);
6423 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(callee_ec)), EINA_FALSE);
6425 EINA_LIST_FOREACH(polwl->tzsh_clients, l, tzsh_client)
6427 if (!tzsh_client->tzsh) continue;
6428 if (!tzsh_client->ec) continue;
6429 if (tzsh_client->ec != callee_ec) continue;
6431 tws_shared_widget_launch_send_prepare_shared_widget(tzsh_client->res_tzsh_client,
6443 _tzsh_swl_iface_cb_release(struct wl_client *client,
6444 struct wl_resource *res_tzsh_swl)
6446 ELOGF("TZSH_SWL", "Release", NULL);
6448 wl_resource_destroy(res_tzsh_swl);
6452 _tzsh_swl_iface_cb_prepare_shared_widget_done(struct wl_client *client,
6453 struct wl_resource *res_tzsh_swl,
6454 const char *shared_widget_info,
6458 E_Policy_Wl_Tzsh_Client *tzsh_client;
6460 ELOGF("TZSH_SWL", "Done", NULL);
6462 tzsh_client = wl_resource_get_user_data(res_tzsh_swl);
6463 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6464 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->tzsh);
6465 EINA_SAFETY_ON_NULL_RETURN(tzsh_client->ec);
6466 EINA_SAFETY_ON_NULL_RETURN(eina_list_data_find(polwl->tzsh_clients, tzsh_client));
6468 // send prepare event to caller
6469 e_service_launcher_prepare_send_with_shared_widget_info(tzsh_client->ec,
6475 static const struct tws_shared_widget_launch_interface _tzsh_swl_iface =
6477 _tzsh_swl_iface_cb_release,
6478 _tzsh_swl_iface_cb_prepare_shared_widget_done,
6482 _tzsh_cb_swl_destroy(struct wl_resource *res_tzsh_swl)
6484 E_Policy_Wl_Tzsh_Client *tzsh_client;
6486 ELOGF("TZSH_SWL", "Destroy", NULL);
6488 tzsh_client = wl_resource_get_user_data(res_tzsh_swl);
6489 EINA_SAFETY_ON_NULL_RETURN(tzsh_client);
6491 e_service_launcher_release_shared_widget_launch(tzsh_client->ec);
6493 tzsh_client->res_tzsh_client = NULL;
6494 _e_policy_wl_tzsh_client_del(tzsh_client);
6498 _tzsh_iface_cb_shared_widget_launch_get(struct wl_client *client,
6499 struct wl_resource *res_tzsh,
6503 E_Policy_Wl_Tzsh *tzsh;
6504 E_Policy_Wl_Tzsh_Client *tzsh_client;
6505 struct wl_resource *res_tzsh_swl;
6509 tzsh = wl_resource_get_user_data(res_tzsh);
6512 wl_resource_post_error
6514 WL_DISPLAY_ERROR_INVALID_OBJECT,
6515 "Invalid res_tzsh's user data");
6519 cp = _e_policy_wl_e_pixmap_get_from_id(client, surf_id);
6522 wl_resource_post_error
6524 WL_DISPLAY_ERROR_INVALID_OBJECT,
6525 "Invalid surface id");
6529 ec = e_pixmap_client_get(cp);
6532 if (!_e_policy_wl_e_client_is_valid(ec))
6534 wl_resource_post_error
6536 WL_DISPLAY_ERROR_INVALID_OBJECT,
6537 "Invalid surface id");
6542 res_tzsh_swl = wl_resource_create(client,
6543 &tws_shared_widget_launch_interface,
6544 wl_resource_get_version(res_tzsh),
6548 ERR("Could not create tws_shared_widget_launch resource: %m");
6549 wl_client_post_no_memory(client);
6553 tzsh_client = _e_policy_wl_tzsh_client_add(tzsh, res_tzsh_swl, cp, ec);
6556 ERR("Could not create tzsh_client");
6557 wl_client_post_no_memory(client);
6561 tzsh_client->handle_type = TZSH_CLIENT_HANDLE_TYPE_SHARED_WIDGET_LAUNCH;
6563 wl_resource_set_implementation(res_tzsh_swl,
6566 _tzsh_cb_swl_destroy);
6569 // --------------------------------------------------------
6570 // tizen_ws_shell_interface
6571 // --------------------------------------------------------
6573 _tzsh_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzsh)
6575 wl_resource_destroy(res_tzsh);
6578 static const struct tizen_ws_shell_interface _tzsh_iface =
6580 _tzsh_iface_cb_destroy,
6581 _tzsh_iface_cb_srv_create,
6582 _tzsh_iface_cb_reg_create,
6583 _tzsh_iface_cb_qp_get,
6584 _tzsh_iface_cb_extension_get,
6585 _tzsh_iface_cb_softkey_get,
6586 _tzsh_iface_cb_shared_widget_launch_get,
6590 _tzsh_cb_unbind(struct wl_resource *res_tzsh)
6592 E_Policy_Wl_Tzsh *tzsh;
6594 tzsh = wl_resource_get_user_data(res_tzsh);
6595 EINA_SAFETY_ON_NULL_RETURN(tzsh);
6597 _e_policy_wl_tzsh_del(tzsh);
6601 _tzsh_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
6603 E_Policy_Wl_Tzsh *tzsh;
6604 struct wl_resource *res_tzsh;
6606 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
6608 res_tzsh = wl_resource_create(client,
6609 &tizen_ws_shell_interface,
6612 EINA_SAFETY_ON_NULL_GOTO(res_tzsh, err);
6614 tzsh = _e_policy_wl_tzsh_add(res_tzsh);
6615 EINA_SAFETY_ON_NULL_GOTO(tzsh, err);
6617 wl_resource_set_implementation(res_tzsh,
6622 _e_policy_wl_tzsh_registered_srv_send(tzsh);
6626 ERR("Could not create tizen_ws_shell_interface res: %m");
6627 wl_client_post_no_memory(client);
6630 // --------------------------------------------------------
6631 // tizen_launch_effect_interface
6632 // --------------------------------------------------------
6633 #define SPLASH_GROUP_NAME "effect"
6634 #define SPLASH_CONFIG_CUSTOM_EFFECT_CALLEE "_CUSTOM_EFFECT_CALLEE_"
6637 _launch_effect_hide(uint32_t pid)
6640 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
6641 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6643 if(pid <= 0) return;
6645 EINA_LIST_FOREACH(polwl->tzlaunch_effect, l, tzlaunch_effect)
6647 EINA_LIST_FOREACH(tzlaunch_effect->splash_list, ll, tzlaunch_splash)
6648 if (tzlaunch_splash->pid == pid)
6650 _launch_splash_off(tzlaunch_splash);
6656 _launch_effect_client_del(E_Client *ec)
6659 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
6660 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6662 EINA_LIST_FOREACH(polwl->tzlaunch_effect, l, tzlaunch_effect)
6664 EINA_LIST_FOREACH(tzlaunch_effect->splash_list, ll, tzlaunch_splash)
6665 if (tzlaunch_splash->ec == ec)
6667 _launch_splash_off(tzlaunch_splash);
6673 _launchscreen_splash_cb_indicator_resized(Ecore_Evas *ee)
6675 Evas_Coord_Size size = {0, 0};
6676 Evas_Object *indicator_obj;
6677 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6679 tzlaunch_splash = ecore_evas_data_get(ee, "tzlaunch_splash");
6680 if (!tzlaunch_splash) return;
6682 indicator_obj = tzlaunch_splash->indicator_obj;
6684 ecore_evas_geometry_get(ee, NULL, NULL, &(size.w), &(size.h));
6685 ELOGF("TZPOL", "Launchscreen indicator_obj resized(%d x %d)",
6688 evas_object_size_hint_min_set(indicator_obj, size.w, size.h);
6689 evas_object_size_hint_max_set(indicator_obj, size.w, size.h);
6690 e_comp_object_indicator_size_set(tzlaunch_splash->ec->frame, size.w, size.h);
6694 _launchscreen_splash_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6696 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash = data;
6698 if ((tzlaunch_splash) && (tzlaunch_splash->obj == obj))
6699 tzlaunch_splash->obj = NULL;
6703 _launchscreen_splash_cb_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6705 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash = data;
6707 if ((tzlaunch_splash) && (tzlaunch_splash->obj == obj))
6708 _launch_splash_off(tzlaunch_splash);
6712 _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash)
6714 E_Client *ec = NULL;
6715 Evas_Object *obj = NULL;
6717 if (!tzlaunch_splash->valid) return;
6718 if (!tzlaunch_splash->ec) return;
6720 ec = tzlaunch_splash->ec;
6721 obj = tzlaunch_splash->obj;
6723 tzlaunch_splash->obj = NULL;
6724 tzlaunch_splash->ec = NULL;
6725 tzlaunch_splash->valid = EINA_FALSE;
6726 if (tzlaunch_splash->timeout) ecore_timer_del(tzlaunch_splash->timeout);
6727 tzlaunch_splash->timeout = NULL;
6729 eina_stringshare_del(tzlaunch_splash->appid);
6730 tzlaunch_splash->appid = NULL;
6731 eina_stringshare_del(tzlaunch_splash->path);
6732 tzlaunch_splash->path = NULL;
6736 "Launchscreen hide | pid %d, replaced:%d, tzlaunch_pixmap:%p, ec_pixmap:%p",
6737 ec, tzlaunch_splash->pid, tzlaunch_splash->replaced, tzlaunch_splash->ep, ec->pixmap);
6739 if (tzlaunch_splash->indicator_obj)
6741 e_comp_object_indicator_unswallow(ec->frame, tzlaunch_splash->indicator_obj);
6742 evas_object_del(tzlaunch_splash->indicator_obj);
6743 evas_object_unref(tzlaunch_splash->indicator_obj);
6744 tzlaunch_splash->indicator_obj = NULL;
6748 (ec->pixmap == tzlaunch_splash->ep))
6750 /* case 1: Surface for this pid is not created until timeout or
6751 * launchscreen resource is destroied.
6755 ec->visible = EINA_FALSE;
6756 evas_object_hide(ec->frame);
6757 ec->ignored = EINA_TRUE;
6760 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
6762 e_pixmap_win_id_del(tzlaunch_splash->ep);
6763 e_object_del(E_OBJECT(ec));
6769 if (!e_util_strcmp("wl_pointer-cursor", ec->icccm.window_role))
6771 // if Launchscreen is replaced to cursor, than hide
6772 e_comp_object_content_unset(ec->frame);
6773 ec->visible = EINA_FALSE;
6774 evas_object_hide(ec->frame);
6775 ec->ignored = EINA_TRUE;
6777 else if (!tzlaunch_splash->replaced)
6780 e_comp_wl_feed_focus_in(ec);
6782 /* to send launch,done event to launchscreen client */
6783 if (!e_object_is_del(E_OBJECT(ec)))
6785 if (ec->first_mapped)
6787 ELOGF("LAUNCH", "SHOW real win by replaced splash ec", ec);
6788 e_comp_object_signal_emit(ec->frame, "e,action,launch_real,done", "e");
6790 e_comp_object_signal_emit(ec->frame, "e,action,launch,done", "e");
6794 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
6798 evas_object_unref(obj);
6800 tzlaunch_splash->ep = NULL;
6801 tzlaunch_splash->replaced = EINA_FALSE;
6805 _launchscreen_splash_timeout(void *data)
6807 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
6808 tzlaunch_splash = (E_Policy_Wl_Tzlaunch_Splash *)data;
6810 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_splash, 0);
6812 _launch_splash_off(tzlaunch_splash);
6814 return ECORE_CALLBACK_CANCEL;
6818 _launchscreen_splash_setup(E_Policy_Wl_Tzlaunch_Splash *splash,
6819 const char *pfname, uint32_t ftype,
6820 uint32_t depth, uint32_t angle,
6821 uint32_t indicator, const char *effect_type,
6822 const char *theme_type, struct wl_array *options,
6823 struct wl_array *extra_config)
6825 E_Client *ec = NULL;
6826 E_Comp_Object_Content_Type content_type = 0;
6827 Eina_Bool intercepted = EINA_FALSE;
6829 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->ec, EINA_FALSE);
6830 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->ec->frame, EINA_FALSE);
6833 ec->effect_type = _e_policy_wl_tzlaunch_effect_type_get(effect_type);
6836 "Launchscreen setup START| path %s(%d), indicator(%d), angle(%d), effect_type(%s), theme_type(%s)",
6837 ec, pfname, ftype, indicator, angle, effect_type, theme_type);
6839 "Launchscreen setup | options %p extra_config:%p",
6840 ec, options, extra_config);
6842 splash->path = eina_stringshare_add(pfname);
6843 splash->type = ftype;
6844 splash->indicator = indicator;
6845 splash->angle = angle;
6849 /* To configure indicator options */
6850 ec->indicator.state = TIZEN_INDICATOR_STATE_ON;
6851 ec->indicator.visible_type = TIZEN_INDICATOR_VISIBLE_TYPE_SHOWN;
6852 ec->indicator.opacity_mode = TIZEN_INDICATOR_OPACITY_MODE_BG_TRANSPARENT;
6855 intercepted = e_policy_interceptor_call(E_POLICY_INTERCEPT_LAUNCHSCREEN_OBJECT_SETUP,
6857 pfname, ftype, depth,
6858 angle, indicator, options);
6861 splash->obj = e_comp_object_content_get(ec->frame);
6864 "Launchscreen setup | was INTERCEPTED : content(%p)",
6867 else //Do original setup process
6869 if (splash->type == LAUNCH_IMG_FILE_TYPE_IMAGE)
6871 Evas_Load_Error err;
6873 content_type = E_COMP_OBJECT_CONTENT_TYPE_EXT_IMAGE;
6874 splash->obj = evas_object_image_add(e_comp->evas);
6875 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->obj, EINA_FALSE);
6877 evas_object_image_file_set(splash->obj, splash->path, NULL);
6879 err = evas_object_image_load_error_get(splash->obj);
6880 if (err != EVAS_LOAD_ERROR_NONE)
6883 "Launchscreen setup | fail to load image %s : %s",
6884 ec, splash->path, evas_load_error_str(err));
6885 evas_object_del(splash->obj);
6890 evas_object_image_fill_set(splash->obj, 0, 0, e_comp->w, e_comp->h);
6891 evas_object_image_filled_set(splash->obj, EINA_TRUE);
6895 content_type = E_COMP_OBJECT_CONTENT_TYPE_EXT_EDJE;
6896 splash->obj = edje_object_add(e_comp->evas);
6897 EINA_SAFETY_ON_NULL_RETURN_VAL(splash->obj, EINA_FALSE);
6899 if (!edje_object_file_set(splash->obj, splash->path, SPLASH_GROUP_NAME))
6901 Edje_Load_Error err;
6903 err = edje_object_load_error_get(splash->obj);
6905 "Launchscreen setup | fail to load edje %s : %s",
6906 ec, splash->path, edje_load_error_str(err));
6907 evas_object_del(splash->obj);
6913 evas_object_move(splash->obj, 0, 0);
6914 evas_object_resize(splash->obj, e_comp->w, e_comp->h);
6917 if (depth == 32) ec->argb = EINA_TRUE;
6918 else ec->argb = EINA_FALSE;
6919 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6921 //set splash->obj to a content of ec->frame
6922 if (!e_comp_object_content_set(ec->frame, splash->obj, content_type))
6924 ERR("Launchscreen setup | setting comp object content failed ec(%p) obj(%p)",
6931 /* Post job of setup content_type */
6933 //Parse extra config
6934 if ((extra_config) && (extra_config->size))
6938 int size = extra_config->size;
6942 p_char = extra_config->data + len;
6943 len = strlen(p_char) + 1;
6946 if (!e_util_strcmp(p_char, SPLASH_CONFIG_CUSTOM_EFFECT_CALLEE))
6948 //parse next data(appid) from array
6951 p_char = p_char + len;
6952 len = strlen(p_char) + 1;
6955 splash->appid = eina_stringshare_add(p_char);
6956 splash->custom_effect_callee = EINA_TRUE;
6959 "Launchscreen setup | custom effect callee set appid(%s)",
6970 Evas_Object *indicator_obj = NULL;
6971 Eina_Bool ret = EINA_FALSE;
6973 e_mod_indicator_owner_set(ec);
6974 e_tzsh_indicator_srv_property_update(ec);
6976 indicator_obj = ecore_evas_extn_plug_new(e_comp->ee);
6980 "Launchscreen setup | Failed to create ecore_evas_plug for indicator",
6985 if (e_config->indicator_plug_name)
6987 ret = ecore_evas_extn_plug_connect(indicator_obj, e_config->indicator_plug_name, 0, EINA_FALSE);
6992 ee = ecore_evas_object_ecore_evas_get(indicator_obj);
6993 ecore_evas_data_set(ee, "tzlaunch_splash", splash);
6994 ecore_evas_callback_resize_set(ee,
6995 _launchscreen_splash_cb_indicator_resized);
6996 e_comp_object_indicator_swallow(ec->frame, indicator_obj);
6997 evas_object_ref(indicator_obj);
6999 "Launchscreen launch | Succeeded to add indicator object plug_name(%s) indicator_obj(%p)",
7000 ec, e_config->indicator_plug_name, indicator_obj);
7004 evas_object_del(indicator_obj);
7005 indicator_obj = NULL;
7012 "Launchscreen launch | Failed to add indicator object plug_name(%s)",
7013 ec, e_config->indicator_plug_name?:"NO PLUG NAME");
7017 splash->indicator_obj = indicator_obj;
7023 evas_object_ref(splash->obj);
7025 evas_object_event_callback_add(splash->obj,
7027 _launchscreen_splash_cb_del, splash);
7028 evas_object_event_callback_add(splash->obj,
7030 _launchscreen_splash_cb_hide, splash);
7033 splash->valid = EINA_TRUE;
7034 splash->content_type = e_comp_object_content_type_get(ec->frame);
7040 _tzlaunch_splash_iface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash)
7042 wl_resource_destroy(res_tzlaunch_splash);
7046 _tzlaunch_splash_iface_cb_launch(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash,
7047 const char *pfname, uint32_t ftype,
7048 uint32_t depth, uint32_t angle,
7049 uint32_t indicator, const char *effect_type,
7050 const char *theme_type, struct wl_array *options)
7052 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7053 Eina_Bool res = EINA_FALSE;
7055 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7056 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7058 ELOGF("TZPOL","Launchscreen launch | START", NULL);
7061 res = _launchscreen_splash_setup(tzlaunch_splash,
7064 indicator, effect_type,
7065 theme_type, options, NULL);
7067 ELOGF("TZPOL","Launchscreen launch | END res:%d ", NULL, res);
7071 ERR("Launchscreen launch | Could not complete %s", __FUNCTION__);
7072 if (tzlaunch_splash->obj)
7074 evas_object_del(tzlaunch_splash->obj);
7075 tzlaunch_splash->obj = NULL;
7081 _tzlaunch_splash_iface_cb_owner(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzlaunch_splash, uint32_t pid)
7083 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7084 E_Client *pre_ec = NULL, *new_ec = NULL, *old_ec;
7085 Eina_List *clients, *l;
7088 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7089 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7090 EINA_SAFETY_ON_FALSE_RETURN(tzlaunch_splash->valid);
7092 /* use ec was already created */
7093 clients = _e_policy_wl_e_clients_find_by_pid(pid);
7094 EINA_LIST_FOREACH(clients, l, pre_ec)
7096 if (pre_ec == tzlaunch_splash->ec) continue;
7097 if (!pre_ec->ignored) continue;
7098 if (pre_ec->is_cursor) continue;
7100 e_client_geometry_get(new_ec, NULL, NULL, &tw, &th);
7101 if (tw <= 1 || th <= 1)
7102 evas_object_resize(new_ec->frame, e_comp->w, e_comp->h);
7105 eina_list_free(clients);
7107 old_ec = tzlaunch_splash->ec;
7110 if (e_comp_object_content_set(new_ec->frame,
7111 tzlaunch_splash->obj,
7112 tzlaunch_splash->content_type))
7114 e_client_unignore(new_ec);
7115 new_ec->visible = EINA_TRUE;
7116 if (new_ec->new_client)
7117 e_comp->new_clients--;
7118 new_ec->new_client = EINA_FALSE;
7119 new_ec->argb = old_ec->argb;
7120 ELOGF("COMP", "Set argb:%d", new_ec, new_ec->argb);
7121 new_ec->effect_type = old_ec->effect_type;
7122 new_ec->use_splash = EINA_TRUE;
7123 e_client_icccm_title_set(new_ec, "launchscreen");
7125 e_comp->launchscrns = eina_list_append(e_comp->launchscrns, new_ec);
7127 if (tzlaunch_splash->custom_effect_callee)
7129 e_service_launcher_callee_register(new_ec, tzlaunch_splash->appid, tzlaunch_splash->path, SPLASH_GROUP_NAME);
7132 evas_object_show(new_ec->frame);
7133 e_client_raise(new_ec);
7135 tzlaunch_splash->ec = new_ec;
7136 tzlaunch_splash->replaced = EINA_TRUE;
7139 "Launchscreen client changed | old(%p) new(%p) using obj(%p)",
7141 old_ec, new_ec, tzlaunch_splash->obj);
7143 if (tzlaunch_splash->indicator_obj)
7145 e_mod_indicator_owner_set(new_ec);
7146 e_tzsh_indicator_srv_property_update(new_ec);
7147 e_comp_object_indicator_unswallow(old_ec->frame, tzlaunch_splash->indicator_obj);
7148 e_comp_object_indicator_swallow(new_ec->frame, tzlaunch_splash->indicator_obj);
7151 /* delete ec was created for launchscreen */
7152 e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, old_ec);
7154 e_pixmap_win_id_del(tzlaunch_splash->ep);
7155 e_object_del(E_OBJECT(old_ec));
7156 tzlaunch_splash->ep = NULL;
7159 ERR("Can't set external content for new_ec(%p)", new_ec);
7163 old_ec->ignored = EINA_FALSE;
7164 old_ec->visible = EINA_TRUE;
7165 if (old_ec->new_client)
7166 e_comp->new_clients--;
7167 old_ec->new_client = EINA_FALSE;
7168 old_ec->icccm.accepts_focus = EINA_TRUE;
7170 if (tzlaunch_splash->custom_effect_callee)
7172 e_service_launcher_callee_register(old_ec, tzlaunch_splash->appid, tzlaunch_splash->path, SPLASH_GROUP_NAME);
7175 evas_object_show(old_ec->frame);
7176 e_client_raise(old_ec);
7179 EC_CHANGED(tzlaunch_splash->ec);
7180 e_comp_visibility_calculation_set(EINA_TRUE);
7182 if (tzlaunch_splash->timeout)
7184 ecore_timer_del(tzlaunch_splash->timeout);
7185 tzlaunch_splash->timeout = NULL;
7187 if (!e_config->launchscreen_without_timer)
7188 tzlaunch_splash->timeout = ecore_timer_add(e_config->launchscreen_timeout, _launchscreen_splash_timeout, tzlaunch_splash);
7190 ELOGF("TZPOL", "Launchscreen img(%d) set owner pid: %d",
7191 tzlaunch_splash->ec,
7192 wl_resource_get_id(res_tzlaunch_splash), pid);
7194 tzlaunch_splash->pid = pid;
7195 tzlaunch_splash->ec->netwm.pid = pid;
7196 tzlaunch_splash->ec->use_splash = EINA_TRUE;
7200 _tzlaunch_splash_iface_cb_launch_v2(struct wl_client *client EINA_UNUSED,
7201 struct wl_resource *res_tzlaunch_splash,
7202 const char *pfname, uint32_t ftype,
7203 uint32_t depth, uint32_t angle,
7204 uint32_t indicator, const char *effect_type,
7205 const char *theme_type, struct wl_array *options,
7206 struct wl_array *extra_config)
7208 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7209 Eina_Bool res = EINA_FALSE;
7211 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7212 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7214 ELOGF("TZPOL","Launchscreen launch_v2 | START", NULL);
7216 res = _launchscreen_splash_setup(tzlaunch_splash,
7219 indicator, effect_type,
7220 theme_type, options, extra_config);
7222 ELOGF("TZPOL","Launchscreen launch_v2 | END res:%d ", NULL, res);
7226 ERR("Launchscreen launch_v2 | Could not complete %s", __FUNCTION__);
7227 if (tzlaunch_splash->obj)
7229 evas_object_del(tzlaunch_splash->obj);
7230 tzlaunch_splash->obj = NULL;
7236 static const struct tizen_launch_splash_interface _tzlaunch_splash_iface =
7238 _tzlaunch_splash_iface_cb_destroy,
7239 _tzlaunch_splash_iface_cb_launch,
7240 _tzlaunch_splash_iface_cb_owner,
7241 _tzlaunch_splash_iface_cb_launch_v2,
7244 static E_Policy_Wl_Tzlaunch_Splash *
7245 _tzlaunch_splash_add(struct wl_resource *res_tzlaunch_effect, struct wl_resource *res_tzlaunch_splash)
7247 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7248 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7250 tzlaunch_splash = E_NEW(E_Policy_Wl_Tzlaunch_Splash, 1);
7251 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash, error);
7253 tzlaunch_effect = wl_resource_get_user_data(res_tzlaunch_effect);
7254 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_effect, error);
7256 tzlaunch_effect->splash_list = eina_list_append(tzlaunch_effect->splash_list, tzlaunch_splash);
7258 tzlaunch_splash->tzlaunch_effect = tzlaunch_effect;
7259 tzlaunch_splash->res_tzlaunch_splash = res_tzlaunch_splash;
7261 tzlaunch_splash->replaced = EINA_FALSE;
7262 tzlaunch_splash->ep = e_pixmap_new(E_PIXMAP_TYPE_EXT_OBJECT, 0);
7263 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash->ep, error);
7264 tzlaunch_splash->ec = e_client_new(tzlaunch_splash->ep, 0, 1);
7265 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_splash->ec, error);
7267 e_client_icccm_title_set(tzlaunch_splash->ec, "Launchscreen");
7268 e_client_icccm_name_set(tzlaunch_splash->ec, "Launchscreen");
7269 tzlaunch_splash->ec->ignored = EINA_TRUE;
7271 e_comp->launchscrns = eina_list_append(e_comp->launchscrns, tzlaunch_splash->ec);
7273 return tzlaunch_splash;
7275 if (tzlaunch_splash)
7277 ERR("Could not initialize launchscreen client");
7278 if (tzlaunch_splash->ep)
7279 e_pixmap_win_id_del(tzlaunch_splash->ep);
7280 if (tzlaunch_splash->ec)
7281 e_object_del(E_OBJECT(tzlaunch_splash->ec));
7282 E_FREE(tzlaunch_splash);
7289 _tzlaunch_splash_destroy(struct wl_resource *res_tzlaunch_splash)
7291 E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash;
7292 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7294 EINA_SAFETY_ON_NULL_RETURN(res_tzlaunch_splash);
7296 tzlaunch_splash = wl_resource_get_user_data(res_tzlaunch_splash);
7297 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_splash);
7299 if (tzlaunch_splash->obj)
7301 evas_object_event_callback_del_full(tzlaunch_splash->obj, EVAS_CALLBACK_DEL, _launchscreen_splash_cb_del, tzlaunch_splash);
7302 evas_object_event_callback_del_full(tzlaunch_splash->obj, EVAS_CALLBACK_HIDE, _launchscreen_splash_cb_hide, tzlaunch_splash);
7305 _launch_splash_off(tzlaunch_splash);
7307 tzlaunch_effect = tzlaunch_splash->tzlaunch_effect;
7308 tzlaunch_effect->splash_list = eina_list_remove(tzlaunch_effect->splash_list, tzlaunch_splash);
7310 eina_stringshare_del(tzlaunch_splash->appid);
7311 eina_stringshare_del(tzlaunch_splash->path);
7312 memset(tzlaunch_splash, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Splash));
7313 E_FREE(tzlaunch_splash);
7317 _tzlaunch_effect_iface_cb_create_splash_img(struct wl_client *client, struct wl_resource *res_tzlaunch_effect, uint32_t id)
7320 E_Policy_Wl_Tzlaunch_Splash *plaunch_splash;
7321 struct wl_resource *res_tzlaunch_splash;
7323 res_tzlaunch_splash = wl_resource_create(client,
7324 &tizen_launch_splash_interface,
7325 wl_resource_get_version(res_tzlaunch_effect),
7327 if (!res_tzlaunch_splash)
7329 wl_resource_post_error
7330 (res_tzlaunch_effect,
7331 WL_DISPLAY_ERROR_INVALID_OBJECT,
7332 "Invalid res_tzlaunch effect's user data");
7336 plaunch_splash = _tzlaunch_splash_add(res_tzlaunch_effect, res_tzlaunch_splash);
7337 EINA_SAFETY_ON_NULL_GOTO(plaunch_splash, err);
7339 ELOGF("TZPOL", "Launchscreen effect create splash img. res_tzlaunch_effect:%p, res_tzlaunch_splash:%p", plaunch_splash->ec, res_tzlaunch_effect, res_tzlaunch_splash);
7341 wl_resource_set_implementation(res_tzlaunch_splash,
7342 &_tzlaunch_splash_iface,
7344 _tzlaunch_splash_destroy);
7349 ERR("Could not create tizen_launch_splash_interface res: %m");
7350 wl_client_post_no_memory(client);
7354 _tzlaunch_effect_iface_cb_type_set(struct wl_client *client, struct wl_resource *res_tzlaunch_effect,
7355 const char *effect_type, uint32_t pid, struct wl_array *options)
7357 Eina_List *clients, *l;
7358 E_Client *_ec = NULL;
7360 int tzlaunch_effect_type = _e_policy_wl_tzlaunch_effect_type_get(effect_type);
7362 clients = _e_policy_wl_e_clients_find_by_pid(pid);
7363 EINA_LIST_FOREACH(clients, l, _ec)
7367 _ec->effect_type = tzlaunch_effect_type;
7370 "Launchscreen effect type set | exist ec | effect (%d) pid (%d)",
7371 _ec, tzlaunch_effect_type, pid);
7374 eina_list_free(clients);
7377 _e_policy_wl_tzlaunch_effect_type_unset(pid);
7380 E_Policy_Wl_Tzlaunch_Effect_Info *tzlaunch_effect_info;
7382 tzlaunch_effect_info = E_NEW(E_Policy_Wl_Tzlaunch_Effect_Info, 1);
7383 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_effect_info);
7384 tzlaunch_effect_info->pid = pid;
7385 tzlaunch_effect_info->effect_type = tzlaunch_effect_type;
7386 polwl->tzlaunch_effect_info = eina_list_append(polwl->tzlaunch_effect_info, tzlaunch_effect_info);
7389 "Launchscreen effect type set | no match ec | effect (%d) pid (%d)",
7390 NULL, tzlaunch_effect_type, pid);
7395 _tzlaunch_effect_iface_cb_type_unset(struct wl_client *client, struct wl_resource *res_tzlaunch_effect,
7398 _e_policy_wl_tzlaunch_effect_type_unset(pid);
7402 _tzlaunch_effect_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
7404 wl_resource_destroy(resource);
7407 static const struct tizen_launch_effect_interface _tzlaunch_effect_iface =
7409 _tzlaunch_effect_iface_cb_create_splash_img,
7410 _tzlaunch_effect_iface_cb_type_set,
7411 _tzlaunch_effect_iface_cb_type_unset,
7412 _tzlaunch_effect_iface_cb_destroy,
7416 _tzlaunch_effect_del(E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect)
7418 E_Policy_Wl_Tzlaunch_Splash *plaunch_splash;
7421 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_effect);
7423 // remove tzlaunch created splash list
7424 EINA_LIST_FOREACH_SAFE(tzlaunch_effect->splash_list, l, ll, plaunch_splash)
7426 if (plaunch_splash->tzlaunch_effect != tzlaunch_effect) continue;
7427 wl_resource_destroy(plaunch_splash->res_tzlaunch_splash);
7431 polwl->tzlaunch_effect = eina_list_remove(polwl->tzlaunch_effect, tzlaunch_effect);
7433 memset(tzlaunch_effect, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Effect));
7434 E_FREE(tzlaunch_effect);
7437 static E_Policy_Wl_Tzlaunch_Effect *
7438 _tzlaunch_effect_add(struct wl_resource *res_tzlaunch_effect)
7440 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect;
7442 tzlaunch_effect = E_NEW(E_Policy_Wl_Tzlaunch_Effect, 1);
7443 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_effect, NULL);
7445 tzlaunch_effect->res_tzlaunch_effect = res_tzlaunch_effect;
7447 polwl->tzlaunch_effect = eina_list_append(polwl->tzlaunch_effect, tzlaunch_effect);
7449 return tzlaunch_effect;
7453 _tzlaunch_effect_cb_unbind(struct wl_resource *res_tzlaunch_effect)
7455 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect = NULL;
7458 EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_effect, l, ll, tzlaunch_effect)
7460 if (tzlaunch_effect->res_tzlaunch_effect != res_tzlaunch_effect) continue;
7461 _tzlaunch_effect_del(tzlaunch_effect);
7467 _tzlaunch_effect_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
7469 E_Policy_Wl_Tzlaunch_Effect *tzlaunch_effect = NULL;
7470 struct wl_resource *res_tzlaunch_effect;
7472 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
7474 res_tzlaunch_effect = wl_resource_create(client,
7475 &tizen_launch_effect_interface,
7478 EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_effect, err);
7480 tzlaunch_effect = _tzlaunch_effect_add(res_tzlaunch_effect);
7481 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_effect, err);
7483 wl_resource_set_implementation(res_tzlaunch_effect,
7484 &_tzlaunch_effect_iface,
7486 _tzlaunch_effect_cb_unbind);
7491 ERR("Could not create tizen_launch_effect_interface res: %m");
7492 wl_client_post_no_memory(client);
7495 // --------------------------------------------------------
7496 // tizen_launch_appinfo_interface
7497 // --------------------------------------------------------
7499 _tzlaunch_appinfo_iface_cb_register_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7502 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7503 E_Appinfo *eai = NULL;
7505 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7506 if (!tzlaunch_appinfo)
7508 wl_resource_post_error(res_tzlaunch_appinfo,
7509 WL_DISPLAY_ERROR_INVALID_OBJECT,
7510 "Invalid tzlaunch_appinfo's user data");
7516 ELOGF("TZ_APPINFO", "registered pid is invalid. pid:%u", NULL, pid);
7520 eai = e_appinfo_find_with_pid(pid);
7523 eai = e_appinfo_new();
7524 EINA_SAFETY_ON_NULL_RETURN(eai);
7526 if (!e_appinfo_pid_set(eai, pid))
7528 ELOGF("TZ_APPINFO", "failed to set pid is invalid. pid:%u", NULL, pid);
7534 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
7538 _tzlaunch_appinfo_iface_cb_deregister_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7541 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7542 E_Appinfo *eai = NULL;
7544 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7545 if (!tzlaunch_appinfo)
7547 wl_resource_post_error(res_tzlaunch_appinfo,
7548 WL_DISPLAY_ERROR_INVALID_OBJECT,
7549 "Invalid tzlaunch_appinfo's user data");
7553 eai = e_appinfo_find_with_pid(pid);
7554 EINA_SAFETY_ON_NULL_RETURN(eai);
7560 _tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7561 uint32_t pid, const char *appid)
7563 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7564 E_Appinfo *eai = NULL;
7568 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7569 if (!tzlaunch_appinfo)
7571 wl_resource_post_error(res_tzlaunch_appinfo,
7572 WL_DISPLAY_ERROR_INVALID_OBJECT,
7573 "Invalid tzlaunch_appinfo's user data");
7579 ELOGF("TZ_APPINFO", "set pid is invalid. pid:%u", NULL, pid);
7583 eai = e_appinfo_find_with_pid(pid);
7584 EINA_SAFETY_ON_NULL_RETURN(eai);
7586 if (!e_appinfo_appid_set(eai, appid))
7588 ELOGF("TZ_APPINFO", "failed to set appid, appid:%s", NULL, appid);
7592 /* about base output resolution */
7593 if (e_config->configured_output_resolution.use)
7596 // 1. send HOOK with pid
7597 e_policy_wl_base_output_resolution_info_update(pid);
7598 // 2. module must set the base_output_resolution.
7599 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7601 ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
7604 // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
7605 // 3-1. if success, use the base_rescreen_resolution
7606 // 3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
7609 if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
7611 ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
7620 _tzlaunch_appinfo_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo)
7622 wl_resource_destroy(res_tzlaunch_appinfo);
7626 _tzlaunch_appinfo_iface_cb_get_base_output_resolution(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7629 E_Appinfo *eai = NULL;
7630 int width = 0, height = 0;
7634 ELOGF("TZ_APPINFO", "requested pid is invalid. pid:%u", NULL, pid);
7638 eai = e_appinfo_find_with_pid(pid);
7641 ELOGF("TZ_APPINFO", "cannot find pid. pid:%u", NULL, pid);
7645 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7647 ELOGF("TZ_APPINFO", "cannot read size. pid:%u", NULL, pid);
7651 tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
7652 ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
7657 width = e_config->configured_output_resolution.w;
7658 height = e_config->configured_output_resolution.h;
7659 ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
7660 tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
7666 _tzlaunch_appinfo_iface_cb_register_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7669 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7670 E_Appinfo *eai = NULL;
7672 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7673 if (!tzlaunch_appinfo)
7675 wl_resource_post_error(res_tzlaunch_appinfo,
7676 WL_DISPLAY_ERROR_INVALID_OBJECT,
7677 "Invalid tzlaunch_appinfo's user data");
7681 if ((eai = e_appinfo_find_with_appid(appid)))
7683 ELOGF("TZ_APPINFO", "appid:%s is already registered!", NULL, appid);
7687 eai = e_appinfo_new();
7688 EINA_SAFETY_ON_NULL_RETURN(eai);
7690 if (!e_appinfo_appid_set(eai, appid))
7692 ELOGF("TZ_APPINFO", "Failed to register appid:%s", NULL, appid);
7697 e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
7701 _tzlaunch_appinfo_iface_cb_deregister_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7704 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7705 E_Appinfo *eai = NULL;
7707 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7708 if (!tzlaunch_appinfo)
7710 wl_resource_post_error(res_tzlaunch_appinfo,
7711 WL_DISPLAY_ERROR_INVALID_OBJECT,
7712 "Invalid tzlaunch_appinfo's user data");
7716 eai = e_appinfo_find_with_appid(appid);
7717 EINA_SAFETY_ON_NULL_RETURN(eai);
7723 _tzlaunch_appinfo_iface_cb_set_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7724 const char *appid, uint32_t pid)
7726 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7727 E_Appinfo *eai = NULL;
7729 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7730 if (!tzlaunch_appinfo)
7732 wl_resource_post_error(res_tzlaunch_appinfo,
7733 WL_DISPLAY_ERROR_INVALID_OBJECT,
7734 "Invalid tzlaunch_appinfo's user data");
7738 eai = e_appinfo_find_with_appid(appid);
7739 EINA_SAFETY_ON_NULL_RETURN(eai);
7741 if (!e_appinfo_pid_set(eai, pid))
7743 ELOGF("TZ_APPINFO", "Failed to set pid:%u for appid:%s", NULL, pid, appid);
7749 _tzlaunch_appinfo_iface_cb_ready_metadata(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7750 const char *appid, uint32_t pid)
7752 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7753 E_Appinfo *eai = NULL;
7754 int width = 0, height = 0;
7756 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7757 if (!tzlaunch_appinfo)
7759 wl_resource_post_error(res_tzlaunch_appinfo,
7760 WL_DISPLAY_ERROR_INVALID_OBJECT,
7761 "Invalid tzlaunch_appinfo's user data");
7765 eai = e_appinfo_find_with_appid(appid);
7766 EINA_SAFETY_ON_NULL_RETURN(eai);
7768 e_appinfo_ready_metadata(eai, pid);
7770 /* about base output resolution */
7771 if (e_config->configured_output_resolution.use)
7773 // 1. send HOOK with pid
7774 e_policy_wl_base_output_resolution_info_update(pid);
7775 // 2. module must set the base_output_resolution.
7776 if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
7778 ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
7781 // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
7782 // 3-1. if success, use the base_rescreen_resolution
7783 // 3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
7786 if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
7788 ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
7795 _tzlaunch_appinfo_iface_cb_set_auto_placement(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
7798 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7799 E_Appinfo *eai = NULL;
7801 tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
7802 if (!tzlaunch_appinfo)
7804 wl_resource_post_error(res_tzlaunch_appinfo,
7805 WL_DISPLAY_ERROR_INVALID_OBJECT,
7806 "Invalid tzlaunch_appinfo's user data");
7810 eai = e_appinfo_find_with_pid(pid);
7811 EINA_SAFETY_ON_NULL_RETURN(eai);
7813 ELOGF("TZ_APPINFO", "Set auto placement. pid(%d)", NULL, pid);
7814 e_appinfo_auto_placement_set(eai, EINA_TRUE);
7817 static const struct tizen_launch_appinfo_interface _tzlaunch_appinfo_iface =
7819 _tzlaunch_appinfo_iface_cb_destroy,
7820 _tzlaunch_appinfo_iface_cb_register_pid,
7821 _tzlaunch_appinfo_iface_cb_deregister_pid,
7822 _tzlaunch_appinfo_iface_cb_set_appid,
7823 _tzlaunch_appinfo_iface_cb_get_base_output_resolution,
7824 _tzlaunch_appinfo_iface_cb_register_appid,
7825 _tzlaunch_appinfo_iface_cb_deregister_appid,
7826 _tzlaunch_appinfo_iface_cb_set_pid,
7827 _tzlaunch_appinfo_iface_cb_ready_metadata,
7828 _tzlaunch_appinfo_iface_cb_set_auto_placement,
7832 _tzlaunch_appinfo_del(E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo)
7834 EINA_SAFETY_ON_NULL_RETURN(tzlaunch_appinfo);
7836 polwl->tzlaunch_appinfo = eina_list_remove(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
7838 memset(tzlaunch_appinfo, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Appinfo));
7839 E_FREE(tzlaunch_appinfo);
7842 static E_Policy_Wl_Tzlaunch_Appinfo *
7843 _tzlaunch_appinfo_add(struct wl_resource *res_tzlaunch_appinfo)
7845 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo;
7847 tzlaunch_appinfo = E_NEW(E_Policy_Wl_Tzlaunch_Appinfo, 1);
7848 EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_appinfo, NULL);
7850 tzlaunch_appinfo->res_tzlaunch_appinfo = res_tzlaunch_appinfo;
7852 polwl->tzlaunch_appinfo = eina_list_append(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
7854 return tzlaunch_appinfo;
7858 _tzlaunch_appinfo_cb_unbind(struct wl_resource *res_tzlaunch_appinfo)
7860 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7863 EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_appinfo, l, ll, tzlaunch_appinfo)
7865 if (tzlaunch_appinfo->res_tzlaunch_appinfo != res_tzlaunch_appinfo) continue;
7866 _tzlaunch_appinfo_del(tzlaunch_appinfo);
7872 _tzlaunch_appinfo_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
7874 E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
7875 struct wl_resource *res_tzlaunch_appinfo;
7877 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
7879 res_tzlaunch_appinfo = wl_resource_create(client,
7880 &tizen_launch_appinfo_interface,
7883 EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_appinfo, err);
7885 tzlaunch_appinfo = _tzlaunch_appinfo_add(res_tzlaunch_appinfo);
7886 EINA_SAFETY_ON_NULL_GOTO(tzlaunch_appinfo, err);
7888 wl_resource_set_implementation(res_tzlaunch_appinfo,
7889 &_tzlaunch_appinfo_iface,
7891 _tzlaunch_appinfo_cb_unbind);
7896 ERR("Could not create tizen_launch_appinfo_interface res: %m");
7897 wl_client_post_no_memory(client);
7901 e_policy_wl_base_output_resolution_info_update(pid_t pid)
7903 _e_policy_wl_hook_call(E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET, pid);
7907 _e_policy_wl_cb_hook_intercept_show_helper(void *data, E_Client *ec)
7909 E_Policy_Wl_Tzpol *tzpol;
7910 E_Policy_Wl_Surface *psurf;
7912 Eina_Bool ret = EINA_TRUE;
7914 it = eina_hash_iterator_data_new(polwl->tzpols);
7915 EINA_ITERATOR_FOREACH(it, tzpol)
7917 psurf = _e_policy_wl_tzpol_surf_find(tzpol, ec);
7920 if (psurf->is_background)
7923 "BACKGROUND State is On, Deny Show",
7930 eina_iterator_free(it);
7936 _e_policy_wl_cb_scrsaver_on(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
7938 if (_scrsaver_mng_res)
7939 tws_service_screensaver_manager_send_idle(_scrsaver_mng_res);
7940 return ECORE_CALLBACK_PASS_ON;
7944 _e_policy_wl_cb_scrsaver_off(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
7946 if (_scrsaver_mng_res)
7947 tws_service_screensaver_manager_send_active(_scrsaver_mng_res);
7948 return ECORE_CALLBACK_PASS_ON;
7951 // --------------------------------------------------------
7952 // E_Policy_Wl_Tz_Indicator
7953 // --------------------------------------------------------
7954 static E_Policy_Wl_Tz_Indicator *
7955 _e_policy_wl_tz_indicator_add(struct wl_resource *res_tz_indicator)
7957 E_Policy_Wl_Tz_Indicator *tz_indicator;
7959 tz_indicator = E_NEW(E_Policy_Wl_Tz_Indicator, 1);
7960 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, NULL);
7962 tz_indicator->res_tz_indicator = res_tz_indicator;
7964 polwl->tz_indicators = eina_list_append(polwl->tz_indicators, tz_indicator);
7966 return tz_indicator;
7970 _e_policy_wl_tz_indicator_del(E_Policy_Wl_Tz_Indicator *tz_indicator)
7972 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
7974 polwl->tz_indicators = eina_list_remove(polwl->tz_indicators, tz_indicator);
7975 E_FREE(tz_indicator);
7978 static E_Policy_Wl_Tz_Indicator *
7979 _e_policy_wl_tz_indicator_get(struct wl_resource *res_tz_indicator)
7982 E_Policy_Wl_Tz_Indicator *tz_indicator;
7984 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
7986 if (tz_indicator->res_tz_indicator == res_tz_indicator)
7987 return tz_indicator;
7992 static E_Policy_Wl_Tz_Indicator *
7993 _e_policy_wl_tz_indicator_get_from_client(E_Client *ec)
7996 E_Policy_Wl_Tz_Indicator *tz_indicator;
7998 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
8000 if (eina_list_data_find(tz_indicator->ec_list, ec))
8001 return tz_indicator;
8008 _e_policy_wl_tz_indicator_set_client(struct wl_resource *res_tz_indicator, E_Client *ec)
8010 E_Policy_Wl_Tz_Indicator *tz_indicator = NULL;
8012 tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
8013 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, EINA_FALSE);
8015 if (!eina_list_data_find(tz_indicator->ec_list, ec))
8016 tz_indicator->ec_list = eina_list_append(tz_indicator->ec_list, ec);
8022 _e_policy_wl_tz_indicator_unset_client(E_Client *ec)
8025 E_Policy_Wl_Tz_Indicator *tz_indicator;
8027 EINA_SAFETY_ON_NULL_RETURN(ec);
8029 EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
8031 if (eina_list_data_find(tz_indicator->ec_list, ec))
8032 tz_indicator->ec_list = eina_list_remove(tz_indicator->ec_list, ec);
8037 _tz_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator)
8039 wl_resource_destroy(res_tz_indicator);
8043 _tz_indicator_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t state)
8046 E_Indicator_State ind_state;
8048 ec = e_client_from_surface_resource(surf);
8049 EINA_SAFETY_ON_NULL_RETURN(ec);
8050 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8052 if (state == TIZEN_INDICATOR_STATE_ON)
8053 ind_state = E_INDICATOR_STATE_ON;
8054 else if (state == TIZEN_INDICATOR_STATE_OFF)
8055 ind_state = E_INDICATOR_STATE_OFF;
8057 ind_state = E_INDICATOR_STATE_UNKNOWN;
8059 ELOGF("TZ_IND", "TZ_STATE:%d, E_STATE:%d", ec, state, ind_state);
8060 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8061 ec->indicator.state = ind_state;
8063 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_STATE_CHANGE);
8067 _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)
8070 E_Indicator_Opacity_Mode op_mode;
8072 ec = e_client_from_surface_resource(surf);
8073 EINA_SAFETY_ON_NULL_RETURN(ec);
8074 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8078 case TIZEN_INDICATOR_OPACITY_MODE_OPAQUE:
8079 op_mode = E_INDICATOR_OPACITY_MODE_OPAQUE;
8082 case TIZEN_INDICATOR_OPACITY_MODE_TRANSLUCENT:
8083 op_mode = E_INDICATOR_OPACITY_MODE_TRANSLUCENT;
8086 case TIZEN_INDICATOR_OPACITY_MODE_TRANSPARENT:
8087 op_mode = E_INDICATOR_OPACITY_MODE_TRANSPARENT;
8090 case TIZEN_INDICATOR_OPACITY_MODE_BG_TRANSPARENT:
8091 op_mode = E_INDICATOR_OPACITY_MODE_BG_TRANSPARENT;
8095 op_mode = E_INDICATOR_OPACITY_MODE_OPAQUE;
8099 ELOGF("TZ_IND", "TZ_OP_MODE:%d, E_OP_MODE:%d", ec, mode, op_mode);
8100 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8102 if (ec->indicator.opacity_mode == op_mode) return;
8104 ec->indicator.opacity_mode = op_mode;
8105 e_tzsh_indicator_srv_property_change_send(ec, ec->e.state.rot.ang.curr);
8107 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE);
8111 _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)
8114 E_Indicator_Visible_Type vis_type;
8116 ec = e_client_from_surface_resource(surf);
8117 EINA_SAFETY_ON_NULL_RETURN(ec);
8118 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8120 if (vtype == TIZEN_INDICATOR_VISIBLE_TYPE_SHOWN)
8121 vis_type = E_INDICATOR_VISIBLE_TYPE_SHOWN;
8123 vis_type = E_INDICATOR_VISIBLE_TYPE_HIDDEN;
8125 ELOGF("TZ_IND", "TZ_VIS_TYPE:%d, E_VIS_TYPE:%d", ec, vtype, vis_type);
8126 _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
8127 ec->indicator.visible_type = vis_type;
8129 e_policy_event_simple(ec, E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE);
8132 // --------------------------------------------------------
8133 // tizen_indicator_interface
8134 // --------------------------------------------------------
8135 static const struct tizen_indicator_interface _tz_indicator_iface =
8137 _tz_indicator_cb_destroy,
8138 _tz_indicator_cb_state_set,
8139 _tz_indicator_cb_opacity_mode_set,
8140 _tz_indicator_cb_visible_type_set,
8144 _tz_indicator_cb_unbind(struct wl_resource *res_tz_indicator)
8146 E_Policy_Wl_Tz_Indicator *tz_indicator;
8148 tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
8149 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
8151 _e_policy_wl_tz_indicator_del(tz_indicator);
8155 _tz_indicator_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
8157 E_Policy_Wl_Tz_Indicator *tz_indicator_pol;
8158 struct wl_resource *res_tz_indicator;
8160 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8162 res_tz_indicator = wl_resource_create(client,
8163 &tizen_indicator_interface,
8166 EINA_SAFETY_ON_NULL_GOTO(res_tz_indicator, err);
8168 tz_indicator_pol = _e_policy_wl_tz_indicator_add(res_tz_indicator);
8169 EINA_SAFETY_ON_NULL_GOTO(tz_indicator_pol, err);
8171 wl_resource_set_implementation(res_tz_indicator,
8172 &_tz_indicator_iface,
8174 _tz_indicator_cb_unbind);
8178 ERR("Could not create tizen_indicator_interface res: %m");
8179 wl_client_post_no_memory(client);
8183 e_policy_wl_indicator_flick_send(E_Client *ec)
8185 E_Comp_Wl_Client_Data *cdata;
8186 E_Policy_Wl_Tz_Indicator *tz_indicator;
8187 struct wl_resource *surf;
8189 tz_indicator = _e_policy_wl_tz_indicator_get_from_client(ec);
8190 EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
8192 cdata = e_client_cdata_get(ec);
8194 surf = cdata->surface;
8198 ELOGF("TZ_IND", "SEND FLICK EVENT", ec);
8199 tizen_indicator_send_flick(tz_indicator->res_tz_indicator, surf, 0);
8203 // --------------------------------------------------------
8204 // E_Policy_Wl_Tz_Clipboard
8205 // --------------------------------------------------------
8206 static E_Policy_Wl_Tz_Clipboard *
8207 _e_policy_wl_tz_clipboard_add(struct wl_resource *res_tz_clipboard)
8209 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8211 tz_clipboard = E_NEW(E_Policy_Wl_Tz_Clipboard, 1);
8212 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_clipboard, NULL);
8214 tz_clipboard->res_tz_clipboard = res_tz_clipboard;
8215 polwl->tz_clipboards = eina_list_append(polwl->tz_clipboards, tz_clipboard);
8217 return tz_clipboard;
8221 _e_policy_wl_tz_clipboard_del(E_Policy_Wl_Tz_Clipboard *tz_clipboard)
8223 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8225 polwl->tz_clipboards = eina_list_remove(polwl->tz_clipboards, tz_clipboard);
8226 E_FREE(tz_clipboard);
8229 static E_Policy_Wl_Tz_Clipboard *
8230 _e_policy_wl_tz_clipboard_get_from_client(E_Client *ec)
8233 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8235 EINA_LIST_FOREACH(polwl->tz_clipboards, l, tz_clipboard)
8237 if (eina_list_data_find(tz_clipboard->ec_list, ec))
8238 return tz_clipboard;
8245 _e_policy_wl_tz_clipboard_set_client(struct wl_resource *res_tz_clipboard, E_Client *ec)
8247 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8249 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8250 EINA_SAFETY_ON_NULL_RETURN_VAL(tz_clipboard, EINA_FALSE);
8252 if (!eina_list_data_find(tz_clipboard->ec_list, ec))
8254 tz_clipboard->ec_list = eina_list_append(tz_clipboard->ec_list, ec);
8260 _e_policy_wl_tz_clipboard_unset_client(E_Client *ec)
8263 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8265 EINA_SAFETY_ON_NULL_RETURN(ec);
8267 EINA_LIST_FOREACH(polwl->tz_clipboards, l, tz_clipboard)
8269 if (eina_list_data_find(tz_clipboard->ec_list, ec))
8271 tz_clipboard->ec_list = eina_list_remove(tz_clipboard->ec_list, ec);
8276 // --------------------------------------------------------
8277 // tizen_clipboard_interface
8278 // --------------------------------------------------------
8280 _tz_clipboard_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard)
8282 wl_resource_destroy(res_tz_clipboard);
8286 _tz_clipboard_cb_show(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard, struct wl_resource *surf)
8290 ec = e_client_from_surface_resource(surf);
8291 EINA_SAFETY_ON_NULL_RETURN(ec);
8292 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8294 _e_policy_wl_tz_clipboard_set_client(res_tz_clipboard, ec);
8295 e_service_cbhm_parent_set(ec, EINA_TRUE);
8296 e_service_cbhm_show();
8300 _tz_clipboard_cb_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_clipboard, struct wl_resource *surf)
8304 ec = e_client_from_surface_resource(surf);
8305 EINA_SAFETY_ON_NULL_RETURN(ec);
8306 EINA_SAFETY_ON_NULL_RETURN(ec->frame);
8308 e_service_cbhm_parent_set(ec, EINA_FALSE);
8309 e_service_cbhm_hide();
8313 _tz_clipboard_cb_data_only_set(struct wl_client *client, struct wl_resource *res_tz_clipboard, uint32_t set)
8315 E_Policy_Wl_Tz_Clipboard *tz_clipboard = NULL;
8316 struct wl_client *_wc;
8317 struct wl_resource *data_res;
8322 E_Client *ec, *found = NULL;
8323 E_Comp_Wl_Client_Data *cdata;
8325 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8326 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8328 if (tz_clipboard->ec_list)
8331 "Unable to set data only mode for wl_client(%p) : "
8337 if (!(data_res = e_comp_wl_data_find_for_client(client)))
8340 "Unable to set data only mode for wl_client(%p) : "
8341 "no wl_data_device resource",
8346 clients = _e_policy_wl_e_clients_find_by_pid(pid);
8349 EINA_LIST_FREE(clients, ec)
8351 if (found) continue;
8352 cdata = e_client_cdata_get(ec);
8353 if (cdata && cdata->surface)
8355 _wc = wl_resource_get_client(cdata->surface);
8365 "Unable to set data only mode for wl_client(%p) : "
8371 /* Privilege Check */
8372 wl_client_get_credentials(client, &pid, &uid, NULL);
8373 res = e_security_privilege_check(pid, uid,
8374 E_PRIVILEGE_DATA_ONLY_SET);
8378 "Privilege Check Failed! DENY data_only_set",
8384 "Set data only mode :%d for wl_client(%p)",
8386 e_comp_wl_data_device_only_set(data_res, !(set == 0));
8387 tizen_clipboard_send_allowed_data_only(res_tz_clipboard, (uint32_t)1);
8391 tizen_clipboard_send_allowed_data_only(res_tz_clipboard, (uint32_t)0);
8394 static const struct tizen_clipboard_interface _tz_clipboard_iface =
8396 _tz_clipboard_cb_destroy,
8397 _tz_clipboard_cb_show,
8398 _tz_clipboard_cb_hide,
8399 _tz_clipboard_cb_data_only_set,
8403 _tz_clipboard_cb_unbind(struct wl_resource *res_tz_clipboard)
8405 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8407 tz_clipboard = wl_resource_get_user_data(res_tz_clipboard);
8408 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8410 _e_policy_wl_tz_clipboard_del(tz_clipboard);
8414 _tz_clipboard_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
8416 E_Policy_Wl_Tz_Clipboard *tz_clipboard_pol;
8417 struct wl_resource *res_tz_clipboard;
8419 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8421 res_tz_clipboard = wl_resource_create(client,
8422 &tizen_clipboard_interface,
8425 EINA_SAFETY_ON_NULL_GOTO(res_tz_clipboard, err);
8427 tz_clipboard_pol = _e_policy_wl_tz_clipboard_add(res_tz_clipboard);
8428 EINA_SAFETY_ON_NULL_GOTO(tz_clipboard_pol, err);
8430 wl_resource_set_implementation(res_tz_clipboard,
8431 &_tz_clipboard_iface,
8433 _tz_clipboard_cb_unbind);
8437 ERR("Could not create tizen_clipboard_interface res: %m");
8438 wl_client_post_no_memory(client);
8442 e_policy_wl_clipboard_data_selected_send(E_Client *ec)
8444 E_Comp_Wl_Client_Data *cdata;
8445 E_Policy_Wl_Tz_Clipboard *tz_clipboard;
8447 EINA_SAFETY_ON_NULL_RETURN(ec);
8449 tz_clipboard = _e_policy_wl_tz_clipboard_get_from_client(ec);
8450 EINA_SAFETY_ON_NULL_RETURN(tz_clipboard);
8452 cdata = e_client_cdata_get(ec);
8453 tizen_clipboard_send_data_selected(tz_clipboard->res_tz_clipboard,
8454 cdata ? cdata->surface : NULL);
8458 _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
8462 if (EINA_UNLIKELY(!ec))
8465 e_client_base_output_resolution_update(ec);
8467 e_policy_client_maximize(ec);
8469 e_client_base_output_resolution_transform_adjust(ec);
8471 if (ec->lock_client_size)
8476 e_client_shell_configure_send(ec, 0, w, h);
8480 _e_policy_wl_cb_hook_alpha_change(void *data, E_Client *ec)
8483 if (!ec->argb) return;
8484 if (!ec->transients) return;
8485 if (!e_policy_visibility_client_is_uniconify_render_running(ec)) return;
8488 Eina_List *list = eina_list_clone(ec->transients);
8490 EINA_LIST_FREE(list, child)
8492 if (e_client_transient_policy_get(child) == E_TRANSIENT_BELOW)
8494 ELOGF("POL_VIS", "Uniconify below child(win:%zx, ec:%p) by changing alpha", ec, e_client_util_win_get(child), child);
8495 e_policy_client_uniconify_by_visibility(child);
8501 _e_policy_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
8505 if (e_object_is_del(E_OBJECT(ec))) return;
8506 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
8508 if (ec->manage_resize.resize_obj)
8510 x = ec->manage_resize.x;
8511 y = ec->manage_resize.y;
8512 w = ec->manage_resize.w;
8513 h = ec->manage_resize.h;
8521 e_client_geometry_get(ec, &x, &y, &w, &h);
8524 E_Policy_Wl_Tzpol *tzpol;
8525 E_Policy_Wl_Surface *psurf;
8530 it = eina_hash_iterator_data_new(polwl->tzpols);
8531 EINA_ITERATOR_FOREACH(it, tzpol)
8533 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8535 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8536 if (!psurf->surf) continue;
8538 ver = wl_resource_get_version(tzpol->res_tzpol);
8541 // interactive_resize_done event is supported since ver 10
8545 tizen_policy_send_interactive_resize_done(tzpol->res_tzpol,
8546 psurf->surf, x, y, w, h,
8547 ec->e.state.rot.ang.curr);
8550 eina_iterator_free(it);
8554 _e_policy_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
8556 if (e_object_is_del(E_OBJECT(ec))) return;
8557 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
8564 e_client_geometry_get(ec, &x, &y, &w, &h);
8566 E_Policy_Wl_Tzpol *tzpol;
8567 E_Policy_Wl_Surface *psurf;
8572 it = eina_hash_iterator_data_new(polwl->tzpols);
8573 EINA_ITERATOR_FOREACH(it, tzpol)
8575 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8577 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8578 if (!psurf->surf) continue;
8580 ver = wl_resource_get_version(tzpol->res_tzpol);
8583 // interactive_move_done event is supported since ver 10
8587 tizen_policy_send_interactive_move_done(tzpol->res_tzpol,
8590 ec->e.state.rot.ang.curr);
8593 eina_iterator_free(it);
8597 e_policy_wl_generate_request(E_Client *ec, E_Policy_Wl_Gen_Request type)
8599 E_Comp_Wl_Client_Data *cdata = NULL;
8602 cdata = e_client_cdata_get(ec);
8604 if (!cdata->wl_surface) return;
8606 ELOGF("POL", "Generate operation (type:%d)", ec, type);
8609 case E_POLICY_WL_GENERATE_REQUEST_LOWER:
8610 _tzpol_iface_cb_lower(NULL, NULL, cdata->wl_surface);
8612 case E_POLICY_WL_GENERATE_REQUEST_ACTIVATE:
8613 _tzpol_iface_cb_activate(NULL, NULL, cdata->wl_surface);
8615 case E_POLICY_WL_GENERATE_REQUEST_ICONIFY:
8616 _tzpol_iface_cb_iconify(NULL, NULL, cdata->wl_surface);
8618 case E_POLICY_WL_GENERATE_REQUEST_UNICONIFY:
8619 _tzpol_iface_cb_uniconify(NULL, NULL, cdata->wl_surface);
8627 e_policy_wl_aux_hint_apply(E_Client *ec)
8629 _e_policy_wl_aux_hint_apply(ec);
8632 // --------------------------------------------------------
8634 // --------------------------------------------------------
8636 e_policy_wl_client_add(E_Client *ec)
8638 EINA_SAFETY_ON_NULL_RETURN(ec);
8639 if (!ec->pixmap) return;
8641 _e_policy_wl_surf_client_set(ec);
8642 _e_policy_wl_tzlaunch_effect_type_sync(ec);
8646 e_policy_wl_client_del(E_Client *ec)
8648 EINA_SAFETY_ON_NULL_RETURN(ec);
8649 if (!ec->pixmap) return;
8651 e_policy_wl_pixmap_del(ec->pixmap);
8652 _e_policy_wl_dpy_surf_del(ec);
8653 _e_policy_wl_tz_indicator_unset_client(ec);
8654 _e_policy_wl_tz_clipboard_unset_client(ec);
8655 _launch_effect_client_del(ec);
8657 polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
8661 e_policy_wl_pixmap_del(E_Pixmap *cp)
8663 E_Policy_Wl_Tzpol *tzpol;
8664 E_Policy_Wl_Surface *psurf;
8668 it = eina_hash_iterator_data_new(polwl->tzpols);
8669 EINA_ITERATOR_FOREACH(it, tzpol)
8670 EINA_LIST_FOREACH_SAFE(tzpol->psurfs, l, ll, psurf)
8672 if (psurf->cp != cp) continue;
8673 tzpol->psurfs = eina_list_remove_list(tzpol->psurfs, l);
8674 _e_policy_wl_surf_del(psurf);
8676 eina_iterator_free(it);
8680 e_policy_wl_aux_message_send(E_Client *ec,
8685 E_Comp_Wl_Client_Data *cdata;
8686 E_Policy_Wl_Tzpol *tzpol;
8687 E_Policy_Wl_Surface *psurf;
8690 struct wl_array opt_array;
8695 if (e_object_is_del(E_OBJECT(ec))) return;
8696 cdata = e_client_cdata_get(ec);
8698 if (!cdata->aux_hint.use_msg) return;
8700 wl_array_init(&opt_array);
8701 EINA_LIST_FOREACH(options, l, option)
8703 len = strlen(option) + 1;
8704 p = wl_array_add(&opt_array, len);
8708 strncpy(p, option, len);
8711 it = eina_hash_iterator_data_new(polwl->tzpols);
8712 EINA_ITERATOR_FOREACH(it, tzpol)
8713 EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
8715 if (e_pixmap_client_get(psurf->cp) != ec) continue;
8716 if (!psurf->surf) continue;
8718 tizen_policy_send_aux_message(tzpol->res_tzpol,
8720 key, val, &opt_array);
8722 "SEND |res_tzpol:%8p|aux message key:%s val:%s opt_count:%d",
8725 key, val, eina_list_count(options));
8727 eina_iterator_free(it);
8728 wl_array_release(&opt_array);
8732 e_policy_wl_aux_hint_init(void)
8735 E_Config_Aux_Hint_Supported *auxhint;
8738 n = (sizeof(hint_names) / sizeof(char *));
8740 for (i = 0; i < n; i++)
8742 e_hints_aux_hint_supported_add(hint_names[i]);
8745 EINA_LIST_FOREACH(e_config->aux_hint_supported, l, auxhint)
8747 if (!auxhint->name) continue;
8748 e_hints_aux_hint_supported_add(auxhint->name);
8755 e_policy_wl_defer_job(void)
8757 struct wl_global *global = NULL;
8758 EINA_SAFETY_ON_NULL_GOTO(polwl, err);
8760 if (!e_config->global_object_not_provide.launch_effect)
8762 global = wl_global_create(e_comp_wl->wl.disp,
8763 &tizen_launch_effect_interface,
8766 _tzlaunch_effect_cb_bind);
8767 EINA_SAFETY_ON_NULL_GOTO(global, err);
8769 polwl->globals = eina_list_append(polwl->globals, global);
8772 global = wl_global_create(e_comp_wl->wl.disp,
8773 &tizen_launch_appinfo_interface,
8776 _tzlaunch_appinfo_cb_bind);
8777 EINA_SAFETY_ON_NULL_GOTO(global, err);
8779 polwl->globals = eina_list_append(polwl->globals, global);
8788 e_policy_wl_init(void)
8790 struct wl_global *global;
8792 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
8793 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->wl.disp, EINA_FALSE);
8795 polwl = E_NEW(E_Policy_Wl, 1);
8796 EINA_SAFETY_ON_NULL_RETURN_VAL(polwl, EINA_FALSE);
8798 /* create globals */
8799 global = wl_global_create(e_comp_wl->wl.disp,
8800 &tizen_policy_interface,
8804 EINA_SAFETY_ON_NULL_GOTO(global, err);
8805 polwl->globals = eina_list_append(polwl->globals, global);
8807 global = wl_global_create(e_comp_wl->wl.disp,
8808 &tizen_display_policy_interface,
8811 _tz_dpy_pol_cb_bind);
8812 EINA_SAFETY_ON_NULL_GOTO(global, err);
8813 polwl->globals = eina_list_append(polwl->globals, global);
8815 global = wl_global_create(e_comp_wl->wl.disp,
8816 &tizen_ws_shell_interface,
8821 EINA_SAFETY_ON_NULL_GOTO(global, err);
8822 polwl->globals = eina_list_append(polwl->globals, global);
8824 global = wl_global_create(e_comp_wl->wl.disp,
8825 &tizen_indicator_interface,
8828 _tz_indicator_cb_bind);
8829 EINA_SAFETY_ON_NULL_GOTO(global, err);
8830 polwl->globals = eina_list_append(polwl->globals, global);
8832 global = wl_global_create(e_comp_wl->wl.disp,
8833 &tizen_clipboard_interface,
8836 _tz_clipboard_cb_bind);
8837 EINA_SAFETY_ON_NULL_GOTO(global, err);
8838 polwl->globals = eina_list_append(polwl->globals, global);
8840 polwl->tzpols = eina_hash_pointer_new(_e_policy_wl_tzpol_del);
8842 E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(hooks_co, E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER, _e_policy_wl_cb_hook_intercept_show_helper, NULL);
8844 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_ON, _e_policy_wl_cb_scrsaver_on, NULL);
8845 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_OFF, _e_policy_wl_cb_scrsaver_off, NULL);
8847 E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_policy_wl_cb_hook_shell_surface_ready, NULL);
8848 E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, _e_policy_wl_cb_hook_alpha_change, NULL);
8850 E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_RESIZE_END, _e_policy_wl_client_cb_resize_end, NULL);
8851 E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_MOVE_END, _e_policy_wl_client_cb_move_end, NULL);
8853 E_EVENT_POLICY_INDICATOR_STATE_CHANGE = ecore_event_type_new();
8854 E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = ecore_event_type_new();
8855 E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = ecore_event_type_new();
8857 e_service_softkey_client_remove_handler_add();
8859 e_policy_display_init();
8866 EINA_LIST_FREE(polwl->globals, global)
8867 wl_global_destroy(global);
8875 e_policy_wl_shutdown(void)
8877 E_Policy_Wl_Tzsh *tzsh;
8878 E_Policy_Wl_Tzsh_Srv *tzsh_srv;
8879 E_Policy_Wl_Tzsh_Extension *tzsh_extension;
8880 E_Policy_Wl_Tzlaunch_Effect_Info *effect_info;
8881 E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
8882 E_Policy_Wl_Tz_Indicator *tz_indicator;
8883 struct wl_global *global;
8886 e_policy_display_shutdown();
8888 EINA_SAFETY_ON_NULL_RETURN(polwl);
8890 E_FREE_LIST(polwl_hooks_ec, e_client_hook_del);
8891 E_FREE_LIST(hooks_cw, e_comp_wl_hook_del);
8892 E_FREE_LIST(hooks_co, e_comp_object_intercept_hook_del);
8893 E_FREE_LIST(handlers, ecore_event_handler_del);
8895 e_service_softkey_client_remove_handler_del();
8897 polwl->pending_vis = eina_list_free(polwl->pending_vis);
8899 for (i = 0; i < TZSH_SRV_ROLE_MAX; i++)
8901 tzsh_srv = polwl->srvs[i];
8902 if (!tzsh_srv) continue;
8904 wl_resource_destroy(tzsh_srv->res_tzsh_srv);
8907 EINA_LIST_FREE(polwl->tzshs, tzsh)
8908 wl_resource_destroy(tzsh->res_tzsh);
8910 EINA_LIST_FREE(polwl->tz_dpy_pols, tz_dpy_pol)
8912 E_Policy_Wl_Dpy_Surface *dpy_surf;
8913 EINA_LIST_FREE(tz_dpy_pol->dpy_surfs, dpy_surf)
8917 wl_resource_destroy(tz_dpy_pol->res_tz_dpy_pol);
8920 EINA_LIST_FREE(polwl->tzlaunch_effect_info, effect_info)
8922 E_FREE(effect_info);
8925 EINA_LIST_FREE(polwl->tz_indicators, tz_indicator)
8927 eina_list_free(tz_indicator->ec_list);
8928 wl_resource_destroy(tz_indicator->res_tz_indicator);
8931 EINA_LIST_FREE(polwl->tzsh_extensions, tzsh_extension)
8933 free(tzsh_extension->name);
8936 EINA_LIST_FREE(polwl->globals, global)
8937 wl_global_destroy(global);
8939 E_FREE_FUNC(polwl->tzpols, eina_hash_free);