2 #include "e_comp_wl_intern.h"
3 #include "e_main_intern.h"
4 #include "e_foreign_intern.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_client_intern.h"
7 #include "e_appinfo_intern.h"
8 #include "e_blender_intern.h"
9 #include "e_utils_intern.h"
10 #include "e_scale_intern.h"
11 #include "e_comp_canvas_intern.h"
12 #include "e_comp_screen_intern.h"
13 #include "e_comp_wl_capture_intern.h"
14 #include "e_comp_wl_data_intern.h"
15 #include "e_comp_wl_input_intern.h"
16 #include "e_comp_wl_renderer_intern.h"
17 #include "e_comp_wl_rsm_intern.h"
18 #include "e_comp_wl_screenshooter_intern.h"
19 #include "e_comp_wl_shell_intern.h"
20 #include "e_comp_wl_subsurface_intern.h"
21 #include "e_comp_wl_tbm_intern.h"
22 #include "e_comp_wl_viewport_intern.h"
23 #include "e_comp_intern.h"
24 #include "e_input_intern.h"
25 #include "e_keyrouter_intern.h"
26 #include "e_error_intern.h"
27 #include "e_pointer_intern.h"
28 #include "e_presentation_time_intern.h"
29 #include "e_grabinput_intern.h"
30 #include "e_env_intern.h"
31 #include "e_dnd_intern.h"
32 #include "e_policy_visibility_intern.h"
33 #include "e_compositor_intern.h"
34 #include "e_client_video_intern.h"
35 #include "e_comp_wl_video_intern.h"
36 #include "e_comp_object_intern.h"
37 #include "e_desk_intern.h"
38 #include "e_zone_intern.h"
39 #include "e_hints_intern.h"
40 #include "e_comp_input_intern.h"
41 #include "e_blur_intern.h"
42 #include "e_input_thread_client_intern.h"
44 #include <tizen-extension-server-protocol.h>
45 #include <relative-pointer-unstable-v1-server-protocol.h>
46 #include <pointer-constraints-unstable-v1-server-protocol.h>
48 #include <wayland-tbm-server.h>
50 #include <libds/log.h>
51 #include <libds/single_pixel_buffer_v1.h>
55 #include <sys/resource.h>
57 /* handle include for printing uint64_t */
58 #define __STDC_FORMAT_MACROS
61 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
63 /* Resource Data Mapping: (wl_resource_get_user_data)
65 * wl_surface == e_pixmap
66 * wl_region == eina_tiler
67 * wl_subsurface == e_client
71 typedef struct _E_Comp_Data E_Comp_Data;
76 struct wl_listener client_created;
79 static void _e_comp_wl_move_resize_init(void);
81 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
84 typedef struct _E_Comp_Wl_Key_Data
90 struct _E_Comp_Wl_Evas_Gl
93 Evas_GL_Config *glcfg;
94 Evas_GL_Context *glctx;
95 Evas_GL_Surface *glsfc;
99 static Eina_List *handlers = NULL;
100 static E_Client *cursor_timer_ec = NULL;
101 static Eina_Bool need_send_released = EINA_FALSE;
102 static Eina_Bool need_send_motion = EINA_TRUE;
104 static GMutex connection_mutex;
106 static int _e_comp_wl_hooks_delete = 0;
107 static int _e_comp_wl_hooks_walking = 0;
109 static int _e_comp_wl_pid_hooks_delete = 0;
110 static int _e_comp_wl_pid_hooks_walking = 0;
112 static int _e_comp_wl_intercept_hooks_delete = 0;
113 static int _e_comp_wl_intercept_hooks_walking = 0;
115 static Eina_Inlist *_e_comp_wl_hooks[] =
117 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
118 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
119 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
120 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
121 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
122 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
123 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
124 [E_COMP_WL_HOOK_DEL] = NULL,
125 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
126 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
127 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
130 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
132 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
135 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
137 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
138 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
139 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
140 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
141 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
142 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
145 static Eina_List *hooks = NULL;
147 /* local functions */
149 _e_comp_wl_hooks_clean(void)
154 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
155 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
157 if (!ch->delete_me) continue;
158 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
164 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
168 e_object_ref(E_OBJECT(ec));
169 _e_comp_wl_hooks_walking++;
170 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
172 if (ch->delete_me) continue;
173 ch->func(ch->data, ec);
174 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
175 (e_object_is_del(E_OBJECT(ec))))
178 _e_comp_wl_hooks_walking--;
179 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
180 _e_comp_wl_hooks_clean();
181 e_object_unref(E_OBJECT(ec));
185 _e_comp_wl_pid_hooks_clean(void)
188 E_Comp_Wl_Pid_Hook *ch;
190 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
191 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
193 if (!ch->delete_me) continue;
194 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
200 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
202 E_Comp_Wl_Pid_Hook *ch;
204 _e_comp_wl_pid_hooks_walking++;
205 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
207 if (ch->delete_me) continue;
208 ch->func(ch->data, pid);
210 _e_comp_wl_pid_hooks_walking--;
211 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
212 _e_comp_wl_pid_hooks_clean();
216 _e_comp_wl_intercept_hooks_clean(void)
219 E_Comp_Wl_Intercept_Hook *ch;
221 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
222 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
224 if (!ch->delete_me) continue;
225 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
231 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
233 E_Comp_Wl_Intercept_Hook *ch;
234 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
236 e_object_ref(E_OBJECT(ec));
237 _e_comp_wl_intercept_hooks_walking++;
238 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
240 if (ch->delete_me) continue;
241 res = ch->func(ch->data, ec);
242 if (!res) ret = EINA_FALSE;
243 if (e_object_is_del(E_OBJECT(ec)))
246 _e_comp_wl_intercept_hooks_walking--;
247 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
248 _e_comp_wl_intercept_hooks_clean();
249 e_object_unref(E_OBJECT(ec));
256 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
262 if (e_comp_object_frame_exists(ec->frame))
263 w = ec->client.w, h = ec->client.h;
265 w = ec->w, h = ec->h;
269 // Width and Height are -1 means that we don't consider size value
273 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
277 _e_comp_wl_focus_check(void)
281 if (stopping) return;
282 ec = e_client_focused_get();
284 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
288 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
290 /* dispatch pending wayland events */
291 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
293 return ECORE_CALLBACK_RENEW;
297 e_comp_wl_display_flush()
299 if (e_comp_wl && e_comp_wl->wl.disp)
301 if (e_config->key_input_ttrace_enable)
303 TRACE_INPUT_BEGIN(wl_display_flush_clients);
304 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
307 g_mutex_lock(&connection_mutex);
308 wl_display_flush_clients(e_comp_wl->wl.disp);
309 g_mutex_unlock(&connection_mutex);
311 if (e_config->key_input_ttrace_enable)
314 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
320 e_comp_wl_connection_lock()
322 e_input_boost_lock(&connection_mutex);
326 e_comp_wl_connection_unlock()
328 e_input_boost_unlock(&connection_mutex);
332 e_comp_wl_focused_client_flush()
334 E_Client *focused_ec;
335 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
337 e_input_boost_lock(&connection_mutex);
338 focused_ec = e_client_focused_get();
342 struct wl_client *wc;
343 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
346 e_input_boost_unlock(&connection_mutex);
350 wc = wl_resource_get_client(surface);
354 e_input_boost_unlock(&connection_mutex);
358 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
362 if (e_comp_wl->idle_exiter_timestamp > 0.0)
364 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
365 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
367 ELOGF("E_COMP", "prepare gap time: %lfms",
372 e_comp_wl->idle_exiter_timestamp = 0.0;
374 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
376 /* flush pending client events */
377 e_comp_wl_display_flush();
379 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
380 IDLE_EXITER~CB_PREPARE);
382 // _e_comp_wl_cb_prepare() function is called before idle state in ecore_main_loop.
383 // idle state means that epoll() or select() is called in ecore_main_loop.
384 e_main_hook_call(E_MAIN_HOOK_LOOP_BEFORE_IDLE_ENTER);
388 _e_comp_wl_cb_awake(void *data)
390 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
392 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
393 IDLE_EXITER~CB_PREPARE);
395 // _e_comp_wl_cb_awake() function is called after idle state in ecore_main_loop.
396 // ecore_main_loop awake due to returning from epoll() or select()
397 e_main_hook_call(E_MAIN_HOOK_LOOP_AFTER_IDLE_EXIT);
400 E_API enum wl_output_transform
401 e_comp_wl_output_buffer_transform_get(E_Client *ec)
403 E_Comp_Wl_Buffer_Viewport *vp;
404 E_Comp_Wl_Buffer *buffer;
405 enum wl_output_transform transform, rotation;
407 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
408 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
409 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
411 vp = &ec->comp_data->scaler.buffer_viewport;
412 if (e_comp_wl_subsurface_check(ec))
413 return vp->buffer.transform;
415 buffer = ec->comp_data->buffer_ref.buffer;
418 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
419 return vp->buffer.transform;
421 rotation = buffer->transform;
423 return vp->buffer.transform;
425 /* ignore the flip value when calculating transform because the screen rotation
426 * functionality doesn't consider the flip output transform currently
428 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
430 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
431 ec, rotation, vp->buffer.transform, transform);
436 EINTERN enum wl_output_transform
437 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
439 E_Comp_Wl_Buffer_Viewport *vp;
440 E_Comp_Wl_Buffer *buffer;
441 enum wl_output_transform transform, rotation;
443 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
444 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
445 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
447 vp = &ec->comp_data->pending.buffer_viewport;
448 if (e_comp_wl_subsurface_check(ec))
449 return vp->buffer.transform;
451 buffer = ec->comp_data->pending.buffer;
454 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
455 return vp->buffer.transform;
457 rotation = buffer->transform;
459 return vp->buffer.transform;
461 /* ignore the flip value when calculating transform because the screen rotation
462 * functionality doesn't consider the flip output transform currently
464 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
466 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
467 ec, rotation, vp->buffer.transform, transform);
473 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
475 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
476 E_Comp_Wl_Buffer *buffer;
477 int32_t width, height;
479 buffer = e_pixmap_resource_get(ec->pixmap);
482 ec->comp_data->width_from_buffer = 0;
483 ec->comp_data->height_from_buffer = 0;
487 switch (e_comp_wl_output_buffer_transform_get(ec))
489 case WL_OUTPUT_TRANSFORM_90:
490 case WL_OUTPUT_TRANSFORM_270:
491 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
492 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
493 width = buffer->h / vp->buffer.scale;
494 height = buffer->w / vp->buffer.scale;
497 width = buffer->w / vp->buffer.scale;
498 height = buffer->h / vp->buffer.scale;
502 ec->comp_data->width_from_buffer = width;
503 ec->comp_data->height_from_buffer = height;
507 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
509 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
510 int32_t width, height;
512 width = ec->comp_data->width_from_buffer;
513 height = ec->comp_data->height_from_buffer;
515 if (width == 0 && height == 0) return;
517 if (width != 0 && vp->surface.width != -1)
519 ec->comp_data->width_from_viewport = vp->surface.width;
520 ec->comp_data->height_from_viewport = vp->surface.height;
524 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
526 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
527 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
528 ec->comp_data->width_from_viewport = w ?: 1;
529 ec->comp_data->height_from_viewport = h ?: 1;
533 ec->comp_data->width_from_viewport = width;
534 ec->comp_data->height_from_viewport = height;
538 e_comp_wl_topmost_parent_get(E_Client *ec)
542 if (!e_comp_wl_subsurface_check(ec))
545 parent = e_comp_wl_subsurface_parent_get(ec);
548 if (!e_comp_wl_subsurface_check(parent))
551 parent = e_comp_wl_subsurface_parent_get(parent);
558 e_comp_wl_map_apply(E_Client *ec)
560 E_Comp_Wl_Buffer_Viewport *vp;
561 E_Comp_Wl_Subsurf_Data *sdata;
562 E_Comp_Wl_Client_Data *cdata;
563 int x1, y1, x2, y2, x, y;
565 Eina_Bool zoom_animating = EINA_FALSE;
567 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
569 e_comp_object_map_update(ec->frame);
571 cdata = ec->comp_data;
572 vp = &cdata->scaler.buffer_viewport;
573 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
574 (!cdata->viewport_transform))
577 if (e_comp_wl_subsurface_check(ec))
579 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
581 sdata = ec->comp_data->sub.data;
582 if (sdata->remote_surface.offscreen_parent)
584 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
585 Eina_Rectangle *rect;
588 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
590 /* TODO: If there are one more regions, it means that provider's offscreen
591 * is displayed by one more remote_surfaces. Have to consider it later. At
592 * this time, just consider only one remote_surface.
606 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
607 if (x != dx || y != dy)
608 evas_object_move(ec->frame, dx, dy);
610 if (!cdata->viewport_transform)
612 cdata->viewport_transform = e_util_transform_new();
613 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
614 e_client_transform_core_add(ec, cdata->viewport_transform);
617 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
618 ec->comp_data->width_from_viewport,
619 ec->comp_data->height_from_viewport);
621 if (vp->buffer.src_width == wl_fixed_from_int(-1))
625 x2 = cdata->width_from_buffer;
626 y2 = cdata->height_from_buffer;
630 x1 = wl_fixed_to_int(vp->buffer.src_x);
631 y1 = wl_fixed_to_int(vp->buffer.src_y);
632 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
633 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
636 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
637 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
638 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
639 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
642 desk = e_comp_desk_find_by_ec(ec);
644 zoom_animating = e_desk_zoom_is_animating(desk);
646 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
647 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
648 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
650 /* workaround:: when the desk zoom is doing their animation,
651 the transform core update can override animation's zoom boundary.
652 so, don't doing transform core update while desk zoom animation */
654 e_client_transform_core_update(ec);
659 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
663 int map_c = 0, map_x = 0, map_y = 0;
664 double inv_x = 0.0, inv_y = 0.0;
666 EINA_SAFETY_ON_NULL_RETURN(ec);
668 map = e_client_map_get(ec);
669 map_c = e_map_count_get(map);
671 if (!map || map_c <= 0)
681 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
682 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
683 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
684 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
686 for (int i = 0; i < map_c; i++)
688 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
689 e_map_point_image_uv_set(map2, i, map_x, map_y);
691 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
701 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
707 if (!(ec = data)) return;
708 if (e_object_is_del(data)) return;
710 if (!ec->override) e_hints_window_visible_set(ec);
712 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
713 (!ec->comp_data->need_reparent))
715 ec->comp_data->need_reparent = EINA_TRUE;
716 ec->visible = EINA_TRUE;
718 if (!e_client_util_ignored_get(ec))
720 ec->take_focus = !starting;
724 if (!ec->comp_data->need_reparent)
726 if ((ec->hidden) || (ec->iconic))
728 evas_object_hide(ec->frame);
729 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
732 evas_object_show(ec->frame);
735 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
736 evas_object_show(tmp->frame);
738 topmost = e_comp_wl_topmost_parent_get(ec);
739 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
740 e_comp_wl_subsurface_show(ec);
742 if (ec->comp_data->sub.below_obj)
743 evas_object_show(ec->comp_data->sub.below_obj);
747 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
753 if (!(ec = data)) return;
754 if (e_object_is_del(E_OBJECT(ec))) return;
756 /* Uncommonly some clients's final buffer can be skipped if the client
757 * requests unmap of its surface right after wl_surface@commit.
758 * So if this client evas object is hidden state and client is already
759 * unmmapped, we can consider to clear pixmap image here mandatorily.
761 if (!ec->comp_data->mapped)
762 e_pixmap_image_clear(ec->pixmap, 1);
764 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
765 evas_object_hide(tmp->frame);
767 topmost = e_comp_wl_topmost_parent_get(ec);
768 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
769 e_comp_wl_subsurface_hide(ec);
771 if (ec->comp_data->sub.below_obj)
772 evas_object_hide(ec->comp_data->sub.below_obj);
774 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
778 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
785 if (!(ec = data)) return;
786 if (e_object_is_del(E_OBJECT(ec))) return;
788 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
790 if (!e_comp_wl_subsurface_check(subc)) continue;
791 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
792 evas_object_move(subc->frame, x, y);
794 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
795 if (cdata->viewport_transform)
796 e_comp_wl_map_apply(subc);
799 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
801 if (!e_comp_wl_subsurface_check(subc)) continue;
802 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
803 evas_object_move(subc->frame, x, y);
805 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
806 if (cdata->viewport_transform)
807 e_comp_wl_map_apply(subc);
810 if (ec->comp_data->sub.below_obj)
812 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
813 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
818 _e_comp_wl_send_touch_cancel(E_Client *ec)
821 struct wl_resource *res;
822 struct wl_client *wc;
823 E_Comp_Config *comp_conf = NULL;
826 if (e_object_is_del(E_OBJECT(ec))) return;
827 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
829 if (!surface) return;
830 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
832 wc = wl_resource_get_client(surface);
834 comp_conf = e_comp_config_get();
836 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
838 if (wl_resource_get_client(res) != wc) continue;
839 if (!e_comp_wl_input_touch_check(res)) continue;
841 if (comp_conf && comp_conf->input_log_enable)
842 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
844 wl_touch_send_cancel(res);
849 _e_comp_wl_touch_cancel(void)
853 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
855 if (!e_comp_wl->touch.pressed) return;
857 _e_comp_wl_send_touch_cancel(ec);
860 static E_Devicemgr_Input_Device *
861 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
863 E_Devicemgr_Input_Device *last_kbd = NULL;
866 case ECORE_DEVICE_CLASS_MOUSE:
867 return e_devicemgr->last_device_ptr;
868 case ECORE_DEVICE_CLASS_KEYBOARD:
869 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
871 case ECORE_DEVICE_CLASS_TOUCH:
872 return e_devicemgr->last_device_touch;
880 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
884 case ECORE_DEVICE_CLASS_MOUSE:
885 e_devicemgr->last_device_ptr = device;
887 case ECORE_DEVICE_CLASS_KEYBOARD:
888 atomic_store(&e_devicemgr->last_device_kbd, device);
890 case ECORE_DEVICE_CLASS_TOUCH:
891 e_devicemgr->last_device_touch = device;
898 static E_Devicemgr_Input_Device *
899 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
901 E_Devicemgr_Input_Device *last_kbd = NULL;
905 case ECORE_DEVICE_CLASS_MOUSE:
906 return ec->comp_data->last_device_ptr;
907 case ECORE_DEVICE_CLASS_KEYBOARD:
908 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
910 case ECORE_DEVICE_CLASS_TOUCH:
911 return ec->comp_data->last_device_touch;
919 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
923 case ECORE_DEVICE_CLASS_MOUSE:
924 ec->comp_data->last_device_ptr = device;
926 case ECORE_DEVICE_CLASS_KEYBOARD:
927 atomic_store(&ec->comp_data->last_device_kbd, device);
929 case ECORE_DEVICE_CLASS_TOUCH:
930 ec->comp_data->last_device_touch = device;
938 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
940 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
941 struct wl_resource *dev_res;
942 const char *dev_name;
943 Ecore_Device_Class dev_class;
944 struct wl_client *wc;
948 EINA_SAFETY_ON_NULL_RETURN(dev);
951 if (ec->cur_mouse_action || e_comp_wl->drag)
953 if (e_object_is_del(E_OBJECT(ec))) return;
954 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
955 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
956 if (!surface) return;
958 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
959 dev_name = evas_device_description_get(dev);
960 last_device = _e_comp_wl_device_last_device_get(dev_class);
961 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
963 serial = wl_display_next_serial(e_comp_wl->wl.disp);
964 wc = wl_resource_get_client(surface);
965 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
966 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
968 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
969 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
971 _e_comp_wl_device_last_device_set(dev_class, input_dev);
972 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
974 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
976 if (wl_resource_get_client(dev_res) != wc) continue;
977 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
981 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
985 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
987 E_Devicemgr_Input_Device *last_device;
988 struct wl_resource *dev_res;
989 struct wl_client *wc;
993 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
994 if (!surface) return;
996 last_device = _e_comp_wl_device_last_device_get(dev_class);
997 if (!last_device) return;
999 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
1001 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1002 wc = wl_resource_get_client(surface);
1003 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
1005 if (wl_resource_get_client(dev_res) != wc) continue;
1006 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
1011 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1013 E_Devicemgr_Input_Device *input_dev;
1014 struct wl_resource *dev_res;
1015 const char *dev_name;
1018 EINA_SAFETY_ON_NULL_RETURN(dev);
1020 dev_name = ecore_device_identifier_get(dev);
1022 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1023 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1025 if (!eina_streq(input_dev->identifier, dev_name) ||
1026 (input_dev->clas != ecore_device_class_get(dev))) continue;
1027 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1029 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1031 if (wl_resource_get_client(dev_res) != wc) continue;
1032 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1035 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1039 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1041 E_Devicemgr_Input_Device *input_dev;
1042 struct wl_resource *dev_res;
1043 const char *dev_name;
1046 EINA_SAFETY_ON_NULL_RETURN(dev);
1048 dev_name = e_device_identifier_get(dev);
1050 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1051 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1053 if (!eina_streq(input_dev->identifier, dev_name) ||
1054 (input_dev->clas != e_device_class_get(dev))) continue;
1055 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1057 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1059 if (wl_resource_get_client(dev_res) != wc) continue;
1060 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1063 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1067 _e_comp_wl_cursor_reload(E_Client *ec)
1069 struct wl_resource *res;
1070 struct wl_client *wc;
1076 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1077 !evas_object_visible_get(e_comp->pointer->o_ptr))
1078 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1081 if (e_object_is_del(E_OBJECT(ec))) return;
1082 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1083 if (!surface) return;
1084 if (ec->pointer_enter_sent) return;
1086 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1087 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1089 if (e_client_transform_core_enable_get(ec))
1091 double dx = 0.0, dy = 0.0;
1092 map = e_client_map_get(ec);
1093 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1099 cx = px - ec->client.x;
1100 cy = py - ec->client.y;
1102 wc = wl_resource_get_client(surface);
1103 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1104 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1106 if (!e_comp_wl_input_pointer_check(res)) continue;
1107 if (wl_resource_get_client(res) != wc) continue;
1108 wl_pointer_send_enter(res, serial, surface,
1109 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1110 ec->pointer_enter_sent = EINA_TRUE;
1112 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1116 _e_comp_wl_cursor_timer(void *data)
1118 E_Client *ec = data;
1120 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1121 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1123 e_comp_wl_cursor_hide(ec);
1125 return ECORE_CALLBACK_CANCEL;
1129 _e_comp_wl_device_send_axis(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, enum tizen_input_device_axis_type axis_type, double value)
1131 E_Devicemgr_Input_Device *input_dev;
1132 struct wl_resource *dev_res;
1133 struct wl_client *wc;
1138 if (ec->cur_mouse_action) return;
1139 if (e_object_is_del(E_OBJECT(ec))) return;
1140 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1141 if (!surface) return;
1143 f_value = wl_fixed_from_double(value);
1144 wc = wl_resource_get_client(surface);
1146 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1147 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1149 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1150 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1152 if (wl_resource_get_client(dev_res) != wc) continue;
1153 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1156 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1160 _e_comp_wl_device_renew_axis(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
1162 if (idx >= e_input_touch_max_count_get()) return;
1164 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1165 e_devicemgr->multi[idx].radius_x = radius_x;
1166 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1167 e_devicemgr->multi[idx].radius_y = radius_y;
1168 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1169 e_devicemgr->multi[idx].pressure = pressure;
1170 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1171 e_devicemgr->multi[idx].angle = angle;
1175 _e_comp_wl_device_handle_axes(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
1177 if (idx >= e_input_touch_max_count_get()) return;
1179 if (e_devicemgr->multi[idx].radius_x != radius_x)
1181 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1182 e_devicemgr->multi[idx].radius_x = radius_x;
1184 if (e_devicemgr->multi[idx].radius_y != radius_y)
1186 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1187 e_devicemgr->multi[idx].radius_y = radius_y;
1189 if (e_devicemgr->multi[idx].pressure != pressure)
1191 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1192 e_devicemgr->multi[idx].pressure = pressure;
1194 if (e_devicemgr->multi[idx].angle != angle)
1196 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1197 e_devicemgr->multi[idx].angle = angle;
1202 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1204 Eina_Bool ret = EINA_TRUE;
1207 case EVAS_CALLBACK_MOUSE_IN:
1208 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1211 if (e_comp_wl->ptr.hide_tmr)
1213 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1214 cursor_timer_ec = ec;
1215 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1219 if (e_pointer_is_hidden(e_comp->pointer))
1224 case EVAS_CALLBACK_MOUSE_OUT:
1225 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1228 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1232 case EVAS_CALLBACK_MOUSE_MOVE:
1233 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1236 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1237 _e_comp_wl_cursor_reload(ec);
1240 case EVAS_CALLBACK_MOUSE_WHEEL:
1241 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1244 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1245 _e_comp_wl_cursor_reload(ec);
1248 case EVAS_CALLBACK_MOUSE_DOWN:
1249 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1252 if (e_comp_wl->ptr.hide_tmr)
1254 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1255 e_comp_wl->ptr.hide_tmr = NULL;
1257 cursor_timer_ec = NULL;
1259 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1260 _e_comp_wl_cursor_reload(ec);
1263 case EVAS_CALLBACK_MOUSE_UP:
1264 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1275 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1277 if (ec->has_cursor_unset)
1280 if (!e_config->show_cursor)
1283 if (!e_config->use_cursor_timer)
1290 _e_comp_wl_check_block_input(E_Client *ec)
1292 E_Client *modal_child = e_client_modal_child_get(ec);
1295 if (modal_child->visible && !modal_child->iconic && (modal_child->visibility.obscured == E_VISIBILITY_UNOBSCURED))
1297 ELOGF("Touch", "Block touch by Modal child(ec:%p, win:0x%08zx)", ec, modal_child, e_client_util_win_get(modal_child));
1306 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1309 Evas_Event_Mouse_In *ev;
1310 struct wl_resource *res;
1311 struct wl_client *wc;
1314 E_Comp_Config *comp_conf;
1315 E_Client *prev_ptr_ec;
1319 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1320 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1322 if (!(ec = data)) return;
1323 if (e_object_is_del(E_OBJECT(ec))) return;
1324 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1325 if (!surface) return;
1327 prev_ptr_ec = e_comp_wl->ptr.ec;
1330 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1331 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1334 e_comp_wl->ptr.ec = ec;
1336 comp_conf = e_comp_config_get();
1337 if (comp_conf && comp_conf->input_log_enable)
1338 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1339 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1340 e_client_util_name_get(ec));
1342 if (_e_comp_wl_check_cursor_timer_needed(ec))
1344 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1348 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1349 wc = wl_resource_get_client(surface);
1350 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1351 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1353 if (!e_comp_wl_input_pointer_check(res)) continue;
1354 if (wl_resource_get_client(res) != wc) continue;
1356 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1358 wl_pointer_send_enter(res, serial, surface,
1359 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1360 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1361 ec->pointer_enter_sent = EINA_TRUE;
1364 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1366 ELOGF("Mouse", "In. Event doesn't have timestamp. no need to send signal", NULL);
1370 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1373 Evas_Event_Mouse_Out *ev;
1374 struct wl_resource *res;
1375 struct wl_client *wc;
1378 Eina_Bool inside_check;
1379 E_Comp_Config *comp_conf;
1383 if (!(ec = data)) return;
1384 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1385 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1386 if (ec->cur_mouse_action && inside_check) return;
1387 if (e_object_is_del(E_OBJECT(e_comp))) return;
1388 if (e_comp_wl->ptr.ec == ec)
1389 e_comp_wl->ptr.ec = NULL;
1390 if (e_object_is_del(E_OBJECT(ec))) return;
1392 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1393 if (!surface) return;
1395 comp_conf = e_comp_config_get();
1396 if (comp_conf && comp_conf->input_log_enable)
1397 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1398 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1399 e_client_util_name_get(ec));
1401 if (_e_comp_wl_check_cursor_timer_needed(ec))
1403 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1407 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1409 wc = wl_resource_get_client(surface);
1410 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1411 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1413 if (!e_comp_wl_input_pointer_check(res)) continue;
1414 if (wl_resource_get_client(res) != wc) continue;
1415 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1417 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1419 wl_pointer_send_leave(res, serial, surface);
1420 ec->pointer_enter_sent = EINA_FALSE;
1423 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
1425 ELOGF("Mouse", "Out. Event doesn't have timestamp. no need to send signal", NULL);
1429 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1432 struct wl_client *wc;
1433 struct wl_resource *res;
1436 E_Comp_Config *comp_conf = NULL;
1439 if (e_object_is_del(E_OBJECT(ec))) return;
1440 if (_e_comp_wl_check_block_input(ec)) return;
1442 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1443 if (!surface) return;
1445 wc = wl_resource_get_client(surface);
1446 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1450 x = wl_fixed_from_int(canvas_x - ec->client.x);
1451 y = wl_fixed_from_int(canvas_y - ec->client.y);
1454 comp_conf = e_comp_config_get();
1456 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1458 if (wl_resource_get_client(res) != wc) continue;
1459 if (!e_comp_wl_input_touch_check(res)) continue;
1460 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1463 if (comp_conf && comp_conf->input_log_enable)
1464 ELOGF("Touch", "Down (id: %d, time: %d, x:%d, y:%d, name:%20s)", ec, idx, timestamp, canvas_x - ec->client.x, canvas_y - ec->client.y, e_client_util_name_get(ec));
1466 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1470 if (comp_conf && comp_conf->input_log_enable)
1471 ELOGF("Touch", "Up (id: %d, time: %d, x:%d, y:%d, name:%20s)\n", ec, idx, timestamp, canvas_x - ec->client.x, canvas_y - ec->client.y, e_client_util_name_get(ec));
1473 wl_touch_send_up(res, serial, timestamp, idx);
1480 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1483 struct wl_client *wc;
1484 struct wl_resource *res;
1488 if (ec->cur_mouse_action) return;
1489 if (e_object_is_del(E_OBJECT(ec))) return;
1490 if (_e_comp_wl_check_block_input(ec)) return;
1492 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1493 if (!surface) return;
1495 wc = wl_resource_get_client(surface);
1497 x = wl_fixed_from_int(canvas_x - ec->client.x);
1498 y = wl_fixed_from_int(canvas_y - ec->client.y);
1500 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1502 if (wl_resource_get_client(res) != wc) continue;
1503 if (!e_comp_wl_input_touch_check(res)) continue;
1504 wl_touch_send_motion(res, timestamp, idx, x, y);
1509 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1511 struct wl_resource *res;
1512 struct wl_client *wc;
1516 if (ec->cur_mouse_action) return;
1517 if (e_object_is_del(E_OBJECT(ec))) return;
1518 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1519 if (!surface) return;
1521 wc = wl_resource_get_client(surface);
1522 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1524 if (!e_comp_wl_input_pointer_check(res)) continue;
1525 if (wl_resource_get_client(res) != wc) continue;
1526 wl_pointer_send_motion(res, timestamp,
1527 wl_fixed_from_int(x - ec->client.x),
1528 wl_fixed_from_int(y - ec->client.y));
1533 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1535 if (e_comp_wl->ptr.hide_tmr)
1537 if (cursor_timer_ec == ec)
1539 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1540 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1544 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1545 cursor_timer_ec = ec;
1546 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1551 cursor_timer_ec = ec;
1552 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1557 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1560 Evas_Event_Mouse_Move *ev;
1561 Evas_Device *dev = NULL;
1562 const char *dev_name;
1563 E_Comp_Config *comp_conf;
1567 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1568 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1570 if (!(ec = data)) return;
1571 if (e_object_is_del(E_OBJECT(ec))) return;
1572 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1573 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1574 if (!surface) return;
1576 if ((!need_send_motion) && (!need_send_released) && (e_client_visibility_get(ec) == E_VISIBILITY_FULLY_OBSCURED)) return;
1579 dev_name = evas_device_description_get(dev);
1581 comp_conf = e_comp_config_get();
1582 if (comp_conf && comp_conf->input_log_enable)
1583 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1584 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1585 e_client_util_name_get(ec), dev_name);
1587 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1589 if (!e_comp_wl->drag_client)
1591 e_comp_wl->touch.faked_ec = ec;
1592 if (e_comp_wl->touch.pressed & (1 << 0))
1594 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1596 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1597 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1598 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1602 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1606 if (!e_comp_wl->drag_client)
1608 if (_e_comp_wl_check_cursor_timer_needed(ec))
1610 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1614 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1615 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1617 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1619 if (_e_comp_wl_check_cursor_timer_needed(ec))
1620 _e_comp_wl_cursor_move_timer_control(ec);
1624 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1629 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1631 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1632 if (e_object_is_del(E_OBJECT(ec))) return;
1633 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1634 if (!surface) return;
1635 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1637 e_comp_wl->ptr.button = BTN_LEFT;
1639 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1643 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1645 E_Client *ec = data;
1646 Evas_Event_Mouse_Down *ev = event;
1647 Evas_Device *dev = NULL;
1648 const Evas_Device *seat_dev;
1649 const char *dev_name, *seat_name;
1650 E_Comp_Config *comp_conf = NULL;
1653 if (e_object_is_del(E_OBJECT(ec))) return;
1654 if (_e_comp_wl_check_block_input(ec)) return;
1657 dev_name = evas_device_description_get(dev);
1659 seat_dev = evas_device_parent_get(dev);
1660 seat_name = evas_device_name_get(seat_dev);
1662 comp_conf = e_comp_config_get();
1663 if (comp_conf && comp_conf->input_log_enable)
1664 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1665 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1666 dev_name, seat_name);
1668 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1670 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1672 e_comp_wl->touch.faked_ec = ec;
1675 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1676 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1677 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1679 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1680 e_comp_wl->touch.pressed |= (1 << 0);
1684 if (_e_comp_wl_check_cursor_timer_needed(ec))
1686 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1690 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1691 WL_POINTER_BUTTON_STATE_PRESSED);
1693 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1696 need_send_released = EINA_TRUE;
1700 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1702 E_Client *ec = data;
1703 Evas_Event_Mouse_Up *ev = event;
1704 Evas_Device *dev = NULL;
1705 const Evas_Device *seat_dev;
1706 const char *dev_name, *seat_name;;
1707 Evas_Event_Flags flags;
1708 E_Comp_Config *comp_conf = NULL;
1711 if (ec->cur_mouse_action) return;
1712 if (e_object_is_del(E_OBJECT(ec))) return;
1713 if (_e_comp_wl_check_block_input(ec)) return;
1715 if (!need_send_released)
1717 need_send_motion = EINA_TRUE;
1721 dev_name = evas_device_description_get(dev);
1723 seat_dev = evas_device_parent_get(dev);
1724 seat_name = evas_device_name_get(seat_dev);
1725 flags = evas_event_default_flags_get(evas);
1727 comp_conf = e_comp_config_get();
1728 if (comp_conf && comp_conf->input_log_enable)
1729 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1730 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1731 dev_name, seat_name);
1733 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1735 e_comp_wl->touch.pressed &= ~(1 << 0);
1737 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1738 e_comp_wl->touch.faked_ec = NULL;
1741 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1743 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1745 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1748 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1749 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1750 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1754 if (_e_comp_wl_check_cursor_timer_needed(ec))
1756 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1760 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1761 WL_POINTER_BUTTON_STATE_RELEASED);
1763 if (_e_comp_wl_check_cursor_timer_needed(ec))
1764 _e_comp_wl_cursor_move_timer_control(ec);
1768 need_send_released = EINA_FALSE;
1772 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1774 struct wl_resource *res;
1775 struct wl_client *wc;
1780 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1782 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1785 dir = -wl_fixed_from_int(abs(z));
1787 dir = wl_fixed_from_int(z);
1790 if (e_object_is_del(E_OBJECT(ec))) return;
1791 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1792 if (!surface) return;
1794 wc = wl_resource_get_client(surface);
1795 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1797 if (!e_comp_wl_input_pointer_check(res)) continue;
1798 if (wl_resource_get_client(res) != wc) continue;
1799 wl_pointer_send_axis(res, timestamp, axis, dir);
1804 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1807 Evas_Event_Mouse_Wheel *ev;
1810 if (!(ec = data)) return;
1811 if (ec->cur_mouse_action) return;
1812 if (e_object_is_del(E_OBJECT(ec))) return;
1813 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1814 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1815 if (!surface) return;
1817 if (!eina_list_count(e_comp_wl->ptr.resources))
1820 if (_e_comp_wl_check_cursor_timer_needed(ec))
1822 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1826 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1828 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1830 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1832 if (_e_comp_wl_check_cursor_timer_needed(ec))
1833 _e_comp_wl_cursor_move_timer_control(ec);
1838 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1840 E_Client *ec = data;
1841 Evas_Event_Multi_Down *ev = event;
1842 Evas_Device *dev = NULL;
1843 const Evas_Device *seat_dev;
1844 const char *dev_name, *seat_name;
1845 Evas_Device_Class dev_class;
1846 E_Comp_Config *comp_conf = NULL;
1849 if (e_object_is_del(E_OBJECT(ec))) return;
1850 if (_e_comp_wl_check_block_input(ec)) return;
1852 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1853 if (!surface) return;
1855 /* Do not deliver emulated single touch events to client */
1856 if (ev->device == 0) return;
1859 dev_name = evas_device_description_get(dev);
1860 e_comp_wl->touch.faked_ec = ec;
1862 seat_dev = evas_device_parent_get(dev);
1863 seat_name = evas_device_name_get(seat_dev);
1865 comp_conf = e_comp_config_get();
1866 if (comp_conf && comp_conf->input_log_enable)
1867 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1868 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1869 dev_name, seat_name);
1871 if (dev && dev_name)
1873 dev_class = evas_device_class_get(dev);
1874 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1875 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1878 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1879 e_comp_wl->touch.pressed |= (1 << ev->device);
1883 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1885 E_Client *ec = data;
1886 Evas_Event_Multi_Up *ev = event;
1887 Evas_Device *dev = NULL;
1888 const Evas_Device *seat_dev;
1889 const char *dev_name, *seat_name;
1890 Evas_Device_Class dev_class;
1891 Evas_Event_Flags flags;
1892 E_Comp_Config *comp_conf = NULL;
1895 if (e_object_is_del(E_OBJECT(ec))) return;
1896 if (_e_comp_wl_check_block_input(ec)) return;
1898 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1899 if (!surface) return;
1901 /* Do not deliver emulated single touch events to client */
1902 if (ev->device == 0) return;
1904 flags = evas_event_default_flags_get(evas);
1906 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1907 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1908 e_comp_wl->touch.faked_ec = NULL;
1910 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1913 dev_name = evas_device_description_get(dev);
1915 seat_dev = evas_device_parent_get(dev);
1916 seat_name = evas_device_name_get(seat_dev);
1918 comp_conf = e_comp_config_get();
1919 if (comp_conf && comp_conf->input_log_enable)
1920 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1921 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1922 dev_name, seat_name);
1924 if (dev && dev_name)
1926 dev_class = evas_device_class_get(dev);
1927 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1928 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1931 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1935 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1937 E_Client *ec = data;
1938 Evas_Event_Multi_Move *ev = event;
1939 Evas_Device *dev = NULL;
1940 const char *dev_name;
1941 Evas_Device_Class dev_class;
1944 if (e_object_is_del(E_OBJECT(ec))) return;
1945 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1946 if (!surface) return;
1948 /* Do not deliver emulated single touch events to client */
1949 if (ev->device == 0) return;
1951 e_comp_wl->touch.faked_ec = ec;
1953 if (e_comp_wl->touch.pressed & (1 << ev->device))
1956 if (dev && (dev_name = evas_device_description_get(dev)))
1958 dev_class = evas_device_class_get(dev);
1959 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1960 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1963 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1968 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1971 char *file, buff[PATH_MAX];
1978 n = (getpriority(PRIO_PROCESS, pid) + adj);
1982 setpriority(PRIO_PROCESS, pid, n);
1985 use_adj = EINA_TRUE;
1987 if (!do_child) return;
1989 files = ecore_file_ls("/proc");
1990 EINA_LIST_FREE(files, file)
1992 if (!isdigit(file[0]))
1995 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1996 if ((f = fopen(buff, "r")))
2000 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
2002 if (num_read == 2 && ppid == pid)
2003 _e_comp_wl_client_priority_adjust(pid2, set,
2005 adj_child, do_child);
2013 _e_comp_wl_client_priority_raise(E_Client *ec)
2015 if (!e_config->priority_control) return;
2016 if (ec->netwm.pid <= 0) return;
2017 if (ec->netwm.pid == getpid()) return;
2018 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
2019 e_config->priority - 1, -1,
2020 EINA_FALSE, EINA_TRUE, EINA_FALSE);
2024 _e_comp_wl_client_priority_normal(E_Client *ec)
2026 if (!e_config->priority_control) return;
2027 if (ec->netwm.pid <= 0) return;
2028 if (ec->netwm.pid == getpid()) return;
2029 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
2030 EINA_FALSE, EINA_TRUE, EINA_FALSE);
2034 _e_comp_wl_input_thread_send_keys()
2037 E_Comp_Wl_Key_Data *k;
2038 struct wl_resource *res;
2042 if (!e_comp_input_key->kbd.focused)
2047 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2048 t = ecore_time_unix_get();
2050 EINA_LIST_FOREACH(e_comp_input_key->kbd.focused, l, res)
2052 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2054 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2055 wl_keyboard_send_key(res, serial, t,
2056 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2062 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
2064 if (!ec) return EINA_FALSE;
2065 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2066 if (!ec->comp_data) return EINA_FALSE;
2068 ec->comp_data->on_focus_timer = NULL;
2070 e_input_thread_safe_call(_e_comp_wl_input_thread_send_keys, NULL, 0);
2076 _e_comp_wl_input_thread_focus_in(void *data)
2078 struct wl_resource *surface = NULL;
2079 struct wl_resource *res;
2080 struct wl_client *wc;
2083 EINA_SAFETY_ON_NULL_RETURN(data);
2084 surface = *(struct wl_resource **)data;
2086 wc = wl_resource_get_client(surface);
2088 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
2090 if (wl_resource_get_client(res) == wc)
2092 if (!eina_list_data_find(e_comp_input_key->kbd.focused, res))
2093 e_comp_input_key->kbd.focused = eina_list_append(e_comp_input_key->kbd.focused, res);
2097 if (!e_comp_input_key->kbd.focused)
2102 e_comp_input_key->kbd.focus = surface;
2103 e_comp_wl_input_keyboard_enter_send(surface);
2104 e_comp_wl_data_device_keyboard_focus_set();
2107 /* It is called in the following cases:
2108 * When a normal ec->frame has focus.
2109 * Or launching image ec is replaced to the real ec.
2112 e_comp_wl_feed_focus_in(E_Client *ec)
2117 if (e_object_is_del(E_OBJECT(ec))) return;
2118 if (ec->iconic) return;
2120 /* block spurious focus events */
2121 focused = e_client_focused_get();
2122 if ((focused) && (ec != focused)) return;
2124 /* raise client priority */
2125 _e_comp_wl_client_priority_raise(ec);
2127 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2128 if (!surface) return;
2130 INF("send focus in request to input thread. surface(%p)\n", surface);
2131 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_in, (void *)&surface, sizeof(struct wl_resource *));
2133 ec->comp_data->on_focus_timer =
2134 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2135 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2136 int rotation = ec->e.state.rot.ang.curr;
2137 e_pointer_rotation_set(e_comp->pointer, rotation);
2141 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2144 if (!(ec = data)) return;
2145 e_comp_wl_feed_focus_in(ec);
2149 _e_comp_wl_input_thread_focus_out(void *data)
2151 struct wl_resource *surface = NULL;
2152 struct wl_resource *res;
2154 E_Comp_Wl_Key_Data *k;
2158 EINA_SAFETY_ON_NULL_RETURN(data);
2160 surface = *(struct wl_resource **)data;
2162 /* update keyboard modifier state */
2163 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2164 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2166 if (!surface) return;
2168 if (!eina_list_count(e_comp_input_key->kbd.resources))
2173 /* send keyboard_leave to all keyboard resources */
2174 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2175 t = ecore_time_unix_get();
2177 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
2179 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2181 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2182 wl_keyboard_send_key(res, serial, t,
2183 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2185 wl_keyboard_send_leave(res, serial, surface);
2186 e_comp_input_key->kbd.focused =
2187 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
2192 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2195 if (!(ec = data)) return;
2197 if (!ec->comp_data) return;
2199 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2201 /* lower client priority */
2202 if (!e_object_is_del(data))
2203 _e_comp_wl_client_priority_normal(ec);
2205 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2206 INF("send focus out request to input thread. surface(%p)\n", surface);
2207 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_out, (void *)&surface, sizeof(struct wl_resource *));
2211 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2213 E_Client *ec = data;
2215 if (e_object_is_del(E_OBJECT(ec))) return;
2217 /* check for wayland pixmap */
2219 if (ec->comp_data->shell.configure_send)
2220 _e_comp_wl_configure_send(ec, 0, 1);
2222 ec->comp_data->maximize_pre = 0;
2226 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2228 E_Client *ec = data;
2230 if (e_object_is_del(E_OBJECT(ec))) return;
2232 /* check for wayland pixmap */
2234 if (ec->comp_data->shell.configure_send)
2235 _e_comp_wl_configure_send(ec, 0, 0);
2237 ec->comp_data->maximize_pre = 0;
2241 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2245 if (!(ec = data)) return;
2247 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2249 e_object_del(E_OBJECT(ec));
2251 _e_comp_wl_focus_check();
2253 /* TODO: Delete request send ??
2254 * NB: No such animal wrt wayland */
2258 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2262 if (!(ec = data)) return;
2264 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2267 if (ec->comp_data->reparented)
2268 e_client_comp_hidden_set(ec, EINA_TRUE);
2271 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2272 if (ec->visible) evas_object_hide(ec->frame);
2273 if (!ec->internal) e_object_del(E_OBJECT(ec));
2275 _e_comp_wl_focus_check();
2279 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2283 if (!(ec = data)) return;
2285 e_client_shell_ping(ec);
2289 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2294 if (!(ec = data)) return;
2295 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2296 if (ec->netwm.opacity == a) return;
2297 ec->netwm.opacity = a;
2298 ec->netwm.opacity_changed = EINA_TRUE;
2302 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2304 Eina_Rectangle *damage_rect = NULL;
2305 Eina_Rectangle *dmg = NULL;
2306 Eina_List *l = NULL;
2308 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2309 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2312 if (!buffer->tbm_surface) return;
2316 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2320 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2321 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2324 eina_rectangle_union(damage_rect, dmg);
2329 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2330 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2333 tbm_surface_internal_set_damage(buffer->tbm_surface,
2339 eina_rectangle_free(damage_rect);
2343 _e_comp_wl_client_evas_init(E_Client *ec)
2345 if (!ec || !ec->comp_data) return;
2346 if (ec->comp_data->evas_init) return;
2348 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2349 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2350 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2353 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2354 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2355 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2356 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2357 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2358 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2360 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2361 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2362 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2364 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2365 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2369 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2370 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2373 /* setup delete/kill callbacks */
2374 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2375 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2377 /* setup ping callback */
2378 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2379 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2381 ec->comp_data->evas_init = EINA_TRUE;
2385 _e_comp_wl_client_evas_deinit(E_Client *ec)
2387 if (!ec || !ec->comp_data) return;
2388 if (!ec->comp_data->evas_init) return;
2390 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2391 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2392 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2394 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2395 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2396 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2397 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2398 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2399 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2401 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2402 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2403 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2405 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2406 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2410 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2411 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2414 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2415 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2417 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2418 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2420 ec->comp_data->evas_init = EINA_FALSE;
2424 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2428 E_Comp_Screen *e_comp_screen;
2429 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2431 if (!e_comp) return ECORE_CALLBACK_RENEW;
2432 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2433 e_comp_screen = e_comp->e_comp_screen;
2435 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2437 if (!eout->config.enabled)
2439 e_comp_wl_output_remove(eout->id);
2443 switch (eout->config.rotation)
2446 transform = WL_OUTPUT_TRANSFORM_90;
2449 transform = WL_OUTPUT_TRANSFORM_180;
2452 transform = WL_OUTPUT_TRANSFORM_270;
2456 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2460 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2462 eout->config.geom.x, eout->config.geom.y,
2463 eout->config.geom.w, eout->config.geom.h,
2464 eout->info.size.w, eout->info.size.h,
2465 eout->config.mode.refresh, 0, transform))
2466 ERR("Could not initialize screen %s", eout->info.name);
2469 return ECORE_CALLBACK_RENEW;
2473 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2477 /* try to get the client from the object */
2478 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2479 return ECORE_CALLBACK_RENEW;
2481 /* check for client being deleted */
2482 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2484 /* check for wayland pixmap */
2485 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2486 return ECORE_CALLBACK_RENEW;
2488 /* if we have not setup evas callbacks for this client, do it */
2489 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2491 return ECORE_CALLBACK_RENEW;
2495 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2499 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2500 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2502 if (e_comp_wl->selection.target &&
2505 struct wl_resource *res;
2507 E_Client *ec = NULL;
2508 E_Client *legacy_target = e_comp_wl->selection.target;
2509 int device_id = e_comp_wl_data_current_device_id_get();
2513 e_comp_wl_data_current_device_id_set(ev->multi.device);
2515 else if (device_id != ev->multi.device)
2517 return ECORE_CALLBACK_RENEW;
2520 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2521 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2523 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2524 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2526 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2527 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2529 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2530 (ec != legacy_target))
2532 e_comp_wl_data_device_send_leave(legacy_target);
2533 e_comp_wl_data_device_send_enter(ec);
2536 if (e_comp_wl->drag)
2537 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2539 if (e_client_transform_core_enable_get(ec))
2541 int trans_x, trans_y;
2542 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2543 x = trans_x - ec->client.x;
2544 y = trans_y - ec->client.y;
2548 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2553 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2556 return ECORE_CALLBACK_RENEW;
2560 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2563 struct wl_resource *surface;
2564 struct wl_resource *res;
2565 struct wl_client *wc;
2567 E_Comp_Config *comp_conf;
2569 ec = e_comp_wl->ptr_constraints.ec;
2570 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2572 surface = e_comp_wl_client_surface_get(ec);
2573 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2575 wc = wl_resource_get_client(surface);
2577 comp_conf = e_comp_config_get();
2579 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2581 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2582 if (wl_resource_get_client(res) != wc) continue;
2584 if (comp_conf && comp_conf->input_log_enable)
2585 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2586 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2587 e_client_util_name_get(ec));
2589 zwp_relative_pointer_v1_send_relative_motion(res,
2591 (uint32_t)(ev->timestamp),
2592 wl_fixed_from_int(ev->dx),
2593 wl_fixed_from_int(ev->dy),
2594 wl_fixed_from_int(ev->dx_unaccel),
2595 wl_fixed_from_int(ev->dy_unaccel));
2598 return ECORE_CALLBACK_DONE;
2602 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2604 _e_comp_wl_touch_cancel();
2606 return ECORE_CALLBACK_PASS_ON;
2610 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2612 if (!ev) return ECORE_CALLBACK_PASS_ON;
2614 E_Zone *zone = ev->zone;
2616 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2617 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2619 if (!e_zone_is_displaying(zone))
2620 _e_comp_wl_touch_cancel();
2622 return ECORE_CALLBACK_PASS_ON;
2626 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2628 E_Client *ec = ev->ec;
2629 E_Comp_Wl_Buffer_Viewport *vp;
2631 if (!ec) return ECORE_CALLBACK_PASS_ON;
2632 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2633 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2634 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2635 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2637 vp = &ec->comp_data->scaler.buffer_viewport;
2638 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2640 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2642 return ECORE_CALLBACK_PASS_ON;
2646 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2648 E_Client *ec = ev->ec;
2649 E_Comp_Wl_Buffer_Viewport *vp;
2651 if (!ec) return ECORE_CALLBACK_PASS_ON;
2652 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2653 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2654 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2656 vp = &ec->comp_data->scaler.buffer_viewport;
2657 vp->wait_for_transform_change = 0;
2659 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2661 return ECORE_CALLBACK_PASS_ON;
2665 _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)
2667 E_Client *focused_ec;
2670 focused_ec = e_client_focused_get();
2671 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2673 rotation = focused_ec->e.state.rot.ang.curr;
2674 e_pointer_rotation_set(e_comp->pointer, rotation);
2676 return ECORE_CALLBACK_PASS_ON;
2680 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2683 Eina_Rectangle *window;
2688 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2690 if ((prev_w != state->bw) ||
2691 (prev_h != state->bh))
2693 ec->changes.buf_size = EINA_TRUE;
2696 if (e_comp_object_frame_exists(ec->frame)) return;
2697 window = &ec->comp_data->shell.window;
2698 if ((!ec->borderless) && /* FIXME temporarily added this check code
2699 * to prevent updating E_Client's size by frame */
2700 (window->x || window->y || window->w || window->h))
2702 e_comp_object_frame_geometry_set(ec->frame,
2704 (window->x + window->w) - state->bw,
2706 (window->y + window->h) - state->bh);
2709 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2713 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2715 E_Comp_Wl_Surface_State *state;
2718 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2719 state->buffer = NULL;
2723 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2725 state->new_attach = EINA_FALSE;
2726 state->buffer = NULL;
2727 state->buffer_destroy_listener.notify =
2728 _e_comp_wl_surface_state_cb_buffer_destroy;
2729 state->sx = state->sy = 0;
2731 state->input = eina_tiler_new(w, h);
2732 eina_tiler_tile_size_set(state->input, 1, 1);
2734 state->opaque = eina_tiler_new(w, h);
2735 eina_tiler_tile_size_set(state->opaque, 1, 1);
2737 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2738 state->buffer_viewport.buffer.scale = 1;
2739 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2740 state->buffer_viewport.surface.width = -1;
2741 state->buffer_viewport.changed = 0;
2743 e_presentation_time_container_init(&state->presentation_container);
2747 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2749 struct wl_resource *cb;
2750 Eina_Rectangle *dmg;
2752 EINA_LIST_FREE(state->frames, cb)
2753 wl_resource_destroy(cb);
2755 EINA_LIST_FREE(state->damages, dmg)
2756 eina_rectangle_free(dmg);
2758 EINA_LIST_FREE(state->buffer_damages, dmg)
2759 eina_rectangle_free(dmg);
2761 if (state->opaque) eina_tiler_free(state->opaque);
2762 state->opaque = NULL;
2764 if (state->input) eina_tiler_free(state->input);
2765 state->input = NULL;
2767 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2768 state->buffer = NULL;
2770 e_presentation_time_container_finish(&state->presentation_container);
2774 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2776 if (state->buffer == buffer) return;
2778 wl_list_remove(&state->buffer_destroy_listener.link);
2779 state->buffer = buffer;
2781 wl_signal_add(&state->buffer->destroy_signal,
2782 &state->buffer_destroy_listener);
2786 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2788 Eina_Rectangle *dmg;
2789 Eina_Bool placed = EINA_TRUE;
2793 E_Comp_Wl_Buffer *buffer;
2794 struct wl_resource *cb;
2796 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2797 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2802 if ((ec->internal) ||
2803 (cdata->shell.surface && state->new_attach))
2807 e_comp->new_clients++;
2808 ELOGF("COMP", "Unignore", ec);
2809 e_client_unignore(ec);
2813 /* buffer transform */
2814 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2817 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2819 /* when buffer is transformed, we have to apply the new evas-map */
2820 state->buffer_viewport.changed = EINA_TRUE;
2822 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2824 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2826 if (transform_change == vp->wait_for_transform_change)
2827 vp->wait_for_transform_change = 0;
2829 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2830 // triggered by E_CLIENT_HOOK calls at those file.
2831 zone = e_comp_zone_find_by_ec(ec);
2834 eout = e_output_find(zone->output_id);
2835 if (eout && eout->hwc)
2837 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2839 if (e_comp_is_on_overlay(ec))
2840 e_comp_hwc_client_end(ec, __FUNCTION__);
2846 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2847 cdata->scaler.buffer_viewport = state->buffer_viewport;
2849 if (state->new_attach)
2851 e_comp_wl_surface_attach(ec, state->buffer);
2854 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2855 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2857 _e_comp_wl_surface_state_buffer_set(state, NULL);
2859 if ((state->new_attach) ||
2860 (state->buffer_viewport.changed))
2862 _e_comp_wl_surface_state_size_update(ec, state);
2863 e_comp_wl_map_size_cal_from_viewport(ec);
2865 /* update the position */
2866 if (ec->changes.pos)
2868 e_comp_object_frame_xy_unadjust(ec->frame,
2878 if (ec->new_client) placed = ec->placed;
2880 if (!ec->lock_client_size)
2885 ec->client.w = state->bw;
2886 ec->client.h = state->bh;
2888 e_comp_object_frame_wh_adjust(ec->frame,
2889 ec->client.w, ec->client.h,
2891 e_client_size_set(ec, nw, nh);
2893 if ((w != ec->w) || (h != ec->h))
2895 ec->changes.size = 1;
2900 if (ec->changes.buf_size)
2902 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2903 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2904 ec->changes.buf_size = EINA_FALSE;
2906 if (ec->move_after_resize)
2908 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2909 ec->move_after_resize = EINA_FALSE;
2914 /* map or unmap ec */
2915 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2916 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2917 if (!pixmap_usable || hide_by_request)
2922 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2927 if ((cdata->sub.below_obj) &&
2928 (evas_object_visible_get(cdata->sub.below_obj)))
2930 evas_object_hide(cdata->sub.below_obj);
2938 if ((cdata->sub.below_obj) &&
2939 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2940 (evas_object_visible_get(ec->frame)))
2942 evas_object_show(cdata->sub.below_obj);
2946 if ((state->new_attach) ||
2947 (state->buffer_viewport.changed))
2949 if ((e_comp_wl->drag) &&
2950 (e_comp_wl->drag_client) &&
2951 (e_comp_wl->drag_client == ec))
2953 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
2955 e_drag_move(e_comp_wl->drag,
2957 e_comp_wl->drag->y);
2959 e_drag_resize(e_comp_wl->drag,
2960 state->bw, state->bh);
2962 else if ((cdata->shell.surface) &&
2963 (cdata->shell.configure))
2965 e_comp_wl_commit_sync_configure(ec);
2967 else if (!e_client_video_hw_composition_check(ec))
2969 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
2974 ec->placed = placed;
2975 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
2979 if (cdata->scaler.buffer_viewport.changed)
2980 e_comp_wl_map_apply(ec);
2982 /* resize transform object */
2983 if (ec->transformed)
2984 e_client_transform_update(ec);
2988 state->new_attach = EINA_FALSE;
2990 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
2992 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
2993 wl_resource_destroy(cb);
2996 /* insert state frame callbacks into comp_data->frames
2997 * NB: This clears state->frames list */
2998 cdata->frames = eina_list_merge(cdata->frames,
3000 state->frames = NULL;
3002 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3003 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3004 &state->presentation_container);
3006 buffer = e_pixmap_resource_get(ec->pixmap);
3008 /* put state damages into surface */
3011 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3012 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3014 if ((cdata->buffer_ref.buffer) &&
3015 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3016 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3018 e_comp_object_damage(ec->frame,
3020 cdata->buffer_ref.buffer->w,
3021 cdata->buffer_ref.buffer->h);
3026 Eina_List *damages = NULL;
3029 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3031 if (eina_list_count(state->buffer_damages))
3033 EINA_LIST_FREE(state->buffer_damages, dmg)
3036 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3037 e_comp_wl_output_buffer_transform_get(ec),
3039 dmg->x, dmg->y, dmg->w, dmg->h,
3040 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3041 damages = eina_list_append(damages, dmg);
3045 EINA_LIST_FREE(state->damages, dmg)
3046 damages = eina_list_append(damages, dmg);
3048 EINA_LIST_FREE(damages, dmg)
3050 /* not creating damage for ec that shows a underlay video */
3051 if (state->buffer_viewport.changed ||
3052 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3053 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3054 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3056 eina_rectangle_free(dmg);
3061 /* put state opaque into surface */
3062 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3065 Eina_Rectangle *rect;
3068 itr = eina_tiler_iterator_new(state->opaque);
3069 EINA_ITERATOR_FOREACH(itr, rect)
3073 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3074 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3075 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3079 eina_iterator_free(itr);
3082 /* put state input into surface */
3083 if ((state->input) &&
3084 (!eina_tiler_empty(state->input)) &&
3087 Eina_Tiler *src, *tmp;
3091 tmp = eina_tiler_new(sw, sh);
3092 eina_tiler_tile_size_set(tmp, 1, 1);
3094 eina_tiler_rect_add(tmp,
3095 &(Eina_Rectangle){0, 0, sw, sh});
3097 if ((src = eina_tiler_intersection(state->input, tmp)))
3099 Eina_Rectangle *rect;
3102 e_comp_object_input_objs_del(ec->frame);
3103 itr = eina_tiler_iterator_new(src);
3104 EINA_ITERATOR_FOREACH(itr, rect)
3106 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3107 ec, rect->x, rect->y, rect->w, rect->h,
3108 ec->w, ec->h, state->bw, state->bh);
3109 e_comp_object_input_area_set(ec->frame,
3114 eina_iterator_free(itr);
3115 eina_tiler_free(src);
3118 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3120 eina_tiler_free(tmp);
3122 /* clear input tiler */
3123 eina_tiler_clear(state->input);
3126 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3128 if ((cdata->video_client) &&
3130 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3131 (e_comp->wl_comp_data->available_hw_accel.underlay))
3133 e_pixmap_image_clear(ec->pixmap, 1);
3136 state->buffer_viewport.changed = 0;
3138 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3141 ec->exp_iconify.buffer_flush &&
3142 e_policy_visibility_client_is_iconic(ec))
3144 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3149 _e_comp_wl_surface_render_stop(E_Client *ec)
3151 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3152 //if ((!ec->internal) && (!e_comp_gl_get()))
3155 /* check if internal animation is running */
3156 if (e_comp_object_is_animating(ec->frame)) return;
3157 /* check if external animation is running */
3158 if (evas_object_data_get(ec->frame, "effect_running")) return;
3160 evas_object_hide(ec->frame);
3164 _e_input_thread_client_free(void *data)
3166 E_Input_Thread_Request_EClient_Data *ec_data = data;
3167 EINA_SAFETY_ON_NULL_RETURN(ec_data);
3169 INF("[input thread|%s] ec: %p, surface: %p\n", __func__, ec_data->ec, ec_data->wl_surface);
3173 e_comp_wl_client_surface_finish(E_Client *ec)
3175 struct wl_resource *res, *surface;
3176 struct wl_client *surface_client = NULL;
3179 surface = e_comp_wl_client_surface_get(ec);
3182 surface_client = wl_resource_get_client(surface);
3184 if (surface_client &&
3185 (ec == e_client_focused_get()))
3187 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
3189 if (wl_resource_get_client(res) ==
3191 e_comp_input_key->kbd.focused =
3192 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
3197 E_Input_Thread_Request_EClient_Data ec_free_data;
3198 memset(&ec_free_data, 0, sizeof(E_Input_Thread_Request_EClient_Data));
3199 ec_free_data.ec = ec;
3200 ec_free_data.wl_surface = ec->comp_data->wl_surface;
3202 INF("[e_comp_wl_client_surface_finish] surface: %p\n", ec_free_data.wl_surface);
3203 e_input_thread_safe_call(_e_input_thread_client_free, &ec_free_data, sizeof(E_Input_Thread_Request_EClient_Data));
3205 e_comp_wl_client_surface_set(ec, NULL);
3207 ec->comp_data->wl_surface = NULL;
3208 e_pixmap_win_id_del(ec->pixmap);
3210 _e_comp_wl_surface_render_stop(ec);
3211 e_object_del(E_OBJECT(ec));
3215 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3220 char proc[512], pname[512];
3223 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3225 h = fopen(proc, "r");
3228 len = fread(pname, sizeof(char), 512, h);
3230 pname[len - 1] = '\0';
3232 strncpy(pname, "NO NAME", sizeof(pname));
3238 strncpy(pname, "NO NAME", sizeof(pname));
3241 strncpy(name, pname, size);
3245 _e_comp_wl_pname_print(pid_t pid)
3248 char proc[512], pname[512];
3251 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3253 h = fopen(proc, "r");
3256 len = fread(pname, sizeof(char), 512, h);
3258 pname[len - 1] = '\0';
3260 strncpy(pname, "NO NAME", sizeof(pname));
3264 ELOGF("COMP", " |%s", NULL, pname);
3269 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3271 struct wl_client *client = data;
3272 E_Comp_Connected_Client_Info *cinfo;
3275 cinfo = wl_container_of(listener, cinfo, destroy);
3277 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3278 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3280 eai = e_appinfo_find_with_pid(cinfo->pid);
3281 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3284 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3286 wl_list_remove(&cinfo->destroy.link);
3287 eina_stringshare_del(cinfo->name);
3292 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3294 E_Comp_Connected_Client_Info *cinfo;
3296 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3297 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3299 cinfo->name = eina_stringshare_add(name);
3303 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3304 wl_client_add_destroy_listener(client, &cinfo->destroy);
3305 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3307 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3311 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3313 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3315 /* send configure */
3316 if (ec->comp_data->shell.configure_send)
3318 if (ec->comp_data->shell.surface)
3319 _e_comp_wl_configure_send(ec, 0, 0);
3322 e_comp_input_key->kbd.focus = ec->comp_data->surface;
3326 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3328 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3330 /* send configure */
3331 if (ec->comp_data->shell.configure_send)
3333 if (ec->comp_data->shell.surface)
3334 _e_comp_wl_configure_send(ec, 0, 0);
3337 _e_comp_wl_focus_check();
3339 if (e_comp_input_key->kbd.focus == ec->comp_data->surface)
3340 e_comp_input_key->kbd.focus = NULL;
3344 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3346 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3347 if (ec->keyboard_resizing) return;
3349 /* do nothing currently */
3354 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3356 if (e_object_is_del(E_OBJECT(ec))) return;
3357 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3359 e_comp_wl->resize.edges = 0;
3360 e_comp_wl->resize.resource = NULL;
3364 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3366 if (e_object_is_del(E_OBJECT(ec))) return;
3367 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3371 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3374 int ratio_w, ratio_h;
3376 phys_w = output->phys_width;
3377 phys_h = output->phys_height;
3379 if (e_config->configured_output_resolution.use)
3381 // change the configured physical size(mm) of the output
3382 if (output->w != res_w)
3384 ratio_w = res_w / output->w;
3385 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3388 if (output->h != res_h)
3390 ratio_h = res_h / output->h;
3391 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3394 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3397 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3398 NULL, res_w, res_h, phys_w, phys_h, pid);
3400 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3401 wl_output_send_scale(resource, output->scale);
3403 wl_output_send_geometry(resource, output->x, output->y,
3405 output->subpixel, output->make ?: "",
3406 output->model ?: "", output->transform);
3408 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3409 res_w, res_h, output->refresh);
3411 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3412 wl_output_send_done(resource);
3416 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3418 E_Comp_Wl_Output *output;
3420 if (!(output = wl_resource_get_user_data(resource))) return;
3422 output->resources = eina_list_remove(output->resources, resource);
3426 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3428 E_Comp_Wl_Output *output;
3429 struct wl_resource *resource;
3430 E_Appinfo *eai = NULL;
3434 if (!(output = data)) return;
3437 wl_resource_create(client, &wl_output_interface, version, id);
3440 wl_client_post_no_memory(client);
3444 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3445 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3447 output->resources = eina_list_append(output->resources, resource);
3449 wl_resource_set_implementation(resource, NULL, output,
3450 _e_comp_wl_cb_output_unbind);
3451 wl_resource_set_user_data(resource, output);
3453 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3454 if (e_config->configured_output_resolution.use)
3456 wl_client_get_credentials(client, &pid, NULL, NULL);
3459 res_w = e_config->configured_output_resolution.w;
3460 res_h = e_config->configured_output_resolution.h;
3464 eai = e_appinfo_find_with_pid(pid);
3467 res_w = e_config->configured_output_resolution.w;
3468 res_h = e_config->configured_output_resolution.h;
3472 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3474 res_w = e_config->configured_output_resolution.w;
3475 res_h = e_config->configured_output_resolution.h;
3479 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3488 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3492 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3495 Evas_GL *evasgl = NULL;
3496 Evas_GL_API *glapi = NULL;
3497 Evas_GL_Context *ctx = NULL;
3498 Evas_GL_Surface *sfc = NULL;
3499 Evas_GL_Config *cfg = NULL;
3501 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3503 if (!e_comp_gl_get()) return;
3505 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3506 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3508 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3509 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3511 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3512 * then we should get evas from ecore_evas.
3515 evas = e_comp->evas;
3517 evas = ecore_evas_get(e_comp->ee);
3519 evasgl = evas_gl_new(evas);
3520 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3522 glapi = evas_gl_api_get(evasgl);
3523 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3524 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3526 cfg = evas_gl_config_new();
3527 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3529 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3530 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3532 ctx = evas_gl_context_create(evasgl, NULL);
3533 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3535 res = evas_gl_make_current(evasgl, sfc, ctx);
3536 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3538 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3539 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3541 evas_gl_config_free(cfg);
3543 evas_gl->gl = evasgl;
3544 evas_gl->glapi = glapi;
3545 evas_gl->glsfc = sfc;
3546 evas_gl->glctx = ctx;
3548 e_comp_wl->evas_gl = evas_gl;
3550 /* for native surface */
3553 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3558 evas_gl_config_free(cfg);
3559 evas_gl_make_current(evasgl, NULL, NULL);
3560 evas_gl_context_destroy(evasgl, ctx);
3561 evas_gl_surface_destroy(evasgl, sfc);
3562 evas_gl_free(evasgl);
3569 _e_comp_wl_gl_popup_cb_close(void *data,
3570 Evas_Object *obj EINA_UNUSED,
3571 void *event_info EINA_UNUSED)
3573 evas_object_del(data);
3577 _e_comp_wl_gl_popup_cb_focus(void *data,
3578 Evas_Object *obj EINA_UNUSED,
3579 void *event_info EINA_UNUSED)
3581 elm_object_focus_set(data, EINA_TRUE);
3586 _e_comp_wl_gl_idle(void *data)
3590 /* show warning window to notify failure of gl init */
3593 Evas_Object *win, *bg, *popup, *btn;
3595 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3596 elm_win_title_set(win, "Compositor Warning");
3597 elm_win_autodel_set(win, EINA_TRUE);
3598 elm_win_borderless_set(win, EINA_TRUE);
3599 elm_win_role_set(win, "notification-low");
3600 elm_win_alpha_set(win, EINA_TRUE);
3602 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3603 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3604 elm_win_resize_object_add(win, bg);
3605 evas_object_color_set(bg, 125, 125, 125, 125);
3606 evas_object_show(bg);
3608 popup = elm_popup_add(win);
3609 elm_object_text_set(popup,
3610 _( "Your screen does not support OpenGL.<br>"
3611 "Falling back to software engine."));
3612 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3614 btn = elm_button_add(popup);
3615 elm_object_text_set(btn, "Close");
3616 elm_object_part_content_set(popup, "button1", btn);
3617 evas_object_show(btn);
3619 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3620 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3622 evas_object_show(popup);
3623 evas_object_show(win);
3627 return ECORE_CALLBACK_CANCEL;
3631 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3633 struct wl_client *client = data;
3639 wl_client_get_credentials(client, &pid, &uid, &gid);
3641 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3643 _e_comp_wl_pname_print(pid);
3644 _e_comp_wl_pname_get(pid, name, sizeof(name));
3645 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3649 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3651 char buf[1024] = {0, };
3653 vsnprintf(buf, 1024, fmt, args);
3657 DBG("[libds] %s", buf);
3660 INF("[libds] %s", buf);
3663 ERR("[libds] %s", buf);
3671 _e_comp_wl_display_create(void)
3674 E_Comp_Wl_Data *wl_cdata;
3679 /* create new compositor data */
3680 if (!(comp = E_NEW(E_Comp_Data, 1)))
3682 ERR("Could not create compositor data: %m");
3685 wl_cdata = &comp->base;
3687 /* set compositor wayland data */
3688 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3690 g_mutex_init(&connection_mutex);
3692 /* try to create a wayland display */
3693 if (!(wl_cdata->wl.disp = wl_display_create()))
3695 ERR("Could not create a Wayland display: %m");
3699 /* try to setup wayland socket */
3700 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3702 ERR("Could not create Wayland display socket: %m");
3703 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3707 res = e_comp_socket_init(name);
3708 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3709 PRCTL("[Winsys] change permission and create sym link for %s", name);
3711 /* set wayland display environment variable */
3712 e_env_set("WAYLAND_DISPLAY", name);
3714 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3715 /* wl_cdata->output.scale = e_scale; */
3717 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3719 if (!e_compositor_init(wl_cdata->wl.disp))
3721 ERR("Failed to initialize compositor");
3725 comp->client_created.notify = _e_comp_wl_cb_client_created;
3726 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3728 if (!e_comp_wl_subsurfaces_init())
3730 ERR("Failed to init_subsurfaces");
3731 goto subsurfaces_err;
3734 /* initialize shm mechanism */
3735 wl_display_init_shm(wl_cdata->wl.disp);
3737 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3739 /* try to init data manager */
3740 if (!e_comp_wl_data_manager_init())
3742 ERR("Could not initialize data manager");
3746 /* try to init input */
3747 if (!e_comp_wl_input_init())
3749 ERR("Could not initialize input");
3753 if (e_comp_gl_get())
3754 _e_comp_wl_gl_init(NULL);
3756 /* get the wayland display loop */
3757 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3759 /* get the file descriptor of the wayland event loop */
3760 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3762 /* create a listener for wayland main loop events */
3764 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3765 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3766 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3767 _e_comp_wl_cb_prepare, wl_cdata);
3769 /* add awake handler */
3770 ecore_main_awake_handler_add(_e_comp_wl_cb_awake, NULL);
3775 e_comp_wl_data_manager_shutdown();
3777 e_comp_wl_subsurfaces_shutdown();
3779 wl_list_remove(&comp->client_created.link);
3781 e_env_unset("WAYLAND_DISPLAY");
3783 wl_display_destroy(wl_cdata->wl.disp);
3785 g_mutex_clear(&connection_mutex);
3791 _e_comp_wl_gl_shutdown(void)
3793 if (!e_comp_wl->evas_gl) return;
3795 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3797 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3798 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3799 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3800 evas_gl_free(e_comp_wl->evas_gl->gl);
3802 E_FREE(e_comp_wl->evas_gl);
3805 /* public functions */
3808 * Creates and initializes a Wayland compositor with ecore.
3809 * Registers callback handlers for keyboard and mouse activity
3810 * and other client events.
3812 * @returns true on success, false if initialization failed.
3815 e_comp_wl_init(void)
3817 TRACE_DS_BEGIN(COMP_WL:INIT);
3819 /* try to create a wayland compositor */
3820 if (!_e_comp_wl_display_create())
3822 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3827 e_comp_wl_shell_init();
3829 #ifdef HAVE_WAYLAND_TBM
3830 e_comp_wl_tbm_init();
3832 e_comp_wl_remote_surface_init();
3836 e_comp_wl_screenshooter_init();
3838 if (!e_comp_wl_video_init())
3839 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3841 e_comp_wl_viewport_init();
3842 e_comp_wl_capture_init();
3843 e_comp_wl_renderer_init();
3844 _e_comp_wl_move_resize_init();
3845 e_presentation_time_init();
3846 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3848 e_blur_manager_init();
3850 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3851 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3853 /* add event handlers to catch E events */
3854 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3855 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3856 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3857 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3858 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3859 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3860 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3861 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3862 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3864 /* add hooks to catch e_client events */
3865 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3866 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3867 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3868 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3869 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3876 e_comp_wl_deferred_job(void)
3878 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3881 /* internal functions */
3883 e_comp_wl_shutdown(void)
3885 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3887 e_comp_wl_subsurfaces_shutdown();
3889 E_FREE_LIST(handlers, ecore_event_handler_del);
3890 E_FREE_LIST(hooks, e_client_hook_del);
3891 _e_comp_wl_gl_shutdown();
3893 e_presentation_time_shutdown();
3894 e_comp_wl_renderer_shutdown();
3895 e_comp_wl_capture_shutdown();
3896 e_comp_wl_viewport_shutdown();
3897 e_comp_wl_video_shutdown();
3898 e_comp_wl_screenshooter_shutdown();
3900 e_comp_wl_remote_surface_shutdown();
3902 e_pixmap_shutdown();
3904 e_wtz_shell_shutdown();
3905 e_comp_wl_shell_shutdown();
3906 e_comp_wl_input_shutdown();
3908 wl_list_remove(&comp->client_created.link);
3910 /* delete awake handler */
3911 ecore_main_awake_handler_del(_e_comp_wl_cb_awake);
3914 e_comp->wl_comp_data = NULL;
3918 E_Comp_Wl_Output *output;
3920 if (e_comp_wl->screenshooter.global)
3921 wl_global_destroy(e_comp_wl->screenshooter.global);
3923 EINA_LIST_FREE(e_comp_wl->outputs, output)
3925 if (output->id) eina_stringshare_del(output->id);
3926 if (output->make) eina_stringshare_del(output->make);
3927 if (output->model) eina_stringshare_del(output->model);
3931 /* delete fd handler */
3932 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3934 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3935 cursor_timer_ec = NULL;
3937 /* free allocated data structure */
3943 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3945 e_object_unref(E_OBJECT(ev->ec));
3950 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3953 ev = E_NEW(E_Event_Client, 1);
3956 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3958 /* set usable early because shell module checks this */
3959 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3960 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3962 e_pixmap_resource_set(ec->pixmap, buffer);
3963 e_pixmap_dirty(ec->pixmap);
3964 e_pixmap_refresh(ec->pixmap);
3966 e_comp_wl_map_size_cal_from_buffer(ec);
3967 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
3969 /* wm-policy module uses it */
3970 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
3973 e_object_ref(E_OBJECT(ec));
3974 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
3975 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
3979 e_comp_wl_surface_commit(E_Client *ec)
3984 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
3985 if (!e_comp_object_damage_exists(ec->frame))
3987 if ((ec->comp_data->video_client) ||
3988 (!e_client_video_hw_composition_check(ec)))
3989 e_pixmap_image_clear(ec->pixmap, 1);
3992 ignored = ec->ignored;
3994 if (e_comp_wl_subsurface_order_commit(ec))
3996 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
3997 e_comp_wl_subsurface_restack(topmost);
3998 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4001 ec->ignored = ignored;
4003 if (ec->is_cursor && ec->visible)
4005 /* ignore cursor changes during resize/move I guess */
4006 if (!e_client_action_get())
4008 if (e_comp->pointer)
4010 x = e_comp->pointer->hot.x;
4011 y = e_comp->pointer->hot.y;
4013 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4019 static E_Comp_Wl_Output *
4020 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4023 E_Comp_Wl_Output *output;
4025 EINA_LIST_FOREACH(outputs, l, output)
4027 if (!strcmp(output->id, id))
4035 * Initializes information about one display output.
4037 * Adds or updates the given data about a single display output,
4038 * with an id matching the provided id.
4040 * @param id identification of output to be added or changed
4041 * @param make manufacturer name of the display output
4042 * @param model model name of the display output
4043 * @param x output's top left corner x coordinate
4044 * @param y output's top left corner y coordinate
4045 * @param w output's width in pixels
4046 * @param h output's height in pixels
4047 * @param pw output's physical width in millimeters
4048 * @param ph output's physical height in millimeters
4049 * @param refresh output's refresh rate in mHz
4050 * @param subpixel output's subpixel layout
4051 * @param transform output's rotation and/or mirror transformation
4053 * @returns True if a display output object could be added or updated
4056 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4057 int x, int y, int w, int h, int pw, int ph,
4058 unsigned int refresh, unsigned int subpixel,
4059 unsigned int transform)
4061 E_Comp_Wl_Output *output;
4063 struct wl_resource *resource;
4065 /* retrieve named output; or create it if it doesn't exist */
4066 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4069 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4071 if (id) output->id = eina_stringshare_add(id);
4073 output->make = eina_stringshare_add(make);
4075 output->make = eina_stringshare_add("unknown");
4077 output->model = eina_stringshare_add(model);
4079 output->model = eina_stringshare_add("unknown");
4081 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4084 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4085 2, output, _e_comp_wl_cb_output_bind);
4087 output->resources = NULL;
4088 output->scale = e_scale;
4091 /* update the output details */
4096 output->phys_width = pw;
4097 output->phys_height = ph;
4098 output->refresh = refresh;
4099 output->subpixel = subpixel;
4100 output->transform = transform;
4102 if (output->scale <= 0)
4103 output->scale = e_scale;
4105 /* if we have bound resources, send updates */
4106 EINA_LIST_FOREACH(output->resources, l2, resource)
4108 wl_output_send_geometry(resource,
4109 output->x, output->y,
4111 output->phys_height,
4113 output->make ?: "", output->model ?: "",
4116 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4117 wl_output_send_scale(resource, output->scale);
4119 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4120 output->w, output->h, output->refresh);
4122 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4123 wl_output_send_done(resource);
4130 e_comp_wl_output_remove(const char *id)
4132 E_Comp_Wl_Output *output;
4134 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4137 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4139 /* wl_global_destroy(output->global); */
4141 /* eina_stringshare_del(output->id); */
4142 /* eina_stringshare_del(output->make); */
4143 /* eina_stringshare_del(output->model); */
4150 _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)
4152 struct wl_resource *res;
4154 uint32_t serial, keycode;
4155 struct wl_client *wc = NULL;
4156 E_Comp_Config *comp_conf = NULL;
4157 const char *device_name = NULL;
4159 keycode = (ev->keycode - 8);
4161 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4163 comp_conf = e_comp_config_get();
4165 if (ec && ec->comp_data)
4167 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4170 wc = wl_resource_get_client(surface);
4173 if (e_config->key_input_ttrace_enable)
4175 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4176 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4179 EINA_LIST_FOREACH(key_list, l, res)
4181 if (wl_resource_get_client(res) != wc) continue;
4183 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4184 if (!e_input_thread_mode_get())
4186 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4187 device_name = ecore_device_name_get(ev->dev);
4193 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4194 device_name = e_device_name_get(dev);
4198 if (comp_conf && comp_conf->input_log_enable)
4199 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4201 wl_keyboard_send_key(res, serial, ev->timestamp,
4206 if (e_config->key_input_ttrace_enable)
4209 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4214 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4216 E_Client *ec = NULL;
4218 E_Comp_Wl_Key_Data *end, *k;
4220 if (ev->window != e_comp->ee_win)
4225 keycode = (ev->keycode - 8);
4226 if (!(e_comp_wl = e_comp->wl_comp_data))
4231 #ifndef E_RELEASE_BUILD
4232 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4233 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4234 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4235 eina_streq(ev->key, "BackSpace"))
4241 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4243 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4245 /* ignore server-generated key repeats */
4246 if (k->key == keycode)
4252 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4254 ec = e_client_focused_get();
4255 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4256 if (ec && ec->comp_data && surface)
4258 if (e_comp_input_key->kbd.focused)
4260 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_input_key->kbd.focused, ec);
4262 /* A key only sent to clients is added to the list */
4263 e_comp_input_key->kbd.keys.size = (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4265 if (!(k = wl_array_add(&e_comp_input_key->kbd.keys, sizeof(*k))))
4267 DBG("wl_array_add: Out of memory\n");
4276 /* update modifier state */
4277 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4283 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4285 E_Client *ec = NULL;
4286 uint32_t keycode, delivered_key;
4287 E_Comp_Wl_Key_Data *end, *k;
4289 if (ev->window != e_comp->ee_win)
4294 keycode = (ev->keycode - 8);
4296 if (!(e_comp_wl = e_comp->wl_comp_data))
4301 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4302 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4304 if (k->key == keycode)
4311 e_comp_input_key->kbd.keys.size =
4312 (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4314 /* 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) */
4315 if ((delivered_key) ||
4316 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4318 ec = e_client_focused_get();
4320 if (e_comp_input_key->kbd.focused)
4322 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_input_key->kbd.focused, ec);
4326 /* update modifier state */
4327 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4333 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4335 Eina_Bool res = EINA_FALSE;
4337 if (type == ECORE_EVENT_KEY_DOWN)
4339 res = e_comp_wl_key_down(ev, dev);
4341 else if (type == ECORE_EVENT_KEY_UP)
4343 res = e_comp_wl_key_up(ev, dev);
4350 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4353 struct wl_client *wc;
4354 uint32_t serial, btn;
4355 struct wl_resource *res;
4356 E_Comp_Config *comp_conf = NULL;
4358 if (ec->cur_mouse_action || e_comp_wl->drag)
4360 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4361 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4365 case 1: btn = BTN_LEFT; break;
4366 case 2: btn = BTN_MIDDLE; break;
4367 case 3: btn = BTN_RIGHT; break;
4368 default: btn = button_id; break;
4371 e_comp_wl->ptr.button = btn;
4372 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4373 if (!surface) return EINA_FALSE;
4375 if (!eina_list_count(e_comp_wl->ptr.resources))
4378 wc = wl_resource_get_client(surface);
4379 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4381 comp_conf = e_comp_config_get();
4383 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4385 if (wl_resource_get_client(res) != wc) continue;
4386 if (!e_comp_wl_input_pointer_check(res)) continue;
4387 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4389 if (comp_conf && comp_conf->input_log_enable)
4390 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4392 wl_pointer_send_button(res, serial, timestamp, btn, state);
4399 e_comp_wl_touch_cancel(void)
4401 _e_comp_wl_touch_cancel();
4404 E_API E_Comp_Wl_Hook *
4405 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4409 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4410 ch = E_NEW(E_Comp_Wl_Hook, 1);
4411 if (!ch) return NULL;
4412 ch->hookpoint = hookpoint;
4414 ch->data = (void*)data;
4415 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4420 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4423 if (_e_comp_wl_hooks_walking == 0)
4425 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4429 _e_comp_wl_hooks_delete++;
4432 E_API E_Comp_Wl_Pid_Hook *
4433 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4435 E_Comp_Wl_Pid_Hook *ch;
4437 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4439 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4440 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4442 ch->hookpoint = hookpoint;
4444 ch->data = (void*)data;
4445 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4451 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4454 if (_e_comp_wl_pid_hooks_walking == 0)
4456 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4460 _e_comp_wl_pid_hooks_delete++;
4463 E_API E_Comp_Wl_Intercept_Hook *
4464 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4466 E_Comp_Wl_Intercept_Hook *ch;
4468 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4469 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4470 if (!ch) return NULL;
4471 ch->hookpoint = hookpoint;
4473 ch->data = (void*)data;
4474 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4479 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4482 if (_e_comp_wl_intercept_hooks_walking == 0)
4484 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4488 _e_comp_wl_intercept_hooks_delete++;
4492 e_comp_wl_shell_surface_ready(E_Client *ec)
4496 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4500 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4502 e_config->use_cursor_timer = !!enabled;
4504 if (e_config->use_cursor_timer)
4506 if (!e_pointer_is_hidden(e_comp->pointer))
4508 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4513 if (e_comp_wl->ptr.hide_tmr)
4515 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4516 e_comp_wl->ptr.hide_tmr = NULL;
4518 cursor_timer_ec = NULL;
4520 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4523 if (e_pointer_is_hidden(e_comp->pointer))
4525 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4531 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4533 EINA_SAFETY_ON_NULL_RETURN(wc);
4534 EINA_SAFETY_ON_NULL_RETURN(dev);
4536 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4540 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4542 EINA_SAFETY_ON_NULL_RETURN(wc);
4543 EINA_SAFETY_ON_NULL_RETURN(dev);
4545 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4549 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4551 struct wl_resource *res;
4552 struct wl_client *wc;
4554 uint32_t serial, wl_keycode;
4555 enum wl_keyboard_key_state state;
4556 E_Comp_Config *comp_conf = NULL;
4557 const char *dev_name = NULL;
4559 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4560 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4561 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4563 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4564 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4566 wl_keycode = keycode - 8;
4567 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4569 wc = wl_resource_get_client(surface);
4570 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4571 if (!time) time = e_util_timestamp_get();
4572 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4573 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4575 comp_conf = e_comp_config_get();
4576 e_keyrouter_event_surface_send(ec, keycode);
4578 if (e_config->key_input_ttrace_enable)
4580 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4581 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4584 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4586 if (wl_resource_get_client(res) != wc) continue;
4587 if (!e_input_thread_mode_get())
4591 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4592 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4596 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4603 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4604 dev_name = e_device_name_get(dev);
4608 if (comp_conf && comp_conf->input_log_enable)
4609 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4612 wl_keyboard_send_key(res, serial, time,
4616 if (e_config->key_input_ttrace_enable)
4619 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4626 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4628 struct wl_resource *res;
4629 struct wl_client *wc;
4631 uint32_t serial, wl_keycode, cancel_keycode;
4632 E_Comp_Config *comp_conf = NULL;
4633 struct xkb_keymap *keymap = NULL;
4635 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4636 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4637 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4639 keymap = e_comp_input_key->xkb.keymap;
4640 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4642 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4643 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4645 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4646 if (cancel_keycode == XKB_KEYCODE_INVALID)
4648 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4652 EINA_SAFETY_ON_TRUE_RETURN_VAL(cancel_keycode < 8, EINA_FALSE);
4654 cancel_keycode = cancel_keycode - 8;
4656 wl_keycode = keycode - 8;
4657 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4659 wc = wl_resource_get_client(surface);
4660 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4661 if (!time) time = e_util_timestamp_get();
4663 comp_conf = e_comp_config_get();
4664 e_keyrouter_event_surface_send(ec, keycode);
4666 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4668 if (wl_resource_get_client(res) != wc) continue;
4669 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4670 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4672 if (comp_conf && comp_conf->input_log_enable)
4673 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4674 wl_keyboard_send_key(res, serial, time,
4675 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4676 wl_keyboard_send_key(res, serial, time,
4677 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4678 wl_keyboard_send_key(res, serial, time,
4679 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4687 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)
4689 struct wl_client *wc;
4691 E_Devicemgr_Input_Device *device = NULL;
4693 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4694 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4695 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4697 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4698 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4700 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4702 wc = wl_resource_get_client(surface);
4703 if (!time) time = e_util_timestamp_get();
4704 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4708 _e_comp_wl_send_event_device(wc, time, dev, serial);
4709 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4713 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4714 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4717 x = x + ec->client.x;
4718 y = y + ec->client.y;
4720 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4726 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)
4728 E_Devicemgr_Input_Device *device;
4730 struct wl_client *wc;
4732 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4733 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4734 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4736 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4737 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4739 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4741 wc = wl_resource_get_client(surface);
4742 if (!time) time = e_util_timestamp_get();
4743 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4747 _e_comp_wl_send_event_device(wc, time, dev, serial);
4748 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4752 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4753 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4756 x = x + ec->client.x;
4757 y = y + ec->client.y;
4759 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4765 e_comp_wl_touch_cancel_send(E_Client *ec)
4767 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4768 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4769 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4771 _e_comp_wl_send_touch_cancel(ec);
4777 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4780 struct wl_client *wc;
4782 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4783 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4784 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4786 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4787 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4789 wc = wl_resource_get_client(surface);
4790 if (!time) time = e_util_timestamp_get();
4791 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4793 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4794 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4797 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4798 WL_POINTER_BUTTON_STATE_PRESSED);
4800 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4801 WL_POINTER_BUTTON_STATE_RELEASED);
4807 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4810 struct wl_client *wc;
4812 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4813 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4814 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4816 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4817 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4819 wc = wl_resource_get_client(surface);
4820 if (!time) time = e_util_timestamp_get();
4821 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4823 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4824 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4826 x = x + ec->client.x;
4827 y = y + ec->client.y;
4829 _e_comp_wl_send_mouse_move(ec, x, y, time);
4835 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4838 struct wl_client *wc;
4840 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4841 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4842 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4844 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4845 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4847 wc = wl_resource_get_client(surface);
4848 if (!time) time = e_util_timestamp_get();
4849 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4851 if (_e_comp_wl_check_cursor_timer_needed(ec))
4853 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4857 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4858 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4860 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4862 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4864 if (_e_comp_wl_check_cursor_timer_needed(ec))
4865 _e_comp_wl_cursor_move_timer_control(ec);
4872 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4875 struct wl_client *wc;
4876 struct wl_resource *res;
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4880 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4882 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4883 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4885 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4886 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4888 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4889 wc = wl_resource_get_client(surface);
4890 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4891 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4893 if (!e_comp_wl_input_pointer_check(res)) continue;
4894 if (wl_resource_get_client(res) != wc) continue;
4896 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4897 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4899 wl_pointer_send_enter(res, serial, surface,
4900 wl_fixed_from_int(x),
4901 wl_fixed_from_int(y));
4902 ec->pointer_enter_sent = EINA_TRUE;
4904 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4910 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4913 struct wl_client *wc;
4914 struct wl_resource *res;
4917 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4918 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4919 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4920 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4921 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4922 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4924 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4925 wc = wl_resource_get_client(surface);
4926 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4927 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4929 if (!e_comp_wl_input_pointer_check(res)) continue;
4930 if (wl_resource_get_client(res) != wc) continue;
4932 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4933 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4935 wl_pointer_send_leave(res, serial, surface);
4936 ec->pointer_enter_sent = EINA_FALSE;
4938 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
4944 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)
4946 Evas_Event_Mouse_In ev_in;
4949 if (ec->pointer_enter_sent) return;
4951 ev_in.buttons = buttons;
4959 ev_in.modifiers = modifiers;
4960 ev_in.locks = locks;
4961 ev_in.timestamp = timestamp;
4962 ev_in.event_flags = event_flags;
4965 ev_in.event_src = event_src;
4967 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
4971 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)
4973 Evas_Event_Mouse_Out ev_out;
4976 if (!ec->pointer_enter_sent) return;
4978 ev_out.buttons = buttons;
4980 ev_out.output.x = x;
4981 ev_out.output.y = y;
4982 ev_out.canvas.x = x;
4983 ev_out.canvas.y = y;
4986 ev_out.modifiers = modifiers;
4987 ev_out.locks = locks;
4988 ev_out.timestamp = timestamp;
4989 ev_out.event_flags = event_flags;
4992 ev_out.event_src = event_src;
4994 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
4998 e_comp_wl_cursor_hide(E_Client *ec)
5000 struct wl_resource *res;
5001 struct wl_client *wc;
5005 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5007 if (e_comp_wl->ptr.hide_tmr)
5009 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5010 e_comp_wl->ptr.hide_tmr = NULL;
5012 cursor_timer_ec = NULL;
5014 if (!ec) return EINA_FALSE;
5015 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5016 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5017 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5019 wc = wl_resource_get_client(surface);
5020 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5021 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5023 if (!e_comp_wl_input_pointer_check(res)) continue;
5024 if (wl_resource_get_client(res) != wc) continue;
5025 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5026 wl_pointer_send_leave(res, serial, surface);
5027 ec->pointer_enter_sent = EINA_FALSE;
5033 /* surface to buffer
5034 * - width : surface width
5035 * - height : surface height
5036 * - transform: buffer transform
5037 * - scale : buffer scale
5039 * - width : screen width
5040 * - height : screen height
5041 * - transform: output transform
5042 * - scale : output scale
5044 static E_Util_Transform_Matrix
5045 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5047 E_Util_Transform_Matrix m;
5049 e_util_transform_matrix_load_identity(&m);
5051 if (transform & 0x4)
5053 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5054 e_util_transform_matrix_flip_x(&m);
5055 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5058 switch (transform & 0x3)
5060 case WL_OUTPUT_TRANSFORM_90:
5061 e_util_transform_matrix_translate(&m, -width, 0, 0);
5062 e_util_transform_matrix_rotation_z(&m, 270);
5064 case WL_OUTPUT_TRANSFORM_180:
5065 e_util_transform_matrix_translate(&m, -width, -height, 0);
5066 e_util_transform_matrix_rotation_z(&m, 180);
5068 case WL_OUTPUT_TRANSFORM_270:
5069 e_util_transform_matrix_translate(&m, 0, -height, 0);
5070 e_util_transform_matrix_rotation_z(&m, 90);
5076 e_util_transform_matrix_scale(&m, scale, scale, 1);
5081 /* surface to buffer
5082 * - surface width, surface height, buffer transform, buffer scale
5084 * - screen width, screen height, output transform, output scale
5087 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5089 E_Util_Transform_Matrix m;
5090 E_Util_Transform_Vertex v;
5092 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5094 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5095 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5096 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5100 * - buffer width, buffer height, buffer transform, buffer scale
5103 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5105 E_Util_Transform_Matrix m;
5106 E_Util_Transform_Vertex v;
5109 if (transform != 0 || scale > 1)
5111 tw = ((transform % 2) ? height : width) / scale;
5112 th = ((transform % 2) ? width : height) / scale;
5120 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5121 m = e_util_transform_matrix_inverse_get(&m);
5123 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5124 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5125 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5128 /* surface to buffer
5129 * - surface width, surface height, buffer transform, buffer scale
5131 * - screen width, screen height, output transform, output scale
5134 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5135 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5137 E_Util_Transform_Matrix m;
5138 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5139 E_Util_Transform_Rect_Vertex sv;
5141 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5143 sv = e_util_transform_rect_to_vertices(&sr);
5144 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5145 sr = e_util_transform_vertices_to_rect(&sv);
5154 * - buffer width, buffer height, buffer transform, buffer scale
5157 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5158 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5160 E_Util_Transform_Matrix m;
5161 E_Util_Transform_Rect br = {bx, by, bw, bh};
5162 E_Util_Transform_Rect_Vertex bv;
5165 if (transform != 0 || scale > 1)
5167 tw = ((transform % 2) ? height : width) / scale;
5168 th = ((transform % 2) ? width : height) / scale;
5176 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5177 m = e_util_transform_matrix_inverse_get(&m);
5179 bv = e_util_transform_rect_to_vertices(&br);
5180 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5181 br = e_util_transform_vertices_to_rect(&bv);
5189 EINTERN E_Comp_Wl_Output*
5190 e_comp_wl_output_find(E_Client *ec)
5193 E_Comp_Wl_Output *output;
5195 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5197 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5199 if (output->transform % 2)
5201 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5202 ec->y < output->x || ec->y >= (output->x + output->w))
5207 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5208 ec->y < output->y || ec->y >= (output->y + output->h))
5218 EINTERN Eina_Array *
5219 e_comp_wl_output_find_all(E_Client *ec)
5221 E_Comp_Wl_Output *output;
5222 Eina_Array *outputs;
5225 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5227 outputs = eina_array_new(4);
5231 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5233 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5234 output->x, output->y, output->w, output->h))
5236 eina_array_push(outputs, output);
5240 if (eina_array_count(outputs) == 0)
5242 eina_array_free(outputs);
5249 // --------------------------------------------------------
5250 // tizen_move_resize
5251 // --------------------------------------------------------
5253 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5260 E_Client_Pending_Geometry *geo;
5263 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5264 if (ec->fullscreen || ec->maximized) goto err;
5266 geo = E_NEW(E_Client_Pending_Geometry, 1);
5269 geo->serial = serial;
5275 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5276 ec->surface_sync.wait_commit = EINA_TRUE;
5281 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5288 e_comp_wl_commit_sync_configure(E_Client *ec)
5291 E_Client_Pending_Geometry *geo;
5293 Eina_Bool match_size = EINA_FALSE;
5300 if (!ec || !ec->frame) goto ret;
5301 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5304 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5305 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5307 if (eina_list_count(ec->surface_sync.pending_geometry))
5309 Eina_List *ll = NULL;
5310 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5314 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5319 if ((geo->w == bw) && (geo->h == bh))
5321 match_size = EINA_TRUE;
5326 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5333 if ((config.w != ec->w) || (config.h != ec->h))
5335 e_client_size_set(ec, config.w, config.h);
5336 ec->changes.size = EINA_TRUE;
5340 // FIXME: The geometry of the client would be better to be calculated
5341 // at e_desk or at e_desk_area. So the position(x,y) of the client
5342 // should be calcuated at the e_desk or at the e_desk_area.
5344 desk = e_comp_desk_find_by_ec(ec);
5347 ec->client.x = desk->geom.x + config.x;
5348 ec->client.y = desk->geom.y + config.y;
5352 ec->client.x = config.x;
5353 ec->client.y = config.y;
5356 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5358 e_client_pos_set(ec, ec->client.x, ec->client.y);
5360 ec->changes.pos = 1;
5364 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5368 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5369 ec->surface_sync.wait_commit = EINA_FALSE;
5371 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5373 // rollback wait_commit if there are pending requests remained
5374 if (eina_list_count(ec->surface_sync.pending_geometry))
5375 ec->surface_sync.wait_commit = EINA_TRUE;
5380 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);
5387 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5388 struct wl_resource *res_moveresize)
5390 wl_resource_destroy(res_moveresize);
5394 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5395 struct wl_resource *res_moveresize,
5396 struct wl_resource *surface,
5403 /* to be implemented */
5406 int cur_w = 0, cur_h = 0;
5408 ec = e_client_from_surface_resource(surface);
5411 pending = e_client_pending_geometry_has(ec);
5412 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5413 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);
5417 if ((cur_w == w) && (cur_h == h))
5419 e_client_pos_set(ec, x, y);
5420 ec->changes.pos = 1;
5426 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5430 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5433 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5435 _tz_move_resize_iface_cb_destroy,
5436 _tz_move_resize_iface_cb_set_geometry,
5440 _tz_moveresize_cb_bind(struct wl_client *client,
5441 void *data EINA_UNUSED,
5445 struct wl_resource *res_moveresize;
5447 res_moveresize = wl_resource_create(client,
5448 &tizen_move_resize_interface,
5451 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5454 wl_resource_set_implementation(res_moveresize,
5455 &_tz_move_resize_iface,
5461 ERR("Could not create tizen_move_resize_interface res: %m");
5462 wl_client_post_no_memory(client);
5466 _e_comp_wl_move_resize_init(void)
5468 if (!e_comp_wl) return;
5469 if (!e_comp_wl->wl.disp) return;
5471 if (!wl_global_create(e_comp_wl->wl.disp,
5472 &tizen_move_resize_interface,
5475 _tz_moveresize_cb_bind))
5477 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5484 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5486 E_Comp_Wl_Output *output;
5487 pid_t output_pid = 0;
5488 Eina_List *l = NULL, *l2 = NULL;
5489 struct wl_resource *resource = NULL;
5491 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5493 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5494 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5495 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5497 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5499 /* if we have bound resources, send updates */
5500 EINA_LIST_FOREACH(output->resources, l2, resource)
5502 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5503 if (output_pid != pid) continue;
5505 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5507 // send output information to the client
5508 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5516 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5518 _e_comp_wl_surface_state_init(state, w, h);
5522 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5524 _e_comp_wl_surface_state_commit(ec, state);
5528 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5530 _e_comp_wl_hook_call(hookpoint, ec);
5534 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5536 _e_comp_wl_surface_state_finish(state);
5540 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5542 _e_comp_wl_surface_state_buffer_set(state, buffer);
5546 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5547 int sx, int sy, int *dx, int *dy)
5551 case WL_OUTPUT_TRANSFORM_NORMAL:
5555 case WL_OUTPUT_TRANSFORM_FLIPPED:
5556 *dx = width - sx, *dy = sy;
5558 case WL_OUTPUT_TRANSFORM_90:
5559 *dx = height - sy, *dy = sx;
5561 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5562 *dx = height - sy, *dy = width - sx;
5564 case WL_OUTPUT_TRANSFORM_180:
5565 *dx = width - sx, *dy = height - sy;
5567 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5568 *dx = sx, *dy = height - sy;
5570 case WL_OUTPUT_TRANSFORM_270:
5571 *dx = sy, *dy = width - sx;
5573 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5583 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5586 int tx1, ty1, tx2, ty2;
5587 int width_from_buffer, height_from_buffer;
5589 switch (vp->buffer.transform)
5591 case WL_OUTPUT_TRANSFORM_90:
5592 case WL_OUTPUT_TRANSFORM_270:
5593 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5594 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5595 width_from_buffer = bh / vp->buffer.scale;
5596 height_from_buffer = bw / vp->buffer.scale;
5599 width_from_buffer = bw / vp->buffer.scale;
5600 height_from_buffer = bh / vp->buffer.scale;
5604 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5608 x2 = width_from_buffer;
5609 y2 = height_from_buffer;
5613 x1 = wl_fixed_to_int(vp->buffer.src_x);
5614 y1 = wl_fixed_to_int(vp->buffer.src_y);
5615 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5616 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5619 buffer_transform(width_from_buffer, height_from_buffer,
5620 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5621 buffer_transform(width_from_buffer, height_from_buffer,
5622 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5624 out->x = (tx1 <= tx2) ? tx1 : tx2;
5625 out->y = (ty1 <= ty2) ? ty1 : ty2;
5626 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5627 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5631 * Convert given four coordinates to elements of rectangle
5632 * @in p[4] Coordinates to be converted
5633 * @out rect x, y, width, and height
5634 * transform Angle which represents TDM_TRANSFORM of rectangle
5635 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5636 * 1. The given coordinates are not represented by rectangle.
5637 * 2. All angles except for 0, 90, 180, 270.
5640 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5642 Eina_Bool ret = EINA_FALSE;
5644 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))
5647 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5650 *rotation = TDM_TRANSFORM_NORMAL;
5653 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5657 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5660 *rotation = TDM_TRANSFORM_180;
5663 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5668 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))
5671 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5674 *rotation = TDM_TRANSFORM_90;
5677 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5681 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5684 *rotation = TDM_TRANSFORM_270;
5687 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5697 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5702 for (i = 0; i < 4; i++)
5703 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5705 if (!_coords_to_rectangle_convert(p, out, rotation))
5707 DBG("Cannot convert given coords to rectangle.\n"
5708 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5709 p[0].x, p[0].y, p[1].x, p[1].y,
5710 p[2].x, p[2].y, p[3].x, p[3].y);
5718 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5720 int trans_rotation, flip;
5722 trans_rotation = transform & 0x3;
5723 flip = transform & 0x4;
5725 return (flip + (trans_rotation + rotation) % 4);
5729 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5737 if (e_comp_wl_subsurface_check(ec))
5738 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5745 out->w = ec->comp_data->width_from_viewport;
5746 out->w = (out->w + 1) & ~1;
5747 out->h = ec->comp_data->height_from_viewport;
5749 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5750 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5754 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5756 E_Comp_Wl_Buffer *buffer;
5757 E_Comp_Wl_Buffer_Viewport *vp;
5759 enum wl_output_transform buffer_transform;
5760 unsigned int rotation;
5761 Eina_Bool res = EINA_FALSE;
5763 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5765 if (e_object_is_del(E_OBJECT(ec)))
5768 vp = &ec->comp_data->scaler.buffer_viewport;
5770 if (buffer_viewport)
5772 buffer = ec->comp_data->buffer_ref.buffer;
5773 /* Getting a viewport of buffer needs geometry of buffer. */
5777 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5780 if ((output_viewport) || (transform))
5782 m = e_client_map_get(ec);
5784 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5786 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5791 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5792 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5793 * Since buffer.transform isn't applied using evas_map,
5794 * it has to be taken into account here to apply buffer.transform
5795 * and rotation of e_client_transform together. */
5797 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5799 *transform = (unsigned int)buffer_transform;
5807 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5809 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5810 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5812 /* Must be called with valid comp_data */
5813 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5815 if ((ec->comp_data->role_name == NULL) ||
5816 (ec->comp_data->role_name == role_name) ||
5817 (strcmp(ec->comp_data->role_name, role_name) == 0))
5819 ec->comp_data->role_name = role_name;
5825 wl_resource_post_error(error_resource, error_code,
5826 "Cannot assign role %s to wl_surface@%d,"
5827 " already has role %s\n",
5829 ec->comp_data->wl_surface ?
5830 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5831 ec->comp_data->role_name);
5837 EINTERN const char *
5838 e_comp_wl_surface_role_get(E_Client *ec)
5840 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5841 return ec->comp_data ? ec->comp_data->role_name : NULL;
5844 EINTERN struct wl_resource *
5845 e_comp_wl_client_surface_get(E_Client *ec)
5847 struct wl_resource *surface = NULL;
5848 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5849 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5851 g_mutex_lock(&ec->comp_data->surface_mutex);
5852 surface = ec->comp_data->surface;
5853 g_mutex_unlock(&ec->comp_data->surface_mutex);
5858 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5860 EINA_SAFETY_ON_NULL_RETURN(ec);
5861 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5863 g_mutex_lock(&ec->comp_data->surface_mutex);
5864 ec->comp_data->surface = surface;
5865 g_mutex_unlock(&ec->comp_data->surface_mutex);
5869 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5871 return e_compositor_util_client_from_surface_resource(surface_resource);
5875 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5877 if (!ec->comp_data->mapped)
5879 if (ec->comp_data->shell.surface &&
5880 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5882 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5888 if (ec->comp_data->mapped)
5890 /* will be unmapped. so run capture */
5891 e_comp_wl_remote_surface_image_save(ec);
5895 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5897 ec->comp_data->pending.sx = sx;
5898 ec->comp_data->pending.sy = sy;
5899 ec->comp_data->pending.new_attach = EINA_TRUE;
5901 e_client_fps_update(ec);
5905 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5907 if (ec->comp_data->pending.opaque)
5908 eina_tiler_clear(ec->comp_data->pending.opaque);
5912 eina_tiler_union(ec->comp_data->pending.opaque, region);
5914 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5918 ec->argb = EINA_FALSE;
5919 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5921 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5922 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5930 ec->argb = EINA_TRUE;
5931 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5933 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5934 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5940 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5942 if (ec->comp_data->pending.input)
5943 eina_tiler_clear(ec->comp_data->pending.input);
5947 if (eina_tiler_empty(region))
5949 ELOGF("COMP", " |unset input rect", NULL);
5950 e_comp_object_input_objs_del(ec->frame);
5951 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
5954 eina_tiler_union(ec->comp_data->pending.input, region);
5958 eina_tiler_rect_add(ec->comp_data->pending.input,
5959 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
5964 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
5966 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
5970 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
5972 E_Comp_Wl_Subsurf_Data *sdata;
5977 if (ec->comp_data->frames)
5979 ec->comp_data->frames =
5980 eina_list_remove(ec->comp_data->frames, callback_resource);
5983 if (ec->comp_data->pending.frames)
5985 ec->comp_data->pending.frames =
5986 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
5989 sdata = ec->comp_data->sub.data;
5990 if ((sdata) && (sdata->cached.frames))
5992 sdata->cached.frames =
5993 eina_list_remove(sdata->cached.frames, callback_resource);
5998 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6000 if (e_object_is_del(E_OBJECT(ec))) return;
6002 if (e_comp_wl_remote_surface_commit(ec)) return;
6004 e_comp_wl_surface_commit(ec);
6006 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6010 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6012 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6013 ec->comp_data->sub.data = sub;
6015 /* set subsurface client properties */
6016 ec->borderless = EINA_TRUE;
6017 ec->argb = EINA_TRUE;
6018 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6019 ec->lock_border = EINA_TRUE;
6020 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6021 ec->netwm.state.skip_taskbar = EINA_TRUE;
6022 ec->netwm.state.skip_pager = EINA_TRUE;
6023 ec->border_size = 0;
6024 ec->lock_user_location = 0;
6025 ec->lock_client_location = 0;
6026 ec->lock_user_size = 0;
6027 ec->lock_client_size = 0;
6028 ec->lock_client_stacking = 0;
6029 ec->lock_user_maximize = 0;
6030 ec->lock_client_maximize = 0;
6031 ec->changes.need_maximize = 0;
6032 ec->maximized = E_MAXIMIZE_NONE;
6035 ec->new_client = ec->netwm.ping = EINA_TRUE;
6036 e_comp->new_clients++;
6037 e_client_unignore(ec);
6039 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6040 * It's not for subsurface. */
6041 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6045 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6047 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6050 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6052 sub->parent = parent;
6056 layer = e_client_layer_get(parent);
6057 if (layer > E_LAYER_BOTTOM)
6058 e_client_layer_set(ec, layer);
6061 if (parent->comp_data)
6063 /* append this client to the parents subsurface list */
6064 parent->comp_data->sub.list_pending =
6065 eina_list_append(parent->comp_data->sub.list_pending, ec);
6066 parent->comp_data->sub.list_changed = EINA_TRUE;
6071 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6073 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6074 E_Client *parent = sub->parent;
6076 parent->comp_data->sub.list =
6077 eina_list_remove(parent->comp_data->sub.list, ec);
6078 parent->comp_data->sub.list_pending =
6079 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6080 parent->comp_data->sub.below_list =
6081 eina_list_remove(parent->comp_data->sub.below_list, ec);
6082 parent->comp_data->sub.below_list_pending =
6083 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6089 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)
6091 sub->resource = subsurface_resource;
6092 sub->cached_buffer_ref.buffer = NULL;
6093 sub->synchronized = EINA_TRUE;
6094 sub->parent = parent;
6095 sub->remote_surface.offscreen_parent = offscreen_parent;
6096 if (offscreen_parent)
6097 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6099 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6101 _e_comp_wl_client_subsurface_set(ec, sub);
6102 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6104 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6108 e_comp_wl_client_subsurface_finish(E_Client *ec)
6110 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6113 e_comp_wl_client_subsurface_parent_unset(ec);
6115 e_comp_wl_surface_state_finish(&sub->cached);
6116 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6118 ec->comp_data->sub.data = NULL;
6122 e_comp_wl_client_evas_init(E_Client *ec)
6124 EINA_SAFETY_ON_NULL_RETURN(ec);
6126 _e_comp_wl_client_evas_init(ec);
6130 e_comp_wl_client_evas_deinit(E_Client *ec)
6132 EINA_SAFETY_ON_NULL_RETURN(ec);
6134 _e_comp_wl_client_evas_deinit(ec);
6138 e_comp_wl_focus_check(void)
6140 _e_comp_wl_focus_check();
6144 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6151 if ((parent->comp_data) && (parent->comp_data->sub.data))
6152 parent = parent->comp_data->sub.data->parent;