3 #include "e_wtz_shell_intern.h"
4 #include "e_comp_wl_private.h"
5 #include "e_client_intern.h"
6 #include "e_appinfo_intern.h"
7 #include "e_blender_intern.h"
8 #include "e_utils_intern.h"
9 #include "e_scale_intern.h"
11 #include <tizen-extension-server-protocol.h>
13 #include <relative-pointer-unstable-v1-server-protocol.h>
14 #include <pointer-constraints-unstable-v1-server-protocol.h>
16 #include <wayland-tbm-server.h>
19 #include <libds/log.h>
20 #include <libds/single_pixel_buffer_v1.h>
22 /* handle include for printing uint64_t */
23 #define __STDC_FORMAT_MACROS
26 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
28 /* Resource Data Mapping: (wl_resource_get_user_data)
30 * wl_surface == e_pixmap
31 * wl_region == eina_tiler
32 * wl_subsurface == e_client
36 typedef struct _E_Comp_Data E_Comp_Data;
41 struct wl_listener client_created;
44 static void _e_comp_wl_move_resize_init(void);
46 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
49 typedef struct _E_Comp_Wl_Key_Data
55 static Eina_List *handlers = NULL;
56 static E_Client *cursor_timer_ec = NULL;
57 static Eina_Bool need_send_released = EINA_FALSE;
58 static Eina_Bool need_send_motion = EINA_TRUE;
60 static GMutex connection_mutex;
62 static int _e_comp_wl_hooks_delete = 0;
63 static int _e_comp_wl_hooks_walking = 0;
65 static int _e_comp_wl_pid_hooks_delete = 0;
66 static int _e_comp_wl_pid_hooks_walking = 0;
68 static int _e_comp_wl_intercept_hooks_delete = 0;
69 static int _e_comp_wl_intercept_hooks_walking = 0;
71 static Eina_Inlist *_e_comp_wl_hooks[] =
73 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
74 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
75 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
76 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
77 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
78 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
79 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
80 [E_COMP_WL_HOOK_DEL] = NULL,
81 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
82 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
83 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
86 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
88 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
91 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
93 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
94 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
95 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
96 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
97 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
98 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
101 static Eina_List *hooks = NULL;
103 /* local functions */
105 _e_comp_wl_hooks_clean(void)
110 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
111 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
113 if (!ch->delete_me) continue;
114 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
120 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
124 e_object_ref(E_OBJECT(ec));
125 _e_comp_wl_hooks_walking++;
126 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
128 if (ch->delete_me) continue;
129 ch->func(ch->data, ec);
130 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
131 (e_object_is_del(E_OBJECT(ec))))
134 _e_comp_wl_hooks_walking--;
135 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
136 _e_comp_wl_hooks_clean();
137 e_object_unref(E_OBJECT(ec));
141 _e_comp_wl_pid_hooks_clean(void)
144 E_Comp_Wl_Pid_Hook *ch;
146 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
147 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
149 if (!ch->delete_me) continue;
150 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
156 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
158 E_Comp_Wl_Pid_Hook *ch;
160 _e_comp_wl_pid_hooks_walking++;
161 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
163 if (ch->delete_me) continue;
164 ch->func(ch->data, pid);
166 _e_comp_wl_pid_hooks_walking--;
167 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
168 _e_comp_wl_pid_hooks_clean();
172 _e_comp_wl_intercept_hooks_clean(void)
175 E_Comp_Wl_Intercept_Hook *ch;
177 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
178 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
180 if (!ch->delete_me) continue;
181 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
187 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
189 E_Comp_Wl_Intercept_Hook *ch;
190 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
192 e_object_ref(E_OBJECT(ec));
193 _e_comp_wl_intercept_hooks_walking++;
194 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
196 if (ch->delete_me) continue;
197 res = ch->func(ch->data, ec);
198 if (!res) ret = EINA_FALSE;
199 if (e_object_is_del(E_OBJECT(ec)))
202 _e_comp_wl_intercept_hooks_walking--;
203 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
204 _e_comp_wl_intercept_hooks_clean();
205 e_object_unref(E_OBJECT(ec));
212 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
218 if (e_comp_object_frame_exists(ec->frame))
219 w = ec->client.w, h = ec->client.h;
221 w = ec->w, h = ec->h;
225 // Width and Height are -1 means that we don't consider size value
229 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
233 _e_comp_wl_focus_check(void)
237 if (stopping) return;
238 ec = e_client_focused_get();
240 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
244 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
246 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
248 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
249 IDLE_EXITER~CB_PREPARE);
251 return ECORE_CALLBACK_RENEW;
255 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
257 /* dispatch pending wayland events */
258 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
260 return ECORE_CALLBACK_RENEW;
264 e_comp_wl_display_flush()
266 if (e_comp_wl && e_comp_wl->wl.disp)
268 if (e_config->key_input_ttrace_enable)
270 TRACE_INPUT_BEGIN(wl_display_flush_clients);
271 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
274 g_mutex_lock(&connection_mutex);
275 wl_display_flush_clients(e_comp_wl->wl.disp);
276 g_mutex_unlock(&connection_mutex);
278 if (e_config->key_input_ttrace_enable)
281 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
287 e_comp_wl_connection_lock()
289 e_input_boost_lock(&connection_mutex);
293 e_comp_wl_connection_unlock()
295 e_input_boost_unlock(&connection_mutex);
299 e_comp_wl_focused_client_flush()
301 E_Client *focused_ec;
302 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
304 e_input_boost_lock(&connection_mutex);
305 focused_ec = e_client_focused_get();
309 struct wl_client *wc;
310 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
313 e_input_boost_unlock(&connection_mutex);
317 wc = wl_resource_get_client(surface);
321 e_input_boost_unlock(&connection_mutex);
325 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
329 if (e_comp_wl->idle_exiter_timestamp > 0.0)
331 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
332 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
334 ELOGF("E_COMP", "prepare gap time: %lfms",
339 e_comp_wl->idle_exiter_timestamp = 0.0;
341 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
343 /* flush pending client events */
344 e_comp_wl_display_flush();
346 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
347 IDLE_EXITER~CB_PREPARE);
350 E_API enum wl_output_transform
351 e_comp_wl_output_buffer_transform_get(E_Client *ec)
353 E_Comp_Wl_Buffer_Viewport *vp;
354 E_Comp_Wl_Buffer *buffer;
355 enum wl_output_transform transform, rotation;
357 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
358 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
359 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
361 vp = &ec->comp_data->scaler.buffer_viewport;
362 if (e_comp_wl_subsurface_check(ec))
363 return vp->buffer.transform;
365 buffer = ec->comp_data->buffer_ref.buffer;
368 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
369 return vp->buffer.transform;
371 rotation = buffer->transform;
373 return vp->buffer.transform;
375 /* ignore the flip value when calculating transform because the screen rotation
376 * functionality doesn't consider the flip output transform currently
378 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
380 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
381 ec, rotation, vp->buffer.transform, transform);
386 EINTERN enum wl_output_transform
387 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
389 E_Comp_Wl_Buffer_Viewport *vp;
390 E_Comp_Wl_Buffer *buffer;
391 enum wl_output_transform transform, rotation;
393 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
394 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
395 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
397 vp = &ec->comp_data->pending.buffer_viewport;
398 if (e_comp_wl_subsurface_check(ec))
399 return vp->buffer.transform;
401 buffer = ec->comp_data->pending.buffer;
404 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
405 return vp->buffer.transform;
407 rotation = buffer->transform;
409 return vp->buffer.transform;
411 /* ignore the flip value when calculating transform because the screen rotation
412 * functionality doesn't consider the flip output transform currently
414 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
416 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
417 ec, rotation, vp->buffer.transform, transform);
423 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
425 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
426 E_Comp_Wl_Buffer *buffer;
427 int32_t width, height;
429 buffer = e_pixmap_resource_get(ec->pixmap);
432 ec->comp_data->width_from_buffer = 0;
433 ec->comp_data->height_from_buffer = 0;
437 switch (e_comp_wl_output_buffer_transform_get(ec))
439 case WL_OUTPUT_TRANSFORM_90:
440 case WL_OUTPUT_TRANSFORM_270:
441 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
442 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
443 width = buffer->h / vp->buffer.scale;
444 height = buffer->w / vp->buffer.scale;
447 width = buffer->w / vp->buffer.scale;
448 height = buffer->h / vp->buffer.scale;
452 ec->comp_data->width_from_buffer = width;
453 ec->comp_data->height_from_buffer = height;
457 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
459 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
460 int32_t width, height;
462 width = ec->comp_data->width_from_buffer;
463 height = ec->comp_data->height_from_buffer;
465 if (width == 0 && height == 0) return;
467 if (width != 0 && vp->surface.width != -1)
469 ec->comp_data->width_from_viewport = vp->surface.width;
470 ec->comp_data->height_from_viewport = vp->surface.height;
474 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
476 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
477 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
478 ec->comp_data->width_from_viewport = w ?: 1;
479 ec->comp_data->height_from_viewport = h ?: 1;
483 ec->comp_data->width_from_viewport = width;
484 ec->comp_data->height_from_viewport = height;
488 e_comp_wl_topmost_parent_get(E_Client *ec)
492 if (!e_comp_wl_subsurface_check(ec))
495 parent = e_comp_wl_subsurface_parent_get(ec);
498 if (!e_comp_wl_subsurface_check(parent))
501 parent = e_comp_wl_subsurface_parent_get(parent);
508 e_comp_wl_map_apply(E_Client *ec)
510 E_Comp_Wl_Buffer_Viewport *vp;
511 E_Comp_Wl_Subsurf_Data *sdata;
512 E_Comp_Wl_Client_Data *cdata;
513 int x1, y1, x2, y2, x, y;
515 Eina_Bool zoom_animating = EINA_FALSE;
517 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
519 e_comp_object_map_update(ec->frame);
521 cdata = ec->comp_data;
522 vp = &cdata->scaler.buffer_viewport;
523 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
524 (!cdata->viewport_transform))
527 if (e_comp_wl_subsurface_check(ec))
529 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
531 sdata = ec->comp_data->sub.data;
532 if (sdata->remote_surface.offscreen_parent)
534 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
535 Eina_Rectangle *rect;
538 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
540 /* TODO: If there are one more regions, it means that provider's offscreen
541 * is displayed by one more remote_surfaces. Have to consider it later. At
542 * this time, just consider only one remote_surface.
556 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
557 if (x != dx || y != dy)
558 evas_object_move(ec->frame, dx, dy);
560 if (!cdata->viewport_transform)
562 cdata->viewport_transform = e_util_transform_new();
563 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
564 e_client_transform_core_add(ec, cdata->viewport_transform);
567 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
568 ec->comp_data->width_from_viewport,
569 ec->comp_data->height_from_viewport);
571 if (vp->buffer.src_width == wl_fixed_from_int(-1))
575 x2 = cdata->width_from_buffer;
576 y2 = cdata->height_from_buffer;
580 x1 = wl_fixed_to_int(vp->buffer.src_x);
581 y1 = wl_fixed_to_int(vp->buffer.src_y);
582 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
583 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
586 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
587 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
588 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
589 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
592 desk = e_comp_desk_find_by_ec(ec);
594 zoom_animating = e_desk_zoom_is_animating(desk);
596 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
597 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
598 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
600 /* workaround:: when the desk zoom is doing their animation,
601 the transform core update can override animation's zoom boundary.
602 so, don't doing transform core update while desk zoom animation */
604 e_client_transform_core_update(ec);
609 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
613 int map_c = 0, map_x = 0, map_y = 0;
614 double inv_x = 0.0, inv_y = 0.0;
616 EINA_SAFETY_ON_NULL_RETURN(ec);
618 map = e_client_map_get(ec);
619 map_c = e_map_count_get(map);
621 if (!map || map_c <= 0)
631 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
632 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
633 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
634 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
636 for (int i = 0; i < map_c; i++)
638 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
639 e_map_point_image_uv_set(map2, i, map_x, map_y);
641 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
651 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
657 if (!(ec = data)) return;
658 if (e_object_is_del(data)) return;
660 if (!ec->override) e_hints_window_visible_set(ec);
662 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
663 (!ec->comp_data->need_reparent))
665 ec->comp_data->need_reparent = EINA_TRUE;
666 ec->visible = EINA_TRUE;
668 if (!e_client_util_ignored_get(ec))
670 ec->take_focus = !starting;
674 if (!ec->comp_data->need_reparent)
676 if ((ec->hidden) || (ec->iconic))
678 evas_object_hide(ec->frame);
679 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
682 evas_object_show(ec->frame);
685 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
686 evas_object_show(tmp->frame);
688 topmost = e_comp_wl_topmost_parent_get(ec);
689 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
690 e_comp_wl_subsurface_show(ec);
692 if (ec->comp_data->sub.below_obj)
693 evas_object_show(ec->comp_data->sub.below_obj);
697 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
703 if (!(ec = data)) return;
704 if (e_object_is_del(E_OBJECT(ec))) return;
706 /* Uncommonly some clients's final buffer can be skipped if the client
707 * requests unmap of its surface right after wl_surface@commit.
708 * So if this client evas object is hidden state and client is already
709 * unmmapped, we can consider to clear pixmap image here mandatorily.
711 if (!ec->comp_data->mapped)
712 e_pixmap_image_clear(ec->pixmap, 1);
714 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
715 evas_object_hide(tmp->frame);
717 topmost = e_comp_wl_topmost_parent_get(ec);
718 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
719 e_comp_wl_subsurface_hide(ec);
721 if (ec->comp_data->sub.below_obj)
722 evas_object_hide(ec->comp_data->sub.below_obj);
724 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
728 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
735 if (!(ec = data)) return;
736 if (e_object_is_del(E_OBJECT(ec))) return;
738 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
740 if (!e_comp_wl_subsurface_check(subc)) continue;
741 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
742 evas_object_move(subc->frame, x, y);
744 if (subc->comp_data->scaler.viewport)
746 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
747 if (cdata->viewport_transform)
748 e_comp_wl_map_apply(subc);
752 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
754 if (!e_comp_wl_subsurface_check(subc)) continue;
755 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
756 evas_object_move(subc->frame, x, y);
758 if (subc->comp_data->scaler.viewport)
760 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
761 if (cdata->viewport_transform)
762 e_comp_wl_map_apply(subc);
766 if (ec->comp_data->sub.below_obj)
768 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
769 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
774 _e_comp_wl_send_touch_cancel(E_Client *ec)
777 struct wl_resource *res;
778 struct wl_client *wc;
779 E_Comp_Config *comp_conf = NULL;
782 if (e_object_is_del(E_OBJECT(ec))) return;
783 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
785 if (!surface) return;
786 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
788 wc = wl_resource_get_client(surface);
790 comp_conf = e_comp_config_get();
792 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
794 if (wl_resource_get_client(res) != wc) continue;
795 if (!e_comp_wl_input_touch_check(res)) continue;
797 if (comp_conf && comp_conf->input_log_enable)
798 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
800 wl_touch_send_cancel(res);
805 _e_comp_wl_touch_cancel(void)
809 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
811 if (!e_comp_wl->touch.pressed) return;
813 _e_comp_wl_send_touch_cancel(ec);
816 static E_Devicemgr_Input_Device *
817 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
819 E_Devicemgr_Input_Device *last_kbd = NULL;
822 case ECORE_DEVICE_CLASS_MOUSE:
823 return e_devicemgr->last_device_ptr;
824 case ECORE_DEVICE_CLASS_KEYBOARD:
825 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
827 case ECORE_DEVICE_CLASS_TOUCH:
828 return e_devicemgr->last_device_touch;
836 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
840 case ECORE_DEVICE_CLASS_MOUSE:
841 e_devicemgr->last_device_ptr = device;
843 case ECORE_DEVICE_CLASS_KEYBOARD:
844 atomic_store(&e_devicemgr->last_device_kbd, device);
846 case ECORE_DEVICE_CLASS_TOUCH:
847 e_devicemgr->last_device_touch = device;
854 static E_Devicemgr_Input_Device *
855 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
857 E_Devicemgr_Input_Device *last_kbd = NULL;
861 case ECORE_DEVICE_CLASS_MOUSE:
862 return ec->comp_data->last_device_ptr;
863 case ECORE_DEVICE_CLASS_KEYBOARD:
864 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
866 case ECORE_DEVICE_CLASS_TOUCH:
867 return ec->comp_data->last_device_touch;
875 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
879 case ECORE_DEVICE_CLASS_MOUSE:
880 ec->comp_data->last_device_ptr = device;
882 case ECORE_DEVICE_CLASS_KEYBOARD:
883 atomic_store(&ec->comp_data->last_device_kbd, device);
885 case ECORE_DEVICE_CLASS_TOUCH:
886 ec->comp_data->last_device_touch = device;
894 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
896 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
897 struct wl_resource *dev_res;
898 const char *dev_name;
899 Ecore_Device_Class dev_class;
900 struct wl_client *wc;
904 EINA_SAFETY_ON_NULL_RETURN(dev);
907 if (ec->cur_mouse_action || e_comp_wl->drag)
909 if (e_object_is_del(E_OBJECT(ec))) return;
910 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
911 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
912 if (!surface) return;
914 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
915 dev_name = evas_device_description_get(dev);
916 last_device = _e_comp_wl_device_last_device_get(dev_class);
917 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
919 serial = wl_display_next_serial(e_comp_wl->wl.disp);
920 wc = wl_resource_get_client(surface);
921 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
922 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
924 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
925 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
927 _e_comp_wl_device_last_device_set(dev_class, input_dev);
928 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
930 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
932 if (wl_resource_get_client(dev_res) != wc) continue;
933 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
937 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
941 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
943 E_Devicemgr_Input_Device *last_device;
944 struct wl_resource *dev_res;
945 struct wl_client *wc;
949 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
950 if (!surface) return;
952 last_device = _e_comp_wl_device_last_device_get(dev_class);
953 if (!last_device) return;
955 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
957 serial = wl_display_next_serial(e_comp_wl->wl.disp);
958 wc = wl_resource_get_client(surface);
959 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
961 if (wl_resource_get_client(dev_res) != wc) continue;
962 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
967 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
969 E_Devicemgr_Input_Device *input_dev;
970 struct wl_resource *dev_res;
971 const char *dev_name;
974 EINA_SAFETY_ON_NULL_RETURN(dev);
976 dev_name = ecore_device_identifier_get(dev);
978 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
979 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
981 if (!eina_streq(input_dev->identifier, dev_name) ||
982 (input_dev->clas != ecore_device_class_get(dev))) continue;
983 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
985 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
987 if (wl_resource_get_client(dev_res) != wc) continue;
988 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
991 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
995 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
997 E_Devicemgr_Input_Device *input_dev;
998 struct wl_resource *dev_res;
999 const char *dev_name;
1002 EINA_SAFETY_ON_NULL_RETURN(dev);
1004 dev_name = e_device_identifier_get(dev);
1006 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1007 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1009 if (!eina_streq(input_dev->identifier, dev_name) ||
1010 (input_dev->clas != e_device_class_get(dev))) continue;
1011 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1013 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1015 if (wl_resource_get_client(dev_res) != wc) continue;
1016 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1019 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1023 _e_comp_wl_cursor_reload(E_Client *ec)
1025 struct wl_resource *res;
1026 struct wl_client *wc;
1032 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1033 !evas_object_visible_get(e_comp->pointer->o_ptr))
1034 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1037 if (e_object_is_del(E_OBJECT(ec))) return;
1038 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1039 if (!surface) return;
1040 if (ec->pointer_enter_sent) return;
1042 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1043 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1045 if (e_client_transform_core_enable_get(ec))
1047 double dx = 0.0, dy = 0.0;
1048 map = e_client_map_get(ec);
1049 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1055 cx = px - ec->client.x;
1056 cy = py - ec->client.y;
1058 wc = wl_resource_get_client(surface);
1059 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1060 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1062 if (!e_comp_wl_input_pointer_check(res)) continue;
1063 if (wl_resource_get_client(res) != wc) continue;
1064 wl_pointer_send_enter(res, serial, surface,
1065 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1066 ec->pointer_enter_sent = EINA_TRUE;
1068 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1072 _e_comp_wl_cursor_timer(void *data)
1074 E_Client *ec = data;
1076 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1077 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1079 e_comp_wl_cursor_hide(ec);
1081 return ECORE_CALLBACK_CANCEL;
1085 _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)
1087 E_Devicemgr_Input_Device *input_dev;
1088 struct wl_resource *dev_res;
1089 struct wl_client *wc;
1094 if (ec->cur_mouse_action) return;
1095 if (e_object_is_del(E_OBJECT(ec))) return;
1096 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1097 if (!surface) return;
1099 f_value = wl_fixed_from_double(value);
1100 wc = wl_resource_get_client(surface);
1102 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1103 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1105 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1106 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1108 if (wl_resource_get_client(dev_res) != wc) continue;
1109 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1112 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1116 _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)
1118 if (idx >= e_input_touch_max_count_get()) return;
1120 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1121 e_devicemgr->multi[idx].radius_x = radius_x;
1122 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1123 e_devicemgr->multi[idx].radius_y = radius_y;
1124 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1125 e_devicemgr->multi[idx].pressure = pressure;
1126 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1127 e_devicemgr->multi[idx].angle = angle;
1131 _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)
1133 if (idx >= e_input_touch_max_count_get()) return;
1135 if (e_devicemgr->multi[idx].radius_x != radius_x)
1137 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1138 e_devicemgr->multi[idx].radius_x = radius_x;
1140 if (e_devicemgr->multi[idx].radius_y != radius_y)
1142 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1143 e_devicemgr->multi[idx].radius_y = radius_y;
1145 if (e_devicemgr->multi[idx].pressure != pressure)
1147 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1148 e_devicemgr->multi[idx].pressure = pressure;
1150 if (e_devicemgr->multi[idx].angle != angle)
1152 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1153 e_devicemgr->multi[idx].angle = angle;
1158 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1160 Eina_Bool ret = EINA_TRUE;
1163 case EVAS_CALLBACK_MOUSE_IN:
1164 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1167 if (e_comp_wl->ptr.hide_tmr)
1169 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1170 cursor_timer_ec = ec;
1171 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1175 if (e_pointer_is_hidden(e_comp->pointer))
1180 case EVAS_CALLBACK_MOUSE_OUT:
1181 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1184 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1188 case EVAS_CALLBACK_MOUSE_MOVE:
1189 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1192 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1193 _e_comp_wl_cursor_reload(ec);
1196 case EVAS_CALLBACK_MOUSE_WHEEL:
1197 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1200 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1201 _e_comp_wl_cursor_reload(ec);
1204 case EVAS_CALLBACK_MOUSE_DOWN:
1205 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1208 if (e_comp_wl->ptr.hide_tmr)
1210 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1211 e_comp_wl->ptr.hide_tmr = NULL;
1213 cursor_timer_ec = NULL;
1215 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1216 _e_comp_wl_cursor_reload(ec);
1219 case EVAS_CALLBACK_MOUSE_UP:
1220 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1231 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1233 if (ec->has_cursor_unset)
1236 if (!e_config->show_cursor)
1239 if (!e_config->use_cursor_timer)
1246 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1249 Evas_Event_Mouse_In *ev;
1250 struct wl_resource *res;
1251 struct wl_client *wc;
1254 E_Comp_Config *comp_conf;
1255 E_Client *prev_ptr_ec;
1259 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1260 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1262 if (!(ec = data)) return;
1263 if (e_object_is_del(E_OBJECT(ec))) return;
1264 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1265 if (!surface) return;
1267 prev_ptr_ec = e_comp_wl->ptr.ec;
1270 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1271 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1274 e_comp_wl->ptr.ec = ec;
1276 comp_conf = e_comp_config_get();
1277 if (comp_conf && comp_conf->input_log_enable)
1278 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1279 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1280 e_client_util_name_get(ec));
1282 if (_e_comp_wl_check_cursor_timer_needed(ec))
1284 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1288 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1289 wc = wl_resource_get_client(surface);
1290 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1291 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1293 if (!e_comp_wl_input_pointer_check(res)) continue;
1294 if (wl_resource_get_client(res) != wc) continue;
1296 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1298 wl_pointer_send_enter(res, serial, surface,
1299 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1300 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1301 ec->pointer_enter_sent = EINA_TRUE;
1304 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1308 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1311 Evas_Event_Mouse_Out *ev;
1312 struct wl_resource *res;
1313 struct wl_client *wc;
1316 Eina_Bool inside_check;
1317 E_Comp_Config *comp_conf;
1321 if (!(ec = data)) return;
1322 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1323 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1324 if (ec->cur_mouse_action && inside_check) return;
1325 if (e_object_is_del(E_OBJECT(e_comp))) return;
1326 if (e_comp_wl->ptr.ec == ec)
1327 e_comp_wl->ptr.ec = NULL;
1328 if (e_object_is_del(E_OBJECT(ec))) return;
1330 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1331 if (!surface) return;
1333 comp_conf = e_comp_config_get();
1334 if (comp_conf && comp_conf->input_log_enable)
1335 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1336 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1337 e_client_util_name_get(ec));
1339 if (_e_comp_wl_check_cursor_timer_needed(ec))
1341 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1345 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1347 wc = wl_resource_get_client(surface);
1348 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1349 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1351 if (!e_comp_wl_input_pointer_check(res)) continue;
1352 if (wl_resource_get_client(res) != wc) continue;
1353 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1355 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1357 wl_pointer_send_leave(res, serial, surface);
1358 ec->pointer_enter_sent = EINA_FALSE;
1363 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1366 struct wl_client *wc;
1367 struct wl_resource *res;
1370 E_Comp_Config *comp_conf = NULL;
1373 if (e_object_is_del(E_OBJECT(ec))) return;
1374 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1375 if (!surface) return;
1377 wc = wl_resource_get_client(surface);
1378 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1382 x = wl_fixed_from_int(canvas_x - ec->client.x);
1383 y = wl_fixed_from_int(canvas_y - ec->client.y);
1386 comp_conf = e_comp_config_get();
1388 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1390 if (wl_resource_get_client(res) != wc) continue;
1391 if (!e_comp_wl_input_touch_check(res)) continue;
1392 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1395 if (comp_conf && comp_conf->input_log_enable)
1396 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));
1398 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1402 if (comp_conf && comp_conf->input_log_enable)
1403 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));
1405 wl_touch_send_up(res, serial, timestamp, idx);
1412 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1415 struct wl_client *wc;
1416 struct wl_resource *res;
1420 if (ec->cur_mouse_action) return;
1421 if (e_object_is_del(E_OBJECT(ec))) return;
1422 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1423 if (!surface) return;
1425 wc = wl_resource_get_client(surface);
1427 x = wl_fixed_from_int(canvas_x - ec->client.x);
1428 y = wl_fixed_from_int(canvas_y - ec->client.y);
1430 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1432 if (wl_resource_get_client(res) != wc) continue;
1433 if (!e_comp_wl_input_touch_check(res)) continue;
1434 wl_touch_send_motion(res, timestamp, idx, x, y);
1439 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1441 struct wl_resource *res;
1442 struct wl_client *wc;
1446 if (ec->cur_mouse_action) return;
1447 if (e_object_is_del(E_OBJECT(ec))) return;
1448 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1449 if (!surface) return;
1451 wc = wl_resource_get_client(surface);
1452 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1454 if (!e_comp_wl_input_pointer_check(res)) continue;
1455 if (wl_resource_get_client(res) != wc) continue;
1456 wl_pointer_send_motion(res, timestamp,
1457 wl_fixed_from_int(x - ec->client.x),
1458 wl_fixed_from_int(y - ec->client.y));
1463 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1465 if (e_comp_wl->ptr.hide_tmr)
1467 if (cursor_timer_ec == ec)
1469 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1470 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1474 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1475 cursor_timer_ec = ec;
1476 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
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 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1490 Evas_Event_Mouse_Move *ev;
1491 Evas_Device *dev = NULL;
1492 const char *dev_name;
1493 E_Comp_Config *comp_conf;
1497 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1498 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1500 if (!(ec = data)) return;
1501 if (e_object_is_del(E_OBJECT(ec))) return;
1502 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1503 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1504 if (!surface) return;
1506 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1509 dev_name = evas_device_description_get(dev);
1511 comp_conf = e_comp_config_get();
1512 if (comp_conf && comp_conf->input_log_enable)
1513 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1514 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1515 e_client_util_name_get(ec), dev_name);
1517 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1519 if (!e_comp_wl->drag_client)
1521 e_comp_wl->touch.faked_ec = ec;
1522 if (e_comp_wl->touch.pressed & (1 << 0))
1524 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1526 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1527 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1528 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1532 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1536 if (!e_comp_wl->drag_client)
1538 if (_e_comp_wl_check_cursor_timer_needed(ec))
1540 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1544 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1545 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1547 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1549 if (_e_comp_wl_check_cursor_timer_needed(ec))
1550 _e_comp_wl_cursor_move_timer_control(ec);
1554 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1559 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1561 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1562 if (e_object_is_del(E_OBJECT(ec))) return;
1563 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1564 if (!surface) return;
1565 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1567 e_comp_wl->ptr.button = BTN_LEFT;
1569 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1573 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1575 E_Client *ec = data;
1576 Evas_Event_Mouse_Down *ev = event;
1577 Evas_Device *dev = NULL;
1578 const Evas_Device *seat_dev;
1579 const char *dev_name, *seat_name;
1580 E_Comp_Config *comp_conf = NULL;
1583 if (e_object_is_del(E_OBJECT(ec))) return;
1586 dev_name = evas_device_description_get(dev);
1588 seat_dev = evas_device_parent_get(dev);
1589 seat_name = evas_device_name_get(seat_dev);
1591 comp_conf = e_comp_config_get();
1592 if (comp_conf && comp_conf->input_log_enable)
1593 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1594 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1595 dev_name, seat_name);
1597 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1599 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1601 e_comp_wl->touch.faked_ec = ec;
1604 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1605 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1606 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1608 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1609 e_comp_wl->touch.pressed |= (1 << 0);
1613 if (_e_comp_wl_check_cursor_timer_needed(ec))
1615 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1619 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1620 WL_POINTER_BUTTON_STATE_PRESSED);
1622 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1625 need_send_released = EINA_TRUE;
1629 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1631 E_Client *ec = data;
1632 Evas_Event_Mouse_Up *ev = event;
1633 Evas_Device *dev = NULL;
1634 const Evas_Device *seat_dev;
1635 const char *dev_name, *seat_name;;
1636 Evas_Event_Flags flags;
1637 E_Comp_Config *comp_conf = NULL;
1640 if (ec->cur_mouse_action) return;
1641 if (e_object_is_del(E_OBJECT(ec))) return;
1643 if (!need_send_released)
1645 need_send_motion = EINA_TRUE;
1649 dev_name = evas_device_description_get(dev);
1651 seat_dev = evas_device_parent_get(dev);
1652 seat_name = evas_device_name_get(seat_dev);
1653 flags = evas_event_default_flags_get(evas);
1655 comp_conf = e_comp_config_get();
1656 if (comp_conf && comp_conf->input_log_enable)
1657 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1658 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1659 dev_name, seat_name);
1661 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1663 e_comp_wl->touch.pressed &= ~(1 << 0);
1665 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1666 e_comp_wl->touch.faked_ec = NULL;
1669 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1671 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1673 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1676 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1677 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1678 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1682 if (_e_comp_wl_check_cursor_timer_needed(ec))
1684 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1688 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1689 WL_POINTER_BUTTON_STATE_RELEASED);
1691 if (_e_comp_wl_check_cursor_timer_needed(ec))
1692 _e_comp_wl_cursor_move_timer_control(ec);
1696 need_send_released = EINA_FALSE;
1700 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1702 struct wl_resource *res;
1703 struct wl_client *wc;
1708 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1710 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1713 dir = -wl_fixed_from_int(abs(z));
1715 dir = wl_fixed_from_int(z);
1718 if (e_object_is_del(E_OBJECT(ec))) return;
1719 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1720 if (!surface) return;
1722 wc = wl_resource_get_client(surface);
1723 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1725 if (!e_comp_wl_input_pointer_check(res)) continue;
1726 if (wl_resource_get_client(res) != wc) continue;
1727 wl_pointer_send_axis(res, timestamp, axis, dir);
1732 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1735 Evas_Event_Mouse_Wheel *ev;
1738 if (!(ec = data)) return;
1739 if (ec->cur_mouse_action) return;
1740 if (e_object_is_del(E_OBJECT(ec))) return;
1741 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1742 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1743 if (!surface) return;
1745 if (!eina_list_count(e_comp_wl->ptr.resources))
1748 if (_e_comp_wl_check_cursor_timer_needed(ec))
1750 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1754 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1756 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1758 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1760 if (_e_comp_wl_check_cursor_timer_needed(ec))
1761 _e_comp_wl_cursor_move_timer_control(ec);
1766 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1768 E_Client *ec = data;
1769 Evas_Event_Multi_Down *ev = event;
1770 Evas_Device *dev = NULL;
1771 const Evas_Device *seat_dev;
1772 const char *dev_name, *seat_name;
1773 Evas_Device_Class dev_class;
1774 E_Comp_Config *comp_conf = NULL;
1777 if (e_object_is_del(E_OBJECT(ec))) return;
1778 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1779 if (!surface) return;
1781 /* Do not deliver emulated single touch events to client */
1782 if (ev->device == 0) return;
1785 dev_name = evas_device_description_get(dev);
1786 e_comp_wl->touch.faked_ec = ec;
1788 seat_dev = evas_device_parent_get(dev);
1789 seat_name = evas_device_name_get(seat_dev);
1791 comp_conf = e_comp_config_get();
1792 if (comp_conf && comp_conf->input_log_enable)
1793 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1794 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1795 dev_name, seat_name);
1797 if (dev && dev_name)
1799 dev_class = evas_device_class_get(dev);
1800 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1801 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1804 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1805 e_comp_wl->touch.pressed |= (1 << ev->device);
1809 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1811 E_Client *ec = data;
1812 Evas_Event_Multi_Up *ev = event;
1813 Evas_Device *dev = NULL;
1814 const Evas_Device *seat_dev;
1815 const char *dev_name, *seat_name;
1816 Evas_Device_Class dev_class;
1817 Evas_Event_Flags flags;
1818 E_Comp_Config *comp_conf = NULL;
1821 if (e_object_is_del(E_OBJECT(ec))) return;
1822 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1823 if (!surface) return;
1825 /* Do not deliver emulated single touch events to client */
1826 if (ev->device == 0) return;
1828 flags = evas_event_default_flags_get(evas);
1830 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1831 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1832 e_comp_wl->touch.faked_ec = NULL;
1834 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1837 dev_name = evas_device_description_get(dev);
1839 seat_dev = evas_device_parent_get(dev);
1840 seat_name = evas_device_name_get(seat_dev);
1842 comp_conf = e_comp_config_get();
1843 if (comp_conf && comp_conf->input_log_enable)
1844 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1845 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1846 dev_name, seat_name);
1848 if (dev && dev_name)
1850 dev_class = evas_device_class_get(dev);
1851 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1852 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1855 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1859 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1861 E_Client *ec = data;
1862 Evas_Event_Multi_Move *ev = event;
1863 Evas_Device *dev = NULL;
1864 const char *dev_name;
1865 Evas_Device_Class dev_class;
1868 if (e_object_is_del(E_OBJECT(ec))) return;
1869 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1870 if (!surface) return;
1872 /* Do not deliver emulated single touch events to client */
1873 if (ev->device == 0) return;
1875 e_comp_wl->touch.faked_ec = ec;
1877 if (e_comp_wl->touch.pressed & (1 << ev->device))
1880 if (dev && (dev_name = evas_device_description_get(dev)))
1882 dev_class = evas_device_class_get(dev);
1883 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1884 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1887 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1892 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1895 char *file, buff[PATH_MAX];
1902 n = (getpriority(PRIO_PROCESS, pid) + adj);
1906 setpriority(PRIO_PROCESS, pid, n);
1909 use_adj = EINA_TRUE;
1911 if (!do_child) return;
1913 files = ecore_file_ls("/proc");
1914 EINA_LIST_FREE(files, file)
1916 if (!isdigit(file[0]))
1919 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1920 if ((f = fopen(buff, "r")))
1924 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1926 if (num_read == 2 && ppid == pid)
1927 _e_comp_wl_client_priority_adjust(pid2, set,
1929 adj_child, do_child);
1937 _e_comp_wl_client_priority_raise(E_Client *ec)
1939 if (!e_config->priority_control) return;
1940 if (ec->netwm.pid <= 0) return;
1941 if (ec->netwm.pid == getpid()) return;
1942 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1943 e_config->priority - 1, -1,
1944 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1948 _e_comp_wl_client_priority_normal(E_Client *ec)
1950 if (!e_config->priority_control) return;
1951 if (ec->netwm.pid <= 0) return;
1952 if (ec->netwm.pid == getpid()) return;
1953 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1954 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1958 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1961 E_Comp_Wl_Key_Data *k;
1962 struct wl_resource *res;
1966 if (!ec) return EINA_FALSE;
1967 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1968 if (!ec->comp_data) return EINA_FALSE;
1970 ec->comp_data->on_focus_timer = NULL;
1971 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1972 if (!e_comp_wl->kbd.focused)
1974 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1977 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1979 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1980 t = ecore_time_unix_get();
1982 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1983 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1984 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1986 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1988 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1989 wl_keyboard_send_key(res, serial, t,
1990 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1993 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1994 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1998 /* It is called in the following cases:
1999 * When a normal ec->frame has focus.
2000 * Or launching image ec is replaced to the real ec.
2003 e_comp_wl_feed_focus_in(E_Client *ec)
2006 struct wl_resource *res;
2007 struct wl_client *wc;
2011 if (e_object_is_del(E_OBJECT(ec))) return;
2012 if (ec->iconic) return;
2014 /* block spurious focus events */
2015 focused = e_client_focused_get();
2016 if ((focused) && (ec != focused)) return;
2018 /* raise client priority */
2019 _e_comp_wl_client_priority_raise(ec);
2020 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2021 if (!surface) return;
2023 wc = wl_resource_get_client(surface);
2025 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2026 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2028 if (wl_resource_get_client(res) == wc)
2030 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2031 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2032 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2033 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2036 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2038 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2039 if (!e_comp_wl->kbd.focused)
2041 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2044 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2046 e_comp_wl->kbd.focus = surface;
2047 e_comp_wl_input_keyboard_enter_send(ec);
2048 e_comp_wl_data_device_keyboard_focus_set();
2049 ec->comp_data->on_focus_timer =
2050 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2051 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2052 int rotation = ec->e.state.rot.ang.curr;
2053 e_pointer_rotation_set(e_comp->pointer, rotation);
2057 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2060 if (!(ec = data)) return;
2061 e_comp_wl_feed_focus_in(ec);
2065 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2068 struct wl_resource *res;
2070 E_Comp_Wl_Key_Data *k;
2074 if (!(ec = data)) return;
2076 if (!ec->comp_data) return;
2078 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2080 /* lower client priority */
2081 if (!e_object_is_del(data))
2082 _e_comp_wl_client_priority_normal(ec);
2085 /* update keyboard modifier state */
2086 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2087 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2088 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2090 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2092 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2093 if (!surface) return;
2095 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2096 if (!eina_list_count(e_comp_wl->kbd.resources))
2098 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2102 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2104 /* send keyboard_leave to all keyboard resources */
2105 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2106 t = ecore_time_unix_get();
2108 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2109 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2110 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2112 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2114 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2115 wl_keyboard_send_key(res, serial, t,
2116 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2118 wl_keyboard_send_leave(res, serial, surface);
2119 e_comp_wl->kbd.focused =
2120 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2122 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2123 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2127 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2131 if (!(ec = data)) return;
2133 if (!ec->comp_data->shell.configure_send) return;
2135 /* TODO: calculate x, y with transfrom object */
2136 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2140 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2141 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2142 if (e_comp_object_frame_exists(ec->frame))
2143 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2145 switch (ec->resize_mode)
2147 case E_POINTER_RESIZE_TL:
2148 case E_POINTER_RESIZE_L:
2149 case E_POINTER_RESIZE_BL:
2150 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2151 ec->mouse.current.mx;
2153 case E_POINTER_RESIZE_TR:
2154 case E_POINTER_RESIZE_R:
2155 case E_POINTER_RESIZE_BR:
2156 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2161 switch (ec->resize_mode)
2163 case E_POINTER_RESIZE_TL:
2164 case E_POINTER_RESIZE_T:
2165 case E_POINTER_RESIZE_TR:
2166 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2167 ec->mouse.current.my;
2169 case E_POINTER_RESIZE_BL:
2170 case E_POINTER_RESIZE_B:
2171 case E_POINTER_RESIZE_BR:
2172 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2177 w = E_CLAMP(w, 1, w);
2178 h = E_CLAMP(h, 1, h);
2179 e_client_resize_limit(ec, &w, &h);
2181 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2183 else if ((!ec->fullscreen) && (!ec->maximized) &&
2184 (!ec->comp_data->maximize_pre))
2188 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2189 if ((pw != ec->w) || (ph != ec->h))
2191 _e_comp_wl_configure_send(ec, 1, 1);
2195 if (ec->comp_data->sub.below_obj)
2196 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2200 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2202 E_Client *ec = data;
2204 ec->comp_data->maximize_pre = 1;
2208 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2210 E_Client *ec = data;
2213 if (e_object_is_del(E_OBJECT(ec))) return;
2215 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2216 e_client_shell_configure_send(ec, 0, w, h);
2218 ec->comp_data->maximize_pre = 0;
2222 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2224 E_Client *ec = data;
2226 ec->comp_data->maximize_pre = 1;
2230 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2232 E_Client *ec = data;
2234 if (e_object_is_del(E_OBJECT(ec))) return;
2236 /* check for wayland pixmap */
2238 if (ec->comp_data->shell.configure_send)
2239 _e_comp_wl_configure_send(ec, 0, 0);
2241 ec->comp_data->maximize_pre = 0;
2245 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2247 E_Client *ec = data;
2249 if (e_object_is_del(E_OBJECT(ec))) return;
2251 /* check for wayland pixmap */
2253 if (ec->comp_data->shell.configure_send)
2254 _e_comp_wl_configure_send(ec, 0, 1);
2256 ec->comp_data->maximize_pre = 0;
2260 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2262 E_Client *ec = data;
2264 if (e_object_is_del(E_OBJECT(ec))) return;
2266 /* check for wayland pixmap */
2268 if (ec->comp_data->shell.configure_send)
2269 _e_comp_wl_configure_send(ec, 0, 0);
2271 ec->comp_data->maximize_pre = 0;
2275 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2279 if (!(ec = data)) return;
2281 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2283 e_object_del(E_OBJECT(ec));
2285 _e_comp_wl_focus_check();
2287 /* TODO: Delete request send ??
2288 * NB: No such animal wrt wayland */
2292 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2296 if (!(ec = data)) return;
2298 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2301 if (ec->comp_data->reparented)
2302 e_client_comp_hidden_set(ec, EINA_TRUE);
2305 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2306 if (ec->visible) evas_object_hide(ec->frame);
2307 if (!ec->internal) e_object_del(E_OBJECT(ec));
2309 _e_comp_wl_focus_check();
2313 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2317 if (!(ec = data)) return;
2319 e_client_shell_ping(ec);
2323 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2328 if (!(ec = data)) return;
2329 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2330 if (ec->netwm.opacity == a) return;
2331 ec->netwm.opacity = a;
2332 ec->netwm.opacity_changed = EINA_TRUE;
2336 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2338 Eina_Rectangle *damage_rect = NULL;
2339 Eina_Rectangle *dmg = NULL;
2340 Eina_List *l = NULL;
2342 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2343 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2346 if (!buffer->tbm_surface) return;
2350 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2354 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2355 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2358 eina_rectangle_union(damage_rect, dmg);
2363 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2364 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2367 tbm_surface_internal_set_damage(buffer->tbm_surface,
2373 eina_rectangle_free(damage_rect);
2377 _e_comp_wl_client_evas_init(E_Client *ec)
2379 if (!ec || !ec->comp_data) return;
2380 if (ec->comp_data->evas_init) return;
2382 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2383 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2384 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2387 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2388 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2389 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2390 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2391 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2392 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2395 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2396 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2398 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2399 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2403 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2404 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2405 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2406 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2407 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2408 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2409 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2412 /* setup delete/kill callbacks */
2413 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2414 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2416 /* setup ping callback */
2417 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2418 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2420 ec->comp_data->evas_init = EINA_TRUE;
2424 _e_comp_wl_client_evas_deinit(E_Client *ec)
2426 if (!ec || !ec->comp_data) return;
2427 if (!ec->comp_data->evas_init) return;
2429 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2430 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2431 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2433 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2434 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2438 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2445 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2449 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2450 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2451 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2452 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2453 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2454 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2455 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2458 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2459 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2461 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2462 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2464 ec->comp_data->evas_init = EINA_FALSE;
2468 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2472 E_Comp_Screen *e_comp_screen;
2473 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2475 if (!e_comp) return ECORE_CALLBACK_RENEW;
2476 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2477 e_comp_screen = e_comp->e_comp_screen;
2479 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2481 if (!eout->config.enabled)
2483 e_comp_wl_output_remove(eout->id);
2487 switch (eout->config.rotation)
2490 transform = WL_OUTPUT_TRANSFORM_90;
2493 transform = WL_OUTPUT_TRANSFORM_180;
2496 transform = WL_OUTPUT_TRANSFORM_270;
2500 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2504 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2506 eout->config.geom.x, eout->config.geom.y,
2507 eout->config.geom.w, eout->config.geom.h,
2508 eout->info.size.w, eout->info.size.h,
2509 eout->config.mode.refresh, 0, transform))
2510 ERR("Could not initialize screen %s", eout->info.name);
2513 return ECORE_CALLBACK_RENEW;
2517 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2521 /* try to get the client from the object */
2522 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2523 return ECORE_CALLBACK_RENEW;
2525 /* check for client being deleted */
2526 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2528 /* check for wayland pixmap */
2529 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2530 return ECORE_CALLBACK_RENEW;
2532 /* if we have not setup evas callbacks for this client, do it */
2533 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2535 return ECORE_CALLBACK_RENEW;
2539 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2543 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2544 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2546 if (e_comp_wl->selection.target &&
2549 struct wl_resource *res;
2551 E_Client *ec = NULL;
2552 E_Client *legacy_target = e_comp_wl->selection.target;
2553 int device_id = e_comp_wl_data_current_device_id_get();
2557 e_comp_wl_data_current_device_id_set(ev->multi.device);
2559 else if (device_id != ev->multi.device)
2561 return ECORE_CALLBACK_RENEW;
2564 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2565 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2567 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2568 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2570 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2571 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2573 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2574 (ec != legacy_target))
2576 e_comp_wl_data_device_send_leave(legacy_target);
2577 e_comp_wl_data_device_send_enter(ec);
2580 if (e_comp_wl->drag)
2581 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2583 if (e_client_transform_core_enable_get(ec))
2585 int trans_x, trans_y;
2586 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2587 x = trans_x - ec->client.x;
2588 y = trans_y - ec->client.y;
2592 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2597 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2600 return ECORE_CALLBACK_RENEW;
2604 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2607 struct wl_resource *surface;
2608 struct wl_resource *res;
2609 struct wl_client *wc;
2611 E_Comp_Config *comp_conf;
2613 ec = e_comp_wl->ptr_constraints.ec;
2614 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2616 surface = e_comp_wl_client_surface_get(ec);
2617 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2619 wc = wl_resource_get_client(surface);
2621 comp_conf = e_comp_config_get();
2623 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2625 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2626 if (wl_resource_get_client(res) != wc) continue;
2628 if (comp_conf && comp_conf->input_log_enable)
2629 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2630 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2631 e_client_util_name_get(ec));
2633 zwp_relative_pointer_v1_send_relative_motion(res,
2635 (uint32_t)(ev->timestamp),
2636 wl_fixed_from_int(ev->dx),
2637 wl_fixed_from_int(ev->dy),
2638 wl_fixed_from_int(ev->dx_unaccel),
2639 wl_fixed_from_int(ev->dy_unaccel));
2642 return ECORE_CALLBACK_DONE;
2646 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2648 _e_comp_wl_touch_cancel();
2650 return ECORE_CALLBACK_PASS_ON;
2654 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2656 if (!ev) return ECORE_CALLBACK_PASS_ON;
2658 E_Zone *zone = ev->zone;
2660 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2661 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2663 if (!e_zone_is_displaying(zone))
2664 _e_comp_wl_touch_cancel();
2666 return ECORE_CALLBACK_PASS_ON;
2670 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2672 E_Client *ec = ev->ec;
2673 E_Comp_Wl_Buffer_Viewport *vp;
2675 if (!ec) return ECORE_CALLBACK_PASS_ON;
2676 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2677 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2678 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2679 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2681 vp = &ec->comp_data->scaler.buffer_viewport;
2682 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2684 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2686 return ECORE_CALLBACK_PASS_ON;
2690 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2692 E_Client *ec = ev->ec;
2693 E_Comp_Wl_Buffer_Viewport *vp;
2695 if (!ec) return ECORE_CALLBACK_PASS_ON;
2696 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2697 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2698 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2700 vp = &ec->comp_data->scaler.buffer_viewport;
2701 vp->wait_for_transform_change = 0;
2703 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2705 return ECORE_CALLBACK_PASS_ON;
2709 _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)
2711 E_Client *focused_ec;
2714 focused_ec = e_client_focused_get();
2715 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2717 rotation = focused_ec->e.state.rot.ang.curr;
2718 e_pointer_rotation_set(e_comp->pointer, rotation);
2720 return ECORE_CALLBACK_PASS_ON;
2724 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2727 Eina_Rectangle *window;
2732 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2734 if ((prev_w != state->bw) ||
2735 (prev_h != state->bh))
2737 ec->changes.buf_size = EINA_TRUE;
2740 if (e_comp_object_frame_exists(ec->frame)) return;
2741 window = &ec->comp_data->shell.window;
2742 if ((!ec->borderless) && /* FIXME temporarily added this check code
2743 * to prevent updating E_Client's size by frame */
2744 (window->x || window->y || window->w || window->h))
2746 e_comp_object_frame_geometry_set(ec->frame,
2748 (window->x + window->w) - state->bw,
2750 (window->y + window->h) - state->bh);
2753 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2757 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2759 E_Comp_Wl_Surface_State *state;
2762 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2763 state->buffer = NULL;
2767 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2769 state->new_attach = EINA_FALSE;
2770 state->buffer = NULL;
2771 state->buffer_destroy_listener.notify =
2772 _e_comp_wl_surface_state_cb_buffer_destroy;
2773 state->sx = state->sy = 0;
2775 state->input = eina_tiler_new(w, h);
2776 eina_tiler_tile_size_set(state->input, 1, 1);
2778 state->opaque = eina_tiler_new(w, h);
2779 eina_tiler_tile_size_set(state->opaque, 1, 1);
2781 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2782 state->buffer_viewport.buffer.scale = 1;
2783 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2784 state->buffer_viewport.surface.width = -1;
2785 state->buffer_viewport.changed = 0;
2787 e_presentation_time_container_init(&state->presentation_container);
2791 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2793 struct wl_resource *cb;
2794 Eina_Rectangle *dmg;
2796 EINA_LIST_FREE(state->frames, cb)
2797 wl_resource_destroy(cb);
2799 EINA_LIST_FREE(state->damages, dmg)
2800 eina_rectangle_free(dmg);
2802 EINA_LIST_FREE(state->buffer_damages, dmg)
2803 eina_rectangle_free(dmg);
2805 if (state->opaque) eina_tiler_free(state->opaque);
2806 state->opaque = NULL;
2808 if (state->input) eina_tiler_free(state->input);
2809 state->input = NULL;
2811 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2812 state->buffer = NULL;
2814 e_presentation_time_container_finish(&state->presentation_container);
2818 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2820 if (state->buffer == buffer) return;
2822 wl_list_remove(&state->buffer_destroy_listener.link);
2823 state->buffer = buffer;
2825 wl_signal_add(&state->buffer->destroy_signal,
2826 &state->buffer_destroy_listener);
2830 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2832 Eina_Rectangle *dmg;
2833 Eina_Bool placed = EINA_TRUE;
2837 E_Comp_Wl_Buffer *buffer;
2838 struct wl_resource *cb;
2840 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2841 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2846 if ((ec->internal) ||
2847 (cdata->shell.surface && state->new_attach))
2851 e_comp->new_clients++;
2852 ELOGF("COMP", "Unignore", ec);
2853 e_client_unignore(ec);
2857 /* buffer transform */
2858 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2861 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2863 /* when buffer is transformed, we have to apply the new evas-map */
2864 state->buffer_viewport.changed = EINA_TRUE;
2866 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2868 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2870 if (transform_change == vp->wait_for_transform_change)
2871 vp->wait_for_transform_change = 0;
2873 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2874 // triggered by E_CLIENT_HOOK calls at those file.
2875 zone = e_comp_zone_find_by_ec(ec);
2878 eout = e_output_find(zone->output_id);
2879 if (eout && eout->hwc)
2881 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2883 if (e_comp_is_on_overlay(ec))
2884 e_comp_hwc_client_end(ec, __FUNCTION__);
2890 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2891 cdata->scaler.buffer_viewport = state->buffer_viewport;
2893 if (state->new_attach)
2895 e_comp_wl_surface_attach(ec, state->buffer);
2898 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2899 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2901 _e_comp_wl_surface_state_buffer_set(state, NULL);
2903 if ((state->new_attach) ||
2904 (state->buffer_viewport.changed))
2906 _e_comp_wl_surface_state_size_update(ec, state);
2907 e_comp_wl_map_size_cal_from_viewport(ec);
2909 /* update the position */
2910 if (ec->changes.pos)
2912 e_comp_object_frame_xy_unadjust(ec->frame,
2922 if (ec->new_client) placed = ec->placed;
2924 if (!ec->lock_client_size)
2929 ec->client.w = state->bw;
2930 ec->client.h = state->bh;
2932 e_comp_object_frame_wh_adjust(ec->frame,
2933 ec->client.w, ec->client.h,
2935 e_client_size_set(ec, nw, nh);
2937 if ((w != ec->w) || (h != ec->h))
2939 ec->changes.size = 1;
2944 if (ec->changes.buf_size)
2946 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2947 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2948 ec->changes.buf_size = EINA_FALSE;
2950 if (ec->move_after_resize)
2952 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2953 ec->move_after_resize = EINA_FALSE;
2958 /* map or unmap ec */
2959 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2960 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2961 if (!pixmap_usable || hide_by_request)
2966 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2971 if ((cdata->sub.below_obj) &&
2972 (evas_object_visible_get(cdata->sub.below_obj)))
2974 evas_object_hide(cdata->sub.below_obj);
2982 if ((cdata->sub.below_obj) &&
2983 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2984 (evas_object_visible_get(ec->frame)))
2986 evas_object_show(cdata->sub.below_obj);
2990 if ((state->new_attach) ||
2991 (state->buffer_viewport.changed))
2993 if ((e_comp_wl->drag) &&
2994 (e_comp_wl->drag_client) &&
2995 (e_comp_wl->drag_client == ec))
2997 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2999 e_drag_move(e_comp_wl->drag,
3001 e_comp_wl->drag->y);
3003 e_drag_resize(e_comp_wl->drag,
3004 state->bw, state->bh);
3006 else if ((cdata->shell.surface) &&
3007 (cdata->shell.configure))
3009 e_comp_wl_commit_sync_configure(ec);
3011 else if (!e_client_video_hw_composition_check(ec))
3013 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3018 ec->placed = placed;
3019 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3023 if (cdata->scaler.buffer_viewport.changed)
3024 e_comp_wl_map_apply(ec);
3026 /* resize transform object */
3027 if (ec->transformed)
3028 e_client_transform_update(ec);
3032 state->new_attach = EINA_FALSE;
3034 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3036 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3037 wl_resource_destroy(cb);
3040 /* insert state frame callbacks into comp_data->frames
3041 * NB: This clears state->frames list */
3042 cdata->frames = eina_list_merge(cdata->frames,
3044 state->frames = NULL;
3046 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3047 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3048 &state->presentation_container);
3050 buffer = e_pixmap_resource_get(ec->pixmap);
3052 /* put state damages into surface */
3055 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3056 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3058 if ((cdata->buffer_ref.buffer) &&
3059 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3060 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3062 e_comp_object_damage(ec->frame,
3064 cdata->buffer_ref.buffer->w,
3065 cdata->buffer_ref.buffer->h);
3070 Eina_List *damages = NULL;
3073 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3075 if (eina_list_count(state->buffer_damages))
3077 EINA_LIST_FREE(state->buffer_damages, dmg)
3080 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3081 e_comp_wl_output_buffer_transform_get(ec),
3083 dmg->x, dmg->y, dmg->w, dmg->h,
3084 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3085 damages = eina_list_append(damages, dmg);
3089 EINA_LIST_FREE(state->damages, dmg)
3090 damages = eina_list_append(damages, dmg);
3092 EINA_LIST_FREE(damages, dmg)
3094 /* not creating damage for ec that shows a underlay video */
3095 if (state->buffer_viewport.changed ||
3096 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3097 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3098 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3100 eina_rectangle_free(dmg);
3105 /* put state opaque into surface */
3106 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3109 Eina_Rectangle *rect;
3112 itr = eina_tiler_iterator_new(state->opaque);
3113 EINA_ITERATOR_FOREACH(itr, rect)
3117 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3118 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3119 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3123 eina_iterator_free(itr);
3126 /* put state input into surface */
3127 if ((state->input) &&
3128 (!eina_tiler_empty(state->input)) &&
3131 Eina_Tiler *src, *tmp;
3135 tmp = eina_tiler_new(sw, sh);
3136 eina_tiler_tile_size_set(tmp, 1, 1);
3138 eina_tiler_rect_add(tmp,
3139 &(Eina_Rectangle){0, 0, sw, sh});
3141 if ((src = eina_tiler_intersection(state->input, tmp)))
3143 Eina_Rectangle *rect;
3146 e_comp_object_input_objs_del(ec->frame);
3147 itr = eina_tiler_iterator_new(src);
3148 EINA_ITERATOR_FOREACH(itr, rect)
3150 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3151 ec, rect->x, rect->y, rect->w, rect->h,
3152 ec->w, ec->h, state->bw, state->bh);
3153 e_comp_object_input_area_set(ec->frame,
3158 eina_iterator_free(itr);
3159 eina_tiler_free(src);
3162 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3164 eina_tiler_free(tmp);
3166 /* clear input tiler */
3167 eina_tiler_clear(state->input);
3170 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3172 if ((cdata->video_client) &&
3174 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3175 (e_comp->wl_comp_data->available_hw_accel.underlay))
3177 e_pixmap_image_clear(ec->pixmap, 1);
3180 state->buffer_viewport.changed = 0;
3182 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3185 ec->exp_iconify.buffer_flush &&
3186 e_policy_visibility_client_is_iconic(ec))
3188 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3193 _e_comp_wl_surface_render_stop(E_Client *ec)
3195 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3196 //if ((!ec->internal) && (!e_comp_gl_get()))
3199 /* check if internal animation is running */
3200 if (e_comp_object_is_animating(ec->frame)) return;
3201 /* check if external animation is running */
3202 if (evas_object_data_get(ec->frame, "effect_running")) return;
3204 evas_object_hide(ec->frame);
3208 e_comp_wl_client_surface_finish(E_Client *ec)
3210 struct wl_resource *res, *surface;
3211 struct wl_client *surface_client = NULL;
3214 surface = e_comp_wl_client_surface_get(ec);
3217 surface_client = wl_resource_get_client(surface);
3219 if (surface_client &&
3220 (ec == e_client_focused_get()))
3222 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3223 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3225 if (wl_resource_get_client(res) ==
3227 e_comp_wl->kbd.focused =
3228 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3232 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3235 e_comp_wl_client_surface_set(ec, NULL);
3237 ec->comp_data->wl_surface = NULL;
3238 e_pixmap_win_id_del(ec->pixmap);
3240 _e_comp_wl_surface_render_stop(ec);
3241 e_object_del(E_OBJECT(ec));
3245 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3250 char proc[512], pname[512];
3253 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3255 h = fopen(proc, "r");
3258 len = fread(pname, sizeof(char), 512, h);
3260 pname[len - 1] = '\0';
3262 strncpy(pname, "NO NAME", sizeof(pname));
3268 strncpy(pname, "NO NAME", sizeof(pname));
3271 strncpy(name, pname, size);
3275 _e_comp_wl_pname_print(pid_t pid)
3278 char proc[512], pname[512];
3281 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3283 h = fopen(proc, "r");
3286 len = fread(pname, sizeof(char), 512, h);
3288 pname[len - 1] = '\0';
3290 strncpy(pname, "NO NAME", sizeof(pname));
3294 ELOGF("COMP", " |%s", NULL, pname);
3299 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3301 struct wl_client *client = data;
3302 E_Comp_Connected_Client_Info *cinfo;
3305 cinfo = wl_container_of(listener, cinfo, destroy);
3307 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3308 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3310 eai = e_appinfo_find_with_pid(cinfo->pid);
3311 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3314 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3316 wl_list_remove(&cinfo->destroy.link);
3317 eina_stringshare_del(cinfo->name);
3322 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3324 E_Comp_Connected_Client_Info *cinfo;
3326 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3327 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3329 cinfo->name = eina_stringshare_add(name);
3333 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3334 wl_client_add_destroy_listener(client, &cinfo->destroy);
3335 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3337 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3341 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3343 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3345 /* send configure */
3346 if (ec->comp_data->shell.configure_send)
3348 if (ec->comp_data->shell.surface)
3349 _e_comp_wl_configure_send(ec, 0, 0);
3352 e_comp_wl->kbd.focus = ec->comp_data->surface;
3356 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3358 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3360 /* send configure */
3361 if (ec->comp_data->shell.configure_send)
3363 if (ec->comp_data->shell.surface)
3364 _e_comp_wl_configure_send(ec, 0, 0);
3367 _e_comp_wl_focus_check();
3369 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3370 e_comp_wl->kbd.focus = NULL;
3374 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3376 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3377 if (ec->keyboard_resizing) return;
3379 /* do nothing currently */
3384 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3386 if (e_object_is_del(E_OBJECT(ec))) return;
3387 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3389 e_comp_wl->resize.edges = 0;
3390 e_comp_wl->resize.resource = NULL;
3394 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3396 if (e_object_is_del(E_OBJECT(ec))) return;
3397 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3401 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3404 int ratio_w, ratio_h;
3406 phys_w = output->phys_width;
3407 phys_h = output->phys_height;
3409 if (e_config->configured_output_resolution.use)
3411 // change the configured physical size(mm) of the output
3412 if (output->w != res_w)
3414 ratio_w = res_w / output->w;
3415 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3418 if (output->h != res_h)
3420 ratio_h = res_h / output->h;
3421 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3424 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3427 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3428 NULL, res_w, res_h, phys_w, phys_h, pid);
3430 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3431 wl_output_send_scale(resource, output->scale);
3433 wl_output_send_geometry(resource, output->x, output->y,
3435 output->subpixel, output->make ?: "",
3436 output->model ?: "", output->transform);
3438 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3439 res_w, res_h, output->refresh);
3441 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3442 wl_output_send_done(resource);
3446 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3448 E_Comp_Wl_Output *output;
3450 if (!(output = wl_resource_get_user_data(resource))) return;
3452 output->resources = eina_list_remove(output->resources, resource);
3456 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3458 E_Comp_Wl_Output *output;
3459 struct wl_resource *resource;
3460 E_Appinfo *eai = NULL;
3464 if (!(output = data)) return;
3467 wl_resource_create(client, &wl_output_interface, version, id);
3470 wl_client_post_no_memory(client);
3474 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3475 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3477 output->resources = eina_list_append(output->resources, resource);
3479 wl_resource_set_implementation(resource, NULL, output,
3480 _e_comp_wl_cb_output_unbind);
3481 wl_resource_set_user_data(resource, output);
3483 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3484 if (e_config->configured_output_resolution.use)
3486 wl_client_get_credentials(client, &pid, NULL, NULL);
3489 res_w = e_config->configured_output_resolution.w;
3490 res_h = e_config->configured_output_resolution.h;
3494 eai = e_appinfo_find_with_pid(pid);
3497 res_w = e_config->configured_output_resolution.w;
3498 res_h = e_config->configured_output_resolution.h;
3502 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3504 res_w = e_config->configured_output_resolution.w;
3505 res_h = e_config->configured_output_resolution.h;
3509 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3518 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3522 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3525 Evas_GL *evasgl = NULL;
3526 Evas_GL_API *glapi = NULL;
3527 Evas_GL_Context *ctx = NULL;
3528 Evas_GL_Surface *sfc = NULL;
3529 Evas_GL_Config *cfg = NULL;
3531 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3533 if (!e_comp_gl_get()) return;
3535 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3536 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3538 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3539 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3541 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3542 * then we should get evas from ecore_evas.
3545 evas = e_comp->evas;
3547 evas = ecore_evas_get(e_comp->ee);
3549 evasgl = evas_gl_new(evas);
3550 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3552 glapi = evas_gl_api_get(evasgl);
3553 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3554 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3556 cfg = evas_gl_config_new();
3557 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3559 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3560 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3562 ctx = evas_gl_context_create(evasgl, NULL);
3563 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3565 res = evas_gl_make_current(evasgl, sfc, ctx);
3566 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3568 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3569 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3571 evas_gl_config_free(cfg);
3573 evas_gl->gl = evasgl;
3574 evas_gl->glapi = glapi;
3575 evas_gl->glsfc = sfc;
3576 evas_gl->glctx = ctx;
3578 e_comp_wl->evas_gl = evas_gl;
3580 /* for native surface */
3583 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3588 evas_gl_config_free(cfg);
3589 evas_gl_make_current(evasgl, NULL, NULL);
3590 evas_gl_context_destroy(evasgl, ctx);
3591 evas_gl_surface_destroy(evasgl, sfc);
3592 evas_gl_free(evasgl);
3599 _e_comp_wl_gl_popup_cb_close(void *data,
3600 Evas_Object *obj EINA_UNUSED,
3601 void *event_info EINA_UNUSED)
3603 evas_object_del(data);
3607 _e_comp_wl_gl_popup_cb_focus(void *data,
3608 Evas_Object *obj EINA_UNUSED,
3609 void *event_info EINA_UNUSED)
3611 elm_object_focus_set(data, EINA_TRUE);
3616 _e_comp_wl_gl_idle(void *data)
3620 /* show warning window to notify failure of gl init */
3623 Evas_Object *win, *bg, *popup, *btn;
3625 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3626 elm_win_title_set(win, "Compositor Warning");
3627 elm_win_autodel_set(win, EINA_TRUE);
3628 elm_win_borderless_set(win, EINA_TRUE);
3629 elm_win_role_set(win, "notification-low");
3630 elm_win_alpha_set(win, EINA_TRUE);
3632 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3633 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3634 elm_win_resize_object_add(win, bg);
3635 evas_object_color_set(bg, 125, 125, 125, 125);
3636 evas_object_show(bg);
3638 popup = elm_popup_add(win);
3639 elm_object_text_set(popup,
3640 _( "Your screen does not support OpenGL.<br>"
3641 "Falling back to software engine."));
3642 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3644 btn = elm_button_add(popup);
3645 elm_object_text_set(btn, "Close");
3646 elm_object_part_content_set(popup, "button1", btn);
3647 evas_object_show(btn);
3649 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3650 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3652 evas_object_show(popup);
3653 evas_object_show(win);
3657 return ECORE_CALLBACK_CANCEL;
3661 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3663 struct wl_client *client = data;
3669 wl_client_get_credentials(client, &pid, &uid, &gid);
3671 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3673 _e_comp_wl_pname_print(pid);
3674 _e_comp_wl_pname_get(pid, name, sizeof(name));
3675 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3679 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3681 char buf[1024] = {0, };
3683 vsnprintf(buf, 1024, fmt, args);
3687 DBG("[libds] %s", buf);
3690 INF("[libds] %s", buf);
3693 ERR("[libds] %s", buf);
3701 _e_comp_wl_display_create(void)
3704 E_Comp_Wl_Data *wl_cdata;
3709 /* create new compositor data */
3710 if (!(comp = E_NEW(E_Comp_Data, 1)))
3712 ERR("Could not create compositor data: %m");
3715 wl_cdata = &comp->base;
3717 /* set compositor wayland data */
3718 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3720 g_mutex_init(&connection_mutex);
3722 /* try to create a wayland display */
3723 if (!(wl_cdata->wl.disp = wl_display_create()))
3725 ERR("Could not create a Wayland display: %m");
3729 /* try to setup wayland socket */
3730 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3732 ERR("Could not create Wayland display socket: %m");
3733 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3737 res = e_comp_socket_init(name);
3738 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3739 PRCTL("[Winsys] change permission and create sym link for %s", name);
3741 /* set wayland display environment variable */
3742 e_env_set("WAYLAND_DISPLAY", name);
3744 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3745 /* wl_cdata->output.scale = e_scale; */
3747 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3749 if (!e_compositor_init(wl_cdata->wl.disp))
3751 ERR("Failed to initialize compositor");
3755 comp->client_created.notify = _e_comp_wl_cb_client_created;
3756 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3758 if (!e_comp_wl_subsurfaces_init())
3760 ERR("Failed to init_subsurfaces");
3761 goto subsurfaces_err;
3764 /* initialize shm mechanism */
3765 wl_display_init_shm(wl_cdata->wl.disp);
3767 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3769 /* try to init data manager */
3770 if (!e_comp_wl_data_manager_init())
3772 ERR("Could not initialize data manager");
3776 /* try to init input */
3777 if (!e_comp_wl_input_init())
3779 ERR("Could not initialize input");
3783 if (e_comp_gl_get())
3784 _e_comp_wl_gl_init(NULL);
3786 /* get the wayland display loop */
3787 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3789 /* get the file descriptor of the wayland event loop */
3790 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3792 /* create a listener for wayland main loop events */
3794 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3795 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3796 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3797 _e_comp_wl_cb_prepare, wl_cdata);
3802 e_comp_wl_data_manager_shutdown();
3804 e_comp_wl_subsurfaces_shutdown();
3806 wl_list_remove(&comp->client_created.link);
3808 e_env_unset("WAYLAND_DISPLAY");
3810 wl_display_destroy(wl_cdata->wl.disp);
3812 g_mutex_clear(&connection_mutex);
3818 _e_comp_wl_gl_shutdown(void)
3820 if (!e_comp_wl->evas_gl) return;
3822 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3824 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3825 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3826 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3827 evas_gl_free(e_comp_wl->evas_gl->gl);
3829 E_FREE(e_comp_wl->evas_gl);
3832 /* public functions */
3835 * Creates and initializes a Wayland compositor with ecore.
3836 * Registers callback handlers for keyboard and mouse activity
3837 * and other client events.
3839 * @returns true on success, false if initialization failed.
3842 e_comp_wl_init(void)
3844 TRACE_DS_BEGIN(COMP_WL:INIT);
3846 /* try to create a wayland compositor */
3847 if (!_e_comp_wl_display_create())
3849 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3854 e_comp_wl_shell_init();
3856 #ifdef HAVE_WAYLAND_TBM
3857 e_comp_wl_tbm_init();
3859 e_comp_wl_remote_surface_init();
3863 e_comp_wl_screenshooter_init();
3865 if (!e_comp_wl_video_init())
3866 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3868 e_comp_wl_viewport_init();
3869 e_comp_wl_capture_init();
3870 e_comp_wl_renderer_init();
3871 _e_comp_wl_move_resize_init();
3872 e_presentation_time_init();
3873 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3876 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3877 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3879 /* add event handlers to catch E events */
3880 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3881 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3882 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3883 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3884 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3885 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3886 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3887 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3888 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3890 /* add hooks to catch e_client events */
3891 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3892 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3893 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3894 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3895 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3897 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3904 e_comp_wl_deferred_job(void)
3906 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3909 /* internal functions */
3911 e_comp_wl_shutdown(void)
3913 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3915 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3917 e_comp_wl_subsurfaces_shutdown();
3919 E_FREE_LIST(handlers, ecore_event_handler_del);
3920 E_FREE_LIST(hooks, e_client_hook_del);
3921 _e_comp_wl_gl_shutdown();
3923 e_blender_shutdown();
3924 e_presentation_time_shutdown();
3925 e_comp_wl_renderer_shutdown();
3926 e_comp_wl_capture_shutdown();
3927 e_comp_wl_viewport_shutdown();
3928 e_comp_wl_video_shutdown();
3929 e_comp_wl_screenshooter_shutdown();
3931 e_comp_wl_remote_surface_shutdown();
3933 e_pixmap_shutdown();
3935 e_wtz_shell_shutdown();
3936 e_comp_wl_shell_shutdown();
3937 e_comp_wl_input_shutdown();
3939 wl_list_remove(&comp->client_created.link);
3942 e_comp->wl_comp_data = NULL;
3946 E_Comp_Wl_Output *output;
3948 if (e_comp_wl->screenshooter.global)
3949 wl_global_destroy(e_comp_wl->screenshooter.global);
3951 EINA_LIST_FREE(e_comp_wl->outputs, output)
3953 if (output->id) eina_stringshare_del(output->id);
3954 if (output->make) eina_stringshare_del(output->make);
3955 if (output->model) eina_stringshare_del(output->model);
3959 /* delete fd handler */
3960 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3962 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3963 cursor_timer_ec = NULL;
3965 /* free allocated data structure */
3971 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3973 e_object_unref(E_OBJECT(ev->ec));
3978 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3981 ev = E_NEW(E_Event_Client, 1);
3984 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3986 /* set usable early because shell module checks this */
3987 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3988 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3990 e_pixmap_resource_set(ec->pixmap, buffer);
3991 e_pixmap_dirty(ec->pixmap);
3992 e_pixmap_refresh(ec->pixmap);
3994 e_comp_wl_map_size_cal_from_buffer(ec);
3995 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3997 /* wm-policy module uses it */
3998 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4001 e_object_ref(E_OBJECT(ec));
4002 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4003 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4007 e_comp_wl_surface_commit(E_Client *ec)
4012 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4013 if (!e_comp_object_damage_exists(ec->frame))
4015 if ((ec->comp_data->video_client) ||
4016 (!e_client_video_hw_composition_check(ec)))
4017 e_pixmap_image_clear(ec->pixmap, 1);
4020 ignored = ec->ignored;
4022 if (e_comp_wl_subsurface_order_commit(ec))
4024 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4025 e_comp_wl_subsurface_restack(topmost);
4026 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4029 ec->ignored = ignored;
4031 if (ec->is_cursor && ec->visible)
4033 /* ignore cursor changes during resize/move I guess */
4034 if (!e_client_action_get())
4036 if (e_comp->pointer)
4038 x = e_comp->pointer->hot.x;
4039 y = e_comp->pointer->hot.y;
4041 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4047 static E_Comp_Wl_Output *
4048 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4051 E_Comp_Wl_Output *output;
4053 EINA_LIST_FOREACH(outputs, l, output)
4055 if (!strcmp(output->id, id))
4063 * Initializes information about one display output.
4065 * Adds or updates the given data about a single display output,
4066 * with an id matching the provided id.
4068 * @param id identification of output to be added or changed
4069 * @param make manufacturer name of the display output
4070 * @param model model name of the display output
4071 * @param x output's top left corner x coordinate
4072 * @param y output's top left corner y coordinate
4073 * @param w output's width in pixels
4074 * @param h output's height in pixels
4075 * @param pw output's physical width in millimeters
4076 * @param ph output's physical height in millimeters
4077 * @param refresh output's refresh rate in mHz
4078 * @param subpixel output's subpixel layout
4079 * @param transform output's rotation and/or mirror transformation
4081 * @returns True if a display output object could be added or updated
4084 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4085 int x, int y, int w, int h, int pw, int ph,
4086 unsigned int refresh, unsigned int subpixel,
4087 unsigned int transform)
4089 E_Comp_Wl_Output *output;
4091 struct wl_resource *resource;
4093 /* retrieve named output; or create it if it doesn't exist */
4094 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4097 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4099 if (id) output->id = eina_stringshare_add(id);
4101 output->make = eina_stringshare_add(make);
4103 output->make = eina_stringshare_add("unknown");
4105 output->model = eina_stringshare_add(model);
4107 output->model = eina_stringshare_add("unknown");
4109 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4112 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4113 2, output, _e_comp_wl_cb_output_bind);
4115 output->resources = NULL;
4116 output->scale = e_scale;
4119 /* update the output details */
4124 output->phys_width = pw;
4125 output->phys_height = ph;
4126 output->refresh = refresh;
4127 output->subpixel = subpixel;
4128 output->transform = transform;
4130 if (output->scale <= 0)
4131 output->scale = e_scale;
4133 /* if we have bound resources, send updates */
4134 EINA_LIST_FOREACH(output->resources, l2, resource)
4136 wl_output_send_geometry(resource,
4137 output->x, output->y,
4139 output->phys_height,
4141 output->make ?: "", output->model ?: "",
4144 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4145 wl_output_send_scale(resource, output->scale);
4147 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4148 output->w, output->h, output->refresh);
4150 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4151 wl_output_send_done(resource);
4158 e_comp_wl_output_remove(const char *id)
4160 E_Comp_Wl_Output *output;
4162 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4165 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4167 /* wl_global_destroy(output->global); */
4169 /* eina_stringshare_del(output->id); */
4170 /* eina_stringshare_del(output->make); */
4171 /* eina_stringshare_del(output->model); */
4178 _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)
4180 struct wl_resource *res;
4182 uint32_t serial, keycode;
4183 struct wl_client *wc = NULL;
4184 E_Comp_Config *comp_conf = NULL;
4185 const char *device_name = NULL;
4187 keycode = (ev->keycode - 8);
4189 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4191 comp_conf = e_comp_config_get();
4193 if (ec && ec->comp_data)
4195 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4198 wc = wl_resource_get_client(surface);
4201 if (e_config->key_input_ttrace_enable)
4203 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4204 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4207 EINA_LIST_FOREACH(key_list, l, res)
4209 if (wl_resource_get_client(res) != wc) continue;
4211 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4212 if (!e_input_thread_mode_get())
4214 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4215 device_name = ecore_device_name_get(ev->dev);
4221 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4222 device_name = e_device_name_get(dev);
4226 if (comp_conf && comp_conf->input_log_enable)
4227 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4229 wl_keyboard_send_key(res, serial, ev->timestamp,
4234 if (e_config->key_input_ttrace_enable)
4237 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4242 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4244 E_Client *ec = NULL;
4246 E_Comp_Wl_Key_Data *end, *k;
4248 if (ev->window != e_comp->ee_win)
4253 keycode = (ev->keycode - 8);
4254 if (!(e_comp_wl = e_comp->wl_comp_data))
4259 #ifndef E_RELEASE_BUILD
4260 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4261 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4262 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4263 eina_streq(ev->key, "BackSpace"))
4269 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4271 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4273 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4275 /* ignore server-generated key repeats */
4276 if (k->key == keycode)
4278 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4283 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4285 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4287 ec = e_client_focused_get();
4288 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4289 if (ec && ec->comp_data && surface)
4291 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4292 if (e_comp_wl->kbd.focused)
4294 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4296 /* A key only sent to clients is added to the list */
4297 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4298 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4300 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4302 DBG("wl_array_add: Out of memory\n");
4303 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4304 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4307 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4311 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4315 /* update modifier state */
4316 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4322 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4324 E_Client *ec = NULL;
4325 uint32_t keycode, delivered_key;
4326 E_Comp_Wl_Key_Data *end, *k;
4328 if (ev->window != e_comp->ee_win)
4333 keycode = (ev->keycode - 8);
4335 if (!(e_comp_wl = e_comp->wl_comp_data))
4340 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4342 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4343 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4345 if (k->key == keycode)
4352 e_comp_wl->kbd.keys.size =
4353 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4355 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4357 /* 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) */
4358 if ((delivered_key) ||
4359 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4361 ec = e_client_focused_get();
4363 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4364 if (e_comp_wl->kbd.focused)
4366 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4368 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4371 /* update modifier state */
4372 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4378 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4380 Eina_Bool res = EINA_FALSE;
4382 if (type == ECORE_EVENT_KEY_DOWN)
4384 res = e_comp_wl_key_down(ev, dev);
4386 else if (type == ECORE_EVENT_KEY_UP)
4388 res = e_comp_wl_key_up(ev, dev);
4395 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4398 struct wl_client *wc;
4399 uint32_t serial, btn;
4400 struct wl_resource *res;
4401 E_Comp_Config *comp_conf = NULL;
4403 if (ec->cur_mouse_action || e_comp_wl->drag)
4405 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4406 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4410 case 1: btn = BTN_LEFT; break;
4411 case 2: btn = BTN_MIDDLE; break;
4412 case 3: btn = BTN_RIGHT; break;
4413 default: btn = button_id; break;
4416 e_comp_wl->ptr.button = btn;
4417 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4418 if (!surface) return EINA_FALSE;
4420 if (!eina_list_count(e_comp_wl->ptr.resources))
4423 wc = wl_resource_get_client(surface);
4424 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4426 comp_conf = e_comp_config_get();
4428 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4430 if (wl_resource_get_client(res) != wc) continue;
4431 if (!e_comp_wl_input_pointer_check(res)) continue;
4432 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4434 if (comp_conf && comp_conf->input_log_enable)
4435 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4437 wl_pointer_send_button(res, serial, timestamp, btn, state);
4444 e_comp_wl_touch_cancel(void)
4446 _e_comp_wl_touch_cancel();
4449 E_API E_Comp_Wl_Hook *
4450 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4454 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4455 ch = E_NEW(E_Comp_Wl_Hook, 1);
4456 if (!ch) return NULL;
4457 ch->hookpoint = hookpoint;
4459 ch->data = (void*)data;
4460 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4465 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4468 if (_e_comp_wl_hooks_walking == 0)
4470 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4474 _e_comp_wl_hooks_delete++;
4477 E_API E_Comp_Wl_Pid_Hook *
4478 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4480 E_Comp_Wl_Pid_Hook *ch;
4482 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4484 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4485 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4487 ch->hookpoint = hookpoint;
4489 ch->data = (void*)data;
4490 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4496 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4499 if (_e_comp_wl_pid_hooks_walking == 0)
4501 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4505 _e_comp_wl_pid_hooks_delete++;
4508 E_API E_Comp_Wl_Intercept_Hook *
4509 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4511 E_Comp_Wl_Intercept_Hook *ch;
4513 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4514 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4515 if (!ch) return NULL;
4516 ch->hookpoint = hookpoint;
4518 ch->data = (void*)data;
4519 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4524 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4527 if (_e_comp_wl_intercept_hooks_walking == 0)
4529 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4533 _e_comp_wl_intercept_hooks_delete++;
4537 e_comp_wl_shell_surface_ready(E_Client *ec)
4541 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4545 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4547 e_config->use_cursor_timer = !!enabled;
4549 if (e_config->use_cursor_timer)
4551 if (!e_pointer_is_hidden(e_comp->pointer))
4553 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4558 if (e_comp_wl->ptr.hide_tmr)
4560 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4561 e_comp_wl->ptr.hide_tmr = NULL;
4563 cursor_timer_ec = NULL;
4565 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4568 if (e_pointer_is_hidden(e_comp->pointer))
4570 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4576 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4578 EINA_SAFETY_ON_NULL_RETURN(wc);
4579 EINA_SAFETY_ON_NULL_RETURN(dev);
4581 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4585 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4587 EINA_SAFETY_ON_NULL_RETURN(wc);
4588 EINA_SAFETY_ON_NULL_RETURN(dev);
4590 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4594 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4596 struct wl_resource *res;
4597 struct wl_client *wc;
4599 uint32_t serial, wl_keycode;
4600 enum wl_keyboard_key_state state;
4601 E_Comp_Config *comp_conf = NULL;
4602 const char *dev_name = NULL;
4604 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4605 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4606 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4608 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4609 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4611 wl_keycode = keycode - 8;
4612 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4614 wc = wl_resource_get_client(surface);
4615 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4616 if (!time) time = e_util_timestamp_get();
4617 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4618 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4620 comp_conf = e_comp_config_get();
4621 e_keyrouter_event_surface_send(ec, keycode);
4623 if (e_config->key_input_ttrace_enable)
4625 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4626 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4629 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4630 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4632 if (wl_resource_get_client(res) != wc) continue;
4633 if (!e_input_thread_mode_get())
4637 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4638 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4642 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4649 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4650 dev_name = e_device_name_get(dev);
4654 if (comp_conf && comp_conf->input_log_enable)
4655 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4658 wl_keyboard_send_key(res, serial, time,
4661 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4663 if (e_config->key_input_ttrace_enable)
4666 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4673 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4675 struct wl_resource *res;
4676 struct wl_client *wc;
4678 uint32_t serial, wl_keycode, cancel_keycode;
4679 E_Comp_Config *comp_conf = NULL;
4680 struct xkb_keymap *keymap = NULL;
4682 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4683 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4684 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4686 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4687 keymap = e_comp_wl->xkb.keymap;
4688 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4689 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4691 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4692 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4694 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4695 if (cancel_keycode == XKB_KEYCODE_INVALID)
4697 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4700 cancel_keycode = cancel_keycode - 8;
4702 wl_keycode = keycode - 8;
4703 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4705 wc = wl_resource_get_client(surface);
4706 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4707 if (!time) time = e_util_timestamp_get();
4709 comp_conf = e_comp_config_get();
4710 e_keyrouter_event_surface_send(ec, keycode);
4712 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4713 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4715 if (wl_resource_get_client(res) != wc) continue;
4716 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4717 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4719 if (comp_conf && comp_conf->input_log_enable)
4720 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4721 wl_keyboard_send_key(res, serial, time,
4722 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4723 wl_keyboard_send_key(res, serial, time,
4724 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4725 wl_keyboard_send_key(res, serial, time,
4726 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4728 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4735 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)
4737 struct wl_client *wc;
4739 E_Devicemgr_Input_Device *device = NULL;
4741 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4742 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4743 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4745 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4746 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4748 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4750 wc = wl_resource_get_client(surface);
4751 if (!time) time = e_util_timestamp_get();
4752 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4756 _e_comp_wl_send_event_device(wc, time, dev, serial);
4757 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4761 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4762 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4765 x = x + ec->client.x;
4766 y = y + ec->client.y;
4768 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4774 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)
4776 E_Devicemgr_Input_Device *device;
4778 struct wl_client *wc;
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4781 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4782 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4784 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4785 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4787 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4789 wc = wl_resource_get_client(surface);
4790 if (!time) time = e_util_timestamp_get();
4791 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4795 _e_comp_wl_send_event_device(wc, time, dev, serial);
4796 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4800 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4801 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4804 x = x + ec->client.x;
4805 y = y + ec->client.y;
4807 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4813 e_comp_wl_touch_cancel_send(E_Client *ec)
4815 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4816 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4817 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4819 _e_comp_wl_send_touch_cancel(ec);
4825 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4828 struct wl_client *wc;
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4831 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4832 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4834 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4835 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4837 wc = wl_resource_get_client(surface);
4838 if (!time) time = e_util_timestamp_get();
4839 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4841 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4842 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4845 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4846 WL_POINTER_BUTTON_STATE_PRESSED);
4848 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4849 WL_POINTER_BUTTON_STATE_RELEASED);
4855 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4858 struct wl_client *wc;
4860 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4861 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4862 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4864 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4865 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4867 wc = wl_resource_get_client(surface);
4868 if (!time) time = e_util_timestamp_get();
4869 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4871 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4872 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4874 x = x + ec->client.x;
4875 y = y + ec->client.y;
4877 _e_comp_wl_send_mouse_move(ec, x, y, time);
4883 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4886 struct wl_client *wc;
4888 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4889 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4890 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4892 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4893 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4895 wc = wl_resource_get_client(surface);
4896 if (!time) time = e_util_timestamp_get();
4897 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4899 if (_e_comp_wl_check_cursor_timer_needed(ec))
4901 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4905 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4906 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4908 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4910 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4912 if (_e_comp_wl_check_cursor_timer_needed(ec))
4913 _e_comp_wl_cursor_move_timer_control(ec);
4920 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4923 struct wl_client *wc;
4924 struct wl_resource *res;
4927 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4928 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4930 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4931 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4933 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4934 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4936 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4937 wc = wl_resource_get_client(surface);
4938 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4939 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4941 if (!e_comp_wl_input_pointer_check(res)) continue;
4942 if (wl_resource_get_client(res) != wc) continue;
4944 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4945 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4947 wl_pointer_send_enter(res, serial, surface,
4948 wl_fixed_from_int(x),
4949 wl_fixed_from_int(y));
4950 ec->pointer_enter_sent = EINA_TRUE;
4952 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4958 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4961 struct wl_client *wc;
4962 struct wl_resource *res;
4965 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4966 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4967 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4968 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4969 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4970 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4972 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4973 wc = wl_resource_get_client(surface);
4974 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4975 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4977 if (!e_comp_wl_input_pointer_check(res)) continue;
4978 if (wl_resource_get_client(res) != wc) continue;
4980 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4981 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4983 wl_pointer_send_leave(res, serial, surface);
4984 ec->pointer_enter_sent = EINA_FALSE;
4991 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)
4993 Evas_Event_Mouse_In ev_in;
4996 if (ec->pointer_enter_sent) return;
4998 ev_in.buttons = buttons;
5006 ev_in.modifiers = modifiers;
5007 ev_in.locks = locks;
5008 ev_in.timestamp = timestamp;
5009 ev_in.event_flags = event_flags;
5012 ev_in.event_src = event_src;
5014 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5018 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)
5020 Evas_Event_Mouse_Out ev_out;
5023 if (!ec->pointer_enter_sent) return;
5025 ev_out.buttons = buttons;
5027 ev_out.output.x = x;
5028 ev_out.output.y = y;
5029 ev_out.canvas.x = x;
5030 ev_out.canvas.y = y;
5033 ev_out.modifiers = modifiers;
5034 ev_out.locks = locks;
5035 ev_out.timestamp = timestamp;
5036 ev_out.event_flags = event_flags;
5039 ev_out.event_src = event_src;
5041 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5045 e_comp_wl_cursor_hide(E_Client *ec)
5047 struct wl_resource *res;
5048 struct wl_client *wc;
5052 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5054 if (e_comp_wl->ptr.hide_tmr)
5056 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5057 e_comp_wl->ptr.hide_tmr = NULL;
5059 cursor_timer_ec = NULL;
5061 if (!ec) return EINA_FALSE;
5062 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5063 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5064 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5066 wc = wl_resource_get_client(surface);
5067 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5068 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5070 if (!e_comp_wl_input_pointer_check(res)) continue;
5071 if (wl_resource_get_client(res) != wc) continue;
5072 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5073 wl_pointer_send_leave(res, serial, surface);
5074 ec->pointer_enter_sent = EINA_FALSE;
5080 /* surface to buffer
5081 * - width : surface width
5082 * - height : surface height
5083 * - transform: buffer transform
5084 * - scale : buffer scale
5086 * - width : screen width
5087 * - height : screen height
5088 * - transform: output transform
5089 * - scale : output scale
5091 static E_Util_Transform_Matrix
5092 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5094 E_Util_Transform_Matrix m;
5096 e_util_transform_matrix_load_identity(&m);
5098 if (transform & 0x4)
5100 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5101 e_util_transform_matrix_flip_x(&m);
5102 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5105 switch (transform & 0x3)
5107 case WL_OUTPUT_TRANSFORM_90:
5108 e_util_transform_matrix_translate(&m, -width, 0, 0);
5109 e_util_transform_matrix_rotation_z(&m, 270);
5111 case WL_OUTPUT_TRANSFORM_180:
5112 e_util_transform_matrix_translate(&m, -width, -height, 0);
5113 e_util_transform_matrix_rotation_z(&m, 180);
5115 case WL_OUTPUT_TRANSFORM_270:
5116 e_util_transform_matrix_translate(&m, 0, -height, 0);
5117 e_util_transform_matrix_rotation_z(&m, 90);
5123 e_util_transform_matrix_scale(&m, scale, scale, 1);
5128 /* surface to buffer
5129 * - surface width, surface height, buffer transform, buffer scale
5131 * - screen width, screen height, output transform, output scale
5134 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5136 E_Util_Transform_Matrix m;
5137 E_Util_Transform_Vertex v;
5139 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5141 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5142 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5143 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5147 * - buffer width, buffer height, buffer transform, buffer scale
5150 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5152 E_Util_Transform_Matrix m;
5153 E_Util_Transform_Vertex v;
5156 if (transform != 0 || scale > 1)
5158 tw = ((transform % 2) ? height : width) / scale;
5159 th = ((transform % 2) ? width : height) / scale;
5167 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5168 m = e_util_transform_matrix_inverse_get(&m);
5170 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5171 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5172 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5175 /* surface to buffer
5176 * - surface width, surface height, buffer transform, buffer scale
5178 * - screen width, screen height, output transform, output scale
5181 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5182 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5184 E_Util_Transform_Matrix m;
5185 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5186 E_Util_Transform_Rect_Vertex sv;
5188 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5190 sv = e_util_transform_rect_to_vertices(&sr);
5191 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5192 sr = e_util_transform_vertices_to_rect(&sv);
5201 * - buffer width, buffer height, buffer transform, buffer scale
5204 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5205 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5207 E_Util_Transform_Matrix m;
5208 E_Util_Transform_Rect br = {bx, by, bw, bh};
5209 E_Util_Transform_Rect_Vertex bv;
5212 if (transform != 0 || scale > 1)
5214 tw = ((transform % 2) ? height : width) / scale;
5215 th = ((transform % 2) ? width : height) / scale;
5223 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5224 m = e_util_transform_matrix_inverse_get(&m);
5226 bv = e_util_transform_rect_to_vertices(&br);
5227 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5228 br = e_util_transform_vertices_to_rect(&bv);
5236 EINTERN E_Comp_Wl_Output*
5237 e_comp_wl_output_find(E_Client *ec)
5240 E_Comp_Wl_Output *output;
5242 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5244 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5246 if (output->transform % 2)
5248 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5249 ec->y < output->x || ec->y >= (output->x + output->w))
5254 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5255 ec->y < output->y || ec->y >= (output->y + output->h))
5265 EINTERN Eina_Array *
5266 e_comp_wl_output_find_all(E_Client *ec)
5268 E_Comp_Wl_Output *output;
5269 Eina_Array *outputs;
5272 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5274 outputs = eina_array_new(4);
5278 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5280 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5281 output->x, output->y, output->w, output->h))
5283 eina_array_push(outputs, output);
5287 if (eina_array_count(outputs) == 0)
5289 eina_array_free(outputs);
5296 // --------------------------------------------------------
5297 // tizen_move_resize
5298 // --------------------------------------------------------
5300 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5307 E_Client_Pending_Geometry *geo;
5310 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5311 if (ec->fullscreen || ec->maximized) goto err;
5313 geo = E_NEW(E_Client_Pending_Geometry, 1);
5316 geo->serial = serial;
5322 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5323 ec->surface_sync.wait_commit = EINA_TRUE;
5328 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5335 e_comp_wl_commit_sync_configure(E_Client *ec)
5338 E_Client_Pending_Geometry *geo;
5340 Eina_Bool match_size = EINA_FALSE;
5347 if (!ec || !ec->frame) goto ret;
5348 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5351 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5352 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5354 if (eina_list_count(ec->surface_sync.pending_geometry))
5356 Eina_List *ll = NULL;
5357 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5361 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5366 if ((geo->w == bw) && (geo->h == bh))
5368 match_size = EINA_TRUE;
5373 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5380 if ((config.w != ec->w) || (config.h != ec->h))
5382 e_client_size_set(ec, config.w, config.h);
5383 ec->changes.size = EINA_TRUE;
5387 // FIXME: The geometry of the client would be better to be calculated
5388 // at e_desk or at e_desk_area. So the position(x,y) of the client
5389 // should be calcuated at the e_desk or at the e_desk_area.
5391 desk = e_comp_desk_find_by_ec(ec);
5394 ec->client.x = desk->geom.x + config.x;
5395 ec->client.y = desk->geom.y + config.y;
5399 ec->client.x = config.x;
5400 ec->client.y = config.y;
5403 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5405 e_client_pos_set(ec, ec->client.x, ec->client.y);
5407 ec->changes.pos = 1;
5411 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5415 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5416 ec->surface_sync.wait_commit = EINA_FALSE;
5418 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5420 // rollback wait_commit if there are pending requests remained
5421 if (eina_list_count(ec->surface_sync.pending_geometry))
5422 ec->surface_sync.wait_commit = EINA_TRUE;
5427 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);
5434 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5435 struct wl_resource *res_moveresize)
5437 wl_resource_destroy(res_moveresize);
5441 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5442 struct wl_resource *res_moveresize,
5443 struct wl_resource *surface,
5450 /* to be implemented */
5453 int cur_w = 0, cur_h = 0;
5455 ec = e_client_from_surface_resource(surface);
5458 pending = e_client_pending_geometry_has(ec);
5459 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5460 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);
5464 if ((cur_w == w) && (cur_h == h))
5466 e_client_pos_set(ec, x, y);
5467 ec->changes.pos = 1;
5473 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5477 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5480 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5482 _tz_move_resize_iface_cb_destroy,
5483 _tz_move_resize_iface_cb_set_geometry,
5487 _tz_moveresize_cb_bind(struct wl_client *client,
5488 void *data EINA_UNUSED,
5492 struct wl_resource *res_moveresize;
5494 res_moveresize = wl_resource_create(client,
5495 &tizen_move_resize_interface,
5498 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5501 wl_resource_set_implementation(res_moveresize,
5502 &_tz_move_resize_iface,
5508 ERR("Could not create tizen_move_resize_interface res: %m");
5509 wl_client_post_no_memory(client);
5513 _e_comp_wl_move_resize_init(void)
5515 if (!e_comp_wl) return;
5516 if (!e_comp_wl->wl.disp) return;
5518 if (!wl_global_create(e_comp_wl->wl.disp,
5519 &tizen_move_resize_interface,
5522 _tz_moveresize_cb_bind))
5524 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5531 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5533 E_Comp_Wl_Output *output;
5534 pid_t output_pid = 0;
5535 Eina_List *l = NULL, *l2 = NULL;
5536 struct wl_resource *resource = NULL;
5538 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5540 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5541 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5542 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5544 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5546 /* if we have bound resources, send updates */
5547 EINA_LIST_FOREACH(output->resources, l2, resource)
5549 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5550 if (output_pid != pid) continue;
5552 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5554 // send output information to the client
5555 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5563 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5565 _e_comp_wl_surface_state_init(state, w, h);
5569 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5571 _e_comp_wl_surface_state_commit(ec, state);
5575 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5577 _e_comp_wl_hook_call(hookpoint, ec);
5581 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5583 _e_comp_wl_surface_state_finish(state);
5587 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5589 _e_comp_wl_surface_state_buffer_set(state, buffer);
5593 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5594 int sx, int sy, int *dx, int *dy)
5598 case WL_OUTPUT_TRANSFORM_NORMAL:
5602 case WL_OUTPUT_TRANSFORM_FLIPPED:
5603 *dx = width - sx, *dy = sy;
5605 case WL_OUTPUT_TRANSFORM_90:
5606 *dx = height - sy, *dy = sx;
5608 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5609 *dx = height - sy, *dy = width - sx;
5611 case WL_OUTPUT_TRANSFORM_180:
5612 *dx = width - sx, *dy = height - sy;
5614 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5615 *dx = sx, *dy = height - sy;
5617 case WL_OUTPUT_TRANSFORM_270:
5618 *dx = sy, *dy = width - sx;
5620 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5630 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5633 int tx1, ty1, tx2, ty2;
5634 int width_from_buffer, height_from_buffer;
5636 switch (vp->buffer.transform)
5638 case WL_OUTPUT_TRANSFORM_90:
5639 case WL_OUTPUT_TRANSFORM_270:
5640 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5641 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5642 width_from_buffer = bh / vp->buffer.scale;
5643 height_from_buffer = bw / vp->buffer.scale;
5646 width_from_buffer = bw / vp->buffer.scale;
5647 height_from_buffer = bh / vp->buffer.scale;
5651 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5655 x2 = width_from_buffer;
5656 y2 = height_from_buffer;
5660 x1 = wl_fixed_to_int(vp->buffer.src_x);
5661 y1 = wl_fixed_to_int(vp->buffer.src_y);
5662 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5663 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5666 buffer_transform(width_from_buffer, height_from_buffer,
5667 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5668 buffer_transform(width_from_buffer, height_from_buffer,
5669 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5671 out->x = (tx1 <= tx2) ? tx1 : tx2;
5672 out->y = (ty1 <= ty2) ? ty1 : ty2;
5673 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5674 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5678 * Convert given four coordinates to elements of rectangle
5679 * @in p[4] Coordinates to be converted
5680 * @out rect x, y, width, and height
5681 * transform Angle which represents TDM_TRANSFORM of rectangle
5682 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5683 * 1. The given coordinates are not represented by rectangle.
5684 * 2. All angles except for 0, 90, 180, 270.
5687 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5689 Eina_Bool ret = EINA_FALSE;
5691 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))
5694 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5697 *rotation = TDM_TRANSFORM_NORMAL;
5700 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5704 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5707 *rotation = TDM_TRANSFORM_180;
5710 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5715 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))
5718 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5721 *rotation = TDM_TRANSFORM_90;
5724 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5728 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5731 *rotation = TDM_TRANSFORM_270;
5734 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5744 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5749 for (i = 0; i < 4; i++)
5750 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5752 if (!_coords_to_rectangle_convert(p, out, rotation))
5754 DBG("Cannot convert given coords to rectangle.\n"
5755 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5756 p[0].x, p[0].y, p[1].x, p[1].y,
5757 p[2].x, p[2].y, p[3].x, p[3].y);
5765 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5767 int trans_rotation, flip;
5769 trans_rotation = transform & 0x3;
5770 flip = transform & 0x4;
5772 return (flip + (trans_rotation + rotation) % 4);
5776 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5784 if (e_comp_wl_subsurface_check(ec))
5785 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5792 out->w = ec->comp_data->width_from_viewport;
5793 out->w = (out->w + 1) & ~1;
5794 out->h = ec->comp_data->height_from_viewport;
5796 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5797 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5801 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5803 E_Comp_Wl_Buffer *buffer;
5804 E_Comp_Wl_Buffer_Viewport *vp;
5806 enum wl_output_transform buffer_transform;
5807 unsigned int rotation;
5808 Eina_Bool res = EINA_FALSE;
5810 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5812 if (e_object_is_del(E_OBJECT(ec)))
5815 vp = &ec->comp_data->scaler.buffer_viewport;
5817 if (buffer_viewport)
5819 buffer = ec->comp_data->buffer_ref.buffer;
5820 /* Getting a viewport of buffer needs geometry of buffer. */
5824 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5827 if ((output_viewport) || (transform))
5829 m = e_client_map_get(ec);
5831 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5833 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5838 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5839 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5840 * Since buffer.transform isn't applied using evas_map,
5841 * it has to be taken into account here to apply buffer.transform
5842 * and rotation of e_client_transform together. */
5844 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5846 *transform = (unsigned int)buffer_transform;
5854 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5856 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5857 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5859 /* Must be called with valid comp_data */
5860 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5862 if ((ec->comp_data->role_name == NULL) ||
5863 (ec->comp_data->role_name == role_name) ||
5864 (strcmp(ec->comp_data->role_name, role_name) == 0))
5866 ec->comp_data->role_name = role_name;
5872 wl_resource_post_error(error_resource, error_code,
5873 "Cannot assign role %s to wl_surface@%d,"
5874 " already has role %s\n",
5876 ec->comp_data->wl_surface ?
5877 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5878 ec->comp_data->role_name);
5884 EINTERN const char *
5885 e_comp_wl_surface_role_get(E_Client *ec)
5887 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5888 return ec->comp_data ? ec->comp_data->role_name : NULL;
5891 EINTERN struct wl_resource *
5892 e_comp_wl_client_surface_get(E_Client *ec)
5894 struct wl_resource *surface = NULL;
5895 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5896 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5898 g_mutex_lock(&ec->comp_data->surface_mutex);
5899 surface = ec->comp_data->surface;
5900 g_mutex_unlock(&ec->comp_data->surface_mutex);
5905 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5907 EINA_SAFETY_ON_NULL_RETURN(ec);
5908 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5910 g_mutex_lock(&ec->comp_data->surface_mutex);
5911 ec->comp_data->surface = surface;
5912 g_mutex_unlock(&ec->comp_data->surface_mutex);
5916 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5918 return e_compositor_util_client_from_surface_resource(surface_resource);
5922 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5924 if (!ec->comp_data->mapped)
5926 if (ec->comp_data->shell.surface &&
5927 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5929 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5935 if (ec->comp_data->mapped)
5937 /* will be unmapped. so run capture */
5938 e_comp_wl_remote_surface_image_save(ec);
5942 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5944 ec->comp_data->pending.sx = sx;
5945 ec->comp_data->pending.sy = sy;
5946 ec->comp_data->pending.new_attach = EINA_TRUE;
5948 e_client_fps_update(ec);
5952 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5954 if (ec->comp_data->pending.opaque)
5955 eina_tiler_clear(ec->comp_data->pending.opaque);
5959 eina_tiler_union(ec->comp_data->pending.opaque, region);
5961 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5965 ec->argb = EINA_FALSE;
5966 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5968 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5969 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5977 ec->argb = EINA_TRUE;
5978 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5980 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5981 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5987 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5989 if (ec->comp_data->pending.input)
5990 eina_tiler_clear(ec->comp_data->pending.input);
5994 if (eina_tiler_empty(region))
5996 ELOGF("COMP", " |unset input rect", NULL);
5997 e_comp_object_input_objs_del(ec->frame);
5998 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6001 eina_tiler_union(ec->comp_data->pending.input, region);
6005 eina_tiler_rect_add(ec->comp_data->pending.input,
6006 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6011 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6013 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6017 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6019 E_Comp_Wl_Subsurf_Data *sdata;
6024 if (ec->comp_data->frames)
6026 ec->comp_data->frames =
6027 eina_list_remove(ec->comp_data->frames, callback_resource);
6030 if (ec->comp_data->pending.frames)
6032 ec->comp_data->pending.frames =
6033 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6036 sdata = ec->comp_data->sub.data;
6037 if ((sdata) && (sdata->cached.frames))
6039 sdata->cached.frames =
6040 eina_list_remove(sdata->cached.frames, callback_resource);
6045 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6047 if (e_object_is_del(E_OBJECT(ec))) return;
6049 if (e_comp_wl_remote_surface_commit(ec)) return;
6051 e_comp_wl_surface_commit(ec);
6053 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6057 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6059 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6060 ec->comp_data->sub.data = sub;
6062 /* set subsurface client properties */
6063 ec->borderless = EINA_TRUE;
6064 ec->argb = EINA_TRUE;
6065 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6066 ec->lock_border = EINA_TRUE;
6067 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6068 ec->netwm.state.skip_taskbar = EINA_TRUE;
6069 ec->netwm.state.skip_pager = EINA_TRUE;
6070 ec->border_size = 0;
6071 ec->lock_user_location = 0;
6072 ec->lock_client_location = 0;
6073 ec->lock_user_size = 0;
6074 ec->lock_client_size = 0;
6075 ec->lock_client_stacking = 0;
6076 ec->lock_user_maximize = 0;
6077 ec->lock_client_maximize = 0;
6078 ec->changes.need_maximize = 0;
6079 ec->maximized = E_MAXIMIZE_NONE;
6082 ec->new_client = ec->netwm.ping = EINA_TRUE;
6083 e_comp->new_clients++;
6084 e_client_unignore(ec);
6086 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6087 * It's not for subsurface. */
6088 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6092 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6094 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6097 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6099 sub->parent = parent;
6103 layer = e_client_layer_get(parent);
6104 if (layer > E_LAYER_BOTTOM)
6105 e_client_layer_set(ec, layer);
6108 if (parent->comp_data)
6110 /* append this client to the parents subsurface list */
6111 parent->comp_data->sub.list_pending =
6112 eina_list_append(parent->comp_data->sub.list_pending, ec);
6113 parent->comp_data->sub.list_changed = EINA_TRUE;
6118 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6120 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6121 E_Client *parent = sub->parent;
6123 parent->comp_data->sub.list =
6124 eina_list_remove(parent->comp_data->sub.list, ec);
6125 parent->comp_data->sub.list_pending =
6126 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6127 parent->comp_data->sub.below_list =
6128 eina_list_remove(parent->comp_data->sub.below_list, ec);
6129 parent->comp_data->sub.below_list_pending =
6130 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6136 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)
6138 sub->resource = subsurface_resource;
6139 sub->cached_buffer_ref.buffer = NULL;
6140 sub->synchronized = EINA_TRUE;
6141 sub->parent = parent;
6142 sub->remote_surface.offscreen_parent = offscreen_parent;
6143 if (offscreen_parent)
6144 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6146 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6148 _e_comp_wl_client_subsurface_set(ec, sub);
6149 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6151 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6155 e_comp_wl_client_subsurface_finish(E_Client *ec)
6157 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6160 e_comp_wl_client_subsurface_parent_unset(ec);
6162 e_comp_wl_surface_state_finish(&sub->cached);
6163 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6165 ec->comp_data->sub.data = NULL;
6169 e_comp_wl_client_evas_init(E_Client *ec)
6171 EINA_SAFETY_ON_NULL_RETURN(ec);
6173 _e_comp_wl_client_evas_init(ec);
6177 e_comp_wl_client_evas_deinit(E_Client *ec)
6179 EINA_SAFETY_ON_NULL_RETURN(ec);
6181 _e_comp_wl_client_evas_deinit(ec);
6185 e_comp_wl_focus_check(void)
6187 _e_comp_wl_focus_check();
6191 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6198 if ((parent->comp_data) && (parent->comp_data->sub.data))
6199 parent = parent->comp_data->sub.data->parent;