3 #include "e_wtz_shell.h"
4 #include "e_comp_wl_private.h"
5 #include <tizen-extension-server-protocol.h>
7 #include <relative-pointer-unstable-v1-server-protocol.h>
8 #include <pointer-constraints-unstable-v1-server-protocol.h>
10 #include <wayland-tbm-server.h>
13 #include <libds/log.h>
14 #include <libds/single_pixel_buffer_v1.h>
16 /* handle include for printing uint64_t */
17 #define __STDC_FORMAT_MACROS
20 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
22 /* Resource Data Mapping: (wl_resource_get_user_data)
24 * wl_surface == e_pixmap
25 * wl_region == eina_tiler
26 * wl_subsurface == e_client
30 typedef struct _E_Comp_Data E_Comp_Data;
35 struct wl_listener client_created;
38 static void _e_comp_wl_move_resize_init(void);
40 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
43 typedef struct _E_Comp_Wl_Key_Data
49 static Eina_List *handlers = NULL;
50 static E_Client *cursor_timer_ec = NULL;
51 static Eina_Bool need_send_released = EINA_FALSE;
52 static Eina_Bool need_send_motion = EINA_TRUE;
54 static GMutex flush_mutex;
56 static int _e_comp_wl_hooks_delete = 0;
57 static int _e_comp_wl_hooks_walking = 0;
59 static int _e_comp_wl_pid_hooks_delete = 0;
60 static int _e_comp_wl_pid_hooks_walking = 0;
62 static int _e_comp_wl_intercept_hooks_delete = 0;
63 static int _e_comp_wl_intercept_hooks_walking = 0;
65 static Eina_Inlist *_e_comp_wl_hooks[] =
67 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
68 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
69 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
70 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
71 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
72 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
73 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
74 [E_COMP_WL_HOOK_DEL] = NULL,
75 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
76 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
77 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
80 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
82 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
85 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
87 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
88 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
89 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
90 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
91 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
92 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
95 static Eina_List *hooks = NULL;
99 _e_comp_wl_hooks_clean(void)
104 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
105 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
107 if (!ch->delete_me) continue;
108 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
114 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
118 e_object_ref(E_OBJECT(ec));
119 _e_comp_wl_hooks_walking++;
120 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
122 if (ch->delete_me) continue;
123 ch->func(ch->data, ec);
124 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
125 (e_object_is_del(E_OBJECT(ec))))
128 _e_comp_wl_hooks_walking--;
129 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
130 _e_comp_wl_hooks_clean();
131 e_object_unref(E_OBJECT(ec));
135 _e_comp_wl_pid_hooks_clean(void)
138 E_Comp_Wl_Pid_Hook *ch;
140 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
141 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
143 if (!ch->delete_me) continue;
144 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
150 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
152 E_Comp_Wl_Pid_Hook *ch;
154 _e_comp_wl_pid_hooks_walking++;
155 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
157 if (ch->delete_me) continue;
158 ch->func(ch->data, pid);
160 _e_comp_wl_pid_hooks_walking--;
161 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
162 _e_comp_wl_pid_hooks_clean();
166 _e_comp_wl_intercept_hooks_clean(void)
169 E_Comp_Wl_Intercept_Hook *ch;
171 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
172 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
174 if (!ch->delete_me) continue;
175 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
181 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
183 E_Comp_Wl_Intercept_Hook *ch;
184 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
186 e_object_ref(E_OBJECT(ec));
187 _e_comp_wl_intercept_hooks_walking++;
188 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
190 if (ch->delete_me) continue;
191 res = ch->func(ch->data, ec);
192 if (!res) ret = EINA_FALSE;
193 if (e_object_is_del(E_OBJECT(ec)))
196 _e_comp_wl_intercept_hooks_walking--;
197 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
198 _e_comp_wl_intercept_hooks_clean();
199 e_object_unref(E_OBJECT(ec));
206 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
212 if (e_comp_object_frame_exists(ec->frame))
213 w = ec->client.w, h = ec->client.h;
215 w = ec->w, h = ec->h;
219 // Width and Height are -1 means that we don't consider size value
223 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
224 edges * e_comp_wl->resize.edges,
229 _e_comp_wl_focus_check(void)
233 if (stopping) return;
234 ec = e_client_focused_get();
236 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
240 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
242 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
244 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
245 IDLE_EXITER~CB_PREPARE);
247 return ECORE_CALLBACK_RENEW;
251 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
253 /* dispatch pending wayland events */
254 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
256 return ECORE_CALLBACK_RENEW;
260 e_comp_wl_display_flush()
262 if (e_comp_wl && e_comp_wl->wl.disp)
264 g_mutex_lock(&flush_mutex);
265 wl_display_flush_clients(e_comp_wl->wl.disp);
266 g_mutex_unlock(&flush_mutex);
271 e_comp_wl_focused_client_flush()
273 E_Client *focused_ec;
274 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
276 g_mutex_lock(&flush_mutex);
277 focused_ec = e_client_focused_get();
281 struct wl_client *wc;
282 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
285 g_mutex_unlock(&flush_mutex);
289 wc = wl_resource_get_client(surface);
293 g_mutex_unlock(&flush_mutex);
297 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
301 if (e_comp_wl->idle_exiter_timestamp > 0.0)
303 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
304 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
306 ELOGF("E_COMP", "prepare gap time: %lfms",
311 e_comp_wl->idle_exiter_timestamp = 0.0;
313 /* flush pending client events */
314 e_comp_wl_display_flush();
316 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
317 IDLE_EXITER~CB_PREPARE);
320 E_API enum wl_output_transform
321 e_comp_wl_output_buffer_transform_get(E_Client *ec)
323 E_Comp_Wl_Buffer_Viewport *vp;
324 E_Comp_Wl_Buffer *buffer;
325 enum wl_output_transform transform, rotation;
327 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
328 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
329 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
331 vp = &ec->comp_data->scaler.buffer_viewport;
332 if (e_comp_wl_subsurface_check(ec))
333 return vp->buffer.transform;
335 buffer = ec->comp_data->buffer_ref.buffer;
338 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
339 return vp->buffer.transform;
341 rotation = buffer->transform;
343 return vp->buffer.transform;
345 /* ignore the flip value when calculating transform because the screen rotation
346 * functionality doesn't consider the flip output transform currently
348 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
350 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
351 ec, rotation, vp->buffer.transform, transform);
356 EINTERN enum wl_output_transform
357 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
359 E_Comp_Wl_Buffer_Viewport *vp;
360 E_Comp_Wl_Buffer *buffer;
361 enum wl_output_transform transform, rotation;
363 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
364 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
365 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
367 vp = &ec->comp_data->pending.buffer_viewport;
368 if (e_comp_wl_subsurface_check(ec))
369 return vp->buffer.transform;
371 buffer = ec->comp_data->pending.buffer;
374 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
375 return vp->buffer.transform;
377 rotation = buffer->transform;
379 return vp->buffer.transform;
381 /* ignore the flip value when calculating transform because the screen rotation
382 * functionality doesn't consider the flip output transform currently
384 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
386 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
387 ec, rotation, vp->buffer.transform, transform);
393 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
395 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
396 E_Comp_Wl_Buffer *buffer;
397 int32_t width, height;
399 buffer = e_pixmap_resource_get(ec->pixmap);
402 ec->comp_data->width_from_buffer = 0;
403 ec->comp_data->height_from_buffer = 0;
407 switch (e_comp_wl_output_buffer_transform_get(ec))
409 case WL_OUTPUT_TRANSFORM_90:
410 case WL_OUTPUT_TRANSFORM_270:
411 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
412 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
413 width = buffer->h / vp->buffer.scale;
414 height = buffer->w / vp->buffer.scale;
417 width = buffer->w / vp->buffer.scale;
418 height = buffer->h / vp->buffer.scale;
422 ec->comp_data->width_from_buffer = width;
423 ec->comp_data->height_from_buffer = height;
427 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
429 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
430 int32_t width, height;
432 width = ec->comp_data->width_from_buffer;
433 height = ec->comp_data->height_from_buffer;
435 if (width == 0 && height == 0) return;
437 if (width != 0 && vp->surface.width != -1)
439 ec->comp_data->width_from_viewport = vp->surface.width;
440 ec->comp_data->height_from_viewport = vp->surface.height;
444 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
446 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
447 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
448 ec->comp_data->width_from_viewport = w ?: 1;
449 ec->comp_data->height_from_viewport = h ?: 1;
453 ec->comp_data->width_from_viewport = width;
454 ec->comp_data->height_from_viewport = height;
458 e_comp_wl_topmost_parent_get(E_Client *ec)
462 if (!e_comp_wl_subsurface_check(ec))
465 parent = e_comp_wl_subsurface_parent_get(ec);
468 if (!e_comp_wl_subsurface_check(parent))
471 parent = e_comp_wl_subsurface_parent_get(parent);
478 e_comp_wl_map_apply(E_Client *ec)
480 E_Comp_Wl_Buffer_Viewport *vp;
481 E_Comp_Wl_Subsurf_Data *sdata;
482 E_Comp_Wl_Client_Data *cdata;
483 int x1, y1, x2, y2, x, y;
485 Eina_Bool zoom_animating = EINA_FALSE;
487 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
489 e_comp_object_map_update(ec->frame);
491 cdata = ec->comp_data;
492 vp = &cdata->scaler.buffer_viewport;
493 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
494 (!cdata->viewport_transform))
497 if (e_comp_wl_subsurface_check(ec))
499 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
501 sdata = ec->comp_data->sub.data;
502 if (sdata->remote_surface.offscreen_parent)
504 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
505 Eina_Rectangle *rect;
508 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
510 /* TODO: If there are one more regions, it means that provider's offscreen
511 * is displayed by one more remote_surfaces. Have to consider it later. At
512 * this time, just consider only one remote_surface.
526 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
527 if (x != dx || y != dy)
528 evas_object_move(ec->frame, dx, dy);
530 if (!cdata->viewport_transform)
532 cdata->viewport_transform = e_util_transform_new();
533 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
534 e_client_transform_core_add(ec, cdata->viewport_transform);
537 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
538 ec->comp_data->width_from_viewport,
539 ec->comp_data->height_from_viewport);
541 if (vp->buffer.src_width == wl_fixed_from_int(-1))
545 x2 = cdata->width_from_buffer;
546 y2 = cdata->height_from_buffer;
550 x1 = wl_fixed_to_int(vp->buffer.src_x);
551 y1 = wl_fixed_to_int(vp->buffer.src_y);
552 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
553 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
556 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
557 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
558 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
559 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
562 desk = e_comp_desk_find_by_ec(ec);
564 zoom_animating = e_desk_zoom_is_animating(desk);
566 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
567 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
568 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
570 /* workaround:: when the desk zoom is doing their animation,
571 the transform core update can override animation's zoom boundary.
572 so, don't doing transform core update while desk zoom animation */
574 e_client_transform_core_update(ec);
579 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
583 int map_c = 0, map_x = 0, map_y = 0;
584 double inv_x = 0.0, inv_y = 0.0;
586 EINA_SAFETY_ON_NULL_RETURN(ec);
588 map = e_client_map_get(ec);
589 map_c = e_map_count_get(map);
591 if (!map || map_c <= 0)
601 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
602 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
603 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
604 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
606 for (int i = 0; i < map_c; i++)
608 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
609 e_map_point_image_uv_set(map2, i, map_x, map_y);
611 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
621 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
627 if (!(ec = data)) return;
628 if (e_object_is_del(data)) return;
630 if (!ec->override) e_hints_window_visible_set(ec);
632 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
633 (!ec->comp_data->need_reparent))
635 ec->comp_data->need_reparent = EINA_TRUE;
636 ec->visible = EINA_TRUE;
638 if (!e_client_util_ignored_get(ec))
640 ec->take_focus = !starting;
644 if (!ec->comp_data->need_reparent)
646 if ((ec->hidden) || (ec->iconic))
648 evas_object_hide(ec->frame);
649 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
652 evas_object_show(ec->frame);
655 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
656 evas_object_show(tmp->frame);
658 topmost = e_comp_wl_topmost_parent_get(ec);
659 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
660 e_comp_wl_subsurface_show(ec);
662 if (ec->comp_data->sub.below_obj)
663 evas_object_show(ec->comp_data->sub.below_obj);
667 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
673 if (!(ec = data)) return;
674 if (e_object_is_del(E_OBJECT(ec))) return;
676 /* Uncommonly some clients's final buffer can be skipped if the client
677 * requests unmap of its surface right after wl_surface@commit.
678 * So if this client evas object is hidden state and client is already
679 * unmmapped, we can consider to clear pixmap image here mandatorily.
681 if (!ec->comp_data->mapped)
682 e_pixmap_image_clear(ec->pixmap, 1);
684 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
685 evas_object_hide(tmp->frame);
687 topmost = e_comp_wl_topmost_parent_get(ec);
688 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
689 e_comp_wl_subsurface_hide(ec);
691 if (ec->comp_data->sub.below_obj)
692 evas_object_hide(ec->comp_data->sub.below_obj);
694 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
698 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
705 if (!(ec = data)) return;
706 if (e_object_is_del(E_OBJECT(ec))) return;
708 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
710 if (!e_comp_wl_subsurface_check(subc)) continue;
711 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
712 evas_object_move(subc->frame, x, y);
714 if (subc->comp_data->scaler.viewport)
716 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
717 if (cdata->viewport_transform)
718 e_comp_wl_map_apply(subc);
722 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
724 if (!e_comp_wl_subsurface_check(subc)) continue;
725 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
726 evas_object_move(subc->frame, x, y);
728 if (subc->comp_data->scaler.viewport)
730 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
731 if (cdata->viewport_transform)
732 e_comp_wl_map_apply(subc);
736 if (ec->comp_data->sub.below_obj)
738 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
739 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
744 _e_comp_wl_send_touch_cancel(E_Client *ec)
747 struct wl_resource *res;
748 struct wl_client *wc;
749 E_Comp_Config *comp_conf = NULL;
752 if (e_object_is_del(E_OBJECT(ec))) return;
753 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
755 if (!surface) return;
756 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
758 wc = wl_resource_get_client(surface);
760 comp_conf = e_comp_config_get();
762 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
764 if (wl_resource_get_client(res) != wc) continue;
765 if (!e_comp_wl_input_touch_check(res)) continue;
767 if (comp_conf && comp_conf->input_log_enable)
768 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
770 wl_touch_send_cancel(res);
775 _e_comp_wl_touch_cancel(void)
779 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
781 if (!e_comp_wl->touch.pressed) return;
783 _e_comp_wl_send_touch_cancel(ec);
786 static E_Devicemgr_Input_Device *
787 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
789 E_Devicemgr_Input_Device *last_kbd = NULL;
792 case ECORE_DEVICE_CLASS_MOUSE:
793 return e_devicemgr->last_device_ptr;
794 case ECORE_DEVICE_CLASS_KEYBOARD:
795 g_rec_mutex_lock(&e_devicemgr->last_device_kbd_mutex);
796 last_kbd = e_devicemgr->last_device_kbd;
797 g_rec_mutex_unlock(&e_devicemgr->last_device_kbd_mutex);
799 case ECORE_DEVICE_CLASS_TOUCH:
800 return e_devicemgr->last_device_touch;
808 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
812 case ECORE_DEVICE_CLASS_MOUSE:
813 e_devicemgr->last_device_ptr = device;
815 case ECORE_DEVICE_CLASS_KEYBOARD:
816 g_rec_mutex_lock(&e_devicemgr->last_device_kbd_mutex);
817 e_devicemgr->last_device_kbd = device;
818 g_rec_mutex_unlock(&e_devicemgr->last_device_kbd_mutex);
820 case ECORE_DEVICE_CLASS_TOUCH:
821 e_devicemgr->last_device_touch = device;
828 static E_Devicemgr_Input_Device *
829 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
831 E_Devicemgr_Input_Device *last_kbd = NULL;
835 case ECORE_DEVICE_CLASS_MOUSE:
836 return ec->comp_data->last_device_ptr;
837 case ECORE_DEVICE_CLASS_KEYBOARD:
838 g_rec_mutex_lock(&ec->comp_data->last_device_kbd_mutex);
839 last_kbd = ec->comp_data->last_device_kbd;
840 g_rec_mutex_unlock(&ec->comp_data->last_device_kbd_mutex);
842 case ECORE_DEVICE_CLASS_TOUCH:
843 return ec->comp_data->last_device_touch;
851 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
855 case ECORE_DEVICE_CLASS_MOUSE:
856 ec->comp_data->last_device_ptr = device;
858 case ECORE_DEVICE_CLASS_KEYBOARD:
859 g_rec_mutex_lock(&ec->comp_data->last_device_kbd_mutex);
860 ec->comp_data->last_device_kbd = device;
861 g_rec_mutex_unlock(&ec->comp_data->last_device_kbd_mutex);
863 case ECORE_DEVICE_CLASS_TOUCH:
864 ec->comp_data->last_device_touch = device;
872 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
874 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
875 struct wl_resource *dev_res;
876 const char *dev_name;
877 Ecore_Device_Class dev_class;
878 struct wl_client *wc;
882 EINA_SAFETY_ON_NULL_RETURN(dev);
885 if (ec->cur_mouse_action || e_comp_wl->drag)
887 if (e_object_is_del(E_OBJECT(ec))) return;
888 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
889 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
890 if (!surface) return;
892 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
893 dev_name = evas_device_description_get(dev);
894 last_device = _e_comp_wl_device_last_device_get(dev_class);
895 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
897 serial = wl_display_next_serial(e_comp_wl->wl.disp);
898 wc = wl_resource_get_client(surface);
899 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
900 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
902 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
903 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
905 _e_comp_wl_device_last_device_set(dev_class, input_dev);
906 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
908 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
910 if (wl_resource_get_client(dev_res) != wc) continue;
911 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
915 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
919 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
921 E_Devicemgr_Input_Device *last_device;
922 struct wl_resource *dev_res;
923 struct wl_client *wc;
927 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
928 if (!surface) return;
930 last_device = _e_comp_wl_device_last_device_get(dev_class);
931 if (!last_device) return;
933 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
935 serial = wl_display_next_serial(e_comp_wl->wl.disp);
936 wc = wl_resource_get_client(surface);
937 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
939 if (wl_resource_get_client(dev_res) != wc) continue;
940 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
945 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
947 E_Devicemgr_Input_Device *input_dev;
948 struct wl_resource *dev_res;
949 const char *dev_name;
952 EINA_SAFETY_ON_NULL_RETURN(dev);
954 dev_name = ecore_device_identifier_get(dev);
956 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
957 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
959 if (!eina_streq(input_dev->identifier, dev_name) ||
960 (input_dev->clas != ecore_device_class_get(dev))) continue;
961 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
963 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
965 if (wl_resource_get_client(dev_res) != wc) continue;
966 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
969 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
973 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
975 E_Devicemgr_Input_Device *input_dev;
976 struct wl_resource *dev_res;
977 const char *dev_name;
980 EINA_SAFETY_ON_NULL_RETURN(dev);
982 dev_name = e_device_identifier_get(dev);
984 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
985 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
987 if (!eina_streq(input_dev->identifier, dev_name) ||
988 (input_dev->clas != e_device_class_get(dev))) continue;
989 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
991 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
993 if (wl_resource_get_client(dev_res) != wc) continue;
994 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
997 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1001 _e_comp_wl_cursor_reload(E_Client *ec)
1003 struct wl_resource *res;
1004 struct wl_client *wc;
1010 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1011 !evas_object_visible_get(e_comp->pointer->o_ptr))
1012 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1015 if (e_object_is_del(E_OBJECT(ec))) return;
1016 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1017 if (!surface) return;
1018 if (ec->pointer_enter_sent) return;
1020 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1021 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1023 if (e_client_transform_core_enable_get(ec))
1025 double dx = 0.0, dy = 0.0;
1026 map = e_client_map_get(ec);
1027 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1033 cx = px - ec->client.x;
1034 cy = py - ec->client.y;
1036 wc = wl_resource_get_client(surface);
1037 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1038 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1040 if (!e_comp_wl_input_pointer_check(res)) continue;
1041 if (wl_resource_get_client(res) != wc) continue;
1042 wl_pointer_send_enter(res, serial, surface,
1043 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1044 ec->pointer_enter_sent = EINA_TRUE;
1046 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1050 _e_comp_wl_cursor_timer(void *data)
1052 E_Client *ec = data;
1054 e_comp_wl_cursor_hide(ec);
1056 return ECORE_CALLBACK_CANCEL;
1060 _e_comp_wl_device_send_axis(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, enum tizen_input_device_axis_type axis_type, double value)
1062 E_Devicemgr_Input_Device *input_dev;
1063 struct wl_resource *dev_res;
1064 struct wl_client *wc;
1069 if (ec->cur_mouse_action) return;
1070 if (e_object_is_del(E_OBJECT(ec))) return;
1071 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1072 if (!surface) return;
1074 f_value = wl_fixed_from_double(value);
1075 wc = wl_resource_get_client(surface);
1077 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1078 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1080 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1081 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1083 if (wl_resource_get_client(dev_res) != wc) continue;
1084 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1087 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1091 _e_comp_wl_device_renew_axis(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
1093 if (idx >= e_input_touch_max_count_get()) return;
1095 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1096 e_devicemgr->multi[idx].radius_x = radius_x;
1097 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1098 e_devicemgr->multi[idx].radius_y = radius_y;
1099 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1100 e_devicemgr->multi[idx].pressure = pressure;
1101 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1102 e_devicemgr->multi[idx].angle = angle;
1106 _e_comp_wl_device_handle_axes(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
1108 if (idx >= e_input_touch_max_count_get()) return;
1110 if (e_devicemgr->multi[idx].radius_x != radius_x)
1112 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1113 e_devicemgr->multi[idx].radius_x = radius_x;
1115 if (e_devicemgr->multi[idx].radius_y != radius_y)
1117 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1118 e_devicemgr->multi[idx].radius_y = radius_y;
1120 if (e_devicemgr->multi[idx].pressure != pressure)
1122 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1123 e_devicemgr->multi[idx].pressure = pressure;
1125 if (e_devicemgr->multi[idx].angle != angle)
1127 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1128 e_devicemgr->multi[idx].angle = angle;
1133 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1135 Eina_Bool ret = EINA_TRUE;
1138 case EVAS_CALLBACK_MOUSE_IN:
1139 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1142 if (e_comp_wl->ptr.hide_tmr)
1144 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1145 cursor_timer_ec = ec;
1146 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1150 if (e_pointer_is_hidden(e_comp->pointer))
1155 case EVAS_CALLBACK_MOUSE_OUT:
1156 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1159 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1163 case EVAS_CALLBACK_MOUSE_MOVE:
1164 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1167 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1168 _e_comp_wl_cursor_reload(ec);
1171 case EVAS_CALLBACK_MOUSE_WHEEL:
1172 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1175 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1176 _e_comp_wl_cursor_reload(ec);
1179 case EVAS_CALLBACK_MOUSE_DOWN:
1180 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1183 if (e_comp_wl->ptr.hide_tmr)
1185 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1186 e_comp_wl->ptr.hide_tmr = NULL;
1188 cursor_timer_ec = NULL;
1190 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1191 _e_comp_wl_cursor_reload(ec);
1194 case EVAS_CALLBACK_MOUSE_UP:
1195 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1206 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1208 if (ec->has_cursor_unset)
1211 if (!e_config->show_cursor)
1214 if (!e_config->use_cursor_timer)
1221 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1224 Evas_Event_Mouse_In *ev;
1225 struct wl_resource *res;
1226 struct wl_client *wc;
1229 E_Comp_Config *comp_conf;
1230 E_Client *prev_ptr_ec;
1234 e_comp_wl->ptr.x = wl_fixed_from_int(ev->canvas.x);
1235 e_comp_wl->ptr.y = wl_fixed_from_int(ev->canvas.y);
1237 if (!(ec = data)) return;
1238 if (e_object_is_del(E_OBJECT(ec))) return;
1239 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1240 if (!surface) return;
1242 prev_ptr_ec = e_comp_wl->ptr.ec;
1245 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1246 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1249 e_comp_wl->ptr.ec = ec;
1251 comp_conf = e_comp_config_get();
1252 if (comp_conf && comp_conf->input_log_enable)
1253 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1254 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1255 e_client_util_name_get(ec));
1257 if (_e_comp_wl_check_cursor_timer_needed(ec))
1259 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1263 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1264 wc = wl_resource_get_client(surface);
1265 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1266 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1268 if (!e_comp_wl_input_pointer_check(res)) continue;
1269 if (wl_resource_get_client(res) != wc) continue;
1271 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1273 wl_pointer_send_enter(res, serial, surface,
1274 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1275 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1276 ec->pointer_enter_sent = EINA_TRUE;
1279 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1283 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1286 Evas_Event_Mouse_Out *ev;
1287 struct wl_resource *res;
1288 struct wl_client *wc;
1291 Eina_Bool inside_check;
1292 E_Comp_Config *comp_conf;
1296 if (!(ec = data)) return;
1297 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1298 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1299 if (ec->cur_mouse_action && inside_check) return;
1300 if (e_object_is_del(E_OBJECT(e_comp))) return;
1301 if (e_comp_wl->ptr.ec == ec)
1302 e_comp_wl->ptr.ec = NULL;
1303 if (e_object_is_del(E_OBJECT(ec))) return;
1305 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1306 if (!surface) return;
1308 comp_conf = e_comp_config_get();
1309 if (comp_conf && comp_conf->input_log_enable)
1310 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1311 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1312 e_client_util_name_get(ec));
1314 if (_e_comp_wl_check_cursor_timer_needed(ec))
1316 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1320 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1322 wc = wl_resource_get_client(surface);
1323 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1324 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1326 if (!e_comp_wl_input_pointer_check(res)) continue;
1327 if (wl_resource_get_client(res) != wc) continue;
1328 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1330 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1332 wl_pointer_send_leave(res, serial, surface);
1333 ec->pointer_enter_sent = EINA_FALSE;
1338 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1341 struct wl_client *wc;
1342 struct wl_resource *res;
1345 E_Comp_Config *comp_conf = NULL;
1348 if (e_object_is_del(E_OBJECT(ec))) return;
1349 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1350 if (!surface) return;
1352 wc = wl_resource_get_client(surface);
1353 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1357 x = wl_fixed_from_int(canvas_x - ec->client.x);
1358 y = wl_fixed_from_int(canvas_y - ec->client.y);
1361 comp_conf = e_comp_config_get();
1363 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1365 if (wl_resource_get_client(res) != wc) continue;
1366 if (!e_comp_wl_input_touch_check(res)) continue;
1367 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1370 if (comp_conf && comp_conf->input_log_enable)
1371 ELOGF("Touch", "Down (id: %d, time: %d, x:%d, y:%d, name:%20s)", ec, idx, timestamp, canvas_x - ec->client.x, canvas_y - ec->client.y, e_client_util_name_get(ec));
1373 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1377 if (comp_conf && comp_conf->input_log_enable)
1378 ELOGF("Touch", "Up (id: %d, time: %d, x:%d, y:%d, name:%20s)\n", ec, idx, timestamp, canvas_x - ec->client.x, canvas_y - ec->client.y, e_client_util_name_get(ec));
1380 wl_touch_send_up(res, serial, timestamp, idx);
1387 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1390 struct wl_client *wc;
1391 struct wl_resource *res;
1395 if (ec->cur_mouse_action) return;
1396 if (e_object_is_del(E_OBJECT(ec))) return;
1397 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1398 if (!surface) return;
1400 wc = wl_resource_get_client(surface);
1402 x = wl_fixed_from_int(canvas_x - ec->client.x);
1403 y = wl_fixed_from_int(canvas_y - ec->client.y);
1405 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1407 if (wl_resource_get_client(res) != wc) continue;
1408 if (!e_comp_wl_input_touch_check(res)) continue;
1409 wl_touch_send_motion(res, timestamp, idx, x, y);
1414 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1416 struct wl_resource *res;
1417 struct wl_client *wc;
1421 if (ec->cur_mouse_action) return;
1422 if (e_object_is_del(E_OBJECT(ec))) return;
1423 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1424 if (!surface) return;
1426 wc = wl_resource_get_client(surface);
1427 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1429 if (!e_comp_wl_input_pointer_check(res)) continue;
1430 if (wl_resource_get_client(res) != wc) continue;
1431 wl_pointer_send_motion(res, timestamp,
1432 wl_fixed_from_int(x - ec->client.x),
1433 wl_fixed_from_int(y - ec->client.y));
1438 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1440 if (e_comp_wl->ptr.hide_tmr)
1442 if (cursor_timer_ec == ec)
1444 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1445 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1449 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1450 cursor_timer_ec = ec;
1451 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1456 cursor_timer_ec = ec;
1457 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1462 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1465 Evas_Event_Mouse_Move *ev;
1466 Evas_Device *dev = NULL;
1467 const char *dev_name;
1468 E_Comp_Config *comp_conf;
1472 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1473 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1475 if (!(ec = data)) return;
1476 if (e_object_is_del(E_OBJECT(ec))) return;
1477 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1478 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1479 if (!surface) return;
1481 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1484 dev_name = evas_device_description_get(dev);
1486 comp_conf = e_comp_config_get();
1487 if (comp_conf && comp_conf->input_log_enable)
1488 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1489 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1490 e_client_util_name_get(ec), dev_name);
1492 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1494 if (!e_comp_wl->drag_client)
1496 e_comp_wl->touch.faked_ec = ec;
1497 if (e_comp_wl->touch.pressed & (1 << 0))
1499 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1501 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1502 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1503 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1507 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1511 if (!e_comp_wl->drag_client)
1513 if (_e_comp_wl_check_cursor_timer_needed(ec))
1515 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1519 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1520 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1522 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1524 if (_e_comp_wl_check_cursor_timer_needed(ec))
1525 _e_comp_wl_cursor_move_timer_control(ec);
1529 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1534 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1536 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1537 if (e_object_is_del(E_OBJECT(ec))) return;
1538 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1539 if (!surface) return;
1540 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1542 e_comp_wl->ptr.button = BTN_LEFT;
1544 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1548 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1550 E_Client *ec = data;
1551 Evas_Event_Mouse_Down *ev = event;
1552 Evas_Device *dev = NULL;
1553 const Evas_Device *seat_dev;
1554 const char *dev_name, *seat_name;
1555 E_Comp_Config *comp_conf = NULL;
1558 if (e_object_is_del(E_OBJECT(ec))) return;
1561 dev_name = evas_device_description_get(dev);
1563 seat_dev = evas_device_parent_get(dev);
1564 seat_name = evas_device_name_get(seat_dev);
1566 comp_conf = e_comp_config_get();
1567 if (comp_conf && comp_conf->input_log_enable)
1568 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1569 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1570 dev_name, seat_name);
1572 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1574 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1576 e_comp_wl->touch.faked_ec = ec;
1579 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1580 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1581 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1583 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1584 e_comp_wl->touch.pressed |= (1 << 0);
1588 if (_e_comp_wl_check_cursor_timer_needed(ec))
1590 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1594 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1595 WL_POINTER_BUTTON_STATE_PRESSED);
1597 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1600 need_send_released = EINA_TRUE;
1604 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1606 E_Client *ec = data;
1607 Evas_Event_Mouse_Up *ev = event;
1608 Evas_Device *dev = NULL;
1609 const Evas_Device *seat_dev;
1610 const char *dev_name, *seat_name;;
1611 Evas_Event_Flags flags;
1612 E_Comp_Config *comp_conf = NULL;
1615 if (ec->cur_mouse_action) return;
1616 if (e_object_is_del(E_OBJECT(ec))) return;
1618 if (!need_send_released)
1620 need_send_motion = EINA_TRUE;
1624 dev_name = evas_device_description_get(dev);
1626 seat_dev = evas_device_parent_get(dev);
1627 seat_name = evas_device_name_get(seat_dev);
1628 flags = evas_event_default_flags_get(evas);
1630 comp_conf = e_comp_config_get();
1631 if (comp_conf && comp_conf->input_log_enable)
1632 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1633 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1634 dev_name, seat_name);
1636 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1638 e_comp_wl->touch.pressed &= ~(1 << 0);
1640 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1641 e_comp_wl->touch.faked_ec = NULL;
1644 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1646 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1648 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1651 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1652 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1653 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1657 if (_e_comp_wl_check_cursor_timer_needed(ec))
1659 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1663 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1664 WL_POINTER_BUTTON_STATE_RELEASED);
1666 if (_e_comp_wl_check_cursor_timer_needed(ec))
1667 _e_comp_wl_cursor_move_timer_control(ec);
1671 need_send_released = EINA_FALSE;
1675 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1677 struct wl_resource *res;
1678 struct wl_client *wc;
1683 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1685 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1688 dir = -wl_fixed_from_int(abs(z));
1690 dir = wl_fixed_from_int(z);
1693 if (e_object_is_del(E_OBJECT(ec))) return;
1694 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1695 if (!surface) return;
1697 wc = wl_resource_get_client(surface);
1698 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1700 if (!e_comp_wl_input_pointer_check(res)) continue;
1701 if (wl_resource_get_client(res) != wc) continue;
1702 wl_pointer_send_axis(res, timestamp, axis, dir);
1707 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1710 Evas_Event_Mouse_Wheel *ev;
1713 if (!(ec = data)) return;
1714 if (ec->cur_mouse_action) return;
1715 if (e_object_is_del(E_OBJECT(ec))) return;
1716 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1717 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1718 if (!surface) return;
1720 if (!eina_list_count(e_comp_wl->ptr.resources))
1723 if (_e_comp_wl_check_cursor_timer_needed(ec))
1725 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1729 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1731 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1733 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1735 if (_e_comp_wl_check_cursor_timer_needed(ec))
1736 _e_comp_wl_cursor_move_timer_control(ec);
1741 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1743 E_Client *ec = data;
1744 Evas_Event_Multi_Down *ev = event;
1745 Evas_Device *dev = NULL;
1746 const Evas_Device *seat_dev;
1747 const char *dev_name, *seat_name;
1748 Evas_Device_Class dev_class;
1749 E_Comp_Config *comp_conf = NULL;
1752 if (e_object_is_del(E_OBJECT(ec))) return;
1753 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1754 if (!surface) return;
1756 /* Do not deliver emulated single touch events to client */
1757 if (ev->device == 0) return;
1760 dev_name = evas_device_description_get(dev);
1761 e_comp_wl->touch.faked_ec = ec;
1763 seat_dev = evas_device_parent_get(dev);
1764 seat_name = evas_device_name_get(seat_dev);
1766 comp_conf = e_comp_config_get();
1767 if (comp_conf && comp_conf->input_log_enable)
1768 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1769 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1770 dev_name, seat_name);
1772 if (dev && dev_name)
1774 dev_class = evas_device_class_get(dev);
1775 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1776 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1779 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1780 e_comp_wl->touch.pressed |= (1 << ev->device);
1784 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1786 E_Client *ec = data;
1787 Evas_Event_Multi_Up *ev = event;
1788 Evas_Device *dev = NULL;
1789 const Evas_Device *seat_dev;
1790 const char *dev_name, *seat_name;
1791 Evas_Device_Class dev_class;
1792 Evas_Event_Flags flags;
1793 E_Comp_Config *comp_conf = NULL;
1796 if (e_object_is_del(E_OBJECT(ec))) return;
1797 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1798 if (!surface) return;
1800 /* Do not deliver emulated single touch events to client */
1801 if (ev->device == 0) return;
1803 flags = evas_event_default_flags_get(evas);
1805 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1806 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1807 e_comp_wl->touch.faked_ec = NULL;
1809 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1812 dev_name = evas_device_description_get(dev);
1814 seat_dev = evas_device_parent_get(dev);
1815 seat_name = evas_device_name_get(seat_dev);
1817 comp_conf = e_comp_config_get();
1818 if (comp_conf && comp_conf->input_log_enable)
1819 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1820 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1821 dev_name, seat_name);
1823 if (dev && dev_name)
1825 dev_class = evas_device_class_get(dev);
1826 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1827 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1830 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1834 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1836 E_Client *ec = data;
1837 Evas_Event_Multi_Move *ev = event;
1838 Evas_Device *dev = NULL;
1839 const char *dev_name;
1840 Evas_Device_Class dev_class;
1843 if (e_object_is_del(E_OBJECT(ec))) return;
1844 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1845 if (!surface) return;
1847 /* Do not deliver emulated single touch events to client */
1848 if (ev->device == 0) return;
1850 e_comp_wl->touch.faked_ec = ec;
1852 if (e_comp_wl->touch.pressed & (1 << ev->device))
1855 if (dev && (dev_name = evas_device_description_get(dev)))
1857 dev_class = evas_device_class_get(dev);
1858 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1859 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1862 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1867 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1870 char *file, buff[PATH_MAX];
1877 n = (getpriority(PRIO_PROCESS, pid) + adj);
1881 setpriority(PRIO_PROCESS, pid, n);
1884 use_adj = EINA_TRUE;
1886 if (!do_child) return;
1888 files = ecore_file_ls("/proc");
1889 EINA_LIST_FREE(files, file)
1891 if (!isdigit(file[0]))
1894 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1895 if ((f = fopen(buff, "r")))
1899 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1901 if (num_read == 2 && ppid == pid)
1902 _e_comp_wl_client_priority_adjust(pid2, set,
1904 adj_child, do_child);
1912 _e_comp_wl_client_priority_raise(E_Client *ec)
1914 if (!e_config->priority_control) return;
1915 if (ec->netwm.pid <= 0) return;
1916 if (ec->netwm.pid == getpid()) return;
1917 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1918 e_config->priority - 1, -1,
1919 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1923 _e_comp_wl_client_priority_normal(E_Client *ec)
1925 if (!e_config->priority_control) return;
1926 if (ec->netwm.pid <= 0) return;
1927 if (ec->netwm.pid == getpid()) return;
1928 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1929 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1933 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1936 E_Comp_Wl_Key_Data *k;
1937 struct wl_resource *res;
1941 if (!ec) return EINA_FALSE;
1942 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1943 if (!ec->comp_data) return EINA_FALSE;
1945 ec->comp_data->on_focus_timer = NULL;
1946 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1947 if (!e_comp_wl->kbd.focused)
1949 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1952 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1954 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1955 t = ecore_time_unix_get();
1957 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1958 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1959 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1961 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1963 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1964 wl_keyboard_send_key(res, serial, t,
1965 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1968 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1969 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1973 /* It is called in the following cases:
1974 * When a normal ec->frame has focus.
1975 * Or launching image ec is replaced to the real ec.
1978 e_comp_wl_feed_focus_in(E_Client *ec)
1981 struct wl_resource *res;
1982 struct wl_client *wc;
1986 if (e_object_is_del(E_OBJECT(ec))) return;
1987 if (ec->iconic) return;
1989 /* block spurious focus events */
1990 focused = e_client_focused_get();
1991 if ((focused) && (ec != focused)) return;
1993 /* raise client priority */
1994 _e_comp_wl_client_priority_raise(ec);
1995 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1996 if (!surface) return;
1998 wc = wl_resource_get_client(surface);
2000 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2001 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2003 if (wl_resource_get_client(res) == wc)
2005 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2006 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2007 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2008 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2011 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2013 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2014 if (!e_comp_wl->kbd.focused)
2016 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2019 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2021 e_comp_wl->kbd.focus = surface;
2022 e_comp_wl_input_keyboard_enter_send(ec);
2023 e_comp_wl_data_device_keyboard_focus_set();
2024 ec->comp_data->on_focus_timer =
2025 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2026 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2027 int rotation = ec->e.state.rot.ang.curr;
2028 e_pointer_rotation_set(e_comp->pointer, rotation);
2032 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2035 if (!(ec = data)) return;
2036 e_comp_wl_feed_focus_in(ec);
2040 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2043 struct wl_resource *res;
2045 E_Comp_Wl_Key_Data *k;
2049 if (!(ec = data)) return;
2051 if (!ec->comp_data) return;
2053 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2055 /* lower client priority */
2056 if (!e_object_is_del(data))
2057 _e_comp_wl_client_priority_normal(ec);
2060 /* update keyboard modifier state */
2061 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2062 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2063 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2065 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2067 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2068 if (!surface) return;
2070 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2071 if (!eina_list_count(e_comp_wl->kbd.resources))
2073 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2077 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2079 /* send keyboard_leave to all keyboard resources */
2080 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2081 t = ecore_time_unix_get();
2083 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2084 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2085 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2087 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2089 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2090 wl_keyboard_send_key(res, serial, t,
2091 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2093 wl_keyboard_send_leave(res, serial, surface);
2094 e_comp_wl->kbd.focused =
2095 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2097 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2098 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2102 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2106 if (!(ec = data)) return;
2108 if ((ec->shading) || (ec->shaded)) return;
2109 if (!ec->comp_data->shell.configure_send) return;
2111 /* TODO: calculate x, y with transfrom object */
2112 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2116 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2117 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2118 if (e_comp_object_frame_exists(ec->frame))
2119 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2121 switch (ec->resize_mode)
2123 case E_POINTER_RESIZE_TL:
2124 case E_POINTER_RESIZE_L:
2125 case E_POINTER_RESIZE_BL:
2126 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2127 ec->mouse.current.mx;
2129 case E_POINTER_RESIZE_TR:
2130 case E_POINTER_RESIZE_R:
2131 case E_POINTER_RESIZE_BR:
2132 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2137 switch (ec->resize_mode)
2139 case E_POINTER_RESIZE_TL:
2140 case E_POINTER_RESIZE_T:
2141 case E_POINTER_RESIZE_TR:
2142 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2143 ec->mouse.current.my;
2145 case E_POINTER_RESIZE_BL:
2146 case E_POINTER_RESIZE_B:
2147 case E_POINTER_RESIZE_BR:
2148 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2153 w = E_CLAMP(w, 1, w);
2154 h = E_CLAMP(h, 1, h);
2155 e_client_resize_limit(ec, &w, &h);
2157 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
2158 e_comp_wl->resize.edges,
2161 else if ((!ec->fullscreen) && (!ec->maximized) &&
2162 (!ec->comp_data->maximize_pre))
2166 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2167 if ((pw != ec->w) || (ph != ec->h))
2169 _e_comp_wl_configure_send(ec, 1, 1);
2173 if (ec->comp_data->sub.below_obj)
2174 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2178 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2180 E_Client *ec = data;
2182 ec->comp_data->maximize_pre = 1;
2186 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2188 E_Client *ec = data;
2191 if (e_object_is_del(E_OBJECT(ec))) return;
2193 if (ec->comp_data->shell.configure_send)
2195 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2196 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, 0, w, h);
2198 ec->comp_data->maximize_pre = 0;
2202 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2204 E_Client *ec = data;
2206 ec->comp_data->maximize_pre = 1;
2210 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2212 E_Client *ec = data;
2214 if (e_object_is_del(E_OBJECT(ec))) return;
2216 /* check for wayland pixmap */
2218 if (ec->comp_data->shell.configure_send)
2219 _e_comp_wl_configure_send(ec, 0, 0);
2221 ec->comp_data->maximize_pre = 0;
2225 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2227 E_Client *ec = data;
2229 if (e_object_is_del(E_OBJECT(ec))) return;
2231 /* check for wayland pixmap */
2233 if (ec->comp_data->shell.configure_send)
2234 _e_comp_wl_configure_send(ec, 0, 1);
2236 ec->comp_data->maximize_pre = 0;
2240 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2242 E_Client *ec = data;
2244 if (e_object_is_del(E_OBJECT(ec))) return;
2246 /* check for wayland pixmap */
2248 if (ec->comp_data->shell.configure_send)
2249 _e_comp_wl_configure_send(ec, 0, 0);
2251 ec->comp_data->maximize_pre = 0;
2255 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2259 if (!(ec = data)) return;
2261 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2263 e_object_del(E_OBJECT(ec));
2265 _e_comp_wl_focus_check();
2267 /* TODO: Delete request send ??
2268 * NB: No such animal wrt wayland */
2272 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2276 if (!(ec = data)) return;
2278 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2281 if (ec->comp_data->reparented)
2282 e_client_comp_hidden_set(ec, EINA_TRUE);
2285 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2286 if (ec->visible) evas_object_hide(ec->frame);
2287 if (!ec->internal) e_object_del(E_OBJECT(ec));
2289 _e_comp_wl_focus_check();
2293 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2297 if (!(ec = data)) return;
2298 if (!(ec->comp_data)) return;
2299 if (!(ec->comp_data->shell.ping)) return;
2300 if (!(ec->comp_data->shell.surface)) return;
2302 ec->comp_data->shell.ping(ec->comp_data->shell.surface);
2306 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2311 if (!(ec = data)) return;
2312 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2313 if (ec->netwm.opacity == a) return;
2314 ec->netwm.opacity = a;
2315 ec->netwm.opacity_changed = EINA_TRUE;
2319 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2321 Eina_Rectangle *damage_rect = NULL;
2322 Eina_Rectangle *dmg = NULL;
2323 Eina_List *l = NULL;
2325 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2326 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2329 if (!buffer->tbm_surface) return;
2333 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2337 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2338 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2341 eina_rectangle_union(damage_rect, dmg);
2346 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2347 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2350 tbm_surface_internal_set_damage(buffer->tbm_surface,
2356 eina_rectangle_free(damage_rect);
2360 _e_comp_wl_client_evas_init(E_Client *ec)
2362 if (!ec || !ec->comp_data) return;
2363 if (ec->comp_data->evas_init) return;
2365 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2366 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2367 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2370 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2371 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2372 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2373 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2374 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2375 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2377 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2378 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2379 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2381 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2382 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2386 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2387 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2388 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2389 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2390 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2391 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2392 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2395 /* setup delete/kill callbacks */
2396 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2397 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2399 /* setup ping callback */
2400 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2401 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2403 ec->comp_data->evas_init = EINA_TRUE;
2407 _e_comp_wl_client_evas_deinit(E_Client *ec)
2409 if (!ec || !ec->comp_data) return;
2410 if (!ec->comp_data->evas_init) return;
2412 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2413 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2414 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2416 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2417 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2418 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2419 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2420 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2421 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2423 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2424 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2425 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2427 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2428 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2432 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2433 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2434 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2435 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2436 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2437 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2438 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2441 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2442 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2444 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2445 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2447 ec->comp_data->evas_init = EINA_FALSE;
2451 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2455 E_Comp_Screen *e_comp_screen;
2456 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2458 if (!e_comp) return ECORE_CALLBACK_RENEW;
2459 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2460 e_comp_screen = e_comp->e_comp_screen;
2462 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2464 if (!eout->config.enabled)
2466 e_comp_wl_output_remove(eout->id);
2470 switch (eout->config.rotation)
2473 transform = WL_OUTPUT_TRANSFORM_90;
2476 transform = WL_OUTPUT_TRANSFORM_180;
2479 transform = WL_OUTPUT_TRANSFORM_270;
2483 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2487 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2489 eout->config.geom.x, eout->config.geom.y,
2490 eout->config.geom.w, eout->config.geom.h,
2491 eout->info.size.w, eout->info.size.h,
2492 eout->config.mode.refresh, 0, transform))
2493 ERR("Could not initialize screen %s", eout->info.name);
2496 return ECORE_CALLBACK_RENEW;
2500 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2504 /* try to get the client from the object */
2505 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2506 return ECORE_CALLBACK_RENEW;
2508 /* check for client being deleted */
2509 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2511 /* check for wayland pixmap */
2512 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2513 return ECORE_CALLBACK_RENEW;
2515 /* if we have not setup evas callbacks for this client, do it */
2516 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2518 return ECORE_CALLBACK_RENEW;
2522 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2526 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2527 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2529 if (e_comp_wl->selection.target &&
2532 struct wl_resource *res;
2534 E_Client *ec = NULL;
2535 E_Client *legacy_target = e_comp_wl->selection.target;
2536 int device_id = e_comp_wl_data_current_device_id_get();
2540 e_comp_wl_data_current_device_id_set(ev->multi.device);
2542 else if (device_id != ev->multi.device)
2544 return ECORE_CALLBACK_RENEW;
2547 ec = e_client_input_rect_under_pointer_get(legacy_target->desk, e_comp_wl->drag_client);
2548 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2550 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2551 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2553 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2554 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2556 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2557 (ec != legacy_target))
2559 e_comp_wl_data_device_send_leave(legacy_target);
2560 e_comp_wl_data_device_send_enter(ec);
2563 if (e_comp_wl->drag)
2564 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2566 if (e_client_transform_core_enable_get(ec))
2568 int trans_x, trans_y;
2569 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2570 x = trans_x - ec->client.x;
2571 y = trans_y - ec->client.y;
2575 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2580 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2583 return ECORE_CALLBACK_RENEW;
2587 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2590 struct wl_resource *surface;
2591 struct wl_resource *res;
2592 struct wl_client *wc;
2594 E_Comp_Config *comp_conf;
2596 ec = e_comp_wl->ptr_constraints.ec;
2597 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2599 surface = e_comp_wl_client_surface_get(ec);
2600 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2602 wc = wl_resource_get_client(surface);
2604 comp_conf = e_comp_config_get();
2606 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2608 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2609 if (wl_resource_get_client(res) != wc) continue;
2611 if (comp_conf && comp_conf->input_log_enable)
2612 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2613 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2614 e_client_util_name_get(ec));
2616 zwp_relative_pointer_v1_send_relative_motion(res,
2618 (uint32_t)(ev->timestamp),
2619 wl_fixed_from_int(ev->dx),
2620 wl_fixed_from_int(ev->dy),
2621 wl_fixed_from_int(ev->dx_unaccel),
2622 wl_fixed_from_int(ev->dy_unaccel));
2625 return ECORE_CALLBACK_DONE;
2629 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2631 _e_comp_wl_touch_cancel();
2633 return ECORE_CALLBACK_PASS_ON;
2637 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2639 if (!ev) return ECORE_CALLBACK_PASS_ON;
2641 E_Zone *zone = ev->zone;
2643 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2644 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2646 if (!e_zone_is_displaying(zone))
2647 _e_comp_wl_touch_cancel();
2649 return ECORE_CALLBACK_PASS_ON;
2653 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2655 E_Client *ec = ev->ec;
2656 E_Comp_Wl_Buffer_Viewport *vp;
2658 if (!ec) return ECORE_CALLBACK_PASS_ON;
2659 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2660 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2661 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2662 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2664 vp = &ec->comp_data->scaler.buffer_viewport;
2665 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2667 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2669 return ECORE_CALLBACK_PASS_ON;
2673 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2675 E_Client *ec = ev->ec;
2676 E_Comp_Wl_Buffer_Viewport *vp;
2678 if (!ec) return ECORE_CALLBACK_PASS_ON;
2679 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2680 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2681 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2683 vp = &ec->comp_data->scaler.buffer_viewport;
2684 vp->wait_for_transform_change = 0;
2686 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2688 return ECORE_CALLBACK_PASS_ON;
2692 _e_comp_wl_cb_client_rot_change_end(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_End *ev EINA_UNUSED)
2694 E_Client *focused_ec;
2697 focused_ec = e_client_focused_get();
2698 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2700 rotation = focused_ec->e.state.rot.ang.curr;
2701 e_pointer_rotation_set(e_comp->pointer, rotation);
2703 return ECORE_CALLBACK_PASS_ON;
2707 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2710 Eina_Rectangle *window;
2715 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2717 if ((prev_w != state->bw) ||
2718 (prev_h != state->bh))
2720 ec->changes.buf_size = EINA_TRUE;
2723 if (e_comp_object_frame_exists(ec->frame)) return;
2724 window = &ec->comp_data->shell.window;
2725 if ((!ec->borderless) && /* FIXME temporarily added this check code
2726 * to prevent updating E_Client's size by frame */
2727 (window->x || window->y || window->w || window->h))
2729 e_comp_object_frame_geometry_set(ec->frame,
2731 (window->x + window->w) - state->bw,
2733 (window->y + window->h) - state->bh);
2736 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2740 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2742 E_Comp_Wl_Surface_State *state;
2745 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2746 state->buffer = NULL;
2750 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2752 state->new_attach = EINA_FALSE;
2753 state->buffer = NULL;
2754 state->buffer_destroy_listener.notify =
2755 _e_comp_wl_surface_state_cb_buffer_destroy;
2756 state->sx = state->sy = 0;
2758 state->input = eina_tiler_new(w, h);
2759 eina_tiler_tile_size_set(state->input, 1, 1);
2761 state->opaque = eina_tiler_new(w, h);
2762 eina_tiler_tile_size_set(state->opaque, 1, 1);
2764 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2765 state->buffer_viewport.buffer.scale = 1;
2766 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2767 state->buffer_viewport.surface.width = -1;
2768 state->buffer_viewport.changed = 0;
2770 e_presentation_time_container_init(&state->presentation_container);
2774 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2776 struct wl_resource *cb;
2777 Eina_Rectangle *dmg;
2779 EINA_LIST_FREE(state->frames, cb)
2780 wl_resource_destroy(cb);
2782 EINA_LIST_FREE(state->damages, dmg)
2783 eina_rectangle_free(dmg);
2785 EINA_LIST_FREE(state->buffer_damages, dmg)
2786 eina_rectangle_free(dmg);
2788 if (state->opaque) eina_tiler_free(state->opaque);
2789 state->opaque = NULL;
2791 if (state->input) eina_tiler_free(state->input);
2792 state->input = NULL;
2794 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2795 state->buffer = NULL;
2797 e_presentation_time_container_finish(&state->presentation_container);
2801 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2803 if (state->buffer == buffer) return;
2805 wl_list_remove(&state->buffer_destroy_listener.link);
2806 state->buffer = buffer;
2808 wl_signal_add(&state->buffer->destroy_signal,
2809 &state->buffer_destroy_listener);
2813 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2815 Eina_Rectangle *dmg;
2816 Eina_Bool placed = EINA_TRUE;
2820 E_Comp_Wl_Buffer *buffer;
2821 struct wl_resource *cb;
2823 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2824 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2829 if ((ec->internal) ||
2830 (cdata->shell.surface && state->new_attach))
2834 e_comp->new_clients++;
2835 ELOGF("COMP", "Unignore", ec);
2836 e_client_unignore(ec);
2840 /* buffer transform */
2841 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2844 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2846 /* when buffer is transformed, we have to apply the new evas-map */
2847 state->buffer_viewport.changed = EINA_TRUE;
2849 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2851 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2853 if (transform_change == vp->wait_for_transform_change)
2854 vp->wait_for_transform_change = 0;
2856 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2857 // triggered by E_CLIENT_HOOK calls at those file.
2858 zone = e_comp_zone_find_by_ec(ec);
2861 eout = e_output_find(zone->output_id);
2862 if (eout && eout->hwc)
2864 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2866 if (e_comp_is_on_overlay(ec))
2867 e_comp_hwc_client_end(ec, __FUNCTION__);
2873 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2874 cdata->scaler.buffer_viewport = state->buffer_viewport;
2876 if (state->new_attach)
2878 e_comp_wl_surface_attach(ec, state->buffer);
2881 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2882 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2884 _e_comp_wl_surface_state_buffer_set(state, NULL);
2886 if ((state->new_attach) ||
2887 (state->buffer_viewport.changed))
2889 _e_comp_wl_surface_state_size_update(ec, state);
2890 e_comp_wl_map_size_cal_from_viewport(ec);
2892 /* update the position */
2893 if (ec->changes.pos)
2895 e_comp_object_frame_xy_unadjust(ec->frame,
2905 if (ec->new_client) placed = ec->placed;
2907 if (!ec->lock_client_size)
2912 ec->client.w = state->bw;
2913 ec->client.h = state->bh;
2915 e_comp_object_frame_wh_adjust(ec->frame,
2916 ec->client.w, ec->client.h,
2918 e_client_size_set(ec, nw, nh);
2920 if ((w != ec->w) || (h != ec->h))
2922 ec->changes.size = 1;
2927 if (ec->changes.buf_size)
2929 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2930 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2931 ec->changes.buf_size = EINA_FALSE;
2933 if (ec->move_after_resize)
2935 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2936 ec->move_after_resize = EINA_FALSE;
2941 /* map or unmap ec */
2942 if (!e_pixmap_usable_get(ec->pixmap))
2947 if ((cdata->shell.surface) &&
2948 (cdata->shell.unmap))
2950 ELOGF("COMP", "Try to unmap. Call shell.unmap.", ec);
2951 if (ec->show_pending.count > 0)
2953 ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
2954 ec->show_pending.count = 0;
2955 if (ec->show_pending.running)
2957 // need to send visibility false;
2958 ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
2959 ELOGF("POL_VIS", "CLIENT VIS ON (fake). argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
2962 ec->show_pending.running = EINA_FALSE;
2964 cdata->shell.unmap(cdata->shell.surface);
2966 else if ((ec->internal) ||
2967 (e_comp_wl_subsurface_check(ec)) ||
2968 (ec == e_comp_wl->drag_client))
2970 ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
2971 ec, ec->internal, cdata->sub.data, (ec == e_comp_wl->drag_client));
2972 ec->visible = EINA_FALSE;
2973 evas_object_hide(ec->frame);
2978 if ((cdata->sub.below_obj) &&
2979 (evas_object_visible_get(cdata->sub.below_obj)))
2981 evas_object_hide(cdata->sub.below_obj);
2989 if ((cdata->shell.surface) &&
2990 (cdata->shell.map) &&
2993 ELOGF("COMP", "Try to map. Call shell.map.", ec);
2994 cdata->shell.map(cdata->shell.surface);
2996 else if ((ec->internal) ||
2997 (e_comp_wl_subsurface_can_show(ec)) ||
2998 (ec == e_comp_wl->drag_client))
3000 ELOGF("COMP", "Try to map. Show window. internal:%d, drag:%d",
3001 ec, ec->internal, (ec == e_comp_wl->drag_client));
3002 ec->visible = EINA_TRUE;
3004 evas_object_show(ec->frame);
3009 if ((cdata->sub.below_obj) &&
3010 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3011 (evas_object_visible_get(ec->frame)))
3013 evas_object_show(cdata->sub.below_obj);
3017 if ((state->new_attach) ||
3018 (state->buffer_viewport.changed))
3020 if ((e_comp_wl->drag) &&
3021 (e_comp_wl->drag_client) &&
3022 (e_comp_wl->drag_client == ec))
3024 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3026 e_drag_move(e_comp_wl->drag,
3028 e_comp_wl->drag->y);
3030 e_drag_resize(e_comp_wl->drag,
3031 state->bw, state->bh);
3033 else if ((cdata->shell.surface) &&
3034 (cdata->shell.configure))
3036 e_comp_wl_commit_sync_configure(ec);
3038 else if (!e_client_video_hw_composition_check(ec))
3040 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3045 ec->placed = placed;
3046 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3050 if (cdata->scaler.buffer_viewport.changed)
3051 e_comp_wl_map_apply(ec);
3053 /* resize transform object */
3054 if (ec->transformed)
3055 e_client_transform_update(ec);
3059 state->new_attach = EINA_FALSE;
3061 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3063 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3064 wl_resource_destroy(cb);
3067 /* insert state frame callbacks into comp_data->frames
3068 * NB: This clears state->frames list */
3069 cdata->frames = eina_list_merge(cdata->frames,
3071 state->frames = NULL;
3073 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3074 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3075 &state->presentation_container);
3077 buffer = e_pixmap_resource_get(ec->pixmap);
3079 /* put state damages into surface */
3082 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3083 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3085 if ((cdata->buffer_ref.buffer) &&
3086 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3087 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3089 e_comp_object_damage(ec->frame,
3091 cdata->buffer_ref.buffer->w,
3092 cdata->buffer_ref.buffer->h);
3097 Eina_List *damages = NULL;
3100 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3102 if (eina_list_count(state->buffer_damages))
3104 EINA_LIST_FREE(state->buffer_damages, dmg)
3107 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3108 e_comp_wl_output_buffer_transform_get(ec),
3110 dmg->x, dmg->y, dmg->w, dmg->h,
3111 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3112 damages = eina_list_append(damages, dmg);
3116 EINA_LIST_FREE(state->damages, dmg)
3117 damages = eina_list_append(damages, dmg);
3119 EINA_LIST_FREE(damages, dmg)
3121 /* not creating damage for ec that shows a underlay video */
3122 if (state->buffer_viewport.changed ||
3123 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3124 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3125 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3127 eina_rectangle_free(dmg);
3132 /* put state opaque into surface */
3133 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3136 Eina_Rectangle *rect;
3139 itr = eina_tiler_iterator_new(state->opaque);
3140 EINA_ITERATOR_FOREACH(itr, rect)
3144 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3145 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3146 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3150 eina_iterator_free(itr);
3153 /* put state input into surface */
3154 if ((state->input) &&
3155 (!eina_tiler_empty(state->input)) &&
3158 Eina_Tiler *src, *tmp;
3162 tmp = eina_tiler_new(sw, sh);
3163 eina_tiler_tile_size_set(tmp, 1, 1);
3165 eina_tiler_rect_add(tmp,
3166 &(Eina_Rectangle){0, 0, sw, sh});
3168 if ((src = eina_tiler_intersection(state->input, tmp)))
3170 Eina_Rectangle *rect;
3173 e_comp_object_input_objs_del(ec->frame);
3174 itr = eina_tiler_iterator_new(src);
3175 EINA_ITERATOR_FOREACH(itr, rect)
3177 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3178 ec, rect->x, rect->y, rect->w, rect->h,
3179 ec->w, ec->h, state->bw, state->bh);
3180 e_comp_object_input_area_set(ec->frame,
3185 eina_iterator_free(itr);
3186 eina_tiler_free(src);
3189 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3191 eina_tiler_free(tmp);
3193 /* clear input tiler */
3194 eina_tiler_clear(state->input);
3197 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3199 if ((cdata->video_client) &&
3201 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3202 (e_comp->wl_comp_data->available_hw_accel.underlay))
3204 e_pixmap_image_clear(ec->pixmap, 1);
3207 state->buffer_viewport.changed = 0;
3209 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3212 ec->exp_iconify.buffer_flush &&
3213 e_policy_visibility_client_is_iconic(ec))
3215 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3220 _e_comp_wl_surface_render_stop(E_Client *ec)
3222 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3223 //if ((!ec->internal) && (!e_comp_gl_get()))
3226 /* check if internal animation is running */
3227 if (e_comp_object_is_animating(ec->frame)) return;
3228 /* check if external animation is running */
3229 if (evas_object_data_get(ec->frame, "effect_running")) return;
3231 evas_object_hide(ec->frame);
3235 e_comp_wl_client_surface_finish(E_Client *ec)
3237 struct wl_resource *res, *surface;
3238 struct wl_client *surface_client = NULL;
3241 surface = e_comp_wl_client_surface_get(ec);
3244 surface_client = wl_resource_get_client(surface);
3246 if (surface_client &&
3247 (ec == e_client_focused_get()))
3249 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3250 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3252 if (wl_resource_get_client(res) ==
3254 e_comp_wl->kbd.focused =
3255 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3259 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3262 e_comp_wl_client_surface_set(ec, NULL);
3264 ec->comp_data->wl_surface = NULL;
3265 e_pixmap_win_id_del(ec->pixmap);
3267 _e_comp_wl_surface_render_stop(ec);
3268 e_object_del(E_OBJECT(ec));
3272 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3277 char proc[512], pname[512];
3280 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3282 h = fopen(proc, "r");
3285 len = fread(pname, sizeof(char), 512, h);
3287 pname[len - 1] = '\0';
3289 strncpy(pname, "NO NAME", sizeof(pname));
3295 strncpy(pname, "NO NAME", sizeof(pname));
3298 strncpy(name, pname, size);
3302 _e_comp_wl_pname_print(pid_t pid)
3305 char proc[512], pname[512];
3308 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3310 h = fopen(proc, "r");
3313 len = fread(pname, sizeof(char), 512, h);
3315 pname[len - 1] = '\0';
3317 strncpy(pname, "NO NAME", sizeof(pname));
3321 ELOGF("COMP", " |%s", NULL, pname);
3326 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3328 struct wl_client *client = data;
3329 E_Comp_Connected_Client_Info *cinfo;
3332 cinfo = wl_container_of(listener, cinfo, destroy);
3334 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3335 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3337 eai = e_appinfo_find_with_pid(cinfo->pid);
3338 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3341 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3343 wl_list_remove(&cinfo->destroy.link);
3344 eina_stringshare_del(cinfo->name);
3349 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3351 E_Comp_Connected_Client_Info *cinfo;
3353 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3354 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3356 cinfo->name = eina_stringshare_add(name);
3360 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3361 wl_client_add_destroy_listener(client, &cinfo->destroy);
3362 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3364 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3368 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3370 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3372 /* send configure */
3373 if (ec->comp_data->shell.configure_send)
3375 if (ec->comp_data->shell.surface)
3376 _e_comp_wl_configure_send(ec, 0, 0);
3379 e_comp_wl->kbd.focus = ec->comp_data->surface;
3383 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3385 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3387 /* send configure */
3388 if (ec->comp_data->shell.configure_send)
3390 if (ec->comp_data->shell.surface)
3391 _e_comp_wl_configure_send(ec, 0, 0);
3394 _e_comp_wl_focus_check();
3396 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3397 e_comp_wl->kbd.focus = NULL;
3401 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3403 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3404 if (ec->keyboard_resizing) return;
3406 /* do nothing currently */
3411 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3413 if (e_object_is_del(E_OBJECT(ec))) return;
3414 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3416 e_comp_wl->resize.edges = 0;
3417 e_comp_wl->resize.resource = NULL;
3419 if (ec->pending_resize)
3421 ec->changes.pos = EINA_TRUE;
3422 ec->changes.size = EINA_TRUE;
3426 E_FREE_LIST(ec->pending_resize, free);
3430 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3432 if (e_object_is_del(E_OBJECT(ec))) return;
3433 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3437 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3440 int ratio_w, ratio_h;
3442 phys_w = output->phys_width;
3443 phys_h = output->phys_height;
3445 if (e_config->configured_output_resolution.use)
3447 // change the configured physical size(mm) of the output
3448 if (output->w != res_w)
3450 ratio_w = res_w / output->w;
3451 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3454 if (output->h != res_h)
3456 ratio_h = res_h / output->h;
3457 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3460 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3463 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3464 NULL, res_w, res_h, phys_w, phys_h, pid);
3466 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3467 wl_output_send_scale(resource, output->scale);
3469 wl_output_send_geometry(resource, output->x, output->y,
3471 output->subpixel, output->make ?: "",
3472 output->model ?: "", output->transform);
3474 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3475 res_w, res_h, output->refresh);
3477 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3478 wl_output_send_done(resource);
3482 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3484 E_Comp_Wl_Output *output;
3486 if (!(output = wl_resource_get_user_data(resource))) return;
3488 output->resources = eina_list_remove(output->resources, resource);
3492 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3494 E_Comp_Wl_Output *output;
3495 struct wl_resource *resource;
3496 E_Appinfo *eai = NULL;
3500 if (!(output = data)) return;
3503 wl_resource_create(client, &wl_output_interface, version, id);
3506 wl_client_post_no_memory(client);
3510 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3511 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3513 output->resources = eina_list_append(output->resources, resource);
3515 wl_resource_set_implementation(resource, NULL, output,
3516 _e_comp_wl_cb_output_unbind);
3517 wl_resource_set_user_data(resource, output);
3519 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3520 if (e_config->configured_output_resolution.use)
3522 wl_client_get_credentials(client, &pid, NULL, NULL);
3525 res_w = e_config->configured_output_resolution.w;
3526 res_h = e_config->configured_output_resolution.h;
3530 eai = e_appinfo_find_with_pid(pid);
3533 res_w = e_config->configured_output_resolution.w;
3534 res_h = e_config->configured_output_resolution.h;
3538 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3540 res_w = e_config->configured_output_resolution.w;
3541 res_h = e_config->configured_output_resolution.h;
3545 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3554 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3558 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3561 Evas_GL *evasgl = NULL;
3562 Evas_GL_API *glapi = NULL;
3563 Evas_GL_Context *ctx = NULL;
3564 Evas_GL_Surface *sfc = NULL;
3565 Evas_GL_Config *cfg = NULL;
3567 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3569 if (!e_comp_gl_get()) return;
3571 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3572 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3574 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3575 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3577 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3578 * then we should get evas from ecore_evas.
3581 evas = e_comp->evas;
3583 evas = ecore_evas_get(e_comp->ee);
3585 evasgl = evas_gl_new(evas);
3586 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3588 glapi = evas_gl_api_get(evasgl);
3589 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3590 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3592 cfg = evas_gl_config_new();
3593 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3595 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3596 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3598 ctx = evas_gl_context_create(evasgl, NULL);
3599 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3601 res = evas_gl_make_current(evasgl, sfc, ctx);
3602 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3604 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3605 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3607 evas_gl_config_free(cfg);
3609 evas_gl->gl = evasgl;
3610 evas_gl->glapi = glapi;
3611 evas_gl->glsfc = sfc;
3612 evas_gl->glctx = ctx;
3614 e_comp_wl->evas_gl = evas_gl;
3616 /* for native surface */
3619 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3624 evas_gl_config_free(cfg);
3625 evas_gl_make_current(evasgl, NULL, NULL);
3626 evas_gl_context_destroy(evasgl, ctx);
3627 evas_gl_surface_destroy(evasgl, sfc);
3628 evas_gl_free(evasgl);
3635 _e_comp_wl_gl_popup_cb_close(void *data,
3636 Evas_Object *obj EINA_UNUSED,
3637 void *event_info EINA_UNUSED)
3639 evas_object_del(data);
3643 _e_comp_wl_gl_popup_cb_focus(void *data,
3644 Evas_Object *obj EINA_UNUSED,
3645 void *event_info EINA_UNUSED)
3647 elm_object_focus_set(data, EINA_TRUE);
3652 _e_comp_wl_gl_idle(void *data)
3656 /* show warning window to notify failure of gl init */
3659 Evas_Object *win, *bg, *popup, *btn;
3661 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3662 elm_win_title_set(win, "Compositor Warning");
3663 elm_win_autodel_set(win, EINA_TRUE);
3664 elm_win_borderless_set(win, EINA_TRUE);
3665 elm_win_role_set(win, "notification-low");
3666 elm_win_alpha_set(win, EINA_TRUE);
3668 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3669 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3670 elm_win_resize_object_add(win, bg);
3671 evas_object_color_set(bg, 125, 125, 125, 125);
3672 evas_object_show(bg);
3674 popup = elm_popup_add(win);
3675 elm_object_text_set(popup,
3676 _( "Your screen does not support OpenGL.<br>"
3677 "Falling back to software engine."));
3678 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3680 btn = elm_button_add(popup);
3681 elm_object_text_set(btn, "Close");
3682 elm_object_part_content_set(popup, "button1", btn);
3683 evas_object_show(btn);
3685 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3686 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3688 evas_object_show(popup);
3689 evas_object_show(win);
3693 return ECORE_CALLBACK_CANCEL;
3697 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3699 struct wl_client *client = data;
3705 wl_client_get_credentials(client, &pid, &uid, &gid);
3707 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3709 _e_comp_wl_pname_print(pid);
3710 _e_comp_wl_pname_get(pid, name, sizeof(name));
3711 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3715 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3717 char buf[1024] = {0, };
3719 vsnprintf(buf, 1024, fmt, args);
3723 DBG("[libds] %s", buf);
3726 INF("[libds] %s", buf);
3729 ERR("[libds] %s", buf);
3737 _e_comp_wl_display_create(void)
3740 E_Comp_Wl_Data *wl_cdata;
3745 /* create new compositor data */
3746 if (!(comp = E_NEW(E_Comp_Data, 1)))
3748 ERR("Could not create compositor data: %m");
3751 wl_cdata = &comp->base;
3753 /* set compositor wayland data */
3754 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3756 g_mutex_init(&flush_mutex);
3758 /* try to create a wayland display */
3759 if (!(wl_cdata->wl.disp = wl_display_create()))
3761 ERR("Could not create a Wayland display: %m");
3765 /* try to setup wayland socket */
3766 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3768 ERR("Could not create Wayland display socket: %m");
3769 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3773 res = e_comp_socket_init(name);
3774 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3775 PRCTL("[Winsys] change permission and create sym link for %s", name);
3777 /* set wayland display environment variable */
3778 e_env_set("WAYLAND_DISPLAY", name);
3780 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3781 /* wl_cdata->output.scale = e_scale; */
3783 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3785 if (!e_compositor_init(wl_cdata->wl.disp))
3787 ERR("Failed to initialize compositor");
3791 comp->client_created.notify = _e_comp_wl_cb_client_created;
3792 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3794 if (!e_comp_wl_subsurfaces_init())
3796 ERR("Failed to init_subsurfaces");
3797 goto subsurfaces_err;
3800 /* initialize shm mechanism */
3801 wl_display_init_shm(wl_cdata->wl.disp);
3803 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3805 /* try to init data manager */
3806 if (!e_comp_wl_data_manager_init())
3808 ERR("Could not initialize data manager");
3812 /* try to init input */
3813 if (!e_comp_wl_input_init())
3815 ERR("Could not initialize input");
3819 if (e_comp_gl_get())
3820 _e_comp_wl_gl_init(NULL);
3822 /* get the wayland display loop */
3823 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3825 /* get the file descriptor of the wayland event loop */
3826 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3828 /* create a listener for wayland main loop events */
3830 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3831 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3832 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3833 _e_comp_wl_cb_prepare, wl_cdata);
3838 e_comp_wl_data_manager_shutdown();
3840 e_comp_wl_subsurfaces_shutdown();
3842 wl_list_remove(&comp->client_created.link);
3844 e_env_unset("WAYLAND_DISPLAY");
3846 wl_display_destroy(wl_cdata->wl.disp);
3848 g_mutex_clear(&flush_mutex);
3854 _e_comp_wl_gl_shutdown(void)
3856 if (!e_comp_wl->evas_gl) return;
3858 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3860 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3861 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3862 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3863 evas_gl_free(e_comp_wl->evas_gl->gl);
3865 E_FREE(e_comp_wl->evas_gl);
3868 /* public functions */
3871 * Creates and initializes a Wayland compositor with ecore.
3872 * Registers callback handlers for keyboard and mouse activity
3873 * and other client events.
3875 * @returns true on success, false if initialization failed.
3878 e_comp_wl_init(void)
3880 TRACE_DS_BEGIN(COMP_WL:INIT);
3882 /* try to create a wayland compositor */
3883 if (!_e_comp_wl_display_create())
3885 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3890 e_comp_wl_shell_init();
3892 #ifdef HAVE_WAYLAND_TBM
3893 e_comp_wl_tbm_init();
3895 e_comp_wl_remote_surface_init();
3899 e_comp_wl_screenshooter_init();
3901 if (!e_comp_wl_video_init())
3902 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3904 e_comp_wl_viewport_init();
3905 e_comp_wl_capture_init();
3906 e_comp_wl_renderer_init();
3907 _e_comp_wl_move_resize_init();
3908 e_presentation_time_init();
3909 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3912 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3913 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3915 /* add event handlers to catch E events */
3916 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3917 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3918 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3919 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3920 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3921 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3922 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3923 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3924 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3926 /* add hooks to catch e_client events */
3927 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3928 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3929 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3930 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3931 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3933 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3940 e_comp_wl_deferred_job(void)
3942 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3945 /* internal functions */
3947 e_comp_wl_shutdown(void)
3949 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3951 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3953 e_comp_wl_subsurfaces_shutdown();
3955 E_FREE_LIST(handlers, ecore_event_handler_del);
3956 E_FREE_LIST(hooks, e_client_hook_del);
3957 _e_comp_wl_gl_shutdown();
3959 e_blender_shutdown();
3960 e_presentation_time_shutdown();
3961 e_comp_wl_renderer_shutdown();
3962 e_comp_wl_capture_shutdown();
3963 e_comp_wl_viewport_shutdown();
3964 e_comp_wl_video_shutdown();
3965 e_comp_wl_screenshooter_shutdown();
3967 e_comp_wl_remote_surface_shutdown();
3969 e_pixmap_shutdown();
3971 e_wtz_shell_shutdown();
3972 e_comp_wl_shell_shutdown();
3973 e_comp_wl_input_shutdown();
3975 wl_list_remove(&comp->client_created.link);
3978 e_comp->wl_comp_data = NULL;
3982 E_Comp_Wl_Output *output;
3984 if (e_comp_wl->screenshooter.global)
3985 wl_global_destroy(e_comp_wl->screenshooter.global);
3987 EINA_LIST_FREE(e_comp_wl->outputs, output)
3989 if (output->id) eina_stringshare_del(output->id);
3990 if (output->make) eina_stringshare_del(output->make);
3991 if (output->model) eina_stringshare_del(output->model);
3995 /* delete fd handler */
3996 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3998 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3999 cursor_timer_ec = NULL;
4001 /* free allocated data structure */
4007 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4009 e_object_unref(E_OBJECT(ev->ec));
4014 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4017 ev = E_NEW(E_Event_Client, 1);
4020 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4022 /* set usable early because shell module checks this */
4023 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4024 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4026 e_pixmap_resource_set(ec->pixmap, buffer);
4027 e_pixmap_dirty(ec->pixmap);
4028 e_pixmap_refresh(ec->pixmap);
4030 e_comp_wl_map_size_cal_from_buffer(ec);
4031 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4033 /* wm-policy module uses it */
4034 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4037 e_object_ref(E_OBJECT(ec));
4038 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4039 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4043 e_comp_wl_surface_commit(E_Client *ec)
4048 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4049 if (!e_comp_object_damage_exists(ec->frame))
4051 if ((ec->comp_data->video_client) ||
4052 (!e_client_video_hw_composition_check(ec)))
4053 e_pixmap_image_clear(ec->pixmap, 1);
4056 ignored = ec->ignored;
4058 if (e_comp_wl_subsurface_order_commit(ec))
4060 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4061 e_comp_wl_subsurface_restack(topmost);
4062 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4065 if (!e_pixmap_usable_get(ec->pixmap))
4067 if (ec->comp_data->mapped)
4069 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
4071 ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
4072 ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
4074 else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
4075 (ec == e_comp_wl->drag_client))
4077 ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
4078 ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
4079 ec->visible = EINA_FALSE;
4080 evas_object_hide(ec->frame);
4081 ec->comp_data->mapped = 0;
4085 if (ec->comp_data->sub.below_obj && evas_object_visible_get(ec->comp_data->sub.below_obj))
4086 evas_object_hide(ec->comp_data->sub.below_obj);
4090 if (!ec->comp_data->mapped)
4092 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
4095 ELOGF("COMP", "Try to map2. Call shell.map.", ec);
4096 ec->comp_data->shell.map(ec->comp_data->shell.surface);
4098 else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
4099 (ec == e_comp_wl->drag_client))
4101 ELOGF("COMP", "Try to map2. Show window. internal:%d, drag:%d",
4102 ec, ec->internal, (ec == e_comp_wl->drag_client));
4103 ec->visible = EINA_TRUE;
4105 evas_object_show(ec->frame);
4106 ec->comp_data->mapped = 1;
4110 if (ec->comp_data->sub.below_obj && !evas_object_visible_get(ec->comp_data->sub.below_obj)
4111 && evas_object_visible_get(ec->frame))
4112 evas_object_show(ec->comp_data->sub.below_obj);
4114 ec->ignored = ignored;
4116 if (ec->is_cursor && ec->visible)
4118 /* ignore cursor changes during resize/move I guess */
4119 if (!e_client_action_get())
4121 if (e_comp->pointer)
4123 x = e_comp->pointer->hot.x;
4124 y = e_comp->pointer->hot.y;
4126 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4132 static E_Comp_Wl_Output *
4133 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4136 E_Comp_Wl_Output *output;
4138 EINA_LIST_FOREACH(outputs, l, output)
4140 if (!strcmp(output->id, id))
4148 * Initializes information about one display output.
4150 * Adds or updates the given data about a single display output,
4151 * with an id matching the provided id.
4153 * @param id identification of output to be added or changed
4154 * @param make manufacturer name of the display output
4155 * @param model model name of the display output
4156 * @param x output's top left corner x coordinate
4157 * @param y output's top left corner y coordinate
4158 * @param w output's width in pixels
4159 * @param h output's height in pixels
4160 * @param pw output's physical width in millimeters
4161 * @param ph output's physical height in millimeters
4162 * @param refresh output's refresh rate in mHz
4163 * @param subpixel output's subpixel layout
4164 * @param transform output's rotation and/or mirror transformation
4166 * @returns True if a display output object could be added or updated
4169 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4170 int x, int y, int w, int h, int pw, int ph,
4171 unsigned int refresh, unsigned int subpixel,
4172 unsigned int transform)
4174 E_Comp_Wl_Output *output;
4176 struct wl_resource *resource;
4178 /* retrieve named output; or create it if it doesn't exist */
4179 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4182 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4184 if (id) output->id = eina_stringshare_add(id);
4186 output->make = eina_stringshare_add(make);
4188 output->make = eina_stringshare_add("unknown");
4190 output->model = eina_stringshare_add(model);
4192 output->model = eina_stringshare_add("unknown");
4194 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4197 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4198 2, output, _e_comp_wl_cb_output_bind);
4200 output->resources = NULL;
4201 output->scale = e_scale;
4204 /* update the output details */
4209 output->phys_width = pw;
4210 output->phys_height = ph;
4211 output->refresh = refresh;
4212 output->subpixel = subpixel;
4213 output->transform = transform;
4215 if (output->scale <= 0)
4216 output->scale = e_scale;
4218 /* if we have bound resources, send updates */
4219 EINA_LIST_FOREACH(output->resources, l2, resource)
4221 wl_output_send_geometry(resource,
4222 output->x, output->y,
4224 output->phys_height,
4226 output->make ?: "", output->model ?: "",
4229 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4230 wl_output_send_scale(resource, output->scale);
4232 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4233 output->w, output->h, output->refresh);
4235 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4236 wl_output_send_done(resource);
4243 e_comp_wl_output_remove(const char *id)
4245 E_Comp_Wl_Output *output;
4247 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4250 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4252 /* wl_global_destroy(output->global); */
4254 /* eina_stringshare_del(output->id); */
4255 /* eina_stringshare_del(output->make); */
4256 /* eina_stringshare_del(output->model); */
4263 _e_comp_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_key_state state, Eina_List *key_list, E_Client *ec)
4265 struct wl_resource *res;
4267 uint32_t serial, keycode;
4268 struct wl_client *wc = NULL;
4269 E_Comp_Config *comp_conf = NULL;
4270 const char *device_name = NULL;
4272 keycode = (ev->keycode - 8);
4274 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4276 comp_conf = e_comp_config_get();
4278 if (ec && ec->comp_data)
4280 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4283 wc = wl_resource_get_client(surface);
4286 EINA_LIST_FOREACH(key_list, l, res)
4288 if (wl_resource_get_client(res) != wc) continue;
4290 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4291 if (!e_input_thread_mode_get())
4293 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4294 device_name = ecore_device_name_get(ev->dev);
4300 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4301 device_name = e_device_name_get(dev);
4305 if (comp_conf && comp_conf->input_log_enable)
4306 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4308 wl_keyboard_send_key(res, serial, ev->timestamp,
4315 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4317 E_Client *ec = NULL;
4319 E_Comp_Wl_Key_Data *end, *k;
4321 if (ev->window != e_comp->ee_win)
4326 keycode = (ev->keycode - 8);
4327 if (!(e_comp_wl = e_comp->wl_comp_data))
4332 #ifndef E_RELEASE_BUILD
4333 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4334 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4335 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4336 eina_streq(ev->key, "BackSpace"))
4342 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4344 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4346 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4348 /* ignore server-generated key repeats */
4349 if (k->key == keycode)
4351 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4356 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4357 g_rec_mutex_lock(&e_comp->input_key_grabs_mutex);
4359 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4361 ec = e_client_focused_get();
4362 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4363 if (ec && ec->comp_data && surface)
4365 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4366 if (e_comp_wl->kbd.focused)
4368 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4370 /* A key only sent to clients is added to the list */
4371 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4372 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4374 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4376 DBG("wl_array_add: Out of memory\n");
4377 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4378 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4379 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4382 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4386 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4390 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4392 /* update modifier state */
4393 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4399 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4401 E_Client *ec = NULL;
4402 uint32_t keycode, delivered_key;
4403 E_Comp_Wl_Key_Data *end, *k;
4405 if (ev->window != e_comp->ee_win)
4410 keycode = (ev->keycode - 8);
4412 if (!(e_comp_wl = e_comp->wl_comp_data))
4417 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4419 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4420 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4422 if (k->key == keycode)
4429 e_comp_wl->kbd.keys.size =
4430 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4432 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4434 /* If a key down event have been sent to clients, send a key up event to client for garantee key event sequence pair. (down/up) */
4435 g_rec_mutex_lock(&e_comp->input_key_grabs_mutex);
4436 if ((delivered_key) ||
4437 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4439 ec = e_client_focused_get();
4441 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4442 if (e_comp_wl->kbd.focused)
4444 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4446 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4448 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4450 /* update modifier state */
4451 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4457 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4459 Eina_Bool res = EINA_FALSE;
4461 if (type == ECORE_EVENT_KEY_DOWN)
4463 res = e_comp_wl_key_down(ev, dev);
4465 else if (type == ECORE_EVENT_KEY_UP)
4467 res = e_comp_wl_key_up(ev, dev);
4474 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4477 struct wl_client *wc;
4478 uint32_t serial, btn;
4479 struct wl_resource *res;
4480 E_Comp_Config *comp_conf = NULL;
4482 if (ec->cur_mouse_action || e_comp_wl->drag)
4484 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4485 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4489 case 1: btn = BTN_LEFT; break;
4490 case 2: btn = BTN_MIDDLE; break;
4491 case 3: btn = BTN_RIGHT; break;
4492 default: btn = button_id; break;
4495 e_comp_wl->ptr.button = btn;
4496 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4497 if (!surface) return EINA_FALSE;
4499 if (!eina_list_count(e_comp_wl->ptr.resources))
4502 wc = wl_resource_get_client(surface);
4503 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4505 comp_conf = e_comp_config_get();
4507 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4509 if (wl_resource_get_client(res) != wc) continue;
4510 if (!e_comp_wl_input_pointer_check(res)) continue;
4511 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4513 if (comp_conf && comp_conf->input_log_enable)
4514 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4516 wl_pointer_send_button(res, serial, timestamp, btn, state);
4523 e_comp_wl_touch_cancel(void)
4525 _e_comp_wl_touch_cancel();
4528 E_API E_Comp_Wl_Hook *
4529 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4533 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4534 ch = E_NEW(E_Comp_Wl_Hook, 1);
4535 if (!ch) return NULL;
4536 ch->hookpoint = hookpoint;
4538 ch->data = (void*)data;
4539 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4544 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4547 if (_e_comp_wl_hooks_walking == 0)
4549 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4553 _e_comp_wl_hooks_delete++;
4556 E_API E_Comp_Wl_Pid_Hook *
4557 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4559 E_Comp_Wl_Pid_Hook *ch;
4561 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4563 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4564 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4566 ch->hookpoint = hookpoint;
4568 ch->data = (void*)data;
4569 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4575 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4578 if (_e_comp_wl_pid_hooks_walking == 0)
4580 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4584 _e_comp_wl_pid_hooks_delete++;
4587 E_API E_Comp_Wl_Intercept_Hook *
4588 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4590 E_Comp_Wl_Intercept_Hook *ch;
4592 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4593 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4594 if (!ch) return NULL;
4595 ch->hookpoint = hookpoint;
4597 ch->data = (void*)data;
4598 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4603 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4606 if (_e_comp_wl_intercept_hooks_walking == 0)
4608 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4612 _e_comp_wl_intercept_hooks_delete++;
4616 e_comp_wl_shell_surface_ready(E_Client *ec)
4620 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4624 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4626 e_config->use_cursor_timer = !!enabled;
4628 if (e_config->use_cursor_timer == EINA_FALSE)
4630 if (e_comp_wl->ptr.hide_tmr)
4632 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4633 e_comp_wl->ptr.hide_tmr = NULL;
4635 cursor_timer_ec = NULL;
4637 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4640 if (e_pointer_is_hidden(e_comp->pointer))
4642 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4648 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4650 EINA_SAFETY_ON_NULL_RETURN(wc);
4651 EINA_SAFETY_ON_NULL_RETURN(dev);
4653 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4657 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4659 EINA_SAFETY_ON_NULL_RETURN(wc);
4660 EINA_SAFETY_ON_NULL_RETURN(dev);
4662 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4666 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4668 struct wl_resource *res;
4669 struct wl_client *wc;
4671 uint32_t serial, wl_keycode;
4672 enum wl_keyboard_key_state state;
4673 E_Comp_Config *comp_conf = NULL;
4674 const char *dev_name = NULL;
4676 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4677 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4678 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4680 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4681 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4683 wl_keycode = keycode - 8;
4684 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4686 wc = wl_resource_get_client(surface);
4687 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4688 if (!time) time = e_util_timestamp_get();
4689 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4690 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4692 comp_conf = e_comp_config_get();
4693 e_keyrouter_event_surface_send(ec, keycode);
4695 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4696 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4698 if (wl_resource_get_client(res) != wc) continue;
4699 if (!e_input_thread_mode_get())
4703 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4704 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4708 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4715 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4716 dev_name = e_device_name_get(dev);
4720 if (comp_conf && comp_conf->input_log_enable)
4721 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4724 wl_keyboard_send_key(res, serial, time,
4727 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4733 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4735 struct wl_resource *res;
4736 struct wl_client *wc;
4738 uint32_t serial, wl_keycode, cancel_keycode;
4739 E_Comp_Config *comp_conf = NULL;
4741 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4742 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4743 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4744 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->xkb.keymap, EINA_FALSE);
4746 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4747 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4749 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4750 if (cancel_keycode == XKB_KEYCODE_INVALID)
4752 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4755 cancel_keycode = cancel_keycode - 8;
4757 wl_keycode = keycode - 8;
4758 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4760 wc = wl_resource_get_client(surface);
4761 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4762 if (!time) time = e_util_timestamp_get();
4764 comp_conf = e_comp_config_get();
4765 e_keyrouter_event_surface_send(ec, keycode);
4767 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4768 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4770 if (wl_resource_get_client(res) != wc) continue;
4771 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4772 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4774 if (comp_conf && comp_conf->input_log_enable)
4775 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4776 wl_keyboard_send_key(res, serial, time,
4777 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4778 wl_keyboard_send_key(res, serial, time,
4779 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4780 wl_keyboard_send_key(res, serial, time,
4781 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4783 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4790 e_comp_wl_touch_send(E_Client *ec, int idx, int x, int y, Eina_Bool pressed, Ecore_Device *dev, double radius_x, double radius_y, double pressure, double angle, uint32_t time)
4792 struct wl_client *wc;
4794 E_Devicemgr_Input_Device *device = NULL;
4796 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4797 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4800 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4801 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4803 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4805 wc = wl_resource_get_client(surface);
4806 if (!time) time = e_util_timestamp_get();
4807 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4811 _e_comp_wl_send_event_device(wc, time, dev, serial);
4812 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4816 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4817 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4820 x = x + ec->client.x;
4821 y = y + ec->client.y;
4823 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4829 e_comp_wl_touch_update_send(E_Client *ec, int idx, int x, int y, Ecore_Device *dev, double radius_x, double radius_y, double pressure, double angle, uint32_t time)
4831 E_Devicemgr_Input_Device *device;
4833 struct wl_client *wc;
4835 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4836 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4837 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4839 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4840 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4842 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4844 wc = wl_resource_get_client(surface);
4845 if (!time) time = e_util_timestamp_get();
4846 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4850 _e_comp_wl_send_event_device(wc, time, dev, serial);
4851 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4855 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4856 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4859 x = x + ec->client.x;
4860 y = y + ec->client.y;
4862 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4868 e_comp_wl_touch_cancel_send(E_Client *ec)
4870 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4871 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4872 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4874 _e_comp_wl_send_touch_cancel(ec);
4880 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4883 struct wl_client *wc;
4885 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4886 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4887 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4889 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4890 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4892 wc = wl_resource_get_client(surface);
4893 if (!time) time = e_util_timestamp_get();
4894 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4896 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4897 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4900 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4901 WL_POINTER_BUTTON_STATE_PRESSED);
4903 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4904 WL_POINTER_BUTTON_STATE_RELEASED);
4910 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4913 struct wl_client *wc;
4915 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4916 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4917 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4919 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4920 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4922 wc = wl_resource_get_client(surface);
4923 if (!time) time = e_util_timestamp_get();
4924 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4926 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4927 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4929 x = x + ec->client.x;
4930 y = y + ec->client.y;
4932 _e_comp_wl_send_mouse_move(ec, x, y, time);
4938 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4941 struct wl_client *wc;
4943 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4944 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4945 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4947 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4948 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4950 wc = wl_resource_get_client(surface);
4951 if (!time) time = e_util_timestamp_get();
4952 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4954 if (_e_comp_wl_check_cursor_timer_needed(ec))
4956 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4960 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4961 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4963 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4965 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4967 if (_e_comp_wl_check_cursor_timer_needed(ec))
4968 _e_comp_wl_cursor_move_timer_control(ec);
4975 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4978 struct wl_client *wc;
4979 struct wl_resource *res;
4982 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4983 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4985 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4986 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4988 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4989 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4991 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4992 wc = wl_resource_get_client(surface);
4993 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4994 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4996 if (!e_comp_wl_input_pointer_check(res)) continue;
4997 if (wl_resource_get_client(res) != wc) continue;
4999 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5000 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5002 wl_pointer_send_enter(res, serial, surface,
5003 wl_fixed_from_int(x),
5004 wl_fixed_from_int(y));
5005 ec->pointer_enter_sent = EINA_TRUE;
5007 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5013 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5016 struct wl_client *wc;
5017 struct wl_resource *res;
5020 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5021 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5022 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5023 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5024 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5025 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5027 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5028 wc = wl_resource_get_client(surface);
5029 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5030 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5032 if (!e_comp_wl_input_pointer_check(res)) continue;
5033 if (wl_resource_get_client(res) != wc) continue;
5035 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5036 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5038 wl_pointer_send_leave(res, serial, surface);
5039 ec->pointer_enter_sent = EINA_FALSE;
5046 e_comp_wl_mouse_in_renew(E_Client *ec, int buttons, int x, int y, void *data, Evas_Modifier *modifiers, Evas_Lock *locks, unsigned int timestamp, Evas_Event_Flags event_flags, Evas_Device *dev, Evas_Object *event_src)
5048 Evas_Event_Mouse_In ev_in;
5051 if (ec->pointer_enter_sent) return;
5053 ev_in.buttons = buttons;
5061 ev_in.modifiers = modifiers;
5062 ev_in.locks = locks;
5063 ev_in.timestamp = timestamp;
5064 ev_in.event_flags = event_flags;
5067 ev_in.event_src = event_src;
5069 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5073 e_comp_wl_mouse_out_renew(E_Client *ec, int buttons, int x, int y, void *data, Evas_Modifier *modifiers, Evas_Lock *locks, unsigned int timestamp, Evas_Event_Flags event_flags, Evas_Device *dev, Evas_Object *event_src)
5075 Evas_Event_Mouse_Out ev_out;
5078 if (!ec->pointer_enter_sent) return;
5080 ev_out.buttons = buttons;
5082 ev_out.output.x = x;
5083 ev_out.output.y = y;
5084 ev_out.canvas.x = x;
5085 ev_out.canvas.y = y;
5088 ev_out.modifiers = modifiers;
5089 ev_out.locks = locks;
5090 ev_out.timestamp = timestamp;
5091 ev_out.event_flags = event_flags;
5094 ev_out.event_src = event_src;
5096 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5100 e_comp_wl_cursor_hide(E_Client *ec)
5102 struct wl_resource *res;
5103 struct wl_client *wc;
5107 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5109 if (e_comp_wl->ptr.hide_tmr)
5111 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5112 e_comp_wl->ptr.hide_tmr = NULL;
5114 cursor_timer_ec = NULL;
5116 if (!ec) return EINA_FALSE;
5117 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5118 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5119 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5121 wc = wl_resource_get_client(surface);
5122 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5123 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5125 if (!e_comp_wl_input_pointer_check(res)) continue;
5126 if (wl_resource_get_client(res) != wc) continue;
5127 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5128 wl_pointer_send_leave(res, serial, surface);
5129 ec->pointer_enter_sent = EINA_FALSE;
5135 /* surface to buffer
5136 * - width : surface width
5137 * - height : surface height
5138 * - transform: buffer transform
5139 * - scale : buffer scale
5141 * - width : screen width
5142 * - height : screen height
5143 * - transform: output transform
5144 * - scale : output scale
5146 static E_Util_Transform_Matrix
5147 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5149 E_Util_Transform_Matrix m;
5151 e_util_transform_matrix_load_identity(&m);
5153 if (transform & 0x4)
5155 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5156 e_util_transform_matrix_flip_x(&m);
5157 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5160 switch (transform & 0x3)
5162 case WL_OUTPUT_TRANSFORM_90:
5163 e_util_transform_matrix_translate(&m, -width, 0, 0);
5164 e_util_transform_matrix_rotation_z(&m, 270);
5166 case WL_OUTPUT_TRANSFORM_180:
5167 e_util_transform_matrix_translate(&m, -width, -height, 0);
5168 e_util_transform_matrix_rotation_z(&m, 180);
5170 case WL_OUTPUT_TRANSFORM_270:
5171 e_util_transform_matrix_translate(&m, 0, -height, 0);
5172 e_util_transform_matrix_rotation_z(&m, 90);
5178 e_util_transform_matrix_scale(&m, scale, scale, 1);
5183 /* surface to buffer
5184 * - surface width, surface height, buffer transform, buffer scale
5186 * - screen width, screen height, output transform, output scale
5189 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5191 E_Util_Transform_Matrix m;
5192 E_Util_Transform_Vertex v;
5194 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5196 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5197 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5198 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5202 * - buffer width, buffer height, buffer transform, buffer scale
5205 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5207 E_Util_Transform_Matrix m;
5208 E_Util_Transform_Vertex v;
5211 if (transform != 0 || scale > 1)
5213 tw = ((transform % 2) ? height : width) / scale;
5214 th = ((transform % 2) ? width : height) / scale;
5222 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5223 m = e_util_transform_matrix_inverse_get(&m);
5225 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5226 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5227 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5230 /* surface to buffer
5231 * - surface width, surface height, buffer transform, buffer scale
5233 * - screen width, screen height, output transform, output scale
5236 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5237 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5239 E_Util_Transform_Matrix m;
5240 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5241 E_Util_Transform_Rect_Vertex sv;
5243 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5245 sv = e_util_transform_rect_to_vertices(&sr);
5246 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5247 sr = e_util_transform_vertices_to_rect(&sv);
5256 * - buffer width, buffer height, buffer transform, buffer scale
5259 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5260 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5262 E_Util_Transform_Matrix m;
5263 E_Util_Transform_Rect br = {bx, by, bw, bh};
5264 E_Util_Transform_Rect_Vertex bv;
5267 if (transform != 0 || scale > 1)
5269 tw = ((transform % 2) ? height : width) / scale;
5270 th = ((transform % 2) ? width : height) / scale;
5278 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5279 m = e_util_transform_matrix_inverse_get(&m);
5281 bv = e_util_transform_rect_to_vertices(&br);
5282 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5283 br = e_util_transform_vertices_to_rect(&bv);
5291 EINTERN E_Comp_Wl_Output*
5292 e_comp_wl_output_find(E_Client *ec)
5295 E_Comp_Wl_Output *output;
5297 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5299 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5301 if (output->transform % 2)
5303 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5304 ec->y < output->x || ec->y >= (output->x + output->w))
5309 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5310 ec->y < output->y || ec->y >= (output->y + output->h))
5320 EINTERN Eina_Array *
5321 e_comp_wl_output_find_all(E_Client *ec)
5323 E_Comp_Wl_Output *output;
5324 Eina_Array *outputs;
5327 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5329 outputs = eina_array_new(4);
5333 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5335 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5336 output->x, output->y, output->w, output->h))
5338 eina_array_push(outputs, output);
5342 if (eina_array_count(outputs) == 0)
5344 eina_array_free(outputs);
5351 // --------------------------------------------------------
5352 // tizen_move_resize
5353 // --------------------------------------------------------
5355 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5362 E_Client_Pending_Geometry *geo;
5365 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5366 if (ec->fullscreen || ec->maximized) goto err;
5368 geo = E_NEW(E_Client_Pending_Geometry, 1);
5371 geo->serial = serial;
5377 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5378 ec->surface_sync.wait_commit = EINA_TRUE;
5383 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5390 e_comp_wl_commit_sync_configure(E_Client *ec)
5393 E_Client_Pending_Geometry *geo;
5395 Eina_Bool match_size = EINA_FALSE;
5402 if (!ec || !ec->frame) goto ret;
5403 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5406 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5407 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5409 if (eina_list_count(ec->surface_sync.pending_geometry))
5411 Eina_List *ll = NULL;
5412 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5416 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5421 if ((geo->w == bw) && (geo->h == bh))
5423 match_size = EINA_TRUE;
5428 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5435 if ((config.w != ec->w) || (config.h != ec->h))
5437 e_client_size_set(ec, config.w, config.h);
5438 ec->changes.size = EINA_TRUE;
5442 // FIXME: The geometry of the client would be better to be calculated
5443 // at e_desk or at e_desk_area. So the position(x,y) of the client
5444 // should be calcuated at the e_desk or at the e_desk_area.
5446 desk = e_comp_desk_find_by_ec(ec);
5449 ec->client.x = desk->geom.x + config.x;
5450 ec->client.y = desk->geom.y + config.y;
5454 ec->client.x = config.x;
5455 ec->client.y = config.y;
5458 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5460 e_client_pos_set(ec, ec->client.x, ec->client.y);
5462 ec->changes.pos = 1;
5466 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5470 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5471 ec->surface_sync.wait_commit = EINA_FALSE;
5473 if ((ec->comp_data->shell.surface) &&
5474 (ec->comp_data->shell.configure))
5476 ec->comp_data->shell.configure(ec->comp_data->shell.surface,
5481 // rollback wait_commit if there are pending requests remained
5482 if (eina_list_count(ec->surface_sync.pending_geometry))
5483 ec->surface_sync.wait_commit = EINA_TRUE;
5488 ELOGF("POSSIZE", "Could not configure geometry (%d,%d - %dx%d) bw:%d bh:%d", ec, ec->x, ec->y, ec->w, ec->h, bw, bh);
5495 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5496 struct wl_resource *res_moveresize)
5498 wl_resource_destroy(res_moveresize);
5502 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5503 struct wl_resource *res_moveresize,
5504 struct wl_resource *surface,
5511 /* to be implemented */
5514 int cur_w = 0, cur_h = 0;
5516 ec = e_client_from_surface_resource(surface);
5519 pending = e_client_pending_geometry_has(ec);
5520 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5521 ELOGF("POSSIZE", "Request move_resize geometry_set. geo(%d,%d,%dx%d) cur(%dx%d). pend:%d", ec, x, y, w, h, cur_w, cur_h, pending);
5525 if ((cur_w == w) && (cur_h == h))
5527 e_client_pos_set(ec, x, y);
5528 ec->changes.pos = 1;
5534 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5538 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5541 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5543 _tz_move_resize_iface_cb_destroy,
5544 _tz_move_resize_iface_cb_set_geometry,
5548 _tz_moveresize_cb_bind(struct wl_client *client,
5549 void *data EINA_UNUSED,
5553 struct wl_resource *res_moveresize;
5555 res_moveresize = wl_resource_create(client,
5556 &tizen_move_resize_interface,
5559 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5562 wl_resource_set_implementation(res_moveresize,
5563 &_tz_move_resize_iface,
5569 ERR("Could not create tizen_move_resize_interface res: %m");
5570 wl_client_post_no_memory(client);
5574 _e_comp_wl_move_resize_init(void)
5576 if (!e_comp_wl) return;
5577 if (!e_comp_wl->wl.disp) return;
5579 if (!wl_global_create(e_comp_wl->wl.disp,
5580 &tizen_move_resize_interface,
5583 _tz_moveresize_cb_bind))
5585 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5592 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5594 E_Comp_Wl_Output *output;
5595 pid_t output_pid = 0;
5596 Eina_List *l = NULL, *l2 = NULL;
5597 struct wl_resource *resource = NULL;
5599 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5601 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5602 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5603 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5605 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5607 /* if we have bound resources, send updates */
5608 EINA_LIST_FOREACH(output->resources, l2, resource)
5610 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5611 if (output_pid != pid) continue;
5613 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5615 // send output information to the client
5616 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5624 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5626 _e_comp_wl_surface_state_init(state, w, h);
5630 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5632 _e_comp_wl_surface_state_commit(ec, state);
5636 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5638 _e_comp_wl_hook_call(hookpoint, ec);
5642 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5644 _e_comp_wl_surface_state_finish(state);
5648 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5650 _e_comp_wl_surface_state_buffer_set(state, buffer);
5654 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5655 int sx, int sy, int *dx, int *dy)
5659 case WL_OUTPUT_TRANSFORM_NORMAL:
5663 case WL_OUTPUT_TRANSFORM_FLIPPED:
5664 *dx = width - sx, *dy = sy;
5666 case WL_OUTPUT_TRANSFORM_90:
5667 *dx = height - sy, *dy = sx;
5669 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5670 *dx = height - sy, *dy = width - sx;
5672 case WL_OUTPUT_TRANSFORM_180:
5673 *dx = width - sx, *dy = height - sy;
5675 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5676 *dx = sx, *dy = height - sy;
5678 case WL_OUTPUT_TRANSFORM_270:
5679 *dx = sy, *dy = width - sx;
5681 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5691 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5694 int tx1, ty1, tx2, ty2;
5695 int width_from_buffer, height_from_buffer;
5697 switch (vp->buffer.transform)
5699 case WL_OUTPUT_TRANSFORM_90:
5700 case WL_OUTPUT_TRANSFORM_270:
5701 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5702 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5703 width_from_buffer = bh / vp->buffer.scale;
5704 height_from_buffer = bw / vp->buffer.scale;
5707 width_from_buffer = bw / vp->buffer.scale;
5708 height_from_buffer = bh / vp->buffer.scale;
5712 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5716 x2 = width_from_buffer;
5717 y2 = height_from_buffer;
5721 x1 = wl_fixed_to_int(vp->buffer.src_x);
5722 y1 = wl_fixed_to_int(vp->buffer.src_y);
5723 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5724 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5727 buffer_transform(width_from_buffer, height_from_buffer,
5728 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5729 buffer_transform(width_from_buffer, height_from_buffer,
5730 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5732 out->x = (tx1 <= tx2) ? tx1 : tx2;
5733 out->y = (ty1 <= ty2) ? ty1 : ty2;
5734 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5735 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5739 * Convert given four coordinates to elements of rectangle
5740 * @in p[4] Coordinates to be converted
5741 * @out rect x, y, width, and height
5742 * transform Angle which represents TDM_TRANSFORM of rectangle
5743 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5744 * 1. The given coordinates are not represented by rectangle.
5745 * 2. All angles except for 0, 90, 180, 270.
5748 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5750 Eina_Bool ret = EINA_FALSE;
5752 if ((p[0].y == p[1].y) && (p[1].x == p[2].x) && (p[2].y == p[3].y) && (p[3].x == p[0].x))
5755 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5758 *rotation = TDM_TRANSFORM_NORMAL;
5761 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5765 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5768 *rotation = TDM_TRANSFORM_180;
5771 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5776 else if ((p[0].x == p[1].x) && (p[1].y == p[2].y) && (p[2].x == p[3].x) && (p[3].y == p[0].y))
5779 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5782 *rotation = TDM_TRANSFORM_90;
5785 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5789 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5792 *rotation = TDM_TRANSFORM_270;
5795 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5805 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5810 for (i = 0; i < 4; i++)
5811 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5813 if (!_coords_to_rectangle_convert(p, out, rotation))
5815 DBG("Cannot convert given coords to rectangle.\n"
5816 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5817 p[0].x, p[0].y, p[1].x, p[1].y,
5818 p[2].x, p[2].y, p[3].x, p[3].y);
5826 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5828 int trans_rotation, flip;
5830 trans_rotation = transform & 0x3;
5831 flip = transform & 0x4;
5833 return (flip + (trans_rotation + rotation) % 4);
5837 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5845 if (e_comp_wl_subsurface_check(ec))
5846 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5853 out->w = ec->comp_data->width_from_viewport;
5854 out->w = (out->w + 1) & ~1;
5855 out->h = ec->comp_data->height_from_viewport;
5857 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5858 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5862 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5864 E_Comp_Wl_Buffer *buffer;
5865 E_Comp_Wl_Buffer_Viewport *vp;
5867 enum wl_output_transform buffer_transform;
5868 unsigned int rotation;
5869 Eina_Bool res = EINA_FALSE;
5871 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5873 if (e_object_is_del(E_OBJECT(ec)))
5876 vp = &ec->comp_data->scaler.buffer_viewport;
5878 if (buffer_viewport)
5880 buffer = ec->comp_data->buffer_ref.buffer;
5881 /* Getting a viewport of buffer needs geometry of buffer. */
5885 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5888 if ((output_viewport) || (transform))
5890 m = e_client_map_get(ec);
5892 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5894 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5899 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5900 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5901 * Since buffer.transform isn't applied using evas_map,
5902 * it has to be taken into account here to apply buffer.transform
5903 * and rotation of e_client_transform together. */
5905 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5907 *transform = (unsigned int)buffer_transform;
5915 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5917 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5918 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5920 /* Must be called with valid comp_data */
5921 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5923 if ((ec->comp_data->role_name == NULL) ||
5924 (ec->comp_data->role_name == role_name) ||
5925 (strcmp(ec->comp_data->role_name, role_name) == 0))
5927 ec->comp_data->role_name = role_name;
5933 wl_resource_post_error(error_resource, error_code,
5934 "Cannot assign role %s to wl_surface@%d,"
5935 " already has role %s\n",
5937 ec->comp_data->wl_surface ?
5938 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5939 ec->comp_data->role_name);
5945 EINTERN const char *
5946 e_comp_wl_surface_role_get(E_Client *ec)
5948 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5949 return ec->comp_data ? ec->comp_data->role_name : NULL;
5952 EINTERN struct wl_resource *
5953 e_comp_wl_client_surface_get(E_Client *ec)
5955 struct wl_resource *surface = NULL;
5956 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5957 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5959 g_mutex_lock(&ec->comp_data->surface_mutex);
5960 surface = ec->comp_data->surface;
5961 g_mutex_unlock(&ec->comp_data->surface_mutex);
5966 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5968 EINA_SAFETY_ON_NULL_RETURN(ec);
5969 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5971 g_mutex_lock(&ec->comp_data->surface_mutex);
5972 ec->comp_data->surface = surface;
5973 g_mutex_unlock(&ec->comp_data->surface_mutex);
5977 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5979 return e_compositor_util_client_from_surface_resource(surface_resource);
5983 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5985 if (!ec->comp_data->mapped)
5987 if (ec->comp_data->shell.surface &&
5988 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5990 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5996 if (ec->comp_data->mapped)
5998 /* will be unmapped. so run capture */
5999 e_comp_wl_remote_surface_image_save(ec);
6003 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
6005 ec->comp_data->pending.sx = sx;
6006 ec->comp_data->pending.sy = sy;
6007 ec->comp_data->pending.new_attach = EINA_TRUE;
6009 e_client_fps_update(ec);
6013 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6015 if (ec->comp_data->pending.opaque)
6016 eina_tiler_clear(ec->comp_data->pending.opaque);
6020 eina_tiler_union(ec->comp_data->pending.opaque, region);
6022 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6026 ec->argb = EINA_FALSE;
6027 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6029 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6030 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6038 ec->argb = EINA_TRUE;
6039 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6041 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6042 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6048 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6050 if (ec->comp_data->pending.input)
6051 eina_tiler_clear(ec->comp_data->pending.input);
6055 if (eina_tiler_empty(region))
6057 ELOGF("COMP", " |unset input rect", NULL);
6058 e_comp_object_input_objs_del(ec->frame);
6059 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6062 eina_tiler_union(ec->comp_data->pending.input, region);
6066 eina_tiler_rect_add(ec->comp_data->pending.input,
6067 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6072 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6074 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6078 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6080 E_Comp_Wl_Subsurf_Data *sdata;
6085 if (ec->comp_data->frames)
6087 ec->comp_data->frames =
6088 eina_list_remove(ec->comp_data->frames, callback_resource);
6091 if (ec->comp_data->pending.frames)
6093 ec->comp_data->pending.frames =
6094 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6097 sdata = ec->comp_data->sub.data;
6098 if ((sdata) && (sdata->cached.frames))
6100 sdata->cached.frames =
6101 eina_list_remove(sdata->cached.frames, callback_resource);
6106 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6108 if (e_object_is_del(E_OBJECT(ec))) return;
6110 if (e_comp_wl_remote_surface_commit(ec)) return;
6112 e_comp_wl_surface_commit(ec);
6114 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6118 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6120 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6121 ec->comp_data->sub.data = sub;
6123 /* set subsurface client properties */
6124 ec->borderless = EINA_TRUE;
6125 ec->argb = EINA_TRUE;
6126 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6127 ec->lock_border = EINA_TRUE;
6128 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6129 ec->netwm.state.skip_taskbar = EINA_TRUE;
6130 ec->netwm.state.skip_pager = EINA_TRUE;
6131 ec->no_shape_cut = EINA_TRUE;
6132 ec->border_size = 0;
6133 ec->lock_user_location = 0;
6134 ec->lock_client_location = 0;
6135 ec->lock_user_size = 0;
6136 ec->lock_client_size = 0;
6137 ec->lock_client_stacking = 0;
6138 ec->lock_user_shade = 0;
6139 ec->lock_client_shade = 0;
6140 ec->lock_user_maximize = 0;
6141 ec->lock_client_maximize = 0;
6142 ec->changes.need_maximize = 0;
6143 ec->maximized = E_MAXIMIZE_NONE;
6146 ec->new_client = ec->netwm.ping = EINA_TRUE;
6147 e_comp->new_clients++;
6148 e_client_unignore(ec);
6150 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6151 * It's not for subsurface. */
6152 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6156 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6158 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6161 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6163 sub->parent = parent;
6167 layer = e_client_layer_get(parent);
6168 if (layer > E_LAYER_BOTTOM)
6169 e_client_layer_set(ec, layer);
6172 if (parent->comp_data)
6174 /* append this client to the parents subsurface list */
6175 parent->comp_data->sub.list_pending =
6176 eina_list_append(parent->comp_data->sub.list_pending, ec);
6177 parent->comp_data->sub.list_changed = EINA_TRUE;
6182 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6184 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6185 E_Client *parent = sub->parent;
6187 parent->comp_data->sub.list =
6188 eina_list_remove(parent->comp_data->sub.list, ec);
6189 parent->comp_data->sub.list_pending =
6190 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6191 parent->comp_data->sub.below_list =
6192 eina_list_remove(parent->comp_data->sub.below_list, ec);
6193 parent->comp_data->sub.below_list_pending =
6194 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6200 e_comp_wl_client_subsurface_init(E_Client *ec, struct wl_resource *subsurface_resource, E_Comp_Wl_Subsurf_Data *sub, E_Client *parent, E_Client *offscreen_parent)
6202 sub->resource = subsurface_resource;
6203 sub->cached_buffer_ref.buffer = NULL;
6204 sub->synchronized = EINA_TRUE;
6205 sub->parent = parent;
6206 sub->remote_surface.offscreen_parent = offscreen_parent;
6207 if (offscreen_parent)
6208 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6210 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6212 _e_comp_wl_client_subsurface_set(ec, sub);
6213 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6215 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6219 e_comp_wl_client_subsurface_finish(E_Client *ec)
6221 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6224 e_comp_wl_client_subsurface_parent_unset(ec);
6226 e_comp_wl_surface_state_finish(&sub->cached);
6227 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6229 ec->comp_data->sub.data = NULL;
6233 e_comp_wl_client_evas_init(E_Client *ec)
6235 EINA_SAFETY_ON_NULL_RETURN(ec);
6237 _e_comp_wl_client_evas_init(ec);
6241 e_comp_wl_client_evas_deinit(E_Client *ec)
6243 EINA_SAFETY_ON_NULL_RETURN(ec);
6245 _e_comp_wl_client_evas_deinit(ec);
6249 e_comp_wl_focus_check(void)
6251 _e_comp_wl_focus_check();
6255 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6262 if ((parent->comp_data) && (parent->comp_data->sub.data))
6263 parent = parent->comp_data->sub.data->parent;