3 #include "e_wtz_shell.h"
4 #include "e_comp_wl_private.h"
5 #include "e_client_intern.h"
6 #include <tizen-extension-server-protocol.h>
8 #include <relative-pointer-unstable-v1-server-protocol.h>
9 #include <pointer-constraints-unstable-v1-server-protocol.h>
11 #include <wayland-tbm-server.h>
14 #include <libds/log.h>
15 #include <libds/single_pixel_buffer_v1.h>
17 /* handle include for printing uint64_t */
18 #define __STDC_FORMAT_MACROS
21 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
23 /* Resource Data Mapping: (wl_resource_get_user_data)
25 * wl_surface == e_pixmap
26 * wl_region == eina_tiler
27 * wl_subsurface == e_client
31 typedef struct _E_Comp_Data E_Comp_Data;
36 struct wl_listener client_created;
39 static void _e_comp_wl_move_resize_init(void);
41 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
44 typedef struct _E_Comp_Wl_Key_Data
50 static Eina_List *handlers = NULL;
51 static E_Client *cursor_timer_ec = NULL;
52 static Eina_Bool need_send_released = EINA_FALSE;
53 static Eina_Bool need_send_motion = EINA_TRUE;
55 static GMutex connection_mutex;
57 static int _e_comp_wl_hooks_delete = 0;
58 static int _e_comp_wl_hooks_walking = 0;
60 static int _e_comp_wl_pid_hooks_delete = 0;
61 static int _e_comp_wl_pid_hooks_walking = 0;
63 static int _e_comp_wl_intercept_hooks_delete = 0;
64 static int _e_comp_wl_intercept_hooks_walking = 0;
66 static Eina_Inlist *_e_comp_wl_hooks[] =
68 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
69 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
70 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
71 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
72 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
73 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
74 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
75 [E_COMP_WL_HOOK_DEL] = NULL,
76 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
77 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
78 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
81 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
83 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
86 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
88 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
89 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
90 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
91 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
92 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
93 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
96 static Eina_List *hooks = NULL;
100 _e_comp_wl_hooks_clean(void)
105 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
106 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
108 if (!ch->delete_me) continue;
109 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
115 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
119 e_object_ref(E_OBJECT(ec));
120 _e_comp_wl_hooks_walking++;
121 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
123 if (ch->delete_me) continue;
124 ch->func(ch->data, ec);
125 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
126 (e_object_is_del(E_OBJECT(ec))))
129 _e_comp_wl_hooks_walking--;
130 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
131 _e_comp_wl_hooks_clean();
132 e_object_unref(E_OBJECT(ec));
136 _e_comp_wl_pid_hooks_clean(void)
139 E_Comp_Wl_Pid_Hook *ch;
141 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
142 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
144 if (!ch->delete_me) continue;
145 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
151 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
153 E_Comp_Wl_Pid_Hook *ch;
155 _e_comp_wl_pid_hooks_walking++;
156 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
158 if (ch->delete_me) continue;
159 ch->func(ch->data, pid);
161 _e_comp_wl_pid_hooks_walking--;
162 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
163 _e_comp_wl_pid_hooks_clean();
167 _e_comp_wl_intercept_hooks_clean(void)
170 E_Comp_Wl_Intercept_Hook *ch;
172 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
173 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
175 if (!ch->delete_me) continue;
176 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
182 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
184 E_Comp_Wl_Intercept_Hook *ch;
185 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
187 e_object_ref(E_OBJECT(ec));
188 _e_comp_wl_intercept_hooks_walking++;
189 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
191 if (ch->delete_me) continue;
192 res = ch->func(ch->data, ec);
193 if (!res) ret = EINA_FALSE;
194 if (e_object_is_del(E_OBJECT(ec)))
197 _e_comp_wl_intercept_hooks_walking--;
198 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
199 _e_comp_wl_intercept_hooks_clean();
200 e_object_unref(E_OBJECT(ec));
207 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
213 if (e_comp_object_frame_exists(ec->frame))
214 w = ec->client.w, h = ec->client.h;
216 w = ec->w, h = ec->h;
220 // Width and Height are -1 means that we don't consider size value
224 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
228 _e_comp_wl_focus_check(void)
232 if (stopping) return;
233 ec = e_client_focused_get();
235 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
239 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
241 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
243 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
244 IDLE_EXITER~CB_PREPARE);
246 return ECORE_CALLBACK_RENEW;
250 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
252 /* dispatch pending wayland events */
253 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
255 return ECORE_CALLBACK_RENEW;
259 e_comp_wl_display_flush()
261 if (e_comp_wl && e_comp_wl->wl.disp)
263 if (e_config->key_input_ttrace_enable)
265 TRACE_INPUT_BEGIN(wl_display_flush_clients);
266 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
269 g_mutex_lock(&connection_mutex);
270 wl_display_flush_clients(e_comp_wl->wl.disp);
271 g_mutex_unlock(&connection_mutex);
273 if (e_config->key_input_ttrace_enable)
276 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
282 e_comp_wl_connection_lock()
284 e_input_boost_lock(&connection_mutex);
288 e_comp_wl_connection_unlock()
290 e_input_boost_unlock(&connection_mutex);
294 e_comp_wl_focused_client_flush()
296 E_Client *focused_ec;
297 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
299 e_input_boost_lock(&connection_mutex);
300 focused_ec = e_client_focused_get();
304 struct wl_client *wc;
305 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
308 e_input_boost_unlock(&connection_mutex);
312 wc = wl_resource_get_client(surface);
316 e_input_boost_unlock(&connection_mutex);
320 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
324 if (e_comp_wl->idle_exiter_timestamp > 0.0)
326 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
327 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
329 ELOGF("E_COMP", "prepare gap time: %lfms",
334 e_comp_wl->idle_exiter_timestamp = 0.0;
336 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
338 /* flush pending client events */
339 e_comp_wl_display_flush();
341 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
342 IDLE_EXITER~CB_PREPARE);
345 E_API enum wl_output_transform
346 e_comp_wl_output_buffer_transform_get(E_Client *ec)
348 E_Comp_Wl_Buffer_Viewport *vp;
349 E_Comp_Wl_Buffer *buffer;
350 enum wl_output_transform transform, rotation;
352 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
353 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
354 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
356 vp = &ec->comp_data->scaler.buffer_viewport;
357 if (e_comp_wl_subsurface_check(ec))
358 return vp->buffer.transform;
360 buffer = ec->comp_data->buffer_ref.buffer;
363 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
364 return vp->buffer.transform;
366 rotation = buffer->transform;
368 return vp->buffer.transform;
370 /* ignore the flip value when calculating transform because the screen rotation
371 * functionality doesn't consider the flip output transform currently
373 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
375 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
376 ec, rotation, vp->buffer.transform, transform);
381 EINTERN enum wl_output_transform
382 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
384 E_Comp_Wl_Buffer_Viewport *vp;
385 E_Comp_Wl_Buffer *buffer;
386 enum wl_output_transform transform, rotation;
388 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
389 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
390 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
392 vp = &ec->comp_data->pending.buffer_viewport;
393 if (e_comp_wl_subsurface_check(ec))
394 return vp->buffer.transform;
396 buffer = ec->comp_data->pending.buffer;
399 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
400 return vp->buffer.transform;
402 rotation = buffer->transform;
404 return vp->buffer.transform;
406 /* ignore the flip value when calculating transform because the screen rotation
407 * functionality doesn't consider the flip output transform currently
409 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
411 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
412 ec, rotation, vp->buffer.transform, transform);
418 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
420 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
421 E_Comp_Wl_Buffer *buffer;
422 int32_t width, height;
424 buffer = e_pixmap_resource_get(ec->pixmap);
427 ec->comp_data->width_from_buffer = 0;
428 ec->comp_data->height_from_buffer = 0;
432 switch (e_comp_wl_output_buffer_transform_get(ec))
434 case WL_OUTPUT_TRANSFORM_90:
435 case WL_OUTPUT_TRANSFORM_270:
436 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
437 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
438 width = buffer->h / vp->buffer.scale;
439 height = buffer->w / vp->buffer.scale;
442 width = buffer->w / vp->buffer.scale;
443 height = buffer->h / vp->buffer.scale;
447 ec->comp_data->width_from_buffer = width;
448 ec->comp_data->height_from_buffer = height;
452 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
454 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
455 int32_t width, height;
457 width = ec->comp_data->width_from_buffer;
458 height = ec->comp_data->height_from_buffer;
460 if (width == 0 && height == 0) return;
462 if (width != 0 && vp->surface.width != -1)
464 ec->comp_data->width_from_viewport = vp->surface.width;
465 ec->comp_data->height_from_viewport = vp->surface.height;
469 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
471 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
472 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
473 ec->comp_data->width_from_viewport = w ?: 1;
474 ec->comp_data->height_from_viewport = h ?: 1;
478 ec->comp_data->width_from_viewport = width;
479 ec->comp_data->height_from_viewport = height;
483 e_comp_wl_topmost_parent_get(E_Client *ec)
487 if (!e_comp_wl_subsurface_check(ec))
490 parent = e_comp_wl_subsurface_parent_get(ec);
493 if (!e_comp_wl_subsurface_check(parent))
496 parent = e_comp_wl_subsurface_parent_get(parent);
503 e_comp_wl_map_apply(E_Client *ec)
505 E_Comp_Wl_Buffer_Viewport *vp;
506 E_Comp_Wl_Subsurf_Data *sdata;
507 E_Comp_Wl_Client_Data *cdata;
508 int x1, y1, x2, y2, x, y;
510 Eina_Bool zoom_animating = EINA_FALSE;
512 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
514 e_comp_object_map_update(ec->frame);
516 cdata = ec->comp_data;
517 vp = &cdata->scaler.buffer_viewport;
518 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
519 (!cdata->viewport_transform))
522 if (e_comp_wl_subsurface_check(ec))
524 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
526 sdata = ec->comp_data->sub.data;
527 if (sdata->remote_surface.offscreen_parent)
529 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
530 Eina_Rectangle *rect;
533 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
535 /* TODO: If there are one more regions, it means that provider's offscreen
536 * is displayed by one more remote_surfaces. Have to consider it later. At
537 * this time, just consider only one remote_surface.
551 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
552 if (x != dx || y != dy)
553 evas_object_move(ec->frame, dx, dy);
555 if (!cdata->viewport_transform)
557 cdata->viewport_transform = e_util_transform_new();
558 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
559 e_client_transform_core_add(ec, cdata->viewport_transform);
562 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
563 ec->comp_data->width_from_viewport,
564 ec->comp_data->height_from_viewport);
566 if (vp->buffer.src_width == wl_fixed_from_int(-1))
570 x2 = cdata->width_from_buffer;
571 y2 = cdata->height_from_buffer;
575 x1 = wl_fixed_to_int(vp->buffer.src_x);
576 y1 = wl_fixed_to_int(vp->buffer.src_y);
577 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
578 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
581 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
582 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
583 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
584 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
587 desk = e_comp_desk_find_by_ec(ec);
589 zoom_animating = e_desk_zoom_is_animating(desk);
591 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
592 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
593 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
595 /* workaround:: when the desk zoom is doing their animation,
596 the transform core update can override animation's zoom boundary.
597 so, don't doing transform core update while desk zoom animation */
599 e_client_transform_core_update(ec);
604 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
608 int map_c = 0, map_x = 0, map_y = 0;
609 double inv_x = 0.0, inv_y = 0.0;
611 EINA_SAFETY_ON_NULL_RETURN(ec);
613 map = e_client_map_get(ec);
614 map_c = e_map_count_get(map);
616 if (!map || map_c <= 0)
626 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
627 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
628 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
629 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
631 for (int i = 0; i < map_c; i++)
633 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
634 e_map_point_image_uv_set(map2, i, map_x, map_y);
636 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
646 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
652 if (!(ec = data)) return;
653 if (e_object_is_del(data)) return;
655 if (!ec->override) e_hints_window_visible_set(ec);
657 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
658 (!ec->comp_data->need_reparent))
660 ec->comp_data->need_reparent = EINA_TRUE;
661 ec->visible = EINA_TRUE;
663 if (!e_client_util_ignored_get(ec))
665 ec->take_focus = !starting;
669 if (!ec->comp_data->need_reparent)
671 if ((ec->hidden) || (ec->iconic))
673 evas_object_hide(ec->frame);
674 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
677 evas_object_show(ec->frame);
680 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
681 evas_object_show(tmp->frame);
683 topmost = e_comp_wl_topmost_parent_get(ec);
684 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
685 e_comp_wl_subsurface_show(ec);
687 if (ec->comp_data->sub.below_obj)
688 evas_object_show(ec->comp_data->sub.below_obj);
692 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
698 if (!(ec = data)) return;
699 if (e_object_is_del(E_OBJECT(ec))) return;
701 /* Uncommonly some clients's final buffer can be skipped if the client
702 * requests unmap of its surface right after wl_surface@commit.
703 * So if this client evas object is hidden state and client is already
704 * unmmapped, we can consider to clear pixmap image here mandatorily.
706 if (!ec->comp_data->mapped)
707 e_pixmap_image_clear(ec->pixmap, 1);
709 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
710 evas_object_hide(tmp->frame);
712 topmost = e_comp_wl_topmost_parent_get(ec);
713 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
714 e_comp_wl_subsurface_hide(ec);
716 if (ec->comp_data->sub.below_obj)
717 evas_object_hide(ec->comp_data->sub.below_obj);
719 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
723 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
730 if (!(ec = data)) return;
731 if (e_object_is_del(E_OBJECT(ec))) return;
733 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
735 if (!e_comp_wl_subsurface_check(subc)) continue;
736 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
737 evas_object_move(subc->frame, x, y);
739 if (subc->comp_data->scaler.viewport)
741 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
742 if (cdata->viewport_transform)
743 e_comp_wl_map_apply(subc);
747 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
749 if (!e_comp_wl_subsurface_check(subc)) continue;
750 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
751 evas_object_move(subc->frame, x, y);
753 if (subc->comp_data->scaler.viewport)
755 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
756 if (cdata->viewport_transform)
757 e_comp_wl_map_apply(subc);
761 if (ec->comp_data->sub.below_obj)
763 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
764 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
769 _e_comp_wl_send_touch_cancel(E_Client *ec)
772 struct wl_resource *res;
773 struct wl_client *wc;
774 E_Comp_Config *comp_conf = NULL;
777 if (e_object_is_del(E_OBJECT(ec))) return;
778 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
780 if (!surface) return;
781 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
783 wc = wl_resource_get_client(surface);
785 comp_conf = e_comp_config_get();
787 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
789 if (wl_resource_get_client(res) != wc) continue;
790 if (!e_comp_wl_input_touch_check(res)) continue;
792 if (comp_conf && comp_conf->input_log_enable)
793 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
795 wl_touch_send_cancel(res);
800 _e_comp_wl_touch_cancel(void)
804 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
806 if (!e_comp_wl->touch.pressed) return;
808 _e_comp_wl_send_touch_cancel(ec);
811 static E_Devicemgr_Input_Device *
812 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
814 E_Devicemgr_Input_Device *last_kbd = NULL;
817 case ECORE_DEVICE_CLASS_MOUSE:
818 return e_devicemgr->last_device_ptr;
819 case ECORE_DEVICE_CLASS_KEYBOARD:
820 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
822 case ECORE_DEVICE_CLASS_TOUCH:
823 return e_devicemgr->last_device_touch;
831 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
835 case ECORE_DEVICE_CLASS_MOUSE:
836 e_devicemgr->last_device_ptr = device;
838 case ECORE_DEVICE_CLASS_KEYBOARD:
839 atomic_store(&e_devicemgr->last_device_kbd, device);
841 case ECORE_DEVICE_CLASS_TOUCH:
842 e_devicemgr->last_device_touch = device;
849 static E_Devicemgr_Input_Device *
850 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
852 E_Devicemgr_Input_Device *last_kbd = NULL;
856 case ECORE_DEVICE_CLASS_MOUSE:
857 return ec->comp_data->last_device_ptr;
858 case ECORE_DEVICE_CLASS_KEYBOARD:
859 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
861 case ECORE_DEVICE_CLASS_TOUCH:
862 return ec->comp_data->last_device_touch;
870 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
874 case ECORE_DEVICE_CLASS_MOUSE:
875 ec->comp_data->last_device_ptr = device;
877 case ECORE_DEVICE_CLASS_KEYBOARD:
878 atomic_store(&ec->comp_data->last_device_kbd, device);
880 case ECORE_DEVICE_CLASS_TOUCH:
881 ec->comp_data->last_device_touch = device;
889 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
891 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
892 struct wl_resource *dev_res;
893 const char *dev_name;
894 Ecore_Device_Class dev_class;
895 struct wl_client *wc;
899 EINA_SAFETY_ON_NULL_RETURN(dev);
902 if (ec->cur_mouse_action || e_comp_wl->drag)
904 if (e_object_is_del(E_OBJECT(ec))) return;
905 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
906 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
907 if (!surface) return;
909 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
910 dev_name = evas_device_description_get(dev);
911 last_device = _e_comp_wl_device_last_device_get(dev_class);
912 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
914 serial = wl_display_next_serial(e_comp_wl->wl.disp);
915 wc = wl_resource_get_client(surface);
916 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
917 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
919 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
920 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
922 _e_comp_wl_device_last_device_set(dev_class, input_dev);
923 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
925 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
927 if (wl_resource_get_client(dev_res) != wc) continue;
928 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
932 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
936 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
938 E_Devicemgr_Input_Device *last_device;
939 struct wl_resource *dev_res;
940 struct wl_client *wc;
944 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
945 if (!surface) return;
947 last_device = _e_comp_wl_device_last_device_get(dev_class);
948 if (!last_device) return;
950 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
952 serial = wl_display_next_serial(e_comp_wl->wl.disp);
953 wc = wl_resource_get_client(surface);
954 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
956 if (wl_resource_get_client(dev_res) != wc) continue;
957 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
962 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
964 E_Devicemgr_Input_Device *input_dev;
965 struct wl_resource *dev_res;
966 const char *dev_name;
969 EINA_SAFETY_ON_NULL_RETURN(dev);
971 dev_name = ecore_device_identifier_get(dev);
973 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
974 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
976 if (!eina_streq(input_dev->identifier, dev_name) ||
977 (input_dev->clas != ecore_device_class_get(dev))) continue;
978 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
980 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
982 if (wl_resource_get_client(dev_res) != wc) continue;
983 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
986 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
990 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
992 E_Devicemgr_Input_Device *input_dev;
993 struct wl_resource *dev_res;
994 const char *dev_name;
997 EINA_SAFETY_ON_NULL_RETURN(dev);
999 dev_name = e_device_identifier_get(dev);
1001 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1002 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1004 if (!eina_streq(input_dev->identifier, dev_name) ||
1005 (input_dev->clas != e_device_class_get(dev))) continue;
1006 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1008 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1010 if (wl_resource_get_client(dev_res) != wc) continue;
1011 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1014 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1018 _e_comp_wl_cursor_reload(E_Client *ec)
1020 struct wl_resource *res;
1021 struct wl_client *wc;
1027 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1028 !evas_object_visible_get(e_comp->pointer->o_ptr))
1029 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1032 if (e_object_is_del(E_OBJECT(ec))) return;
1033 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1034 if (!surface) return;
1035 if (ec->pointer_enter_sent) return;
1037 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1038 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1040 if (e_client_transform_core_enable_get(ec))
1042 double dx = 0.0, dy = 0.0;
1043 map = e_client_map_get(ec);
1044 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1050 cx = px - ec->client.x;
1051 cy = py - ec->client.y;
1053 wc = wl_resource_get_client(surface);
1054 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1055 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1057 if (!e_comp_wl_input_pointer_check(res)) continue;
1058 if (wl_resource_get_client(res) != wc) continue;
1059 wl_pointer_send_enter(res, serial, surface,
1060 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1061 ec->pointer_enter_sent = EINA_TRUE;
1063 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1067 _e_comp_wl_cursor_timer(void *data)
1069 E_Client *ec = data;
1071 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1072 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1074 e_comp_wl_cursor_hide(ec);
1076 return ECORE_CALLBACK_CANCEL;
1080 _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)
1082 E_Devicemgr_Input_Device *input_dev;
1083 struct wl_resource *dev_res;
1084 struct wl_client *wc;
1089 if (ec->cur_mouse_action) return;
1090 if (e_object_is_del(E_OBJECT(ec))) return;
1091 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1092 if (!surface) return;
1094 f_value = wl_fixed_from_double(value);
1095 wc = wl_resource_get_client(surface);
1097 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1098 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1100 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1101 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1103 if (wl_resource_get_client(dev_res) != wc) continue;
1104 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1107 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1111 _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)
1113 if (idx >= e_input_touch_max_count_get()) return;
1115 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1116 e_devicemgr->multi[idx].radius_x = radius_x;
1117 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1118 e_devicemgr->multi[idx].radius_y = radius_y;
1119 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1120 e_devicemgr->multi[idx].pressure = pressure;
1121 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1122 e_devicemgr->multi[idx].angle = angle;
1126 _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)
1128 if (idx >= e_input_touch_max_count_get()) return;
1130 if (e_devicemgr->multi[idx].radius_x != radius_x)
1132 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1133 e_devicemgr->multi[idx].radius_x = radius_x;
1135 if (e_devicemgr->multi[idx].radius_y != radius_y)
1137 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1138 e_devicemgr->multi[idx].radius_y = radius_y;
1140 if (e_devicemgr->multi[idx].pressure != pressure)
1142 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1143 e_devicemgr->multi[idx].pressure = pressure;
1145 if (e_devicemgr->multi[idx].angle != angle)
1147 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1148 e_devicemgr->multi[idx].angle = angle;
1153 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1155 Eina_Bool ret = EINA_TRUE;
1158 case EVAS_CALLBACK_MOUSE_IN:
1159 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1162 if (e_comp_wl->ptr.hide_tmr)
1164 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1165 cursor_timer_ec = ec;
1166 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1170 if (e_pointer_is_hidden(e_comp->pointer))
1175 case EVAS_CALLBACK_MOUSE_OUT:
1176 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1179 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1183 case EVAS_CALLBACK_MOUSE_MOVE:
1184 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1187 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1188 _e_comp_wl_cursor_reload(ec);
1191 case EVAS_CALLBACK_MOUSE_WHEEL:
1192 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1195 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1196 _e_comp_wl_cursor_reload(ec);
1199 case EVAS_CALLBACK_MOUSE_DOWN:
1200 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1203 if (e_comp_wl->ptr.hide_tmr)
1205 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1206 e_comp_wl->ptr.hide_tmr = NULL;
1208 cursor_timer_ec = NULL;
1210 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1211 _e_comp_wl_cursor_reload(ec);
1214 case EVAS_CALLBACK_MOUSE_UP:
1215 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1226 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1228 if (ec->has_cursor_unset)
1231 if (!e_config->show_cursor)
1234 if (!e_config->use_cursor_timer)
1241 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1244 Evas_Event_Mouse_In *ev;
1245 struct wl_resource *res;
1246 struct wl_client *wc;
1249 E_Comp_Config *comp_conf;
1250 E_Client *prev_ptr_ec;
1254 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1255 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1257 if (!(ec = data)) return;
1258 if (e_object_is_del(E_OBJECT(ec))) return;
1259 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1260 if (!surface) return;
1262 prev_ptr_ec = e_comp_wl->ptr.ec;
1265 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1266 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1269 e_comp_wl->ptr.ec = ec;
1271 comp_conf = e_comp_config_get();
1272 if (comp_conf && comp_conf->input_log_enable)
1273 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1274 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1275 e_client_util_name_get(ec));
1277 if (_e_comp_wl_check_cursor_timer_needed(ec))
1279 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1283 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1284 wc = wl_resource_get_client(surface);
1285 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1286 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1288 if (!e_comp_wl_input_pointer_check(res)) continue;
1289 if (wl_resource_get_client(res) != wc) continue;
1291 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1293 wl_pointer_send_enter(res, serial, surface,
1294 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1295 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1296 ec->pointer_enter_sent = EINA_TRUE;
1299 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1303 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1306 Evas_Event_Mouse_Out *ev;
1307 struct wl_resource *res;
1308 struct wl_client *wc;
1311 Eina_Bool inside_check;
1312 E_Comp_Config *comp_conf;
1316 if (!(ec = data)) return;
1317 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1318 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1319 if (ec->cur_mouse_action && inside_check) return;
1320 if (e_object_is_del(E_OBJECT(e_comp))) return;
1321 if (e_comp_wl->ptr.ec == ec)
1322 e_comp_wl->ptr.ec = NULL;
1323 if (e_object_is_del(E_OBJECT(ec))) return;
1325 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1326 if (!surface) return;
1328 comp_conf = e_comp_config_get();
1329 if (comp_conf && comp_conf->input_log_enable)
1330 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1331 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1332 e_client_util_name_get(ec));
1334 if (_e_comp_wl_check_cursor_timer_needed(ec))
1336 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1340 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1342 wc = wl_resource_get_client(surface);
1343 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1344 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1346 if (!e_comp_wl_input_pointer_check(res)) continue;
1347 if (wl_resource_get_client(res) != wc) continue;
1348 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1350 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1352 wl_pointer_send_leave(res, serial, surface);
1353 ec->pointer_enter_sent = EINA_FALSE;
1358 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1361 struct wl_client *wc;
1362 struct wl_resource *res;
1365 E_Comp_Config *comp_conf = NULL;
1368 if (e_object_is_del(E_OBJECT(ec))) return;
1369 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1370 if (!surface) return;
1372 wc = wl_resource_get_client(surface);
1373 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1377 x = wl_fixed_from_int(canvas_x - ec->client.x);
1378 y = wl_fixed_from_int(canvas_y - ec->client.y);
1381 comp_conf = e_comp_config_get();
1383 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1385 if (wl_resource_get_client(res) != wc) continue;
1386 if (!e_comp_wl_input_touch_check(res)) continue;
1387 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1390 if (comp_conf && comp_conf->input_log_enable)
1391 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));
1393 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1397 if (comp_conf && comp_conf->input_log_enable)
1398 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));
1400 wl_touch_send_up(res, serial, timestamp, idx);
1407 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1410 struct wl_client *wc;
1411 struct wl_resource *res;
1415 if (ec->cur_mouse_action) return;
1416 if (e_object_is_del(E_OBJECT(ec))) return;
1417 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1418 if (!surface) return;
1420 wc = wl_resource_get_client(surface);
1422 x = wl_fixed_from_int(canvas_x - ec->client.x);
1423 y = wl_fixed_from_int(canvas_y - ec->client.y);
1425 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1427 if (wl_resource_get_client(res) != wc) continue;
1428 if (!e_comp_wl_input_touch_check(res)) continue;
1429 wl_touch_send_motion(res, timestamp, idx, x, y);
1434 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1436 struct wl_resource *res;
1437 struct wl_client *wc;
1441 if (ec->cur_mouse_action) return;
1442 if (e_object_is_del(E_OBJECT(ec))) return;
1443 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1444 if (!surface) return;
1446 wc = wl_resource_get_client(surface);
1447 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1449 if (!e_comp_wl_input_pointer_check(res)) continue;
1450 if (wl_resource_get_client(res) != wc) continue;
1451 wl_pointer_send_motion(res, timestamp,
1452 wl_fixed_from_int(x - ec->client.x),
1453 wl_fixed_from_int(y - ec->client.y));
1458 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1460 if (e_comp_wl->ptr.hide_tmr)
1462 if (cursor_timer_ec == ec)
1464 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1465 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1469 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1470 cursor_timer_ec = ec;
1471 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1476 cursor_timer_ec = ec;
1477 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1482 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1485 Evas_Event_Mouse_Move *ev;
1486 Evas_Device *dev = NULL;
1487 const char *dev_name;
1488 E_Comp_Config *comp_conf;
1492 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1493 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1495 if (!(ec = data)) return;
1496 if (e_object_is_del(E_OBJECT(ec))) return;
1497 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1498 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1499 if (!surface) return;
1501 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1504 dev_name = evas_device_description_get(dev);
1506 comp_conf = e_comp_config_get();
1507 if (comp_conf && comp_conf->input_log_enable)
1508 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1509 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1510 e_client_util_name_get(ec), dev_name);
1512 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1514 if (!e_comp_wl->drag_client)
1516 e_comp_wl->touch.faked_ec = ec;
1517 if (e_comp_wl->touch.pressed & (1 << 0))
1519 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1521 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1522 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1523 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1527 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1531 if (!e_comp_wl->drag_client)
1533 if (_e_comp_wl_check_cursor_timer_needed(ec))
1535 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1539 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1540 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1542 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1544 if (_e_comp_wl_check_cursor_timer_needed(ec))
1545 _e_comp_wl_cursor_move_timer_control(ec);
1549 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1554 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1556 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1557 if (e_object_is_del(E_OBJECT(ec))) return;
1558 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1559 if (!surface) return;
1560 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1562 e_comp_wl->ptr.button = BTN_LEFT;
1564 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1568 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1570 E_Client *ec = data;
1571 Evas_Event_Mouse_Down *ev = event;
1572 Evas_Device *dev = NULL;
1573 const Evas_Device *seat_dev;
1574 const char *dev_name, *seat_name;
1575 E_Comp_Config *comp_conf = NULL;
1578 if (e_object_is_del(E_OBJECT(ec))) return;
1581 dev_name = evas_device_description_get(dev);
1583 seat_dev = evas_device_parent_get(dev);
1584 seat_name = evas_device_name_get(seat_dev);
1586 comp_conf = e_comp_config_get();
1587 if (comp_conf && comp_conf->input_log_enable)
1588 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1589 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1590 dev_name, seat_name);
1592 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1594 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1596 e_comp_wl->touch.faked_ec = ec;
1599 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1600 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1601 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1603 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1604 e_comp_wl->touch.pressed |= (1 << 0);
1608 if (_e_comp_wl_check_cursor_timer_needed(ec))
1610 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1614 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1615 WL_POINTER_BUTTON_STATE_PRESSED);
1617 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1620 need_send_released = EINA_TRUE;
1624 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1626 E_Client *ec = data;
1627 Evas_Event_Mouse_Up *ev = event;
1628 Evas_Device *dev = NULL;
1629 const Evas_Device *seat_dev;
1630 const char *dev_name, *seat_name;;
1631 Evas_Event_Flags flags;
1632 E_Comp_Config *comp_conf = NULL;
1635 if (ec->cur_mouse_action) return;
1636 if (e_object_is_del(E_OBJECT(ec))) return;
1638 if (!need_send_released)
1640 need_send_motion = EINA_TRUE;
1644 dev_name = evas_device_description_get(dev);
1646 seat_dev = evas_device_parent_get(dev);
1647 seat_name = evas_device_name_get(seat_dev);
1648 flags = evas_event_default_flags_get(evas);
1650 comp_conf = e_comp_config_get();
1651 if (comp_conf && comp_conf->input_log_enable)
1652 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1653 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1654 dev_name, seat_name);
1656 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1658 e_comp_wl->touch.pressed &= ~(1 << 0);
1660 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1661 e_comp_wl->touch.faked_ec = NULL;
1664 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1666 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1668 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1671 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1672 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1673 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1677 if (_e_comp_wl_check_cursor_timer_needed(ec))
1679 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1683 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1684 WL_POINTER_BUTTON_STATE_RELEASED);
1686 if (_e_comp_wl_check_cursor_timer_needed(ec))
1687 _e_comp_wl_cursor_move_timer_control(ec);
1691 need_send_released = EINA_FALSE;
1695 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1697 struct wl_resource *res;
1698 struct wl_client *wc;
1703 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1705 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1708 dir = -wl_fixed_from_int(abs(z));
1710 dir = wl_fixed_from_int(z);
1713 if (e_object_is_del(E_OBJECT(ec))) return;
1714 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1715 if (!surface) return;
1717 wc = wl_resource_get_client(surface);
1718 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1720 if (!e_comp_wl_input_pointer_check(res)) continue;
1721 if (wl_resource_get_client(res) != wc) continue;
1722 wl_pointer_send_axis(res, timestamp, axis, dir);
1727 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1730 Evas_Event_Mouse_Wheel *ev;
1733 if (!(ec = data)) return;
1734 if (ec->cur_mouse_action) return;
1735 if (e_object_is_del(E_OBJECT(ec))) return;
1736 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1737 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1738 if (!surface) return;
1740 if (!eina_list_count(e_comp_wl->ptr.resources))
1743 if (_e_comp_wl_check_cursor_timer_needed(ec))
1745 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1749 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1751 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1753 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1755 if (_e_comp_wl_check_cursor_timer_needed(ec))
1756 _e_comp_wl_cursor_move_timer_control(ec);
1761 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1763 E_Client *ec = data;
1764 Evas_Event_Multi_Down *ev = event;
1765 Evas_Device *dev = NULL;
1766 const Evas_Device *seat_dev;
1767 const char *dev_name, *seat_name;
1768 Evas_Device_Class dev_class;
1769 E_Comp_Config *comp_conf = NULL;
1772 if (e_object_is_del(E_OBJECT(ec))) return;
1773 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1774 if (!surface) return;
1776 /* Do not deliver emulated single touch events to client */
1777 if (ev->device == 0) return;
1780 dev_name = evas_device_description_get(dev);
1781 e_comp_wl->touch.faked_ec = ec;
1783 seat_dev = evas_device_parent_get(dev);
1784 seat_name = evas_device_name_get(seat_dev);
1786 comp_conf = e_comp_config_get();
1787 if (comp_conf && comp_conf->input_log_enable)
1788 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1789 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1790 dev_name, seat_name);
1792 if (dev && dev_name)
1794 dev_class = evas_device_class_get(dev);
1795 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1796 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1799 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1800 e_comp_wl->touch.pressed |= (1 << ev->device);
1804 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1806 E_Client *ec = data;
1807 Evas_Event_Multi_Up *ev = event;
1808 Evas_Device *dev = NULL;
1809 const Evas_Device *seat_dev;
1810 const char *dev_name, *seat_name;
1811 Evas_Device_Class dev_class;
1812 Evas_Event_Flags flags;
1813 E_Comp_Config *comp_conf = NULL;
1816 if (e_object_is_del(E_OBJECT(ec))) return;
1817 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1818 if (!surface) return;
1820 /* Do not deliver emulated single touch events to client */
1821 if (ev->device == 0) return;
1823 flags = evas_event_default_flags_get(evas);
1825 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1826 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1827 e_comp_wl->touch.faked_ec = NULL;
1829 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1832 dev_name = evas_device_description_get(dev);
1834 seat_dev = evas_device_parent_get(dev);
1835 seat_name = evas_device_name_get(seat_dev);
1837 comp_conf = e_comp_config_get();
1838 if (comp_conf && comp_conf->input_log_enable)
1839 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1840 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1841 dev_name, seat_name);
1843 if (dev && dev_name)
1845 dev_class = evas_device_class_get(dev);
1846 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1847 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1850 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1854 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1856 E_Client *ec = data;
1857 Evas_Event_Multi_Move *ev = event;
1858 Evas_Device *dev = NULL;
1859 const char *dev_name;
1860 Evas_Device_Class dev_class;
1863 if (e_object_is_del(E_OBJECT(ec))) return;
1864 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1865 if (!surface) return;
1867 /* Do not deliver emulated single touch events to client */
1868 if (ev->device == 0) return;
1870 e_comp_wl->touch.faked_ec = ec;
1872 if (e_comp_wl->touch.pressed & (1 << ev->device))
1875 if (dev && (dev_name = evas_device_description_get(dev)))
1877 dev_class = evas_device_class_get(dev);
1878 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1879 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1882 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1887 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1890 char *file, buff[PATH_MAX];
1897 n = (getpriority(PRIO_PROCESS, pid) + adj);
1901 setpriority(PRIO_PROCESS, pid, n);
1904 use_adj = EINA_TRUE;
1906 if (!do_child) return;
1908 files = ecore_file_ls("/proc");
1909 EINA_LIST_FREE(files, file)
1911 if (!isdigit(file[0]))
1914 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1915 if ((f = fopen(buff, "r")))
1919 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1921 if (num_read == 2 && ppid == pid)
1922 _e_comp_wl_client_priority_adjust(pid2, set,
1924 adj_child, do_child);
1932 _e_comp_wl_client_priority_raise(E_Client *ec)
1934 if (!e_config->priority_control) return;
1935 if (ec->netwm.pid <= 0) return;
1936 if (ec->netwm.pid == getpid()) return;
1937 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1938 e_config->priority - 1, -1,
1939 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1943 _e_comp_wl_client_priority_normal(E_Client *ec)
1945 if (!e_config->priority_control) return;
1946 if (ec->netwm.pid <= 0) return;
1947 if (ec->netwm.pid == getpid()) return;
1948 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1949 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1953 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1956 E_Comp_Wl_Key_Data *k;
1957 struct wl_resource *res;
1961 if (!ec) return EINA_FALSE;
1962 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1963 if (!ec->comp_data) return EINA_FALSE;
1965 ec->comp_data->on_focus_timer = NULL;
1966 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1967 if (!e_comp_wl->kbd.focused)
1969 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1972 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1974 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1975 t = ecore_time_unix_get();
1977 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1978 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1979 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1981 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1983 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1984 wl_keyboard_send_key(res, serial, t,
1985 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1988 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1989 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1993 /* It is called in the following cases:
1994 * When a normal ec->frame has focus.
1995 * Or launching image ec is replaced to the real ec.
1998 e_comp_wl_feed_focus_in(E_Client *ec)
2001 struct wl_resource *res;
2002 struct wl_client *wc;
2006 if (e_object_is_del(E_OBJECT(ec))) return;
2007 if (ec->iconic) return;
2009 /* block spurious focus events */
2010 focused = e_client_focused_get();
2011 if ((focused) && (ec != focused)) return;
2013 /* raise client priority */
2014 _e_comp_wl_client_priority_raise(ec);
2015 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2016 if (!surface) return;
2018 wc = wl_resource_get_client(surface);
2020 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2021 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2023 if (wl_resource_get_client(res) == wc)
2025 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2026 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2027 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2028 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2031 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2033 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2034 if (!e_comp_wl->kbd.focused)
2036 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2039 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2041 e_comp_wl->kbd.focus = surface;
2042 e_comp_wl_input_keyboard_enter_send(ec);
2043 e_comp_wl_data_device_keyboard_focus_set();
2044 ec->comp_data->on_focus_timer =
2045 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2046 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2047 int rotation = ec->e.state.rot.ang.curr;
2048 e_pointer_rotation_set(e_comp->pointer, rotation);
2052 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2055 if (!(ec = data)) return;
2056 e_comp_wl_feed_focus_in(ec);
2060 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2063 struct wl_resource *res;
2065 E_Comp_Wl_Key_Data *k;
2069 if (!(ec = data)) return;
2071 if (!ec->comp_data) return;
2073 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2075 /* lower client priority */
2076 if (!e_object_is_del(data))
2077 _e_comp_wl_client_priority_normal(ec);
2080 /* update keyboard modifier state */
2081 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2082 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2083 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2085 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2087 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2088 if (!surface) return;
2090 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2091 if (!eina_list_count(e_comp_wl->kbd.resources))
2093 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2097 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2099 /* send keyboard_leave to all keyboard resources */
2100 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2101 t = ecore_time_unix_get();
2103 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2104 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2105 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2107 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2109 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2110 wl_keyboard_send_key(res, serial, t,
2111 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2113 wl_keyboard_send_leave(res, serial, surface);
2114 e_comp_wl->kbd.focused =
2115 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2117 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2118 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2122 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2126 if (!(ec = data)) return;
2128 if (!ec->comp_data->shell.configure_send) return;
2130 /* TODO: calculate x, y with transfrom object */
2131 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2135 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2136 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2137 if (e_comp_object_frame_exists(ec->frame))
2138 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2140 switch (ec->resize_mode)
2142 case E_POINTER_RESIZE_TL:
2143 case E_POINTER_RESIZE_L:
2144 case E_POINTER_RESIZE_BL:
2145 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2146 ec->mouse.current.mx;
2148 case E_POINTER_RESIZE_TR:
2149 case E_POINTER_RESIZE_R:
2150 case E_POINTER_RESIZE_BR:
2151 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2156 switch (ec->resize_mode)
2158 case E_POINTER_RESIZE_TL:
2159 case E_POINTER_RESIZE_T:
2160 case E_POINTER_RESIZE_TR:
2161 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2162 ec->mouse.current.my;
2164 case E_POINTER_RESIZE_BL:
2165 case E_POINTER_RESIZE_B:
2166 case E_POINTER_RESIZE_BR:
2167 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2172 w = E_CLAMP(w, 1, w);
2173 h = E_CLAMP(h, 1, h);
2174 e_client_resize_limit(ec, &w, &h);
2176 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2178 else if ((!ec->fullscreen) && (!ec->maximized) &&
2179 (!ec->comp_data->maximize_pre))
2183 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2184 if ((pw != ec->w) || (ph != ec->h))
2186 _e_comp_wl_configure_send(ec, 1, 1);
2190 if (ec->comp_data->sub.below_obj)
2191 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2195 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2197 E_Client *ec = data;
2199 ec->comp_data->maximize_pre = 1;
2203 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2205 E_Client *ec = data;
2208 if (e_object_is_del(E_OBJECT(ec))) return;
2210 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2211 e_client_shell_configure_send(ec, 0, w, h);
2213 ec->comp_data->maximize_pre = 0;
2217 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2219 E_Client *ec = data;
2221 ec->comp_data->maximize_pre = 1;
2225 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2227 E_Client *ec = data;
2229 if (e_object_is_del(E_OBJECT(ec))) return;
2231 /* check for wayland pixmap */
2233 if (ec->comp_data->shell.configure_send)
2234 _e_comp_wl_configure_send(ec, 0, 0);
2236 ec->comp_data->maximize_pre = 0;
2240 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2242 E_Client *ec = data;
2244 if (e_object_is_del(E_OBJECT(ec))) return;
2246 /* check for wayland pixmap */
2248 if (ec->comp_data->shell.configure_send)
2249 _e_comp_wl_configure_send(ec, 0, 1);
2251 ec->comp_data->maximize_pre = 0;
2255 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2257 E_Client *ec = data;
2259 if (e_object_is_del(E_OBJECT(ec))) return;
2261 /* check for wayland pixmap */
2263 if (ec->comp_data->shell.configure_send)
2264 _e_comp_wl_configure_send(ec, 0, 0);
2266 ec->comp_data->maximize_pre = 0;
2270 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2274 if (!(ec = data)) return;
2276 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2278 e_object_del(E_OBJECT(ec));
2280 _e_comp_wl_focus_check();
2282 /* TODO: Delete request send ??
2283 * NB: No such animal wrt wayland */
2287 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2291 if (!(ec = data)) return;
2293 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2296 if (ec->comp_data->reparented)
2297 e_client_comp_hidden_set(ec, EINA_TRUE);
2300 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2301 if (ec->visible) evas_object_hide(ec->frame);
2302 if (!ec->internal) e_object_del(E_OBJECT(ec));
2304 _e_comp_wl_focus_check();
2308 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2312 if (!(ec = data)) return;
2314 e_client_shell_ping(ec);
2318 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2323 if (!(ec = data)) return;
2324 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2325 if (ec->netwm.opacity == a) return;
2326 ec->netwm.opacity = a;
2327 ec->netwm.opacity_changed = EINA_TRUE;
2331 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2333 Eina_Rectangle *damage_rect = NULL;
2334 Eina_Rectangle *dmg = NULL;
2335 Eina_List *l = NULL;
2337 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2338 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2341 if (!buffer->tbm_surface) return;
2345 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2349 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2350 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2353 eina_rectangle_union(damage_rect, dmg);
2358 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2359 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2362 tbm_surface_internal_set_damage(buffer->tbm_surface,
2368 eina_rectangle_free(damage_rect);
2372 _e_comp_wl_client_evas_init(E_Client *ec)
2374 if (!ec || !ec->comp_data) return;
2375 if (ec->comp_data->evas_init) return;
2377 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2378 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2379 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2382 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2383 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2384 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2385 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2386 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2387 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2389 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2390 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2391 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2393 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2398 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2399 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2400 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2401 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2402 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2403 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2404 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2407 /* setup delete/kill callbacks */
2408 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2409 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2411 /* setup ping callback */
2412 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2413 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2415 ec->comp_data->evas_init = EINA_TRUE;
2419 _e_comp_wl_client_evas_deinit(E_Client *ec)
2421 if (!ec || !ec->comp_data) return;
2422 if (!ec->comp_data->evas_init) return;
2424 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2425 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2426 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2428 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2429 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2430 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2431 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2432 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2433 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2444 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2445 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2446 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2447 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2448 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2449 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2450 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2453 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2454 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2456 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2457 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2459 ec->comp_data->evas_init = EINA_FALSE;
2463 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2467 E_Comp_Screen *e_comp_screen;
2468 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2470 if (!e_comp) return ECORE_CALLBACK_RENEW;
2471 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2472 e_comp_screen = e_comp->e_comp_screen;
2474 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2476 if (!eout->config.enabled)
2478 e_comp_wl_output_remove(eout->id);
2482 switch (eout->config.rotation)
2485 transform = WL_OUTPUT_TRANSFORM_90;
2488 transform = WL_OUTPUT_TRANSFORM_180;
2491 transform = WL_OUTPUT_TRANSFORM_270;
2495 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2499 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2501 eout->config.geom.x, eout->config.geom.y,
2502 eout->config.geom.w, eout->config.geom.h,
2503 eout->info.size.w, eout->info.size.h,
2504 eout->config.mode.refresh, 0, transform))
2505 ERR("Could not initialize screen %s", eout->info.name);
2508 return ECORE_CALLBACK_RENEW;
2512 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2516 /* try to get the client from the object */
2517 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2518 return ECORE_CALLBACK_RENEW;
2520 /* check for client being deleted */
2521 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2523 /* check for wayland pixmap */
2524 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2525 return ECORE_CALLBACK_RENEW;
2527 /* if we have not setup evas callbacks for this client, do it */
2528 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2530 return ECORE_CALLBACK_RENEW;
2534 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2538 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2539 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2541 if (e_comp_wl->selection.target &&
2544 struct wl_resource *res;
2546 E_Client *ec = NULL;
2547 E_Client *legacy_target = e_comp_wl->selection.target;
2548 int device_id = e_comp_wl_data_current_device_id_get();
2552 e_comp_wl_data_current_device_id_set(ev->multi.device);
2554 else if (device_id != ev->multi.device)
2556 return ECORE_CALLBACK_RENEW;
2559 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2560 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2562 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2563 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2565 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2566 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2568 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2569 (ec != legacy_target))
2571 e_comp_wl_data_device_send_leave(legacy_target);
2572 e_comp_wl_data_device_send_enter(ec);
2575 if (e_comp_wl->drag)
2576 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2578 if (e_client_transform_core_enable_get(ec))
2580 int trans_x, trans_y;
2581 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2582 x = trans_x - ec->client.x;
2583 y = trans_y - ec->client.y;
2587 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2592 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2595 return ECORE_CALLBACK_RENEW;
2599 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2602 struct wl_resource *surface;
2603 struct wl_resource *res;
2604 struct wl_client *wc;
2606 E_Comp_Config *comp_conf;
2608 ec = e_comp_wl->ptr_constraints.ec;
2609 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2611 surface = e_comp_wl_client_surface_get(ec);
2612 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2614 wc = wl_resource_get_client(surface);
2616 comp_conf = e_comp_config_get();
2618 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2620 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2621 if (wl_resource_get_client(res) != wc) continue;
2623 if (comp_conf && comp_conf->input_log_enable)
2624 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2625 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2626 e_client_util_name_get(ec));
2628 zwp_relative_pointer_v1_send_relative_motion(res,
2630 (uint32_t)(ev->timestamp),
2631 wl_fixed_from_int(ev->dx),
2632 wl_fixed_from_int(ev->dy),
2633 wl_fixed_from_int(ev->dx_unaccel),
2634 wl_fixed_from_int(ev->dy_unaccel));
2637 return ECORE_CALLBACK_DONE;
2641 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2643 _e_comp_wl_touch_cancel();
2645 return ECORE_CALLBACK_PASS_ON;
2649 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2651 if (!ev) return ECORE_CALLBACK_PASS_ON;
2653 E_Zone *zone = ev->zone;
2655 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2656 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2658 if (!e_zone_is_displaying(zone))
2659 _e_comp_wl_touch_cancel();
2661 return ECORE_CALLBACK_PASS_ON;
2665 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2667 E_Client *ec = ev->ec;
2668 E_Comp_Wl_Buffer_Viewport *vp;
2670 if (!ec) return ECORE_CALLBACK_PASS_ON;
2671 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2672 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2673 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2674 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2676 vp = &ec->comp_data->scaler.buffer_viewport;
2677 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2679 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2681 return ECORE_CALLBACK_PASS_ON;
2685 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2687 E_Client *ec = ev->ec;
2688 E_Comp_Wl_Buffer_Viewport *vp;
2690 if (!ec) return ECORE_CALLBACK_PASS_ON;
2691 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2692 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2693 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2695 vp = &ec->comp_data->scaler.buffer_viewport;
2696 vp->wait_for_transform_change = 0;
2698 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2700 return ECORE_CALLBACK_PASS_ON;
2704 _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)
2706 E_Client *focused_ec;
2709 focused_ec = e_client_focused_get();
2710 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2712 rotation = focused_ec->e.state.rot.ang.curr;
2713 e_pointer_rotation_set(e_comp->pointer, rotation);
2715 return ECORE_CALLBACK_PASS_ON;
2719 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2722 Eina_Rectangle *window;
2727 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2729 if ((prev_w != state->bw) ||
2730 (prev_h != state->bh))
2732 ec->changes.buf_size = EINA_TRUE;
2735 if (e_comp_object_frame_exists(ec->frame)) return;
2736 window = &ec->comp_data->shell.window;
2737 if ((!ec->borderless) && /* FIXME temporarily added this check code
2738 * to prevent updating E_Client's size by frame */
2739 (window->x || window->y || window->w || window->h))
2741 e_comp_object_frame_geometry_set(ec->frame,
2743 (window->x + window->w) - state->bw,
2745 (window->y + window->h) - state->bh);
2748 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2752 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2754 E_Comp_Wl_Surface_State *state;
2757 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2758 state->buffer = NULL;
2762 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2764 state->new_attach = EINA_FALSE;
2765 state->buffer = NULL;
2766 state->buffer_destroy_listener.notify =
2767 _e_comp_wl_surface_state_cb_buffer_destroy;
2768 state->sx = state->sy = 0;
2770 state->input = eina_tiler_new(w, h);
2771 eina_tiler_tile_size_set(state->input, 1, 1);
2773 state->opaque = eina_tiler_new(w, h);
2774 eina_tiler_tile_size_set(state->opaque, 1, 1);
2776 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2777 state->buffer_viewport.buffer.scale = 1;
2778 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2779 state->buffer_viewport.surface.width = -1;
2780 state->buffer_viewport.changed = 0;
2782 e_presentation_time_container_init(&state->presentation_container);
2786 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2788 struct wl_resource *cb;
2789 Eina_Rectangle *dmg;
2791 EINA_LIST_FREE(state->frames, cb)
2792 wl_resource_destroy(cb);
2794 EINA_LIST_FREE(state->damages, dmg)
2795 eina_rectangle_free(dmg);
2797 EINA_LIST_FREE(state->buffer_damages, dmg)
2798 eina_rectangle_free(dmg);
2800 if (state->opaque) eina_tiler_free(state->opaque);
2801 state->opaque = NULL;
2803 if (state->input) eina_tiler_free(state->input);
2804 state->input = NULL;
2806 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2807 state->buffer = NULL;
2809 e_presentation_time_container_finish(&state->presentation_container);
2813 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2815 if (state->buffer == buffer) return;
2817 wl_list_remove(&state->buffer_destroy_listener.link);
2818 state->buffer = buffer;
2820 wl_signal_add(&state->buffer->destroy_signal,
2821 &state->buffer_destroy_listener);
2825 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2827 Eina_Rectangle *dmg;
2828 Eina_Bool placed = EINA_TRUE;
2832 E_Comp_Wl_Buffer *buffer;
2833 struct wl_resource *cb;
2835 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2836 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2841 if ((ec->internal) ||
2842 (cdata->shell.surface && state->new_attach))
2846 e_comp->new_clients++;
2847 ELOGF("COMP", "Unignore", ec);
2848 e_client_unignore(ec);
2852 /* buffer transform */
2853 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2856 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2858 /* when buffer is transformed, we have to apply the new evas-map */
2859 state->buffer_viewport.changed = EINA_TRUE;
2861 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2863 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2865 if (transform_change == vp->wait_for_transform_change)
2866 vp->wait_for_transform_change = 0;
2868 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2869 // triggered by E_CLIENT_HOOK calls at those file.
2870 zone = e_comp_zone_find_by_ec(ec);
2873 eout = e_output_find(zone->output_id);
2874 if (eout && eout->hwc)
2876 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2878 if (e_comp_is_on_overlay(ec))
2879 e_comp_hwc_client_end(ec, __FUNCTION__);
2885 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2886 cdata->scaler.buffer_viewport = state->buffer_viewport;
2888 if (state->new_attach)
2890 e_comp_wl_surface_attach(ec, state->buffer);
2893 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2894 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2896 _e_comp_wl_surface_state_buffer_set(state, NULL);
2898 if ((state->new_attach) ||
2899 (state->buffer_viewport.changed))
2901 _e_comp_wl_surface_state_size_update(ec, state);
2902 e_comp_wl_map_size_cal_from_viewport(ec);
2904 /* update the position */
2905 if (ec->changes.pos)
2907 e_comp_object_frame_xy_unadjust(ec->frame,
2917 if (ec->new_client) placed = ec->placed;
2919 if (!ec->lock_client_size)
2924 ec->client.w = state->bw;
2925 ec->client.h = state->bh;
2927 e_comp_object_frame_wh_adjust(ec->frame,
2928 ec->client.w, ec->client.h,
2930 e_client_size_set(ec, nw, nh);
2932 if ((w != ec->w) || (h != ec->h))
2934 ec->changes.size = 1;
2939 if (ec->changes.buf_size)
2941 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2942 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2943 ec->changes.buf_size = EINA_FALSE;
2945 if (ec->move_after_resize)
2947 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2948 ec->move_after_resize = EINA_FALSE;
2953 /* map or unmap ec */
2954 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2955 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2956 if (!pixmap_usable || hide_by_request)
2961 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2966 if ((cdata->sub.below_obj) &&
2967 (evas_object_visible_get(cdata->sub.below_obj)))
2969 evas_object_hide(cdata->sub.below_obj);
2977 if ((cdata->sub.below_obj) &&
2978 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2979 (evas_object_visible_get(ec->frame)))
2981 evas_object_show(cdata->sub.below_obj);
2985 if ((state->new_attach) ||
2986 (state->buffer_viewport.changed))
2988 if ((e_comp_wl->drag) &&
2989 (e_comp_wl->drag_client) &&
2990 (e_comp_wl->drag_client == ec))
2992 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2994 e_drag_move(e_comp_wl->drag,
2996 e_comp_wl->drag->y);
2998 e_drag_resize(e_comp_wl->drag,
2999 state->bw, state->bh);
3001 else if ((cdata->shell.surface) &&
3002 (cdata->shell.configure))
3004 e_comp_wl_commit_sync_configure(ec);
3006 else if (!e_client_video_hw_composition_check(ec))
3008 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3013 ec->placed = placed;
3014 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3018 if (cdata->scaler.buffer_viewport.changed)
3019 e_comp_wl_map_apply(ec);
3021 /* resize transform object */
3022 if (ec->transformed)
3023 e_client_transform_update(ec);
3027 state->new_attach = EINA_FALSE;
3029 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3031 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3032 wl_resource_destroy(cb);
3035 /* insert state frame callbacks into comp_data->frames
3036 * NB: This clears state->frames list */
3037 cdata->frames = eina_list_merge(cdata->frames,
3039 state->frames = NULL;
3041 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3042 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3043 &state->presentation_container);
3045 buffer = e_pixmap_resource_get(ec->pixmap);
3047 /* put state damages into surface */
3050 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3051 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3053 if ((cdata->buffer_ref.buffer) &&
3054 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3055 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3057 e_comp_object_damage(ec->frame,
3059 cdata->buffer_ref.buffer->w,
3060 cdata->buffer_ref.buffer->h);
3065 Eina_List *damages = NULL;
3068 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3070 if (eina_list_count(state->buffer_damages))
3072 EINA_LIST_FREE(state->buffer_damages, dmg)
3075 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3076 e_comp_wl_output_buffer_transform_get(ec),
3078 dmg->x, dmg->y, dmg->w, dmg->h,
3079 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3080 damages = eina_list_append(damages, dmg);
3084 EINA_LIST_FREE(state->damages, dmg)
3085 damages = eina_list_append(damages, dmg);
3087 EINA_LIST_FREE(damages, dmg)
3089 /* not creating damage for ec that shows a underlay video */
3090 if (state->buffer_viewport.changed ||
3091 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3092 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3093 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3095 eina_rectangle_free(dmg);
3100 /* put state opaque into surface */
3101 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3104 Eina_Rectangle *rect;
3107 itr = eina_tiler_iterator_new(state->opaque);
3108 EINA_ITERATOR_FOREACH(itr, rect)
3112 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3113 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3114 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3118 eina_iterator_free(itr);
3121 /* put state input into surface */
3122 if ((state->input) &&
3123 (!eina_tiler_empty(state->input)) &&
3126 Eina_Tiler *src, *tmp;
3130 tmp = eina_tiler_new(sw, sh);
3131 eina_tiler_tile_size_set(tmp, 1, 1);
3133 eina_tiler_rect_add(tmp,
3134 &(Eina_Rectangle){0, 0, sw, sh});
3136 if ((src = eina_tiler_intersection(state->input, tmp)))
3138 Eina_Rectangle *rect;
3141 e_comp_object_input_objs_del(ec->frame);
3142 itr = eina_tiler_iterator_new(src);
3143 EINA_ITERATOR_FOREACH(itr, rect)
3145 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3146 ec, rect->x, rect->y, rect->w, rect->h,
3147 ec->w, ec->h, state->bw, state->bh);
3148 e_comp_object_input_area_set(ec->frame,
3153 eina_iterator_free(itr);
3154 eina_tiler_free(src);
3157 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3159 eina_tiler_free(tmp);
3161 /* clear input tiler */
3162 eina_tiler_clear(state->input);
3165 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3167 if ((cdata->video_client) &&
3169 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3170 (e_comp->wl_comp_data->available_hw_accel.underlay))
3172 e_pixmap_image_clear(ec->pixmap, 1);
3175 state->buffer_viewport.changed = 0;
3177 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3180 ec->exp_iconify.buffer_flush &&
3181 e_policy_visibility_client_is_iconic(ec))
3183 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3188 _e_comp_wl_surface_render_stop(E_Client *ec)
3190 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3191 //if ((!ec->internal) && (!e_comp_gl_get()))
3194 /* check if internal animation is running */
3195 if (e_comp_object_is_animating(ec->frame)) return;
3196 /* check if external animation is running */
3197 if (evas_object_data_get(ec->frame, "effect_running")) return;
3199 evas_object_hide(ec->frame);
3203 e_comp_wl_client_surface_finish(E_Client *ec)
3205 struct wl_resource *res, *surface;
3206 struct wl_client *surface_client = NULL;
3209 surface = e_comp_wl_client_surface_get(ec);
3212 surface_client = wl_resource_get_client(surface);
3214 if (surface_client &&
3215 (ec == e_client_focused_get()))
3217 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3218 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3220 if (wl_resource_get_client(res) ==
3222 e_comp_wl->kbd.focused =
3223 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3227 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3230 e_comp_wl_client_surface_set(ec, NULL);
3232 ec->comp_data->wl_surface = NULL;
3233 e_pixmap_win_id_del(ec->pixmap);
3235 _e_comp_wl_surface_render_stop(ec);
3236 e_object_del(E_OBJECT(ec));
3240 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3245 char proc[512], pname[512];
3248 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3250 h = fopen(proc, "r");
3253 len = fread(pname, sizeof(char), 512, h);
3255 pname[len - 1] = '\0';
3257 strncpy(pname, "NO NAME", sizeof(pname));
3263 strncpy(pname, "NO NAME", sizeof(pname));
3266 strncpy(name, pname, size);
3270 _e_comp_wl_pname_print(pid_t pid)
3273 char proc[512], pname[512];
3276 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3278 h = fopen(proc, "r");
3281 len = fread(pname, sizeof(char), 512, h);
3283 pname[len - 1] = '\0';
3285 strncpy(pname, "NO NAME", sizeof(pname));
3289 ELOGF("COMP", " |%s", NULL, pname);
3294 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3296 struct wl_client *client = data;
3297 E_Comp_Connected_Client_Info *cinfo;
3300 cinfo = wl_container_of(listener, cinfo, destroy);
3302 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3303 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3305 eai = e_appinfo_find_with_pid(cinfo->pid);
3306 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3309 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3311 wl_list_remove(&cinfo->destroy.link);
3312 eina_stringshare_del(cinfo->name);
3317 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3319 E_Comp_Connected_Client_Info *cinfo;
3321 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3322 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3324 cinfo->name = eina_stringshare_add(name);
3328 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3329 wl_client_add_destroy_listener(client, &cinfo->destroy);
3330 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3332 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3336 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3338 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3340 /* send configure */
3341 if (ec->comp_data->shell.configure_send)
3343 if (ec->comp_data->shell.surface)
3344 _e_comp_wl_configure_send(ec, 0, 0);
3347 e_comp_wl->kbd.focus = ec->comp_data->surface;
3351 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3353 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3355 /* send configure */
3356 if (ec->comp_data->shell.configure_send)
3358 if (ec->comp_data->shell.surface)
3359 _e_comp_wl_configure_send(ec, 0, 0);
3362 _e_comp_wl_focus_check();
3364 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3365 e_comp_wl->kbd.focus = NULL;
3369 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3371 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3372 if (ec->keyboard_resizing) return;
3374 /* do nothing currently */
3379 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3381 if (e_object_is_del(E_OBJECT(ec))) return;
3382 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3384 e_comp_wl->resize.edges = 0;
3385 e_comp_wl->resize.resource = NULL;
3389 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3391 if (e_object_is_del(E_OBJECT(ec))) return;
3392 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3396 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3399 int ratio_w, ratio_h;
3401 phys_w = output->phys_width;
3402 phys_h = output->phys_height;
3404 if (e_config->configured_output_resolution.use)
3406 // change the configured physical size(mm) of the output
3407 if (output->w != res_w)
3409 ratio_w = res_w / output->w;
3410 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3413 if (output->h != res_h)
3415 ratio_h = res_h / output->h;
3416 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3419 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3422 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3423 NULL, res_w, res_h, phys_w, phys_h, pid);
3425 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3426 wl_output_send_scale(resource, output->scale);
3428 wl_output_send_geometry(resource, output->x, output->y,
3430 output->subpixel, output->make ?: "",
3431 output->model ?: "", output->transform);
3433 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3434 res_w, res_h, output->refresh);
3436 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3437 wl_output_send_done(resource);
3441 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3443 E_Comp_Wl_Output *output;
3445 if (!(output = wl_resource_get_user_data(resource))) return;
3447 output->resources = eina_list_remove(output->resources, resource);
3451 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3453 E_Comp_Wl_Output *output;
3454 struct wl_resource *resource;
3455 E_Appinfo *eai = NULL;
3459 if (!(output = data)) return;
3462 wl_resource_create(client, &wl_output_interface, version, id);
3465 wl_client_post_no_memory(client);
3469 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3470 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3472 output->resources = eina_list_append(output->resources, resource);
3474 wl_resource_set_implementation(resource, NULL, output,
3475 _e_comp_wl_cb_output_unbind);
3476 wl_resource_set_user_data(resource, output);
3478 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3479 if (e_config->configured_output_resolution.use)
3481 wl_client_get_credentials(client, &pid, NULL, NULL);
3484 res_w = e_config->configured_output_resolution.w;
3485 res_h = e_config->configured_output_resolution.h;
3489 eai = e_appinfo_find_with_pid(pid);
3492 res_w = e_config->configured_output_resolution.w;
3493 res_h = e_config->configured_output_resolution.h;
3497 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3499 res_w = e_config->configured_output_resolution.w;
3500 res_h = e_config->configured_output_resolution.h;
3504 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3513 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3517 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3520 Evas_GL *evasgl = NULL;
3521 Evas_GL_API *glapi = NULL;
3522 Evas_GL_Context *ctx = NULL;
3523 Evas_GL_Surface *sfc = NULL;
3524 Evas_GL_Config *cfg = NULL;
3526 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3528 if (!e_comp_gl_get()) return;
3530 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3531 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3533 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3534 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3536 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3537 * then we should get evas from ecore_evas.
3540 evas = e_comp->evas;
3542 evas = ecore_evas_get(e_comp->ee);
3544 evasgl = evas_gl_new(evas);
3545 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3547 glapi = evas_gl_api_get(evasgl);
3548 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3549 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3551 cfg = evas_gl_config_new();
3552 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3554 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3555 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3557 ctx = evas_gl_context_create(evasgl, NULL);
3558 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3560 res = evas_gl_make_current(evasgl, sfc, ctx);
3561 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3563 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3564 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3566 evas_gl_config_free(cfg);
3568 evas_gl->gl = evasgl;
3569 evas_gl->glapi = glapi;
3570 evas_gl->glsfc = sfc;
3571 evas_gl->glctx = ctx;
3573 e_comp_wl->evas_gl = evas_gl;
3575 /* for native surface */
3578 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3583 evas_gl_config_free(cfg);
3584 evas_gl_make_current(evasgl, NULL, NULL);
3585 evas_gl_context_destroy(evasgl, ctx);
3586 evas_gl_surface_destroy(evasgl, sfc);
3587 evas_gl_free(evasgl);
3594 _e_comp_wl_gl_popup_cb_close(void *data,
3595 Evas_Object *obj EINA_UNUSED,
3596 void *event_info EINA_UNUSED)
3598 evas_object_del(data);
3602 _e_comp_wl_gl_popup_cb_focus(void *data,
3603 Evas_Object *obj EINA_UNUSED,
3604 void *event_info EINA_UNUSED)
3606 elm_object_focus_set(data, EINA_TRUE);
3611 _e_comp_wl_gl_idle(void *data)
3615 /* show warning window to notify failure of gl init */
3618 Evas_Object *win, *bg, *popup, *btn;
3620 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3621 elm_win_title_set(win, "Compositor Warning");
3622 elm_win_autodel_set(win, EINA_TRUE);
3623 elm_win_borderless_set(win, EINA_TRUE);
3624 elm_win_role_set(win, "notification-low");
3625 elm_win_alpha_set(win, EINA_TRUE);
3627 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3628 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3629 elm_win_resize_object_add(win, bg);
3630 evas_object_color_set(bg, 125, 125, 125, 125);
3631 evas_object_show(bg);
3633 popup = elm_popup_add(win);
3634 elm_object_text_set(popup,
3635 _( "Your screen does not support OpenGL.<br>"
3636 "Falling back to software engine."));
3637 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3639 btn = elm_button_add(popup);
3640 elm_object_text_set(btn, "Close");
3641 elm_object_part_content_set(popup, "button1", btn);
3642 evas_object_show(btn);
3644 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3645 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3647 evas_object_show(popup);
3648 evas_object_show(win);
3652 return ECORE_CALLBACK_CANCEL;
3656 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3658 struct wl_client *client = data;
3664 wl_client_get_credentials(client, &pid, &uid, &gid);
3666 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3668 _e_comp_wl_pname_print(pid);
3669 _e_comp_wl_pname_get(pid, name, sizeof(name));
3670 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3674 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3676 char buf[1024] = {0, };
3678 vsnprintf(buf, 1024, fmt, args);
3682 DBG("[libds] %s", buf);
3685 INF("[libds] %s", buf);
3688 ERR("[libds] %s", buf);
3696 _e_comp_wl_display_create(void)
3699 E_Comp_Wl_Data *wl_cdata;
3704 /* create new compositor data */
3705 if (!(comp = E_NEW(E_Comp_Data, 1)))
3707 ERR("Could not create compositor data: %m");
3710 wl_cdata = &comp->base;
3712 /* set compositor wayland data */
3713 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3715 g_mutex_init(&connection_mutex);
3717 /* try to create a wayland display */
3718 if (!(wl_cdata->wl.disp = wl_display_create()))
3720 ERR("Could not create a Wayland display: %m");
3724 /* try to setup wayland socket */
3725 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3727 ERR("Could not create Wayland display socket: %m");
3728 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3732 res = e_comp_socket_init(name);
3733 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3734 PRCTL("[Winsys] change permission and create sym link for %s", name);
3736 /* set wayland display environment variable */
3737 e_env_set("WAYLAND_DISPLAY", name);
3739 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3740 /* wl_cdata->output.scale = e_scale; */
3742 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3744 if (!e_compositor_init(wl_cdata->wl.disp))
3746 ERR("Failed to initialize compositor");
3750 comp->client_created.notify = _e_comp_wl_cb_client_created;
3751 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3753 if (!e_comp_wl_subsurfaces_init())
3755 ERR("Failed to init_subsurfaces");
3756 goto subsurfaces_err;
3759 /* initialize shm mechanism */
3760 wl_display_init_shm(wl_cdata->wl.disp);
3762 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3764 /* try to init data manager */
3765 if (!e_comp_wl_data_manager_init())
3767 ERR("Could not initialize data manager");
3771 /* try to init input */
3772 if (!e_comp_wl_input_init())
3774 ERR("Could not initialize input");
3778 if (e_comp_gl_get())
3779 _e_comp_wl_gl_init(NULL);
3781 /* get the wayland display loop */
3782 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3784 /* get the file descriptor of the wayland event loop */
3785 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3787 /* create a listener for wayland main loop events */
3789 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3790 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3791 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3792 _e_comp_wl_cb_prepare, wl_cdata);
3797 e_comp_wl_data_manager_shutdown();
3799 e_comp_wl_subsurfaces_shutdown();
3801 wl_list_remove(&comp->client_created.link);
3803 e_env_unset("WAYLAND_DISPLAY");
3805 wl_display_destroy(wl_cdata->wl.disp);
3807 g_mutex_clear(&connection_mutex);
3813 _e_comp_wl_gl_shutdown(void)
3815 if (!e_comp_wl->evas_gl) return;
3817 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3819 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3820 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3821 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3822 evas_gl_free(e_comp_wl->evas_gl->gl);
3824 E_FREE(e_comp_wl->evas_gl);
3827 /* public functions */
3830 * Creates and initializes a Wayland compositor with ecore.
3831 * Registers callback handlers for keyboard and mouse activity
3832 * and other client events.
3834 * @returns true on success, false if initialization failed.
3837 e_comp_wl_init(void)
3839 TRACE_DS_BEGIN(COMP_WL:INIT);
3841 /* try to create a wayland compositor */
3842 if (!_e_comp_wl_display_create())
3844 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3849 e_comp_wl_shell_init();
3851 #ifdef HAVE_WAYLAND_TBM
3852 e_comp_wl_tbm_init();
3854 e_comp_wl_remote_surface_init();
3858 e_comp_wl_screenshooter_init();
3860 if (!e_comp_wl_video_init())
3861 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3863 e_comp_wl_viewport_init();
3864 e_comp_wl_capture_init();
3865 e_comp_wl_renderer_init();
3866 _e_comp_wl_move_resize_init();
3867 e_presentation_time_init();
3868 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3871 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3872 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3874 /* add event handlers to catch E events */
3875 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3876 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3877 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3878 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3879 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3880 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3881 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3882 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3883 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3885 /* add hooks to catch e_client events */
3886 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3887 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3888 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3889 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3890 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3892 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3899 e_comp_wl_deferred_job(void)
3901 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3904 /* internal functions */
3906 e_comp_wl_shutdown(void)
3908 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3910 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3912 e_comp_wl_subsurfaces_shutdown();
3914 E_FREE_LIST(handlers, ecore_event_handler_del);
3915 E_FREE_LIST(hooks, e_client_hook_del);
3916 _e_comp_wl_gl_shutdown();
3918 e_blender_shutdown();
3919 e_presentation_time_shutdown();
3920 e_comp_wl_renderer_shutdown();
3921 e_comp_wl_capture_shutdown();
3922 e_comp_wl_viewport_shutdown();
3923 e_comp_wl_video_shutdown();
3924 e_comp_wl_screenshooter_shutdown();
3926 e_comp_wl_remote_surface_shutdown();
3928 e_pixmap_shutdown();
3930 e_wtz_shell_shutdown();
3931 e_comp_wl_shell_shutdown();
3932 e_comp_wl_input_shutdown();
3934 wl_list_remove(&comp->client_created.link);
3937 e_comp->wl_comp_data = NULL;
3941 E_Comp_Wl_Output *output;
3943 if (e_comp_wl->screenshooter.global)
3944 wl_global_destroy(e_comp_wl->screenshooter.global);
3946 EINA_LIST_FREE(e_comp_wl->outputs, output)
3948 if (output->id) eina_stringshare_del(output->id);
3949 if (output->make) eina_stringshare_del(output->make);
3950 if (output->model) eina_stringshare_del(output->model);
3954 /* delete fd handler */
3955 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3957 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3958 cursor_timer_ec = NULL;
3960 /* free allocated data structure */
3966 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3968 e_object_unref(E_OBJECT(ev->ec));
3973 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3976 ev = E_NEW(E_Event_Client, 1);
3979 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3981 /* set usable early because shell module checks this */
3982 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3983 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3985 e_pixmap_resource_set(ec->pixmap, buffer);
3986 e_pixmap_dirty(ec->pixmap);
3987 e_pixmap_refresh(ec->pixmap);
3989 e_comp_wl_map_size_cal_from_buffer(ec);
3990 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3992 /* wm-policy module uses it */
3993 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
3996 e_object_ref(E_OBJECT(ec));
3997 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
3998 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4002 e_comp_wl_surface_commit(E_Client *ec)
4007 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4008 if (!e_comp_object_damage_exists(ec->frame))
4010 if ((ec->comp_data->video_client) ||
4011 (!e_client_video_hw_composition_check(ec)))
4012 e_pixmap_image_clear(ec->pixmap, 1);
4015 ignored = ec->ignored;
4017 if (e_comp_wl_subsurface_order_commit(ec))
4019 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4020 e_comp_wl_subsurface_restack(topmost);
4021 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4024 ec->ignored = ignored;
4026 if (ec->is_cursor && ec->visible)
4028 /* ignore cursor changes during resize/move I guess */
4029 if (!e_client_action_get())
4031 if (e_comp->pointer)
4033 x = e_comp->pointer->hot.x;
4034 y = e_comp->pointer->hot.y;
4036 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4042 static E_Comp_Wl_Output *
4043 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4046 E_Comp_Wl_Output *output;
4048 EINA_LIST_FOREACH(outputs, l, output)
4050 if (!strcmp(output->id, id))
4058 * Initializes information about one display output.
4060 * Adds or updates the given data about a single display output,
4061 * with an id matching the provided id.
4063 * @param id identification of output to be added or changed
4064 * @param make manufacturer name of the display output
4065 * @param model model name of the display output
4066 * @param x output's top left corner x coordinate
4067 * @param y output's top left corner y coordinate
4068 * @param w output's width in pixels
4069 * @param h output's height in pixels
4070 * @param pw output's physical width in millimeters
4071 * @param ph output's physical height in millimeters
4072 * @param refresh output's refresh rate in mHz
4073 * @param subpixel output's subpixel layout
4074 * @param transform output's rotation and/or mirror transformation
4076 * @returns True if a display output object could be added or updated
4079 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4080 int x, int y, int w, int h, int pw, int ph,
4081 unsigned int refresh, unsigned int subpixel,
4082 unsigned int transform)
4084 E_Comp_Wl_Output *output;
4086 struct wl_resource *resource;
4088 /* retrieve named output; or create it if it doesn't exist */
4089 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4092 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4094 if (id) output->id = eina_stringshare_add(id);
4096 output->make = eina_stringshare_add(make);
4098 output->make = eina_stringshare_add("unknown");
4100 output->model = eina_stringshare_add(model);
4102 output->model = eina_stringshare_add("unknown");
4104 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4107 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4108 2, output, _e_comp_wl_cb_output_bind);
4110 output->resources = NULL;
4111 output->scale = e_scale;
4114 /* update the output details */
4119 output->phys_width = pw;
4120 output->phys_height = ph;
4121 output->refresh = refresh;
4122 output->subpixel = subpixel;
4123 output->transform = transform;
4125 if (output->scale <= 0)
4126 output->scale = e_scale;
4128 /* if we have bound resources, send updates */
4129 EINA_LIST_FOREACH(output->resources, l2, resource)
4131 wl_output_send_geometry(resource,
4132 output->x, output->y,
4134 output->phys_height,
4136 output->make ?: "", output->model ?: "",
4139 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4140 wl_output_send_scale(resource, output->scale);
4142 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4143 output->w, output->h, output->refresh);
4145 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4146 wl_output_send_done(resource);
4153 e_comp_wl_output_remove(const char *id)
4155 E_Comp_Wl_Output *output;
4157 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4160 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4162 /* wl_global_destroy(output->global); */
4164 /* eina_stringshare_del(output->id); */
4165 /* eina_stringshare_del(output->make); */
4166 /* eina_stringshare_del(output->model); */
4173 _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)
4175 struct wl_resource *res;
4177 uint32_t serial, keycode;
4178 struct wl_client *wc = NULL;
4179 E_Comp_Config *comp_conf = NULL;
4180 const char *device_name = NULL;
4182 keycode = (ev->keycode - 8);
4184 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4186 comp_conf = e_comp_config_get();
4188 if (ec && ec->comp_data)
4190 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4193 wc = wl_resource_get_client(surface);
4196 if (e_config->key_input_ttrace_enable)
4198 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4199 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4202 EINA_LIST_FOREACH(key_list, l, res)
4204 if (wl_resource_get_client(res) != wc) continue;
4206 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4207 if (!e_input_thread_mode_get())
4209 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4210 device_name = ecore_device_name_get(ev->dev);
4216 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4217 device_name = e_device_name_get(dev);
4221 if (comp_conf && comp_conf->input_log_enable)
4222 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4224 wl_keyboard_send_key(res, serial, ev->timestamp,
4229 if (e_config->key_input_ttrace_enable)
4232 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4237 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4239 E_Client *ec = NULL;
4241 E_Comp_Wl_Key_Data *end, *k;
4243 if (ev->window != e_comp->ee_win)
4248 keycode = (ev->keycode - 8);
4249 if (!(e_comp_wl = e_comp->wl_comp_data))
4254 #ifndef E_RELEASE_BUILD
4255 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4256 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4257 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4258 eina_streq(ev->key, "BackSpace"))
4264 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4266 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4268 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4270 /* ignore server-generated key repeats */
4271 if (k->key == keycode)
4273 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4278 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4280 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4282 ec = e_client_focused_get();
4283 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4284 if (ec && ec->comp_data && surface)
4286 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4287 if (e_comp_wl->kbd.focused)
4289 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4291 /* A key only sent to clients is added to the list */
4292 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4293 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4295 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4297 DBG("wl_array_add: Out of memory\n");
4298 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4299 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4302 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4306 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4310 /* update modifier state */
4311 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4317 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4319 E_Client *ec = NULL;
4320 uint32_t keycode, delivered_key;
4321 E_Comp_Wl_Key_Data *end, *k;
4323 if (ev->window != e_comp->ee_win)
4328 keycode = (ev->keycode - 8);
4330 if (!(e_comp_wl = e_comp->wl_comp_data))
4335 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4337 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4338 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4340 if (k->key == keycode)
4347 e_comp_wl->kbd.keys.size =
4348 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4350 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4352 /* 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) */
4353 if ((delivered_key) ||
4354 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4356 ec = e_client_focused_get();
4358 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4359 if (e_comp_wl->kbd.focused)
4361 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4363 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4366 /* update modifier state */
4367 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4373 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4375 Eina_Bool res = EINA_FALSE;
4377 if (type == ECORE_EVENT_KEY_DOWN)
4379 res = e_comp_wl_key_down(ev, dev);
4381 else if (type == ECORE_EVENT_KEY_UP)
4383 res = e_comp_wl_key_up(ev, dev);
4390 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4393 struct wl_client *wc;
4394 uint32_t serial, btn;
4395 struct wl_resource *res;
4396 E_Comp_Config *comp_conf = NULL;
4398 if (ec->cur_mouse_action || e_comp_wl->drag)
4400 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4401 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4405 case 1: btn = BTN_LEFT; break;
4406 case 2: btn = BTN_MIDDLE; break;
4407 case 3: btn = BTN_RIGHT; break;
4408 default: btn = button_id; break;
4411 e_comp_wl->ptr.button = btn;
4412 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4413 if (!surface) return EINA_FALSE;
4415 if (!eina_list_count(e_comp_wl->ptr.resources))
4418 wc = wl_resource_get_client(surface);
4419 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4421 comp_conf = e_comp_config_get();
4423 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4425 if (wl_resource_get_client(res) != wc) continue;
4426 if (!e_comp_wl_input_pointer_check(res)) continue;
4427 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4429 if (comp_conf && comp_conf->input_log_enable)
4430 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4432 wl_pointer_send_button(res, serial, timestamp, btn, state);
4439 e_comp_wl_touch_cancel(void)
4441 _e_comp_wl_touch_cancel();
4444 E_API E_Comp_Wl_Hook *
4445 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4449 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4450 ch = E_NEW(E_Comp_Wl_Hook, 1);
4451 if (!ch) return NULL;
4452 ch->hookpoint = hookpoint;
4454 ch->data = (void*)data;
4455 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4460 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4463 if (_e_comp_wl_hooks_walking == 0)
4465 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4469 _e_comp_wl_hooks_delete++;
4472 E_API E_Comp_Wl_Pid_Hook *
4473 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4475 E_Comp_Wl_Pid_Hook *ch;
4477 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4479 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4480 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4482 ch->hookpoint = hookpoint;
4484 ch->data = (void*)data;
4485 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4491 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4494 if (_e_comp_wl_pid_hooks_walking == 0)
4496 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4500 _e_comp_wl_pid_hooks_delete++;
4503 E_API E_Comp_Wl_Intercept_Hook *
4504 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4506 E_Comp_Wl_Intercept_Hook *ch;
4508 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4509 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4510 if (!ch) return NULL;
4511 ch->hookpoint = hookpoint;
4513 ch->data = (void*)data;
4514 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4519 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4522 if (_e_comp_wl_intercept_hooks_walking == 0)
4524 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4528 _e_comp_wl_intercept_hooks_delete++;
4532 e_comp_wl_shell_surface_ready(E_Client *ec)
4536 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4540 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4542 e_config->use_cursor_timer = !!enabled;
4544 if (e_config->use_cursor_timer)
4546 if (!e_pointer_is_hidden(e_comp->pointer))
4548 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4553 if (e_comp_wl->ptr.hide_tmr)
4555 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4556 e_comp_wl->ptr.hide_tmr = NULL;
4558 cursor_timer_ec = NULL;
4560 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4563 if (e_pointer_is_hidden(e_comp->pointer))
4565 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4571 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4573 EINA_SAFETY_ON_NULL_RETURN(wc);
4574 EINA_SAFETY_ON_NULL_RETURN(dev);
4576 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4580 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4582 EINA_SAFETY_ON_NULL_RETURN(wc);
4583 EINA_SAFETY_ON_NULL_RETURN(dev);
4585 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4589 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4591 struct wl_resource *res;
4592 struct wl_client *wc;
4594 uint32_t serial, wl_keycode;
4595 enum wl_keyboard_key_state state;
4596 E_Comp_Config *comp_conf = NULL;
4597 const char *dev_name = NULL;
4599 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4600 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4601 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4603 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4604 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4606 wl_keycode = keycode - 8;
4607 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4609 wc = wl_resource_get_client(surface);
4610 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4611 if (!time) time = e_util_timestamp_get();
4612 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4613 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4615 comp_conf = e_comp_config_get();
4616 e_keyrouter_event_surface_send(ec, keycode);
4618 if (e_config->key_input_ttrace_enable)
4620 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4621 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4624 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4625 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4627 if (wl_resource_get_client(res) != wc) continue;
4628 if (!e_input_thread_mode_get())
4632 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4633 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4637 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4644 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4645 dev_name = e_device_name_get(dev);
4649 if (comp_conf && comp_conf->input_log_enable)
4650 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4653 wl_keyboard_send_key(res, serial, time,
4656 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4658 if (e_config->key_input_ttrace_enable)
4661 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4668 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4670 struct wl_resource *res;
4671 struct wl_client *wc;
4673 uint32_t serial, wl_keycode, cancel_keycode;
4674 E_Comp_Config *comp_conf = NULL;
4675 struct xkb_keymap *keymap = NULL;
4677 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4678 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4679 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4681 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4682 keymap = e_comp_wl->xkb.keymap;
4683 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4684 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4686 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4687 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4689 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4690 if (cancel_keycode == XKB_KEYCODE_INVALID)
4692 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4695 cancel_keycode = cancel_keycode - 8;
4697 wl_keycode = keycode - 8;
4698 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4700 wc = wl_resource_get_client(surface);
4701 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4702 if (!time) time = e_util_timestamp_get();
4704 comp_conf = e_comp_config_get();
4705 e_keyrouter_event_surface_send(ec, keycode);
4707 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4708 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4710 if (wl_resource_get_client(res) != wc) continue;
4711 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4712 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4714 if (comp_conf && comp_conf->input_log_enable)
4715 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4716 wl_keyboard_send_key(res, serial, time,
4717 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4718 wl_keyboard_send_key(res, serial, time,
4719 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4720 wl_keyboard_send_key(res, serial, time,
4721 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4723 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4730 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)
4732 struct wl_client *wc;
4734 E_Devicemgr_Input_Device *device = NULL;
4736 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4737 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4738 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4740 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4741 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4743 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4745 wc = wl_resource_get_client(surface);
4746 if (!time) time = e_util_timestamp_get();
4747 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4751 _e_comp_wl_send_event_device(wc, time, dev, serial);
4752 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4756 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4757 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4760 x = x + ec->client.x;
4761 y = y + ec->client.y;
4763 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4769 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)
4771 E_Devicemgr_Input_Device *device;
4773 struct wl_client *wc;
4775 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4776 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4777 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4779 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4782 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4784 wc = wl_resource_get_client(surface);
4785 if (!time) time = e_util_timestamp_get();
4786 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4790 _e_comp_wl_send_event_device(wc, time, dev, serial);
4791 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4795 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4796 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4799 x = x + ec->client.x;
4800 y = y + ec->client.y;
4802 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4808 e_comp_wl_touch_cancel_send(E_Client *ec)
4810 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4811 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4812 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4814 _e_comp_wl_send_touch_cancel(ec);
4820 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4823 struct wl_client *wc;
4825 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4826 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4827 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4829 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4832 wc = wl_resource_get_client(surface);
4833 if (!time) time = e_util_timestamp_get();
4834 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4836 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4837 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4840 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4841 WL_POINTER_BUTTON_STATE_PRESSED);
4843 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4844 WL_POINTER_BUTTON_STATE_RELEASED);
4850 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4853 struct wl_client *wc;
4855 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4856 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4857 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4859 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4860 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4862 wc = wl_resource_get_client(surface);
4863 if (!time) time = e_util_timestamp_get();
4864 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4866 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4867 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4869 x = x + ec->client.x;
4870 y = y + ec->client.y;
4872 _e_comp_wl_send_mouse_move(ec, x, y, time);
4878 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4881 struct wl_client *wc;
4883 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4884 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4885 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4887 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4888 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4890 wc = wl_resource_get_client(surface);
4891 if (!time) time = e_util_timestamp_get();
4892 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4894 if (_e_comp_wl_check_cursor_timer_needed(ec))
4896 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4900 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4901 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4903 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4905 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4907 if (_e_comp_wl_check_cursor_timer_needed(ec))
4908 _e_comp_wl_cursor_move_timer_control(ec);
4915 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4918 struct wl_client *wc;
4919 struct wl_resource *res;
4922 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4923 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4925 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4926 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4928 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4929 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4931 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4932 wc = wl_resource_get_client(surface);
4933 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4934 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4936 if (!e_comp_wl_input_pointer_check(res)) continue;
4937 if (wl_resource_get_client(res) != wc) continue;
4939 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4940 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4942 wl_pointer_send_enter(res, serial, surface,
4943 wl_fixed_from_int(x),
4944 wl_fixed_from_int(y));
4945 ec->pointer_enter_sent = EINA_TRUE;
4947 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4953 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4956 struct wl_client *wc;
4957 struct wl_resource *res;
4960 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4961 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4962 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4963 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4964 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4965 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4967 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4968 wc = wl_resource_get_client(surface);
4969 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4970 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4972 if (!e_comp_wl_input_pointer_check(res)) continue;
4973 if (wl_resource_get_client(res) != wc) continue;
4975 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4976 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4978 wl_pointer_send_leave(res, serial, surface);
4979 ec->pointer_enter_sent = EINA_FALSE;
4986 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)
4988 Evas_Event_Mouse_In ev_in;
4991 if (ec->pointer_enter_sent) return;
4993 ev_in.buttons = buttons;
5001 ev_in.modifiers = modifiers;
5002 ev_in.locks = locks;
5003 ev_in.timestamp = timestamp;
5004 ev_in.event_flags = event_flags;
5007 ev_in.event_src = event_src;
5009 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5013 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)
5015 Evas_Event_Mouse_Out ev_out;
5018 if (!ec->pointer_enter_sent) return;
5020 ev_out.buttons = buttons;
5022 ev_out.output.x = x;
5023 ev_out.output.y = y;
5024 ev_out.canvas.x = x;
5025 ev_out.canvas.y = y;
5028 ev_out.modifiers = modifiers;
5029 ev_out.locks = locks;
5030 ev_out.timestamp = timestamp;
5031 ev_out.event_flags = event_flags;
5034 ev_out.event_src = event_src;
5036 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5040 e_comp_wl_cursor_hide(E_Client *ec)
5042 struct wl_resource *res;
5043 struct wl_client *wc;
5047 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5049 if (e_comp_wl->ptr.hide_tmr)
5051 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5052 e_comp_wl->ptr.hide_tmr = NULL;
5054 cursor_timer_ec = NULL;
5056 if (!ec) return EINA_FALSE;
5057 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5058 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5059 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5061 wc = wl_resource_get_client(surface);
5062 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5063 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5065 if (!e_comp_wl_input_pointer_check(res)) continue;
5066 if (wl_resource_get_client(res) != wc) continue;
5067 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5068 wl_pointer_send_leave(res, serial, surface);
5069 ec->pointer_enter_sent = EINA_FALSE;
5075 /* surface to buffer
5076 * - width : surface width
5077 * - height : surface height
5078 * - transform: buffer transform
5079 * - scale : buffer scale
5081 * - width : screen width
5082 * - height : screen height
5083 * - transform: output transform
5084 * - scale : output scale
5086 static E_Util_Transform_Matrix
5087 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5089 E_Util_Transform_Matrix m;
5091 e_util_transform_matrix_load_identity(&m);
5093 if (transform & 0x4)
5095 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5096 e_util_transform_matrix_flip_x(&m);
5097 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5100 switch (transform & 0x3)
5102 case WL_OUTPUT_TRANSFORM_90:
5103 e_util_transform_matrix_translate(&m, -width, 0, 0);
5104 e_util_transform_matrix_rotation_z(&m, 270);
5106 case WL_OUTPUT_TRANSFORM_180:
5107 e_util_transform_matrix_translate(&m, -width, -height, 0);
5108 e_util_transform_matrix_rotation_z(&m, 180);
5110 case WL_OUTPUT_TRANSFORM_270:
5111 e_util_transform_matrix_translate(&m, 0, -height, 0);
5112 e_util_transform_matrix_rotation_z(&m, 90);
5118 e_util_transform_matrix_scale(&m, scale, scale, 1);
5123 /* surface to buffer
5124 * - surface width, surface height, buffer transform, buffer scale
5126 * - screen width, screen height, output transform, output scale
5129 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5131 E_Util_Transform_Matrix m;
5132 E_Util_Transform_Vertex v;
5134 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5136 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5137 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5138 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5142 * - buffer width, buffer height, buffer transform, buffer scale
5145 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5147 E_Util_Transform_Matrix m;
5148 E_Util_Transform_Vertex v;
5151 if (transform != 0 || scale > 1)
5153 tw = ((transform % 2) ? height : width) / scale;
5154 th = ((transform % 2) ? width : height) / scale;
5162 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5163 m = e_util_transform_matrix_inverse_get(&m);
5165 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5166 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5167 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5170 /* surface to buffer
5171 * - surface width, surface height, buffer transform, buffer scale
5173 * - screen width, screen height, output transform, output scale
5176 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5177 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5179 E_Util_Transform_Matrix m;
5180 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5181 E_Util_Transform_Rect_Vertex sv;
5183 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5185 sv = e_util_transform_rect_to_vertices(&sr);
5186 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5187 sr = e_util_transform_vertices_to_rect(&sv);
5196 * - buffer width, buffer height, buffer transform, buffer scale
5199 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5200 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5202 E_Util_Transform_Matrix m;
5203 E_Util_Transform_Rect br = {bx, by, bw, bh};
5204 E_Util_Transform_Rect_Vertex bv;
5207 if (transform != 0 || scale > 1)
5209 tw = ((transform % 2) ? height : width) / scale;
5210 th = ((transform % 2) ? width : height) / scale;
5218 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5219 m = e_util_transform_matrix_inverse_get(&m);
5221 bv = e_util_transform_rect_to_vertices(&br);
5222 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5223 br = e_util_transform_vertices_to_rect(&bv);
5231 EINTERN E_Comp_Wl_Output*
5232 e_comp_wl_output_find(E_Client *ec)
5235 E_Comp_Wl_Output *output;
5237 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5239 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5241 if (output->transform % 2)
5243 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5244 ec->y < output->x || ec->y >= (output->x + output->w))
5249 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5250 ec->y < output->y || ec->y >= (output->y + output->h))
5260 EINTERN Eina_Array *
5261 e_comp_wl_output_find_all(E_Client *ec)
5263 E_Comp_Wl_Output *output;
5264 Eina_Array *outputs;
5267 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5269 outputs = eina_array_new(4);
5273 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5275 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5276 output->x, output->y, output->w, output->h))
5278 eina_array_push(outputs, output);
5282 if (eina_array_count(outputs) == 0)
5284 eina_array_free(outputs);
5291 // --------------------------------------------------------
5292 // tizen_move_resize
5293 // --------------------------------------------------------
5295 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5302 E_Client_Pending_Geometry *geo;
5305 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5306 if (ec->fullscreen || ec->maximized) goto err;
5308 geo = E_NEW(E_Client_Pending_Geometry, 1);
5311 geo->serial = serial;
5317 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5318 ec->surface_sync.wait_commit = EINA_TRUE;
5323 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5330 e_comp_wl_commit_sync_configure(E_Client *ec)
5333 E_Client_Pending_Geometry *geo;
5335 Eina_Bool match_size = EINA_FALSE;
5342 if (!ec || !ec->frame) goto ret;
5343 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5346 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5347 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5349 if (eina_list_count(ec->surface_sync.pending_geometry))
5351 Eina_List *ll = NULL;
5352 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5356 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5361 if ((geo->w == bw) && (geo->h == bh))
5363 match_size = EINA_TRUE;
5368 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5375 if ((config.w != ec->w) || (config.h != ec->h))
5377 e_client_size_set(ec, config.w, config.h);
5378 ec->changes.size = EINA_TRUE;
5382 // FIXME: The geometry of the client would be better to be calculated
5383 // at e_desk or at e_desk_area. So the position(x,y) of the client
5384 // should be calcuated at the e_desk or at the e_desk_area.
5386 desk = e_comp_desk_find_by_ec(ec);
5389 ec->client.x = desk->geom.x + config.x;
5390 ec->client.y = desk->geom.y + config.y;
5394 ec->client.x = config.x;
5395 ec->client.y = config.y;
5398 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5400 e_client_pos_set(ec, ec->client.x, ec->client.y);
5402 ec->changes.pos = 1;
5406 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5410 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5411 ec->surface_sync.wait_commit = EINA_FALSE;
5413 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5415 // rollback wait_commit if there are pending requests remained
5416 if (eina_list_count(ec->surface_sync.pending_geometry))
5417 ec->surface_sync.wait_commit = EINA_TRUE;
5422 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);
5429 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5430 struct wl_resource *res_moveresize)
5432 wl_resource_destroy(res_moveresize);
5436 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5437 struct wl_resource *res_moveresize,
5438 struct wl_resource *surface,
5445 /* to be implemented */
5448 int cur_w = 0, cur_h = 0;
5450 ec = e_client_from_surface_resource(surface);
5453 pending = e_client_pending_geometry_has(ec);
5454 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5455 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);
5459 if ((cur_w == w) && (cur_h == h))
5461 e_client_pos_set(ec, x, y);
5462 ec->changes.pos = 1;
5468 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5472 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5475 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5477 _tz_move_resize_iface_cb_destroy,
5478 _tz_move_resize_iface_cb_set_geometry,
5482 _tz_moveresize_cb_bind(struct wl_client *client,
5483 void *data EINA_UNUSED,
5487 struct wl_resource *res_moveresize;
5489 res_moveresize = wl_resource_create(client,
5490 &tizen_move_resize_interface,
5493 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5496 wl_resource_set_implementation(res_moveresize,
5497 &_tz_move_resize_iface,
5503 ERR("Could not create tizen_move_resize_interface res: %m");
5504 wl_client_post_no_memory(client);
5508 _e_comp_wl_move_resize_init(void)
5510 if (!e_comp_wl) return;
5511 if (!e_comp_wl->wl.disp) return;
5513 if (!wl_global_create(e_comp_wl->wl.disp,
5514 &tizen_move_resize_interface,
5517 _tz_moveresize_cb_bind))
5519 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5526 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5528 E_Comp_Wl_Output *output;
5529 pid_t output_pid = 0;
5530 Eina_List *l = NULL, *l2 = NULL;
5531 struct wl_resource *resource = NULL;
5533 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5535 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5536 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5537 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5539 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5541 /* if we have bound resources, send updates */
5542 EINA_LIST_FOREACH(output->resources, l2, resource)
5544 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5545 if (output_pid != pid) continue;
5547 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5549 // send output information to the client
5550 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5558 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5560 _e_comp_wl_surface_state_init(state, w, h);
5564 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5566 _e_comp_wl_surface_state_commit(ec, state);
5570 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5572 _e_comp_wl_hook_call(hookpoint, ec);
5576 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5578 _e_comp_wl_surface_state_finish(state);
5582 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5584 _e_comp_wl_surface_state_buffer_set(state, buffer);
5588 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5589 int sx, int sy, int *dx, int *dy)
5593 case WL_OUTPUT_TRANSFORM_NORMAL:
5597 case WL_OUTPUT_TRANSFORM_FLIPPED:
5598 *dx = width - sx, *dy = sy;
5600 case WL_OUTPUT_TRANSFORM_90:
5601 *dx = height - sy, *dy = sx;
5603 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5604 *dx = height - sy, *dy = width - sx;
5606 case WL_OUTPUT_TRANSFORM_180:
5607 *dx = width - sx, *dy = height - sy;
5609 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5610 *dx = sx, *dy = height - sy;
5612 case WL_OUTPUT_TRANSFORM_270:
5613 *dx = sy, *dy = width - sx;
5615 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5625 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5628 int tx1, ty1, tx2, ty2;
5629 int width_from_buffer, height_from_buffer;
5631 switch (vp->buffer.transform)
5633 case WL_OUTPUT_TRANSFORM_90:
5634 case WL_OUTPUT_TRANSFORM_270:
5635 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5636 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5637 width_from_buffer = bh / vp->buffer.scale;
5638 height_from_buffer = bw / vp->buffer.scale;
5641 width_from_buffer = bw / vp->buffer.scale;
5642 height_from_buffer = bh / vp->buffer.scale;
5646 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5650 x2 = width_from_buffer;
5651 y2 = height_from_buffer;
5655 x1 = wl_fixed_to_int(vp->buffer.src_x);
5656 y1 = wl_fixed_to_int(vp->buffer.src_y);
5657 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5658 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5661 buffer_transform(width_from_buffer, height_from_buffer,
5662 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5663 buffer_transform(width_from_buffer, height_from_buffer,
5664 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5666 out->x = (tx1 <= tx2) ? tx1 : tx2;
5667 out->y = (ty1 <= ty2) ? ty1 : ty2;
5668 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5669 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5673 * Convert given four coordinates to elements of rectangle
5674 * @in p[4] Coordinates to be converted
5675 * @out rect x, y, width, and height
5676 * transform Angle which represents TDM_TRANSFORM of rectangle
5677 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5678 * 1. The given coordinates are not represented by rectangle.
5679 * 2. All angles except for 0, 90, 180, 270.
5682 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5684 Eina_Bool ret = EINA_FALSE;
5686 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))
5689 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5692 *rotation = TDM_TRANSFORM_NORMAL;
5695 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5699 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5702 *rotation = TDM_TRANSFORM_180;
5705 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5710 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))
5713 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5716 *rotation = TDM_TRANSFORM_90;
5719 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5723 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5726 *rotation = TDM_TRANSFORM_270;
5729 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5739 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5744 for (i = 0; i < 4; i++)
5745 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5747 if (!_coords_to_rectangle_convert(p, out, rotation))
5749 DBG("Cannot convert given coords to rectangle.\n"
5750 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5751 p[0].x, p[0].y, p[1].x, p[1].y,
5752 p[2].x, p[2].y, p[3].x, p[3].y);
5760 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5762 int trans_rotation, flip;
5764 trans_rotation = transform & 0x3;
5765 flip = transform & 0x4;
5767 return (flip + (trans_rotation + rotation) % 4);
5771 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5779 if (e_comp_wl_subsurface_check(ec))
5780 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5787 out->w = ec->comp_data->width_from_viewport;
5788 out->w = (out->w + 1) & ~1;
5789 out->h = ec->comp_data->height_from_viewport;
5791 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5792 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5796 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5798 E_Comp_Wl_Buffer *buffer;
5799 E_Comp_Wl_Buffer_Viewport *vp;
5801 enum wl_output_transform buffer_transform;
5802 unsigned int rotation;
5803 Eina_Bool res = EINA_FALSE;
5805 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5807 if (e_object_is_del(E_OBJECT(ec)))
5810 vp = &ec->comp_data->scaler.buffer_viewport;
5812 if (buffer_viewport)
5814 buffer = ec->comp_data->buffer_ref.buffer;
5815 /* Getting a viewport of buffer needs geometry of buffer. */
5819 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5822 if ((output_viewport) || (transform))
5824 m = e_client_map_get(ec);
5826 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5828 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5833 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5834 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5835 * Since buffer.transform isn't applied using evas_map,
5836 * it has to be taken into account here to apply buffer.transform
5837 * and rotation of e_client_transform together. */
5839 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5841 *transform = (unsigned int)buffer_transform;
5849 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5851 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5852 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5854 /* Must be called with valid comp_data */
5855 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5857 if ((ec->comp_data->role_name == NULL) ||
5858 (ec->comp_data->role_name == role_name) ||
5859 (strcmp(ec->comp_data->role_name, role_name) == 0))
5861 ec->comp_data->role_name = role_name;
5867 wl_resource_post_error(error_resource, error_code,
5868 "Cannot assign role %s to wl_surface@%d,"
5869 " already has role %s\n",
5871 ec->comp_data->wl_surface ?
5872 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5873 ec->comp_data->role_name);
5879 EINTERN const char *
5880 e_comp_wl_surface_role_get(E_Client *ec)
5882 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5883 return ec->comp_data ? ec->comp_data->role_name : NULL;
5886 EINTERN struct wl_resource *
5887 e_comp_wl_client_surface_get(E_Client *ec)
5889 struct wl_resource *surface = NULL;
5890 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5891 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5893 g_mutex_lock(&ec->comp_data->surface_mutex);
5894 surface = ec->comp_data->surface;
5895 g_mutex_unlock(&ec->comp_data->surface_mutex);
5900 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5902 EINA_SAFETY_ON_NULL_RETURN(ec);
5903 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5905 g_mutex_lock(&ec->comp_data->surface_mutex);
5906 ec->comp_data->surface = surface;
5907 g_mutex_unlock(&ec->comp_data->surface_mutex);
5911 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5913 return e_compositor_util_client_from_surface_resource(surface_resource);
5917 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5919 if (!ec->comp_data->mapped)
5921 if (ec->comp_data->shell.surface &&
5922 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5924 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5930 if (ec->comp_data->mapped)
5932 /* will be unmapped. so run capture */
5933 e_comp_wl_remote_surface_image_save(ec);
5937 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5939 ec->comp_data->pending.sx = sx;
5940 ec->comp_data->pending.sy = sy;
5941 ec->comp_data->pending.new_attach = EINA_TRUE;
5943 e_client_fps_update(ec);
5947 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5949 if (ec->comp_data->pending.opaque)
5950 eina_tiler_clear(ec->comp_data->pending.opaque);
5954 eina_tiler_union(ec->comp_data->pending.opaque, region);
5956 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5960 ec->argb = EINA_FALSE;
5961 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5963 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5964 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5972 ec->argb = EINA_TRUE;
5973 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5975 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5976 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5982 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5984 if (ec->comp_data->pending.input)
5985 eina_tiler_clear(ec->comp_data->pending.input);
5989 if (eina_tiler_empty(region))
5991 ELOGF("COMP", " |unset input rect", NULL);
5992 e_comp_object_input_objs_del(ec->frame);
5993 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
5996 eina_tiler_union(ec->comp_data->pending.input, region);
6000 eina_tiler_rect_add(ec->comp_data->pending.input,
6001 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6006 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6008 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6012 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6014 E_Comp_Wl_Subsurf_Data *sdata;
6019 if (ec->comp_data->frames)
6021 ec->comp_data->frames =
6022 eina_list_remove(ec->comp_data->frames, callback_resource);
6025 if (ec->comp_data->pending.frames)
6027 ec->comp_data->pending.frames =
6028 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6031 sdata = ec->comp_data->sub.data;
6032 if ((sdata) && (sdata->cached.frames))
6034 sdata->cached.frames =
6035 eina_list_remove(sdata->cached.frames, callback_resource);
6040 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6042 if (e_object_is_del(E_OBJECT(ec))) return;
6044 if (e_comp_wl_remote_surface_commit(ec)) return;
6046 e_comp_wl_surface_commit(ec);
6048 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6052 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6054 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6055 ec->comp_data->sub.data = sub;
6057 /* set subsurface client properties */
6058 ec->borderless = EINA_TRUE;
6059 ec->argb = EINA_TRUE;
6060 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6061 ec->lock_border = EINA_TRUE;
6062 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6063 ec->netwm.state.skip_taskbar = EINA_TRUE;
6064 ec->netwm.state.skip_pager = EINA_TRUE;
6065 ec->border_size = 0;
6066 ec->lock_user_location = 0;
6067 ec->lock_client_location = 0;
6068 ec->lock_user_size = 0;
6069 ec->lock_client_size = 0;
6070 ec->lock_client_stacking = 0;
6071 ec->lock_user_maximize = 0;
6072 ec->lock_client_maximize = 0;
6073 ec->changes.need_maximize = 0;
6074 ec->maximized = E_MAXIMIZE_NONE;
6077 ec->new_client = ec->netwm.ping = EINA_TRUE;
6078 e_comp->new_clients++;
6079 e_client_unignore(ec);
6081 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6082 * It's not for subsurface. */
6083 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6087 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6089 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6092 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6094 sub->parent = parent;
6098 layer = e_client_layer_get(parent);
6099 if (layer > E_LAYER_BOTTOM)
6100 e_client_layer_set(ec, layer);
6103 if (parent->comp_data)
6105 /* append this client to the parents subsurface list */
6106 parent->comp_data->sub.list_pending =
6107 eina_list_append(parent->comp_data->sub.list_pending, ec);
6108 parent->comp_data->sub.list_changed = EINA_TRUE;
6113 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6115 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6116 E_Client *parent = sub->parent;
6118 parent->comp_data->sub.list =
6119 eina_list_remove(parent->comp_data->sub.list, ec);
6120 parent->comp_data->sub.list_pending =
6121 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6122 parent->comp_data->sub.below_list =
6123 eina_list_remove(parent->comp_data->sub.below_list, ec);
6124 parent->comp_data->sub.below_list_pending =
6125 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6131 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)
6133 sub->resource = subsurface_resource;
6134 sub->cached_buffer_ref.buffer = NULL;
6135 sub->synchronized = EINA_TRUE;
6136 sub->parent = parent;
6137 sub->remote_surface.offscreen_parent = offscreen_parent;
6138 if (offscreen_parent)
6139 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6141 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6143 _e_comp_wl_client_subsurface_set(ec, sub);
6144 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6146 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6150 e_comp_wl_client_subsurface_finish(E_Client *ec)
6152 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6155 e_comp_wl_client_subsurface_parent_unset(ec);
6157 e_comp_wl_surface_state_finish(&sub->cached);
6158 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6160 ec->comp_data->sub.data = NULL;
6164 e_comp_wl_client_evas_init(E_Client *ec)
6166 EINA_SAFETY_ON_NULL_RETURN(ec);
6168 _e_comp_wl_client_evas_init(ec);
6172 e_comp_wl_client_evas_deinit(E_Client *ec)
6174 EINA_SAFETY_ON_NULL_RETURN(ec);
6176 _e_comp_wl_client_evas_deinit(ec);
6180 e_comp_wl_focus_check(void)
6182 _e_comp_wl_focus_check();
6186 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6193 if ((parent->comp_data) && (parent->comp_data->sub.data))
6194 parent = parent->comp_data->sub.data->parent;