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_backend_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 Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
80 static void _e_comp_wl_surface_state_serial_update(E_Client *ec, E_Comp_Wl_Surface_State *state);
83 typedef struct _E_Comp_Wl_Key_Data
89 struct _E_Comp_Wl_Evas_Gl
92 Evas_GL_Config *glcfg;
93 Evas_GL_Context *glctx;
94 Evas_GL_Surface *glsfc;
98 static Eina_List *handlers = NULL;
99 static E_Client *cursor_timer_ec = NULL;
100 static Eina_Bool need_send_released = EINA_FALSE;
101 static Eina_Bool need_send_motion = EINA_TRUE;
103 static GMutex connection_mutex;
105 static int _e_comp_wl_hooks_delete = 0;
106 static int _e_comp_wl_hooks_walking = 0;
108 static int _e_comp_wl_pid_hooks_delete = 0;
109 static int _e_comp_wl_pid_hooks_walking = 0;
111 static int _e_comp_wl_intercept_hooks_delete = 0;
112 static int _e_comp_wl_intercept_hooks_walking = 0;
114 static Eina_Inlist *_e_comp_wl_hooks[] =
116 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
117 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
118 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
119 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
120 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
121 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
122 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
123 [E_COMP_WL_HOOK_DEL] = NULL,
124 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
125 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
126 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
129 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
131 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
134 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
136 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
137 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
138 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
139 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
140 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
141 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
144 static Eina_List *hooks = NULL;
145 static Eina_Bool serial_trace_debug = 0;
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_thread_boost_lock(&connection_mutex);
326 e_comp_wl_connection_unlock()
328 e_input_thread_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_thread_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_thread_boost_unlock(&connection_mutex);
350 wc = wl_resource_get_client(surface);
354 e_input_thread_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);
744 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
750 if (!(ec = data)) return;
751 if (e_object_is_del(E_OBJECT(ec))) return;
753 /* Uncommonly some clients's final buffer can be skipped if the client
754 * requests unmap of its surface right after wl_surface@commit.
755 * So if this client evas object is hidden state and client is already
756 * unmmapped, we can consider to clear pixmap image here mandatorily.
758 if (!ec->comp_data->mapped)
759 e_pixmap_image_clear(ec->pixmap, 1);
761 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
762 evas_object_hide(tmp->frame);
764 topmost = e_comp_wl_topmost_parent_get(ec);
765 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
766 e_comp_wl_subsurface_hide(ec);
768 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
772 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
779 if (!(ec = data)) return;
780 if (e_object_is_del(E_OBJECT(ec))) return;
782 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
784 if (!e_comp_wl_subsurface_check(subc)) continue;
785 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
786 evas_object_move(subc->frame, x, y);
788 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
789 if (cdata->viewport_transform)
790 e_comp_wl_map_apply(subc);
793 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
795 if (!e_comp_wl_subsurface_check(subc)) continue;
796 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
797 evas_object_move(subc->frame, x, y);
799 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
800 if (cdata->viewport_transform)
801 e_comp_wl_map_apply(subc);
806 _e_comp_wl_send_touch_cancel(E_Client *ec)
809 struct wl_resource *res;
810 struct wl_client *wc;
813 if (e_object_is_del(E_OBJECT(ec))) return;
814 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
816 if (!surface) return;
817 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
819 wc = wl_resource_get_client(surface);
821 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
823 if (wl_resource_get_client(res) != wc) continue;
824 if (!e_comp_wl_input_touch_check(res)) continue;
826 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
828 wl_touch_send_cancel(res);
833 _e_comp_wl_touch_cancel(void)
837 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
839 if (!e_comp_wl->touch.pressed) return;
841 _e_comp_wl_send_touch_cancel(ec);
844 static E_Devicemgr_Input_Device *
845 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
847 E_Devicemgr_Input_Device *last_kbd = NULL;
850 case ECORE_DEVICE_CLASS_MOUSE:
851 return e_devicemgr->last_device_ptr;
852 case ECORE_DEVICE_CLASS_KEYBOARD:
853 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
855 case ECORE_DEVICE_CLASS_TOUCH:
856 return e_devicemgr->last_device_touch;
864 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
868 case ECORE_DEVICE_CLASS_MOUSE:
869 e_devicemgr->last_device_ptr = device;
871 case ECORE_DEVICE_CLASS_KEYBOARD:
872 atomic_store(&e_devicemgr->last_device_kbd, device);
874 case ECORE_DEVICE_CLASS_TOUCH:
875 e_devicemgr->last_device_touch = device;
882 static E_Devicemgr_Input_Device *
883 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
885 E_Devicemgr_Input_Device *last_kbd = NULL;
889 case ECORE_DEVICE_CLASS_MOUSE:
890 return ec->comp_data->last_device_ptr;
891 case ECORE_DEVICE_CLASS_KEYBOARD:
892 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
894 case ECORE_DEVICE_CLASS_TOUCH:
895 return ec->comp_data->last_device_touch;
903 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
907 case ECORE_DEVICE_CLASS_MOUSE:
908 ec->comp_data->last_device_ptr = device;
910 case ECORE_DEVICE_CLASS_KEYBOARD:
911 atomic_store(&ec->comp_data->last_device_kbd, device);
913 case ECORE_DEVICE_CLASS_TOUCH:
914 ec->comp_data->last_device_touch = device;
922 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
924 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
925 struct wl_resource *dev_res;
926 const char *dev_name;
927 Ecore_Device_Class dev_class;
928 struct wl_client *wc;
932 EINA_SAFETY_ON_NULL_RETURN(dev);
935 if (ec->cur_mouse_action || e_comp_wl->drag)
937 if (e_object_is_del(E_OBJECT(ec))) return;
938 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
939 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
940 if (!surface) return;
942 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
943 dev_name = evas_device_description_get(dev);
944 last_device = _e_comp_wl_device_last_device_get(dev_class);
945 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
947 serial = wl_display_next_serial(e_comp_wl->wl.disp);
948 wc = wl_resource_get_client(surface);
949 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
950 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
952 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
953 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
955 _e_comp_wl_device_last_device_set(dev_class, input_dev);
956 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
958 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
960 if (wl_resource_get_client(dev_res) != wc) continue;
961 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
965 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
969 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
971 E_Devicemgr_Input_Device *last_device;
972 struct wl_resource *dev_res;
973 struct wl_client *wc;
977 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
978 if (!surface) return;
980 last_device = _e_comp_wl_device_last_device_get(dev_class);
981 if (!last_device) return;
983 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
985 serial = wl_display_next_serial(e_comp_wl->wl.disp);
986 wc = wl_resource_get_client(surface);
987 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
989 if (wl_resource_get_client(dev_res) != wc) continue;
990 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
995 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
997 E_Devicemgr_Input_Device *input_dev;
998 struct wl_resource *dev_res;
999 const char *dev_name;
1002 EINA_SAFETY_ON_NULL_RETURN(dev);
1004 dev_name = ecore_device_identifier_get(dev);
1006 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1007 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1009 if (!eina_streq(input_dev->identifier, dev_name) ||
1010 (input_dev->clas != ecore_device_class_get(dev))) continue;
1011 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1013 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1015 if (wl_resource_get_client(dev_res) != wc) continue;
1016 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1019 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1023 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1025 E_Devicemgr_Input_Device *input_dev;
1026 struct wl_resource *dev_res;
1027 const char *dev_name;
1030 EINA_SAFETY_ON_NULL_RETURN(dev);
1032 dev_name = e_device_identifier_get(dev);
1034 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1035 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1037 if (!eina_streq(input_dev->identifier, dev_name) ||
1038 (input_dev->clas != e_device_class_get(dev))) continue;
1039 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1041 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1043 if (wl_resource_get_client(dev_res) != wc) continue;
1044 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1047 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1051 _e_comp_wl_cursor_reload(E_Client *ec)
1053 struct wl_resource *res;
1054 struct wl_client *wc;
1060 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1061 !evas_object_visible_get(e_comp->pointer->o_ptr))
1062 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1065 if (e_object_is_del(E_OBJECT(ec))) return;
1066 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1067 if (!surface) return;
1068 if (ec->pointer_enter_sent) return;
1070 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1071 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1073 if (e_client_transform_core_enable_get(ec))
1075 double dx = 0.0, dy = 0.0;
1076 map = e_client_map_get(ec);
1077 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1083 cx = px - ec->client.x;
1084 cy = py - ec->client.y;
1086 wc = wl_resource_get_client(surface);
1087 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1088 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1090 if (!e_comp_wl_input_pointer_check(res)) continue;
1091 if (wl_resource_get_client(res) != wc) continue;
1092 wl_pointer_send_enter(res, serial, surface,
1093 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1094 ec->pointer_enter_sent = EINA_TRUE;
1096 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1100 _e_comp_wl_cursor_timer(void *data)
1102 E_Client *ec = data;
1104 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1105 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1107 e_comp_wl_cursor_hide(ec);
1109 return ECORE_CALLBACK_CANCEL;
1113 _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)
1115 E_Devicemgr_Input_Device *input_dev;
1116 struct wl_resource *dev_res;
1117 struct wl_client *wc;
1122 if (ec->cur_mouse_action) return;
1123 if (e_object_is_del(E_OBJECT(ec))) return;
1124 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1125 if (!surface) return;
1127 f_value = wl_fixed_from_double(value);
1128 wc = wl_resource_get_client(surface);
1130 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1131 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1133 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1134 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1136 if (wl_resource_get_client(dev_res) != wc) continue;
1137 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1140 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1144 _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)
1146 if (idx >= e_input_touch_max_count_get()) return;
1148 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1149 e_devicemgr->multi[idx].radius_x = radius_x;
1150 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1151 e_devicemgr->multi[idx].radius_y = radius_y;
1152 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1153 e_devicemgr->multi[idx].pressure = pressure;
1154 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1155 e_devicemgr->multi[idx].angle = angle;
1159 _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)
1161 if (idx >= e_input_touch_max_count_get()) return;
1163 if (e_devicemgr->multi[idx].radius_x != radius_x)
1165 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1166 e_devicemgr->multi[idx].radius_x = radius_x;
1168 if (e_devicemgr->multi[idx].radius_y != radius_y)
1170 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1171 e_devicemgr->multi[idx].radius_y = radius_y;
1173 if (e_devicemgr->multi[idx].pressure != pressure)
1175 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1176 e_devicemgr->multi[idx].pressure = pressure;
1178 if (e_devicemgr->multi[idx].angle != angle)
1180 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1181 e_devicemgr->multi[idx].angle = angle;
1186 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1188 Eina_Bool ret = EINA_TRUE;
1191 case EVAS_CALLBACK_MOUSE_IN:
1192 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1195 if (e_comp_wl->ptr.hide_tmr)
1197 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1198 cursor_timer_ec = ec;
1199 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1203 if (e_pointer_is_hidden(e_comp->pointer))
1208 case EVAS_CALLBACK_MOUSE_OUT:
1209 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1212 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1216 case EVAS_CALLBACK_MOUSE_MOVE:
1217 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1220 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1221 _e_comp_wl_cursor_reload(ec);
1224 case EVAS_CALLBACK_MOUSE_WHEEL:
1225 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1228 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1229 _e_comp_wl_cursor_reload(ec);
1232 case EVAS_CALLBACK_MOUSE_DOWN:
1233 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1236 if (e_comp_wl->ptr.hide_tmr)
1238 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1239 e_comp_wl->ptr.hide_tmr = NULL;
1241 cursor_timer_ec = NULL;
1243 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1244 _e_comp_wl_cursor_reload(ec);
1247 case EVAS_CALLBACK_MOUSE_UP:
1248 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1259 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1261 if (ec->has_cursor_unset)
1264 if (!e_config->show_cursor)
1267 if (!e_config->use_cursor_timer)
1274 _e_comp_wl_check_block_input(E_Client *ec)
1276 E_Client *modal_child = e_client_modal_child_get(ec);
1279 if (modal_child->visible && !modal_child->iconic && (modal_child->visibility.obscured == E_VISIBILITY_UNOBSCURED))
1281 ELOGF("Touch", "Block touch by Modal child(ec:%p, win:0x%08zx)", ec, modal_child, e_client_util_win_get(modal_child));
1290 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1293 Evas_Event_Mouse_In *ev;
1294 struct wl_resource *res;
1295 struct wl_client *wc;
1298 E_Client *prev_ptr_ec;
1302 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1303 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1305 if (!(ec = data)) return;
1306 if (e_object_is_del(E_OBJECT(ec))) return;
1307 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1308 if (!surface) return;
1310 prev_ptr_ec = e_comp_wl->ptr.ec;
1313 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1314 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1317 e_comp_wl->ptr.ec = ec;
1319 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1320 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1321 e_client_util_name_get(ec));
1323 if (_e_comp_wl_check_cursor_timer_needed(ec))
1325 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1329 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1330 wc = wl_resource_get_client(surface);
1331 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1332 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1334 if (!e_comp_wl_input_pointer_check(res)) continue;
1335 if (wl_resource_get_client(res) != wc) continue;
1337 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1339 wl_pointer_send_enter(res, serial, surface,
1340 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1341 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1342 ec->pointer_enter_sent = EINA_TRUE;
1344 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1348 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1351 Evas_Event_Mouse_Out *ev;
1352 struct wl_resource *res;
1353 struct wl_client *wc;
1356 Eina_Bool inside_check;
1360 if (!(ec = data)) return;
1361 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1362 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1363 if (ec->cur_mouse_action && inside_check) return;
1364 if (e_object_is_del(E_OBJECT(e_comp))) return;
1365 if (e_comp_wl->ptr.ec == ec)
1366 e_comp_wl->ptr.ec = NULL;
1367 if (e_object_is_del(E_OBJECT(ec))) return;
1369 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1370 if (!surface) return;
1372 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1373 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1374 e_client_util_name_get(ec));
1376 if (_e_comp_wl_check_cursor_timer_needed(ec))
1378 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1382 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1384 wc = wl_resource_get_client(surface);
1385 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1386 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1388 if (!e_comp_wl_input_pointer_check(res)) continue;
1389 if (wl_resource_get_client(res) != wc) continue;
1390 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1392 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1394 wl_pointer_send_leave(res, serial, surface);
1395 ec->pointer_enter_sent = EINA_FALSE;
1397 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
1401 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1404 struct wl_client *wc;
1405 struct wl_resource *res;
1410 if (e_object_is_del(E_OBJECT(ec))) return;
1411 if (_e_comp_wl_check_block_input(ec)) return;
1413 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1414 if (!surface) return;
1416 wc = wl_resource_get_client(surface);
1417 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1421 x = wl_fixed_from_int(canvas_x - ec->client.x);
1422 y = wl_fixed_from_int(canvas_y - ec->client.y);
1425 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1427 if (wl_resource_get_client(res) != wc) continue;
1428 if (!e_comp_wl_input_touch_check(res)) continue;
1429 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1432 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));
1434 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1438 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));
1440 wl_touch_send_up(res, serial, timestamp, idx);
1447 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1450 struct wl_client *wc;
1451 struct wl_resource *res;
1455 if (ec->cur_mouse_action) return;
1456 if (e_object_is_del(E_OBJECT(ec))) return;
1457 if (_e_comp_wl_check_block_input(ec)) return;
1459 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1460 if (!surface) return;
1462 wc = wl_resource_get_client(surface);
1464 x = wl_fixed_from_int(canvas_x - ec->client.x);
1465 y = wl_fixed_from_int(canvas_y - ec->client.y);
1467 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1469 if (wl_resource_get_client(res) != wc) continue;
1470 if (!e_comp_wl_input_touch_check(res)) continue;
1471 wl_touch_send_motion(res, timestamp, idx, x, y);
1476 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1478 struct wl_resource *res;
1479 struct wl_client *wc;
1483 if (ec->cur_mouse_action) return;
1484 if (e_object_is_del(E_OBJECT(ec))) return;
1485 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1486 if (!surface) return;
1488 wc = wl_resource_get_client(surface);
1489 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1491 if (!e_comp_wl_input_pointer_check(res)) continue;
1492 if (wl_resource_get_client(res) != wc) continue;
1493 wl_pointer_send_motion(res, timestamp,
1494 wl_fixed_from_int(x - ec->client.x),
1495 wl_fixed_from_int(y - ec->client.y));
1500 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1502 if (e_comp_wl->ptr.hide_tmr)
1504 if (cursor_timer_ec == ec)
1506 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1507 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1511 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1512 cursor_timer_ec = ec;
1513 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1518 cursor_timer_ec = ec;
1519 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1524 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1527 Evas_Event_Mouse_Move *ev;
1528 Evas_Device *dev = NULL;
1529 const char *dev_name;
1530 E_Comp_Config *comp_conf;
1534 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.output.x);
1535 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.output.y);
1537 if (!(ec = data)) return;
1538 if (e_object_is_del(E_OBJECT(ec))) return;
1539 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1540 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1541 if (!surface) return;
1543 if ((!need_send_motion) && (!need_send_released) && (e_client_visibility_get(ec) == E_VISIBILITY_FULLY_OBSCURED)) return;
1546 dev_name = evas_device_description_get(dev);
1548 comp_conf = e_comp_config_get();
1549 if (comp_conf && comp_conf->input_log_enable)
1550 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1551 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1552 e_client_util_name_get(ec), dev_name);
1554 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1556 if (!e_comp_wl->drag_client)
1558 e_comp_wl->touch.faked_ec = ec;
1559 if (e_comp_wl->touch.pressed & (1 << 0))
1561 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1563 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1564 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1565 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1569 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1573 if (!e_comp_wl->drag_client)
1575 if (_e_comp_wl_check_cursor_timer_needed(ec))
1577 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1581 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1582 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1584 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1586 if (_e_comp_wl_check_cursor_timer_needed(ec))
1587 _e_comp_wl_cursor_move_timer_control(ec);
1591 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1596 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1598 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1599 if (e_object_is_del(E_OBJECT(ec))) return;
1600 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1601 if (!surface) return;
1602 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1604 e_comp_wl->ptr.button = BTN_LEFT;
1606 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1610 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1612 E_Client *ec = data;
1613 Evas_Event_Mouse_Down *ev = event;
1614 Evas_Device *dev = NULL;
1615 const Evas_Device *seat_dev;
1616 const char *dev_name, *seat_name;
1619 if (e_object_is_del(E_OBJECT(ec))) return;
1620 if (_e_comp_wl_check_block_input(ec)) return;
1623 dev_name = evas_device_description_get(dev);
1625 seat_dev = evas_device_parent_get(dev);
1626 seat_name = evas_device_name_get(seat_dev);
1628 ELOGF("Mouse", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1629 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1630 dev_name, seat_name);
1632 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1634 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1636 e_comp_wl->touch.faked_ec = ec;
1639 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1640 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1641 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1643 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1644 e_comp_wl->touch.pressed |= (1 << 0);
1648 if (_e_comp_wl_check_cursor_timer_needed(ec))
1650 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1654 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1655 WL_POINTER_BUTTON_STATE_PRESSED);
1657 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1660 need_send_released = EINA_TRUE;
1664 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1666 E_Client *ec = data;
1667 Evas_Event_Mouse_Up *ev = event;
1668 Evas_Device *dev = NULL;
1669 const Evas_Device *seat_dev;
1670 const char *dev_name, *seat_name;;
1671 Evas_Event_Flags flags;
1674 if (ec->cur_mouse_action) return;
1675 if (e_object_is_del(E_OBJECT(ec))) return;
1676 if (_e_comp_wl_check_block_input(ec)) return;
1678 if (!need_send_released)
1680 need_send_motion = EINA_TRUE;
1684 dev_name = evas_device_description_get(dev);
1686 seat_dev = evas_device_parent_get(dev);
1687 seat_name = evas_device_name_get(seat_dev);
1688 flags = evas_event_default_flags_get(evas);
1690 ELOGF("Mouse", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1691 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1692 dev_name, seat_name);
1694 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1696 e_comp_wl->touch.pressed &= ~(1 << 0);
1698 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1699 e_comp_wl->touch.faked_ec = NULL;
1702 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1704 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1706 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1709 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1710 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1711 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1715 if (_e_comp_wl_check_cursor_timer_needed(ec))
1717 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1721 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1722 WL_POINTER_BUTTON_STATE_RELEASED);
1724 if (_e_comp_wl_check_cursor_timer_needed(ec))
1725 _e_comp_wl_cursor_move_timer_control(ec);
1729 need_send_released = EINA_FALSE;
1733 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1735 struct wl_resource *res;
1736 struct wl_client *wc;
1741 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1743 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1746 dir = -wl_fixed_from_int(abs(z));
1748 dir = wl_fixed_from_int(z);
1751 if (e_object_is_del(E_OBJECT(ec))) return;
1752 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1753 if (!surface) return;
1755 wc = wl_resource_get_client(surface);
1756 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1758 if (!e_comp_wl_input_pointer_check(res)) continue;
1759 if (wl_resource_get_client(res) != wc) continue;
1760 wl_pointer_send_axis(res, timestamp, axis, dir);
1765 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1768 Evas_Event_Mouse_Wheel *ev;
1771 if (!(ec = data)) return;
1772 if (ec->cur_mouse_action) return;
1773 if (e_object_is_del(E_OBJECT(ec))) return;
1774 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1775 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1776 if (!surface) return;
1778 if (!eina_list_count(e_comp_wl->ptr.resources))
1781 if (_e_comp_wl_check_cursor_timer_needed(ec))
1783 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1787 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1789 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1791 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1793 if (_e_comp_wl_check_cursor_timer_needed(ec))
1794 _e_comp_wl_cursor_move_timer_control(ec);
1799 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1801 E_Client *ec = data;
1802 Evas_Event_Multi_Down *ev = event;
1803 Evas_Device *dev = NULL;
1804 const Evas_Device *seat_dev;
1805 const char *dev_name, *seat_name;
1806 Evas_Device_Class dev_class;
1809 if (e_object_is_del(E_OBJECT(ec))) return;
1810 if (_e_comp_wl_check_block_input(ec)) return;
1812 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1813 if (!surface) return;
1815 /* Do not deliver emulated single touch events to client */
1816 if (ev->device == 0) return;
1819 dev_name = evas_device_description_get(dev);
1820 e_comp_wl->touch.faked_ec = ec;
1822 seat_dev = evas_device_parent_get(dev);
1823 seat_name = evas_device_name_get(seat_dev);
1825 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1826 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1827 dev_name, seat_name);
1829 if (dev && dev_name)
1831 dev_class = evas_device_class_get(dev);
1832 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1833 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1836 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1837 e_comp_wl->touch.pressed |= (1 << ev->device);
1841 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1843 E_Client *ec = data;
1844 Evas_Event_Multi_Up *ev = event;
1845 Evas_Device *dev = NULL;
1846 const Evas_Device *seat_dev;
1847 const char *dev_name, *seat_name;
1848 Evas_Device_Class dev_class;
1849 Evas_Event_Flags flags;
1852 if (e_object_is_del(E_OBJECT(ec))) return;
1853 if (_e_comp_wl_check_block_input(ec)) return;
1855 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1856 if (!surface) return;
1858 /* Do not deliver emulated single touch events to client */
1859 if (ev->device == 0) return;
1861 flags = evas_event_default_flags_get(evas);
1863 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1864 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1865 e_comp_wl->touch.faked_ec = NULL;
1867 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1870 dev_name = evas_device_description_get(dev);
1872 seat_dev = evas_device_parent_get(dev);
1873 seat_name = evas_device_name_get(seat_dev);
1875 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1876 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1877 dev_name, seat_name);
1879 if (dev && dev_name)
1881 dev_class = evas_device_class_get(dev);
1882 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1883 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1886 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1890 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1892 E_Client *ec = data;
1893 Evas_Event_Multi_Move *ev = event;
1894 Evas_Device *dev = NULL;
1895 const char *dev_name;
1896 Evas_Device_Class dev_class;
1899 if (e_object_is_del(E_OBJECT(ec))) return;
1900 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1901 if (!surface) return;
1903 /* Do not deliver emulated single touch events to client */
1904 if (ev->device == 0) return;
1906 e_comp_wl->touch.faked_ec = ec;
1908 if (e_comp_wl->touch.pressed & (1 << ev->device))
1911 if (dev && (dev_name = evas_device_description_get(dev)))
1913 dev_class = evas_device_class_get(dev);
1914 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1915 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1918 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1923 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1926 char *file, buff[PATH_MAX];
1933 n = (getpriority(PRIO_PROCESS, pid) + adj);
1937 setpriority(PRIO_PROCESS, pid, n);
1940 use_adj = EINA_TRUE;
1942 if (!do_child) return;
1944 files = ecore_file_ls("/proc");
1945 EINA_LIST_FREE(files, file)
1947 if (!isdigit(file[0]))
1950 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1951 if ((f = fopen(buff, "r")))
1955 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1957 if (num_read == 2 && ppid == pid)
1958 _e_comp_wl_client_priority_adjust(pid2, set,
1960 adj_child, do_child);
1968 _e_comp_wl_client_priority_raise(E_Client *ec)
1970 if (!e_config->priority_control) return;
1971 if (ec->netwm.pid <= 0) return;
1972 if (ec->netwm.pid == getpid()) return;
1973 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1974 e_config->priority - 1, -1,
1975 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1979 _e_comp_wl_client_priority_normal(E_Client *ec)
1981 if (!e_config->priority_control) return;
1982 if (ec->netwm.pid <= 0) return;
1983 if (ec->netwm.pid == getpid()) return;
1984 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1985 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1989 _e_comp_wl_input_thread_send_keys()
1992 E_Comp_Wl_Key_Data *k;
1993 struct wl_resource *res;
1997 if (!e_comp_input_key->kbd.focused)
2002 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2003 t = ecore_time_unix_get();
2005 EINA_LIST_FOREACH(e_comp_input_key->kbd.focused, l, res)
2007 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2009 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2010 wl_keyboard_send_key(res, serial, t,
2011 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2017 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
2019 if (!ec) return EINA_FALSE;
2020 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2021 if (!ec->comp_data) return EINA_FALSE;
2023 ec->comp_data->on_focus_timer = NULL;
2025 _e_comp_wl_input_thread_send_keys(NULL);
2031 _e_comp_wl_input_thread_focus_in(void *data)
2033 struct wl_resource *surface = NULL;
2034 struct wl_resource *res;
2035 struct wl_client *wc;
2038 EINA_SAFETY_ON_NULL_RETURN(data);
2039 surface = *(struct wl_resource **)data;
2041 wc = wl_resource_get_client(surface);
2043 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
2045 if (wl_resource_get_client(res) == wc)
2047 if (!eina_list_data_find(e_comp_input_key->kbd.focused, res))
2048 e_comp_input_key->kbd.focused = eina_list_append(e_comp_input_key->kbd.focused, res);
2052 if (!e_comp_input_key->kbd.focused)
2057 e_comp_input_key->kbd.focus = surface;
2058 e_comp_wl_input_keyboard_enter_send(surface);
2059 e_comp_wl_data_device_keyboard_focus_set();
2062 /* It is called in the following cases:
2063 * When a normal ec->frame has focus.
2064 * Or launching image ec is replaced to the real ec.
2067 e_comp_wl_feed_focus_in(E_Client *ec)
2072 if (e_object_is_del(E_OBJECT(ec))) return;
2073 if (ec->iconic) return;
2075 /* block spurious focus events */
2076 focused = e_client_focused_get();
2077 if ((focused) && (ec != focused)) return;
2079 /* raise client priority */
2080 _e_comp_wl_client_priority_raise(ec);
2082 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2083 if (!surface) return;
2085 INF("send focus in request to input thread. surface(%p)\n", surface);
2086 _e_comp_wl_input_thread_focus_in(&surface);
2088 ec->comp_data->on_focus_timer =
2089 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2090 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2091 int rotation = ec->e.state.rot.ang.curr;
2092 e_pointer_rotation_set(e_comp->pointer, rotation);
2096 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2099 if (!(ec = data)) return;
2100 e_comp_wl_feed_focus_in(ec);
2104 _e_comp_wl_input_thread_focus_out(void *data)
2106 struct wl_resource *surface = NULL;
2107 struct wl_resource *res;
2109 E_Comp_Wl_Key_Data *k;
2113 EINA_SAFETY_ON_NULL_RETURN(data);
2115 surface = *(struct wl_resource **)data;
2117 /* update keyboard modifier state */
2118 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2119 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2121 if (!surface) return;
2123 if (!eina_list_count(e_comp_input_key->kbd.resources))
2128 /* send keyboard_leave to all keyboard resources */
2129 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2130 t = ecore_time_unix_get();
2132 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
2134 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2136 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2137 wl_keyboard_send_key(res, serial, t,
2138 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2140 wl_keyboard_send_leave(res, serial, surface);
2141 e_comp_input_key->kbd.focused =
2142 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
2147 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2150 if (!(ec = data)) return;
2152 if (!ec->comp_data) return;
2154 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2156 /* lower client priority */
2157 if (!e_object_is_del(data))
2158 _e_comp_wl_client_priority_normal(ec);
2160 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2161 INF("send focus out request to input thread. surface(%p)\n", surface);
2162 _e_comp_wl_input_thread_focus_out(&surface);
2166 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2168 Eina_Rectangle *damage_rect = NULL;
2169 Eina_Rectangle *dmg = NULL;
2170 Eina_List *l = NULL;
2172 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2173 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2176 if (!buffer->tbm_surface) return;
2180 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2184 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2185 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2188 eina_rectangle_union(damage_rect, dmg);
2193 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2194 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2197 tbm_surface_internal_set_damage(buffer->tbm_surface,
2203 eina_rectangle_free(damage_rect);
2207 _e_comp_wl_client_evas_init(E_Client *ec)
2209 if (!ec || !ec->comp_data) return;
2210 if (ec->comp_data->evas_init) return;
2212 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2213 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2214 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2217 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2218 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2219 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2220 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2221 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2222 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2224 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2225 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2226 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2228 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2229 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2231 ec->comp_data->evas_init = EINA_TRUE;
2235 _e_comp_wl_client_evas_deinit(E_Client *ec)
2237 if (!ec || !ec->comp_data) return;
2238 if (!ec->comp_data->evas_init) return;
2240 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2241 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2242 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2244 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2245 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2246 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2247 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2248 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2249 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2251 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2252 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2253 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2255 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2256 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2258 ec->comp_data->evas_init = EINA_FALSE;
2262 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2266 E_Comp_Screen *e_comp_screen;
2267 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2269 if (!e_comp) return ECORE_CALLBACK_RENEW;
2270 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2271 e_comp_screen = e_comp->e_comp_screen;
2273 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2275 if (!eout->config.enabled)
2277 e_comp_wl_output_remove(eout->id);
2281 switch (eout->config.rotation)
2284 transform = WL_OUTPUT_TRANSFORM_90;
2287 transform = WL_OUTPUT_TRANSFORM_180;
2290 transform = WL_OUTPUT_TRANSFORM_270;
2294 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2298 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2300 eout->config.geom.x, eout->config.geom.y,
2301 eout->config.geom.w, eout->config.geom.h,
2302 eout->info.size.w, eout->info.size.h,
2303 eout->config.mode.refresh, 0, transform))
2304 ERR("Could not initialize screen %s", eout->info.name);
2307 return ECORE_CALLBACK_RENEW;
2311 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2315 /* try to get the client from the object */
2316 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2317 return ECORE_CALLBACK_RENEW;
2319 /* check for client being deleted */
2320 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2322 /* check for wayland pixmap */
2323 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2324 return ECORE_CALLBACK_RENEW;
2326 /* if we have not setup evas callbacks for this client, do it */
2327 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2329 return ECORE_CALLBACK_RENEW;
2333 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2335 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2336 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2338 return ECORE_CALLBACK_RENEW;
2342 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2345 struct wl_resource *surface;
2346 struct wl_resource *res;
2347 struct wl_client *wc;
2349 E_Comp_Config *comp_conf;
2351 ec = e_comp_wl->ptr_constraints.ec;
2352 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2354 surface = e_comp_wl_client_surface_get(ec);
2355 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2357 wc = wl_resource_get_client(surface);
2359 comp_conf = e_comp_config_get();
2361 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2363 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2364 if (wl_resource_get_client(res) != wc) continue;
2366 if (comp_conf && comp_conf->input_log_enable)
2367 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2368 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2369 e_client_util_name_get(ec));
2371 zwp_relative_pointer_v1_send_relative_motion(res,
2373 (uint32_t)(ev->timestamp),
2374 wl_fixed_from_int(ev->dx),
2375 wl_fixed_from_int(ev->dy),
2376 wl_fixed_from_int(ev->dx_unaccel),
2377 wl_fixed_from_int(ev->dy_unaccel));
2380 return ECORE_CALLBACK_DONE;
2384 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2386 _e_comp_wl_touch_cancel();
2388 return ECORE_CALLBACK_PASS_ON;
2392 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2394 if (!ev) return ECORE_CALLBACK_PASS_ON;
2396 E_Zone *zone = ev->zone;
2398 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2399 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2401 if (!e_zone_is_displaying(zone))
2402 _e_comp_wl_touch_cancel();
2404 return ECORE_CALLBACK_PASS_ON;
2408 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2410 E_Client *ec = ev->ec;
2411 E_Comp_Wl_Buffer_Viewport *vp;
2413 if (!ec) return ECORE_CALLBACK_PASS_ON;
2414 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2415 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2416 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2417 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2419 vp = &ec->comp_data->scaler.buffer_viewport;
2420 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2422 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2424 return ECORE_CALLBACK_PASS_ON;
2428 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2430 E_Client *ec = ev->ec;
2431 E_Comp_Wl_Buffer_Viewport *vp;
2433 if (!ec) return ECORE_CALLBACK_PASS_ON;
2434 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2435 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2436 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2438 vp = &ec->comp_data->scaler.buffer_viewport;
2439 vp->wait_for_transform_change = 0;
2441 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2443 return ECORE_CALLBACK_PASS_ON;
2447 _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)
2449 E_Client *focused_ec;
2452 focused_ec = e_client_focused_get();
2453 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2455 rotation = focused_ec->e.state.rot.ang.curr;
2456 e_pointer_rotation_set(e_comp->pointer, rotation);
2458 return ECORE_CALLBACK_PASS_ON;
2462 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2465 Eina_Rectangle *window;
2470 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2472 if ((prev_w != state->bw) ||
2473 (prev_h != state->bh))
2475 ec->changes.buf_size = EINA_TRUE;
2478 if (e_comp_object_frame_exists(ec->frame)) return;
2479 window = &ec->comp_data->shell.window;
2480 if ((!ec->borderless) && /* FIXME temporarily added this check code
2481 * to prevent updating E_Client's size by frame */
2482 (window->x || window->y || window->w || window->h))
2484 e_comp_object_frame_geometry_set(ec->frame,
2486 (window->x + window->w) - state->bw,
2488 (window->y + window->h) - state->bh);
2491 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2495 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2497 E_Comp_Wl_Surface_State *state;
2500 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2501 state->buffer = NULL;
2505 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2507 state->new_attach = EINA_FALSE;
2508 state->buffer = NULL;
2509 state->buffer_destroy_listener.notify =
2510 _e_comp_wl_surface_state_cb_buffer_destroy;
2511 state->sx = state->sy = 0;
2513 state->input = eina_tiler_new(w, h);
2514 eina_tiler_tile_size_set(state->input, 1, 1);
2516 state->opaque = eina_tiler_new(w, h);
2517 eina_tiler_tile_size_set(state->opaque, 1, 1);
2519 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2520 state->buffer_viewport.buffer.scale = 1;
2521 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2522 state->buffer_viewport.surface.width = -1;
2523 state->buffer_viewport.changed = 0;
2525 e_presentation_time_container_init(&state->presentation_container);
2529 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2531 struct wl_resource *cb;
2532 Eina_Rectangle *dmg;
2534 EINA_LIST_FREE(state->frames, cb)
2535 wl_resource_destroy(cb);
2537 EINA_LIST_FREE(state->damages, dmg)
2538 eina_rectangle_free(dmg);
2540 EINA_LIST_FREE(state->buffer_damages, dmg)
2541 eina_rectangle_free(dmg);
2543 if (state->opaque) eina_tiler_free(state->opaque);
2544 state->opaque = NULL;
2546 if (state->input) eina_tiler_free(state->input);
2547 state->input = NULL;
2549 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2550 state->buffer = NULL;
2552 e_presentation_time_container_finish(&state->presentation_container);
2556 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2558 if (state->buffer == buffer) return;
2560 wl_list_remove(&state->buffer_destroy_listener.link);
2561 state->buffer = buffer;
2563 wl_signal_add(&state->buffer->destroy_signal,
2564 &state->buffer_destroy_listener);
2568 e_comp_wl_trace_serial_debug(Eina_Bool on)
2570 if (on == serial_trace_debug) return;
2571 serial_trace_debug = on;
2572 ELOGF("COMP", "serial trace_debug %s", NULL, (on ? "ON" : "OFF"));
2576 _e_comp_wl_surface_state_serial_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2578 E_Comp_Wl_Buffer *buffer;
2579 uint32_t serial = 0;
2582 if (e_object_is_del(E_OBJECT(ec))) return;
2583 if (!ec->comp_data) return;
2585 buffer = state->buffer;
2586 if (!buffer) return;
2588 serial = wayland_tbm_server_buffer_get_buffer_serial(buffer->resource);
2589 ec->surface_sync.serial = serial;
2591 if (serial_trace_debug)
2592 ELOGF("COMP", "Update serial(%u) wl_buffer(%u)", ec, serial, wl_resource_get_id(buffer->resource));
2596 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2598 Eina_Rectangle *dmg;
2599 Eina_Bool placed = EINA_TRUE;
2603 E_Comp_Wl_Buffer *buffer;
2604 struct wl_resource *cb;
2606 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2607 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2612 if ((ec->internal) ||
2613 (cdata->shell.surface && state->new_attach))
2617 e_comp->new_clients++;
2618 ELOGF("COMP", "Unignore", ec);
2619 e_client_unignore(ec);
2623 /* buffer transform */
2624 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2627 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2629 /* when buffer is transformed, we have to apply the new evas-map */
2630 state->buffer_viewport.changed = EINA_TRUE;
2632 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2634 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2636 if (transform_change == vp->wait_for_transform_change)
2637 vp->wait_for_transform_change = 0;
2639 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2640 // triggered by E_CLIENT_HOOK calls at those file.
2641 zone = e_comp_zone_find_by_ec(ec);
2644 eout = e_output_find(zone->output_id);
2645 if (eout && eout->hwc)
2647 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2649 if (e_comp_is_on_overlay(ec))
2650 e_comp_hwc_client_end(ec, __FUNCTION__);
2656 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2657 cdata->scaler.buffer_viewport = state->buffer_viewport;
2659 if (state->new_attach)
2661 _e_comp_wl_surface_state_serial_update(ec, state);
2662 e_comp_wl_surface_attach(ec, state->buffer);
2665 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2666 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2668 _e_comp_wl_surface_state_buffer_set(state, NULL);
2670 if ((state->new_attach) ||
2671 (state->buffer_viewport.changed))
2673 _e_comp_wl_surface_state_size_update(ec, state);
2674 e_comp_wl_map_size_cal_from_viewport(ec);
2676 /* update the position */
2677 if (ec->changes.pos)
2679 e_comp_object_frame_xy_unadjust(ec->frame,
2689 if (ec->new_client) placed = ec->placed;
2691 if (!ec->lock_client_size)
2696 ec->client.w = state->bw;
2697 ec->client.h = state->bh;
2699 e_comp_object_frame_wh_adjust(ec->frame,
2700 ec->client.w, ec->client.h,
2702 e_client_size_set(ec, nw, nh);
2704 if ((w != ec->w) || (h != ec->h))
2706 ec->changes.size = 1;
2711 if (ec->changes.buf_size)
2713 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2714 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2715 ec->changes.buf_size = EINA_FALSE;
2717 if (ec->move_after_resize)
2719 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2720 ec->move_after_resize = EINA_FALSE;
2721 ec->changes.pos = EINA_TRUE;
2727 /* map or unmap ec */
2728 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2729 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2730 if (!pixmap_usable || hide_by_request)
2735 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2746 if ((state->new_attach) ||
2747 (state->buffer_viewport.changed))
2749 if ((e_comp_wl->drag) &&
2750 (e_comp_wl->drag_client) &&
2751 (e_comp_wl->drag_client == ec))
2753 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2755 e_drag_move(e_comp_wl->drag,
2757 e_comp_wl->drag->y);
2759 e_drag_resize(e_comp_wl->drag,
2760 state->bw, state->bh);
2762 else if ((cdata->shell.surface) &&
2763 (cdata->shell.configure))
2765 e_comp_wl_commit_sync_configure(ec);
2767 else if (!e_client_video_hw_composition_check(ec))
2769 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
2774 ec->placed = placed;
2775 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
2779 if (cdata->scaler.buffer_viewport.changed)
2780 e_comp_wl_map_apply(ec);
2782 /* resize transform object */
2783 if (ec->transformed)
2784 e_client_transform_update(ec);
2788 state->new_attach = EINA_FALSE;
2790 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
2792 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
2793 wl_resource_destroy(cb);
2796 /* insert state frame callbacks into comp_data->frames
2797 * NB: This clears state->frames list */
2798 cdata->frames = eina_list_merge(cdata->frames,
2800 state->frames = NULL;
2802 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
2803 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
2804 &state->presentation_container);
2806 buffer = e_pixmap_resource_get(ec->pixmap);
2808 /* put state damages into surface */
2811 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
2812 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
2814 if ((cdata->buffer_ref.buffer) &&
2815 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
2816 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
2818 e_comp_object_damage(ec->frame,
2820 cdata->buffer_ref.buffer->w,
2821 cdata->buffer_ref.buffer->h);
2826 Eina_List *damages = NULL;
2829 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
2831 if (eina_list_count(state->buffer_damages))
2833 EINA_LIST_FREE(state->buffer_damages, dmg)
2836 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
2837 e_comp_wl_output_buffer_transform_get(ec),
2839 dmg->x, dmg->y, dmg->w, dmg->h,
2840 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
2841 damages = eina_list_append(damages, dmg);
2845 EINA_LIST_FREE(state->damages, dmg)
2846 damages = eina_list_append(damages, dmg);
2848 EINA_LIST_FREE(damages, dmg)
2850 /* not creating damage for ec that shows a underlay video */
2851 if (state->buffer_viewport.changed ||
2852 !e_comp->wl_comp_data->available_hw_accel.underlay ||
2853 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
2854 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
2856 eina_rectangle_free(dmg);
2861 /* put state opaque into surface */
2862 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
2865 Eina_Rectangle *rect;
2868 itr = eina_tiler_iterator_new(state->opaque);
2869 EINA_ITERATOR_FOREACH(itr, rect)
2873 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
2874 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
2875 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
2879 eina_iterator_free(itr);
2882 /* put state input into surface */
2883 if ((state->input) &&
2884 (!eina_tiler_empty(state->input)) &&
2887 Eina_Tiler *src, *tmp;
2891 tmp = eina_tiler_new(sw, sh);
2892 eina_tiler_tile_size_set(tmp, 1, 1);
2894 eina_tiler_rect_add(tmp,
2895 &(Eina_Rectangle){0, 0, sw, sh});
2897 if ((src = eina_tiler_intersection(state->input, tmp)))
2899 Eina_Rectangle *rect;
2902 e_comp_object_input_objs_del(ec->frame);
2903 itr = eina_tiler_iterator_new(src);
2904 EINA_ITERATOR_FOREACH(itr, rect)
2906 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
2907 ec, rect->x, rect->y, rect->w, rect->h,
2908 ec->w, ec->h, state->bw, state->bh);
2909 e_comp_object_input_area_set(ec->frame,
2914 eina_iterator_free(itr);
2915 eina_tiler_free(src);
2918 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
2920 eina_tiler_free(tmp);
2922 /* clear input tiler */
2923 eina_tiler_clear(state->input);
2926 e_comp_wl_subsurface_check_alpha_mask_rect(ec);
2928 if ((cdata->video_client) &&
2930 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
2931 (e_comp->wl_comp_data->available_hw_accel.underlay))
2933 e_pixmap_image_clear(ec->pixmap, 1);
2936 state->buffer_viewport.changed = 0;
2938 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
2941 ec->exp_iconify.buffer_flush &&
2942 e_policy_visibility_client_is_iconic(ec))
2944 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
2949 _e_comp_wl_surface_render_stop(E_Client *ec)
2951 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
2952 //if ((!ec->internal) && (!e_comp_gl_get()))
2955 /* check if internal animation is running */
2956 if (e_comp_object_is_animating(ec->frame)) return;
2957 /* check if external animation is running */
2958 if (evas_object_data_get(ec->frame, "effect_running")) return;
2960 evas_object_hide(ec->frame);
2964 e_comp_wl_client_surface_finish(E_Client *ec)
2966 struct wl_resource *res, *surface;
2967 struct wl_client *surface_client = NULL;
2970 surface = e_comp_wl_client_surface_get(ec);
2973 surface_client = wl_resource_get_client(surface);
2975 if (surface_client &&
2976 (ec == e_client_focused_get()))
2978 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
2980 if (wl_resource_get_client(res) ==
2982 e_comp_input_key->kbd.focused =
2983 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
2988 e_comp_wl_client_surface_set(ec, NULL);
2990 ec->comp_data->wl_surface = NULL;
2991 e_pixmap_win_id_del(ec->pixmap);
2993 _e_comp_wl_surface_render_stop(ec);
2994 e_object_del(E_OBJECT(ec));
2998 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3003 char proc[512], pname[512];
3006 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3008 h = fopen(proc, "r");
3011 len = fread(pname, sizeof(char), 512, h);
3013 pname[len - 1] = '\0';
3015 strncpy(pname, "NO NAME", sizeof(pname));
3021 strncpy(pname, "NO NAME", sizeof(pname));
3024 strncpy(name, pname, size);
3028 _e_comp_wl_pname_print(pid_t pid)
3031 char proc[512], pname[512];
3034 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3036 h = fopen(proc, "r");
3039 len = fread(pname, sizeof(char), 512, h);
3041 pname[len - 1] = '\0';
3043 strncpy(pname, "NO NAME", sizeof(pname));
3047 ELOGF("COMP", " |%s", NULL, pname);
3052 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3054 struct wl_client *client = data;
3055 E_Comp_Connected_Client_Info *cinfo;
3058 cinfo = wl_container_of(listener, cinfo, destroy);
3060 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3061 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3063 eai = e_appinfo_find_with_pid(cinfo->pid);
3064 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3067 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3069 wl_list_remove(&cinfo->destroy.link);
3070 eina_stringshare_del(cinfo->name);
3075 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3077 E_Comp_Connected_Client_Info *cinfo;
3079 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3080 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3082 cinfo->name = eina_stringshare_add(name);
3086 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3087 wl_client_add_destroy_listener(client, &cinfo->destroy);
3088 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3090 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3094 _e_input_thread_client_cb_focus_set(void *data)
3096 struct wl_resource *surface = NULL;
3098 EINA_SAFETY_ON_NULL_RETURN(data);
3099 surface = *(struct wl_resource **)data;
3101 INF("[input thread|%s] surface(%p)", __func__, surface);
3103 e_comp_input_key->kbd.focus = surface;
3107 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3109 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3111 /* send configure */
3112 if (ec->comp_data->shell.configure_send)
3114 if (ec->comp_data->shell.surface)
3115 _e_comp_wl_configure_send(ec, 0, 0);
3118 INF("[%s] surface(%p)", __func__, ec->comp_data->surface);
3119 e_input_backend_thread_safe_call(_e_input_thread_client_cb_focus_set, (void *)&ec->comp_data->surface, sizeof(struct wl_resource *));
3123 _e_input_thread_client_cb_focus_unset(void *data)
3125 struct wl_resource *surface = NULL;
3127 EINA_SAFETY_ON_NULL_RETURN(data);
3128 surface = *(struct wl_resource **)data;
3130 INF("[input thread|%s] surface(%p)", __func__, surface);
3132 if (e_comp_input_key->kbd.focus == surface)
3133 e_comp_input_key->kbd.focus = NULL;
3137 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3139 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3141 /* send configure */
3142 if (ec->comp_data->shell.configure_send)
3144 if (ec->comp_data->shell.surface)
3145 _e_comp_wl_configure_send(ec, 0, 0);
3148 _e_comp_wl_focus_check();
3150 INF("[%s] surface(%p)", __func__, ec->comp_data->surface);
3151 e_input_backend_thread_safe_call(_e_input_thread_client_cb_focus_unset, (void *)&ec->comp_data->surface, sizeof(struct wl_resource *));
3155 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3157 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3158 if (ec->keyboard_resizing) return;
3160 /* do nothing currently */
3165 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3167 if (e_object_is_del(E_OBJECT(ec))) return;
3168 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3170 e_comp_wl->resize.edges = 0;
3171 e_comp_wl->resize.resource = NULL;
3175 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3177 if (e_object_is_del(E_OBJECT(ec))) return;
3178 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3182 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3185 int ratio_w, ratio_h;
3187 phys_w = output->phys_width;
3188 phys_h = output->phys_height;
3190 if (e_config->configured_output_resolution.use)
3192 // change the configured physical size(mm) of the output
3193 if (output->w != res_w)
3195 ratio_w = res_w / output->w;
3196 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3199 if (output->h != res_h)
3201 ratio_h = res_h / output->h;
3202 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3205 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3208 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3209 NULL, res_w, res_h, phys_w, phys_h, pid);
3211 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3212 wl_output_send_scale(resource, output->scale);
3214 wl_output_send_geometry(resource, output->x, output->y,
3216 output->subpixel, output->make ?: "",
3217 output->model ?: "", output->transform);
3219 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3220 res_w, res_h, output->refresh);
3222 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3223 wl_output_send_done(resource);
3227 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3229 E_Comp_Wl_Output *output;
3231 if (!(output = wl_resource_get_user_data(resource))) return;
3233 output->resources = eina_list_remove(output->resources, resource);
3237 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3239 E_Comp_Wl_Output *output;
3240 struct wl_resource *resource;
3241 E_Appinfo *eai = NULL;
3245 if (!(output = data)) return;
3248 wl_resource_create(client, &wl_output_interface, version, id);
3251 wl_client_post_no_memory(client);
3255 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3256 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3258 output->resources = eina_list_append(output->resources, resource);
3260 wl_resource_set_implementation(resource, NULL, output,
3261 _e_comp_wl_cb_output_unbind);
3262 wl_resource_set_user_data(resource, output);
3264 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3265 if (e_config->configured_output_resolution.use)
3267 wl_client_get_credentials(client, &pid, NULL, NULL);
3270 res_w = e_config->configured_output_resolution.w;
3271 res_h = e_config->configured_output_resolution.h;
3275 eai = e_appinfo_find_with_pid(pid);
3278 res_w = e_config->configured_output_resolution.w;
3279 res_h = e_config->configured_output_resolution.h;
3283 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3285 res_w = e_config->configured_output_resolution.w;
3286 res_h = e_config->configured_output_resolution.h;
3290 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3299 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3303 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3306 Evas_GL *evasgl = NULL;
3307 Evas_GL_API *glapi = NULL;
3308 Evas_GL_Context *ctx = NULL;
3309 Evas_GL_Surface *sfc = NULL;
3310 Evas_GL_Config *cfg = NULL;
3312 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3314 if (!e_comp_gl_get()) return;
3316 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3317 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3319 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3320 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3322 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3323 * then we should get evas from ecore_evas.
3326 evas = e_comp->evas;
3328 evas = ecore_evas_get(e_comp->ee);
3330 evasgl = evas_gl_new(evas);
3331 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3333 glapi = evas_gl_api_get(evasgl);
3334 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3336 if (!glapi->evasglBindWaylandDisplay)
3338 evas_gl_free(evasgl);
3341 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3345 cfg = evas_gl_config_new();
3346 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3348 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3349 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3351 ctx = evas_gl_context_create(evasgl, NULL);
3352 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3354 res = evas_gl_make_current(evasgl, sfc, ctx);
3355 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3357 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3358 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3360 evas_gl_config_free(cfg);
3362 evas_gl->gl = evasgl;
3363 evas_gl->glapi = glapi;
3364 evas_gl->glsfc = sfc;
3365 evas_gl->glctx = ctx;
3367 e_comp_wl->evas_gl = evas_gl;
3369 /* for native surface */
3372 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3377 evas_gl_config_free(cfg);
3378 evas_gl_make_current(evasgl, NULL, NULL);
3379 evas_gl_context_destroy(evasgl, ctx);
3380 evas_gl_surface_destroy(evasgl, sfc);
3381 evas_gl_free(evasgl);
3388 _e_comp_wl_gl_popup_cb_close(void *data,
3389 Evas_Object *obj EINA_UNUSED,
3390 void *event_info EINA_UNUSED)
3392 evas_object_del(data);
3396 _e_comp_wl_gl_popup_cb_focus(void *data,
3397 Evas_Object *obj EINA_UNUSED,
3398 void *event_info EINA_UNUSED)
3400 elm_object_focus_set(data, EINA_TRUE);
3405 _e_comp_wl_gl_idle(void *data)
3407 return ECORE_CALLBACK_CANCEL;
3411 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3413 struct wl_client *client = data;
3419 wl_client_get_credentials(client, &pid, &uid, &gid);
3421 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3423 _e_comp_wl_pname_print(pid);
3424 _e_comp_wl_pname_get(pid, name, sizeof(name));
3425 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3429 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3431 char buf[1024] = {0, };
3433 vsnprintf(buf, 1024, fmt, args);
3437 DBG("[libds] %s", buf);
3440 INF("[libds] %s", buf);
3443 ERR("[libds] %s", buf);
3451 _e_comp_wl_display_create(void)
3454 E_Comp_Wl_Data *wl_cdata;
3459 /* create new compositor data */
3460 if (!(comp = E_NEW(E_Comp_Data, 1)))
3462 ERR("Could not create compositor data: %m");
3465 wl_cdata = &comp->base;
3467 /* set compositor wayland data */
3468 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3470 g_mutex_init(&connection_mutex);
3472 /* try to create a wayland display */
3473 if (!(wl_cdata->wl.disp = wl_display_create()))
3475 ERR("Could not create a Wayland display: %m");
3479 /* try to setup wayland socket */
3480 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3482 ERR("Could not create Wayland display socket: %m");
3483 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3487 res = e_comp_socket_init(name);
3488 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3489 PRCTL("[Winsys] change permission and create sym link for %s", name);
3491 /* set wayland display environment variable */
3492 e_env_set("WAYLAND_DISPLAY", name);
3494 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3495 /* wl_cdata->output.scale = e_scale; */
3497 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3499 if (!e_compositor_init(wl_cdata->wl.disp))
3501 ERR("Failed to initialize compositor");
3505 /* initialize shm mechanism */
3506 wl_display_init_shm(wl_cdata->wl.disp);
3508 /* get the wayland display loop */
3509 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3511 /* get the file descriptor of the wayland event loop */
3512 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3514 comp->client_created.notify = _e_comp_wl_cb_client_created;
3515 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3517 // TODO: this function has to move to compmgr module
3518 if (e_comp_gl_get())
3519 _e_comp_wl_gl_init(NULL);
3521 /* create a listener for wayland main loop events */
3523 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3524 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3525 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3526 _e_comp_wl_cb_prepare, wl_cdata);
3528 /* add awake handler */
3529 ecore_main_awake_handler_add(_e_comp_wl_cb_awake, NULL);
3534 e_env_unset("WAYLAND_DISPLAY");
3536 wl_display_destroy(wl_cdata->wl.disp);
3538 g_mutex_clear(&connection_mutex);
3544 _e_comp_wl_gl_shutdown(void)
3546 if (!e_comp_wl->evas_gl) return;
3548 if (e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay)
3549 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3551 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3552 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3553 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3554 evas_gl_free(e_comp_wl->evas_gl->gl);
3556 E_FREE(e_comp_wl->evas_gl);
3559 /* public functions */
3562 * Creates and initializes a Wayland compositor with ecore.
3563 * Registers callback handlers for keyboard and mouse activity
3564 * and other client events.
3566 * @returns true on success, false if initialization failed.
3569 e_comp_wl_init(void)
3571 TRACE_DS_BEGIN(COMP_WL:INIT);
3573 /* try to create a wayland compositor */
3574 if (!_e_comp_wl_display_create())
3576 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3581 //TODO: this is not to crate subsurface resource.
3582 // figure out where this function put.
3583 if (!e_comp_wl_subsurfaces_init())
3585 ERR("Failed to init_subsurfaces");
3586 e_comp_wl_subsurfaces_shutdown();
3591 // TODO: this does not belong to server mdoule
3592 e_comp_wl_capture_init();
3594 // TODO: make a file and call the init function at e_server_init func
3595 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3597 /* add event handlers to catch E events */
3598 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3599 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3600 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3601 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3602 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3603 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3604 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3605 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3606 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3608 /* add hooks to catch e_client events */
3609 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3610 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3611 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3612 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3613 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3621 e_comp_wl_deferred_job(void)
3623 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3626 /* internal functions */
3628 e_comp_wl_shutdown(void)
3630 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3632 e_comp_wl_subsurfaces_shutdown();
3634 E_FREE_LIST(handlers, ecore_event_handler_del);
3635 E_FREE_LIST(hooks, e_client_hook_del);
3636 _e_comp_wl_gl_shutdown();
3638 e_comp_wl_capture_shutdown();
3640 wl_list_remove(&comp->client_created.link);
3642 /* delete awake handler */
3643 ecore_main_awake_handler_del(_e_comp_wl_cb_awake);
3646 e_comp->wl_comp_data = NULL;
3650 E_Comp_Wl_Output *output;
3652 if (e_comp_wl->screenshooter.global)
3653 wl_global_destroy(e_comp_wl->screenshooter.global);
3655 EINA_LIST_FREE(e_comp_wl->outputs, output)
3657 if (output->id) eina_stringshare_del(output->id);
3658 if (output->make) eina_stringshare_del(output->make);
3659 if (output->model) eina_stringshare_del(output->model);
3663 /* delete fd handler */
3664 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3666 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3667 cursor_timer_ec = NULL;
3669 /* free allocated data structure */
3675 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3677 e_object_unref(E_OBJECT(ev->ec));
3682 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3685 ev = E_NEW(E_Event_Client, 1);
3688 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3690 /* set usable early because shell module checks this */
3691 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3692 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3694 e_pixmap_resource_set(ec->pixmap, buffer);
3695 e_pixmap_dirty(ec->pixmap);
3696 e_pixmap_refresh(ec->pixmap);
3698 e_comp_wl_map_size_cal_from_buffer(ec);
3699 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3701 /* wm-policy module uses it */
3702 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
3705 e_object_ref(E_OBJECT(ec));
3706 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
3707 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
3711 e_comp_wl_surface_commit(E_Client *ec)
3716 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
3717 if (!e_comp_object_damage_exists(ec->frame))
3719 if ((ec->comp_data->video_client) ||
3720 (!e_client_video_hw_composition_check(ec)))
3721 e_pixmap_image_clear(ec->pixmap, 1);
3724 ignored = ec->ignored;
3726 if (e_comp_wl_subsurface_order_commit(ec))
3728 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
3729 e_comp_wl_subsurface_restack(topmost);
3730 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
3733 ec->ignored = ignored;
3735 if (ec->is_cursor && ec->visible)
3737 /* ignore cursor changes during resize/move I guess */
3738 if (!e_client_action_get())
3740 if (e_comp->pointer)
3742 x = e_comp->pointer->hot.x;
3743 y = e_comp->pointer->hot.y;
3745 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
3751 static E_Comp_Wl_Output *
3752 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
3755 E_Comp_Wl_Output *output;
3757 EINA_LIST_FOREACH(outputs, l, output)
3759 if (!strcmp(output->id, id))
3767 * Initializes information about one display output.
3769 * Adds or updates the given data about a single display output,
3770 * with an id matching the provided id.
3772 * @param id identification of output to be added or changed
3773 * @param make manufacturer name of the display output
3774 * @param model model name of the display output
3775 * @param x output's top left corner x coordinate
3776 * @param y output's top left corner y coordinate
3777 * @param w output's width in pixels
3778 * @param h output's height in pixels
3779 * @param pw output's physical width in millimeters
3780 * @param ph output's physical height in millimeters
3781 * @param refresh output's refresh rate in mHz
3782 * @param subpixel output's subpixel layout
3783 * @param transform output's rotation and/or mirror transformation
3785 * @returns True if a display output object could be added or updated
3788 e_comp_wl_output_init(const char *id, const char *make, const char *model,
3789 int x, int y, int w, int h, int pw, int ph,
3790 unsigned int refresh, unsigned int subpixel,
3791 unsigned int transform)
3793 E_Comp_Wl_Output *output;
3795 struct wl_resource *resource;
3797 /* retrieve named output; or create it if it doesn't exist */
3798 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
3801 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
3803 if (id) output->id = eina_stringshare_add(id);
3805 output->make = eina_stringshare_add(make);
3807 output->make = eina_stringshare_add("unknown");
3809 output->model = eina_stringshare_add(model);
3811 output->model = eina_stringshare_add("unknown");
3813 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
3816 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
3817 2, output, _e_comp_wl_cb_output_bind);
3819 output->resources = NULL;
3820 output->scale = e_scale;
3823 /* update the output details */
3828 output->phys_width = pw;
3829 output->phys_height = ph;
3830 output->refresh = refresh;
3831 output->subpixel = subpixel;
3832 output->transform = transform;
3834 if (output->scale <= 0)
3835 output->scale = e_scale;
3837 /* if we have bound resources, send updates */
3838 EINA_LIST_FOREACH(output->resources, l2, resource)
3840 wl_output_send_geometry(resource,
3841 output->x, output->y,
3843 output->phys_height,
3845 output->make ?: "", output->model ?: "",
3848 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3849 wl_output_send_scale(resource, output->scale);
3851 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3852 output->w, output->h, output->refresh);
3854 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3855 wl_output_send_done(resource);
3862 e_comp_wl_output_remove(const char *id)
3864 E_Comp_Wl_Output *output;
3866 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
3869 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
3871 /* wl_global_destroy(output->global); */
3873 /* eina_stringshare_del(output->id); */
3874 /* eina_stringshare_del(output->make); */
3875 /* eina_stringshare_del(output->model); */
3882 _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)
3884 struct wl_resource *res;
3886 uint32_t serial, keycode;
3887 struct wl_client *wc = NULL;
3888 E_Comp_Config *comp_conf = NULL;
3889 const char *device_name = NULL;
3891 keycode = (ev->keycode - 8);
3893 serial = wl_display_next_serial(e_comp_wl->wl.disp);
3895 comp_conf = e_comp_config_get();
3897 if (ec && ec->comp_data)
3899 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
3902 wc = wl_resource_get_client(surface);
3905 if (e_config->key_input_ttrace_enable)
3907 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
3908 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
3911 EINA_LIST_FOREACH(key_list, l, res)
3913 if (wl_resource_get_client(res) != wc) continue;
3915 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
3916 if (!e_input_thread_mode_get())
3918 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
3919 device_name = ecore_device_name_get(ev->dev);
3925 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
3926 device_name = e_device_name_get(dev);
3930 if (comp_conf && comp_conf->input_log_enable)
3931 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
3933 wl_keyboard_send_key(res, serial, ev->timestamp,
3938 if (e_config->key_input_ttrace_enable)
3941 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
3946 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
3948 E_Client *ec = NULL;
3950 E_Comp_Wl_Key_Data *end, *k;
3952 if (ev->window != e_comp->ee_win)
3957 keycode = (ev->keycode - 8);
3958 if (!(e_comp_wl = e_comp->wl_comp_data))
3963 #ifndef E_RELEASE_BUILD
3964 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
3965 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
3966 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
3967 eina_streq(ev->key, "BackSpace"))
3973 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
3975 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
3977 /* ignore server-generated key repeats */
3978 if (k->key == keycode)
3984 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
3986 ec = e_client_focused_get();
3987 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
3988 if (ec && ec->comp_data && surface)
3990 if (e_comp_input_key->kbd.focused)
3992 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_input_key->kbd.focused, ec);
3994 /* A key only sent to clients is added to the list */
3995 e_comp_input_key->kbd.keys.size = (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
3997 if (!(k = wl_array_add(&e_comp_input_key->kbd.keys, sizeof(*k))))
3999 DBG("wl_array_add: Out of memory\n");
4008 /* update modifier state */
4009 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4015 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4017 E_Client *ec = NULL;
4018 uint32_t keycode, delivered_key;
4019 E_Comp_Wl_Key_Data *end, *k;
4021 if (ev->window != e_comp->ee_win)
4026 keycode = (ev->keycode - 8);
4028 if (!(e_comp_wl = e_comp->wl_comp_data))
4033 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4034 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4036 if (k->key == keycode)
4043 e_comp_input_key->kbd.keys.size =
4044 (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4046 /* 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) */
4047 if ((delivered_key) ||
4048 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4050 ec = e_client_focused_get();
4052 if (e_comp_input_key->kbd.focused)
4054 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_input_key->kbd.focused, ec);
4058 /* update modifier state */
4059 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4065 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4067 Eina_Bool res = EINA_FALSE;
4069 if (type == ECORE_EVENT_KEY_DOWN)
4071 res = e_comp_wl_key_down(ev, dev);
4073 else if (type == ECORE_EVENT_KEY_UP)
4075 res = e_comp_wl_key_up(ev, dev);
4082 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4085 struct wl_client *wc;
4086 uint32_t serial, btn;
4087 struct wl_resource *res;
4089 if (ec->cur_mouse_action) return EINA_FALSE;
4090 if (e_comp_wl->drag)
4092 ELOGF("Mouse", "Button %s ignored. dragging. (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), button_id, timestamp);
4095 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4096 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4100 case 1: btn = BTN_LEFT; break;
4101 case 2: btn = BTN_MIDDLE; break;
4102 case 3: btn = BTN_RIGHT; break;
4103 default: btn = button_id; break;
4106 e_comp_wl->ptr.button = btn;
4107 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4108 if (!surface) return EINA_FALSE;
4110 if (!eina_list_count(e_comp_wl->ptr.resources))
4113 wc = wl_resource_get_client(surface);
4114 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4116 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4118 if (wl_resource_get_client(res) != wc) continue;
4119 if (!e_comp_wl_input_pointer_check(res)) continue;
4120 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4122 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4124 wl_pointer_send_button(res, serial, timestamp, btn, state);
4131 e_comp_wl_touch_cancel(void)
4133 _e_comp_wl_touch_cancel();
4136 E_API E_Comp_Wl_Hook *
4137 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4141 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4142 ch = E_NEW(E_Comp_Wl_Hook, 1);
4143 if (!ch) return NULL;
4144 ch->hookpoint = hookpoint;
4146 ch->data = (void*)data;
4147 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4152 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4155 if (_e_comp_wl_hooks_walking == 0)
4157 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4161 _e_comp_wl_hooks_delete++;
4164 E_API E_Comp_Wl_Pid_Hook *
4165 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4167 E_Comp_Wl_Pid_Hook *ch;
4169 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4171 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4172 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4174 ch->hookpoint = hookpoint;
4176 ch->data = (void*)data;
4177 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4183 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4186 if (_e_comp_wl_pid_hooks_walking == 0)
4188 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4192 _e_comp_wl_pid_hooks_delete++;
4195 E_API E_Comp_Wl_Intercept_Hook *
4196 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4198 E_Comp_Wl_Intercept_Hook *ch;
4200 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4201 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4202 if (!ch) return NULL;
4203 ch->hookpoint = hookpoint;
4205 ch->data = (void*)data;
4206 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4211 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4214 if (_e_comp_wl_intercept_hooks_walking == 0)
4216 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4220 _e_comp_wl_intercept_hooks_delete++;
4224 e_comp_wl_shell_surface_ready(E_Client *ec)
4228 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4232 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4234 e_config->use_cursor_timer = !!enabled;
4236 if (e_config->use_cursor_timer)
4238 if (!e_pointer_is_hidden(e_comp->pointer))
4240 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4245 if (e_comp_wl->ptr.hide_tmr)
4247 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4248 e_comp_wl->ptr.hide_tmr = NULL;
4250 cursor_timer_ec = NULL;
4252 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4255 if (e_pointer_is_hidden(e_comp->pointer))
4257 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4263 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4265 EINA_SAFETY_ON_NULL_RETURN(wc);
4266 EINA_SAFETY_ON_NULL_RETURN(dev);
4268 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4272 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4274 EINA_SAFETY_ON_NULL_RETURN(wc);
4275 EINA_SAFETY_ON_NULL_RETURN(dev);
4277 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4281 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4283 struct wl_resource *res;
4284 struct wl_client *wc;
4286 uint32_t serial, wl_keycode;
4287 enum wl_keyboard_key_state state;
4288 E_Comp_Config *comp_conf = NULL;
4289 const char *dev_name = NULL;
4291 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4292 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4293 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4295 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4296 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4298 wl_keycode = keycode - 8;
4299 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4301 wc = wl_resource_get_client(surface);
4302 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4303 if (!time) time = e_util_timestamp_get();
4304 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4305 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4307 comp_conf = e_comp_config_get();
4308 e_keyrouter_event_surface_send(ec, keycode);
4310 if (e_config->key_input_ttrace_enable)
4312 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4313 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4316 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4318 if (wl_resource_get_client(res) != wc) continue;
4319 if (!e_input_thread_mode_get())
4323 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4324 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4328 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4335 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4336 dev_name = e_device_name_get(dev);
4340 if (comp_conf && comp_conf->input_log_enable)
4341 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4344 wl_keyboard_send_key(res, serial, time,
4348 if (e_config->key_input_ttrace_enable)
4351 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4358 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4360 struct wl_resource *res;
4361 struct wl_client *wc;
4363 uint32_t serial, wl_keycode, cancel_keycode;
4364 E_Comp_Config *comp_conf = NULL;
4365 struct xkb_keymap *keymap = NULL;
4367 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4368 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4369 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4371 keymap = e_comp_input_key->xkb.keymap;
4372 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4374 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4375 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4377 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4378 if (cancel_keycode == XKB_KEYCODE_INVALID)
4380 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4384 EINA_SAFETY_ON_TRUE_RETURN_VAL(cancel_keycode < 8, EINA_FALSE);
4386 cancel_keycode = cancel_keycode - 8;
4388 wl_keycode = keycode - 8;
4389 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4391 wc = wl_resource_get_client(surface);
4392 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4393 if (!time) time = e_util_timestamp_get();
4395 comp_conf = e_comp_config_get();
4396 e_keyrouter_event_surface_send(ec, keycode);
4398 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4400 if (wl_resource_get_client(res) != wc) continue;
4401 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4402 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4404 if (comp_conf && comp_conf->input_log_enable)
4405 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4406 wl_keyboard_send_key(res, serial, time,
4407 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4408 wl_keyboard_send_key(res, serial, time,
4409 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4410 wl_keyboard_send_key(res, serial, time,
4411 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4419 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)
4421 struct wl_client *wc;
4423 E_Devicemgr_Input_Device *device = NULL;
4425 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4426 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4427 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4429 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4430 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4432 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4434 wc = wl_resource_get_client(surface);
4435 if (!time) time = e_util_timestamp_get();
4436 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4440 _e_comp_wl_send_event_device(wc, time, dev, serial);
4441 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4445 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4446 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4449 x = x + ec->client.x;
4450 y = y + ec->client.y;
4452 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4458 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)
4460 E_Devicemgr_Input_Device *device;
4462 struct wl_client *wc;
4464 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4465 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4466 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4468 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4469 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4471 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4473 wc = wl_resource_get_client(surface);
4474 if (!time) time = e_util_timestamp_get();
4475 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4479 _e_comp_wl_send_event_device(wc, time, dev, serial);
4480 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4484 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4485 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4488 x = x + ec->client.x;
4489 y = y + ec->client.y;
4491 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4497 e_comp_wl_touch_cancel_send(E_Client *ec)
4499 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4500 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4501 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4503 _e_comp_wl_send_touch_cancel(ec);
4509 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4512 struct wl_client *wc;
4514 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4515 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4516 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4518 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4519 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4521 wc = wl_resource_get_client(surface);
4522 if (!time) time = e_util_timestamp_get();
4523 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4525 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4526 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4529 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4530 WL_POINTER_BUTTON_STATE_PRESSED);
4532 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4533 WL_POINTER_BUTTON_STATE_RELEASED);
4539 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4542 struct wl_client *wc;
4544 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4545 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4546 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4548 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4549 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4551 wc = wl_resource_get_client(surface);
4552 if (!time) time = e_util_timestamp_get();
4553 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4555 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4556 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4558 x = x + ec->client.x;
4559 y = y + ec->client.y;
4561 _e_comp_wl_send_mouse_move(ec, x, y, time);
4567 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4570 struct wl_client *wc;
4572 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4573 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4574 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4576 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4577 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4579 wc = wl_resource_get_client(surface);
4580 if (!time) time = e_util_timestamp_get();
4581 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4583 if (_e_comp_wl_check_cursor_timer_needed(ec))
4585 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4589 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4590 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4592 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4594 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4596 if (_e_comp_wl_check_cursor_timer_needed(ec))
4597 _e_comp_wl_cursor_move_timer_control(ec);
4604 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4607 struct wl_client *wc;
4608 struct wl_resource *res;
4611 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4612 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4614 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4615 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4617 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4618 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4620 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4621 wc = wl_resource_get_client(surface);
4622 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4623 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4625 if (!e_comp_wl_input_pointer_check(res)) continue;
4626 if (wl_resource_get_client(res) != wc) continue;
4628 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4629 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4631 wl_pointer_send_enter(res, serial, surface,
4632 wl_fixed_from_int(x),
4633 wl_fixed_from_int(y));
4634 ec->pointer_enter_sent = EINA_TRUE;
4636 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4642 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4645 struct wl_client *wc;
4646 struct wl_resource *res;
4649 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4650 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4651 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4652 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4653 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4654 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4656 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4657 wc = wl_resource_get_client(surface);
4658 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4659 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4661 if (!e_comp_wl_input_pointer_check(res)) continue;
4662 if (wl_resource_get_client(res) != wc) continue;
4664 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4665 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4667 wl_pointer_send_leave(res, serial, surface);
4668 ec->pointer_enter_sent = EINA_FALSE;
4670 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
4676 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)
4678 Evas_Event_Mouse_In ev_in;
4681 if (ec->pointer_enter_sent) return;
4683 ev_in.buttons = buttons;
4691 ev_in.modifiers = modifiers;
4692 ev_in.locks = locks;
4693 ev_in.timestamp = timestamp;
4694 ev_in.event_flags = event_flags;
4697 ev_in.event_src = event_src;
4699 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
4703 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)
4705 Evas_Event_Mouse_Out ev_out;
4708 if (!ec->pointer_enter_sent) return;
4710 ev_out.buttons = buttons;
4712 ev_out.output.x = x;
4713 ev_out.output.y = y;
4714 ev_out.canvas.x = x;
4715 ev_out.canvas.y = y;
4718 ev_out.modifiers = modifiers;
4719 ev_out.locks = locks;
4720 ev_out.timestamp = timestamp;
4721 ev_out.event_flags = event_flags;
4724 ev_out.event_src = event_src;
4726 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
4730 e_comp_wl_cursor_hide(E_Client *ec)
4732 struct wl_resource *res;
4733 struct wl_client *wc;
4737 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
4739 if (e_comp_wl->ptr.hide_tmr)
4741 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4742 e_comp_wl->ptr.hide_tmr = NULL;
4744 cursor_timer_ec = NULL;
4746 if (!ec) return EINA_FALSE;
4747 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4748 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4749 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4751 wc = wl_resource_get_client(surface);
4752 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4753 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4755 if (!e_comp_wl_input_pointer_check(res)) continue;
4756 if (wl_resource_get_client(res) != wc) continue;
4757 if (ec->pointer_enter_sent == EINA_FALSE) continue;
4758 wl_pointer_send_leave(res, serial, surface);
4759 ec->pointer_enter_sent = EINA_FALSE;
4765 /* surface to buffer
4766 * - width : surface width
4767 * - height : surface height
4768 * - transform: buffer transform
4769 * - scale : buffer scale
4771 * - width : screen width
4772 * - height : screen height
4773 * - transform: output transform
4774 * - scale : output scale
4776 static E_Util_Transform_Matrix
4777 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
4779 E_Util_Transform_Matrix m;
4781 e_util_transform_matrix_load_identity(&m);
4783 if (transform & 0x4)
4785 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
4786 e_util_transform_matrix_flip_x(&m);
4787 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
4790 switch (transform & 0x3)
4792 case WL_OUTPUT_TRANSFORM_90:
4793 e_util_transform_matrix_translate(&m, -width, 0, 0);
4794 e_util_transform_matrix_rotation_z(&m, 270);
4796 case WL_OUTPUT_TRANSFORM_180:
4797 e_util_transform_matrix_translate(&m, -width, -height, 0);
4798 e_util_transform_matrix_rotation_z(&m, 180);
4800 case WL_OUTPUT_TRANSFORM_270:
4801 e_util_transform_matrix_translate(&m, 0, -height, 0);
4802 e_util_transform_matrix_rotation_z(&m, 90);
4808 e_util_transform_matrix_scale(&m, scale, scale, 1);
4813 /* surface to buffer
4814 * - surface width, surface height, buffer transform, buffer scale
4816 * - screen width, screen height, output transform, output scale
4819 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
4821 E_Util_Transform_Matrix m;
4822 E_Util_Transform_Vertex v;
4824 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
4826 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
4827 v = e_util_transform_matrix_multiply_vertex(&m, &v);
4828 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
4832 * - buffer width, buffer height, buffer transform, buffer scale
4835 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
4837 E_Util_Transform_Matrix m;
4838 E_Util_Transform_Vertex v;
4841 if (transform != 0 || scale > 1)
4843 tw = ((transform % 2) ? height : width) / scale;
4844 th = ((transform % 2) ? width : height) / scale;
4852 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
4853 m = e_util_transform_matrix_inverse_get(&m);
4855 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
4856 v = e_util_transform_matrix_multiply_vertex(&m, &v);
4857 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
4860 /* surface to buffer
4861 * - surface width, surface height, buffer transform, buffer scale
4863 * - screen width, screen height, output transform, output scale
4866 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
4867 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
4869 E_Util_Transform_Matrix m;
4870 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
4871 E_Util_Transform_Rect_Vertex sv;
4873 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
4875 sv = e_util_transform_rect_to_vertices(&sr);
4876 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
4877 sr = e_util_transform_vertices_to_rect(&sv);
4886 * - buffer width, buffer height, buffer transform, buffer scale
4889 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
4890 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
4892 E_Util_Transform_Matrix m;
4893 E_Util_Transform_Rect br = {bx, by, bw, bh};
4894 E_Util_Transform_Rect_Vertex bv;
4897 if (transform != 0 || scale > 1)
4899 tw = ((transform % 2) ? height : width) / scale;
4900 th = ((transform % 2) ? width : height) / scale;
4908 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
4909 m = e_util_transform_matrix_inverse_get(&m);
4911 bv = e_util_transform_rect_to_vertices(&br);
4912 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
4913 br = e_util_transform_vertices_to_rect(&bv);
4921 EINTERN E_Comp_Wl_Output*
4922 e_comp_wl_output_find(E_Client *ec)
4925 E_Comp_Wl_Output *output;
4927 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
4929 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
4931 if (output->transform % 2)
4933 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
4934 ec->y < output->x || ec->y >= (output->x + output->w))
4939 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
4940 ec->y < output->y || ec->y >= (output->y + output->h))
4950 EINTERN Eina_Array *
4951 e_comp_wl_output_find_all(E_Client *ec)
4953 E_Comp_Wl_Output *output;
4954 Eina_Array *outputs;
4957 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
4959 outputs = eina_array_new(4);
4963 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
4965 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
4966 output->x, output->y, output->w, output->h))
4968 eina_array_push(outputs, output);
4972 if (eina_array_count(outputs) == 0)
4974 eina_array_free(outputs);
4981 // --------------------------------------------------------
4982 // tizen_move_resize
4983 // --------------------------------------------------------
4985 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
4992 E_Client_Pending_Geometry *geo;
4995 if (e_object_is_del(E_OBJECT(ec))) goto ret;
4996 if (ec->fullscreen || ec->maximized) goto err;
4998 geo = E_NEW(E_Client_Pending_Geometry, 1);
5001 geo->serial = serial;
5007 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5008 ec->surface_sync.wait_commit = EINA_TRUE;
5013 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5020 e_comp_wl_commit_sync_configure(E_Client *ec)
5023 E_Client_Pending_Geometry *geo;
5025 Eina_Bool match_size = EINA_FALSE;
5032 if (!ec || !ec->frame) goto ret;
5033 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5036 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5037 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5039 if (eina_list_count(ec->surface_sync.pending_geometry))
5041 Eina_List *ll = NULL;
5042 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5046 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5051 if ((geo->w == bw) && (geo->h == bh))
5053 match_size = EINA_TRUE;
5058 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5065 if ((config.w != ec->w) || (config.h != ec->h))
5067 e_client_size_set(ec, config.w, config.h);
5068 ec->changes.size = EINA_TRUE;
5072 // FIXME: The geometry of the client would be better to be calculated
5073 // at e_desk or at e_desk_area. So the position(x,y) of the client
5074 // should be calcuated at the e_desk or at the e_desk_area.
5076 desk = e_comp_desk_find_by_ec(ec);
5079 ec->client.x = desk->geom.x + config.x;
5080 ec->client.y = desk->geom.y + config.y;
5084 ec->client.x = config.x;
5085 ec->client.y = config.y;
5088 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5090 e_client_pos_set(ec, ec->client.x, ec->client.y);
5092 ec->changes.pos = 1;
5096 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5100 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5101 ec->surface_sync.wait_commit = EINA_FALSE;
5103 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5105 // rollback wait_commit if there are pending requests remained
5106 if (eina_list_count(ec->surface_sync.pending_geometry))
5107 ec->surface_sync.wait_commit = EINA_TRUE;
5112 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);
5119 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5120 struct wl_resource *res_moveresize)
5122 wl_resource_destroy(res_moveresize);
5126 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5127 struct wl_resource *res_moveresize,
5128 struct wl_resource *surface,
5135 /* to be implemented */
5138 int cur_w = 0, cur_h = 0;
5140 ec = e_client_from_surface_resource(surface);
5143 pending = e_client_pending_geometry_has(ec);
5144 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5145 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);
5149 if ((cur_w == w) && (cur_h == h))
5151 e_client_pos_set(ec, x, y);
5152 ec->changes.pos = 1;
5158 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5162 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5165 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5167 _tz_move_resize_iface_cb_destroy,
5168 _tz_move_resize_iface_cb_set_geometry,
5172 _tz_moveresize_cb_bind(struct wl_client *client,
5173 void *data EINA_UNUSED,
5177 struct wl_resource *res_moveresize;
5179 res_moveresize = wl_resource_create(client,
5180 &tizen_move_resize_interface,
5183 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5186 wl_resource_set_implementation(res_moveresize,
5187 &_tz_move_resize_iface,
5193 ERR("Could not create tizen_move_resize_interface res: %m");
5194 wl_client_post_no_memory(client);
5198 e_comp_wl_move_resize_init(void)
5200 if (!e_comp_wl) return EINA_FALSE;
5201 if (!e_comp_wl->wl.disp) return EINA_FALSE;
5203 if (!wl_global_create(e_comp_wl->wl.disp,
5204 &tizen_move_resize_interface,
5207 _tz_moveresize_cb_bind))
5209 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5217 e_comp_wl_move_resize_shutdown(void)
5222 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5224 E_Comp_Wl_Output *output;
5225 pid_t output_pid = 0;
5226 Eina_List *l = NULL, *l2 = NULL;
5227 struct wl_resource *resource = NULL;
5229 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5231 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5232 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5233 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5235 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5237 /* if we have bound resources, send updates */
5238 EINA_LIST_FOREACH(output->resources, l2, resource)
5240 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5241 if (output_pid != pid) continue;
5243 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5245 // send output information to the client
5246 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5254 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5256 _e_comp_wl_surface_state_init(state, w, h);
5260 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5262 _e_comp_wl_surface_state_commit(ec, state);
5266 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5268 _e_comp_wl_hook_call(hookpoint, ec);
5272 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5274 _e_comp_wl_surface_state_finish(state);
5278 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5280 _e_comp_wl_surface_state_buffer_set(state, buffer);
5284 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5285 int sx, int sy, int *dx, int *dy)
5289 case WL_OUTPUT_TRANSFORM_NORMAL:
5293 case WL_OUTPUT_TRANSFORM_FLIPPED:
5294 *dx = width - sx, *dy = sy;
5296 case WL_OUTPUT_TRANSFORM_90:
5297 *dx = height - sy, *dy = sx;
5299 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5300 *dx = height - sy, *dy = width - sx;
5302 case WL_OUTPUT_TRANSFORM_180:
5303 *dx = width - sx, *dy = height - sy;
5305 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5306 *dx = sx, *dy = height - sy;
5308 case WL_OUTPUT_TRANSFORM_270:
5309 *dx = sy, *dy = width - sx;
5311 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5321 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5324 int tx1, ty1, tx2, ty2;
5325 int width_from_buffer, height_from_buffer;
5327 switch (vp->buffer.transform)
5329 case WL_OUTPUT_TRANSFORM_90:
5330 case WL_OUTPUT_TRANSFORM_270:
5331 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5332 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5333 width_from_buffer = bh / vp->buffer.scale;
5334 height_from_buffer = bw / vp->buffer.scale;
5337 width_from_buffer = bw / vp->buffer.scale;
5338 height_from_buffer = bh / vp->buffer.scale;
5342 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5346 x2 = width_from_buffer;
5347 y2 = height_from_buffer;
5351 x1 = wl_fixed_to_int(vp->buffer.src_x);
5352 y1 = wl_fixed_to_int(vp->buffer.src_y);
5353 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5354 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5357 buffer_transform(width_from_buffer, height_from_buffer,
5358 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5359 buffer_transform(width_from_buffer, height_from_buffer,
5360 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5362 out->x = (tx1 <= tx2) ? tx1 : tx2;
5363 out->y = (ty1 <= ty2) ? ty1 : ty2;
5364 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5365 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5369 * Convert given four coordinates to elements of rectangle
5370 * @in p[4] Coordinates to be converted
5371 * @out rect x, y, width, and height
5372 * transform Angle which represents TDM_TRANSFORM of rectangle
5373 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5374 * 1. The given coordinates are not represented by rectangle.
5375 * 2. All angles except for 0, 90, 180, 270.
5378 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5380 Eina_Bool ret = EINA_FALSE;
5382 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))
5385 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5388 *rotation = TDM_TRANSFORM_NORMAL;
5391 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5395 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5398 *rotation = TDM_TRANSFORM_180;
5401 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5406 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))
5409 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5412 *rotation = TDM_TRANSFORM_90;
5415 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5419 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5422 *rotation = TDM_TRANSFORM_270;
5425 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5435 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5440 for (i = 0; i < 4; i++)
5441 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5443 if (!_coords_to_rectangle_convert(p, out, rotation))
5445 DBG("Cannot convert given coords to rectangle.\n"
5446 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5447 p[0].x, p[0].y, p[1].x, p[1].y,
5448 p[2].x, p[2].y, p[3].x, p[3].y);
5456 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5458 int trans_rotation, flip;
5460 trans_rotation = transform & 0x3;
5461 flip = transform & 0x4;
5463 return (flip + (trans_rotation + rotation) % 4);
5467 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5475 if (e_comp_wl_subsurface_check(ec))
5476 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5483 out->w = ec->comp_data->width_from_viewport;
5484 out->w = (out->w + 1) & ~1;
5485 out->h = ec->comp_data->height_from_viewport;
5487 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5488 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5492 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5494 E_Comp_Wl_Buffer *buffer;
5495 E_Comp_Wl_Buffer_Viewport *vp;
5497 enum wl_output_transform buffer_transform;
5498 unsigned int rotation;
5499 Eina_Bool res = EINA_FALSE;
5501 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5503 if (e_object_is_del(E_OBJECT(ec)))
5506 vp = &ec->comp_data->scaler.buffer_viewport;
5508 if (buffer_viewport)
5510 buffer = ec->comp_data->buffer_ref.buffer;
5511 /* Getting a viewport of buffer needs geometry of buffer. */
5515 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5518 if ((output_viewport) || (transform))
5520 m = e_client_map_get(ec);
5522 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5524 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5529 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5530 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5531 * Since buffer.transform isn't applied using evas_map,
5532 * it has to be taken into account here to apply buffer.transform
5533 * and rotation of e_client_transform together. */
5535 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5537 *transform = (unsigned int)buffer_transform;
5545 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5547 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5548 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5550 /* Must be called with valid comp_data */
5551 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5553 if ((ec->comp_data->role_name == NULL) ||
5554 (ec->comp_data->role_name == role_name) ||
5555 (strcmp(ec->comp_data->role_name, role_name) == 0))
5557 ec->comp_data->role_name = role_name;
5563 wl_resource_post_error(error_resource, error_code,
5564 "Cannot assign role %s to wl_surface@%d,"
5565 " already has role %s\n",
5567 ec->comp_data->wl_surface ?
5568 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5569 ec->comp_data->role_name);
5575 EINTERN const char *
5576 e_comp_wl_surface_role_get(E_Client *ec)
5578 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5579 return ec->comp_data ? ec->comp_data->role_name : NULL;
5582 EINTERN struct wl_resource *
5583 e_comp_wl_client_surface_get(E_Client *ec)
5585 struct wl_resource *surface = NULL;
5586 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5587 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5589 g_mutex_lock(&ec->comp_data->surface_mutex);
5590 surface = ec->comp_data->surface;
5591 g_mutex_unlock(&ec->comp_data->surface_mutex);
5596 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5598 EINA_SAFETY_ON_NULL_RETURN(ec);
5599 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5601 g_mutex_lock(&ec->comp_data->surface_mutex);
5602 ec->comp_data->surface = surface;
5603 g_mutex_unlock(&ec->comp_data->surface_mutex);
5607 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5609 return e_compositor_util_client_from_surface_resource(surface_resource);
5613 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5615 if (!ec->comp_data->mapped)
5617 if (ec->comp_data->shell.surface &&
5618 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5620 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5626 if (ec->comp_data->mapped)
5628 /* will be unmapped. so run capture */
5629 e_comp_wl_remote_surface_image_save(ec);
5633 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5635 ec->comp_data->pending.sx = sx;
5636 ec->comp_data->pending.sy = sy;
5637 ec->comp_data->pending.new_attach = EINA_TRUE;
5639 e_client_fps_update(ec);
5643 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5645 if (ec->comp_data->pending.opaque)
5646 eina_tiler_clear(ec->comp_data->pending.opaque);
5650 eina_tiler_union(ec->comp_data->pending.opaque, region);
5652 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5656 ec->argb = EINA_FALSE;
5657 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5659 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5660 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5668 ec->argb = EINA_TRUE;
5669 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5671 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5672 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5678 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5680 if (ec->comp_data->pending.input)
5681 eina_tiler_clear(ec->comp_data->pending.input);
5685 if (eina_tiler_empty(region))
5687 ELOGF("COMP", " |unset input rect", NULL);
5688 e_comp_object_input_objs_del(ec->frame);
5689 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
5692 eina_tiler_union(ec->comp_data->pending.input, region);
5696 eina_tiler_rect_add(ec->comp_data->pending.input,
5697 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
5702 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
5704 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
5708 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
5710 E_Comp_Wl_Subsurf_Data *sdata;
5715 if (ec->comp_data->frames)
5717 ec->comp_data->frames =
5718 eina_list_remove(ec->comp_data->frames, callback_resource);
5721 if (ec->comp_data->pending.frames)
5723 ec->comp_data->pending.frames =
5724 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
5727 sdata = ec->comp_data->sub.data;
5728 if ((sdata) && (sdata->cached.frames))
5730 sdata->cached.frames =
5731 eina_list_remove(sdata->cached.frames, callback_resource);
5736 e_comp_wl_client_surface_pending_commit(E_Client *ec)
5738 if (e_object_is_del(E_OBJECT(ec))) return;
5740 if (e_comp_wl_remote_surface_commit(ec)) return;
5742 e_comp_wl_surface_commit(ec);
5744 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
5748 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
5750 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
5751 ec->comp_data->sub.data = sub;
5753 /* set subsurface client properties */
5754 ec->borderless = EINA_TRUE;
5755 ec->argb = EINA_TRUE;
5756 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
5757 ec->lock_border = EINA_TRUE;
5758 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
5759 ec->netwm.state.skip_taskbar = EINA_TRUE;
5760 ec->netwm.state.skip_pager = EINA_TRUE;
5761 ec->border_size = 0;
5762 ec->lock_user_location = 0;
5763 ec->lock_client_location = 0;
5764 ec->lock_user_size = 0;
5765 ec->lock_client_size = 0;
5766 ec->lock_client_stacking = 0;
5767 ec->lock_user_maximize = 0;
5768 ec->lock_client_maximize = 0;
5769 ec->changes.need_maximize = 0;
5770 ec->maximized = E_MAXIMIZE_NONE;
5773 ec->new_client = ec->netwm.ping = EINA_TRUE;
5774 e_comp->new_clients++;
5775 e_client_unignore(ec);
5779 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
5781 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
5784 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
5786 sub->parent = parent;
5790 layer = e_client_layer_get(parent);
5791 if (layer > E_LAYER_BOTTOM)
5792 e_client_layer_set(ec, layer);
5795 if (parent->comp_data)
5797 /* append this client to the parents subsurface list */
5798 parent->comp_data->sub.list_pending =
5799 eina_list_append(parent->comp_data->sub.list_pending, ec);
5800 parent->comp_data->sub.list_changed = EINA_TRUE;
5805 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
5807 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
5808 E_Client *parent = sub->parent;
5810 parent->comp_data->sub.list =
5811 eina_list_remove(parent->comp_data->sub.list, ec);
5812 parent->comp_data->sub.list_pending =
5813 eina_list_remove(parent->comp_data->sub.list_pending, ec);
5814 parent->comp_data->sub.below_list =
5815 eina_list_remove(parent->comp_data->sub.below_list, ec);
5816 parent->comp_data->sub.below_list_pending =
5817 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
5823 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)
5825 sub->resource = subsurface_resource;
5826 sub->cached_buffer_ref.buffer = NULL;
5827 sub->synchronized = EINA_TRUE;
5828 sub->parent = parent;
5829 sub->remote_surface.offscreen_parent = offscreen_parent;
5830 if (offscreen_parent)
5831 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
5833 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
5835 _e_comp_wl_client_subsurface_set(ec, sub);
5836 _e_comp_wl_client_subsurface_parent_set(ec, parent);
5838 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
5842 e_comp_wl_client_subsurface_finish(E_Client *ec)
5844 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
5847 e_comp_wl_client_subsurface_parent_unset(ec);
5849 e_comp_wl_surface_state_finish(&sub->cached);
5850 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
5852 ec->comp_data->sub.data = NULL;
5856 e_comp_wl_client_evas_init(E_Client *ec)
5858 EINA_SAFETY_ON_NULL_RETURN(ec);
5860 _e_comp_wl_client_evas_init(ec);
5864 e_comp_wl_client_evas_deinit(E_Client *ec)
5866 EINA_SAFETY_ON_NULL_RETURN(ec);
5868 _e_comp_wl_client_evas_deinit(ec);
5872 e_comp_wl_focus_check(void)
5874 _e_comp_wl_focus_check();
5878 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
5885 if ((parent->comp_data) && (parent->comp_data->sub.data))
5886 parent = parent->comp_data->sub.data->parent;
5894 E_API struct wl_display *
5895 e_comp_wl_display_get(void)
5897 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
5899 return e_comp_wl->wl.disp;
5902 E_API struct xkb_keymap *
5903 e_comp_wl_xkb_keymap_get(void)
5905 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
5907 return e_comp_wl->xkb.keymap;
5911 e_comp_wl_xkb_keymap_lock(void)
5913 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
5915 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
5919 e_comp_wl_xkb_keymap_unlock(void)
5921 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
5923 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
5926 E_API struct xkb_context *
5927 e_comp_wl_xkb_context_get(void)
5929 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
5931 return e_comp_wl->xkb.context;
5934 E_API struct xkb_state *
5935 e_comp_wl_xkb_state_get(void)
5937 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
5939 return e_comp_wl->xkb.state;
5943 e_comp_wl_xkb_fd_get(void)
5945 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, -1);
5947 return e_comp_wl->xkb.fd;
5951 e_comp_wl_xkb_size_get(void)
5953 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, 0);
5955 return e_comp_wl->xkb.size;
5959 e_comp_wl_kbd_resource_list_get(void)
5961 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
5963 return e_comp_wl->kbd.resources;
5967 e_comp_wl_kbd_resource_list_lock(void)
5969 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
5971 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
5975 e_comp_wl_kbd_resource_list_unlock(void)
5977 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
5979 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
5983 e_comp_wl_kbd_repeat_delay_get(void)
5985 EINA_SAFETY_ON_FALSE_RETURN_VAL(e_comp_wl, -1);
5987 return e_comp_wl->kbd.repeat_delay;
5991 e_comp_wl_kbd_repeat_delay_lock(void)
5993 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
5995 g_mutex_lock(&e_comp_wl->kbd.repeat_delay_mutex);
5999 e_comp_wl_kbd_repeat_delay_unlock(void)
6001 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
6003 g_mutex_unlock(&e_comp_wl->kbd.repeat_delay_mutex);
6007 e_comp_wl_kbd_repeat_rate_get(void)
6009 EINA_SAFETY_ON_FALSE_RETURN_VAL(e_comp_wl, -1);
6011 return e_comp_wl->kbd.repeat_rate;
6015 e_comp_wl_kbd_repeat_rate_lock(void)
6017 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
6019 g_mutex_lock(&e_comp_wl->kbd.repeat_rate_mutex);
6023 e_comp_wl_kbd_repeat_rate_unlock(void)
6025 EINA_SAFETY_ON_NULL_RETURN(e_comp_wl);
6027 g_mutex_unlock(&e_comp_wl->kbd.repeat_rate_mutex);
6031 e_comp_wl_ptr_ec_get(void)
6033 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
6035 return e_comp_wl->ptr.ec;