2 #include "e_comp_wl_intern.h"
3 #include "e_comp_wl_private.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_comp_wl_private.h"
7 #include "e_client_intern.h"
8 #include "e_appinfo_intern.h"
9 #include "e_blender_intern.h"
10 #include "e_utils_intern.h"
11 #include "e_scale_intern.h"
12 #include "e_comp_canvas_intern.h"
13 #include "e_comp_screen_intern.h"
14 #include "e_comp_wl_capture_intern.h"
15 #include "e_comp_wl_data_intern.h"
16 #include "e_comp_wl_input_intern.h"
17 #include "e_comp_wl_renderer_intern.h"
18 #include "e_comp_wl_rsm_intern.h"
19 #include "e_comp_wl_screenshooter_intern.h"
20 #include "e_comp_wl_shell_intern.h"
21 #include "e_comp_wl_subsurface_intern.h"
22 #include "e_comp_wl_tbm_intern.h"
23 #include "e_comp_wl_viewport_intern.h"
24 #include "e_comp_intern.h"
26 #include <tizen-extension-server-protocol.h>
27 #include <relative-pointer-unstable-v1-server-protocol.h>
28 #include <pointer-constraints-unstable-v1-server-protocol.h>
30 #include <wayland-tbm-server.h>
32 #include <libds/log.h>
33 #include <libds/single_pixel_buffer_v1.h>
35 /* handle include for printing uint64_t */
36 #define __STDC_FORMAT_MACROS
39 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
41 /* Resource Data Mapping: (wl_resource_get_user_data)
43 * wl_surface == e_pixmap
44 * wl_region == eina_tiler
45 * wl_subsurface == e_client
49 typedef struct _E_Comp_Data E_Comp_Data;
54 struct wl_listener client_created;
57 static void _e_comp_wl_move_resize_init(void);
59 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
62 typedef struct _E_Comp_Wl_Key_Data
68 static Eina_List *handlers = NULL;
69 static E_Client *cursor_timer_ec = NULL;
70 static Eina_Bool need_send_released = EINA_FALSE;
71 static Eina_Bool need_send_motion = EINA_TRUE;
73 static GMutex connection_mutex;
75 static int _e_comp_wl_hooks_delete = 0;
76 static int _e_comp_wl_hooks_walking = 0;
78 static int _e_comp_wl_pid_hooks_delete = 0;
79 static int _e_comp_wl_pid_hooks_walking = 0;
81 static int _e_comp_wl_intercept_hooks_delete = 0;
82 static int _e_comp_wl_intercept_hooks_walking = 0;
84 static Eina_Inlist *_e_comp_wl_hooks[] =
86 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
87 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
88 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
89 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
90 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
91 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
92 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
93 [E_COMP_WL_HOOK_DEL] = NULL,
94 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
95 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
96 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
99 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
101 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
104 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
106 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
107 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
108 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
109 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
110 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
111 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
114 static Eina_List *hooks = NULL;
116 /* local functions */
118 _e_comp_wl_hooks_clean(void)
123 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
124 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
126 if (!ch->delete_me) continue;
127 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
133 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
137 e_object_ref(E_OBJECT(ec));
138 _e_comp_wl_hooks_walking++;
139 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
141 if (ch->delete_me) continue;
142 ch->func(ch->data, ec);
143 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
144 (e_object_is_del(E_OBJECT(ec))))
147 _e_comp_wl_hooks_walking--;
148 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
149 _e_comp_wl_hooks_clean();
150 e_object_unref(E_OBJECT(ec));
154 _e_comp_wl_pid_hooks_clean(void)
157 E_Comp_Wl_Pid_Hook *ch;
159 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
160 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
162 if (!ch->delete_me) continue;
163 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
169 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
171 E_Comp_Wl_Pid_Hook *ch;
173 _e_comp_wl_pid_hooks_walking++;
174 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
176 if (ch->delete_me) continue;
177 ch->func(ch->data, pid);
179 _e_comp_wl_pid_hooks_walking--;
180 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
181 _e_comp_wl_pid_hooks_clean();
185 _e_comp_wl_intercept_hooks_clean(void)
188 E_Comp_Wl_Intercept_Hook *ch;
190 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
191 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
193 if (!ch->delete_me) continue;
194 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
200 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
202 E_Comp_Wl_Intercept_Hook *ch;
203 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
205 e_object_ref(E_OBJECT(ec));
206 _e_comp_wl_intercept_hooks_walking++;
207 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
209 if (ch->delete_me) continue;
210 res = ch->func(ch->data, ec);
211 if (!res) ret = EINA_FALSE;
212 if (e_object_is_del(E_OBJECT(ec)))
215 _e_comp_wl_intercept_hooks_walking--;
216 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
217 _e_comp_wl_intercept_hooks_clean();
218 e_object_unref(E_OBJECT(ec));
225 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
231 if (e_comp_object_frame_exists(ec->frame))
232 w = ec->client.w, h = ec->client.h;
234 w = ec->w, h = ec->h;
238 // Width and Height are -1 means that we don't consider size value
242 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
246 _e_comp_wl_focus_check(void)
250 if (stopping) return;
251 ec = e_client_focused_get();
253 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
257 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
259 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
261 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
262 IDLE_EXITER~CB_PREPARE);
264 return ECORE_CALLBACK_RENEW;
268 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
270 /* dispatch pending wayland events */
271 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
273 return ECORE_CALLBACK_RENEW;
277 e_comp_wl_display_flush()
279 if (e_comp_wl && e_comp_wl->wl.disp)
281 if (e_config->key_input_ttrace_enable)
283 TRACE_INPUT_BEGIN(wl_display_flush_clients);
284 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
287 g_mutex_lock(&connection_mutex);
288 wl_display_flush_clients(e_comp_wl->wl.disp);
289 g_mutex_unlock(&connection_mutex);
291 if (e_config->key_input_ttrace_enable)
294 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
300 e_comp_wl_connection_lock()
302 e_input_boost_lock(&connection_mutex);
306 e_comp_wl_connection_unlock()
308 e_input_boost_unlock(&connection_mutex);
312 e_comp_wl_focused_client_flush()
314 E_Client *focused_ec;
315 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
317 e_input_boost_lock(&connection_mutex);
318 focused_ec = e_client_focused_get();
322 struct wl_client *wc;
323 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
326 e_input_boost_unlock(&connection_mutex);
330 wc = wl_resource_get_client(surface);
334 e_input_boost_unlock(&connection_mutex);
338 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
342 if (e_comp_wl->idle_exiter_timestamp > 0.0)
344 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
345 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
347 ELOGF("E_COMP", "prepare gap time: %lfms",
352 e_comp_wl->idle_exiter_timestamp = 0.0;
354 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
356 /* flush pending client events */
357 e_comp_wl_display_flush();
359 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
360 IDLE_EXITER~CB_PREPARE);
363 E_API enum wl_output_transform
364 e_comp_wl_output_buffer_transform_get(E_Client *ec)
366 E_Comp_Wl_Buffer_Viewport *vp;
367 E_Comp_Wl_Buffer *buffer;
368 enum wl_output_transform transform, rotation;
370 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
371 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
372 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
374 vp = &ec->comp_data->scaler.buffer_viewport;
375 if (e_comp_wl_subsurface_check(ec))
376 return vp->buffer.transform;
378 buffer = ec->comp_data->buffer_ref.buffer;
381 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
382 return vp->buffer.transform;
384 rotation = buffer->transform;
386 return vp->buffer.transform;
388 /* ignore the flip value when calculating transform because the screen rotation
389 * functionality doesn't consider the flip output transform currently
391 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
393 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
394 ec, rotation, vp->buffer.transform, transform);
399 EINTERN enum wl_output_transform
400 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
402 E_Comp_Wl_Buffer_Viewport *vp;
403 E_Comp_Wl_Buffer *buffer;
404 enum wl_output_transform transform, rotation;
406 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
407 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
408 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
410 vp = &ec->comp_data->pending.buffer_viewport;
411 if (e_comp_wl_subsurface_check(ec))
412 return vp->buffer.transform;
414 buffer = ec->comp_data->pending.buffer;
417 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
418 return vp->buffer.transform;
420 rotation = buffer->transform;
422 return vp->buffer.transform;
424 /* ignore the flip value when calculating transform because the screen rotation
425 * functionality doesn't consider the flip output transform currently
427 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
429 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
430 ec, rotation, vp->buffer.transform, transform);
436 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
438 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
439 E_Comp_Wl_Buffer *buffer;
440 int32_t width, height;
442 buffer = e_pixmap_resource_get(ec->pixmap);
445 ec->comp_data->width_from_buffer = 0;
446 ec->comp_data->height_from_buffer = 0;
450 switch (e_comp_wl_output_buffer_transform_get(ec))
452 case WL_OUTPUT_TRANSFORM_90:
453 case WL_OUTPUT_TRANSFORM_270:
454 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
455 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
456 width = buffer->h / vp->buffer.scale;
457 height = buffer->w / vp->buffer.scale;
460 width = buffer->w / vp->buffer.scale;
461 height = buffer->h / vp->buffer.scale;
465 ec->comp_data->width_from_buffer = width;
466 ec->comp_data->height_from_buffer = height;
470 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
472 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
473 int32_t width, height;
475 width = ec->comp_data->width_from_buffer;
476 height = ec->comp_data->height_from_buffer;
478 if (width == 0 && height == 0) return;
480 if (width != 0 && vp->surface.width != -1)
482 ec->comp_data->width_from_viewport = vp->surface.width;
483 ec->comp_data->height_from_viewport = vp->surface.height;
487 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
489 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
490 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
491 ec->comp_data->width_from_viewport = w ?: 1;
492 ec->comp_data->height_from_viewport = h ?: 1;
496 ec->comp_data->width_from_viewport = width;
497 ec->comp_data->height_from_viewport = height;
501 e_comp_wl_topmost_parent_get(E_Client *ec)
505 if (!e_comp_wl_subsurface_check(ec))
508 parent = e_comp_wl_subsurface_parent_get(ec);
511 if (!e_comp_wl_subsurface_check(parent))
514 parent = e_comp_wl_subsurface_parent_get(parent);
521 e_comp_wl_map_apply(E_Client *ec)
523 E_Comp_Wl_Buffer_Viewport *vp;
524 E_Comp_Wl_Subsurf_Data *sdata;
525 E_Comp_Wl_Client_Data *cdata;
526 int x1, y1, x2, y2, x, y;
528 Eina_Bool zoom_animating = EINA_FALSE;
530 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
532 e_comp_object_map_update(ec->frame);
534 cdata = ec->comp_data;
535 vp = &cdata->scaler.buffer_viewport;
536 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
537 (!cdata->viewport_transform))
540 if (e_comp_wl_subsurface_check(ec))
542 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
544 sdata = ec->comp_data->sub.data;
545 if (sdata->remote_surface.offscreen_parent)
547 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
548 Eina_Rectangle *rect;
551 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
553 /* TODO: If there are one more regions, it means that provider's offscreen
554 * is displayed by one more remote_surfaces. Have to consider it later. At
555 * this time, just consider only one remote_surface.
569 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
570 if (x != dx || y != dy)
571 evas_object_move(ec->frame, dx, dy);
573 if (!cdata->viewport_transform)
575 cdata->viewport_transform = e_util_transform_new();
576 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
577 e_client_transform_core_add(ec, cdata->viewport_transform);
580 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
581 ec->comp_data->width_from_viewport,
582 ec->comp_data->height_from_viewport);
584 if (vp->buffer.src_width == wl_fixed_from_int(-1))
588 x2 = cdata->width_from_buffer;
589 y2 = cdata->height_from_buffer;
593 x1 = wl_fixed_to_int(vp->buffer.src_x);
594 y1 = wl_fixed_to_int(vp->buffer.src_y);
595 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
596 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
599 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
600 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
601 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
602 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
605 desk = e_comp_desk_find_by_ec(ec);
607 zoom_animating = e_desk_zoom_is_animating(desk);
609 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
610 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
611 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
613 /* workaround:: when the desk zoom is doing their animation,
614 the transform core update can override animation's zoom boundary.
615 so, don't doing transform core update while desk zoom animation */
617 e_client_transform_core_update(ec);
622 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
626 int map_c = 0, map_x = 0, map_y = 0;
627 double inv_x = 0.0, inv_y = 0.0;
629 EINA_SAFETY_ON_NULL_RETURN(ec);
631 map = e_client_map_get(ec);
632 map_c = e_map_count_get(map);
634 if (!map || map_c <= 0)
644 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
645 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
646 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
647 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
649 for (int i = 0; i < map_c; i++)
651 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
652 e_map_point_image_uv_set(map2, i, map_x, map_y);
654 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
664 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
670 if (!(ec = data)) return;
671 if (e_object_is_del(data)) return;
673 if (!ec->override) e_hints_window_visible_set(ec);
675 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
676 (!ec->comp_data->need_reparent))
678 ec->comp_data->need_reparent = EINA_TRUE;
679 ec->visible = EINA_TRUE;
681 if (!e_client_util_ignored_get(ec))
683 ec->take_focus = !starting;
687 if (!ec->comp_data->need_reparent)
689 if ((ec->hidden) || (ec->iconic))
691 evas_object_hide(ec->frame);
692 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
695 evas_object_show(ec->frame);
698 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
699 evas_object_show(tmp->frame);
701 topmost = e_comp_wl_topmost_parent_get(ec);
702 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
703 e_comp_wl_subsurface_show(ec);
705 if (ec->comp_data->sub.below_obj)
706 evas_object_show(ec->comp_data->sub.below_obj);
710 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
716 if (!(ec = data)) return;
717 if (e_object_is_del(E_OBJECT(ec))) return;
719 /* Uncommonly some clients's final buffer can be skipped if the client
720 * requests unmap of its surface right after wl_surface@commit.
721 * So if this client evas object is hidden state and client is already
722 * unmmapped, we can consider to clear pixmap image here mandatorily.
724 if (!ec->comp_data->mapped)
725 e_pixmap_image_clear(ec->pixmap, 1);
727 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
728 evas_object_hide(tmp->frame);
730 topmost = e_comp_wl_topmost_parent_get(ec);
731 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
732 e_comp_wl_subsurface_hide(ec);
734 if (ec->comp_data->sub.below_obj)
735 evas_object_hide(ec->comp_data->sub.below_obj);
737 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
741 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
748 if (!(ec = data)) return;
749 if (e_object_is_del(E_OBJECT(ec))) return;
751 EINA_LIST_FOREACH(ec->comp_data->sub.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 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
767 if (!e_comp_wl_subsurface_check(subc)) continue;
768 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
769 evas_object_move(subc->frame, x, y);
771 if (subc->comp_data->scaler.viewport)
773 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
774 if (cdata->viewport_transform)
775 e_comp_wl_map_apply(subc);
779 if (ec->comp_data->sub.below_obj)
781 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
782 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
787 _e_comp_wl_send_touch_cancel(E_Client *ec)
790 struct wl_resource *res;
791 struct wl_client *wc;
792 E_Comp_Config *comp_conf = NULL;
795 if (e_object_is_del(E_OBJECT(ec))) return;
796 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
798 if (!surface) return;
799 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
801 wc = wl_resource_get_client(surface);
803 comp_conf = e_comp_config_get();
805 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
807 if (wl_resource_get_client(res) != wc) continue;
808 if (!e_comp_wl_input_touch_check(res)) continue;
810 if (comp_conf && comp_conf->input_log_enable)
811 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
813 wl_touch_send_cancel(res);
818 _e_comp_wl_touch_cancel(void)
822 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
824 if (!e_comp_wl->touch.pressed) return;
826 _e_comp_wl_send_touch_cancel(ec);
829 static E_Devicemgr_Input_Device *
830 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
832 E_Devicemgr_Input_Device *last_kbd = NULL;
835 case ECORE_DEVICE_CLASS_MOUSE:
836 return e_devicemgr->last_device_ptr;
837 case ECORE_DEVICE_CLASS_KEYBOARD:
838 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
840 case ECORE_DEVICE_CLASS_TOUCH:
841 return e_devicemgr->last_device_touch;
849 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
853 case ECORE_DEVICE_CLASS_MOUSE:
854 e_devicemgr->last_device_ptr = device;
856 case ECORE_DEVICE_CLASS_KEYBOARD:
857 atomic_store(&e_devicemgr->last_device_kbd, device);
859 case ECORE_DEVICE_CLASS_TOUCH:
860 e_devicemgr->last_device_touch = device;
867 static E_Devicemgr_Input_Device *
868 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
870 E_Devicemgr_Input_Device *last_kbd = NULL;
874 case ECORE_DEVICE_CLASS_MOUSE:
875 return ec->comp_data->last_device_ptr;
876 case ECORE_DEVICE_CLASS_KEYBOARD:
877 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
879 case ECORE_DEVICE_CLASS_TOUCH:
880 return ec->comp_data->last_device_touch;
888 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
892 case ECORE_DEVICE_CLASS_MOUSE:
893 ec->comp_data->last_device_ptr = device;
895 case ECORE_DEVICE_CLASS_KEYBOARD:
896 atomic_store(&ec->comp_data->last_device_kbd, device);
898 case ECORE_DEVICE_CLASS_TOUCH:
899 ec->comp_data->last_device_touch = device;
907 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
909 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
910 struct wl_resource *dev_res;
911 const char *dev_name;
912 Ecore_Device_Class dev_class;
913 struct wl_client *wc;
917 EINA_SAFETY_ON_NULL_RETURN(dev);
920 if (ec->cur_mouse_action || e_comp_wl->drag)
922 if (e_object_is_del(E_OBJECT(ec))) return;
923 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
924 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
925 if (!surface) return;
927 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
928 dev_name = evas_device_description_get(dev);
929 last_device = _e_comp_wl_device_last_device_get(dev_class);
930 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
932 serial = wl_display_next_serial(e_comp_wl->wl.disp);
933 wc = wl_resource_get_client(surface);
934 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
935 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
937 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
938 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
940 _e_comp_wl_device_last_device_set(dev_class, input_dev);
941 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
943 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
945 if (wl_resource_get_client(dev_res) != wc) continue;
946 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
950 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
954 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
956 E_Devicemgr_Input_Device *last_device;
957 struct wl_resource *dev_res;
958 struct wl_client *wc;
962 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
963 if (!surface) return;
965 last_device = _e_comp_wl_device_last_device_get(dev_class);
966 if (!last_device) return;
968 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
970 serial = wl_display_next_serial(e_comp_wl->wl.disp);
971 wc = wl_resource_get_client(surface);
972 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
974 if (wl_resource_get_client(dev_res) != wc) continue;
975 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
980 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
982 E_Devicemgr_Input_Device *input_dev;
983 struct wl_resource *dev_res;
984 const char *dev_name;
987 EINA_SAFETY_ON_NULL_RETURN(dev);
989 dev_name = ecore_device_identifier_get(dev);
991 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
992 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
994 if (!eina_streq(input_dev->identifier, dev_name) ||
995 (input_dev->clas != ecore_device_class_get(dev))) continue;
996 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
998 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1000 if (wl_resource_get_client(dev_res) != wc) continue;
1001 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1004 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1008 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1010 E_Devicemgr_Input_Device *input_dev;
1011 struct wl_resource *dev_res;
1012 const char *dev_name;
1015 EINA_SAFETY_ON_NULL_RETURN(dev);
1017 dev_name = e_device_identifier_get(dev);
1019 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1020 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1022 if (!eina_streq(input_dev->identifier, dev_name) ||
1023 (input_dev->clas != e_device_class_get(dev))) continue;
1024 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1026 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1028 if (wl_resource_get_client(dev_res) != wc) continue;
1029 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1032 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1036 _e_comp_wl_cursor_reload(E_Client *ec)
1038 struct wl_resource *res;
1039 struct wl_client *wc;
1045 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1046 !evas_object_visible_get(e_comp->pointer->o_ptr))
1047 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1050 if (e_object_is_del(E_OBJECT(ec))) return;
1051 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1052 if (!surface) return;
1053 if (ec->pointer_enter_sent) return;
1055 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1056 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1058 if (e_client_transform_core_enable_get(ec))
1060 double dx = 0.0, dy = 0.0;
1061 map = e_client_map_get(ec);
1062 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1068 cx = px - ec->client.x;
1069 cy = py - ec->client.y;
1071 wc = wl_resource_get_client(surface);
1072 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1073 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1075 if (!e_comp_wl_input_pointer_check(res)) continue;
1076 if (wl_resource_get_client(res) != wc) continue;
1077 wl_pointer_send_enter(res, serial, surface,
1078 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1079 ec->pointer_enter_sent = EINA_TRUE;
1081 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1085 _e_comp_wl_cursor_timer(void *data)
1087 E_Client *ec = data;
1089 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1090 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1092 e_comp_wl_cursor_hide(ec);
1094 return ECORE_CALLBACK_CANCEL;
1098 _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)
1100 E_Devicemgr_Input_Device *input_dev;
1101 struct wl_resource *dev_res;
1102 struct wl_client *wc;
1107 if (ec->cur_mouse_action) return;
1108 if (e_object_is_del(E_OBJECT(ec))) return;
1109 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1110 if (!surface) return;
1112 f_value = wl_fixed_from_double(value);
1113 wc = wl_resource_get_client(surface);
1115 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1116 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1118 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1119 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1121 if (wl_resource_get_client(dev_res) != wc) continue;
1122 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1125 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1129 _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)
1131 if (idx >= e_input_touch_max_count_get()) return;
1133 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1134 e_devicemgr->multi[idx].radius_x = radius_x;
1135 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1136 e_devicemgr->multi[idx].radius_y = radius_y;
1137 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1138 e_devicemgr->multi[idx].pressure = pressure;
1139 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1140 e_devicemgr->multi[idx].angle = angle;
1144 _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)
1146 if (idx >= e_input_touch_max_count_get()) return;
1148 if (e_devicemgr->multi[idx].radius_x != radius_x)
1150 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1151 e_devicemgr->multi[idx].radius_x = radius_x;
1153 if (e_devicemgr->multi[idx].radius_y != radius_y)
1155 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1156 e_devicemgr->multi[idx].radius_y = radius_y;
1158 if (e_devicemgr->multi[idx].pressure != pressure)
1160 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1161 e_devicemgr->multi[idx].pressure = pressure;
1163 if (e_devicemgr->multi[idx].angle != angle)
1165 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1166 e_devicemgr->multi[idx].angle = angle;
1171 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1173 Eina_Bool ret = EINA_TRUE;
1176 case EVAS_CALLBACK_MOUSE_IN:
1177 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1180 if (e_comp_wl->ptr.hide_tmr)
1182 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1183 cursor_timer_ec = ec;
1184 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1188 if (e_pointer_is_hidden(e_comp->pointer))
1193 case EVAS_CALLBACK_MOUSE_OUT:
1194 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1197 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1201 case EVAS_CALLBACK_MOUSE_MOVE:
1202 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1205 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1206 _e_comp_wl_cursor_reload(ec);
1209 case EVAS_CALLBACK_MOUSE_WHEEL:
1210 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1213 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1214 _e_comp_wl_cursor_reload(ec);
1217 case EVAS_CALLBACK_MOUSE_DOWN:
1218 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1221 if (e_comp_wl->ptr.hide_tmr)
1223 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1224 e_comp_wl->ptr.hide_tmr = NULL;
1226 cursor_timer_ec = NULL;
1228 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1229 _e_comp_wl_cursor_reload(ec);
1232 case EVAS_CALLBACK_MOUSE_UP:
1233 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1244 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1246 if (ec->has_cursor_unset)
1249 if (!e_config->show_cursor)
1252 if (!e_config->use_cursor_timer)
1259 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1262 Evas_Event_Mouse_In *ev;
1263 struct wl_resource *res;
1264 struct wl_client *wc;
1267 E_Comp_Config *comp_conf;
1268 E_Client *prev_ptr_ec;
1272 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1273 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1275 if (!(ec = data)) return;
1276 if (e_object_is_del(E_OBJECT(ec))) return;
1277 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1278 if (!surface) return;
1280 prev_ptr_ec = e_comp_wl->ptr.ec;
1283 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1284 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1287 e_comp_wl->ptr.ec = ec;
1289 comp_conf = e_comp_config_get();
1290 if (comp_conf && comp_conf->input_log_enable)
1291 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1292 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1293 e_client_util_name_get(ec));
1295 if (_e_comp_wl_check_cursor_timer_needed(ec))
1297 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1301 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1302 wc = wl_resource_get_client(surface);
1303 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1304 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1306 if (!e_comp_wl_input_pointer_check(res)) continue;
1307 if (wl_resource_get_client(res) != wc) continue;
1309 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1311 wl_pointer_send_enter(res, serial, surface,
1312 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1313 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1314 ec->pointer_enter_sent = EINA_TRUE;
1317 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1321 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1324 Evas_Event_Mouse_Out *ev;
1325 struct wl_resource *res;
1326 struct wl_client *wc;
1329 Eina_Bool inside_check;
1330 E_Comp_Config *comp_conf;
1334 if (!(ec = data)) return;
1335 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1336 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1337 if (ec->cur_mouse_action && inside_check) return;
1338 if (e_object_is_del(E_OBJECT(e_comp))) return;
1339 if (e_comp_wl->ptr.ec == ec)
1340 e_comp_wl->ptr.ec = NULL;
1341 if (e_object_is_del(E_OBJECT(ec))) return;
1343 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1344 if (!surface) return;
1346 comp_conf = e_comp_config_get();
1347 if (comp_conf && comp_conf->input_log_enable)
1348 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1349 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1350 e_client_util_name_get(ec));
1352 if (_e_comp_wl_check_cursor_timer_needed(ec))
1354 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1358 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1360 wc = wl_resource_get_client(surface);
1361 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1362 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1364 if (!e_comp_wl_input_pointer_check(res)) continue;
1365 if (wl_resource_get_client(res) != wc) continue;
1366 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1368 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1370 wl_pointer_send_leave(res, serial, surface);
1371 ec->pointer_enter_sent = EINA_FALSE;
1376 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1379 struct wl_client *wc;
1380 struct wl_resource *res;
1383 E_Comp_Config *comp_conf = NULL;
1386 if (e_object_is_del(E_OBJECT(ec))) return;
1387 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1388 if (!surface) return;
1390 wc = wl_resource_get_client(surface);
1391 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1395 x = wl_fixed_from_int(canvas_x - ec->client.x);
1396 y = wl_fixed_from_int(canvas_y - ec->client.y);
1399 comp_conf = e_comp_config_get();
1401 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1403 if (wl_resource_get_client(res) != wc) continue;
1404 if (!e_comp_wl_input_touch_check(res)) continue;
1405 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1408 if (comp_conf && comp_conf->input_log_enable)
1409 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));
1411 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1415 if (comp_conf && comp_conf->input_log_enable)
1416 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));
1418 wl_touch_send_up(res, serial, timestamp, idx);
1425 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1428 struct wl_client *wc;
1429 struct wl_resource *res;
1433 if (ec->cur_mouse_action) return;
1434 if (e_object_is_del(E_OBJECT(ec))) return;
1435 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1436 if (!surface) return;
1438 wc = wl_resource_get_client(surface);
1440 x = wl_fixed_from_int(canvas_x - ec->client.x);
1441 y = wl_fixed_from_int(canvas_y - ec->client.y);
1443 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1445 if (wl_resource_get_client(res) != wc) continue;
1446 if (!e_comp_wl_input_touch_check(res)) continue;
1447 wl_touch_send_motion(res, timestamp, idx, x, y);
1452 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1454 struct wl_resource *res;
1455 struct wl_client *wc;
1459 if (ec->cur_mouse_action) return;
1460 if (e_object_is_del(E_OBJECT(ec))) return;
1461 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1462 if (!surface) return;
1464 wc = wl_resource_get_client(surface);
1465 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1467 if (!e_comp_wl_input_pointer_check(res)) continue;
1468 if (wl_resource_get_client(res) != wc) continue;
1469 wl_pointer_send_motion(res, timestamp,
1470 wl_fixed_from_int(x - ec->client.x),
1471 wl_fixed_from_int(y - ec->client.y));
1476 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1478 if (e_comp_wl->ptr.hide_tmr)
1480 if (cursor_timer_ec == ec)
1482 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1483 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1487 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1488 cursor_timer_ec = ec;
1489 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1494 cursor_timer_ec = ec;
1495 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1500 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1503 Evas_Event_Mouse_Move *ev;
1504 Evas_Device *dev = NULL;
1505 const char *dev_name;
1506 E_Comp_Config *comp_conf;
1510 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1511 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1513 if (!(ec = data)) return;
1514 if (e_object_is_del(E_OBJECT(ec))) return;
1515 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1516 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1517 if (!surface) return;
1519 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1522 dev_name = evas_device_description_get(dev);
1524 comp_conf = e_comp_config_get();
1525 if (comp_conf && comp_conf->input_log_enable)
1526 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1527 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1528 e_client_util_name_get(ec), dev_name);
1530 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1532 if (!e_comp_wl->drag_client)
1534 e_comp_wl->touch.faked_ec = ec;
1535 if (e_comp_wl->touch.pressed & (1 << 0))
1537 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1539 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1540 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1541 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1545 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1549 if (!e_comp_wl->drag_client)
1551 if (_e_comp_wl_check_cursor_timer_needed(ec))
1553 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1557 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1558 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1560 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1562 if (_e_comp_wl_check_cursor_timer_needed(ec))
1563 _e_comp_wl_cursor_move_timer_control(ec);
1567 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1572 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1574 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1575 if (e_object_is_del(E_OBJECT(ec))) return;
1576 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1577 if (!surface) return;
1578 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1580 e_comp_wl->ptr.button = BTN_LEFT;
1582 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1586 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1588 E_Client *ec = data;
1589 Evas_Event_Mouse_Down *ev = event;
1590 Evas_Device *dev = NULL;
1591 const Evas_Device *seat_dev;
1592 const char *dev_name, *seat_name;
1593 E_Comp_Config *comp_conf = NULL;
1596 if (e_object_is_del(E_OBJECT(ec))) return;
1599 dev_name = evas_device_description_get(dev);
1601 seat_dev = evas_device_parent_get(dev);
1602 seat_name = evas_device_name_get(seat_dev);
1604 comp_conf = e_comp_config_get();
1605 if (comp_conf && comp_conf->input_log_enable)
1606 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1607 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1608 dev_name, seat_name);
1610 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1612 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1614 e_comp_wl->touch.faked_ec = ec;
1617 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1618 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1619 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1621 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1622 e_comp_wl->touch.pressed |= (1 << 0);
1626 if (_e_comp_wl_check_cursor_timer_needed(ec))
1628 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1632 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1633 WL_POINTER_BUTTON_STATE_PRESSED);
1635 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1638 need_send_released = EINA_TRUE;
1642 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1644 E_Client *ec = data;
1645 Evas_Event_Mouse_Up *ev = event;
1646 Evas_Device *dev = NULL;
1647 const Evas_Device *seat_dev;
1648 const char *dev_name, *seat_name;;
1649 Evas_Event_Flags flags;
1650 E_Comp_Config *comp_conf = NULL;
1653 if (ec->cur_mouse_action) return;
1654 if (e_object_is_del(E_OBJECT(ec))) return;
1656 if (!need_send_released)
1658 need_send_motion = EINA_TRUE;
1662 dev_name = evas_device_description_get(dev);
1664 seat_dev = evas_device_parent_get(dev);
1665 seat_name = evas_device_name_get(seat_dev);
1666 flags = evas_event_default_flags_get(evas);
1668 comp_conf = e_comp_config_get();
1669 if (comp_conf && comp_conf->input_log_enable)
1670 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1671 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1672 dev_name, seat_name);
1674 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1676 e_comp_wl->touch.pressed &= ~(1 << 0);
1678 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1679 e_comp_wl->touch.faked_ec = NULL;
1682 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1684 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1686 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1689 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1690 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1691 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1695 if (_e_comp_wl_check_cursor_timer_needed(ec))
1697 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1701 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1702 WL_POINTER_BUTTON_STATE_RELEASED);
1704 if (_e_comp_wl_check_cursor_timer_needed(ec))
1705 _e_comp_wl_cursor_move_timer_control(ec);
1709 need_send_released = EINA_FALSE;
1713 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1715 struct wl_resource *res;
1716 struct wl_client *wc;
1721 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1723 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1726 dir = -wl_fixed_from_int(abs(z));
1728 dir = wl_fixed_from_int(z);
1731 if (e_object_is_del(E_OBJECT(ec))) return;
1732 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1733 if (!surface) return;
1735 wc = wl_resource_get_client(surface);
1736 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1738 if (!e_comp_wl_input_pointer_check(res)) continue;
1739 if (wl_resource_get_client(res) != wc) continue;
1740 wl_pointer_send_axis(res, timestamp, axis, dir);
1745 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1748 Evas_Event_Mouse_Wheel *ev;
1751 if (!(ec = data)) return;
1752 if (ec->cur_mouse_action) return;
1753 if (e_object_is_del(E_OBJECT(ec))) return;
1754 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1755 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1756 if (!surface) return;
1758 if (!eina_list_count(e_comp_wl->ptr.resources))
1761 if (_e_comp_wl_check_cursor_timer_needed(ec))
1763 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1767 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1769 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1771 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1773 if (_e_comp_wl_check_cursor_timer_needed(ec))
1774 _e_comp_wl_cursor_move_timer_control(ec);
1779 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1781 E_Client *ec = data;
1782 Evas_Event_Multi_Down *ev = event;
1783 Evas_Device *dev = NULL;
1784 const Evas_Device *seat_dev;
1785 const char *dev_name, *seat_name;
1786 Evas_Device_Class dev_class;
1787 E_Comp_Config *comp_conf = NULL;
1790 if (e_object_is_del(E_OBJECT(ec))) return;
1791 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1792 if (!surface) return;
1794 /* Do not deliver emulated single touch events to client */
1795 if (ev->device == 0) return;
1798 dev_name = evas_device_description_get(dev);
1799 e_comp_wl->touch.faked_ec = ec;
1801 seat_dev = evas_device_parent_get(dev);
1802 seat_name = evas_device_name_get(seat_dev);
1804 comp_conf = e_comp_config_get();
1805 if (comp_conf && comp_conf->input_log_enable)
1806 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1807 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1808 dev_name, seat_name);
1810 if (dev && dev_name)
1812 dev_class = evas_device_class_get(dev);
1813 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1814 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1817 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1818 e_comp_wl->touch.pressed |= (1 << ev->device);
1822 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1824 E_Client *ec = data;
1825 Evas_Event_Multi_Up *ev = event;
1826 Evas_Device *dev = NULL;
1827 const Evas_Device *seat_dev;
1828 const char *dev_name, *seat_name;
1829 Evas_Device_Class dev_class;
1830 Evas_Event_Flags flags;
1831 E_Comp_Config *comp_conf = NULL;
1834 if (e_object_is_del(E_OBJECT(ec))) return;
1835 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1836 if (!surface) return;
1838 /* Do not deliver emulated single touch events to client */
1839 if (ev->device == 0) return;
1841 flags = evas_event_default_flags_get(evas);
1843 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1844 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1845 e_comp_wl->touch.faked_ec = NULL;
1847 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1850 dev_name = evas_device_description_get(dev);
1852 seat_dev = evas_device_parent_get(dev);
1853 seat_name = evas_device_name_get(seat_dev);
1855 comp_conf = e_comp_config_get();
1856 if (comp_conf && comp_conf->input_log_enable)
1857 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1858 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1859 dev_name, seat_name);
1861 if (dev && dev_name)
1863 dev_class = evas_device_class_get(dev);
1864 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1865 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1868 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1872 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1874 E_Client *ec = data;
1875 Evas_Event_Multi_Move *ev = event;
1876 Evas_Device *dev = NULL;
1877 const char *dev_name;
1878 Evas_Device_Class dev_class;
1881 if (e_object_is_del(E_OBJECT(ec))) return;
1882 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1883 if (!surface) return;
1885 /* Do not deliver emulated single touch events to client */
1886 if (ev->device == 0) return;
1888 e_comp_wl->touch.faked_ec = ec;
1890 if (e_comp_wl->touch.pressed & (1 << ev->device))
1893 if (dev && (dev_name = evas_device_description_get(dev)))
1895 dev_class = evas_device_class_get(dev);
1896 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1897 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1900 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1905 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1908 char *file, buff[PATH_MAX];
1915 n = (getpriority(PRIO_PROCESS, pid) + adj);
1919 setpriority(PRIO_PROCESS, pid, n);
1922 use_adj = EINA_TRUE;
1924 if (!do_child) return;
1926 files = ecore_file_ls("/proc");
1927 EINA_LIST_FREE(files, file)
1929 if (!isdigit(file[0]))
1932 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1933 if ((f = fopen(buff, "r")))
1937 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1939 if (num_read == 2 && ppid == pid)
1940 _e_comp_wl_client_priority_adjust(pid2, set,
1942 adj_child, do_child);
1950 _e_comp_wl_client_priority_raise(E_Client *ec)
1952 if (!e_config->priority_control) return;
1953 if (ec->netwm.pid <= 0) return;
1954 if (ec->netwm.pid == getpid()) return;
1955 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1956 e_config->priority - 1, -1,
1957 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1961 _e_comp_wl_client_priority_normal(E_Client *ec)
1963 if (!e_config->priority_control) return;
1964 if (ec->netwm.pid <= 0) return;
1965 if (ec->netwm.pid == getpid()) return;
1966 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1967 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1971 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1974 E_Comp_Wl_Key_Data *k;
1975 struct wl_resource *res;
1979 if (!ec) return EINA_FALSE;
1980 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1981 if (!ec->comp_data) return EINA_FALSE;
1983 ec->comp_data->on_focus_timer = NULL;
1984 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1985 if (!e_comp_wl->kbd.focused)
1987 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1990 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1992 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1993 t = ecore_time_unix_get();
1995 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1996 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1997 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1999 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2001 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2002 wl_keyboard_send_key(res, serial, t,
2003 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2006 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2007 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2011 /* It is called in the following cases:
2012 * When a normal ec->frame has focus.
2013 * Or launching image ec is replaced to the real ec.
2016 e_comp_wl_feed_focus_in(E_Client *ec)
2019 struct wl_resource *res;
2020 struct wl_client *wc;
2024 if (e_object_is_del(E_OBJECT(ec))) return;
2025 if (ec->iconic) return;
2027 /* block spurious focus events */
2028 focused = e_client_focused_get();
2029 if ((focused) && (ec != focused)) return;
2031 /* raise client priority */
2032 _e_comp_wl_client_priority_raise(ec);
2033 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2034 if (!surface) return;
2036 wc = wl_resource_get_client(surface);
2038 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2039 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2041 if (wl_resource_get_client(res) == wc)
2043 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2044 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2045 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2046 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2049 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2051 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2052 if (!e_comp_wl->kbd.focused)
2054 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2057 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2059 e_comp_wl->kbd.focus = surface;
2060 e_comp_wl_input_keyboard_enter_send(ec);
2061 e_comp_wl_data_device_keyboard_focus_set();
2062 ec->comp_data->on_focus_timer =
2063 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2064 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2065 int rotation = ec->e.state.rot.ang.curr;
2066 e_pointer_rotation_set(e_comp->pointer, rotation);
2070 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2073 if (!(ec = data)) return;
2074 e_comp_wl_feed_focus_in(ec);
2078 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2081 struct wl_resource *res;
2083 E_Comp_Wl_Key_Data *k;
2087 if (!(ec = data)) return;
2089 if (!ec->comp_data) return;
2091 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2093 /* lower client priority */
2094 if (!e_object_is_del(data))
2095 _e_comp_wl_client_priority_normal(ec);
2098 /* update keyboard modifier state */
2099 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2100 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2101 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2103 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2105 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2106 if (!surface) return;
2108 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2109 if (!eina_list_count(e_comp_wl->kbd.resources))
2111 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2115 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2117 /* send keyboard_leave to all keyboard resources */
2118 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2119 t = ecore_time_unix_get();
2121 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2122 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2123 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2125 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2127 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2128 wl_keyboard_send_key(res, serial, t,
2129 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2131 wl_keyboard_send_leave(res, serial, surface);
2132 e_comp_wl->kbd.focused =
2133 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2135 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2136 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2140 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2144 if (!(ec = data)) return;
2146 if (!ec->comp_data->shell.configure_send) return;
2148 /* TODO: calculate x, y with transfrom object */
2149 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2153 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2154 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2155 if (e_comp_object_frame_exists(ec->frame))
2156 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2158 switch (ec->resize_mode)
2160 case E_POINTER_RESIZE_TL:
2161 case E_POINTER_RESIZE_L:
2162 case E_POINTER_RESIZE_BL:
2163 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2164 ec->mouse.current.mx;
2166 case E_POINTER_RESIZE_TR:
2167 case E_POINTER_RESIZE_R:
2168 case E_POINTER_RESIZE_BR:
2169 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2174 switch (ec->resize_mode)
2176 case E_POINTER_RESIZE_TL:
2177 case E_POINTER_RESIZE_T:
2178 case E_POINTER_RESIZE_TR:
2179 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2180 ec->mouse.current.my;
2182 case E_POINTER_RESIZE_BL:
2183 case E_POINTER_RESIZE_B:
2184 case E_POINTER_RESIZE_BR:
2185 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2190 w = E_CLAMP(w, 1, w);
2191 h = E_CLAMP(h, 1, h);
2192 e_client_resize_limit(ec, &w, &h);
2194 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2196 else if ((!ec->fullscreen) && (!ec->maximized) &&
2197 (!ec->comp_data->maximize_pre))
2201 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2202 if ((pw != ec->w) || (ph != ec->h))
2204 _e_comp_wl_configure_send(ec, 1, 1);
2208 if (ec->comp_data->sub.below_obj)
2209 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2213 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2215 E_Client *ec = data;
2217 ec->comp_data->maximize_pre = 1;
2221 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2223 E_Client *ec = data;
2226 if (e_object_is_del(E_OBJECT(ec))) return;
2228 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2229 e_client_shell_configure_send(ec, 0, w, h);
2231 ec->comp_data->maximize_pre = 0;
2235 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2237 E_Client *ec = data;
2239 ec->comp_data->maximize_pre = 1;
2243 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2245 E_Client *ec = data;
2247 if (e_object_is_del(E_OBJECT(ec))) return;
2249 /* check for wayland pixmap */
2251 if (ec->comp_data->shell.configure_send)
2252 _e_comp_wl_configure_send(ec, 0, 0);
2254 ec->comp_data->maximize_pre = 0;
2258 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2260 E_Client *ec = data;
2262 if (e_object_is_del(E_OBJECT(ec))) return;
2264 /* check for wayland pixmap */
2266 if (ec->comp_data->shell.configure_send)
2267 _e_comp_wl_configure_send(ec, 0, 1);
2269 ec->comp_data->maximize_pre = 0;
2273 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2275 E_Client *ec = data;
2277 if (e_object_is_del(E_OBJECT(ec))) return;
2279 /* check for wayland pixmap */
2281 if (ec->comp_data->shell.configure_send)
2282 _e_comp_wl_configure_send(ec, 0, 0);
2284 ec->comp_data->maximize_pre = 0;
2288 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2292 if (!(ec = data)) return;
2294 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2296 e_object_del(E_OBJECT(ec));
2298 _e_comp_wl_focus_check();
2300 /* TODO: Delete request send ??
2301 * NB: No such animal wrt wayland */
2305 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2309 if (!(ec = data)) return;
2311 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2314 if (ec->comp_data->reparented)
2315 e_client_comp_hidden_set(ec, EINA_TRUE);
2318 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2319 if (ec->visible) evas_object_hide(ec->frame);
2320 if (!ec->internal) e_object_del(E_OBJECT(ec));
2322 _e_comp_wl_focus_check();
2326 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2330 if (!(ec = data)) return;
2332 e_client_shell_ping(ec);
2336 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2341 if (!(ec = data)) return;
2342 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2343 if (ec->netwm.opacity == a) return;
2344 ec->netwm.opacity = a;
2345 ec->netwm.opacity_changed = EINA_TRUE;
2349 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2351 Eina_Rectangle *damage_rect = NULL;
2352 Eina_Rectangle *dmg = NULL;
2353 Eina_List *l = NULL;
2355 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2356 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2359 if (!buffer->tbm_surface) return;
2363 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2367 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2368 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2371 eina_rectangle_union(damage_rect, dmg);
2376 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2377 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2380 tbm_surface_internal_set_damage(buffer->tbm_surface,
2386 eina_rectangle_free(damage_rect);
2390 _e_comp_wl_client_evas_init(E_Client *ec)
2392 if (!ec || !ec->comp_data) return;
2393 if (ec->comp_data->evas_init) return;
2395 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2396 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2397 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2400 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2401 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2403 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2404 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2405 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2407 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2408 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2409 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2411 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2412 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2416 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2417 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2418 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2419 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2420 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2421 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2422 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2425 /* setup delete/kill callbacks */
2426 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2427 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2429 /* setup ping callback */
2430 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2431 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2433 ec->comp_data->evas_init = EINA_TRUE;
2437 _e_comp_wl_client_evas_deinit(E_Client *ec)
2439 if (!ec || !ec->comp_data) return;
2440 if (!ec->comp_data->evas_init) return;
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2446 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2449 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2453 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2454 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2455 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2457 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2458 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2462 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2463 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2464 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2465 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2466 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2467 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2468 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2471 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2472 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2474 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2475 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2477 ec->comp_data->evas_init = EINA_FALSE;
2481 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2485 E_Comp_Screen *e_comp_screen;
2486 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2488 if (!e_comp) return ECORE_CALLBACK_RENEW;
2489 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2490 e_comp_screen = e_comp->e_comp_screen;
2492 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2494 if (!eout->config.enabled)
2496 e_comp_wl_output_remove(eout->id);
2500 switch (eout->config.rotation)
2503 transform = WL_OUTPUT_TRANSFORM_90;
2506 transform = WL_OUTPUT_TRANSFORM_180;
2509 transform = WL_OUTPUT_TRANSFORM_270;
2513 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2517 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2519 eout->config.geom.x, eout->config.geom.y,
2520 eout->config.geom.w, eout->config.geom.h,
2521 eout->info.size.w, eout->info.size.h,
2522 eout->config.mode.refresh, 0, transform))
2523 ERR("Could not initialize screen %s", eout->info.name);
2526 return ECORE_CALLBACK_RENEW;
2530 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2534 /* try to get the client from the object */
2535 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2536 return ECORE_CALLBACK_RENEW;
2538 /* check for client being deleted */
2539 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2541 /* check for wayland pixmap */
2542 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2543 return ECORE_CALLBACK_RENEW;
2545 /* if we have not setup evas callbacks for this client, do it */
2546 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2548 return ECORE_CALLBACK_RENEW;
2552 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2556 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2557 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2559 if (e_comp_wl->selection.target &&
2562 struct wl_resource *res;
2564 E_Client *ec = NULL;
2565 E_Client *legacy_target = e_comp_wl->selection.target;
2566 int device_id = e_comp_wl_data_current_device_id_get();
2570 e_comp_wl_data_current_device_id_set(ev->multi.device);
2572 else if (device_id != ev->multi.device)
2574 return ECORE_CALLBACK_RENEW;
2577 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2578 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2580 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2581 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2583 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2584 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2586 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2587 (ec != legacy_target))
2589 e_comp_wl_data_device_send_leave(legacy_target);
2590 e_comp_wl_data_device_send_enter(ec);
2593 if (e_comp_wl->drag)
2594 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2596 if (e_client_transform_core_enable_get(ec))
2598 int trans_x, trans_y;
2599 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2600 x = trans_x - ec->client.x;
2601 y = trans_y - ec->client.y;
2605 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2610 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2613 return ECORE_CALLBACK_RENEW;
2617 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2620 struct wl_resource *surface;
2621 struct wl_resource *res;
2622 struct wl_client *wc;
2624 E_Comp_Config *comp_conf;
2626 ec = e_comp_wl->ptr_constraints.ec;
2627 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2629 surface = e_comp_wl_client_surface_get(ec);
2630 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2632 wc = wl_resource_get_client(surface);
2634 comp_conf = e_comp_config_get();
2636 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2638 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2639 if (wl_resource_get_client(res) != wc) continue;
2641 if (comp_conf && comp_conf->input_log_enable)
2642 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2643 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2644 e_client_util_name_get(ec));
2646 zwp_relative_pointer_v1_send_relative_motion(res,
2648 (uint32_t)(ev->timestamp),
2649 wl_fixed_from_int(ev->dx),
2650 wl_fixed_from_int(ev->dy),
2651 wl_fixed_from_int(ev->dx_unaccel),
2652 wl_fixed_from_int(ev->dy_unaccel));
2655 return ECORE_CALLBACK_DONE;
2659 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2661 _e_comp_wl_touch_cancel();
2663 return ECORE_CALLBACK_PASS_ON;
2667 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2669 if (!ev) return ECORE_CALLBACK_PASS_ON;
2671 E_Zone *zone = ev->zone;
2673 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2674 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2676 if (!e_zone_is_displaying(zone))
2677 _e_comp_wl_touch_cancel();
2679 return ECORE_CALLBACK_PASS_ON;
2683 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2685 E_Client *ec = ev->ec;
2686 E_Comp_Wl_Buffer_Viewport *vp;
2688 if (!ec) return ECORE_CALLBACK_PASS_ON;
2689 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2690 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2691 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2692 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2694 vp = &ec->comp_data->scaler.buffer_viewport;
2695 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2697 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2699 return ECORE_CALLBACK_PASS_ON;
2703 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2705 E_Client *ec = ev->ec;
2706 E_Comp_Wl_Buffer_Viewport *vp;
2708 if (!ec) return ECORE_CALLBACK_PASS_ON;
2709 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2710 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2711 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2713 vp = &ec->comp_data->scaler.buffer_viewport;
2714 vp->wait_for_transform_change = 0;
2716 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2718 return ECORE_CALLBACK_PASS_ON;
2722 _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)
2724 E_Client *focused_ec;
2727 focused_ec = e_client_focused_get();
2728 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2730 rotation = focused_ec->e.state.rot.ang.curr;
2731 e_pointer_rotation_set(e_comp->pointer, rotation);
2733 return ECORE_CALLBACK_PASS_ON;
2737 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2740 Eina_Rectangle *window;
2745 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2747 if ((prev_w != state->bw) ||
2748 (prev_h != state->bh))
2750 ec->changes.buf_size = EINA_TRUE;
2753 if (e_comp_object_frame_exists(ec->frame)) return;
2754 window = &ec->comp_data->shell.window;
2755 if ((!ec->borderless) && /* FIXME temporarily added this check code
2756 * to prevent updating E_Client's size by frame */
2757 (window->x || window->y || window->w || window->h))
2759 e_comp_object_frame_geometry_set(ec->frame,
2761 (window->x + window->w) - state->bw,
2763 (window->y + window->h) - state->bh);
2766 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2770 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2772 E_Comp_Wl_Surface_State *state;
2775 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2776 state->buffer = NULL;
2780 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2782 state->new_attach = EINA_FALSE;
2783 state->buffer = NULL;
2784 state->buffer_destroy_listener.notify =
2785 _e_comp_wl_surface_state_cb_buffer_destroy;
2786 state->sx = state->sy = 0;
2788 state->input = eina_tiler_new(w, h);
2789 eina_tiler_tile_size_set(state->input, 1, 1);
2791 state->opaque = eina_tiler_new(w, h);
2792 eina_tiler_tile_size_set(state->opaque, 1, 1);
2794 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2795 state->buffer_viewport.buffer.scale = 1;
2796 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2797 state->buffer_viewport.surface.width = -1;
2798 state->buffer_viewport.changed = 0;
2800 e_presentation_time_container_init(&state->presentation_container);
2804 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2806 struct wl_resource *cb;
2807 Eina_Rectangle *dmg;
2809 EINA_LIST_FREE(state->frames, cb)
2810 wl_resource_destroy(cb);
2812 EINA_LIST_FREE(state->damages, dmg)
2813 eina_rectangle_free(dmg);
2815 EINA_LIST_FREE(state->buffer_damages, dmg)
2816 eina_rectangle_free(dmg);
2818 if (state->opaque) eina_tiler_free(state->opaque);
2819 state->opaque = NULL;
2821 if (state->input) eina_tiler_free(state->input);
2822 state->input = NULL;
2824 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2825 state->buffer = NULL;
2827 e_presentation_time_container_finish(&state->presentation_container);
2831 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2833 if (state->buffer == buffer) return;
2835 wl_list_remove(&state->buffer_destroy_listener.link);
2836 state->buffer = buffer;
2838 wl_signal_add(&state->buffer->destroy_signal,
2839 &state->buffer_destroy_listener);
2843 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2845 Eina_Rectangle *dmg;
2846 Eina_Bool placed = EINA_TRUE;
2850 E_Comp_Wl_Buffer *buffer;
2851 struct wl_resource *cb;
2853 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2854 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2859 if ((ec->internal) ||
2860 (cdata->shell.surface && state->new_attach))
2864 e_comp->new_clients++;
2865 ELOGF("COMP", "Unignore", ec);
2866 e_client_unignore(ec);
2870 /* buffer transform */
2871 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2874 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2876 /* when buffer is transformed, we have to apply the new evas-map */
2877 state->buffer_viewport.changed = EINA_TRUE;
2879 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2881 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2883 if (transform_change == vp->wait_for_transform_change)
2884 vp->wait_for_transform_change = 0;
2886 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2887 // triggered by E_CLIENT_HOOK calls at those file.
2888 zone = e_comp_zone_find_by_ec(ec);
2891 eout = e_output_find(zone->output_id);
2892 if (eout && eout->hwc)
2894 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2896 if (e_comp_is_on_overlay(ec))
2897 e_comp_hwc_client_end(ec, __FUNCTION__);
2903 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2904 cdata->scaler.buffer_viewport = state->buffer_viewport;
2906 if (state->new_attach)
2908 e_comp_wl_surface_attach(ec, state->buffer);
2911 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2912 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2914 _e_comp_wl_surface_state_buffer_set(state, NULL);
2916 if ((state->new_attach) ||
2917 (state->buffer_viewport.changed))
2919 _e_comp_wl_surface_state_size_update(ec, state);
2920 e_comp_wl_map_size_cal_from_viewport(ec);
2922 /* update the position */
2923 if (ec->changes.pos)
2925 e_comp_object_frame_xy_unadjust(ec->frame,
2935 if (ec->new_client) placed = ec->placed;
2937 if (!ec->lock_client_size)
2942 ec->client.w = state->bw;
2943 ec->client.h = state->bh;
2945 e_comp_object_frame_wh_adjust(ec->frame,
2946 ec->client.w, ec->client.h,
2948 e_client_size_set(ec, nw, nh);
2950 if ((w != ec->w) || (h != ec->h))
2952 ec->changes.size = 1;
2957 if (ec->changes.buf_size)
2959 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2960 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2961 ec->changes.buf_size = EINA_FALSE;
2963 if (ec->move_after_resize)
2965 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2966 ec->move_after_resize = EINA_FALSE;
2971 /* map or unmap ec */
2972 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2973 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2974 if (!pixmap_usable || hide_by_request)
2979 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2984 if ((cdata->sub.below_obj) &&
2985 (evas_object_visible_get(cdata->sub.below_obj)))
2987 evas_object_hide(cdata->sub.below_obj);
2995 if ((cdata->sub.below_obj) &&
2996 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2997 (evas_object_visible_get(ec->frame)))
2999 evas_object_show(cdata->sub.below_obj);
3003 if ((state->new_attach) ||
3004 (state->buffer_viewport.changed))
3006 if ((e_comp_wl->drag) &&
3007 (e_comp_wl->drag_client) &&
3008 (e_comp_wl->drag_client == ec))
3010 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3012 e_drag_move(e_comp_wl->drag,
3014 e_comp_wl->drag->y);
3016 e_drag_resize(e_comp_wl->drag,
3017 state->bw, state->bh);
3019 else if ((cdata->shell.surface) &&
3020 (cdata->shell.configure))
3022 e_comp_wl_commit_sync_configure(ec);
3024 else if (!e_client_video_hw_composition_check(ec))
3026 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3031 ec->placed = placed;
3032 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3036 if (cdata->scaler.buffer_viewport.changed)
3037 e_comp_wl_map_apply(ec);
3039 /* resize transform object */
3040 if (ec->transformed)
3041 e_client_transform_update(ec);
3045 state->new_attach = EINA_FALSE;
3047 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3049 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3050 wl_resource_destroy(cb);
3053 /* insert state frame callbacks into comp_data->frames
3054 * NB: This clears state->frames list */
3055 cdata->frames = eina_list_merge(cdata->frames,
3057 state->frames = NULL;
3059 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3060 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3061 &state->presentation_container);
3063 buffer = e_pixmap_resource_get(ec->pixmap);
3065 /* put state damages into surface */
3068 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3069 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3071 if ((cdata->buffer_ref.buffer) &&
3072 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3073 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3075 e_comp_object_damage(ec->frame,
3077 cdata->buffer_ref.buffer->w,
3078 cdata->buffer_ref.buffer->h);
3083 Eina_List *damages = NULL;
3086 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3088 if (eina_list_count(state->buffer_damages))
3090 EINA_LIST_FREE(state->buffer_damages, dmg)
3093 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3094 e_comp_wl_output_buffer_transform_get(ec),
3096 dmg->x, dmg->y, dmg->w, dmg->h,
3097 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3098 damages = eina_list_append(damages, dmg);
3102 EINA_LIST_FREE(state->damages, dmg)
3103 damages = eina_list_append(damages, dmg);
3105 EINA_LIST_FREE(damages, dmg)
3107 /* not creating damage for ec that shows a underlay video */
3108 if (state->buffer_viewport.changed ||
3109 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3110 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3111 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3113 eina_rectangle_free(dmg);
3118 /* put state opaque into surface */
3119 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3122 Eina_Rectangle *rect;
3125 itr = eina_tiler_iterator_new(state->opaque);
3126 EINA_ITERATOR_FOREACH(itr, rect)
3130 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3131 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3132 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3136 eina_iterator_free(itr);
3139 /* put state input into surface */
3140 if ((state->input) &&
3141 (!eina_tiler_empty(state->input)) &&
3144 Eina_Tiler *src, *tmp;
3148 tmp = eina_tiler_new(sw, sh);
3149 eina_tiler_tile_size_set(tmp, 1, 1);
3151 eina_tiler_rect_add(tmp,
3152 &(Eina_Rectangle){0, 0, sw, sh});
3154 if ((src = eina_tiler_intersection(state->input, tmp)))
3156 Eina_Rectangle *rect;
3159 e_comp_object_input_objs_del(ec->frame);
3160 itr = eina_tiler_iterator_new(src);
3161 EINA_ITERATOR_FOREACH(itr, rect)
3163 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3164 ec, rect->x, rect->y, rect->w, rect->h,
3165 ec->w, ec->h, state->bw, state->bh);
3166 e_comp_object_input_area_set(ec->frame,
3171 eina_iterator_free(itr);
3172 eina_tiler_free(src);
3175 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3177 eina_tiler_free(tmp);
3179 /* clear input tiler */
3180 eina_tiler_clear(state->input);
3183 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3185 if ((cdata->video_client) &&
3187 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3188 (e_comp->wl_comp_data->available_hw_accel.underlay))
3190 e_pixmap_image_clear(ec->pixmap, 1);
3193 state->buffer_viewport.changed = 0;
3195 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3198 ec->exp_iconify.buffer_flush &&
3199 e_policy_visibility_client_is_iconic(ec))
3201 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3206 _e_comp_wl_surface_render_stop(E_Client *ec)
3208 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3209 //if ((!ec->internal) && (!e_comp_gl_get()))
3212 /* check if internal animation is running */
3213 if (e_comp_object_is_animating(ec->frame)) return;
3214 /* check if external animation is running */
3215 if (evas_object_data_get(ec->frame, "effect_running")) return;
3217 evas_object_hide(ec->frame);
3221 e_comp_wl_client_surface_finish(E_Client *ec)
3223 struct wl_resource *res, *surface;
3224 struct wl_client *surface_client = NULL;
3227 surface = e_comp_wl_client_surface_get(ec);
3230 surface_client = wl_resource_get_client(surface);
3232 if (surface_client &&
3233 (ec == e_client_focused_get()))
3235 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3236 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3238 if (wl_resource_get_client(res) ==
3240 e_comp_wl->kbd.focused =
3241 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3245 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3248 e_comp_wl_client_surface_set(ec, NULL);
3250 ec->comp_data->wl_surface = NULL;
3251 e_pixmap_win_id_del(ec->pixmap);
3253 _e_comp_wl_surface_render_stop(ec);
3254 e_object_del(E_OBJECT(ec));
3258 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3263 char proc[512], pname[512];
3266 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3268 h = fopen(proc, "r");
3271 len = fread(pname, sizeof(char), 512, h);
3273 pname[len - 1] = '\0';
3275 strncpy(pname, "NO NAME", sizeof(pname));
3281 strncpy(pname, "NO NAME", sizeof(pname));
3284 strncpy(name, pname, size);
3288 _e_comp_wl_pname_print(pid_t pid)
3291 char proc[512], pname[512];
3294 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3296 h = fopen(proc, "r");
3299 len = fread(pname, sizeof(char), 512, h);
3301 pname[len - 1] = '\0';
3303 strncpy(pname, "NO NAME", sizeof(pname));
3307 ELOGF("COMP", " |%s", NULL, pname);
3312 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3314 struct wl_client *client = data;
3315 E_Comp_Connected_Client_Info *cinfo;
3318 cinfo = wl_container_of(listener, cinfo, destroy);
3320 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3321 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3323 eai = e_appinfo_find_with_pid(cinfo->pid);
3324 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3327 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3329 wl_list_remove(&cinfo->destroy.link);
3330 eina_stringshare_del(cinfo->name);
3335 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3337 E_Comp_Connected_Client_Info *cinfo;
3339 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3340 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3342 cinfo->name = eina_stringshare_add(name);
3346 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3347 wl_client_add_destroy_listener(client, &cinfo->destroy);
3348 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3350 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3354 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3356 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3358 /* send configure */
3359 if (ec->comp_data->shell.configure_send)
3361 if (ec->comp_data->shell.surface)
3362 _e_comp_wl_configure_send(ec, 0, 0);
3365 e_comp_wl->kbd.focus = ec->comp_data->surface;
3369 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3371 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3373 /* send configure */
3374 if (ec->comp_data->shell.configure_send)
3376 if (ec->comp_data->shell.surface)
3377 _e_comp_wl_configure_send(ec, 0, 0);
3380 _e_comp_wl_focus_check();
3382 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3383 e_comp_wl->kbd.focus = NULL;
3387 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3389 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3390 if (ec->keyboard_resizing) return;
3392 /* do nothing currently */
3397 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3399 if (e_object_is_del(E_OBJECT(ec))) return;
3400 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3402 e_comp_wl->resize.edges = 0;
3403 e_comp_wl->resize.resource = NULL;
3407 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3409 if (e_object_is_del(E_OBJECT(ec))) return;
3410 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3414 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3417 int ratio_w, ratio_h;
3419 phys_w = output->phys_width;
3420 phys_h = output->phys_height;
3422 if (e_config->configured_output_resolution.use)
3424 // change the configured physical size(mm) of the output
3425 if (output->w != res_w)
3427 ratio_w = res_w / output->w;
3428 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3431 if (output->h != res_h)
3433 ratio_h = res_h / output->h;
3434 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3437 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3440 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3441 NULL, res_w, res_h, phys_w, phys_h, pid);
3443 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3444 wl_output_send_scale(resource, output->scale);
3446 wl_output_send_geometry(resource, output->x, output->y,
3448 output->subpixel, output->make ?: "",
3449 output->model ?: "", output->transform);
3451 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3452 res_w, res_h, output->refresh);
3454 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3455 wl_output_send_done(resource);
3459 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3461 E_Comp_Wl_Output *output;
3463 if (!(output = wl_resource_get_user_data(resource))) return;
3465 output->resources = eina_list_remove(output->resources, resource);
3469 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3471 E_Comp_Wl_Output *output;
3472 struct wl_resource *resource;
3473 E_Appinfo *eai = NULL;
3477 if (!(output = data)) return;
3480 wl_resource_create(client, &wl_output_interface, version, id);
3483 wl_client_post_no_memory(client);
3487 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3488 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3490 output->resources = eina_list_append(output->resources, resource);
3492 wl_resource_set_implementation(resource, NULL, output,
3493 _e_comp_wl_cb_output_unbind);
3494 wl_resource_set_user_data(resource, output);
3496 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3497 if (e_config->configured_output_resolution.use)
3499 wl_client_get_credentials(client, &pid, NULL, NULL);
3502 res_w = e_config->configured_output_resolution.w;
3503 res_h = e_config->configured_output_resolution.h;
3507 eai = e_appinfo_find_with_pid(pid);
3510 res_w = e_config->configured_output_resolution.w;
3511 res_h = e_config->configured_output_resolution.h;
3515 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3517 res_w = e_config->configured_output_resolution.w;
3518 res_h = e_config->configured_output_resolution.h;
3522 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3531 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3535 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3538 Evas_GL *evasgl = NULL;
3539 Evas_GL_API *glapi = NULL;
3540 Evas_GL_Context *ctx = NULL;
3541 Evas_GL_Surface *sfc = NULL;
3542 Evas_GL_Config *cfg = NULL;
3544 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3546 if (!e_comp_gl_get()) return;
3548 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3549 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3551 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3552 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3554 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3555 * then we should get evas from ecore_evas.
3558 evas = e_comp->evas;
3560 evas = ecore_evas_get(e_comp->ee);
3562 evasgl = evas_gl_new(evas);
3563 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3565 glapi = evas_gl_api_get(evasgl);
3566 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3567 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3569 cfg = evas_gl_config_new();
3570 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3572 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3573 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3575 ctx = evas_gl_context_create(evasgl, NULL);
3576 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3578 res = evas_gl_make_current(evasgl, sfc, ctx);
3579 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3581 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3582 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3584 evas_gl_config_free(cfg);
3586 evas_gl->gl = evasgl;
3587 evas_gl->glapi = glapi;
3588 evas_gl->glsfc = sfc;
3589 evas_gl->glctx = ctx;
3591 e_comp_wl->evas_gl = evas_gl;
3593 /* for native surface */
3596 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3601 evas_gl_config_free(cfg);
3602 evas_gl_make_current(evasgl, NULL, NULL);
3603 evas_gl_context_destroy(evasgl, ctx);
3604 evas_gl_surface_destroy(evasgl, sfc);
3605 evas_gl_free(evasgl);
3612 _e_comp_wl_gl_popup_cb_close(void *data,
3613 Evas_Object *obj EINA_UNUSED,
3614 void *event_info EINA_UNUSED)
3616 evas_object_del(data);
3620 _e_comp_wl_gl_popup_cb_focus(void *data,
3621 Evas_Object *obj EINA_UNUSED,
3622 void *event_info EINA_UNUSED)
3624 elm_object_focus_set(data, EINA_TRUE);
3629 _e_comp_wl_gl_idle(void *data)
3633 /* show warning window to notify failure of gl init */
3636 Evas_Object *win, *bg, *popup, *btn;
3638 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3639 elm_win_title_set(win, "Compositor Warning");
3640 elm_win_autodel_set(win, EINA_TRUE);
3641 elm_win_borderless_set(win, EINA_TRUE);
3642 elm_win_role_set(win, "notification-low");
3643 elm_win_alpha_set(win, EINA_TRUE);
3645 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3646 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3647 elm_win_resize_object_add(win, bg);
3648 evas_object_color_set(bg, 125, 125, 125, 125);
3649 evas_object_show(bg);
3651 popup = elm_popup_add(win);
3652 elm_object_text_set(popup,
3653 _( "Your screen does not support OpenGL.<br>"
3654 "Falling back to software engine."));
3655 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3657 btn = elm_button_add(popup);
3658 elm_object_text_set(btn, "Close");
3659 elm_object_part_content_set(popup, "button1", btn);
3660 evas_object_show(btn);
3662 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3663 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3665 evas_object_show(popup);
3666 evas_object_show(win);
3670 return ECORE_CALLBACK_CANCEL;
3674 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3676 struct wl_client *client = data;
3682 wl_client_get_credentials(client, &pid, &uid, &gid);
3684 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3686 _e_comp_wl_pname_print(pid);
3687 _e_comp_wl_pname_get(pid, name, sizeof(name));
3688 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3692 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3694 char buf[1024] = {0, };
3696 vsnprintf(buf, 1024, fmt, args);
3700 DBG("[libds] %s", buf);
3703 INF("[libds] %s", buf);
3706 ERR("[libds] %s", buf);
3714 _e_comp_wl_display_create(void)
3717 E_Comp_Wl_Data *wl_cdata;
3722 /* create new compositor data */
3723 if (!(comp = E_NEW(E_Comp_Data, 1)))
3725 ERR("Could not create compositor data: %m");
3728 wl_cdata = &comp->base;
3730 /* set compositor wayland data */
3731 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3733 g_mutex_init(&connection_mutex);
3735 /* try to create a wayland display */
3736 if (!(wl_cdata->wl.disp = wl_display_create()))
3738 ERR("Could not create a Wayland display: %m");
3742 /* try to setup wayland socket */
3743 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3745 ERR("Could not create Wayland display socket: %m");
3746 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3750 res = e_comp_socket_init(name);
3751 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3752 PRCTL("[Winsys] change permission and create sym link for %s", name);
3754 /* set wayland display environment variable */
3755 e_env_set("WAYLAND_DISPLAY", name);
3757 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3758 /* wl_cdata->output.scale = e_scale; */
3760 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3762 if (!e_compositor_init(wl_cdata->wl.disp))
3764 ERR("Failed to initialize compositor");
3768 comp->client_created.notify = _e_comp_wl_cb_client_created;
3769 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3771 if (!e_comp_wl_subsurfaces_init())
3773 ERR("Failed to init_subsurfaces");
3774 goto subsurfaces_err;
3777 /* initialize shm mechanism */
3778 wl_display_init_shm(wl_cdata->wl.disp);
3780 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3782 /* try to init data manager */
3783 if (!e_comp_wl_data_manager_init())
3785 ERR("Could not initialize data manager");
3789 /* try to init input */
3790 if (!e_comp_wl_input_init())
3792 ERR("Could not initialize input");
3796 if (e_comp_gl_get())
3797 _e_comp_wl_gl_init(NULL);
3799 /* get the wayland display loop */
3800 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3802 /* get the file descriptor of the wayland event loop */
3803 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3805 /* create a listener for wayland main loop events */
3807 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3808 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3809 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3810 _e_comp_wl_cb_prepare, wl_cdata);
3815 e_comp_wl_data_manager_shutdown();
3817 e_comp_wl_subsurfaces_shutdown();
3819 wl_list_remove(&comp->client_created.link);
3821 e_env_unset("WAYLAND_DISPLAY");
3823 wl_display_destroy(wl_cdata->wl.disp);
3825 g_mutex_clear(&connection_mutex);
3831 _e_comp_wl_gl_shutdown(void)
3833 if (!e_comp_wl->evas_gl) return;
3835 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3837 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3838 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3839 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3840 evas_gl_free(e_comp_wl->evas_gl->gl);
3842 E_FREE(e_comp_wl->evas_gl);
3845 /* public functions */
3848 * Creates and initializes a Wayland compositor with ecore.
3849 * Registers callback handlers for keyboard and mouse activity
3850 * and other client events.
3852 * @returns true on success, false if initialization failed.
3855 e_comp_wl_init(void)
3857 TRACE_DS_BEGIN(COMP_WL:INIT);
3859 /* try to create a wayland compositor */
3860 if (!_e_comp_wl_display_create())
3862 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3867 e_comp_wl_shell_init();
3869 #ifdef HAVE_WAYLAND_TBM
3870 e_comp_wl_tbm_init();
3872 e_comp_wl_remote_surface_init();
3876 e_comp_wl_screenshooter_init();
3878 if (!e_comp_wl_video_init())
3879 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3881 e_comp_wl_viewport_init();
3882 e_comp_wl_capture_init();
3883 e_comp_wl_renderer_init();
3884 _e_comp_wl_move_resize_init();
3885 e_presentation_time_init();
3886 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3889 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3890 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3892 /* add event handlers to catch E events */
3893 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3894 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3895 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3896 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3897 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3898 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3899 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3900 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3901 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3903 /* add hooks to catch e_client events */
3904 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3905 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3906 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3907 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3908 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3910 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3917 e_comp_wl_deferred_job(void)
3919 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3922 /* internal functions */
3924 e_comp_wl_shutdown(void)
3926 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3928 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3930 e_comp_wl_subsurfaces_shutdown();
3932 E_FREE_LIST(handlers, ecore_event_handler_del);
3933 E_FREE_LIST(hooks, e_client_hook_del);
3934 _e_comp_wl_gl_shutdown();
3936 e_blender_shutdown();
3937 e_presentation_time_shutdown();
3938 e_comp_wl_renderer_shutdown();
3939 e_comp_wl_capture_shutdown();
3940 e_comp_wl_viewport_shutdown();
3941 e_comp_wl_video_shutdown();
3942 e_comp_wl_screenshooter_shutdown();
3944 e_comp_wl_remote_surface_shutdown();
3946 e_pixmap_shutdown();
3948 e_wtz_shell_shutdown();
3949 e_comp_wl_shell_shutdown();
3950 e_comp_wl_input_shutdown();
3952 wl_list_remove(&comp->client_created.link);
3955 e_comp->wl_comp_data = NULL;
3959 E_Comp_Wl_Output *output;
3961 if (e_comp_wl->screenshooter.global)
3962 wl_global_destroy(e_comp_wl->screenshooter.global);
3964 EINA_LIST_FREE(e_comp_wl->outputs, output)
3966 if (output->id) eina_stringshare_del(output->id);
3967 if (output->make) eina_stringshare_del(output->make);
3968 if (output->model) eina_stringshare_del(output->model);
3972 /* delete fd handler */
3973 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3975 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3976 cursor_timer_ec = NULL;
3978 /* free allocated data structure */
3984 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3986 e_object_unref(E_OBJECT(ev->ec));
3991 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3994 ev = E_NEW(E_Event_Client, 1);
3997 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3999 /* set usable early because shell module checks this */
4000 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4001 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4003 e_pixmap_resource_set(ec->pixmap, buffer);
4004 e_pixmap_dirty(ec->pixmap);
4005 e_pixmap_refresh(ec->pixmap);
4007 e_comp_wl_map_size_cal_from_buffer(ec);
4008 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4010 /* wm-policy module uses it */
4011 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4014 e_object_ref(E_OBJECT(ec));
4015 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4016 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4020 e_comp_wl_surface_commit(E_Client *ec)
4025 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4026 if (!e_comp_object_damage_exists(ec->frame))
4028 if ((ec->comp_data->video_client) ||
4029 (!e_client_video_hw_composition_check(ec)))
4030 e_pixmap_image_clear(ec->pixmap, 1);
4033 ignored = ec->ignored;
4035 if (e_comp_wl_subsurface_order_commit(ec))
4037 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4038 e_comp_wl_subsurface_restack(topmost);
4039 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4042 ec->ignored = ignored;
4044 if (ec->is_cursor && ec->visible)
4046 /* ignore cursor changes during resize/move I guess */
4047 if (!e_client_action_get())
4049 if (e_comp->pointer)
4051 x = e_comp->pointer->hot.x;
4052 y = e_comp->pointer->hot.y;
4054 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4060 static E_Comp_Wl_Output *
4061 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4064 E_Comp_Wl_Output *output;
4066 EINA_LIST_FOREACH(outputs, l, output)
4068 if (!strcmp(output->id, id))
4076 * Initializes information about one display output.
4078 * Adds or updates the given data about a single display output,
4079 * with an id matching the provided id.
4081 * @param id identification of output to be added or changed
4082 * @param make manufacturer name of the display output
4083 * @param model model name of the display output
4084 * @param x output's top left corner x coordinate
4085 * @param y output's top left corner y coordinate
4086 * @param w output's width in pixels
4087 * @param h output's height in pixels
4088 * @param pw output's physical width in millimeters
4089 * @param ph output's physical height in millimeters
4090 * @param refresh output's refresh rate in mHz
4091 * @param subpixel output's subpixel layout
4092 * @param transform output's rotation and/or mirror transformation
4094 * @returns True if a display output object could be added or updated
4097 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4098 int x, int y, int w, int h, int pw, int ph,
4099 unsigned int refresh, unsigned int subpixel,
4100 unsigned int transform)
4102 E_Comp_Wl_Output *output;
4104 struct wl_resource *resource;
4106 /* retrieve named output; or create it if it doesn't exist */
4107 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4110 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4112 if (id) output->id = eina_stringshare_add(id);
4114 output->make = eina_stringshare_add(make);
4116 output->make = eina_stringshare_add("unknown");
4118 output->model = eina_stringshare_add(model);
4120 output->model = eina_stringshare_add("unknown");
4122 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4125 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4126 2, output, _e_comp_wl_cb_output_bind);
4128 output->resources = NULL;
4129 output->scale = e_scale;
4132 /* update the output details */
4137 output->phys_width = pw;
4138 output->phys_height = ph;
4139 output->refresh = refresh;
4140 output->subpixel = subpixel;
4141 output->transform = transform;
4143 if (output->scale <= 0)
4144 output->scale = e_scale;
4146 /* if we have bound resources, send updates */
4147 EINA_LIST_FOREACH(output->resources, l2, resource)
4149 wl_output_send_geometry(resource,
4150 output->x, output->y,
4152 output->phys_height,
4154 output->make ?: "", output->model ?: "",
4157 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4158 wl_output_send_scale(resource, output->scale);
4160 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4161 output->w, output->h, output->refresh);
4163 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4164 wl_output_send_done(resource);
4171 e_comp_wl_output_remove(const char *id)
4173 E_Comp_Wl_Output *output;
4175 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4178 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4180 /* wl_global_destroy(output->global); */
4182 /* eina_stringshare_del(output->id); */
4183 /* eina_stringshare_del(output->make); */
4184 /* eina_stringshare_del(output->model); */
4191 _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)
4193 struct wl_resource *res;
4195 uint32_t serial, keycode;
4196 struct wl_client *wc = NULL;
4197 E_Comp_Config *comp_conf = NULL;
4198 const char *device_name = NULL;
4200 keycode = (ev->keycode - 8);
4202 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4204 comp_conf = e_comp_config_get();
4206 if (ec && ec->comp_data)
4208 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4211 wc = wl_resource_get_client(surface);
4214 if (e_config->key_input_ttrace_enable)
4216 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4217 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4220 EINA_LIST_FOREACH(key_list, l, res)
4222 if (wl_resource_get_client(res) != wc) continue;
4224 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4225 if (!e_input_thread_mode_get())
4227 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4228 device_name = ecore_device_name_get(ev->dev);
4234 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4235 device_name = e_device_name_get(dev);
4239 if (comp_conf && comp_conf->input_log_enable)
4240 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4242 wl_keyboard_send_key(res, serial, ev->timestamp,
4247 if (e_config->key_input_ttrace_enable)
4250 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4255 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4257 E_Client *ec = NULL;
4259 E_Comp_Wl_Key_Data *end, *k;
4261 if (ev->window != e_comp->ee_win)
4266 keycode = (ev->keycode - 8);
4267 if (!(e_comp_wl = e_comp->wl_comp_data))
4272 #ifndef E_RELEASE_BUILD
4273 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4274 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4275 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4276 eina_streq(ev->key, "BackSpace"))
4282 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4284 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4286 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4288 /* ignore server-generated key repeats */
4289 if (k->key == keycode)
4291 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4296 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4298 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4300 ec = e_client_focused_get();
4301 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4302 if (ec && ec->comp_data && surface)
4304 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4305 if (e_comp_wl->kbd.focused)
4307 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4309 /* A key only sent to clients is added to the list */
4310 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4311 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4313 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4315 DBG("wl_array_add: Out of memory\n");
4316 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4317 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4320 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4324 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4328 /* update modifier state */
4329 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4335 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4337 E_Client *ec = NULL;
4338 uint32_t keycode, delivered_key;
4339 E_Comp_Wl_Key_Data *end, *k;
4341 if (ev->window != e_comp->ee_win)
4346 keycode = (ev->keycode - 8);
4348 if (!(e_comp_wl = e_comp->wl_comp_data))
4353 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4355 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4356 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4358 if (k->key == keycode)
4365 e_comp_wl->kbd.keys.size =
4366 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4368 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4370 /* 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) */
4371 if ((delivered_key) ||
4372 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4374 ec = e_client_focused_get();
4376 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4377 if (e_comp_wl->kbd.focused)
4379 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4381 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4384 /* update modifier state */
4385 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4391 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4393 Eina_Bool res = EINA_FALSE;
4395 if (type == ECORE_EVENT_KEY_DOWN)
4397 res = e_comp_wl_key_down(ev, dev);
4399 else if (type == ECORE_EVENT_KEY_UP)
4401 res = e_comp_wl_key_up(ev, dev);
4408 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4411 struct wl_client *wc;
4412 uint32_t serial, btn;
4413 struct wl_resource *res;
4414 E_Comp_Config *comp_conf = NULL;
4416 if (ec->cur_mouse_action || e_comp_wl->drag)
4418 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4419 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4423 case 1: btn = BTN_LEFT; break;
4424 case 2: btn = BTN_MIDDLE; break;
4425 case 3: btn = BTN_RIGHT; break;
4426 default: btn = button_id; break;
4429 e_comp_wl->ptr.button = btn;
4430 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4431 if (!surface) return EINA_FALSE;
4433 if (!eina_list_count(e_comp_wl->ptr.resources))
4436 wc = wl_resource_get_client(surface);
4437 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4439 comp_conf = e_comp_config_get();
4441 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4443 if (wl_resource_get_client(res) != wc) continue;
4444 if (!e_comp_wl_input_pointer_check(res)) continue;
4445 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4447 if (comp_conf && comp_conf->input_log_enable)
4448 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4450 wl_pointer_send_button(res, serial, timestamp, btn, state);
4457 e_comp_wl_touch_cancel(void)
4459 _e_comp_wl_touch_cancel();
4462 E_API E_Comp_Wl_Hook *
4463 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4467 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4468 ch = E_NEW(E_Comp_Wl_Hook, 1);
4469 if (!ch) return NULL;
4470 ch->hookpoint = hookpoint;
4472 ch->data = (void*)data;
4473 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4478 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4481 if (_e_comp_wl_hooks_walking == 0)
4483 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4487 _e_comp_wl_hooks_delete++;
4490 E_API E_Comp_Wl_Pid_Hook *
4491 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4493 E_Comp_Wl_Pid_Hook *ch;
4495 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4497 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4498 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4500 ch->hookpoint = hookpoint;
4502 ch->data = (void*)data;
4503 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4509 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4512 if (_e_comp_wl_pid_hooks_walking == 0)
4514 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4518 _e_comp_wl_pid_hooks_delete++;
4521 E_API E_Comp_Wl_Intercept_Hook *
4522 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4524 E_Comp_Wl_Intercept_Hook *ch;
4526 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4527 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4528 if (!ch) return NULL;
4529 ch->hookpoint = hookpoint;
4531 ch->data = (void*)data;
4532 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4537 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4540 if (_e_comp_wl_intercept_hooks_walking == 0)
4542 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4546 _e_comp_wl_intercept_hooks_delete++;
4550 e_comp_wl_shell_surface_ready(E_Client *ec)
4554 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4558 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4560 e_config->use_cursor_timer = !!enabled;
4562 if (e_config->use_cursor_timer)
4564 if (!e_pointer_is_hidden(e_comp->pointer))
4566 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4571 if (e_comp_wl->ptr.hide_tmr)
4573 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4574 e_comp_wl->ptr.hide_tmr = NULL;
4576 cursor_timer_ec = NULL;
4578 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4581 if (e_pointer_is_hidden(e_comp->pointer))
4583 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4589 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4591 EINA_SAFETY_ON_NULL_RETURN(wc);
4592 EINA_SAFETY_ON_NULL_RETURN(dev);
4594 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4598 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4600 EINA_SAFETY_ON_NULL_RETURN(wc);
4601 EINA_SAFETY_ON_NULL_RETURN(dev);
4603 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4607 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4609 struct wl_resource *res;
4610 struct wl_client *wc;
4612 uint32_t serial, wl_keycode;
4613 enum wl_keyboard_key_state state;
4614 E_Comp_Config *comp_conf = NULL;
4615 const char *dev_name = NULL;
4617 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4618 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4619 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4621 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4622 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4624 wl_keycode = keycode - 8;
4625 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4627 wc = wl_resource_get_client(surface);
4628 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4629 if (!time) time = e_util_timestamp_get();
4630 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4631 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4633 comp_conf = e_comp_config_get();
4634 e_keyrouter_event_surface_send(ec, keycode);
4636 if (e_config->key_input_ttrace_enable)
4638 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4639 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4642 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4643 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4645 if (wl_resource_get_client(res) != wc) continue;
4646 if (!e_input_thread_mode_get())
4650 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4651 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4655 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4662 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4663 dev_name = e_device_name_get(dev);
4667 if (comp_conf && comp_conf->input_log_enable)
4668 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4671 wl_keyboard_send_key(res, serial, time,
4674 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4676 if (e_config->key_input_ttrace_enable)
4679 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4686 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4688 struct wl_resource *res;
4689 struct wl_client *wc;
4691 uint32_t serial, wl_keycode, cancel_keycode;
4692 E_Comp_Config *comp_conf = NULL;
4693 struct xkb_keymap *keymap = NULL;
4695 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4696 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4697 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4699 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4700 keymap = e_comp_wl->xkb.keymap;
4701 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4702 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4704 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4705 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4707 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4708 if (cancel_keycode == XKB_KEYCODE_INVALID)
4710 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4713 cancel_keycode = cancel_keycode - 8;
4715 wl_keycode = keycode - 8;
4716 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4718 wc = wl_resource_get_client(surface);
4719 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4720 if (!time) time = e_util_timestamp_get();
4722 comp_conf = e_comp_config_get();
4723 e_keyrouter_event_surface_send(ec, keycode);
4725 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4726 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4728 if (wl_resource_get_client(res) != wc) continue;
4729 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4730 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4732 if (comp_conf && comp_conf->input_log_enable)
4733 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4734 wl_keyboard_send_key(res, serial, time,
4735 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4736 wl_keyboard_send_key(res, serial, time,
4737 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4738 wl_keyboard_send_key(res, serial, time,
4739 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4741 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4748 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)
4750 struct wl_client *wc;
4752 E_Devicemgr_Input_Device *device = NULL;
4754 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4755 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4756 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4758 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4759 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4761 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4763 wc = wl_resource_get_client(surface);
4764 if (!time) time = e_util_timestamp_get();
4765 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4769 _e_comp_wl_send_event_device(wc, time, dev, serial);
4770 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4774 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4775 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4778 x = x + ec->client.x;
4779 y = y + ec->client.y;
4781 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4787 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)
4789 E_Devicemgr_Input_Device *device;
4791 struct wl_client *wc;
4793 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4794 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4795 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4797 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4800 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4802 wc = wl_resource_get_client(surface);
4803 if (!time) time = e_util_timestamp_get();
4804 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4808 _e_comp_wl_send_event_device(wc, time, dev, serial);
4809 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4813 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4814 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4817 x = x + ec->client.x;
4818 y = y + ec->client.y;
4820 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4826 e_comp_wl_touch_cancel_send(E_Client *ec)
4828 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4829 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4832 _e_comp_wl_send_touch_cancel(ec);
4838 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4841 struct wl_client *wc;
4843 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4844 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4845 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4847 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4848 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4850 wc = wl_resource_get_client(surface);
4851 if (!time) time = e_util_timestamp_get();
4852 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4854 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4855 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4858 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4859 WL_POINTER_BUTTON_STATE_PRESSED);
4861 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4862 WL_POINTER_BUTTON_STATE_RELEASED);
4868 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4871 struct wl_client *wc;
4873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4874 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4875 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4877 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4878 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4880 wc = wl_resource_get_client(surface);
4881 if (!time) time = e_util_timestamp_get();
4882 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4884 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4885 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4887 x = x + ec->client.x;
4888 y = y + ec->client.y;
4890 _e_comp_wl_send_mouse_move(ec, x, y, time);
4896 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4899 struct wl_client *wc;
4901 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4902 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4903 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4905 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4906 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4908 wc = wl_resource_get_client(surface);
4909 if (!time) time = e_util_timestamp_get();
4910 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4912 if (_e_comp_wl_check_cursor_timer_needed(ec))
4914 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4918 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4919 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4921 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4923 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4925 if (_e_comp_wl_check_cursor_timer_needed(ec))
4926 _e_comp_wl_cursor_move_timer_control(ec);
4933 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4936 struct wl_client *wc;
4937 struct wl_resource *res;
4940 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4941 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4943 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4944 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4946 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4947 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4949 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4950 wc = wl_resource_get_client(surface);
4951 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4952 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4954 if (!e_comp_wl_input_pointer_check(res)) continue;
4955 if (wl_resource_get_client(res) != wc) continue;
4957 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4958 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4960 wl_pointer_send_enter(res, serial, surface,
4961 wl_fixed_from_int(x),
4962 wl_fixed_from_int(y));
4963 ec->pointer_enter_sent = EINA_TRUE;
4965 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4971 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4974 struct wl_client *wc;
4975 struct wl_resource *res;
4978 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4979 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4980 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4981 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4982 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4983 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4985 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4986 wc = wl_resource_get_client(surface);
4987 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4988 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4990 if (!e_comp_wl_input_pointer_check(res)) continue;
4991 if (wl_resource_get_client(res) != wc) continue;
4993 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4994 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4996 wl_pointer_send_leave(res, serial, surface);
4997 ec->pointer_enter_sent = EINA_FALSE;
5004 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)
5006 Evas_Event_Mouse_In ev_in;
5009 if (ec->pointer_enter_sent) return;
5011 ev_in.buttons = buttons;
5019 ev_in.modifiers = modifiers;
5020 ev_in.locks = locks;
5021 ev_in.timestamp = timestamp;
5022 ev_in.event_flags = event_flags;
5025 ev_in.event_src = event_src;
5027 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5031 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)
5033 Evas_Event_Mouse_Out ev_out;
5036 if (!ec->pointer_enter_sent) return;
5038 ev_out.buttons = buttons;
5040 ev_out.output.x = x;
5041 ev_out.output.y = y;
5042 ev_out.canvas.x = x;
5043 ev_out.canvas.y = y;
5046 ev_out.modifiers = modifiers;
5047 ev_out.locks = locks;
5048 ev_out.timestamp = timestamp;
5049 ev_out.event_flags = event_flags;
5052 ev_out.event_src = event_src;
5054 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5058 e_comp_wl_cursor_hide(E_Client *ec)
5060 struct wl_resource *res;
5061 struct wl_client *wc;
5065 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5067 if (e_comp_wl->ptr.hide_tmr)
5069 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5070 e_comp_wl->ptr.hide_tmr = NULL;
5072 cursor_timer_ec = NULL;
5074 if (!ec) return EINA_FALSE;
5075 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5076 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5077 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5079 wc = wl_resource_get_client(surface);
5080 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5081 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5083 if (!e_comp_wl_input_pointer_check(res)) continue;
5084 if (wl_resource_get_client(res) != wc) continue;
5085 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5086 wl_pointer_send_leave(res, serial, surface);
5087 ec->pointer_enter_sent = EINA_FALSE;
5093 /* surface to buffer
5094 * - width : surface width
5095 * - height : surface height
5096 * - transform: buffer transform
5097 * - scale : buffer scale
5099 * - width : screen width
5100 * - height : screen height
5101 * - transform: output transform
5102 * - scale : output scale
5104 static E_Util_Transform_Matrix
5105 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5107 E_Util_Transform_Matrix m;
5109 e_util_transform_matrix_load_identity(&m);
5111 if (transform & 0x4)
5113 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5114 e_util_transform_matrix_flip_x(&m);
5115 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5118 switch (transform & 0x3)
5120 case WL_OUTPUT_TRANSFORM_90:
5121 e_util_transform_matrix_translate(&m, -width, 0, 0);
5122 e_util_transform_matrix_rotation_z(&m, 270);
5124 case WL_OUTPUT_TRANSFORM_180:
5125 e_util_transform_matrix_translate(&m, -width, -height, 0);
5126 e_util_transform_matrix_rotation_z(&m, 180);
5128 case WL_OUTPUT_TRANSFORM_270:
5129 e_util_transform_matrix_translate(&m, 0, -height, 0);
5130 e_util_transform_matrix_rotation_z(&m, 90);
5136 e_util_transform_matrix_scale(&m, scale, scale, 1);
5141 /* surface to buffer
5142 * - surface width, surface height, buffer transform, buffer scale
5144 * - screen width, screen height, output transform, output scale
5147 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5149 E_Util_Transform_Matrix m;
5150 E_Util_Transform_Vertex v;
5152 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5154 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5155 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5156 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5160 * - buffer width, buffer height, buffer transform, buffer scale
5163 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5165 E_Util_Transform_Matrix m;
5166 E_Util_Transform_Vertex v;
5169 if (transform != 0 || scale > 1)
5171 tw = ((transform % 2) ? height : width) / scale;
5172 th = ((transform % 2) ? width : height) / scale;
5180 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5181 m = e_util_transform_matrix_inverse_get(&m);
5183 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5184 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5185 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5188 /* surface to buffer
5189 * - surface width, surface height, buffer transform, buffer scale
5191 * - screen width, screen height, output transform, output scale
5194 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5195 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5197 E_Util_Transform_Matrix m;
5198 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5199 E_Util_Transform_Rect_Vertex sv;
5201 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5203 sv = e_util_transform_rect_to_vertices(&sr);
5204 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5205 sr = e_util_transform_vertices_to_rect(&sv);
5214 * - buffer width, buffer height, buffer transform, buffer scale
5217 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5218 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5220 E_Util_Transform_Matrix m;
5221 E_Util_Transform_Rect br = {bx, by, bw, bh};
5222 E_Util_Transform_Rect_Vertex bv;
5225 if (transform != 0 || scale > 1)
5227 tw = ((transform % 2) ? height : width) / scale;
5228 th = ((transform % 2) ? width : height) / scale;
5236 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5237 m = e_util_transform_matrix_inverse_get(&m);
5239 bv = e_util_transform_rect_to_vertices(&br);
5240 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5241 br = e_util_transform_vertices_to_rect(&bv);
5249 EINTERN E_Comp_Wl_Output*
5250 e_comp_wl_output_find(E_Client *ec)
5253 E_Comp_Wl_Output *output;
5255 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5257 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5259 if (output->transform % 2)
5261 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5262 ec->y < output->x || ec->y >= (output->x + output->w))
5267 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5268 ec->y < output->y || ec->y >= (output->y + output->h))
5278 EINTERN Eina_Array *
5279 e_comp_wl_output_find_all(E_Client *ec)
5281 E_Comp_Wl_Output *output;
5282 Eina_Array *outputs;
5285 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5287 outputs = eina_array_new(4);
5291 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5293 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5294 output->x, output->y, output->w, output->h))
5296 eina_array_push(outputs, output);
5300 if (eina_array_count(outputs) == 0)
5302 eina_array_free(outputs);
5309 // --------------------------------------------------------
5310 // tizen_move_resize
5311 // --------------------------------------------------------
5313 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5320 E_Client_Pending_Geometry *geo;
5323 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5324 if (ec->fullscreen || ec->maximized) goto err;
5326 geo = E_NEW(E_Client_Pending_Geometry, 1);
5329 geo->serial = serial;
5335 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5336 ec->surface_sync.wait_commit = EINA_TRUE;
5341 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5348 e_comp_wl_commit_sync_configure(E_Client *ec)
5351 E_Client_Pending_Geometry *geo;
5353 Eina_Bool match_size = EINA_FALSE;
5360 if (!ec || !ec->frame) goto ret;
5361 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5364 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5365 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5367 if (eina_list_count(ec->surface_sync.pending_geometry))
5369 Eina_List *ll = NULL;
5370 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5374 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5379 if ((geo->w == bw) && (geo->h == bh))
5381 match_size = EINA_TRUE;
5386 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5393 if ((config.w != ec->w) || (config.h != ec->h))
5395 e_client_size_set(ec, config.w, config.h);
5396 ec->changes.size = EINA_TRUE;
5400 // FIXME: The geometry of the client would be better to be calculated
5401 // at e_desk or at e_desk_area. So the position(x,y) of the client
5402 // should be calcuated at the e_desk or at the e_desk_area.
5404 desk = e_comp_desk_find_by_ec(ec);
5407 ec->client.x = desk->geom.x + config.x;
5408 ec->client.y = desk->geom.y + config.y;
5412 ec->client.x = config.x;
5413 ec->client.y = config.y;
5416 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5418 e_client_pos_set(ec, ec->client.x, ec->client.y);
5420 ec->changes.pos = 1;
5424 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5428 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5429 ec->surface_sync.wait_commit = EINA_FALSE;
5431 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5433 // rollback wait_commit if there are pending requests remained
5434 if (eina_list_count(ec->surface_sync.pending_geometry))
5435 ec->surface_sync.wait_commit = EINA_TRUE;
5440 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);
5447 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5448 struct wl_resource *res_moveresize)
5450 wl_resource_destroy(res_moveresize);
5454 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5455 struct wl_resource *res_moveresize,
5456 struct wl_resource *surface,
5463 /* to be implemented */
5466 int cur_w = 0, cur_h = 0;
5468 ec = e_client_from_surface_resource(surface);
5471 pending = e_client_pending_geometry_has(ec);
5472 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5473 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);
5477 if ((cur_w == w) && (cur_h == h))
5479 e_client_pos_set(ec, x, y);
5480 ec->changes.pos = 1;
5486 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5490 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5493 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5495 _tz_move_resize_iface_cb_destroy,
5496 _tz_move_resize_iface_cb_set_geometry,
5500 _tz_moveresize_cb_bind(struct wl_client *client,
5501 void *data EINA_UNUSED,
5505 struct wl_resource *res_moveresize;
5507 res_moveresize = wl_resource_create(client,
5508 &tizen_move_resize_interface,
5511 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5514 wl_resource_set_implementation(res_moveresize,
5515 &_tz_move_resize_iface,
5521 ERR("Could not create tizen_move_resize_interface res: %m");
5522 wl_client_post_no_memory(client);
5526 _e_comp_wl_move_resize_init(void)
5528 if (!e_comp_wl) return;
5529 if (!e_comp_wl->wl.disp) return;
5531 if (!wl_global_create(e_comp_wl->wl.disp,
5532 &tizen_move_resize_interface,
5535 _tz_moveresize_cb_bind))
5537 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5544 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5546 E_Comp_Wl_Output *output;
5547 pid_t output_pid = 0;
5548 Eina_List *l = NULL, *l2 = NULL;
5549 struct wl_resource *resource = NULL;
5551 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5553 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5554 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5555 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5557 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5559 /* if we have bound resources, send updates */
5560 EINA_LIST_FOREACH(output->resources, l2, resource)
5562 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5563 if (output_pid != pid) continue;
5565 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5567 // send output information to the client
5568 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5576 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5578 _e_comp_wl_surface_state_init(state, w, h);
5582 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5584 _e_comp_wl_surface_state_commit(ec, state);
5588 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5590 _e_comp_wl_hook_call(hookpoint, ec);
5594 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5596 _e_comp_wl_surface_state_finish(state);
5600 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5602 _e_comp_wl_surface_state_buffer_set(state, buffer);
5606 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5607 int sx, int sy, int *dx, int *dy)
5611 case WL_OUTPUT_TRANSFORM_NORMAL:
5615 case WL_OUTPUT_TRANSFORM_FLIPPED:
5616 *dx = width - sx, *dy = sy;
5618 case WL_OUTPUT_TRANSFORM_90:
5619 *dx = height - sy, *dy = sx;
5621 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5622 *dx = height - sy, *dy = width - sx;
5624 case WL_OUTPUT_TRANSFORM_180:
5625 *dx = width - sx, *dy = height - sy;
5627 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5628 *dx = sx, *dy = height - sy;
5630 case WL_OUTPUT_TRANSFORM_270:
5631 *dx = sy, *dy = width - sx;
5633 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5643 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5646 int tx1, ty1, tx2, ty2;
5647 int width_from_buffer, height_from_buffer;
5649 switch (vp->buffer.transform)
5651 case WL_OUTPUT_TRANSFORM_90:
5652 case WL_OUTPUT_TRANSFORM_270:
5653 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5654 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5655 width_from_buffer = bh / vp->buffer.scale;
5656 height_from_buffer = bw / vp->buffer.scale;
5659 width_from_buffer = bw / vp->buffer.scale;
5660 height_from_buffer = bh / vp->buffer.scale;
5664 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5668 x2 = width_from_buffer;
5669 y2 = height_from_buffer;
5673 x1 = wl_fixed_to_int(vp->buffer.src_x);
5674 y1 = wl_fixed_to_int(vp->buffer.src_y);
5675 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5676 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5679 buffer_transform(width_from_buffer, height_from_buffer,
5680 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5681 buffer_transform(width_from_buffer, height_from_buffer,
5682 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5684 out->x = (tx1 <= tx2) ? tx1 : tx2;
5685 out->y = (ty1 <= ty2) ? ty1 : ty2;
5686 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5687 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5691 * Convert given four coordinates to elements of rectangle
5692 * @in p[4] Coordinates to be converted
5693 * @out rect x, y, width, and height
5694 * transform Angle which represents TDM_TRANSFORM of rectangle
5695 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5696 * 1. The given coordinates are not represented by rectangle.
5697 * 2. All angles except for 0, 90, 180, 270.
5700 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5702 Eina_Bool ret = EINA_FALSE;
5704 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))
5707 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5710 *rotation = TDM_TRANSFORM_NORMAL;
5713 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5717 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5720 *rotation = TDM_TRANSFORM_180;
5723 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5728 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))
5731 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5734 *rotation = TDM_TRANSFORM_90;
5737 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5741 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5744 *rotation = TDM_TRANSFORM_270;
5747 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5757 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5762 for (i = 0; i < 4; i++)
5763 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5765 if (!_coords_to_rectangle_convert(p, out, rotation))
5767 DBG("Cannot convert given coords to rectangle.\n"
5768 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5769 p[0].x, p[0].y, p[1].x, p[1].y,
5770 p[2].x, p[2].y, p[3].x, p[3].y);
5778 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5780 int trans_rotation, flip;
5782 trans_rotation = transform & 0x3;
5783 flip = transform & 0x4;
5785 return (flip + (trans_rotation + rotation) % 4);
5789 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5797 if (e_comp_wl_subsurface_check(ec))
5798 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5805 out->w = ec->comp_data->width_from_viewport;
5806 out->w = (out->w + 1) & ~1;
5807 out->h = ec->comp_data->height_from_viewport;
5809 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5810 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5814 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5816 E_Comp_Wl_Buffer *buffer;
5817 E_Comp_Wl_Buffer_Viewport *vp;
5819 enum wl_output_transform buffer_transform;
5820 unsigned int rotation;
5821 Eina_Bool res = EINA_FALSE;
5823 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5825 if (e_object_is_del(E_OBJECT(ec)))
5828 vp = &ec->comp_data->scaler.buffer_viewport;
5830 if (buffer_viewport)
5832 buffer = ec->comp_data->buffer_ref.buffer;
5833 /* Getting a viewport of buffer needs geometry of buffer. */
5837 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5840 if ((output_viewport) || (transform))
5842 m = e_client_map_get(ec);
5844 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5846 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5851 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5852 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5853 * Since buffer.transform isn't applied using evas_map,
5854 * it has to be taken into account here to apply buffer.transform
5855 * and rotation of e_client_transform together. */
5857 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5859 *transform = (unsigned int)buffer_transform;
5867 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5869 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5870 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5872 /* Must be called with valid comp_data */
5873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5875 if ((ec->comp_data->role_name == NULL) ||
5876 (ec->comp_data->role_name == role_name) ||
5877 (strcmp(ec->comp_data->role_name, role_name) == 0))
5879 ec->comp_data->role_name = role_name;
5885 wl_resource_post_error(error_resource, error_code,
5886 "Cannot assign role %s to wl_surface@%d,"
5887 " already has role %s\n",
5889 ec->comp_data->wl_surface ?
5890 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5891 ec->comp_data->role_name);
5897 EINTERN const char *
5898 e_comp_wl_surface_role_get(E_Client *ec)
5900 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5901 return ec->comp_data ? ec->comp_data->role_name : NULL;
5904 EINTERN struct wl_resource *
5905 e_comp_wl_client_surface_get(E_Client *ec)
5907 struct wl_resource *surface = NULL;
5908 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5909 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5911 g_mutex_lock(&ec->comp_data->surface_mutex);
5912 surface = ec->comp_data->surface;
5913 g_mutex_unlock(&ec->comp_data->surface_mutex);
5918 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5920 EINA_SAFETY_ON_NULL_RETURN(ec);
5921 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5923 g_mutex_lock(&ec->comp_data->surface_mutex);
5924 ec->comp_data->surface = surface;
5925 g_mutex_unlock(&ec->comp_data->surface_mutex);
5929 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5931 return e_compositor_util_client_from_surface_resource(surface_resource);
5935 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5937 if (!ec->comp_data->mapped)
5939 if (ec->comp_data->shell.surface &&
5940 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5942 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5948 if (ec->comp_data->mapped)
5950 /* will be unmapped. so run capture */
5951 e_comp_wl_remote_surface_image_save(ec);
5955 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5957 ec->comp_data->pending.sx = sx;
5958 ec->comp_data->pending.sy = sy;
5959 ec->comp_data->pending.new_attach = EINA_TRUE;
5961 e_client_fps_update(ec);
5965 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5967 if (ec->comp_data->pending.opaque)
5968 eina_tiler_clear(ec->comp_data->pending.opaque);
5972 eina_tiler_union(ec->comp_data->pending.opaque, region);
5974 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5978 ec->argb = EINA_FALSE;
5979 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5981 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5982 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5990 ec->argb = EINA_TRUE;
5991 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5993 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5994 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6000 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6002 if (ec->comp_data->pending.input)
6003 eina_tiler_clear(ec->comp_data->pending.input);
6007 if (eina_tiler_empty(region))
6009 ELOGF("COMP", " |unset input rect", NULL);
6010 e_comp_object_input_objs_del(ec->frame);
6011 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6014 eina_tiler_union(ec->comp_data->pending.input, region);
6018 eina_tiler_rect_add(ec->comp_data->pending.input,
6019 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6024 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6026 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6030 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6032 E_Comp_Wl_Subsurf_Data *sdata;
6037 if (ec->comp_data->frames)
6039 ec->comp_data->frames =
6040 eina_list_remove(ec->comp_data->frames, callback_resource);
6043 if (ec->comp_data->pending.frames)
6045 ec->comp_data->pending.frames =
6046 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6049 sdata = ec->comp_data->sub.data;
6050 if ((sdata) && (sdata->cached.frames))
6052 sdata->cached.frames =
6053 eina_list_remove(sdata->cached.frames, callback_resource);
6058 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6060 if (e_object_is_del(E_OBJECT(ec))) return;
6062 if (e_comp_wl_remote_surface_commit(ec)) return;
6064 e_comp_wl_surface_commit(ec);
6066 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6070 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6072 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6073 ec->comp_data->sub.data = sub;
6075 /* set subsurface client properties */
6076 ec->borderless = EINA_TRUE;
6077 ec->argb = EINA_TRUE;
6078 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6079 ec->lock_border = EINA_TRUE;
6080 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6081 ec->netwm.state.skip_taskbar = EINA_TRUE;
6082 ec->netwm.state.skip_pager = EINA_TRUE;
6083 ec->border_size = 0;
6084 ec->lock_user_location = 0;
6085 ec->lock_client_location = 0;
6086 ec->lock_user_size = 0;
6087 ec->lock_client_size = 0;
6088 ec->lock_client_stacking = 0;
6089 ec->lock_user_maximize = 0;
6090 ec->lock_client_maximize = 0;
6091 ec->changes.need_maximize = 0;
6092 ec->maximized = E_MAXIMIZE_NONE;
6095 ec->new_client = ec->netwm.ping = EINA_TRUE;
6096 e_comp->new_clients++;
6097 e_client_unignore(ec);
6099 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6100 * It's not for subsurface. */
6101 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6105 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6107 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6110 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6112 sub->parent = parent;
6116 layer = e_client_layer_get(parent);
6117 if (layer > E_LAYER_BOTTOM)
6118 e_client_layer_set(ec, layer);
6121 if (parent->comp_data)
6123 /* append this client to the parents subsurface list */
6124 parent->comp_data->sub.list_pending =
6125 eina_list_append(parent->comp_data->sub.list_pending, ec);
6126 parent->comp_data->sub.list_changed = EINA_TRUE;
6131 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6133 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6134 E_Client *parent = sub->parent;
6136 parent->comp_data->sub.list =
6137 eina_list_remove(parent->comp_data->sub.list, ec);
6138 parent->comp_data->sub.list_pending =
6139 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6140 parent->comp_data->sub.below_list =
6141 eina_list_remove(parent->comp_data->sub.below_list, ec);
6142 parent->comp_data->sub.below_list_pending =
6143 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6149 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)
6151 sub->resource = subsurface_resource;
6152 sub->cached_buffer_ref.buffer = NULL;
6153 sub->synchronized = EINA_TRUE;
6154 sub->parent = parent;
6155 sub->remote_surface.offscreen_parent = offscreen_parent;
6156 if (offscreen_parent)
6157 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6159 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6161 _e_comp_wl_client_subsurface_set(ec, sub);
6162 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6164 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6168 e_comp_wl_client_subsurface_finish(E_Client *ec)
6170 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6173 e_comp_wl_client_subsurface_parent_unset(ec);
6175 e_comp_wl_surface_state_finish(&sub->cached);
6176 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6178 ec->comp_data->sub.data = NULL;
6182 e_comp_wl_client_evas_init(E_Client *ec)
6184 EINA_SAFETY_ON_NULL_RETURN(ec);
6186 _e_comp_wl_client_evas_init(ec);
6190 e_comp_wl_client_evas_deinit(E_Client *ec)
6192 EINA_SAFETY_ON_NULL_RETURN(ec);
6194 _e_comp_wl_client_evas_deinit(ec);
6198 e_comp_wl_focus_check(void)
6200 _e_comp_wl_focus_check();
6204 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6211 if ((parent->comp_data) && (parent->comp_data->sub.data))
6212 parent = parent->comp_data->sub.data->parent;