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"
23 #include <tizen-extension-server-protocol.h>
24 #include <relative-pointer-unstable-v1-server-protocol.h>
25 #include <pointer-constraints-unstable-v1-server-protocol.h>
27 #include <wayland-tbm-server.h>
29 #include <libds/log.h>
30 #include <libds/single_pixel_buffer_v1.h>
32 /* handle include for printing uint64_t */
33 #define __STDC_FORMAT_MACROS
36 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
38 /* Resource Data Mapping: (wl_resource_get_user_data)
40 * wl_surface == e_pixmap
41 * wl_region == eina_tiler
42 * wl_subsurface == e_client
46 typedef struct _E_Comp_Data E_Comp_Data;
51 struct wl_listener client_created;
54 static void _e_comp_wl_move_resize_init(void);
56 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
59 typedef struct _E_Comp_Wl_Key_Data
65 static Eina_List *handlers = NULL;
66 static E_Client *cursor_timer_ec = NULL;
67 static Eina_Bool need_send_released = EINA_FALSE;
68 static Eina_Bool need_send_motion = EINA_TRUE;
70 static GMutex connection_mutex;
72 static int _e_comp_wl_hooks_delete = 0;
73 static int _e_comp_wl_hooks_walking = 0;
75 static int _e_comp_wl_pid_hooks_delete = 0;
76 static int _e_comp_wl_pid_hooks_walking = 0;
78 static int _e_comp_wl_intercept_hooks_delete = 0;
79 static int _e_comp_wl_intercept_hooks_walking = 0;
81 static Eina_Inlist *_e_comp_wl_hooks[] =
83 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
84 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
85 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
86 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
87 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
88 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
89 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
90 [E_COMP_WL_HOOK_DEL] = NULL,
91 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
92 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
93 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
96 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
98 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
101 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
103 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
104 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
105 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
106 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
107 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
108 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
111 static Eina_List *hooks = NULL;
113 /* local functions */
115 _e_comp_wl_hooks_clean(void)
120 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
121 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
123 if (!ch->delete_me) continue;
124 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
130 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
134 e_object_ref(E_OBJECT(ec));
135 _e_comp_wl_hooks_walking++;
136 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
138 if (ch->delete_me) continue;
139 ch->func(ch->data, ec);
140 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
141 (e_object_is_del(E_OBJECT(ec))))
144 _e_comp_wl_hooks_walking--;
145 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
146 _e_comp_wl_hooks_clean();
147 e_object_unref(E_OBJECT(ec));
151 _e_comp_wl_pid_hooks_clean(void)
154 E_Comp_Wl_Pid_Hook *ch;
156 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
157 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
159 if (!ch->delete_me) continue;
160 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
166 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
168 E_Comp_Wl_Pid_Hook *ch;
170 _e_comp_wl_pid_hooks_walking++;
171 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
173 if (ch->delete_me) continue;
174 ch->func(ch->data, pid);
176 _e_comp_wl_pid_hooks_walking--;
177 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
178 _e_comp_wl_pid_hooks_clean();
182 _e_comp_wl_intercept_hooks_clean(void)
185 E_Comp_Wl_Intercept_Hook *ch;
187 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
188 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
190 if (!ch->delete_me) continue;
191 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
197 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
199 E_Comp_Wl_Intercept_Hook *ch;
200 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
202 e_object_ref(E_OBJECT(ec));
203 _e_comp_wl_intercept_hooks_walking++;
204 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
206 if (ch->delete_me) continue;
207 res = ch->func(ch->data, ec);
208 if (!res) ret = EINA_FALSE;
209 if (e_object_is_del(E_OBJECT(ec)))
212 _e_comp_wl_intercept_hooks_walking--;
213 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
214 _e_comp_wl_intercept_hooks_clean();
215 e_object_unref(E_OBJECT(ec));
222 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
228 if (e_comp_object_frame_exists(ec->frame))
229 w = ec->client.w, h = ec->client.h;
231 w = ec->w, h = ec->h;
235 // Width and Height are -1 means that we don't consider size value
239 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
243 _e_comp_wl_focus_check(void)
247 if (stopping) return;
248 ec = e_client_focused_get();
250 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
254 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
256 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
258 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
259 IDLE_EXITER~CB_PREPARE);
261 return ECORE_CALLBACK_RENEW;
265 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
267 /* dispatch pending wayland events */
268 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
270 return ECORE_CALLBACK_RENEW;
274 e_comp_wl_display_flush()
276 if (e_comp_wl && e_comp_wl->wl.disp)
278 if (e_config->key_input_ttrace_enable)
280 TRACE_INPUT_BEGIN(wl_display_flush_clients);
281 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
284 g_mutex_lock(&connection_mutex);
285 wl_display_flush_clients(e_comp_wl->wl.disp);
286 g_mutex_unlock(&connection_mutex);
288 if (e_config->key_input_ttrace_enable)
291 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
297 e_comp_wl_connection_lock()
299 e_input_boost_lock(&connection_mutex);
303 e_comp_wl_connection_unlock()
305 e_input_boost_unlock(&connection_mutex);
309 e_comp_wl_focused_client_flush()
311 E_Client *focused_ec;
312 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
314 e_input_boost_lock(&connection_mutex);
315 focused_ec = e_client_focused_get();
319 struct wl_client *wc;
320 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
323 e_input_boost_unlock(&connection_mutex);
327 wc = wl_resource_get_client(surface);
331 e_input_boost_unlock(&connection_mutex);
335 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
339 if (e_comp_wl->idle_exiter_timestamp > 0.0)
341 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
342 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
344 ELOGF("E_COMP", "prepare gap time: %lfms",
349 e_comp_wl->idle_exiter_timestamp = 0.0;
351 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
353 /* flush pending client events */
354 e_comp_wl_display_flush();
356 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
357 IDLE_EXITER~CB_PREPARE);
360 E_API enum wl_output_transform
361 e_comp_wl_output_buffer_transform_get(E_Client *ec)
363 E_Comp_Wl_Buffer_Viewport *vp;
364 E_Comp_Wl_Buffer *buffer;
365 enum wl_output_transform transform, rotation;
367 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
368 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
369 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
371 vp = &ec->comp_data->scaler.buffer_viewport;
372 if (e_comp_wl_subsurface_check(ec))
373 return vp->buffer.transform;
375 buffer = ec->comp_data->buffer_ref.buffer;
378 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
379 return vp->buffer.transform;
381 rotation = buffer->transform;
383 return vp->buffer.transform;
385 /* ignore the flip value when calculating transform because the screen rotation
386 * functionality doesn't consider the flip output transform currently
388 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
390 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
391 ec, rotation, vp->buffer.transform, transform);
396 EINTERN enum wl_output_transform
397 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
399 E_Comp_Wl_Buffer_Viewport *vp;
400 E_Comp_Wl_Buffer *buffer;
401 enum wl_output_transform transform, rotation;
403 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
404 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
405 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
407 vp = &ec->comp_data->pending.buffer_viewport;
408 if (e_comp_wl_subsurface_check(ec))
409 return vp->buffer.transform;
411 buffer = ec->comp_data->pending.buffer;
414 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
415 return vp->buffer.transform;
417 rotation = buffer->transform;
419 return vp->buffer.transform;
421 /* ignore the flip value when calculating transform because the screen rotation
422 * functionality doesn't consider the flip output transform currently
424 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
426 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
427 ec, rotation, vp->buffer.transform, transform);
433 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
435 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
436 E_Comp_Wl_Buffer *buffer;
437 int32_t width, height;
439 buffer = e_pixmap_resource_get(ec->pixmap);
442 ec->comp_data->width_from_buffer = 0;
443 ec->comp_data->height_from_buffer = 0;
447 switch (e_comp_wl_output_buffer_transform_get(ec))
449 case WL_OUTPUT_TRANSFORM_90:
450 case WL_OUTPUT_TRANSFORM_270:
451 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
452 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
453 width = buffer->h / vp->buffer.scale;
454 height = buffer->w / vp->buffer.scale;
457 width = buffer->w / vp->buffer.scale;
458 height = buffer->h / vp->buffer.scale;
462 ec->comp_data->width_from_buffer = width;
463 ec->comp_data->height_from_buffer = height;
467 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
469 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
470 int32_t width, height;
472 width = ec->comp_data->width_from_buffer;
473 height = ec->comp_data->height_from_buffer;
475 if (width == 0 && height == 0) return;
477 if (width != 0 && vp->surface.width != -1)
479 ec->comp_data->width_from_viewport = vp->surface.width;
480 ec->comp_data->height_from_viewport = vp->surface.height;
484 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
486 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
487 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
488 ec->comp_data->width_from_viewport = w ?: 1;
489 ec->comp_data->height_from_viewport = h ?: 1;
493 ec->comp_data->width_from_viewport = width;
494 ec->comp_data->height_from_viewport = height;
498 e_comp_wl_topmost_parent_get(E_Client *ec)
502 if (!e_comp_wl_subsurface_check(ec))
505 parent = e_comp_wl_subsurface_parent_get(ec);
508 if (!e_comp_wl_subsurface_check(parent))
511 parent = e_comp_wl_subsurface_parent_get(parent);
518 e_comp_wl_map_apply(E_Client *ec)
520 E_Comp_Wl_Buffer_Viewport *vp;
521 E_Comp_Wl_Subsurf_Data *sdata;
522 E_Comp_Wl_Client_Data *cdata;
523 int x1, y1, x2, y2, x, y;
525 Eina_Bool zoom_animating = EINA_FALSE;
527 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
529 e_comp_object_map_update(ec->frame);
531 cdata = ec->comp_data;
532 vp = &cdata->scaler.buffer_viewport;
533 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
534 (!cdata->viewport_transform))
537 if (e_comp_wl_subsurface_check(ec))
539 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
541 sdata = ec->comp_data->sub.data;
542 if (sdata->remote_surface.offscreen_parent)
544 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
545 Eina_Rectangle *rect;
548 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
550 /* TODO: If there are one more regions, it means that provider's offscreen
551 * is displayed by one more remote_surfaces. Have to consider it later. At
552 * this time, just consider only one remote_surface.
566 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
567 if (x != dx || y != dy)
568 evas_object_move(ec->frame, dx, dy);
570 if (!cdata->viewport_transform)
572 cdata->viewport_transform = e_util_transform_new();
573 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
574 e_client_transform_core_add(ec, cdata->viewport_transform);
577 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
578 ec->comp_data->width_from_viewport,
579 ec->comp_data->height_from_viewport);
581 if (vp->buffer.src_width == wl_fixed_from_int(-1))
585 x2 = cdata->width_from_buffer;
586 y2 = cdata->height_from_buffer;
590 x1 = wl_fixed_to_int(vp->buffer.src_x);
591 y1 = wl_fixed_to_int(vp->buffer.src_y);
592 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
593 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
596 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
597 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
598 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
599 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
602 desk = e_comp_desk_find_by_ec(ec);
604 zoom_animating = e_desk_zoom_is_animating(desk);
606 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
607 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
608 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
610 /* workaround:: when the desk zoom is doing their animation,
611 the transform core update can override animation's zoom boundary.
612 so, don't doing transform core update while desk zoom animation */
614 e_client_transform_core_update(ec);
619 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
623 int map_c = 0, map_x = 0, map_y = 0;
624 double inv_x = 0.0, inv_y = 0.0;
626 EINA_SAFETY_ON_NULL_RETURN(ec);
628 map = e_client_map_get(ec);
629 map_c = e_map_count_get(map);
631 if (!map || map_c <= 0)
641 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
642 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
643 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
644 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
646 for (int i = 0; i < map_c; i++)
648 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
649 e_map_point_image_uv_set(map2, i, map_x, map_y);
651 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
661 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
667 if (!(ec = data)) return;
668 if (e_object_is_del(data)) return;
670 if (!ec->override) e_hints_window_visible_set(ec);
672 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
673 (!ec->comp_data->need_reparent))
675 ec->comp_data->need_reparent = EINA_TRUE;
676 ec->visible = EINA_TRUE;
678 if (!e_client_util_ignored_get(ec))
680 ec->take_focus = !starting;
684 if (!ec->comp_data->need_reparent)
686 if ((ec->hidden) || (ec->iconic))
688 evas_object_hide(ec->frame);
689 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
692 evas_object_show(ec->frame);
695 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
696 evas_object_show(tmp->frame);
698 topmost = e_comp_wl_topmost_parent_get(ec);
699 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
700 e_comp_wl_subsurface_show(ec);
702 if (ec->comp_data->sub.below_obj)
703 evas_object_show(ec->comp_data->sub.below_obj);
707 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
713 if (!(ec = data)) return;
714 if (e_object_is_del(E_OBJECT(ec))) return;
716 /* Uncommonly some clients's final buffer can be skipped if the client
717 * requests unmap of its surface right after wl_surface@commit.
718 * So if this client evas object is hidden state and client is already
719 * unmmapped, we can consider to clear pixmap image here mandatorily.
721 if (!ec->comp_data->mapped)
722 e_pixmap_image_clear(ec->pixmap, 1);
724 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
725 evas_object_hide(tmp->frame);
727 topmost = e_comp_wl_topmost_parent_get(ec);
728 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
729 e_comp_wl_subsurface_hide(ec);
731 if (ec->comp_data->sub.below_obj)
732 evas_object_hide(ec->comp_data->sub.below_obj);
734 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
738 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
745 if (!(ec = data)) return;
746 if (e_object_is_del(E_OBJECT(ec))) return;
748 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
750 if (!e_comp_wl_subsurface_check(subc)) continue;
751 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
752 evas_object_move(subc->frame, x, y);
754 if (subc->comp_data->scaler.viewport)
756 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
757 if (cdata->viewport_transform)
758 e_comp_wl_map_apply(subc);
762 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
764 if (!e_comp_wl_subsurface_check(subc)) continue;
765 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
766 evas_object_move(subc->frame, x, y);
768 if (subc->comp_data->scaler.viewport)
770 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
771 if (cdata->viewport_transform)
772 e_comp_wl_map_apply(subc);
776 if (ec->comp_data->sub.below_obj)
778 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
779 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
784 _e_comp_wl_send_touch_cancel(E_Client *ec)
787 struct wl_resource *res;
788 struct wl_client *wc;
789 E_Comp_Config *comp_conf = NULL;
792 if (e_object_is_del(E_OBJECT(ec))) return;
793 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
795 if (!surface) return;
796 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
798 wc = wl_resource_get_client(surface);
800 comp_conf = e_comp_config_get();
802 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
804 if (wl_resource_get_client(res) != wc) continue;
805 if (!e_comp_wl_input_touch_check(res)) continue;
807 if (comp_conf && comp_conf->input_log_enable)
808 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
810 wl_touch_send_cancel(res);
815 _e_comp_wl_touch_cancel(void)
819 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
821 if (!e_comp_wl->touch.pressed) return;
823 _e_comp_wl_send_touch_cancel(ec);
826 static E_Devicemgr_Input_Device *
827 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
829 E_Devicemgr_Input_Device *last_kbd = NULL;
832 case ECORE_DEVICE_CLASS_MOUSE:
833 return e_devicemgr->last_device_ptr;
834 case ECORE_DEVICE_CLASS_KEYBOARD:
835 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
837 case ECORE_DEVICE_CLASS_TOUCH:
838 return e_devicemgr->last_device_touch;
846 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
850 case ECORE_DEVICE_CLASS_MOUSE:
851 e_devicemgr->last_device_ptr = device;
853 case ECORE_DEVICE_CLASS_KEYBOARD:
854 atomic_store(&e_devicemgr->last_device_kbd, device);
856 case ECORE_DEVICE_CLASS_TOUCH:
857 e_devicemgr->last_device_touch = device;
864 static E_Devicemgr_Input_Device *
865 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
867 E_Devicemgr_Input_Device *last_kbd = NULL;
871 case ECORE_DEVICE_CLASS_MOUSE:
872 return ec->comp_data->last_device_ptr;
873 case ECORE_DEVICE_CLASS_KEYBOARD:
874 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
876 case ECORE_DEVICE_CLASS_TOUCH:
877 return ec->comp_data->last_device_touch;
885 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
889 case ECORE_DEVICE_CLASS_MOUSE:
890 ec->comp_data->last_device_ptr = device;
892 case ECORE_DEVICE_CLASS_KEYBOARD:
893 atomic_store(&ec->comp_data->last_device_kbd, device);
895 case ECORE_DEVICE_CLASS_TOUCH:
896 ec->comp_data->last_device_touch = device;
904 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
906 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
907 struct wl_resource *dev_res;
908 const char *dev_name;
909 Ecore_Device_Class dev_class;
910 struct wl_client *wc;
914 EINA_SAFETY_ON_NULL_RETURN(dev);
917 if (ec->cur_mouse_action || e_comp_wl->drag)
919 if (e_object_is_del(E_OBJECT(ec))) return;
920 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
921 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
922 if (!surface) return;
924 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
925 dev_name = evas_device_description_get(dev);
926 last_device = _e_comp_wl_device_last_device_get(dev_class);
927 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
929 serial = wl_display_next_serial(e_comp_wl->wl.disp);
930 wc = wl_resource_get_client(surface);
931 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
932 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
934 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
935 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
937 _e_comp_wl_device_last_device_set(dev_class, input_dev);
938 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
940 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
942 if (wl_resource_get_client(dev_res) != wc) continue;
943 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
947 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
951 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
953 E_Devicemgr_Input_Device *last_device;
954 struct wl_resource *dev_res;
955 struct wl_client *wc;
959 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
960 if (!surface) return;
962 last_device = _e_comp_wl_device_last_device_get(dev_class);
963 if (!last_device) return;
965 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
967 serial = wl_display_next_serial(e_comp_wl->wl.disp);
968 wc = wl_resource_get_client(surface);
969 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
971 if (wl_resource_get_client(dev_res) != wc) continue;
972 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
977 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
979 E_Devicemgr_Input_Device *input_dev;
980 struct wl_resource *dev_res;
981 const char *dev_name;
984 EINA_SAFETY_ON_NULL_RETURN(dev);
986 dev_name = ecore_device_identifier_get(dev);
988 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
989 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
991 if (!eina_streq(input_dev->identifier, dev_name) ||
992 (input_dev->clas != ecore_device_class_get(dev))) continue;
993 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
995 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
997 if (wl_resource_get_client(dev_res) != wc) continue;
998 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1001 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1005 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1007 E_Devicemgr_Input_Device *input_dev;
1008 struct wl_resource *dev_res;
1009 const char *dev_name;
1012 EINA_SAFETY_ON_NULL_RETURN(dev);
1014 dev_name = e_device_identifier_get(dev);
1016 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1017 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1019 if (!eina_streq(input_dev->identifier, dev_name) ||
1020 (input_dev->clas != e_device_class_get(dev))) continue;
1021 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1023 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1025 if (wl_resource_get_client(dev_res) != wc) continue;
1026 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1029 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1033 _e_comp_wl_cursor_reload(E_Client *ec)
1035 struct wl_resource *res;
1036 struct wl_client *wc;
1042 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1043 !evas_object_visible_get(e_comp->pointer->o_ptr))
1044 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1047 if (e_object_is_del(E_OBJECT(ec))) return;
1048 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1049 if (!surface) return;
1050 if (ec->pointer_enter_sent) return;
1052 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1053 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1055 if (e_client_transform_core_enable_get(ec))
1057 double dx = 0.0, dy = 0.0;
1058 map = e_client_map_get(ec);
1059 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1065 cx = px - ec->client.x;
1066 cy = py - ec->client.y;
1068 wc = wl_resource_get_client(surface);
1069 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1070 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1072 if (!e_comp_wl_input_pointer_check(res)) continue;
1073 if (wl_resource_get_client(res) != wc) continue;
1074 wl_pointer_send_enter(res, serial, surface,
1075 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1076 ec->pointer_enter_sent = EINA_TRUE;
1078 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1082 _e_comp_wl_cursor_timer(void *data)
1084 E_Client *ec = data;
1086 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1087 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1089 e_comp_wl_cursor_hide(ec);
1091 return ECORE_CALLBACK_CANCEL;
1095 _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)
1097 E_Devicemgr_Input_Device *input_dev;
1098 struct wl_resource *dev_res;
1099 struct wl_client *wc;
1104 if (ec->cur_mouse_action) return;
1105 if (e_object_is_del(E_OBJECT(ec))) return;
1106 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1107 if (!surface) return;
1109 f_value = wl_fixed_from_double(value);
1110 wc = wl_resource_get_client(surface);
1112 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1113 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1115 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1116 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1118 if (wl_resource_get_client(dev_res) != wc) continue;
1119 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1122 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1126 _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)
1128 if (idx >= e_input_touch_max_count_get()) return;
1130 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1131 e_devicemgr->multi[idx].radius_x = radius_x;
1132 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1133 e_devicemgr->multi[idx].radius_y = radius_y;
1134 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1135 e_devicemgr->multi[idx].pressure = pressure;
1136 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1137 e_devicemgr->multi[idx].angle = angle;
1141 _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)
1143 if (idx >= e_input_touch_max_count_get()) return;
1145 if (e_devicemgr->multi[idx].radius_x != radius_x)
1147 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1148 e_devicemgr->multi[idx].radius_x = radius_x;
1150 if (e_devicemgr->multi[idx].radius_y != radius_y)
1152 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1153 e_devicemgr->multi[idx].radius_y = radius_y;
1155 if (e_devicemgr->multi[idx].pressure != pressure)
1157 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1158 e_devicemgr->multi[idx].pressure = pressure;
1160 if (e_devicemgr->multi[idx].angle != angle)
1162 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1163 e_devicemgr->multi[idx].angle = angle;
1168 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1170 Eina_Bool ret = EINA_TRUE;
1173 case EVAS_CALLBACK_MOUSE_IN:
1174 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1177 if (e_comp_wl->ptr.hide_tmr)
1179 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1180 cursor_timer_ec = ec;
1181 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1185 if (e_pointer_is_hidden(e_comp->pointer))
1190 case EVAS_CALLBACK_MOUSE_OUT:
1191 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1194 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1198 case EVAS_CALLBACK_MOUSE_MOVE:
1199 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1202 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1203 _e_comp_wl_cursor_reload(ec);
1206 case EVAS_CALLBACK_MOUSE_WHEEL:
1207 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1210 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1211 _e_comp_wl_cursor_reload(ec);
1214 case EVAS_CALLBACK_MOUSE_DOWN:
1215 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1218 if (e_comp_wl->ptr.hide_tmr)
1220 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1221 e_comp_wl->ptr.hide_tmr = NULL;
1223 cursor_timer_ec = NULL;
1225 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1226 _e_comp_wl_cursor_reload(ec);
1229 case EVAS_CALLBACK_MOUSE_UP:
1230 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1241 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1243 if (ec->has_cursor_unset)
1246 if (!e_config->show_cursor)
1249 if (!e_config->use_cursor_timer)
1256 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1259 Evas_Event_Mouse_In *ev;
1260 struct wl_resource *res;
1261 struct wl_client *wc;
1264 E_Comp_Config *comp_conf;
1265 E_Client *prev_ptr_ec;
1269 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1270 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1272 if (!(ec = data)) return;
1273 if (e_object_is_del(E_OBJECT(ec))) return;
1274 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1275 if (!surface) return;
1277 prev_ptr_ec = e_comp_wl->ptr.ec;
1280 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1281 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1284 e_comp_wl->ptr.ec = ec;
1286 comp_conf = e_comp_config_get();
1287 if (comp_conf && comp_conf->input_log_enable)
1288 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1289 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1290 e_client_util_name_get(ec));
1292 if (_e_comp_wl_check_cursor_timer_needed(ec))
1294 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1298 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1299 wc = wl_resource_get_client(surface);
1300 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1301 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1303 if (!e_comp_wl_input_pointer_check(res)) continue;
1304 if (wl_resource_get_client(res) != wc) continue;
1306 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1308 wl_pointer_send_enter(res, serial, surface,
1309 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1310 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1311 ec->pointer_enter_sent = EINA_TRUE;
1314 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1318 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1321 Evas_Event_Mouse_Out *ev;
1322 struct wl_resource *res;
1323 struct wl_client *wc;
1326 Eina_Bool inside_check;
1327 E_Comp_Config *comp_conf;
1331 if (!(ec = data)) return;
1332 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1333 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1334 if (ec->cur_mouse_action && inside_check) return;
1335 if (e_object_is_del(E_OBJECT(e_comp))) return;
1336 if (e_comp_wl->ptr.ec == ec)
1337 e_comp_wl->ptr.ec = NULL;
1338 if (e_object_is_del(E_OBJECT(ec))) return;
1340 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1341 if (!surface) return;
1343 comp_conf = e_comp_config_get();
1344 if (comp_conf && comp_conf->input_log_enable)
1345 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1346 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1347 e_client_util_name_get(ec));
1349 if (_e_comp_wl_check_cursor_timer_needed(ec))
1351 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1355 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1357 wc = wl_resource_get_client(surface);
1358 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1359 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1361 if (!e_comp_wl_input_pointer_check(res)) continue;
1362 if (wl_resource_get_client(res) != wc) continue;
1363 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1365 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1367 wl_pointer_send_leave(res, serial, surface);
1368 ec->pointer_enter_sent = EINA_FALSE;
1373 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1376 struct wl_client *wc;
1377 struct wl_resource *res;
1380 E_Comp_Config *comp_conf = NULL;
1383 if (e_object_is_del(E_OBJECT(ec))) return;
1384 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1385 if (!surface) return;
1387 wc = wl_resource_get_client(surface);
1388 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1392 x = wl_fixed_from_int(canvas_x - ec->client.x);
1393 y = wl_fixed_from_int(canvas_y - ec->client.y);
1396 comp_conf = e_comp_config_get();
1398 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1400 if (wl_resource_get_client(res) != wc) continue;
1401 if (!e_comp_wl_input_touch_check(res)) continue;
1402 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1405 if (comp_conf && comp_conf->input_log_enable)
1406 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));
1408 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1412 if (comp_conf && comp_conf->input_log_enable)
1413 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));
1415 wl_touch_send_up(res, serial, timestamp, idx);
1422 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1425 struct wl_client *wc;
1426 struct wl_resource *res;
1430 if (ec->cur_mouse_action) return;
1431 if (e_object_is_del(E_OBJECT(ec))) return;
1432 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1433 if (!surface) return;
1435 wc = wl_resource_get_client(surface);
1437 x = wl_fixed_from_int(canvas_x - ec->client.x);
1438 y = wl_fixed_from_int(canvas_y - ec->client.y);
1440 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1442 if (wl_resource_get_client(res) != wc) continue;
1443 if (!e_comp_wl_input_touch_check(res)) continue;
1444 wl_touch_send_motion(res, timestamp, idx, x, y);
1449 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1451 struct wl_resource *res;
1452 struct wl_client *wc;
1456 if (ec->cur_mouse_action) return;
1457 if (e_object_is_del(E_OBJECT(ec))) return;
1458 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1459 if (!surface) return;
1461 wc = wl_resource_get_client(surface);
1462 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1464 if (!e_comp_wl_input_pointer_check(res)) continue;
1465 if (wl_resource_get_client(res) != wc) continue;
1466 wl_pointer_send_motion(res, timestamp,
1467 wl_fixed_from_int(x - ec->client.x),
1468 wl_fixed_from_int(y - ec->client.y));
1473 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1475 if (e_comp_wl->ptr.hide_tmr)
1477 if (cursor_timer_ec == ec)
1479 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1480 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1484 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1485 cursor_timer_ec = ec;
1486 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1491 cursor_timer_ec = ec;
1492 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1497 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1500 Evas_Event_Mouse_Move *ev;
1501 Evas_Device *dev = NULL;
1502 const char *dev_name;
1503 E_Comp_Config *comp_conf;
1507 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1508 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1510 if (!(ec = data)) return;
1511 if (e_object_is_del(E_OBJECT(ec))) return;
1512 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1513 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1514 if (!surface) return;
1516 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1519 dev_name = evas_device_description_get(dev);
1521 comp_conf = e_comp_config_get();
1522 if (comp_conf && comp_conf->input_log_enable)
1523 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1524 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1525 e_client_util_name_get(ec), dev_name);
1527 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1529 if (!e_comp_wl->drag_client)
1531 e_comp_wl->touch.faked_ec = ec;
1532 if (e_comp_wl->touch.pressed & (1 << 0))
1534 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1536 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1537 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1538 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1542 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1546 if (!e_comp_wl->drag_client)
1548 if (_e_comp_wl_check_cursor_timer_needed(ec))
1550 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1554 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1555 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1557 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1559 if (_e_comp_wl_check_cursor_timer_needed(ec))
1560 _e_comp_wl_cursor_move_timer_control(ec);
1564 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1569 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1571 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1572 if (e_object_is_del(E_OBJECT(ec))) return;
1573 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1574 if (!surface) return;
1575 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1577 e_comp_wl->ptr.button = BTN_LEFT;
1579 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1583 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1585 E_Client *ec = data;
1586 Evas_Event_Mouse_Down *ev = event;
1587 Evas_Device *dev = NULL;
1588 const Evas_Device *seat_dev;
1589 const char *dev_name, *seat_name;
1590 E_Comp_Config *comp_conf = NULL;
1593 if (e_object_is_del(E_OBJECT(ec))) return;
1596 dev_name = evas_device_description_get(dev);
1598 seat_dev = evas_device_parent_get(dev);
1599 seat_name = evas_device_name_get(seat_dev);
1601 comp_conf = e_comp_config_get();
1602 if (comp_conf && comp_conf->input_log_enable)
1603 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1604 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1605 dev_name, seat_name);
1607 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1609 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1611 e_comp_wl->touch.faked_ec = ec;
1614 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1615 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1616 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1618 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1619 e_comp_wl->touch.pressed |= (1 << 0);
1623 if (_e_comp_wl_check_cursor_timer_needed(ec))
1625 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1629 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1630 WL_POINTER_BUTTON_STATE_PRESSED);
1632 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1635 need_send_released = EINA_TRUE;
1639 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1641 E_Client *ec = data;
1642 Evas_Event_Mouse_Up *ev = event;
1643 Evas_Device *dev = NULL;
1644 const Evas_Device *seat_dev;
1645 const char *dev_name, *seat_name;;
1646 Evas_Event_Flags flags;
1647 E_Comp_Config *comp_conf = NULL;
1650 if (ec->cur_mouse_action) return;
1651 if (e_object_is_del(E_OBJECT(ec))) return;
1653 if (!need_send_released)
1655 need_send_motion = EINA_TRUE;
1659 dev_name = evas_device_description_get(dev);
1661 seat_dev = evas_device_parent_get(dev);
1662 seat_name = evas_device_name_get(seat_dev);
1663 flags = evas_event_default_flags_get(evas);
1665 comp_conf = e_comp_config_get();
1666 if (comp_conf && comp_conf->input_log_enable)
1667 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1668 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1669 dev_name, seat_name);
1671 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1673 e_comp_wl->touch.pressed &= ~(1 << 0);
1675 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1676 e_comp_wl->touch.faked_ec = NULL;
1679 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1681 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1683 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1686 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1687 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1688 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1692 if (_e_comp_wl_check_cursor_timer_needed(ec))
1694 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1698 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1699 WL_POINTER_BUTTON_STATE_RELEASED);
1701 if (_e_comp_wl_check_cursor_timer_needed(ec))
1702 _e_comp_wl_cursor_move_timer_control(ec);
1706 need_send_released = EINA_FALSE;
1710 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1712 struct wl_resource *res;
1713 struct wl_client *wc;
1718 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1720 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1723 dir = -wl_fixed_from_int(abs(z));
1725 dir = wl_fixed_from_int(z);
1728 if (e_object_is_del(E_OBJECT(ec))) return;
1729 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1730 if (!surface) return;
1732 wc = wl_resource_get_client(surface);
1733 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1735 if (!e_comp_wl_input_pointer_check(res)) continue;
1736 if (wl_resource_get_client(res) != wc) continue;
1737 wl_pointer_send_axis(res, timestamp, axis, dir);
1742 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1745 Evas_Event_Mouse_Wheel *ev;
1748 if (!(ec = data)) return;
1749 if (ec->cur_mouse_action) return;
1750 if (e_object_is_del(E_OBJECT(ec))) return;
1751 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1752 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1753 if (!surface) return;
1755 if (!eina_list_count(e_comp_wl->ptr.resources))
1758 if (_e_comp_wl_check_cursor_timer_needed(ec))
1760 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1764 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1766 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1768 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1770 if (_e_comp_wl_check_cursor_timer_needed(ec))
1771 _e_comp_wl_cursor_move_timer_control(ec);
1776 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1778 E_Client *ec = data;
1779 Evas_Event_Multi_Down *ev = event;
1780 Evas_Device *dev = NULL;
1781 const Evas_Device *seat_dev;
1782 const char *dev_name, *seat_name;
1783 Evas_Device_Class dev_class;
1784 E_Comp_Config *comp_conf = NULL;
1787 if (e_object_is_del(E_OBJECT(ec))) return;
1788 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1789 if (!surface) return;
1791 /* Do not deliver emulated single touch events to client */
1792 if (ev->device == 0) return;
1795 dev_name = evas_device_description_get(dev);
1796 e_comp_wl->touch.faked_ec = ec;
1798 seat_dev = evas_device_parent_get(dev);
1799 seat_name = evas_device_name_get(seat_dev);
1801 comp_conf = e_comp_config_get();
1802 if (comp_conf && comp_conf->input_log_enable)
1803 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1804 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1805 dev_name, seat_name);
1807 if (dev && dev_name)
1809 dev_class = evas_device_class_get(dev);
1810 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1811 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1814 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1815 e_comp_wl->touch.pressed |= (1 << ev->device);
1819 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1821 E_Client *ec = data;
1822 Evas_Event_Multi_Up *ev = event;
1823 Evas_Device *dev = NULL;
1824 const Evas_Device *seat_dev;
1825 const char *dev_name, *seat_name;
1826 Evas_Device_Class dev_class;
1827 Evas_Event_Flags flags;
1828 E_Comp_Config *comp_conf = NULL;
1831 if (e_object_is_del(E_OBJECT(ec))) return;
1832 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1833 if (!surface) return;
1835 /* Do not deliver emulated single touch events to client */
1836 if (ev->device == 0) return;
1838 flags = evas_event_default_flags_get(evas);
1840 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1841 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1842 e_comp_wl->touch.faked_ec = NULL;
1844 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1847 dev_name = evas_device_description_get(dev);
1849 seat_dev = evas_device_parent_get(dev);
1850 seat_name = evas_device_name_get(seat_dev);
1852 comp_conf = e_comp_config_get();
1853 if (comp_conf && comp_conf->input_log_enable)
1854 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1855 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1856 dev_name, seat_name);
1858 if (dev && dev_name)
1860 dev_class = evas_device_class_get(dev);
1861 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1862 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1865 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1869 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1871 E_Client *ec = data;
1872 Evas_Event_Multi_Move *ev = event;
1873 Evas_Device *dev = NULL;
1874 const char *dev_name;
1875 Evas_Device_Class dev_class;
1878 if (e_object_is_del(E_OBJECT(ec))) return;
1879 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1880 if (!surface) return;
1882 /* Do not deliver emulated single touch events to client */
1883 if (ev->device == 0) return;
1885 e_comp_wl->touch.faked_ec = ec;
1887 if (e_comp_wl->touch.pressed & (1 << ev->device))
1890 if (dev && (dev_name = evas_device_description_get(dev)))
1892 dev_class = evas_device_class_get(dev);
1893 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1894 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1897 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1902 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1905 char *file, buff[PATH_MAX];
1912 n = (getpriority(PRIO_PROCESS, pid) + adj);
1916 setpriority(PRIO_PROCESS, pid, n);
1919 use_adj = EINA_TRUE;
1921 if (!do_child) return;
1923 files = ecore_file_ls("/proc");
1924 EINA_LIST_FREE(files, file)
1926 if (!isdigit(file[0]))
1929 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1930 if ((f = fopen(buff, "r")))
1934 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1936 if (num_read == 2 && ppid == pid)
1937 _e_comp_wl_client_priority_adjust(pid2, set,
1939 adj_child, do_child);
1947 _e_comp_wl_client_priority_raise(E_Client *ec)
1949 if (!e_config->priority_control) return;
1950 if (ec->netwm.pid <= 0) return;
1951 if (ec->netwm.pid == getpid()) return;
1952 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1953 e_config->priority - 1, -1,
1954 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1958 _e_comp_wl_client_priority_normal(E_Client *ec)
1960 if (!e_config->priority_control) return;
1961 if (ec->netwm.pid <= 0) return;
1962 if (ec->netwm.pid == getpid()) return;
1963 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1964 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1968 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1971 E_Comp_Wl_Key_Data *k;
1972 struct wl_resource *res;
1976 if (!ec) return EINA_FALSE;
1977 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1978 if (!ec->comp_data) return EINA_FALSE;
1980 ec->comp_data->on_focus_timer = NULL;
1981 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1982 if (!e_comp_wl->kbd.focused)
1984 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1987 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1989 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1990 t = ecore_time_unix_get();
1992 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1993 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1994 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1996 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1998 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1999 wl_keyboard_send_key(res, serial, t,
2000 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2003 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2004 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2008 /* It is called in the following cases:
2009 * When a normal ec->frame has focus.
2010 * Or launching image ec is replaced to the real ec.
2013 e_comp_wl_feed_focus_in(E_Client *ec)
2016 struct wl_resource *res;
2017 struct wl_client *wc;
2021 if (e_object_is_del(E_OBJECT(ec))) return;
2022 if (ec->iconic) return;
2024 /* block spurious focus events */
2025 focused = e_client_focused_get();
2026 if ((focused) && (ec != focused)) return;
2028 /* raise client priority */
2029 _e_comp_wl_client_priority_raise(ec);
2030 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2031 if (!surface) return;
2033 wc = wl_resource_get_client(surface);
2035 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2036 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2038 if (wl_resource_get_client(res) == wc)
2040 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2041 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2042 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2043 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2046 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2048 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2049 if (!e_comp_wl->kbd.focused)
2051 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2054 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2056 e_comp_wl->kbd.focus = surface;
2057 e_comp_wl_input_keyboard_enter_send(ec);
2058 e_comp_wl_data_device_keyboard_focus_set();
2059 ec->comp_data->on_focus_timer =
2060 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2061 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2062 int rotation = ec->e.state.rot.ang.curr;
2063 e_pointer_rotation_set(e_comp->pointer, rotation);
2067 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2070 if (!(ec = data)) return;
2071 e_comp_wl_feed_focus_in(ec);
2075 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2078 struct wl_resource *res;
2080 E_Comp_Wl_Key_Data *k;
2084 if (!(ec = data)) return;
2086 if (!ec->comp_data) return;
2088 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2090 /* lower client priority */
2091 if (!e_object_is_del(data))
2092 _e_comp_wl_client_priority_normal(ec);
2095 /* update keyboard modifier state */
2096 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2097 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2098 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2100 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2102 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2103 if (!surface) return;
2105 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2106 if (!eina_list_count(e_comp_wl->kbd.resources))
2108 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2112 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2114 /* send keyboard_leave to all keyboard resources */
2115 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2116 t = ecore_time_unix_get();
2118 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2119 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2120 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2122 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2124 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2125 wl_keyboard_send_key(res, serial, t,
2126 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2128 wl_keyboard_send_leave(res, serial, surface);
2129 e_comp_wl->kbd.focused =
2130 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2132 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2133 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2137 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2141 if (!(ec = data)) return;
2143 if (!ec->comp_data->shell.configure_send) return;
2145 /* TODO: calculate x, y with transfrom object */
2146 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2150 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2151 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2152 if (e_comp_object_frame_exists(ec->frame))
2153 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2155 switch (ec->resize_mode)
2157 case E_POINTER_RESIZE_TL:
2158 case E_POINTER_RESIZE_L:
2159 case E_POINTER_RESIZE_BL:
2160 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2161 ec->mouse.current.mx;
2163 case E_POINTER_RESIZE_TR:
2164 case E_POINTER_RESIZE_R:
2165 case E_POINTER_RESIZE_BR:
2166 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2171 switch (ec->resize_mode)
2173 case E_POINTER_RESIZE_TL:
2174 case E_POINTER_RESIZE_T:
2175 case E_POINTER_RESIZE_TR:
2176 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2177 ec->mouse.current.my;
2179 case E_POINTER_RESIZE_BL:
2180 case E_POINTER_RESIZE_B:
2181 case E_POINTER_RESIZE_BR:
2182 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2187 w = E_CLAMP(w, 1, w);
2188 h = E_CLAMP(h, 1, h);
2189 e_client_resize_limit(ec, &w, &h);
2191 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2193 else if ((!ec->fullscreen) && (!ec->maximized) &&
2194 (!ec->comp_data->maximize_pre))
2198 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2199 if ((pw != ec->w) || (ph != ec->h))
2201 _e_comp_wl_configure_send(ec, 1, 1);
2205 if (ec->comp_data->sub.below_obj)
2206 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2210 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2212 E_Client *ec = data;
2214 ec->comp_data->maximize_pre = 1;
2218 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2220 E_Client *ec = data;
2223 if (e_object_is_del(E_OBJECT(ec))) return;
2225 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2226 e_client_shell_configure_send(ec, 0, w, h);
2228 ec->comp_data->maximize_pre = 0;
2232 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2234 E_Client *ec = data;
2236 ec->comp_data->maximize_pre = 1;
2240 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2242 E_Client *ec = data;
2244 if (e_object_is_del(E_OBJECT(ec))) return;
2246 /* check for wayland pixmap */
2248 if (ec->comp_data->shell.configure_send)
2249 _e_comp_wl_configure_send(ec, 0, 0);
2251 ec->comp_data->maximize_pre = 0;
2255 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2257 E_Client *ec = data;
2259 if (e_object_is_del(E_OBJECT(ec))) return;
2261 /* check for wayland pixmap */
2263 if (ec->comp_data->shell.configure_send)
2264 _e_comp_wl_configure_send(ec, 0, 1);
2266 ec->comp_data->maximize_pre = 0;
2270 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2272 E_Client *ec = data;
2274 if (e_object_is_del(E_OBJECT(ec))) return;
2276 /* check for wayland pixmap */
2278 if (ec->comp_data->shell.configure_send)
2279 _e_comp_wl_configure_send(ec, 0, 0);
2281 ec->comp_data->maximize_pre = 0;
2285 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2289 if (!(ec = data)) return;
2291 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2293 e_object_del(E_OBJECT(ec));
2295 _e_comp_wl_focus_check();
2297 /* TODO: Delete request send ??
2298 * NB: No such animal wrt wayland */
2302 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2306 if (!(ec = data)) return;
2308 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2311 if (ec->comp_data->reparented)
2312 e_client_comp_hidden_set(ec, EINA_TRUE);
2315 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2316 if (ec->visible) evas_object_hide(ec->frame);
2317 if (!ec->internal) e_object_del(E_OBJECT(ec));
2319 _e_comp_wl_focus_check();
2323 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2327 if (!(ec = data)) return;
2329 e_client_shell_ping(ec);
2333 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2338 if (!(ec = data)) return;
2339 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2340 if (ec->netwm.opacity == a) return;
2341 ec->netwm.opacity = a;
2342 ec->netwm.opacity_changed = EINA_TRUE;
2346 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2348 Eina_Rectangle *damage_rect = NULL;
2349 Eina_Rectangle *dmg = NULL;
2350 Eina_List *l = NULL;
2352 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2353 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2356 if (!buffer->tbm_surface) return;
2360 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2364 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2365 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2368 eina_rectangle_union(damage_rect, dmg);
2373 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2374 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2377 tbm_surface_internal_set_damage(buffer->tbm_surface,
2383 eina_rectangle_free(damage_rect);
2387 _e_comp_wl_client_evas_init(E_Client *ec)
2389 if (!ec || !ec->comp_data) return;
2390 if (ec->comp_data->evas_init) return;
2392 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2393 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2394 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2397 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2398 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2399 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2400 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2401 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2404 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2405 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2406 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2408 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2409 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2413 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2414 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2415 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2416 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2417 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2418 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2419 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2422 /* setup delete/kill callbacks */
2423 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2424 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2426 /* setup ping callback */
2427 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2428 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2430 ec->comp_data->evas_init = EINA_TRUE;
2434 _e_comp_wl_client_evas_deinit(E_Client *ec)
2436 if (!ec || !ec->comp_data) return;
2437 if (!ec->comp_data->evas_init) return;
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2445 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2446 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2454 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2455 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2459 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2460 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2461 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2462 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2463 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2464 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2465 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2468 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2469 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2471 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2472 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2474 ec->comp_data->evas_init = EINA_FALSE;
2478 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2482 E_Comp_Screen *e_comp_screen;
2483 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2485 if (!e_comp) return ECORE_CALLBACK_RENEW;
2486 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2487 e_comp_screen = e_comp->e_comp_screen;
2489 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2491 if (!eout->config.enabled)
2493 e_comp_wl_output_remove(eout->id);
2497 switch (eout->config.rotation)
2500 transform = WL_OUTPUT_TRANSFORM_90;
2503 transform = WL_OUTPUT_TRANSFORM_180;
2506 transform = WL_OUTPUT_TRANSFORM_270;
2510 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2514 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2516 eout->config.geom.x, eout->config.geom.y,
2517 eout->config.geom.w, eout->config.geom.h,
2518 eout->info.size.w, eout->info.size.h,
2519 eout->config.mode.refresh, 0, transform))
2520 ERR("Could not initialize screen %s", eout->info.name);
2523 return ECORE_CALLBACK_RENEW;
2527 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2531 /* try to get the client from the object */
2532 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2533 return ECORE_CALLBACK_RENEW;
2535 /* check for client being deleted */
2536 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2538 /* check for wayland pixmap */
2539 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2540 return ECORE_CALLBACK_RENEW;
2542 /* if we have not setup evas callbacks for this client, do it */
2543 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2545 return ECORE_CALLBACK_RENEW;
2549 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2553 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2554 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2556 if (e_comp_wl->selection.target &&
2559 struct wl_resource *res;
2561 E_Client *ec = NULL;
2562 E_Client *legacy_target = e_comp_wl->selection.target;
2563 int device_id = e_comp_wl_data_current_device_id_get();
2567 e_comp_wl_data_current_device_id_set(ev->multi.device);
2569 else if (device_id != ev->multi.device)
2571 return ECORE_CALLBACK_RENEW;
2574 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2575 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2577 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2578 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2580 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2581 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2583 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2584 (ec != legacy_target))
2586 e_comp_wl_data_device_send_leave(legacy_target);
2587 e_comp_wl_data_device_send_enter(ec);
2590 if (e_comp_wl->drag)
2591 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2593 if (e_client_transform_core_enable_get(ec))
2595 int trans_x, trans_y;
2596 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2597 x = trans_x - ec->client.x;
2598 y = trans_y - ec->client.y;
2602 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2607 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2610 return ECORE_CALLBACK_RENEW;
2614 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2617 struct wl_resource *surface;
2618 struct wl_resource *res;
2619 struct wl_client *wc;
2621 E_Comp_Config *comp_conf;
2623 ec = e_comp_wl->ptr_constraints.ec;
2624 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2626 surface = e_comp_wl_client_surface_get(ec);
2627 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2629 wc = wl_resource_get_client(surface);
2631 comp_conf = e_comp_config_get();
2633 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2635 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2636 if (wl_resource_get_client(res) != wc) continue;
2638 if (comp_conf && comp_conf->input_log_enable)
2639 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2640 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2641 e_client_util_name_get(ec));
2643 zwp_relative_pointer_v1_send_relative_motion(res,
2645 (uint32_t)(ev->timestamp),
2646 wl_fixed_from_int(ev->dx),
2647 wl_fixed_from_int(ev->dy),
2648 wl_fixed_from_int(ev->dx_unaccel),
2649 wl_fixed_from_int(ev->dy_unaccel));
2652 return ECORE_CALLBACK_DONE;
2656 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2658 _e_comp_wl_touch_cancel();
2660 return ECORE_CALLBACK_PASS_ON;
2664 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2666 if (!ev) return ECORE_CALLBACK_PASS_ON;
2668 E_Zone *zone = ev->zone;
2670 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2671 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2673 if (!e_zone_is_displaying(zone))
2674 _e_comp_wl_touch_cancel();
2676 return ECORE_CALLBACK_PASS_ON;
2680 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2682 E_Client *ec = ev->ec;
2683 E_Comp_Wl_Buffer_Viewport *vp;
2685 if (!ec) return ECORE_CALLBACK_PASS_ON;
2686 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2687 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2688 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2689 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2691 vp = &ec->comp_data->scaler.buffer_viewport;
2692 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2694 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2696 return ECORE_CALLBACK_PASS_ON;
2700 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2702 E_Client *ec = ev->ec;
2703 E_Comp_Wl_Buffer_Viewport *vp;
2705 if (!ec) return ECORE_CALLBACK_PASS_ON;
2706 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2707 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2708 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2710 vp = &ec->comp_data->scaler.buffer_viewport;
2711 vp->wait_for_transform_change = 0;
2713 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2715 return ECORE_CALLBACK_PASS_ON;
2719 _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)
2721 E_Client *focused_ec;
2724 focused_ec = e_client_focused_get();
2725 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2727 rotation = focused_ec->e.state.rot.ang.curr;
2728 e_pointer_rotation_set(e_comp->pointer, rotation);
2730 return ECORE_CALLBACK_PASS_ON;
2734 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2737 Eina_Rectangle *window;
2742 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2744 if ((prev_w != state->bw) ||
2745 (prev_h != state->bh))
2747 ec->changes.buf_size = EINA_TRUE;
2750 if (e_comp_object_frame_exists(ec->frame)) return;
2751 window = &ec->comp_data->shell.window;
2752 if ((!ec->borderless) && /* FIXME temporarily added this check code
2753 * to prevent updating E_Client's size by frame */
2754 (window->x || window->y || window->w || window->h))
2756 e_comp_object_frame_geometry_set(ec->frame,
2758 (window->x + window->w) - state->bw,
2760 (window->y + window->h) - state->bh);
2763 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2767 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2769 E_Comp_Wl_Surface_State *state;
2772 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2773 state->buffer = NULL;
2777 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2779 state->new_attach = EINA_FALSE;
2780 state->buffer = NULL;
2781 state->buffer_destroy_listener.notify =
2782 _e_comp_wl_surface_state_cb_buffer_destroy;
2783 state->sx = state->sy = 0;
2785 state->input = eina_tiler_new(w, h);
2786 eina_tiler_tile_size_set(state->input, 1, 1);
2788 state->opaque = eina_tiler_new(w, h);
2789 eina_tiler_tile_size_set(state->opaque, 1, 1);
2791 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2792 state->buffer_viewport.buffer.scale = 1;
2793 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2794 state->buffer_viewport.surface.width = -1;
2795 state->buffer_viewport.changed = 0;
2797 e_presentation_time_container_init(&state->presentation_container);
2801 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2803 struct wl_resource *cb;
2804 Eina_Rectangle *dmg;
2806 EINA_LIST_FREE(state->frames, cb)
2807 wl_resource_destroy(cb);
2809 EINA_LIST_FREE(state->damages, dmg)
2810 eina_rectangle_free(dmg);
2812 EINA_LIST_FREE(state->buffer_damages, dmg)
2813 eina_rectangle_free(dmg);
2815 if (state->opaque) eina_tiler_free(state->opaque);
2816 state->opaque = NULL;
2818 if (state->input) eina_tiler_free(state->input);
2819 state->input = NULL;
2821 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2822 state->buffer = NULL;
2824 e_presentation_time_container_finish(&state->presentation_container);
2828 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2830 if (state->buffer == buffer) return;
2832 wl_list_remove(&state->buffer_destroy_listener.link);
2833 state->buffer = buffer;
2835 wl_signal_add(&state->buffer->destroy_signal,
2836 &state->buffer_destroy_listener);
2840 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2842 Eina_Rectangle *dmg;
2843 Eina_Bool placed = EINA_TRUE;
2847 E_Comp_Wl_Buffer *buffer;
2848 struct wl_resource *cb;
2850 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2851 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2856 if ((ec->internal) ||
2857 (cdata->shell.surface && state->new_attach))
2861 e_comp->new_clients++;
2862 ELOGF("COMP", "Unignore", ec);
2863 e_client_unignore(ec);
2867 /* buffer transform */
2868 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2871 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2873 /* when buffer is transformed, we have to apply the new evas-map */
2874 state->buffer_viewport.changed = EINA_TRUE;
2876 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2878 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2880 if (transform_change == vp->wait_for_transform_change)
2881 vp->wait_for_transform_change = 0;
2883 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2884 // triggered by E_CLIENT_HOOK calls at those file.
2885 zone = e_comp_zone_find_by_ec(ec);
2888 eout = e_output_find(zone->output_id);
2889 if (eout && eout->hwc)
2891 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2893 if (e_comp_is_on_overlay(ec))
2894 e_comp_hwc_client_end(ec, __FUNCTION__);
2900 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2901 cdata->scaler.buffer_viewport = state->buffer_viewport;
2903 if (state->new_attach)
2905 e_comp_wl_surface_attach(ec, state->buffer);
2908 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2909 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2911 _e_comp_wl_surface_state_buffer_set(state, NULL);
2913 if ((state->new_attach) ||
2914 (state->buffer_viewport.changed))
2916 _e_comp_wl_surface_state_size_update(ec, state);
2917 e_comp_wl_map_size_cal_from_viewport(ec);
2919 /* update the position */
2920 if (ec->changes.pos)
2922 e_comp_object_frame_xy_unadjust(ec->frame,
2932 if (ec->new_client) placed = ec->placed;
2934 if (!ec->lock_client_size)
2939 ec->client.w = state->bw;
2940 ec->client.h = state->bh;
2942 e_comp_object_frame_wh_adjust(ec->frame,
2943 ec->client.w, ec->client.h,
2945 e_client_size_set(ec, nw, nh);
2947 if ((w != ec->w) || (h != ec->h))
2949 ec->changes.size = 1;
2954 if (ec->changes.buf_size)
2956 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2957 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2958 ec->changes.buf_size = EINA_FALSE;
2960 if (ec->move_after_resize)
2962 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2963 ec->move_after_resize = EINA_FALSE;
2968 /* map or unmap ec */
2969 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2970 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2971 if (!pixmap_usable || hide_by_request)
2976 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2981 if ((cdata->sub.below_obj) &&
2982 (evas_object_visible_get(cdata->sub.below_obj)))
2984 evas_object_hide(cdata->sub.below_obj);
2992 if ((cdata->sub.below_obj) &&
2993 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2994 (evas_object_visible_get(ec->frame)))
2996 evas_object_show(cdata->sub.below_obj);
3000 if ((state->new_attach) ||
3001 (state->buffer_viewport.changed))
3003 if ((e_comp_wl->drag) &&
3004 (e_comp_wl->drag_client) &&
3005 (e_comp_wl->drag_client == ec))
3007 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3009 e_drag_move(e_comp_wl->drag,
3011 e_comp_wl->drag->y);
3013 e_drag_resize(e_comp_wl->drag,
3014 state->bw, state->bh);
3016 else if ((cdata->shell.surface) &&
3017 (cdata->shell.configure))
3019 e_comp_wl_commit_sync_configure(ec);
3021 else if (!e_client_video_hw_composition_check(ec))
3023 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3028 ec->placed = placed;
3029 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3033 if (cdata->scaler.buffer_viewport.changed)
3034 e_comp_wl_map_apply(ec);
3036 /* resize transform object */
3037 if (ec->transformed)
3038 e_client_transform_update(ec);
3042 state->new_attach = EINA_FALSE;
3044 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3046 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3047 wl_resource_destroy(cb);
3050 /* insert state frame callbacks into comp_data->frames
3051 * NB: This clears state->frames list */
3052 cdata->frames = eina_list_merge(cdata->frames,
3054 state->frames = NULL;
3056 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3057 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3058 &state->presentation_container);
3060 buffer = e_pixmap_resource_get(ec->pixmap);
3062 /* put state damages into surface */
3065 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3066 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3068 if ((cdata->buffer_ref.buffer) &&
3069 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3070 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3072 e_comp_object_damage(ec->frame,
3074 cdata->buffer_ref.buffer->w,
3075 cdata->buffer_ref.buffer->h);
3080 Eina_List *damages = NULL;
3083 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3085 if (eina_list_count(state->buffer_damages))
3087 EINA_LIST_FREE(state->buffer_damages, dmg)
3090 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3091 e_comp_wl_output_buffer_transform_get(ec),
3093 dmg->x, dmg->y, dmg->w, dmg->h,
3094 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3095 damages = eina_list_append(damages, dmg);
3099 EINA_LIST_FREE(state->damages, dmg)
3100 damages = eina_list_append(damages, dmg);
3102 EINA_LIST_FREE(damages, dmg)
3104 /* not creating damage for ec that shows a underlay video */
3105 if (state->buffer_viewport.changed ||
3106 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3107 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3108 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3110 eina_rectangle_free(dmg);
3115 /* put state opaque into surface */
3116 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3119 Eina_Rectangle *rect;
3122 itr = eina_tiler_iterator_new(state->opaque);
3123 EINA_ITERATOR_FOREACH(itr, rect)
3127 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3128 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3129 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3133 eina_iterator_free(itr);
3136 /* put state input into surface */
3137 if ((state->input) &&
3138 (!eina_tiler_empty(state->input)) &&
3141 Eina_Tiler *src, *tmp;
3145 tmp = eina_tiler_new(sw, sh);
3146 eina_tiler_tile_size_set(tmp, 1, 1);
3148 eina_tiler_rect_add(tmp,
3149 &(Eina_Rectangle){0, 0, sw, sh});
3151 if ((src = eina_tiler_intersection(state->input, tmp)))
3153 Eina_Rectangle *rect;
3156 e_comp_object_input_objs_del(ec->frame);
3157 itr = eina_tiler_iterator_new(src);
3158 EINA_ITERATOR_FOREACH(itr, rect)
3160 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3161 ec, rect->x, rect->y, rect->w, rect->h,
3162 ec->w, ec->h, state->bw, state->bh);
3163 e_comp_object_input_area_set(ec->frame,
3168 eina_iterator_free(itr);
3169 eina_tiler_free(src);
3172 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3174 eina_tiler_free(tmp);
3176 /* clear input tiler */
3177 eina_tiler_clear(state->input);
3180 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3182 if ((cdata->video_client) &&
3184 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3185 (e_comp->wl_comp_data->available_hw_accel.underlay))
3187 e_pixmap_image_clear(ec->pixmap, 1);
3190 state->buffer_viewport.changed = 0;
3192 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3195 ec->exp_iconify.buffer_flush &&
3196 e_policy_visibility_client_is_iconic(ec))
3198 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3203 _e_comp_wl_surface_render_stop(E_Client *ec)
3205 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3206 //if ((!ec->internal) && (!e_comp_gl_get()))
3209 /* check if internal animation is running */
3210 if (e_comp_object_is_animating(ec->frame)) return;
3211 /* check if external animation is running */
3212 if (evas_object_data_get(ec->frame, "effect_running")) return;
3214 evas_object_hide(ec->frame);
3218 e_comp_wl_client_surface_finish(E_Client *ec)
3220 struct wl_resource *res, *surface;
3221 struct wl_client *surface_client = NULL;
3224 surface = e_comp_wl_client_surface_get(ec);
3227 surface_client = wl_resource_get_client(surface);
3229 if (surface_client &&
3230 (ec == e_client_focused_get()))
3232 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3233 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3235 if (wl_resource_get_client(res) ==
3237 e_comp_wl->kbd.focused =
3238 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3242 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3245 e_comp_wl_client_surface_set(ec, NULL);
3247 ec->comp_data->wl_surface = NULL;
3248 e_pixmap_win_id_del(ec->pixmap);
3250 _e_comp_wl_surface_render_stop(ec);
3251 e_object_del(E_OBJECT(ec));
3255 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3260 char proc[512], pname[512];
3263 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3265 h = fopen(proc, "r");
3268 len = fread(pname, sizeof(char), 512, h);
3270 pname[len - 1] = '\0';
3272 strncpy(pname, "NO NAME", sizeof(pname));
3278 strncpy(pname, "NO NAME", sizeof(pname));
3281 strncpy(name, pname, size);
3285 _e_comp_wl_pname_print(pid_t pid)
3288 char proc[512], pname[512];
3291 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3293 h = fopen(proc, "r");
3296 len = fread(pname, sizeof(char), 512, h);
3298 pname[len - 1] = '\0';
3300 strncpy(pname, "NO NAME", sizeof(pname));
3304 ELOGF("COMP", " |%s", NULL, pname);
3309 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3311 struct wl_client *client = data;
3312 E_Comp_Connected_Client_Info *cinfo;
3315 cinfo = wl_container_of(listener, cinfo, destroy);
3317 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3318 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3320 eai = e_appinfo_find_with_pid(cinfo->pid);
3321 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3324 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3326 wl_list_remove(&cinfo->destroy.link);
3327 eina_stringshare_del(cinfo->name);
3332 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3334 E_Comp_Connected_Client_Info *cinfo;
3336 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3337 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3339 cinfo->name = eina_stringshare_add(name);
3343 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3344 wl_client_add_destroy_listener(client, &cinfo->destroy);
3345 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3347 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3351 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3353 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3355 /* send configure */
3356 if (ec->comp_data->shell.configure_send)
3358 if (ec->comp_data->shell.surface)
3359 _e_comp_wl_configure_send(ec, 0, 0);
3362 e_comp_wl->kbd.focus = ec->comp_data->surface;
3366 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3368 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3370 /* send configure */
3371 if (ec->comp_data->shell.configure_send)
3373 if (ec->comp_data->shell.surface)
3374 _e_comp_wl_configure_send(ec, 0, 0);
3377 _e_comp_wl_focus_check();
3379 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3380 e_comp_wl->kbd.focus = NULL;
3384 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3386 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3387 if (ec->keyboard_resizing) return;
3389 /* do nothing currently */
3394 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3396 if (e_object_is_del(E_OBJECT(ec))) return;
3397 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3399 e_comp_wl->resize.edges = 0;
3400 e_comp_wl->resize.resource = NULL;
3404 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3406 if (e_object_is_del(E_OBJECT(ec))) return;
3407 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3411 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3414 int ratio_w, ratio_h;
3416 phys_w = output->phys_width;
3417 phys_h = output->phys_height;
3419 if (e_config->configured_output_resolution.use)
3421 // change the configured physical size(mm) of the output
3422 if (output->w != res_w)
3424 ratio_w = res_w / output->w;
3425 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3428 if (output->h != res_h)
3430 ratio_h = res_h / output->h;
3431 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3434 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3437 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3438 NULL, res_w, res_h, phys_w, phys_h, pid);
3440 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3441 wl_output_send_scale(resource, output->scale);
3443 wl_output_send_geometry(resource, output->x, output->y,
3445 output->subpixel, output->make ?: "",
3446 output->model ?: "", output->transform);
3448 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3449 res_w, res_h, output->refresh);
3451 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3452 wl_output_send_done(resource);
3456 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3458 E_Comp_Wl_Output *output;
3460 if (!(output = wl_resource_get_user_data(resource))) return;
3462 output->resources = eina_list_remove(output->resources, resource);
3466 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3468 E_Comp_Wl_Output *output;
3469 struct wl_resource *resource;
3470 E_Appinfo *eai = NULL;
3474 if (!(output = data)) return;
3477 wl_resource_create(client, &wl_output_interface, version, id);
3480 wl_client_post_no_memory(client);
3484 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3485 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3487 output->resources = eina_list_append(output->resources, resource);
3489 wl_resource_set_implementation(resource, NULL, output,
3490 _e_comp_wl_cb_output_unbind);
3491 wl_resource_set_user_data(resource, output);
3493 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3494 if (e_config->configured_output_resolution.use)
3496 wl_client_get_credentials(client, &pid, NULL, NULL);
3499 res_w = e_config->configured_output_resolution.w;
3500 res_h = e_config->configured_output_resolution.h;
3504 eai = e_appinfo_find_with_pid(pid);
3507 res_w = e_config->configured_output_resolution.w;
3508 res_h = e_config->configured_output_resolution.h;
3512 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3514 res_w = e_config->configured_output_resolution.w;
3515 res_h = e_config->configured_output_resolution.h;
3519 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3528 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3532 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3535 Evas_GL *evasgl = NULL;
3536 Evas_GL_API *glapi = NULL;
3537 Evas_GL_Context *ctx = NULL;
3538 Evas_GL_Surface *sfc = NULL;
3539 Evas_GL_Config *cfg = NULL;
3541 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3543 if (!e_comp_gl_get()) return;
3545 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3546 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3548 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3549 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3551 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3552 * then we should get evas from ecore_evas.
3555 evas = e_comp->evas;
3557 evas = ecore_evas_get(e_comp->ee);
3559 evasgl = evas_gl_new(evas);
3560 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3562 glapi = evas_gl_api_get(evasgl);
3563 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3564 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3566 cfg = evas_gl_config_new();
3567 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3569 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3570 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3572 ctx = evas_gl_context_create(evasgl, NULL);
3573 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3575 res = evas_gl_make_current(evasgl, sfc, ctx);
3576 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3578 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3579 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3581 evas_gl_config_free(cfg);
3583 evas_gl->gl = evasgl;
3584 evas_gl->glapi = glapi;
3585 evas_gl->glsfc = sfc;
3586 evas_gl->glctx = ctx;
3588 e_comp_wl->evas_gl = evas_gl;
3590 /* for native surface */
3593 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3598 evas_gl_config_free(cfg);
3599 evas_gl_make_current(evasgl, NULL, NULL);
3600 evas_gl_context_destroy(evasgl, ctx);
3601 evas_gl_surface_destroy(evasgl, sfc);
3602 evas_gl_free(evasgl);
3609 _e_comp_wl_gl_popup_cb_close(void *data,
3610 Evas_Object *obj EINA_UNUSED,
3611 void *event_info EINA_UNUSED)
3613 evas_object_del(data);
3617 _e_comp_wl_gl_popup_cb_focus(void *data,
3618 Evas_Object *obj EINA_UNUSED,
3619 void *event_info EINA_UNUSED)
3621 elm_object_focus_set(data, EINA_TRUE);
3626 _e_comp_wl_gl_idle(void *data)
3630 /* show warning window to notify failure of gl init */
3633 Evas_Object *win, *bg, *popup, *btn;
3635 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3636 elm_win_title_set(win, "Compositor Warning");
3637 elm_win_autodel_set(win, EINA_TRUE);
3638 elm_win_borderless_set(win, EINA_TRUE);
3639 elm_win_role_set(win, "notification-low");
3640 elm_win_alpha_set(win, EINA_TRUE);
3642 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3643 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3644 elm_win_resize_object_add(win, bg);
3645 evas_object_color_set(bg, 125, 125, 125, 125);
3646 evas_object_show(bg);
3648 popup = elm_popup_add(win);
3649 elm_object_text_set(popup,
3650 _( "Your screen does not support OpenGL.<br>"
3651 "Falling back to software engine."));
3652 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3654 btn = elm_button_add(popup);
3655 elm_object_text_set(btn, "Close");
3656 elm_object_part_content_set(popup, "button1", btn);
3657 evas_object_show(btn);
3659 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3660 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3662 evas_object_show(popup);
3663 evas_object_show(win);
3667 return ECORE_CALLBACK_CANCEL;
3671 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3673 struct wl_client *client = data;
3679 wl_client_get_credentials(client, &pid, &uid, &gid);
3681 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3683 _e_comp_wl_pname_print(pid);
3684 _e_comp_wl_pname_get(pid, name, sizeof(name));
3685 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3689 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3691 char buf[1024] = {0, };
3693 vsnprintf(buf, 1024, fmt, args);
3697 DBG("[libds] %s", buf);
3700 INF("[libds] %s", buf);
3703 ERR("[libds] %s", buf);
3711 _e_comp_wl_display_create(void)
3714 E_Comp_Wl_Data *wl_cdata;
3719 /* create new compositor data */
3720 if (!(comp = E_NEW(E_Comp_Data, 1)))
3722 ERR("Could not create compositor data: %m");
3725 wl_cdata = &comp->base;
3727 /* set compositor wayland data */
3728 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3730 g_mutex_init(&connection_mutex);
3732 /* try to create a wayland display */
3733 if (!(wl_cdata->wl.disp = wl_display_create()))
3735 ERR("Could not create a Wayland display: %m");
3739 /* try to setup wayland socket */
3740 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3742 ERR("Could not create Wayland display socket: %m");
3743 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3747 res = e_comp_socket_init(name);
3748 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3749 PRCTL("[Winsys] change permission and create sym link for %s", name);
3751 /* set wayland display environment variable */
3752 e_env_set("WAYLAND_DISPLAY", name);
3754 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3755 /* wl_cdata->output.scale = e_scale; */
3757 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3759 if (!e_compositor_init(wl_cdata->wl.disp))
3761 ERR("Failed to initialize compositor");
3765 comp->client_created.notify = _e_comp_wl_cb_client_created;
3766 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3768 if (!e_comp_wl_subsurfaces_init())
3770 ERR("Failed to init_subsurfaces");
3771 goto subsurfaces_err;
3774 /* initialize shm mechanism */
3775 wl_display_init_shm(wl_cdata->wl.disp);
3777 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3779 /* try to init data manager */
3780 if (!e_comp_wl_data_manager_init())
3782 ERR("Could not initialize data manager");
3786 /* try to init input */
3787 if (!e_comp_wl_input_init())
3789 ERR("Could not initialize input");
3793 if (e_comp_gl_get())
3794 _e_comp_wl_gl_init(NULL);
3796 /* get the wayland display loop */
3797 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3799 /* get the file descriptor of the wayland event loop */
3800 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3802 /* create a listener for wayland main loop events */
3804 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3805 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3806 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3807 _e_comp_wl_cb_prepare, wl_cdata);
3812 e_comp_wl_data_manager_shutdown();
3814 e_comp_wl_subsurfaces_shutdown();
3816 wl_list_remove(&comp->client_created.link);
3818 e_env_unset("WAYLAND_DISPLAY");
3820 wl_display_destroy(wl_cdata->wl.disp);
3822 g_mutex_clear(&connection_mutex);
3828 _e_comp_wl_gl_shutdown(void)
3830 if (!e_comp_wl->evas_gl) return;
3832 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3834 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3835 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3836 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3837 evas_gl_free(e_comp_wl->evas_gl->gl);
3839 E_FREE(e_comp_wl->evas_gl);
3842 /* public functions */
3845 * Creates and initializes a Wayland compositor with ecore.
3846 * Registers callback handlers for keyboard and mouse activity
3847 * and other client events.
3849 * @returns true on success, false if initialization failed.
3852 e_comp_wl_init(void)
3854 TRACE_DS_BEGIN(COMP_WL:INIT);
3856 /* try to create a wayland compositor */
3857 if (!_e_comp_wl_display_create())
3859 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3864 e_comp_wl_shell_init();
3866 #ifdef HAVE_WAYLAND_TBM
3867 e_comp_wl_tbm_init();
3869 e_comp_wl_remote_surface_init();
3873 e_comp_wl_screenshooter_init();
3875 if (!e_comp_wl_video_init())
3876 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3878 e_comp_wl_viewport_init();
3879 e_comp_wl_capture_init();
3880 e_comp_wl_renderer_init();
3881 _e_comp_wl_move_resize_init();
3882 e_presentation_time_init();
3883 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3886 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3887 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3889 /* add event handlers to catch E events */
3890 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3891 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3892 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3893 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3894 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3895 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3896 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3897 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3898 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3900 /* add hooks to catch e_client events */
3901 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3902 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3903 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3904 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3905 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3907 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3914 e_comp_wl_deferred_job(void)
3916 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3919 /* internal functions */
3921 e_comp_wl_shutdown(void)
3923 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3925 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3927 e_comp_wl_subsurfaces_shutdown();
3929 E_FREE_LIST(handlers, ecore_event_handler_del);
3930 E_FREE_LIST(hooks, e_client_hook_del);
3931 _e_comp_wl_gl_shutdown();
3933 e_blender_shutdown();
3934 e_presentation_time_shutdown();
3935 e_comp_wl_renderer_shutdown();
3936 e_comp_wl_capture_shutdown();
3937 e_comp_wl_viewport_shutdown();
3938 e_comp_wl_video_shutdown();
3939 e_comp_wl_screenshooter_shutdown();
3941 e_comp_wl_remote_surface_shutdown();
3943 e_pixmap_shutdown();
3945 e_wtz_shell_shutdown();
3946 e_comp_wl_shell_shutdown();
3947 e_comp_wl_input_shutdown();
3949 wl_list_remove(&comp->client_created.link);
3952 e_comp->wl_comp_data = NULL;
3956 E_Comp_Wl_Output *output;
3958 if (e_comp_wl->screenshooter.global)
3959 wl_global_destroy(e_comp_wl->screenshooter.global);
3961 EINA_LIST_FREE(e_comp_wl->outputs, output)
3963 if (output->id) eina_stringshare_del(output->id);
3964 if (output->make) eina_stringshare_del(output->make);
3965 if (output->model) eina_stringshare_del(output->model);
3969 /* delete fd handler */
3970 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3972 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3973 cursor_timer_ec = NULL;
3975 /* free allocated data structure */
3981 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3983 e_object_unref(E_OBJECT(ev->ec));
3988 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3991 ev = E_NEW(E_Event_Client, 1);
3994 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3996 /* set usable early because shell module checks this */
3997 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3998 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4000 e_pixmap_resource_set(ec->pixmap, buffer);
4001 e_pixmap_dirty(ec->pixmap);
4002 e_pixmap_refresh(ec->pixmap);
4004 e_comp_wl_map_size_cal_from_buffer(ec);
4005 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4007 /* wm-policy module uses it */
4008 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4011 e_object_ref(E_OBJECT(ec));
4012 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4013 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4017 e_comp_wl_surface_commit(E_Client *ec)
4022 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4023 if (!e_comp_object_damage_exists(ec->frame))
4025 if ((ec->comp_data->video_client) ||
4026 (!e_client_video_hw_composition_check(ec)))
4027 e_pixmap_image_clear(ec->pixmap, 1);
4030 ignored = ec->ignored;
4032 if (e_comp_wl_subsurface_order_commit(ec))
4034 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4035 e_comp_wl_subsurface_restack(topmost);
4036 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4039 ec->ignored = ignored;
4041 if (ec->is_cursor && ec->visible)
4043 /* ignore cursor changes during resize/move I guess */
4044 if (!e_client_action_get())
4046 if (e_comp->pointer)
4048 x = e_comp->pointer->hot.x;
4049 y = e_comp->pointer->hot.y;
4051 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4057 static E_Comp_Wl_Output *
4058 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4061 E_Comp_Wl_Output *output;
4063 EINA_LIST_FOREACH(outputs, l, output)
4065 if (!strcmp(output->id, id))
4073 * Initializes information about one display output.
4075 * Adds or updates the given data about a single display output,
4076 * with an id matching the provided id.
4078 * @param id identification of output to be added or changed
4079 * @param make manufacturer name of the display output
4080 * @param model model name of the display output
4081 * @param x output's top left corner x coordinate
4082 * @param y output's top left corner y coordinate
4083 * @param w output's width in pixels
4084 * @param h output's height in pixels
4085 * @param pw output's physical width in millimeters
4086 * @param ph output's physical height in millimeters
4087 * @param refresh output's refresh rate in mHz
4088 * @param subpixel output's subpixel layout
4089 * @param transform output's rotation and/or mirror transformation
4091 * @returns True if a display output object could be added or updated
4094 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4095 int x, int y, int w, int h, int pw, int ph,
4096 unsigned int refresh, unsigned int subpixel,
4097 unsigned int transform)
4099 E_Comp_Wl_Output *output;
4101 struct wl_resource *resource;
4103 /* retrieve named output; or create it if it doesn't exist */
4104 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4107 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4109 if (id) output->id = eina_stringshare_add(id);
4111 output->make = eina_stringshare_add(make);
4113 output->make = eina_stringshare_add("unknown");
4115 output->model = eina_stringshare_add(model);
4117 output->model = eina_stringshare_add("unknown");
4119 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4122 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4123 2, output, _e_comp_wl_cb_output_bind);
4125 output->resources = NULL;
4126 output->scale = e_scale;
4129 /* update the output details */
4134 output->phys_width = pw;
4135 output->phys_height = ph;
4136 output->refresh = refresh;
4137 output->subpixel = subpixel;
4138 output->transform = transform;
4140 if (output->scale <= 0)
4141 output->scale = e_scale;
4143 /* if we have bound resources, send updates */
4144 EINA_LIST_FOREACH(output->resources, l2, resource)
4146 wl_output_send_geometry(resource,
4147 output->x, output->y,
4149 output->phys_height,
4151 output->make ?: "", output->model ?: "",
4154 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4155 wl_output_send_scale(resource, output->scale);
4157 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4158 output->w, output->h, output->refresh);
4160 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4161 wl_output_send_done(resource);
4168 e_comp_wl_output_remove(const char *id)
4170 E_Comp_Wl_Output *output;
4172 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4175 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4177 /* wl_global_destroy(output->global); */
4179 /* eina_stringshare_del(output->id); */
4180 /* eina_stringshare_del(output->make); */
4181 /* eina_stringshare_del(output->model); */
4188 _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)
4190 struct wl_resource *res;
4192 uint32_t serial, keycode;
4193 struct wl_client *wc = NULL;
4194 E_Comp_Config *comp_conf = NULL;
4195 const char *device_name = NULL;
4197 keycode = (ev->keycode - 8);
4199 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4201 comp_conf = e_comp_config_get();
4203 if (ec && ec->comp_data)
4205 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4208 wc = wl_resource_get_client(surface);
4211 if (e_config->key_input_ttrace_enable)
4213 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4214 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4217 EINA_LIST_FOREACH(key_list, l, res)
4219 if (wl_resource_get_client(res) != wc) continue;
4221 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4222 if (!e_input_thread_mode_get())
4224 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4225 device_name = ecore_device_name_get(ev->dev);
4231 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4232 device_name = e_device_name_get(dev);
4236 if (comp_conf && comp_conf->input_log_enable)
4237 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4239 wl_keyboard_send_key(res, serial, ev->timestamp,
4244 if (e_config->key_input_ttrace_enable)
4247 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4252 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4254 E_Client *ec = NULL;
4256 E_Comp_Wl_Key_Data *end, *k;
4258 if (ev->window != e_comp->ee_win)
4263 keycode = (ev->keycode - 8);
4264 if (!(e_comp_wl = e_comp->wl_comp_data))
4269 #ifndef E_RELEASE_BUILD
4270 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4271 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4272 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4273 eina_streq(ev->key, "BackSpace"))
4279 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4281 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4283 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4285 /* ignore server-generated key repeats */
4286 if (k->key == keycode)
4288 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4293 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4295 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4297 ec = e_client_focused_get();
4298 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4299 if (ec && ec->comp_data && surface)
4301 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4302 if (e_comp_wl->kbd.focused)
4304 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4306 /* A key only sent to clients is added to the list */
4307 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4308 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4310 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4312 DBG("wl_array_add: Out of memory\n");
4313 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4314 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4317 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4321 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4325 /* update modifier state */
4326 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4332 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4334 E_Client *ec = NULL;
4335 uint32_t keycode, delivered_key;
4336 E_Comp_Wl_Key_Data *end, *k;
4338 if (ev->window != e_comp->ee_win)
4343 keycode = (ev->keycode - 8);
4345 if (!(e_comp_wl = e_comp->wl_comp_data))
4350 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4352 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4353 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4355 if (k->key == keycode)
4362 e_comp_wl->kbd.keys.size =
4363 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4365 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4367 /* 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) */
4368 if ((delivered_key) ||
4369 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4371 ec = e_client_focused_get();
4373 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4374 if (e_comp_wl->kbd.focused)
4376 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4378 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4381 /* update modifier state */
4382 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4388 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4390 Eina_Bool res = EINA_FALSE;
4392 if (type == ECORE_EVENT_KEY_DOWN)
4394 res = e_comp_wl_key_down(ev, dev);
4396 else if (type == ECORE_EVENT_KEY_UP)
4398 res = e_comp_wl_key_up(ev, dev);
4405 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4408 struct wl_client *wc;
4409 uint32_t serial, btn;
4410 struct wl_resource *res;
4411 E_Comp_Config *comp_conf = NULL;
4413 if (ec->cur_mouse_action || e_comp_wl->drag)
4415 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4416 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4420 case 1: btn = BTN_LEFT; break;
4421 case 2: btn = BTN_MIDDLE; break;
4422 case 3: btn = BTN_RIGHT; break;
4423 default: btn = button_id; break;
4426 e_comp_wl->ptr.button = btn;
4427 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4428 if (!surface) return EINA_FALSE;
4430 if (!eina_list_count(e_comp_wl->ptr.resources))
4433 wc = wl_resource_get_client(surface);
4434 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4436 comp_conf = e_comp_config_get();
4438 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4440 if (wl_resource_get_client(res) != wc) continue;
4441 if (!e_comp_wl_input_pointer_check(res)) continue;
4442 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4444 if (comp_conf && comp_conf->input_log_enable)
4445 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4447 wl_pointer_send_button(res, serial, timestamp, btn, state);
4454 e_comp_wl_touch_cancel(void)
4456 _e_comp_wl_touch_cancel();
4459 E_API E_Comp_Wl_Hook *
4460 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4464 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4465 ch = E_NEW(E_Comp_Wl_Hook, 1);
4466 if (!ch) return NULL;
4467 ch->hookpoint = hookpoint;
4469 ch->data = (void*)data;
4470 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4475 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4478 if (_e_comp_wl_hooks_walking == 0)
4480 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4484 _e_comp_wl_hooks_delete++;
4487 E_API E_Comp_Wl_Pid_Hook *
4488 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4490 E_Comp_Wl_Pid_Hook *ch;
4492 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4494 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4495 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4497 ch->hookpoint = hookpoint;
4499 ch->data = (void*)data;
4500 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4506 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4509 if (_e_comp_wl_pid_hooks_walking == 0)
4511 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4515 _e_comp_wl_pid_hooks_delete++;
4518 E_API E_Comp_Wl_Intercept_Hook *
4519 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4521 E_Comp_Wl_Intercept_Hook *ch;
4523 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4524 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4525 if (!ch) return NULL;
4526 ch->hookpoint = hookpoint;
4528 ch->data = (void*)data;
4529 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4534 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4537 if (_e_comp_wl_intercept_hooks_walking == 0)
4539 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4543 _e_comp_wl_intercept_hooks_delete++;
4547 e_comp_wl_shell_surface_ready(E_Client *ec)
4551 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4555 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4557 e_config->use_cursor_timer = !!enabled;
4559 if (e_config->use_cursor_timer)
4561 if (!e_pointer_is_hidden(e_comp->pointer))
4563 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4568 if (e_comp_wl->ptr.hide_tmr)
4570 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4571 e_comp_wl->ptr.hide_tmr = NULL;
4573 cursor_timer_ec = NULL;
4575 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4578 if (e_pointer_is_hidden(e_comp->pointer))
4580 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4586 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4588 EINA_SAFETY_ON_NULL_RETURN(wc);
4589 EINA_SAFETY_ON_NULL_RETURN(dev);
4591 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4595 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4597 EINA_SAFETY_ON_NULL_RETURN(wc);
4598 EINA_SAFETY_ON_NULL_RETURN(dev);
4600 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4604 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4606 struct wl_resource *res;
4607 struct wl_client *wc;
4609 uint32_t serial, wl_keycode;
4610 enum wl_keyboard_key_state state;
4611 E_Comp_Config *comp_conf = NULL;
4612 const char *dev_name = NULL;
4614 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4615 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4616 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4618 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4619 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4621 wl_keycode = keycode - 8;
4622 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4624 wc = wl_resource_get_client(surface);
4625 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4626 if (!time) time = e_util_timestamp_get();
4627 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4628 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4630 comp_conf = e_comp_config_get();
4631 e_keyrouter_event_surface_send(ec, keycode);
4633 if (e_config->key_input_ttrace_enable)
4635 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4636 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4639 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4640 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4642 if (wl_resource_get_client(res) != wc) continue;
4643 if (!e_input_thread_mode_get())
4647 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4648 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4652 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4659 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4660 dev_name = e_device_name_get(dev);
4664 if (comp_conf && comp_conf->input_log_enable)
4665 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4668 wl_keyboard_send_key(res, serial, time,
4671 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4673 if (e_config->key_input_ttrace_enable)
4676 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4683 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4685 struct wl_resource *res;
4686 struct wl_client *wc;
4688 uint32_t serial, wl_keycode, cancel_keycode;
4689 E_Comp_Config *comp_conf = NULL;
4690 struct xkb_keymap *keymap = NULL;
4692 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4693 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4694 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4696 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4697 keymap = e_comp_wl->xkb.keymap;
4698 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4699 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4701 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4702 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4704 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4705 if (cancel_keycode == XKB_KEYCODE_INVALID)
4707 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4710 cancel_keycode = cancel_keycode - 8;
4712 wl_keycode = keycode - 8;
4713 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4715 wc = wl_resource_get_client(surface);
4716 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4717 if (!time) time = e_util_timestamp_get();
4719 comp_conf = e_comp_config_get();
4720 e_keyrouter_event_surface_send(ec, keycode);
4722 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4723 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4725 if (wl_resource_get_client(res) != wc) continue;
4726 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4727 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4729 if (comp_conf && comp_conf->input_log_enable)
4730 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4731 wl_keyboard_send_key(res, serial, time,
4732 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4733 wl_keyboard_send_key(res, serial, time,
4734 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4735 wl_keyboard_send_key(res, serial, time,
4736 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4738 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4745 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)
4747 struct wl_client *wc;
4749 E_Devicemgr_Input_Device *device = NULL;
4751 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4752 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4753 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4755 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4756 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4758 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4760 wc = wl_resource_get_client(surface);
4761 if (!time) time = e_util_timestamp_get();
4762 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4766 _e_comp_wl_send_event_device(wc, time, dev, serial);
4767 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4771 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4772 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4775 x = x + ec->client.x;
4776 y = y + ec->client.y;
4778 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4784 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)
4786 E_Devicemgr_Input_Device *device;
4788 struct wl_client *wc;
4790 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4791 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4792 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4794 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4795 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4797 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4799 wc = wl_resource_get_client(surface);
4800 if (!time) time = e_util_timestamp_get();
4801 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4805 _e_comp_wl_send_event_device(wc, time, dev, serial);
4806 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4810 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4811 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4814 x = x + ec->client.x;
4815 y = y + ec->client.y;
4817 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4823 e_comp_wl_touch_cancel_send(E_Client *ec)
4825 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4826 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4827 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4829 _e_comp_wl_send_touch_cancel(ec);
4835 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4838 struct wl_client *wc;
4840 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4841 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4842 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4844 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4845 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4847 wc = wl_resource_get_client(surface);
4848 if (!time) time = e_util_timestamp_get();
4849 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4851 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4852 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4855 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4856 WL_POINTER_BUTTON_STATE_PRESSED);
4858 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4859 WL_POINTER_BUTTON_STATE_RELEASED);
4865 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4868 struct wl_client *wc;
4870 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4871 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4872 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4874 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4875 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4877 wc = wl_resource_get_client(surface);
4878 if (!time) time = e_util_timestamp_get();
4879 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4881 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4882 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4884 x = x + ec->client.x;
4885 y = y + ec->client.y;
4887 _e_comp_wl_send_mouse_move(ec, x, y, time);
4893 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4896 struct wl_client *wc;
4898 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4899 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4900 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4902 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4903 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4905 wc = wl_resource_get_client(surface);
4906 if (!time) time = e_util_timestamp_get();
4907 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4909 if (_e_comp_wl_check_cursor_timer_needed(ec))
4911 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4915 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4916 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4918 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4920 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4922 if (_e_comp_wl_check_cursor_timer_needed(ec))
4923 _e_comp_wl_cursor_move_timer_control(ec);
4930 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4933 struct wl_client *wc;
4934 struct wl_resource *res;
4937 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4938 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4940 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4941 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4943 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4944 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4946 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4947 wc = wl_resource_get_client(surface);
4948 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4949 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4951 if (!e_comp_wl_input_pointer_check(res)) continue;
4952 if (wl_resource_get_client(res) != wc) continue;
4954 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4955 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4957 wl_pointer_send_enter(res, serial, surface,
4958 wl_fixed_from_int(x),
4959 wl_fixed_from_int(y));
4960 ec->pointer_enter_sent = EINA_TRUE;
4962 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4968 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4971 struct wl_client *wc;
4972 struct wl_resource *res;
4975 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4976 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4977 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4978 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4979 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4980 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4982 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4983 wc = wl_resource_get_client(surface);
4984 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4985 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4987 if (!e_comp_wl_input_pointer_check(res)) continue;
4988 if (wl_resource_get_client(res) != wc) continue;
4990 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4991 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4993 wl_pointer_send_leave(res, serial, surface);
4994 ec->pointer_enter_sent = EINA_FALSE;
5001 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)
5003 Evas_Event_Mouse_In ev_in;
5006 if (ec->pointer_enter_sent) return;
5008 ev_in.buttons = buttons;
5016 ev_in.modifiers = modifiers;
5017 ev_in.locks = locks;
5018 ev_in.timestamp = timestamp;
5019 ev_in.event_flags = event_flags;
5022 ev_in.event_src = event_src;
5024 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5028 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)
5030 Evas_Event_Mouse_Out ev_out;
5033 if (!ec->pointer_enter_sent) return;
5035 ev_out.buttons = buttons;
5037 ev_out.output.x = x;
5038 ev_out.output.y = y;
5039 ev_out.canvas.x = x;
5040 ev_out.canvas.y = y;
5043 ev_out.modifiers = modifiers;
5044 ev_out.locks = locks;
5045 ev_out.timestamp = timestamp;
5046 ev_out.event_flags = event_flags;
5049 ev_out.event_src = event_src;
5051 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5055 e_comp_wl_cursor_hide(E_Client *ec)
5057 struct wl_resource *res;
5058 struct wl_client *wc;
5062 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5064 if (e_comp_wl->ptr.hide_tmr)
5066 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5067 e_comp_wl->ptr.hide_tmr = NULL;
5069 cursor_timer_ec = NULL;
5071 if (!ec) return EINA_FALSE;
5072 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5073 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5074 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5076 wc = wl_resource_get_client(surface);
5077 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5078 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5080 if (!e_comp_wl_input_pointer_check(res)) continue;
5081 if (wl_resource_get_client(res) != wc) continue;
5082 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5083 wl_pointer_send_leave(res, serial, surface);
5084 ec->pointer_enter_sent = EINA_FALSE;
5090 /* surface to buffer
5091 * - width : surface width
5092 * - height : surface height
5093 * - transform: buffer transform
5094 * - scale : buffer scale
5096 * - width : screen width
5097 * - height : screen height
5098 * - transform: output transform
5099 * - scale : output scale
5101 static E_Util_Transform_Matrix
5102 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5104 E_Util_Transform_Matrix m;
5106 e_util_transform_matrix_load_identity(&m);
5108 if (transform & 0x4)
5110 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5111 e_util_transform_matrix_flip_x(&m);
5112 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5115 switch (transform & 0x3)
5117 case WL_OUTPUT_TRANSFORM_90:
5118 e_util_transform_matrix_translate(&m, -width, 0, 0);
5119 e_util_transform_matrix_rotation_z(&m, 270);
5121 case WL_OUTPUT_TRANSFORM_180:
5122 e_util_transform_matrix_translate(&m, -width, -height, 0);
5123 e_util_transform_matrix_rotation_z(&m, 180);
5125 case WL_OUTPUT_TRANSFORM_270:
5126 e_util_transform_matrix_translate(&m, 0, -height, 0);
5127 e_util_transform_matrix_rotation_z(&m, 90);
5133 e_util_transform_matrix_scale(&m, scale, scale, 1);
5138 /* surface to buffer
5139 * - surface width, surface height, buffer transform, buffer scale
5141 * - screen width, screen height, output transform, output scale
5144 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5146 E_Util_Transform_Matrix m;
5147 E_Util_Transform_Vertex v;
5149 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5151 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5152 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5153 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5157 * - buffer width, buffer height, buffer transform, buffer scale
5160 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5162 E_Util_Transform_Matrix m;
5163 E_Util_Transform_Vertex v;
5166 if (transform != 0 || scale > 1)
5168 tw = ((transform % 2) ? height : width) / scale;
5169 th = ((transform % 2) ? width : height) / scale;
5177 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5178 m = e_util_transform_matrix_inverse_get(&m);
5180 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5181 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5182 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5185 /* surface to buffer
5186 * - surface width, surface height, buffer transform, buffer scale
5188 * - screen width, screen height, output transform, output scale
5191 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5192 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5194 E_Util_Transform_Matrix m;
5195 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5196 E_Util_Transform_Rect_Vertex sv;
5198 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5200 sv = e_util_transform_rect_to_vertices(&sr);
5201 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5202 sr = e_util_transform_vertices_to_rect(&sv);
5211 * - buffer width, buffer height, buffer transform, buffer scale
5214 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5215 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5217 E_Util_Transform_Matrix m;
5218 E_Util_Transform_Rect br = {bx, by, bw, bh};
5219 E_Util_Transform_Rect_Vertex bv;
5222 if (transform != 0 || scale > 1)
5224 tw = ((transform % 2) ? height : width) / scale;
5225 th = ((transform % 2) ? width : height) / scale;
5233 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5234 m = e_util_transform_matrix_inverse_get(&m);
5236 bv = e_util_transform_rect_to_vertices(&br);
5237 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5238 br = e_util_transform_vertices_to_rect(&bv);
5246 EINTERN E_Comp_Wl_Output*
5247 e_comp_wl_output_find(E_Client *ec)
5250 E_Comp_Wl_Output *output;
5252 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5254 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5256 if (output->transform % 2)
5258 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5259 ec->y < output->x || ec->y >= (output->x + output->w))
5264 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5265 ec->y < output->y || ec->y >= (output->y + output->h))
5275 EINTERN Eina_Array *
5276 e_comp_wl_output_find_all(E_Client *ec)
5278 E_Comp_Wl_Output *output;
5279 Eina_Array *outputs;
5282 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5284 outputs = eina_array_new(4);
5288 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5290 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5291 output->x, output->y, output->w, output->h))
5293 eina_array_push(outputs, output);
5297 if (eina_array_count(outputs) == 0)
5299 eina_array_free(outputs);
5306 // --------------------------------------------------------
5307 // tizen_move_resize
5308 // --------------------------------------------------------
5310 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5317 E_Client_Pending_Geometry *geo;
5320 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5321 if (ec->fullscreen || ec->maximized) goto err;
5323 geo = E_NEW(E_Client_Pending_Geometry, 1);
5326 geo->serial = serial;
5332 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5333 ec->surface_sync.wait_commit = EINA_TRUE;
5338 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5345 e_comp_wl_commit_sync_configure(E_Client *ec)
5348 E_Client_Pending_Geometry *geo;
5350 Eina_Bool match_size = EINA_FALSE;
5357 if (!ec || !ec->frame) goto ret;
5358 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5361 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5362 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5364 if (eina_list_count(ec->surface_sync.pending_geometry))
5366 Eina_List *ll = NULL;
5367 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5371 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5376 if ((geo->w == bw) && (geo->h == bh))
5378 match_size = EINA_TRUE;
5383 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5390 if ((config.w != ec->w) || (config.h != ec->h))
5392 e_client_size_set(ec, config.w, config.h);
5393 ec->changes.size = EINA_TRUE;
5397 // FIXME: The geometry of the client would be better to be calculated
5398 // at e_desk or at e_desk_area. So the position(x,y) of the client
5399 // should be calcuated at the e_desk or at the e_desk_area.
5401 desk = e_comp_desk_find_by_ec(ec);
5404 ec->client.x = desk->geom.x + config.x;
5405 ec->client.y = desk->geom.y + config.y;
5409 ec->client.x = config.x;
5410 ec->client.y = config.y;
5413 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5415 e_client_pos_set(ec, ec->client.x, ec->client.y);
5417 ec->changes.pos = 1;
5421 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5425 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5426 ec->surface_sync.wait_commit = EINA_FALSE;
5428 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5430 // rollback wait_commit if there are pending requests remained
5431 if (eina_list_count(ec->surface_sync.pending_geometry))
5432 ec->surface_sync.wait_commit = EINA_TRUE;
5437 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);
5444 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5445 struct wl_resource *res_moveresize)
5447 wl_resource_destroy(res_moveresize);
5451 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5452 struct wl_resource *res_moveresize,
5453 struct wl_resource *surface,
5460 /* to be implemented */
5463 int cur_w = 0, cur_h = 0;
5465 ec = e_client_from_surface_resource(surface);
5468 pending = e_client_pending_geometry_has(ec);
5469 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5470 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);
5474 if ((cur_w == w) && (cur_h == h))
5476 e_client_pos_set(ec, x, y);
5477 ec->changes.pos = 1;
5483 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5487 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5490 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5492 _tz_move_resize_iface_cb_destroy,
5493 _tz_move_resize_iface_cb_set_geometry,
5497 _tz_moveresize_cb_bind(struct wl_client *client,
5498 void *data EINA_UNUSED,
5502 struct wl_resource *res_moveresize;
5504 res_moveresize = wl_resource_create(client,
5505 &tizen_move_resize_interface,
5508 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5511 wl_resource_set_implementation(res_moveresize,
5512 &_tz_move_resize_iface,
5518 ERR("Could not create tizen_move_resize_interface res: %m");
5519 wl_client_post_no_memory(client);
5523 _e_comp_wl_move_resize_init(void)
5525 if (!e_comp_wl) return;
5526 if (!e_comp_wl->wl.disp) return;
5528 if (!wl_global_create(e_comp_wl->wl.disp,
5529 &tizen_move_resize_interface,
5532 _tz_moveresize_cb_bind))
5534 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5541 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5543 E_Comp_Wl_Output *output;
5544 pid_t output_pid = 0;
5545 Eina_List *l = NULL, *l2 = NULL;
5546 struct wl_resource *resource = NULL;
5548 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5550 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5551 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5552 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5554 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5556 /* if we have bound resources, send updates */
5557 EINA_LIST_FOREACH(output->resources, l2, resource)
5559 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5560 if (output_pid != pid) continue;
5562 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5564 // send output information to the client
5565 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5573 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5575 _e_comp_wl_surface_state_init(state, w, h);
5579 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5581 _e_comp_wl_surface_state_commit(ec, state);
5585 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5587 _e_comp_wl_hook_call(hookpoint, ec);
5591 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5593 _e_comp_wl_surface_state_finish(state);
5597 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5599 _e_comp_wl_surface_state_buffer_set(state, buffer);
5603 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5604 int sx, int sy, int *dx, int *dy)
5608 case WL_OUTPUT_TRANSFORM_NORMAL:
5612 case WL_OUTPUT_TRANSFORM_FLIPPED:
5613 *dx = width - sx, *dy = sy;
5615 case WL_OUTPUT_TRANSFORM_90:
5616 *dx = height - sy, *dy = sx;
5618 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5619 *dx = height - sy, *dy = width - sx;
5621 case WL_OUTPUT_TRANSFORM_180:
5622 *dx = width - sx, *dy = height - sy;
5624 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5625 *dx = sx, *dy = height - sy;
5627 case WL_OUTPUT_TRANSFORM_270:
5628 *dx = sy, *dy = width - sx;
5630 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5640 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5643 int tx1, ty1, tx2, ty2;
5644 int width_from_buffer, height_from_buffer;
5646 switch (vp->buffer.transform)
5648 case WL_OUTPUT_TRANSFORM_90:
5649 case WL_OUTPUT_TRANSFORM_270:
5650 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5651 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5652 width_from_buffer = bh / vp->buffer.scale;
5653 height_from_buffer = bw / vp->buffer.scale;
5656 width_from_buffer = bw / vp->buffer.scale;
5657 height_from_buffer = bh / vp->buffer.scale;
5661 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5665 x2 = width_from_buffer;
5666 y2 = height_from_buffer;
5670 x1 = wl_fixed_to_int(vp->buffer.src_x);
5671 y1 = wl_fixed_to_int(vp->buffer.src_y);
5672 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5673 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5676 buffer_transform(width_from_buffer, height_from_buffer,
5677 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5678 buffer_transform(width_from_buffer, height_from_buffer,
5679 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5681 out->x = (tx1 <= tx2) ? tx1 : tx2;
5682 out->y = (ty1 <= ty2) ? ty1 : ty2;
5683 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5684 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5688 * Convert given four coordinates to elements of rectangle
5689 * @in p[4] Coordinates to be converted
5690 * @out rect x, y, width, and height
5691 * transform Angle which represents TDM_TRANSFORM of rectangle
5692 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5693 * 1. The given coordinates are not represented by rectangle.
5694 * 2. All angles except for 0, 90, 180, 270.
5697 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5699 Eina_Bool ret = EINA_FALSE;
5701 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))
5704 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5707 *rotation = TDM_TRANSFORM_NORMAL;
5710 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5714 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5717 *rotation = TDM_TRANSFORM_180;
5720 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5725 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))
5728 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5731 *rotation = TDM_TRANSFORM_90;
5734 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5738 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5741 *rotation = TDM_TRANSFORM_270;
5744 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5754 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5759 for (i = 0; i < 4; i++)
5760 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5762 if (!_coords_to_rectangle_convert(p, out, rotation))
5764 DBG("Cannot convert given coords to rectangle.\n"
5765 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5766 p[0].x, p[0].y, p[1].x, p[1].y,
5767 p[2].x, p[2].y, p[3].x, p[3].y);
5775 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5777 int trans_rotation, flip;
5779 trans_rotation = transform & 0x3;
5780 flip = transform & 0x4;
5782 return (flip + (trans_rotation + rotation) % 4);
5786 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5794 if (e_comp_wl_subsurface_check(ec))
5795 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5802 out->w = ec->comp_data->width_from_viewport;
5803 out->w = (out->w + 1) & ~1;
5804 out->h = ec->comp_data->height_from_viewport;
5806 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5807 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5811 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5813 E_Comp_Wl_Buffer *buffer;
5814 E_Comp_Wl_Buffer_Viewport *vp;
5816 enum wl_output_transform buffer_transform;
5817 unsigned int rotation;
5818 Eina_Bool res = EINA_FALSE;
5820 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5822 if (e_object_is_del(E_OBJECT(ec)))
5825 vp = &ec->comp_data->scaler.buffer_viewport;
5827 if (buffer_viewport)
5829 buffer = ec->comp_data->buffer_ref.buffer;
5830 /* Getting a viewport of buffer needs geometry of buffer. */
5834 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5837 if ((output_viewport) || (transform))
5839 m = e_client_map_get(ec);
5841 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5843 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5848 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5849 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5850 * Since buffer.transform isn't applied using evas_map,
5851 * it has to be taken into account here to apply buffer.transform
5852 * and rotation of e_client_transform together. */
5854 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5856 *transform = (unsigned int)buffer_transform;
5864 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5866 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5867 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5869 /* Must be called with valid comp_data */
5870 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5872 if ((ec->comp_data->role_name == NULL) ||
5873 (ec->comp_data->role_name == role_name) ||
5874 (strcmp(ec->comp_data->role_name, role_name) == 0))
5876 ec->comp_data->role_name = role_name;
5882 wl_resource_post_error(error_resource, error_code,
5883 "Cannot assign role %s to wl_surface@%d,"
5884 " already has role %s\n",
5886 ec->comp_data->wl_surface ?
5887 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5888 ec->comp_data->role_name);
5894 EINTERN const char *
5895 e_comp_wl_surface_role_get(E_Client *ec)
5897 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5898 return ec->comp_data ? ec->comp_data->role_name : NULL;
5901 EINTERN struct wl_resource *
5902 e_comp_wl_client_surface_get(E_Client *ec)
5904 struct wl_resource *surface = NULL;
5905 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5906 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5908 g_mutex_lock(&ec->comp_data->surface_mutex);
5909 surface = ec->comp_data->surface;
5910 g_mutex_unlock(&ec->comp_data->surface_mutex);
5915 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5917 EINA_SAFETY_ON_NULL_RETURN(ec);
5918 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5920 g_mutex_lock(&ec->comp_data->surface_mutex);
5921 ec->comp_data->surface = surface;
5922 g_mutex_unlock(&ec->comp_data->surface_mutex);
5926 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5928 return e_compositor_util_client_from_surface_resource(surface_resource);
5932 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5934 if (!ec->comp_data->mapped)
5936 if (ec->comp_data->shell.surface &&
5937 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5939 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5945 if (ec->comp_data->mapped)
5947 /* will be unmapped. so run capture */
5948 e_comp_wl_remote_surface_image_save(ec);
5952 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5954 ec->comp_data->pending.sx = sx;
5955 ec->comp_data->pending.sy = sy;
5956 ec->comp_data->pending.new_attach = EINA_TRUE;
5958 e_client_fps_update(ec);
5962 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5964 if (ec->comp_data->pending.opaque)
5965 eina_tiler_clear(ec->comp_data->pending.opaque);
5969 eina_tiler_union(ec->comp_data->pending.opaque, region);
5971 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5975 ec->argb = EINA_FALSE;
5976 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5978 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5979 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5987 ec->argb = EINA_TRUE;
5988 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5990 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5991 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5997 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5999 if (ec->comp_data->pending.input)
6000 eina_tiler_clear(ec->comp_data->pending.input);
6004 if (eina_tiler_empty(region))
6006 ELOGF("COMP", " |unset input rect", NULL);
6007 e_comp_object_input_objs_del(ec->frame);
6008 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6011 eina_tiler_union(ec->comp_data->pending.input, region);
6015 eina_tiler_rect_add(ec->comp_data->pending.input,
6016 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6021 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6023 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6027 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6029 E_Comp_Wl_Subsurf_Data *sdata;
6034 if (ec->comp_data->frames)
6036 ec->comp_data->frames =
6037 eina_list_remove(ec->comp_data->frames, callback_resource);
6040 if (ec->comp_data->pending.frames)
6042 ec->comp_data->pending.frames =
6043 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6046 sdata = ec->comp_data->sub.data;
6047 if ((sdata) && (sdata->cached.frames))
6049 sdata->cached.frames =
6050 eina_list_remove(sdata->cached.frames, callback_resource);
6055 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6057 if (e_object_is_del(E_OBJECT(ec))) return;
6059 if (e_comp_wl_remote_surface_commit(ec)) return;
6061 e_comp_wl_surface_commit(ec);
6063 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6067 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6069 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6070 ec->comp_data->sub.data = sub;
6072 /* set subsurface client properties */
6073 ec->borderless = EINA_TRUE;
6074 ec->argb = EINA_TRUE;
6075 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6076 ec->lock_border = EINA_TRUE;
6077 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6078 ec->netwm.state.skip_taskbar = EINA_TRUE;
6079 ec->netwm.state.skip_pager = EINA_TRUE;
6080 ec->border_size = 0;
6081 ec->lock_user_location = 0;
6082 ec->lock_client_location = 0;
6083 ec->lock_user_size = 0;
6084 ec->lock_client_size = 0;
6085 ec->lock_client_stacking = 0;
6086 ec->lock_user_maximize = 0;
6087 ec->lock_client_maximize = 0;
6088 ec->changes.need_maximize = 0;
6089 ec->maximized = E_MAXIMIZE_NONE;
6092 ec->new_client = ec->netwm.ping = EINA_TRUE;
6093 e_comp->new_clients++;
6094 e_client_unignore(ec);
6096 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6097 * It's not for subsurface. */
6098 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6102 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6104 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6107 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6109 sub->parent = parent;
6113 layer = e_client_layer_get(parent);
6114 if (layer > E_LAYER_BOTTOM)
6115 e_client_layer_set(ec, layer);
6118 if (parent->comp_data)
6120 /* append this client to the parents subsurface list */
6121 parent->comp_data->sub.list_pending =
6122 eina_list_append(parent->comp_data->sub.list_pending, ec);
6123 parent->comp_data->sub.list_changed = EINA_TRUE;
6128 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6130 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6131 E_Client *parent = sub->parent;
6133 parent->comp_data->sub.list =
6134 eina_list_remove(parent->comp_data->sub.list, ec);
6135 parent->comp_data->sub.list_pending =
6136 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6137 parent->comp_data->sub.below_list =
6138 eina_list_remove(parent->comp_data->sub.below_list, ec);
6139 parent->comp_data->sub.below_list_pending =
6140 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6146 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)
6148 sub->resource = subsurface_resource;
6149 sub->cached_buffer_ref.buffer = NULL;
6150 sub->synchronized = EINA_TRUE;
6151 sub->parent = parent;
6152 sub->remote_surface.offscreen_parent = offscreen_parent;
6153 if (offscreen_parent)
6154 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6156 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6158 _e_comp_wl_client_subsurface_set(ec, sub);
6159 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6161 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6165 e_comp_wl_client_subsurface_finish(E_Client *ec)
6167 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6170 e_comp_wl_client_subsurface_parent_unset(ec);
6172 e_comp_wl_surface_state_finish(&sub->cached);
6173 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6175 ec->comp_data->sub.data = NULL;
6179 e_comp_wl_client_evas_init(E_Client *ec)
6181 EINA_SAFETY_ON_NULL_RETURN(ec);
6183 _e_comp_wl_client_evas_init(ec);
6187 e_comp_wl_client_evas_deinit(E_Client *ec)
6189 EINA_SAFETY_ON_NULL_RETURN(ec);
6191 _e_comp_wl_client_evas_deinit(ec);
6195 e_comp_wl_focus_check(void)
6197 _e_comp_wl_focus_check();
6201 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6208 if ((parent->comp_data) && (parent->comp_data->sub.data))
6209 parent = parent->comp_data->sub.data->parent;