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"
19 #include <tizen-extension-server-protocol.h>
20 #include <relative-pointer-unstable-v1-server-protocol.h>
21 #include <pointer-constraints-unstable-v1-server-protocol.h>
23 #include <wayland-tbm-server.h>
25 #include <libds/log.h>
26 #include <libds/single_pixel_buffer_v1.h>
28 /* handle include for printing uint64_t */
29 #define __STDC_FORMAT_MACROS
32 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
34 /* Resource Data Mapping: (wl_resource_get_user_data)
36 * wl_surface == e_pixmap
37 * wl_region == eina_tiler
38 * wl_subsurface == e_client
42 typedef struct _E_Comp_Data E_Comp_Data;
47 struct wl_listener client_created;
50 static void _e_comp_wl_move_resize_init(void);
52 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
55 typedef struct _E_Comp_Wl_Key_Data
61 static Eina_List *handlers = NULL;
62 static E_Client *cursor_timer_ec = NULL;
63 static Eina_Bool need_send_released = EINA_FALSE;
64 static Eina_Bool need_send_motion = EINA_TRUE;
66 static GMutex connection_mutex;
68 static int _e_comp_wl_hooks_delete = 0;
69 static int _e_comp_wl_hooks_walking = 0;
71 static int _e_comp_wl_pid_hooks_delete = 0;
72 static int _e_comp_wl_pid_hooks_walking = 0;
74 static int _e_comp_wl_intercept_hooks_delete = 0;
75 static int _e_comp_wl_intercept_hooks_walking = 0;
77 static Eina_Inlist *_e_comp_wl_hooks[] =
79 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
80 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
81 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
82 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
83 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
84 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
85 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
86 [E_COMP_WL_HOOK_DEL] = NULL,
87 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
88 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
89 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
92 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
94 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
97 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
99 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
100 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
101 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
102 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
103 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
104 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
107 static Eina_List *hooks = NULL;
109 /* local functions */
111 _e_comp_wl_hooks_clean(void)
116 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
117 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
119 if (!ch->delete_me) continue;
120 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
126 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
130 e_object_ref(E_OBJECT(ec));
131 _e_comp_wl_hooks_walking++;
132 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
134 if (ch->delete_me) continue;
135 ch->func(ch->data, ec);
136 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
137 (e_object_is_del(E_OBJECT(ec))))
140 _e_comp_wl_hooks_walking--;
141 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
142 _e_comp_wl_hooks_clean();
143 e_object_unref(E_OBJECT(ec));
147 _e_comp_wl_pid_hooks_clean(void)
150 E_Comp_Wl_Pid_Hook *ch;
152 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
153 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
155 if (!ch->delete_me) continue;
156 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
162 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
164 E_Comp_Wl_Pid_Hook *ch;
166 _e_comp_wl_pid_hooks_walking++;
167 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
169 if (ch->delete_me) continue;
170 ch->func(ch->data, pid);
172 _e_comp_wl_pid_hooks_walking--;
173 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
174 _e_comp_wl_pid_hooks_clean();
178 _e_comp_wl_intercept_hooks_clean(void)
181 E_Comp_Wl_Intercept_Hook *ch;
183 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
184 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
186 if (!ch->delete_me) continue;
187 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
193 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
195 E_Comp_Wl_Intercept_Hook *ch;
196 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
198 e_object_ref(E_OBJECT(ec));
199 _e_comp_wl_intercept_hooks_walking++;
200 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
202 if (ch->delete_me) continue;
203 res = ch->func(ch->data, ec);
204 if (!res) ret = EINA_FALSE;
205 if (e_object_is_del(E_OBJECT(ec)))
208 _e_comp_wl_intercept_hooks_walking--;
209 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
210 _e_comp_wl_intercept_hooks_clean();
211 e_object_unref(E_OBJECT(ec));
218 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
224 if (e_comp_object_frame_exists(ec->frame))
225 w = ec->client.w, h = ec->client.h;
227 w = ec->w, h = ec->h;
231 // Width and Height are -1 means that we don't consider size value
235 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
239 _e_comp_wl_focus_check(void)
243 if (stopping) return;
244 ec = e_client_focused_get();
246 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
250 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
252 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
254 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
255 IDLE_EXITER~CB_PREPARE);
257 return ECORE_CALLBACK_RENEW;
261 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
263 /* dispatch pending wayland events */
264 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
266 return ECORE_CALLBACK_RENEW;
270 e_comp_wl_display_flush()
272 if (e_comp_wl && e_comp_wl->wl.disp)
274 if (e_config->key_input_ttrace_enable)
276 TRACE_INPUT_BEGIN(wl_display_flush_clients);
277 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
280 g_mutex_lock(&connection_mutex);
281 wl_display_flush_clients(e_comp_wl->wl.disp);
282 g_mutex_unlock(&connection_mutex);
284 if (e_config->key_input_ttrace_enable)
287 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
293 e_comp_wl_connection_lock()
295 e_input_boost_lock(&connection_mutex);
299 e_comp_wl_connection_unlock()
301 e_input_boost_unlock(&connection_mutex);
305 e_comp_wl_focused_client_flush()
307 E_Client *focused_ec;
308 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
310 e_input_boost_lock(&connection_mutex);
311 focused_ec = e_client_focused_get();
315 struct wl_client *wc;
316 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
319 e_input_boost_unlock(&connection_mutex);
323 wc = wl_resource_get_client(surface);
327 e_input_boost_unlock(&connection_mutex);
331 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
335 if (e_comp_wl->idle_exiter_timestamp > 0.0)
337 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
338 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
340 ELOGF("E_COMP", "prepare gap time: %lfms",
345 e_comp_wl->idle_exiter_timestamp = 0.0;
347 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
349 /* flush pending client events */
350 e_comp_wl_display_flush();
352 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
353 IDLE_EXITER~CB_PREPARE);
356 E_API enum wl_output_transform
357 e_comp_wl_output_buffer_transform_get(E_Client *ec)
359 E_Comp_Wl_Buffer_Viewport *vp;
360 E_Comp_Wl_Buffer *buffer;
361 enum wl_output_transform transform, rotation;
363 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
364 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
365 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
367 vp = &ec->comp_data->scaler.buffer_viewport;
368 if (e_comp_wl_subsurface_check(ec))
369 return vp->buffer.transform;
371 buffer = ec->comp_data->buffer_ref.buffer;
374 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
375 return vp->buffer.transform;
377 rotation = buffer->transform;
379 return vp->buffer.transform;
381 /* ignore the flip value when calculating transform because the screen rotation
382 * functionality doesn't consider the flip output transform currently
384 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
386 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
387 ec, rotation, vp->buffer.transform, transform);
392 EINTERN enum wl_output_transform
393 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
395 E_Comp_Wl_Buffer_Viewport *vp;
396 E_Comp_Wl_Buffer *buffer;
397 enum wl_output_transform transform, rotation;
399 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
400 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
401 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
403 vp = &ec->comp_data->pending.buffer_viewport;
404 if (e_comp_wl_subsurface_check(ec))
405 return vp->buffer.transform;
407 buffer = ec->comp_data->pending.buffer;
410 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
411 return vp->buffer.transform;
413 rotation = buffer->transform;
415 return vp->buffer.transform;
417 /* ignore the flip value when calculating transform because the screen rotation
418 * functionality doesn't consider the flip output transform currently
420 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
422 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
423 ec, rotation, vp->buffer.transform, transform);
429 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
431 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
432 E_Comp_Wl_Buffer *buffer;
433 int32_t width, height;
435 buffer = e_pixmap_resource_get(ec->pixmap);
438 ec->comp_data->width_from_buffer = 0;
439 ec->comp_data->height_from_buffer = 0;
443 switch (e_comp_wl_output_buffer_transform_get(ec))
445 case WL_OUTPUT_TRANSFORM_90:
446 case WL_OUTPUT_TRANSFORM_270:
447 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
448 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
449 width = buffer->h / vp->buffer.scale;
450 height = buffer->w / vp->buffer.scale;
453 width = buffer->w / vp->buffer.scale;
454 height = buffer->h / vp->buffer.scale;
458 ec->comp_data->width_from_buffer = width;
459 ec->comp_data->height_from_buffer = height;
463 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
465 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
466 int32_t width, height;
468 width = ec->comp_data->width_from_buffer;
469 height = ec->comp_data->height_from_buffer;
471 if (width == 0 && height == 0) return;
473 if (width != 0 && vp->surface.width != -1)
475 ec->comp_data->width_from_viewport = vp->surface.width;
476 ec->comp_data->height_from_viewport = vp->surface.height;
480 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
482 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
483 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
484 ec->comp_data->width_from_viewport = w ?: 1;
485 ec->comp_data->height_from_viewport = h ?: 1;
489 ec->comp_data->width_from_viewport = width;
490 ec->comp_data->height_from_viewport = height;
494 e_comp_wl_topmost_parent_get(E_Client *ec)
498 if (!e_comp_wl_subsurface_check(ec))
501 parent = e_comp_wl_subsurface_parent_get(ec);
504 if (!e_comp_wl_subsurface_check(parent))
507 parent = e_comp_wl_subsurface_parent_get(parent);
514 e_comp_wl_map_apply(E_Client *ec)
516 E_Comp_Wl_Buffer_Viewport *vp;
517 E_Comp_Wl_Subsurf_Data *sdata;
518 E_Comp_Wl_Client_Data *cdata;
519 int x1, y1, x2, y2, x, y;
521 Eina_Bool zoom_animating = EINA_FALSE;
523 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
525 e_comp_object_map_update(ec->frame);
527 cdata = ec->comp_data;
528 vp = &cdata->scaler.buffer_viewport;
529 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
530 (!cdata->viewport_transform))
533 if (e_comp_wl_subsurface_check(ec))
535 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
537 sdata = ec->comp_data->sub.data;
538 if (sdata->remote_surface.offscreen_parent)
540 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
541 Eina_Rectangle *rect;
544 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
546 /* TODO: If there are one more regions, it means that provider's offscreen
547 * is displayed by one more remote_surfaces. Have to consider it later. At
548 * this time, just consider only one remote_surface.
562 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
563 if (x != dx || y != dy)
564 evas_object_move(ec->frame, dx, dy);
566 if (!cdata->viewport_transform)
568 cdata->viewport_transform = e_util_transform_new();
569 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
570 e_client_transform_core_add(ec, cdata->viewport_transform);
573 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
574 ec->comp_data->width_from_viewport,
575 ec->comp_data->height_from_viewport);
577 if (vp->buffer.src_width == wl_fixed_from_int(-1))
581 x2 = cdata->width_from_buffer;
582 y2 = cdata->height_from_buffer;
586 x1 = wl_fixed_to_int(vp->buffer.src_x);
587 y1 = wl_fixed_to_int(vp->buffer.src_y);
588 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
589 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
592 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
593 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
594 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
595 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
598 desk = e_comp_desk_find_by_ec(ec);
600 zoom_animating = e_desk_zoom_is_animating(desk);
602 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
603 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
604 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
606 /* workaround:: when the desk zoom is doing their animation,
607 the transform core update can override animation's zoom boundary.
608 so, don't doing transform core update while desk zoom animation */
610 e_client_transform_core_update(ec);
615 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
619 int map_c = 0, map_x = 0, map_y = 0;
620 double inv_x = 0.0, inv_y = 0.0;
622 EINA_SAFETY_ON_NULL_RETURN(ec);
624 map = e_client_map_get(ec);
625 map_c = e_map_count_get(map);
627 if (!map || map_c <= 0)
637 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
638 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
639 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
640 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
642 for (int i = 0; i < map_c; i++)
644 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
645 e_map_point_image_uv_set(map2, i, map_x, map_y);
647 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
657 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
663 if (!(ec = data)) return;
664 if (e_object_is_del(data)) return;
666 if (!ec->override) e_hints_window_visible_set(ec);
668 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
669 (!ec->comp_data->need_reparent))
671 ec->comp_data->need_reparent = EINA_TRUE;
672 ec->visible = EINA_TRUE;
674 if (!e_client_util_ignored_get(ec))
676 ec->take_focus = !starting;
680 if (!ec->comp_data->need_reparent)
682 if ((ec->hidden) || (ec->iconic))
684 evas_object_hide(ec->frame);
685 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
688 evas_object_show(ec->frame);
691 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
692 evas_object_show(tmp->frame);
694 topmost = e_comp_wl_topmost_parent_get(ec);
695 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
696 e_comp_wl_subsurface_show(ec);
698 if (ec->comp_data->sub.below_obj)
699 evas_object_show(ec->comp_data->sub.below_obj);
703 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
709 if (!(ec = data)) return;
710 if (e_object_is_del(E_OBJECT(ec))) return;
712 /* Uncommonly some clients's final buffer can be skipped if the client
713 * requests unmap of its surface right after wl_surface@commit.
714 * So if this client evas object is hidden state and client is already
715 * unmmapped, we can consider to clear pixmap image here mandatorily.
717 if (!ec->comp_data->mapped)
718 e_pixmap_image_clear(ec->pixmap, 1);
720 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
721 evas_object_hide(tmp->frame);
723 topmost = e_comp_wl_topmost_parent_get(ec);
724 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
725 e_comp_wl_subsurface_hide(ec);
727 if (ec->comp_data->sub.below_obj)
728 evas_object_hide(ec->comp_data->sub.below_obj);
730 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
734 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
741 if (!(ec = data)) return;
742 if (e_object_is_del(E_OBJECT(ec))) return;
744 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
746 if (!e_comp_wl_subsurface_check(subc)) continue;
747 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
748 evas_object_move(subc->frame, x, y);
750 if (subc->comp_data->scaler.viewport)
752 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
753 if (cdata->viewport_transform)
754 e_comp_wl_map_apply(subc);
758 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
760 if (!e_comp_wl_subsurface_check(subc)) continue;
761 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
762 evas_object_move(subc->frame, x, y);
764 if (subc->comp_data->scaler.viewport)
766 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
767 if (cdata->viewport_transform)
768 e_comp_wl_map_apply(subc);
772 if (ec->comp_data->sub.below_obj)
774 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
775 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
780 _e_comp_wl_send_touch_cancel(E_Client *ec)
783 struct wl_resource *res;
784 struct wl_client *wc;
785 E_Comp_Config *comp_conf = NULL;
788 if (e_object_is_del(E_OBJECT(ec))) return;
789 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
791 if (!surface) return;
792 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
794 wc = wl_resource_get_client(surface);
796 comp_conf = e_comp_config_get();
798 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
800 if (wl_resource_get_client(res) != wc) continue;
801 if (!e_comp_wl_input_touch_check(res)) continue;
803 if (comp_conf && comp_conf->input_log_enable)
804 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
806 wl_touch_send_cancel(res);
811 _e_comp_wl_touch_cancel(void)
815 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
817 if (!e_comp_wl->touch.pressed) return;
819 _e_comp_wl_send_touch_cancel(ec);
822 static E_Devicemgr_Input_Device *
823 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
825 E_Devicemgr_Input_Device *last_kbd = NULL;
828 case ECORE_DEVICE_CLASS_MOUSE:
829 return e_devicemgr->last_device_ptr;
830 case ECORE_DEVICE_CLASS_KEYBOARD:
831 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
833 case ECORE_DEVICE_CLASS_TOUCH:
834 return e_devicemgr->last_device_touch;
842 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
846 case ECORE_DEVICE_CLASS_MOUSE:
847 e_devicemgr->last_device_ptr = device;
849 case ECORE_DEVICE_CLASS_KEYBOARD:
850 atomic_store(&e_devicemgr->last_device_kbd, device);
852 case ECORE_DEVICE_CLASS_TOUCH:
853 e_devicemgr->last_device_touch = device;
860 static E_Devicemgr_Input_Device *
861 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
863 E_Devicemgr_Input_Device *last_kbd = NULL;
867 case ECORE_DEVICE_CLASS_MOUSE:
868 return ec->comp_data->last_device_ptr;
869 case ECORE_DEVICE_CLASS_KEYBOARD:
870 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
872 case ECORE_DEVICE_CLASS_TOUCH:
873 return ec->comp_data->last_device_touch;
881 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
885 case ECORE_DEVICE_CLASS_MOUSE:
886 ec->comp_data->last_device_ptr = device;
888 case ECORE_DEVICE_CLASS_KEYBOARD:
889 atomic_store(&ec->comp_data->last_device_kbd, device);
891 case ECORE_DEVICE_CLASS_TOUCH:
892 ec->comp_data->last_device_touch = device;
900 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
902 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
903 struct wl_resource *dev_res;
904 const char *dev_name;
905 Ecore_Device_Class dev_class;
906 struct wl_client *wc;
910 EINA_SAFETY_ON_NULL_RETURN(dev);
913 if (ec->cur_mouse_action || e_comp_wl->drag)
915 if (e_object_is_del(E_OBJECT(ec))) return;
916 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
917 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
918 if (!surface) return;
920 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
921 dev_name = evas_device_description_get(dev);
922 last_device = _e_comp_wl_device_last_device_get(dev_class);
923 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
925 serial = wl_display_next_serial(e_comp_wl->wl.disp);
926 wc = wl_resource_get_client(surface);
927 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
928 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
930 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
931 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
933 _e_comp_wl_device_last_device_set(dev_class, input_dev);
934 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
936 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
938 if (wl_resource_get_client(dev_res) != wc) continue;
939 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
943 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
947 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
949 E_Devicemgr_Input_Device *last_device;
950 struct wl_resource *dev_res;
951 struct wl_client *wc;
955 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
956 if (!surface) return;
958 last_device = _e_comp_wl_device_last_device_get(dev_class);
959 if (!last_device) return;
961 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
963 serial = wl_display_next_serial(e_comp_wl->wl.disp);
964 wc = wl_resource_get_client(surface);
965 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
967 if (wl_resource_get_client(dev_res) != wc) continue;
968 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
973 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
975 E_Devicemgr_Input_Device *input_dev;
976 struct wl_resource *dev_res;
977 const char *dev_name;
980 EINA_SAFETY_ON_NULL_RETURN(dev);
982 dev_name = ecore_device_identifier_get(dev);
984 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
985 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
987 if (!eina_streq(input_dev->identifier, dev_name) ||
988 (input_dev->clas != ecore_device_class_get(dev))) continue;
989 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
991 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
993 if (wl_resource_get_client(dev_res) != wc) continue;
994 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
997 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1001 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1003 E_Devicemgr_Input_Device *input_dev;
1004 struct wl_resource *dev_res;
1005 const char *dev_name;
1008 EINA_SAFETY_ON_NULL_RETURN(dev);
1010 dev_name = e_device_identifier_get(dev);
1012 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1013 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1015 if (!eina_streq(input_dev->identifier, dev_name) ||
1016 (input_dev->clas != e_device_class_get(dev))) continue;
1017 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1019 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1021 if (wl_resource_get_client(dev_res) != wc) continue;
1022 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1025 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1029 _e_comp_wl_cursor_reload(E_Client *ec)
1031 struct wl_resource *res;
1032 struct wl_client *wc;
1038 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1039 !evas_object_visible_get(e_comp->pointer->o_ptr))
1040 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1043 if (e_object_is_del(E_OBJECT(ec))) return;
1044 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1045 if (!surface) return;
1046 if (ec->pointer_enter_sent) return;
1048 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1049 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1051 if (e_client_transform_core_enable_get(ec))
1053 double dx = 0.0, dy = 0.0;
1054 map = e_client_map_get(ec);
1055 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1061 cx = px - ec->client.x;
1062 cy = py - ec->client.y;
1064 wc = wl_resource_get_client(surface);
1065 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1066 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1068 if (!e_comp_wl_input_pointer_check(res)) continue;
1069 if (wl_resource_get_client(res) != wc) continue;
1070 wl_pointer_send_enter(res, serial, surface,
1071 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1072 ec->pointer_enter_sent = EINA_TRUE;
1074 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1078 _e_comp_wl_cursor_timer(void *data)
1080 E_Client *ec = data;
1082 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1083 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1085 e_comp_wl_cursor_hide(ec);
1087 return ECORE_CALLBACK_CANCEL;
1091 _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)
1093 E_Devicemgr_Input_Device *input_dev;
1094 struct wl_resource *dev_res;
1095 struct wl_client *wc;
1100 if (ec->cur_mouse_action) return;
1101 if (e_object_is_del(E_OBJECT(ec))) return;
1102 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1103 if (!surface) return;
1105 f_value = wl_fixed_from_double(value);
1106 wc = wl_resource_get_client(surface);
1108 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1109 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1111 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1112 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1114 if (wl_resource_get_client(dev_res) != wc) continue;
1115 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1118 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1122 _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)
1124 if (idx >= e_input_touch_max_count_get()) return;
1126 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1127 e_devicemgr->multi[idx].radius_x = radius_x;
1128 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1129 e_devicemgr->multi[idx].radius_y = radius_y;
1130 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1131 e_devicemgr->multi[idx].pressure = pressure;
1132 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1133 e_devicemgr->multi[idx].angle = angle;
1137 _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)
1139 if (idx >= e_input_touch_max_count_get()) return;
1141 if (e_devicemgr->multi[idx].radius_x != radius_x)
1143 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1144 e_devicemgr->multi[idx].radius_x = radius_x;
1146 if (e_devicemgr->multi[idx].radius_y != radius_y)
1148 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1149 e_devicemgr->multi[idx].radius_y = radius_y;
1151 if (e_devicemgr->multi[idx].pressure != pressure)
1153 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1154 e_devicemgr->multi[idx].pressure = pressure;
1156 if (e_devicemgr->multi[idx].angle != angle)
1158 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1159 e_devicemgr->multi[idx].angle = angle;
1164 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1166 Eina_Bool ret = EINA_TRUE;
1169 case EVAS_CALLBACK_MOUSE_IN:
1170 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1173 if (e_comp_wl->ptr.hide_tmr)
1175 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1176 cursor_timer_ec = ec;
1177 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1181 if (e_pointer_is_hidden(e_comp->pointer))
1186 case EVAS_CALLBACK_MOUSE_OUT:
1187 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1190 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1194 case EVAS_CALLBACK_MOUSE_MOVE:
1195 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1198 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1199 _e_comp_wl_cursor_reload(ec);
1202 case EVAS_CALLBACK_MOUSE_WHEEL:
1203 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1206 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1207 _e_comp_wl_cursor_reload(ec);
1210 case EVAS_CALLBACK_MOUSE_DOWN:
1211 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1214 if (e_comp_wl->ptr.hide_tmr)
1216 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1217 e_comp_wl->ptr.hide_tmr = NULL;
1219 cursor_timer_ec = NULL;
1221 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1222 _e_comp_wl_cursor_reload(ec);
1225 case EVAS_CALLBACK_MOUSE_UP:
1226 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1237 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1239 if (ec->has_cursor_unset)
1242 if (!e_config->show_cursor)
1245 if (!e_config->use_cursor_timer)
1252 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1255 Evas_Event_Mouse_In *ev;
1256 struct wl_resource *res;
1257 struct wl_client *wc;
1260 E_Comp_Config *comp_conf;
1261 E_Client *prev_ptr_ec;
1265 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1266 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1268 if (!(ec = data)) return;
1269 if (e_object_is_del(E_OBJECT(ec))) return;
1270 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1271 if (!surface) return;
1273 prev_ptr_ec = e_comp_wl->ptr.ec;
1276 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1277 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1280 e_comp_wl->ptr.ec = ec;
1282 comp_conf = e_comp_config_get();
1283 if (comp_conf && comp_conf->input_log_enable)
1284 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1285 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1286 e_client_util_name_get(ec));
1288 if (_e_comp_wl_check_cursor_timer_needed(ec))
1290 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1294 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1295 wc = wl_resource_get_client(surface);
1296 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1297 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1299 if (!e_comp_wl_input_pointer_check(res)) continue;
1300 if (wl_resource_get_client(res) != wc) continue;
1302 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1304 wl_pointer_send_enter(res, serial, surface,
1305 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1306 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1307 ec->pointer_enter_sent = EINA_TRUE;
1310 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1314 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1317 Evas_Event_Mouse_Out *ev;
1318 struct wl_resource *res;
1319 struct wl_client *wc;
1322 Eina_Bool inside_check;
1323 E_Comp_Config *comp_conf;
1327 if (!(ec = data)) return;
1328 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1329 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1330 if (ec->cur_mouse_action && inside_check) return;
1331 if (e_object_is_del(E_OBJECT(e_comp))) return;
1332 if (e_comp_wl->ptr.ec == ec)
1333 e_comp_wl->ptr.ec = NULL;
1334 if (e_object_is_del(E_OBJECT(ec))) return;
1336 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1337 if (!surface) return;
1339 comp_conf = e_comp_config_get();
1340 if (comp_conf && comp_conf->input_log_enable)
1341 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1342 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1343 e_client_util_name_get(ec));
1345 if (_e_comp_wl_check_cursor_timer_needed(ec))
1347 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1351 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1353 wc = wl_resource_get_client(surface);
1354 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1355 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1357 if (!e_comp_wl_input_pointer_check(res)) continue;
1358 if (wl_resource_get_client(res) != wc) continue;
1359 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1361 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1363 wl_pointer_send_leave(res, serial, surface);
1364 ec->pointer_enter_sent = EINA_FALSE;
1369 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1372 struct wl_client *wc;
1373 struct wl_resource *res;
1376 E_Comp_Config *comp_conf = NULL;
1379 if (e_object_is_del(E_OBJECT(ec))) return;
1380 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1381 if (!surface) return;
1383 wc = wl_resource_get_client(surface);
1384 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1388 x = wl_fixed_from_int(canvas_x - ec->client.x);
1389 y = wl_fixed_from_int(canvas_y - ec->client.y);
1392 comp_conf = e_comp_config_get();
1394 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1396 if (wl_resource_get_client(res) != wc) continue;
1397 if (!e_comp_wl_input_touch_check(res)) continue;
1398 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1401 if (comp_conf && comp_conf->input_log_enable)
1402 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));
1404 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1408 if (comp_conf && comp_conf->input_log_enable)
1409 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));
1411 wl_touch_send_up(res, serial, timestamp, idx);
1418 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1421 struct wl_client *wc;
1422 struct wl_resource *res;
1426 if (ec->cur_mouse_action) return;
1427 if (e_object_is_del(E_OBJECT(ec))) return;
1428 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1429 if (!surface) return;
1431 wc = wl_resource_get_client(surface);
1433 x = wl_fixed_from_int(canvas_x - ec->client.x);
1434 y = wl_fixed_from_int(canvas_y - ec->client.y);
1436 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1438 if (wl_resource_get_client(res) != wc) continue;
1439 if (!e_comp_wl_input_touch_check(res)) continue;
1440 wl_touch_send_motion(res, timestamp, idx, x, y);
1445 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1447 struct wl_resource *res;
1448 struct wl_client *wc;
1452 if (ec->cur_mouse_action) return;
1453 if (e_object_is_del(E_OBJECT(ec))) return;
1454 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1455 if (!surface) return;
1457 wc = wl_resource_get_client(surface);
1458 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1460 if (!e_comp_wl_input_pointer_check(res)) continue;
1461 if (wl_resource_get_client(res) != wc) continue;
1462 wl_pointer_send_motion(res, timestamp,
1463 wl_fixed_from_int(x - ec->client.x),
1464 wl_fixed_from_int(y - ec->client.y));
1469 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1471 if (e_comp_wl->ptr.hide_tmr)
1473 if (cursor_timer_ec == ec)
1475 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1476 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1480 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1481 cursor_timer_ec = ec;
1482 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1487 cursor_timer_ec = ec;
1488 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1493 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1496 Evas_Event_Mouse_Move *ev;
1497 Evas_Device *dev = NULL;
1498 const char *dev_name;
1499 E_Comp_Config *comp_conf;
1503 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1504 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1506 if (!(ec = data)) return;
1507 if (e_object_is_del(E_OBJECT(ec))) return;
1508 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1509 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1510 if (!surface) return;
1512 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1515 dev_name = evas_device_description_get(dev);
1517 comp_conf = e_comp_config_get();
1518 if (comp_conf && comp_conf->input_log_enable)
1519 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1520 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1521 e_client_util_name_get(ec), dev_name);
1523 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1525 if (!e_comp_wl->drag_client)
1527 e_comp_wl->touch.faked_ec = ec;
1528 if (e_comp_wl->touch.pressed & (1 << 0))
1530 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1532 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1533 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1534 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1538 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1542 if (!e_comp_wl->drag_client)
1544 if (_e_comp_wl_check_cursor_timer_needed(ec))
1546 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1550 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1551 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1553 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1555 if (_e_comp_wl_check_cursor_timer_needed(ec))
1556 _e_comp_wl_cursor_move_timer_control(ec);
1560 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1565 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1567 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1568 if (e_object_is_del(E_OBJECT(ec))) return;
1569 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1570 if (!surface) return;
1571 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1573 e_comp_wl->ptr.button = BTN_LEFT;
1575 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1579 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1581 E_Client *ec = data;
1582 Evas_Event_Mouse_Down *ev = event;
1583 Evas_Device *dev = NULL;
1584 const Evas_Device *seat_dev;
1585 const char *dev_name, *seat_name;
1586 E_Comp_Config *comp_conf = NULL;
1589 if (e_object_is_del(E_OBJECT(ec))) return;
1592 dev_name = evas_device_description_get(dev);
1594 seat_dev = evas_device_parent_get(dev);
1595 seat_name = evas_device_name_get(seat_dev);
1597 comp_conf = e_comp_config_get();
1598 if (comp_conf && comp_conf->input_log_enable)
1599 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1600 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1601 dev_name, seat_name);
1603 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1605 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1607 e_comp_wl->touch.faked_ec = ec;
1610 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1611 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1612 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1614 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1615 e_comp_wl->touch.pressed |= (1 << 0);
1619 if (_e_comp_wl_check_cursor_timer_needed(ec))
1621 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1625 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1626 WL_POINTER_BUTTON_STATE_PRESSED);
1628 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1631 need_send_released = EINA_TRUE;
1635 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1637 E_Client *ec = data;
1638 Evas_Event_Mouse_Up *ev = event;
1639 Evas_Device *dev = NULL;
1640 const Evas_Device *seat_dev;
1641 const char *dev_name, *seat_name;;
1642 Evas_Event_Flags flags;
1643 E_Comp_Config *comp_conf = NULL;
1646 if (ec->cur_mouse_action) return;
1647 if (e_object_is_del(E_OBJECT(ec))) return;
1649 if (!need_send_released)
1651 need_send_motion = EINA_TRUE;
1655 dev_name = evas_device_description_get(dev);
1657 seat_dev = evas_device_parent_get(dev);
1658 seat_name = evas_device_name_get(seat_dev);
1659 flags = evas_event_default_flags_get(evas);
1661 comp_conf = e_comp_config_get();
1662 if (comp_conf && comp_conf->input_log_enable)
1663 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1664 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1665 dev_name, seat_name);
1667 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1669 e_comp_wl->touch.pressed &= ~(1 << 0);
1671 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1672 e_comp_wl->touch.faked_ec = NULL;
1675 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1677 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1679 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1682 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1683 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1684 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1688 if (_e_comp_wl_check_cursor_timer_needed(ec))
1690 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1694 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1695 WL_POINTER_BUTTON_STATE_RELEASED);
1697 if (_e_comp_wl_check_cursor_timer_needed(ec))
1698 _e_comp_wl_cursor_move_timer_control(ec);
1702 need_send_released = EINA_FALSE;
1706 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1708 struct wl_resource *res;
1709 struct wl_client *wc;
1714 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1716 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1719 dir = -wl_fixed_from_int(abs(z));
1721 dir = wl_fixed_from_int(z);
1724 if (e_object_is_del(E_OBJECT(ec))) return;
1725 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1726 if (!surface) return;
1728 wc = wl_resource_get_client(surface);
1729 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1731 if (!e_comp_wl_input_pointer_check(res)) continue;
1732 if (wl_resource_get_client(res) != wc) continue;
1733 wl_pointer_send_axis(res, timestamp, axis, dir);
1738 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1741 Evas_Event_Mouse_Wheel *ev;
1744 if (!(ec = data)) return;
1745 if (ec->cur_mouse_action) return;
1746 if (e_object_is_del(E_OBJECT(ec))) return;
1747 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1748 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1749 if (!surface) return;
1751 if (!eina_list_count(e_comp_wl->ptr.resources))
1754 if (_e_comp_wl_check_cursor_timer_needed(ec))
1756 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1760 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1762 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1764 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1766 if (_e_comp_wl_check_cursor_timer_needed(ec))
1767 _e_comp_wl_cursor_move_timer_control(ec);
1772 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1774 E_Client *ec = data;
1775 Evas_Event_Multi_Down *ev = event;
1776 Evas_Device *dev = NULL;
1777 const Evas_Device *seat_dev;
1778 const char *dev_name, *seat_name;
1779 Evas_Device_Class dev_class;
1780 E_Comp_Config *comp_conf = NULL;
1783 if (e_object_is_del(E_OBJECT(ec))) return;
1784 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1785 if (!surface) return;
1787 /* Do not deliver emulated single touch events to client */
1788 if (ev->device == 0) return;
1791 dev_name = evas_device_description_get(dev);
1792 e_comp_wl->touch.faked_ec = ec;
1794 seat_dev = evas_device_parent_get(dev);
1795 seat_name = evas_device_name_get(seat_dev);
1797 comp_conf = e_comp_config_get();
1798 if (comp_conf && comp_conf->input_log_enable)
1799 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1800 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1801 dev_name, seat_name);
1803 if (dev && dev_name)
1805 dev_class = evas_device_class_get(dev);
1806 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1807 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1810 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1811 e_comp_wl->touch.pressed |= (1 << ev->device);
1815 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1817 E_Client *ec = data;
1818 Evas_Event_Multi_Up *ev = event;
1819 Evas_Device *dev = NULL;
1820 const Evas_Device *seat_dev;
1821 const char *dev_name, *seat_name;
1822 Evas_Device_Class dev_class;
1823 Evas_Event_Flags flags;
1824 E_Comp_Config *comp_conf = NULL;
1827 if (e_object_is_del(E_OBJECT(ec))) return;
1828 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1829 if (!surface) return;
1831 /* Do not deliver emulated single touch events to client */
1832 if (ev->device == 0) return;
1834 flags = evas_event_default_flags_get(evas);
1836 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1837 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1838 e_comp_wl->touch.faked_ec = NULL;
1840 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1843 dev_name = evas_device_description_get(dev);
1845 seat_dev = evas_device_parent_get(dev);
1846 seat_name = evas_device_name_get(seat_dev);
1848 comp_conf = e_comp_config_get();
1849 if (comp_conf && comp_conf->input_log_enable)
1850 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1851 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1852 dev_name, seat_name);
1854 if (dev && dev_name)
1856 dev_class = evas_device_class_get(dev);
1857 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1858 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1861 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1865 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1867 E_Client *ec = data;
1868 Evas_Event_Multi_Move *ev = event;
1869 Evas_Device *dev = NULL;
1870 const char *dev_name;
1871 Evas_Device_Class dev_class;
1874 if (e_object_is_del(E_OBJECT(ec))) return;
1875 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1876 if (!surface) return;
1878 /* Do not deliver emulated single touch events to client */
1879 if (ev->device == 0) return;
1881 e_comp_wl->touch.faked_ec = ec;
1883 if (e_comp_wl->touch.pressed & (1 << ev->device))
1886 if (dev && (dev_name = evas_device_description_get(dev)))
1888 dev_class = evas_device_class_get(dev);
1889 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1890 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1893 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1898 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1901 char *file, buff[PATH_MAX];
1908 n = (getpriority(PRIO_PROCESS, pid) + adj);
1912 setpriority(PRIO_PROCESS, pid, n);
1915 use_adj = EINA_TRUE;
1917 if (!do_child) return;
1919 files = ecore_file_ls("/proc");
1920 EINA_LIST_FREE(files, file)
1922 if (!isdigit(file[0]))
1925 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1926 if ((f = fopen(buff, "r")))
1930 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1932 if (num_read == 2 && ppid == pid)
1933 _e_comp_wl_client_priority_adjust(pid2, set,
1935 adj_child, do_child);
1943 _e_comp_wl_client_priority_raise(E_Client *ec)
1945 if (!e_config->priority_control) return;
1946 if (ec->netwm.pid <= 0) return;
1947 if (ec->netwm.pid == getpid()) return;
1948 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1949 e_config->priority - 1, -1,
1950 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1954 _e_comp_wl_client_priority_normal(E_Client *ec)
1956 if (!e_config->priority_control) return;
1957 if (ec->netwm.pid <= 0) return;
1958 if (ec->netwm.pid == getpid()) return;
1959 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1960 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1964 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1967 E_Comp_Wl_Key_Data *k;
1968 struct wl_resource *res;
1972 if (!ec) return EINA_FALSE;
1973 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1974 if (!ec->comp_data) return EINA_FALSE;
1976 ec->comp_data->on_focus_timer = NULL;
1977 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1978 if (!e_comp_wl->kbd.focused)
1980 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1983 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1985 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1986 t = ecore_time_unix_get();
1988 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1989 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1990 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1992 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1994 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1995 wl_keyboard_send_key(res, serial, t,
1996 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1999 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2000 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2004 /* It is called in the following cases:
2005 * When a normal ec->frame has focus.
2006 * Or launching image ec is replaced to the real ec.
2009 e_comp_wl_feed_focus_in(E_Client *ec)
2012 struct wl_resource *res;
2013 struct wl_client *wc;
2017 if (e_object_is_del(E_OBJECT(ec))) return;
2018 if (ec->iconic) return;
2020 /* block spurious focus events */
2021 focused = e_client_focused_get();
2022 if ((focused) && (ec != focused)) return;
2024 /* raise client priority */
2025 _e_comp_wl_client_priority_raise(ec);
2026 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2027 if (!surface) return;
2029 wc = wl_resource_get_client(surface);
2031 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2032 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2034 if (wl_resource_get_client(res) == wc)
2036 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2037 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2038 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2039 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2042 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2044 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2045 if (!e_comp_wl->kbd.focused)
2047 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2050 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2052 e_comp_wl->kbd.focus = surface;
2053 e_comp_wl_input_keyboard_enter_send(ec);
2054 e_comp_wl_data_device_keyboard_focus_set();
2055 ec->comp_data->on_focus_timer =
2056 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2057 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2058 int rotation = ec->e.state.rot.ang.curr;
2059 e_pointer_rotation_set(e_comp->pointer, rotation);
2063 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2066 if (!(ec = data)) return;
2067 e_comp_wl_feed_focus_in(ec);
2071 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2074 struct wl_resource *res;
2076 E_Comp_Wl_Key_Data *k;
2080 if (!(ec = data)) return;
2082 if (!ec->comp_data) return;
2084 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2086 /* lower client priority */
2087 if (!e_object_is_del(data))
2088 _e_comp_wl_client_priority_normal(ec);
2091 /* update keyboard modifier state */
2092 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2093 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2094 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2096 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2098 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2099 if (!surface) return;
2101 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2102 if (!eina_list_count(e_comp_wl->kbd.resources))
2104 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2108 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2110 /* send keyboard_leave to all keyboard resources */
2111 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2112 t = ecore_time_unix_get();
2114 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2115 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2116 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2118 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2120 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2121 wl_keyboard_send_key(res, serial, t,
2122 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2124 wl_keyboard_send_leave(res, serial, surface);
2125 e_comp_wl->kbd.focused =
2126 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2128 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2129 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2133 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2137 if (!(ec = data)) return;
2139 if (!ec->comp_data->shell.configure_send) return;
2141 /* TODO: calculate x, y with transfrom object */
2142 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2146 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2147 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2148 if (e_comp_object_frame_exists(ec->frame))
2149 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2151 switch (ec->resize_mode)
2153 case E_POINTER_RESIZE_TL:
2154 case E_POINTER_RESIZE_L:
2155 case E_POINTER_RESIZE_BL:
2156 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2157 ec->mouse.current.mx;
2159 case E_POINTER_RESIZE_TR:
2160 case E_POINTER_RESIZE_R:
2161 case E_POINTER_RESIZE_BR:
2162 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2167 switch (ec->resize_mode)
2169 case E_POINTER_RESIZE_TL:
2170 case E_POINTER_RESIZE_T:
2171 case E_POINTER_RESIZE_TR:
2172 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2173 ec->mouse.current.my;
2175 case E_POINTER_RESIZE_BL:
2176 case E_POINTER_RESIZE_B:
2177 case E_POINTER_RESIZE_BR:
2178 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2183 w = E_CLAMP(w, 1, w);
2184 h = E_CLAMP(h, 1, h);
2185 e_client_resize_limit(ec, &w, &h);
2187 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2189 else if ((!ec->fullscreen) && (!ec->maximized) &&
2190 (!ec->comp_data->maximize_pre))
2194 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2195 if ((pw != ec->w) || (ph != ec->h))
2197 _e_comp_wl_configure_send(ec, 1, 1);
2201 if (ec->comp_data->sub.below_obj)
2202 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2206 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2208 E_Client *ec = data;
2210 ec->comp_data->maximize_pre = 1;
2214 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2216 E_Client *ec = data;
2219 if (e_object_is_del(E_OBJECT(ec))) return;
2221 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2222 e_client_shell_configure_send(ec, 0, w, h);
2224 ec->comp_data->maximize_pre = 0;
2228 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2230 E_Client *ec = data;
2232 ec->comp_data->maximize_pre = 1;
2236 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2238 E_Client *ec = data;
2240 if (e_object_is_del(E_OBJECT(ec))) return;
2242 /* check for wayland pixmap */
2244 if (ec->comp_data->shell.configure_send)
2245 _e_comp_wl_configure_send(ec, 0, 0);
2247 ec->comp_data->maximize_pre = 0;
2251 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2253 E_Client *ec = data;
2255 if (e_object_is_del(E_OBJECT(ec))) return;
2257 /* check for wayland pixmap */
2259 if (ec->comp_data->shell.configure_send)
2260 _e_comp_wl_configure_send(ec, 0, 1);
2262 ec->comp_data->maximize_pre = 0;
2266 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2268 E_Client *ec = data;
2270 if (e_object_is_del(E_OBJECT(ec))) return;
2272 /* check for wayland pixmap */
2274 if (ec->comp_data->shell.configure_send)
2275 _e_comp_wl_configure_send(ec, 0, 0);
2277 ec->comp_data->maximize_pre = 0;
2281 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2285 if (!(ec = data)) return;
2287 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2289 e_object_del(E_OBJECT(ec));
2291 _e_comp_wl_focus_check();
2293 /* TODO: Delete request send ??
2294 * NB: No such animal wrt wayland */
2298 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2302 if (!(ec = data)) return;
2304 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2307 if (ec->comp_data->reparented)
2308 e_client_comp_hidden_set(ec, EINA_TRUE);
2311 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2312 if (ec->visible) evas_object_hide(ec->frame);
2313 if (!ec->internal) e_object_del(E_OBJECT(ec));
2315 _e_comp_wl_focus_check();
2319 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2323 if (!(ec = data)) return;
2325 e_client_shell_ping(ec);
2329 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2334 if (!(ec = data)) return;
2335 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2336 if (ec->netwm.opacity == a) return;
2337 ec->netwm.opacity = a;
2338 ec->netwm.opacity_changed = EINA_TRUE;
2342 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2344 Eina_Rectangle *damage_rect = NULL;
2345 Eina_Rectangle *dmg = NULL;
2346 Eina_List *l = NULL;
2348 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2349 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2352 if (!buffer->tbm_surface) return;
2356 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2360 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2361 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2364 eina_rectangle_union(damage_rect, dmg);
2369 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2370 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2373 tbm_surface_internal_set_damage(buffer->tbm_surface,
2379 eina_rectangle_free(damage_rect);
2383 _e_comp_wl_client_evas_init(E_Client *ec)
2385 if (!ec || !ec->comp_data) return;
2386 if (ec->comp_data->evas_init) return;
2388 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2389 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2390 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2393 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2395 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2396 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2397 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2398 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2400 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2401 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2404 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2405 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2409 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2410 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2411 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2412 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2413 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2414 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2415 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2418 /* setup delete/kill callbacks */
2419 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2420 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2422 /* setup ping callback */
2423 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2424 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2426 ec->comp_data->evas_init = EINA_TRUE;
2430 _e_comp_wl_client_evas_deinit(E_Client *ec)
2432 if (!ec || !ec->comp_data) return;
2433 if (!ec->comp_data->evas_init) return;
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2446 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2455 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2456 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2457 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2458 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2459 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2460 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2461 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2464 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2465 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2467 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2468 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2470 ec->comp_data->evas_init = EINA_FALSE;
2474 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2478 E_Comp_Screen *e_comp_screen;
2479 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2481 if (!e_comp) return ECORE_CALLBACK_RENEW;
2482 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2483 e_comp_screen = e_comp->e_comp_screen;
2485 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2487 if (!eout->config.enabled)
2489 e_comp_wl_output_remove(eout->id);
2493 switch (eout->config.rotation)
2496 transform = WL_OUTPUT_TRANSFORM_90;
2499 transform = WL_OUTPUT_TRANSFORM_180;
2502 transform = WL_OUTPUT_TRANSFORM_270;
2506 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2510 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2512 eout->config.geom.x, eout->config.geom.y,
2513 eout->config.geom.w, eout->config.geom.h,
2514 eout->info.size.w, eout->info.size.h,
2515 eout->config.mode.refresh, 0, transform))
2516 ERR("Could not initialize screen %s", eout->info.name);
2519 return ECORE_CALLBACK_RENEW;
2523 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2527 /* try to get the client from the object */
2528 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2529 return ECORE_CALLBACK_RENEW;
2531 /* check for client being deleted */
2532 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2534 /* check for wayland pixmap */
2535 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2536 return ECORE_CALLBACK_RENEW;
2538 /* if we have not setup evas callbacks for this client, do it */
2539 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2541 return ECORE_CALLBACK_RENEW;
2545 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2549 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2550 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2552 if (e_comp_wl->selection.target &&
2555 struct wl_resource *res;
2557 E_Client *ec = NULL;
2558 E_Client *legacy_target = e_comp_wl->selection.target;
2559 int device_id = e_comp_wl_data_current_device_id_get();
2563 e_comp_wl_data_current_device_id_set(ev->multi.device);
2565 else if (device_id != ev->multi.device)
2567 return ECORE_CALLBACK_RENEW;
2570 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2571 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2573 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2574 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2576 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2577 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2579 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2580 (ec != legacy_target))
2582 e_comp_wl_data_device_send_leave(legacy_target);
2583 e_comp_wl_data_device_send_enter(ec);
2586 if (e_comp_wl->drag)
2587 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2589 if (e_client_transform_core_enable_get(ec))
2591 int trans_x, trans_y;
2592 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2593 x = trans_x - ec->client.x;
2594 y = trans_y - ec->client.y;
2598 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2603 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2606 return ECORE_CALLBACK_RENEW;
2610 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2613 struct wl_resource *surface;
2614 struct wl_resource *res;
2615 struct wl_client *wc;
2617 E_Comp_Config *comp_conf;
2619 ec = e_comp_wl->ptr_constraints.ec;
2620 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2622 surface = e_comp_wl_client_surface_get(ec);
2623 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2625 wc = wl_resource_get_client(surface);
2627 comp_conf = e_comp_config_get();
2629 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2631 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2632 if (wl_resource_get_client(res) != wc) continue;
2634 if (comp_conf && comp_conf->input_log_enable)
2635 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2636 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2637 e_client_util_name_get(ec));
2639 zwp_relative_pointer_v1_send_relative_motion(res,
2641 (uint32_t)(ev->timestamp),
2642 wl_fixed_from_int(ev->dx),
2643 wl_fixed_from_int(ev->dy),
2644 wl_fixed_from_int(ev->dx_unaccel),
2645 wl_fixed_from_int(ev->dy_unaccel));
2648 return ECORE_CALLBACK_DONE;
2652 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2654 _e_comp_wl_touch_cancel();
2656 return ECORE_CALLBACK_PASS_ON;
2660 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2662 if (!ev) return ECORE_CALLBACK_PASS_ON;
2664 E_Zone *zone = ev->zone;
2666 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2667 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2669 if (!e_zone_is_displaying(zone))
2670 _e_comp_wl_touch_cancel();
2672 return ECORE_CALLBACK_PASS_ON;
2676 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2678 E_Client *ec = ev->ec;
2679 E_Comp_Wl_Buffer_Viewport *vp;
2681 if (!ec) return ECORE_CALLBACK_PASS_ON;
2682 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2683 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2684 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2685 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2687 vp = &ec->comp_data->scaler.buffer_viewport;
2688 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2690 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2692 return ECORE_CALLBACK_PASS_ON;
2696 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2698 E_Client *ec = ev->ec;
2699 E_Comp_Wl_Buffer_Viewport *vp;
2701 if (!ec) return ECORE_CALLBACK_PASS_ON;
2702 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2703 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2704 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2706 vp = &ec->comp_data->scaler.buffer_viewport;
2707 vp->wait_for_transform_change = 0;
2709 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2711 return ECORE_CALLBACK_PASS_ON;
2715 _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)
2717 E_Client *focused_ec;
2720 focused_ec = e_client_focused_get();
2721 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2723 rotation = focused_ec->e.state.rot.ang.curr;
2724 e_pointer_rotation_set(e_comp->pointer, rotation);
2726 return ECORE_CALLBACK_PASS_ON;
2730 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2733 Eina_Rectangle *window;
2738 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2740 if ((prev_w != state->bw) ||
2741 (prev_h != state->bh))
2743 ec->changes.buf_size = EINA_TRUE;
2746 if (e_comp_object_frame_exists(ec->frame)) return;
2747 window = &ec->comp_data->shell.window;
2748 if ((!ec->borderless) && /* FIXME temporarily added this check code
2749 * to prevent updating E_Client's size by frame */
2750 (window->x || window->y || window->w || window->h))
2752 e_comp_object_frame_geometry_set(ec->frame,
2754 (window->x + window->w) - state->bw,
2756 (window->y + window->h) - state->bh);
2759 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2763 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2765 E_Comp_Wl_Surface_State *state;
2768 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2769 state->buffer = NULL;
2773 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2775 state->new_attach = EINA_FALSE;
2776 state->buffer = NULL;
2777 state->buffer_destroy_listener.notify =
2778 _e_comp_wl_surface_state_cb_buffer_destroy;
2779 state->sx = state->sy = 0;
2781 state->input = eina_tiler_new(w, h);
2782 eina_tiler_tile_size_set(state->input, 1, 1);
2784 state->opaque = eina_tiler_new(w, h);
2785 eina_tiler_tile_size_set(state->opaque, 1, 1);
2787 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2788 state->buffer_viewport.buffer.scale = 1;
2789 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2790 state->buffer_viewport.surface.width = -1;
2791 state->buffer_viewport.changed = 0;
2793 e_presentation_time_container_init(&state->presentation_container);
2797 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2799 struct wl_resource *cb;
2800 Eina_Rectangle *dmg;
2802 EINA_LIST_FREE(state->frames, cb)
2803 wl_resource_destroy(cb);
2805 EINA_LIST_FREE(state->damages, dmg)
2806 eina_rectangle_free(dmg);
2808 EINA_LIST_FREE(state->buffer_damages, dmg)
2809 eina_rectangle_free(dmg);
2811 if (state->opaque) eina_tiler_free(state->opaque);
2812 state->opaque = NULL;
2814 if (state->input) eina_tiler_free(state->input);
2815 state->input = NULL;
2817 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2818 state->buffer = NULL;
2820 e_presentation_time_container_finish(&state->presentation_container);
2824 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2826 if (state->buffer == buffer) return;
2828 wl_list_remove(&state->buffer_destroy_listener.link);
2829 state->buffer = buffer;
2831 wl_signal_add(&state->buffer->destroy_signal,
2832 &state->buffer_destroy_listener);
2836 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2838 Eina_Rectangle *dmg;
2839 Eina_Bool placed = EINA_TRUE;
2843 E_Comp_Wl_Buffer *buffer;
2844 struct wl_resource *cb;
2846 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2847 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2852 if ((ec->internal) ||
2853 (cdata->shell.surface && state->new_attach))
2857 e_comp->new_clients++;
2858 ELOGF("COMP", "Unignore", ec);
2859 e_client_unignore(ec);
2863 /* buffer transform */
2864 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2867 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2869 /* when buffer is transformed, we have to apply the new evas-map */
2870 state->buffer_viewport.changed = EINA_TRUE;
2872 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2874 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2876 if (transform_change == vp->wait_for_transform_change)
2877 vp->wait_for_transform_change = 0;
2879 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2880 // triggered by E_CLIENT_HOOK calls at those file.
2881 zone = e_comp_zone_find_by_ec(ec);
2884 eout = e_output_find(zone->output_id);
2885 if (eout && eout->hwc)
2887 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2889 if (e_comp_is_on_overlay(ec))
2890 e_comp_hwc_client_end(ec, __FUNCTION__);
2896 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2897 cdata->scaler.buffer_viewport = state->buffer_viewport;
2899 if (state->new_attach)
2901 e_comp_wl_surface_attach(ec, state->buffer);
2904 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2905 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2907 _e_comp_wl_surface_state_buffer_set(state, NULL);
2909 if ((state->new_attach) ||
2910 (state->buffer_viewport.changed))
2912 _e_comp_wl_surface_state_size_update(ec, state);
2913 e_comp_wl_map_size_cal_from_viewport(ec);
2915 /* update the position */
2916 if (ec->changes.pos)
2918 e_comp_object_frame_xy_unadjust(ec->frame,
2928 if (ec->new_client) placed = ec->placed;
2930 if (!ec->lock_client_size)
2935 ec->client.w = state->bw;
2936 ec->client.h = state->bh;
2938 e_comp_object_frame_wh_adjust(ec->frame,
2939 ec->client.w, ec->client.h,
2941 e_client_size_set(ec, nw, nh);
2943 if ((w != ec->w) || (h != ec->h))
2945 ec->changes.size = 1;
2950 if (ec->changes.buf_size)
2952 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2953 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2954 ec->changes.buf_size = EINA_FALSE;
2956 if (ec->move_after_resize)
2958 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2959 ec->move_after_resize = EINA_FALSE;
2964 /* map or unmap ec */
2965 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2966 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2967 if (!pixmap_usable || hide_by_request)
2972 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2977 if ((cdata->sub.below_obj) &&
2978 (evas_object_visible_get(cdata->sub.below_obj)))
2980 evas_object_hide(cdata->sub.below_obj);
2988 if ((cdata->sub.below_obj) &&
2989 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2990 (evas_object_visible_get(ec->frame)))
2992 evas_object_show(cdata->sub.below_obj);
2996 if ((state->new_attach) ||
2997 (state->buffer_viewport.changed))
2999 if ((e_comp_wl->drag) &&
3000 (e_comp_wl->drag_client) &&
3001 (e_comp_wl->drag_client == ec))
3003 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3005 e_drag_move(e_comp_wl->drag,
3007 e_comp_wl->drag->y);
3009 e_drag_resize(e_comp_wl->drag,
3010 state->bw, state->bh);
3012 else if ((cdata->shell.surface) &&
3013 (cdata->shell.configure))
3015 e_comp_wl_commit_sync_configure(ec);
3017 else if (!e_client_video_hw_composition_check(ec))
3019 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3024 ec->placed = placed;
3025 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3029 if (cdata->scaler.buffer_viewport.changed)
3030 e_comp_wl_map_apply(ec);
3032 /* resize transform object */
3033 if (ec->transformed)
3034 e_client_transform_update(ec);
3038 state->new_attach = EINA_FALSE;
3040 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3042 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3043 wl_resource_destroy(cb);
3046 /* insert state frame callbacks into comp_data->frames
3047 * NB: This clears state->frames list */
3048 cdata->frames = eina_list_merge(cdata->frames,
3050 state->frames = NULL;
3052 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3053 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3054 &state->presentation_container);
3056 buffer = e_pixmap_resource_get(ec->pixmap);
3058 /* put state damages into surface */
3061 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3062 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3064 if ((cdata->buffer_ref.buffer) &&
3065 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3066 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3068 e_comp_object_damage(ec->frame,
3070 cdata->buffer_ref.buffer->w,
3071 cdata->buffer_ref.buffer->h);
3076 Eina_List *damages = NULL;
3079 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3081 if (eina_list_count(state->buffer_damages))
3083 EINA_LIST_FREE(state->buffer_damages, dmg)
3086 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3087 e_comp_wl_output_buffer_transform_get(ec),
3089 dmg->x, dmg->y, dmg->w, dmg->h,
3090 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3091 damages = eina_list_append(damages, dmg);
3095 EINA_LIST_FREE(state->damages, dmg)
3096 damages = eina_list_append(damages, dmg);
3098 EINA_LIST_FREE(damages, dmg)
3100 /* not creating damage for ec that shows a underlay video */
3101 if (state->buffer_viewport.changed ||
3102 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3103 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3104 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3106 eina_rectangle_free(dmg);
3111 /* put state opaque into surface */
3112 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3115 Eina_Rectangle *rect;
3118 itr = eina_tiler_iterator_new(state->opaque);
3119 EINA_ITERATOR_FOREACH(itr, rect)
3123 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3124 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3125 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3129 eina_iterator_free(itr);
3132 /* put state input into surface */
3133 if ((state->input) &&
3134 (!eina_tiler_empty(state->input)) &&
3137 Eina_Tiler *src, *tmp;
3141 tmp = eina_tiler_new(sw, sh);
3142 eina_tiler_tile_size_set(tmp, 1, 1);
3144 eina_tiler_rect_add(tmp,
3145 &(Eina_Rectangle){0, 0, sw, sh});
3147 if ((src = eina_tiler_intersection(state->input, tmp)))
3149 Eina_Rectangle *rect;
3152 e_comp_object_input_objs_del(ec->frame);
3153 itr = eina_tiler_iterator_new(src);
3154 EINA_ITERATOR_FOREACH(itr, rect)
3156 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3157 ec, rect->x, rect->y, rect->w, rect->h,
3158 ec->w, ec->h, state->bw, state->bh);
3159 e_comp_object_input_area_set(ec->frame,
3164 eina_iterator_free(itr);
3165 eina_tiler_free(src);
3168 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3170 eina_tiler_free(tmp);
3172 /* clear input tiler */
3173 eina_tiler_clear(state->input);
3176 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3178 if ((cdata->video_client) &&
3180 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3181 (e_comp->wl_comp_data->available_hw_accel.underlay))
3183 e_pixmap_image_clear(ec->pixmap, 1);
3186 state->buffer_viewport.changed = 0;
3188 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3191 ec->exp_iconify.buffer_flush &&
3192 e_policy_visibility_client_is_iconic(ec))
3194 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3199 _e_comp_wl_surface_render_stop(E_Client *ec)
3201 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3202 //if ((!ec->internal) && (!e_comp_gl_get()))
3205 /* check if internal animation is running */
3206 if (e_comp_object_is_animating(ec->frame)) return;
3207 /* check if external animation is running */
3208 if (evas_object_data_get(ec->frame, "effect_running")) return;
3210 evas_object_hide(ec->frame);
3214 e_comp_wl_client_surface_finish(E_Client *ec)
3216 struct wl_resource *res, *surface;
3217 struct wl_client *surface_client = NULL;
3220 surface = e_comp_wl_client_surface_get(ec);
3223 surface_client = wl_resource_get_client(surface);
3225 if (surface_client &&
3226 (ec == e_client_focused_get()))
3228 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3229 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3231 if (wl_resource_get_client(res) ==
3233 e_comp_wl->kbd.focused =
3234 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3238 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3241 e_comp_wl_client_surface_set(ec, NULL);
3243 ec->comp_data->wl_surface = NULL;
3244 e_pixmap_win_id_del(ec->pixmap);
3246 _e_comp_wl_surface_render_stop(ec);
3247 e_object_del(E_OBJECT(ec));
3251 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3256 char proc[512], pname[512];
3259 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3261 h = fopen(proc, "r");
3264 len = fread(pname, sizeof(char), 512, h);
3266 pname[len - 1] = '\0';
3268 strncpy(pname, "NO NAME", sizeof(pname));
3274 strncpy(pname, "NO NAME", sizeof(pname));
3277 strncpy(name, pname, size);
3281 _e_comp_wl_pname_print(pid_t pid)
3284 char proc[512], pname[512];
3287 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3289 h = fopen(proc, "r");
3292 len = fread(pname, sizeof(char), 512, h);
3294 pname[len - 1] = '\0';
3296 strncpy(pname, "NO NAME", sizeof(pname));
3300 ELOGF("COMP", " |%s", NULL, pname);
3305 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3307 struct wl_client *client = data;
3308 E_Comp_Connected_Client_Info *cinfo;
3311 cinfo = wl_container_of(listener, cinfo, destroy);
3313 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3314 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3316 eai = e_appinfo_find_with_pid(cinfo->pid);
3317 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3320 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3322 wl_list_remove(&cinfo->destroy.link);
3323 eina_stringshare_del(cinfo->name);
3328 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3330 E_Comp_Connected_Client_Info *cinfo;
3332 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3333 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3335 cinfo->name = eina_stringshare_add(name);
3339 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3340 wl_client_add_destroy_listener(client, &cinfo->destroy);
3341 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3343 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3347 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3349 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3351 /* send configure */
3352 if (ec->comp_data->shell.configure_send)
3354 if (ec->comp_data->shell.surface)
3355 _e_comp_wl_configure_send(ec, 0, 0);
3358 e_comp_wl->kbd.focus = ec->comp_data->surface;
3362 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3364 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3366 /* send configure */
3367 if (ec->comp_data->shell.configure_send)
3369 if (ec->comp_data->shell.surface)
3370 _e_comp_wl_configure_send(ec, 0, 0);
3373 _e_comp_wl_focus_check();
3375 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3376 e_comp_wl->kbd.focus = NULL;
3380 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3382 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3383 if (ec->keyboard_resizing) return;
3385 /* do nothing currently */
3390 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3392 if (e_object_is_del(E_OBJECT(ec))) return;
3393 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3395 e_comp_wl->resize.edges = 0;
3396 e_comp_wl->resize.resource = NULL;
3400 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3402 if (e_object_is_del(E_OBJECT(ec))) return;
3403 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3407 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3410 int ratio_w, ratio_h;
3412 phys_w = output->phys_width;
3413 phys_h = output->phys_height;
3415 if (e_config->configured_output_resolution.use)
3417 // change the configured physical size(mm) of the output
3418 if (output->w != res_w)
3420 ratio_w = res_w / output->w;
3421 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3424 if (output->h != res_h)
3426 ratio_h = res_h / output->h;
3427 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3430 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3433 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3434 NULL, res_w, res_h, phys_w, phys_h, pid);
3436 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3437 wl_output_send_scale(resource, output->scale);
3439 wl_output_send_geometry(resource, output->x, output->y,
3441 output->subpixel, output->make ?: "",
3442 output->model ?: "", output->transform);
3444 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3445 res_w, res_h, output->refresh);
3447 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3448 wl_output_send_done(resource);
3452 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3454 E_Comp_Wl_Output *output;
3456 if (!(output = wl_resource_get_user_data(resource))) return;
3458 output->resources = eina_list_remove(output->resources, resource);
3462 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3464 E_Comp_Wl_Output *output;
3465 struct wl_resource *resource;
3466 E_Appinfo *eai = NULL;
3470 if (!(output = data)) return;
3473 wl_resource_create(client, &wl_output_interface, version, id);
3476 wl_client_post_no_memory(client);
3480 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3481 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3483 output->resources = eina_list_append(output->resources, resource);
3485 wl_resource_set_implementation(resource, NULL, output,
3486 _e_comp_wl_cb_output_unbind);
3487 wl_resource_set_user_data(resource, output);
3489 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3490 if (e_config->configured_output_resolution.use)
3492 wl_client_get_credentials(client, &pid, NULL, NULL);
3495 res_w = e_config->configured_output_resolution.w;
3496 res_h = e_config->configured_output_resolution.h;
3500 eai = e_appinfo_find_with_pid(pid);
3503 res_w = e_config->configured_output_resolution.w;
3504 res_h = e_config->configured_output_resolution.h;
3508 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3510 res_w = e_config->configured_output_resolution.w;
3511 res_h = e_config->configured_output_resolution.h;
3515 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3524 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3528 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3531 Evas_GL *evasgl = NULL;
3532 Evas_GL_API *glapi = NULL;
3533 Evas_GL_Context *ctx = NULL;
3534 Evas_GL_Surface *sfc = NULL;
3535 Evas_GL_Config *cfg = NULL;
3537 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3539 if (!e_comp_gl_get()) return;
3541 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3542 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3544 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3545 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3547 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3548 * then we should get evas from ecore_evas.
3551 evas = e_comp->evas;
3553 evas = ecore_evas_get(e_comp->ee);
3555 evasgl = evas_gl_new(evas);
3556 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3558 glapi = evas_gl_api_get(evasgl);
3559 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3560 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3562 cfg = evas_gl_config_new();
3563 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3565 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3566 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3568 ctx = evas_gl_context_create(evasgl, NULL);
3569 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3571 res = evas_gl_make_current(evasgl, sfc, ctx);
3572 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3574 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3575 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3577 evas_gl_config_free(cfg);
3579 evas_gl->gl = evasgl;
3580 evas_gl->glapi = glapi;
3581 evas_gl->glsfc = sfc;
3582 evas_gl->glctx = ctx;
3584 e_comp_wl->evas_gl = evas_gl;
3586 /* for native surface */
3589 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3594 evas_gl_config_free(cfg);
3595 evas_gl_make_current(evasgl, NULL, NULL);
3596 evas_gl_context_destroy(evasgl, ctx);
3597 evas_gl_surface_destroy(evasgl, sfc);
3598 evas_gl_free(evasgl);
3605 _e_comp_wl_gl_popup_cb_close(void *data,
3606 Evas_Object *obj EINA_UNUSED,
3607 void *event_info EINA_UNUSED)
3609 evas_object_del(data);
3613 _e_comp_wl_gl_popup_cb_focus(void *data,
3614 Evas_Object *obj EINA_UNUSED,
3615 void *event_info EINA_UNUSED)
3617 elm_object_focus_set(data, EINA_TRUE);
3622 _e_comp_wl_gl_idle(void *data)
3626 /* show warning window to notify failure of gl init */
3629 Evas_Object *win, *bg, *popup, *btn;
3631 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3632 elm_win_title_set(win, "Compositor Warning");
3633 elm_win_autodel_set(win, EINA_TRUE);
3634 elm_win_borderless_set(win, EINA_TRUE);
3635 elm_win_role_set(win, "notification-low");
3636 elm_win_alpha_set(win, EINA_TRUE);
3638 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3639 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3640 elm_win_resize_object_add(win, bg);
3641 evas_object_color_set(bg, 125, 125, 125, 125);
3642 evas_object_show(bg);
3644 popup = elm_popup_add(win);
3645 elm_object_text_set(popup,
3646 _( "Your screen does not support OpenGL.<br>"
3647 "Falling back to software engine."));
3648 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3650 btn = elm_button_add(popup);
3651 elm_object_text_set(btn, "Close");
3652 elm_object_part_content_set(popup, "button1", btn);
3653 evas_object_show(btn);
3655 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3656 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3658 evas_object_show(popup);
3659 evas_object_show(win);
3663 return ECORE_CALLBACK_CANCEL;
3667 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3669 struct wl_client *client = data;
3675 wl_client_get_credentials(client, &pid, &uid, &gid);
3677 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3679 _e_comp_wl_pname_print(pid);
3680 _e_comp_wl_pname_get(pid, name, sizeof(name));
3681 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3685 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3687 char buf[1024] = {0, };
3689 vsnprintf(buf, 1024, fmt, args);
3693 DBG("[libds] %s", buf);
3696 INF("[libds] %s", buf);
3699 ERR("[libds] %s", buf);
3707 _e_comp_wl_display_create(void)
3710 E_Comp_Wl_Data *wl_cdata;
3715 /* create new compositor data */
3716 if (!(comp = E_NEW(E_Comp_Data, 1)))
3718 ERR("Could not create compositor data: %m");
3721 wl_cdata = &comp->base;
3723 /* set compositor wayland data */
3724 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3726 g_mutex_init(&connection_mutex);
3728 /* try to create a wayland display */
3729 if (!(wl_cdata->wl.disp = wl_display_create()))
3731 ERR("Could not create a Wayland display: %m");
3735 /* try to setup wayland socket */
3736 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3738 ERR("Could not create Wayland display socket: %m");
3739 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3743 res = e_comp_socket_init(name);
3744 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3745 PRCTL("[Winsys] change permission and create sym link for %s", name);
3747 /* set wayland display environment variable */
3748 e_env_set("WAYLAND_DISPLAY", name);
3750 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3751 /* wl_cdata->output.scale = e_scale; */
3753 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3755 if (!e_compositor_init(wl_cdata->wl.disp))
3757 ERR("Failed to initialize compositor");
3761 comp->client_created.notify = _e_comp_wl_cb_client_created;
3762 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3764 if (!e_comp_wl_subsurfaces_init())
3766 ERR("Failed to init_subsurfaces");
3767 goto subsurfaces_err;
3770 /* initialize shm mechanism */
3771 wl_display_init_shm(wl_cdata->wl.disp);
3773 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3775 /* try to init data manager */
3776 if (!e_comp_wl_data_manager_init())
3778 ERR("Could not initialize data manager");
3782 /* try to init input */
3783 if (!e_comp_wl_input_init())
3785 ERR("Could not initialize input");
3789 if (e_comp_gl_get())
3790 _e_comp_wl_gl_init(NULL);
3792 /* get the wayland display loop */
3793 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3795 /* get the file descriptor of the wayland event loop */
3796 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3798 /* create a listener for wayland main loop events */
3800 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3801 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3802 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3803 _e_comp_wl_cb_prepare, wl_cdata);
3808 e_comp_wl_data_manager_shutdown();
3810 e_comp_wl_subsurfaces_shutdown();
3812 wl_list_remove(&comp->client_created.link);
3814 e_env_unset("WAYLAND_DISPLAY");
3816 wl_display_destroy(wl_cdata->wl.disp);
3818 g_mutex_clear(&connection_mutex);
3824 _e_comp_wl_gl_shutdown(void)
3826 if (!e_comp_wl->evas_gl) return;
3828 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3830 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3831 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3832 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3833 evas_gl_free(e_comp_wl->evas_gl->gl);
3835 E_FREE(e_comp_wl->evas_gl);
3838 /* public functions */
3841 * Creates and initializes a Wayland compositor with ecore.
3842 * Registers callback handlers for keyboard and mouse activity
3843 * and other client events.
3845 * @returns true on success, false if initialization failed.
3848 e_comp_wl_init(void)
3850 TRACE_DS_BEGIN(COMP_WL:INIT);
3852 /* try to create a wayland compositor */
3853 if (!_e_comp_wl_display_create())
3855 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3860 e_comp_wl_shell_init();
3862 #ifdef HAVE_WAYLAND_TBM
3863 e_comp_wl_tbm_init();
3865 e_comp_wl_remote_surface_init();
3869 e_comp_wl_screenshooter_init();
3871 if (!e_comp_wl_video_init())
3872 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3874 e_comp_wl_viewport_init();
3875 e_comp_wl_capture_init();
3876 e_comp_wl_renderer_init();
3877 _e_comp_wl_move_resize_init();
3878 e_presentation_time_init();
3879 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3882 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3883 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3885 /* add event handlers to catch E events */
3886 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3887 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3888 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3889 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3890 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3891 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3892 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3893 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3894 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3896 /* add hooks to catch e_client events */
3897 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3898 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3899 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3900 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3901 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3903 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3910 e_comp_wl_deferred_job(void)
3912 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3915 /* internal functions */
3917 e_comp_wl_shutdown(void)
3919 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3921 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3923 e_comp_wl_subsurfaces_shutdown();
3925 E_FREE_LIST(handlers, ecore_event_handler_del);
3926 E_FREE_LIST(hooks, e_client_hook_del);
3927 _e_comp_wl_gl_shutdown();
3929 e_blender_shutdown();
3930 e_presentation_time_shutdown();
3931 e_comp_wl_renderer_shutdown();
3932 e_comp_wl_capture_shutdown();
3933 e_comp_wl_viewport_shutdown();
3934 e_comp_wl_video_shutdown();
3935 e_comp_wl_screenshooter_shutdown();
3937 e_comp_wl_remote_surface_shutdown();
3939 e_pixmap_shutdown();
3941 e_wtz_shell_shutdown();
3942 e_comp_wl_shell_shutdown();
3943 e_comp_wl_input_shutdown();
3945 wl_list_remove(&comp->client_created.link);
3948 e_comp->wl_comp_data = NULL;
3952 E_Comp_Wl_Output *output;
3954 if (e_comp_wl->screenshooter.global)
3955 wl_global_destroy(e_comp_wl->screenshooter.global);
3957 EINA_LIST_FREE(e_comp_wl->outputs, output)
3959 if (output->id) eina_stringshare_del(output->id);
3960 if (output->make) eina_stringshare_del(output->make);
3961 if (output->model) eina_stringshare_del(output->model);
3965 /* delete fd handler */
3966 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3968 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3969 cursor_timer_ec = NULL;
3971 /* free allocated data structure */
3977 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3979 e_object_unref(E_OBJECT(ev->ec));
3984 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3987 ev = E_NEW(E_Event_Client, 1);
3990 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3992 /* set usable early because shell module checks this */
3993 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3994 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3996 e_pixmap_resource_set(ec->pixmap, buffer);
3997 e_pixmap_dirty(ec->pixmap);
3998 e_pixmap_refresh(ec->pixmap);
4000 e_comp_wl_map_size_cal_from_buffer(ec);
4001 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4003 /* wm-policy module uses it */
4004 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4007 e_object_ref(E_OBJECT(ec));
4008 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4009 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4013 e_comp_wl_surface_commit(E_Client *ec)
4018 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4019 if (!e_comp_object_damage_exists(ec->frame))
4021 if ((ec->comp_data->video_client) ||
4022 (!e_client_video_hw_composition_check(ec)))
4023 e_pixmap_image_clear(ec->pixmap, 1);
4026 ignored = ec->ignored;
4028 if (e_comp_wl_subsurface_order_commit(ec))
4030 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4031 e_comp_wl_subsurface_restack(topmost);
4032 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4035 ec->ignored = ignored;
4037 if (ec->is_cursor && ec->visible)
4039 /* ignore cursor changes during resize/move I guess */
4040 if (!e_client_action_get())
4042 if (e_comp->pointer)
4044 x = e_comp->pointer->hot.x;
4045 y = e_comp->pointer->hot.y;
4047 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4053 static E_Comp_Wl_Output *
4054 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4057 E_Comp_Wl_Output *output;
4059 EINA_LIST_FOREACH(outputs, l, output)
4061 if (!strcmp(output->id, id))
4069 * Initializes information about one display output.
4071 * Adds or updates the given data about a single display output,
4072 * with an id matching the provided id.
4074 * @param id identification of output to be added or changed
4075 * @param make manufacturer name of the display output
4076 * @param model model name of the display output
4077 * @param x output's top left corner x coordinate
4078 * @param y output's top left corner y coordinate
4079 * @param w output's width in pixels
4080 * @param h output's height in pixels
4081 * @param pw output's physical width in millimeters
4082 * @param ph output's physical height in millimeters
4083 * @param refresh output's refresh rate in mHz
4084 * @param subpixel output's subpixel layout
4085 * @param transform output's rotation and/or mirror transformation
4087 * @returns True if a display output object could be added or updated
4090 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4091 int x, int y, int w, int h, int pw, int ph,
4092 unsigned int refresh, unsigned int subpixel,
4093 unsigned int transform)
4095 E_Comp_Wl_Output *output;
4097 struct wl_resource *resource;
4099 /* retrieve named output; or create it if it doesn't exist */
4100 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4103 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4105 if (id) output->id = eina_stringshare_add(id);
4107 output->make = eina_stringshare_add(make);
4109 output->make = eina_stringshare_add("unknown");
4111 output->model = eina_stringshare_add(model);
4113 output->model = eina_stringshare_add("unknown");
4115 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4118 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4119 2, output, _e_comp_wl_cb_output_bind);
4121 output->resources = NULL;
4122 output->scale = e_scale;
4125 /* update the output details */
4130 output->phys_width = pw;
4131 output->phys_height = ph;
4132 output->refresh = refresh;
4133 output->subpixel = subpixel;
4134 output->transform = transform;
4136 if (output->scale <= 0)
4137 output->scale = e_scale;
4139 /* if we have bound resources, send updates */
4140 EINA_LIST_FOREACH(output->resources, l2, resource)
4142 wl_output_send_geometry(resource,
4143 output->x, output->y,
4145 output->phys_height,
4147 output->make ?: "", output->model ?: "",
4150 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4151 wl_output_send_scale(resource, output->scale);
4153 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4154 output->w, output->h, output->refresh);
4156 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4157 wl_output_send_done(resource);
4164 e_comp_wl_output_remove(const char *id)
4166 E_Comp_Wl_Output *output;
4168 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4171 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4173 /* wl_global_destroy(output->global); */
4175 /* eina_stringshare_del(output->id); */
4176 /* eina_stringshare_del(output->make); */
4177 /* eina_stringshare_del(output->model); */
4184 _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)
4186 struct wl_resource *res;
4188 uint32_t serial, keycode;
4189 struct wl_client *wc = NULL;
4190 E_Comp_Config *comp_conf = NULL;
4191 const char *device_name = NULL;
4193 keycode = (ev->keycode - 8);
4195 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4197 comp_conf = e_comp_config_get();
4199 if (ec && ec->comp_data)
4201 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4204 wc = wl_resource_get_client(surface);
4207 if (e_config->key_input_ttrace_enable)
4209 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4210 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4213 EINA_LIST_FOREACH(key_list, l, res)
4215 if (wl_resource_get_client(res) != wc) continue;
4217 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4218 if (!e_input_thread_mode_get())
4220 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4221 device_name = ecore_device_name_get(ev->dev);
4227 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4228 device_name = e_device_name_get(dev);
4232 if (comp_conf && comp_conf->input_log_enable)
4233 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4235 wl_keyboard_send_key(res, serial, ev->timestamp,
4240 if (e_config->key_input_ttrace_enable)
4243 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4248 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4250 E_Client *ec = NULL;
4252 E_Comp_Wl_Key_Data *end, *k;
4254 if (ev->window != e_comp->ee_win)
4259 keycode = (ev->keycode - 8);
4260 if (!(e_comp_wl = e_comp->wl_comp_data))
4265 #ifndef E_RELEASE_BUILD
4266 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4267 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4268 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4269 eina_streq(ev->key, "BackSpace"))
4275 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4277 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4279 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4281 /* ignore server-generated key repeats */
4282 if (k->key == keycode)
4284 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4289 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4291 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4293 ec = e_client_focused_get();
4294 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4295 if (ec && ec->comp_data && surface)
4297 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4298 if (e_comp_wl->kbd.focused)
4300 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4302 /* A key only sent to clients is added to the list */
4303 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4304 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4306 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4308 DBG("wl_array_add: Out of memory\n");
4309 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4310 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4313 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4317 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4321 /* update modifier state */
4322 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4328 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4330 E_Client *ec = NULL;
4331 uint32_t keycode, delivered_key;
4332 E_Comp_Wl_Key_Data *end, *k;
4334 if (ev->window != e_comp->ee_win)
4339 keycode = (ev->keycode - 8);
4341 if (!(e_comp_wl = e_comp->wl_comp_data))
4346 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4348 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4349 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4351 if (k->key == keycode)
4358 e_comp_wl->kbd.keys.size =
4359 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4361 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4363 /* 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) */
4364 if ((delivered_key) ||
4365 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4367 ec = e_client_focused_get();
4369 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4370 if (e_comp_wl->kbd.focused)
4372 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4374 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4377 /* update modifier state */
4378 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4384 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4386 Eina_Bool res = EINA_FALSE;
4388 if (type == ECORE_EVENT_KEY_DOWN)
4390 res = e_comp_wl_key_down(ev, dev);
4392 else if (type == ECORE_EVENT_KEY_UP)
4394 res = e_comp_wl_key_up(ev, dev);
4401 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4404 struct wl_client *wc;
4405 uint32_t serial, btn;
4406 struct wl_resource *res;
4407 E_Comp_Config *comp_conf = NULL;
4409 if (ec->cur_mouse_action || e_comp_wl->drag)
4411 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4412 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4416 case 1: btn = BTN_LEFT; break;
4417 case 2: btn = BTN_MIDDLE; break;
4418 case 3: btn = BTN_RIGHT; break;
4419 default: btn = button_id; break;
4422 e_comp_wl->ptr.button = btn;
4423 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4424 if (!surface) return EINA_FALSE;
4426 if (!eina_list_count(e_comp_wl->ptr.resources))
4429 wc = wl_resource_get_client(surface);
4430 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4432 comp_conf = e_comp_config_get();
4434 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4436 if (wl_resource_get_client(res) != wc) continue;
4437 if (!e_comp_wl_input_pointer_check(res)) continue;
4438 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4440 if (comp_conf && comp_conf->input_log_enable)
4441 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4443 wl_pointer_send_button(res, serial, timestamp, btn, state);
4450 e_comp_wl_touch_cancel(void)
4452 _e_comp_wl_touch_cancel();
4455 E_API E_Comp_Wl_Hook *
4456 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4460 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4461 ch = E_NEW(E_Comp_Wl_Hook, 1);
4462 if (!ch) return NULL;
4463 ch->hookpoint = hookpoint;
4465 ch->data = (void*)data;
4466 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4471 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4474 if (_e_comp_wl_hooks_walking == 0)
4476 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4480 _e_comp_wl_hooks_delete++;
4483 E_API E_Comp_Wl_Pid_Hook *
4484 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4486 E_Comp_Wl_Pid_Hook *ch;
4488 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4490 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4491 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4493 ch->hookpoint = hookpoint;
4495 ch->data = (void*)data;
4496 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4502 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4505 if (_e_comp_wl_pid_hooks_walking == 0)
4507 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4511 _e_comp_wl_pid_hooks_delete++;
4514 E_API E_Comp_Wl_Intercept_Hook *
4515 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4517 E_Comp_Wl_Intercept_Hook *ch;
4519 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4520 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4521 if (!ch) return NULL;
4522 ch->hookpoint = hookpoint;
4524 ch->data = (void*)data;
4525 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4530 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4533 if (_e_comp_wl_intercept_hooks_walking == 0)
4535 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4539 _e_comp_wl_intercept_hooks_delete++;
4543 e_comp_wl_shell_surface_ready(E_Client *ec)
4547 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4551 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4553 e_config->use_cursor_timer = !!enabled;
4555 if (e_config->use_cursor_timer)
4557 if (!e_pointer_is_hidden(e_comp->pointer))
4559 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4564 if (e_comp_wl->ptr.hide_tmr)
4566 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4567 e_comp_wl->ptr.hide_tmr = NULL;
4569 cursor_timer_ec = NULL;
4571 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4574 if (e_pointer_is_hidden(e_comp->pointer))
4576 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4582 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4584 EINA_SAFETY_ON_NULL_RETURN(wc);
4585 EINA_SAFETY_ON_NULL_RETURN(dev);
4587 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4591 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4593 EINA_SAFETY_ON_NULL_RETURN(wc);
4594 EINA_SAFETY_ON_NULL_RETURN(dev);
4596 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4600 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4602 struct wl_resource *res;
4603 struct wl_client *wc;
4605 uint32_t serial, wl_keycode;
4606 enum wl_keyboard_key_state state;
4607 E_Comp_Config *comp_conf = NULL;
4608 const char *dev_name = NULL;
4610 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4611 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4612 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4614 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4615 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4617 wl_keycode = keycode - 8;
4618 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4620 wc = wl_resource_get_client(surface);
4621 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4622 if (!time) time = e_util_timestamp_get();
4623 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4624 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4626 comp_conf = e_comp_config_get();
4627 e_keyrouter_event_surface_send(ec, keycode);
4629 if (e_config->key_input_ttrace_enable)
4631 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4632 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4635 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4636 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4638 if (wl_resource_get_client(res) != wc) continue;
4639 if (!e_input_thread_mode_get())
4643 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4644 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4648 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4655 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4656 dev_name = e_device_name_get(dev);
4660 if (comp_conf && comp_conf->input_log_enable)
4661 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4664 wl_keyboard_send_key(res, serial, time,
4667 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4669 if (e_config->key_input_ttrace_enable)
4672 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4679 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4681 struct wl_resource *res;
4682 struct wl_client *wc;
4684 uint32_t serial, wl_keycode, cancel_keycode;
4685 E_Comp_Config *comp_conf = NULL;
4686 struct xkb_keymap *keymap = NULL;
4688 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4689 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4690 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4692 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4693 keymap = e_comp_wl->xkb.keymap;
4694 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4695 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4697 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4698 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4700 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4701 if (cancel_keycode == XKB_KEYCODE_INVALID)
4703 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4706 cancel_keycode = cancel_keycode - 8;
4708 wl_keycode = keycode - 8;
4709 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4711 wc = wl_resource_get_client(surface);
4712 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4713 if (!time) time = e_util_timestamp_get();
4715 comp_conf = e_comp_config_get();
4716 e_keyrouter_event_surface_send(ec, keycode);
4718 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4719 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4721 if (wl_resource_get_client(res) != wc) continue;
4722 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4723 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4725 if (comp_conf && comp_conf->input_log_enable)
4726 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4727 wl_keyboard_send_key(res, serial, time,
4728 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4729 wl_keyboard_send_key(res, serial, time,
4730 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4731 wl_keyboard_send_key(res, serial, time,
4732 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4734 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4741 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)
4743 struct wl_client *wc;
4745 E_Devicemgr_Input_Device *device = NULL;
4747 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4748 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4749 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4751 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4752 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4754 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4756 wc = wl_resource_get_client(surface);
4757 if (!time) time = e_util_timestamp_get();
4758 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4762 _e_comp_wl_send_event_device(wc, time, dev, serial);
4763 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4767 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4768 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4771 x = x + ec->client.x;
4772 y = y + ec->client.y;
4774 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4780 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)
4782 E_Devicemgr_Input_Device *device;
4784 struct wl_client *wc;
4786 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4787 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4788 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4790 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4791 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4793 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4795 wc = wl_resource_get_client(surface);
4796 if (!time) time = e_util_timestamp_get();
4797 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4801 _e_comp_wl_send_event_device(wc, time, dev, serial);
4802 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4806 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4807 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4810 x = x + ec->client.x;
4811 y = y + ec->client.y;
4813 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4819 e_comp_wl_touch_cancel_send(E_Client *ec)
4821 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4822 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4823 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4825 _e_comp_wl_send_touch_cancel(ec);
4831 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4834 struct wl_client *wc;
4836 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4837 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4838 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4840 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4841 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4843 wc = wl_resource_get_client(surface);
4844 if (!time) time = e_util_timestamp_get();
4845 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4847 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4848 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4851 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4852 WL_POINTER_BUTTON_STATE_PRESSED);
4854 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4855 WL_POINTER_BUTTON_STATE_RELEASED);
4861 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4864 struct wl_client *wc;
4866 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4870 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4871 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4873 wc = wl_resource_get_client(surface);
4874 if (!time) time = e_util_timestamp_get();
4875 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4877 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4878 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4880 x = x + ec->client.x;
4881 y = y + ec->client.y;
4883 _e_comp_wl_send_mouse_move(ec, x, y, time);
4889 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4892 struct wl_client *wc;
4894 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4895 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4896 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4898 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4899 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4901 wc = wl_resource_get_client(surface);
4902 if (!time) time = e_util_timestamp_get();
4903 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4905 if (_e_comp_wl_check_cursor_timer_needed(ec))
4907 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4911 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4912 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4914 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4916 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4918 if (_e_comp_wl_check_cursor_timer_needed(ec))
4919 _e_comp_wl_cursor_move_timer_control(ec);
4926 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4929 struct wl_client *wc;
4930 struct wl_resource *res;
4933 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4934 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4936 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4937 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4939 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4940 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4942 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4943 wc = wl_resource_get_client(surface);
4944 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4945 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4947 if (!e_comp_wl_input_pointer_check(res)) continue;
4948 if (wl_resource_get_client(res) != wc) continue;
4950 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4951 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4953 wl_pointer_send_enter(res, serial, surface,
4954 wl_fixed_from_int(x),
4955 wl_fixed_from_int(y));
4956 ec->pointer_enter_sent = EINA_TRUE;
4958 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4964 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4967 struct wl_client *wc;
4968 struct wl_resource *res;
4971 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4972 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4973 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4974 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4975 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4976 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4978 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4979 wc = wl_resource_get_client(surface);
4980 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4981 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4983 if (!e_comp_wl_input_pointer_check(res)) continue;
4984 if (wl_resource_get_client(res) != wc) continue;
4986 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4987 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4989 wl_pointer_send_leave(res, serial, surface);
4990 ec->pointer_enter_sent = EINA_FALSE;
4997 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)
4999 Evas_Event_Mouse_In ev_in;
5002 if (ec->pointer_enter_sent) return;
5004 ev_in.buttons = buttons;
5012 ev_in.modifiers = modifiers;
5013 ev_in.locks = locks;
5014 ev_in.timestamp = timestamp;
5015 ev_in.event_flags = event_flags;
5018 ev_in.event_src = event_src;
5020 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5024 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)
5026 Evas_Event_Mouse_Out ev_out;
5029 if (!ec->pointer_enter_sent) return;
5031 ev_out.buttons = buttons;
5033 ev_out.output.x = x;
5034 ev_out.output.y = y;
5035 ev_out.canvas.x = x;
5036 ev_out.canvas.y = y;
5039 ev_out.modifiers = modifiers;
5040 ev_out.locks = locks;
5041 ev_out.timestamp = timestamp;
5042 ev_out.event_flags = event_flags;
5045 ev_out.event_src = event_src;
5047 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5051 e_comp_wl_cursor_hide(E_Client *ec)
5053 struct wl_resource *res;
5054 struct wl_client *wc;
5058 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5060 if (e_comp_wl->ptr.hide_tmr)
5062 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5063 e_comp_wl->ptr.hide_tmr = NULL;
5065 cursor_timer_ec = NULL;
5067 if (!ec) return EINA_FALSE;
5068 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5069 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5070 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5072 wc = wl_resource_get_client(surface);
5073 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5074 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5076 if (!e_comp_wl_input_pointer_check(res)) continue;
5077 if (wl_resource_get_client(res) != wc) continue;
5078 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5079 wl_pointer_send_leave(res, serial, surface);
5080 ec->pointer_enter_sent = EINA_FALSE;
5086 /* surface to buffer
5087 * - width : surface width
5088 * - height : surface height
5089 * - transform: buffer transform
5090 * - scale : buffer scale
5092 * - width : screen width
5093 * - height : screen height
5094 * - transform: output transform
5095 * - scale : output scale
5097 static E_Util_Transform_Matrix
5098 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5100 E_Util_Transform_Matrix m;
5102 e_util_transform_matrix_load_identity(&m);
5104 if (transform & 0x4)
5106 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5107 e_util_transform_matrix_flip_x(&m);
5108 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5111 switch (transform & 0x3)
5113 case WL_OUTPUT_TRANSFORM_90:
5114 e_util_transform_matrix_translate(&m, -width, 0, 0);
5115 e_util_transform_matrix_rotation_z(&m, 270);
5117 case WL_OUTPUT_TRANSFORM_180:
5118 e_util_transform_matrix_translate(&m, -width, -height, 0);
5119 e_util_transform_matrix_rotation_z(&m, 180);
5121 case WL_OUTPUT_TRANSFORM_270:
5122 e_util_transform_matrix_translate(&m, 0, -height, 0);
5123 e_util_transform_matrix_rotation_z(&m, 90);
5129 e_util_transform_matrix_scale(&m, scale, scale, 1);
5134 /* surface to buffer
5135 * - surface width, surface height, buffer transform, buffer scale
5137 * - screen width, screen height, output transform, output scale
5140 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5142 E_Util_Transform_Matrix m;
5143 E_Util_Transform_Vertex v;
5145 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5147 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5148 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5149 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5153 * - buffer width, buffer height, buffer transform, buffer scale
5156 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5158 E_Util_Transform_Matrix m;
5159 E_Util_Transform_Vertex v;
5162 if (transform != 0 || scale > 1)
5164 tw = ((transform % 2) ? height : width) / scale;
5165 th = ((transform % 2) ? width : height) / scale;
5173 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5174 m = e_util_transform_matrix_inverse_get(&m);
5176 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5177 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5178 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5181 /* surface to buffer
5182 * - surface width, surface height, buffer transform, buffer scale
5184 * - screen width, screen height, output transform, output scale
5187 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5188 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5190 E_Util_Transform_Matrix m;
5191 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5192 E_Util_Transform_Rect_Vertex sv;
5194 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5196 sv = e_util_transform_rect_to_vertices(&sr);
5197 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5198 sr = e_util_transform_vertices_to_rect(&sv);
5207 * - buffer width, buffer height, buffer transform, buffer scale
5210 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5211 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5213 E_Util_Transform_Matrix m;
5214 E_Util_Transform_Rect br = {bx, by, bw, bh};
5215 E_Util_Transform_Rect_Vertex bv;
5218 if (transform != 0 || scale > 1)
5220 tw = ((transform % 2) ? height : width) / scale;
5221 th = ((transform % 2) ? width : height) / scale;
5229 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5230 m = e_util_transform_matrix_inverse_get(&m);
5232 bv = e_util_transform_rect_to_vertices(&br);
5233 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5234 br = e_util_transform_vertices_to_rect(&bv);
5242 EINTERN E_Comp_Wl_Output*
5243 e_comp_wl_output_find(E_Client *ec)
5246 E_Comp_Wl_Output *output;
5248 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5250 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5252 if (output->transform % 2)
5254 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5255 ec->y < output->x || ec->y >= (output->x + output->w))
5260 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5261 ec->y < output->y || ec->y >= (output->y + output->h))
5271 EINTERN Eina_Array *
5272 e_comp_wl_output_find_all(E_Client *ec)
5274 E_Comp_Wl_Output *output;
5275 Eina_Array *outputs;
5278 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5280 outputs = eina_array_new(4);
5284 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5286 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5287 output->x, output->y, output->w, output->h))
5289 eina_array_push(outputs, output);
5293 if (eina_array_count(outputs) == 0)
5295 eina_array_free(outputs);
5302 // --------------------------------------------------------
5303 // tizen_move_resize
5304 // --------------------------------------------------------
5306 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5313 E_Client_Pending_Geometry *geo;
5316 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5317 if (ec->fullscreen || ec->maximized) goto err;
5319 geo = E_NEW(E_Client_Pending_Geometry, 1);
5322 geo->serial = serial;
5328 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5329 ec->surface_sync.wait_commit = EINA_TRUE;
5334 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5341 e_comp_wl_commit_sync_configure(E_Client *ec)
5344 E_Client_Pending_Geometry *geo;
5346 Eina_Bool match_size = EINA_FALSE;
5353 if (!ec || !ec->frame) goto ret;
5354 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5357 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5358 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5360 if (eina_list_count(ec->surface_sync.pending_geometry))
5362 Eina_List *ll = NULL;
5363 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5367 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5372 if ((geo->w == bw) && (geo->h == bh))
5374 match_size = EINA_TRUE;
5379 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5386 if ((config.w != ec->w) || (config.h != ec->h))
5388 e_client_size_set(ec, config.w, config.h);
5389 ec->changes.size = EINA_TRUE;
5393 // FIXME: The geometry of the client would be better to be calculated
5394 // at e_desk or at e_desk_area. So the position(x,y) of the client
5395 // should be calcuated at the e_desk or at the e_desk_area.
5397 desk = e_comp_desk_find_by_ec(ec);
5400 ec->client.x = desk->geom.x + config.x;
5401 ec->client.y = desk->geom.y + config.y;
5405 ec->client.x = config.x;
5406 ec->client.y = config.y;
5409 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5411 e_client_pos_set(ec, ec->client.x, ec->client.y);
5413 ec->changes.pos = 1;
5417 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5421 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5422 ec->surface_sync.wait_commit = EINA_FALSE;
5424 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5426 // rollback wait_commit if there are pending requests remained
5427 if (eina_list_count(ec->surface_sync.pending_geometry))
5428 ec->surface_sync.wait_commit = EINA_TRUE;
5433 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);
5440 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5441 struct wl_resource *res_moveresize)
5443 wl_resource_destroy(res_moveresize);
5447 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5448 struct wl_resource *res_moveresize,
5449 struct wl_resource *surface,
5456 /* to be implemented */
5459 int cur_w = 0, cur_h = 0;
5461 ec = e_client_from_surface_resource(surface);
5464 pending = e_client_pending_geometry_has(ec);
5465 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5466 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);
5470 if ((cur_w == w) && (cur_h == h))
5472 e_client_pos_set(ec, x, y);
5473 ec->changes.pos = 1;
5479 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5483 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5486 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5488 _tz_move_resize_iface_cb_destroy,
5489 _tz_move_resize_iface_cb_set_geometry,
5493 _tz_moveresize_cb_bind(struct wl_client *client,
5494 void *data EINA_UNUSED,
5498 struct wl_resource *res_moveresize;
5500 res_moveresize = wl_resource_create(client,
5501 &tizen_move_resize_interface,
5504 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5507 wl_resource_set_implementation(res_moveresize,
5508 &_tz_move_resize_iface,
5514 ERR("Could not create tizen_move_resize_interface res: %m");
5515 wl_client_post_no_memory(client);
5519 _e_comp_wl_move_resize_init(void)
5521 if (!e_comp_wl) return;
5522 if (!e_comp_wl->wl.disp) return;
5524 if (!wl_global_create(e_comp_wl->wl.disp,
5525 &tizen_move_resize_interface,
5528 _tz_moveresize_cb_bind))
5530 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5537 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5539 E_Comp_Wl_Output *output;
5540 pid_t output_pid = 0;
5541 Eina_List *l = NULL, *l2 = NULL;
5542 struct wl_resource *resource = NULL;
5544 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5546 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5547 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5548 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5550 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5552 /* if we have bound resources, send updates */
5553 EINA_LIST_FOREACH(output->resources, l2, resource)
5555 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5556 if (output_pid != pid) continue;
5558 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5560 // send output information to the client
5561 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5569 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5571 _e_comp_wl_surface_state_init(state, w, h);
5575 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5577 _e_comp_wl_surface_state_commit(ec, state);
5581 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5583 _e_comp_wl_hook_call(hookpoint, ec);
5587 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5589 _e_comp_wl_surface_state_finish(state);
5593 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5595 _e_comp_wl_surface_state_buffer_set(state, buffer);
5599 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5600 int sx, int sy, int *dx, int *dy)
5604 case WL_OUTPUT_TRANSFORM_NORMAL:
5608 case WL_OUTPUT_TRANSFORM_FLIPPED:
5609 *dx = width - sx, *dy = sy;
5611 case WL_OUTPUT_TRANSFORM_90:
5612 *dx = height - sy, *dy = sx;
5614 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5615 *dx = height - sy, *dy = width - sx;
5617 case WL_OUTPUT_TRANSFORM_180:
5618 *dx = width - sx, *dy = height - sy;
5620 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5621 *dx = sx, *dy = height - sy;
5623 case WL_OUTPUT_TRANSFORM_270:
5624 *dx = sy, *dy = width - sx;
5626 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5636 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5639 int tx1, ty1, tx2, ty2;
5640 int width_from_buffer, height_from_buffer;
5642 switch (vp->buffer.transform)
5644 case WL_OUTPUT_TRANSFORM_90:
5645 case WL_OUTPUT_TRANSFORM_270:
5646 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5647 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5648 width_from_buffer = bh / vp->buffer.scale;
5649 height_from_buffer = bw / vp->buffer.scale;
5652 width_from_buffer = bw / vp->buffer.scale;
5653 height_from_buffer = bh / vp->buffer.scale;
5657 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5661 x2 = width_from_buffer;
5662 y2 = height_from_buffer;
5666 x1 = wl_fixed_to_int(vp->buffer.src_x);
5667 y1 = wl_fixed_to_int(vp->buffer.src_y);
5668 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5669 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5672 buffer_transform(width_from_buffer, height_from_buffer,
5673 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5674 buffer_transform(width_from_buffer, height_from_buffer,
5675 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5677 out->x = (tx1 <= tx2) ? tx1 : tx2;
5678 out->y = (ty1 <= ty2) ? ty1 : ty2;
5679 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5680 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5684 * Convert given four coordinates to elements of rectangle
5685 * @in p[4] Coordinates to be converted
5686 * @out rect x, y, width, and height
5687 * transform Angle which represents TDM_TRANSFORM of rectangle
5688 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5689 * 1. The given coordinates are not represented by rectangle.
5690 * 2. All angles except for 0, 90, 180, 270.
5693 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5695 Eina_Bool ret = EINA_FALSE;
5697 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))
5700 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5703 *rotation = TDM_TRANSFORM_NORMAL;
5706 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5710 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5713 *rotation = TDM_TRANSFORM_180;
5716 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5721 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))
5724 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5727 *rotation = TDM_TRANSFORM_90;
5730 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5734 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5737 *rotation = TDM_TRANSFORM_270;
5740 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5750 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5755 for (i = 0; i < 4; i++)
5756 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5758 if (!_coords_to_rectangle_convert(p, out, rotation))
5760 DBG("Cannot convert given coords to rectangle.\n"
5761 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5762 p[0].x, p[0].y, p[1].x, p[1].y,
5763 p[2].x, p[2].y, p[3].x, p[3].y);
5771 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5773 int trans_rotation, flip;
5775 trans_rotation = transform & 0x3;
5776 flip = transform & 0x4;
5778 return (flip + (trans_rotation + rotation) % 4);
5782 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5790 if (e_comp_wl_subsurface_check(ec))
5791 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5798 out->w = ec->comp_data->width_from_viewport;
5799 out->w = (out->w + 1) & ~1;
5800 out->h = ec->comp_data->height_from_viewport;
5802 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5803 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5807 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5809 E_Comp_Wl_Buffer *buffer;
5810 E_Comp_Wl_Buffer_Viewport *vp;
5812 enum wl_output_transform buffer_transform;
5813 unsigned int rotation;
5814 Eina_Bool res = EINA_FALSE;
5816 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5818 if (e_object_is_del(E_OBJECT(ec)))
5821 vp = &ec->comp_data->scaler.buffer_viewport;
5823 if (buffer_viewport)
5825 buffer = ec->comp_data->buffer_ref.buffer;
5826 /* Getting a viewport of buffer needs geometry of buffer. */
5830 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5833 if ((output_viewport) || (transform))
5835 m = e_client_map_get(ec);
5837 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5839 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5844 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5845 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5846 * Since buffer.transform isn't applied using evas_map,
5847 * it has to be taken into account here to apply buffer.transform
5848 * and rotation of e_client_transform together. */
5850 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5852 *transform = (unsigned int)buffer_transform;
5860 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5862 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5863 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5865 /* Must be called with valid comp_data */
5866 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5868 if ((ec->comp_data->role_name == NULL) ||
5869 (ec->comp_data->role_name == role_name) ||
5870 (strcmp(ec->comp_data->role_name, role_name) == 0))
5872 ec->comp_data->role_name = role_name;
5878 wl_resource_post_error(error_resource, error_code,
5879 "Cannot assign role %s to wl_surface@%d,"
5880 " already has role %s\n",
5882 ec->comp_data->wl_surface ?
5883 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5884 ec->comp_data->role_name);
5890 EINTERN const char *
5891 e_comp_wl_surface_role_get(E_Client *ec)
5893 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5894 return ec->comp_data ? ec->comp_data->role_name : NULL;
5897 EINTERN struct wl_resource *
5898 e_comp_wl_client_surface_get(E_Client *ec)
5900 struct wl_resource *surface = NULL;
5901 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5902 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5904 g_mutex_lock(&ec->comp_data->surface_mutex);
5905 surface = ec->comp_data->surface;
5906 g_mutex_unlock(&ec->comp_data->surface_mutex);
5911 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5913 EINA_SAFETY_ON_NULL_RETURN(ec);
5914 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5916 g_mutex_lock(&ec->comp_data->surface_mutex);
5917 ec->comp_data->surface = surface;
5918 g_mutex_unlock(&ec->comp_data->surface_mutex);
5922 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5924 return e_compositor_util_client_from_surface_resource(surface_resource);
5928 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5930 if (!ec->comp_data->mapped)
5932 if (ec->comp_data->shell.surface &&
5933 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5935 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5941 if (ec->comp_data->mapped)
5943 /* will be unmapped. so run capture */
5944 e_comp_wl_remote_surface_image_save(ec);
5948 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5950 ec->comp_data->pending.sx = sx;
5951 ec->comp_data->pending.sy = sy;
5952 ec->comp_data->pending.new_attach = EINA_TRUE;
5954 e_client_fps_update(ec);
5958 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5960 if (ec->comp_data->pending.opaque)
5961 eina_tiler_clear(ec->comp_data->pending.opaque);
5965 eina_tiler_union(ec->comp_data->pending.opaque, region);
5967 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5971 ec->argb = EINA_FALSE;
5972 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5974 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5975 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5983 ec->argb = EINA_TRUE;
5984 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5986 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5987 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5993 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5995 if (ec->comp_data->pending.input)
5996 eina_tiler_clear(ec->comp_data->pending.input);
6000 if (eina_tiler_empty(region))
6002 ELOGF("COMP", " |unset input rect", NULL);
6003 e_comp_object_input_objs_del(ec->frame);
6004 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6007 eina_tiler_union(ec->comp_data->pending.input, region);
6011 eina_tiler_rect_add(ec->comp_data->pending.input,
6012 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6017 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6019 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6023 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6025 E_Comp_Wl_Subsurf_Data *sdata;
6030 if (ec->comp_data->frames)
6032 ec->comp_data->frames =
6033 eina_list_remove(ec->comp_data->frames, callback_resource);
6036 if (ec->comp_data->pending.frames)
6038 ec->comp_data->pending.frames =
6039 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6042 sdata = ec->comp_data->sub.data;
6043 if ((sdata) && (sdata->cached.frames))
6045 sdata->cached.frames =
6046 eina_list_remove(sdata->cached.frames, callback_resource);
6051 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6053 if (e_object_is_del(E_OBJECT(ec))) return;
6055 if (e_comp_wl_remote_surface_commit(ec)) return;
6057 e_comp_wl_surface_commit(ec);
6059 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6063 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6065 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6066 ec->comp_data->sub.data = sub;
6068 /* set subsurface client properties */
6069 ec->borderless = EINA_TRUE;
6070 ec->argb = EINA_TRUE;
6071 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6072 ec->lock_border = EINA_TRUE;
6073 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6074 ec->netwm.state.skip_taskbar = EINA_TRUE;
6075 ec->netwm.state.skip_pager = EINA_TRUE;
6076 ec->border_size = 0;
6077 ec->lock_user_location = 0;
6078 ec->lock_client_location = 0;
6079 ec->lock_user_size = 0;
6080 ec->lock_client_size = 0;
6081 ec->lock_client_stacking = 0;
6082 ec->lock_user_maximize = 0;
6083 ec->lock_client_maximize = 0;
6084 ec->changes.need_maximize = 0;
6085 ec->maximized = E_MAXIMIZE_NONE;
6088 ec->new_client = ec->netwm.ping = EINA_TRUE;
6089 e_comp->new_clients++;
6090 e_client_unignore(ec);
6092 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6093 * It's not for subsurface. */
6094 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6098 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6100 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6103 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6105 sub->parent = parent;
6109 layer = e_client_layer_get(parent);
6110 if (layer > E_LAYER_BOTTOM)
6111 e_client_layer_set(ec, layer);
6114 if (parent->comp_data)
6116 /* append this client to the parents subsurface list */
6117 parent->comp_data->sub.list_pending =
6118 eina_list_append(parent->comp_data->sub.list_pending, ec);
6119 parent->comp_data->sub.list_changed = EINA_TRUE;
6124 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6126 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6127 E_Client *parent = sub->parent;
6129 parent->comp_data->sub.list =
6130 eina_list_remove(parent->comp_data->sub.list, ec);
6131 parent->comp_data->sub.list_pending =
6132 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6133 parent->comp_data->sub.below_list =
6134 eina_list_remove(parent->comp_data->sub.below_list, ec);
6135 parent->comp_data->sub.below_list_pending =
6136 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6142 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)
6144 sub->resource = subsurface_resource;
6145 sub->cached_buffer_ref.buffer = NULL;
6146 sub->synchronized = EINA_TRUE;
6147 sub->parent = parent;
6148 sub->remote_surface.offscreen_parent = offscreen_parent;
6149 if (offscreen_parent)
6150 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6152 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6154 _e_comp_wl_client_subsurface_set(ec, sub);
6155 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6157 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6161 e_comp_wl_client_subsurface_finish(E_Client *ec)
6163 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6166 e_comp_wl_client_subsurface_parent_unset(ec);
6168 e_comp_wl_surface_state_finish(&sub->cached);
6169 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6171 ec->comp_data->sub.data = NULL;
6175 e_comp_wl_client_evas_init(E_Client *ec)
6177 EINA_SAFETY_ON_NULL_RETURN(ec);
6179 _e_comp_wl_client_evas_init(ec);
6183 e_comp_wl_client_evas_deinit(E_Client *ec)
6185 EINA_SAFETY_ON_NULL_RETURN(ec);
6187 _e_comp_wl_client_evas_deinit(ec);
6191 e_comp_wl_focus_check(void)
6193 _e_comp_wl_focus_check();
6197 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6204 if ((parent->comp_data) && (parent->comp_data->sub.data))
6205 parent = parent->comp_data->sub.data->parent;