2 #include "e_comp_wl_intern.h"
3 #include "e_comp_wl_private.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_comp_wl_private.h"
7 #include "e_client_intern.h"
8 #include "e_appinfo_intern.h"
9 #include "e_blender_intern.h"
10 #include "e_utils_intern.h"
11 #include "e_scale_intern.h"
12 #include "e_comp_canvas_intern.h"
13 #include "e_comp_screen_intern.h"
14 #include "e_comp_wl_capture_intern.h"
15 #include "e_comp_wl_data_intern.h"
16 #include "e_comp_wl_input_intern.h"
17 #include "e_comp_wl_renderer_intern.h"
18 #include "e_comp_wl_rsm_intern.h"
19 #include "e_comp_wl_screenshooter_intern.h"
20 #include "e_comp_wl_shell_intern.h"
21 #include "e_comp_wl_subsurface_intern.h"
22 #include "e_comp_wl_tbm_intern.h"
23 #include "e_comp_wl_viewport_intern.h"
25 #include <tizen-extension-server-protocol.h>
26 #include <relative-pointer-unstable-v1-server-protocol.h>
27 #include <pointer-constraints-unstable-v1-server-protocol.h>
29 #include <wayland-tbm-server.h>
31 #include <libds/log.h>
32 #include <libds/single_pixel_buffer_v1.h>
34 /* handle include for printing uint64_t */
35 #define __STDC_FORMAT_MACROS
38 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
40 /* Resource Data Mapping: (wl_resource_get_user_data)
42 * wl_surface == e_pixmap
43 * wl_region == eina_tiler
44 * wl_subsurface == e_client
48 typedef struct _E_Comp_Data E_Comp_Data;
53 struct wl_listener client_created;
56 static void _e_comp_wl_move_resize_init(void);
58 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
61 typedef struct _E_Comp_Wl_Key_Data
67 static Eina_List *handlers = NULL;
68 static E_Client *cursor_timer_ec = NULL;
69 static Eina_Bool need_send_released = EINA_FALSE;
70 static Eina_Bool need_send_motion = EINA_TRUE;
72 static GMutex connection_mutex;
74 static int _e_comp_wl_hooks_delete = 0;
75 static int _e_comp_wl_hooks_walking = 0;
77 static int _e_comp_wl_pid_hooks_delete = 0;
78 static int _e_comp_wl_pid_hooks_walking = 0;
80 static int _e_comp_wl_intercept_hooks_delete = 0;
81 static int _e_comp_wl_intercept_hooks_walking = 0;
83 static Eina_Inlist *_e_comp_wl_hooks[] =
85 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
86 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
87 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
88 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
89 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
90 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
91 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
92 [E_COMP_WL_HOOK_DEL] = NULL,
93 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
94 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
95 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
98 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
100 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
103 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
105 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
106 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
107 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
108 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
109 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
110 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
113 static Eina_List *hooks = NULL;
115 /* local functions */
117 _e_comp_wl_hooks_clean(void)
122 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
123 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
125 if (!ch->delete_me) continue;
126 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
132 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
136 e_object_ref(E_OBJECT(ec));
137 _e_comp_wl_hooks_walking++;
138 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
140 if (ch->delete_me) continue;
141 ch->func(ch->data, ec);
142 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
143 (e_object_is_del(E_OBJECT(ec))))
146 _e_comp_wl_hooks_walking--;
147 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
148 _e_comp_wl_hooks_clean();
149 e_object_unref(E_OBJECT(ec));
153 _e_comp_wl_pid_hooks_clean(void)
156 E_Comp_Wl_Pid_Hook *ch;
158 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
159 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
161 if (!ch->delete_me) continue;
162 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
168 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
170 E_Comp_Wl_Pid_Hook *ch;
172 _e_comp_wl_pid_hooks_walking++;
173 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
175 if (ch->delete_me) continue;
176 ch->func(ch->data, pid);
178 _e_comp_wl_pid_hooks_walking--;
179 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
180 _e_comp_wl_pid_hooks_clean();
184 _e_comp_wl_intercept_hooks_clean(void)
187 E_Comp_Wl_Intercept_Hook *ch;
189 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
190 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
192 if (!ch->delete_me) continue;
193 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
199 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
201 E_Comp_Wl_Intercept_Hook *ch;
202 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
204 e_object_ref(E_OBJECT(ec));
205 _e_comp_wl_intercept_hooks_walking++;
206 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
208 if (ch->delete_me) continue;
209 res = ch->func(ch->data, ec);
210 if (!res) ret = EINA_FALSE;
211 if (e_object_is_del(E_OBJECT(ec)))
214 _e_comp_wl_intercept_hooks_walking--;
215 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
216 _e_comp_wl_intercept_hooks_clean();
217 e_object_unref(E_OBJECT(ec));
224 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
230 if (e_comp_object_frame_exists(ec->frame))
231 w = ec->client.w, h = ec->client.h;
233 w = ec->w, h = ec->h;
237 // Width and Height are -1 means that we don't consider size value
241 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
245 _e_comp_wl_focus_check(void)
249 if (stopping) return;
250 ec = e_client_focused_get();
252 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
256 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
258 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
260 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
261 IDLE_EXITER~CB_PREPARE);
263 return ECORE_CALLBACK_RENEW;
267 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
269 /* dispatch pending wayland events */
270 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
272 return ECORE_CALLBACK_RENEW;
276 e_comp_wl_display_flush()
278 if (e_comp_wl && e_comp_wl->wl.disp)
280 if (e_config->key_input_ttrace_enable)
282 TRACE_INPUT_BEGIN(wl_display_flush_clients);
283 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
286 g_mutex_lock(&connection_mutex);
287 wl_display_flush_clients(e_comp_wl->wl.disp);
288 g_mutex_unlock(&connection_mutex);
290 if (e_config->key_input_ttrace_enable)
293 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
299 e_comp_wl_connection_lock()
301 e_input_boost_lock(&connection_mutex);
305 e_comp_wl_connection_unlock()
307 e_input_boost_unlock(&connection_mutex);
311 e_comp_wl_focused_client_flush()
313 E_Client *focused_ec;
314 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
316 e_input_boost_lock(&connection_mutex);
317 focused_ec = e_client_focused_get();
321 struct wl_client *wc;
322 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
325 e_input_boost_unlock(&connection_mutex);
329 wc = wl_resource_get_client(surface);
333 e_input_boost_unlock(&connection_mutex);
337 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
341 if (e_comp_wl->idle_exiter_timestamp > 0.0)
343 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
344 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
346 ELOGF("E_COMP", "prepare gap time: %lfms",
351 e_comp_wl->idle_exiter_timestamp = 0.0;
353 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
355 /* flush pending client events */
356 e_comp_wl_display_flush();
358 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
359 IDLE_EXITER~CB_PREPARE);
362 E_API enum wl_output_transform
363 e_comp_wl_output_buffer_transform_get(E_Client *ec)
365 E_Comp_Wl_Buffer_Viewport *vp;
366 E_Comp_Wl_Buffer *buffer;
367 enum wl_output_transform transform, rotation;
369 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
370 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
371 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
373 vp = &ec->comp_data->scaler.buffer_viewport;
374 if (e_comp_wl_subsurface_check(ec))
375 return vp->buffer.transform;
377 buffer = ec->comp_data->buffer_ref.buffer;
380 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
381 return vp->buffer.transform;
383 rotation = buffer->transform;
385 return vp->buffer.transform;
387 /* ignore the flip value when calculating transform because the screen rotation
388 * functionality doesn't consider the flip output transform currently
390 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
392 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
393 ec, rotation, vp->buffer.transform, transform);
398 EINTERN enum wl_output_transform
399 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
401 E_Comp_Wl_Buffer_Viewport *vp;
402 E_Comp_Wl_Buffer *buffer;
403 enum wl_output_transform transform, rotation;
405 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
406 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
407 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
409 vp = &ec->comp_data->pending.buffer_viewport;
410 if (e_comp_wl_subsurface_check(ec))
411 return vp->buffer.transform;
413 buffer = ec->comp_data->pending.buffer;
416 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
417 return vp->buffer.transform;
419 rotation = buffer->transform;
421 return vp->buffer.transform;
423 /* ignore the flip value when calculating transform because the screen rotation
424 * functionality doesn't consider the flip output transform currently
426 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
428 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
429 ec, rotation, vp->buffer.transform, transform);
435 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
437 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
438 E_Comp_Wl_Buffer *buffer;
439 int32_t width, height;
441 buffer = e_pixmap_resource_get(ec->pixmap);
444 ec->comp_data->width_from_buffer = 0;
445 ec->comp_data->height_from_buffer = 0;
449 switch (e_comp_wl_output_buffer_transform_get(ec))
451 case WL_OUTPUT_TRANSFORM_90:
452 case WL_OUTPUT_TRANSFORM_270:
453 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
454 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
455 width = buffer->h / vp->buffer.scale;
456 height = buffer->w / vp->buffer.scale;
459 width = buffer->w / vp->buffer.scale;
460 height = buffer->h / vp->buffer.scale;
464 ec->comp_data->width_from_buffer = width;
465 ec->comp_data->height_from_buffer = height;
469 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
471 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
472 int32_t width, height;
474 width = ec->comp_data->width_from_buffer;
475 height = ec->comp_data->height_from_buffer;
477 if (width == 0 && height == 0) return;
479 if (width != 0 && vp->surface.width != -1)
481 ec->comp_data->width_from_viewport = vp->surface.width;
482 ec->comp_data->height_from_viewport = vp->surface.height;
486 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
488 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
489 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
490 ec->comp_data->width_from_viewport = w ?: 1;
491 ec->comp_data->height_from_viewport = h ?: 1;
495 ec->comp_data->width_from_viewport = width;
496 ec->comp_data->height_from_viewport = height;
500 e_comp_wl_topmost_parent_get(E_Client *ec)
504 if (!e_comp_wl_subsurface_check(ec))
507 parent = e_comp_wl_subsurface_parent_get(ec);
510 if (!e_comp_wl_subsurface_check(parent))
513 parent = e_comp_wl_subsurface_parent_get(parent);
520 e_comp_wl_map_apply(E_Client *ec)
522 E_Comp_Wl_Buffer_Viewport *vp;
523 E_Comp_Wl_Subsurf_Data *sdata;
524 E_Comp_Wl_Client_Data *cdata;
525 int x1, y1, x2, y2, x, y;
527 Eina_Bool zoom_animating = EINA_FALSE;
529 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
531 e_comp_object_map_update(ec->frame);
533 cdata = ec->comp_data;
534 vp = &cdata->scaler.buffer_viewport;
535 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
536 (!cdata->viewport_transform))
539 if (e_comp_wl_subsurface_check(ec))
541 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
543 sdata = ec->comp_data->sub.data;
544 if (sdata->remote_surface.offscreen_parent)
546 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
547 Eina_Rectangle *rect;
550 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
552 /* TODO: If there are one more regions, it means that provider's offscreen
553 * is displayed by one more remote_surfaces. Have to consider it later. At
554 * this time, just consider only one remote_surface.
568 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
569 if (x != dx || y != dy)
570 evas_object_move(ec->frame, dx, dy);
572 if (!cdata->viewport_transform)
574 cdata->viewport_transform = e_util_transform_new();
575 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
576 e_client_transform_core_add(ec, cdata->viewport_transform);
579 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
580 ec->comp_data->width_from_viewport,
581 ec->comp_data->height_from_viewport);
583 if (vp->buffer.src_width == wl_fixed_from_int(-1))
587 x2 = cdata->width_from_buffer;
588 y2 = cdata->height_from_buffer;
592 x1 = wl_fixed_to_int(vp->buffer.src_x);
593 y1 = wl_fixed_to_int(vp->buffer.src_y);
594 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
595 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
598 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
599 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
600 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
601 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
604 desk = e_comp_desk_find_by_ec(ec);
606 zoom_animating = e_desk_zoom_is_animating(desk);
608 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
609 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
610 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
612 /* workaround:: when the desk zoom is doing their animation,
613 the transform core update can override animation's zoom boundary.
614 so, don't doing transform core update while desk zoom animation */
616 e_client_transform_core_update(ec);
621 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
625 int map_c = 0, map_x = 0, map_y = 0;
626 double inv_x = 0.0, inv_y = 0.0;
628 EINA_SAFETY_ON_NULL_RETURN(ec);
630 map = e_client_map_get(ec);
631 map_c = e_map_count_get(map);
633 if (!map || map_c <= 0)
643 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
644 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
645 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
646 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
648 for (int i = 0; i < map_c; i++)
650 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
651 e_map_point_image_uv_set(map2, i, map_x, map_y);
653 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
663 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
669 if (!(ec = data)) return;
670 if (e_object_is_del(data)) return;
672 if (!ec->override) e_hints_window_visible_set(ec);
674 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
675 (!ec->comp_data->need_reparent))
677 ec->comp_data->need_reparent = EINA_TRUE;
678 ec->visible = EINA_TRUE;
680 if (!e_client_util_ignored_get(ec))
682 ec->take_focus = !starting;
686 if (!ec->comp_data->need_reparent)
688 if ((ec->hidden) || (ec->iconic))
690 evas_object_hide(ec->frame);
691 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
694 evas_object_show(ec->frame);
697 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
698 evas_object_show(tmp->frame);
700 topmost = e_comp_wl_topmost_parent_get(ec);
701 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
702 e_comp_wl_subsurface_show(ec);
704 if (ec->comp_data->sub.below_obj)
705 evas_object_show(ec->comp_data->sub.below_obj);
709 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
715 if (!(ec = data)) return;
716 if (e_object_is_del(E_OBJECT(ec))) return;
718 /* Uncommonly some clients's final buffer can be skipped if the client
719 * requests unmap of its surface right after wl_surface@commit.
720 * So if this client evas object is hidden state and client is already
721 * unmmapped, we can consider to clear pixmap image here mandatorily.
723 if (!ec->comp_data->mapped)
724 e_pixmap_image_clear(ec->pixmap, 1);
726 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
727 evas_object_hide(tmp->frame);
729 topmost = e_comp_wl_topmost_parent_get(ec);
730 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
731 e_comp_wl_subsurface_hide(ec);
733 if (ec->comp_data->sub.below_obj)
734 evas_object_hide(ec->comp_data->sub.below_obj);
736 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
740 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
747 if (!(ec = data)) return;
748 if (e_object_is_del(E_OBJECT(ec))) return;
750 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
752 if (!e_comp_wl_subsurface_check(subc)) continue;
753 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
754 evas_object_move(subc->frame, x, y);
756 if (subc->comp_data->scaler.viewport)
758 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
759 if (cdata->viewport_transform)
760 e_comp_wl_map_apply(subc);
764 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
766 if (!e_comp_wl_subsurface_check(subc)) continue;
767 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
768 evas_object_move(subc->frame, x, y);
770 if (subc->comp_data->scaler.viewport)
772 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
773 if (cdata->viewport_transform)
774 e_comp_wl_map_apply(subc);
778 if (ec->comp_data->sub.below_obj)
780 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
781 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
786 _e_comp_wl_send_touch_cancel(E_Client *ec)
789 struct wl_resource *res;
790 struct wl_client *wc;
791 E_Comp_Config *comp_conf = NULL;
794 if (e_object_is_del(E_OBJECT(ec))) return;
795 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
797 if (!surface) return;
798 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
800 wc = wl_resource_get_client(surface);
802 comp_conf = e_comp_config_get();
804 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
806 if (wl_resource_get_client(res) != wc) continue;
807 if (!e_comp_wl_input_touch_check(res)) continue;
809 if (comp_conf && comp_conf->input_log_enable)
810 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
812 wl_touch_send_cancel(res);
817 _e_comp_wl_touch_cancel(void)
821 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
823 if (!e_comp_wl->touch.pressed) return;
825 _e_comp_wl_send_touch_cancel(ec);
828 static E_Devicemgr_Input_Device *
829 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
831 E_Devicemgr_Input_Device *last_kbd = NULL;
834 case ECORE_DEVICE_CLASS_MOUSE:
835 return e_devicemgr->last_device_ptr;
836 case ECORE_DEVICE_CLASS_KEYBOARD:
837 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
839 case ECORE_DEVICE_CLASS_TOUCH:
840 return e_devicemgr->last_device_touch;
848 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
852 case ECORE_DEVICE_CLASS_MOUSE:
853 e_devicemgr->last_device_ptr = device;
855 case ECORE_DEVICE_CLASS_KEYBOARD:
856 atomic_store(&e_devicemgr->last_device_kbd, device);
858 case ECORE_DEVICE_CLASS_TOUCH:
859 e_devicemgr->last_device_touch = device;
866 static E_Devicemgr_Input_Device *
867 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
869 E_Devicemgr_Input_Device *last_kbd = NULL;
873 case ECORE_DEVICE_CLASS_MOUSE:
874 return ec->comp_data->last_device_ptr;
875 case ECORE_DEVICE_CLASS_KEYBOARD:
876 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
878 case ECORE_DEVICE_CLASS_TOUCH:
879 return ec->comp_data->last_device_touch;
887 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
891 case ECORE_DEVICE_CLASS_MOUSE:
892 ec->comp_data->last_device_ptr = device;
894 case ECORE_DEVICE_CLASS_KEYBOARD:
895 atomic_store(&ec->comp_data->last_device_kbd, device);
897 case ECORE_DEVICE_CLASS_TOUCH:
898 ec->comp_data->last_device_touch = device;
906 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
908 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
909 struct wl_resource *dev_res;
910 const char *dev_name;
911 Ecore_Device_Class dev_class;
912 struct wl_client *wc;
916 EINA_SAFETY_ON_NULL_RETURN(dev);
919 if (ec->cur_mouse_action || e_comp_wl->drag)
921 if (e_object_is_del(E_OBJECT(ec))) return;
922 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
923 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
924 if (!surface) return;
926 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
927 dev_name = evas_device_description_get(dev);
928 last_device = _e_comp_wl_device_last_device_get(dev_class);
929 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
931 serial = wl_display_next_serial(e_comp_wl->wl.disp);
932 wc = wl_resource_get_client(surface);
933 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
934 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
936 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
937 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
939 _e_comp_wl_device_last_device_set(dev_class, input_dev);
940 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
942 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
944 if (wl_resource_get_client(dev_res) != wc) continue;
945 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
949 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
953 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
955 E_Devicemgr_Input_Device *last_device;
956 struct wl_resource *dev_res;
957 struct wl_client *wc;
961 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
962 if (!surface) return;
964 last_device = _e_comp_wl_device_last_device_get(dev_class);
965 if (!last_device) return;
967 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
969 serial = wl_display_next_serial(e_comp_wl->wl.disp);
970 wc = wl_resource_get_client(surface);
971 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
973 if (wl_resource_get_client(dev_res) != wc) continue;
974 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
979 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
981 E_Devicemgr_Input_Device *input_dev;
982 struct wl_resource *dev_res;
983 const char *dev_name;
986 EINA_SAFETY_ON_NULL_RETURN(dev);
988 dev_name = ecore_device_identifier_get(dev);
990 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
991 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
993 if (!eina_streq(input_dev->identifier, dev_name) ||
994 (input_dev->clas != ecore_device_class_get(dev))) continue;
995 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
997 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
999 if (wl_resource_get_client(dev_res) != wc) continue;
1000 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1003 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1007 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1009 E_Devicemgr_Input_Device *input_dev;
1010 struct wl_resource *dev_res;
1011 const char *dev_name;
1014 EINA_SAFETY_ON_NULL_RETURN(dev);
1016 dev_name = e_device_identifier_get(dev);
1018 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1019 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1021 if (!eina_streq(input_dev->identifier, dev_name) ||
1022 (input_dev->clas != e_device_class_get(dev))) continue;
1023 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1025 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1027 if (wl_resource_get_client(dev_res) != wc) continue;
1028 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1031 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1035 _e_comp_wl_cursor_reload(E_Client *ec)
1037 struct wl_resource *res;
1038 struct wl_client *wc;
1044 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1045 !evas_object_visible_get(e_comp->pointer->o_ptr))
1046 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1049 if (e_object_is_del(E_OBJECT(ec))) return;
1050 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1051 if (!surface) return;
1052 if (ec->pointer_enter_sent) return;
1054 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1055 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1057 if (e_client_transform_core_enable_get(ec))
1059 double dx = 0.0, dy = 0.0;
1060 map = e_client_map_get(ec);
1061 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1067 cx = px - ec->client.x;
1068 cy = py - ec->client.y;
1070 wc = wl_resource_get_client(surface);
1071 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1072 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1074 if (!e_comp_wl_input_pointer_check(res)) continue;
1075 if (wl_resource_get_client(res) != wc) continue;
1076 wl_pointer_send_enter(res, serial, surface,
1077 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1078 ec->pointer_enter_sent = EINA_TRUE;
1080 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1084 _e_comp_wl_cursor_timer(void *data)
1086 E_Client *ec = data;
1088 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1089 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1091 e_comp_wl_cursor_hide(ec);
1093 return ECORE_CALLBACK_CANCEL;
1097 _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)
1099 E_Devicemgr_Input_Device *input_dev;
1100 struct wl_resource *dev_res;
1101 struct wl_client *wc;
1106 if (ec->cur_mouse_action) return;
1107 if (e_object_is_del(E_OBJECT(ec))) return;
1108 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1109 if (!surface) return;
1111 f_value = wl_fixed_from_double(value);
1112 wc = wl_resource_get_client(surface);
1114 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1115 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1117 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1118 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1120 if (wl_resource_get_client(dev_res) != wc) continue;
1121 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1124 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1128 _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)
1130 if (idx >= e_input_touch_max_count_get()) return;
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;
1134 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1135 e_devicemgr->multi[idx].radius_y = radius_y;
1136 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1137 e_devicemgr->multi[idx].pressure = pressure;
1138 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1139 e_devicemgr->multi[idx].angle = angle;
1143 _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)
1145 if (idx >= e_input_touch_max_count_get()) return;
1147 if (e_devicemgr->multi[idx].radius_x != radius_x)
1149 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1150 e_devicemgr->multi[idx].radius_x = radius_x;
1152 if (e_devicemgr->multi[idx].radius_y != radius_y)
1154 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1155 e_devicemgr->multi[idx].radius_y = radius_y;
1157 if (e_devicemgr->multi[idx].pressure != pressure)
1159 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1160 e_devicemgr->multi[idx].pressure = pressure;
1162 if (e_devicemgr->multi[idx].angle != angle)
1164 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1165 e_devicemgr->multi[idx].angle = angle;
1170 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1172 Eina_Bool ret = EINA_TRUE;
1175 case EVAS_CALLBACK_MOUSE_IN:
1176 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1179 if (e_comp_wl->ptr.hide_tmr)
1181 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1182 cursor_timer_ec = ec;
1183 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1187 if (e_pointer_is_hidden(e_comp->pointer))
1192 case EVAS_CALLBACK_MOUSE_OUT:
1193 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1196 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1200 case EVAS_CALLBACK_MOUSE_MOVE:
1201 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1204 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1205 _e_comp_wl_cursor_reload(ec);
1208 case EVAS_CALLBACK_MOUSE_WHEEL:
1209 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1212 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1213 _e_comp_wl_cursor_reload(ec);
1216 case EVAS_CALLBACK_MOUSE_DOWN:
1217 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1220 if (e_comp_wl->ptr.hide_tmr)
1222 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1223 e_comp_wl->ptr.hide_tmr = NULL;
1225 cursor_timer_ec = NULL;
1227 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1228 _e_comp_wl_cursor_reload(ec);
1231 case EVAS_CALLBACK_MOUSE_UP:
1232 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1243 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1245 if (ec->has_cursor_unset)
1248 if (!e_config->show_cursor)
1251 if (!e_config->use_cursor_timer)
1258 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1261 Evas_Event_Mouse_In *ev;
1262 struct wl_resource *res;
1263 struct wl_client *wc;
1266 E_Comp_Config *comp_conf;
1267 E_Client *prev_ptr_ec;
1271 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1272 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1274 if (!(ec = data)) return;
1275 if (e_object_is_del(E_OBJECT(ec))) return;
1276 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1277 if (!surface) return;
1279 prev_ptr_ec = e_comp_wl->ptr.ec;
1282 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1283 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1286 e_comp_wl->ptr.ec = ec;
1288 comp_conf = e_comp_config_get();
1289 if (comp_conf && comp_conf->input_log_enable)
1290 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1291 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1292 e_client_util_name_get(ec));
1294 if (_e_comp_wl_check_cursor_timer_needed(ec))
1296 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1300 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1301 wc = wl_resource_get_client(surface);
1302 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1303 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1305 if (!e_comp_wl_input_pointer_check(res)) continue;
1306 if (wl_resource_get_client(res) != wc) continue;
1308 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1310 wl_pointer_send_enter(res, serial, surface,
1311 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1312 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1313 ec->pointer_enter_sent = EINA_TRUE;
1316 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1320 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1323 Evas_Event_Mouse_Out *ev;
1324 struct wl_resource *res;
1325 struct wl_client *wc;
1328 Eina_Bool inside_check;
1329 E_Comp_Config *comp_conf;
1333 if (!(ec = data)) return;
1334 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1335 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1336 if (ec->cur_mouse_action && inside_check) return;
1337 if (e_object_is_del(E_OBJECT(e_comp))) return;
1338 if (e_comp_wl->ptr.ec == ec)
1339 e_comp_wl->ptr.ec = NULL;
1340 if (e_object_is_del(E_OBJECT(ec))) return;
1342 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1343 if (!surface) return;
1345 comp_conf = e_comp_config_get();
1346 if (comp_conf && comp_conf->input_log_enable)
1347 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1348 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1349 e_client_util_name_get(ec));
1351 if (_e_comp_wl_check_cursor_timer_needed(ec))
1353 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1357 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1359 wc = wl_resource_get_client(surface);
1360 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1361 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1363 if (!e_comp_wl_input_pointer_check(res)) continue;
1364 if (wl_resource_get_client(res) != wc) continue;
1365 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1367 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1369 wl_pointer_send_leave(res, serial, surface);
1370 ec->pointer_enter_sent = EINA_FALSE;
1375 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1378 struct wl_client *wc;
1379 struct wl_resource *res;
1382 E_Comp_Config *comp_conf = NULL;
1385 if (e_object_is_del(E_OBJECT(ec))) return;
1386 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1387 if (!surface) return;
1389 wc = wl_resource_get_client(surface);
1390 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1394 x = wl_fixed_from_int(canvas_x - ec->client.x);
1395 y = wl_fixed_from_int(canvas_y - ec->client.y);
1398 comp_conf = e_comp_config_get();
1400 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1402 if (wl_resource_get_client(res) != wc) continue;
1403 if (!e_comp_wl_input_touch_check(res)) continue;
1404 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1407 if (comp_conf && comp_conf->input_log_enable)
1408 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));
1410 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1414 if (comp_conf && comp_conf->input_log_enable)
1415 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));
1417 wl_touch_send_up(res, serial, timestamp, idx);
1424 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1427 struct wl_client *wc;
1428 struct wl_resource *res;
1432 if (ec->cur_mouse_action) return;
1433 if (e_object_is_del(E_OBJECT(ec))) return;
1434 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1435 if (!surface) return;
1437 wc = wl_resource_get_client(surface);
1439 x = wl_fixed_from_int(canvas_x - ec->client.x);
1440 y = wl_fixed_from_int(canvas_y - ec->client.y);
1442 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1444 if (wl_resource_get_client(res) != wc) continue;
1445 if (!e_comp_wl_input_touch_check(res)) continue;
1446 wl_touch_send_motion(res, timestamp, idx, x, y);
1451 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1453 struct wl_resource *res;
1454 struct wl_client *wc;
1458 if (ec->cur_mouse_action) return;
1459 if (e_object_is_del(E_OBJECT(ec))) return;
1460 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1461 if (!surface) return;
1463 wc = wl_resource_get_client(surface);
1464 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1466 if (!e_comp_wl_input_pointer_check(res)) continue;
1467 if (wl_resource_get_client(res) != wc) continue;
1468 wl_pointer_send_motion(res, timestamp,
1469 wl_fixed_from_int(x - ec->client.x),
1470 wl_fixed_from_int(y - ec->client.y));
1475 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1477 if (e_comp_wl->ptr.hide_tmr)
1479 if (cursor_timer_ec == ec)
1481 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1482 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1486 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1487 cursor_timer_ec = ec;
1488 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1493 cursor_timer_ec = ec;
1494 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1499 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1502 Evas_Event_Mouse_Move *ev;
1503 Evas_Device *dev = NULL;
1504 const char *dev_name;
1505 E_Comp_Config *comp_conf;
1509 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1510 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1512 if (!(ec = data)) return;
1513 if (e_object_is_del(E_OBJECT(ec))) return;
1514 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1515 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1516 if (!surface) return;
1518 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1521 dev_name = evas_device_description_get(dev);
1523 comp_conf = e_comp_config_get();
1524 if (comp_conf && comp_conf->input_log_enable)
1525 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1526 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1527 e_client_util_name_get(ec), dev_name);
1529 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1531 if (!e_comp_wl->drag_client)
1533 e_comp_wl->touch.faked_ec = ec;
1534 if (e_comp_wl->touch.pressed & (1 << 0))
1536 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1538 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1539 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1540 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1544 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1548 if (!e_comp_wl->drag_client)
1550 if (_e_comp_wl_check_cursor_timer_needed(ec))
1552 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1556 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1557 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1559 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1561 if (_e_comp_wl_check_cursor_timer_needed(ec))
1562 _e_comp_wl_cursor_move_timer_control(ec);
1566 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1571 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1573 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1574 if (e_object_is_del(E_OBJECT(ec))) return;
1575 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1576 if (!surface) return;
1577 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1579 e_comp_wl->ptr.button = BTN_LEFT;
1581 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1585 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1587 E_Client *ec = data;
1588 Evas_Event_Mouse_Down *ev = event;
1589 Evas_Device *dev = NULL;
1590 const Evas_Device *seat_dev;
1591 const char *dev_name, *seat_name;
1592 E_Comp_Config *comp_conf = NULL;
1595 if (e_object_is_del(E_OBJECT(ec))) return;
1598 dev_name = evas_device_description_get(dev);
1600 seat_dev = evas_device_parent_get(dev);
1601 seat_name = evas_device_name_get(seat_dev);
1603 comp_conf = e_comp_config_get();
1604 if (comp_conf && comp_conf->input_log_enable)
1605 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1606 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1607 dev_name, seat_name);
1609 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1611 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1613 e_comp_wl->touch.faked_ec = ec;
1616 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1617 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1618 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1620 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1621 e_comp_wl->touch.pressed |= (1 << 0);
1625 if (_e_comp_wl_check_cursor_timer_needed(ec))
1627 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1631 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1632 WL_POINTER_BUTTON_STATE_PRESSED);
1634 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1637 need_send_released = EINA_TRUE;
1641 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1643 E_Client *ec = data;
1644 Evas_Event_Mouse_Up *ev = event;
1645 Evas_Device *dev = NULL;
1646 const Evas_Device *seat_dev;
1647 const char *dev_name, *seat_name;;
1648 Evas_Event_Flags flags;
1649 E_Comp_Config *comp_conf = NULL;
1652 if (ec->cur_mouse_action) return;
1653 if (e_object_is_del(E_OBJECT(ec))) return;
1655 if (!need_send_released)
1657 need_send_motion = EINA_TRUE;
1661 dev_name = evas_device_description_get(dev);
1663 seat_dev = evas_device_parent_get(dev);
1664 seat_name = evas_device_name_get(seat_dev);
1665 flags = evas_event_default_flags_get(evas);
1667 comp_conf = e_comp_config_get();
1668 if (comp_conf && comp_conf->input_log_enable)
1669 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1670 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1671 dev_name, seat_name);
1673 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1675 e_comp_wl->touch.pressed &= ~(1 << 0);
1677 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1678 e_comp_wl->touch.faked_ec = NULL;
1681 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1683 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1685 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1688 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1689 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1690 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1694 if (_e_comp_wl_check_cursor_timer_needed(ec))
1696 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1700 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1701 WL_POINTER_BUTTON_STATE_RELEASED);
1703 if (_e_comp_wl_check_cursor_timer_needed(ec))
1704 _e_comp_wl_cursor_move_timer_control(ec);
1708 need_send_released = EINA_FALSE;
1712 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1714 struct wl_resource *res;
1715 struct wl_client *wc;
1720 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1722 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1725 dir = -wl_fixed_from_int(abs(z));
1727 dir = wl_fixed_from_int(z);
1730 if (e_object_is_del(E_OBJECT(ec))) return;
1731 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1732 if (!surface) return;
1734 wc = wl_resource_get_client(surface);
1735 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1737 if (!e_comp_wl_input_pointer_check(res)) continue;
1738 if (wl_resource_get_client(res) != wc) continue;
1739 wl_pointer_send_axis(res, timestamp, axis, dir);
1744 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1747 Evas_Event_Mouse_Wheel *ev;
1750 if (!(ec = data)) return;
1751 if (ec->cur_mouse_action) return;
1752 if (e_object_is_del(E_OBJECT(ec))) return;
1753 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1754 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1755 if (!surface) return;
1757 if (!eina_list_count(e_comp_wl->ptr.resources))
1760 if (_e_comp_wl_check_cursor_timer_needed(ec))
1762 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1766 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1768 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1770 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1772 if (_e_comp_wl_check_cursor_timer_needed(ec))
1773 _e_comp_wl_cursor_move_timer_control(ec);
1778 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1780 E_Client *ec = data;
1781 Evas_Event_Multi_Down *ev = event;
1782 Evas_Device *dev = NULL;
1783 const Evas_Device *seat_dev;
1784 const char *dev_name, *seat_name;
1785 Evas_Device_Class dev_class;
1786 E_Comp_Config *comp_conf = NULL;
1789 if (e_object_is_del(E_OBJECT(ec))) return;
1790 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1791 if (!surface) return;
1793 /* Do not deliver emulated single touch events to client */
1794 if (ev->device == 0) return;
1797 dev_name = evas_device_description_get(dev);
1798 e_comp_wl->touch.faked_ec = ec;
1800 seat_dev = evas_device_parent_get(dev);
1801 seat_name = evas_device_name_get(seat_dev);
1803 comp_conf = e_comp_config_get();
1804 if (comp_conf && comp_conf->input_log_enable)
1805 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1806 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1807 dev_name, seat_name);
1809 if (dev && dev_name)
1811 dev_class = evas_device_class_get(dev);
1812 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1813 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1816 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1817 e_comp_wl->touch.pressed |= (1 << ev->device);
1821 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1823 E_Client *ec = data;
1824 Evas_Event_Multi_Up *ev = event;
1825 Evas_Device *dev = NULL;
1826 const Evas_Device *seat_dev;
1827 const char *dev_name, *seat_name;
1828 Evas_Device_Class dev_class;
1829 Evas_Event_Flags flags;
1830 E_Comp_Config *comp_conf = NULL;
1833 if (e_object_is_del(E_OBJECT(ec))) return;
1834 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1835 if (!surface) return;
1837 /* Do not deliver emulated single touch events to client */
1838 if (ev->device == 0) return;
1840 flags = evas_event_default_flags_get(evas);
1842 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1843 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1844 e_comp_wl->touch.faked_ec = NULL;
1846 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1849 dev_name = evas_device_description_get(dev);
1851 seat_dev = evas_device_parent_get(dev);
1852 seat_name = evas_device_name_get(seat_dev);
1854 comp_conf = e_comp_config_get();
1855 if (comp_conf && comp_conf->input_log_enable)
1856 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1857 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1858 dev_name, seat_name);
1860 if (dev && dev_name)
1862 dev_class = evas_device_class_get(dev);
1863 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1864 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1867 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1871 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1873 E_Client *ec = data;
1874 Evas_Event_Multi_Move *ev = event;
1875 Evas_Device *dev = NULL;
1876 const char *dev_name;
1877 Evas_Device_Class dev_class;
1880 if (e_object_is_del(E_OBJECT(ec))) return;
1881 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1882 if (!surface) return;
1884 /* Do not deliver emulated single touch events to client */
1885 if (ev->device == 0) return;
1887 e_comp_wl->touch.faked_ec = ec;
1889 if (e_comp_wl->touch.pressed & (1 << ev->device))
1892 if (dev && (dev_name = evas_device_description_get(dev)))
1894 dev_class = evas_device_class_get(dev);
1895 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1896 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1899 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1904 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1907 char *file, buff[PATH_MAX];
1914 n = (getpriority(PRIO_PROCESS, pid) + adj);
1918 setpriority(PRIO_PROCESS, pid, n);
1921 use_adj = EINA_TRUE;
1923 if (!do_child) return;
1925 files = ecore_file_ls("/proc");
1926 EINA_LIST_FREE(files, file)
1928 if (!isdigit(file[0]))
1931 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1932 if ((f = fopen(buff, "r")))
1936 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1938 if (num_read == 2 && ppid == pid)
1939 _e_comp_wl_client_priority_adjust(pid2, set,
1941 adj_child, do_child);
1949 _e_comp_wl_client_priority_raise(E_Client *ec)
1951 if (!e_config->priority_control) return;
1952 if (ec->netwm.pid <= 0) return;
1953 if (ec->netwm.pid == getpid()) return;
1954 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1955 e_config->priority - 1, -1,
1956 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1960 _e_comp_wl_client_priority_normal(E_Client *ec)
1962 if (!e_config->priority_control) return;
1963 if (ec->netwm.pid <= 0) return;
1964 if (ec->netwm.pid == getpid()) return;
1965 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1966 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1970 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1973 E_Comp_Wl_Key_Data *k;
1974 struct wl_resource *res;
1978 if (!ec) return EINA_FALSE;
1979 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1980 if (!ec->comp_data) return EINA_FALSE;
1982 ec->comp_data->on_focus_timer = NULL;
1983 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1984 if (!e_comp_wl->kbd.focused)
1986 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1989 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1991 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1992 t = ecore_time_unix_get();
1994 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1995 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1996 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1998 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2000 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2001 wl_keyboard_send_key(res, serial, t,
2002 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2005 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2006 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2010 /* It is called in the following cases:
2011 * When a normal ec->frame has focus.
2012 * Or launching image ec is replaced to the real ec.
2015 e_comp_wl_feed_focus_in(E_Client *ec)
2018 struct wl_resource *res;
2019 struct wl_client *wc;
2023 if (e_object_is_del(E_OBJECT(ec))) return;
2024 if (ec->iconic) return;
2026 /* block spurious focus events */
2027 focused = e_client_focused_get();
2028 if ((focused) && (ec != focused)) return;
2030 /* raise client priority */
2031 _e_comp_wl_client_priority_raise(ec);
2032 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2033 if (!surface) return;
2035 wc = wl_resource_get_client(surface);
2037 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2038 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2040 if (wl_resource_get_client(res) == wc)
2042 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2043 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2044 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2045 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2048 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2050 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2051 if (!e_comp_wl->kbd.focused)
2053 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2056 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2058 e_comp_wl->kbd.focus = surface;
2059 e_comp_wl_input_keyboard_enter_send(ec);
2060 e_comp_wl_data_device_keyboard_focus_set();
2061 ec->comp_data->on_focus_timer =
2062 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2063 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2064 int rotation = ec->e.state.rot.ang.curr;
2065 e_pointer_rotation_set(e_comp->pointer, rotation);
2069 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2072 if (!(ec = data)) return;
2073 e_comp_wl_feed_focus_in(ec);
2077 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2080 struct wl_resource *res;
2082 E_Comp_Wl_Key_Data *k;
2086 if (!(ec = data)) return;
2088 if (!ec->comp_data) return;
2090 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2092 /* lower client priority */
2093 if (!e_object_is_del(data))
2094 _e_comp_wl_client_priority_normal(ec);
2097 /* update keyboard modifier state */
2098 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2099 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2100 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2102 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2104 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2105 if (!surface) return;
2107 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2108 if (!eina_list_count(e_comp_wl->kbd.resources))
2110 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2114 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2116 /* send keyboard_leave to all keyboard resources */
2117 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2118 t = ecore_time_unix_get();
2120 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2121 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2122 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2124 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2126 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2127 wl_keyboard_send_key(res, serial, t,
2128 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2130 wl_keyboard_send_leave(res, serial, surface);
2131 e_comp_wl->kbd.focused =
2132 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2134 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2135 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2139 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2143 if (!(ec = data)) return;
2145 if (!ec->comp_data->shell.configure_send) return;
2147 /* TODO: calculate x, y with transfrom object */
2148 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2152 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2153 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2154 if (e_comp_object_frame_exists(ec->frame))
2155 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2157 switch (ec->resize_mode)
2159 case E_POINTER_RESIZE_TL:
2160 case E_POINTER_RESIZE_L:
2161 case E_POINTER_RESIZE_BL:
2162 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2163 ec->mouse.current.mx;
2165 case E_POINTER_RESIZE_TR:
2166 case E_POINTER_RESIZE_R:
2167 case E_POINTER_RESIZE_BR:
2168 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2173 switch (ec->resize_mode)
2175 case E_POINTER_RESIZE_TL:
2176 case E_POINTER_RESIZE_T:
2177 case E_POINTER_RESIZE_TR:
2178 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2179 ec->mouse.current.my;
2181 case E_POINTER_RESIZE_BL:
2182 case E_POINTER_RESIZE_B:
2183 case E_POINTER_RESIZE_BR:
2184 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2189 w = E_CLAMP(w, 1, w);
2190 h = E_CLAMP(h, 1, h);
2191 e_client_resize_limit(ec, &w, &h);
2193 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2195 else if ((!ec->fullscreen) && (!ec->maximized) &&
2196 (!ec->comp_data->maximize_pre))
2200 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2201 if ((pw != ec->w) || (ph != ec->h))
2203 _e_comp_wl_configure_send(ec, 1, 1);
2207 if (ec->comp_data->sub.below_obj)
2208 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2212 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2214 E_Client *ec = data;
2216 ec->comp_data->maximize_pre = 1;
2220 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2222 E_Client *ec = data;
2225 if (e_object_is_del(E_OBJECT(ec))) return;
2227 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2228 e_client_shell_configure_send(ec, 0, w, h);
2230 ec->comp_data->maximize_pre = 0;
2234 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2236 E_Client *ec = data;
2238 ec->comp_data->maximize_pre = 1;
2242 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2244 E_Client *ec = data;
2246 if (e_object_is_del(E_OBJECT(ec))) return;
2248 /* check for wayland pixmap */
2250 if (ec->comp_data->shell.configure_send)
2251 _e_comp_wl_configure_send(ec, 0, 0);
2253 ec->comp_data->maximize_pre = 0;
2257 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2259 E_Client *ec = data;
2261 if (e_object_is_del(E_OBJECT(ec))) return;
2263 /* check for wayland pixmap */
2265 if (ec->comp_data->shell.configure_send)
2266 _e_comp_wl_configure_send(ec, 0, 1);
2268 ec->comp_data->maximize_pre = 0;
2272 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2274 E_Client *ec = data;
2276 if (e_object_is_del(E_OBJECT(ec))) return;
2278 /* check for wayland pixmap */
2280 if (ec->comp_data->shell.configure_send)
2281 _e_comp_wl_configure_send(ec, 0, 0);
2283 ec->comp_data->maximize_pre = 0;
2287 _e_comp_wl_evas_cb_delete_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));
2295 e_object_del(E_OBJECT(ec));
2297 _e_comp_wl_focus_check();
2299 /* TODO: Delete request send ??
2300 * NB: No such animal wrt wayland */
2304 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2308 if (!(ec = data)) return;
2310 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2313 if (ec->comp_data->reparented)
2314 e_client_comp_hidden_set(ec, EINA_TRUE);
2317 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2318 if (ec->visible) evas_object_hide(ec->frame);
2319 if (!ec->internal) e_object_del(E_OBJECT(ec));
2321 _e_comp_wl_focus_check();
2325 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2329 if (!(ec = data)) return;
2331 e_client_shell_ping(ec);
2335 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2340 if (!(ec = data)) return;
2341 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2342 if (ec->netwm.opacity == a) return;
2343 ec->netwm.opacity = a;
2344 ec->netwm.opacity_changed = EINA_TRUE;
2348 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2350 Eina_Rectangle *damage_rect = NULL;
2351 Eina_Rectangle *dmg = NULL;
2352 Eina_List *l = NULL;
2354 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2355 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2358 if (!buffer->tbm_surface) return;
2362 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2366 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2367 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2370 eina_rectangle_union(damage_rect, dmg);
2375 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2376 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2379 tbm_surface_internal_set_damage(buffer->tbm_surface,
2385 eina_rectangle_free(damage_rect);
2389 _e_comp_wl_client_evas_init(E_Client *ec)
2391 if (!ec || !ec->comp_data) return;
2392 if (ec->comp_data->evas_init) return;
2394 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2395 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2396 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2399 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2400 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2401 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2403 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2404 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2406 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2407 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2408 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2410 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2411 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2415 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2416 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2417 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2418 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2419 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2420 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2421 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2424 /* setup delete/kill callbacks */
2425 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2426 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2428 /* setup ping callback */
2429 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2430 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2432 ec->comp_data->evas_init = EINA_TRUE;
2436 _e_comp_wl_client_evas_deinit(E_Client *ec)
2438 if (!ec || !ec->comp_data) return;
2439 if (!ec->comp_data->evas_init) return;
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2445 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2446 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2449 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2453 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2454 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2456 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2457 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2461 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2462 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2463 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2464 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2465 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2466 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2467 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2470 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2471 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2473 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2474 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2476 ec->comp_data->evas_init = EINA_FALSE;
2480 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2484 E_Comp_Screen *e_comp_screen;
2485 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2487 if (!e_comp) return ECORE_CALLBACK_RENEW;
2488 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2489 e_comp_screen = e_comp->e_comp_screen;
2491 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2493 if (!eout->config.enabled)
2495 e_comp_wl_output_remove(eout->id);
2499 switch (eout->config.rotation)
2502 transform = WL_OUTPUT_TRANSFORM_90;
2505 transform = WL_OUTPUT_TRANSFORM_180;
2508 transform = WL_OUTPUT_TRANSFORM_270;
2512 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2516 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2518 eout->config.geom.x, eout->config.geom.y,
2519 eout->config.geom.w, eout->config.geom.h,
2520 eout->info.size.w, eout->info.size.h,
2521 eout->config.mode.refresh, 0, transform))
2522 ERR("Could not initialize screen %s", eout->info.name);
2525 return ECORE_CALLBACK_RENEW;
2529 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2533 /* try to get the client from the object */
2534 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2535 return ECORE_CALLBACK_RENEW;
2537 /* check for client being deleted */
2538 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2540 /* check for wayland pixmap */
2541 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2542 return ECORE_CALLBACK_RENEW;
2544 /* if we have not setup evas callbacks for this client, do it */
2545 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2547 return ECORE_CALLBACK_RENEW;
2551 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2555 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2556 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2558 if (e_comp_wl->selection.target &&
2561 struct wl_resource *res;
2563 E_Client *ec = NULL;
2564 E_Client *legacy_target = e_comp_wl->selection.target;
2565 int device_id = e_comp_wl_data_current_device_id_get();
2569 e_comp_wl_data_current_device_id_set(ev->multi.device);
2571 else if (device_id != ev->multi.device)
2573 return ECORE_CALLBACK_RENEW;
2576 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2577 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2579 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2580 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2582 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2583 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2585 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2586 (ec != legacy_target))
2588 e_comp_wl_data_device_send_leave(legacy_target);
2589 e_comp_wl_data_device_send_enter(ec);
2592 if (e_comp_wl->drag)
2593 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2595 if (e_client_transform_core_enable_get(ec))
2597 int trans_x, trans_y;
2598 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2599 x = trans_x - ec->client.x;
2600 y = trans_y - ec->client.y;
2604 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2609 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2612 return ECORE_CALLBACK_RENEW;
2616 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2619 struct wl_resource *surface;
2620 struct wl_resource *res;
2621 struct wl_client *wc;
2623 E_Comp_Config *comp_conf;
2625 ec = e_comp_wl->ptr_constraints.ec;
2626 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2628 surface = e_comp_wl_client_surface_get(ec);
2629 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2631 wc = wl_resource_get_client(surface);
2633 comp_conf = e_comp_config_get();
2635 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2637 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2638 if (wl_resource_get_client(res) != wc) continue;
2640 if (comp_conf && comp_conf->input_log_enable)
2641 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2642 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2643 e_client_util_name_get(ec));
2645 zwp_relative_pointer_v1_send_relative_motion(res,
2647 (uint32_t)(ev->timestamp),
2648 wl_fixed_from_int(ev->dx),
2649 wl_fixed_from_int(ev->dy),
2650 wl_fixed_from_int(ev->dx_unaccel),
2651 wl_fixed_from_int(ev->dy_unaccel));
2654 return ECORE_CALLBACK_DONE;
2658 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2660 _e_comp_wl_touch_cancel();
2662 return ECORE_CALLBACK_PASS_ON;
2666 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2668 if (!ev) return ECORE_CALLBACK_PASS_ON;
2670 E_Zone *zone = ev->zone;
2672 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2673 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2675 if (!e_zone_is_displaying(zone))
2676 _e_comp_wl_touch_cancel();
2678 return ECORE_CALLBACK_PASS_ON;
2682 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2684 E_Client *ec = ev->ec;
2685 E_Comp_Wl_Buffer_Viewport *vp;
2687 if (!ec) return ECORE_CALLBACK_PASS_ON;
2688 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2689 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2690 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2691 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2693 vp = &ec->comp_data->scaler.buffer_viewport;
2694 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2696 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2698 return ECORE_CALLBACK_PASS_ON;
2702 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2704 E_Client *ec = ev->ec;
2705 E_Comp_Wl_Buffer_Viewport *vp;
2707 if (!ec) return ECORE_CALLBACK_PASS_ON;
2708 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2709 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2710 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2712 vp = &ec->comp_data->scaler.buffer_viewport;
2713 vp->wait_for_transform_change = 0;
2715 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2717 return ECORE_CALLBACK_PASS_ON;
2721 _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)
2723 E_Client *focused_ec;
2726 focused_ec = e_client_focused_get();
2727 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2729 rotation = focused_ec->e.state.rot.ang.curr;
2730 e_pointer_rotation_set(e_comp->pointer, rotation);
2732 return ECORE_CALLBACK_PASS_ON;
2736 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2739 Eina_Rectangle *window;
2744 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2746 if ((prev_w != state->bw) ||
2747 (prev_h != state->bh))
2749 ec->changes.buf_size = EINA_TRUE;
2752 if (e_comp_object_frame_exists(ec->frame)) return;
2753 window = &ec->comp_data->shell.window;
2754 if ((!ec->borderless) && /* FIXME temporarily added this check code
2755 * to prevent updating E_Client's size by frame */
2756 (window->x || window->y || window->w || window->h))
2758 e_comp_object_frame_geometry_set(ec->frame,
2760 (window->x + window->w) - state->bw,
2762 (window->y + window->h) - state->bh);
2765 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2769 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2771 E_Comp_Wl_Surface_State *state;
2774 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2775 state->buffer = NULL;
2779 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2781 state->new_attach = EINA_FALSE;
2782 state->buffer = NULL;
2783 state->buffer_destroy_listener.notify =
2784 _e_comp_wl_surface_state_cb_buffer_destroy;
2785 state->sx = state->sy = 0;
2787 state->input = eina_tiler_new(w, h);
2788 eina_tiler_tile_size_set(state->input, 1, 1);
2790 state->opaque = eina_tiler_new(w, h);
2791 eina_tiler_tile_size_set(state->opaque, 1, 1);
2793 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2794 state->buffer_viewport.buffer.scale = 1;
2795 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2796 state->buffer_viewport.surface.width = -1;
2797 state->buffer_viewport.changed = 0;
2799 e_presentation_time_container_init(&state->presentation_container);
2803 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2805 struct wl_resource *cb;
2806 Eina_Rectangle *dmg;
2808 EINA_LIST_FREE(state->frames, cb)
2809 wl_resource_destroy(cb);
2811 EINA_LIST_FREE(state->damages, dmg)
2812 eina_rectangle_free(dmg);
2814 EINA_LIST_FREE(state->buffer_damages, dmg)
2815 eina_rectangle_free(dmg);
2817 if (state->opaque) eina_tiler_free(state->opaque);
2818 state->opaque = NULL;
2820 if (state->input) eina_tiler_free(state->input);
2821 state->input = NULL;
2823 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2824 state->buffer = NULL;
2826 e_presentation_time_container_finish(&state->presentation_container);
2830 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2832 if (state->buffer == buffer) return;
2834 wl_list_remove(&state->buffer_destroy_listener.link);
2835 state->buffer = buffer;
2837 wl_signal_add(&state->buffer->destroy_signal,
2838 &state->buffer_destroy_listener);
2842 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2844 Eina_Rectangle *dmg;
2845 Eina_Bool placed = EINA_TRUE;
2849 E_Comp_Wl_Buffer *buffer;
2850 struct wl_resource *cb;
2852 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2853 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2858 if ((ec->internal) ||
2859 (cdata->shell.surface && state->new_attach))
2863 e_comp->new_clients++;
2864 ELOGF("COMP", "Unignore", ec);
2865 e_client_unignore(ec);
2869 /* buffer transform */
2870 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2873 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2875 /* when buffer is transformed, we have to apply the new evas-map */
2876 state->buffer_viewport.changed = EINA_TRUE;
2878 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2880 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2882 if (transform_change == vp->wait_for_transform_change)
2883 vp->wait_for_transform_change = 0;
2885 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2886 // triggered by E_CLIENT_HOOK calls at those file.
2887 zone = e_comp_zone_find_by_ec(ec);
2890 eout = e_output_find(zone->output_id);
2891 if (eout && eout->hwc)
2893 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2895 if (e_comp_is_on_overlay(ec))
2896 e_comp_hwc_client_end(ec, __FUNCTION__);
2902 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2903 cdata->scaler.buffer_viewport = state->buffer_viewport;
2905 if (state->new_attach)
2907 e_comp_wl_surface_attach(ec, state->buffer);
2910 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2911 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2913 _e_comp_wl_surface_state_buffer_set(state, NULL);
2915 if ((state->new_attach) ||
2916 (state->buffer_viewport.changed))
2918 _e_comp_wl_surface_state_size_update(ec, state);
2919 e_comp_wl_map_size_cal_from_viewport(ec);
2921 /* update the position */
2922 if (ec->changes.pos)
2924 e_comp_object_frame_xy_unadjust(ec->frame,
2934 if (ec->new_client) placed = ec->placed;
2936 if (!ec->lock_client_size)
2941 ec->client.w = state->bw;
2942 ec->client.h = state->bh;
2944 e_comp_object_frame_wh_adjust(ec->frame,
2945 ec->client.w, ec->client.h,
2947 e_client_size_set(ec, nw, nh);
2949 if ((w != ec->w) || (h != ec->h))
2951 ec->changes.size = 1;
2956 if (ec->changes.buf_size)
2958 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2959 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2960 ec->changes.buf_size = EINA_FALSE;
2962 if (ec->move_after_resize)
2964 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2965 ec->move_after_resize = EINA_FALSE;
2970 /* map or unmap ec */
2971 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2972 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2973 if (!pixmap_usable || hide_by_request)
2978 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2983 if ((cdata->sub.below_obj) &&
2984 (evas_object_visible_get(cdata->sub.below_obj)))
2986 evas_object_hide(cdata->sub.below_obj);
2994 if ((cdata->sub.below_obj) &&
2995 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2996 (evas_object_visible_get(ec->frame)))
2998 evas_object_show(cdata->sub.below_obj);
3002 if ((state->new_attach) ||
3003 (state->buffer_viewport.changed))
3005 if ((e_comp_wl->drag) &&
3006 (e_comp_wl->drag_client) &&
3007 (e_comp_wl->drag_client == ec))
3009 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3011 e_drag_move(e_comp_wl->drag,
3013 e_comp_wl->drag->y);
3015 e_drag_resize(e_comp_wl->drag,
3016 state->bw, state->bh);
3018 else if ((cdata->shell.surface) &&
3019 (cdata->shell.configure))
3021 e_comp_wl_commit_sync_configure(ec);
3023 else if (!e_client_video_hw_composition_check(ec))
3025 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3030 ec->placed = placed;
3031 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3035 if (cdata->scaler.buffer_viewport.changed)
3036 e_comp_wl_map_apply(ec);
3038 /* resize transform object */
3039 if (ec->transformed)
3040 e_client_transform_update(ec);
3044 state->new_attach = EINA_FALSE;
3046 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3048 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3049 wl_resource_destroy(cb);
3052 /* insert state frame callbacks into comp_data->frames
3053 * NB: This clears state->frames list */
3054 cdata->frames = eina_list_merge(cdata->frames,
3056 state->frames = NULL;
3058 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3059 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3060 &state->presentation_container);
3062 buffer = e_pixmap_resource_get(ec->pixmap);
3064 /* put state damages into surface */
3067 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3068 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3070 if ((cdata->buffer_ref.buffer) &&
3071 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3072 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3074 e_comp_object_damage(ec->frame,
3076 cdata->buffer_ref.buffer->w,
3077 cdata->buffer_ref.buffer->h);
3082 Eina_List *damages = NULL;
3085 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3087 if (eina_list_count(state->buffer_damages))
3089 EINA_LIST_FREE(state->buffer_damages, dmg)
3092 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3093 e_comp_wl_output_buffer_transform_get(ec),
3095 dmg->x, dmg->y, dmg->w, dmg->h,
3096 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3097 damages = eina_list_append(damages, dmg);
3101 EINA_LIST_FREE(state->damages, dmg)
3102 damages = eina_list_append(damages, dmg);
3104 EINA_LIST_FREE(damages, dmg)
3106 /* not creating damage for ec that shows a underlay video */
3107 if (state->buffer_viewport.changed ||
3108 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3109 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3110 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3112 eina_rectangle_free(dmg);
3117 /* put state opaque into surface */
3118 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3121 Eina_Rectangle *rect;
3124 itr = eina_tiler_iterator_new(state->opaque);
3125 EINA_ITERATOR_FOREACH(itr, rect)
3129 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3130 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3131 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3135 eina_iterator_free(itr);
3138 /* put state input into surface */
3139 if ((state->input) &&
3140 (!eina_tiler_empty(state->input)) &&
3143 Eina_Tiler *src, *tmp;
3147 tmp = eina_tiler_new(sw, sh);
3148 eina_tiler_tile_size_set(tmp, 1, 1);
3150 eina_tiler_rect_add(tmp,
3151 &(Eina_Rectangle){0, 0, sw, sh});
3153 if ((src = eina_tiler_intersection(state->input, tmp)))
3155 Eina_Rectangle *rect;
3158 e_comp_object_input_objs_del(ec->frame);
3159 itr = eina_tiler_iterator_new(src);
3160 EINA_ITERATOR_FOREACH(itr, rect)
3162 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3163 ec, rect->x, rect->y, rect->w, rect->h,
3164 ec->w, ec->h, state->bw, state->bh);
3165 e_comp_object_input_area_set(ec->frame,
3170 eina_iterator_free(itr);
3171 eina_tiler_free(src);
3174 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3176 eina_tiler_free(tmp);
3178 /* clear input tiler */
3179 eina_tiler_clear(state->input);
3182 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3184 if ((cdata->video_client) &&
3186 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3187 (e_comp->wl_comp_data->available_hw_accel.underlay))
3189 e_pixmap_image_clear(ec->pixmap, 1);
3192 state->buffer_viewport.changed = 0;
3194 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3197 ec->exp_iconify.buffer_flush &&
3198 e_policy_visibility_client_is_iconic(ec))
3200 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3205 _e_comp_wl_surface_render_stop(E_Client *ec)
3207 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3208 //if ((!ec->internal) && (!e_comp_gl_get()))
3211 /* check if internal animation is running */
3212 if (e_comp_object_is_animating(ec->frame)) return;
3213 /* check if external animation is running */
3214 if (evas_object_data_get(ec->frame, "effect_running")) return;
3216 evas_object_hide(ec->frame);
3220 e_comp_wl_client_surface_finish(E_Client *ec)
3222 struct wl_resource *res, *surface;
3223 struct wl_client *surface_client = NULL;
3226 surface = e_comp_wl_client_surface_get(ec);
3229 surface_client = wl_resource_get_client(surface);
3231 if (surface_client &&
3232 (ec == e_client_focused_get()))
3234 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3235 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3237 if (wl_resource_get_client(res) ==
3239 e_comp_wl->kbd.focused =
3240 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3244 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3247 e_comp_wl_client_surface_set(ec, NULL);
3249 ec->comp_data->wl_surface = NULL;
3250 e_pixmap_win_id_del(ec->pixmap);
3252 _e_comp_wl_surface_render_stop(ec);
3253 e_object_del(E_OBJECT(ec));
3257 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3262 char proc[512], pname[512];
3265 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3267 h = fopen(proc, "r");
3270 len = fread(pname, sizeof(char), 512, h);
3272 pname[len - 1] = '\0';
3274 strncpy(pname, "NO NAME", sizeof(pname));
3280 strncpy(pname, "NO NAME", sizeof(pname));
3283 strncpy(name, pname, size);
3287 _e_comp_wl_pname_print(pid_t pid)
3290 char proc[512], pname[512];
3293 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3295 h = fopen(proc, "r");
3298 len = fread(pname, sizeof(char), 512, h);
3300 pname[len - 1] = '\0';
3302 strncpy(pname, "NO NAME", sizeof(pname));
3306 ELOGF("COMP", " |%s", NULL, pname);
3311 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3313 struct wl_client *client = data;
3314 E_Comp_Connected_Client_Info *cinfo;
3317 cinfo = wl_container_of(listener, cinfo, destroy);
3319 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3320 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3322 eai = e_appinfo_find_with_pid(cinfo->pid);
3323 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3326 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3328 wl_list_remove(&cinfo->destroy.link);
3329 eina_stringshare_del(cinfo->name);
3334 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3336 E_Comp_Connected_Client_Info *cinfo;
3338 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3339 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3341 cinfo->name = eina_stringshare_add(name);
3345 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3346 wl_client_add_destroy_listener(client, &cinfo->destroy);
3347 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3349 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3353 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3355 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3357 /* send configure */
3358 if (ec->comp_data->shell.configure_send)
3360 if (ec->comp_data->shell.surface)
3361 _e_comp_wl_configure_send(ec, 0, 0);
3364 e_comp_wl->kbd.focus = ec->comp_data->surface;
3368 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3370 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3372 /* send configure */
3373 if (ec->comp_data->shell.configure_send)
3375 if (ec->comp_data->shell.surface)
3376 _e_comp_wl_configure_send(ec, 0, 0);
3379 _e_comp_wl_focus_check();
3381 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3382 e_comp_wl->kbd.focus = NULL;
3386 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3388 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3389 if (ec->keyboard_resizing) return;
3391 /* do nothing currently */
3396 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3398 if (e_object_is_del(E_OBJECT(ec))) return;
3399 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3401 e_comp_wl->resize.edges = 0;
3402 e_comp_wl->resize.resource = NULL;
3406 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3408 if (e_object_is_del(E_OBJECT(ec))) return;
3409 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3413 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3416 int ratio_w, ratio_h;
3418 phys_w = output->phys_width;
3419 phys_h = output->phys_height;
3421 if (e_config->configured_output_resolution.use)
3423 // change the configured physical size(mm) of the output
3424 if (output->w != res_w)
3426 ratio_w = res_w / output->w;
3427 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3430 if (output->h != res_h)
3432 ratio_h = res_h / output->h;
3433 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3436 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3439 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3440 NULL, res_w, res_h, phys_w, phys_h, pid);
3442 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3443 wl_output_send_scale(resource, output->scale);
3445 wl_output_send_geometry(resource, output->x, output->y,
3447 output->subpixel, output->make ?: "",
3448 output->model ?: "", output->transform);
3450 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3451 res_w, res_h, output->refresh);
3453 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3454 wl_output_send_done(resource);
3458 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3460 E_Comp_Wl_Output *output;
3462 if (!(output = wl_resource_get_user_data(resource))) return;
3464 output->resources = eina_list_remove(output->resources, resource);
3468 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3470 E_Comp_Wl_Output *output;
3471 struct wl_resource *resource;
3472 E_Appinfo *eai = NULL;
3476 if (!(output = data)) return;
3479 wl_resource_create(client, &wl_output_interface, version, id);
3482 wl_client_post_no_memory(client);
3486 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3487 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3489 output->resources = eina_list_append(output->resources, resource);
3491 wl_resource_set_implementation(resource, NULL, output,
3492 _e_comp_wl_cb_output_unbind);
3493 wl_resource_set_user_data(resource, output);
3495 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3496 if (e_config->configured_output_resolution.use)
3498 wl_client_get_credentials(client, &pid, NULL, NULL);
3501 res_w = e_config->configured_output_resolution.w;
3502 res_h = e_config->configured_output_resolution.h;
3506 eai = e_appinfo_find_with_pid(pid);
3509 res_w = e_config->configured_output_resolution.w;
3510 res_h = e_config->configured_output_resolution.h;
3514 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3516 res_w = e_config->configured_output_resolution.w;
3517 res_h = e_config->configured_output_resolution.h;
3521 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3530 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3534 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3537 Evas_GL *evasgl = NULL;
3538 Evas_GL_API *glapi = NULL;
3539 Evas_GL_Context *ctx = NULL;
3540 Evas_GL_Surface *sfc = NULL;
3541 Evas_GL_Config *cfg = NULL;
3543 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3545 if (!e_comp_gl_get()) return;
3547 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3548 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3550 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3551 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3553 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3554 * then we should get evas from ecore_evas.
3557 evas = e_comp->evas;
3559 evas = ecore_evas_get(e_comp->ee);
3561 evasgl = evas_gl_new(evas);
3562 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3564 glapi = evas_gl_api_get(evasgl);
3565 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3566 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3568 cfg = evas_gl_config_new();
3569 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3571 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3572 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3574 ctx = evas_gl_context_create(evasgl, NULL);
3575 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3577 res = evas_gl_make_current(evasgl, sfc, ctx);
3578 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3580 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3581 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3583 evas_gl_config_free(cfg);
3585 evas_gl->gl = evasgl;
3586 evas_gl->glapi = glapi;
3587 evas_gl->glsfc = sfc;
3588 evas_gl->glctx = ctx;
3590 e_comp_wl->evas_gl = evas_gl;
3592 /* for native surface */
3595 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3600 evas_gl_config_free(cfg);
3601 evas_gl_make_current(evasgl, NULL, NULL);
3602 evas_gl_context_destroy(evasgl, ctx);
3603 evas_gl_surface_destroy(evasgl, sfc);
3604 evas_gl_free(evasgl);
3611 _e_comp_wl_gl_popup_cb_close(void *data,
3612 Evas_Object *obj EINA_UNUSED,
3613 void *event_info EINA_UNUSED)
3615 evas_object_del(data);
3619 _e_comp_wl_gl_popup_cb_focus(void *data,
3620 Evas_Object *obj EINA_UNUSED,
3621 void *event_info EINA_UNUSED)
3623 elm_object_focus_set(data, EINA_TRUE);
3628 _e_comp_wl_gl_idle(void *data)
3632 /* show warning window to notify failure of gl init */
3635 Evas_Object *win, *bg, *popup, *btn;
3637 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3638 elm_win_title_set(win, "Compositor Warning");
3639 elm_win_autodel_set(win, EINA_TRUE);
3640 elm_win_borderless_set(win, EINA_TRUE);
3641 elm_win_role_set(win, "notification-low");
3642 elm_win_alpha_set(win, EINA_TRUE);
3644 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3645 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3646 elm_win_resize_object_add(win, bg);
3647 evas_object_color_set(bg, 125, 125, 125, 125);
3648 evas_object_show(bg);
3650 popup = elm_popup_add(win);
3651 elm_object_text_set(popup,
3652 _( "Your screen does not support OpenGL.<br>"
3653 "Falling back to software engine."));
3654 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3656 btn = elm_button_add(popup);
3657 elm_object_text_set(btn, "Close");
3658 elm_object_part_content_set(popup, "button1", btn);
3659 evas_object_show(btn);
3661 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3662 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3664 evas_object_show(popup);
3665 evas_object_show(win);
3669 return ECORE_CALLBACK_CANCEL;
3673 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3675 struct wl_client *client = data;
3681 wl_client_get_credentials(client, &pid, &uid, &gid);
3683 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3685 _e_comp_wl_pname_print(pid);
3686 _e_comp_wl_pname_get(pid, name, sizeof(name));
3687 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3691 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3693 char buf[1024] = {0, };
3695 vsnprintf(buf, 1024, fmt, args);
3699 DBG("[libds] %s", buf);
3702 INF("[libds] %s", buf);
3705 ERR("[libds] %s", buf);
3713 _e_comp_wl_display_create(void)
3716 E_Comp_Wl_Data *wl_cdata;
3721 /* create new compositor data */
3722 if (!(comp = E_NEW(E_Comp_Data, 1)))
3724 ERR("Could not create compositor data: %m");
3727 wl_cdata = &comp->base;
3729 /* set compositor wayland data */
3730 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3732 g_mutex_init(&connection_mutex);
3734 /* try to create a wayland display */
3735 if (!(wl_cdata->wl.disp = wl_display_create()))
3737 ERR("Could not create a Wayland display: %m");
3741 /* try to setup wayland socket */
3742 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3744 ERR("Could not create Wayland display socket: %m");
3745 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3749 res = e_comp_socket_init(name);
3750 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3751 PRCTL("[Winsys] change permission and create sym link for %s", name);
3753 /* set wayland display environment variable */
3754 e_env_set("WAYLAND_DISPLAY", name);
3756 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3757 /* wl_cdata->output.scale = e_scale; */
3759 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3761 if (!e_compositor_init(wl_cdata->wl.disp))
3763 ERR("Failed to initialize compositor");
3767 comp->client_created.notify = _e_comp_wl_cb_client_created;
3768 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3770 if (!e_comp_wl_subsurfaces_init())
3772 ERR("Failed to init_subsurfaces");
3773 goto subsurfaces_err;
3776 /* initialize shm mechanism */
3777 wl_display_init_shm(wl_cdata->wl.disp);
3779 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3781 /* try to init data manager */
3782 if (!e_comp_wl_data_manager_init())
3784 ERR("Could not initialize data manager");
3788 /* try to init input */
3789 if (!e_comp_wl_input_init())
3791 ERR("Could not initialize input");
3795 if (e_comp_gl_get())
3796 _e_comp_wl_gl_init(NULL);
3798 /* get the wayland display loop */
3799 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3801 /* get the file descriptor of the wayland event loop */
3802 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3804 /* create a listener for wayland main loop events */
3806 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3807 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3808 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3809 _e_comp_wl_cb_prepare, wl_cdata);
3814 e_comp_wl_data_manager_shutdown();
3816 e_comp_wl_subsurfaces_shutdown();
3818 wl_list_remove(&comp->client_created.link);
3820 e_env_unset("WAYLAND_DISPLAY");
3822 wl_display_destroy(wl_cdata->wl.disp);
3824 g_mutex_clear(&connection_mutex);
3830 _e_comp_wl_gl_shutdown(void)
3832 if (!e_comp_wl->evas_gl) return;
3834 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3836 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3837 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3838 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3839 evas_gl_free(e_comp_wl->evas_gl->gl);
3841 E_FREE(e_comp_wl->evas_gl);
3844 /* public functions */
3847 * Creates and initializes a Wayland compositor with ecore.
3848 * Registers callback handlers for keyboard and mouse activity
3849 * and other client events.
3851 * @returns true on success, false if initialization failed.
3854 e_comp_wl_init(void)
3856 TRACE_DS_BEGIN(COMP_WL:INIT);
3858 /* try to create a wayland compositor */
3859 if (!_e_comp_wl_display_create())
3861 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3866 e_comp_wl_shell_init();
3868 #ifdef HAVE_WAYLAND_TBM
3869 e_comp_wl_tbm_init();
3871 e_comp_wl_remote_surface_init();
3875 e_comp_wl_screenshooter_init();
3877 if (!e_comp_wl_video_init())
3878 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3880 e_comp_wl_viewport_init();
3881 e_comp_wl_capture_init();
3882 e_comp_wl_renderer_init();
3883 _e_comp_wl_move_resize_init();
3884 e_presentation_time_init();
3885 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3888 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3889 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3891 /* add event handlers to catch E events */
3892 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3893 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3894 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3895 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3896 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3897 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3898 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3899 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3900 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3902 /* add hooks to catch e_client events */
3903 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3904 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3905 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3906 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3907 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3909 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3916 e_comp_wl_deferred_job(void)
3918 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3921 /* internal functions */
3923 e_comp_wl_shutdown(void)
3925 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3927 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3929 e_comp_wl_subsurfaces_shutdown();
3931 E_FREE_LIST(handlers, ecore_event_handler_del);
3932 E_FREE_LIST(hooks, e_client_hook_del);
3933 _e_comp_wl_gl_shutdown();
3935 e_blender_shutdown();
3936 e_presentation_time_shutdown();
3937 e_comp_wl_renderer_shutdown();
3938 e_comp_wl_capture_shutdown();
3939 e_comp_wl_viewport_shutdown();
3940 e_comp_wl_video_shutdown();
3941 e_comp_wl_screenshooter_shutdown();
3943 e_comp_wl_remote_surface_shutdown();
3945 e_pixmap_shutdown();
3947 e_wtz_shell_shutdown();
3948 e_comp_wl_shell_shutdown();
3949 e_comp_wl_input_shutdown();
3951 wl_list_remove(&comp->client_created.link);
3954 e_comp->wl_comp_data = NULL;
3958 E_Comp_Wl_Output *output;
3960 if (e_comp_wl->screenshooter.global)
3961 wl_global_destroy(e_comp_wl->screenshooter.global);
3963 EINA_LIST_FREE(e_comp_wl->outputs, output)
3965 if (output->id) eina_stringshare_del(output->id);
3966 if (output->make) eina_stringshare_del(output->make);
3967 if (output->model) eina_stringshare_del(output->model);
3971 /* delete fd handler */
3972 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3974 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3975 cursor_timer_ec = NULL;
3977 /* free allocated data structure */
3983 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3985 e_object_unref(E_OBJECT(ev->ec));
3990 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3993 ev = E_NEW(E_Event_Client, 1);
3996 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3998 /* set usable early because shell module checks this */
3999 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4000 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4002 e_pixmap_resource_set(ec->pixmap, buffer);
4003 e_pixmap_dirty(ec->pixmap);
4004 e_pixmap_refresh(ec->pixmap);
4006 e_comp_wl_map_size_cal_from_buffer(ec);
4007 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4009 /* wm-policy module uses it */
4010 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4013 e_object_ref(E_OBJECT(ec));
4014 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4015 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4019 e_comp_wl_surface_commit(E_Client *ec)
4024 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4025 if (!e_comp_object_damage_exists(ec->frame))
4027 if ((ec->comp_data->video_client) ||
4028 (!e_client_video_hw_composition_check(ec)))
4029 e_pixmap_image_clear(ec->pixmap, 1);
4032 ignored = ec->ignored;
4034 if (e_comp_wl_subsurface_order_commit(ec))
4036 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4037 e_comp_wl_subsurface_restack(topmost);
4038 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4041 ec->ignored = ignored;
4043 if (ec->is_cursor && ec->visible)
4045 /* ignore cursor changes during resize/move I guess */
4046 if (!e_client_action_get())
4048 if (e_comp->pointer)
4050 x = e_comp->pointer->hot.x;
4051 y = e_comp->pointer->hot.y;
4053 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4059 static E_Comp_Wl_Output *
4060 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4063 E_Comp_Wl_Output *output;
4065 EINA_LIST_FOREACH(outputs, l, output)
4067 if (!strcmp(output->id, id))
4075 * Initializes information about one display output.
4077 * Adds or updates the given data about a single display output,
4078 * with an id matching the provided id.
4080 * @param id identification of output to be added or changed
4081 * @param make manufacturer name of the display output
4082 * @param model model name of the display output
4083 * @param x output's top left corner x coordinate
4084 * @param y output's top left corner y coordinate
4085 * @param w output's width in pixels
4086 * @param h output's height in pixels
4087 * @param pw output's physical width in millimeters
4088 * @param ph output's physical height in millimeters
4089 * @param refresh output's refresh rate in mHz
4090 * @param subpixel output's subpixel layout
4091 * @param transform output's rotation and/or mirror transformation
4093 * @returns True if a display output object could be added or updated
4096 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4097 int x, int y, int w, int h, int pw, int ph,
4098 unsigned int refresh, unsigned int subpixel,
4099 unsigned int transform)
4101 E_Comp_Wl_Output *output;
4103 struct wl_resource *resource;
4105 /* retrieve named output; or create it if it doesn't exist */
4106 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4109 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4111 if (id) output->id = eina_stringshare_add(id);
4113 output->make = eina_stringshare_add(make);
4115 output->make = eina_stringshare_add("unknown");
4117 output->model = eina_stringshare_add(model);
4119 output->model = eina_stringshare_add("unknown");
4121 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4124 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4125 2, output, _e_comp_wl_cb_output_bind);
4127 output->resources = NULL;
4128 output->scale = e_scale;
4131 /* update the output details */
4136 output->phys_width = pw;
4137 output->phys_height = ph;
4138 output->refresh = refresh;
4139 output->subpixel = subpixel;
4140 output->transform = transform;
4142 if (output->scale <= 0)
4143 output->scale = e_scale;
4145 /* if we have bound resources, send updates */
4146 EINA_LIST_FOREACH(output->resources, l2, resource)
4148 wl_output_send_geometry(resource,
4149 output->x, output->y,
4151 output->phys_height,
4153 output->make ?: "", output->model ?: "",
4156 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4157 wl_output_send_scale(resource, output->scale);
4159 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4160 output->w, output->h, output->refresh);
4162 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4163 wl_output_send_done(resource);
4170 e_comp_wl_output_remove(const char *id)
4172 E_Comp_Wl_Output *output;
4174 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4177 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4179 /* wl_global_destroy(output->global); */
4181 /* eina_stringshare_del(output->id); */
4182 /* eina_stringshare_del(output->make); */
4183 /* eina_stringshare_del(output->model); */
4190 _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)
4192 struct wl_resource *res;
4194 uint32_t serial, keycode;
4195 struct wl_client *wc = NULL;
4196 E_Comp_Config *comp_conf = NULL;
4197 const char *device_name = NULL;
4199 keycode = (ev->keycode - 8);
4201 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4203 comp_conf = e_comp_config_get();
4205 if (ec && ec->comp_data)
4207 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4210 wc = wl_resource_get_client(surface);
4213 if (e_config->key_input_ttrace_enable)
4215 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4216 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4219 EINA_LIST_FOREACH(key_list, l, res)
4221 if (wl_resource_get_client(res) != wc) continue;
4223 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4224 if (!e_input_thread_mode_get())
4226 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4227 device_name = ecore_device_name_get(ev->dev);
4233 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4234 device_name = e_device_name_get(dev);
4238 if (comp_conf && comp_conf->input_log_enable)
4239 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4241 wl_keyboard_send_key(res, serial, ev->timestamp,
4246 if (e_config->key_input_ttrace_enable)
4249 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4254 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4256 E_Client *ec = NULL;
4258 E_Comp_Wl_Key_Data *end, *k;
4260 if (ev->window != e_comp->ee_win)
4265 keycode = (ev->keycode - 8);
4266 if (!(e_comp_wl = e_comp->wl_comp_data))
4271 #ifndef E_RELEASE_BUILD
4272 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4273 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4274 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4275 eina_streq(ev->key, "BackSpace"))
4281 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4283 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4285 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4287 /* ignore server-generated key repeats */
4288 if (k->key == keycode)
4290 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4295 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4297 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4299 ec = e_client_focused_get();
4300 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4301 if (ec && ec->comp_data && surface)
4303 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4304 if (e_comp_wl->kbd.focused)
4306 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4308 /* A key only sent to clients is added to the list */
4309 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4310 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4312 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4314 DBG("wl_array_add: Out of memory\n");
4315 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4316 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4319 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4323 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4327 /* update modifier state */
4328 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4334 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4336 E_Client *ec = NULL;
4337 uint32_t keycode, delivered_key;
4338 E_Comp_Wl_Key_Data *end, *k;
4340 if (ev->window != e_comp->ee_win)
4345 keycode = (ev->keycode - 8);
4347 if (!(e_comp_wl = e_comp->wl_comp_data))
4352 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4354 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4355 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4357 if (k->key == keycode)
4364 e_comp_wl->kbd.keys.size =
4365 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4367 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4369 /* 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) */
4370 if ((delivered_key) ||
4371 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4373 ec = e_client_focused_get();
4375 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4376 if (e_comp_wl->kbd.focused)
4378 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4380 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4383 /* update modifier state */
4384 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4390 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4392 Eina_Bool res = EINA_FALSE;
4394 if (type == ECORE_EVENT_KEY_DOWN)
4396 res = e_comp_wl_key_down(ev, dev);
4398 else if (type == ECORE_EVENT_KEY_UP)
4400 res = e_comp_wl_key_up(ev, dev);
4407 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4410 struct wl_client *wc;
4411 uint32_t serial, btn;
4412 struct wl_resource *res;
4413 E_Comp_Config *comp_conf = NULL;
4415 if (ec->cur_mouse_action || e_comp_wl->drag)
4417 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4418 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4422 case 1: btn = BTN_LEFT; break;
4423 case 2: btn = BTN_MIDDLE; break;
4424 case 3: btn = BTN_RIGHT; break;
4425 default: btn = button_id; break;
4428 e_comp_wl->ptr.button = btn;
4429 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4430 if (!surface) return EINA_FALSE;
4432 if (!eina_list_count(e_comp_wl->ptr.resources))
4435 wc = wl_resource_get_client(surface);
4436 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4438 comp_conf = e_comp_config_get();
4440 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4442 if (wl_resource_get_client(res) != wc) continue;
4443 if (!e_comp_wl_input_pointer_check(res)) continue;
4444 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4446 if (comp_conf && comp_conf->input_log_enable)
4447 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4449 wl_pointer_send_button(res, serial, timestamp, btn, state);
4456 e_comp_wl_touch_cancel(void)
4458 _e_comp_wl_touch_cancel();
4461 E_API E_Comp_Wl_Hook *
4462 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4466 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4467 ch = E_NEW(E_Comp_Wl_Hook, 1);
4468 if (!ch) return NULL;
4469 ch->hookpoint = hookpoint;
4471 ch->data = (void*)data;
4472 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4477 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4480 if (_e_comp_wl_hooks_walking == 0)
4482 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4486 _e_comp_wl_hooks_delete++;
4489 E_API E_Comp_Wl_Pid_Hook *
4490 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4492 E_Comp_Wl_Pid_Hook *ch;
4494 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4496 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4497 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4499 ch->hookpoint = hookpoint;
4501 ch->data = (void*)data;
4502 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4508 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4511 if (_e_comp_wl_pid_hooks_walking == 0)
4513 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4517 _e_comp_wl_pid_hooks_delete++;
4520 E_API E_Comp_Wl_Intercept_Hook *
4521 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4523 E_Comp_Wl_Intercept_Hook *ch;
4525 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4526 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4527 if (!ch) return NULL;
4528 ch->hookpoint = hookpoint;
4530 ch->data = (void*)data;
4531 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4536 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4539 if (_e_comp_wl_intercept_hooks_walking == 0)
4541 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4545 _e_comp_wl_intercept_hooks_delete++;
4549 e_comp_wl_shell_surface_ready(E_Client *ec)
4553 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4557 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4559 e_config->use_cursor_timer = !!enabled;
4561 if (e_config->use_cursor_timer)
4563 if (!e_pointer_is_hidden(e_comp->pointer))
4565 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4570 if (e_comp_wl->ptr.hide_tmr)
4572 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4573 e_comp_wl->ptr.hide_tmr = NULL;
4575 cursor_timer_ec = NULL;
4577 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4580 if (e_pointer_is_hidden(e_comp->pointer))
4582 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4588 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4590 EINA_SAFETY_ON_NULL_RETURN(wc);
4591 EINA_SAFETY_ON_NULL_RETURN(dev);
4593 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4597 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4599 EINA_SAFETY_ON_NULL_RETURN(wc);
4600 EINA_SAFETY_ON_NULL_RETURN(dev);
4602 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4606 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4608 struct wl_resource *res;
4609 struct wl_client *wc;
4611 uint32_t serial, wl_keycode;
4612 enum wl_keyboard_key_state state;
4613 E_Comp_Config *comp_conf = NULL;
4614 const char *dev_name = NULL;
4616 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4617 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4618 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4620 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4621 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4623 wl_keycode = keycode - 8;
4624 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4626 wc = wl_resource_get_client(surface);
4627 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4628 if (!time) time = e_util_timestamp_get();
4629 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4630 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4632 comp_conf = e_comp_config_get();
4633 e_keyrouter_event_surface_send(ec, keycode);
4635 if (e_config->key_input_ttrace_enable)
4637 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4638 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4641 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4642 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4644 if (wl_resource_get_client(res) != wc) continue;
4645 if (!e_input_thread_mode_get())
4649 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4650 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4654 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4661 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4662 dev_name = e_device_name_get(dev);
4666 if (comp_conf && comp_conf->input_log_enable)
4667 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4670 wl_keyboard_send_key(res, serial, time,
4673 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4675 if (e_config->key_input_ttrace_enable)
4678 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4685 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4687 struct wl_resource *res;
4688 struct wl_client *wc;
4690 uint32_t serial, wl_keycode, cancel_keycode;
4691 E_Comp_Config *comp_conf = NULL;
4692 struct xkb_keymap *keymap = NULL;
4694 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4695 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4696 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4698 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4699 keymap = e_comp_wl->xkb.keymap;
4700 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4701 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4703 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4704 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4706 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4707 if (cancel_keycode == XKB_KEYCODE_INVALID)
4709 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4712 cancel_keycode = cancel_keycode - 8;
4714 wl_keycode = keycode - 8;
4715 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4717 wc = wl_resource_get_client(surface);
4718 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4719 if (!time) time = e_util_timestamp_get();
4721 comp_conf = e_comp_config_get();
4722 e_keyrouter_event_surface_send(ec, keycode);
4724 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4725 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4727 if (wl_resource_get_client(res) != wc) continue;
4728 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4729 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4731 if (comp_conf && comp_conf->input_log_enable)
4732 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4733 wl_keyboard_send_key(res, serial, time,
4734 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4735 wl_keyboard_send_key(res, serial, time,
4736 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4737 wl_keyboard_send_key(res, serial, time,
4738 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4740 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4747 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)
4749 struct wl_client *wc;
4751 E_Devicemgr_Input_Device *device = NULL;
4753 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4754 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4755 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4757 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4758 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4760 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4762 wc = wl_resource_get_client(surface);
4763 if (!time) time = e_util_timestamp_get();
4764 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4768 _e_comp_wl_send_event_device(wc, time, dev, serial);
4769 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4773 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4774 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4777 x = x + ec->client.x;
4778 y = y + ec->client.y;
4780 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4786 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)
4788 E_Devicemgr_Input_Device *device;
4790 struct wl_client *wc;
4792 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4793 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4794 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4796 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4797 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4799 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4801 wc = wl_resource_get_client(surface);
4802 if (!time) time = e_util_timestamp_get();
4803 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4807 _e_comp_wl_send_event_device(wc, time, dev, serial);
4808 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4812 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4813 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4816 x = x + ec->client.x;
4817 y = y + ec->client.y;
4819 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4825 e_comp_wl_touch_cancel_send(E_Client *ec)
4827 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4828 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4829 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4831 _e_comp_wl_send_touch_cancel(ec);
4837 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4840 struct wl_client *wc;
4842 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4843 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4844 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4846 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4847 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4849 wc = wl_resource_get_client(surface);
4850 if (!time) time = e_util_timestamp_get();
4851 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4853 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4854 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4857 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4858 WL_POINTER_BUTTON_STATE_PRESSED);
4860 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4861 WL_POINTER_BUTTON_STATE_RELEASED);
4867 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4870 struct wl_client *wc;
4872 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4874 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4876 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4877 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4879 wc = wl_resource_get_client(surface);
4880 if (!time) time = e_util_timestamp_get();
4881 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4883 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4884 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4886 x = x + ec->client.x;
4887 y = y + ec->client.y;
4889 _e_comp_wl_send_mouse_move(ec, x, y, time);
4895 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4898 struct wl_client *wc;
4900 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4901 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4902 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4904 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4905 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4907 wc = wl_resource_get_client(surface);
4908 if (!time) time = e_util_timestamp_get();
4909 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4911 if (_e_comp_wl_check_cursor_timer_needed(ec))
4913 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4917 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4918 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4920 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4922 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4924 if (_e_comp_wl_check_cursor_timer_needed(ec))
4925 _e_comp_wl_cursor_move_timer_control(ec);
4932 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4935 struct wl_client *wc;
4936 struct wl_resource *res;
4939 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4940 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4942 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4943 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4945 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4946 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4948 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4949 wc = wl_resource_get_client(surface);
4950 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4951 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4953 if (!e_comp_wl_input_pointer_check(res)) continue;
4954 if (wl_resource_get_client(res) != wc) continue;
4956 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4957 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4959 wl_pointer_send_enter(res, serial, surface,
4960 wl_fixed_from_int(x),
4961 wl_fixed_from_int(y));
4962 ec->pointer_enter_sent = EINA_TRUE;
4964 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4970 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4973 struct wl_client *wc;
4974 struct wl_resource *res;
4977 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4978 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4979 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4980 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4981 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4982 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4984 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4985 wc = wl_resource_get_client(surface);
4986 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4987 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4989 if (!e_comp_wl_input_pointer_check(res)) continue;
4990 if (wl_resource_get_client(res) != wc) continue;
4992 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4993 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4995 wl_pointer_send_leave(res, serial, surface);
4996 ec->pointer_enter_sent = EINA_FALSE;
5003 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)
5005 Evas_Event_Mouse_In ev_in;
5008 if (ec->pointer_enter_sent) return;
5010 ev_in.buttons = buttons;
5018 ev_in.modifiers = modifiers;
5019 ev_in.locks = locks;
5020 ev_in.timestamp = timestamp;
5021 ev_in.event_flags = event_flags;
5024 ev_in.event_src = event_src;
5026 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5030 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)
5032 Evas_Event_Mouse_Out ev_out;
5035 if (!ec->pointer_enter_sent) return;
5037 ev_out.buttons = buttons;
5039 ev_out.output.x = x;
5040 ev_out.output.y = y;
5041 ev_out.canvas.x = x;
5042 ev_out.canvas.y = y;
5045 ev_out.modifiers = modifiers;
5046 ev_out.locks = locks;
5047 ev_out.timestamp = timestamp;
5048 ev_out.event_flags = event_flags;
5051 ev_out.event_src = event_src;
5053 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5057 e_comp_wl_cursor_hide(E_Client *ec)
5059 struct wl_resource *res;
5060 struct wl_client *wc;
5064 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5066 if (e_comp_wl->ptr.hide_tmr)
5068 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5069 e_comp_wl->ptr.hide_tmr = NULL;
5071 cursor_timer_ec = NULL;
5073 if (!ec) return EINA_FALSE;
5074 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5075 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5076 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5078 wc = wl_resource_get_client(surface);
5079 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5080 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5082 if (!e_comp_wl_input_pointer_check(res)) continue;
5083 if (wl_resource_get_client(res) != wc) continue;
5084 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5085 wl_pointer_send_leave(res, serial, surface);
5086 ec->pointer_enter_sent = EINA_FALSE;
5092 /* surface to buffer
5093 * - width : surface width
5094 * - height : surface height
5095 * - transform: buffer transform
5096 * - scale : buffer scale
5098 * - width : screen width
5099 * - height : screen height
5100 * - transform: output transform
5101 * - scale : output scale
5103 static E_Util_Transform_Matrix
5104 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5106 E_Util_Transform_Matrix m;
5108 e_util_transform_matrix_load_identity(&m);
5110 if (transform & 0x4)
5112 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5113 e_util_transform_matrix_flip_x(&m);
5114 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5117 switch (transform & 0x3)
5119 case WL_OUTPUT_TRANSFORM_90:
5120 e_util_transform_matrix_translate(&m, -width, 0, 0);
5121 e_util_transform_matrix_rotation_z(&m, 270);
5123 case WL_OUTPUT_TRANSFORM_180:
5124 e_util_transform_matrix_translate(&m, -width, -height, 0);
5125 e_util_transform_matrix_rotation_z(&m, 180);
5127 case WL_OUTPUT_TRANSFORM_270:
5128 e_util_transform_matrix_translate(&m, 0, -height, 0);
5129 e_util_transform_matrix_rotation_z(&m, 90);
5135 e_util_transform_matrix_scale(&m, scale, scale, 1);
5140 /* surface to buffer
5141 * - surface width, surface height, buffer transform, buffer scale
5143 * - screen width, screen height, output transform, output scale
5146 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5148 E_Util_Transform_Matrix m;
5149 E_Util_Transform_Vertex v;
5151 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5153 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5154 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5155 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5159 * - buffer width, buffer height, buffer transform, buffer scale
5162 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5164 E_Util_Transform_Matrix m;
5165 E_Util_Transform_Vertex v;
5168 if (transform != 0 || scale > 1)
5170 tw = ((transform % 2) ? height : width) / scale;
5171 th = ((transform % 2) ? width : height) / scale;
5179 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5180 m = e_util_transform_matrix_inverse_get(&m);
5182 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5183 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5184 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5187 /* surface to buffer
5188 * - surface width, surface height, buffer transform, buffer scale
5190 * - screen width, screen height, output transform, output scale
5193 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5194 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5196 E_Util_Transform_Matrix m;
5197 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5198 E_Util_Transform_Rect_Vertex sv;
5200 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5202 sv = e_util_transform_rect_to_vertices(&sr);
5203 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5204 sr = e_util_transform_vertices_to_rect(&sv);
5213 * - buffer width, buffer height, buffer transform, buffer scale
5216 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5217 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5219 E_Util_Transform_Matrix m;
5220 E_Util_Transform_Rect br = {bx, by, bw, bh};
5221 E_Util_Transform_Rect_Vertex bv;
5224 if (transform != 0 || scale > 1)
5226 tw = ((transform % 2) ? height : width) / scale;
5227 th = ((transform % 2) ? width : height) / scale;
5235 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5236 m = e_util_transform_matrix_inverse_get(&m);
5238 bv = e_util_transform_rect_to_vertices(&br);
5239 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5240 br = e_util_transform_vertices_to_rect(&bv);
5248 EINTERN E_Comp_Wl_Output*
5249 e_comp_wl_output_find(E_Client *ec)
5252 E_Comp_Wl_Output *output;
5254 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5256 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5258 if (output->transform % 2)
5260 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5261 ec->y < output->x || ec->y >= (output->x + output->w))
5266 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5267 ec->y < output->y || ec->y >= (output->y + output->h))
5277 EINTERN Eina_Array *
5278 e_comp_wl_output_find_all(E_Client *ec)
5280 E_Comp_Wl_Output *output;
5281 Eina_Array *outputs;
5284 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5286 outputs = eina_array_new(4);
5290 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5292 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5293 output->x, output->y, output->w, output->h))
5295 eina_array_push(outputs, output);
5299 if (eina_array_count(outputs) == 0)
5301 eina_array_free(outputs);
5308 // --------------------------------------------------------
5309 // tizen_move_resize
5310 // --------------------------------------------------------
5312 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5319 E_Client_Pending_Geometry *geo;
5322 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5323 if (ec->fullscreen || ec->maximized) goto err;
5325 geo = E_NEW(E_Client_Pending_Geometry, 1);
5328 geo->serial = serial;
5334 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5335 ec->surface_sync.wait_commit = EINA_TRUE;
5340 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5347 e_comp_wl_commit_sync_configure(E_Client *ec)
5350 E_Client_Pending_Geometry *geo;
5352 Eina_Bool match_size = EINA_FALSE;
5359 if (!ec || !ec->frame) goto ret;
5360 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5363 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5364 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5366 if (eina_list_count(ec->surface_sync.pending_geometry))
5368 Eina_List *ll = NULL;
5369 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5373 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5378 if ((geo->w == bw) && (geo->h == bh))
5380 match_size = EINA_TRUE;
5385 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5392 if ((config.w != ec->w) || (config.h != ec->h))
5394 e_client_size_set(ec, config.w, config.h);
5395 ec->changes.size = EINA_TRUE;
5399 // FIXME: The geometry of the client would be better to be calculated
5400 // at e_desk or at e_desk_area. So the position(x,y) of the client
5401 // should be calcuated at the e_desk or at the e_desk_area.
5403 desk = e_comp_desk_find_by_ec(ec);
5406 ec->client.x = desk->geom.x + config.x;
5407 ec->client.y = desk->geom.y + config.y;
5411 ec->client.x = config.x;
5412 ec->client.y = config.y;
5415 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5417 e_client_pos_set(ec, ec->client.x, ec->client.y);
5419 ec->changes.pos = 1;
5423 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5427 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5428 ec->surface_sync.wait_commit = EINA_FALSE;
5430 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5432 // rollback wait_commit if there are pending requests remained
5433 if (eina_list_count(ec->surface_sync.pending_geometry))
5434 ec->surface_sync.wait_commit = EINA_TRUE;
5439 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);
5446 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5447 struct wl_resource *res_moveresize)
5449 wl_resource_destroy(res_moveresize);
5453 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5454 struct wl_resource *res_moveresize,
5455 struct wl_resource *surface,
5462 /* to be implemented */
5465 int cur_w = 0, cur_h = 0;
5467 ec = e_client_from_surface_resource(surface);
5470 pending = e_client_pending_geometry_has(ec);
5471 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5472 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);
5476 if ((cur_w == w) && (cur_h == h))
5478 e_client_pos_set(ec, x, y);
5479 ec->changes.pos = 1;
5485 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5489 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5492 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5494 _tz_move_resize_iface_cb_destroy,
5495 _tz_move_resize_iface_cb_set_geometry,
5499 _tz_moveresize_cb_bind(struct wl_client *client,
5500 void *data EINA_UNUSED,
5504 struct wl_resource *res_moveresize;
5506 res_moveresize = wl_resource_create(client,
5507 &tizen_move_resize_interface,
5510 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5513 wl_resource_set_implementation(res_moveresize,
5514 &_tz_move_resize_iface,
5520 ERR("Could not create tizen_move_resize_interface res: %m");
5521 wl_client_post_no_memory(client);
5525 _e_comp_wl_move_resize_init(void)
5527 if (!e_comp_wl) return;
5528 if (!e_comp_wl->wl.disp) return;
5530 if (!wl_global_create(e_comp_wl->wl.disp,
5531 &tizen_move_resize_interface,
5534 _tz_moveresize_cb_bind))
5536 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5543 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5545 E_Comp_Wl_Output *output;
5546 pid_t output_pid = 0;
5547 Eina_List *l = NULL, *l2 = NULL;
5548 struct wl_resource *resource = NULL;
5550 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5552 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5553 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5554 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5556 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5558 /* if we have bound resources, send updates */
5559 EINA_LIST_FOREACH(output->resources, l2, resource)
5561 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5562 if (output_pid != pid) continue;
5564 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5566 // send output information to the client
5567 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5575 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5577 _e_comp_wl_surface_state_init(state, w, h);
5581 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5583 _e_comp_wl_surface_state_commit(ec, state);
5587 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5589 _e_comp_wl_hook_call(hookpoint, ec);
5593 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5595 _e_comp_wl_surface_state_finish(state);
5599 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5601 _e_comp_wl_surface_state_buffer_set(state, buffer);
5605 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5606 int sx, int sy, int *dx, int *dy)
5610 case WL_OUTPUT_TRANSFORM_NORMAL:
5614 case WL_OUTPUT_TRANSFORM_FLIPPED:
5615 *dx = width - sx, *dy = sy;
5617 case WL_OUTPUT_TRANSFORM_90:
5618 *dx = height - sy, *dy = sx;
5620 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5621 *dx = height - sy, *dy = width - sx;
5623 case WL_OUTPUT_TRANSFORM_180:
5624 *dx = width - sx, *dy = height - sy;
5626 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5627 *dx = sx, *dy = height - sy;
5629 case WL_OUTPUT_TRANSFORM_270:
5630 *dx = sy, *dy = width - sx;
5632 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5642 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5645 int tx1, ty1, tx2, ty2;
5646 int width_from_buffer, height_from_buffer;
5648 switch (vp->buffer.transform)
5650 case WL_OUTPUT_TRANSFORM_90:
5651 case WL_OUTPUT_TRANSFORM_270:
5652 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5653 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5654 width_from_buffer = bh / vp->buffer.scale;
5655 height_from_buffer = bw / vp->buffer.scale;
5658 width_from_buffer = bw / vp->buffer.scale;
5659 height_from_buffer = bh / vp->buffer.scale;
5663 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5667 x2 = width_from_buffer;
5668 y2 = height_from_buffer;
5672 x1 = wl_fixed_to_int(vp->buffer.src_x);
5673 y1 = wl_fixed_to_int(vp->buffer.src_y);
5674 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5675 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5678 buffer_transform(width_from_buffer, height_from_buffer,
5679 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5680 buffer_transform(width_from_buffer, height_from_buffer,
5681 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5683 out->x = (tx1 <= tx2) ? tx1 : tx2;
5684 out->y = (ty1 <= ty2) ? ty1 : ty2;
5685 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5686 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5690 * Convert given four coordinates to elements of rectangle
5691 * @in p[4] Coordinates to be converted
5692 * @out rect x, y, width, and height
5693 * transform Angle which represents TDM_TRANSFORM of rectangle
5694 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5695 * 1. The given coordinates are not represented by rectangle.
5696 * 2. All angles except for 0, 90, 180, 270.
5699 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5701 Eina_Bool ret = EINA_FALSE;
5703 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))
5706 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5709 *rotation = TDM_TRANSFORM_NORMAL;
5712 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5716 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5719 *rotation = TDM_TRANSFORM_180;
5722 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5727 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))
5730 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5733 *rotation = TDM_TRANSFORM_90;
5736 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5740 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5743 *rotation = TDM_TRANSFORM_270;
5746 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5756 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5761 for (i = 0; i < 4; i++)
5762 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5764 if (!_coords_to_rectangle_convert(p, out, rotation))
5766 DBG("Cannot convert given coords to rectangle.\n"
5767 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5768 p[0].x, p[0].y, p[1].x, p[1].y,
5769 p[2].x, p[2].y, p[3].x, p[3].y);
5777 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5779 int trans_rotation, flip;
5781 trans_rotation = transform & 0x3;
5782 flip = transform & 0x4;
5784 return (flip + (trans_rotation + rotation) % 4);
5788 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5796 if (e_comp_wl_subsurface_check(ec))
5797 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5804 out->w = ec->comp_data->width_from_viewport;
5805 out->w = (out->w + 1) & ~1;
5806 out->h = ec->comp_data->height_from_viewport;
5808 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5809 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5813 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5815 E_Comp_Wl_Buffer *buffer;
5816 E_Comp_Wl_Buffer_Viewport *vp;
5818 enum wl_output_transform buffer_transform;
5819 unsigned int rotation;
5820 Eina_Bool res = EINA_FALSE;
5822 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5824 if (e_object_is_del(E_OBJECT(ec)))
5827 vp = &ec->comp_data->scaler.buffer_viewport;
5829 if (buffer_viewport)
5831 buffer = ec->comp_data->buffer_ref.buffer;
5832 /* Getting a viewport of buffer needs geometry of buffer. */
5836 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5839 if ((output_viewport) || (transform))
5841 m = e_client_map_get(ec);
5843 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5845 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5850 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5851 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5852 * Since buffer.transform isn't applied using evas_map,
5853 * it has to be taken into account here to apply buffer.transform
5854 * and rotation of e_client_transform together. */
5856 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5858 *transform = (unsigned int)buffer_transform;
5866 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5868 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5869 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5871 /* Must be called with valid comp_data */
5872 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5874 if ((ec->comp_data->role_name == NULL) ||
5875 (ec->comp_data->role_name == role_name) ||
5876 (strcmp(ec->comp_data->role_name, role_name) == 0))
5878 ec->comp_data->role_name = role_name;
5884 wl_resource_post_error(error_resource, error_code,
5885 "Cannot assign role %s to wl_surface@%d,"
5886 " already has role %s\n",
5888 ec->comp_data->wl_surface ?
5889 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5890 ec->comp_data->role_name);
5896 EINTERN const char *
5897 e_comp_wl_surface_role_get(E_Client *ec)
5899 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5900 return ec->comp_data ? ec->comp_data->role_name : NULL;
5903 EINTERN struct wl_resource *
5904 e_comp_wl_client_surface_get(E_Client *ec)
5906 struct wl_resource *surface = NULL;
5907 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5908 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5910 g_mutex_lock(&ec->comp_data->surface_mutex);
5911 surface = ec->comp_data->surface;
5912 g_mutex_unlock(&ec->comp_data->surface_mutex);
5917 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5919 EINA_SAFETY_ON_NULL_RETURN(ec);
5920 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5922 g_mutex_lock(&ec->comp_data->surface_mutex);
5923 ec->comp_data->surface = surface;
5924 g_mutex_unlock(&ec->comp_data->surface_mutex);
5928 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5930 return e_compositor_util_client_from_surface_resource(surface_resource);
5934 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5936 if (!ec->comp_data->mapped)
5938 if (ec->comp_data->shell.surface &&
5939 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5941 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5947 if (ec->comp_data->mapped)
5949 /* will be unmapped. so run capture */
5950 e_comp_wl_remote_surface_image_save(ec);
5954 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5956 ec->comp_data->pending.sx = sx;
5957 ec->comp_data->pending.sy = sy;
5958 ec->comp_data->pending.new_attach = EINA_TRUE;
5960 e_client_fps_update(ec);
5964 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5966 if (ec->comp_data->pending.opaque)
5967 eina_tiler_clear(ec->comp_data->pending.opaque);
5971 eina_tiler_union(ec->comp_data->pending.opaque, region);
5973 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5977 ec->argb = EINA_FALSE;
5978 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5980 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5981 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5989 ec->argb = EINA_TRUE;
5990 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5992 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5993 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5999 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6001 if (ec->comp_data->pending.input)
6002 eina_tiler_clear(ec->comp_data->pending.input);
6006 if (eina_tiler_empty(region))
6008 ELOGF("COMP", " |unset input rect", NULL);
6009 e_comp_object_input_objs_del(ec->frame);
6010 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6013 eina_tiler_union(ec->comp_data->pending.input, region);
6017 eina_tiler_rect_add(ec->comp_data->pending.input,
6018 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6023 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6025 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6029 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6031 E_Comp_Wl_Subsurf_Data *sdata;
6036 if (ec->comp_data->frames)
6038 ec->comp_data->frames =
6039 eina_list_remove(ec->comp_data->frames, callback_resource);
6042 if (ec->comp_data->pending.frames)
6044 ec->comp_data->pending.frames =
6045 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6048 sdata = ec->comp_data->sub.data;
6049 if ((sdata) && (sdata->cached.frames))
6051 sdata->cached.frames =
6052 eina_list_remove(sdata->cached.frames, callback_resource);
6057 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6059 if (e_object_is_del(E_OBJECT(ec))) return;
6061 if (e_comp_wl_remote_surface_commit(ec)) return;
6063 e_comp_wl_surface_commit(ec);
6065 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6069 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6071 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6072 ec->comp_data->sub.data = sub;
6074 /* set subsurface client properties */
6075 ec->borderless = EINA_TRUE;
6076 ec->argb = EINA_TRUE;
6077 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6078 ec->lock_border = EINA_TRUE;
6079 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6080 ec->netwm.state.skip_taskbar = EINA_TRUE;
6081 ec->netwm.state.skip_pager = EINA_TRUE;
6082 ec->border_size = 0;
6083 ec->lock_user_location = 0;
6084 ec->lock_client_location = 0;
6085 ec->lock_user_size = 0;
6086 ec->lock_client_size = 0;
6087 ec->lock_client_stacking = 0;
6088 ec->lock_user_maximize = 0;
6089 ec->lock_client_maximize = 0;
6090 ec->changes.need_maximize = 0;
6091 ec->maximized = E_MAXIMIZE_NONE;
6094 ec->new_client = ec->netwm.ping = EINA_TRUE;
6095 e_comp->new_clients++;
6096 e_client_unignore(ec);
6098 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6099 * It's not for subsurface. */
6100 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6104 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6106 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6109 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6111 sub->parent = parent;
6115 layer = e_client_layer_get(parent);
6116 if (layer > E_LAYER_BOTTOM)
6117 e_client_layer_set(ec, layer);
6120 if (parent->comp_data)
6122 /* append this client to the parents subsurface list */
6123 parent->comp_data->sub.list_pending =
6124 eina_list_append(parent->comp_data->sub.list_pending, ec);
6125 parent->comp_data->sub.list_changed = EINA_TRUE;
6130 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6132 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6133 E_Client *parent = sub->parent;
6135 parent->comp_data->sub.list =
6136 eina_list_remove(parent->comp_data->sub.list, ec);
6137 parent->comp_data->sub.list_pending =
6138 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6139 parent->comp_data->sub.below_list =
6140 eina_list_remove(parent->comp_data->sub.below_list, ec);
6141 parent->comp_data->sub.below_list_pending =
6142 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6148 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)
6150 sub->resource = subsurface_resource;
6151 sub->cached_buffer_ref.buffer = NULL;
6152 sub->synchronized = EINA_TRUE;
6153 sub->parent = parent;
6154 sub->remote_surface.offscreen_parent = offscreen_parent;
6155 if (offscreen_parent)
6156 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6158 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6160 _e_comp_wl_client_subsurface_set(ec, sub);
6161 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6163 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6167 e_comp_wl_client_subsurface_finish(E_Client *ec)
6169 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6172 e_comp_wl_client_subsurface_parent_unset(ec);
6174 e_comp_wl_surface_state_finish(&sub->cached);
6175 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6177 ec->comp_data->sub.data = NULL;
6181 e_comp_wl_client_evas_init(E_Client *ec)
6183 EINA_SAFETY_ON_NULL_RETURN(ec);
6185 _e_comp_wl_client_evas_init(ec);
6189 e_comp_wl_client_evas_deinit(E_Client *ec)
6191 EINA_SAFETY_ON_NULL_RETURN(ec);
6193 _e_comp_wl_client_evas_deinit(ec);
6197 e_comp_wl_focus_check(void)
6199 _e_comp_wl_focus_check();
6203 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6210 if ((parent->comp_data) && (parent->comp_data->sub.data))
6211 parent = parent->comp_data->sub.data->parent;