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"
7 #include <tzsh_server.h>
8 #include <wayland-tbm-server.h>
10 typedef struct _E_Service_Launcher E_Service_Launcher;
11 typedef struct _E_Service_Launcher_Handler E_Service_Launcher_Handler;
12 typedef struct _E_Service_Launcher_Consumer E_Service_Launcher_Consumer;
17 LAUNCHER_STATE_MONITORING,
18 LAUNCHER_STATE_PREPARING,
19 LAUNCHER_STATE_LAUNCHING,
20 LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER,
22 LAUNCHER_STATE_CANCELED,
23 LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE,
26 struct _E_Service_Launcher_Consumer
28 E_Service_Launcher *lc;
29 E_Vis_Grab *vis_grab; //grab of client's visibility
32 E_Object_Delfn *delfn; //del callback of E_Client
34 Ecore_Event_Handler *buff_attach; //event handler for BUFFER_CHANGE
35 int buff_attach_count;
38 struct _E_Service_Launcher
40 Launcher_State state; //current state of launcher
42 struct wl_resource *res; //tizen_window_transition_launcher resource
43 E_Client *ec; //launcher E_Client
45 E_Vis_Grab *vis_grab; //grab of launcher visibility
46 uint32_t serial; //identifier
47 enum tws_service_launcher_direction direction; //direction of transition
51 E_Client *ec; //target E_Client
53 const char *appid; //appid
54 E_Vis_Grab *vis_grab; //grab of target client's visibility
56 Eina_Bool delay_del; //refered delay_del
57 E_Object_Delfn *delfn; //del callback of target E_Client
59 const char *splash_path; //path of file for splash
60 const char *splash_group; //group name for splash
61 } target; //target window information for transition
63 E_Client *launched_ec; //E_Client was launched by launcher
64 E_Object_Delfn *launched_delfn; //del callback of launched_ec
66 Ecore_Event_Handler *buff_attach; //event handler for BUFFER_CHANGE
68 Eina_Bool with_swl; //it's for shared widget launch
69 Eina_Bool swl_done; //flag indicating done of callee
71 Eina_Bool block_input; //input is blocked(1) or not(0) while running client side animation
73 Eina_List *consumers; //list launcher consumer of launcher ec
76 struct _E_Service_Launcher_Handler
78 Eina_Hash *launcher_hash; //hash key:launcher_ec, data:E_Service_Launcher
79 unsigned int launcher_count; //count of launcher object
81 Eina_List *hooks_ec; //hook list for E_CLIENT_HOOK_*
82 Eina_List *hooks_vis; //hook list for E_POL_VIS_HOOK_TYPE_*
83 Eina_List *hooks_co; //hook list for E_COMP_OBJECT_INTERCEPT_HOOK_*
84 Eina_List *hooks_appinfo; //hook list for E_APPINFO_HOOK_*
85 Eina_List *hdlrs_ev; //handler list for ecore event
87 E_Service_Launcher *runner; //current runner(running launcher)
88 E_Service_Launcher *pre_runner; //previous runner
91 ////////////////////////////////////////////////////////////////////
92 static E_Service_Launcher_Handler *_laundler = NULL;
94 static void _launcher_launched_ec_set(E_Service_Launcher *lc, E_Client *launched_ec);
95 static void _launcher_target_ec_set(E_Service_Launcher *lc, E_Client *target_ec);
97 static E_Service_Launcher *_launcher_handler_launcher_find(E_Client *ec);
98 static Eina_Bool _launcher_handler_launcher_add(E_Service_Launcher *lc);
99 static Eina_Bool _launcher_handler_launcher_del(E_Service_Launcher *lc);
101 static E_Service_Launcher *_launcher_handler_launcher_runner_get(void);
102 static void _launcher_handler_launcher_runner_set(E_Service_Launcher *lc);
103 static void _launcher_handler_launcher_runner_unset(E_Service_Launcher *lc);
104 static E_Service_Launcher *_launcher_handler_launcher_pre_runner_get(void);
105 static void _launcher_handler_launcher_pre_runner_set(E_Service_Launcher *lc);
106 static void _launcher_handler_launcher_pre_runner_unset(E_Service_Launcher *lc);
108 ////////////////////////////////////////////////////////////////////
110 _launcher_clients_find_by_pid(pid_t pid)
113 Eina_List *clients = NULL, *l;
115 EINA_LIST_FOREACH(e_comp->clients, l, ec)
117 if (e_object_is_del(E_OBJECT(ec))) continue;
118 if (ec->netwm.pid != pid) continue;
119 clients = eina_list_append(clients, ec);
127 _launcher_cb_input_block_expired(void *data)
129 E_Service_Launcher *lc = (E_Service_Launcher*)data;
130 EINA_SAFETY_ON_NULL_RETURN(lc);
132 lc->block_input = EINA_FALSE;
134 ELOGF("LAUNCHER_SRV", "Input block EXPIRED", lc->ec);
138 _launcher_input_block_set(E_Service_Launcher *lc, Eina_Bool set)
140 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
144 //request for block all input
145 lc->block_input = e_devicemgr_block_internal_add(ECORE_DEVICE_CLASS_NONE,
147 (uint32_t)(e_policy_visibility_timeout_get() * 1000),
148 _launcher_cb_input_block_expired, lc);
149 return lc->block_input;
153 return e_devicemgr_block_internal_remove(_launcher_cb_input_block_expired, lc);
158 _launcher_state_to_str(Launcher_State state)
162 case LAUNCHER_STATE_IDLE:
164 case LAUNCHER_STATE_MONITORING:
165 return "PID_MONITORING";
166 case LAUNCHER_STATE_PREPARING:
168 case LAUNCHER_STATE_LAUNCHING:
170 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER:
171 return "LAUNCHING_BUT_WAITING_BUFFER";
172 case LAUNCHER_STATE_DONE:
173 return "LAUNCH_DONE";
174 case LAUNCHER_STATE_CANCELED:
175 return "LAUNCH_CANCELED";
176 case LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE:
177 return "WAIT_FOR_RESPONSE_FROM_CALLEE";
183 _launcher_state_set(E_Service_Launcher *lc,
184 Launcher_State state)
186 EINA_SAFETY_ON_NULL_RETURN(lc);
188 if (state == lc->state) return;
190 ELOGF("LAUNCHER_SRV", "Set state %s --> %s",
192 _launcher_state_to_str(lc->state),
193 _launcher_state_to_str(state));
199 _launcher_consumer_del(E_Service_Launcher_Consumer *consumer)
201 E_Service_Launcher *lc;
203 EINA_SAFETY_ON_NULL_RETURN(consumer);
207 ELOGF("LAUNCHER_SRV", "Del launcher_consumer ec:%p", lc ? lc->ec : NULL, consumer->ec);
211 e_object_delfn_del(E_OBJECT(consumer->ec), consumer->delfn);
213 consumer->delfn = NULL;
216 if (consumer->vis_grab)
218 e_policy_visibility_client_grab_release(consumer->vis_grab);
219 consumer->vis_grab = NULL;
222 if (consumer->buff_attach)
223 E_FREE_FUNC(consumer->buff_attach, ecore_event_handler_del);
226 lc->consumers = eina_list_remove(lc->consumers, consumer);
232 _launcher_cb_consumer_ec_del(void *data, void *obj)
234 E_Service_Launcher_Consumer *consumer;
237 ec = (E_Client *)obj;
238 EINA_SAFETY_ON_NULL_RETURN(ec);
240 consumer= (E_Service_Launcher_Consumer *)data;
241 EINA_SAFETY_ON_NULL_RETURN(consumer);
242 EINA_SAFETY_ON_TRUE_RETURN(consumer->ec != ec);
245 consumer->delfn = NULL;
247 _launcher_consumer_del(consumer);
250 static E_Service_Launcher_Consumer *
251 _launcher_consumer_create(E_Service_Launcher *lc, E_Client *ec)
253 E_Service_Launcher_Consumer *consumer;
255 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, NULL);
256 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
258 consumer = E_NEW(E_Service_Launcher_Consumer, 1);
259 EINA_SAFETY_ON_NULL_RETURN_VAL(consumer, NULL);
262 consumer->delfn = e_object_delfn_add(E_OBJECT(ec),
263 _launcher_cb_consumer_ec_del, consumer);
266 lc->consumers = eina_list_append(lc->consumers, consumer);
268 ELOGF("LAUNCHER_SRV", "Create launcher_consumer ec:%p", lc->ec, ec);
274 _launcher_consumers_reset(E_Service_Launcher *lc)
276 E_Service_Launcher_Consumer *consumer;
279 EINA_SAFETY_ON_NULL_RETURN(lc);
281 EINA_LIST_FOREACH_SAFE(lc->consumers, l, ll, consumer)
282 _launcher_consumer_del(consumer);
286 _launcher_post_forward(E_Service_Launcher *lc, Eina_Bool success)
288 E_Client *target_ec = NULL;
290 if ((lc->target.ec) && (!e_object_is_del(E_OBJECT(lc->target.ec))))
291 target_ec = lc->target.ec;
293 _launcher_target_ec_set(lc, NULL);
298 E_FREE_FUNC(lc->target.appid, eina_stringshare_del);
299 E_FREE_FUNC(lc->target.splash_path, eina_stringshare_del);
300 E_FREE_FUNC(lc->target.splash_group, eina_stringshare_del);
301 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
303 //if forward animation is failed, enlightenment can run animation instead.
304 if ((!success) && (target_ec))
305 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
307 if (!_launcher_input_block_set(lc, EINA_FALSE))
308 ELOGF("LAUNCHER_SRV", "Input block remove FAIL...", lc->ec);
311 e_policy_visibility_client_grab_release(lc->vis_grab);
312 if (lc->target.vis_grab)
313 e_policy_visibility_client_grab_release(lc->target.vis_grab);
316 lc->target.vis_grab = NULL;
318 if (!target_ec) return;
321 _launcher_launched_ec_set(lc, target_ec);
324 e_comp_object_damage(target_ec->frame, 0, 0, target_ec->w, target_ec->h);
325 e_comp_object_dirty(target_ec->frame);
326 e_comp_object_render(target_ec->frame);
327 evas_object_show(target_ec->frame);
329 e_comp_client_override_del(target_ec);
333 _launcher_post_backward(E_Service_Launcher *lc, Eina_Bool success)
335 E_Client *target_ec = NULL;
337 target_ec = lc->target.ec;
338 _launcher_target_ec_set(lc, NULL);
344 E_FREE_FUNC(lc->target.appid, eina_stringshare_del);
345 E_FREE_FUNC(lc->target.splash_path, eina_stringshare_del);
346 E_FREE_FUNC(lc->target.splash_group, eina_stringshare_del);
347 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
352 is_del = e_object_is_del(E_OBJECT(target_ec));
353 if (lc->target.delay_del)
354 e_object_delay_del_unref(E_OBJECT(target_ec));
359 lc->target.delay_del = EINA_FALSE;
361 //if forward animation is failed, enlightenment can run animation instead.
362 if ((!success) && (target_ec))
363 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
365 if (!_launcher_input_block_set(lc, EINA_FALSE))
366 ELOGF("LAUNCHER_SRV", "Input block remove FAIL...", lc->ec);
369 e_policy_visibility_client_grab_release(lc->vis_grab);
370 if (lc->target.vis_grab)
371 e_policy_visibility_client_grab_release(lc->target.vis_grab);
374 lc->target.vis_grab = NULL;
376 _launcher_consumers_reset(lc);
378 if (!target_ec) return;
381 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
383 e_comp_client_override_del(target_ec);
387 _launcher_stop_send(E_Service_Launcher *lc)
389 EINA_SAFETY_ON_NULL_RETURN(lc);
391 ELOGF("LAUNCHER_SRV", "Send STOP event(%d) target(ec:%p)",
392 lc->ec, lc->serial, lc->target.ec);
394 tws_service_launcher_send_stop(lc->res, lc->serial);
398 _launcher_prepare_send(E_Service_Launcher *lc,
401 const char *shared_widget_info)
405 E_Comp_Object_Content_Type content_type = 0;
406 enum tws_service_launcher_target_type target_type = 0;
407 const char *target_path = NULL, *target_group = NULL;
408 Evas_Object *content = NULL;
409 struct wl_array info_array;
415 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
416 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
418 wl_array_init(&info_array);
419 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
421 content_type = e_comp_object_content_type_get(target_ec->frame);
422 switch (content_type)
424 case E_COMP_OBJECT_CONTENT_TYPE_EXT_IMAGE:
425 content = e_comp_object_content_get(target_ec->frame);
426 EINA_SAFETY_ON_NULL_GOTO(content, fail);
428 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_IMAGE;
429 evas_object_image_file_get(content, &target_path, NULL);
430 EINA_SAFETY_ON_NULL_GOTO(target_path, fail);
432 len = strlen(target_path) + 1;
433 p_char = wl_array_add(&info_array, len);
434 EINA_SAFETY_ON_NULL_GOTO(p_char, fail);
436 strncpy(p_char, target_path, len);
438 case E_COMP_OBJECT_CONTENT_TYPE_EXT_EDJE:
439 content = e_comp_object_content_get(target_ec->frame);
440 EINA_SAFETY_ON_NULL_GOTO(content, fail);
442 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_EDJE;
443 target_path = lc->target.splash_path;
444 target_group = lc->target.splash_group;
445 if ((!target_path) || (!target_group))
446 edje_object_file_get(content, &target_path, &target_group);
447 EINA_SAFETY_ON_NULL_GOTO(target_path, fail);
448 EINA_SAFETY_ON_NULL_GOTO(target_group, fail);
450 len = strlen(target_path) + 1;
451 p_char = wl_array_add(&info_array, len);
452 EINA_SAFETY_ON_NULL_GOTO(p_char, fail);
454 strncpy(p_char, target_path, len);
456 len = strlen(target_group) + 1;
457 p_char = wl_array_add(&info_array, len);
458 EINA_SAFETY_ON_NULL_GOTO(p_char, fail);
460 strncpy(p_char, target_group, len);
464 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_REMOTE_SURFACE;
465 res_id = e_pixmap_res_id_get(target_ec->pixmap);
467 p_u32 = wl_array_add(&info_array, sizeof(uint32_t));
468 EINA_SAFETY_ON_NULL_GOTO(p_u32, fail);
475 target_type = TWS_SERVICE_LAUNCHER_TARGET_TYPE_REMOTE_SURFACE;
476 res_id = e_pixmap_res_id_get(target_ec->pixmap);
478 p_u32 = wl_array_add(&info_array, sizeof(uint32_t));
479 EINA_SAFETY_ON_NULL_GOTO(p_u32, fail);
485 ELOGF("LAUNCHER_SRV", "Send PREPARE event(%d) direction:%s target(ec:%p type:%d res:%d path:%s pos(%d,%d) widget:%s)",
486 lc->ec, lc->serial, lc->direction?"BACKWARD":"FORWARD", target_ec, target_type, res_id, target_path?:"N/A", x, y, shared_widget_info);
488 tws_service_launcher_send_prepare(lc->res,
493 shared_widget_info ? shared_widget_info : "None",
496 wl_array_release(&info_array);
499 wl_array_release(&info_array);
504 _launcher_prepare_shared_widget_forward_send(E_Service_Launcher *lc,
507 Eina_Bool sent = EINA_FALSE;
509 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
510 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
511 if(e_object_is_del(E_OBJECT(target_ec))) return EINA_FALSE;
513 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
514 e_comp_client_override_add(target_ec);
516 // grab uniconify job of target_ec
517 if (target_ec->iconic)
519 lc->target.vis_grab =
520 e_policy_visibility_client_filtered_grab_get
522 (E_VIS_JOB_TYPE_UNICONIFY | E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY),
526 if (!_launcher_input_block_set(lc, EINA_TRUE))
527 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
529 _launcher_launched_ec_set(lc, NULL);
530 _launcher_target_ec_set(lc, target_ec);
532 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD;
534 sent = e_tzsh_shared_widget_launch_prepare_send(target_ec,
535 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE,
539 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:FORWARD)", lc->ec);
540 _launcher_post_forward(lc, EINA_FALSE);
547 _launcher_prepare_shared_widget_backward_send(E_Service_Launcher *lc,
550 E_Vis_Job_Type job_type)
552 Eina_Bool sent = EINA_FALSE;
554 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
555 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
556 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
558 if (e_object_is_del(E_OBJECT(target_ec)))
560 if (lc->with_swl) return EINA_FALSE;
561 // do nothing if ec is deleted and there's no delay_del_ref as well.
562 if (!e_object_delay_del_ref_get(E_OBJECT(target_ec)))
566 e_object_delay_del_ref(E_OBJECT(target_ec));
567 lc->target.delay_del = EINA_TRUE;
569 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
570 e_comp_client_override_add(target_ec);
572 if (activity == target_ec)
574 lc->vis_grab = e_policy_visibility_client_filtered_grab_get(lc->ec, job_type, __func__);
575 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, E_VIS_JOB_TYPE_ALL, __func__);
579 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, job_type, __func__);
582 if (!_launcher_input_block_set(lc, EINA_TRUE))
583 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
585 _launcher_launched_ec_set(lc, NULL);
586 _launcher_target_ec_set(lc, target_ec);
588 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD;
589 lc->serial = wl_display_next_serial(e_comp_wl->wl.disp);
591 sent = e_tzsh_shared_widget_launch_prepare_send(target_ec,
592 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE,
595 // fail to send protocol event
598 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:BACKWARD)", lc->ec);
599 _launcher_post_backward(lc, EINA_FALSE);
606 _launcher_prepare_forward_send(E_Service_Launcher *lc,
609 Eina_Bool sent = EINA_FALSE;
612 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
613 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
615 if(e_object_is_del(E_OBJECT(target_ec))) return EINA_FALSE;
617 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
618 e_comp_client_override_add(target_ec);
620 //grab uniconify job of target_ec
621 if (target_ec->iconic)
622 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec,
623 (E_VIS_JOB_TYPE_UNICONIFY |
624 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY),
627 if (!_launcher_input_block_set(lc, EINA_TRUE))
628 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
630 _launcher_launched_ec_set(lc, NULL);
631 _launcher_target_ec_set(lc, target_ec);
633 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD;
634 e_client_pos_get(target_ec, &x, &y);
636 sent = _launcher_prepare_send(lc, target_ec, x, y, NULL);
638 //fail to send protocol event
641 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:FORWARD)", lc->ec);
642 _launcher_post_forward(lc, EINA_FALSE);
649 _launcher_prepare_backward_send(E_Service_Launcher *lc,
652 E_Vis_Job_Type job_type)
655 Eina_Bool sent = EINA_FALSE;
656 Eina_List *consumers;
659 E_Service_Launcher_Consumer *consumer;
661 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
662 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
663 EINA_SAFETY_ON_NULL_RETURN_VAL(target_ec, EINA_FALSE);
665 if (e_object_is_del(E_OBJECT(target_ec)))
667 //can't do nothing if ec is deleted and there's no delay_del_ref as well.
668 if (!e_object_delay_del_ref_get(E_OBJECT(target_ec)))
672 e_object_delay_del_ref(E_OBJECT(target_ec));
673 lc->target.delay_del = EINA_TRUE;
675 e_policy_animatable_lock(target_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 1);
676 e_comp_client_override_add(target_ec);
678 if ((lc->ec) && (lc->ec->remote_surface.provider))
680 consumers = e_comp_wl_remote_surface_consumers_get(lc->ec);
681 EINA_LIST_FOREACH(consumers, l, ec)
683 if (e_object_is_del(E_OBJECT(ec))) continue;
684 if (!e_policy_visibility_client_is_uniconify_render_running(ec)) continue;
686 consumer = _launcher_consumer_create(lc, ec);
687 consumer->vis_grab = e_policy_visibility_client_filtered_grab_get(ec,
688 (E_VIS_JOB_TYPE_UNICONIFY |
689 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY),
692 eina_list_free(consumers);
695 if (activity == target_ec)
697 lc->vis_grab = e_policy_visibility_client_filtered_grab_get(lc->ec, job_type, __func__);
698 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, E_VIS_JOB_TYPE_ALL, __func__);
702 lc->target.vis_grab = e_policy_visibility_client_filtered_grab_get(target_ec, job_type, __func__);
705 if (!_launcher_input_block_set(lc, EINA_TRUE))
706 ELOGF("LAUNCHER_SRV", "Input block add FAIL...", lc->ec);
708 _launcher_launched_ec_set(lc, NULL);
709 _launcher_target_ec_set(lc, target_ec);
711 lc->serial = wl_display_next_serial(e_comp_wl->wl.disp);
712 lc->direction = TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD;
713 e_client_pos_get(target_ec, &x, &y);
715 sent = _launcher_prepare_send(lc, target_ec, x, y, NULL);
717 //fail to send protocol event
720 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:BACKWARD)", lc->ec);
721 _launcher_post_backward(lc, EINA_FALSE);
729 _launcher_data_reset(E_Service_Launcher *lc)
731 EINA_SAFETY_ON_NULL_RETURN(lc);
733 ELOGF("LAUNCHER_SRV", "Reset Launcher Data", lc->ec);
735 //clear resource and send 'DISQUALIFIED' msg
738 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_DISQUALIFIED, lc->serial);
739 wl_resource_set_user_data(lc->res, NULL);
743 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
744 _launcher_post_forward(lc, EINA_FALSE);
745 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
746 _launcher_post_backward(lc, EINA_FALSE);
748 _launcher_state_set(lc, LAUNCHER_STATE_IDLE);
749 _launcher_launched_ec_set(lc, NULL);
750 _launcher_consumers_reset(lc);
752 _launcher_handler_launcher_runner_unset(lc);
753 _launcher_handler_launcher_pre_runner_unset(lc);
760 _launcher_cb_done_buff_attach(void *data, int type EINA_UNUSED, void *event)
762 E_Service_Launcher *lc;
766 lc = (E_Service_Launcher*)data;
767 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, ECORE_CALLBACK_PASS_ON);
768 if (!lc->with_swl) goto clean;
769 if (lc->direction != TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD) goto clean;
771 ev = (E_Event_Client *)event;
772 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
773 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
776 if (ec != lc->target.ec) return ECORE_CALLBACK_PASS_ON;
777 if (!lc->swl_done) goto clean;
779 ELOGF("LAUNCHER_SRV", "Event cb(BUFFER_CHANGE) for LAUNCH_DONE", ec);
781 lc->swl_done = EINA_FALSE;
783 _launcher_post_forward(lc, EINA_TRUE);
785 _launcher_handler_launcher_runner_unset(lc);
786 _launcher_handler_launcher_pre_runner_set(lc);
787 _launcher_state_set(lc, LAUNCHER_STATE_DONE);
790 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
792 return ECORE_CALLBACK_DONE;
796 _launcher_cb_launching_consumer_buff_attach(void *data, int type EINA_UNUSED, void *event)
798 E_Service_Launcher *lc;
799 E_Service_Launcher_Consumer *consumer;
803 consumer = (E_Service_Launcher_Consumer*)data;
804 EINA_SAFETY_ON_NULL_RETURN_VAL(consumer, ECORE_CALLBACK_PASS_ON);
806 EINA_SAFETY_ON_NULL_GOTO(lc, clean);
807 EINA_SAFETY_ON_FALSE_GOTO(lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD, clean);
809 ev = (E_Event_Client *)event;
810 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
811 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
814 if (ec != consumer->ec) return ECORE_CALLBACK_PASS_ON;
816 ELOGF("LAUNCHER_SRV", "Event cb(BUFFER_CHANGE) for WAIT_CONSUMER_LAUNCHING count:%d",
817 ec, consumer->buff_attach_count);
819 consumer->buff_attach_count++;
820 if (consumer->buff_attach_count < 2) return ECORE_CALLBACK_PASS_ON;
822 if (consumer->vis_grab)
824 e_policy_visibility_client_grab_release(consumer->vis_grab);
825 consumer->vis_grab = NULL;
829 _launcher_consumer_del(consumer);
831 return ECORE_CALLBACK_PASS_ON;
835 _launcher_consumers_buffer_change_wait(E_Service_Launcher *lc)
837 E_Service_Launcher_Consumer *consumer;
840 EINA_LIST_FOREACH(lc->consumers, l, consumer)
841 consumer->buff_attach = ecore_event_handler_add(E_EVENT_CLIENT_BUFFER_CHANGE,
842 _launcher_cb_launching_consumer_buff_attach,
847 _launcher_cb_launching_buff_attach(void *data, int type EINA_UNUSED, void *event)
849 E_Service_Launcher *lc;
853 lc = (E_Service_Launcher*)data;
854 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, ECORE_CALLBACK_PASS_ON);
855 if (lc->direction != TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD) goto clean;
857 ev = (E_Event_Client *)event;
858 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
859 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
862 if (ec != lc->ec) return ECORE_CALLBACK_PASS_ON;
864 ELOGF("LAUNCHER_SRV", "Event cb(BUFFER_CHANGE) for LAUNCHING", ec);
866 if (lc->state == LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER)
868 _launcher_consumers_buffer_change_wait(lc);
869 _launcher_state_set(lc, LAUNCHER_STATE_LAUNCHING);
874 e_policy_visibility_client_grab_release(lc->vis_grab);
878 if (lc->target.vis_grab)
880 e_policy_visibility_client_grab_release(lc->target.vis_grab);
881 lc->target.vis_grab = NULL;
885 E_FREE_FUNC(lc->buff_attach, ecore_event_handler_del);
887 return ECORE_CALLBACK_PASS_ON;
891 _launcher_buffer_change_wait(E_Service_Launcher *lc)
894 if (lc->buff_attach) return;
896 if (lc->state == LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER)
897 lc->buff_attach = ecore_event_handler_add(E_EVENT_CLIENT_BUFFER_CHANGE,
898 _launcher_cb_launching_buff_attach,
900 else if ((lc->with_swl) && (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD))
901 lc->buff_attach = ecore_event_handler_add(E_EVENT_CLIENT_BUFFER_CHANGE,
902 _launcher_cb_done_buff_attach,
908 _launcher_cb_launched_ec_del(void *data, void *obj)
910 E_Service_Launcher *lc = (E_Service_Launcher *)data;
911 E_Client *launched_ec = (E_Client *)obj;
913 EINA_SAFETY_ON_NULL_RETURN(launched_ec);
914 EINA_SAFETY_ON_NULL_RETURN(lc);
915 EINA_SAFETY_ON_TRUE_RETURN(lc->launched_ec != launched_ec);
917 lc->launched_ec = NULL;
918 lc->launched_delfn = NULL;
922 _launcher_cb_target_ec_del(void *data, void *obj)
924 E_Service_Launcher *lc = (E_Service_Launcher *)data;
925 E_Client *target_ec = (E_Client *)obj;
927 EINA_SAFETY_ON_NULL_RETURN(target_ec);
928 EINA_SAFETY_ON_NULL_RETURN(lc);
929 EINA_SAFETY_ON_TRUE_RETURN(lc->target.ec != target_ec);
931 lc->target.ec = NULL;
932 lc->target.delfn = NULL;
936 case LAUNCHER_STATE_PREPARING:
937 case LAUNCHER_STATE_LAUNCHING:
938 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER:
939 _launcher_stop_send(lc);
940 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
941 _launcher_post_forward(lc, EINA_FALSE);
942 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
943 _launcher_post_backward(lc, EINA_FALSE);
945 _launcher_handler_launcher_runner_unset(lc);
946 _launcher_handler_launcher_pre_runner_unset(lc);
948 _launcher_state_set(lc, LAUNCHER_STATE_IDLE);
956 _launcher_launched_ec_set(E_Service_Launcher *lc, E_Client *launched_ec)
958 EINA_SAFETY_ON_NULL_RETURN(lc);
959 if (lc->launched_ec == launched_ec) return;
963 e_object_delfn_del(E_OBJECT(lc->launched_ec), lc->launched_delfn);
964 lc->launched_ec = NULL;
965 lc->launched_delfn = NULL;
970 lc->launched_ec = launched_ec;
971 lc->launched_delfn = e_object_delfn_add(E_OBJECT(launched_ec),
972 _launcher_cb_launched_ec_del, lc);
977 _launcher_target_ec_set(E_Service_Launcher *lc, E_Client *target_ec)
979 EINA_SAFETY_ON_NULL_RETURN(lc);
980 if (lc->target.ec == target_ec) return;
984 e_object_delfn_del(E_OBJECT(lc->target.ec), lc->target.delfn);
985 lc->target.ec = NULL;
986 lc->target.delfn = NULL;
991 lc->target.ec = target_ec;
992 lc->target.delfn = e_object_delfn_add(E_OBJECT(target_ec),
993 _launcher_cb_target_ec_del, lc);
998 _launcher_cb_resource_destroy(struct wl_resource *res_tws_lc)
1000 E_Service_Launcher *lc;
1002 lc = wl_resource_get_user_data(res_tws_lc);
1005 ELOGF("LAUNCHER_SRV", "Start Resource Destroy tws_service_launcher", lc->ec);
1007 _launcher_handler_launcher_del(lc);
1010 _launcher_data_reset(lc);
1014 ELOGF("LAUNCHER_SRV", "End Resource Destroy tws_service_launcher", NULL);
1018 _launcher_cb_destroy(struct wl_client *client EINA_UNUSED,
1019 struct wl_resource *res_tws_lc)
1021 ELOGF("LAUNCHER_SRV", "Received request(launcher_destroy)", NULL);
1022 wl_resource_destroy(res_tws_lc);
1026 _launcher_cb_launch(struct wl_client *client EINA_UNUSED,
1027 struct wl_resource *res_tws_lc,
1029 const char *instance_id,
1033 E_Service_Launcher *lc;
1034 E_Service_Launcher *runner, *pre_runner;
1035 E_Client *target_ec;
1037 Eina_Bool sent = EINA_FALSE;
1039 lc = wl_resource_get_user_data(res_tws_lc);
1040 EINA_SAFETY_ON_NULL_RETURN(lc);
1041 EINA_SAFETY_ON_NULL_RETURN(lc->ec);
1043 ELOGF("LAUNCHER_SRV",
1044 "Recieved request(launcher_launch) appid:%s instance id:%s pid:%d",
1045 lc->ec, app_id?:"NONE", instance_id?:"NONE", pid);
1047 EINA_SAFETY_ON_TRUE_GOTO(lc->ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED, send_stop);
1048 EINA_SAFETY_ON_TRUE_GOTO((pid < 0) && !(app_id) , send_stop);
1050 //check current state of lc
1051 runner = _launcher_handler_launcher_runner_get();
1054 ELOGF("LAUNCHER_SRV",
1055 "Launcher(%s) requests LAUNCH again without cancel, ignore this.",
1056 lc->ec, _launcher_state_to_str(lc->state));
1058 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1062 pre_runner = _launcher_handler_launcher_pre_runner_get();
1063 if (pre_runner == lc)
1065 _launcher_handler_launcher_pre_runner_set(NULL);
1066 _launcher_launched_ec_set(lc, NULL);
1069 lc->serial = serial;
1070 lc->target.pid = pid;
1074 ecs = _launcher_clients_find_by_pid(pid);
1075 EINA_LIST_FOREACH(ecs, l, target_ec)
1077 if (e_object_is_del(E_OBJECT(target_ec))) continue;
1078 if (e_client_util_ignored_get(target_ec)) continue;
1080 ELOGF("LAUNCHER_SRV", "Found target_ec:%p", lc->ec, target_ec);
1082 sent = _launcher_prepare_forward_send(lc, target_ec);
1083 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1085 _launcher_state_set(lc, LAUNCHER_STATE_PREPARING);
1088 eina_list_free(ecs);
1093 lc->target.appid = eina_stringshare_add(app_id);
1098 ELOGF("LAUNCHER_SRV", "Can't find target_ec, Start Monitoring", lc->ec);
1099 _launcher_state_set(lc, LAUNCHER_STATE_MONITORING);
1102 _launcher_handler_launcher_runner_set(lc);
1107 ELOGF("LAUNCHER_SRV", "can't process request(launcher_launch)", lc->ec);
1108 _launcher_stop_send(lc);
1112 _launcher_cb_launch_with_shared_widget(struct wl_client *client EINA_UNUSED,
1113 struct wl_resource *res_tws_lc,
1115 const char *instance_id,
1119 E_Service_Launcher *lc;
1120 E_Service_Launcher *runner, *pre_runner;
1121 E_Client *target_ec;
1123 Eina_Bool sent = EINA_FALSE;
1125 lc = wl_resource_get_user_data(res_tws_lc);
1126 EINA_SAFETY_ON_NULL_RETURN(lc);
1127 EINA_SAFETY_ON_NULL_RETURN(lc->ec);
1129 ELOGF("LAUNCHER_SRV",
1130 "Recieved request(launcher_launch_with_shared_widget) appid:%s instance id:%s pid:%d",
1131 lc->ec, app_id?:"NONE", instance_id?:"NONE", pid);
1133 EINA_SAFETY_ON_TRUE_GOTO(lc->ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED, send_stop);
1134 EINA_SAFETY_ON_TRUE_GOTO((pid < 0) && !(app_id), send_stop);
1136 // check current state of lc
1137 runner = _launcher_handler_launcher_runner_get();
1140 ELOGF("LAUNCHER_SRV",
1141 "Launcher(%s) requests LAUNCH again without cancel, ignore this.",
1142 lc->ec, _launcher_state_to_str(lc->state));
1144 tws_service_launcher_send_error(lc->res,
1145 TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST,
1150 pre_runner = _launcher_handler_launcher_pre_runner_get();
1151 if (pre_runner == lc)
1153 _launcher_handler_launcher_pre_runner_set(NULL);
1154 _launcher_launched_ec_set(lc, NULL);
1157 lc->with_swl = EINA_TRUE; /* set swl flag */
1158 lc->serial = serial;
1159 lc->target.pid = pid;
1163 ecs = _launcher_clients_find_by_pid(pid);
1164 EINA_LIST_FOREACH(ecs, l, target_ec)
1166 if (e_object_is_del(E_OBJECT(target_ec))) continue;
1167 if (e_client_util_ignored_get(target_ec)) continue;
1169 ELOGF("LAUNCHER_SRV", "Found target_ec:%p", lc->ec, target_ec);
1171 // send prepare_shared_widget event to callee
1172 sent = _launcher_prepare_shared_widget_forward_send(lc, target_ec);
1173 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1175 _launcher_state_set(lc, LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE);
1178 eina_list_free(ecs);
1183 lc->target.appid = eina_stringshare_add(app_id);
1188 ELOGF("LAUNCHER_SRV", "Can't find target_ec, Start Monitoring", lc->ec);
1189 _launcher_state_set(lc, LAUNCHER_STATE_MONITORING);
1192 _launcher_handler_launcher_runner_set(lc);
1197 ELOGF("LAUNCHER_SRV", "can't process request(launcher_launch)", lc->ec);
1198 _launcher_stop_send(lc);
1202 _launcher_cb_launching(struct wl_client *client EINA_UNUSED,
1203 struct wl_resource *res_tws_lc,
1206 E_Service_Launcher *lc;
1207 E_Service_Launcher *runner;
1209 lc = wl_resource_get_user_data(res_tws_lc);
1210 EINA_SAFETY_ON_NULL_RETURN(lc);
1212 ELOGF("LAUNCHER_SRV", "LAUNCHING(%d) %s",
1213 lc->ec, serial, lc->direction?"backward":"forward");
1215 //check current state of lc
1216 runner = _launcher_handler_launcher_runner_get();
1219 ELOGF("LAUNCHER_SRV", "lc(%p) runner(%p), lc is not runner, ignore LAUNCHING",
1220 lc->ec, lc, runner);
1221 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1225 _launcher_state_set(lc, LAUNCHER_STATE_LAUNCHING);
1227 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1229 _launcher_state_set(lc, LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER);
1230 _launcher_buffer_change_wait(lc);
1235 _launcher_target_ec_queue_flush(E_Service_Launcher *lc)
1237 struct wayland_tbm_client_queue *cqueue;
1239 if (!e_comp_wl) return;
1241 if (!lc->target.ec) return;
1242 if (e_object_is_del(E_OBJECT(lc->target.ec))) return;
1244 cqueue = e_comp_wl_tbm_client_queue_get(lc->target.ec);
1246 wayland_tbm_server_client_queue_flush(cqueue);
1250 _launcher_cb_launch_done(struct wl_client *client EINA_UNUSED,
1251 struct wl_resource *res_tws_lc,
1254 E_Service_Launcher *lc;
1255 E_Service_Launcher *runner;
1256 E_Client *target_ec = NULL;
1257 enum tws_service_launcher_direction launch_direction = 0;
1259 lc = wl_resource_get_user_data(res_tws_lc);
1260 EINA_SAFETY_ON_NULL_RETURN(lc);
1262 ELOGF("LAUNCHER_SRV", "LAUNCH_DONE(%d) target:%p", lc->ec, serial, lc->target.ec);
1264 target_ec = lc->target.ec;
1265 launch_direction = lc->direction;
1267 //check current state of lc
1268 runner = _launcher_handler_launcher_runner_get();
1271 ELOGF("LAUNCHER_SRV", "lc(%p) runner(%p), lc is not runner, ignore LAUNCH_DONE",
1272 lc->ec, lc, runner);
1273 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1277 //shared widget launch case
1280 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1284 sent = e_tzsh_shared_widget_launch_prepare_send(lc->target.ec,
1285 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW,
1288 //TODO : handle failure case
1291 _launcher_buffer_change_wait(lc);
1297 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1299 e_tzsh_shared_widget_launch_prepare_send(lc->target.ec,
1300 TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW,
1302 _launcher_post_backward(lc, EINA_TRUE);
1305 else //normal launcher
1307 _launcher_target_ec_queue_flush(lc);
1308 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1309 _launcher_post_forward(lc, EINA_TRUE);
1310 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1311 _launcher_post_backward(lc, EINA_TRUE);
1314 _launcher_handler_launcher_runner_unset(lc);
1315 _launcher_handler_launcher_pre_runner_set(lc);
1316 _launcher_state_set(lc, LAUNCHER_STATE_DONE);
1318 if (launch_direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1320 if (target_ec && !e_object_is_del(E_OBJECT(target_ec)))
1322 if (target_ec->launching == EINA_TRUE)
1324 ELOGF("COMP", "Un-Set launching flag..", target_ec);
1325 target_ec->launching = EINA_FALSE;
1327 if (target_ec->first_mapped)
1329 E_Comp_Wl_Client_Data *target_cdata = e_client_cdata_get(target_ec);
1330 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);
1331 e_comp_object_signal_emit(target_ec->frame, "e,action,launch_real,done", "e");
1333 e_comp_object_signal_emit(target_ec->frame, "e,action,launch,done", "e");
1340 _launcher_cb_launch_cancel(struct wl_client *client EINA_UNUSED,
1341 struct wl_resource *res_tws_lc,
1344 E_Service_Launcher *lc;
1345 E_Service_Launcher *runner;
1347 lc = wl_resource_get_user_data(res_tws_lc);
1348 EINA_SAFETY_ON_NULL_RETURN(lc);
1350 ELOGF("LAUNCHER_SRV", "LAUNCH_CANCEL(%d) target_ec:%p",
1351 lc->ec, serial, lc->target.ec);
1354 runner = _launcher_handler_launcher_runner_get();
1357 ELOGF("LAUNCHER_SRV", "lc(%p) runner(%p), lc is not runner, ignore LAUNCH_CANCEL",
1358 lc->ec, lc, runner);
1359 tws_service_launcher_send_error(lc->res, TWS_SERVICE_LAUNCHER_ERROR_WRONG_REQUEST, lc->serial);
1363 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1364 _launcher_post_forward(lc, EINA_FALSE);
1365 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1366 _launcher_post_backward(lc, EINA_FALSE);
1368 _launcher_handler_launcher_runner_unset(lc);
1369 _launcher_handler_launcher_pre_runner_set(lc);
1370 _launcher_state_set(lc, LAUNCHER_STATE_CANCELED);
1373 static const struct tws_service_launcher_interface _launcher_iface =
1375 _launcher_cb_destroy,
1376 _launcher_cb_launch,
1377 _launcher_cb_launch_with_shared_widget,
1378 _launcher_cb_launching,
1379 _launcher_cb_launch_done,
1380 _launcher_cb_launch_cancel,
1384 _launcher_handler_rsm_provider_client_find(E_Client *rsm_consumer_ec)
1386 E_Client *prov_ec = NULL;
1387 E_Comp_Wl_Client_Data *prov_cdata = NULL;
1388 Eina_List *tzrs_provs, *l;
1389 E_Service_Launcher *lc;
1391 if (!rsm_consumer_ec->remote_surface.consumer) return NULL;
1393 tzrs_provs = e_comp_wl_remote_surface_providers_get(rsm_consumer_ec);
1394 if (!tzrs_provs) return NULL;
1396 EINA_LIST_FOREACH(tzrs_provs, l, prov_ec)
1398 /* check remote surface provider */
1399 if (!prov_ec->remote_surface.provider) continue;
1400 if (prov_ec->visible) continue;
1401 if (evas_object_visible_get(prov_ec->frame)) continue;
1402 prov_cdata = e_client_cdata_get(prov_ec);
1403 if (prov_cdata->mapped) continue;
1404 if (!(lc = _launcher_handler_launcher_find(prov_ec))) continue;
1405 if (!lc->launched_ec) continue;
1407 ELOGF("LAUNCHER_SRV", "Found prov_ec:%p", rsm_consumer_ec, prov_ec);
1410 eina_list_free(tzrs_provs);
1415 static E_Service_Launcher *
1416 _launcher_handler_launcher_find(E_Client *ec)
1418 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
1419 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, NULL);
1420 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler->launcher_hash, NULL);
1422 return eina_hash_find(_laundler->launcher_hash, &ec);
1426 _launcher_handler_launcher_add(E_Service_Launcher *lc)
1430 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
1431 EINA_SAFETY_ON_NULL_RETURN_VAL(lc->ec, EINA_FALSE);
1432 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, EINA_FALSE);
1433 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler->launcher_hash, EINA_FALSE);
1435 ret = eina_hash_add(_laundler->launcher_hash, &lc->ec, lc);
1437 _laundler->launcher_count++;
1443 _launcher_handler_launcher_del(E_Service_Launcher *lc)
1447 EINA_SAFETY_ON_NULL_RETURN_VAL(lc, EINA_FALSE);
1448 EINA_SAFETY_ON_NULL_RETURN_VAL(lc->ec, EINA_FALSE);
1449 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, EINA_FALSE);
1450 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler->launcher_hash, EINA_FALSE);
1452 ret = eina_hash_del(_laundler->launcher_hash, &lc->ec, lc);
1453 if (ret) _laundler->launcher_count--;
1459 _launcher_handler_launcher_runner_set(E_Service_Launcher *lc)
1461 E_Service_Launcher *runner = NULL;
1463 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1464 if (_laundler->runner == lc) return;
1466 //reset previous runner
1467 runner = _laundler->runner;
1470 switch (runner->state)
1472 case LAUNCHER_STATE_PREPARING:
1473 case LAUNCHER_STATE_LAUNCHING:
1474 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER:
1475 _launcher_state_set(runner, LAUNCHER_STATE_CANCELED);
1476 _launcher_stop_send(runner);
1477 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1478 _launcher_post_forward(runner, EINA_FALSE);
1479 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1480 _launcher_post_backward(runner, EINA_FALSE);
1482 case LAUNCHER_STATE_MONITORING:
1483 _launcher_state_set(runner, LAUNCHER_STATE_CANCELED);
1484 _launcher_stop_send(runner);
1485 runner->target.pid = -1;
1486 runner->target.ec = NULL;
1487 E_FREE_FUNC(runner->target.appid, eina_stringshare_del);
1488 E_FREE_FUNC(runner->target.splash_path, eina_stringshare_del);
1489 E_FREE_FUNC(runner->target.splash_group, eina_stringshare_del);
1494 _launcher_handler_launcher_pre_runner_set(runner);
1497 ELOGF("LAUNCHER_SRV", "runner change %p(ec:%p) to %p(ec:%p)",
1498 NULL, runner, runner?runner->ec:NULL, lc, lc?lc->ec:NULL);
1500 _laundler->runner = lc;
1504 _launcher_handler_launcher_runner_unset(E_Service_Launcher *lc)
1506 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1507 if (_laundler->runner != lc) return;
1509 _laundler->runner = NULL;
1511 ELOGF("LAUNCHER_SRV", "runner unset %p(ec:%p)",
1512 NULL, lc, lc?lc->ec:NULL);
1515 static E_Service_Launcher *
1516 _launcher_handler_launcher_runner_get(void)
1518 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, NULL);
1519 return _laundler->runner;
1523 _launcher_handler_launcher_pre_runner_set(E_Service_Launcher *lc)
1525 E_Service_Launcher *pre_runner = NULL;
1527 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1529 pre_runner = _laundler->pre_runner;
1530 if (pre_runner == lc) return;
1533 if (pre_runner->launched_ec)
1534 e_policy_animatable_lock(pre_runner->launched_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
1535 _launcher_state_set(pre_runner, LAUNCHER_STATE_IDLE);
1538 _laundler->pre_runner = lc;
1540 ELOGF("LAUNCHER_SRV", "pre_runner change %p(ec:%p) to %p(ec:%p)",
1541 NULL, pre_runner, pre_runner?pre_runner->ec:NULL, lc, lc?lc->ec:NULL);
1545 _launcher_handler_launcher_pre_runner_unset(E_Service_Launcher *lc)
1547 EINA_SAFETY_ON_NULL_RETURN(_laundler);
1548 if (_laundler->pre_runner != lc) return;
1550 _laundler->pre_runner = NULL;
1552 ELOGF("LAUNCHER_SRV", "pre_runner unset %p(ec:%p)",
1553 NULL, lc, lc?lc->ec:NULL);
1556 static E_Service_Launcher *
1557 _launcher_handler_launcher_pre_runner_get(void)
1559 EINA_SAFETY_ON_NULL_RETURN_VAL(_laundler, NULL);
1560 return _laundler->pre_runner;
1564 _launcher_handler_cb_hook_vis_uniconify_render_running(void *data EINA_UNUSED, E_Client *ec)
1566 E_Service_Launcher *lc = NULL;
1567 E_Service_Launcher *runner, *pre_runner = NULL;
1568 E_Client *activity = NULL, *prov_ec = NULL;
1569 Launcher_State new_state;
1571 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1573 lc = _launcher_handler_launcher_find(ec);
1576 prov_ec = _launcher_handler_rsm_provider_client_find(ec);
1579 /* find launcher handler again with provider ec */
1580 lc = _launcher_handler_launcher_find(prov_ec);
1581 /* set rsm provider ec pointer value to given ec (rsm consumer) */
1585 if (!lc) return EINA_TRUE;
1587 activity = e_policy_visibility_main_activity_get();
1588 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_TRUE);
1592 ELOGF("LAUNCHER_SRV", "Hook uniconify render begin target.ec:%p activity:%p launched_ec:%p",
1593 ec, lc->target.ec, activity, lc->launched_ec);
1595 if (activity == lc->launched_ec)
1597 int sent = EINA_FALSE;
1599 ELOGF("LAUNCHER_SRV", "Current activity(%p, is_del:%d) was launched by launcher.",
1600 ec, activity, e_object_is_del(E_OBJECT(activity)));
1603 runner = _launcher_handler_launcher_runner_get();
1606 ELOGF("LAUNCHER_SRV",
1607 "Launcher(%s) is already runner, do nothing",
1608 lc->ec, _launcher_state_to_str(lc->state));
1612 pre_runner = _launcher_handler_launcher_pre_runner_get();
1613 if (pre_runner == lc)
1615 _launcher_handler_launcher_pre_runner_set(NULL);
1620 sent = _launcher_prepare_shared_widget_backward_send
1621 (lc, activity, activity,
1622 (E_VIS_JOB_TYPE_UNICONIFY |
1623 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY));
1625 new_state = LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE;
1629 sent = _launcher_prepare_backward_send
1630 (lc, activity, activity,
1631 (E_VIS_JOB_TYPE_UNICONIFY |
1632 E_VIS_JOB_TYPE_UNICONIFY_BY_VISIBILITY));
1634 new_state = LAUNCHER_STATE_PREPARING;
1638 if (!sent) return EINA_FALSE;
1640 _launcher_state_set(lc, new_state);
1641 _launcher_handler_launcher_runner_set(lc);
1649 _launcher_handler_cb_hook_vis_lower(void *data EINA_UNUSED, E_Client *ec)
1651 E_Service_Launcher *lc = NULL;
1652 E_Service_Launcher *runner, *pre_runner;
1653 E_Client *activity = NULL, *prov_ec = NULL;
1654 Launcher_State new_state;
1656 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1658 activity = e_policy_visibility_main_activity_get();
1659 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
1661 lc = _launcher_handler_launcher_find(activity);
1664 prov_ec = _launcher_handler_rsm_provider_client_find(activity);
1667 /* find launcher handler again with provider activity */
1668 lc = _launcher_handler_launcher_find(prov_ec);
1671 if (!lc) return EINA_FALSE;
1673 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) return EINA_FALSE;
1675 if (ec == lc->launched_ec)
1677 Eina_Bool sent = EINA_FALSE;
1678 ELOGF("LAUNCHER_SRV", "Lower hook of launched_ec(%p)", lc->ec, ec);
1681 runner = _launcher_handler_launcher_runner_get();
1684 ELOGF("LAUNCHER_SRV",
1685 "Launcher(%s) is already runner, do nothing",
1686 lc->ec, _launcher_state_to_str(lc->state));
1690 pre_runner = _launcher_handler_launcher_pre_runner_get();
1691 if (pre_runner == lc)
1693 _launcher_handler_launcher_pre_runner_set(NULL);
1698 sent = _launcher_prepare_shared_widget_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_LOWER);
1699 new_state = LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE;
1703 sent = _launcher_prepare_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_LOWER);
1704 new_state = LAUNCHER_STATE_PREPARING;
1707 if (!sent) return EINA_FALSE;
1709 _launcher_state_set(lc, new_state);
1710 _launcher_handler_launcher_runner_set(lc);
1717 _launcher_handler_cb_hook_vis_hide(void *data EINA_UNUSED, E_Client *ec)
1719 E_Service_Launcher *lc = NULL;
1720 E_Service_Launcher *runner, *pre_runner;
1721 E_Client *activity = NULL, *prov_ec = NULL;
1722 Launcher_State new_state;
1724 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
1726 activity = e_policy_visibility_main_activity_get();
1727 EINA_SAFETY_ON_NULL_RETURN_VAL(activity, EINA_FALSE);
1729 lc = _launcher_handler_launcher_find(activity);
1732 prov_ec = _launcher_handler_rsm_provider_client_find(activity);
1735 /* find launcher handler again with provider ec */
1736 lc = _launcher_handler_launcher_find(prov_ec);
1742 * activity: callee ec
1743 * given ec: callee ec (transient_for child) <-- destroying by back key
1744 * caller ec (transient_for parent) <-- will be shown
1746 * In this case, the given ec is a callee ec and is transient_for with caller ec (lc) by
1747 * group launching. Also, because of transient_for, caller ec is not iconified.
1748 * Since the given ec is destroyed by the back key, we can't find out caller ec(lc) with activity and given ec.
1749 * We have to use transient_for to find caller ec(lc).
1753 ELOGF("LAUNCHER_SRV", "Hide hook of ec->parent(%p)", ec, ec->parent);
1754 lc = _launcher_handler_launcher_find(ec->parent);
1755 if ((lc) && (lc->launched_ec != ec)) lc = NULL;
1759 ELOGF("LAUNCHER_SRV", "Hide hook of ec->parent(NULL)", ec);
1763 if (!lc) return EINA_FALSE;
1765 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) return EINA_FALSE;
1767 if (ec == lc->launched_ec)
1769 Eina_Bool sent = EINA_FALSE;
1770 ELOGF("LAUNCHER_SRV", "Hide hook of launched_ec(%p)", lc->ec, ec);
1773 runner = _launcher_handler_launcher_runner_get();
1776 ELOGF("LAUNCHER_SRV",
1777 "Launcher(%s) is already runner, do nothing",
1778 lc->ec, _launcher_state_to_str(lc->state));
1782 pre_runner = _launcher_handler_launcher_pre_runner_get();
1783 if (pre_runner == lc)
1785 _launcher_handler_launcher_pre_runner_set(NULL);
1790 sent = _launcher_prepare_shared_widget_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_HIDE);
1791 new_state = LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE;
1795 sent = _launcher_prepare_backward_send(lc, activity, ec, E_VIS_JOB_TYPE_HIDE);
1796 new_state = LAUNCHER_STATE_PREPARING;
1798 if (!sent) return EINA_FALSE;
1800 _launcher_state_set(lc, new_state);
1801 _launcher_handler_launcher_runner_set(lc);
1808 _launcher_handler_cb_hook_client_del(void *data EINA_UNUSED, E_Client *ec)
1810 E_Service_Launcher *lc;
1812 EINA_SAFETY_ON_NULL_RETURN(ec);
1814 lc = _launcher_handler_launcher_find(ec);
1817 if (lc->ec == ec) //launcher surface is gone.
1819 _launcher_handler_launcher_del(lc);
1820 _launcher_data_reset(lc);
1826 _launcher_handler_cb_hook_intercept_show_helper(void *data, E_Client *ec)
1828 E_Service_Launcher *runner;
1829 Eina_Bool sent = EINA_FALSE;
1831 runner = _launcher_handler_launcher_runner_get();
1833 if (!runner) goto show_allow;
1834 EINA_SAFETY_ON_NULL_GOTO(ec, show_allow);
1836 if (ec->new_client) goto show_allow;
1838 switch (runner->state)
1840 case LAUNCHER_STATE_LAUNCHING_WAIT_BUFFER: //waiting buffer change
1841 if (ec == runner->ec)
1844 case LAUNCHER_STATE_PREPARING: //waiting launcher client's preparation
1845 case LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE:
1846 if (ec == runner->target.ec) goto show_deny;
1848 case LAUNCHER_STATE_LAUNCHING: //doing animation
1849 if (ec == runner->target.ec) goto show_deny; //don't show launched app window
1850 else if (ec == runner->ec) goto show_allow; //show launcher
1852 case LAUNCHER_STATE_MONITORING: //waiting creation of target window
1853 if ((runner->target.pid >= 0) && (ec->netwm.pid != runner->target.pid)) goto show_allow; //detect by pid
1854 if ((runner->target.appid) && (runner->target.ec) && (runner->target.ec != ec)) goto show_allow; //detect by appid
1855 if ((runner->target.appid) && (runner->target.pid < 0) && (!runner->target.ec)) goto show_allow; //not enough info
1856 if (e_object_is_del(E_OBJECT(ec))) goto show_allow;
1858 if (runner->with_swl)
1860 sent = _launcher_prepare_shared_widget_forward_send(runner, ec);
1861 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1863 _launcher_state_set(runner, LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE);
1867 sent = _launcher_prepare_forward_send(runner, ec);
1868 EINA_SAFETY_ON_FALSE_GOTO(sent, send_stop);
1870 _launcher_state_set(runner, LAUNCHER_STATE_PREPARING);
1882 runner->target.pid = -1;
1884 runner->target.ec = NULL;
1885 E_FREE_FUNC(runner->target.appid, eina_stringshare_del);
1886 E_FREE_FUNC(runner->target.splash_path, eina_stringshare_del);
1887 E_FREE_FUNC(runner->target.splash_group, eina_stringshare_del);
1889 _launcher_stop_send(runner);
1890 _launcher_state_set(runner, LAUNCHER_STATE_IDLE);
1891 _launcher_handler_launcher_runner_unset(runner);
1895 static void _launcher_handler_cb_hook_appinfo_pid_set(const char *appid, pid_t pid, void *data)
1897 E_Service_Launcher *runner;
1899 EINA_SAFETY_ON_NULL_RETURN(appid);
1900 EINA_SAFETY_ON_TRUE_RETURN(pid < 0);
1902 runner = _launcher_handler_launcher_runner_get();
1903 if (!runner) return;
1904 if (runner->state != LAUNCHER_STATE_MONITORING) return;
1906 if (runner->target.appid)
1908 if (!e_util_strcmp(appid, runner->target.appid))
1910 runner->target.pid = pid;
1912 ELOGF("LAUNCHER_SRV", "Register callee pid:%d by appid(%s)",
1913 runner->ec, pid, runner->target.appid);
1919 _launcher_handler_cb_event_client_show(void *data, int type EINA_UNUSED, void *event)
1921 E_Service_Launcher *runner, *pre_runner;
1925 runner = _launcher_handler_launcher_runner_get();
1926 if (!runner) return ECORE_CALLBACK_PASS_ON;
1928 ev = (E_Event_Client *)event;
1929 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
1930 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
1934 switch (runner->state)
1936 case LAUNCHER_STATE_MONITORING:
1937 if (ec->netwm.pid == runner->target.pid)
1940 case LAUNCHER_STATE_PREPARING:
1941 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1943 if (ec == runner->target.ec) goto send_stop;
1945 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1947 if (ec == runner->ec) goto send_stop;
1950 case LAUNCHER_STATE_LAUNCHING:
1951 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1953 if (ec == runner->target.ec) goto send_stop;
1960 pre_runner = _launcher_handler_launcher_pre_runner_get();
1963 switch (pre_runner->state)
1965 case LAUNCHER_STATE_DONE:
1966 if (ec == pre_runner->launched_ec)
1967 _launcher_handler_launcher_pre_runner_set(NULL);
1969 case LAUNCHER_STATE_CANCELED:
1970 _launcher_handler_launcher_pre_runner_set(NULL);
1977 return ECORE_CALLBACK_PASS_ON;
1980 ELOGF("LAUNCHER_SRV", "CLIENT SHOW: Failure Case runner:%p", ec, runner);
1982 _launcher_stop_send(runner);
1984 if (runner->state == LAUNCHER_STATE_MONITORING)
1986 runner->target.pid = -1;
1989 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
1990 _launcher_post_forward(runner, EINA_FALSE);
1991 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
1992 _launcher_post_backward(runner, EINA_FALSE);
1994 _launcher_state_set(runner, LAUNCHER_STATE_IDLE);
1995 _launcher_handler_launcher_runner_unset(runner);
1997 return ECORE_CALLBACK_PASS_ON;
2001 _launcher_handler_cb_event_client_visibility_change(void *data, int type EINA_UNUSED, void *event)
2003 E_Service_Launcher *pre_runner;
2007 ev = (E_Event_Client *)event;
2008 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
2009 EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON);
2012 if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED)
2013 return ECORE_CALLBACK_PASS_ON;
2015 pre_runner = _launcher_handler_launcher_pre_runner_get();
2018 switch (pre_runner->state)
2020 case LAUNCHER_STATE_DONE:
2021 case LAUNCHER_STATE_CANCELED:
2022 if (pre_runner->launched_ec)
2024 if (pre_runner->launched_ec == ec)
2026 e_policy_animatable_lock(pre_runner->launched_ec, E_POLICY_ANIMATABLE_CUSTOMIZED, 0);
2035 return ECORE_CALLBACK_PASS_ON;
2038 #undef LAUNCHER_HANDLER_CB_ADD
2039 #define LAUNCHER_HANDLER_CB_ADD(l, appender, event_type, cb, data) \
2043 _h = appender(event_type, cb, data); \
2045 l = eina_list_append(l, _h); \
2050 static E_Service_Launcher_Handler *
2051 _launcher_handler_create(void)
2053 E_Service_Launcher_Handler *laundler = NULL;
2055 laundler = E_NEW(E_Service_Launcher_Handler, 1);
2056 EINA_SAFETY_ON_NULL_RETURN_VAL(laundler, NULL);
2058 laundler->launcher_count = 0;
2059 laundler->launcher_hash = eina_hash_pointer_new(NULL);
2061 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_vis,
2062 e_policy_visibility_hook_add,
2063 E_POL_VIS_HOOK_TYPE_UNICONIFY_RENDER_RUNNING,
2064 _launcher_handler_cb_hook_vis_uniconify_render_running, NULL);
2066 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_vis,
2067 e_policy_visibility_hook_add,
2068 E_POL_VIS_HOOK_TYPE_LOWER,
2069 _launcher_handler_cb_hook_vis_lower, NULL);
2071 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_vis,
2072 e_policy_visibility_hook_add,
2073 E_POL_VIS_HOOK_TYPE_HIDE,
2074 _launcher_handler_cb_hook_vis_hide, NULL);
2076 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_ec,
2079 _launcher_handler_cb_hook_client_del, NULL);
2081 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_co,
2082 e_comp_object_intercept_hook_add,
2083 E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER,
2084 _launcher_handler_cb_hook_intercept_show_helper, NULL);
2086 LAUNCHER_HANDLER_CB_ADD(laundler->hooks_appinfo,
2088 E_APPINFO_HOOK_PID_SET,
2089 _launcher_handler_cb_hook_appinfo_pid_set, NULL);
2091 LAUNCHER_HANDLER_CB_ADD(laundler->hdlrs_ev,
2092 ecore_event_handler_add,
2093 E_EVENT_CLIENT_SHOW,
2094 _launcher_handler_cb_event_client_show, NULL);
2096 LAUNCHER_HANDLER_CB_ADD(laundler->hdlrs_ev,
2097 ecore_event_handler_add,
2098 E_EVENT_CLIENT_VISIBILITY_CHANGE,
2099 _launcher_handler_cb_event_client_visibility_change, NULL);
2101 ELOGF("LAUNCHER_SRV", "new launcher handler(%p) created", NULL, laundler);
2107 _launcher_handler_destroy(E_Service_Launcher_Handler *laundler)
2109 EINA_SAFETY_ON_NULL_RETURN(laundler);
2111 E_FREE_LIST(laundler->hdlrs_ev, ecore_event_handler_del);
2112 E_FREE_LIST(laundler->hooks_appinfo, e_appinfo_hook_del);
2113 E_FREE_LIST(laundler->hooks_co, e_comp_object_intercept_hook_del);
2114 E_FREE_LIST(laundler->hooks_ec, e_client_hook_del);
2115 E_FREE_LIST(laundler->hooks_vis, e_policy_visibility_hook_del);
2117 E_FREE_FUNC(laundler->launcher_hash, eina_hash_free);
2122 e_service_launcher_resource_set(E_Client *ec, struct wl_resource *res_tws_lc)
2124 E_Service_Launcher *lc;
2126 EINA_SAFETY_ON_NULL_RETURN(ec);
2127 EINA_SAFETY_ON_NULL_RETURN(res_tws_lc);
2129 lc = _launcher_handler_launcher_find(ec);
2130 EINA_SAFETY_ON_NULL_RETURN(lc);
2131 EINA_SAFETY_ON_TRUE_RETURN(lc->ec != ec);
2134 _launcher_data_reset(lc);
2136 lc->res = res_tws_lc;
2137 wl_resource_set_implementation(res_tws_lc,
2138 &_launcher_iface, lc,
2139 _launcher_cb_resource_destroy);
2143 e_service_launcher_client_set(E_Client *ec)
2145 E_Service_Launcher *lc = NULL;
2147 EINA_SAFETY_ON_NULL_RETURN(ec);
2148 EINA_SAFETY_ON_TRUE_RETURN(e_object_is_del(E_OBJECT(ec)));
2150 if ((lc = _launcher_handler_launcher_find(ec)))
2152 ELOGF("LAUNCHER_SRV", "ec(%p) is already set as launcher(%p)",
2159 _laundler = _launcher_handler_create();
2160 EINA_SAFETY_ON_NULL_RETURN(_laundler);
2163 lc = E_NEW(E_Service_Launcher, 1);
2164 EINA_SAFETY_ON_NULL_RETURN(lc);
2167 if (!_launcher_handler_launcher_add(lc))
2170 ELOGF("LAUNCHER_SRV", "Fail to add launcher", ec);
2174 ELOGF("LAUNCHER_SRV", "client set|Created New Launcher(%p)", ec, lc);
2175 _launcher_state_set(lc, LAUNCHER_STATE_IDLE);
2181 e_service_launcher_client_unset(E_Client *ec)
2183 E_Service_Launcher *lc;
2185 EINA_SAFETY_ON_NULL_RETURN(ec);
2187 lc = _launcher_handler_launcher_find(ec);
2188 EINA_SAFETY_ON_NULL_RETURN(lc);
2190 _launcher_handler_launcher_del(lc);
2191 _launcher_data_reset(lc);
2194 ELOGF("LAUNCHER_SRV", "client unset", ec);
2196 if ((_laundler) && (_laundler->launcher_count == 0))
2198 ELOGF("LAUNCHER_SRV", "No launcher available, Destroy Launcher Handler(%p)",
2201 _launcher_handler_destroy(_laundler);
2207 e_service_launcher_prepare_send_with_shared_widget_info(E_Client *target_ec,
2208 const char *shared_widget_info,
2212 E_Service_Launcher *lc = NULL;
2215 Eina_Iterator *hash_iter;
2216 Eina_Bool found = EINA_FALSE;
2218 EINA_SAFETY_ON_NULL_RETURN(_laundler);
2220 /* look for launcher service object which has given target_ec */
2221 hash_iter = eina_hash_iterator_data_new(_laundler->launcher_hash);
2222 EINA_ITERATOR_FOREACH(hash_iter, lc)
2224 if (lc->target.ec != target_ec) continue;
2225 if (lc->serial != serial) continue;
2229 eina_iterator_free(hash_iter);
2231 EINA_SAFETY_ON_FALSE_RETURN(found);
2232 EINA_SAFETY_ON_NULL_RETURN(lc);
2234 ELOGF("LAUNCHER_SRV", "SWL | callee(%p) cb(PREPARE_DONE(%d))",
2235 lc->ec, target_ec, state);
2237 if (state == TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE)
2239 e_client_pos_get(target_ec, &x, &y);
2241 sent = _launcher_prepare_send(lc, target_ec, x, y, shared_widget_info);
2242 EINA_SAFETY_ON_FALSE_GOTO(sent, error);
2244 _launcher_state_set(lc, LAUNCHER_STATE_PREPARING);
2246 else if (state == TWS_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW)
2248 if (!lc->buff_attach)
2250 if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
2251 _launcher_post_forward(lc, EINA_TRUE);
2252 else if (lc->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
2253 _launcher_post_backward(lc, EINA_TRUE);
2255 _launcher_handler_launcher_runner_unset(lc);
2256 _launcher_handler_launcher_pre_runner_set(lc);
2257 _launcher_state_set(lc, LAUNCHER_STATE_DONE);
2260 lc->swl_done = EINA_TRUE;
2262 ELOGF("LAUNCHER_SRV", "SWL | send CLEANUP", lc->ec);
2263 tws_service_launcher_send_cleanup(lc->res,
2270 ELOGF("LAUNCHER_SRV", "Failed to send event(PREPARE:FORWARD)", lc->ec);
2271 _launcher_post_forward(lc, EINA_FALSE);
2275 e_service_launcher_release_shared_widget_launch(E_Client *ec)
2277 E_Service_Launcher *runner;
2279 EINA_SAFETY_ON_NULL_RETURN(ec);
2281 runner = _launcher_handler_launcher_runner_get();
2282 EINA_SAFETY_ON_NULL_RETURN(runner);
2284 ELOGF("LAUNCHER_SRV", "Released tzsh_swl", ec);
2286 if ((runner) && (runner->target.ec == ec))
2288 if (runner->with_swl)
2290 //callee is gone before replying prepare_done
2291 if (runner->state == LAUNCHER_STATE_WAIT_RESPONSE_FROM_CALLEE)
2293 if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_FORWARD)
2294 _launcher_post_forward(runner, EINA_FALSE);
2295 else if (runner->direction == TWS_SERVICE_LAUNCHER_DIRECTION_BACKWARD)
2296 _launcher_post_backward(runner, EINA_FALSE);
2298 _launcher_state_set(runner, LAUNCHER_STATE_IDLE);
2299 _launcher_launched_ec_set(runner, NULL);
2301 _launcher_handler_launcher_runner_unset(runner);
2302 _launcher_handler_launcher_pre_runner_unset(runner);
2304 runner->direction = 0;
2305 runner->with_swl = 0;
2312 e_service_launcher_callee_register(E_Client *callee, const char *appid, const char *splash_path, const char *splash_group)
2314 E_Service_Launcher *runner;
2316 EINA_SAFETY_ON_NULL_RETURN(callee);
2318 runner = _launcher_handler_launcher_runner_get();
2319 EINA_SAFETY_ON_NULL_RETURN(runner);
2320 EINA_SAFETY_ON_TRUE_RETURN(runner->state != LAUNCHER_STATE_MONITORING);
2322 if (runner->target.appid)
2324 if (!e_util_strcmp(appid, runner->target.appid))
2326 runner->target.ec = callee;
2327 runner->target.splash_path = eina_stringshare_add(splash_path);
2328 runner->target.splash_group = eina_stringshare_add(splash_group);
2330 ELOGF("LAUNCHER_SRV", "Register callee(%p) by appid(%s)",
2331 runner->ec, runner->target.ec, runner->target.appid);