2 #include "e_comp_wl_intern.h"
3 #include "e_main_intern.h"
4 #include "e_foreign_intern.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_client_intern.h"
7 #include "e_appinfo_intern.h"
8 #include "e_blender_intern.h"
9 #include "e_utils_intern.h"
10 #include "e_scale_intern.h"
11 #include "e_comp_canvas_intern.h"
12 #include "e_comp_screen_intern.h"
13 #include "e_comp_wl_capture_intern.h"
14 #include "e_comp_wl_data_intern.h"
15 #include "e_comp_wl_input_intern.h"
16 #include "e_comp_wl_renderer_intern.h"
17 #include "e_comp_wl_rsm_intern.h"
18 #include "e_comp_wl_screenshooter_intern.h"
19 #include "e_comp_wl_shell_intern.h"
20 #include "e_comp_wl_subsurface_intern.h"
21 #include "e_comp_wl_tbm_intern.h"
22 #include "e_comp_wl_viewport_intern.h"
23 #include "e_comp_intern.h"
24 #include "e_input_intern.h"
25 #include "e_keyrouter_intern.h"
26 #include "e_error_intern.h"
27 #include "e_pointer_intern.h"
28 #include "e_presentation_time_intern.h"
29 #include "e_grabinput_intern.h"
30 #include "e_env_intern.h"
31 #include "e_dnd_intern.h"
32 #include "e_policy_visibility_intern.h"
33 #include "e_compositor_intern.h"
34 #include "e_client_video_intern.h"
35 #include "e_comp_wl_video_intern.h"
36 #include "e_comp_object_intern.h"
37 #include "e_desk_intern.h"
38 #include "e_zone_intern.h"
39 #include "e_hints_intern.h"
40 #include "e_comp_input_intern.h"
41 #include "e_blur_intern.h"
42 #include "e_input_thread_client_intern.h"
44 #include <tizen-extension-server-protocol.h>
45 #include <relative-pointer-unstable-v1-server-protocol.h>
46 #include <pointer-constraints-unstable-v1-server-protocol.h>
48 #include <wayland-tbm-server.h>
50 #include <libds/log.h>
51 #include <libds/single_pixel_buffer_v1.h>
55 #include <sys/resource.h>
57 /* handle include for printing uint64_t */
58 #define __STDC_FORMAT_MACROS
61 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
63 /* Resource Data Mapping: (wl_resource_get_user_data)
65 * wl_surface == e_pixmap
66 * wl_region == eina_tiler
67 * wl_subsurface == e_client
71 typedef struct _E_Comp_Data E_Comp_Data;
76 struct wl_listener client_created;
79 static void _e_comp_wl_move_resize_init(void);
81 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
84 typedef struct _E_Comp_Wl_Key_Data
90 struct _E_Comp_Wl_Evas_Gl
93 Evas_GL_Config *glcfg;
94 Evas_GL_Context *glctx;
95 Evas_GL_Surface *glsfc;
99 static Eina_List *handlers = NULL;
100 static E_Client *cursor_timer_ec = NULL;
101 static Eina_Bool need_send_released = EINA_FALSE;
102 static Eina_Bool need_send_motion = EINA_TRUE;
104 static GMutex connection_mutex;
106 static int _e_comp_wl_hooks_delete = 0;
107 static int _e_comp_wl_hooks_walking = 0;
109 static int _e_comp_wl_pid_hooks_delete = 0;
110 static int _e_comp_wl_pid_hooks_walking = 0;
112 static int _e_comp_wl_intercept_hooks_delete = 0;
113 static int _e_comp_wl_intercept_hooks_walking = 0;
115 static Eina_Inlist *_e_comp_wl_hooks[] =
117 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
118 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
119 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
120 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
121 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
122 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
123 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
124 [E_COMP_WL_HOOK_DEL] = NULL,
125 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
126 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
127 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
130 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
132 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
135 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
137 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
138 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
139 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
140 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
141 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
142 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
145 static Eina_List *hooks = NULL;
147 /* local functions */
149 _e_comp_wl_hooks_clean(void)
154 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
155 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
157 if (!ch->delete_me) continue;
158 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
164 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
168 e_object_ref(E_OBJECT(ec));
169 _e_comp_wl_hooks_walking++;
170 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
172 if (ch->delete_me) continue;
173 ch->func(ch->data, ec);
174 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
175 (e_object_is_del(E_OBJECT(ec))))
178 _e_comp_wl_hooks_walking--;
179 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
180 _e_comp_wl_hooks_clean();
181 e_object_unref(E_OBJECT(ec));
185 _e_comp_wl_pid_hooks_clean(void)
188 E_Comp_Wl_Pid_Hook *ch;
190 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
191 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
193 if (!ch->delete_me) continue;
194 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
200 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
202 E_Comp_Wl_Pid_Hook *ch;
204 _e_comp_wl_pid_hooks_walking++;
205 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
207 if (ch->delete_me) continue;
208 ch->func(ch->data, pid);
210 _e_comp_wl_pid_hooks_walking--;
211 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
212 _e_comp_wl_pid_hooks_clean();
216 _e_comp_wl_intercept_hooks_clean(void)
219 E_Comp_Wl_Intercept_Hook *ch;
221 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
222 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
224 if (!ch->delete_me) continue;
225 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
231 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
233 E_Comp_Wl_Intercept_Hook *ch;
234 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
236 e_object_ref(E_OBJECT(ec));
237 _e_comp_wl_intercept_hooks_walking++;
238 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
240 if (ch->delete_me) continue;
241 res = ch->func(ch->data, ec);
242 if (!res) ret = EINA_FALSE;
243 if (e_object_is_del(E_OBJECT(ec)))
246 _e_comp_wl_intercept_hooks_walking--;
247 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
248 _e_comp_wl_intercept_hooks_clean();
249 e_object_unref(E_OBJECT(ec));
256 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
262 if (e_comp_object_frame_exists(ec->frame))
263 w = ec->client.w, h = ec->client.h;
265 w = ec->w, h = ec->h;
269 // Width and Height are -1 means that we don't consider size value
273 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
277 _e_comp_wl_focus_check(void)
281 if (stopping) return;
282 ec = e_client_focused_get();
284 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
288 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
290 /* dispatch pending wayland events */
291 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
293 return ECORE_CALLBACK_RENEW;
297 e_comp_wl_display_flush()
299 if (e_comp_wl && e_comp_wl->wl.disp)
301 if (e_config->key_input_ttrace_enable)
303 TRACE_INPUT_BEGIN(wl_display_flush_clients);
304 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
307 g_mutex_lock(&connection_mutex);
308 wl_display_flush_clients(e_comp_wl->wl.disp);
309 g_mutex_unlock(&connection_mutex);
311 if (e_config->key_input_ttrace_enable)
314 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
320 e_comp_wl_connection_lock()
322 e_input_boost_lock(&connection_mutex);
326 e_comp_wl_connection_unlock()
328 e_input_boost_unlock(&connection_mutex);
332 e_comp_wl_focused_client_flush()
334 E_Client *focused_ec;
335 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
337 e_input_boost_lock(&connection_mutex);
338 focused_ec = e_client_focused_get();
342 struct wl_client *wc;
343 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
346 e_input_boost_unlock(&connection_mutex);
350 wc = wl_resource_get_client(surface);
354 e_input_boost_unlock(&connection_mutex);
358 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
362 if (e_comp_wl->idle_exiter_timestamp > 0.0)
364 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
365 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
367 ELOGF("E_COMP", "prepare gap time: %lfms",
372 e_comp_wl->idle_exiter_timestamp = 0.0;
374 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
376 /* flush pending client events */
377 e_comp_wl_display_flush();
379 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
380 IDLE_EXITER~CB_PREPARE);
382 // _e_comp_wl_cb_prepare() function is called before idle state in ecore_main_loop.
383 // idle state means that epoll() or select() is called in ecore_main_loop.
384 e_main_hook_call(E_MAIN_HOOK_LOOP_BEFORE_IDLE_ENTER);
388 _e_comp_wl_cb_awake(void *data)
390 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
392 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
393 IDLE_EXITER~CB_PREPARE);
395 // _e_comp_wl_cb_awake() function is called after idle state in ecore_main_loop.
396 // ecore_main_loop awake due to returning from epoll() or select()
397 e_main_hook_call(E_MAIN_HOOK_LOOP_AFTER_IDLE_EXIT);
400 E_API enum wl_output_transform
401 e_comp_wl_output_buffer_transform_get(E_Client *ec)
403 E_Comp_Wl_Buffer_Viewport *vp;
404 E_Comp_Wl_Buffer *buffer;
405 enum wl_output_transform transform, rotation;
407 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
408 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
409 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
411 vp = &ec->comp_data->scaler.buffer_viewport;
412 if (e_comp_wl_subsurface_check(ec))
413 return vp->buffer.transform;
415 buffer = ec->comp_data->buffer_ref.buffer;
418 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
419 return vp->buffer.transform;
421 rotation = buffer->transform;
423 return vp->buffer.transform;
425 /* ignore the flip value when calculating transform because the screen rotation
426 * functionality doesn't consider the flip output transform currently
428 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
430 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
431 ec, rotation, vp->buffer.transform, transform);
436 EINTERN enum wl_output_transform
437 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
439 E_Comp_Wl_Buffer_Viewport *vp;
440 E_Comp_Wl_Buffer *buffer;
441 enum wl_output_transform transform, rotation;
443 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
444 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
445 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
447 vp = &ec->comp_data->pending.buffer_viewport;
448 if (e_comp_wl_subsurface_check(ec))
449 return vp->buffer.transform;
451 buffer = ec->comp_data->pending.buffer;
454 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
455 return vp->buffer.transform;
457 rotation = buffer->transform;
459 return vp->buffer.transform;
461 /* ignore the flip value when calculating transform because the screen rotation
462 * functionality doesn't consider the flip output transform currently
464 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
466 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
467 ec, rotation, vp->buffer.transform, transform);
473 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
475 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
476 E_Comp_Wl_Buffer *buffer;
477 int32_t width, height;
479 buffer = e_pixmap_resource_get(ec->pixmap);
482 ec->comp_data->width_from_buffer = 0;
483 ec->comp_data->height_from_buffer = 0;
487 switch (e_comp_wl_output_buffer_transform_get(ec))
489 case WL_OUTPUT_TRANSFORM_90:
490 case WL_OUTPUT_TRANSFORM_270:
491 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
492 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
493 width = buffer->h / vp->buffer.scale;
494 height = buffer->w / vp->buffer.scale;
497 width = buffer->w / vp->buffer.scale;
498 height = buffer->h / vp->buffer.scale;
502 ec->comp_data->width_from_buffer = width;
503 ec->comp_data->height_from_buffer = height;
507 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
509 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
510 int32_t width, height;
512 width = ec->comp_data->width_from_buffer;
513 height = ec->comp_data->height_from_buffer;
515 if (width == 0 && height == 0) return;
517 if (width != 0 && vp->surface.width != -1)
519 ec->comp_data->width_from_viewport = vp->surface.width;
520 ec->comp_data->height_from_viewport = vp->surface.height;
524 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
526 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
527 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
528 ec->comp_data->width_from_viewport = w ?: 1;
529 ec->comp_data->height_from_viewport = h ?: 1;
533 ec->comp_data->width_from_viewport = width;
534 ec->comp_data->height_from_viewport = height;
538 e_comp_wl_topmost_parent_get(E_Client *ec)
542 if (!e_comp_wl_subsurface_check(ec))
545 parent = e_comp_wl_subsurface_parent_get(ec);
548 if (!e_comp_wl_subsurface_check(parent))
551 parent = e_comp_wl_subsurface_parent_get(parent);
558 e_comp_wl_map_apply(E_Client *ec)
560 E_Comp_Wl_Buffer_Viewport *vp;
561 E_Comp_Wl_Subsurf_Data *sdata;
562 E_Comp_Wl_Client_Data *cdata;
563 int x1, y1, x2, y2, x, y;
565 Eina_Bool zoom_animating = EINA_FALSE;
567 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
569 e_comp_object_map_update(ec->frame);
571 cdata = ec->comp_data;
572 vp = &cdata->scaler.buffer_viewport;
573 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
574 (!cdata->viewport_transform))
577 if (e_comp_wl_subsurface_check(ec))
579 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
581 sdata = ec->comp_data->sub.data;
582 if (sdata->remote_surface.offscreen_parent)
584 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
585 Eina_Rectangle *rect;
588 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
590 /* TODO: If there are one more regions, it means that provider's offscreen
591 * is displayed by one more remote_surfaces. Have to consider it later. At
592 * this time, just consider only one remote_surface.
606 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
607 if (x != dx || y != dy)
608 evas_object_move(ec->frame, dx, dy);
610 if (!cdata->viewport_transform)
612 cdata->viewport_transform = e_util_transform_new();
613 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
614 e_client_transform_core_add(ec, cdata->viewport_transform);
617 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
618 ec->comp_data->width_from_viewport,
619 ec->comp_data->height_from_viewport);
621 if (vp->buffer.src_width == wl_fixed_from_int(-1))
625 x2 = cdata->width_from_buffer;
626 y2 = cdata->height_from_buffer;
630 x1 = wl_fixed_to_int(vp->buffer.src_x);
631 y1 = wl_fixed_to_int(vp->buffer.src_y);
632 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
633 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
636 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
637 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
638 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
639 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
642 desk = e_comp_desk_find_by_ec(ec);
644 zoom_animating = e_desk_zoom_is_animating(desk);
646 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
647 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
648 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
650 /* workaround:: when the desk zoom is doing their animation,
651 the transform core update can override animation's zoom boundary.
652 so, don't doing transform core update while desk zoom animation */
654 e_client_transform_core_update(ec);
659 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
663 int map_c = 0, map_x = 0, map_y = 0;
664 double inv_x = 0.0, inv_y = 0.0;
666 EINA_SAFETY_ON_NULL_RETURN(ec);
668 map = e_client_map_get(ec);
669 map_c = e_map_count_get(map);
671 if (!map || map_c <= 0)
681 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
682 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
683 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
684 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
686 for (int i = 0; i < map_c; i++)
688 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
689 e_map_point_image_uv_set(map2, i, map_x, map_y);
691 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
701 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
707 if (!(ec = data)) return;
708 if (e_object_is_del(data)) return;
710 if (!ec->override) e_hints_window_visible_set(ec);
712 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
713 (!ec->comp_data->need_reparent))
715 ec->comp_data->need_reparent = EINA_TRUE;
716 ec->visible = EINA_TRUE;
718 if (!e_client_util_ignored_get(ec))
720 ec->take_focus = !starting;
724 if (!ec->comp_data->need_reparent)
726 if ((ec->hidden) || (ec->iconic))
728 evas_object_hide(ec->frame);
729 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
732 evas_object_show(ec->frame);
735 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
736 evas_object_show(tmp->frame);
738 topmost = e_comp_wl_topmost_parent_get(ec);
739 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
740 e_comp_wl_subsurface_show(ec);
742 if (ec->comp_data->sub.below_obj)
743 evas_object_show(ec->comp_data->sub.below_obj);
747 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
753 if (!(ec = data)) return;
754 if (e_object_is_del(E_OBJECT(ec))) return;
756 /* Uncommonly some clients's final buffer can be skipped if the client
757 * requests unmap of its surface right after wl_surface@commit.
758 * So if this client evas object is hidden state and client is already
759 * unmmapped, we can consider to clear pixmap image here mandatorily.
761 if (!ec->comp_data->mapped)
762 e_pixmap_image_clear(ec->pixmap, 1);
764 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
765 evas_object_hide(tmp->frame);
767 topmost = e_comp_wl_topmost_parent_get(ec);
768 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
769 e_comp_wl_subsurface_hide(ec);
771 if (ec->comp_data->sub.below_obj)
772 evas_object_hide(ec->comp_data->sub.below_obj);
774 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
778 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
785 if (!(ec = data)) return;
786 if (e_object_is_del(E_OBJECT(ec))) return;
788 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
790 if (!e_comp_wl_subsurface_check(subc)) continue;
791 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
792 evas_object_move(subc->frame, x, y);
794 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
795 if (cdata->viewport_transform)
796 e_comp_wl_map_apply(subc);
799 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
801 if (!e_comp_wl_subsurface_check(subc)) continue;
802 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
803 evas_object_move(subc->frame, x, y);
805 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
806 if (cdata->viewport_transform)
807 e_comp_wl_map_apply(subc);
810 if (ec->comp_data->sub.below_obj)
812 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
813 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
818 _e_comp_wl_send_touch_cancel(E_Client *ec)
821 struct wl_resource *res;
822 struct wl_client *wc;
823 E_Comp_Config *comp_conf = NULL;
826 if (e_object_is_del(E_OBJECT(ec))) return;
827 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
829 if (!surface) return;
830 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
832 wc = wl_resource_get_client(surface);
834 comp_conf = e_comp_config_get();
836 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
838 if (wl_resource_get_client(res) != wc) continue;
839 if (!e_comp_wl_input_touch_check(res)) continue;
841 if (comp_conf && comp_conf->input_log_enable)
842 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
844 wl_touch_send_cancel(res);
849 _e_comp_wl_touch_cancel(void)
853 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
855 if (!e_comp_wl->touch.pressed) return;
857 _e_comp_wl_send_touch_cancel(ec);
860 static E_Devicemgr_Input_Device *
861 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
863 E_Devicemgr_Input_Device *last_kbd = NULL;
866 case ECORE_DEVICE_CLASS_MOUSE:
867 return e_devicemgr->last_device_ptr;
868 case ECORE_DEVICE_CLASS_KEYBOARD:
869 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
871 case ECORE_DEVICE_CLASS_TOUCH:
872 return e_devicemgr->last_device_touch;
880 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
884 case ECORE_DEVICE_CLASS_MOUSE:
885 e_devicemgr->last_device_ptr = device;
887 case ECORE_DEVICE_CLASS_KEYBOARD:
888 atomic_store(&e_devicemgr->last_device_kbd, device);
890 case ECORE_DEVICE_CLASS_TOUCH:
891 e_devicemgr->last_device_touch = device;
898 static E_Devicemgr_Input_Device *
899 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
901 E_Devicemgr_Input_Device *last_kbd = NULL;
905 case ECORE_DEVICE_CLASS_MOUSE:
906 return ec->comp_data->last_device_ptr;
907 case ECORE_DEVICE_CLASS_KEYBOARD:
908 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
910 case ECORE_DEVICE_CLASS_TOUCH:
911 return ec->comp_data->last_device_touch;
919 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
923 case ECORE_DEVICE_CLASS_MOUSE:
924 ec->comp_data->last_device_ptr = device;
926 case ECORE_DEVICE_CLASS_KEYBOARD:
927 atomic_store(&ec->comp_data->last_device_kbd, device);
929 case ECORE_DEVICE_CLASS_TOUCH:
930 ec->comp_data->last_device_touch = device;
938 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
940 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
941 struct wl_resource *dev_res;
942 const char *dev_name;
943 Ecore_Device_Class dev_class;
944 struct wl_client *wc;
948 EINA_SAFETY_ON_NULL_RETURN(dev);
951 if (ec->cur_mouse_action || e_comp_wl->drag)
953 if (e_object_is_del(E_OBJECT(ec))) return;
954 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
955 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
956 if (!surface) return;
958 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
959 dev_name = evas_device_description_get(dev);
960 last_device = _e_comp_wl_device_last_device_get(dev_class);
961 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
963 serial = wl_display_next_serial(e_comp_wl->wl.disp);
964 wc = wl_resource_get_client(surface);
965 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
966 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
968 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
969 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
971 _e_comp_wl_device_last_device_set(dev_class, input_dev);
972 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
974 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
976 if (wl_resource_get_client(dev_res) != wc) continue;
977 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
981 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
985 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
987 E_Devicemgr_Input_Device *last_device;
988 struct wl_resource *dev_res;
989 struct wl_client *wc;
993 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
994 if (!surface) return;
996 last_device = _e_comp_wl_device_last_device_get(dev_class);
997 if (!last_device) return;
999 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
1001 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1002 wc = wl_resource_get_client(surface);
1003 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
1005 if (wl_resource_get_client(dev_res) != wc) continue;
1006 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
1011 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1013 E_Devicemgr_Input_Device *input_dev;
1014 struct wl_resource *dev_res;
1015 const char *dev_name;
1018 EINA_SAFETY_ON_NULL_RETURN(dev);
1020 dev_name = ecore_device_identifier_get(dev);
1022 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1023 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1025 if (!eina_streq(input_dev->identifier, dev_name) ||
1026 (input_dev->clas != ecore_device_class_get(dev))) continue;
1027 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1029 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1031 if (wl_resource_get_client(dev_res) != wc) continue;
1032 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1035 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1039 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1041 E_Devicemgr_Input_Device *input_dev;
1042 struct wl_resource *dev_res;
1043 const char *dev_name;
1046 EINA_SAFETY_ON_NULL_RETURN(dev);
1048 dev_name = e_device_identifier_get(dev);
1050 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1051 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1053 if (!eina_streq(input_dev->identifier, dev_name) ||
1054 (input_dev->clas != e_device_class_get(dev))) continue;
1055 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1057 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1059 if (wl_resource_get_client(dev_res) != wc) continue;
1060 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1063 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1067 _e_comp_wl_cursor_reload(E_Client *ec)
1069 struct wl_resource *res;
1070 struct wl_client *wc;
1076 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1077 !evas_object_visible_get(e_comp->pointer->o_ptr))
1078 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1081 if (e_object_is_del(E_OBJECT(ec))) return;
1082 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1083 if (!surface) return;
1084 if (ec->pointer_enter_sent) return;
1086 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1087 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1089 if (e_client_transform_core_enable_get(ec))
1091 double dx = 0.0, dy = 0.0;
1092 map = e_client_map_get(ec);
1093 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1099 cx = px - ec->client.x;
1100 cy = py - ec->client.y;
1102 wc = wl_resource_get_client(surface);
1103 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1104 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1106 if (!e_comp_wl_input_pointer_check(res)) continue;
1107 if (wl_resource_get_client(res) != wc) continue;
1108 wl_pointer_send_enter(res, serial, surface,
1109 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1110 ec->pointer_enter_sent = EINA_TRUE;
1112 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1116 _e_comp_wl_cursor_timer(void *data)
1118 E_Client *ec = data;
1120 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1121 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1123 e_comp_wl_cursor_hide(ec);
1125 return ECORE_CALLBACK_CANCEL;
1129 _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)
1131 E_Devicemgr_Input_Device *input_dev;
1132 struct wl_resource *dev_res;
1133 struct wl_client *wc;
1138 if (ec->cur_mouse_action) return;
1139 if (e_object_is_del(E_OBJECT(ec))) return;
1140 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1141 if (!surface) return;
1143 f_value = wl_fixed_from_double(value);
1144 wc = wl_resource_get_client(surface);
1146 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1147 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1149 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1150 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1152 if (wl_resource_get_client(dev_res) != wc) continue;
1153 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1156 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1160 _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)
1162 if (idx >= e_input_touch_max_count_get()) return;
1164 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1165 e_devicemgr->multi[idx].radius_x = radius_x;
1166 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1167 e_devicemgr->multi[idx].radius_y = radius_y;
1168 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1169 e_devicemgr->multi[idx].pressure = pressure;
1170 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1171 e_devicemgr->multi[idx].angle = angle;
1175 _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)
1177 if (idx >= e_input_touch_max_count_get()) return;
1179 if (e_devicemgr->multi[idx].radius_x != radius_x)
1181 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1182 e_devicemgr->multi[idx].radius_x = radius_x;
1184 if (e_devicemgr->multi[idx].radius_y != radius_y)
1186 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1187 e_devicemgr->multi[idx].radius_y = radius_y;
1189 if (e_devicemgr->multi[idx].pressure != pressure)
1191 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1192 e_devicemgr->multi[idx].pressure = pressure;
1194 if (e_devicemgr->multi[idx].angle != angle)
1196 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1197 e_devicemgr->multi[idx].angle = angle;
1202 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1204 Eina_Bool ret = EINA_TRUE;
1207 case EVAS_CALLBACK_MOUSE_IN:
1208 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1211 if (e_comp_wl->ptr.hide_tmr)
1213 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1214 cursor_timer_ec = ec;
1215 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1219 if (e_pointer_is_hidden(e_comp->pointer))
1224 case EVAS_CALLBACK_MOUSE_OUT:
1225 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1228 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1232 case EVAS_CALLBACK_MOUSE_MOVE:
1233 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1236 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1237 _e_comp_wl_cursor_reload(ec);
1240 case EVAS_CALLBACK_MOUSE_WHEEL:
1241 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1244 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1245 _e_comp_wl_cursor_reload(ec);
1248 case EVAS_CALLBACK_MOUSE_DOWN:
1249 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1252 if (e_comp_wl->ptr.hide_tmr)
1254 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1255 e_comp_wl->ptr.hide_tmr = NULL;
1257 cursor_timer_ec = NULL;
1259 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1260 _e_comp_wl_cursor_reload(ec);
1263 case EVAS_CALLBACK_MOUSE_UP:
1264 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1275 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1277 if (ec->has_cursor_unset)
1280 if (!e_config->show_cursor)
1283 if (!e_config->use_cursor_timer)
1290 _e_comp_wl_check_block_input(E_Client *ec)
1292 E_Client *modal_child = e_client_modal_child_get(ec);
1295 if (modal_child->visible && !modal_child->iconic && (modal_child->visibility.obscured == E_VISIBILITY_UNOBSCURED))
1297 ELOGF("Touch", "Block touch by Modal child(ec:%p, win:0x%08zx)", ec, modal_child, e_client_util_win_get(modal_child));
1306 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1309 Evas_Event_Mouse_In *ev;
1310 struct wl_resource *res;
1311 struct wl_client *wc;
1314 E_Comp_Config *comp_conf;
1315 E_Client *prev_ptr_ec;
1319 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1320 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1322 if (!(ec = data)) return;
1323 if (e_object_is_del(E_OBJECT(ec))) return;
1324 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1325 if (!surface) return;
1327 prev_ptr_ec = e_comp_wl->ptr.ec;
1330 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1331 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1334 e_comp_wl->ptr.ec = ec;
1336 comp_conf = e_comp_config_get();
1337 if (comp_conf && comp_conf->input_log_enable)
1338 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1339 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1340 e_client_util_name_get(ec));
1342 if (_e_comp_wl_check_cursor_timer_needed(ec))
1344 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1348 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1349 wc = wl_resource_get_client(surface);
1350 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1351 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1353 if (!e_comp_wl_input_pointer_check(res)) continue;
1354 if (wl_resource_get_client(res) != wc) continue;
1356 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1358 wl_pointer_send_enter(res, serial, surface,
1359 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1360 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1361 ec->pointer_enter_sent = EINA_TRUE;
1364 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1366 ELOGF("Mouse", "In. Event doesn't have timestamp. no need to send signal", NULL);
1370 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1373 Evas_Event_Mouse_Out *ev;
1374 struct wl_resource *res;
1375 struct wl_client *wc;
1378 Eina_Bool inside_check;
1379 E_Comp_Config *comp_conf;
1383 if (!(ec = data)) return;
1384 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1385 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1386 if (ec->cur_mouse_action && inside_check) return;
1387 if (e_object_is_del(E_OBJECT(e_comp))) return;
1388 if (e_comp_wl->ptr.ec == ec)
1389 e_comp_wl->ptr.ec = NULL;
1390 if (e_object_is_del(E_OBJECT(ec))) return;
1392 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1393 if (!surface) return;
1395 comp_conf = e_comp_config_get();
1396 if (comp_conf && comp_conf->input_log_enable)
1397 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1398 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1399 e_client_util_name_get(ec));
1401 if (_e_comp_wl_check_cursor_timer_needed(ec))
1403 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1407 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1409 wc = wl_resource_get_client(surface);
1410 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1411 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1413 if (!e_comp_wl_input_pointer_check(res)) continue;
1414 if (wl_resource_get_client(res) != wc) continue;
1415 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1417 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1419 wl_pointer_send_leave(res, serial, surface);
1420 ec->pointer_enter_sent = EINA_FALSE;
1423 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
1425 ELOGF("Mouse", "Out. Event doesn't have timestamp. no need to send signal", NULL);
1429 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1432 struct wl_client *wc;
1433 struct wl_resource *res;
1436 E_Comp_Config *comp_conf = NULL;
1439 if (e_object_is_del(E_OBJECT(ec))) return;
1440 if (_e_comp_wl_check_block_input(ec)) return;
1442 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1443 if (!surface) return;
1445 wc = wl_resource_get_client(surface);
1446 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1450 x = wl_fixed_from_int(canvas_x - ec->client.x);
1451 y = wl_fixed_from_int(canvas_y - ec->client.y);
1454 comp_conf = e_comp_config_get();
1456 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1458 if (wl_resource_get_client(res) != wc) continue;
1459 if (!e_comp_wl_input_touch_check(res)) continue;
1460 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1463 if (comp_conf && comp_conf->input_log_enable)
1464 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));
1466 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1470 if (comp_conf && comp_conf->input_log_enable)
1471 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));
1473 wl_touch_send_up(res, serial, timestamp, idx);
1480 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1483 struct wl_client *wc;
1484 struct wl_resource *res;
1488 if (ec->cur_mouse_action) return;
1489 if (e_object_is_del(E_OBJECT(ec))) return;
1490 if (_e_comp_wl_check_block_input(ec)) return;
1492 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1493 if (!surface) return;
1495 wc = wl_resource_get_client(surface);
1497 x = wl_fixed_from_int(canvas_x - ec->client.x);
1498 y = wl_fixed_from_int(canvas_y - ec->client.y);
1500 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1502 if (wl_resource_get_client(res) != wc) continue;
1503 if (!e_comp_wl_input_touch_check(res)) continue;
1504 wl_touch_send_motion(res, timestamp, idx, x, y);
1509 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1511 struct wl_resource *res;
1512 struct wl_client *wc;
1516 if (ec->cur_mouse_action) return;
1517 if (e_object_is_del(E_OBJECT(ec))) return;
1518 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1519 if (!surface) return;
1521 wc = wl_resource_get_client(surface);
1522 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1524 if (!e_comp_wl_input_pointer_check(res)) continue;
1525 if (wl_resource_get_client(res) != wc) continue;
1526 wl_pointer_send_motion(res, timestamp,
1527 wl_fixed_from_int(x - ec->client.x),
1528 wl_fixed_from_int(y - ec->client.y));
1533 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1535 if (e_comp_wl->ptr.hide_tmr)
1537 if (cursor_timer_ec == ec)
1539 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1540 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1544 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1545 cursor_timer_ec = ec;
1546 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1551 cursor_timer_ec = ec;
1552 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1557 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1560 Evas_Event_Mouse_Move *ev;
1561 Evas_Device *dev = NULL;
1562 const char *dev_name;
1563 E_Comp_Config *comp_conf;
1567 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1568 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1570 if (!(ec = data)) return;
1571 if (e_object_is_del(E_OBJECT(ec))) return;
1572 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1573 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1574 if (!surface) return;
1576 if ((!need_send_motion) && (!need_send_released) && (e_client_visibility_get(ec) == E_VISIBILITY_FULLY_OBSCURED)) return;
1579 dev_name = evas_device_description_get(dev);
1581 comp_conf = e_comp_config_get();
1582 if (comp_conf && comp_conf->input_log_enable)
1583 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1584 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1585 e_client_util_name_get(ec), dev_name);
1587 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1589 if (!e_comp_wl->drag_client)
1591 e_comp_wl->touch.faked_ec = ec;
1592 if (e_comp_wl->touch.pressed & (1 << 0))
1594 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1596 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1597 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1598 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1602 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1606 if (!e_comp_wl->drag_client)
1608 if (_e_comp_wl_check_cursor_timer_needed(ec))
1610 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1614 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1615 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1617 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1619 if (_e_comp_wl_check_cursor_timer_needed(ec))
1620 _e_comp_wl_cursor_move_timer_control(ec);
1624 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1629 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1631 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1632 if (e_object_is_del(E_OBJECT(ec))) return;
1633 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1634 if (!surface) return;
1635 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1637 e_comp_wl->ptr.button = BTN_LEFT;
1639 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1643 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1645 E_Client *ec = data;
1646 Evas_Event_Mouse_Down *ev = event;
1647 Evas_Device *dev = NULL;
1648 const Evas_Device *seat_dev;
1649 const char *dev_name, *seat_name;
1650 E_Comp_Config *comp_conf = NULL;
1653 if (e_object_is_del(E_OBJECT(ec))) return;
1654 if (_e_comp_wl_check_block_input(ec)) return;
1657 dev_name = evas_device_description_get(dev);
1659 seat_dev = evas_device_parent_get(dev);
1660 seat_name = evas_device_name_get(seat_dev);
1662 comp_conf = e_comp_config_get();
1663 if (comp_conf && comp_conf->input_log_enable)
1664 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1665 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1666 dev_name, seat_name);
1668 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1670 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1672 e_comp_wl->touch.faked_ec = ec;
1675 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1676 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1677 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1679 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1680 e_comp_wl->touch.pressed |= (1 << 0);
1684 if (_e_comp_wl_check_cursor_timer_needed(ec))
1686 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1690 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1691 WL_POINTER_BUTTON_STATE_PRESSED);
1693 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1696 need_send_released = EINA_TRUE;
1700 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1702 E_Client *ec = data;
1703 Evas_Event_Mouse_Up *ev = event;
1704 Evas_Device *dev = NULL;
1705 const Evas_Device *seat_dev;
1706 const char *dev_name, *seat_name;;
1707 Evas_Event_Flags flags;
1708 E_Comp_Config *comp_conf = NULL;
1711 if (ec->cur_mouse_action) return;
1712 if (e_object_is_del(E_OBJECT(ec))) return;
1713 if (_e_comp_wl_check_block_input(ec)) return;
1715 if (!need_send_released)
1717 need_send_motion = EINA_TRUE;
1721 dev_name = evas_device_description_get(dev);
1723 seat_dev = evas_device_parent_get(dev);
1724 seat_name = evas_device_name_get(seat_dev);
1725 flags = evas_event_default_flags_get(evas);
1727 comp_conf = e_comp_config_get();
1728 if (comp_conf && comp_conf->input_log_enable)
1729 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1730 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1731 dev_name, seat_name);
1733 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1735 e_comp_wl->touch.pressed &= ~(1 << 0);
1737 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1738 e_comp_wl->touch.faked_ec = NULL;
1741 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1743 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1745 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1748 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1749 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1750 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1754 if (_e_comp_wl_check_cursor_timer_needed(ec))
1756 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1760 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1761 WL_POINTER_BUTTON_STATE_RELEASED);
1763 if (_e_comp_wl_check_cursor_timer_needed(ec))
1764 _e_comp_wl_cursor_move_timer_control(ec);
1768 need_send_released = EINA_FALSE;
1772 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1774 struct wl_resource *res;
1775 struct wl_client *wc;
1780 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1782 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1785 dir = -wl_fixed_from_int(abs(z));
1787 dir = wl_fixed_from_int(z);
1790 if (e_object_is_del(E_OBJECT(ec))) return;
1791 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1792 if (!surface) return;
1794 wc = wl_resource_get_client(surface);
1795 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1797 if (!e_comp_wl_input_pointer_check(res)) continue;
1798 if (wl_resource_get_client(res) != wc) continue;
1799 wl_pointer_send_axis(res, timestamp, axis, dir);
1804 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1807 Evas_Event_Mouse_Wheel *ev;
1810 if (!(ec = data)) return;
1811 if (ec->cur_mouse_action) return;
1812 if (e_object_is_del(E_OBJECT(ec))) return;
1813 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1814 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1815 if (!surface) return;
1817 if (!eina_list_count(e_comp_wl->ptr.resources))
1820 if (_e_comp_wl_check_cursor_timer_needed(ec))
1822 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1826 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1828 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1830 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1832 if (_e_comp_wl_check_cursor_timer_needed(ec))
1833 _e_comp_wl_cursor_move_timer_control(ec);
1838 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1840 E_Client *ec = data;
1841 Evas_Event_Multi_Down *ev = event;
1842 Evas_Device *dev = NULL;
1843 const Evas_Device *seat_dev;
1844 const char *dev_name, *seat_name;
1845 Evas_Device_Class dev_class;
1846 E_Comp_Config *comp_conf = NULL;
1849 if (e_object_is_del(E_OBJECT(ec))) return;
1850 if (_e_comp_wl_check_block_input(ec)) return;
1852 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1853 if (!surface) return;
1855 /* Do not deliver emulated single touch events to client */
1856 if (ev->device == 0) return;
1859 dev_name = evas_device_description_get(dev);
1860 e_comp_wl->touch.faked_ec = ec;
1862 seat_dev = evas_device_parent_get(dev);
1863 seat_name = evas_device_name_get(seat_dev);
1865 comp_conf = e_comp_config_get();
1866 if (comp_conf && comp_conf->input_log_enable)
1867 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1868 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1869 dev_name, seat_name);
1871 if (dev && dev_name)
1873 dev_class = evas_device_class_get(dev);
1874 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1875 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1878 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1879 e_comp_wl->touch.pressed |= (1 << ev->device);
1883 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1885 E_Client *ec = data;
1886 Evas_Event_Multi_Up *ev = event;
1887 Evas_Device *dev = NULL;
1888 const Evas_Device *seat_dev;
1889 const char *dev_name, *seat_name;
1890 Evas_Device_Class dev_class;
1891 Evas_Event_Flags flags;
1892 E_Comp_Config *comp_conf = NULL;
1895 if (e_object_is_del(E_OBJECT(ec))) return;
1896 if (_e_comp_wl_check_block_input(ec)) return;
1898 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1899 if (!surface) return;
1901 /* Do not deliver emulated single touch events to client */
1902 if (ev->device == 0) return;
1904 flags = evas_event_default_flags_get(evas);
1906 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1907 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1908 e_comp_wl->touch.faked_ec = NULL;
1910 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1913 dev_name = evas_device_description_get(dev);
1915 seat_dev = evas_device_parent_get(dev);
1916 seat_name = evas_device_name_get(seat_dev);
1918 comp_conf = e_comp_config_get();
1919 if (comp_conf && comp_conf->input_log_enable)
1920 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1921 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1922 dev_name, seat_name);
1924 if (dev && dev_name)
1926 dev_class = evas_device_class_get(dev);
1927 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1928 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1931 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1935 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1937 E_Client *ec = data;
1938 Evas_Event_Multi_Move *ev = event;
1939 Evas_Device *dev = NULL;
1940 const char *dev_name;
1941 Evas_Device_Class dev_class;
1944 if (e_object_is_del(E_OBJECT(ec))) return;
1945 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1946 if (!surface) return;
1948 /* Do not deliver emulated single touch events to client */
1949 if (ev->device == 0) return;
1951 e_comp_wl->touch.faked_ec = ec;
1953 if (e_comp_wl->touch.pressed & (1 << ev->device))
1956 if (dev && (dev_name = evas_device_description_get(dev)))
1958 dev_class = evas_device_class_get(dev);
1959 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1960 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1963 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1968 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1971 char *file, buff[PATH_MAX];
1978 n = (getpriority(PRIO_PROCESS, pid) + adj);
1982 setpriority(PRIO_PROCESS, pid, n);
1985 use_adj = EINA_TRUE;
1987 if (!do_child) return;
1989 files = ecore_file_ls("/proc");
1990 EINA_LIST_FREE(files, file)
1992 if (!isdigit(file[0]))
1995 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1996 if ((f = fopen(buff, "r")))
2000 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
2002 if (num_read == 2 && ppid == pid)
2003 _e_comp_wl_client_priority_adjust(pid2, set,
2005 adj_child, do_child);
2013 _e_comp_wl_client_priority_raise(E_Client *ec)
2015 if (!e_config->priority_control) return;
2016 if (ec->netwm.pid <= 0) return;
2017 if (ec->netwm.pid == getpid()) return;
2018 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
2019 e_config->priority - 1, -1,
2020 EINA_FALSE, EINA_TRUE, EINA_FALSE);
2024 _e_comp_wl_client_priority_normal(E_Client *ec)
2026 if (!e_config->priority_control) return;
2027 if (ec->netwm.pid <= 0) return;
2028 if (ec->netwm.pid == getpid()) return;
2029 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
2030 EINA_FALSE, EINA_TRUE, EINA_FALSE);
2034 _e_comp_wl_input_thread_send_keys()
2037 E_Comp_Wl_Key_Data *k;
2038 struct wl_resource *res;
2042 if (!e_comp_input_key->kbd.focused)
2047 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2048 t = ecore_time_unix_get();
2050 EINA_LIST_FOREACH(e_comp_input_key->kbd.focused, l, res)
2052 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2054 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2055 wl_keyboard_send_key(res, serial, t,
2056 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2062 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
2064 if (!ec) return EINA_FALSE;
2065 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2066 if (!ec->comp_data) return EINA_FALSE;
2068 ec->comp_data->on_focus_timer = NULL;
2070 e_input_thread_safe_call(_e_comp_wl_input_thread_send_keys, NULL, 0);
2076 _e_comp_wl_input_thread_focus_in(void *data)
2078 struct wl_resource *surface = NULL;
2079 struct wl_resource *res;
2080 struct wl_client *wc;
2083 EINA_SAFETY_ON_NULL_RETURN(data);
2084 surface = *(struct wl_resource **)data;
2086 wc = wl_resource_get_client(surface);
2088 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
2090 if (wl_resource_get_client(res) == wc)
2092 if (!eina_list_data_find(e_comp_input_key->kbd.focused, res))
2093 e_comp_input_key->kbd.focused = eina_list_append(e_comp_input_key->kbd.focused, res);
2097 if (!e_comp_input_key->kbd.focused)
2102 e_comp_input_key->kbd.focus = surface;
2103 e_comp_wl_input_keyboard_enter_send(surface);
2104 e_comp_wl_data_device_keyboard_focus_set();
2107 /* It is called in the following cases:
2108 * When a normal ec->frame has focus.
2109 * Or launching image ec is replaced to the real ec.
2112 e_comp_wl_feed_focus_in(E_Client *ec)
2117 if (e_object_is_del(E_OBJECT(ec))) return;
2118 if (ec->iconic) return;
2120 /* block spurious focus events */
2121 focused = e_client_focused_get();
2122 if ((focused) && (ec != focused)) return;
2124 /* raise client priority */
2125 _e_comp_wl_client_priority_raise(ec);
2127 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2128 if (!surface) return;
2130 INF("send focus in request to input thread. surface(%p)\n", surface);
2131 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_in, (void *)&surface, sizeof(struct wl_resource *));
2133 ec->comp_data->on_focus_timer =
2134 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2135 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2136 int rotation = ec->e.state.rot.ang.curr;
2137 e_pointer_rotation_set(e_comp->pointer, rotation);
2141 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2144 if (!(ec = data)) return;
2145 e_comp_wl_feed_focus_in(ec);
2149 _e_comp_wl_input_thread_focus_out(void *data)
2151 struct wl_resource *surface = NULL;
2152 struct wl_resource *res;
2154 E_Comp_Wl_Key_Data *k;
2158 EINA_SAFETY_ON_NULL_RETURN(data);
2160 surface = *(struct wl_resource **)data;
2162 /* update keyboard modifier state */
2163 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2164 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2166 if (!surface) return;
2168 if (!eina_list_count(e_comp_input_key->kbd.resources))
2173 /* send keyboard_leave to all keyboard resources */
2174 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2175 t = ecore_time_unix_get();
2177 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
2179 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2181 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2182 wl_keyboard_send_key(res, serial, t,
2183 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2185 wl_keyboard_send_leave(res, serial, surface);
2186 e_comp_input_key->kbd.focused =
2187 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
2192 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2195 if (!(ec = data)) return;
2197 if (!ec->comp_data) return;
2199 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2201 /* lower client priority */
2202 if (!e_object_is_del(data))
2203 _e_comp_wl_client_priority_normal(ec);
2205 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2206 INF("send focus out request to input thread. surface(%p)\n", surface);
2207 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_out, (void *)&surface, sizeof(struct wl_resource *));
2211 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2215 if (!(ec = data)) return;
2217 e_client_shell_ping(ec);
2221 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2226 if (!(ec = data)) return;
2227 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2228 if (ec->netwm.opacity == a) return;
2229 ec->netwm.opacity = a;
2230 ec->netwm.opacity_changed = EINA_TRUE;
2234 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2236 Eina_Rectangle *damage_rect = NULL;
2237 Eina_Rectangle *dmg = NULL;
2238 Eina_List *l = NULL;
2240 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2241 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2244 if (!buffer->tbm_surface) return;
2248 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2252 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2253 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2256 eina_rectangle_union(damage_rect, dmg);
2261 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2262 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2265 tbm_surface_internal_set_damage(buffer->tbm_surface,
2271 eina_rectangle_free(damage_rect);
2275 _e_comp_wl_client_evas_init(E_Client *ec)
2277 if (!ec || !ec->comp_data) return;
2278 if (ec->comp_data->evas_init) return;
2280 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2281 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2282 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2285 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2286 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2287 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2288 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2289 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2290 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2292 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2293 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2294 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2296 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2297 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2299 /* setup ping callback */
2300 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2301 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2303 ec->comp_data->evas_init = EINA_TRUE;
2307 _e_comp_wl_client_evas_deinit(E_Client *ec)
2309 if (!ec || !ec->comp_data) return;
2310 if (!ec->comp_data->evas_init) return;
2312 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2313 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2314 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2316 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2317 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2318 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2319 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2320 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2321 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2323 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2324 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2325 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2327 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2328 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2330 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2331 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2333 ec->comp_data->evas_init = EINA_FALSE;
2337 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2341 E_Comp_Screen *e_comp_screen;
2342 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2344 if (!e_comp) return ECORE_CALLBACK_RENEW;
2345 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2346 e_comp_screen = e_comp->e_comp_screen;
2348 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2350 if (!eout->config.enabled)
2352 e_comp_wl_output_remove(eout->id);
2356 switch (eout->config.rotation)
2359 transform = WL_OUTPUT_TRANSFORM_90;
2362 transform = WL_OUTPUT_TRANSFORM_180;
2365 transform = WL_OUTPUT_TRANSFORM_270;
2369 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2373 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2375 eout->config.geom.x, eout->config.geom.y,
2376 eout->config.geom.w, eout->config.geom.h,
2377 eout->info.size.w, eout->info.size.h,
2378 eout->config.mode.refresh, 0, transform))
2379 ERR("Could not initialize screen %s", eout->info.name);
2382 return ECORE_CALLBACK_RENEW;
2386 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2390 /* try to get the client from the object */
2391 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2392 return ECORE_CALLBACK_RENEW;
2394 /* check for client being deleted */
2395 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2397 /* check for wayland pixmap */
2398 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2399 return ECORE_CALLBACK_RENEW;
2401 /* if we have not setup evas callbacks for this client, do it */
2402 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2404 return ECORE_CALLBACK_RENEW;
2408 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2412 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2413 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2415 if (e_comp_wl->selection.target &&
2418 struct wl_resource *res;
2420 E_Client *ec = NULL;
2421 E_Client *legacy_target = e_comp_wl->selection.target;
2422 int device_id = e_comp_wl_data_current_device_id_get();
2426 e_comp_wl_data_current_device_id_set(ev->multi.device);
2428 else if (device_id != ev->multi.device)
2430 return ECORE_CALLBACK_RENEW;
2433 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2434 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2436 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2437 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2439 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2440 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2442 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2443 (ec != legacy_target))
2445 e_comp_wl_data_device_send_leave(legacy_target);
2446 e_comp_wl_data_device_send_enter(ec);
2449 if (e_comp_wl->drag)
2450 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2452 if (e_client_transform_core_enable_get(ec))
2454 int trans_x, trans_y;
2455 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2456 x = trans_x - ec->client.x;
2457 y = trans_y - ec->client.y;
2461 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2466 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2469 return ECORE_CALLBACK_RENEW;
2473 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2476 struct wl_resource *surface;
2477 struct wl_resource *res;
2478 struct wl_client *wc;
2480 E_Comp_Config *comp_conf;
2482 ec = e_comp_wl->ptr_constraints.ec;
2483 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2485 surface = e_comp_wl_client_surface_get(ec);
2486 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2488 wc = wl_resource_get_client(surface);
2490 comp_conf = e_comp_config_get();
2492 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2494 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2495 if (wl_resource_get_client(res) != wc) continue;
2497 if (comp_conf && comp_conf->input_log_enable)
2498 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2499 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2500 e_client_util_name_get(ec));
2502 zwp_relative_pointer_v1_send_relative_motion(res,
2504 (uint32_t)(ev->timestamp),
2505 wl_fixed_from_int(ev->dx),
2506 wl_fixed_from_int(ev->dy),
2507 wl_fixed_from_int(ev->dx_unaccel),
2508 wl_fixed_from_int(ev->dy_unaccel));
2511 return ECORE_CALLBACK_DONE;
2515 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2517 _e_comp_wl_touch_cancel();
2519 return ECORE_CALLBACK_PASS_ON;
2523 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2525 if (!ev) return ECORE_CALLBACK_PASS_ON;
2527 E_Zone *zone = ev->zone;
2529 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2530 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2532 if (!e_zone_is_displaying(zone))
2533 _e_comp_wl_touch_cancel();
2535 return ECORE_CALLBACK_PASS_ON;
2539 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2541 E_Client *ec = ev->ec;
2542 E_Comp_Wl_Buffer_Viewport *vp;
2544 if (!ec) return ECORE_CALLBACK_PASS_ON;
2545 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2546 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2547 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2548 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2550 vp = &ec->comp_data->scaler.buffer_viewport;
2551 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2553 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2555 return ECORE_CALLBACK_PASS_ON;
2559 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2561 E_Client *ec = ev->ec;
2562 E_Comp_Wl_Buffer_Viewport *vp;
2564 if (!ec) return ECORE_CALLBACK_PASS_ON;
2565 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2566 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2567 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2569 vp = &ec->comp_data->scaler.buffer_viewport;
2570 vp->wait_for_transform_change = 0;
2572 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2574 return ECORE_CALLBACK_PASS_ON;
2578 _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)
2580 E_Client *focused_ec;
2583 focused_ec = e_client_focused_get();
2584 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2586 rotation = focused_ec->e.state.rot.ang.curr;
2587 e_pointer_rotation_set(e_comp->pointer, rotation);
2589 return ECORE_CALLBACK_PASS_ON;
2593 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2596 Eina_Rectangle *window;
2601 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2603 if ((prev_w != state->bw) ||
2604 (prev_h != state->bh))
2606 ec->changes.buf_size = EINA_TRUE;
2609 if (e_comp_object_frame_exists(ec->frame)) return;
2610 window = &ec->comp_data->shell.window;
2611 if ((!ec->borderless) && /* FIXME temporarily added this check code
2612 * to prevent updating E_Client's size by frame */
2613 (window->x || window->y || window->w || window->h))
2615 e_comp_object_frame_geometry_set(ec->frame,
2617 (window->x + window->w) - state->bw,
2619 (window->y + window->h) - state->bh);
2622 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2626 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2628 E_Comp_Wl_Surface_State *state;
2631 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2632 state->buffer = NULL;
2636 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2638 state->new_attach = EINA_FALSE;
2639 state->buffer = NULL;
2640 state->buffer_destroy_listener.notify =
2641 _e_comp_wl_surface_state_cb_buffer_destroy;
2642 state->sx = state->sy = 0;
2644 state->input = eina_tiler_new(w, h);
2645 eina_tiler_tile_size_set(state->input, 1, 1);
2647 state->opaque = eina_tiler_new(w, h);
2648 eina_tiler_tile_size_set(state->opaque, 1, 1);
2650 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2651 state->buffer_viewport.buffer.scale = 1;
2652 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2653 state->buffer_viewport.surface.width = -1;
2654 state->buffer_viewport.changed = 0;
2656 e_presentation_time_container_init(&state->presentation_container);
2660 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2662 struct wl_resource *cb;
2663 Eina_Rectangle *dmg;
2665 EINA_LIST_FREE(state->frames, cb)
2666 wl_resource_destroy(cb);
2668 EINA_LIST_FREE(state->damages, dmg)
2669 eina_rectangle_free(dmg);
2671 EINA_LIST_FREE(state->buffer_damages, dmg)
2672 eina_rectangle_free(dmg);
2674 if (state->opaque) eina_tiler_free(state->opaque);
2675 state->opaque = NULL;
2677 if (state->input) eina_tiler_free(state->input);
2678 state->input = NULL;
2680 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2681 state->buffer = NULL;
2683 e_presentation_time_container_finish(&state->presentation_container);
2687 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2689 if (state->buffer == buffer) return;
2691 wl_list_remove(&state->buffer_destroy_listener.link);
2692 state->buffer = buffer;
2694 wl_signal_add(&state->buffer->destroy_signal,
2695 &state->buffer_destroy_listener);
2699 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2701 Eina_Rectangle *dmg;
2702 Eina_Bool placed = EINA_TRUE;
2706 E_Comp_Wl_Buffer *buffer;
2707 struct wl_resource *cb;
2709 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2710 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2715 if ((ec->internal) ||
2716 (cdata->shell.surface && state->new_attach))
2720 e_comp->new_clients++;
2721 ELOGF("COMP", "Unignore", ec);
2722 e_client_unignore(ec);
2726 /* buffer transform */
2727 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2730 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2732 /* when buffer is transformed, we have to apply the new evas-map */
2733 state->buffer_viewport.changed = EINA_TRUE;
2735 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2737 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2739 if (transform_change == vp->wait_for_transform_change)
2740 vp->wait_for_transform_change = 0;
2742 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2743 // triggered by E_CLIENT_HOOK calls at those file.
2744 zone = e_comp_zone_find_by_ec(ec);
2747 eout = e_output_find(zone->output_id);
2748 if (eout && eout->hwc)
2750 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2752 if (e_comp_is_on_overlay(ec))
2753 e_comp_hwc_client_end(ec, __FUNCTION__);
2759 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2760 cdata->scaler.buffer_viewport = state->buffer_viewport;
2762 if (state->new_attach)
2764 e_comp_wl_surface_attach(ec, state->buffer);
2767 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2768 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2770 _e_comp_wl_surface_state_buffer_set(state, NULL);
2772 if ((state->new_attach) ||
2773 (state->buffer_viewport.changed))
2775 _e_comp_wl_surface_state_size_update(ec, state);
2776 e_comp_wl_map_size_cal_from_viewport(ec);
2778 /* update the position */
2779 if (ec->changes.pos)
2781 e_comp_object_frame_xy_unadjust(ec->frame,
2791 if (ec->new_client) placed = ec->placed;
2793 if (!ec->lock_client_size)
2798 ec->client.w = state->bw;
2799 ec->client.h = state->bh;
2801 e_comp_object_frame_wh_adjust(ec->frame,
2802 ec->client.w, ec->client.h,
2804 e_client_size_set(ec, nw, nh);
2806 if ((w != ec->w) || (h != ec->h))
2808 ec->changes.size = 1;
2813 if (ec->changes.buf_size)
2815 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2816 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2817 ec->changes.buf_size = EINA_FALSE;
2819 if (ec->move_after_resize)
2821 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2822 ec->move_after_resize = EINA_FALSE;
2827 /* map or unmap ec */
2828 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2829 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2830 if (!pixmap_usable || hide_by_request)
2835 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2840 if ((cdata->sub.below_obj) &&
2841 (evas_object_visible_get(cdata->sub.below_obj)))
2843 evas_object_hide(cdata->sub.below_obj);
2851 if ((cdata->sub.below_obj) &&
2852 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2853 (evas_object_visible_get(ec->frame)))
2855 evas_object_show(cdata->sub.below_obj);
2859 if ((state->new_attach) ||
2860 (state->buffer_viewport.changed))
2862 if ((e_comp_wl->drag) &&
2863 (e_comp_wl->drag_client) &&
2864 (e_comp_wl->drag_client == ec))
2866 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2868 e_drag_move(e_comp_wl->drag,
2870 e_comp_wl->drag->y);
2872 e_drag_resize(e_comp_wl->drag,
2873 state->bw, state->bh);
2875 else if ((cdata->shell.surface) &&
2876 (cdata->shell.configure))
2878 e_comp_wl_commit_sync_configure(ec);
2880 else if (!e_client_video_hw_composition_check(ec))
2882 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
2887 ec->placed = placed;
2888 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
2892 if (cdata->scaler.buffer_viewport.changed)
2893 e_comp_wl_map_apply(ec);
2895 /* resize transform object */
2896 if (ec->transformed)
2897 e_client_transform_update(ec);
2901 state->new_attach = EINA_FALSE;
2903 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
2905 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
2906 wl_resource_destroy(cb);
2909 /* insert state frame callbacks into comp_data->frames
2910 * NB: This clears state->frames list */
2911 cdata->frames = eina_list_merge(cdata->frames,
2913 state->frames = NULL;
2915 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
2916 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
2917 &state->presentation_container);
2919 buffer = e_pixmap_resource_get(ec->pixmap);
2921 /* put state damages into surface */
2924 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
2925 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
2927 if ((cdata->buffer_ref.buffer) &&
2928 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
2929 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
2931 e_comp_object_damage(ec->frame,
2933 cdata->buffer_ref.buffer->w,
2934 cdata->buffer_ref.buffer->h);
2939 Eina_List *damages = NULL;
2942 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
2944 if (eina_list_count(state->buffer_damages))
2946 EINA_LIST_FREE(state->buffer_damages, dmg)
2949 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
2950 e_comp_wl_output_buffer_transform_get(ec),
2952 dmg->x, dmg->y, dmg->w, dmg->h,
2953 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
2954 damages = eina_list_append(damages, dmg);
2958 EINA_LIST_FREE(state->damages, dmg)
2959 damages = eina_list_append(damages, dmg);
2961 EINA_LIST_FREE(damages, dmg)
2963 /* not creating damage for ec that shows a underlay video */
2964 if (state->buffer_viewport.changed ||
2965 !e_comp->wl_comp_data->available_hw_accel.underlay ||
2966 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
2967 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
2969 eina_rectangle_free(dmg);
2974 /* put state opaque into surface */
2975 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
2978 Eina_Rectangle *rect;
2981 itr = eina_tiler_iterator_new(state->opaque);
2982 EINA_ITERATOR_FOREACH(itr, rect)
2986 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
2987 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
2988 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
2992 eina_iterator_free(itr);
2995 /* put state input into surface */
2996 if ((state->input) &&
2997 (!eina_tiler_empty(state->input)) &&
3000 Eina_Tiler *src, *tmp;
3004 tmp = eina_tiler_new(sw, sh);
3005 eina_tiler_tile_size_set(tmp, 1, 1);
3007 eina_tiler_rect_add(tmp,
3008 &(Eina_Rectangle){0, 0, sw, sh});
3010 if ((src = eina_tiler_intersection(state->input, tmp)))
3012 Eina_Rectangle *rect;
3015 e_comp_object_input_objs_del(ec->frame);
3016 itr = eina_tiler_iterator_new(src);
3017 EINA_ITERATOR_FOREACH(itr, rect)
3019 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3020 ec, rect->x, rect->y, rect->w, rect->h,
3021 ec->w, ec->h, state->bw, state->bh);
3022 e_comp_object_input_area_set(ec->frame,
3027 eina_iterator_free(itr);
3028 eina_tiler_free(src);
3031 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3033 eina_tiler_free(tmp);
3035 /* clear input tiler */
3036 eina_tiler_clear(state->input);
3039 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3041 if ((cdata->video_client) &&
3043 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3044 (e_comp->wl_comp_data->available_hw_accel.underlay))
3046 e_pixmap_image_clear(ec->pixmap, 1);
3049 state->buffer_viewport.changed = 0;
3051 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3054 ec->exp_iconify.buffer_flush &&
3055 e_policy_visibility_client_is_iconic(ec))
3057 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3062 _e_comp_wl_surface_render_stop(E_Client *ec)
3064 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3065 //if ((!ec->internal) && (!e_comp_gl_get()))
3068 /* check if internal animation is running */
3069 if (e_comp_object_is_animating(ec->frame)) return;
3070 /* check if external animation is running */
3071 if (evas_object_data_get(ec->frame, "effect_running")) return;
3073 evas_object_hide(ec->frame);
3077 _e_input_thread_client_free(void *data)
3079 E_Input_Thread_Request_EClient_Data *ec_data = data;
3080 EINA_SAFETY_ON_NULL_RETURN(ec_data);
3082 INF("[input thread|%s] ec: %p, surface: %p\n", __func__, ec_data->ec, ec_data->wl_surface);
3086 e_comp_wl_client_surface_finish(E_Client *ec)
3088 struct wl_resource *res, *surface;
3089 struct wl_client *surface_client = NULL;
3092 surface = e_comp_wl_client_surface_get(ec);
3095 surface_client = wl_resource_get_client(surface);
3097 if (surface_client &&
3098 (ec == e_client_focused_get()))
3100 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
3102 if (wl_resource_get_client(res) ==
3104 e_comp_input_key->kbd.focused =
3105 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
3110 E_Input_Thread_Request_EClient_Data ec_free_data;
3111 memset(&ec_free_data, 0, sizeof(E_Input_Thread_Request_EClient_Data));
3112 ec_free_data.ec = ec;
3113 ec_free_data.wl_surface = ec->comp_data->wl_surface;
3115 INF("[e_comp_wl_client_surface_finish] surface: %p\n", ec_free_data.wl_surface);
3116 e_input_thread_safe_call(_e_input_thread_client_free, &ec_free_data, sizeof(E_Input_Thread_Request_EClient_Data));
3118 e_comp_wl_client_surface_set(ec, NULL);
3120 ec->comp_data->wl_surface = NULL;
3121 e_pixmap_win_id_del(ec->pixmap);
3123 _e_comp_wl_surface_render_stop(ec);
3124 e_object_del(E_OBJECT(ec));
3128 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3133 char proc[512], pname[512];
3136 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3138 h = fopen(proc, "r");
3141 len = fread(pname, sizeof(char), 512, h);
3143 pname[len - 1] = '\0';
3145 strncpy(pname, "NO NAME", sizeof(pname));
3151 strncpy(pname, "NO NAME", sizeof(pname));
3154 strncpy(name, pname, size);
3158 _e_comp_wl_pname_print(pid_t pid)
3161 char proc[512], pname[512];
3164 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3166 h = fopen(proc, "r");
3169 len = fread(pname, sizeof(char), 512, h);
3171 pname[len - 1] = '\0';
3173 strncpy(pname, "NO NAME", sizeof(pname));
3177 ELOGF("COMP", " |%s", NULL, pname);
3182 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3184 struct wl_client *client = data;
3185 E_Comp_Connected_Client_Info *cinfo;
3188 cinfo = wl_container_of(listener, cinfo, destroy);
3190 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3191 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3193 eai = e_appinfo_find_with_pid(cinfo->pid);
3194 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3197 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3199 wl_list_remove(&cinfo->destroy.link);
3200 eina_stringshare_del(cinfo->name);
3205 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3207 E_Comp_Connected_Client_Info *cinfo;
3209 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3210 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3212 cinfo->name = eina_stringshare_add(name);
3216 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3217 wl_client_add_destroy_listener(client, &cinfo->destroy);
3218 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3220 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3224 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3226 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3228 /* send configure */
3229 if (ec->comp_data->shell.configure_send)
3231 if (ec->comp_data->shell.surface)
3232 _e_comp_wl_configure_send(ec, 0, 0);
3235 e_comp_input_key->kbd.focus = ec->comp_data->surface;
3239 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3241 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3243 /* send configure */
3244 if (ec->comp_data->shell.configure_send)
3246 if (ec->comp_data->shell.surface)
3247 _e_comp_wl_configure_send(ec, 0, 0);
3250 _e_comp_wl_focus_check();
3252 if (e_comp_input_key->kbd.focus == ec->comp_data->surface)
3253 e_comp_input_key->kbd.focus = NULL;
3257 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3259 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3260 if (ec->keyboard_resizing) return;
3262 /* do nothing currently */
3267 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3269 if (e_object_is_del(E_OBJECT(ec))) return;
3270 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3272 e_comp_wl->resize.edges = 0;
3273 e_comp_wl->resize.resource = NULL;
3277 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3279 if (e_object_is_del(E_OBJECT(ec))) return;
3280 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3284 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3287 int ratio_w, ratio_h;
3289 phys_w = output->phys_width;
3290 phys_h = output->phys_height;
3292 if (e_config->configured_output_resolution.use)
3294 // change the configured physical size(mm) of the output
3295 if (output->w != res_w)
3297 ratio_w = res_w / output->w;
3298 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3301 if (output->h != res_h)
3303 ratio_h = res_h / output->h;
3304 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3307 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3310 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3311 NULL, res_w, res_h, phys_w, phys_h, pid);
3313 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3314 wl_output_send_scale(resource, output->scale);
3316 wl_output_send_geometry(resource, output->x, output->y,
3318 output->subpixel, output->make ?: "",
3319 output->model ?: "", output->transform);
3321 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3322 res_w, res_h, output->refresh);
3324 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3325 wl_output_send_done(resource);
3329 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3331 E_Comp_Wl_Output *output;
3333 if (!(output = wl_resource_get_user_data(resource))) return;
3335 output->resources = eina_list_remove(output->resources, resource);
3339 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3341 E_Comp_Wl_Output *output;
3342 struct wl_resource *resource;
3343 E_Appinfo *eai = NULL;
3347 if (!(output = data)) return;
3350 wl_resource_create(client, &wl_output_interface, version, id);
3353 wl_client_post_no_memory(client);
3357 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3358 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3360 output->resources = eina_list_append(output->resources, resource);
3362 wl_resource_set_implementation(resource, NULL, output,
3363 _e_comp_wl_cb_output_unbind);
3364 wl_resource_set_user_data(resource, output);
3366 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3367 if (e_config->configured_output_resolution.use)
3369 wl_client_get_credentials(client, &pid, NULL, NULL);
3372 res_w = e_config->configured_output_resolution.w;
3373 res_h = e_config->configured_output_resolution.h;
3377 eai = e_appinfo_find_with_pid(pid);
3380 res_w = e_config->configured_output_resolution.w;
3381 res_h = e_config->configured_output_resolution.h;
3385 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3387 res_w = e_config->configured_output_resolution.w;
3388 res_h = e_config->configured_output_resolution.h;
3392 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3401 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3405 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3408 Evas_GL *evasgl = NULL;
3409 Evas_GL_API *glapi = NULL;
3410 Evas_GL_Context *ctx = NULL;
3411 Evas_GL_Surface *sfc = NULL;
3412 Evas_GL_Config *cfg = NULL;
3414 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3416 if (!e_comp_gl_get()) return;
3418 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3419 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3421 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3422 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3424 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3425 * then we should get evas from ecore_evas.
3428 evas = e_comp->evas;
3430 evas = ecore_evas_get(e_comp->ee);
3432 evasgl = evas_gl_new(evas);
3433 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3435 glapi = evas_gl_api_get(evasgl);
3436 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3437 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3439 cfg = evas_gl_config_new();
3440 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3442 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3443 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3445 ctx = evas_gl_context_create(evasgl, NULL);
3446 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3448 res = evas_gl_make_current(evasgl, sfc, ctx);
3449 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3451 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3452 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3454 evas_gl_config_free(cfg);
3456 evas_gl->gl = evasgl;
3457 evas_gl->glapi = glapi;
3458 evas_gl->glsfc = sfc;
3459 evas_gl->glctx = ctx;
3461 e_comp_wl->evas_gl = evas_gl;
3463 /* for native surface */
3466 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3471 evas_gl_config_free(cfg);
3472 evas_gl_make_current(evasgl, NULL, NULL);
3473 evas_gl_context_destroy(evasgl, ctx);
3474 evas_gl_surface_destroy(evasgl, sfc);
3475 evas_gl_free(evasgl);
3482 _e_comp_wl_gl_popup_cb_close(void *data,
3483 Evas_Object *obj EINA_UNUSED,
3484 void *event_info EINA_UNUSED)
3486 evas_object_del(data);
3490 _e_comp_wl_gl_popup_cb_focus(void *data,
3491 Evas_Object *obj EINA_UNUSED,
3492 void *event_info EINA_UNUSED)
3494 elm_object_focus_set(data, EINA_TRUE);
3499 _e_comp_wl_gl_idle(void *data)
3503 /* show warning window to notify failure of gl init */
3506 Evas_Object *win, *bg, *popup, *btn;
3508 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3509 elm_win_title_set(win, "Compositor Warning");
3510 elm_win_autodel_set(win, EINA_TRUE);
3511 elm_win_borderless_set(win, EINA_TRUE);
3512 elm_win_role_set(win, "notification-low");
3513 elm_win_alpha_set(win, EINA_TRUE);
3515 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3516 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3517 elm_win_resize_object_add(win, bg);
3518 evas_object_color_set(bg, 125, 125, 125, 125);
3519 evas_object_show(bg);
3521 popup = elm_popup_add(win);
3522 elm_object_text_set(popup,
3523 _( "Your screen does not support OpenGL.<br>"
3524 "Falling back to software engine."));
3525 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3527 btn = elm_button_add(popup);
3528 elm_object_text_set(btn, "Close");
3529 elm_object_part_content_set(popup, "button1", btn);
3530 evas_object_show(btn);
3532 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3533 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3535 evas_object_show(popup);
3536 evas_object_show(win);
3540 return ECORE_CALLBACK_CANCEL;
3544 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3546 struct wl_client *client = data;
3552 wl_client_get_credentials(client, &pid, &uid, &gid);
3554 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3556 _e_comp_wl_pname_print(pid);
3557 _e_comp_wl_pname_get(pid, name, sizeof(name));
3558 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3562 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3564 char buf[1024] = {0, };
3566 vsnprintf(buf, 1024, fmt, args);
3570 DBG("[libds] %s", buf);
3573 INF("[libds] %s", buf);
3576 ERR("[libds] %s", buf);
3584 _e_comp_wl_display_create(void)
3587 E_Comp_Wl_Data *wl_cdata;
3592 /* create new compositor data */
3593 if (!(comp = E_NEW(E_Comp_Data, 1)))
3595 ERR("Could not create compositor data: %m");
3598 wl_cdata = &comp->base;
3600 /* set compositor wayland data */
3601 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3603 g_mutex_init(&connection_mutex);
3605 /* try to create a wayland display */
3606 if (!(wl_cdata->wl.disp = wl_display_create()))
3608 ERR("Could not create a Wayland display: %m");
3612 /* try to setup wayland socket */
3613 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3615 ERR("Could not create Wayland display socket: %m");
3616 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3620 res = e_comp_socket_init(name);
3621 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3622 PRCTL("[Winsys] change permission and create sym link for %s", name);
3624 /* set wayland display environment variable */
3625 e_env_set("WAYLAND_DISPLAY", name);
3627 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3628 /* wl_cdata->output.scale = e_scale; */
3630 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3632 if (!e_compositor_init(wl_cdata->wl.disp))
3634 ERR("Failed to initialize compositor");
3638 comp->client_created.notify = _e_comp_wl_cb_client_created;
3639 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3641 if (!e_comp_wl_subsurfaces_init())
3643 ERR("Failed to init_subsurfaces");
3644 goto subsurfaces_err;
3647 /* initialize shm mechanism */
3648 wl_display_init_shm(wl_cdata->wl.disp);
3650 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3652 /* try to init data manager */
3653 if (!e_comp_wl_data_manager_init())
3655 ERR("Could not initialize data manager");
3659 /* try to init input */
3660 if (!e_comp_wl_input_init())
3662 ERR("Could not initialize input");
3666 if (e_comp_gl_get())
3667 _e_comp_wl_gl_init(NULL);
3669 /* get the wayland display loop */
3670 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3672 /* get the file descriptor of the wayland event loop */
3673 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3675 /* create a listener for wayland main loop events */
3677 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3678 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3679 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3680 _e_comp_wl_cb_prepare, wl_cdata);
3682 /* add awake handler */
3683 ecore_main_awake_handler_add(_e_comp_wl_cb_awake, NULL);
3688 e_comp_wl_data_manager_shutdown();
3690 e_comp_wl_subsurfaces_shutdown();
3692 wl_list_remove(&comp->client_created.link);
3694 e_env_unset("WAYLAND_DISPLAY");
3696 wl_display_destroy(wl_cdata->wl.disp);
3698 g_mutex_clear(&connection_mutex);
3704 _e_comp_wl_gl_shutdown(void)
3706 if (!e_comp_wl->evas_gl) return;
3708 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3710 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3711 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3712 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3713 evas_gl_free(e_comp_wl->evas_gl->gl);
3715 E_FREE(e_comp_wl->evas_gl);
3718 /* public functions */
3721 * Creates and initializes a Wayland compositor with ecore.
3722 * Registers callback handlers for keyboard and mouse activity
3723 * and other client events.
3725 * @returns true on success, false if initialization failed.
3728 e_comp_wl_init(void)
3730 TRACE_DS_BEGIN(COMP_WL:INIT);
3732 /* try to create a wayland compositor */
3733 if (!_e_comp_wl_display_create())
3735 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3740 e_comp_wl_shell_init();
3742 #ifdef HAVE_WAYLAND_TBM
3743 e_comp_wl_tbm_init();
3745 e_comp_wl_remote_surface_init();
3749 e_comp_wl_screenshooter_init();
3751 if (!e_comp_wl_video_init())
3752 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3754 e_comp_wl_viewport_init();
3755 e_comp_wl_capture_init();
3756 e_comp_wl_renderer_init();
3757 _e_comp_wl_move_resize_init();
3758 e_presentation_time_init();
3759 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3761 e_blur_manager_init();
3763 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3764 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3766 /* add event handlers to catch E events */
3767 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3768 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3769 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3770 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3771 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3772 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3773 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3774 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3775 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3777 /* add hooks to catch e_client events */
3778 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3779 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3780 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3781 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3782 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3789 e_comp_wl_deferred_job(void)
3791 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3794 /* internal functions */
3796 e_comp_wl_shutdown(void)
3798 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3800 e_comp_wl_subsurfaces_shutdown();
3802 E_FREE_LIST(handlers, ecore_event_handler_del);
3803 E_FREE_LIST(hooks, e_client_hook_del);
3804 _e_comp_wl_gl_shutdown();
3806 e_presentation_time_shutdown();
3807 e_comp_wl_renderer_shutdown();
3808 e_comp_wl_capture_shutdown();
3809 e_comp_wl_viewport_shutdown();
3810 e_comp_wl_video_shutdown();
3811 e_comp_wl_screenshooter_shutdown();
3813 e_comp_wl_remote_surface_shutdown();
3815 e_pixmap_shutdown();
3817 e_wtz_shell_shutdown();
3818 e_comp_wl_shell_shutdown();
3819 e_comp_wl_input_shutdown();
3821 wl_list_remove(&comp->client_created.link);
3823 /* delete awake handler */
3824 ecore_main_awake_handler_del(_e_comp_wl_cb_awake);
3827 e_comp->wl_comp_data = NULL;
3831 E_Comp_Wl_Output *output;
3833 if (e_comp_wl->screenshooter.global)
3834 wl_global_destroy(e_comp_wl->screenshooter.global);
3836 EINA_LIST_FREE(e_comp_wl->outputs, output)
3838 if (output->id) eina_stringshare_del(output->id);
3839 if (output->make) eina_stringshare_del(output->make);
3840 if (output->model) eina_stringshare_del(output->model);
3844 /* delete fd handler */
3845 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3847 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3848 cursor_timer_ec = NULL;
3850 /* free allocated data structure */
3856 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3858 e_object_unref(E_OBJECT(ev->ec));
3863 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3866 ev = E_NEW(E_Event_Client, 1);
3869 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3871 /* set usable early because shell module checks this */
3872 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3873 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3875 e_pixmap_resource_set(ec->pixmap, buffer);
3876 e_pixmap_dirty(ec->pixmap);
3877 e_pixmap_refresh(ec->pixmap);
3879 e_comp_wl_map_size_cal_from_buffer(ec);
3880 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3882 /* wm-policy module uses it */
3883 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
3886 e_object_ref(E_OBJECT(ec));
3887 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
3888 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
3892 e_comp_wl_surface_commit(E_Client *ec)
3897 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
3898 if (!e_comp_object_damage_exists(ec->frame))
3900 if ((ec->comp_data->video_client) ||
3901 (!e_client_video_hw_composition_check(ec)))
3902 e_pixmap_image_clear(ec->pixmap, 1);
3905 ignored = ec->ignored;
3907 if (e_comp_wl_subsurface_order_commit(ec))
3909 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
3910 e_comp_wl_subsurface_restack(topmost);
3911 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
3914 ec->ignored = ignored;
3916 if (ec->is_cursor && ec->visible)
3918 /* ignore cursor changes during resize/move I guess */
3919 if (!e_client_action_get())
3921 if (e_comp->pointer)
3923 x = e_comp->pointer->hot.x;
3924 y = e_comp->pointer->hot.y;
3926 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
3932 static E_Comp_Wl_Output *
3933 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
3936 E_Comp_Wl_Output *output;
3938 EINA_LIST_FOREACH(outputs, l, output)
3940 if (!strcmp(output->id, id))
3948 * Initializes information about one display output.
3950 * Adds or updates the given data about a single display output,
3951 * with an id matching the provided id.
3953 * @param id identification of output to be added or changed
3954 * @param make manufacturer name of the display output
3955 * @param model model name of the display output
3956 * @param x output's top left corner x coordinate
3957 * @param y output's top left corner y coordinate
3958 * @param w output's width in pixels
3959 * @param h output's height in pixels
3960 * @param pw output's physical width in millimeters
3961 * @param ph output's physical height in millimeters
3962 * @param refresh output's refresh rate in mHz
3963 * @param subpixel output's subpixel layout
3964 * @param transform output's rotation and/or mirror transformation
3966 * @returns True if a display output object could be added or updated
3969 e_comp_wl_output_init(const char *id, const char *make, const char *model,
3970 int x, int y, int w, int h, int pw, int ph,
3971 unsigned int refresh, unsigned int subpixel,
3972 unsigned int transform)
3974 E_Comp_Wl_Output *output;
3976 struct wl_resource *resource;
3978 /* retrieve named output; or create it if it doesn't exist */
3979 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
3982 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
3984 if (id) output->id = eina_stringshare_add(id);
3986 output->make = eina_stringshare_add(make);
3988 output->make = eina_stringshare_add("unknown");
3990 output->model = eina_stringshare_add(model);
3992 output->model = eina_stringshare_add("unknown");
3994 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
3997 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
3998 2, output, _e_comp_wl_cb_output_bind);
4000 output->resources = NULL;
4001 output->scale = e_scale;
4004 /* update the output details */
4009 output->phys_width = pw;
4010 output->phys_height = ph;
4011 output->refresh = refresh;
4012 output->subpixel = subpixel;
4013 output->transform = transform;
4015 if (output->scale <= 0)
4016 output->scale = e_scale;
4018 /* if we have bound resources, send updates */
4019 EINA_LIST_FOREACH(output->resources, l2, resource)
4021 wl_output_send_geometry(resource,
4022 output->x, output->y,
4024 output->phys_height,
4026 output->make ?: "", output->model ?: "",
4029 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4030 wl_output_send_scale(resource, output->scale);
4032 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4033 output->w, output->h, output->refresh);
4035 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4036 wl_output_send_done(resource);
4043 e_comp_wl_output_remove(const char *id)
4045 E_Comp_Wl_Output *output;
4047 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4050 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4052 /* wl_global_destroy(output->global); */
4054 /* eina_stringshare_del(output->id); */
4055 /* eina_stringshare_del(output->make); */
4056 /* eina_stringshare_del(output->model); */
4063 _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)
4065 struct wl_resource *res;
4067 uint32_t serial, keycode;
4068 struct wl_client *wc = NULL;
4069 E_Comp_Config *comp_conf = NULL;
4070 const char *device_name = NULL;
4072 keycode = (ev->keycode - 8);
4074 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4076 comp_conf = e_comp_config_get();
4078 if (ec && ec->comp_data)
4080 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4083 wc = wl_resource_get_client(surface);
4086 if (e_config->key_input_ttrace_enable)
4088 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4089 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4092 EINA_LIST_FOREACH(key_list, l, res)
4094 if (wl_resource_get_client(res) != wc) continue;
4096 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4097 if (!e_input_thread_mode_get())
4099 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4100 device_name = ecore_device_name_get(ev->dev);
4106 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4107 device_name = e_device_name_get(dev);
4111 if (comp_conf && comp_conf->input_log_enable)
4112 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4114 wl_keyboard_send_key(res, serial, ev->timestamp,
4119 if (e_config->key_input_ttrace_enable)
4122 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4127 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4129 E_Client *ec = NULL;
4131 E_Comp_Wl_Key_Data *end, *k;
4133 if (ev->window != e_comp->ee_win)
4138 keycode = (ev->keycode - 8);
4139 if (!(e_comp_wl = e_comp->wl_comp_data))
4144 #ifndef E_RELEASE_BUILD
4145 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4146 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4147 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4148 eina_streq(ev->key, "BackSpace"))
4154 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4156 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4158 /* ignore server-generated key repeats */
4159 if (k->key == keycode)
4165 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4167 ec = e_client_focused_get();
4168 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4169 if (ec && ec->comp_data && surface)
4171 if (e_comp_input_key->kbd.focused)
4173 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_input_key->kbd.focused, ec);
4175 /* A key only sent to clients is added to the list */
4176 e_comp_input_key->kbd.keys.size = (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4178 if (!(k = wl_array_add(&e_comp_input_key->kbd.keys, sizeof(*k))))
4180 DBG("wl_array_add: Out of memory\n");
4189 /* update modifier state */
4190 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4196 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4198 E_Client *ec = NULL;
4199 uint32_t keycode, delivered_key;
4200 E_Comp_Wl_Key_Data *end, *k;
4202 if (ev->window != e_comp->ee_win)
4207 keycode = (ev->keycode - 8);
4209 if (!(e_comp_wl = e_comp->wl_comp_data))
4214 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4215 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4217 if (k->key == keycode)
4224 e_comp_input_key->kbd.keys.size =
4225 (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4227 /* 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) */
4228 if ((delivered_key) ||
4229 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4231 ec = e_client_focused_get();
4233 if (e_comp_input_key->kbd.focused)
4235 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_input_key->kbd.focused, ec);
4239 /* update modifier state */
4240 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4246 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4248 Eina_Bool res = EINA_FALSE;
4250 if (type == ECORE_EVENT_KEY_DOWN)
4252 res = e_comp_wl_key_down(ev, dev);
4254 else if (type == ECORE_EVENT_KEY_UP)
4256 res = e_comp_wl_key_up(ev, dev);
4263 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4266 struct wl_client *wc;
4267 uint32_t serial, btn;
4268 struct wl_resource *res;
4269 E_Comp_Config *comp_conf = NULL;
4271 if (ec->cur_mouse_action || e_comp_wl->drag)
4273 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4274 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4278 case 1: btn = BTN_LEFT; break;
4279 case 2: btn = BTN_MIDDLE; break;
4280 case 3: btn = BTN_RIGHT; break;
4281 default: btn = button_id; break;
4284 e_comp_wl->ptr.button = btn;
4285 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4286 if (!surface) return EINA_FALSE;
4288 if (!eina_list_count(e_comp_wl->ptr.resources))
4291 wc = wl_resource_get_client(surface);
4292 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4294 comp_conf = e_comp_config_get();
4296 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4298 if (wl_resource_get_client(res) != wc) continue;
4299 if (!e_comp_wl_input_pointer_check(res)) continue;
4300 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4302 if (comp_conf && comp_conf->input_log_enable)
4303 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4305 wl_pointer_send_button(res, serial, timestamp, btn, state);
4312 e_comp_wl_touch_cancel(void)
4314 _e_comp_wl_touch_cancel();
4317 E_API E_Comp_Wl_Hook *
4318 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4322 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4323 ch = E_NEW(E_Comp_Wl_Hook, 1);
4324 if (!ch) return NULL;
4325 ch->hookpoint = hookpoint;
4327 ch->data = (void*)data;
4328 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4333 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4336 if (_e_comp_wl_hooks_walking == 0)
4338 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4342 _e_comp_wl_hooks_delete++;
4345 E_API E_Comp_Wl_Pid_Hook *
4346 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4348 E_Comp_Wl_Pid_Hook *ch;
4350 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4352 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4353 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4355 ch->hookpoint = hookpoint;
4357 ch->data = (void*)data;
4358 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4364 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4367 if (_e_comp_wl_pid_hooks_walking == 0)
4369 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4373 _e_comp_wl_pid_hooks_delete++;
4376 E_API E_Comp_Wl_Intercept_Hook *
4377 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4379 E_Comp_Wl_Intercept_Hook *ch;
4381 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4382 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4383 if (!ch) return NULL;
4384 ch->hookpoint = hookpoint;
4386 ch->data = (void*)data;
4387 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4392 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4395 if (_e_comp_wl_intercept_hooks_walking == 0)
4397 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4401 _e_comp_wl_intercept_hooks_delete++;
4405 e_comp_wl_shell_surface_ready(E_Client *ec)
4409 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4413 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4415 e_config->use_cursor_timer = !!enabled;
4417 if (e_config->use_cursor_timer)
4419 if (!e_pointer_is_hidden(e_comp->pointer))
4421 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4426 if (e_comp_wl->ptr.hide_tmr)
4428 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4429 e_comp_wl->ptr.hide_tmr = NULL;
4431 cursor_timer_ec = NULL;
4433 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4436 if (e_pointer_is_hidden(e_comp->pointer))
4438 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4444 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4446 EINA_SAFETY_ON_NULL_RETURN(wc);
4447 EINA_SAFETY_ON_NULL_RETURN(dev);
4449 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4453 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4455 EINA_SAFETY_ON_NULL_RETURN(wc);
4456 EINA_SAFETY_ON_NULL_RETURN(dev);
4458 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4462 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4464 struct wl_resource *res;
4465 struct wl_client *wc;
4467 uint32_t serial, wl_keycode;
4468 enum wl_keyboard_key_state state;
4469 E_Comp_Config *comp_conf = NULL;
4470 const char *dev_name = NULL;
4472 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4473 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4474 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4476 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4477 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4479 wl_keycode = keycode - 8;
4480 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4482 wc = wl_resource_get_client(surface);
4483 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4484 if (!time) time = e_util_timestamp_get();
4485 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4486 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4488 comp_conf = e_comp_config_get();
4489 e_keyrouter_event_surface_send(ec, keycode);
4491 if (e_config->key_input_ttrace_enable)
4493 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4494 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4497 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4499 if (wl_resource_get_client(res) != wc) continue;
4500 if (!e_input_thread_mode_get())
4504 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4505 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4509 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4516 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4517 dev_name = e_device_name_get(dev);
4521 if (comp_conf && comp_conf->input_log_enable)
4522 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4525 wl_keyboard_send_key(res, serial, time,
4529 if (e_config->key_input_ttrace_enable)
4532 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4539 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4541 struct wl_resource *res;
4542 struct wl_client *wc;
4544 uint32_t serial, wl_keycode, cancel_keycode;
4545 E_Comp_Config *comp_conf = NULL;
4546 struct xkb_keymap *keymap = NULL;
4548 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4549 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4550 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4552 keymap = e_comp_input_key->xkb.keymap;
4553 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4555 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4556 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4558 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4559 if (cancel_keycode == XKB_KEYCODE_INVALID)
4561 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4565 EINA_SAFETY_ON_TRUE_RETURN_VAL(cancel_keycode < 8, EINA_FALSE);
4567 cancel_keycode = cancel_keycode - 8;
4569 wl_keycode = keycode - 8;
4570 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4572 wc = wl_resource_get_client(surface);
4573 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4574 if (!time) time = e_util_timestamp_get();
4576 comp_conf = e_comp_config_get();
4577 e_keyrouter_event_surface_send(ec, keycode);
4579 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4581 if (wl_resource_get_client(res) != wc) continue;
4582 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4583 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4585 if (comp_conf && comp_conf->input_log_enable)
4586 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4587 wl_keyboard_send_key(res, serial, time,
4588 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4589 wl_keyboard_send_key(res, serial, time,
4590 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4591 wl_keyboard_send_key(res, serial, time,
4592 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4600 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)
4602 struct wl_client *wc;
4604 E_Devicemgr_Input_Device *device = NULL;
4606 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4607 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4608 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4610 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4611 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4613 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4615 wc = wl_resource_get_client(surface);
4616 if (!time) time = e_util_timestamp_get();
4617 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4621 _e_comp_wl_send_event_device(wc, time, dev, serial);
4622 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4626 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4627 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4630 x = x + ec->client.x;
4631 y = y + ec->client.y;
4633 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4639 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)
4641 E_Devicemgr_Input_Device *device;
4643 struct wl_client *wc;
4645 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4646 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4647 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4649 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4650 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4652 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4654 wc = wl_resource_get_client(surface);
4655 if (!time) time = e_util_timestamp_get();
4656 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4660 _e_comp_wl_send_event_device(wc, time, dev, serial);
4661 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4665 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4666 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4669 x = x + ec->client.x;
4670 y = y + ec->client.y;
4672 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4678 e_comp_wl_touch_cancel_send(E_Client *ec)
4680 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4681 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4682 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4684 _e_comp_wl_send_touch_cancel(ec);
4690 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4693 struct wl_client *wc;
4695 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4696 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4697 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4699 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4700 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4702 wc = wl_resource_get_client(surface);
4703 if (!time) time = e_util_timestamp_get();
4704 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4706 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4707 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4710 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4711 WL_POINTER_BUTTON_STATE_PRESSED);
4713 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4714 WL_POINTER_BUTTON_STATE_RELEASED);
4720 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4723 struct wl_client *wc;
4725 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4726 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4727 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4729 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4730 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4732 wc = wl_resource_get_client(surface);
4733 if (!time) time = e_util_timestamp_get();
4734 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4736 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4737 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4739 x = x + ec->client.x;
4740 y = y + ec->client.y;
4742 _e_comp_wl_send_mouse_move(ec, x, y, time);
4748 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4751 struct wl_client *wc;
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 wc = wl_resource_get_client(surface);
4761 if (!time) time = e_util_timestamp_get();
4762 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4764 if (_e_comp_wl_check_cursor_timer_needed(ec))
4766 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4770 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4771 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4773 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4775 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4777 if (_e_comp_wl_check_cursor_timer_needed(ec))
4778 _e_comp_wl_cursor_move_timer_control(ec);
4785 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4788 struct wl_client *wc;
4789 struct wl_resource *res;
4792 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4793 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4795 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4796 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4799 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4801 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4802 wc = wl_resource_get_client(surface);
4803 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4804 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4806 if (!e_comp_wl_input_pointer_check(res)) continue;
4807 if (wl_resource_get_client(res) != wc) continue;
4809 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4810 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4812 wl_pointer_send_enter(res, serial, surface,
4813 wl_fixed_from_int(x),
4814 wl_fixed_from_int(y));
4815 ec->pointer_enter_sent = EINA_TRUE;
4817 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4823 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4826 struct wl_client *wc;
4827 struct wl_resource *res;
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4831 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4832 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4833 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4834 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4835 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4837 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4838 wc = wl_resource_get_client(surface);
4839 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4840 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4842 if (!e_comp_wl_input_pointer_check(res)) continue;
4843 if (wl_resource_get_client(res) != wc) continue;
4845 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4846 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4848 wl_pointer_send_leave(res, serial, surface);
4849 ec->pointer_enter_sent = EINA_FALSE;
4851 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
4857 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)
4859 Evas_Event_Mouse_In ev_in;
4862 if (ec->pointer_enter_sent) return;
4864 ev_in.buttons = buttons;
4872 ev_in.modifiers = modifiers;
4873 ev_in.locks = locks;
4874 ev_in.timestamp = timestamp;
4875 ev_in.event_flags = event_flags;
4878 ev_in.event_src = event_src;
4880 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
4884 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)
4886 Evas_Event_Mouse_Out ev_out;
4889 if (!ec->pointer_enter_sent) return;
4891 ev_out.buttons = buttons;
4893 ev_out.output.x = x;
4894 ev_out.output.y = y;
4895 ev_out.canvas.x = x;
4896 ev_out.canvas.y = y;
4899 ev_out.modifiers = modifiers;
4900 ev_out.locks = locks;
4901 ev_out.timestamp = timestamp;
4902 ev_out.event_flags = event_flags;
4905 ev_out.event_src = event_src;
4907 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
4911 e_comp_wl_cursor_hide(E_Client *ec)
4913 struct wl_resource *res;
4914 struct wl_client *wc;
4918 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
4920 if (e_comp_wl->ptr.hide_tmr)
4922 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4923 e_comp_wl->ptr.hide_tmr = NULL;
4925 cursor_timer_ec = NULL;
4927 if (!ec) return EINA_FALSE;
4928 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4929 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4930 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4932 wc = wl_resource_get_client(surface);
4933 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4934 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4936 if (!e_comp_wl_input_pointer_check(res)) continue;
4937 if (wl_resource_get_client(res) != wc) continue;
4938 if (ec->pointer_enter_sent == EINA_FALSE) continue;
4939 wl_pointer_send_leave(res, serial, surface);
4940 ec->pointer_enter_sent = EINA_FALSE;
4946 /* surface to buffer
4947 * - width : surface width
4948 * - height : surface height
4949 * - transform: buffer transform
4950 * - scale : buffer scale
4952 * - width : screen width
4953 * - height : screen height
4954 * - transform: output transform
4955 * - scale : output scale
4957 static E_Util_Transform_Matrix
4958 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
4960 E_Util_Transform_Matrix m;
4962 e_util_transform_matrix_load_identity(&m);
4964 if (transform & 0x4)
4966 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
4967 e_util_transform_matrix_flip_x(&m);
4968 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
4971 switch (transform & 0x3)
4973 case WL_OUTPUT_TRANSFORM_90:
4974 e_util_transform_matrix_translate(&m, -width, 0, 0);
4975 e_util_transform_matrix_rotation_z(&m, 270);
4977 case WL_OUTPUT_TRANSFORM_180:
4978 e_util_transform_matrix_translate(&m, -width, -height, 0);
4979 e_util_transform_matrix_rotation_z(&m, 180);
4981 case WL_OUTPUT_TRANSFORM_270:
4982 e_util_transform_matrix_translate(&m, 0, -height, 0);
4983 e_util_transform_matrix_rotation_z(&m, 90);
4989 e_util_transform_matrix_scale(&m, scale, scale, 1);
4994 /* surface to buffer
4995 * - surface width, surface height, buffer transform, buffer scale
4997 * - screen width, screen height, output transform, output scale
5000 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5002 E_Util_Transform_Matrix m;
5003 E_Util_Transform_Vertex v;
5005 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5007 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5008 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5009 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5013 * - buffer width, buffer height, buffer transform, buffer scale
5016 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5018 E_Util_Transform_Matrix m;
5019 E_Util_Transform_Vertex v;
5022 if (transform != 0 || scale > 1)
5024 tw = ((transform % 2) ? height : width) / scale;
5025 th = ((transform % 2) ? width : height) / scale;
5033 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5034 m = e_util_transform_matrix_inverse_get(&m);
5036 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5037 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5038 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5041 /* surface to buffer
5042 * - surface width, surface height, buffer transform, buffer scale
5044 * - screen width, screen height, output transform, output scale
5047 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5048 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5050 E_Util_Transform_Matrix m;
5051 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5052 E_Util_Transform_Rect_Vertex sv;
5054 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5056 sv = e_util_transform_rect_to_vertices(&sr);
5057 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5058 sr = e_util_transform_vertices_to_rect(&sv);
5067 * - buffer width, buffer height, buffer transform, buffer scale
5070 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5071 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5073 E_Util_Transform_Matrix m;
5074 E_Util_Transform_Rect br = {bx, by, bw, bh};
5075 E_Util_Transform_Rect_Vertex bv;
5078 if (transform != 0 || scale > 1)
5080 tw = ((transform % 2) ? height : width) / scale;
5081 th = ((transform % 2) ? width : height) / scale;
5089 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5090 m = e_util_transform_matrix_inverse_get(&m);
5092 bv = e_util_transform_rect_to_vertices(&br);
5093 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5094 br = e_util_transform_vertices_to_rect(&bv);
5102 EINTERN E_Comp_Wl_Output*
5103 e_comp_wl_output_find(E_Client *ec)
5106 E_Comp_Wl_Output *output;
5108 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5110 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5112 if (output->transform % 2)
5114 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5115 ec->y < output->x || ec->y >= (output->x + output->w))
5120 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5121 ec->y < output->y || ec->y >= (output->y + output->h))
5131 EINTERN Eina_Array *
5132 e_comp_wl_output_find_all(E_Client *ec)
5134 E_Comp_Wl_Output *output;
5135 Eina_Array *outputs;
5138 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5140 outputs = eina_array_new(4);
5144 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5146 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5147 output->x, output->y, output->w, output->h))
5149 eina_array_push(outputs, output);
5153 if (eina_array_count(outputs) == 0)
5155 eina_array_free(outputs);
5162 // --------------------------------------------------------
5163 // tizen_move_resize
5164 // --------------------------------------------------------
5166 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5173 E_Client_Pending_Geometry *geo;
5176 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5177 if (ec->fullscreen || ec->maximized) goto err;
5179 geo = E_NEW(E_Client_Pending_Geometry, 1);
5182 geo->serial = serial;
5188 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5189 ec->surface_sync.wait_commit = EINA_TRUE;
5194 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5201 e_comp_wl_commit_sync_configure(E_Client *ec)
5204 E_Client_Pending_Geometry *geo;
5206 Eina_Bool match_size = EINA_FALSE;
5213 if (!ec || !ec->frame) goto ret;
5214 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5217 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5218 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5220 if (eina_list_count(ec->surface_sync.pending_geometry))
5222 Eina_List *ll = NULL;
5223 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5227 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5232 if ((geo->w == bw) && (geo->h == bh))
5234 match_size = EINA_TRUE;
5239 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5246 if ((config.w != ec->w) || (config.h != ec->h))
5248 e_client_size_set(ec, config.w, config.h);
5249 ec->changes.size = EINA_TRUE;
5253 // FIXME: The geometry of the client would be better to be calculated
5254 // at e_desk or at e_desk_area. So the position(x,y) of the client
5255 // should be calcuated at the e_desk or at the e_desk_area.
5257 desk = e_comp_desk_find_by_ec(ec);
5260 ec->client.x = desk->geom.x + config.x;
5261 ec->client.y = desk->geom.y + config.y;
5265 ec->client.x = config.x;
5266 ec->client.y = config.y;
5269 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5271 e_client_pos_set(ec, ec->client.x, ec->client.y);
5273 ec->changes.pos = 1;
5277 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5281 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5282 ec->surface_sync.wait_commit = EINA_FALSE;
5284 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5286 // rollback wait_commit if there are pending requests remained
5287 if (eina_list_count(ec->surface_sync.pending_geometry))
5288 ec->surface_sync.wait_commit = EINA_TRUE;
5293 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);
5300 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5301 struct wl_resource *res_moveresize)
5303 wl_resource_destroy(res_moveresize);
5307 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5308 struct wl_resource *res_moveresize,
5309 struct wl_resource *surface,
5316 /* to be implemented */
5319 int cur_w = 0, cur_h = 0;
5321 ec = e_client_from_surface_resource(surface);
5324 pending = e_client_pending_geometry_has(ec);
5325 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5326 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);
5330 if ((cur_w == w) && (cur_h == h))
5332 e_client_pos_set(ec, x, y);
5333 ec->changes.pos = 1;
5339 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5343 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5346 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5348 _tz_move_resize_iface_cb_destroy,
5349 _tz_move_resize_iface_cb_set_geometry,
5353 _tz_moveresize_cb_bind(struct wl_client *client,
5354 void *data EINA_UNUSED,
5358 struct wl_resource *res_moveresize;
5360 res_moveresize = wl_resource_create(client,
5361 &tizen_move_resize_interface,
5364 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5367 wl_resource_set_implementation(res_moveresize,
5368 &_tz_move_resize_iface,
5374 ERR("Could not create tizen_move_resize_interface res: %m");
5375 wl_client_post_no_memory(client);
5379 _e_comp_wl_move_resize_init(void)
5381 if (!e_comp_wl) return;
5382 if (!e_comp_wl->wl.disp) return;
5384 if (!wl_global_create(e_comp_wl->wl.disp,
5385 &tizen_move_resize_interface,
5388 _tz_moveresize_cb_bind))
5390 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5397 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5399 E_Comp_Wl_Output *output;
5400 pid_t output_pid = 0;
5401 Eina_List *l = NULL, *l2 = NULL;
5402 struct wl_resource *resource = NULL;
5404 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5406 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5407 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5408 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5410 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5412 /* if we have bound resources, send updates */
5413 EINA_LIST_FOREACH(output->resources, l2, resource)
5415 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5416 if (output_pid != pid) continue;
5418 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5420 // send output information to the client
5421 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5429 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5431 _e_comp_wl_surface_state_init(state, w, h);
5435 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5437 _e_comp_wl_surface_state_commit(ec, state);
5441 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5443 _e_comp_wl_hook_call(hookpoint, ec);
5447 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5449 _e_comp_wl_surface_state_finish(state);
5453 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5455 _e_comp_wl_surface_state_buffer_set(state, buffer);
5459 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5460 int sx, int sy, int *dx, int *dy)
5464 case WL_OUTPUT_TRANSFORM_NORMAL:
5468 case WL_OUTPUT_TRANSFORM_FLIPPED:
5469 *dx = width - sx, *dy = sy;
5471 case WL_OUTPUT_TRANSFORM_90:
5472 *dx = height - sy, *dy = sx;
5474 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5475 *dx = height - sy, *dy = width - sx;
5477 case WL_OUTPUT_TRANSFORM_180:
5478 *dx = width - sx, *dy = height - sy;
5480 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5481 *dx = sx, *dy = height - sy;
5483 case WL_OUTPUT_TRANSFORM_270:
5484 *dx = sy, *dy = width - sx;
5486 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5496 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5499 int tx1, ty1, tx2, ty2;
5500 int width_from_buffer, height_from_buffer;
5502 switch (vp->buffer.transform)
5504 case WL_OUTPUT_TRANSFORM_90:
5505 case WL_OUTPUT_TRANSFORM_270:
5506 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5507 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5508 width_from_buffer = bh / vp->buffer.scale;
5509 height_from_buffer = bw / vp->buffer.scale;
5512 width_from_buffer = bw / vp->buffer.scale;
5513 height_from_buffer = bh / vp->buffer.scale;
5517 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5521 x2 = width_from_buffer;
5522 y2 = height_from_buffer;
5526 x1 = wl_fixed_to_int(vp->buffer.src_x);
5527 y1 = wl_fixed_to_int(vp->buffer.src_y);
5528 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5529 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5532 buffer_transform(width_from_buffer, height_from_buffer,
5533 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5534 buffer_transform(width_from_buffer, height_from_buffer,
5535 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5537 out->x = (tx1 <= tx2) ? tx1 : tx2;
5538 out->y = (ty1 <= ty2) ? ty1 : ty2;
5539 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5540 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5544 * Convert given four coordinates to elements of rectangle
5545 * @in p[4] Coordinates to be converted
5546 * @out rect x, y, width, and height
5547 * transform Angle which represents TDM_TRANSFORM of rectangle
5548 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5549 * 1. The given coordinates are not represented by rectangle.
5550 * 2. All angles except for 0, 90, 180, 270.
5553 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5555 Eina_Bool ret = EINA_FALSE;
5557 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))
5560 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5563 *rotation = TDM_TRANSFORM_NORMAL;
5566 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5570 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5573 *rotation = TDM_TRANSFORM_180;
5576 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5581 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))
5584 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5587 *rotation = TDM_TRANSFORM_90;
5590 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5594 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5597 *rotation = TDM_TRANSFORM_270;
5600 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5610 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5615 for (i = 0; i < 4; i++)
5616 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5618 if (!_coords_to_rectangle_convert(p, out, rotation))
5620 DBG("Cannot convert given coords to rectangle.\n"
5621 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5622 p[0].x, p[0].y, p[1].x, p[1].y,
5623 p[2].x, p[2].y, p[3].x, p[3].y);
5631 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5633 int trans_rotation, flip;
5635 trans_rotation = transform & 0x3;
5636 flip = transform & 0x4;
5638 return (flip + (trans_rotation + rotation) % 4);
5642 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5650 if (e_comp_wl_subsurface_check(ec))
5651 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5658 out->w = ec->comp_data->width_from_viewport;
5659 out->w = (out->w + 1) & ~1;
5660 out->h = ec->comp_data->height_from_viewport;
5662 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5663 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5667 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5669 E_Comp_Wl_Buffer *buffer;
5670 E_Comp_Wl_Buffer_Viewport *vp;
5672 enum wl_output_transform buffer_transform;
5673 unsigned int rotation;
5674 Eina_Bool res = EINA_FALSE;
5676 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5678 if (e_object_is_del(E_OBJECT(ec)))
5681 vp = &ec->comp_data->scaler.buffer_viewport;
5683 if (buffer_viewport)
5685 buffer = ec->comp_data->buffer_ref.buffer;
5686 /* Getting a viewport of buffer needs geometry of buffer. */
5690 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5693 if ((output_viewport) || (transform))
5695 m = e_client_map_get(ec);
5697 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5699 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5704 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5705 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5706 * Since buffer.transform isn't applied using evas_map,
5707 * it has to be taken into account here to apply buffer.transform
5708 * and rotation of e_client_transform together. */
5710 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5712 *transform = (unsigned int)buffer_transform;
5720 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5722 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5723 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5725 /* Must be called with valid comp_data */
5726 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5728 if ((ec->comp_data->role_name == NULL) ||
5729 (ec->comp_data->role_name == role_name) ||
5730 (strcmp(ec->comp_data->role_name, role_name) == 0))
5732 ec->comp_data->role_name = role_name;
5738 wl_resource_post_error(error_resource, error_code,
5739 "Cannot assign role %s to wl_surface@%d,"
5740 " already has role %s\n",
5742 ec->comp_data->wl_surface ?
5743 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5744 ec->comp_data->role_name);
5750 EINTERN const char *
5751 e_comp_wl_surface_role_get(E_Client *ec)
5753 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5754 return ec->comp_data ? ec->comp_data->role_name : NULL;
5757 EINTERN struct wl_resource *
5758 e_comp_wl_client_surface_get(E_Client *ec)
5760 struct wl_resource *surface = NULL;
5761 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5762 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5764 g_mutex_lock(&ec->comp_data->surface_mutex);
5765 surface = ec->comp_data->surface;
5766 g_mutex_unlock(&ec->comp_data->surface_mutex);
5771 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5773 EINA_SAFETY_ON_NULL_RETURN(ec);
5774 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5776 g_mutex_lock(&ec->comp_data->surface_mutex);
5777 ec->comp_data->surface = surface;
5778 g_mutex_unlock(&ec->comp_data->surface_mutex);
5782 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5784 return e_compositor_util_client_from_surface_resource(surface_resource);
5788 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5790 if (!ec->comp_data->mapped)
5792 if (ec->comp_data->shell.surface &&
5793 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5795 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5801 if (ec->comp_data->mapped)
5803 /* will be unmapped. so run capture */
5804 e_comp_wl_remote_surface_image_save(ec);
5808 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5810 ec->comp_data->pending.sx = sx;
5811 ec->comp_data->pending.sy = sy;
5812 ec->comp_data->pending.new_attach = EINA_TRUE;
5814 e_client_fps_update(ec);
5818 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5820 if (ec->comp_data->pending.opaque)
5821 eina_tiler_clear(ec->comp_data->pending.opaque);
5825 eina_tiler_union(ec->comp_data->pending.opaque, region);
5827 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5831 ec->argb = EINA_FALSE;
5832 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5834 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5835 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5843 ec->argb = EINA_TRUE;
5844 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5846 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5847 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5853 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5855 if (ec->comp_data->pending.input)
5856 eina_tiler_clear(ec->comp_data->pending.input);
5860 if (eina_tiler_empty(region))
5862 ELOGF("COMP", " |unset input rect", NULL);
5863 e_comp_object_input_objs_del(ec->frame);
5864 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
5867 eina_tiler_union(ec->comp_data->pending.input, region);
5871 eina_tiler_rect_add(ec->comp_data->pending.input,
5872 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
5877 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
5879 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
5883 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
5885 E_Comp_Wl_Subsurf_Data *sdata;
5890 if (ec->comp_data->frames)
5892 ec->comp_data->frames =
5893 eina_list_remove(ec->comp_data->frames, callback_resource);
5896 if (ec->comp_data->pending.frames)
5898 ec->comp_data->pending.frames =
5899 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
5902 sdata = ec->comp_data->sub.data;
5903 if ((sdata) && (sdata->cached.frames))
5905 sdata->cached.frames =
5906 eina_list_remove(sdata->cached.frames, callback_resource);
5911 e_comp_wl_client_surface_pending_commit(E_Client *ec)
5913 if (e_object_is_del(E_OBJECT(ec))) return;
5915 if (e_comp_wl_remote_surface_commit(ec)) return;
5917 e_comp_wl_surface_commit(ec);
5919 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
5923 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
5925 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
5926 ec->comp_data->sub.data = sub;
5928 /* set subsurface client properties */
5929 ec->borderless = EINA_TRUE;
5930 ec->argb = EINA_TRUE;
5931 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
5932 ec->lock_border = EINA_TRUE;
5933 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
5934 ec->netwm.state.skip_taskbar = EINA_TRUE;
5935 ec->netwm.state.skip_pager = EINA_TRUE;
5936 ec->border_size = 0;
5937 ec->lock_user_location = 0;
5938 ec->lock_client_location = 0;
5939 ec->lock_user_size = 0;
5940 ec->lock_client_size = 0;
5941 ec->lock_client_stacking = 0;
5942 ec->lock_user_maximize = 0;
5943 ec->lock_client_maximize = 0;
5944 ec->changes.need_maximize = 0;
5945 ec->maximized = E_MAXIMIZE_NONE;
5948 ec->new_client = ec->netwm.ping = EINA_TRUE;
5949 e_comp->new_clients++;
5950 e_client_unignore(ec);
5952 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
5953 * It's not for subsurface. */
5954 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
5958 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
5960 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
5963 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
5965 sub->parent = parent;
5969 layer = e_client_layer_get(parent);
5970 if (layer > E_LAYER_BOTTOM)
5971 e_client_layer_set(ec, layer);
5974 if (parent->comp_data)
5976 /* append this client to the parents subsurface list */
5977 parent->comp_data->sub.list_pending =
5978 eina_list_append(parent->comp_data->sub.list_pending, ec);
5979 parent->comp_data->sub.list_changed = EINA_TRUE;
5984 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
5986 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
5987 E_Client *parent = sub->parent;
5989 parent->comp_data->sub.list =
5990 eina_list_remove(parent->comp_data->sub.list, ec);
5991 parent->comp_data->sub.list_pending =
5992 eina_list_remove(parent->comp_data->sub.list_pending, ec);
5993 parent->comp_data->sub.below_list =
5994 eina_list_remove(parent->comp_data->sub.below_list, ec);
5995 parent->comp_data->sub.below_list_pending =
5996 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6002 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)
6004 sub->resource = subsurface_resource;
6005 sub->cached_buffer_ref.buffer = NULL;
6006 sub->synchronized = EINA_TRUE;
6007 sub->parent = parent;
6008 sub->remote_surface.offscreen_parent = offscreen_parent;
6009 if (offscreen_parent)
6010 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6012 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6014 _e_comp_wl_client_subsurface_set(ec, sub);
6015 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6017 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6021 e_comp_wl_client_subsurface_finish(E_Client *ec)
6023 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6026 e_comp_wl_client_subsurface_parent_unset(ec);
6028 e_comp_wl_surface_state_finish(&sub->cached);
6029 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6031 ec->comp_data->sub.data = NULL;
6035 e_comp_wl_client_evas_init(E_Client *ec)
6037 EINA_SAFETY_ON_NULL_RETURN(ec);
6039 _e_comp_wl_client_evas_init(ec);
6043 e_comp_wl_client_evas_deinit(E_Client *ec)
6045 EINA_SAFETY_ON_NULL_RETURN(ec);
6047 _e_comp_wl_client_evas_deinit(ec);
6051 e_comp_wl_focus_check(void)
6053 _e_comp_wl_focus_check();
6057 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6064 if ((parent->comp_data) && (parent->comp_data->sub.data))
6065 parent = parent->comp_data->sub.data->parent;