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"
8 #include "e_utils_intern.h"
10 #include <tizen-extension-server-protocol.h>
12 #include <relative-pointer-unstable-v1-server-protocol.h>
13 #include <pointer-constraints-unstable-v1-server-protocol.h>
15 #include <wayland-tbm-server.h>
18 #include <libds/log.h>
19 #include <libds/single_pixel_buffer_v1.h>
21 /* handle include for printing uint64_t */
22 #define __STDC_FORMAT_MACROS
25 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
27 /* Resource Data Mapping: (wl_resource_get_user_data)
29 * wl_surface == e_pixmap
30 * wl_region == eina_tiler
31 * wl_subsurface == e_client
35 typedef struct _E_Comp_Data E_Comp_Data;
40 struct wl_listener client_created;
43 static void _e_comp_wl_move_resize_init(void);
45 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
48 typedef struct _E_Comp_Wl_Key_Data
54 static Eina_List *handlers = NULL;
55 static E_Client *cursor_timer_ec = NULL;
56 static Eina_Bool need_send_released = EINA_FALSE;
57 static Eina_Bool need_send_motion = EINA_TRUE;
59 static GMutex connection_mutex;
61 static int _e_comp_wl_hooks_delete = 0;
62 static int _e_comp_wl_hooks_walking = 0;
64 static int _e_comp_wl_pid_hooks_delete = 0;
65 static int _e_comp_wl_pid_hooks_walking = 0;
67 static int _e_comp_wl_intercept_hooks_delete = 0;
68 static int _e_comp_wl_intercept_hooks_walking = 0;
70 static Eina_Inlist *_e_comp_wl_hooks[] =
72 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
73 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
74 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
75 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
76 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
77 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
78 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
79 [E_COMP_WL_HOOK_DEL] = NULL,
80 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
81 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
82 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
85 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
87 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
90 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
92 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
93 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
94 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
95 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
96 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
97 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
100 static Eina_List *hooks = NULL;
102 /* local functions */
104 _e_comp_wl_hooks_clean(void)
109 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
110 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
112 if (!ch->delete_me) continue;
113 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
119 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
123 e_object_ref(E_OBJECT(ec));
124 _e_comp_wl_hooks_walking++;
125 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
127 if (ch->delete_me) continue;
128 ch->func(ch->data, ec);
129 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
130 (e_object_is_del(E_OBJECT(ec))))
133 _e_comp_wl_hooks_walking--;
134 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
135 _e_comp_wl_hooks_clean();
136 e_object_unref(E_OBJECT(ec));
140 _e_comp_wl_pid_hooks_clean(void)
143 E_Comp_Wl_Pid_Hook *ch;
145 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
146 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
148 if (!ch->delete_me) continue;
149 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
155 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
157 E_Comp_Wl_Pid_Hook *ch;
159 _e_comp_wl_pid_hooks_walking++;
160 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
162 if (ch->delete_me) continue;
163 ch->func(ch->data, pid);
165 _e_comp_wl_pid_hooks_walking--;
166 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
167 _e_comp_wl_pid_hooks_clean();
171 _e_comp_wl_intercept_hooks_clean(void)
174 E_Comp_Wl_Intercept_Hook *ch;
176 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
177 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
179 if (!ch->delete_me) continue;
180 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
186 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
188 E_Comp_Wl_Intercept_Hook *ch;
189 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
191 e_object_ref(E_OBJECT(ec));
192 _e_comp_wl_intercept_hooks_walking++;
193 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
195 if (ch->delete_me) continue;
196 res = ch->func(ch->data, ec);
197 if (!res) ret = EINA_FALSE;
198 if (e_object_is_del(E_OBJECT(ec)))
201 _e_comp_wl_intercept_hooks_walking--;
202 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
203 _e_comp_wl_intercept_hooks_clean();
204 e_object_unref(E_OBJECT(ec));
211 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
217 if (e_comp_object_frame_exists(ec->frame))
218 w = ec->client.w, h = ec->client.h;
220 w = ec->w, h = ec->h;
224 // Width and Height are -1 means that we don't consider size value
228 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
232 _e_comp_wl_focus_check(void)
236 if (stopping) return;
237 ec = e_client_focused_get();
239 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
243 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
245 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
247 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
248 IDLE_EXITER~CB_PREPARE);
250 return ECORE_CALLBACK_RENEW;
254 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
256 /* dispatch pending wayland events */
257 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
259 return ECORE_CALLBACK_RENEW;
263 e_comp_wl_display_flush()
265 if (e_comp_wl && e_comp_wl->wl.disp)
267 if (e_config->key_input_ttrace_enable)
269 TRACE_INPUT_BEGIN(wl_display_flush_clients);
270 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
273 g_mutex_lock(&connection_mutex);
274 wl_display_flush_clients(e_comp_wl->wl.disp);
275 g_mutex_unlock(&connection_mutex);
277 if (e_config->key_input_ttrace_enable)
280 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
286 e_comp_wl_connection_lock()
288 e_input_boost_lock(&connection_mutex);
292 e_comp_wl_connection_unlock()
294 e_input_boost_unlock(&connection_mutex);
298 e_comp_wl_focused_client_flush()
300 E_Client *focused_ec;
301 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
303 e_input_boost_lock(&connection_mutex);
304 focused_ec = e_client_focused_get();
308 struct wl_client *wc;
309 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
312 e_input_boost_unlock(&connection_mutex);
316 wc = wl_resource_get_client(surface);
320 e_input_boost_unlock(&connection_mutex);
324 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
328 if (e_comp_wl->idle_exiter_timestamp > 0.0)
330 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
331 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
333 ELOGF("E_COMP", "prepare gap time: %lfms",
338 e_comp_wl->idle_exiter_timestamp = 0.0;
340 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
342 /* flush pending client events */
343 e_comp_wl_display_flush();
345 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
346 IDLE_EXITER~CB_PREPARE);
349 E_API enum wl_output_transform
350 e_comp_wl_output_buffer_transform_get(E_Client *ec)
352 E_Comp_Wl_Buffer_Viewport *vp;
353 E_Comp_Wl_Buffer *buffer;
354 enum wl_output_transform transform, rotation;
356 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
357 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
358 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
360 vp = &ec->comp_data->scaler.buffer_viewport;
361 if (e_comp_wl_subsurface_check(ec))
362 return vp->buffer.transform;
364 buffer = ec->comp_data->buffer_ref.buffer;
367 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
368 return vp->buffer.transform;
370 rotation = buffer->transform;
372 return vp->buffer.transform;
374 /* ignore the flip value when calculating transform because the screen rotation
375 * functionality doesn't consider the flip output transform currently
377 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
379 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
380 ec, rotation, vp->buffer.transform, transform);
385 EINTERN enum wl_output_transform
386 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
388 E_Comp_Wl_Buffer_Viewport *vp;
389 E_Comp_Wl_Buffer *buffer;
390 enum wl_output_transform transform, rotation;
392 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
393 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
394 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
396 vp = &ec->comp_data->pending.buffer_viewport;
397 if (e_comp_wl_subsurface_check(ec))
398 return vp->buffer.transform;
400 buffer = ec->comp_data->pending.buffer;
403 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
404 return vp->buffer.transform;
406 rotation = buffer->transform;
408 return vp->buffer.transform;
410 /* ignore the flip value when calculating transform because the screen rotation
411 * functionality doesn't consider the flip output transform currently
413 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
415 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
416 ec, rotation, vp->buffer.transform, transform);
422 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
424 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
425 E_Comp_Wl_Buffer *buffer;
426 int32_t width, height;
428 buffer = e_pixmap_resource_get(ec->pixmap);
431 ec->comp_data->width_from_buffer = 0;
432 ec->comp_data->height_from_buffer = 0;
436 switch (e_comp_wl_output_buffer_transform_get(ec))
438 case WL_OUTPUT_TRANSFORM_90:
439 case WL_OUTPUT_TRANSFORM_270:
440 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
441 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
442 width = buffer->h / vp->buffer.scale;
443 height = buffer->w / vp->buffer.scale;
446 width = buffer->w / vp->buffer.scale;
447 height = buffer->h / vp->buffer.scale;
451 ec->comp_data->width_from_buffer = width;
452 ec->comp_data->height_from_buffer = height;
456 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
458 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
459 int32_t width, height;
461 width = ec->comp_data->width_from_buffer;
462 height = ec->comp_data->height_from_buffer;
464 if (width == 0 && height == 0) return;
466 if (width != 0 && vp->surface.width != -1)
468 ec->comp_data->width_from_viewport = vp->surface.width;
469 ec->comp_data->height_from_viewport = vp->surface.height;
473 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
475 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
476 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
477 ec->comp_data->width_from_viewport = w ?: 1;
478 ec->comp_data->height_from_viewport = h ?: 1;
482 ec->comp_data->width_from_viewport = width;
483 ec->comp_data->height_from_viewport = height;
487 e_comp_wl_topmost_parent_get(E_Client *ec)
491 if (!e_comp_wl_subsurface_check(ec))
494 parent = e_comp_wl_subsurface_parent_get(ec);
497 if (!e_comp_wl_subsurface_check(parent))
500 parent = e_comp_wl_subsurface_parent_get(parent);
507 e_comp_wl_map_apply(E_Client *ec)
509 E_Comp_Wl_Buffer_Viewport *vp;
510 E_Comp_Wl_Subsurf_Data *sdata;
511 E_Comp_Wl_Client_Data *cdata;
512 int x1, y1, x2, y2, x, y;
514 Eina_Bool zoom_animating = EINA_FALSE;
516 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
518 e_comp_object_map_update(ec->frame);
520 cdata = ec->comp_data;
521 vp = &cdata->scaler.buffer_viewport;
522 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
523 (!cdata->viewport_transform))
526 if (e_comp_wl_subsurface_check(ec))
528 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
530 sdata = ec->comp_data->sub.data;
531 if (sdata->remote_surface.offscreen_parent)
533 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
534 Eina_Rectangle *rect;
537 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
539 /* TODO: If there are one more regions, it means that provider's offscreen
540 * is displayed by one more remote_surfaces. Have to consider it later. At
541 * this time, just consider only one remote_surface.
555 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
556 if (x != dx || y != dy)
557 evas_object_move(ec->frame, dx, dy);
559 if (!cdata->viewport_transform)
561 cdata->viewport_transform = e_util_transform_new();
562 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
563 e_client_transform_core_add(ec, cdata->viewport_transform);
566 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
567 ec->comp_data->width_from_viewport,
568 ec->comp_data->height_from_viewport);
570 if (vp->buffer.src_width == wl_fixed_from_int(-1))
574 x2 = cdata->width_from_buffer;
575 y2 = cdata->height_from_buffer;
579 x1 = wl_fixed_to_int(vp->buffer.src_x);
580 y1 = wl_fixed_to_int(vp->buffer.src_y);
581 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
582 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
585 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
586 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
587 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
588 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
591 desk = e_comp_desk_find_by_ec(ec);
593 zoom_animating = e_desk_zoom_is_animating(desk);
595 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
596 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
597 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
599 /* workaround:: when the desk zoom is doing their animation,
600 the transform core update can override animation's zoom boundary.
601 so, don't doing transform core update while desk zoom animation */
603 e_client_transform_core_update(ec);
608 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
612 int map_c = 0, map_x = 0, map_y = 0;
613 double inv_x = 0.0, inv_y = 0.0;
615 EINA_SAFETY_ON_NULL_RETURN(ec);
617 map = e_client_map_get(ec);
618 map_c = e_map_count_get(map);
620 if (!map || map_c <= 0)
630 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
631 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
632 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
633 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
635 for (int i = 0; i < map_c; i++)
637 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
638 e_map_point_image_uv_set(map2, i, map_x, map_y);
640 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
650 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
656 if (!(ec = data)) return;
657 if (e_object_is_del(data)) return;
659 if (!ec->override) e_hints_window_visible_set(ec);
661 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
662 (!ec->comp_data->need_reparent))
664 ec->comp_data->need_reparent = EINA_TRUE;
665 ec->visible = EINA_TRUE;
667 if (!e_client_util_ignored_get(ec))
669 ec->take_focus = !starting;
673 if (!ec->comp_data->need_reparent)
675 if ((ec->hidden) || (ec->iconic))
677 evas_object_hide(ec->frame);
678 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
681 evas_object_show(ec->frame);
684 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
685 evas_object_show(tmp->frame);
687 topmost = e_comp_wl_topmost_parent_get(ec);
688 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
689 e_comp_wl_subsurface_show(ec);
691 if (ec->comp_data->sub.below_obj)
692 evas_object_show(ec->comp_data->sub.below_obj);
696 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
702 if (!(ec = data)) return;
703 if (e_object_is_del(E_OBJECT(ec))) return;
705 /* Uncommonly some clients's final buffer can be skipped if the client
706 * requests unmap of its surface right after wl_surface@commit.
707 * So if this client evas object is hidden state and client is already
708 * unmmapped, we can consider to clear pixmap image here mandatorily.
710 if (!ec->comp_data->mapped)
711 e_pixmap_image_clear(ec->pixmap, 1);
713 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
714 evas_object_hide(tmp->frame);
716 topmost = e_comp_wl_topmost_parent_get(ec);
717 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
718 e_comp_wl_subsurface_hide(ec);
720 if (ec->comp_data->sub.below_obj)
721 evas_object_hide(ec->comp_data->sub.below_obj);
723 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
727 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
734 if (!(ec = data)) return;
735 if (e_object_is_del(E_OBJECT(ec))) return;
737 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
739 if (!e_comp_wl_subsurface_check(subc)) continue;
740 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
741 evas_object_move(subc->frame, x, y);
743 if (subc->comp_data->scaler.viewport)
745 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
746 if (cdata->viewport_transform)
747 e_comp_wl_map_apply(subc);
751 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
753 if (!e_comp_wl_subsurface_check(subc)) continue;
754 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
755 evas_object_move(subc->frame, x, y);
757 if (subc->comp_data->scaler.viewport)
759 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
760 if (cdata->viewport_transform)
761 e_comp_wl_map_apply(subc);
765 if (ec->comp_data->sub.below_obj)
767 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
768 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
773 _e_comp_wl_send_touch_cancel(E_Client *ec)
776 struct wl_resource *res;
777 struct wl_client *wc;
778 E_Comp_Config *comp_conf = NULL;
781 if (e_object_is_del(E_OBJECT(ec))) return;
782 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
784 if (!surface) return;
785 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
787 wc = wl_resource_get_client(surface);
789 comp_conf = e_comp_config_get();
791 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
793 if (wl_resource_get_client(res) != wc) continue;
794 if (!e_comp_wl_input_touch_check(res)) continue;
796 if (comp_conf && comp_conf->input_log_enable)
797 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
799 wl_touch_send_cancel(res);
804 _e_comp_wl_touch_cancel(void)
808 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
810 if (!e_comp_wl->touch.pressed) return;
812 _e_comp_wl_send_touch_cancel(ec);
815 static E_Devicemgr_Input_Device *
816 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
818 E_Devicemgr_Input_Device *last_kbd = NULL;
821 case ECORE_DEVICE_CLASS_MOUSE:
822 return e_devicemgr->last_device_ptr;
823 case ECORE_DEVICE_CLASS_KEYBOARD:
824 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
826 case ECORE_DEVICE_CLASS_TOUCH:
827 return e_devicemgr->last_device_touch;
835 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
839 case ECORE_DEVICE_CLASS_MOUSE:
840 e_devicemgr->last_device_ptr = device;
842 case ECORE_DEVICE_CLASS_KEYBOARD:
843 atomic_store(&e_devicemgr->last_device_kbd, device);
845 case ECORE_DEVICE_CLASS_TOUCH:
846 e_devicemgr->last_device_touch = device;
853 static E_Devicemgr_Input_Device *
854 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
856 E_Devicemgr_Input_Device *last_kbd = NULL;
860 case ECORE_DEVICE_CLASS_MOUSE:
861 return ec->comp_data->last_device_ptr;
862 case ECORE_DEVICE_CLASS_KEYBOARD:
863 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
865 case ECORE_DEVICE_CLASS_TOUCH:
866 return ec->comp_data->last_device_touch;
874 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
878 case ECORE_DEVICE_CLASS_MOUSE:
879 ec->comp_data->last_device_ptr = device;
881 case ECORE_DEVICE_CLASS_KEYBOARD:
882 atomic_store(&ec->comp_data->last_device_kbd, device);
884 case ECORE_DEVICE_CLASS_TOUCH:
885 ec->comp_data->last_device_touch = device;
893 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
895 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
896 struct wl_resource *dev_res;
897 const char *dev_name;
898 Ecore_Device_Class dev_class;
899 struct wl_client *wc;
903 EINA_SAFETY_ON_NULL_RETURN(dev);
906 if (ec->cur_mouse_action || e_comp_wl->drag)
908 if (e_object_is_del(E_OBJECT(ec))) return;
909 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
910 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
911 if (!surface) return;
913 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
914 dev_name = evas_device_description_get(dev);
915 last_device = _e_comp_wl_device_last_device_get(dev_class);
916 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
918 serial = wl_display_next_serial(e_comp_wl->wl.disp);
919 wc = wl_resource_get_client(surface);
920 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
921 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
923 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
924 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
926 _e_comp_wl_device_last_device_set(dev_class, input_dev);
927 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
929 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
931 if (wl_resource_get_client(dev_res) != wc) continue;
932 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
936 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
940 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
942 E_Devicemgr_Input_Device *last_device;
943 struct wl_resource *dev_res;
944 struct wl_client *wc;
948 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
949 if (!surface) return;
951 last_device = _e_comp_wl_device_last_device_get(dev_class);
952 if (!last_device) return;
954 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
956 serial = wl_display_next_serial(e_comp_wl->wl.disp);
957 wc = wl_resource_get_client(surface);
958 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
960 if (wl_resource_get_client(dev_res) != wc) continue;
961 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
966 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
968 E_Devicemgr_Input_Device *input_dev;
969 struct wl_resource *dev_res;
970 const char *dev_name;
973 EINA_SAFETY_ON_NULL_RETURN(dev);
975 dev_name = ecore_device_identifier_get(dev);
977 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
978 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
980 if (!eina_streq(input_dev->identifier, dev_name) ||
981 (input_dev->clas != ecore_device_class_get(dev))) continue;
982 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
984 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
986 if (wl_resource_get_client(dev_res) != wc) continue;
987 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
990 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
994 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
996 E_Devicemgr_Input_Device *input_dev;
997 struct wl_resource *dev_res;
998 const char *dev_name;
1001 EINA_SAFETY_ON_NULL_RETURN(dev);
1003 dev_name = e_device_identifier_get(dev);
1005 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1006 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1008 if (!eina_streq(input_dev->identifier, dev_name) ||
1009 (input_dev->clas != e_device_class_get(dev))) continue;
1010 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1012 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1014 if (wl_resource_get_client(dev_res) != wc) continue;
1015 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1018 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1022 _e_comp_wl_cursor_reload(E_Client *ec)
1024 struct wl_resource *res;
1025 struct wl_client *wc;
1031 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1032 !evas_object_visible_get(e_comp->pointer->o_ptr))
1033 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1036 if (e_object_is_del(E_OBJECT(ec))) return;
1037 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1038 if (!surface) return;
1039 if (ec->pointer_enter_sent) return;
1041 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1042 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1044 if (e_client_transform_core_enable_get(ec))
1046 double dx = 0.0, dy = 0.0;
1047 map = e_client_map_get(ec);
1048 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1054 cx = px - ec->client.x;
1055 cy = py - ec->client.y;
1057 wc = wl_resource_get_client(surface);
1058 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1059 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1061 if (!e_comp_wl_input_pointer_check(res)) continue;
1062 if (wl_resource_get_client(res) != wc) continue;
1063 wl_pointer_send_enter(res, serial, surface,
1064 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1065 ec->pointer_enter_sent = EINA_TRUE;
1067 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1071 _e_comp_wl_cursor_timer(void *data)
1073 E_Client *ec = data;
1075 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1076 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1078 e_comp_wl_cursor_hide(ec);
1080 return ECORE_CALLBACK_CANCEL;
1084 _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)
1086 E_Devicemgr_Input_Device *input_dev;
1087 struct wl_resource *dev_res;
1088 struct wl_client *wc;
1093 if (ec->cur_mouse_action) return;
1094 if (e_object_is_del(E_OBJECT(ec))) return;
1095 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1096 if (!surface) return;
1098 f_value = wl_fixed_from_double(value);
1099 wc = wl_resource_get_client(surface);
1101 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1102 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1104 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1105 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1107 if (wl_resource_get_client(dev_res) != wc) continue;
1108 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1111 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1115 _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)
1117 if (idx >= e_input_touch_max_count_get()) return;
1119 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1120 e_devicemgr->multi[idx].radius_x = radius_x;
1121 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1122 e_devicemgr->multi[idx].radius_y = radius_y;
1123 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1124 e_devicemgr->multi[idx].pressure = pressure;
1125 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1126 e_devicemgr->multi[idx].angle = angle;
1130 _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)
1132 if (idx >= e_input_touch_max_count_get()) return;
1134 if (e_devicemgr->multi[idx].radius_x != radius_x)
1136 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1137 e_devicemgr->multi[idx].radius_x = radius_x;
1139 if (e_devicemgr->multi[idx].radius_y != radius_y)
1141 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1142 e_devicemgr->multi[idx].radius_y = radius_y;
1144 if (e_devicemgr->multi[idx].pressure != pressure)
1146 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1147 e_devicemgr->multi[idx].pressure = pressure;
1149 if (e_devicemgr->multi[idx].angle != angle)
1151 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1152 e_devicemgr->multi[idx].angle = angle;
1157 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1159 Eina_Bool ret = EINA_TRUE;
1162 case EVAS_CALLBACK_MOUSE_IN:
1163 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1166 if (e_comp_wl->ptr.hide_tmr)
1168 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1169 cursor_timer_ec = ec;
1170 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1174 if (e_pointer_is_hidden(e_comp->pointer))
1179 case EVAS_CALLBACK_MOUSE_OUT:
1180 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1183 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1187 case EVAS_CALLBACK_MOUSE_MOVE:
1188 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1191 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1192 _e_comp_wl_cursor_reload(ec);
1195 case EVAS_CALLBACK_MOUSE_WHEEL:
1196 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1199 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1200 _e_comp_wl_cursor_reload(ec);
1203 case EVAS_CALLBACK_MOUSE_DOWN:
1204 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1207 if (e_comp_wl->ptr.hide_tmr)
1209 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1210 e_comp_wl->ptr.hide_tmr = NULL;
1212 cursor_timer_ec = NULL;
1214 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1215 _e_comp_wl_cursor_reload(ec);
1218 case EVAS_CALLBACK_MOUSE_UP:
1219 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1230 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1232 if (ec->has_cursor_unset)
1235 if (!e_config->show_cursor)
1238 if (!e_config->use_cursor_timer)
1245 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1248 Evas_Event_Mouse_In *ev;
1249 struct wl_resource *res;
1250 struct wl_client *wc;
1253 E_Comp_Config *comp_conf;
1254 E_Client *prev_ptr_ec;
1258 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1259 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1261 if (!(ec = data)) return;
1262 if (e_object_is_del(E_OBJECT(ec))) return;
1263 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1264 if (!surface) return;
1266 prev_ptr_ec = e_comp_wl->ptr.ec;
1269 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1270 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1273 e_comp_wl->ptr.ec = ec;
1275 comp_conf = e_comp_config_get();
1276 if (comp_conf && comp_conf->input_log_enable)
1277 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1278 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1279 e_client_util_name_get(ec));
1281 if (_e_comp_wl_check_cursor_timer_needed(ec))
1283 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1287 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1288 wc = wl_resource_get_client(surface);
1289 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1290 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1292 if (!e_comp_wl_input_pointer_check(res)) continue;
1293 if (wl_resource_get_client(res) != wc) continue;
1295 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1297 wl_pointer_send_enter(res, serial, surface,
1298 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1299 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1300 ec->pointer_enter_sent = EINA_TRUE;
1303 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1307 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1310 Evas_Event_Mouse_Out *ev;
1311 struct wl_resource *res;
1312 struct wl_client *wc;
1315 Eina_Bool inside_check;
1316 E_Comp_Config *comp_conf;
1320 if (!(ec = data)) return;
1321 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1322 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1323 if (ec->cur_mouse_action && inside_check) return;
1324 if (e_object_is_del(E_OBJECT(e_comp))) return;
1325 if (e_comp_wl->ptr.ec == ec)
1326 e_comp_wl->ptr.ec = NULL;
1327 if (e_object_is_del(E_OBJECT(ec))) return;
1329 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1330 if (!surface) return;
1332 comp_conf = e_comp_config_get();
1333 if (comp_conf && comp_conf->input_log_enable)
1334 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1335 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1336 e_client_util_name_get(ec));
1338 if (_e_comp_wl_check_cursor_timer_needed(ec))
1340 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1344 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1346 wc = wl_resource_get_client(surface);
1347 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1348 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1350 if (!e_comp_wl_input_pointer_check(res)) continue;
1351 if (wl_resource_get_client(res) != wc) continue;
1352 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1354 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1356 wl_pointer_send_leave(res, serial, surface);
1357 ec->pointer_enter_sent = EINA_FALSE;
1362 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1365 struct wl_client *wc;
1366 struct wl_resource *res;
1369 E_Comp_Config *comp_conf = NULL;
1372 if (e_object_is_del(E_OBJECT(ec))) return;
1373 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1374 if (!surface) return;
1376 wc = wl_resource_get_client(surface);
1377 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1381 x = wl_fixed_from_int(canvas_x - ec->client.x);
1382 y = wl_fixed_from_int(canvas_y - ec->client.y);
1385 comp_conf = e_comp_config_get();
1387 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1389 if (wl_resource_get_client(res) != wc) continue;
1390 if (!e_comp_wl_input_touch_check(res)) continue;
1391 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1394 if (comp_conf && comp_conf->input_log_enable)
1395 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));
1397 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1401 if (comp_conf && comp_conf->input_log_enable)
1402 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));
1404 wl_touch_send_up(res, serial, timestamp, idx);
1411 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1414 struct wl_client *wc;
1415 struct wl_resource *res;
1419 if (ec->cur_mouse_action) return;
1420 if (e_object_is_del(E_OBJECT(ec))) return;
1421 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1422 if (!surface) return;
1424 wc = wl_resource_get_client(surface);
1426 x = wl_fixed_from_int(canvas_x - ec->client.x);
1427 y = wl_fixed_from_int(canvas_y - ec->client.y);
1429 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1431 if (wl_resource_get_client(res) != wc) continue;
1432 if (!e_comp_wl_input_touch_check(res)) continue;
1433 wl_touch_send_motion(res, timestamp, idx, x, y);
1438 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1440 struct wl_resource *res;
1441 struct wl_client *wc;
1445 if (ec->cur_mouse_action) return;
1446 if (e_object_is_del(E_OBJECT(ec))) return;
1447 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1448 if (!surface) return;
1450 wc = wl_resource_get_client(surface);
1451 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1453 if (!e_comp_wl_input_pointer_check(res)) continue;
1454 if (wl_resource_get_client(res) != wc) continue;
1455 wl_pointer_send_motion(res, timestamp,
1456 wl_fixed_from_int(x - ec->client.x),
1457 wl_fixed_from_int(y - ec->client.y));
1462 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1464 if (e_comp_wl->ptr.hide_tmr)
1466 if (cursor_timer_ec == ec)
1468 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1469 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1473 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1474 cursor_timer_ec = ec;
1475 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1480 cursor_timer_ec = ec;
1481 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1486 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1489 Evas_Event_Mouse_Move *ev;
1490 Evas_Device *dev = NULL;
1491 const char *dev_name;
1492 E_Comp_Config *comp_conf;
1496 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1497 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1499 if (!(ec = data)) return;
1500 if (e_object_is_del(E_OBJECT(ec))) return;
1501 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1502 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1503 if (!surface) return;
1505 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1508 dev_name = evas_device_description_get(dev);
1510 comp_conf = e_comp_config_get();
1511 if (comp_conf && comp_conf->input_log_enable)
1512 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1513 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1514 e_client_util_name_get(ec), dev_name);
1516 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1518 if (!e_comp_wl->drag_client)
1520 e_comp_wl->touch.faked_ec = ec;
1521 if (e_comp_wl->touch.pressed & (1 << 0))
1523 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1525 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1526 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1527 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1531 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1535 if (!e_comp_wl->drag_client)
1537 if (_e_comp_wl_check_cursor_timer_needed(ec))
1539 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1543 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1544 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1546 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1548 if (_e_comp_wl_check_cursor_timer_needed(ec))
1549 _e_comp_wl_cursor_move_timer_control(ec);
1553 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1558 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1560 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1561 if (e_object_is_del(E_OBJECT(ec))) return;
1562 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1563 if (!surface) return;
1564 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1566 e_comp_wl->ptr.button = BTN_LEFT;
1568 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1572 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1574 E_Client *ec = data;
1575 Evas_Event_Mouse_Down *ev = event;
1576 Evas_Device *dev = NULL;
1577 const Evas_Device *seat_dev;
1578 const char *dev_name, *seat_name;
1579 E_Comp_Config *comp_conf = NULL;
1582 if (e_object_is_del(E_OBJECT(ec))) return;
1585 dev_name = evas_device_description_get(dev);
1587 seat_dev = evas_device_parent_get(dev);
1588 seat_name = evas_device_name_get(seat_dev);
1590 comp_conf = e_comp_config_get();
1591 if (comp_conf && comp_conf->input_log_enable)
1592 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1593 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1594 dev_name, seat_name);
1596 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1598 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1600 e_comp_wl->touch.faked_ec = ec;
1603 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1604 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1605 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1607 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1608 e_comp_wl->touch.pressed |= (1 << 0);
1612 if (_e_comp_wl_check_cursor_timer_needed(ec))
1614 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1618 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1619 WL_POINTER_BUTTON_STATE_PRESSED);
1621 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1624 need_send_released = EINA_TRUE;
1628 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1630 E_Client *ec = data;
1631 Evas_Event_Mouse_Up *ev = event;
1632 Evas_Device *dev = NULL;
1633 const Evas_Device *seat_dev;
1634 const char *dev_name, *seat_name;;
1635 Evas_Event_Flags flags;
1636 E_Comp_Config *comp_conf = NULL;
1639 if (ec->cur_mouse_action) return;
1640 if (e_object_is_del(E_OBJECT(ec))) return;
1642 if (!need_send_released)
1644 need_send_motion = EINA_TRUE;
1648 dev_name = evas_device_description_get(dev);
1650 seat_dev = evas_device_parent_get(dev);
1651 seat_name = evas_device_name_get(seat_dev);
1652 flags = evas_event_default_flags_get(evas);
1654 comp_conf = e_comp_config_get();
1655 if (comp_conf && comp_conf->input_log_enable)
1656 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1657 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1658 dev_name, seat_name);
1660 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1662 e_comp_wl->touch.pressed &= ~(1 << 0);
1664 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1665 e_comp_wl->touch.faked_ec = NULL;
1668 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1670 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1672 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1675 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1676 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1677 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1681 if (_e_comp_wl_check_cursor_timer_needed(ec))
1683 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1687 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1688 WL_POINTER_BUTTON_STATE_RELEASED);
1690 if (_e_comp_wl_check_cursor_timer_needed(ec))
1691 _e_comp_wl_cursor_move_timer_control(ec);
1695 need_send_released = EINA_FALSE;
1699 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1701 struct wl_resource *res;
1702 struct wl_client *wc;
1707 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1709 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1712 dir = -wl_fixed_from_int(abs(z));
1714 dir = wl_fixed_from_int(z);
1717 if (e_object_is_del(E_OBJECT(ec))) return;
1718 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1719 if (!surface) return;
1721 wc = wl_resource_get_client(surface);
1722 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1724 if (!e_comp_wl_input_pointer_check(res)) continue;
1725 if (wl_resource_get_client(res) != wc) continue;
1726 wl_pointer_send_axis(res, timestamp, axis, dir);
1731 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1734 Evas_Event_Mouse_Wheel *ev;
1737 if (!(ec = data)) return;
1738 if (ec->cur_mouse_action) return;
1739 if (e_object_is_del(E_OBJECT(ec))) return;
1740 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1741 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1742 if (!surface) return;
1744 if (!eina_list_count(e_comp_wl->ptr.resources))
1747 if (_e_comp_wl_check_cursor_timer_needed(ec))
1749 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1753 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1755 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1757 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1759 if (_e_comp_wl_check_cursor_timer_needed(ec))
1760 _e_comp_wl_cursor_move_timer_control(ec);
1765 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1767 E_Client *ec = data;
1768 Evas_Event_Multi_Down *ev = event;
1769 Evas_Device *dev = NULL;
1770 const Evas_Device *seat_dev;
1771 const char *dev_name, *seat_name;
1772 Evas_Device_Class dev_class;
1773 E_Comp_Config *comp_conf = NULL;
1776 if (e_object_is_del(E_OBJECT(ec))) return;
1777 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1778 if (!surface) return;
1780 /* Do not deliver emulated single touch events to client */
1781 if (ev->device == 0) return;
1784 dev_name = evas_device_description_get(dev);
1785 e_comp_wl->touch.faked_ec = ec;
1787 seat_dev = evas_device_parent_get(dev);
1788 seat_name = evas_device_name_get(seat_dev);
1790 comp_conf = e_comp_config_get();
1791 if (comp_conf && comp_conf->input_log_enable)
1792 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1793 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1794 dev_name, seat_name);
1796 if (dev && dev_name)
1798 dev_class = evas_device_class_get(dev);
1799 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1800 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1803 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1804 e_comp_wl->touch.pressed |= (1 << ev->device);
1808 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1810 E_Client *ec = data;
1811 Evas_Event_Multi_Up *ev = event;
1812 Evas_Device *dev = NULL;
1813 const Evas_Device *seat_dev;
1814 const char *dev_name, *seat_name;
1815 Evas_Device_Class dev_class;
1816 Evas_Event_Flags flags;
1817 E_Comp_Config *comp_conf = NULL;
1820 if (e_object_is_del(E_OBJECT(ec))) return;
1821 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1822 if (!surface) return;
1824 /* Do not deliver emulated single touch events to client */
1825 if (ev->device == 0) return;
1827 flags = evas_event_default_flags_get(evas);
1829 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1830 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1831 e_comp_wl->touch.faked_ec = NULL;
1833 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1836 dev_name = evas_device_description_get(dev);
1838 seat_dev = evas_device_parent_get(dev);
1839 seat_name = evas_device_name_get(seat_dev);
1841 comp_conf = e_comp_config_get();
1842 if (comp_conf && comp_conf->input_log_enable)
1843 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1844 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1845 dev_name, seat_name);
1847 if (dev && dev_name)
1849 dev_class = evas_device_class_get(dev);
1850 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1851 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1854 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1858 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1860 E_Client *ec = data;
1861 Evas_Event_Multi_Move *ev = event;
1862 Evas_Device *dev = NULL;
1863 const char *dev_name;
1864 Evas_Device_Class dev_class;
1867 if (e_object_is_del(E_OBJECT(ec))) return;
1868 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1869 if (!surface) return;
1871 /* Do not deliver emulated single touch events to client */
1872 if (ev->device == 0) return;
1874 e_comp_wl->touch.faked_ec = ec;
1876 if (e_comp_wl->touch.pressed & (1 << ev->device))
1879 if (dev && (dev_name = evas_device_description_get(dev)))
1881 dev_class = evas_device_class_get(dev);
1882 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1883 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1886 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1891 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1894 char *file, buff[PATH_MAX];
1901 n = (getpriority(PRIO_PROCESS, pid) + adj);
1905 setpriority(PRIO_PROCESS, pid, n);
1908 use_adj = EINA_TRUE;
1910 if (!do_child) return;
1912 files = ecore_file_ls("/proc");
1913 EINA_LIST_FREE(files, file)
1915 if (!isdigit(file[0]))
1918 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1919 if ((f = fopen(buff, "r")))
1923 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1925 if (num_read == 2 && ppid == pid)
1926 _e_comp_wl_client_priority_adjust(pid2, set,
1928 adj_child, do_child);
1936 _e_comp_wl_client_priority_raise(E_Client *ec)
1938 if (!e_config->priority_control) return;
1939 if (ec->netwm.pid <= 0) return;
1940 if (ec->netwm.pid == getpid()) return;
1941 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1942 e_config->priority - 1, -1,
1943 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1947 _e_comp_wl_client_priority_normal(E_Client *ec)
1949 if (!e_config->priority_control) return;
1950 if (ec->netwm.pid <= 0) return;
1951 if (ec->netwm.pid == getpid()) return;
1952 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1953 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1957 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1960 E_Comp_Wl_Key_Data *k;
1961 struct wl_resource *res;
1965 if (!ec) return EINA_FALSE;
1966 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1967 if (!ec->comp_data) return EINA_FALSE;
1969 ec->comp_data->on_focus_timer = NULL;
1970 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1971 if (!e_comp_wl->kbd.focused)
1973 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1976 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1978 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1979 t = ecore_time_unix_get();
1981 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1982 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1983 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1985 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1987 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1988 wl_keyboard_send_key(res, serial, t,
1989 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1992 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1993 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1997 /* It is called in the following cases:
1998 * When a normal ec->frame has focus.
1999 * Or launching image ec is replaced to the real ec.
2002 e_comp_wl_feed_focus_in(E_Client *ec)
2005 struct wl_resource *res;
2006 struct wl_client *wc;
2010 if (e_object_is_del(E_OBJECT(ec))) return;
2011 if (ec->iconic) return;
2013 /* block spurious focus events */
2014 focused = e_client_focused_get();
2015 if ((focused) && (ec != focused)) return;
2017 /* raise client priority */
2018 _e_comp_wl_client_priority_raise(ec);
2019 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2020 if (!surface) return;
2022 wc = wl_resource_get_client(surface);
2024 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2025 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2027 if (wl_resource_get_client(res) == wc)
2029 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2030 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2031 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2032 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2035 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2037 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2038 if (!e_comp_wl->kbd.focused)
2040 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2043 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2045 e_comp_wl->kbd.focus = surface;
2046 e_comp_wl_input_keyboard_enter_send(ec);
2047 e_comp_wl_data_device_keyboard_focus_set();
2048 ec->comp_data->on_focus_timer =
2049 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2050 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2051 int rotation = ec->e.state.rot.ang.curr;
2052 e_pointer_rotation_set(e_comp->pointer, rotation);
2056 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2059 if (!(ec = data)) return;
2060 e_comp_wl_feed_focus_in(ec);
2064 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2067 struct wl_resource *res;
2069 E_Comp_Wl_Key_Data *k;
2073 if (!(ec = data)) return;
2075 if (!ec->comp_data) return;
2077 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2079 /* lower client priority */
2080 if (!e_object_is_del(data))
2081 _e_comp_wl_client_priority_normal(ec);
2084 /* update keyboard modifier state */
2085 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2086 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2087 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2089 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2091 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2092 if (!surface) return;
2094 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2095 if (!eina_list_count(e_comp_wl->kbd.resources))
2097 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2101 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2103 /* send keyboard_leave to all keyboard resources */
2104 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2105 t = ecore_time_unix_get();
2107 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2108 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2109 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2111 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2113 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2114 wl_keyboard_send_key(res, serial, t,
2115 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2117 wl_keyboard_send_leave(res, serial, surface);
2118 e_comp_wl->kbd.focused =
2119 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2121 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2122 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2126 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2130 if (!(ec = data)) return;
2132 if (!ec->comp_data->shell.configure_send) return;
2134 /* TODO: calculate x, y with transfrom object */
2135 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2139 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2140 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2141 if (e_comp_object_frame_exists(ec->frame))
2142 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2144 switch (ec->resize_mode)
2146 case E_POINTER_RESIZE_TL:
2147 case E_POINTER_RESIZE_L:
2148 case E_POINTER_RESIZE_BL:
2149 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2150 ec->mouse.current.mx;
2152 case E_POINTER_RESIZE_TR:
2153 case E_POINTER_RESIZE_R:
2154 case E_POINTER_RESIZE_BR:
2155 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2160 switch (ec->resize_mode)
2162 case E_POINTER_RESIZE_TL:
2163 case E_POINTER_RESIZE_T:
2164 case E_POINTER_RESIZE_TR:
2165 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2166 ec->mouse.current.my;
2168 case E_POINTER_RESIZE_BL:
2169 case E_POINTER_RESIZE_B:
2170 case E_POINTER_RESIZE_BR:
2171 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2176 w = E_CLAMP(w, 1, w);
2177 h = E_CLAMP(h, 1, h);
2178 e_client_resize_limit(ec, &w, &h);
2180 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2182 else if ((!ec->fullscreen) && (!ec->maximized) &&
2183 (!ec->comp_data->maximize_pre))
2187 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2188 if ((pw != ec->w) || (ph != ec->h))
2190 _e_comp_wl_configure_send(ec, 1, 1);
2194 if (ec->comp_data->sub.below_obj)
2195 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2199 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2201 E_Client *ec = data;
2203 ec->comp_data->maximize_pre = 1;
2207 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2209 E_Client *ec = data;
2212 if (e_object_is_del(E_OBJECT(ec))) return;
2214 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2215 e_client_shell_configure_send(ec, 0, w, h);
2217 ec->comp_data->maximize_pre = 0;
2221 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2223 E_Client *ec = data;
2225 ec->comp_data->maximize_pre = 1;
2229 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2231 E_Client *ec = data;
2233 if (e_object_is_del(E_OBJECT(ec))) return;
2235 /* check for wayland pixmap */
2237 if (ec->comp_data->shell.configure_send)
2238 _e_comp_wl_configure_send(ec, 0, 0);
2240 ec->comp_data->maximize_pre = 0;
2244 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2246 E_Client *ec = data;
2248 if (e_object_is_del(E_OBJECT(ec))) return;
2250 /* check for wayland pixmap */
2252 if (ec->comp_data->shell.configure_send)
2253 _e_comp_wl_configure_send(ec, 0, 1);
2255 ec->comp_data->maximize_pre = 0;
2259 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2261 E_Client *ec = data;
2263 if (e_object_is_del(E_OBJECT(ec))) return;
2265 /* check for wayland pixmap */
2267 if (ec->comp_data->shell.configure_send)
2268 _e_comp_wl_configure_send(ec, 0, 0);
2270 ec->comp_data->maximize_pre = 0;
2274 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2278 if (!(ec = data)) return;
2280 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2282 e_object_del(E_OBJECT(ec));
2284 _e_comp_wl_focus_check();
2286 /* TODO: Delete request send ??
2287 * NB: No such animal wrt wayland */
2291 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2295 if (!(ec = data)) return;
2297 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2300 if (ec->comp_data->reparented)
2301 e_client_comp_hidden_set(ec, EINA_TRUE);
2304 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2305 if (ec->visible) evas_object_hide(ec->frame);
2306 if (!ec->internal) e_object_del(E_OBJECT(ec));
2308 _e_comp_wl_focus_check();
2312 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2316 if (!(ec = data)) return;
2318 e_client_shell_ping(ec);
2322 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2327 if (!(ec = data)) return;
2328 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2329 if (ec->netwm.opacity == a) return;
2330 ec->netwm.opacity = a;
2331 ec->netwm.opacity_changed = EINA_TRUE;
2335 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2337 Eina_Rectangle *damage_rect = NULL;
2338 Eina_Rectangle *dmg = NULL;
2339 Eina_List *l = NULL;
2341 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2342 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2345 if (!buffer->tbm_surface) return;
2349 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2353 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2354 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2357 eina_rectangle_union(damage_rect, dmg);
2362 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2363 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2366 tbm_surface_internal_set_damage(buffer->tbm_surface,
2372 eina_rectangle_free(damage_rect);
2376 _e_comp_wl_client_evas_init(E_Client *ec)
2378 if (!ec || !ec->comp_data) return;
2379 if (ec->comp_data->evas_init) return;
2381 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2382 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2383 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2386 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2387 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2388 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2389 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2390 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2391 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2393 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2395 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2397 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2398 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2402 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2403 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2404 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2405 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2406 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2407 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2408 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2411 /* setup delete/kill callbacks */
2412 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2413 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2415 /* setup ping callback */
2416 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2417 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2419 ec->comp_data->evas_init = EINA_TRUE;
2423 _e_comp_wl_client_evas_deinit(E_Client *ec)
2425 if (!ec || !ec->comp_data) return;
2426 if (!ec->comp_data->evas_init) return;
2428 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2429 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2430 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2432 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2433 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2434 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2448 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2449 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2450 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2451 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2452 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2453 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2454 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2457 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2458 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2460 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2461 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2463 ec->comp_data->evas_init = EINA_FALSE;
2467 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2471 E_Comp_Screen *e_comp_screen;
2472 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2474 if (!e_comp) return ECORE_CALLBACK_RENEW;
2475 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2476 e_comp_screen = e_comp->e_comp_screen;
2478 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2480 if (!eout->config.enabled)
2482 e_comp_wl_output_remove(eout->id);
2486 switch (eout->config.rotation)
2489 transform = WL_OUTPUT_TRANSFORM_90;
2492 transform = WL_OUTPUT_TRANSFORM_180;
2495 transform = WL_OUTPUT_TRANSFORM_270;
2499 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2503 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2505 eout->config.geom.x, eout->config.geom.y,
2506 eout->config.geom.w, eout->config.geom.h,
2507 eout->info.size.w, eout->info.size.h,
2508 eout->config.mode.refresh, 0, transform))
2509 ERR("Could not initialize screen %s", eout->info.name);
2512 return ECORE_CALLBACK_RENEW;
2516 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2520 /* try to get the client from the object */
2521 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2522 return ECORE_CALLBACK_RENEW;
2524 /* check for client being deleted */
2525 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2527 /* check for wayland pixmap */
2528 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2529 return ECORE_CALLBACK_RENEW;
2531 /* if we have not setup evas callbacks for this client, do it */
2532 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2534 return ECORE_CALLBACK_RENEW;
2538 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2542 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2543 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2545 if (e_comp_wl->selection.target &&
2548 struct wl_resource *res;
2550 E_Client *ec = NULL;
2551 E_Client *legacy_target = e_comp_wl->selection.target;
2552 int device_id = e_comp_wl_data_current_device_id_get();
2556 e_comp_wl_data_current_device_id_set(ev->multi.device);
2558 else if (device_id != ev->multi.device)
2560 return ECORE_CALLBACK_RENEW;
2563 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2564 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2566 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2567 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2569 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2570 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2572 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2573 (ec != legacy_target))
2575 e_comp_wl_data_device_send_leave(legacy_target);
2576 e_comp_wl_data_device_send_enter(ec);
2579 if (e_comp_wl->drag)
2580 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2582 if (e_client_transform_core_enable_get(ec))
2584 int trans_x, trans_y;
2585 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2586 x = trans_x - ec->client.x;
2587 y = trans_y - ec->client.y;
2591 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2596 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2599 return ECORE_CALLBACK_RENEW;
2603 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2606 struct wl_resource *surface;
2607 struct wl_resource *res;
2608 struct wl_client *wc;
2610 E_Comp_Config *comp_conf;
2612 ec = e_comp_wl->ptr_constraints.ec;
2613 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2615 surface = e_comp_wl_client_surface_get(ec);
2616 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2618 wc = wl_resource_get_client(surface);
2620 comp_conf = e_comp_config_get();
2622 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2624 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2625 if (wl_resource_get_client(res) != wc) continue;
2627 if (comp_conf && comp_conf->input_log_enable)
2628 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2629 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2630 e_client_util_name_get(ec));
2632 zwp_relative_pointer_v1_send_relative_motion(res,
2634 (uint32_t)(ev->timestamp),
2635 wl_fixed_from_int(ev->dx),
2636 wl_fixed_from_int(ev->dy),
2637 wl_fixed_from_int(ev->dx_unaccel),
2638 wl_fixed_from_int(ev->dy_unaccel));
2641 return ECORE_CALLBACK_DONE;
2645 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2647 _e_comp_wl_touch_cancel();
2649 return ECORE_CALLBACK_PASS_ON;
2653 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2655 if (!ev) return ECORE_CALLBACK_PASS_ON;
2657 E_Zone *zone = ev->zone;
2659 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2660 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2662 if (!e_zone_is_displaying(zone))
2663 _e_comp_wl_touch_cancel();
2665 return ECORE_CALLBACK_PASS_ON;
2669 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2671 E_Client *ec = ev->ec;
2672 E_Comp_Wl_Buffer_Viewport *vp;
2674 if (!ec) return ECORE_CALLBACK_PASS_ON;
2675 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2676 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2677 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2678 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2680 vp = &ec->comp_data->scaler.buffer_viewport;
2681 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2683 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2685 return ECORE_CALLBACK_PASS_ON;
2689 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2691 E_Client *ec = ev->ec;
2692 E_Comp_Wl_Buffer_Viewport *vp;
2694 if (!ec) return ECORE_CALLBACK_PASS_ON;
2695 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2696 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2697 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2699 vp = &ec->comp_data->scaler.buffer_viewport;
2700 vp->wait_for_transform_change = 0;
2702 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2704 return ECORE_CALLBACK_PASS_ON;
2708 _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)
2710 E_Client *focused_ec;
2713 focused_ec = e_client_focused_get();
2714 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2716 rotation = focused_ec->e.state.rot.ang.curr;
2717 e_pointer_rotation_set(e_comp->pointer, rotation);
2719 return ECORE_CALLBACK_PASS_ON;
2723 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2726 Eina_Rectangle *window;
2731 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2733 if ((prev_w != state->bw) ||
2734 (prev_h != state->bh))
2736 ec->changes.buf_size = EINA_TRUE;
2739 if (e_comp_object_frame_exists(ec->frame)) return;
2740 window = &ec->comp_data->shell.window;
2741 if ((!ec->borderless) && /* FIXME temporarily added this check code
2742 * to prevent updating E_Client's size by frame */
2743 (window->x || window->y || window->w || window->h))
2745 e_comp_object_frame_geometry_set(ec->frame,
2747 (window->x + window->w) - state->bw,
2749 (window->y + window->h) - state->bh);
2752 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2756 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2758 E_Comp_Wl_Surface_State *state;
2761 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2762 state->buffer = NULL;
2766 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2768 state->new_attach = EINA_FALSE;
2769 state->buffer = NULL;
2770 state->buffer_destroy_listener.notify =
2771 _e_comp_wl_surface_state_cb_buffer_destroy;
2772 state->sx = state->sy = 0;
2774 state->input = eina_tiler_new(w, h);
2775 eina_tiler_tile_size_set(state->input, 1, 1);
2777 state->opaque = eina_tiler_new(w, h);
2778 eina_tiler_tile_size_set(state->opaque, 1, 1);
2780 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2781 state->buffer_viewport.buffer.scale = 1;
2782 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2783 state->buffer_viewport.surface.width = -1;
2784 state->buffer_viewport.changed = 0;
2786 e_presentation_time_container_init(&state->presentation_container);
2790 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2792 struct wl_resource *cb;
2793 Eina_Rectangle *dmg;
2795 EINA_LIST_FREE(state->frames, cb)
2796 wl_resource_destroy(cb);
2798 EINA_LIST_FREE(state->damages, dmg)
2799 eina_rectangle_free(dmg);
2801 EINA_LIST_FREE(state->buffer_damages, dmg)
2802 eina_rectangle_free(dmg);
2804 if (state->opaque) eina_tiler_free(state->opaque);
2805 state->opaque = NULL;
2807 if (state->input) eina_tiler_free(state->input);
2808 state->input = NULL;
2810 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2811 state->buffer = NULL;
2813 e_presentation_time_container_finish(&state->presentation_container);
2817 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2819 if (state->buffer == buffer) return;
2821 wl_list_remove(&state->buffer_destroy_listener.link);
2822 state->buffer = buffer;
2824 wl_signal_add(&state->buffer->destroy_signal,
2825 &state->buffer_destroy_listener);
2829 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2831 Eina_Rectangle *dmg;
2832 Eina_Bool placed = EINA_TRUE;
2836 E_Comp_Wl_Buffer *buffer;
2837 struct wl_resource *cb;
2839 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2840 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2845 if ((ec->internal) ||
2846 (cdata->shell.surface && state->new_attach))
2850 e_comp->new_clients++;
2851 ELOGF("COMP", "Unignore", ec);
2852 e_client_unignore(ec);
2856 /* buffer transform */
2857 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2860 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2862 /* when buffer is transformed, we have to apply the new evas-map */
2863 state->buffer_viewport.changed = EINA_TRUE;
2865 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2867 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2869 if (transform_change == vp->wait_for_transform_change)
2870 vp->wait_for_transform_change = 0;
2872 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2873 // triggered by E_CLIENT_HOOK calls at those file.
2874 zone = e_comp_zone_find_by_ec(ec);
2877 eout = e_output_find(zone->output_id);
2878 if (eout && eout->hwc)
2880 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2882 if (e_comp_is_on_overlay(ec))
2883 e_comp_hwc_client_end(ec, __FUNCTION__);
2889 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2890 cdata->scaler.buffer_viewport = state->buffer_viewport;
2892 if (state->new_attach)
2894 e_comp_wl_surface_attach(ec, state->buffer);
2897 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2898 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2900 _e_comp_wl_surface_state_buffer_set(state, NULL);
2902 if ((state->new_attach) ||
2903 (state->buffer_viewport.changed))
2905 _e_comp_wl_surface_state_size_update(ec, state);
2906 e_comp_wl_map_size_cal_from_viewport(ec);
2908 /* update the position */
2909 if (ec->changes.pos)
2911 e_comp_object_frame_xy_unadjust(ec->frame,
2921 if (ec->new_client) placed = ec->placed;
2923 if (!ec->lock_client_size)
2928 ec->client.w = state->bw;
2929 ec->client.h = state->bh;
2931 e_comp_object_frame_wh_adjust(ec->frame,
2932 ec->client.w, ec->client.h,
2934 e_client_size_set(ec, nw, nh);
2936 if ((w != ec->w) || (h != ec->h))
2938 ec->changes.size = 1;
2943 if (ec->changes.buf_size)
2945 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2946 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2947 ec->changes.buf_size = EINA_FALSE;
2949 if (ec->move_after_resize)
2951 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2952 ec->move_after_resize = EINA_FALSE;
2957 /* map or unmap ec */
2958 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2959 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2960 if (!pixmap_usable || hide_by_request)
2965 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2970 if ((cdata->sub.below_obj) &&
2971 (evas_object_visible_get(cdata->sub.below_obj)))
2973 evas_object_hide(cdata->sub.below_obj);
2981 if ((cdata->sub.below_obj) &&
2982 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2983 (evas_object_visible_get(ec->frame)))
2985 evas_object_show(cdata->sub.below_obj);
2989 if ((state->new_attach) ||
2990 (state->buffer_viewport.changed))
2992 if ((e_comp_wl->drag) &&
2993 (e_comp_wl->drag_client) &&
2994 (e_comp_wl->drag_client == ec))
2996 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2998 e_drag_move(e_comp_wl->drag,
3000 e_comp_wl->drag->y);
3002 e_drag_resize(e_comp_wl->drag,
3003 state->bw, state->bh);
3005 else if ((cdata->shell.surface) &&
3006 (cdata->shell.configure))
3008 e_comp_wl_commit_sync_configure(ec);
3010 else if (!e_client_video_hw_composition_check(ec))
3012 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3017 ec->placed = placed;
3018 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3022 if (cdata->scaler.buffer_viewport.changed)
3023 e_comp_wl_map_apply(ec);
3025 /* resize transform object */
3026 if (ec->transformed)
3027 e_client_transform_update(ec);
3031 state->new_attach = EINA_FALSE;
3033 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3035 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3036 wl_resource_destroy(cb);
3039 /* insert state frame callbacks into comp_data->frames
3040 * NB: This clears state->frames list */
3041 cdata->frames = eina_list_merge(cdata->frames,
3043 state->frames = NULL;
3045 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3046 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3047 &state->presentation_container);
3049 buffer = e_pixmap_resource_get(ec->pixmap);
3051 /* put state damages into surface */
3054 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3055 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3057 if ((cdata->buffer_ref.buffer) &&
3058 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3059 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3061 e_comp_object_damage(ec->frame,
3063 cdata->buffer_ref.buffer->w,
3064 cdata->buffer_ref.buffer->h);
3069 Eina_List *damages = NULL;
3072 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3074 if (eina_list_count(state->buffer_damages))
3076 EINA_LIST_FREE(state->buffer_damages, dmg)
3079 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3080 e_comp_wl_output_buffer_transform_get(ec),
3082 dmg->x, dmg->y, dmg->w, dmg->h,
3083 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3084 damages = eina_list_append(damages, dmg);
3088 EINA_LIST_FREE(state->damages, dmg)
3089 damages = eina_list_append(damages, dmg);
3091 EINA_LIST_FREE(damages, dmg)
3093 /* not creating damage for ec that shows a underlay video */
3094 if (state->buffer_viewport.changed ||
3095 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3096 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3097 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3099 eina_rectangle_free(dmg);
3104 /* put state opaque into surface */
3105 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3108 Eina_Rectangle *rect;
3111 itr = eina_tiler_iterator_new(state->opaque);
3112 EINA_ITERATOR_FOREACH(itr, rect)
3116 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3117 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3118 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3122 eina_iterator_free(itr);
3125 /* put state input into surface */
3126 if ((state->input) &&
3127 (!eina_tiler_empty(state->input)) &&
3130 Eina_Tiler *src, *tmp;
3134 tmp = eina_tiler_new(sw, sh);
3135 eina_tiler_tile_size_set(tmp, 1, 1);
3137 eina_tiler_rect_add(tmp,
3138 &(Eina_Rectangle){0, 0, sw, sh});
3140 if ((src = eina_tiler_intersection(state->input, tmp)))
3142 Eina_Rectangle *rect;
3145 e_comp_object_input_objs_del(ec->frame);
3146 itr = eina_tiler_iterator_new(src);
3147 EINA_ITERATOR_FOREACH(itr, rect)
3149 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3150 ec, rect->x, rect->y, rect->w, rect->h,
3151 ec->w, ec->h, state->bw, state->bh);
3152 e_comp_object_input_area_set(ec->frame,
3157 eina_iterator_free(itr);
3158 eina_tiler_free(src);
3161 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3163 eina_tiler_free(tmp);
3165 /* clear input tiler */
3166 eina_tiler_clear(state->input);
3169 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3171 if ((cdata->video_client) &&
3173 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3174 (e_comp->wl_comp_data->available_hw_accel.underlay))
3176 e_pixmap_image_clear(ec->pixmap, 1);
3179 state->buffer_viewport.changed = 0;
3181 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3184 ec->exp_iconify.buffer_flush &&
3185 e_policy_visibility_client_is_iconic(ec))
3187 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3192 _e_comp_wl_surface_render_stop(E_Client *ec)
3194 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3195 //if ((!ec->internal) && (!e_comp_gl_get()))
3198 /* check if internal animation is running */
3199 if (e_comp_object_is_animating(ec->frame)) return;
3200 /* check if external animation is running */
3201 if (evas_object_data_get(ec->frame, "effect_running")) return;
3203 evas_object_hide(ec->frame);
3207 e_comp_wl_client_surface_finish(E_Client *ec)
3209 struct wl_resource *res, *surface;
3210 struct wl_client *surface_client = NULL;
3213 surface = e_comp_wl_client_surface_get(ec);
3216 surface_client = wl_resource_get_client(surface);
3218 if (surface_client &&
3219 (ec == e_client_focused_get()))
3221 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3222 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3224 if (wl_resource_get_client(res) ==
3226 e_comp_wl->kbd.focused =
3227 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3231 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3234 e_comp_wl_client_surface_set(ec, NULL);
3236 ec->comp_data->wl_surface = NULL;
3237 e_pixmap_win_id_del(ec->pixmap);
3239 _e_comp_wl_surface_render_stop(ec);
3240 e_object_del(E_OBJECT(ec));
3244 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3249 char proc[512], pname[512];
3252 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3254 h = fopen(proc, "r");
3257 len = fread(pname, sizeof(char), 512, h);
3259 pname[len - 1] = '\0';
3261 strncpy(pname, "NO NAME", sizeof(pname));
3267 strncpy(pname, "NO NAME", sizeof(pname));
3270 strncpy(name, pname, size);
3274 _e_comp_wl_pname_print(pid_t pid)
3277 char proc[512], pname[512];
3280 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3282 h = fopen(proc, "r");
3285 len = fread(pname, sizeof(char), 512, h);
3287 pname[len - 1] = '\0';
3289 strncpy(pname, "NO NAME", sizeof(pname));
3293 ELOGF("COMP", " |%s", NULL, pname);
3298 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3300 struct wl_client *client = data;
3301 E_Comp_Connected_Client_Info *cinfo;
3304 cinfo = wl_container_of(listener, cinfo, destroy);
3306 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3307 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3309 eai = e_appinfo_find_with_pid(cinfo->pid);
3310 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3313 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3315 wl_list_remove(&cinfo->destroy.link);
3316 eina_stringshare_del(cinfo->name);
3321 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3323 E_Comp_Connected_Client_Info *cinfo;
3325 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3326 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3328 cinfo->name = eina_stringshare_add(name);
3332 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3333 wl_client_add_destroy_listener(client, &cinfo->destroy);
3334 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3336 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3340 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3342 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3344 /* send configure */
3345 if (ec->comp_data->shell.configure_send)
3347 if (ec->comp_data->shell.surface)
3348 _e_comp_wl_configure_send(ec, 0, 0);
3351 e_comp_wl->kbd.focus = ec->comp_data->surface;
3355 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3357 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3359 /* send configure */
3360 if (ec->comp_data->shell.configure_send)
3362 if (ec->comp_data->shell.surface)
3363 _e_comp_wl_configure_send(ec, 0, 0);
3366 _e_comp_wl_focus_check();
3368 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3369 e_comp_wl->kbd.focus = NULL;
3373 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3375 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3376 if (ec->keyboard_resizing) return;
3378 /* do nothing currently */
3383 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3385 if (e_object_is_del(E_OBJECT(ec))) return;
3386 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3388 e_comp_wl->resize.edges = 0;
3389 e_comp_wl->resize.resource = NULL;
3393 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3395 if (e_object_is_del(E_OBJECT(ec))) return;
3396 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3400 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3403 int ratio_w, ratio_h;
3405 phys_w = output->phys_width;
3406 phys_h = output->phys_height;
3408 if (e_config->configured_output_resolution.use)
3410 // change the configured physical size(mm) of the output
3411 if (output->w != res_w)
3413 ratio_w = res_w / output->w;
3414 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3417 if (output->h != res_h)
3419 ratio_h = res_h / output->h;
3420 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3423 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3426 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3427 NULL, res_w, res_h, phys_w, phys_h, pid);
3429 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3430 wl_output_send_scale(resource, output->scale);
3432 wl_output_send_geometry(resource, output->x, output->y,
3434 output->subpixel, output->make ?: "",
3435 output->model ?: "", output->transform);
3437 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3438 res_w, res_h, output->refresh);
3440 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3441 wl_output_send_done(resource);
3445 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3447 E_Comp_Wl_Output *output;
3449 if (!(output = wl_resource_get_user_data(resource))) return;
3451 output->resources = eina_list_remove(output->resources, resource);
3455 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3457 E_Comp_Wl_Output *output;
3458 struct wl_resource *resource;
3459 E_Appinfo *eai = NULL;
3463 if (!(output = data)) return;
3466 wl_resource_create(client, &wl_output_interface, version, id);
3469 wl_client_post_no_memory(client);
3473 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3474 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3476 output->resources = eina_list_append(output->resources, resource);
3478 wl_resource_set_implementation(resource, NULL, output,
3479 _e_comp_wl_cb_output_unbind);
3480 wl_resource_set_user_data(resource, output);
3482 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3483 if (e_config->configured_output_resolution.use)
3485 wl_client_get_credentials(client, &pid, NULL, NULL);
3488 res_w = e_config->configured_output_resolution.w;
3489 res_h = e_config->configured_output_resolution.h;
3493 eai = e_appinfo_find_with_pid(pid);
3496 res_w = e_config->configured_output_resolution.w;
3497 res_h = e_config->configured_output_resolution.h;
3501 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3503 res_w = e_config->configured_output_resolution.w;
3504 res_h = e_config->configured_output_resolution.h;
3508 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3517 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3521 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3524 Evas_GL *evasgl = NULL;
3525 Evas_GL_API *glapi = NULL;
3526 Evas_GL_Context *ctx = NULL;
3527 Evas_GL_Surface *sfc = NULL;
3528 Evas_GL_Config *cfg = NULL;
3530 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3532 if (!e_comp_gl_get()) return;
3534 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3535 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3537 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3538 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3540 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3541 * then we should get evas from ecore_evas.
3544 evas = e_comp->evas;
3546 evas = ecore_evas_get(e_comp->ee);
3548 evasgl = evas_gl_new(evas);
3549 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3551 glapi = evas_gl_api_get(evasgl);
3552 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3553 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3555 cfg = evas_gl_config_new();
3556 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3558 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3559 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3561 ctx = evas_gl_context_create(evasgl, NULL);
3562 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3564 res = evas_gl_make_current(evasgl, sfc, ctx);
3565 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3567 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3568 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3570 evas_gl_config_free(cfg);
3572 evas_gl->gl = evasgl;
3573 evas_gl->glapi = glapi;
3574 evas_gl->glsfc = sfc;
3575 evas_gl->glctx = ctx;
3577 e_comp_wl->evas_gl = evas_gl;
3579 /* for native surface */
3582 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3587 evas_gl_config_free(cfg);
3588 evas_gl_make_current(evasgl, NULL, NULL);
3589 evas_gl_context_destroy(evasgl, ctx);
3590 evas_gl_surface_destroy(evasgl, sfc);
3591 evas_gl_free(evasgl);
3598 _e_comp_wl_gl_popup_cb_close(void *data,
3599 Evas_Object *obj EINA_UNUSED,
3600 void *event_info EINA_UNUSED)
3602 evas_object_del(data);
3606 _e_comp_wl_gl_popup_cb_focus(void *data,
3607 Evas_Object *obj EINA_UNUSED,
3608 void *event_info EINA_UNUSED)
3610 elm_object_focus_set(data, EINA_TRUE);
3615 _e_comp_wl_gl_idle(void *data)
3619 /* show warning window to notify failure of gl init */
3622 Evas_Object *win, *bg, *popup, *btn;
3624 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3625 elm_win_title_set(win, "Compositor Warning");
3626 elm_win_autodel_set(win, EINA_TRUE);
3627 elm_win_borderless_set(win, EINA_TRUE);
3628 elm_win_role_set(win, "notification-low");
3629 elm_win_alpha_set(win, EINA_TRUE);
3631 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3632 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3633 elm_win_resize_object_add(win, bg);
3634 evas_object_color_set(bg, 125, 125, 125, 125);
3635 evas_object_show(bg);
3637 popup = elm_popup_add(win);
3638 elm_object_text_set(popup,
3639 _( "Your screen does not support OpenGL.<br>"
3640 "Falling back to software engine."));
3641 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3643 btn = elm_button_add(popup);
3644 elm_object_text_set(btn, "Close");
3645 elm_object_part_content_set(popup, "button1", btn);
3646 evas_object_show(btn);
3648 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3649 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3651 evas_object_show(popup);
3652 evas_object_show(win);
3656 return ECORE_CALLBACK_CANCEL;
3660 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3662 struct wl_client *client = data;
3668 wl_client_get_credentials(client, &pid, &uid, &gid);
3670 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3672 _e_comp_wl_pname_print(pid);
3673 _e_comp_wl_pname_get(pid, name, sizeof(name));
3674 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3678 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3680 char buf[1024] = {0, };
3682 vsnprintf(buf, 1024, fmt, args);
3686 DBG("[libds] %s", buf);
3689 INF("[libds] %s", buf);
3692 ERR("[libds] %s", buf);
3700 _e_comp_wl_display_create(void)
3703 E_Comp_Wl_Data *wl_cdata;
3708 /* create new compositor data */
3709 if (!(comp = E_NEW(E_Comp_Data, 1)))
3711 ERR("Could not create compositor data: %m");
3714 wl_cdata = &comp->base;
3716 /* set compositor wayland data */
3717 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3719 g_mutex_init(&connection_mutex);
3721 /* try to create a wayland display */
3722 if (!(wl_cdata->wl.disp = wl_display_create()))
3724 ERR("Could not create a Wayland display: %m");
3728 /* try to setup wayland socket */
3729 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3731 ERR("Could not create Wayland display socket: %m");
3732 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3736 res = e_comp_socket_init(name);
3737 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3738 PRCTL("[Winsys] change permission and create sym link for %s", name);
3740 /* set wayland display environment variable */
3741 e_env_set("WAYLAND_DISPLAY", name);
3743 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3744 /* wl_cdata->output.scale = e_scale; */
3746 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3748 if (!e_compositor_init(wl_cdata->wl.disp))
3750 ERR("Failed to initialize compositor");
3754 comp->client_created.notify = _e_comp_wl_cb_client_created;
3755 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3757 if (!e_comp_wl_subsurfaces_init())
3759 ERR("Failed to init_subsurfaces");
3760 goto subsurfaces_err;
3763 /* initialize shm mechanism */
3764 wl_display_init_shm(wl_cdata->wl.disp);
3766 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3768 /* try to init data manager */
3769 if (!e_comp_wl_data_manager_init())
3771 ERR("Could not initialize data manager");
3775 /* try to init input */
3776 if (!e_comp_wl_input_init())
3778 ERR("Could not initialize input");
3782 if (e_comp_gl_get())
3783 _e_comp_wl_gl_init(NULL);
3785 /* get the wayland display loop */
3786 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3788 /* get the file descriptor of the wayland event loop */
3789 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3791 /* create a listener for wayland main loop events */
3793 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3794 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3795 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3796 _e_comp_wl_cb_prepare, wl_cdata);
3801 e_comp_wl_data_manager_shutdown();
3803 e_comp_wl_subsurfaces_shutdown();
3805 wl_list_remove(&comp->client_created.link);
3807 e_env_unset("WAYLAND_DISPLAY");
3809 wl_display_destroy(wl_cdata->wl.disp);
3811 g_mutex_clear(&connection_mutex);
3817 _e_comp_wl_gl_shutdown(void)
3819 if (!e_comp_wl->evas_gl) return;
3821 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3823 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3824 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3825 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3826 evas_gl_free(e_comp_wl->evas_gl->gl);
3828 E_FREE(e_comp_wl->evas_gl);
3831 /* public functions */
3834 * Creates and initializes a Wayland compositor with ecore.
3835 * Registers callback handlers for keyboard and mouse activity
3836 * and other client events.
3838 * @returns true on success, false if initialization failed.
3841 e_comp_wl_init(void)
3843 TRACE_DS_BEGIN(COMP_WL:INIT);
3845 /* try to create a wayland compositor */
3846 if (!_e_comp_wl_display_create())
3848 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3853 e_comp_wl_shell_init();
3855 #ifdef HAVE_WAYLAND_TBM
3856 e_comp_wl_tbm_init();
3858 e_comp_wl_remote_surface_init();
3862 e_comp_wl_screenshooter_init();
3864 if (!e_comp_wl_video_init())
3865 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3867 e_comp_wl_viewport_init();
3868 e_comp_wl_capture_init();
3869 e_comp_wl_renderer_init();
3870 _e_comp_wl_move_resize_init();
3871 e_presentation_time_init();
3872 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3875 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3876 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3878 /* add event handlers to catch E events */
3879 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3880 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3881 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3882 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3883 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3884 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3885 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3886 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3887 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3889 /* add hooks to catch e_client events */
3890 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3891 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3892 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3893 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3894 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3896 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3903 e_comp_wl_deferred_job(void)
3905 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3908 /* internal functions */
3910 e_comp_wl_shutdown(void)
3912 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3914 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3916 e_comp_wl_subsurfaces_shutdown();
3918 E_FREE_LIST(handlers, ecore_event_handler_del);
3919 E_FREE_LIST(hooks, e_client_hook_del);
3920 _e_comp_wl_gl_shutdown();
3922 e_blender_shutdown();
3923 e_presentation_time_shutdown();
3924 e_comp_wl_renderer_shutdown();
3925 e_comp_wl_capture_shutdown();
3926 e_comp_wl_viewport_shutdown();
3927 e_comp_wl_video_shutdown();
3928 e_comp_wl_screenshooter_shutdown();
3930 e_comp_wl_remote_surface_shutdown();
3932 e_pixmap_shutdown();
3934 e_wtz_shell_shutdown();
3935 e_comp_wl_shell_shutdown();
3936 e_comp_wl_input_shutdown();
3938 wl_list_remove(&comp->client_created.link);
3941 e_comp->wl_comp_data = NULL;
3945 E_Comp_Wl_Output *output;
3947 if (e_comp_wl->screenshooter.global)
3948 wl_global_destroy(e_comp_wl->screenshooter.global);
3950 EINA_LIST_FREE(e_comp_wl->outputs, output)
3952 if (output->id) eina_stringshare_del(output->id);
3953 if (output->make) eina_stringshare_del(output->make);
3954 if (output->model) eina_stringshare_del(output->model);
3958 /* delete fd handler */
3959 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3961 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3962 cursor_timer_ec = NULL;
3964 /* free allocated data structure */
3970 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3972 e_object_unref(E_OBJECT(ev->ec));
3977 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3980 ev = E_NEW(E_Event_Client, 1);
3983 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3985 /* set usable early because shell module checks this */
3986 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3987 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3989 e_pixmap_resource_set(ec->pixmap, buffer);
3990 e_pixmap_dirty(ec->pixmap);
3991 e_pixmap_refresh(ec->pixmap);
3993 e_comp_wl_map_size_cal_from_buffer(ec);
3994 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3996 /* wm-policy module uses it */
3997 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4000 e_object_ref(E_OBJECT(ec));
4001 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4002 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4006 e_comp_wl_surface_commit(E_Client *ec)
4011 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4012 if (!e_comp_object_damage_exists(ec->frame))
4014 if ((ec->comp_data->video_client) ||
4015 (!e_client_video_hw_composition_check(ec)))
4016 e_pixmap_image_clear(ec->pixmap, 1);
4019 ignored = ec->ignored;
4021 if (e_comp_wl_subsurface_order_commit(ec))
4023 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4024 e_comp_wl_subsurface_restack(topmost);
4025 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4028 ec->ignored = ignored;
4030 if (ec->is_cursor && ec->visible)
4032 /* ignore cursor changes during resize/move I guess */
4033 if (!e_client_action_get())
4035 if (e_comp->pointer)
4037 x = e_comp->pointer->hot.x;
4038 y = e_comp->pointer->hot.y;
4040 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4046 static E_Comp_Wl_Output *
4047 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4050 E_Comp_Wl_Output *output;
4052 EINA_LIST_FOREACH(outputs, l, output)
4054 if (!strcmp(output->id, id))
4062 * Initializes information about one display output.
4064 * Adds or updates the given data about a single display output,
4065 * with an id matching the provided id.
4067 * @param id identification of output to be added or changed
4068 * @param make manufacturer name of the display output
4069 * @param model model name of the display output
4070 * @param x output's top left corner x coordinate
4071 * @param y output's top left corner y coordinate
4072 * @param w output's width in pixels
4073 * @param h output's height in pixels
4074 * @param pw output's physical width in millimeters
4075 * @param ph output's physical height in millimeters
4076 * @param refresh output's refresh rate in mHz
4077 * @param subpixel output's subpixel layout
4078 * @param transform output's rotation and/or mirror transformation
4080 * @returns True if a display output object could be added or updated
4083 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4084 int x, int y, int w, int h, int pw, int ph,
4085 unsigned int refresh, unsigned int subpixel,
4086 unsigned int transform)
4088 E_Comp_Wl_Output *output;
4090 struct wl_resource *resource;
4092 /* retrieve named output; or create it if it doesn't exist */
4093 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4096 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4098 if (id) output->id = eina_stringshare_add(id);
4100 output->make = eina_stringshare_add(make);
4102 output->make = eina_stringshare_add("unknown");
4104 output->model = eina_stringshare_add(model);
4106 output->model = eina_stringshare_add("unknown");
4108 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4111 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4112 2, output, _e_comp_wl_cb_output_bind);
4114 output->resources = NULL;
4115 output->scale = e_scale;
4118 /* update the output details */
4123 output->phys_width = pw;
4124 output->phys_height = ph;
4125 output->refresh = refresh;
4126 output->subpixel = subpixel;
4127 output->transform = transform;
4129 if (output->scale <= 0)
4130 output->scale = e_scale;
4132 /* if we have bound resources, send updates */
4133 EINA_LIST_FOREACH(output->resources, l2, resource)
4135 wl_output_send_geometry(resource,
4136 output->x, output->y,
4138 output->phys_height,
4140 output->make ?: "", output->model ?: "",
4143 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4144 wl_output_send_scale(resource, output->scale);
4146 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4147 output->w, output->h, output->refresh);
4149 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4150 wl_output_send_done(resource);
4157 e_comp_wl_output_remove(const char *id)
4159 E_Comp_Wl_Output *output;
4161 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4164 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4166 /* wl_global_destroy(output->global); */
4168 /* eina_stringshare_del(output->id); */
4169 /* eina_stringshare_del(output->make); */
4170 /* eina_stringshare_del(output->model); */
4177 _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)
4179 struct wl_resource *res;
4181 uint32_t serial, keycode;
4182 struct wl_client *wc = NULL;
4183 E_Comp_Config *comp_conf = NULL;
4184 const char *device_name = NULL;
4186 keycode = (ev->keycode - 8);
4188 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4190 comp_conf = e_comp_config_get();
4192 if (ec && ec->comp_data)
4194 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4197 wc = wl_resource_get_client(surface);
4200 if (e_config->key_input_ttrace_enable)
4202 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4203 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4206 EINA_LIST_FOREACH(key_list, l, res)
4208 if (wl_resource_get_client(res) != wc) continue;
4210 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4211 if (!e_input_thread_mode_get())
4213 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4214 device_name = ecore_device_name_get(ev->dev);
4220 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4221 device_name = e_device_name_get(dev);
4225 if (comp_conf && comp_conf->input_log_enable)
4226 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4228 wl_keyboard_send_key(res, serial, ev->timestamp,
4233 if (e_config->key_input_ttrace_enable)
4236 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4241 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4243 E_Client *ec = NULL;
4245 E_Comp_Wl_Key_Data *end, *k;
4247 if (ev->window != e_comp->ee_win)
4252 keycode = (ev->keycode - 8);
4253 if (!(e_comp_wl = e_comp->wl_comp_data))
4258 #ifndef E_RELEASE_BUILD
4259 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4260 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4261 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4262 eina_streq(ev->key, "BackSpace"))
4268 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4270 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4272 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4274 /* ignore server-generated key repeats */
4275 if (k->key == keycode)
4277 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4282 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4284 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4286 ec = e_client_focused_get();
4287 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4288 if (ec && ec->comp_data && surface)
4290 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4291 if (e_comp_wl->kbd.focused)
4293 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4295 /* A key only sent to clients is added to the list */
4296 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4297 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4299 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4301 DBG("wl_array_add: Out of memory\n");
4302 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4303 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4306 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4310 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4314 /* update modifier state */
4315 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4321 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4323 E_Client *ec = NULL;
4324 uint32_t keycode, delivered_key;
4325 E_Comp_Wl_Key_Data *end, *k;
4327 if (ev->window != e_comp->ee_win)
4332 keycode = (ev->keycode - 8);
4334 if (!(e_comp_wl = e_comp->wl_comp_data))
4339 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4341 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4342 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4344 if (k->key == keycode)
4351 e_comp_wl->kbd.keys.size =
4352 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4354 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4356 /* 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) */
4357 if ((delivered_key) ||
4358 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4360 ec = e_client_focused_get();
4362 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4363 if (e_comp_wl->kbd.focused)
4365 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4367 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4370 /* update modifier state */
4371 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4377 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4379 Eina_Bool res = EINA_FALSE;
4381 if (type == ECORE_EVENT_KEY_DOWN)
4383 res = e_comp_wl_key_down(ev, dev);
4385 else if (type == ECORE_EVENT_KEY_UP)
4387 res = e_comp_wl_key_up(ev, dev);
4394 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4397 struct wl_client *wc;
4398 uint32_t serial, btn;
4399 struct wl_resource *res;
4400 E_Comp_Config *comp_conf = NULL;
4402 if (ec->cur_mouse_action || e_comp_wl->drag)
4404 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4405 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4409 case 1: btn = BTN_LEFT; break;
4410 case 2: btn = BTN_MIDDLE; break;
4411 case 3: btn = BTN_RIGHT; break;
4412 default: btn = button_id; break;
4415 e_comp_wl->ptr.button = btn;
4416 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4417 if (!surface) return EINA_FALSE;
4419 if (!eina_list_count(e_comp_wl->ptr.resources))
4422 wc = wl_resource_get_client(surface);
4423 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4425 comp_conf = e_comp_config_get();
4427 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4429 if (wl_resource_get_client(res) != wc) continue;
4430 if (!e_comp_wl_input_pointer_check(res)) continue;
4431 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4433 if (comp_conf && comp_conf->input_log_enable)
4434 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4436 wl_pointer_send_button(res, serial, timestamp, btn, state);
4443 e_comp_wl_touch_cancel(void)
4445 _e_comp_wl_touch_cancel();
4448 E_API E_Comp_Wl_Hook *
4449 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4453 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4454 ch = E_NEW(E_Comp_Wl_Hook, 1);
4455 if (!ch) return NULL;
4456 ch->hookpoint = hookpoint;
4458 ch->data = (void*)data;
4459 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4464 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4467 if (_e_comp_wl_hooks_walking == 0)
4469 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4473 _e_comp_wl_hooks_delete++;
4476 E_API E_Comp_Wl_Pid_Hook *
4477 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4479 E_Comp_Wl_Pid_Hook *ch;
4481 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4483 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4484 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4486 ch->hookpoint = hookpoint;
4488 ch->data = (void*)data;
4489 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4495 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4498 if (_e_comp_wl_pid_hooks_walking == 0)
4500 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4504 _e_comp_wl_pid_hooks_delete++;
4507 E_API E_Comp_Wl_Intercept_Hook *
4508 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4510 E_Comp_Wl_Intercept_Hook *ch;
4512 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4513 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4514 if (!ch) return NULL;
4515 ch->hookpoint = hookpoint;
4517 ch->data = (void*)data;
4518 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4523 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4526 if (_e_comp_wl_intercept_hooks_walking == 0)
4528 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4532 _e_comp_wl_intercept_hooks_delete++;
4536 e_comp_wl_shell_surface_ready(E_Client *ec)
4540 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4544 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4546 e_config->use_cursor_timer = !!enabled;
4548 if (e_config->use_cursor_timer)
4550 if (!e_pointer_is_hidden(e_comp->pointer))
4552 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4557 if (e_comp_wl->ptr.hide_tmr)
4559 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4560 e_comp_wl->ptr.hide_tmr = NULL;
4562 cursor_timer_ec = NULL;
4564 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4567 if (e_pointer_is_hidden(e_comp->pointer))
4569 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4575 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4577 EINA_SAFETY_ON_NULL_RETURN(wc);
4578 EINA_SAFETY_ON_NULL_RETURN(dev);
4580 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4584 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4586 EINA_SAFETY_ON_NULL_RETURN(wc);
4587 EINA_SAFETY_ON_NULL_RETURN(dev);
4589 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4593 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4595 struct wl_resource *res;
4596 struct wl_client *wc;
4598 uint32_t serial, wl_keycode;
4599 enum wl_keyboard_key_state state;
4600 E_Comp_Config *comp_conf = NULL;
4601 const char *dev_name = NULL;
4603 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4604 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4605 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4607 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4608 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4610 wl_keycode = keycode - 8;
4611 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4613 wc = wl_resource_get_client(surface);
4614 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4615 if (!time) time = e_util_timestamp_get();
4616 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4617 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4619 comp_conf = e_comp_config_get();
4620 e_keyrouter_event_surface_send(ec, keycode);
4622 if (e_config->key_input_ttrace_enable)
4624 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4625 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4628 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4629 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4631 if (wl_resource_get_client(res) != wc) continue;
4632 if (!e_input_thread_mode_get())
4636 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4637 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4641 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4648 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4649 dev_name = e_device_name_get(dev);
4653 if (comp_conf && comp_conf->input_log_enable)
4654 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4657 wl_keyboard_send_key(res, serial, time,
4660 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4662 if (e_config->key_input_ttrace_enable)
4665 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4672 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4674 struct wl_resource *res;
4675 struct wl_client *wc;
4677 uint32_t serial, wl_keycode, cancel_keycode;
4678 E_Comp_Config *comp_conf = NULL;
4679 struct xkb_keymap *keymap = NULL;
4681 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4682 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4683 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4685 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4686 keymap = e_comp_wl->xkb.keymap;
4687 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4688 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4690 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4691 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4693 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4694 if (cancel_keycode == XKB_KEYCODE_INVALID)
4696 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4699 cancel_keycode = cancel_keycode - 8;
4701 wl_keycode = keycode - 8;
4702 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4704 wc = wl_resource_get_client(surface);
4705 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4706 if (!time) time = e_util_timestamp_get();
4708 comp_conf = e_comp_config_get();
4709 e_keyrouter_event_surface_send(ec, keycode);
4711 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4712 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4714 if (wl_resource_get_client(res) != wc) continue;
4715 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4716 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4718 if (comp_conf && comp_conf->input_log_enable)
4719 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4720 wl_keyboard_send_key(res, serial, time,
4721 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4722 wl_keyboard_send_key(res, serial, time,
4723 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4724 wl_keyboard_send_key(res, serial, time,
4725 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4727 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4734 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)
4736 struct wl_client *wc;
4738 E_Devicemgr_Input_Device *device = NULL;
4740 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4741 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4742 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4744 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4745 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4747 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4749 wc = wl_resource_get_client(surface);
4750 if (!time) time = e_util_timestamp_get();
4751 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4755 _e_comp_wl_send_event_device(wc, time, dev, serial);
4756 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4760 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4761 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4764 x = x + ec->client.x;
4765 y = y + ec->client.y;
4767 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4773 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)
4775 E_Devicemgr_Input_Device *device;
4777 struct wl_client *wc;
4779 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4781 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4783 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4784 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4786 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4788 wc = wl_resource_get_client(surface);
4789 if (!time) time = e_util_timestamp_get();
4790 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4794 _e_comp_wl_send_event_device(wc, time, dev, serial);
4795 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4799 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4800 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4803 x = x + ec->client.x;
4804 y = y + ec->client.y;
4806 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4812 e_comp_wl_touch_cancel_send(E_Client *ec)
4814 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4815 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4816 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4818 _e_comp_wl_send_touch_cancel(ec);
4824 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4827 struct wl_client *wc;
4829 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4831 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4833 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4834 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4836 wc = wl_resource_get_client(surface);
4837 if (!time) time = e_util_timestamp_get();
4838 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4840 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4841 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4844 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4845 WL_POINTER_BUTTON_STATE_PRESSED);
4847 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4848 WL_POINTER_BUTTON_STATE_RELEASED);
4854 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4857 struct wl_client *wc;
4859 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4860 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4861 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4863 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4864 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4866 wc = wl_resource_get_client(surface);
4867 if (!time) time = e_util_timestamp_get();
4868 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4870 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4871 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4873 x = x + ec->client.x;
4874 y = y + ec->client.y;
4876 _e_comp_wl_send_mouse_move(ec, x, y, time);
4882 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4885 struct wl_client *wc;
4887 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4888 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4889 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4891 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4892 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4894 wc = wl_resource_get_client(surface);
4895 if (!time) time = e_util_timestamp_get();
4896 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4898 if (_e_comp_wl_check_cursor_timer_needed(ec))
4900 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4904 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4905 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4907 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4909 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4911 if (_e_comp_wl_check_cursor_timer_needed(ec))
4912 _e_comp_wl_cursor_move_timer_control(ec);
4919 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4922 struct wl_client *wc;
4923 struct wl_resource *res;
4926 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4927 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4929 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4930 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4932 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4933 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4935 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4936 wc = wl_resource_get_client(surface);
4937 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4938 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4940 if (!e_comp_wl_input_pointer_check(res)) continue;
4941 if (wl_resource_get_client(res) != wc) continue;
4943 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4944 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4946 wl_pointer_send_enter(res, serial, surface,
4947 wl_fixed_from_int(x),
4948 wl_fixed_from_int(y));
4949 ec->pointer_enter_sent = EINA_TRUE;
4951 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4957 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4960 struct wl_client *wc;
4961 struct wl_resource *res;
4964 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4965 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4966 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4967 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4968 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4969 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4971 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4972 wc = wl_resource_get_client(surface);
4973 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4974 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4976 if (!e_comp_wl_input_pointer_check(res)) continue;
4977 if (wl_resource_get_client(res) != wc) continue;
4979 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4980 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4982 wl_pointer_send_leave(res, serial, surface);
4983 ec->pointer_enter_sent = EINA_FALSE;
4990 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)
4992 Evas_Event_Mouse_In ev_in;
4995 if (ec->pointer_enter_sent) return;
4997 ev_in.buttons = buttons;
5005 ev_in.modifiers = modifiers;
5006 ev_in.locks = locks;
5007 ev_in.timestamp = timestamp;
5008 ev_in.event_flags = event_flags;
5011 ev_in.event_src = event_src;
5013 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5017 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)
5019 Evas_Event_Mouse_Out ev_out;
5022 if (!ec->pointer_enter_sent) return;
5024 ev_out.buttons = buttons;
5026 ev_out.output.x = x;
5027 ev_out.output.y = y;
5028 ev_out.canvas.x = x;
5029 ev_out.canvas.y = y;
5032 ev_out.modifiers = modifiers;
5033 ev_out.locks = locks;
5034 ev_out.timestamp = timestamp;
5035 ev_out.event_flags = event_flags;
5038 ev_out.event_src = event_src;
5040 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5044 e_comp_wl_cursor_hide(E_Client *ec)
5046 struct wl_resource *res;
5047 struct wl_client *wc;
5051 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5053 if (e_comp_wl->ptr.hide_tmr)
5055 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5056 e_comp_wl->ptr.hide_tmr = NULL;
5058 cursor_timer_ec = NULL;
5060 if (!ec) return EINA_FALSE;
5061 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5062 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5063 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5065 wc = wl_resource_get_client(surface);
5066 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5067 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5069 if (!e_comp_wl_input_pointer_check(res)) continue;
5070 if (wl_resource_get_client(res) != wc) continue;
5071 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5072 wl_pointer_send_leave(res, serial, surface);
5073 ec->pointer_enter_sent = EINA_FALSE;
5079 /* surface to buffer
5080 * - width : surface width
5081 * - height : surface height
5082 * - transform: buffer transform
5083 * - scale : buffer scale
5085 * - width : screen width
5086 * - height : screen height
5087 * - transform: output transform
5088 * - scale : output scale
5090 static E_Util_Transform_Matrix
5091 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5093 E_Util_Transform_Matrix m;
5095 e_util_transform_matrix_load_identity(&m);
5097 if (transform & 0x4)
5099 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5100 e_util_transform_matrix_flip_x(&m);
5101 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5104 switch (transform & 0x3)
5106 case WL_OUTPUT_TRANSFORM_90:
5107 e_util_transform_matrix_translate(&m, -width, 0, 0);
5108 e_util_transform_matrix_rotation_z(&m, 270);
5110 case WL_OUTPUT_TRANSFORM_180:
5111 e_util_transform_matrix_translate(&m, -width, -height, 0);
5112 e_util_transform_matrix_rotation_z(&m, 180);
5114 case WL_OUTPUT_TRANSFORM_270:
5115 e_util_transform_matrix_translate(&m, 0, -height, 0);
5116 e_util_transform_matrix_rotation_z(&m, 90);
5122 e_util_transform_matrix_scale(&m, scale, scale, 1);
5127 /* surface to buffer
5128 * - surface width, surface height, buffer transform, buffer scale
5130 * - screen width, screen height, output transform, output scale
5133 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5135 E_Util_Transform_Matrix m;
5136 E_Util_Transform_Vertex v;
5138 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5140 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5141 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5142 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5146 * - buffer width, buffer height, buffer transform, buffer scale
5149 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5151 E_Util_Transform_Matrix m;
5152 E_Util_Transform_Vertex v;
5155 if (transform != 0 || scale > 1)
5157 tw = ((transform % 2) ? height : width) / scale;
5158 th = ((transform % 2) ? width : height) / scale;
5166 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5167 m = e_util_transform_matrix_inverse_get(&m);
5169 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5170 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5171 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5174 /* surface to buffer
5175 * - surface width, surface height, buffer transform, buffer scale
5177 * - screen width, screen height, output transform, output scale
5180 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5181 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5183 E_Util_Transform_Matrix m;
5184 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5185 E_Util_Transform_Rect_Vertex sv;
5187 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5189 sv = e_util_transform_rect_to_vertices(&sr);
5190 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5191 sr = e_util_transform_vertices_to_rect(&sv);
5200 * - buffer width, buffer height, buffer transform, buffer scale
5203 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5204 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5206 E_Util_Transform_Matrix m;
5207 E_Util_Transform_Rect br = {bx, by, bw, bh};
5208 E_Util_Transform_Rect_Vertex bv;
5211 if (transform != 0 || scale > 1)
5213 tw = ((transform % 2) ? height : width) / scale;
5214 th = ((transform % 2) ? width : height) / scale;
5222 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5223 m = e_util_transform_matrix_inverse_get(&m);
5225 bv = e_util_transform_rect_to_vertices(&br);
5226 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5227 br = e_util_transform_vertices_to_rect(&bv);
5235 EINTERN E_Comp_Wl_Output*
5236 e_comp_wl_output_find(E_Client *ec)
5239 E_Comp_Wl_Output *output;
5241 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5243 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5245 if (output->transform % 2)
5247 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5248 ec->y < output->x || ec->y >= (output->x + output->w))
5253 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5254 ec->y < output->y || ec->y >= (output->y + output->h))
5264 EINTERN Eina_Array *
5265 e_comp_wl_output_find_all(E_Client *ec)
5267 E_Comp_Wl_Output *output;
5268 Eina_Array *outputs;
5271 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5273 outputs = eina_array_new(4);
5277 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5279 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5280 output->x, output->y, output->w, output->h))
5282 eina_array_push(outputs, output);
5286 if (eina_array_count(outputs) == 0)
5288 eina_array_free(outputs);
5295 // --------------------------------------------------------
5296 // tizen_move_resize
5297 // --------------------------------------------------------
5299 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5306 E_Client_Pending_Geometry *geo;
5309 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5310 if (ec->fullscreen || ec->maximized) goto err;
5312 geo = E_NEW(E_Client_Pending_Geometry, 1);
5315 geo->serial = serial;
5321 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5322 ec->surface_sync.wait_commit = EINA_TRUE;
5327 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5334 e_comp_wl_commit_sync_configure(E_Client *ec)
5337 E_Client_Pending_Geometry *geo;
5339 Eina_Bool match_size = EINA_FALSE;
5346 if (!ec || !ec->frame) goto ret;
5347 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5350 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5351 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5353 if (eina_list_count(ec->surface_sync.pending_geometry))
5355 Eina_List *ll = NULL;
5356 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5360 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5365 if ((geo->w == bw) && (geo->h == bh))
5367 match_size = EINA_TRUE;
5372 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5379 if ((config.w != ec->w) || (config.h != ec->h))
5381 e_client_size_set(ec, config.w, config.h);
5382 ec->changes.size = EINA_TRUE;
5386 // FIXME: The geometry of the client would be better to be calculated
5387 // at e_desk or at e_desk_area. So the position(x,y) of the client
5388 // should be calcuated at the e_desk or at the e_desk_area.
5390 desk = e_comp_desk_find_by_ec(ec);
5393 ec->client.x = desk->geom.x + config.x;
5394 ec->client.y = desk->geom.y + config.y;
5398 ec->client.x = config.x;
5399 ec->client.y = config.y;
5402 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5404 e_client_pos_set(ec, ec->client.x, ec->client.y);
5406 ec->changes.pos = 1;
5410 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5414 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5415 ec->surface_sync.wait_commit = EINA_FALSE;
5417 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5419 // rollback wait_commit if there are pending requests remained
5420 if (eina_list_count(ec->surface_sync.pending_geometry))
5421 ec->surface_sync.wait_commit = EINA_TRUE;
5426 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);
5433 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5434 struct wl_resource *res_moveresize)
5436 wl_resource_destroy(res_moveresize);
5440 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5441 struct wl_resource *res_moveresize,
5442 struct wl_resource *surface,
5449 /* to be implemented */
5452 int cur_w = 0, cur_h = 0;
5454 ec = e_client_from_surface_resource(surface);
5457 pending = e_client_pending_geometry_has(ec);
5458 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5459 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);
5463 if ((cur_w == w) && (cur_h == h))
5465 e_client_pos_set(ec, x, y);
5466 ec->changes.pos = 1;
5472 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5476 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5479 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5481 _tz_move_resize_iface_cb_destroy,
5482 _tz_move_resize_iface_cb_set_geometry,
5486 _tz_moveresize_cb_bind(struct wl_client *client,
5487 void *data EINA_UNUSED,
5491 struct wl_resource *res_moveresize;
5493 res_moveresize = wl_resource_create(client,
5494 &tizen_move_resize_interface,
5497 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5500 wl_resource_set_implementation(res_moveresize,
5501 &_tz_move_resize_iface,
5507 ERR("Could not create tizen_move_resize_interface res: %m");
5508 wl_client_post_no_memory(client);
5512 _e_comp_wl_move_resize_init(void)
5514 if (!e_comp_wl) return;
5515 if (!e_comp_wl->wl.disp) return;
5517 if (!wl_global_create(e_comp_wl->wl.disp,
5518 &tizen_move_resize_interface,
5521 _tz_moveresize_cb_bind))
5523 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5530 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5532 E_Comp_Wl_Output *output;
5533 pid_t output_pid = 0;
5534 Eina_List *l = NULL, *l2 = NULL;
5535 struct wl_resource *resource = NULL;
5537 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5539 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5540 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5541 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5543 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5545 /* if we have bound resources, send updates */
5546 EINA_LIST_FOREACH(output->resources, l2, resource)
5548 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5549 if (output_pid != pid) continue;
5551 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5553 // send output information to the client
5554 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5562 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5564 _e_comp_wl_surface_state_init(state, w, h);
5568 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5570 _e_comp_wl_surface_state_commit(ec, state);
5574 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5576 _e_comp_wl_hook_call(hookpoint, ec);
5580 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5582 _e_comp_wl_surface_state_finish(state);
5586 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5588 _e_comp_wl_surface_state_buffer_set(state, buffer);
5592 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5593 int sx, int sy, int *dx, int *dy)
5597 case WL_OUTPUT_TRANSFORM_NORMAL:
5601 case WL_OUTPUT_TRANSFORM_FLIPPED:
5602 *dx = width - sx, *dy = sy;
5604 case WL_OUTPUT_TRANSFORM_90:
5605 *dx = height - sy, *dy = sx;
5607 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5608 *dx = height - sy, *dy = width - sx;
5610 case WL_OUTPUT_TRANSFORM_180:
5611 *dx = width - sx, *dy = height - sy;
5613 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5614 *dx = sx, *dy = height - sy;
5616 case WL_OUTPUT_TRANSFORM_270:
5617 *dx = sy, *dy = width - sx;
5619 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5629 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5632 int tx1, ty1, tx2, ty2;
5633 int width_from_buffer, height_from_buffer;
5635 switch (vp->buffer.transform)
5637 case WL_OUTPUT_TRANSFORM_90:
5638 case WL_OUTPUT_TRANSFORM_270:
5639 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5640 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5641 width_from_buffer = bh / vp->buffer.scale;
5642 height_from_buffer = bw / vp->buffer.scale;
5645 width_from_buffer = bw / vp->buffer.scale;
5646 height_from_buffer = bh / vp->buffer.scale;
5650 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5654 x2 = width_from_buffer;
5655 y2 = height_from_buffer;
5659 x1 = wl_fixed_to_int(vp->buffer.src_x);
5660 y1 = wl_fixed_to_int(vp->buffer.src_y);
5661 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5662 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5665 buffer_transform(width_from_buffer, height_from_buffer,
5666 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5667 buffer_transform(width_from_buffer, height_from_buffer,
5668 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5670 out->x = (tx1 <= tx2) ? tx1 : tx2;
5671 out->y = (ty1 <= ty2) ? ty1 : ty2;
5672 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5673 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5677 * Convert given four coordinates to elements of rectangle
5678 * @in p[4] Coordinates to be converted
5679 * @out rect x, y, width, and height
5680 * transform Angle which represents TDM_TRANSFORM of rectangle
5681 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5682 * 1. The given coordinates are not represented by rectangle.
5683 * 2. All angles except for 0, 90, 180, 270.
5686 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5688 Eina_Bool ret = EINA_FALSE;
5690 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))
5693 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5696 *rotation = TDM_TRANSFORM_NORMAL;
5699 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5703 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5706 *rotation = TDM_TRANSFORM_180;
5709 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5714 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))
5717 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5720 *rotation = TDM_TRANSFORM_90;
5723 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5727 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5730 *rotation = TDM_TRANSFORM_270;
5733 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5743 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5748 for (i = 0; i < 4; i++)
5749 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5751 if (!_coords_to_rectangle_convert(p, out, rotation))
5753 DBG("Cannot convert given coords to rectangle.\n"
5754 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5755 p[0].x, p[0].y, p[1].x, p[1].y,
5756 p[2].x, p[2].y, p[3].x, p[3].y);
5764 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5766 int trans_rotation, flip;
5768 trans_rotation = transform & 0x3;
5769 flip = transform & 0x4;
5771 return (flip + (trans_rotation + rotation) % 4);
5775 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5783 if (e_comp_wl_subsurface_check(ec))
5784 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5791 out->w = ec->comp_data->width_from_viewport;
5792 out->w = (out->w + 1) & ~1;
5793 out->h = ec->comp_data->height_from_viewport;
5795 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5796 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5800 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5802 E_Comp_Wl_Buffer *buffer;
5803 E_Comp_Wl_Buffer_Viewport *vp;
5805 enum wl_output_transform buffer_transform;
5806 unsigned int rotation;
5807 Eina_Bool res = EINA_FALSE;
5809 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5811 if (e_object_is_del(E_OBJECT(ec)))
5814 vp = &ec->comp_data->scaler.buffer_viewport;
5816 if (buffer_viewport)
5818 buffer = ec->comp_data->buffer_ref.buffer;
5819 /* Getting a viewport of buffer needs geometry of buffer. */
5823 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5826 if ((output_viewport) || (transform))
5828 m = e_client_map_get(ec);
5830 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5832 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5837 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5838 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5839 * Since buffer.transform isn't applied using evas_map,
5840 * it has to be taken into account here to apply buffer.transform
5841 * and rotation of e_client_transform together. */
5843 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5845 *transform = (unsigned int)buffer_transform;
5853 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5855 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5856 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5858 /* Must be called with valid comp_data */
5859 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5861 if ((ec->comp_data->role_name == NULL) ||
5862 (ec->comp_data->role_name == role_name) ||
5863 (strcmp(ec->comp_data->role_name, role_name) == 0))
5865 ec->comp_data->role_name = role_name;
5871 wl_resource_post_error(error_resource, error_code,
5872 "Cannot assign role %s to wl_surface@%d,"
5873 " already has role %s\n",
5875 ec->comp_data->wl_surface ?
5876 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5877 ec->comp_data->role_name);
5883 EINTERN const char *
5884 e_comp_wl_surface_role_get(E_Client *ec)
5886 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5887 return ec->comp_data ? ec->comp_data->role_name : NULL;
5890 EINTERN struct wl_resource *
5891 e_comp_wl_client_surface_get(E_Client *ec)
5893 struct wl_resource *surface = NULL;
5894 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5895 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5897 g_mutex_lock(&ec->comp_data->surface_mutex);
5898 surface = ec->comp_data->surface;
5899 g_mutex_unlock(&ec->comp_data->surface_mutex);
5904 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5906 EINA_SAFETY_ON_NULL_RETURN(ec);
5907 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5909 g_mutex_lock(&ec->comp_data->surface_mutex);
5910 ec->comp_data->surface = surface;
5911 g_mutex_unlock(&ec->comp_data->surface_mutex);
5915 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5917 return e_compositor_util_client_from_surface_resource(surface_resource);
5921 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5923 if (!ec->comp_data->mapped)
5925 if (ec->comp_data->shell.surface &&
5926 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5928 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5934 if (ec->comp_data->mapped)
5936 /* will be unmapped. so run capture */
5937 e_comp_wl_remote_surface_image_save(ec);
5941 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5943 ec->comp_data->pending.sx = sx;
5944 ec->comp_data->pending.sy = sy;
5945 ec->comp_data->pending.new_attach = EINA_TRUE;
5947 e_client_fps_update(ec);
5951 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5953 if (ec->comp_data->pending.opaque)
5954 eina_tiler_clear(ec->comp_data->pending.opaque);
5958 eina_tiler_union(ec->comp_data->pending.opaque, region);
5960 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5964 ec->argb = EINA_FALSE;
5965 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5967 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5968 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5976 ec->argb = EINA_TRUE;
5977 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5979 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5980 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5986 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5988 if (ec->comp_data->pending.input)
5989 eina_tiler_clear(ec->comp_data->pending.input);
5993 if (eina_tiler_empty(region))
5995 ELOGF("COMP", " |unset input rect", NULL);
5996 e_comp_object_input_objs_del(ec->frame);
5997 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6000 eina_tiler_union(ec->comp_data->pending.input, region);
6004 eina_tiler_rect_add(ec->comp_data->pending.input,
6005 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6010 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6012 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6016 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6018 E_Comp_Wl_Subsurf_Data *sdata;
6023 if (ec->comp_data->frames)
6025 ec->comp_data->frames =
6026 eina_list_remove(ec->comp_data->frames, callback_resource);
6029 if (ec->comp_data->pending.frames)
6031 ec->comp_data->pending.frames =
6032 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6035 sdata = ec->comp_data->sub.data;
6036 if ((sdata) && (sdata->cached.frames))
6038 sdata->cached.frames =
6039 eina_list_remove(sdata->cached.frames, callback_resource);
6044 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6046 if (e_object_is_del(E_OBJECT(ec))) return;
6048 if (e_comp_wl_remote_surface_commit(ec)) return;
6050 e_comp_wl_surface_commit(ec);
6052 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6056 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6058 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6059 ec->comp_data->sub.data = sub;
6061 /* set subsurface client properties */
6062 ec->borderless = EINA_TRUE;
6063 ec->argb = EINA_TRUE;
6064 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6065 ec->lock_border = EINA_TRUE;
6066 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6067 ec->netwm.state.skip_taskbar = EINA_TRUE;
6068 ec->netwm.state.skip_pager = EINA_TRUE;
6069 ec->border_size = 0;
6070 ec->lock_user_location = 0;
6071 ec->lock_client_location = 0;
6072 ec->lock_user_size = 0;
6073 ec->lock_client_size = 0;
6074 ec->lock_client_stacking = 0;
6075 ec->lock_user_maximize = 0;
6076 ec->lock_client_maximize = 0;
6077 ec->changes.need_maximize = 0;
6078 ec->maximized = E_MAXIMIZE_NONE;
6081 ec->new_client = ec->netwm.ping = EINA_TRUE;
6082 e_comp->new_clients++;
6083 e_client_unignore(ec);
6085 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6086 * It's not for subsurface. */
6087 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6091 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6093 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6096 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6098 sub->parent = parent;
6102 layer = e_client_layer_get(parent);
6103 if (layer > E_LAYER_BOTTOM)
6104 e_client_layer_set(ec, layer);
6107 if (parent->comp_data)
6109 /* append this client to the parents subsurface list */
6110 parent->comp_data->sub.list_pending =
6111 eina_list_append(parent->comp_data->sub.list_pending, ec);
6112 parent->comp_data->sub.list_changed = EINA_TRUE;
6117 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6119 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6120 E_Client *parent = sub->parent;
6122 parent->comp_data->sub.list =
6123 eina_list_remove(parent->comp_data->sub.list, ec);
6124 parent->comp_data->sub.list_pending =
6125 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6126 parent->comp_data->sub.below_list =
6127 eina_list_remove(parent->comp_data->sub.below_list, ec);
6128 parent->comp_data->sub.below_list_pending =
6129 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6135 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)
6137 sub->resource = subsurface_resource;
6138 sub->cached_buffer_ref.buffer = NULL;
6139 sub->synchronized = EINA_TRUE;
6140 sub->parent = parent;
6141 sub->remote_surface.offscreen_parent = offscreen_parent;
6142 if (offscreen_parent)
6143 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6145 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6147 _e_comp_wl_client_subsurface_set(ec, sub);
6148 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6150 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6154 e_comp_wl_client_subsurface_finish(E_Client *ec)
6156 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6159 e_comp_wl_client_subsurface_parent_unset(ec);
6161 e_comp_wl_surface_state_finish(&sub->cached);
6162 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6164 ec->comp_data->sub.data = NULL;
6168 e_comp_wl_client_evas_init(E_Client *ec)
6170 EINA_SAFETY_ON_NULL_RETURN(ec);
6172 _e_comp_wl_client_evas_init(ec);
6176 e_comp_wl_client_evas_deinit(E_Client *ec)
6178 EINA_SAFETY_ON_NULL_RETURN(ec);
6180 _e_comp_wl_client_evas_deinit(ec);
6184 e_comp_wl_focus_check(void)
6186 _e_comp_wl_focus_check();
6190 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6197 if ((parent->comp_data) && (parent->comp_data->sub.data))
6198 parent = parent->comp_data->sub.data->parent;