3 #include "e_wtz_shell_intern.h"
4 #include "e_comp_wl_private.h"
5 #include "e_client_intern.h"
6 #include "e_appinfo_intern.h"
7 #include "e_blender_intern.h"
9 #include <tizen-extension-server-protocol.h>
11 #include <relative-pointer-unstable-v1-server-protocol.h>
12 #include <pointer-constraints-unstable-v1-server-protocol.h>
14 #include <wayland-tbm-server.h>
17 #include <libds/log.h>
18 #include <libds/single_pixel_buffer_v1.h>
20 /* handle include for printing uint64_t */
21 #define __STDC_FORMAT_MACROS
24 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
26 /* Resource Data Mapping: (wl_resource_get_user_data)
28 * wl_surface == e_pixmap
29 * wl_region == eina_tiler
30 * wl_subsurface == e_client
34 typedef struct _E_Comp_Data E_Comp_Data;
39 struct wl_listener client_created;
42 static void _e_comp_wl_move_resize_init(void);
44 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
47 typedef struct _E_Comp_Wl_Key_Data
53 static Eina_List *handlers = NULL;
54 static E_Client *cursor_timer_ec = NULL;
55 static Eina_Bool need_send_released = EINA_FALSE;
56 static Eina_Bool need_send_motion = EINA_TRUE;
58 static GMutex connection_mutex;
60 static int _e_comp_wl_hooks_delete = 0;
61 static int _e_comp_wl_hooks_walking = 0;
63 static int _e_comp_wl_pid_hooks_delete = 0;
64 static int _e_comp_wl_pid_hooks_walking = 0;
66 static int _e_comp_wl_intercept_hooks_delete = 0;
67 static int _e_comp_wl_intercept_hooks_walking = 0;
69 static Eina_Inlist *_e_comp_wl_hooks[] =
71 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
72 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
73 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
74 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
75 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
76 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
77 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
78 [E_COMP_WL_HOOK_DEL] = NULL,
79 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
80 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
81 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
84 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
86 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
89 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
91 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
92 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
93 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
94 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
95 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
96 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
99 static Eina_List *hooks = NULL;
101 /* local functions */
103 _e_comp_wl_hooks_clean(void)
108 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
109 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
111 if (!ch->delete_me) continue;
112 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
118 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
122 e_object_ref(E_OBJECT(ec));
123 _e_comp_wl_hooks_walking++;
124 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
126 if (ch->delete_me) continue;
127 ch->func(ch->data, ec);
128 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
129 (e_object_is_del(E_OBJECT(ec))))
132 _e_comp_wl_hooks_walking--;
133 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
134 _e_comp_wl_hooks_clean();
135 e_object_unref(E_OBJECT(ec));
139 _e_comp_wl_pid_hooks_clean(void)
142 E_Comp_Wl_Pid_Hook *ch;
144 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
145 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
147 if (!ch->delete_me) continue;
148 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
154 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
156 E_Comp_Wl_Pid_Hook *ch;
158 _e_comp_wl_pid_hooks_walking++;
159 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
161 if (ch->delete_me) continue;
162 ch->func(ch->data, pid);
164 _e_comp_wl_pid_hooks_walking--;
165 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
166 _e_comp_wl_pid_hooks_clean();
170 _e_comp_wl_intercept_hooks_clean(void)
173 E_Comp_Wl_Intercept_Hook *ch;
175 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
176 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
178 if (!ch->delete_me) continue;
179 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
185 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
187 E_Comp_Wl_Intercept_Hook *ch;
188 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
190 e_object_ref(E_OBJECT(ec));
191 _e_comp_wl_intercept_hooks_walking++;
192 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
194 if (ch->delete_me) continue;
195 res = ch->func(ch->data, ec);
196 if (!res) ret = EINA_FALSE;
197 if (e_object_is_del(E_OBJECT(ec)))
200 _e_comp_wl_intercept_hooks_walking--;
201 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
202 _e_comp_wl_intercept_hooks_clean();
203 e_object_unref(E_OBJECT(ec));
210 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
216 if (e_comp_object_frame_exists(ec->frame))
217 w = ec->client.w, h = ec->client.h;
219 w = ec->w, h = ec->h;
223 // Width and Height are -1 means that we don't consider size value
227 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
231 _e_comp_wl_focus_check(void)
235 if (stopping) return;
236 ec = e_client_focused_get();
238 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
242 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
244 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
246 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
247 IDLE_EXITER~CB_PREPARE);
249 return ECORE_CALLBACK_RENEW;
253 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
255 /* dispatch pending wayland events */
256 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
258 return ECORE_CALLBACK_RENEW;
262 e_comp_wl_display_flush()
264 if (e_comp_wl && e_comp_wl->wl.disp)
266 if (e_config->key_input_ttrace_enable)
268 TRACE_INPUT_BEGIN(wl_display_flush_clients);
269 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
272 g_mutex_lock(&connection_mutex);
273 wl_display_flush_clients(e_comp_wl->wl.disp);
274 g_mutex_unlock(&connection_mutex);
276 if (e_config->key_input_ttrace_enable)
279 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
285 e_comp_wl_connection_lock()
287 e_input_boost_lock(&connection_mutex);
291 e_comp_wl_connection_unlock()
293 e_input_boost_unlock(&connection_mutex);
297 e_comp_wl_focused_client_flush()
299 E_Client *focused_ec;
300 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
302 e_input_boost_lock(&connection_mutex);
303 focused_ec = e_client_focused_get();
307 struct wl_client *wc;
308 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
311 e_input_boost_unlock(&connection_mutex);
315 wc = wl_resource_get_client(surface);
319 e_input_boost_unlock(&connection_mutex);
323 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
327 if (e_comp_wl->idle_exiter_timestamp > 0.0)
329 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
330 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
332 ELOGF("E_COMP", "prepare gap time: %lfms",
337 e_comp_wl->idle_exiter_timestamp = 0.0;
339 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
341 /* flush pending client events */
342 e_comp_wl_display_flush();
344 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
345 IDLE_EXITER~CB_PREPARE);
348 E_API enum wl_output_transform
349 e_comp_wl_output_buffer_transform_get(E_Client *ec)
351 E_Comp_Wl_Buffer_Viewport *vp;
352 E_Comp_Wl_Buffer *buffer;
353 enum wl_output_transform transform, rotation;
355 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
356 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
357 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
359 vp = &ec->comp_data->scaler.buffer_viewport;
360 if (e_comp_wl_subsurface_check(ec))
361 return vp->buffer.transform;
363 buffer = ec->comp_data->buffer_ref.buffer;
366 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
367 return vp->buffer.transform;
369 rotation = buffer->transform;
371 return vp->buffer.transform;
373 /* ignore the flip value when calculating transform because the screen rotation
374 * functionality doesn't consider the flip output transform currently
376 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
378 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
379 ec, rotation, vp->buffer.transform, transform);
384 EINTERN enum wl_output_transform
385 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
387 E_Comp_Wl_Buffer_Viewport *vp;
388 E_Comp_Wl_Buffer *buffer;
389 enum wl_output_transform transform, rotation;
391 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
392 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
393 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
395 vp = &ec->comp_data->pending.buffer_viewport;
396 if (e_comp_wl_subsurface_check(ec))
397 return vp->buffer.transform;
399 buffer = ec->comp_data->pending.buffer;
402 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
403 return vp->buffer.transform;
405 rotation = buffer->transform;
407 return vp->buffer.transform;
409 /* ignore the flip value when calculating transform because the screen rotation
410 * functionality doesn't consider the flip output transform currently
412 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
414 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
415 ec, rotation, vp->buffer.transform, transform);
421 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
423 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
424 E_Comp_Wl_Buffer *buffer;
425 int32_t width, height;
427 buffer = e_pixmap_resource_get(ec->pixmap);
430 ec->comp_data->width_from_buffer = 0;
431 ec->comp_data->height_from_buffer = 0;
435 switch (e_comp_wl_output_buffer_transform_get(ec))
437 case WL_OUTPUT_TRANSFORM_90:
438 case WL_OUTPUT_TRANSFORM_270:
439 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
440 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
441 width = buffer->h / vp->buffer.scale;
442 height = buffer->w / vp->buffer.scale;
445 width = buffer->w / vp->buffer.scale;
446 height = buffer->h / vp->buffer.scale;
450 ec->comp_data->width_from_buffer = width;
451 ec->comp_data->height_from_buffer = height;
455 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
457 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
458 int32_t width, height;
460 width = ec->comp_data->width_from_buffer;
461 height = ec->comp_data->height_from_buffer;
463 if (width == 0 && height == 0) return;
465 if (width != 0 && vp->surface.width != -1)
467 ec->comp_data->width_from_viewport = vp->surface.width;
468 ec->comp_data->height_from_viewport = vp->surface.height;
472 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
474 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
475 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
476 ec->comp_data->width_from_viewport = w ?: 1;
477 ec->comp_data->height_from_viewport = h ?: 1;
481 ec->comp_data->width_from_viewport = width;
482 ec->comp_data->height_from_viewport = height;
486 e_comp_wl_topmost_parent_get(E_Client *ec)
490 if (!e_comp_wl_subsurface_check(ec))
493 parent = e_comp_wl_subsurface_parent_get(ec);
496 if (!e_comp_wl_subsurface_check(parent))
499 parent = e_comp_wl_subsurface_parent_get(parent);
506 e_comp_wl_map_apply(E_Client *ec)
508 E_Comp_Wl_Buffer_Viewport *vp;
509 E_Comp_Wl_Subsurf_Data *sdata;
510 E_Comp_Wl_Client_Data *cdata;
511 int x1, y1, x2, y2, x, y;
513 Eina_Bool zoom_animating = EINA_FALSE;
515 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
517 e_comp_object_map_update(ec->frame);
519 cdata = ec->comp_data;
520 vp = &cdata->scaler.buffer_viewport;
521 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
522 (!cdata->viewport_transform))
525 if (e_comp_wl_subsurface_check(ec))
527 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
529 sdata = ec->comp_data->sub.data;
530 if (sdata->remote_surface.offscreen_parent)
532 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
533 Eina_Rectangle *rect;
536 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
538 /* TODO: If there are one more regions, it means that provider's offscreen
539 * is displayed by one more remote_surfaces. Have to consider it later. At
540 * this time, just consider only one remote_surface.
554 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
555 if (x != dx || y != dy)
556 evas_object_move(ec->frame, dx, dy);
558 if (!cdata->viewport_transform)
560 cdata->viewport_transform = e_util_transform_new();
561 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
562 e_client_transform_core_add(ec, cdata->viewport_transform);
565 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
566 ec->comp_data->width_from_viewport,
567 ec->comp_data->height_from_viewport);
569 if (vp->buffer.src_width == wl_fixed_from_int(-1))
573 x2 = cdata->width_from_buffer;
574 y2 = cdata->height_from_buffer;
578 x1 = wl_fixed_to_int(vp->buffer.src_x);
579 y1 = wl_fixed_to_int(vp->buffer.src_y);
580 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
581 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
584 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
585 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
586 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
587 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
590 desk = e_comp_desk_find_by_ec(ec);
592 zoom_animating = e_desk_zoom_is_animating(desk);
594 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
595 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
596 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
598 /* workaround:: when the desk zoom is doing their animation,
599 the transform core update can override animation's zoom boundary.
600 so, don't doing transform core update while desk zoom animation */
602 e_client_transform_core_update(ec);
607 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
611 int map_c = 0, map_x = 0, map_y = 0;
612 double inv_x = 0.0, inv_y = 0.0;
614 EINA_SAFETY_ON_NULL_RETURN(ec);
616 map = e_client_map_get(ec);
617 map_c = e_map_count_get(map);
619 if (!map || map_c <= 0)
629 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
630 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
631 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
632 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
634 for (int i = 0; i < map_c; i++)
636 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
637 e_map_point_image_uv_set(map2, i, map_x, map_y);
639 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
649 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
655 if (!(ec = data)) return;
656 if (e_object_is_del(data)) return;
658 if (!ec->override) e_hints_window_visible_set(ec);
660 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
661 (!ec->comp_data->need_reparent))
663 ec->comp_data->need_reparent = EINA_TRUE;
664 ec->visible = EINA_TRUE;
666 if (!e_client_util_ignored_get(ec))
668 ec->take_focus = !starting;
672 if (!ec->comp_data->need_reparent)
674 if ((ec->hidden) || (ec->iconic))
676 evas_object_hide(ec->frame);
677 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
680 evas_object_show(ec->frame);
683 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
684 evas_object_show(tmp->frame);
686 topmost = e_comp_wl_topmost_parent_get(ec);
687 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
688 e_comp_wl_subsurface_show(ec);
690 if (ec->comp_data->sub.below_obj)
691 evas_object_show(ec->comp_data->sub.below_obj);
695 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
701 if (!(ec = data)) return;
702 if (e_object_is_del(E_OBJECT(ec))) return;
704 /* Uncommonly some clients's final buffer can be skipped if the client
705 * requests unmap of its surface right after wl_surface@commit.
706 * So if this client evas object is hidden state and client is already
707 * unmmapped, we can consider to clear pixmap image here mandatorily.
709 if (!ec->comp_data->mapped)
710 e_pixmap_image_clear(ec->pixmap, 1);
712 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
713 evas_object_hide(tmp->frame);
715 topmost = e_comp_wl_topmost_parent_get(ec);
716 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
717 e_comp_wl_subsurface_hide(ec);
719 if (ec->comp_data->sub.below_obj)
720 evas_object_hide(ec->comp_data->sub.below_obj);
722 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
726 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
733 if (!(ec = data)) return;
734 if (e_object_is_del(E_OBJECT(ec))) return;
736 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
738 if (!e_comp_wl_subsurface_check(subc)) continue;
739 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
740 evas_object_move(subc->frame, x, y);
742 if (subc->comp_data->scaler.viewport)
744 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
745 if (cdata->viewport_transform)
746 e_comp_wl_map_apply(subc);
750 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
752 if (!e_comp_wl_subsurface_check(subc)) continue;
753 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
754 evas_object_move(subc->frame, x, y);
756 if (subc->comp_data->scaler.viewport)
758 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
759 if (cdata->viewport_transform)
760 e_comp_wl_map_apply(subc);
764 if (ec->comp_data->sub.below_obj)
766 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
767 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
772 _e_comp_wl_send_touch_cancel(E_Client *ec)
775 struct wl_resource *res;
776 struct wl_client *wc;
777 E_Comp_Config *comp_conf = NULL;
780 if (e_object_is_del(E_OBJECT(ec))) return;
781 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
783 if (!surface) return;
784 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
786 wc = wl_resource_get_client(surface);
788 comp_conf = e_comp_config_get();
790 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
792 if (wl_resource_get_client(res) != wc) continue;
793 if (!e_comp_wl_input_touch_check(res)) continue;
795 if (comp_conf && comp_conf->input_log_enable)
796 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
798 wl_touch_send_cancel(res);
803 _e_comp_wl_touch_cancel(void)
807 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
809 if (!e_comp_wl->touch.pressed) return;
811 _e_comp_wl_send_touch_cancel(ec);
814 static E_Devicemgr_Input_Device *
815 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
817 E_Devicemgr_Input_Device *last_kbd = NULL;
820 case ECORE_DEVICE_CLASS_MOUSE:
821 return e_devicemgr->last_device_ptr;
822 case ECORE_DEVICE_CLASS_KEYBOARD:
823 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
825 case ECORE_DEVICE_CLASS_TOUCH:
826 return e_devicemgr->last_device_touch;
834 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
838 case ECORE_DEVICE_CLASS_MOUSE:
839 e_devicemgr->last_device_ptr = device;
841 case ECORE_DEVICE_CLASS_KEYBOARD:
842 atomic_store(&e_devicemgr->last_device_kbd, device);
844 case ECORE_DEVICE_CLASS_TOUCH:
845 e_devicemgr->last_device_touch = device;
852 static E_Devicemgr_Input_Device *
853 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
855 E_Devicemgr_Input_Device *last_kbd = NULL;
859 case ECORE_DEVICE_CLASS_MOUSE:
860 return ec->comp_data->last_device_ptr;
861 case ECORE_DEVICE_CLASS_KEYBOARD:
862 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
864 case ECORE_DEVICE_CLASS_TOUCH:
865 return ec->comp_data->last_device_touch;
873 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
877 case ECORE_DEVICE_CLASS_MOUSE:
878 ec->comp_data->last_device_ptr = device;
880 case ECORE_DEVICE_CLASS_KEYBOARD:
881 atomic_store(&ec->comp_data->last_device_kbd, device);
883 case ECORE_DEVICE_CLASS_TOUCH:
884 ec->comp_data->last_device_touch = device;
892 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
894 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
895 struct wl_resource *dev_res;
896 const char *dev_name;
897 Ecore_Device_Class dev_class;
898 struct wl_client *wc;
902 EINA_SAFETY_ON_NULL_RETURN(dev);
905 if (ec->cur_mouse_action || e_comp_wl->drag)
907 if (e_object_is_del(E_OBJECT(ec))) return;
908 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
909 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
910 if (!surface) return;
912 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
913 dev_name = evas_device_description_get(dev);
914 last_device = _e_comp_wl_device_last_device_get(dev_class);
915 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
917 serial = wl_display_next_serial(e_comp_wl->wl.disp);
918 wc = wl_resource_get_client(surface);
919 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
920 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
922 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
923 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
925 _e_comp_wl_device_last_device_set(dev_class, input_dev);
926 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
928 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
930 if (wl_resource_get_client(dev_res) != wc) continue;
931 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
935 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
939 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
941 E_Devicemgr_Input_Device *last_device;
942 struct wl_resource *dev_res;
943 struct wl_client *wc;
947 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
948 if (!surface) return;
950 last_device = _e_comp_wl_device_last_device_get(dev_class);
951 if (!last_device) return;
953 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
955 serial = wl_display_next_serial(e_comp_wl->wl.disp);
956 wc = wl_resource_get_client(surface);
957 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
959 if (wl_resource_get_client(dev_res) != wc) continue;
960 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
965 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
967 E_Devicemgr_Input_Device *input_dev;
968 struct wl_resource *dev_res;
969 const char *dev_name;
972 EINA_SAFETY_ON_NULL_RETURN(dev);
974 dev_name = ecore_device_identifier_get(dev);
976 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
977 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
979 if (!eina_streq(input_dev->identifier, dev_name) ||
980 (input_dev->clas != ecore_device_class_get(dev))) continue;
981 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
983 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
985 if (wl_resource_get_client(dev_res) != wc) continue;
986 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
989 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
993 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
995 E_Devicemgr_Input_Device *input_dev;
996 struct wl_resource *dev_res;
997 const char *dev_name;
1000 EINA_SAFETY_ON_NULL_RETURN(dev);
1002 dev_name = e_device_identifier_get(dev);
1004 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1005 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1007 if (!eina_streq(input_dev->identifier, dev_name) ||
1008 (input_dev->clas != e_device_class_get(dev))) continue;
1009 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1011 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1013 if (wl_resource_get_client(dev_res) != wc) continue;
1014 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1017 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1021 _e_comp_wl_cursor_reload(E_Client *ec)
1023 struct wl_resource *res;
1024 struct wl_client *wc;
1030 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1031 !evas_object_visible_get(e_comp->pointer->o_ptr))
1032 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1035 if (e_object_is_del(E_OBJECT(ec))) return;
1036 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1037 if (!surface) return;
1038 if (ec->pointer_enter_sent) return;
1040 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1041 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1043 if (e_client_transform_core_enable_get(ec))
1045 double dx = 0.0, dy = 0.0;
1046 map = e_client_map_get(ec);
1047 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1053 cx = px - ec->client.x;
1054 cy = py - ec->client.y;
1056 wc = wl_resource_get_client(surface);
1057 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1058 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1060 if (!e_comp_wl_input_pointer_check(res)) continue;
1061 if (wl_resource_get_client(res) != wc) continue;
1062 wl_pointer_send_enter(res, serial, surface,
1063 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1064 ec->pointer_enter_sent = EINA_TRUE;
1066 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1070 _e_comp_wl_cursor_timer(void *data)
1072 E_Client *ec = data;
1074 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1075 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1077 e_comp_wl_cursor_hide(ec);
1079 return ECORE_CALLBACK_CANCEL;
1083 _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)
1085 E_Devicemgr_Input_Device *input_dev;
1086 struct wl_resource *dev_res;
1087 struct wl_client *wc;
1092 if (ec->cur_mouse_action) return;
1093 if (e_object_is_del(E_OBJECT(ec))) return;
1094 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1095 if (!surface) return;
1097 f_value = wl_fixed_from_double(value);
1098 wc = wl_resource_get_client(surface);
1100 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1101 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1103 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1104 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1106 if (wl_resource_get_client(dev_res) != wc) continue;
1107 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1110 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1114 _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)
1116 if (idx >= e_input_touch_max_count_get()) return;
1118 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1119 e_devicemgr->multi[idx].radius_x = radius_x;
1120 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1121 e_devicemgr->multi[idx].radius_y = radius_y;
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;
1124 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1125 e_devicemgr->multi[idx].angle = angle;
1129 _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)
1131 if (idx >= e_input_touch_max_count_get()) return;
1133 if (e_devicemgr->multi[idx].radius_x != radius_x)
1135 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1136 e_devicemgr->multi[idx].radius_x = radius_x;
1138 if (e_devicemgr->multi[idx].radius_y != radius_y)
1140 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1141 e_devicemgr->multi[idx].radius_y = radius_y;
1143 if (e_devicemgr->multi[idx].pressure != pressure)
1145 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1146 e_devicemgr->multi[idx].pressure = pressure;
1148 if (e_devicemgr->multi[idx].angle != angle)
1150 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1151 e_devicemgr->multi[idx].angle = angle;
1156 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1158 Eina_Bool ret = EINA_TRUE;
1161 case EVAS_CALLBACK_MOUSE_IN:
1162 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1165 if (e_comp_wl->ptr.hide_tmr)
1167 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1168 cursor_timer_ec = ec;
1169 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1173 if (e_pointer_is_hidden(e_comp->pointer))
1178 case EVAS_CALLBACK_MOUSE_OUT:
1179 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1182 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1186 case EVAS_CALLBACK_MOUSE_MOVE:
1187 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
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_WHEEL:
1195 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1198 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1199 _e_comp_wl_cursor_reload(ec);
1202 case EVAS_CALLBACK_MOUSE_DOWN:
1203 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1206 if (e_comp_wl->ptr.hide_tmr)
1208 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1209 e_comp_wl->ptr.hide_tmr = NULL;
1211 cursor_timer_ec = NULL;
1213 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1214 _e_comp_wl_cursor_reload(ec);
1217 case EVAS_CALLBACK_MOUSE_UP:
1218 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1229 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1231 if (ec->has_cursor_unset)
1234 if (!e_config->show_cursor)
1237 if (!e_config->use_cursor_timer)
1244 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1247 Evas_Event_Mouse_In *ev;
1248 struct wl_resource *res;
1249 struct wl_client *wc;
1252 E_Comp_Config *comp_conf;
1253 E_Client *prev_ptr_ec;
1257 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1258 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1260 if (!(ec = data)) return;
1261 if (e_object_is_del(E_OBJECT(ec))) return;
1262 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1263 if (!surface) return;
1265 prev_ptr_ec = e_comp_wl->ptr.ec;
1268 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1269 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1272 e_comp_wl->ptr.ec = ec;
1274 comp_conf = e_comp_config_get();
1275 if (comp_conf && comp_conf->input_log_enable)
1276 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1277 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1278 e_client_util_name_get(ec));
1280 if (_e_comp_wl_check_cursor_timer_needed(ec))
1282 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1286 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1287 wc = wl_resource_get_client(surface);
1288 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1289 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1291 if (!e_comp_wl_input_pointer_check(res)) continue;
1292 if (wl_resource_get_client(res) != wc) continue;
1294 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1296 wl_pointer_send_enter(res, serial, surface,
1297 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1298 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1299 ec->pointer_enter_sent = EINA_TRUE;
1302 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1306 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1309 Evas_Event_Mouse_Out *ev;
1310 struct wl_resource *res;
1311 struct wl_client *wc;
1314 Eina_Bool inside_check;
1315 E_Comp_Config *comp_conf;
1319 if (!(ec = data)) return;
1320 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1321 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1322 if (ec->cur_mouse_action && inside_check) return;
1323 if (e_object_is_del(E_OBJECT(e_comp))) return;
1324 if (e_comp_wl->ptr.ec == ec)
1325 e_comp_wl->ptr.ec = NULL;
1326 if (e_object_is_del(E_OBJECT(ec))) return;
1328 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1329 if (!surface) return;
1331 comp_conf = e_comp_config_get();
1332 if (comp_conf && comp_conf->input_log_enable)
1333 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1334 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1335 e_client_util_name_get(ec));
1337 if (_e_comp_wl_check_cursor_timer_needed(ec))
1339 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1343 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1345 wc = wl_resource_get_client(surface);
1346 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1347 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1349 if (!e_comp_wl_input_pointer_check(res)) continue;
1350 if (wl_resource_get_client(res) != wc) continue;
1351 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1353 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1355 wl_pointer_send_leave(res, serial, surface);
1356 ec->pointer_enter_sent = EINA_FALSE;
1361 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1364 struct wl_client *wc;
1365 struct wl_resource *res;
1368 E_Comp_Config *comp_conf = NULL;
1371 if (e_object_is_del(E_OBJECT(ec))) return;
1372 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1373 if (!surface) return;
1375 wc = wl_resource_get_client(surface);
1376 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1380 x = wl_fixed_from_int(canvas_x - ec->client.x);
1381 y = wl_fixed_from_int(canvas_y - ec->client.y);
1384 comp_conf = e_comp_config_get();
1386 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1388 if (wl_resource_get_client(res) != wc) continue;
1389 if (!e_comp_wl_input_touch_check(res)) continue;
1390 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1393 if (comp_conf && comp_conf->input_log_enable)
1394 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));
1396 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1400 if (comp_conf && comp_conf->input_log_enable)
1401 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));
1403 wl_touch_send_up(res, serial, timestamp, idx);
1410 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1413 struct wl_client *wc;
1414 struct wl_resource *res;
1418 if (ec->cur_mouse_action) return;
1419 if (e_object_is_del(E_OBJECT(ec))) return;
1420 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1421 if (!surface) return;
1423 wc = wl_resource_get_client(surface);
1425 x = wl_fixed_from_int(canvas_x - ec->client.x);
1426 y = wl_fixed_from_int(canvas_y - ec->client.y);
1428 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1430 if (wl_resource_get_client(res) != wc) continue;
1431 if (!e_comp_wl_input_touch_check(res)) continue;
1432 wl_touch_send_motion(res, timestamp, idx, x, y);
1437 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1439 struct wl_resource *res;
1440 struct wl_client *wc;
1444 if (ec->cur_mouse_action) return;
1445 if (e_object_is_del(E_OBJECT(ec))) return;
1446 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1447 if (!surface) return;
1449 wc = wl_resource_get_client(surface);
1450 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1452 if (!e_comp_wl_input_pointer_check(res)) continue;
1453 if (wl_resource_get_client(res) != wc) continue;
1454 wl_pointer_send_motion(res, timestamp,
1455 wl_fixed_from_int(x - ec->client.x),
1456 wl_fixed_from_int(y - ec->client.y));
1461 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1463 if (e_comp_wl->ptr.hide_tmr)
1465 if (cursor_timer_ec == ec)
1467 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1468 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1472 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1473 cursor_timer_ec = ec;
1474 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1479 cursor_timer_ec = ec;
1480 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1485 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1488 Evas_Event_Mouse_Move *ev;
1489 Evas_Device *dev = NULL;
1490 const char *dev_name;
1491 E_Comp_Config *comp_conf;
1495 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1496 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1498 if (!(ec = data)) return;
1499 if (e_object_is_del(E_OBJECT(ec))) return;
1500 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1501 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1502 if (!surface) return;
1504 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1507 dev_name = evas_device_description_get(dev);
1509 comp_conf = e_comp_config_get();
1510 if (comp_conf && comp_conf->input_log_enable)
1511 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1512 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1513 e_client_util_name_get(ec), dev_name);
1515 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1517 if (!e_comp_wl->drag_client)
1519 e_comp_wl->touch.faked_ec = ec;
1520 if (e_comp_wl->touch.pressed & (1 << 0))
1522 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1524 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1525 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1526 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1530 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1534 if (!e_comp_wl->drag_client)
1536 if (_e_comp_wl_check_cursor_timer_needed(ec))
1538 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1542 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1543 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1545 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1547 if (_e_comp_wl_check_cursor_timer_needed(ec))
1548 _e_comp_wl_cursor_move_timer_control(ec);
1552 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1557 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1559 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1560 if (e_object_is_del(E_OBJECT(ec))) return;
1561 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1562 if (!surface) return;
1563 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1565 e_comp_wl->ptr.button = BTN_LEFT;
1567 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1571 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1573 E_Client *ec = data;
1574 Evas_Event_Mouse_Down *ev = event;
1575 Evas_Device *dev = NULL;
1576 const Evas_Device *seat_dev;
1577 const char *dev_name, *seat_name;
1578 E_Comp_Config *comp_conf = NULL;
1581 if (e_object_is_del(E_OBJECT(ec))) return;
1584 dev_name = evas_device_description_get(dev);
1586 seat_dev = evas_device_parent_get(dev);
1587 seat_name = evas_device_name_get(seat_dev);
1589 comp_conf = e_comp_config_get();
1590 if (comp_conf && comp_conf->input_log_enable)
1591 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1592 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1593 dev_name, seat_name);
1595 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1597 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1599 e_comp_wl->touch.faked_ec = ec;
1602 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1603 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1604 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1606 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1607 e_comp_wl->touch.pressed |= (1 << 0);
1611 if (_e_comp_wl_check_cursor_timer_needed(ec))
1613 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1617 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1618 WL_POINTER_BUTTON_STATE_PRESSED);
1620 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1623 need_send_released = EINA_TRUE;
1627 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1629 E_Client *ec = data;
1630 Evas_Event_Mouse_Up *ev = event;
1631 Evas_Device *dev = NULL;
1632 const Evas_Device *seat_dev;
1633 const char *dev_name, *seat_name;;
1634 Evas_Event_Flags flags;
1635 E_Comp_Config *comp_conf = NULL;
1638 if (ec->cur_mouse_action) return;
1639 if (e_object_is_del(E_OBJECT(ec))) return;
1641 if (!need_send_released)
1643 need_send_motion = EINA_TRUE;
1647 dev_name = evas_device_description_get(dev);
1649 seat_dev = evas_device_parent_get(dev);
1650 seat_name = evas_device_name_get(seat_dev);
1651 flags = evas_event_default_flags_get(evas);
1653 comp_conf = e_comp_config_get();
1654 if (comp_conf && comp_conf->input_log_enable)
1655 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1656 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1657 dev_name, seat_name);
1659 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1661 e_comp_wl->touch.pressed &= ~(1 << 0);
1663 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1664 e_comp_wl->touch.faked_ec = NULL;
1667 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1669 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1671 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1674 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1675 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1676 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1680 if (_e_comp_wl_check_cursor_timer_needed(ec))
1682 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1686 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1687 WL_POINTER_BUTTON_STATE_RELEASED);
1689 if (_e_comp_wl_check_cursor_timer_needed(ec))
1690 _e_comp_wl_cursor_move_timer_control(ec);
1694 need_send_released = EINA_FALSE;
1698 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1700 struct wl_resource *res;
1701 struct wl_client *wc;
1706 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1708 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1711 dir = -wl_fixed_from_int(abs(z));
1713 dir = wl_fixed_from_int(z);
1716 if (e_object_is_del(E_OBJECT(ec))) return;
1717 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1718 if (!surface) return;
1720 wc = wl_resource_get_client(surface);
1721 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1723 if (!e_comp_wl_input_pointer_check(res)) continue;
1724 if (wl_resource_get_client(res) != wc) continue;
1725 wl_pointer_send_axis(res, timestamp, axis, dir);
1730 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1733 Evas_Event_Mouse_Wheel *ev;
1736 if (!(ec = data)) return;
1737 if (ec->cur_mouse_action) return;
1738 if (e_object_is_del(E_OBJECT(ec))) return;
1739 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1740 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1741 if (!surface) return;
1743 if (!eina_list_count(e_comp_wl->ptr.resources))
1746 if (_e_comp_wl_check_cursor_timer_needed(ec))
1748 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1752 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1754 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1756 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1758 if (_e_comp_wl_check_cursor_timer_needed(ec))
1759 _e_comp_wl_cursor_move_timer_control(ec);
1764 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1766 E_Client *ec = data;
1767 Evas_Event_Multi_Down *ev = event;
1768 Evas_Device *dev = NULL;
1769 const Evas_Device *seat_dev;
1770 const char *dev_name, *seat_name;
1771 Evas_Device_Class dev_class;
1772 E_Comp_Config *comp_conf = NULL;
1775 if (e_object_is_del(E_OBJECT(ec))) return;
1776 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1777 if (!surface) return;
1779 /* Do not deliver emulated single touch events to client */
1780 if (ev->device == 0) return;
1783 dev_name = evas_device_description_get(dev);
1784 e_comp_wl->touch.faked_ec = ec;
1786 seat_dev = evas_device_parent_get(dev);
1787 seat_name = evas_device_name_get(seat_dev);
1789 comp_conf = e_comp_config_get();
1790 if (comp_conf && comp_conf->input_log_enable)
1791 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1792 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1793 dev_name, seat_name);
1795 if (dev && dev_name)
1797 dev_class = evas_device_class_get(dev);
1798 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1799 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1802 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1803 e_comp_wl->touch.pressed |= (1 << ev->device);
1807 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1809 E_Client *ec = data;
1810 Evas_Event_Multi_Up *ev = event;
1811 Evas_Device *dev = NULL;
1812 const Evas_Device *seat_dev;
1813 const char *dev_name, *seat_name;
1814 Evas_Device_Class dev_class;
1815 Evas_Event_Flags flags;
1816 E_Comp_Config *comp_conf = NULL;
1819 if (e_object_is_del(E_OBJECT(ec))) return;
1820 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1821 if (!surface) return;
1823 /* Do not deliver emulated single touch events to client */
1824 if (ev->device == 0) return;
1826 flags = evas_event_default_flags_get(evas);
1828 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1829 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1830 e_comp_wl->touch.faked_ec = NULL;
1832 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1835 dev_name = evas_device_description_get(dev);
1837 seat_dev = evas_device_parent_get(dev);
1838 seat_name = evas_device_name_get(seat_dev);
1840 comp_conf = e_comp_config_get();
1841 if (comp_conf && comp_conf->input_log_enable)
1842 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1843 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1844 dev_name, seat_name);
1846 if (dev && dev_name)
1848 dev_class = evas_device_class_get(dev);
1849 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1850 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1853 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1857 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1859 E_Client *ec = data;
1860 Evas_Event_Multi_Move *ev = event;
1861 Evas_Device *dev = NULL;
1862 const char *dev_name;
1863 Evas_Device_Class dev_class;
1866 if (e_object_is_del(E_OBJECT(ec))) return;
1867 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1868 if (!surface) return;
1870 /* Do not deliver emulated single touch events to client */
1871 if (ev->device == 0) return;
1873 e_comp_wl->touch.faked_ec = ec;
1875 if (e_comp_wl->touch.pressed & (1 << ev->device))
1878 if (dev && (dev_name = evas_device_description_get(dev)))
1880 dev_class = evas_device_class_get(dev);
1881 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1882 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1885 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1890 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1893 char *file, buff[PATH_MAX];
1900 n = (getpriority(PRIO_PROCESS, pid) + adj);
1904 setpriority(PRIO_PROCESS, pid, n);
1907 use_adj = EINA_TRUE;
1909 if (!do_child) return;
1911 files = ecore_file_ls("/proc");
1912 EINA_LIST_FREE(files, file)
1914 if (!isdigit(file[0]))
1917 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1918 if ((f = fopen(buff, "r")))
1922 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1924 if (num_read == 2 && ppid == pid)
1925 _e_comp_wl_client_priority_adjust(pid2, set,
1927 adj_child, do_child);
1935 _e_comp_wl_client_priority_raise(E_Client *ec)
1937 if (!e_config->priority_control) return;
1938 if (ec->netwm.pid <= 0) return;
1939 if (ec->netwm.pid == getpid()) return;
1940 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1941 e_config->priority - 1, -1,
1942 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1946 _e_comp_wl_client_priority_normal(E_Client *ec)
1948 if (!e_config->priority_control) return;
1949 if (ec->netwm.pid <= 0) return;
1950 if (ec->netwm.pid == getpid()) return;
1951 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1952 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1956 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1959 E_Comp_Wl_Key_Data *k;
1960 struct wl_resource *res;
1964 if (!ec) return EINA_FALSE;
1965 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1966 if (!ec->comp_data) return EINA_FALSE;
1968 ec->comp_data->on_focus_timer = NULL;
1969 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1970 if (!e_comp_wl->kbd.focused)
1972 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1975 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1977 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1978 t = ecore_time_unix_get();
1980 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1981 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1982 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1984 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1986 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1987 wl_keyboard_send_key(res, serial, t,
1988 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1991 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1992 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1996 /* It is called in the following cases:
1997 * When a normal ec->frame has focus.
1998 * Or launching image ec is replaced to the real ec.
2001 e_comp_wl_feed_focus_in(E_Client *ec)
2004 struct wl_resource *res;
2005 struct wl_client *wc;
2009 if (e_object_is_del(E_OBJECT(ec))) return;
2010 if (ec->iconic) return;
2012 /* block spurious focus events */
2013 focused = e_client_focused_get();
2014 if ((focused) && (ec != focused)) return;
2016 /* raise client priority */
2017 _e_comp_wl_client_priority_raise(ec);
2018 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2019 if (!surface) return;
2021 wc = wl_resource_get_client(surface);
2023 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2024 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2026 if (wl_resource_get_client(res) == wc)
2028 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2029 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2030 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2031 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2034 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2036 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2037 if (!e_comp_wl->kbd.focused)
2039 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2042 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2044 e_comp_wl->kbd.focus = surface;
2045 e_comp_wl_input_keyboard_enter_send(ec);
2046 e_comp_wl_data_device_keyboard_focus_set();
2047 ec->comp_data->on_focus_timer =
2048 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2049 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2050 int rotation = ec->e.state.rot.ang.curr;
2051 e_pointer_rotation_set(e_comp->pointer, rotation);
2055 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2058 if (!(ec = data)) return;
2059 e_comp_wl_feed_focus_in(ec);
2063 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2066 struct wl_resource *res;
2068 E_Comp_Wl_Key_Data *k;
2072 if (!(ec = data)) return;
2074 if (!ec->comp_data) return;
2076 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2078 /* lower client priority */
2079 if (!e_object_is_del(data))
2080 _e_comp_wl_client_priority_normal(ec);
2083 /* update keyboard modifier state */
2084 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2085 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2086 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2088 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2090 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2091 if (!surface) return;
2093 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2094 if (!eina_list_count(e_comp_wl->kbd.resources))
2096 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2100 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2102 /* send keyboard_leave to all keyboard resources */
2103 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2104 t = ecore_time_unix_get();
2106 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2107 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2108 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2110 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2112 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2113 wl_keyboard_send_key(res, serial, t,
2114 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2116 wl_keyboard_send_leave(res, serial, surface);
2117 e_comp_wl->kbd.focused =
2118 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2120 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2121 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2125 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2129 if (!(ec = data)) return;
2131 if (!ec->comp_data->shell.configure_send) return;
2133 /* TODO: calculate x, y with transfrom object */
2134 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2138 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2139 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2140 if (e_comp_object_frame_exists(ec->frame))
2141 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2143 switch (ec->resize_mode)
2145 case E_POINTER_RESIZE_TL:
2146 case E_POINTER_RESIZE_L:
2147 case E_POINTER_RESIZE_BL:
2148 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2149 ec->mouse.current.mx;
2151 case E_POINTER_RESIZE_TR:
2152 case E_POINTER_RESIZE_R:
2153 case E_POINTER_RESIZE_BR:
2154 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2159 switch (ec->resize_mode)
2161 case E_POINTER_RESIZE_TL:
2162 case E_POINTER_RESIZE_T:
2163 case E_POINTER_RESIZE_TR:
2164 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2165 ec->mouse.current.my;
2167 case E_POINTER_RESIZE_BL:
2168 case E_POINTER_RESIZE_B:
2169 case E_POINTER_RESIZE_BR:
2170 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2175 w = E_CLAMP(w, 1, w);
2176 h = E_CLAMP(h, 1, h);
2177 e_client_resize_limit(ec, &w, &h);
2179 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2181 else if ((!ec->fullscreen) && (!ec->maximized) &&
2182 (!ec->comp_data->maximize_pre))
2186 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2187 if ((pw != ec->w) || (ph != ec->h))
2189 _e_comp_wl_configure_send(ec, 1, 1);
2193 if (ec->comp_data->sub.below_obj)
2194 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2198 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2200 E_Client *ec = data;
2202 ec->comp_data->maximize_pre = 1;
2206 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2208 E_Client *ec = data;
2211 if (e_object_is_del(E_OBJECT(ec))) return;
2213 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2214 e_client_shell_configure_send(ec, 0, w, h);
2216 ec->comp_data->maximize_pre = 0;
2220 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2222 E_Client *ec = data;
2224 ec->comp_data->maximize_pre = 1;
2228 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2230 E_Client *ec = data;
2232 if (e_object_is_del(E_OBJECT(ec))) return;
2234 /* check for wayland pixmap */
2236 if (ec->comp_data->shell.configure_send)
2237 _e_comp_wl_configure_send(ec, 0, 0);
2239 ec->comp_data->maximize_pre = 0;
2243 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2245 E_Client *ec = data;
2247 if (e_object_is_del(E_OBJECT(ec))) return;
2249 /* check for wayland pixmap */
2251 if (ec->comp_data->shell.configure_send)
2252 _e_comp_wl_configure_send(ec, 0, 1);
2254 ec->comp_data->maximize_pre = 0;
2258 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2260 E_Client *ec = data;
2262 if (e_object_is_del(E_OBJECT(ec))) return;
2264 /* check for wayland pixmap */
2266 if (ec->comp_data->shell.configure_send)
2267 _e_comp_wl_configure_send(ec, 0, 0);
2269 ec->comp_data->maximize_pre = 0;
2273 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2277 if (!(ec = data)) return;
2279 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2281 e_object_del(E_OBJECT(ec));
2283 _e_comp_wl_focus_check();
2285 /* TODO: Delete request send ??
2286 * NB: No such animal wrt wayland */
2290 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2294 if (!(ec = data)) return;
2296 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2299 if (ec->comp_data->reparented)
2300 e_client_comp_hidden_set(ec, EINA_TRUE);
2303 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2304 if (ec->visible) evas_object_hide(ec->frame);
2305 if (!ec->internal) e_object_del(E_OBJECT(ec));
2307 _e_comp_wl_focus_check();
2311 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2315 if (!(ec = data)) return;
2317 e_client_shell_ping(ec);
2321 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2326 if (!(ec = data)) return;
2327 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2328 if (ec->netwm.opacity == a) return;
2329 ec->netwm.opacity = a;
2330 ec->netwm.opacity_changed = EINA_TRUE;
2334 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2336 Eina_Rectangle *damage_rect = NULL;
2337 Eina_Rectangle *dmg = NULL;
2338 Eina_List *l = NULL;
2340 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2341 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2344 if (!buffer->tbm_surface) return;
2348 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2352 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2353 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2356 eina_rectangle_union(damage_rect, dmg);
2361 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2362 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2365 tbm_surface_internal_set_damage(buffer->tbm_surface,
2371 eina_rectangle_free(damage_rect);
2375 _e_comp_wl_client_evas_init(E_Client *ec)
2377 if (!ec || !ec->comp_data) return;
2378 if (ec->comp_data->evas_init) return;
2380 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2381 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2382 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2385 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2386 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2387 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2388 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2389 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2390 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2392 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2393 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2396 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2397 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2401 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2402 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2403 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2404 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2405 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2406 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2407 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2410 /* setup delete/kill callbacks */
2411 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2412 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2414 /* setup ping callback */
2415 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2416 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2418 ec->comp_data->evas_init = EINA_TRUE;
2422 _e_comp_wl_client_evas_deinit(E_Client *ec)
2424 if (!ec || !ec->comp_data) return;
2425 if (!ec->comp_data->evas_init) return;
2427 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2428 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2429 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2431 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2432 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2433 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2434 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2438 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2447 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2448 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2449 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2450 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2451 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2452 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2453 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2456 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2457 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2459 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2460 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2462 ec->comp_data->evas_init = EINA_FALSE;
2466 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2470 E_Comp_Screen *e_comp_screen;
2471 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2473 if (!e_comp) return ECORE_CALLBACK_RENEW;
2474 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2475 e_comp_screen = e_comp->e_comp_screen;
2477 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2479 if (!eout->config.enabled)
2481 e_comp_wl_output_remove(eout->id);
2485 switch (eout->config.rotation)
2488 transform = WL_OUTPUT_TRANSFORM_90;
2491 transform = WL_OUTPUT_TRANSFORM_180;
2494 transform = WL_OUTPUT_TRANSFORM_270;
2498 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2502 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2504 eout->config.geom.x, eout->config.geom.y,
2505 eout->config.geom.w, eout->config.geom.h,
2506 eout->info.size.w, eout->info.size.h,
2507 eout->config.mode.refresh, 0, transform))
2508 ERR("Could not initialize screen %s", eout->info.name);
2511 return ECORE_CALLBACK_RENEW;
2515 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2519 /* try to get the client from the object */
2520 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2521 return ECORE_CALLBACK_RENEW;
2523 /* check for client being deleted */
2524 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2526 /* check for wayland pixmap */
2527 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2528 return ECORE_CALLBACK_RENEW;
2530 /* if we have not setup evas callbacks for this client, do it */
2531 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2533 return ECORE_CALLBACK_RENEW;
2537 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2541 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2542 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2544 if (e_comp_wl->selection.target &&
2547 struct wl_resource *res;
2549 E_Client *ec = NULL;
2550 E_Client *legacy_target = e_comp_wl->selection.target;
2551 int device_id = e_comp_wl_data_current_device_id_get();
2555 e_comp_wl_data_current_device_id_set(ev->multi.device);
2557 else if (device_id != ev->multi.device)
2559 return ECORE_CALLBACK_RENEW;
2562 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2563 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2565 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2566 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2568 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2569 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2571 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2572 (ec != legacy_target))
2574 e_comp_wl_data_device_send_leave(legacy_target);
2575 e_comp_wl_data_device_send_enter(ec);
2578 if (e_comp_wl->drag)
2579 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2581 if (e_client_transform_core_enable_get(ec))
2583 int trans_x, trans_y;
2584 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2585 x = trans_x - ec->client.x;
2586 y = trans_y - ec->client.y;
2590 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2595 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2598 return ECORE_CALLBACK_RENEW;
2602 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2605 struct wl_resource *surface;
2606 struct wl_resource *res;
2607 struct wl_client *wc;
2609 E_Comp_Config *comp_conf;
2611 ec = e_comp_wl->ptr_constraints.ec;
2612 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2614 surface = e_comp_wl_client_surface_get(ec);
2615 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2617 wc = wl_resource_get_client(surface);
2619 comp_conf = e_comp_config_get();
2621 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2623 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2624 if (wl_resource_get_client(res) != wc) continue;
2626 if (comp_conf && comp_conf->input_log_enable)
2627 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2628 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2629 e_client_util_name_get(ec));
2631 zwp_relative_pointer_v1_send_relative_motion(res,
2633 (uint32_t)(ev->timestamp),
2634 wl_fixed_from_int(ev->dx),
2635 wl_fixed_from_int(ev->dy),
2636 wl_fixed_from_int(ev->dx_unaccel),
2637 wl_fixed_from_int(ev->dy_unaccel));
2640 return ECORE_CALLBACK_DONE;
2644 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2646 _e_comp_wl_touch_cancel();
2648 return ECORE_CALLBACK_PASS_ON;
2652 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2654 if (!ev) return ECORE_CALLBACK_PASS_ON;
2656 E_Zone *zone = ev->zone;
2658 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2659 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2661 if (!e_zone_is_displaying(zone))
2662 _e_comp_wl_touch_cancel();
2664 return ECORE_CALLBACK_PASS_ON;
2668 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2670 E_Client *ec = ev->ec;
2671 E_Comp_Wl_Buffer_Viewport *vp;
2673 if (!ec) return ECORE_CALLBACK_PASS_ON;
2674 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2675 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2676 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2677 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2679 vp = &ec->comp_data->scaler.buffer_viewport;
2680 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2682 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2684 return ECORE_CALLBACK_PASS_ON;
2688 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2690 E_Client *ec = ev->ec;
2691 E_Comp_Wl_Buffer_Viewport *vp;
2693 if (!ec) return ECORE_CALLBACK_PASS_ON;
2694 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2695 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2696 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2698 vp = &ec->comp_data->scaler.buffer_viewport;
2699 vp->wait_for_transform_change = 0;
2701 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2703 return ECORE_CALLBACK_PASS_ON;
2707 _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)
2709 E_Client *focused_ec;
2712 focused_ec = e_client_focused_get();
2713 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2715 rotation = focused_ec->e.state.rot.ang.curr;
2716 e_pointer_rotation_set(e_comp->pointer, rotation);
2718 return ECORE_CALLBACK_PASS_ON;
2722 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2725 Eina_Rectangle *window;
2730 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2732 if ((prev_w != state->bw) ||
2733 (prev_h != state->bh))
2735 ec->changes.buf_size = EINA_TRUE;
2738 if (e_comp_object_frame_exists(ec->frame)) return;
2739 window = &ec->comp_data->shell.window;
2740 if ((!ec->borderless) && /* FIXME temporarily added this check code
2741 * to prevent updating E_Client's size by frame */
2742 (window->x || window->y || window->w || window->h))
2744 e_comp_object_frame_geometry_set(ec->frame,
2746 (window->x + window->w) - state->bw,
2748 (window->y + window->h) - state->bh);
2751 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2755 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2757 E_Comp_Wl_Surface_State *state;
2760 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2761 state->buffer = NULL;
2765 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2767 state->new_attach = EINA_FALSE;
2768 state->buffer = NULL;
2769 state->buffer_destroy_listener.notify =
2770 _e_comp_wl_surface_state_cb_buffer_destroy;
2771 state->sx = state->sy = 0;
2773 state->input = eina_tiler_new(w, h);
2774 eina_tiler_tile_size_set(state->input, 1, 1);
2776 state->opaque = eina_tiler_new(w, h);
2777 eina_tiler_tile_size_set(state->opaque, 1, 1);
2779 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2780 state->buffer_viewport.buffer.scale = 1;
2781 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2782 state->buffer_viewport.surface.width = -1;
2783 state->buffer_viewport.changed = 0;
2785 e_presentation_time_container_init(&state->presentation_container);
2789 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2791 struct wl_resource *cb;
2792 Eina_Rectangle *dmg;
2794 EINA_LIST_FREE(state->frames, cb)
2795 wl_resource_destroy(cb);
2797 EINA_LIST_FREE(state->damages, dmg)
2798 eina_rectangle_free(dmg);
2800 EINA_LIST_FREE(state->buffer_damages, dmg)
2801 eina_rectangle_free(dmg);
2803 if (state->opaque) eina_tiler_free(state->opaque);
2804 state->opaque = NULL;
2806 if (state->input) eina_tiler_free(state->input);
2807 state->input = NULL;
2809 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2810 state->buffer = NULL;
2812 e_presentation_time_container_finish(&state->presentation_container);
2816 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2818 if (state->buffer == buffer) return;
2820 wl_list_remove(&state->buffer_destroy_listener.link);
2821 state->buffer = buffer;
2823 wl_signal_add(&state->buffer->destroy_signal,
2824 &state->buffer_destroy_listener);
2828 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2830 Eina_Rectangle *dmg;
2831 Eina_Bool placed = EINA_TRUE;
2835 E_Comp_Wl_Buffer *buffer;
2836 struct wl_resource *cb;
2838 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2839 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2844 if ((ec->internal) ||
2845 (cdata->shell.surface && state->new_attach))
2849 e_comp->new_clients++;
2850 ELOGF("COMP", "Unignore", ec);
2851 e_client_unignore(ec);
2855 /* buffer transform */
2856 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2859 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2861 /* when buffer is transformed, we have to apply the new evas-map */
2862 state->buffer_viewport.changed = EINA_TRUE;
2864 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2866 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2868 if (transform_change == vp->wait_for_transform_change)
2869 vp->wait_for_transform_change = 0;
2871 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2872 // triggered by E_CLIENT_HOOK calls at those file.
2873 zone = e_comp_zone_find_by_ec(ec);
2876 eout = e_output_find(zone->output_id);
2877 if (eout && eout->hwc)
2879 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2881 if (e_comp_is_on_overlay(ec))
2882 e_comp_hwc_client_end(ec, __FUNCTION__);
2888 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2889 cdata->scaler.buffer_viewport = state->buffer_viewport;
2891 if (state->new_attach)
2893 e_comp_wl_surface_attach(ec, state->buffer);
2896 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2897 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2899 _e_comp_wl_surface_state_buffer_set(state, NULL);
2901 if ((state->new_attach) ||
2902 (state->buffer_viewport.changed))
2904 _e_comp_wl_surface_state_size_update(ec, state);
2905 e_comp_wl_map_size_cal_from_viewport(ec);
2907 /* update the position */
2908 if (ec->changes.pos)
2910 e_comp_object_frame_xy_unadjust(ec->frame,
2920 if (ec->new_client) placed = ec->placed;
2922 if (!ec->lock_client_size)
2927 ec->client.w = state->bw;
2928 ec->client.h = state->bh;
2930 e_comp_object_frame_wh_adjust(ec->frame,
2931 ec->client.w, ec->client.h,
2933 e_client_size_set(ec, nw, nh);
2935 if ((w != ec->w) || (h != ec->h))
2937 ec->changes.size = 1;
2942 if (ec->changes.buf_size)
2944 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2945 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2946 ec->changes.buf_size = EINA_FALSE;
2948 if (ec->move_after_resize)
2950 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2951 ec->move_after_resize = EINA_FALSE;
2956 /* map or unmap ec */
2957 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2958 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2959 if (!pixmap_usable || hide_by_request)
2964 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2969 if ((cdata->sub.below_obj) &&
2970 (evas_object_visible_get(cdata->sub.below_obj)))
2972 evas_object_hide(cdata->sub.below_obj);
2980 if ((cdata->sub.below_obj) &&
2981 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2982 (evas_object_visible_get(ec->frame)))
2984 evas_object_show(cdata->sub.below_obj);
2988 if ((state->new_attach) ||
2989 (state->buffer_viewport.changed))
2991 if ((e_comp_wl->drag) &&
2992 (e_comp_wl->drag_client) &&
2993 (e_comp_wl->drag_client == ec))
2995 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2997 e_drag_move(e_comp_wl->drag,
2999 e_comp_wl->drag->y);
3001 e_drag_resize(e_comp_wl->drag,
3002 state->bw, state->bh);
3004 else if ((cdata->shell.surface) &&
3005 (cdata->shell.configure))
3007 e_comp_wl_commit_sync_configure(ec);
3009 else if (!e_client_video_hw_composition_check(ec))
3011 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3016 ec->placed = placed;
3017 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3021 if (cdata->scaler.buffer_viewport.changed)
3022 e_comp_wl_map_apply(ec);
3024 /* resize transform object */
3025 if (ec->transformed)
3026 e_client_transform_update(ec);
3030 state->new_attach = EINA_FALSE;
3032 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3034 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3035 wl_resource_destroy(cb);
3038 /* insert state frame callbacks into comp_data->frames
3039 * NB: This clears state->frames list */
3040 cdata->frames = eina_list_merge(cdata->frames,
3042 state->frames = NULL;
3044 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3045 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3046 &state->presentation_container);
3048 buffer = e_pixmap_resource_get(ec->pixmap);
3050 /* put state damages into surface */
3053 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3054 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3056 if ((cdata->buffer_ref.buffer) &&
3057 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3058 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3060 e_comp_object_damage(ec->frame,
3062 cdata->buffer_ref.buffer->w,
3063 cdata->buffer_ref.buffer->h);
3068 Eina_List *damages = NULL;
3071 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3073 if (eina_list_count(state->buffer_damages))
3075 EINA_LIST_FREE(state->buffer_damages, dmg)
3078 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3079 e_comp_wl_output_buffer_transform_get(ec),
3081 dmg->x, dmg->y, dmg->w, dmg->h,
3082 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3083 damages = eina_list_append(damages, dmg);
3087 EINA_LIST_FREE(state->damages, dmg)
3088 damages = eina_list_append(damages, dmg);
3090 EINA_LIST_FREE(damages, dmg)
3092 /* not creating damage for ec that shows a underlay video */
3093 if (state->buffer_viewport.changed ||
3094 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3095 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3096 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3098 eina_rectangle_free(dmg);
3103 /* put state opaque into surface */
3104 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3107 Eina_Rectangle *rect;
3110 itr = eina_tiler_iterator_new(state->opaque);
3111 EINA_ITERATOR_FOREACH(itr, rect)
3115 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3116 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3117 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3121 eina_iterator_free(itr);
3124 /* put state input into surface */
3125 if ((state->input) &&
3126 (!eina_tiler_empty(state->input)) &&
3129 Eina_Tiler *src, *tmp;
3133 tmp = eina_tiler_new(sw, sh);
3134 eina_tiler_tile_size_set(tmp, 1, 1);
3136 eina_tiler_rect_add(tmp,
3137 &(Eina_Rectangle){0, 0, sw, sh});
3139 if ((src = eina_tiler_intersection(state->input, tmp)))
3141 Eina_Rectangle *rect;
3144 e_comp_object_input_objs_del(ec->frame);
3145 itr = eina_tiler_iterator_new(src);
3146 EINA_ITERATOR_FOREACH(itr, rect)
3148 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3149 ec, rect->x, rect->y, rect->w, rect->h,
3150 ec->w, ec->h, state->bw, state->bh);
3151 e_comp_object_input_area_set(ec->frame,
3156 eina_iterator_free(itr);
3157 eina_tiler_free(src);
3160 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3162 eina_tiler_free(tmp);
3164 /* clear input tiler */
3165 eina_tiler_clear(state->input);
3168 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3170 if ((cdata->video_client) &&
3172 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3173 (e_comp->wl_comp_data->available_hw_accel.underlay))
3175 e_pixmap_image_clear(ec->pixmap, 1);
3178 state->buffer_viewport.changed = 0;
3180 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3183 ec->exp_iconify.buffer_flush &&
3184 e_policy_visibility_client_is_iconic(ec))
3186 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3191 _e_comp_wl_surface_render_stop(E_Client *ec)
3193 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3194 //if ((!ec->internal) && (!e_comp_gl_get()))
3197 /* check if internal animation is running */
3198 if (e_comp_object_is_animating(ec->frame)) return;
3199 /* check if external animation is running */
3200 if (evas_object_data_get(ec->frame, "effect_running")) return;
3202 evas_object_hide(ec->frame);
3206 e_comp_wl_client_surface_finish(E_Client *ec)
3208 struct wl_resource *res, *surface;
3209 struct wl_client *surface_client = NULL;
3212 surface = e_comp_wl_client_surface_get(ec);
3215 surface_client = wl_resource_get_client(surface);
3217 if (surface_client &&
3218 (ec == e_client_focused_get()))
3220 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3221 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3223 if (wl_resource_get_client(res) ==
3225 e_comp_wl->kbd.focused =
3226 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3230 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3233 e_comp_wl_client_surface_set(ec, NULL);
3235 ec->comp_data->wl_surface = NULL;
3236 e_pixmap_win_id_del(ec->pixmap);
3238 _e_comp_wl_surface_render_stop(ec);
3239 e_object_del(E_OBJECT(ec));
3243 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3248 char proc[512], pname[512];
3251 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3253 h = fopen(proc, "r");
3256 len = fread(pname, sizeof(char), 512, h);
3258 pname[len - 1] = '\0';
3260 strncpy(pname, "NO NAME", sizeof(pname));
3266 strncpy(pname, "NO NAME", sizeof(pname));
3269 strncpy(name, pname, size);
3273 _e_comp_wl_pname_print(pid_t pid)
3276 char proc[512], pname[512];
3279 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3281 h = fopen(proc, "r");
3284 len = fread(pname, sizeof(char), 512, h);
3286 pname[len - 1] = '\0';
3288 strncpy(pname, "NO NAME", sizeof(pname));
3292 ELOGF("COMP", " |%s", NULL, pname);
3297 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3299 struct wl_client *client = data;
3300 E_Comp_Connected_Client_Info *cinfo;
3303 cinfo = wl_container_of(listener, cinfo, destroy);
3305 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3306 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3308 eai = e_appinfo_find_with_pid(cinfo->pid);
3309 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3312 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3314 wl_list_remove(&cinfo->destroy.link);
3315 eina_stringshare_del(cinfo->name);
3320 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3322 E_Comp_Connected_Client_Info *cinfo;
3324 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3325 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3327 cinfo->name = eina_stringshare_add(name);
3331 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3332 wl_client_add_destroy_listener(client, &cinfo->destroy);
3333 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3335 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3339 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3341 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3343 /* send configure */
3344 if (ec->comp_data->shell.configure_send)
3346 if (ec->comp_data->shell.surface)
3347 _e_comp_wl_configure_send(ec, 0, 0);
3350 e_comp_wl->kbd.focus = ec->comp_data->surface;
3354 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3356 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3358 /* send configure */
3359 if (ec->comp_data->shell.configure_send)
3361 if (ec->comp_data->shell.surface)
3362 _e_comp_wl_configure_send(ec, 0, 0);
3365 _e_comp_wl_focus_check();
3367 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3368 e_comp_wl->kbd.focus = NULL;
3372 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3374 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3375 if (ec->keyboard_resizing) return;
3377 /* do nothing currently */
3382 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3384 if (e_object_is_del(E_OBJECT(ec))) return;
3385 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3387 e_comp_wl->resize.edges = 0;
3388 e_comp_wl->resize.resource = NULL;
3392 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3394 if (e_object_is_del(E_OBJECT(ec))) return;
3395 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3399 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3402 int ratio_w, ratio_h;
3404 phys_w = output->phys_width;
3405 phys_h = output->phys_height;
3407 if (e_config->configured_output_resolution.use)
3409 // change the configured physical size(mm) of the output
3410 if (output->w != res_w)
3412 ratio_w = res_w / output->w;
3413 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3416 if (output->h != res_h)
3418 ratio_h = res_h / output->h;
3419 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3422 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3425 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3426 NULL, res_w, res_h, phys_w, phys_h, pid);
3428 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3429 wl_output_send_scale(resource, output->scale);
3431 wl_output_send_geometry(resource, output->x, output->y,
3433 output->subpixel, output->make ?: "",
3434 output->model ?: "", output->transform);
3436 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3437 res_w, res_h, output->refresh);
3439 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3440 wl_output_send_done(resource);
3444 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3446 E_Comp_Wl_Output *output;
3448 if (!(output = wl_resource_get_user_data(resource))) return;
3450 output->resources = eina_list_remove(output->resources, resource);
3454 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3456 E_Comp_Wl_Output *output;
3457 struct wl_resource *resource;
3458 E_Appinfo *eai = NULL;
3462 if (!(output = data)) return;
3465 wl_resource_create(client, &wl_output_interface, version, id);
3468 wl_client_post_no_memory(client);
3472 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3473 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3475 output->resources = eina_list_append(output->resources, resource);
3477 wl_resource_set_implementation(resource, NULL, output,
3478 _e_comp_wl_cb_output_unbind);
3479 wl_resource_set_user_data(resource, output);
3481 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3482 if (e_config->configured_output_resolution.use)
3484 wl_client_get_credentials(client, &pid, NULL, NULL);
3487 res_w = e_config->configured_output_resolution.w;
3488 res_h = e_config->configured_output_resolution.h;
3492 eai = e_appinfo_find_with_pid(pid);
3495 res_w = e_config->configured_output_resolution.w;
3496 res_h = e_config->configured_output_resolution.h;
3500 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3502 res_w = e_config->configured_output_resolution.w;
3503 res_h = e_config->configured_output_resolution.h;
3507 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3516 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3520 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3523 Evas_GL *evasgl = NULL;
3524 Evas_GL_API *glapi = NULL;
3525 Evas_GL_Context *ctx = NULL;
3526 Evas_GL_Surface *sfc = NULL;
3527 Evas_GL_Config *cfg = NULL;
3529 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3531 if (!e_comp_gl_get()) return;
3533 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3534 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3536 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3537 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3539 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3540 * then we should get evas from ecore_evas.
3543 evas = e_comp->evas;
3545 evas = ecore_evas_get(e_comp->ee);
3547 evasgl = evas_gl_new(evas);
3548 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3550 glapi = evas_gl_api_get(evasgl);
3551 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3552 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3554 cfg = evas_gl_config_new();
3555 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3557 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3558 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3560 ctx = evas_gl_context_create(evasgl, NULL);
3561 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3563 res = evas_gl_make_current(evasgl, sfc, ctx);
3564 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3566 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3567 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3569 evas_gl_config_free(cfg);
3571 evas_gl->gl = evasgl;
3572 evas_gl->glapi = glapi;
3573 evas_gl->glsfc = sfc;
3574 evas_gl->glctx = ctx;
3576 e_comp_wl->evas_gl = evas_gl;
3578 /* for native surface */
3581 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3586 evas_gl_config_free(cfg);
3587 evas_gl_make_current(evasgl, NULL, NULL);
3588 evas_gl_context_destroy(evasgl, ctx);
3589 evas_gl_surface_destroy(evasgl, sfc);
3590 evas_gl_free(evasgl);
3597 _e_comp_wl_gl_popup_cb_close(void *data,
3598 Evas_Object *obj EINA_UNUSED,
3599 void *event_info EINA_UNUSED)
3601 evas_object_del(data);
3605 _e_comp_wl_gl_popup_cb_focus(void *data,
3606 Evas_Object *obj EINA_UNUSED,
3607 void *event_info EINA_UNUSED)
3609 elm_object_focus_set(data, EINA_TRUE);
3614 _e_comp_wl_gl_idle(void *data)
3618 /* show warning window to notify failure of gl init */
3621 Evas_Object *win, *bg, *popup, *btn;
3623 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3624 elm_win_title_set(win, "Compositor Warning");
3625 elm_win_autodel_set(win, EINA_TRUE);
3626 elm_win_borderless_set(win, EINA_TRUE);
3627 elm_win_role_set(win, "notification-low");
3628 elm_win_alpha_set(win, EINA_TRUE);
3630 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3631 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3632 elm_win_resize_object_add(win, bg);
3633 evas_object_color_set(bg, 125, 125, 125, 125);
3634 evas_object_show(bg);
3636 popup = elm_popup_add(win);
3637 elm_object_text_set(popup,
3638 _( "Your screen does not support OpenGL.<br>"
3639 "Falling back to software engine."));
3640 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3642 btn = elm_button_add(popup);
3643 elm_object_text_set(btn, "Close");
3644 elm_object_part_content_set(popup, "button1", btn);
3645 evas_object_show(btn);
3647 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3648 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3650 evas_object_show(popup);
3651 evas_object_show(win);
3655 return ECORE_CALLBACK_CANCEL;
3659 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3661 struct wl_client *client = data;
3667 wl_client_get_credentials(client, &pid, &uid, &gid);
3669 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3671 _e_comp_wl_pname_print(pid);
3672 _e_comp_wl_pname_get(pid, name, sizeof(name));
3673 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3677 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3679 char buf[1024] = {0, };
3681 vsnprintf(buf, 1024, fmt, args);
3685 DBG("[libds] %s", buf);
3688 INF("[libds] %s", buf);
3691 ERR("[libds] %s", buf);
3699 _e_comp_wl_display_create(void)
3702 E_Comp_Wl_Data *wl_cdata;
3707 /* create new compositor data */
3708 if (!(comp = E_NEW(E_Comp_Data, 1)))
3710 ERR("Could not create compositor data: %m");
3713 wl_cdata = &comp->base;
3715 /* set compositor wayland data */
3716 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3718 g_mutex_init(&connection_mutex);
3720 /* try to create a wayland display */
3721 if (!(wl_cdata->wl.disp = wl_display_create()))
3723 ERR("Could not create a Wayland display: %m");
3727 /* try to setup wayland socket */
3728 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3730 ERR("Could not create Wayland display socket: %m");
3731 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3735 res = e_comp_socket_init(name);
3736 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3737 PRCTL("[Winsys] change permission and create sym link for %s", name);
3739 /* set wayland display environment variable */
3740 e_env_set("WAYLAND_DISPLAY", name);
3742 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3743 /* wl_cdata->output.scale = e_scale; */
3745 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3747 if (!e_compositor_init(wl_cdata->wl.disp))
3749 ERR("Failed to initialize compositor");
3753 comp->client_created.notify = _e_comp_wl_cb_client_created;
3754 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3756 if (!e_comp_wl_subsurfaces_init())
3758 ERR("Failed to init_subsurfaces");
3759 goto subsurfaces_err;
3762 /* initialize shm mechanism */
3763 wl_display_init_shm(wl_cdata->wl.disp);
3765 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3767 /* try to init data manager */
3768 if (!e_comp_wl_data_manager_init())
3770 ERR("Could not initialize data manager");
3774 /* try to init input */
3775 if (!e_comp_wl_input_init())
3777 ERR("Could not initialize input");
3781 if (e_comp_gl_get())
3782 _e_comp_wl_gl_init(NULL);
3784 /* get the wayland display loop */
3785 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3787 /* get the file descriptor of the wayland event loop */
3788 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3790 /* create a listener for wayland main loop events */
3792 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3793 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3794 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3795 _e_comp_wl_cb_prepare, wl_cdata);
3800 e_comp_wl_data_manager_shutdown();
3802 e_comp_wl_subsurfaces_shutdown();
3804 wl_list_remove(&comp->client_created.link);
3806 e_env_unset("WAYLAND_DISPLAY");
3808 wl_display_destroy(wl_cdata->wl.disp);
3810 g_mutex_clear(&connection_mutex);
3816 _e_comp_wl_gl_shutdown(void)
3818 if (!e_comp_wl->evas_gl) return;
3820 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3822 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3823 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3824 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3825 evas_gl_free(e_comp_wl->evas_gl->gl);
3827 E_FREE(e_comp_wl->evas_gl);
3830 /* public functions */
3833 * Creates and initializes a Wayland compositor with ecore.
3834 * Registers callback handlers for keyboard and mouse activity
3835 * and other client events.
3837 * @returns true on success, false if initialization failed.
3840 e_comp_wl_init(void)
3842 TRACE_DS_BEGIN(COMP_WL:INIT);
3844 /* try to create a wayland compositor */
3845 if (!_e_comp_wl_display_create())
3847 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3852 e_comp_wl_shell_init();
3854 #ifdef HAVE_WAYLAND_TBM
3855 e_comp_wl_tbm_init();
3857 e_comp_wl_remote_surface_init();
3861 e_comp_wl_screenshooter_init();
3863 if (!e_comp_wl_video_init())
3864 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3866 e_comp_wl_viewport_init();
3867 e_comp_wl_capture_init();
3868 e_comp_wl_renderer_init();
3869 _e_comp_wl_move_resize_init();
3870 e_presentation_time_init();
3871 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3874 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3875 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3877 /* add event handlers to catch E events */
3878 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3879 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3880 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3881 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3882 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3883 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3884 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3885 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3886 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3888 /* add hooks to catch e_client events */
3889 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3890 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3891 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3892 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3893 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3895 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3902 e_comp_wl_deferred_job(void)
3904 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3907 /* internal functions */
3909 e_comp_wl_shutdown(void)
3911 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3913 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3915 e_comp_wl_subsurfaces_shutdown();
3917 E_FREE_LIST(handlers, ecore_event_handler_del);
3918 E_FREE_LIST(hooks, e_client_hook_del);
3919 _e_comp_wl_gl_shutdown();
3921 e_blender_shutdown();
3922 e_presentation_time_shutdown();
3923 e_comp_wl_renderer_shutdown();
3924 e_comp_wl_capture_shutdown();
3925 e_comp_wl_viewport_shutdown();
3926 e_comp_wl_video_shutdown();
3927 e_comp_wl_screenshooter_shutdown();
3929 e_comp_wl_remote_surface_shutdown();
3931 e_pixmap_shutdown();
3933 e_wtz_shell_shutdown();
3934 e_comp_wl_shell_shutdown();
3935 e_comp_wl_input_shutdown();
3937 wl_list_remove(&comp->client_created.link);
3940 e_comp->wl_comp_data = NULL;
3944 E_Comp_Wl_Output *output;
3946 if (e_comp_wl->screenshooter.global)
3947 wl_global_destroy(e_comp_wl->screenshooter.global);
3949 EINA_LIST_FREE(e_comp_wl->outputs, output)
3951 if (output->id) eina_stringshare_del(output->id);
3952 if (output->make) eina_stringshare_del(output->make);
3953 if (output->model) eina_stringshare_del(output->model);
3957 /* delete fd handler */
3958 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3960 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3961 cursor_timer_ec = NULL;
3963 /* free allocated data structure */
3969 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3971 e_object_unref(E_OBJECT(ev->ec));
3976 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3979 ev = E_NEW(E_Event_Client, 1);
3982 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3984 /* set usable early because shell module checks this */
3985 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3986 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3988 e_pixmap_resource_set(ec->pixmap, buffer);
3989 e_pixmap_dirty(ec->pixmap);
3990 e_pixmap_refresh(ec->pixmap);
3992 e_comp_wl_map_size_cal_from_buffer(ec);
3993 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3995 /* wm-policy module uses it */
3996 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
3999 e_object_ref(E_OBJECT(ec));
4000 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4001 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4005 e_comp_wl_surface_commit(E_Client *ec)
4010 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4011 if (!e_comp_object_damage_exists(ec->frame))
4013 if ((ec->comp_data->video_client) ||
4014 (!e_client_video_hw_composition_check(ec)))
4015 e_pixmap_image_clear(ec->pixmap, 1);
4018 ignored = ec->ignored;
4020 if (e_comp_wl_subsurface_order_commit(ec))
4022 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4023 e_comp_wl_subsurface_restack(topmost);
4024 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4027 ec->ignored = ignored;
4029 if (ec->is_cursor && ec->visible)
4031 /* ignore cursor changes during resize/move I guess */
4032 if (!e_client_action_get())
4034 if (e_comp->pointer)
4036 x = e_comp->pointer->hot.x;
4037 y = e_comp->pointer->hot.y;
4039 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4045 static E_Comp_Wl_Output *
4046 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4049 E_Comp_Wl_Output *output;
4051 EINA_LIST_FOREACH(outputs, l, output)
4053 if (!strcmp(output->id, id))
4061 * Initializes information about one display output.
4063 * Adds or updates the given data about a single display output,
4064 * with an id matching the provided id.
4066 * @param id identification of output to be added or changed
4067 * @param make manufacturer name of the display output
4068 * @param model model name of the display output
4069 * @param x output's top left corner x coordinate
4070 * @param y output's top left corner y coordinate
4071 * @param w output's width in pixels
4072 * @param h output's height in pixels
4073 * @param pw output's physical width in millimeters
4074 * @param ph output's physical height in millimeters
4075 * @param refresh output's refresh rate in mHz
4076 * @param subpixel output's subpixel layout
4077 * @param transform output's rotation and/or mirror transformation
4079 * @returns True if a display output object could be added or updated
4082 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4083 int x, int y, int w, int h, int pw, int ph,
4084 unsigned int refresh, unsigned int subpixel,
4085 unsigned int transform)
4087 E_Comp_Wl_Output *output;
4089 struct wl_resource *resource;
4091 /* retrieve named output; or create it if it doesn't exist */
4092 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4095 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4097 if (id) output->id = eina_stringshare_add(id);
4099 output->make = eina_stringshare_add(make);
4101 output->make = eina_stringshare_add("unknown");
4103 output->model = eina_stringshare_add(model);
4105 output->model = eina_stringshare_add("unknown");
4107 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4110 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4111 2, output, _e_comp_wl_cb_output_bind);
4113 output->resources = NULL;
4114 output->scale = e_scale;
4117 /* update the output details */
4122 output->phys_width = pw;
4123 output->phys_height = ph;
4124 output->refresh = refresh;
4125 output->subpixel = subpixel;
4126 output->transform = transform;
4128 if (output->scale <= 0)
4129 output->scale = e_scale;
4131 /* if we have bound resources, send updates */
4132 EINA_LIST_FOREACH(output->resources, l2, resource)
4134 wl_output_send_geometry(resource,
4135 output->x, output->y,
4137 output->phys_height,
4139 output->make ?: "", output->model ?: "",
4142 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4143 wl_output_send_scale(resource, output->scale);
4145 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4146 output->w, output->h, output->refresh);
4148 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4149 wl_output_send_done(resource);
4156 e_comp_wl_output_remove(const char *id)
4158 E_Comp_Wl_Output *output;
4160 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4163 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4165 /* wl_global_destroy(output->global); */
4167 /* eina_stringshare_del(output->id); */
4168 /* eina_stringshare_del(output->make); */
4169 /* eina_stringshare_del(output->model); */
4176 _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)
4178 struct wl_resource *res;
4180 uint32_t serial, keycode;
4181 struct wl_client *wc = NULL;
4182 E_Comp_Config *comp_conf = NULL;
4183 const char *device_name = NULL;
4185 keycode = (ev->keycode - 8);
4187 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4189 comp_conf = e_comp_config_get();
4191 if (ec && ec->comp_data)
4193 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4196 wc = wl_resource_get_client(surface);
4199 if (e_config->key_input_ttrace_enable)
4201 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4202 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4205 EINA_LIST_FOREACH(key_list, l, res)
4207 if (wl_resource_get_client(res) != wc) continue;
4209 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4210 if (!e_input_thread_mode_get())
4212 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4213 device_name = ecore_device_name_get(ev->dev);
4219 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4220 device_name = e_device_name_get(dev);
4224 if (comp_conf && comp_conf->input_log_enable)
4225 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4227 wl_keyboard_send_key(res, serial, ev->timestamp,
4232 if (e_config->key_input_ttrace_enable)
4235 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4240 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4242 E_Client *ec = NULL;
4244 E_Comp_Wl_Key_Data *end, *k;
4246 if (ev->window != e_comp->ee_win)
4251 keycode = (ev->keycode - 8);
4252 if (!(e_comp_wl = e_comp->wl_comp_data))
4257 #ifndef E_RELEASE_BUILD
4258 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4259 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4260 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4261 eina_streq(ev->key, "BackSpace"))
4267 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4269 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4271 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4273 /* ignore server-generated key repeats */
4274 if (k->key == keycode)
4276 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4281 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4283 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4285 ec = e_client_focused_get();
4286 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4287 if (ec && ec->comp_data && surface)
4289 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4290 if (e_comp_wl->kbd.focused)
4292 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4294 /* A key only sent to clients is added to the list */
4295 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4296 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4298 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4300 DBG("wl_array_add: Out of memory\n");
4301 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4302 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4305 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4309 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4313 /* update modifier state */
4314 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4320 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4322 E_Client *ec = NULL;
4323 uint32_t keycode, delivered_key;
4324 E_Comp_Wl_Key_Data *end, *k;
4326 if (ev->window != e_comp->ee_win)
4331 keycode = (ev->keycode - 8);
4333 if (!(e_comp_wl = e_comp->wl_comp_data))
4338 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4340 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4341 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4343 if (k->key == keycode)
4350 e_comp_wl->kbd.keys.size =
4351 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4353 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4355 /* 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) */
4356 if ((delivered_key) ||
4357 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4359 ec = e_client_focused_get();
4361 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4362 if (e_comp_wl->kbd.focused)
4364 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4366 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4369 /* update modifier state */
4370 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4376 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4378 Eina_Bool res = EINA_FALSE;
4380 if (type == ECORE_EVENT_KEY_DOWN)
4382 res = e_comp_wl_key_down(ev, dev);
4384 else if (type == ECORE_EVENT_KEY_UP)
4386 res = e_comp_wl_key_up(ev, dev);
4393 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4396 struct wl_client *wc;
4397 uint32_t serial, btn;
4398 struct wl_resource *res;
4399 E_Comp_Config *comp_conf = NULL;
4401 if (ec->cur_mouse_action || e_comp_wl->drag)
4403 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4404 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4408 case 1: btn = BTN_LEFT; break;
4409 case 2: btn = BTN_MIDDLE; break;
4410 case 3: btn = BTN_RIGHT; break;
4411 default: btn = button_id; break;
4414 e_comp_wl->ptr.button = btn;
4415 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4416 if (!surface) return EINA_FALSE;
4418 if (!eina_list_count(e_comp_wl->ptr.resources))
4421 wc = wl_resource_get_client(surface);
4422 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4424 comp_conf = e_comp_config_get();
4426 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4428 if (wl_resource_get_client(res) != wc) continue;
4429 if (!e_comp_wl_input_pointer_check(res)) continue;
4430 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4432 if (comp_conf && comp_conf->input_log_enable)
4433 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4435 wl_pointer_send_button(res, serial, timestamp, btn, state);
4442 e_comp_wl_touch_cancel(void)
4444 _e_comp_wl_touch_cancel();
4447 E_API E_Comp_Wl_Hook *
4448 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4452 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4453 ch = E_NEW(E_Comp_Wl_Hook, 1);
4454 if (!ch) return NULL;
4455 ch->hookpoint = hookpoint;
4457 ch->data = (void*)data;
4458 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4463 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4466 if (_e_comp_wl_hooks_walking == 0)
4468 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4472 _e_comp_wl_hooks_delete++;
4475 E_API E_Comp_Wl_Pid_Hook *
4476 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4478 E_Comp_Wl_Pid_Hook *ch;
4480 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4482 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4483 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4485 ch->hookpoint = hookpoint;
4487 ch->data = (void*)data;
4488 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4494 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4497 if (_e_comp_wl_pid_hooks_walking == 0)
4499 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4503 _e_comp_wl_pid_hooks_delete++;
4506 E_API E_Comp_Wl_Intercept_Hook *
4507 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4509 E_Comp_Wl_Intercept_Hook *ch;
4511 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4512 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4513 if (!ch) return NULL;
4514 ch->hookpoint = hookpoint;
4516 ch->data = (void*)data;
4517 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4522 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4525 if (_e_comp_wl_intercept_hooks_walking == 0)
4527 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4531 _e_comp_wl_intercept_hooks_delete++;
4535 e_comp_wl_shell_surface_ready(E_Client *ec)
4539 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4543 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4545 e_config->use_cursor_timer = !!enabled;
4547 if (e_config->use_cursor_timer)
4549 if (!e_pointer_is_hidden(e_comp->pointer))
4551 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4556 if (e_comp_wl->ptr.hide_tmr)
4558 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4559 e_comp_wl->ptr.hide_tmr = NULL;
4561 cursor_timer_ec = NULL;
4563 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4566 if (e_pointer_is_hidden(e_comp->pointer))
4568 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4574 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4576 EINA_SAFETY_ON_NULL_RETURN(wc);
4577 EINA_SAFETY_ON_NULL_RETURN(dev);
4579 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4583 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4585 EINA_SAFETY_ON_NULL_RETURN(wc);
4586 EINA_SAFETY_ON_NULL_RETURN(dev);
4588 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4592 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4594 struct wl_resource *res;
4595 struct wl_client *wc;
4597 uint32_t serial, wl_keycode;
4598 enum wl_keyboard_key_state state;
4599 E_Comp_Config *comp_conf = NULL;
4600 const char *dev_name = NULL;
4602 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4603 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4604 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4606 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4607 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4609 wl_keycode = keycode - 8;
4610 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4612 wc = wl_resource_get_client(surface);
4613 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4614 if (!time) time = e_util_timestamp_get();
4615 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4616 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4618 comp_conf = e_comp_config_get();
4619 e_keyrouter_event_surface_send(ec, keycode);
4621 if (e_config->key_input_ttrace_enable)
4623 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4624 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4627 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4628 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4630 if (wl_resource_get_client(res) != wc) continue;
4631 if (!e_input_thread_mode_get())
4635 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4636 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4640 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4647 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4648 dev_name = e_device_name_get(dev);
4652 if (comp_conf && comp_conf->input_log_enable)
4653 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4656 wl_keyboard_send_key(res, serial, time,
4659 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4661 if (e_config->key_input_ttrace_enable)
4664 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4671 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4673 struct wl_resource *res;
4674 struct wl_client *wc;
4676 uint32_t serial, wl_keycode, cancel_keycode;
4677 E_Comp_Config *comp_conf = NULL;
4678 struct xkb_keymap *keymap = NULL;
4680 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4681 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4682 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4684 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4685 keymap = e_comp_wl->xkb.keymap;
4686 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4687 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4689 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4690 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4692 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4693 if (cancel_keycode == XKB_KEYCODE_INVALID)
4695 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4698 cancel_keycode = cancel_keycode - 8;
4700 wl_keycode = keycode - 8;
4701 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4703 wc = wl_resource_get_client(surface);
4704 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4705 if (!time) time = e_util_timestamp_get();
4707 comp_conf = e_comp_config_get();
4708 e_keyrouter_event_surface_send(ec, keycode);
4710 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4711 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4713 if (wl_resource_get_client(res) != wc) continue;
4714 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4715 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4717 if (comp_conf && comp_conf->input_log_enable)
4718 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4719 wl_keyboard_send_key(res, serial, time,
4720 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4721 wl_keyboard_send_key(res, serial, time,
4722 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4723 wl_keyboard_send_key(res, serial, time,
4724 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4726 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4733 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)
4735 struct wl_client *wc;
4737 E_Devicemgr_Input_Device *device = NULL;
4739 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4740 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4741 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4743 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4744 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4746 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4748 wc = wl_resource_get_client(surface);
4749 if (!time) time = e_util_timestamp_get();
4750 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4754 _e_comp_wl_send_event_device(wc, time, dev, serial);
4755 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4759 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4760 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4763 x = x + ec->client.x;
4764 y = y + ec->client.y;
4766 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4772 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)
4774 E_Devicemgr_Input_Device *device;
4776 struct wl_client *wc;
4778 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4779 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4782 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4783 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4785 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4787 wc = wl_resource_get_client(surface);
4788 if (!time) time = e_util_timestamp_get();
4789 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4793 _e_comp_wl_send_event_device(wc, time, dev, serial);
4794 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4798 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4799 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4802 x = x + ec->client.x;
4803 y = y + ec->client.y;
4805 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4811 e_comp_wl_touch_cancel_send(E_Client *ec)
4813 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4814 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4815 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4817 _e_comp_wl_send_touch_cancel(ec);
4823 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4826 struct wl_client *wc;
4828 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4829 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4832 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4833 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4835 wc = wl_resource_get_client(surface);
4836 if (!time) time = e_util_timestamp_get();
4837 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4839 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4840 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4843 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4844 WL_POINTER_BUTTON_STATE_PRESSED);
4846 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4847 WL_POINTER_BUTTON_STATE_RELEASED);
4853 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4856 struct wl_client *wc;
4858 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4859 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4860 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4862 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4863 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4865 wc = wl_resource_get_client(surface);
4866 if (!time) time = e_util_timestamp_get();
4867 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4869 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4870 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4872 x = x + ec->client.x;
4873 y = y + ec->client.y;
4875 _e_comp_wl_send_mouse_move(ec, x, y, time);
4881 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4884 struct wl_client *wc;
4886 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4887 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4888 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4890 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4891 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4893 wc = wl_resource_get_client(surface);
4894 if (!time) time = e_util_timestamp_get();
4895 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4897 if (_e_comp_wl_check_cursor_timer_needed(ec))
4899 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4903 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4904 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4906 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4908 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4910 if (_e_comp_wl_check_cursor_timer_needed(ec))
4911 _e_comp_wl_cursor_move_timer_control(ec);
4918 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4921 struct wl_client *wc;
4922 struct wl_resource *res;
4925 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4926 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4928 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4929 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4931 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4932 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4934 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4935 wc = wl_resource_get_client(surface);
4936 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4937 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4939 if (!e_comp_wl_input_pointer_check(res)) continue;
4940 if (wl_resource_get_client(res) != wc) continue;
4942 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4943 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4945 wl_pointer_send_enter(res, serial, surface,
4946 wl_fixed_from_int(x),
4947 wl_fixed_from_int(y));
4948 ec->pointer_enter_sent = EINA_TRUE;
4950 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4956 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4959 struct wl_client *wc;
4960 struct wl_resource *res;
4963 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4964 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4965 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4966 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4967 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4968 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4970 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4971 wc = wl_resource_get_client(surface);
4972 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4973 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4975 if (!e_comp_wl_input_pointer_check(res)) continue;
4976 if (wl_resource_get_client(res) != wc) continue;
4978 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4979 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4981 wl_pointer_send_leave(res, serial, surface);
4982 ec->pointer_enter_sent = EINA_FALSE;
4989 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)
4991 Evas_Event_Mouse_In ev_in;
4994 if (ec->pointer_enter_sent) return;
4996 ev_in.buttons = buttons;
5004 ev_in.modifiers = modifiers;
5005 ev_in.locks = locks;
5006 ev_in.timestamp = timestamp;
5007 ev_in.event_flags = event_flags;
5010 ev_in.event_src = event_src;
5012 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5016 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)
5018 Evas_Event_Mouse_Out ev_out;
5021 if (!ec->pointer_enter_sent) return;
5023 ev_out.buttons = buttons;
5025 ev_out.output.x = x;
5026 ev_out.output.y = y;
5027 ev_out.canvas.x = x;
5028 ev_out.canvas.y = y;
5031 ev_out.modifiers = modifiers;
5032 ev_out.locks = locks;
5033 ev_out.timestamp = timestamp;
5034 ev_out.event_flags = event_flags;
5037 ev_out.event_src = event_src;
5039 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5043 e_comp_wl_cursor_hide(E_Client *ec)
5045 struct wl_resource *res;
5046 struct wl_client *wc;
5050 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5052 if (e_comp_wl->ptr.hide_tmr)
5054 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5055 e_comp_wl->ptr.hide_tmr = NULL;
5057 cursor_timer_ec = NULL;
5059 if (!ec) return EINA_FALSE;
5060 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5061 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5062 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5064 wc = wl_resource_get_client(surface);
5065 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5066 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5068 if (!e_comp_wl_input_pointer_check(res)) continue;
5069 if (wl_resource_get_client(res) != wc) continue;
5070 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5071 wl_pointer_send_leave(res, serial, surface);
5072 ec->pointer_enter_sent = EINA_FALSE;
5078 /* surface to buffer
5079 * - width : surface width
5080 * - height : surface height
5081 * - transform: buffer transform
5082 * - scale : buffer scale
5084 * - width : screen width
5085 * - height : screen height
5086 * - transform: output transform
5087 * - scale : output scale
5089 static E_Util_Transform_Matrix
5090 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5092 E_Util_Transform_Matrix m;
5094 e_util_transform_matrix_load_identity(&m);
5096 if (transform & 0x4)
5098 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5099 e_util_transform_matrix_flip_x(&m);
5100 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5103 switch (transform & 0x3)
5105 case WL_OUTPUT_TRANSFORM_90:
5106 e_util_transform_matrix_translate(&m, -width, 0, 0);
5107 e_util_transform_matrix_rotation_z(&m, 270);
5109 case WL_OUTPUT_TRANSFORM_180:
5110 e_util_transform_matrix_translate(&m, -width, -height, 0);
5111 e_util_transform_matrix_rotation_z(&m, 180);
5113 case WL_OUTPUT_TRANSFORM_270:
5114 e_util_transform_matrix_translate(&m, 0, -height, 0);
5115 e_util_transform_matrix_rotation_z(&m, 90);
5121 e_util_transform_matrix_scale(&m, scale, scale, 1);
5126 /* surface to buffer
5127 * - surface width, surface height, buffer transform, buffer scale
5129 * - screen width, screen height, output transform, output scale
5132 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5134 E_Util_Transform_Matrix m;
5135 E_Util_Transform_Vertex v;
5137 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5139 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5140 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5141 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5145 * - buffer width, buffer height, buffer transform, buffer scale
5148 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5150 E_Util_Transform_Matrix m;
5151 E_Util_Transform_Vertex v;
5154 if (transform != 0 || scale > 1)
5156 tw = ((transform % 2) ? height : width) / scale;
5157 th = ((transform % 2) ? width : height) / scale;
5165 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5166 m = e_util_transform_matrix_inverse_get(&m);
5168 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5169 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5170 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5173 /* surface to buffer
5174 * - surface width, surface height, buffer transform, buffer scale
5176 * - screen width, screen height, output transform, output scale
5179 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5180 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5182 E_Util_Transform_Matrix m;
5183 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5184 E_Util_Transform_Rect_Vertex sv;
5186 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5188 sv = e_util_transform_rect_to_vertices(&sr);
5189 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5190 sr = e_util_transform_vertices_to_rect(&sv);
5199 * - buffer width, buffer height, buffer transform, buffer scale
5202 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5203 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5205 E_Util_Transform_Matrix m;
5206 E_Util_Transform_Rect br = {bx, by, bw, bh};
5207 E_Util_Transform_Rect_Vertex bv;
5210 if (transform != 0 || scale > 1)
5212 tw = ((transform % 2) ? height : width) / scale;
5213 th = ((transform % 2) ? width : height) / scale;
5221 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5222 m = e_util_transform_matrix_inverse_get(&m);
5224 bv = e_util_transform_rect_to_vertices(&br);
5225 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5226 br = e_util_transform_vertices_to_rect(&bv);
5234 EINTERN E_Comp_Wl_Output*
5235 e_comp_wl_output_find(E_Client *ec)
5238 E_Comp_Wl_Output *output;
5240 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5242 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5244 if (output->transform % 2)
5246 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5247 ec->y < output->x || ec->y >= (output->x + output->w))
5252 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5253 ec->y < output->y || ec->y >= (output->y + output->h))
5263 EINTERN Eina_Array *
5264 e_comp_wl_output_find_all(E_Client *ec)
5266 E_Comp_Wl_Output *output;
5267 Eina_Array *outputs;
5270 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5272 outputs = eina_array_new(4);
5276 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5278 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5279 output->x, output->y, output->w, output->h))
5281 eina_array_push(outputs, output);
5285 if (eina_array_count(outputs) == 0)
5287 eina_array_free(outputs);
5294 // --------------------------------------------------------
5295 // tizen_move_resize
5296 // --------------------------------------------------------
5298 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5305 E_Client_Pending_Geometry *geo;
5308 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5309 if (ec->fullscreen || ec->maximized) goto err;
5311 geo = E_NEW(E_Client_Pending_Geometry, 1);
5314 geo->serial = serial;
5320 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5321 ec->surface_sync.wait_commit = EINA_TRUE;
5326 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5333 e_comp_wl_commit_sync_configure(E_Client *ec)
5336 E_Client_Pending_Geometry *geo;
5338 Eina_Bool match_size = EINA_FALSE;
5345 if (!ec || !ec->frame) goto ret;
5346 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5349 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5350 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5352 if (eina_list_count(ec->surface_sync.pending_geometry))
5354 Eina_List *ll = NULL;
5355 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5359 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5364 if ((geo->w == bw) && (geo->h == bh))
5366 match_size = EINA_TRUE;
5371 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5378 if ((config.w != ec->w) || (config.h != ec->h))
5380 e_client_size_set(ec, config.w, config.h);
5381 ec->changes.size = EINA_TRUE;
5385 // FIXME: The geometry of the client would be better to be calculated
5386 // at e_desk or at e_desk_area. So the position(x,y) of the client
5387 // should be calcuated at the e_desk or at the e_desk_area.
5389 desk = e_comp_desk_find_by_ec(ec);
5392 ec->client.x = desk->geom.x + config.x;
5393 ec->client.y = desk->geom.y + config.y;
5397 ec->client.x = config.x;
5398 ec->client.y = config.y;
5401 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5403 e_client_pos_set(ec, ec->client.x, ec->client.y);
5405 ec->changes.pos = 1;
5409 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5413 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5414 ec->surface_sync.wait_commit = EINA_FALSE;
5416 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5418 // rollback wait_commit if there are pending requests remained
5419 if (eina_list_count(ec->surface_sync.pending_geometry))
5420 ec->surface_sync.wait_commit = EINA_TRUE;
5425 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);
5432 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5433 struct wl_resource *res_moveresize)
5435 wl_resource_destroy(res_moveresize);
5439 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5440 struct wl_resource *res_moveresize,
5441 struct wl_resource *surface,
5448 /* to be implemented */
5451 int cur_w = 0, cur_h = 0;
5453 ec = e_client_from_surface_resource(surface);
5456 pending = e_client_pending_geometry_has(ec);
5457 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5458 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);
5462 if ((cur_w == w) && (cur_h == h))
5464 e_client_pos_set(ec, x, y);
5465 ec->changes.pos = 1;
5471 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5475 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5478 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5480 _tz_move_resize_iface_cb_destroy,
5481 _tz_move_resize_iface_cb_set_geometry,
5485 _tz_moveresize_cb_bind(struct wl_client *client,
5486 void *data EINA_UNUSED,
5490 struct wl_resource *res_moveresize;
5492 res_moveresize = wl_resource_create(client,
5493 &tizen_move_resize_interface,
5496 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5499 wl_resource_set_implementation(res_moveresize,
5500 &_tz_move_resize_iface,
5506 ERR("Could not create tizen_move_resize_interface res: %m");
5507 wl_client_post_no_memory(client);
5511 _e_comp_wl_move_resize_init(void)
5513 if (!e_comp_wl) return;
5514 if (!e_comp_wl->wl.disp) return;
5516 if (!wl_global_create(e_comp_wl->wl.disp,
5517 &tizen_move_resize_interface,
5520 _tz_moveresize_cb_bind))
5522 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5529 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5531 E_Comp_Wl_Output *output;
5532 pid_t output_pid = 0;
5533 Eina_List *l = NULL, *l2 = NULL;
5534 struct wl_resource *resource = NULL;
5536 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5538 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5539 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5540 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5542 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5544 /* if we have bound resources, send updates */
5545 EINA_LIST_FOREACH(output->resources, l2, resource)
5547 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5548 if (output_pid != pid) continue;
5550 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5552 // send output information to the client
5553 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5561 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5563 _e_comp_wl_surface_state_init(state, w, h);
5567 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5569 _e_comp_wl_surface_state_commit(ec, state);
5573 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5575 _e_comp_wl_hook_call(hookpoint, ec);
5579 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5581 _e_comp_wl_surface_state_finish(state);
5585 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5587 _e_comp_wl_surface_state_buffer_set(state, buffer);
5591 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5592 int sx, int sy, int *dx, int *dy)
5596 case WL_OUTPUT_TRANSFORM_NORMAL:
5600 case WL_OUTPUT_TRANSFORM_FLIPPED:
5601 *dx = width - sx, *dy = sy;
5603 case WL_OUTPUT_TRANSFORM_90:
5604 *dx = height - sy, *dy = sx;
5606 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5607 *dx = height - sy, *dy = width - sx;
5609 case WL_OUTPUT_TRANSFORM_180:
5610 *dx = width - sx, *dy = height - sy;
5612 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5613 *dx = sx, *dy = height - sy;
5615 case WL_OUTPUT_TRANSFORM_270:
5616 *dx = sy, *dy = width - sx;
5618 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5628 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5631 int tx1, ty1, tx2, ty2;
5632 int width_from_buffer, height_from_buffer;
5634 switch (vp->buffer.transform)
5636 case WL_OUTPUT_TRANSFORM_90:
5637 case WL_OUTPUT_TRANSFORM_270:
5638 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5639 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5640 width_from_buffer = bh / vp->buffer.scale;
5641 height_from_buffer = bw / vp->buffer.scale;
5644 width_from_buffer = bw / vp->buffer.scale;
5645 height_from_buffer = bh / vp->buffer.scale;
5649 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5653 x2 = width_from_buffer;
5654 y2 = height_from_buffer;
5658 x1 = wl_fixed_to_int(vp->buffer.src_x);
5659 y1 = wl_fixed_to_int(vp->buffer.src_y);
5660 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5661 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5664 buffer_transform(width_from_buffer, height_from_buffer,
5665 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5666 buffer_transform(width_from_buffer, height_from_buffer,
5667 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5669 out->x = (tx1 <= tx2) ? tx1 : tx2;
5670 out->y = (ty1 <= ty2) ? ty1 : ty2;
5671 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5672 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5676 * Convert given four coordinates to elements of rectangle
5677 * @in p[4] Coordinates to be converted
5678 * @out rect x, y, width, and height
5679 * transform Angle which represents TDM_TRANSFORM of rectangle
5680 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5681 * 1. The given coordinates are not represented by rectangle.
5682 * 2. All angles except for 0, 90, 180, 270.
5685 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5687 Eina_Bool ret = EINA_FALSE;
5689 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))
5692 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5695 *rotation = TDM_TRANSFORM_NORMAL;
5698 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5702 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5705 *rotation = TDM_TRANSFORM_180;
5708 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5713 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))
5716 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5719 *rotation = TDM_TRANSFORM_90;
5722 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5726 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5729 *rotation = TDM_TRANSFORM_270;
5732 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5742 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5747 for (i = 0; i < 4; i++)
5748 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5750 if (!_coords_to_rectangle_convert(p, out, rotation))
5752 DBG("Cannot convert given coords to rectangle.\n"
5753 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5754 p[0].x, p[0].y, p[1].x, p[1].y,
5755 p[2].x, p[2].y, p[3].x, p[3].y);
5763 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5765 int trans_rotation, flip;
5767 trans_rotation = transform & 0x3;
5768 flip = transform & 0x4;
5770 return (flip + (trans_rotation + rotation) % 4);
5774 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5782 if (e_comp_wl_subsurface_check(ec))
5783 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5790 out->w = ec->comp_data->width_from_viewport;
5791 out->w = (out->w + 1) & ~1;
5792 out->h = ec->comp_data->height_from_viewport;
5794 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5795 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5799 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5801 E_Comp_Wl_Buffer *buffer;
5802 E_Comp_Wl_Buffer_Viewport *vp;
5804 enum wl_output_transform buffer_transform;
5805 unsigned int rotation;
5806 Eina_Bool res = EINA_FALSE;
5808 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5810 if (e_object_is_del(E_OBJECT(ec)))
5813 vp = &ec->comp_data->scaler.buffer_viewport;
5815 if (buffer_viewport)
5817 buffer = ec->comp_data->buffer_ref.buffer;
5818 /* Getting a viewport of buffer needs geometry of buffer. */
5822 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5825 if ((output_viewport) || (transform))
5827 m = e_client_map_get(ec);
5829 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5831 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5836 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5837 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5838 * Since buffer.transform isn't applied using evas_map,
5839 * it has to be taken into account here to apply buffer.transform
5840 * and rotation of e_client_transform together. */
5842 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5844 *transform = (unsigned int)buffer_transform;
5852 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5854 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5855 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5857 /* Must be called with valid comp_data */
5858 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5860 if ((ec->comp_data->role_name == NULL) ||
5861 (ec->comp_data->role_name == role_name) ||
5862 (strcmp(ec->comp_data->role_name, role_name) == 0))
5864 ec->comp_data->role_name = role_name;
5870 wl_resource_post_error(error_resource, error_code,
5871 "Cannot assign role %s to wl_surface@%d,"
5872 " already has role %s\n",
5874 ec->comp_data->wl_surface ?
5875 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5876 ec->comp_data->role_name);
5882 EINTERN const char *
5883 e_comp_wl_surface_role_get(E_Client *ec)
5885 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5886 return ec->comp_data ? ec->comp_data->role_name : NULL;
5889 EINTERN struct wl_resource *
5890 e_comp_wl_client_surface_get(E_Client *ec)
5892 struct wl_resource *surface = NULL;
5893 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5894 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5896 g_mutex_lock(&ec->comp_data->surface_mutex);
5897 surface = ec->comp_data->surface;
5898 g_mutex_unlock(&ec->comp_data->surface_mutex);
5903 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5905 EINA_SAFETY_ON_NULL_RETURN(ec);
5906 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5908 g_mutex_lock(&ec->comp_data->surface_mutex);
5909 ec->comp_data->surface = surface;
5910 g_mutex_unlock(&ec->comp_data->surface_mutex);
5914 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5916 return e_compositor_util_client_from_surface_resource(surface_resource);
5920 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5922 if (!ec->comp_data->mapped)
5924 if (ec->comp_data->shell.surface &&
5925 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5927 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5933 if (ec->comp_data->mapped)
5935 /* will be unmapped. so run capture */
5936 e_comp_wl_remote_surface_image_save(ec);
5940 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5942 ec->comp_data->pending.sx = sx;
5943 ec->comp_data->pending.sy = sy;
5944 ec->comp_data->pending.new_attach = EINA_TRUE;
5946 e_client_fps_update(ec);
5950 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5952 if (ec->comp_data->pending.opaque)
5953 eina_tiler_clear(ec->comp_data->pending.opaque);
5957 eina_tiler_union(ec->comp_data->pending.opaque, region);
5959 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5963 ec->argb = EINA_FALSE;
5964 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5966 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5967 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5975 ec->argb = EINA_TRUE;
5976 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5978 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5979 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5985 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5987 if (ec->comp_data->pending.input)
5988 eina_tiler_clear(ec->comp_data->pending.input);
5992 if (eina_tiler_empty(region))
5994 ELOGF("COMP", " |unset input rect", NULL);
5995 e_comp_object_input_objs_del(ec->frame);
5996 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
5999 eina_tiler_union(ec->comp_data->pending.input, region);
6003 eina_tiler_rect_add(ec->comp_data->pending.input,
6004 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6009 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6011 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6015 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6017 E_Comp_Wl_Subsurf_Data *sdata;
6022 if (ec->comp_data->frames)
6024 ec->comp_data->frames =
6025 eina_list_remove(ec->comp_data->frames, callback_resource);
6028 if (ec->comp_data->pending.frames)
6030 ec->comp_data->pending.frames =
6031 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6034 sdata = ec->comp_data->sub.data;
6035 if ((sdata) && (sdata->cached.frames))
6037 sdata->cached.frames =
6038 eina_list_remove(sdata->cached.frames, callback_resource);
6043 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6045 if (e_object_is_del(E_OBJECT(ec))) return;
6047 if (e_comp_wl_remote_surface_commit(ec)) return;
6049 e_comp_wl_surface_commit(ec);
6051 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6055 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6057 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6058 ec->comp_data->sub.data = sub;
6060 /* set subsurface client properties */
6061 ec->borderless = EINA_TRUE;
6062 ec->argb = EINA_TRUE;
6063 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6064 ec->lock_border = EINA_TRUE;
6065 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6066 ec->netwm.state.skip_taskbar = EINA_TRUE;
6067 ec->netwm.state.skip_pager = EINA_TRUE;
6068 ec->border_size = 0;
6069 ec->lock_user_location = 0;
6070 ec->lock_client_location = 0;
6071 ec->lock_user_size = 0;
6072 ec->lock_client_size = 0;
6073 ec->lock_client_stacking = 0;
6074 ec->lock_user_maximize = 0;
6075 ec->lock_client_maximize = 0;
6076 ec->changes.need_maximize = 0;
6077 ec->maximized = E_MAXIMIZE_NONE;
6080 ec->new_client = ec->netwm.ping = EINA_TRUE;
6081 e_comp->new_clients++;
6082 e_client_unignore(ec);
6084 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6085 * It's not for subsurface. */
6086 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6090 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6092 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6095 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6097 sub->parent = parent;
6101 layer = e_client_layer_get(parent);
6102 if (layer > E_LAYER_BOTTOM)
6103 e_client_layer_set(ec, layer);
6106 if (parent->comp_data)
6108 /* append this client to the parents subsurface list */
6109 parent->comp_data->sub.list_pending =
6110 eina_list_append(parent->comp_data->sub.list_pending, ec);
6111 parent->comp_data->sub.list_changed = EINA_TRUE;
6116 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6118 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6119 E_Client *parent = sub->parent;
6121 parent->comp_data->sub.list =
6122 eina_list_remove(parent->comp_data->sub.list, ec);
6123 parent->comp_data->sub.list_pending =
6124 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6125 parent->comp_data->sub.below_list =
6126 eina_list_remove(parent->comp_data->sub.below_list, ec);
6127 parent->comp_data->sub.below_list_pending =
6128 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6134 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)
6136 sub->resource = subsurface_resource;
6137 sub->cached_buffer_ref.buffer = NULL;
6138 sub->synchronized = EINA_TRUE;
6139 sub->parent = parent;
6140 sub->remote_surface.offscreen_parent = offscreen_parent;
6141 if (offscreen_parent)
6142 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6144 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6146 _e_comp_wl_client_subsurface_set(ec, sub);
6147 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6149 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6153 e_comp_wl_client_subsurface_finish(E_Client *ec)
6155 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6158 e_comp_wl_client_subsurface_parent_unset(ec);
6160 e_comp_wl_surface_state_finish(&sub->cached);
6161 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6163 ec->comp_data->sub.data = NULL;
6167 e_comp_wl_client_evas_init(E_Client *ec)
6169 EINA_SAFETY_ON_NULL_RETURN(ec);
6171 _e_comp_wl_client_evas_init(ec);
6175 e_comp_wl_client_evas_deinit(E_Client *ec)
6177 EINA_SAFETY_ON_NULL_RETURN(ec);
6179 _e_comp_wl_client_evas_deinit(ec);
6183 e_comp_wl_focus_check(void)
6185 _e_comp_wl_focus_check();
6189 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6196 if ((parent->comp_data) && (parent->comp_data->sub.data))
6197 parent = parent->comp_data->sub.data->parent;