2 #include "e_policy_wl.h"
3 #include "services/e_service_launcher.h"
4 #include "e_comp_wl_rsm_intern.h"
5 #include "e_comp_wl_tbm_intern.h"
6 #include "e_devicemgr_intern.h"
8 #include <tzsh_server.h>
9 #include <wayland-tbm-server.h>
11 typedef struct _E_Service_Launcher E_Service_Launcher;
12 typedef struct _E_Service_Launcher_Handler E_Service_Launcher_Handler;
13 typedef struct _E_Service_Launcher_Consumer E_Service_Launcher_Consumer;
18 LAUNCHER_STATE_MONITORING,
19 LAUNCHER_STATE_PREPARING,
20 LAUNCHER_STATE_LAUNCHING,
21 LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER,
23 LAUNCHER_STATE_CANCELED,
24 LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE,
27 struct _E_Service_Launcher_Consumer
29 E_Service_Launcher *lc;
30 E_Vis_Grab *vis_grab; //grab of client's visibility
33 E_Object_Delfn *delfn; //del callback of E_Client
35 Ecore_Event_Handler *buff_attach; //event handler for BUFFER_CHANGE
36 int buff_attach_count;
39 struct _E_Service_Launcher
41 Launcher_State state; //current state of launcher
43 struct wl_resource *res; //tizen_window_transition_launcher resource
44 E_Client *ec; //launcher E_Client
46 E_Vis_Grab *vis_grab; //grab of launcher visibility
47 uint32_t serial; //identifier
48 enum tws_service_launcher_direction direction; //direction of transition
52 E_Client *ec; //target E_Client
54 const char *appid; //appid
55 E_Vis_Grab *vis_grab; //grab of target client's visibility
57 Eina_Bool delay_del; //refered delay_del
58 E_Object_Delfn *delfn; //del callback of target E_Client
60 const char *splash_path; //path of file for splash
61 const char *splash_group; //group name for splash
62 } target; //target window information for transition
64 E_Client *launched_ec; //E_Client was launched by launcher
65 E_Object_Delfn *launched_delfn; //del callback of launched_ec
67 Ecore_Event_Handler *buff_attach; //event handler for BUFFER_CHANGE
69 Eina_Bool with_swl; //it's for shared widget launch
70 Eina_Bool swl_done; //flag indicating done of callee
72 Eina_Bool block_input; //input is blocked(1) or not(0) while running client side animation
74 Eina_List *consumers; //list launcher consumer of launcher ec
77 struct _E_Service_Launcher_Handler
79 Eina_Hash *launcher_hash; //hash key:launcher_ec, data:E_Service_Launcher
80 unsigned int launcher_count; //count of launcher object
82 Eina_List *hooks_ec; //hook list for E_CLIENT_HOOK_*
83 Eina_List *hooks_vis; //hook list for E_POL_VIS_HOOK_TYPE_*
84 Eina_List *hooks_co; //hook list for E_COMP_OBJECT_INTERCEPT_HOOK_*
85 Eina_List *hooks_appinfo; //hook list for E_APPINFO_HOOK_*
86 Eina_List *hdlrs_ev; //handler list for ecore event
88 E_Service_Launcher *runner; //current runner(running launcher)
89 E_Service_Launcher *pre_runner; //previous runner
92 ////////////////////////////////////////////////////////////////////
93 static E_Service_Launcher_Handler *_laundler = NULL;
95 static void _launcher_launched_ec_set(E_Service_Launcher *lc, E_Client *launched_ec);
96 static void _launcher_target_ec_set(E_Service_Launcher *lc, E_Client *target_ec);
98 static E_Service_Launcher *_launcher_handler_launcher_find(E_Client *ec);
99 static Eina_Bool _launcher_handler_launcher_add(E_Service_Launcher *lc);
100 static Eina_Bool _launcher_handler_launcher_del(E_Service_Launcher *lc);
102 static E_Service_Launcher *_launcher_handler_launcher_runner_get(void);
103 static void _launcher_handler_launcher_runner_set(E_Service_Launcher *lc);
104 static void _launcher_handler_launcher_runner_unset(E_Service_Launcher *lc);
105 static E_Service_Launcher *_launcher_handler_launcher_pre_runner_get(void);
106 static void _launcher_handler_launcher_pre_runner_set(E_Service_Launcher *lc);
107 static void _launcher_handler_launcher_pre_runner_unset(E_Service_Launcher *lc);
109 ////////////////////////////////////////////////////////////////////
111 _launcher_clients_find_by_pid(pid_t pid)
114 Eina_List *clients = NULL, *l;
116 EINA_LIST_FOREACH(e_comp->clients, l, ec)
118 if (e_object_is_del(E_OBJECT(ec))) continue;
119 if (ec->netwm.pid != pid) continue;
120 clients = eina_list_append(clients, ec);
128 _launcher_cb_input_block_expired(void *data)
130 E_Service_Launcher *lc = (E_Service_Launcher*)data;
131 EINA_SAFETY_ON_NULL_RETURN(lc);
133 lc->block_input = EINA_FALSE;
135 ELOGF("LAUNCHER_SRV", "Input block EXPIRED", lc->ec);
139 _launcher_input_block_set(E_Service_Launcher *lc, Eina_Bool set)
141 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
145 //request for block all input
146 lc->block_input = e_devicemgr_block_internal_add(ECORE_DEVICE_CLASS_NONE,
148 (uint32_t)(e_policy_visibility_timeout_get() * 1000),
149 _launcher_cb_input_block_expired, lc);
150 return lc->block_input;
154 return e_devicemgr_block_internal_remove(_launcher_cb_input_block_expired, lc);
159 _launcher_state_to_str(Launcher_State state)
163 case LAUNCHER_STATE_IDLE:
165 case LAUNCHER_STATE_MONITORING:
166 return "PID_MONITORING";
167 case LAUNCHER_STATE_PREPARING:
169 case LAUNCHER_STATE_LAUNCHING:
171 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER:
172 return "LAUNCHING_BUT_WAITING_BUFFER";
173 case LAUNCHER_STATE_DONE:
174 return "LAUNCH_DONE";
175 case LAUNCHER_STATE_CANCELED:
176 return "LAUNCH_CANCELED";
177 case LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE:
178 return "WAIT_FOR_RESPONSE_FROM_CALLEE";
184 _launcher_state_set(E_Service_Launcher *lc,
185 Launcher_State state)
187 EINA_SAFETY_ON_NULL_RETURN(lc);
189 if (state == lc->state) return;
191 ELOGF("LAUNCHER_SRV", "Set state %s --> %s",
193 _launcher_state_to_str(lc->state),
194 _launcher_state_to_str(state));
200 _launcher_consumer_del(E_Service_Launcher_Consumer *consumer)
202 E_Service_Launcher *lc;
204 EINA_SAFETY_ON_NULL_RETURN(consumer);
208 ELOGF("LAUNCHER_SRV", "Del launcher_consumer ec:%p", lc ? lc->ec : NULL, consumer->ec);
212 e_object_delfn_del(E_OBJECT(consumer->ec), consumer->delfn);
214 consumer->delfn = NULL;
217 if (consumer->vis_grab)
219 e_policy_visibility_client_grab_release(consumer->vis_grab);
220 consumer->vis_grab = NULL;
223 if (consumer->buff_attach)
224 E_FREE_FUNC(consumer->buff_attach, ecore_event_handler_del);
227 lc->consumers = eina_list_remove(lc->consumers, consumer);
233 _launcher_cb_consumer_ec_del(void *data, void *obj)
235 E_Service_Launcher_Consumer *consumer;
238 ec = (E_Client *)obj;
239 EINA_SAFETY_ON_NULL_RETURN(ec);
241 consumer= (E_Service_Launcher_Consumer *)data;
242 EINA_SAFETY_ON_NULL_RETURN(consumer);
243 EINA_SAFETY_ON_TRUE_RETURN(consumer->ec != ec);
246 consumer->delfn = NULL;
248 _launcher_consumer_del(consumer);
251 static E_Service_Launcher_Consumer *
252 _launcher_consumer_create(E_Service_Launcher *lc, E_Client *ec)
254 E_Service_Launcher_Consumer *consumer;
256 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, NULL);
257 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
259 consumer = E_NEW(E_Service_Launcher_Consumer, 1);
260 EINA_SAFETY_ON_NULL_RETURN_VAL(consumer, NULL);
263 consumer->delfn = e_object_delfn_add(E_OBJECT(ec),
264 _launcher_cb_consumer_ec_del, consumer);
267 lc->consumers = eina_list_append(lc->consumers, consumer);
269 ELOGF("LAUNCHER_SRV", "Create launcher_consumer ec:%p", lc->ec, ec);
275 _launcher_consumers_reset(E_Service_Launcher *lc)
277 E_Service_Launcher_Consumer *consumer;
280 EINA_SAFETY_ON_NULL_RETURN(lc);
282 EINA_LIST_FOREACH_SAFE(lc->consumers, l, ll, consumer)
283 _launcher_consumer_del(consumer);
287 _launcher_post_forward(E_Service_Launcher *lc, Eina_Bool success)
289 E_Client *target_ec = NULL;
291 if ((lc->target.ec) && (!e_object_is_del(E_OBJECT(lc->target.ec))))
292 target_ec = lc->target.ec;
294 _launcher_target_ec_set(lc, NULL);
299 E_FREE_FUNC(lc->target.appid, eina_stringshare_del);
300 E_FREE_FUNC(lc->target.splash_path, eina_stringshare_del);
301 E_FREE_FUNC(lc->target.splash_group, eina_stringshare_del);
302 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
304 //if forward animation is failed, enlightenment can run animation instead.
305 if ((!success) && (target_ec))
306 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
308 if (!_launcher_input_block_set(lc, EINA_FALSE))
309 ELOGF("LAUNCHER_SRV", "Input block remove FAIL...", lc->ec);
312 e_policy_visibility_client_grab_release(lc->vis_grab);
313 if (lc->target.vis_grab)
314 e_policy_visibility_client_grab_release(lc->target.vis_grab);
317 lc->target.vis_grab = NULL;
319 if (!target_ec) return;
322 _launcher_launched_ec_set(lc, target_ec);
325 e_comp_object_damage(target_ec->frame, 0, 0, target_ec->w, target_ec->h);
326 e_comp_object_dirty(target_ec->frame);
327 e_comp_object_render(target_ec->frame);
328 evas_object_show(target_ec->frame);
330 e_comp_client_override_del(target_ec);
334 _launcher_post_backward(E_Service_Launcher *lc, Eina_Bool success)
336 E_Client *target_ec = NULL;
338 target_ec = lc->target.ec;
339 _launcher_target_ec_set(lc, NULL);
345 E_FREE_FUNC(lc->target.appid, eina_stringshare_del);
346 E_FREE_FUNC(lc->target.splash_path, eina_stringshare_del);
347 E_FREE_FUNC(lc->target.splash_group, eina_stringshare_del);
348 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
353 is_del = e_object_is_del(E_OBJECT(target_ec));
354 if (lc->target.delay_del)
355 e_object_delay_del_unref(E_OBJECT(target_ec));
360 lc->target.delay_del = EINA_FALSE;
362 //if forward animation is failed, enlightenment can run animation instead.
363 if ((!success) && (target_ec))
364 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
366 if (!_launcher_input_block_set(lc, EINA_FALSE))
367 ELOGF("LAUNCHER_SRV", "Input block remove FAIL...", lc->ec);
370 e_policy_visibility_client_grab_release(lc->vis_grab);
371 if (lc->target.vis_grab)
372 e_policy_visibility_client_grab_release(lc->target.vis_grab);
375 lc->target.vis_grab = NULL;
377 _launcher_consumers_reset(lc);
379 if (!target_ec) return;
382 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
384 e_comp_client_override_del(target_ec);
388 _launcher_stop_send(E_Service_Launcher *lc)
390 EINA_SAFETY_ON_NULL_RETURN(lc);
392 ELOGF("LAUNCHER_SRV", "Send STOP event(%d) target(ec:%p)",
393 lc->ec, lc->serial, lc->target.ec);
395 tws_service_launcher_send_stop(lc->res, lc->serial);
399 _launcher_prepare_send(E_Service_Launcher *lc,
402 const char *shared_widget_info)
406 E_Comp_Object_Content_Type content_type = 0;
407 enum tws_service_launcher_target_type target_type = 0;
408 const char *target_path = NULL, *target_group = NULL;
409 Evas_Object *content = NULL;
410 struct wl_array info_array;
416 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
417 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
419 wl_array_init(&info_array);
420 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
422 content_type = e_comp_object_content_type_get(target_ec->frame);
423 switch (content_type)
425 case E_COMP_OBJECT_CONTENT_TYPE_EXT_IMAGE:
426 content = e_comp_object_content_get(target_ec->frame);
427 EINA_SAFETY_ON_NULL_GOTO(content, fail);
429 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_IMAGE;
430 evas_object_image_file_get(content, &target_path, NULL);
431 EINA_SAFETY_ON_NULL_GOTO(target_path, fail);
433 len = strlen(target_path) + 1;
434 p_char = wl_array_add(&info_array, len);
435 EINA_SAFETY_ON_NULL_GOTO(p_char, fail);
437 strncpy(p_char, target_path, len);
439 case E_COMP_OBJECT_CONTENT_TYPE_EXT_EDJE:
440 content = e_comp_object_content_get(target_ec->frame);
441 EINA_SAFETY_ON_NULL_GOTO(content, fail);
443 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_EDJE;
444 target_path = lc->target.splash_path;
445 target_group = lc->target.splash_group;
446 if ((!target_path) || (!target_group))
447 edje_object_file_get(content, &target_path, &target_group);
448 EINA_SAFETY_ON_NULL_GOTO(target_path, fail);
449 EINA_SAFETY_ON_NULL_GOTO(target_group, fail);
451 len = strlen(target_path) + 1;
452 p_char = wl_array_add(&info_array, len);
453 EINA_SAFETY_ON_NULL_GOTO(p_char, fail);
455 strncpy(p_char, target_path, len);
457 len = strlen(target_group) + 1;
458 p_char = wl_array_add(&info_array, len);
459 EINA_SAFETY_ON_NULL_GOTO(p_char, fail);
461 strncpy(p_char, target_group, len);
465 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_REMOTE_SURFACE;
466 res_id = e_pixmap_res_id_get(target_ec->pixmap);
468 p_u32 = wl_array_add(&info_array, sizeof(uint32_t));
469 EINA_SAFETY_ON_NULL_GOTO(p_u32, fail);
476 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_REMOTE_SURFACE;
477 res_id = e_pixmap_res_id_get(target_ec->pixmap);
479 p_u32 = wl_array_add(&info_array, sizeof(uint32_t));
480 EINA_SAFETY_ON_NULL_GOTO(p_u32, fail);
486 ELOGF("LAUNCHER_SRV", "Send PREPARE event(%d) direction:%s target(ec:%p type:%d res:%d path:%s pos(%d,%d) widget:%s)",
487 lc->ec, lc->serial, lc->direction?"BACKWARD":"FORWARD", target_ec, target_type, res_id, target_path?:"N/A", x, y, shared_widget_info);
489 tws_service_launcher_send_prepare(lc->res,
494 shared_widget_info ? shared_widget_info : "None",
497 wl_array_release(&info_array);
500 wl_array_release(&info_array);
505 _launcher_prepare_shared_widget_forward_send(E_Service_Launcher *lc,
508 Eina_Bool sent = EINA_FALSE;
510 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
511 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
512 if(e_object_is_del(E_OBJECT(target_ec))) return EINA_FALSE;
514 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
515 e_comp_client_override_add(target_ec);
517 // grab uniconify job of target_ec
518 if (target_ec->iconic)
520 lc->target.vis_grab =
521 e_policy_visibility_client_filtered_grab_get
523 (E_VIS_JOB_TYPE_UNICONIFY | E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY),
527 if (!_launcher_input_block_set(lc, EINA_TRUE))
528 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
530 _launcher_launched_ec_set(lc, NULL);
531 _launcher_target_ec_set(lc, target_ec);
533 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD;
535 sent = e_tzsh_shared_widget_launch_prepare_send(target_ec,
536 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE,
540 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:FORWARD)", lc->ec);
541 _launcher_post_forward(lc, EINA_FALSE);
548 _launcher_prepare_shared_widget_backward_send(E_Service_Launcher *lc,
551 E_Vis_Job_Type job_type)
553 Eina_Bool sent = EINA_FALSE;
555 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
556 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
557 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
559 if (e_object_is_del(E_OBJECT(target_ec)))
561 if (lc->with_swl) return EINA_FALSE;
562 // do nothing if ec is deleted and there's no delay_del_ref as well.
563 if (!e_object_delay_del_ref_get(E_OBJECT(target_ec)))
567 e_object_delay_del_ref(E_OBJECT(target_ec));
568 lc->target.delay_del = EINA_TRUE;
570 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
571 e_comp_client_override_add(target_ec);
573 if (activity == target_ec)
575 lc->vis_grab = e_policy_visibility_client_filtered_grab_get(lc->ec, job_type, __func__);
576 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, E_VIS_JOB_TYPE_ALL, __func__);
580 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, job_type, __func__);
583 if (!_launcher_input_block_set(lc, EINA_TRUE))
584 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
586 _launcher_launched_ec_set(lc, NULL);
587 _launcher_target_ec_set(lc, target_ec);
589 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD;
590 lc->serial = wl_display_next_serial(e_comp_wl->wl.disp);
592 sent = e_tzsh_shared_widget_launch_prepare_send(target_ec,
593 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE,
596 // fail to send protocol event
599 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:BACKWARD)", lc->ec);
600 _launcher_post_backward(lc, EINA_FALSE);
607 _launcher_prepare_forward_send(E_Service_Launcher *lc,
610 Eina_Bool sent = EINA_FALSE;
613 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
614 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
616 if(e_object_is_del(E_OBJECT(target_ec))) return EINA_FALSE;
618 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
619 e_comp_client_override_add(target_ec);
621 //grab uniconify job of target_ec
622 if (target_ec->iconic)
623 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec,
624 (E_VIS_JOB_TYPE_UNICONIFY |
625 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY),
628 if (!_launcher_input_block_set(lc, EINA_TRUE))
629 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
631 _launcher_launched_ec_set(lc, NULL);
632 _launcher_target_ec_set(lc, target_ec);
634 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD;
635 e_client_pos_get(target_ec, &x, &y);
637 sent = _launcher_prepare_send(lc, target_ec, x, y, NULL);
639 //fail to send protocol event
642 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:FORWARD)", lc->ec);
643 _launcher_post_forward(lc, EINA_FALSE);
650 _launcher_prepare_backward_send(E_Service_Launcher *lc,
653 E_Vis_Job_Type job_type)
656 Eina_Bool sent = EINA_FALSE;
657 Eina_List *consumers;
660 E_Service_Launcher_Consumer *consumer;
662 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
663 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
664 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
666 if (e_object_is_del(E_OBJECT(target_ec)))
668 //can't do nothing if ec is deleted and there's no delay_del_ref as well.
669 if (!e_object_delay_del_ref_get(E_OBJECT(target_ec)))
673 e_object_delay_del_ref(E_OBJECT(target_ec));
674 lc->target.delay_del = EINA_TRUE;
676 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
677 e_comp_client_override_add(target_ec);
679 if ((lc->ec) && (lc->ec->remote_surface.provider))
681 consumers = e_comp_wl_remote_surface_consumers_get(lc->ec);
682 EINA_LIST_FOREACH(consumers, l, ec)
684 if (e_object_is_del(E_OBJECT(ec))) continue;
685 if (!e_policy_visibility_client_is_uniconify_render_running(ec)) continue;
687 consumer = _launcher_consumer_create(lc, ec);
688 consumer->vis_grab = e_policy_visibility_client_filtered_grab_get(ec,
689 (E_VIS_JOB_TYPE_UNICONIFY |
690 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY),
693 eina_list_free(consumers);
696 if (activity == target_ec)
698 lc->vis_grab = e_policy_visibility_client_filtered_grab_get(lc->ec, job_type, __func__);
699 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, E_VIS_JOB_TYPE_ALL, __func__);
703 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, job_type, __func__);
706 if (!_launcher_input_block_set(lc, EINA_TRUE))
707 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
709 _launcher_launched_ec_set(lc, NULL);
710 _launcher_target_ec_set(lc, target_ec);
712 lc->serial = wl_display_next_serial(e_comp_wl->wl.disp);
713 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD;
714 e_client_pos_get(target_ec, &x, &y);
716 sent = _launcher_prepare_send(lc, target_ec, x, y, NULL);
718 //fail to send protocol event
721 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:BACKWARD)", lc->ec);
722 _launcher_post_backward(lc, EINA_FALSE);
730 _launcher_data_reset(E_Service_Launcher *lc)
732 EINA_SAFETY_ON_NULL_RETURN(lc);
734 ELOGF("LAUNCHER_SRV", "Reset Launcher Data", lc->ec);
736 //clear resource and send 'DISQUALIFIED' msg
739 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_DISQUALIFIED, lc->serial);
740 wl_resource_set_user_data(lc->res, NULL);
744 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
745 _launcher_post_forward(lc, EINA_FALSE);
746 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
747 _launcher_post_backward(lc, EINA_FALSE);
749 _launcher_state_set(lc, LAUNCHER_STATE_IDLE);
750 _launcher_launched_ec_set(lc, NULL);
751 _launcher_consumers_reset(lc);
753 _launcher_handler_launcher_runner_unset(lc);
754 _launcher_handler_launcher_pre_runner_unset(lc);
761 _launcher_cb_done_buff_attach(void *data, int type EINA_UNUSED, void *event)
763 E_Service_Launcher *lc;
767 lc = (E_Service_Launcher*)data;
768 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, ECORE_CALLBACK_PASS_ON);
769 if (!lc->with_swl) goto clean;
770 if (lc->direction != TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD) goto clean;
772 ev = (E_Event_Client *)event;
773 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
774 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
777 if (ec != lc->target.ec) return ECORE_CALLBACK_PASS_ON;
778 if (!lc->swl_done) goto clean;
780 ELOGF("LAUNCHER_SRV", "Event cb(BUFFER_CHANGE) for LAUNCH_DONE", ec);
782 lc->swl_done = EINA_FALSE;
784 _launcher_post_forward(lc, EINA_TRUE);
786 _launcher_handler_launcher_runner_unset(lc);
787 _launcher_handler_launcher_pre_runner_set(lc);
788 _launcher_state_set(lc, LAUNCHER_STATE_DONE);
791 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
793 return ECORE_CALLBACK_DONE;
797 _launcher_cb_launching_consumer_buff_attach(void *data, int type EINA_UNUSED, void *event)
799 E_Service_Launcher *lc;
800 E_Service_Launcher_Consumer *consumer;
804 consumer = (E_Service_Launcher_Consumer*)data;
805 EINA_SAFETY_ON_NULL_RETURN_VAL(consumer, ECORE_CALLBACK_PASS_ON);
807 EINA_SAFETY_ON_NULL_GOTO(lc, clean);
808 EINA_SAFETY_ON_FALSE_GOTO(lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD, clean);
810 ev = (E_Event_Client *)event;
811 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
812 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
815 if (ec != consumer->ec) return ECORE_CALLBACK_PASS_ON;
817 ELOGF("LAUNCHER_SRV", "Event cb(BUFFER_CHANGE) for WAIT_CONSUMER_LAUNCHING count:%d",
818 ec, consumer->buff_attach_count);
820 consumer->buff_attach_count++;
821 if (consumer->buff_attach_count < 2) return ECORE_CALLBACK_PASS_ON;
823 if (consumer->vis_grab)
825 e_policy_visibility_client_grab_release(consumer->vis_grab);
826 consumer->vis_grab = NULL;
830 _launcher_consumer_del(consumer);
832 return ECORE_CALLBACK_PASS_ON;
836 _launcher_consumers_buffer_change_wait(E_Service_Launcher *lc)
838 E_Service_Launcher_Consumer *consumer;
841 EINA_LIST_FOREACH(lc->consumers, l, consumer)
842 consumer->buff_attach = ecore_event_handler_add(E_EVENT_CLIENT_BUFFER_CHANGE,
843 _launcher_cb_launching_consumer_buff_attach,
848 _launcher_cb_launching_buff_attach(void *data, int type EINA_UNUSED, void *event)
850 E_Service_Launcher *lc;
854 lc = (E_Service_Launcher*)data;
855 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, ECORE_CALLBACK_PASS_ON);
856 if (lc->direction != TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD) goto clean;
858 ev = (E_Event_Client *)event;
859 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
860 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
863 if (ec != lc->ec) return ECORE_CALLBACK_PASS_ON;
865 ELOGF("LAUNCHER_SRV", "Event cb(BUFFER_CHANGE) for LAUNCHING", ec);
867 if (lc->state == LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER)
869 _launcher_consumers_buffer_change_wait(lc);
870 _launcher_state_set(lc, LAUNCHER_STATE_LAUNCHING);
875 e_policy_visibility_client_grab_release(lc->vis_grab);
879 if (lc->target.vis_grab)
881 e_policy_visibility_client_grab_release(lc->target.vis_grab);
882 lc->target.vis_grab = NULL;
886 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
888 return ECORE_CALLBACK_PASS_ON;
892 _launcher_buffer_change_wait(E_Service_Launcher *lc)
895 if (lc->buff_attach) return;
897 if (lc->state == LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER)
898 lc->buff_attach = ecore_event_handler_add(E_EVENT_CLIENT_BUFFER_CHANGE,
899 _launcher_cb_launching_buff_attach,
901 else if ((lc->with_swl) && (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD))
902 lc->buff_attach = ecore_event_handler_add(E_EVENT_CLIENT_BUFFER_CHANGE,
903 _launcher_cb_done_buff_attach,
909 _launcher_cb_launched_ec_del(void *data, void *obj)
911 E_Service_Launcher *lc = (E_Service_Launcher *)data;
912 E_Client *launched_ec = (E_Client *)obj;
914 EINA_SAFETY_ON_NULL_RETURN(launched_ec);
915 EINA_SAFETY_ON_NULL_RETURN(lc);
916 EINA_SAFETY_ON_TRUE_RETURN(lc->launched_ec != launched_ec);
918 lc->launched_ec = NULL;
919 lc->launched_delfn = NULL;
923 _launcher_cb_target_ec_del(void *data, void *obj)
925 E_Service_Launcher *lc = (E_Service_Launcher *)data;
926 E_Client *target_ec = (E_Client *)obj;
928 EINA_SAFETY_ON_NULL_RETURN(target_ec);
929 EINA_SAFETY_ON_NULL_RETURN(lc);
930 EINA_SAFETY_ON_TRUE_RETURN(lc->target.ec != target_ec);
932 lc->target.ec = NULL;
933 lc->target.delfn = NULL;
937 case LAUNCHER_STATE_PREPARING:
938 case LAUNCHER_STATE_LAUNCHING:
939 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER:
940 _launcher_stop_send(lc);
941 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
942 _launcher_post_forward(lc, EINA_FALSE);
943 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
944 _launcher_post_backward(lc, EINA_FALSE);
946 _launcher_handler_launcher_runner_unset(lc);
947 _launcher_handler_launcher_pre_runner_unset(lc);
949 _launcher_state_set(lc, LAUNCHER_STATE_IDLE);
957 _launcher_launched_ec_set(E_Service_Launcher *lc, E_Client *launched_ec)
959 EINA_SAFETY_ON_NULL_RETURN(lc);
960 if (lc->launched_ec == launched_ec) return;
964 e_object_delfn_del(E_OBJECT(lc->launched_ec), lc->launched_delfn);
965 lc->launched_ec = NULL;
966 lc->launched_delfn = NULL;
971 lc->launched_ec = launched_ec;
972 lc->launched_delfn = e_object_delfn_add(E_OBJECT(launched_ec),
973 _launcher_cb_launched_ec_del, lc);
978 _launcher_target_ec_set(E_Service_Launcher *lc, E_Client *target_ec)
980 EINA_SAFETY_ON_NULL_RETURN(lc);
981 if (lc->target.ec == target_ec) return;
985 e_object_delfn_del(E_OBJECT(lc->target.ec), lc->target.delfn);
986 lc->target.ec = NULL;
987 lc->target.delfn = NULL;
992 lc->target.ec = target_ec;
993 lc->target.delfn = e_object_delfn_add(E_OBJECT(target_ec),
994 _launcher_cb_target_ec_del, lc);
999 _launcher_cb_resource_destroy(struct wl_resource *res_tws_lc)
1001 E_Service_Launcher *lc;
1003 lc = wl_resource_get_user_data(res_tws_lc);
1006 ELOGF("LAUNCHER_SRV", "Start Resource Destroy tws_service_launcher", lc->ec);
1008 _launcher_handler_launcher_del(lc);
1011 _launcher_data_reset(lc);
1015 ELOGF("LAUNCHER_SRV", "End Resource Destroy tws_service_launcher", NULL);
1019 _launcher_cb_destroy(struct wl_client *client EINA_UNUSED,
1020 struct wl_resource *res_tws_lc)
1022 ELOGF("LAUNCHER_SRV", "Received request(launcher_destroy)", NULL);
1023 wl_resource_destroy(res_tws_lc);
1027 _launcher_cb_launch(struct wl_client *client EINA_UNUSED,
1028 struct wl_resource *res_tws_lc,
1030 const char *instance_id,
1034 E_Service_Launcher *lc;
1035 E_Service_Launcher *runner, *pre_runner;
1036 E_Client *target_ec;
1038 Eina_Bool sent = EINA_FALSE;
1040 lc = wl_resource_get_user_data(res_tws_lc);
1041 EINA_SAFETY_ON_NULL_RETURN(lc);
1042 EINA_SAFETY_ON_NULL_RETURN(lc->ec);
1044 ELOGF("LAUNCHER_SRV",
1045 "Recieved request(launcher_launch) appid:%s instance id:%s pid:%d",
1046 lc->ec, app_id?:"NONE", instance_id?:"NONE", pid);
1048 EINA_SAFETY_ON_TRUE_GOTO(lc->ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED, send_stop);
1049 EINA_SAFETY_ON_TRUE_GOTO((pid < 0) && !(app_id) , send_stop);
1051 //check current state of lc
1052 runner = _launcher_handler_launcher_runner_get();
1055 ELOGF("LAUNCHER_SRV",
1056 "Launcher(%s) requests LAUNCH again without cancel, ignore this.",
1057 lc->ec, _launcher_state_to_str(lc->state));
1059 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1063 pre_runner = _launcher_handler_launcher_pre_runner_get();
1064 if (pre_runner == lc)
1066 _launcher_handler_launcher_pre_runner_set(NULL);
1067 _launcher_launched_ec_set(lc, NULL);
1070 lc->serial = serial;
1071 lc->target.pid = pid;
1075 ecs = _launcher_clients_find_by_pid(pid);
1076 EINA_LIST_FOREACH(ecs, l, target_ec)
1078 if (e_object_is_del(E_OBJECT(target_ec))) continue;
1079 if (e_client_util_ignored_get(target_ec)) continue;
1081 ELOGF("LAUNCHER_SRV", "Found target_ec:%p", lc->ec, target_ec);
1083 sent = _launcher_prepare_forward_send(lc, target_ec);
1084 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1086 _launcher_state_set(lc, LAUNCHER_STATE_PREPARING);
1089 eina_list_free(ecs);
1094 lc->target.appid = eina_stringshare_add(app_id);
1099 ELOGF("LAUNCHER_SRV", "Can't find target_ec, Start Monitoring", lc->ec);
1100 _launcher_state_set(lc, LAUNCHER_STATE_MONITORING);
1103 _launcher_handler_launcher_runner_set(lc);
1108 ELOGF("LAUNCHER_SRV", "can't process request(launcher_launch)", lc->ec);
1109 _launcher_stop_send(lc);
1113 _launcher_cb_launch_with_shared_widget(struct wl_client *client EINA_UNUSED,
1114 struct wl_resource *res_tws_lc,
1116 const char *instance_id,
1120 E_Service_Launcher *lc;
1121 E_Service_Launcher *runner, *pre_runner;
1122 E_Client *target_ec;
1124 Eina_Bool sent = EINA_FALSE;
1126 lc = wl_resource_get_user_data(res_tws_lc);
1127 EINA_SAFETY_ON_NULL_RETURN(lc);
1128 EINA_SAFETY_ON_NULL_RETURN(lc->ec);
1130 ELOGF("LAUNCHER_SRV",
1131 "Recieved request(launcher_launch_with_shared_widget) appid:%s instance id:%s pid:%d",
1132 lc->ec, app_id?:"NONE", instance_id?:"NONE", pid);
1134 EINA_SAFETY_ON_TRUE_GOTO(lc->ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED, send_stop);
1135 EINA_SAFETY_ON_TRUE_GOTO((pid < 0) && !(app_id), send_stop);
1137 // check current state of lc
1138 runner = _launcher_handler_launcher_runner_get();
1141 ELOGF("LAUNCHER_SRV",
1142 "Launcher(%s) requests LAUNCH again without cancel, ignore this.",
1143 lc->ec, _launcher_state_to_str(lc->state));
1145 tws_service_launcher_send_error(lc->res,
1146 TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST,
1151 pre_runner = _launcher_handler_launcher_pre_runner_get();
1152 if (pre_runner == lc)
1154 _launcher_handler_launcher_pre_runner_set(NULL);
1155 _launcher_launched_ec_set(lc, NULL);
1158 lc->with_swl = EINA_TRUE; /* set swl flag */
1159 lc->serial = serial;
1160 lc->target.pid = pid;
1164 ecs = _launcher_clients_find_by_pid(pid);
1165 EINA_LIST_FOREACH(ecs, l, target_ec)
1167 if (e_object_is_del(E_OBJECT(target_ec))) continue;
1168 if (e_client_util_ignored_get(target_ec)) continue;
1170 ELOGF("LAUNCHER_SRV", "Found target_ec:%p", lc->ec, target_ec);
1172 // send prepare_shared_widget event to callee
1173 sent = _launcher_prepare_shared_widget_forward_send(lc, target_ec);
1174 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1176 _launcher_state_set(lc, LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE);
1179 eina_list_free(ecs);
1184 lc->target.appid = eina_stringshare_add(app_id);
1189 ELOGF("LAUNCHER_SRV", "Can't find target_ec, Start Monitoring", lc->ec);
1190 _launcher_state_set(lc, LAUNCHER_STATE_MONITORING);
1193 _launcher_handler_launcher_runner_set(lc);
1198 ELOGF("LAUNCHER_SRV", "can't process request(launcher_launch)", lc->ec);
1199 _launcher_stop_send(lc);
1203 _launcher_cb_launching(struct wl_client *client EINA_UNUSED,
1204 struct wl_resource *res_tws_lc,
1207 E_Service_Launcher *lc;
1208 E_Service_Launcher *runner;
1210 lc = wl_resource_get_user_data(res_tws_lc);
1211 EINA_SAFETY_ON_NULL_RETURN(lc);
1213 ELOGF("LAUNCHER_SRV", "LAUNCHING(%d) %s",
1214 lc->ec, serial, lc->direction?"backward":"forward");
1216 //check current state of lc
1217 runner = _launcher_handler_launcher_runner_get();
1220 ELOGF("LAUNCHER_SRV", "lc(%p) runner(%p), lc is not runner, ignore LAUNCHING",
1221 lc->ec, lc, runner);
1222 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1226 _launcher_state_set(lc, LAUNCHER_STATE_LAUNCHING);
1228 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1230 _launcher_state_set(lc, LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER);
1231 _launcher_buffer_change_wait(lc);
1236 _launcher_target_ec_queue_flush(E_Service_Launcher *lc)
1238 struct wayland_tbm_client_queue *cqueue;
1240 if (!e_comp_wl) return;
1242 if (!lc->target.ec) return;
1243 if (e_object_is_del(E_OBJECT(lc->target.ec))) return;
1245 cqueue = e_comp_wl_tbm_client_queue_get(lc->target.ec);
1247 wayland_tbm_server_client_queue_flush(cqueue);
1251 _launcher_cb_launch_done(struct wl_client *client EINA_UNUSED,
1252 struct wl_resource *res_tws_lc,
1255 E_Service_Launcher *lc;
1256 E_Service_Launcher *runner;
1257 E_Client *target_ec = NULL;
1258 enum tws_service_launcher_direction launch_direction = 0;
1260 lc = wl_resource_get_user_data(res_tws_lc);
1261 EINA_SAFETY_ON_NULL_RETURN(lc);
1263 ELOGF("LAUNCHER_SRV", "LAUNCH_DONE(%d) target:%p", lc->ec, serial, lc->target.ec);
1265 target_ec = lc->target.ec;
1266 launch_direction = lc->direction;
1268 //check current state of lc
1269 runner = _launcher_handler_launcher_runner_get();
1272 ELOGF("LAUNCHER_SRV", "lc(%p) runner(%p), lc is not runner, ignore LAUNCH_DONE",
1273 lc->ec, lc, runner);
1274 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1278 //shared widget launch case
1281 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1285 sent = e_tzsh_shared_widget_launch_prepare_send(lc->target.ec,
1286 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW,
1289 //TODO : handle failure case
1292 _launcher_buffer_change_wait(lc);
1298 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1300 e_tzsh_shared_widget_launch_prepare_send(lc->target.ec,
1301 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW,
1303 _launcher_post_backward(lc, EINA_TRUE);
1306 else //normal launcher
1308 _launcher_target_ec_queue_flush(lc);
1309 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1310 _launcher_post_forward(lc, EINA_TRUE);
1311 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1312 _launcher_post_backward(lc, EINA_TRUE);
1315 _launcher_handler_launcher_runner_unset(lc);
1316 _launcher_handler_launcher_pre_runner_set(lc);
1317 _launcher_state_set(lc, LAUNCHER_STATE_DONE);
1319 if (launch_direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1321 if (target_ec && !e_object_is_del(E_OBJECT(target_ec)))
1323 if (target_ec->launching == EINA_TRUE)
1325 ELOGF("COMP", "Un-Set launching flag..", target_ec);
1326 target_ec->launching = EINA_FALSE;
1328 if (target_ec->first_mapped)
1330 E_Comp_Wl_Client_Data *target_cdata = e_client_cdata_get(target_ec);
1331 ELOGF("LAUNCH", "SHOW real win (target->frame:%p, map:%d) by launcher service (win:0x%08zx, ec:%p).", target_ec, target_ec->frame, target_cdata->mapped, e_client_util_win_get(lc->ec), lc->ec);
1332 e_comp_object_signal_emit(target_ec->frame, "e,action,launch_real,done", "e");
1334 e_comp_object_signal_emit(target_ec->frame, "e,action,launch,done", "e");
1341 _launcher_cb_launch_cancel(struct wl_client *client EINA_UNUSED,
1342 struct wl_resource *res_tws_lc,
1345 E_Service_Launcher *lc;
1346 E_Service_Launcher *runner;
1348 lc = wl_resource_get_user_data(res_tws_lc);
1349 EINA_SAFETY_ON_NULL_RETURN(lc);
1351 ELOGF("LAUNCHER_SRV", "LAUNCH_CANCEL(%d) target_ec:%p",
1352 lc->ec, serial, lc->target.ec);
1355 runner = _launcher_handler_launcher_runner_get();
1358 ELOGF("LAUNCHER_SRV", "lc(%p) runner(%p), lc is not runner, ignore LAUNCH_CANCEL",
1359 lc->ec, lc, runner);
1360 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1364 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1365 _launcher_post_forward(lc, EINA_FALSE);
1366 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1367 _launcher_post_backward(lc, EINA_FALSE);
1369 _launcher_handler_launcher_runner_unset(lc);
1370 _launcher_handler_launcher_pre_runner_set(lc);
1371 _launcher_state_set(lc, LAUNCHER_STATE_CANCELED);
1374 static const struct tws_service_launcher_interface _launcher_iface =
1376 _launcher_cb_destroy,
1377 _launcher_cb_launch,
1378 _launcher_cb_launch_with_shared_widget,
1379 _launcher_cb_launching,
1380 _launcher_cb_launch_done,
1381 _launcher_cb_launch_cancel,
1385 _launcher_handler_rsm_provider_client_find(E_Client *rsm_consumer_ec)
1387 E_Client *prov_ec = NULL;
1388 E_Comp_Wl_Client_Data *prov_cdata = NULL;
1389 Eina_List *tzrs_provs, *l;
1390 E_Service_Launcher *lc;
1392 if (!rsm_consumer_ec->remote_surface.consumer) return NULL;
1394 tzrs_provs = e_comp_wl_remote_surface_providers_get(rsm_consumer_ec);
1395 if (!tzrs_provs) return NULL;
1397 EINA_LIST_FOREACH(tzrs_provs, l, prov_ec)
1399 /* check remote surface provider */
1400 if (!prov_ec->remote_surface.provider) continue;
1401 if (prov_ec->visible) continue;
1402 if (evas_object_visible_get(prov_ec->frame)) continue;
1403 prov_cdata = e_client_cdata_get(prov_ec);
1404 if (prov_cdata->mapped) continue;
1405 if (!(lc = _launcher_handler_launcher_find(prov_ec))) continue;
1406 if (!lc->launched_ec) continue;
1408 ELOGF("LAUNCHER_SRV", "Found prov_ec:%p", rsm_consumer_ec, prov_ec);
1411 eina_list_free(tzrs_provs);
1416 static E_Service_Launcher *
1417 _launcher_handler_launcher_find(E_Client *ec)
1419 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
1420 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, NULL);
1421 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler->launcher_hash, NULL);
1423 return eina_hash_find(_laundler->launcher_hash, &ec);
1427 _launcher_handler_launcher_add(E_Service_Launcher *lc)
1431 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
1432 EINA_SAFETY_ON_NULL_RETURN_VAL(lc->ec, EINA_FALSE);
1433 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, EINA_FALSE);
1434 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler->launcher_hash, EINA_FALSE);
1436 ret = eina_hash_add(_laundler->launcher_hash, &lc->ec, lc);
1438 _laundler->launcher_count++;
1444 _launcher_handler_launcher_del(E_Service_Launcher *lc)
1448 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
1449 EINA_SAFETY_ON_NULL_RETURN_VAL(lc->ec, EINA_FALSE);
1450 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, EINA_FALSE);
1451 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler->launcher_hash, EINA_FALSE);
1453 ret = eina_hash_del(_laundler->launcher_hash, &lc->ec, lc);
1454 if (ret) _laundler->launcher_count--;
1460 _launcher_handler_launcher_runner_set(E_Service_Launcher *lc)
1462 E_Service_Launcher *runner = NULL;
1464 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1465 if (_laundler->runner == lc) return;
1467 //reset previous runner
1468 runner = _laundler->runner;
1471 switch (runner->state)
1473 case LAUNCHER_STATE_PREPARING:
1474 case LAUNCHER_STATE_LAUNCHING:
1475 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER:
1476 _launcher_state_set(runner, LAUNCHER_STATE_CANCELED);
1477 _launcher_stop_send(runner);
1478 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1479 _launcher_post_forward(runner, EINA_FALSE);
1480 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1481 _launcher_post_backward(runner, EINA_FALSE);
1483 case LAUNCHER_STATE_MONITORING:
1484 _launcher_state_set(runner, LAUNCHER_STATE_CANCELED);
1485 _launcher_stop_send(runner);
1486 runner->target.pid = -1;
1487 runner->target.ec = NULL;
1488 E_FREE_FUNC(runner->target.appid, eina_stringshare_del);
1489 E_FREE_FUNC(runner->target.splash_path, eina_stringshare_del);
1490 E_FREE_FUNC(runner->target.splash_group, eina_stringshare_del);
1495 _launcher_handler_launcher_pre_runner_set(runner);
1498 ELOGF("LAUNCHER_SRV", "runner change %p(ec:%p) to %p(ec:%p)",
1499 NULL, runner, runner?runner->ec:NULL, lc, lc?lc->ec:NULL);
1501 _laundler->runner = lc;
1505 _launcher_handler_launcher_runner_unset(E_Service_Launcher *lc)
1507 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1508 if (_laundler->runner != lc) return;
1510 _laundler->runner = NULL;
1512 ELOGF("LAUNCHER_SRV", "runner unset %p(ec:%p)",
1513 NULL, lc, lc?lc->ec:NULL);
1516 static E_Service_Launcher *
1517 _launcher_handler_launcher_runner_get(void)
1519 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, NULL);
1520 return _laundler->runner;
1524 _launcher_handler_launcher_pre_runner_set(E_Service_Launcher *lc)
1526 E_Service_Launcher *pre_runner = NULL;
1528 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1530 pre_runner = _laundler->pre_runner;
1531 if (pre_runner == lc) return;
1534 if (pre_runner->launched_ec)
1535 e_policy_animatable_lock(pre_runner->launched_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
1536 _launcher_state_set(pre_runner, LAUNCHER_STATE_IDLE);
1539 _laundler->pre_runner = lc;
1541 ELOGF("LAUNCHER_SRV", "pre_runner change %p(ec:%p) to %p(ec:%p)",
1542 NULL, pre_runner, pre_runner?pre_runner->ec:NULL, lc, lc?lc->ec:NULL);
1546 _launcher_handler_launcher_pre_runner_unset(E_Service_Launcher *lc)
1548 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1549 if (_laundler->pre_runner != lc) return;
1551 _laundler->pre_runner = NULL;
1553 ELOGF("LAUNCHER_SRV", "pre_runner unset %p(ec:%p)",
1554 NULL, lc, lc?lc->ec:NULL);
1557 static E_Service_Launcher *
1558 _launcher_handler_launcher_pre_runner_get(void)
1560 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, NULL);
1561 return _laundler->pre_runner;
1565 _launcher_handler_cb_hook_vis_uniconify_render_running(void *data EINA_UNUSED, E_Client *ec)
1567 E_Service_Launcher *lc = NULL;
1568 E_Service_Launcher *runner, *pre_runner = NULL;
1569 E_Client *activity = NULL, *prov_ec = NULL;
1570 Launcher_State new_state;
1572 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1574 lc = _launcher_handler_launcher_find(ec);
1577 prov_ec = _launcher_handler_rsm_provider_client_find(ec);
1580 /* find launcher handler again with provider ec */
1581 lc = _launcher_handler_launcher_find(prov_ec);
1582 /* set rsm provider ec pointer value to given ec (rsm consumer) */
1586 if (!lc) return EINA_TRUE;
1588 activity = e_policy_visibility_main_activity_get();
1589 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_TRUE);
1593 ELOGF("LAUNCHER_SRV", "Hook uniconify render begin target.ec:%p activity:%p launched_ec:%p",
1594 ec, lc->target.ec, activity, lc->launched_ec);
1596 if (activity == lc->launched_ec)
1598 int sent = EINA_FALSE;
1600 ELOGF("LAUNCHER_SRV", "Current activity(%p, is_del:%d) was launched by launcher.",
1601 ec, activity, e_object_is_del(E_OBJECT(activity)));
1604 runner = _launcher_handler_launcher_runner_get();
1607 ELOGF("LAUNCHER_SRV",
1608 "Launcher(%s) is already runner, do nothing",
1609 lc->ec, _launcher_state_to_str(lc->state));
1613 pre_runner = _launcher_handler_launcher_pre_runner_get();
1614 if (pre_runner == lc)
1616 _launcher_handler_launcher_pre_runner_set(NULL);
1621 sent = _launcher_prepare_shared_widget_backward_send
1622 (lc, activity, activity,
1623 (E_VIS_JOB_TYPE_UNICONIFY |
1624 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY));
1626 new_state = LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE;
1630 sent = _launcher_prepare_backward_send
1631 (lc, activity, activity,
1632 (E_VIS_JOB_TYPE_UNICONIFY |
1633 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY));
1635 new_state = LAUNCHER_STATE_PREPARING;
1639 if (!sent) return EINA_FALSE;
1641 _launcher_state_set(lc, new_state);
1642 _launcher_handler_launcher_runner_set(lc);
1650 _launcher_handler_cb_hook_vis_lower(void *data EINA_UNUSED, E_Client *ec)
1652 E_Service_Launcher *lc = NULL;
1653 E_Service_Launcher *runner, *pre_runner;
1654 E_Client *activity = NULL, *prov_ec = NULL;
1655 Launcher_State new_state;
1657 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1659 activity = e_policy_visibility_main_activity_get();
1660 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
1662 lc = _launcher_handler_launcher_find(activity);
1665 prov_ec = _launcher_handler_rsm_provider_client_find(activity);
1668 /* find launcher handler again with provider activity */
1669 lc = _launcher_handler_launcher_find(prov_ec);
1672 if (!lc) return EINA_FALSE;
1674 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) return EINA_FALSE;
1676 if (ec == lc->launched_ec)
1678 Eina_Bool sent = EINA_FALSE;
1679 ELOGF("LAUNCHER_SRV", "Lower hook of launched_ec(%p)", lc->ec, ec);
1682 runner = _launcher_handler_launcher_runner_get();
1685 ELOGF("LAUNCHER_SRV",
1686 "Launcher(%s) is already runner, do nothing",
1687 lc->ec, _launcher_state_to_str(lc->state));
1691 pre_runner = _launcher_handler_launcher_pre_runner_get();
1692 if (pre_runner == lc)
1694 _launcher_handler_launcher_pre_runner_set(NULL);
1699 sent = _launcher_prepare_shared_widget_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_LOWER);
1700 new_state = LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE;
1704 sent = _launcher_prepare_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_LOWER);
1705 new_state = LAUNCHER_STATE_PREPARING;
1708 if (!sent) return EINA_FALSE;
1710 _launcher_state_set(lc, new_state);
1711 _launcher_handler_launcher_runner_set(lc);
1718 _launcher_handler_cb_hook_vis_hide(void *data EINA_UNUSED, E_Client *ec)
1720 E_Service_Launcher *lc = NULL;
1721 E_Service_Launcher *runner, *pre_runner;
1722 E_Client *activity = NULL, *prov_ec = NULL;
1723 Launcher_State new_state;
1725 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1727 activity = e_policy_visibility_main_activity_get();
1728 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
1730 lc = _launcher_handler_launcher_find(activity);
1733 prov_ec = _launcher_handler_rsm_provider_client_find(activity);
1736 /* find launcher handler again with provider ec */
1737 lc = _launcher_handler_launcher_find(prov_ec);
1743 * activity: callee ec
1744 * given ec: callee ec (transient_for child) <-- destroying by back key
1745 * caller ec (transient_for parent) <-- will be shown
1747 * In this case, the given ec is a callee ec and is transient_for with caller ec (lc) by
1748 * group launching. Also, because of transient_for, caller ec is not iconified.
1749 * Since the given ec is destroyed by the back key, we can't find out caller ec(lc) with activity and given ec.
1750 * We have to use transient_for to find caller ec(lc).
1754 ELOGF("LAUNCHER_SRV", "Hide hook of ec->parent(%p)", ec, ec->parent);
1755 lc = _launcher_handler_launcher_find(ec->parent);
1756 if ((lc) && (lc->launched_ec != ec)) lc = NULL;
1760 ELOGF("LAUNCHER_SRV", "Hide hook of ec->parent(NULL)", ec);
1764 if (!lc) return EINA_FALSE;
1766 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) return EINA_FALSE;
1768 if (ec == lc->launched_ec)
1770 Eina_Bool sent = EINA_FALSE;
1771 ELOGF("LAUNCHER_SRV", "Hide hook of launched_ec(%p)", lc->ec, ec);
1774 runner = _launcher_handler_launcher_runner_get();
1777 ELOGF("LAUNCHER_SRV",
1778 "Launcher(%s) is already runner, do nothing",
1779 lc->ec, _launcher_state_to_str(lc->state));
1783 pre_runner = _launcher_handler_launcher_pre_runner_get();
1784 if (pre_runner == lc)
1786 _launcher_handler_launcher_pre_runner_set(NULL);
1791 sent = _launcher_prepare_shared_widget_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_HIDE);
1792 new_state = LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE;
1796 sent = _launcher_prepare_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_HIDE);
1797 new_state = LAUNCHER_STATE_PREPARING;
1799 if (!sent) return EINA_FALSE;
1801 _launcher_state_set(lc, new_state);
1802 _launcher_handler_launcher_runner_set(lc);
1809 _launcher_handler_cb_hook_client_del(void *data EINA_UNUSED, E_Client *ec)
1811 E_Service_Launcher *lc;
1813 EINA_SAFETY_ON_NULL_RETURN(ec);
1815 lc = _launcher_handler_launcher_find(ec);
1818 if (lc->ec == ec) //launcher surface is gone.
1820 _launcher_handler_launcher_del(lc);
1821 _launcher_data_reset(lc);
1827 _launcher_handler_cb_hook_intercept_show_helper(void *data, E_Client *ec)
1829 E_Service_Launcher *runner;
1830 Eina_Bool sent = EINA_FALSE;
1832 runner = _launcher_handler_launcher_runner_get();
1834 if (!runner) goto show_allow;
1835 EINA_SAFETY_ON_NULL_GOTO(ec, show_allow);
1837 if (ec->new_client) goto show_allow;
1839 switch (runner->state)
1841 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER: //waiting buffer change
1842 if (ec == runner->ec)
1845 case LAUNCHER_STATE_PREPARING: //waiting launcher client's preparation
1846 case LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE:
1847 if (ec == runner->target.ec) goto show_deny;
1849 case LAUNCHER_STATE_LAUNCHING: //doing animation
1850 if (ec == runner->target.ec) goto show_deny; //don't show launched app window
1851 else if (ec == runner->ec) goto show_allow; //show launcher
1853 case LAUNCHER_STATE_MONITORING: //waiting creation of target window
1854 if ((runner->target.pid >= 0) && (ec->netwm.pid != runner->target.pid)) goto show_allow; //detect by pid
1855 if ((runner->target.appid) && (runner->target.ec) && (runner->target.ec != ec)) goto show_allow; //detect by appid
1856 if ((runner->target.appid) && (runner->target.pid < 0) && (!runner->target.ec)) goto show_allow; //not enough info
1857 if (e_object_is_del(E_OBJECT(ec))) goto show_allow;
1859 if (runner->with_swl)
1861 sent = _launcher_prepare_shared_widget_forward_send(runner, ec);
1862 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1864 _launcher_state_set(runner, LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE);
1868 sent = _launcher_prepare_forward_send(runner, ec);
1869 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1871 _launcher_state_set(runner, LAUNCHER_STATE_PREPARING);
1883 runner->target.pid = -1;
1885 runner->target.ec = NULL;
1886 E_FREE_FUNC(runner->target.appid, eina_stringshare_del);
1887 E_FREE_FUNC(runner->target.splash_path, eina_stringshare_del);
1888 E_FREE_FUNC(runner->target.splash_group, eina_stringshare_del);
1890 _launcher_stop_send(runner);
1891 _launcher_state_set(runner, LAUNCHER_STATE_IDLE);
1892 _launcher_handler_launcher_runner_unset(runner);
1896 static void _launcher_handler_cb_hook_appinfo_pid_set(const char *appid, pid_t pid, void *data)
1898 E_Service_Launcher *runner;
1900 EINA_SAFETY_ON_NULL_RETURN(appid);
1901 EINA_SAFETY_ON_TRUE_RETURN(pid < 0);
1903 runner = _launcher_handler_launcher_runner_get();
1904 if (!runner) return;
1905 if (runner->state != LAUNCHER_STATE_MONITORING) return;
1907 if (runner->target.appid)
1909 if (!e_util_strcmp(appid, runner->target.appid))
1911 runner->target.pid = pid;
1913 ELOGF("LAUNCHER_SRV", "Register callee pid:%d by appid(%s)",
1914 runner->ec, pid, runner->target.appid);
1920 _launcher_handler_cb_event_client_show(void *data, int type EINA_UNUSED, void *event)
1922 E_Service_Launcher *runner, *pre_runner;
1926 runner = _launcher_handler_launcher_runner_get();
1927 if (!runner) return ECORE_CALLBACK_PASS_ON;
1929 ev = (E_Event_Client *)event;
1930 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
1931 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
1935 switch (runner->state)
1937 case LAUNCHER_STATE_MONITORING:
1938 if (ec->netwm.pid == runner->target.pid)
1941 case LAUNCHER_STATE_PREPARING:
1942 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1944 if (ec == runner->target.ec) goto send_stop;
1946 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1948 if (ec == runner->ec) goto send_stop;
1951 case LAUNCHER_STATE_LAUNCHING:
1952 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1954 if (ec == runner->target.ec) goto send_stop;
1961 pre_runner = _launcher_handler_launcher_pre_runner_get();
1964 switch (pre_runner->state)
1966 case LAUNCHER_STATE_DONE:
1967 if (ec == pre_runner->launched_ec)
1968 _launcher_handler_launcher_pre_runner_set(NULL);
1970 case LAUNCHER_STATE_CANCELED:
1971 _launcher_handler_launcher_pre_runner_set(NULL);
1978 return ECORE_CALLBACK_PASS_ON;
1981 ELOGF("LAUNCHER_SRV", "CLIENT SHOW: Failure Case runner:%p", ec, runner);
1983 _launcher_stop_send(runner);
1985 if (runner->state == LAUNCHER_STATE_MONITORING)
1987 runner->target.pid = -1;
1990 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1991 _launcher_post_forward(runner, EINA_FALSE);
1992 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1993 _launcher_post_backward(runner, EINA_FALSE);
1995 _launcher_state_set(runner, LAUNCHER_STATE_IDLE);
1996 _launcher_handler_launcher_runner_unset(runner);
1998 return ECORE_CALLBACK_PASS_ON;
2002 _launcher_handler_cb_event_client_visibility_change(void *data, int type EINA_UNUSED, void *event)
2004 E_Service_Launcher *pre_runner;
2008 ev = (E_Event_Client *)event;
2009 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
2010 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
2013 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED)
2014 return ECORE_CALLBACK_PASS_ON;
2016 pre_runner = _launcher_handler_launcher_pre_runner_get();
2019 switch (pre_runner->state)
2021 case LAUNCHER_STATE_DONE:
2022 case LAUNCHER_STATE_CANCELED:
2023 if (pre_runner->launched_ec)
2025 if (pre_runner->launched_ec == ec)
2027 e_policy_animatable_lock(pre_runner->launched_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
2036 return ECORE_CALLBACK_PASS_ON;
2039 #undef LAUNCHER_HANDLER_CB_ADD
2040 #define LAUNCHER_HANDLER_CB_ADD(l, appender, event_type, cb, data) \
2044 _h = appender(event_type, cb, data); \
2046 l = eina_list_append(l, _h); \
2051 static E_Service_Launcher_Handler *
2052 _launcher_handler_create(void)
2054 E_Service_Launcher_Handler *laundler = NULL;
2056 laundler = E_NEW(E_Service_Launcher_Handler, 1);
2057 EINA_SAFETY_ON_NULL_RETURN_VAL(laundler, NULL);
2059 laundler->launcher_count = 0;
2060 laundler->launcher_hash = eina_hash_pointer_new(NULL);
2062 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_vis,
2063 e_policy_visibility_hook_add,
2064 E_POL_VIS_HOOK_TYPE_UNICONIFY_RENDER_RUNNING,
2065 _launcher_handler_cb_hook_vis_uniconify_render_running, NULL);
2067 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_vis,
2068 e_policy_visibility_hook_add,
2069 E_POL_VIS_HOOK_TYPE_LOWER,
2070 _launcher_handler_cb_hook_vis_lower, NULL);
2072 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_vis,
2073 e_policy_visibility_hook_add,
2074 E_POL_VIS_HOOK_TYPE_HIDE,
2075 _launcher_handler_cb_hook_vis_hide, NULL);
2077 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_ec,
2080 _launcher_handler_cb_hook_client_del, NULL);
2082 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_co,
2083 e_comp_object_intercept_hook_add,
2084 E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER,
2085 _launcher_handler_cb_hook_intercept_show_helper, NULL);
2087 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_appinfo,
2089 E_APPINFO_HOOK_PID_SET,
2090 _launcher_handler_cb_hook_appinfo_pid_set, NULL);
2092 LAUNCHER_HANDLER_CB_ADD(laundler->hdlrs_ev,
2093 ecore_event_handler_add,
2094 E_EVENT_CLIENT_SHOW,
2095 _launcher_handler_cb_event_client_show, NULL);
2097 LAUNCHER_HANDLER_CB_ADD(laundler->hdlrs_ev,
2098 ecore_event_handler_add,
2099 E_EVENT_CLIENT_VISIBILITY_CHANGE,
2100 _launcher_handler_cb_event_client_visibility_change, NULL);
2102 ELOGF("LAUNCHER_SRV", "new launcher handler(%p) created", NULL, laundler);
2108 _launcher_handler_destroy(E_Service_Launcher_Handler *laundler)
2110 EINA_SAFETY_ON_NULL_RETURN(laundler);
2112 E_FREE_LIST(laundler->hdlrs_ev, ecore_event_handler_del);
2113 E_FREE_LIST(laundler->hooks_appinfo, e_appinfo_hook_del);
2114 E_FREE_LIST(laundler->hooks_co, e_comp_object_intercept_hook_del);
2115 E_FREE_LIST(laundler->hooks_ec, e_client_hook_del);
2116 E_FREE_LIST(laundler->hooks_vis, e_policy_visibility_hook_del);
2118 E_FREE_FUNC(laundler->launcher_hash, eina_hash_free);
2123 e_service_launcher_resource_set(E_Client *ec, struct wl_resource *res_tws_lc)
2125 E_Service_Launcher *lc;
2127 EINA_SAFETY_ON_NULL_RETURN(ec);
2128 EINA_SAFETY_ON_NULL_RETURN(res_tws_lc);
2130 lc = _launcher_handler_launcher_find(ec);
2131 EINA_SAFETY_ON_NULL_RETURN(lc);
2132 EINA_SAFETY_ON_TRUE_RETURN(lc->ec != ec);
2135 _launcher_data_reset(lc);
2137 lc->res = res_tws_lc;
2138 wl_resource_set_implementation(res_tws_lc,
2139 &_launcher_iface, lc,
2140 _launcher_cb_resource_destroy);
2144 e_service_launcher_client_set(E_Client *ec)
2146 E_Service_Launcher *lc = NULL;
2148 EINA_SAFETY_ON_NULL_RETURN(ec);
2149 EINA_SAFETY_ON_TRUE_RETURN(e_object_is_del(E_OBJECT(ec)));
2151 if ((lc = _launcher_handler_launcher_find(ec)))
2153 ELOGF("LAUNCHER_SRV", "ec(%p) is already set as launcher(%p)",
2160 _laundler = _launcher_handler_create();
2161 EINA_SAFETY_ON_NULL_RETURN(_laundler);
2164 lc = E_NEW(E_Service_Launcher, 1);
2165 EINA_SAFETY_ON_NULL_RETURN(lc);
2168 if (!_launcher_handler_launcher_add(lc))
2171 ELOGF("LAUNCHER_SRV", "Fail to add launcher", ec);
2175 ELOGF("LAUNCHER_SRV", "client set|Created New Launcher(%p)", ec, lc);
2176 _launcher_state_set(lc, LAUNCHER_STATE_IDLE);
2182 e_service_launcher_client_unset(E_Client *ec)
2184 E_Service_Launcher *lc;
2186 EINA_SAFETY_ON_NULL_RETURN(ec);
2188 lc = _launcher_handler_launcher_find(ec);
2189 EINA_SAFETY_ON_NULL_RETURN(lc);
2191 _launcher_handler_launcher_del(lc);
2192 _launcher_data_reset(lc);
2195 ELOGF("LAUNCHER_SRV", "client unset", ec);
2197 if ((_laundler) && (_laundler->launcher_count == 0))
2199 ELOGF("LAUNCHER_SRV", "No launcher available, Destroy Launcher Handler(%p)",
2202 _launcher_handler_destroy(_laundler);
2208 e_service_launcher_prepare_send_with_shared_widget_info(E_Client *target_ec,
2209 const char *shared_widget_info,
2213 E_Service_Launcher *lc = NULL;
2216 Eina_Iterator *hash_iter;
2217 Eina_Bool found = EINA_FALSE;
2219 EINA_SAFETY_ON_NULL_RETURN(_laundler);
2221 /* look for launcher service object which has given target_ec */
2222 hash_iter = eina_hash_iterator_data_new(_laundler->launcher_hash);
2223 EINA_ITERATOR_FOREACH(hash_iter, lc)
2225 if (lc->target.ec != target_ec) continue;
2226 if (lc->serial != serial) continue;
2230 eina_iterator_free(hash_iter);
2232 EINA_SAFETY_ON_FALSE_RETURN(found);
2233 EINA_SAFETY_ON_NULL_RETURN(lc);
2235 ELOGF("LAUNCHER_SRV", "SWL | callee(%p) cb(PREPARE_DONE(%d))",
2236 lc->ec, target_ec, state);
2238 if (state == TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE)
2240 e_client_pos_get(target_ec, &x, &y);
2242 sent = _launcher_prepare_send(lc, target_ec, x, y, shared_widget_info);
2243 EINA_SAFETY_ON_FALSE_GOTO(sent, error);
2245 _launcher_state_set(lc, LAUNCHER_STATE_PREPARING);
2247 else if (state == TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW)
2249 if (!lc->buff_attach)
2251 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
2252 _launcher_post_forward(lc, EINA_TRUE);
2253 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
2254 _launcher_post_backward(lc, EINA_TRUE);
2256 _launcher_handler_launcher_runner_unset(lc);
2257 _launcher_handler_launcher_pre_runner_set(lc);
2258 _launcher_state_set(lc, LAUNCHER_STATE_DONE);
2261 lc->swl_done = EINA_TRUE;
2263 ELOGF("LAUNCHER_SRV", "SWL | send CLEANUP", lc->ec);
2264 tws_service_launcher_send_cleanup(lc->res,
2271 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:FORWARD)", lc->ec);
2272 _launcher_post_forward(lc, EINA_FALSE);
2276 e_service_launcher_release_shared_widget_launch(E_Client *ec)
2278 E_Service_Launcher *runner;
2280 EINA_SAFETY_ON_NULL_RETURN(ec);
2282 runner = _launcher_handler_launcher_runner_get();
2283 EINA_SAFETY_ON_NULL_RETURN(runner);
2285 ELOGF("LAUNCHER_SRV", "Released tzsh_swl", ec);
2287 if ((runner) && (runner->target.ec == ec))
2289 if (runner->with_swl)
2291 //callee is gone before replying prepare_done
2292 if (runner->state == LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE)
2294 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
2295 _launcher_post_forward(runner, EINA_FALSE);
2296 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
2297 _launcher_post_backward(runner, EINA_FALSE);
2299 _launcher_state_set(runner, LAUNCHER_STATE_IDLE);
2300 _launcher_launched_ec_set(runner, NULL);
2302 _launcher_handler_launcher_runner_unset(runner);
2303 _launcher_handler_launcher_pre_runner_unset(runner);
2305 runner->direction = 0;
2306 runner->with_swl = 0;
2313 e_service_launcher_callee_register(E_Client *callee, const char *appid, const char *splash_path, const char *splash_group)
2315 E_Service_Launcher *runner;
2317 EINA_SAFETY_ON_NULL_RETURN(callee);
2319 runner = _launcher_handler_launcher_runner_get();
2320 EINA_SAFETY_ON_NULL_RETURN(runner);
2321 EINA_SAFETY_ON_TRUE_RETURN(runner->state != LAUNCHER_STATE_MONITORING);
2323 if (runner->target.appid)
2325 if (!e_util_strcmp(appid, runner->target.appid))
2327 runner->target.ec = callee;
2328 runner->target.splash_path = eina_stringshare_add(splash_path);
2329 runner->target.splash_group = eina_stringshare_add(splash_group);
2331 ELOGF("LAUNCHER_SRV", "Register callee(%p) by appid(%s)",
2332 runner->ec, runner->target.ec, runner->target.appid);