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_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1293 Evas_Event_Mouse_In *ev;
1294 struct wl_resource *res;
1295 struct wl_client *wc;
1298 E_Comp_Config *comp_conf;
1299 E_Client *prev_ptr_ec;
1303 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1304 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1306 if (!(ec = data)) return;
1307 if (e_object_is_del(E_OBJECT(ec))) return;
1308 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1309 if (!surface) return;
1311 prev_ptr_ec = e_comp_wl->ptr.ec;
1314 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1315 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1318 e_comp_wl->ptr.ec = ec;
1320 comp_conf = e_comp_config_get();
1321 if (comp_conf && comp_conf->input_log_enable)
1322 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1323 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1324 e_client_util_name_get(ec));
1326 if (_e_comp_wl_check_cursor_timer_needed(ec))
1328 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1332 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1333 wc = wl_resource_get_client(surface);
1334 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1335 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1337 if (!e_comp_wl_input_pointer_check(res)) continue;
1338 if (wl_resource_get_client(res) != wc) continue;
1340 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1342 wl_pointer_send_enter(res, serial, surface,
1343 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1344 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1345 ec->pointer_enter_sent = EINA_TRUE;
1348 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1352 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1355 Evas_Event_Mouse_Out *ev;
1356 struct wl_resource *res;
1357 struct wl_client *wc;
1360 Eina_Bool inside_check;
1361 E_Comp_Config *comp_conf;
1365 if (!(ec = data)) return;
1366 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1367 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1368 if (ec->cur_mouse_action && inside_check) return;
1369 if (e_object_is_del(E_OBJECT(e_comp))) return;
1370 if (e_comp_wl->ptr.ec == ec)
1371 e_comp_wl->ptr.ec = NULL;
1372 if (e_object_is_del(E_OBJECT(ec))) return;
1374 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1375 if (!surface) return;
1377 comp_conf = e_comp_config_get();
1378 if (comp_conf && comp_conf->input_log_enable)
1379 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1380 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1381 e_client_util_name_get(ec));
1383 if (_e_comp_wl_check_cursor_timer_needed(ec))
1385 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1389 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1391 wc = wl_resource_get_client(surface);
1392 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1393 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1395 if (!e_comp_wl_input_pointer_check(res)) continue;
1396 if (wl_resource_get_client(res) != wc) continue;
1397 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1399 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1401 wl_pointer_send_leave(res, serial, surface);
1402 ec->pointer_enter_sent = EINA_FALSE;
1404 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
1408 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1411 struct wl_client *wc;
1412 struct wl_resource *res;
1415 E_Comp_Config *comp_conf = NULL;
1418 if (e_object_is_del(E_OBJECT(ec))) return;
1419 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1420 if (!surface) return;
1422 wc = wl_resource_get_client(surface);
1423 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1427 x = wl_fixed_from_int(canvas_x - ec->client.x);
1428 y = wl_fixed_from_int(canvas_y - ec->client.y);
1431 comp_conf = e_comp_config_get();
1433 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1435 if (wl_resource_get_client(res) != wc) continue;
1436 if (!e_comp_wl_input_touch_check(res)) continue;
1437 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1440 if (comp_conf && comp_conf->input_log_enable)
1441 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));
1443 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1447 if (comp_conf && comp_conf->input_log_enable)
1448 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));
1450 wl_touch_send_up(res, serial, timestamp, idx);
1457 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1460 struct wl_client *wc;
1461 struct wl_resource *res;
1465 if (ec->cur_mouse_action) return;
1466 if (e_object_is_del(E_OBJECT(ec))) return;
1467 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1468 if (!surface) return;
1470 wc = wl_resource_get_client(surface);
1472 x = wl_fixed_from_int(canvas_x - ec->client.x);
1473 y = wl_fixed_from_int(canvas_y - ec->client.y);
1475 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1477 if (wl_resource_get_client(res) != wc) continue;
1478 if (!e_comp_wl_input_touch_check(res)) continue;
1479 wl_touch_send_motion(res, timestamp, idx, x, y);
1484 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1486 struct wl_resource *res;
1487 struct wl_client *wc;
1491 if (ec->cur_mouse_action) return;
1492 if (e_object_is_del(E_OBJECT(ec))) return;
1493 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1494 if (!surface) return;
1496 wc = wl_resource_get_client(surface);
1497 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1499 if (!e_comp_wl_input_pointer_check(res)) continue;
1500 if (wl_resource_get_client(res) != wc) continue;
1501 wl_pointer_send_motion(res, timestamp,
1502 wl_fixed_from_int(x - ec->client.x),
1503 wl_fixed_from_int(y - ec->client.y));
1508 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1510 if (e_comp_wl->ptr.hide_tmr)
1512 if (cursor_timer_ec == ec)
1514 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1515 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1519 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1520 cursor_timer_ec = ec;
1521 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1526 cursor_timer_ec = ec;
1527 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1532 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1535 Evas_Event_Mouse_Move *ev;
1536 Evas_Device *dev = NULL;
1537 const char *dev_name;
1538 E_Comp_Config *comp_conf;
1542 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1543 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1545 if (!(ec = data)) return;
1546 if (e_object_is_del(E_OBJECT(ec))) return;
1547 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1548 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1549 if (!surface) return;
1551 if ((!need_send_motion) && (!need_send_released) && (e_client_visibility_get(ec) == E_VISIBILITY_FULLY_OBSCURED)) return;
1554 dev_name = evas_device_description_get(dev);
1556 comp_conf = e_comp_config_get();
1557 if (comp_conf && comp_conf->input_log_enable)
1558 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1559 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1560 e_client_util_name_get(ec), dev_name);
1562 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1564 if (!e_comp_wl->drag_client)
1566 e_comp_wl->touch.faked_ec = ec;
1567 if (e_comp_wl->touch.pressed & (1 << 0))
1569 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1571 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1572 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1573 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1577 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1581 if (!e_comp_wl->drag_client)
1583 if (_e_comp_wl_check_cursor_timer_needed(ec))
1585 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1589 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1590 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1592 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1594 if (_e_comp_wl_check_cursor_timer_needed(ec))
1595 _e_comp_wl_cursor_move_timer_control(ec);
1599 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1604 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1606 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1607 if (e_object_is_del(E_OBJECT(ec))) return;
1608 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1609 if (!surface) return;
1610 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1612 e_comp_wl->ptr.button = BTN_LEFT;
1614 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1618 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1620 E_Client *ec = data;
1621 Evas_Event_Mouse_Down *ev = event;
1622 Evas_Device *dev = NULL;
1623 const Evas_Device *seat_dev;
1624 const char *dev_name, *seat_name;
1625 E_Comp_Config *comp_conf = NULL;
1628 if (e_object_is_del(E_OBJECT(ec))) return;
1631 dev_name = evas_device_description_get(dev);
1633 seat_dev = evas_device_parent_get(dev);
1634 seat_name = evas_device_name_get(seat_dev);
1636 comp_conf = e_comp_config_get();
1637 if (comp_conf && comp_conf->input_log_enable)
1638 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1639 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1640 dev_name, seat_name);
1642 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1644 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1646 e_comp_wl->touch.faked_ec = ec;
1649 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1650 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1651 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1653 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1654 e_comp_wl->touch.pressed |= (1 << 0);
1658 if (_e_comp_wl_check_cursor_timer_needed(ec))
1660 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1664 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1665 WL_POINTER_BUTTON_STATE_PRESSED);
1667 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1670 need_send_released = EINA_TRUE;
1674 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1676 E_Client *ec = data;
1677 Evas_Event_Mouse_Up *ev = event;
1678 Evas_Device *dev = NULL;
1679 const Evas_Device *seat_dev;
1680 const char *dev_name, *seat_name;;
1681 Evas_Event_Flags flags;
1682 E_Comp_Config *comp_conf = NULL;
1685 if (ec->cur_mouse_action) return;
1686 if (e_object_is_del(E_OBJECT(ec))) return;
1688 if (!need_send_released)
1690 need_send_motion = EINA_TRUE;
1694 dev_name = evas_device_description_get(dev);
1696 seat_dev = evas_device_parent_get(dev);
1697 seat_name = evas_device_name_get(seat_dev);
1698 flags = evas_event_default_flags_get(evas);
1700 comp_conf = e_comp_config_get();
1701 if (comp_conf && comp_conf->input_log_enable)
1702 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1703 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1704 dev_name, seat_name);
1706 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1708 e_comp_wl->touch.pressed &= ~(1 << 0);
1710 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1711 e_comp_wl->touch.faked_ec = NULL;
1714 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1716 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1718 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1721 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1722 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1723 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1727 if (_e_comp_wl_check_cursor_timer_needed(ec))
1729 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1733 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1734 WL_POINTER_BUTTON_STATE_RELEASED);
1736 if (_e_comp_wl_check_cursor_timer_needed(ec))
1737 _e_comp_wl_cursor_move_timer_control(ec);
1741 need_send_released = EINA_FALSE;
1745 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1747 struct wl_resource *res;
1748 struct wl_client *wc;
1753 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1755 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1758 dir = -wl_fixed_from_int(abs(z));
1760 dir = wl_fixed_from_int(z);
1763 if (e_object_is_del(E_OBJECT(ec))) return;
1764 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1765 if (!surface) return;
1767 wc = wl_resource_get_client(surface);
1768 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1770 if (!e_comp_wl_input_pointer_check(res)) continue;
1771 if (wl_resource_get_client(res) != wc) continue;
1772 wl_pointer_send_axis(res, timestamp, axis, dir);
1777 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1780 Evas_Event_Mouse_Wheel *ev;
1783 if (!(ec = data)) return;
1784 if (ec->cur_mouse_action) return;
1785 if (e_object_is_del(E_OBJECT(ec))) return;
1786 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1787 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1788 if (!surface) return;
1790 if (!eina_list_count(e_comp_wl->ptr.resources))
1793 if (_e_comp_wl_check_cursor_timer_needed(ec))
1795 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1799 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1801 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1803 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1805 if (_e_comp_wl_check_cursor_timer_needed(ec))
1806 _e_comp_wl_cursor_move_timer_control(ec);
1811 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1813 E_Client *ec = data;
1814 Evas_Event_Multi_Down *ev = event;
1815 Evas_Device *dev = NULL;
1816 const Evas_Device *seat_dev;
1817 const char *dev_name, *seat_name;
1818 Evas_Device_Class dev_class;
1819 E_Comp_Config *comp_conf = NULL;
1822 if (e_object_is_del(E_OBJECT(ec))) return;
1823 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1824 if (!surface) return;
1826 /* Do not deliver emulated single touch events to client */
1827 if (ev->device == 0) return;
1830 dev_name = evas_device_description_get(dev);
1831 e_comp_wl->touch.faked_ec = ec;
1833 seat_dev = evas_device_parent_get(dev);
1834 seat_name = evas_device_name_get(seat_dev);
1836 comp_conf = e_comp_config_get();
1837 if (comp_conf && comp_conf->input_log_enable)
1838 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1839 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1840 dev_name, seat_name);
1842 if (dev && dev_name)
1844 dev_class = evas_device_class_get(dev);
1845 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1846 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1849 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1850 e_comp_wl->touch.pressed |= (1 << ev->device);
1854 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1856 E_Client *ec = data;
1857 Evas_Event_Multi_Up *ev = event;
1858 Evas_Device *dev = NULL;
1859 const Evas_Device *seat_dev;
1860 const char *dev_name, *seat_name;
1861 Evas_Device_Class dev_class;
1862 Evas_Event_Flags flags;
1863 E_Comp_Config *comp_conf = NULL;
1866 if (e_object_is_del(E_OBJECT(ec))) return;
1867 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1868 if (!surface) return;
1870 /* Do not deliver emulated single touch events to client */
1871 if (ev->device == 0) return;
1873 flags = evas_event_default_flags_get(evas);
1875 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1876 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1877 e_comp_wl->touch.faked_ec = NULL;
1879 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1882 dev_name = evas_device_description_get(dev);
1884 seat_dev = evas_device_parent_get(dev);
1885 seat_name = evas_device_name_get(seat_dev);
1887 comp_conf = e_comp_config_get();
1888 if (comp_conf && comp_conf->input_log_enable)
1889 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1890 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1891 dev_name, seat_name);
1893 if (dev && dev_name)
1895 dev_class = evas_device_class_get(dev);
1896 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1897 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1900 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1904 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1906 E_Client *ec = data;
1907 Evas_Event_Multi_Move *ev = event;
1908 Evas_Device *dev = NULL;
1909 const char *dev_name;
1910 Evas_Device_Class dev_class;
1913 if (e_object_is_del(E_OBJECT(ec))) return;
1914 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1915 if (!surface) return;
1917 /* Do not deliver emulated single touch events to client */
1918 if (ev->device == 0) return;
1920 e_comp_wl->touch.faked_ec = ec;
1922 if (e_comp_wl->touch.pressed & (1 << ev->device))
1925 if (dev && (dev_name = evas_device_description_get(dev)))
1927 dev_class = evas_device_class_get(dev);
1928 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1929 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1932 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1937 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1940 char *file, buff[PATH_MAX];
1947 n = (getpriority(PRIO_PROCESS, pid) + adj);
1951 setpriority(PRIO_PROCESS, pid, n);
1954 use_adj = EINA_TRUE;
1956 if (!do_child) return;
1958 files = ecore_file_ls("/proc");
1959 EINA_LIST_FREE(files, file)
1961 if (!isdigit(file[0]))
1964 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1965 if ((f = fopen(buff, "r")))
1969 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1971 if (num_read == 2 && ppid == pid)
1972 _e_comp_wl_client_priority_adjust(pid2, set,
1974 adj_child, do_child);
1982 _e_comp_wl_client_priority_raise(E_Client *ec)
1984 if (!e_config->priority_control) return;
1985 if (ec->netwm.pid <= 0) return;
1986 if (ec->netwm.pid == getpid()) return;
1987 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1988 e_config->priority - 1, -1,
1989 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1993 _e_comp_wl_client_priority_normal(E_Client *ec)
1995 if (!e_config->priority_control) return;
1996 if (ec->netwm.pid <= 0) return;
1997 if (ec->netwm.pid == getpid()) return;
1998 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1999 EINA_FALSE, EINA_TRUE, EINA_FALSE);
2003 _e_comp_wl_input_thread_send_keys()
2006 E_Comp_Wl_Key_Data *k;
2007 struct wl_resource *res;
2011 if (!e_comp_input_key->kbd.focused)
2016 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2017 t = ecore_time_unix_get();
2019 EINA_LIST_FOREACH(e_comp_input_key->kbd.focused, l, res)
2021 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2023 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2024 wl_keyboard_send_key(res, serial, t,
2025 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2031 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
2033 if (!ec) return EINA_FALSE;
2034 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2035 if (!ec->comp_data) return EINA_FALSE;
2037 ec->comp_data->on_focus_timer = NULL;
2039 e_input_thread_safe_call(_e_comp_wl_input_thread_send_keys, NULL, 0);
2045 _e_comp_wl_input_thread_focus_in(void *data)
2047 struct wl_resource *surface = NULL;
2048 memcpy(&surface, data, sizeof(struct wl_resource *));
2049 struct wl_resource *res;
2050 struct wl_client *wc;
2053 wc = wl_resource_get_client(surface);
2055 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
2057 if (wl_resource_get_client(res) == wc)
2059 if (!eina_list_data_find(e_comp_input_key->kbd.focused, res))
2060 e_comp_input_key->kbd.focused = eina_list_append(e_comp_input_key->kbd.focused, res);
2064 if (!e_comp_input_key->kbd.focused)
2069 e_comp_input_key->kbd.focus = surface;
2070 e_comp_wl_input_keyboard_enter_send(surface);
2071 e_comp_wl_data_device_keyboard_focus_set();
2074 /* It is called in the following cases:
2075 * When a normal ec->frame has focus.
2076 * Or launching image ec is replaced to the real ec.
2079 e_comp_wl_feed_focus_in(E_Client *ec)
2084 if (e_object_is_del(E_OBJECT(ec))) return;
2085 if (ec->iconic) return;
2087 /* block spurious focus events */
2088 focused = e_client_focused_get();
2089 if ((focused) && (ec != focused)) return;
2091 /* raise client priority */
2092 _e_comp_wl_client_priority_raise(ec);
2094 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2095 if (!surface) return;
2097 INF("send focus in request to input thread. resource %p\n", surface);
2098 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_in, (void *)&surface, sizeof(struct wl_resource *));
2100 ec->comp_data->on_focus_timer =
2101 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2102 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2103 int rotation = ec->e.state.rot.ang.curr;
2104 e_pointer_rotation_set(e_comp->pointer, rotation);
2108 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2111 if (!(ec = data)) return;
2112 e_comp_wl_feed_focus_in(ec);
2116 _e_comp_wl_input_thread_focus_out(void *data)
2118 struct wl_resource *surface = NULL;
2119 struct wl_resource *res;
2121 E_Comp_Wl_Key_Data *k;
2125 memcpy(&surface, data, sizeof(struct wl_resource *));
2127 /* update keyboard modifier state */
2128 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2129 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2131 if (!surface) return;
2133 if (!eina_list_count(e_comp_input_key->kbd.resources))
2138 /* send keyboard_leave to all keyboard resources */
2139 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2140 t = ecore_time_unix_get();
2142 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
2144 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2146 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2147 wl_keyboard_send_key(res, serial, t,
2148 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2150 wl_keyboard_send_leave(res, serial, surface);
2151 e_comp_input_key->kbd.focused =
2152 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
2157 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2160 if (!(ec = data)) return;
2162 if (!ec->comp_data) return;
2164 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2166 /* lower client priority */
2167 if (!e_object_is_del(data))
2168 _e_comp_wl_client_priority_normal(ec);
2170 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2171 INF("send focus out request to input thread. resource %p\n", surface);
2172 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_out, (void *)&surface, sizeof(struct wl_resource *));
2176 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2180 if (!(ec = data)) return;
2182 if (!ec->comp_data->shell.configure_send) return;
2184 /* TODO: calculate x, y with transfrom object */
2185 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2189 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2190 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2191 if (e_comp_object_frame_exists(ec->frame))
2192 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2194 switch (ec->resize_mode)
2196 case E_POINTER_RESIZE_TL:
2197 case E_POINTER_RESIZE_L:
2198 case E_POINTER_RESIZE_BL:
2199 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2200 ec->mouse.current.mx;
2202 case E_POINTER_RESIZE_TR:
2203 case E_POINTER_RESIZE_R:
2204 case E_POINTER_RESIZE_BR:
2205 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2210 switch (ec->resize_mode)
2212 case E_POINTER_RESIZE_TL:
2213 case E_POINTER_RESIZE_T:
2214 case E_POINTER_RESIZE_TR:
2215 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2216 ec->mouse.current.my;
2218 case E_POINTER_RESIZE_BL:
2219 case E_POINTER_RESIZE_B:
2220 case E_POINTER_RESIZE_BR:
2221 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2226 w = E_CLAMP(w, 1, w);
2227 h = E_CLAMP(h, 1, h);
2228 e_client_resize_limit(ec, &w, &h);
2230 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2232 else if ((!ec->fullscreen) && (!ec->maximized) &&
2233 (!ec->comp_data->maximize_pre))
2237 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2238 if ((pw != ec->w) || (ph != ec->h))
2240 _e_comp_wl_configure_send(ec, 1, 1);
2244 if (ec->comp_data->sub.below_obj)
2245 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2249 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2251 E_Client *ec = data;
2253 ec->comp_data->maximize_pre = 1;
2257 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2259 E_Client *ec = data;
2262 if (e_object_is_del(E_OBJECT(ec))) return;
2264 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2265 e_client_shell_configure_send(ec, 0, w, h);
2267 ec->comp_data->maximize_pre = 0;
2271 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2273 E_Client *ec = data;
2275 ec->comp_data->maximize_pre = 1;
2279 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2281 E_Client *ec = data;
2283 if (e_object_is_del(E_OBJECT(ec))) return;
2285 /* check for wayland pixmap */
2287 if (ec->comp_data->shell.configure_send)
2288 _e_comp_wl_configure_send(ec, 0, 0);
2290 ec->comp_data->maximize_pre = 0;
2294 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2296 E_Client *ec = data;
2298 if (e_object_is_del(E_OBJECT(ec))) return;
2300 /* check for wayland pixmap */
2302 if (ec->comp_data->shell.configure_send)
2303 _e_comp_wl_configure_send(ec, 0, 1);
2305 ec->comp_data->maximize_pre = 0;
2309 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2311 E_Client *ec = data;
2313 if (e_object_is_del(E_OBJECT(ec))) return;
2315 /* check for wayland pixmap */
2317 if (ec->comp_data->shell.configure_send)
2318 _e_comp_wl_configure_send(ec, 0, 0);
2320 ec->comp_data->maximize_pre = 0;
2324 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2328 if (!(ec = data)) return;
2330 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2332 e_object_del(E_OBJECT(ec));
2334 _e_comp_wl_focus_check();
2336 /* TODO: Delete request send ??
2337 * NB: No such animal wrt wayland */
2341 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2345 if (!(ec = data)) return;
2347 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2350 if (ec->comp_data->reparented)
2351 e_client_comp_hidden_set(ec, EINA_TRUE);
2354 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2355 if (ec->visible) evas_object_hide(ec->frame);
2356 if (!ec->internal) e_object_del(E_OBJECT(ec));
2358 _e_comp_wl_focus_check();
2362 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2366 if (!(ec = data)) return;
2368 e_client_shell_ping(ec);
2372 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2377 if (!(ec = data)) return;
2378 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2379 if (ec->netwm.opacity == a) return;
2380 ec->netwm.opacity = a;
2381 ec->netwm.opacity_changed = EINA_TRUE;
2385 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2387 Eina_Rectangle *damage_rect = NULL;
2388 Eina_Rectangle *dmg = NULL;
2389 Eina_List *l = NULL;
2391 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2392 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2395 if (!buffer->tbm_surface) return;
2399 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2403 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2404 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2407 eina_rectangle_union(damage_rect, dmg);
2412 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2413 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2416 tbm_surface_internal_set_damage(buffer->tbm_surface,
2422 eina_rectangle_free(damage_rect);
2426 _e_comp_wl_client_evas_init(E_Client *ec)
2428 if (!ec || !ec->comp_data) return;
2429 if (ec->comp_data->evas_init) return;
2431 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2432 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2433 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2436 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2437 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2438 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2439 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2440 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2441 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2443 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2444 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2445 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2447 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2448 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2452 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2453 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2454 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2455 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2456 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2457 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2458 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2461 /* setup delete/kill callbacks */
2462 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2463 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2465 /* setup ping callback */
2466 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2467 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2469 ec->comp_data->evas_init = EINA_TRUE;
2473 _e_comp_wl_client_evas_deinit(E_Client *ec)
2475 if (!ec || !ec->comp_data) return;
2476 if (!ec->comp_data->evas_init) return;
2478 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2479 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2480 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2482 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2483 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2484 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2485 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2486 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2487 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2489 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2490 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2491 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2493 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2494 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2498 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2499 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2500 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2501 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2502 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2503 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2504 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2507 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2508 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2510 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2511 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2513 ec->comp_data->evas_init = EINA_FALSE;
2517 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2521 E_Comp_Screen *e_comp_screen;
2522 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2524 if (!e_comp) return ECORE_CALLBACK_RENEW;
2525 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2526 e_comp_screen = e_comp->e_comp_screen;
2528 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2530 if (!eout->config.enabled)
2532 e_comp_wl_output_remove(eout->id);
2536 switch (eout->config.rotation)
2539 transform = WL_OUTPUT_TRANSFORM_90;
2542 transform = WL_OUTPUT_TRANSFORM_180;
2545 transform = WL_OUTPUT_TRANSFORM_270;
2549 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2553 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2555 eout->config.geom.x, eout->config.geom.y,
2556 eout->config.geom.w, eout->config.geom.h,
2557 eout->info.size.w, eout->info.size.h,
2558 eout->config.mode.refresh, 0, transform))
2559 ERR("Could not initialize screen %s", eout->info.name);
2562 return ECORE_CALLBACK_RENEW;
2566 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2570 /* try to get the client from the object */
2571 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2572 return ECORE_CALLBACK_RENEW;
2574 /* check for client being deleted */
2575 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2577 /* check for wayland pixmap */
2578 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2579 return ECORE_CALLBACK_RENEW;
2581 /* if we have not setup evas callbacks for this client, do it */
2582 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2584 return ECORE_CALLBACK_RENEW;
2588 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2592 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2593 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2595 if (e_comp_wl->selection.target &&
2598 struct wl_resource *res;
2600 E_Client *ec = NULL;
2601 E_Client *legacy_target = e_comp_wl->selection.target;
2602 int device_id = e_comp_wl_data_current_device_id_get();
2606 e_comp_wl_data_current_device_id_set(ev->multi.device);
2608 else if (device_id != ev->multi.device)
2610 return ECORE_CALLBACK_RENEW;
2613 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2614 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2616 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2617 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2619 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2620 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2622 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2623 (ec != legacy_target))
2625 e_comp_wl_data_device_send_leave(legacy_target);
2626 e_comp_wl_data_device_send_enter(ec);
2629 if (e_comp_wl->drag)
2630 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2632 if (e_client_transform_core_enable_get(ec))
2634 int trans_x, trans_y;
2635 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2636 x = trans_x - ec->client.x;
2637 y = trans_y - ec->client.y;
2641 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2646 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2649 return ECORE_CALLBACK_RENEW;
2653 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2656 struct wl_resource *surface;
2657 struct wl_resource *res;
2658 struct wl_client *wc;
2660 E_Comp_Config *comp_conf;
2662 ec = e_comp_wl->ptr_constraints.ec;
2663 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2665 surface = e_comp_wl_client_surface_get(ec);
2666 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2668 wc = wl_resource_get_client(surface);
2670 comp_conf = e_comp_config_get();
2672 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2674 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2675 if (wl_resource_get_client(res) != wc) continue;
2677 if (comp_conf && comp_conf->input_log_enable)
2678 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2679 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2680 e_client_util_name_get(ec));
2682 zwp_relative_pointer_v1_send_relative_motion(res,
2684 (uint32_t)(ev->timestamp),
2685 wl_fixed_from_int(ev->dx),
2686 wl_fixed_from_int(ev->dy),
2687 wl_fixed_from_int(ev->dx_unaccel),
2688 wl_fixed_from_int(ev->dy_unaccel));
2691 return ECORE_CALLBACK_DONE;
2695 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2697 _e_comp_wl_touch_cancel();
2699 return ECORE_CALLBACK_PASS_ON;
2703 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2705 if (!ev) return ECORE_CALLBACK_PASS_ON;
2707 E_Zone *zone = ev->zone;
2709 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2710 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2712 if (!e_zone_is_displaying(zone))
2713 _e_comp_wl_touch_cancel();
2715 return ECORE_CALLBACK_PASS_ON;
2719 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2721 E_Client *ec = ev->ec;
2722 E_Comp_Wl_Buffer_Viewport *vp;
2724 if (!ec) return ECORE_CALLBACK_PASS_ON;
2725 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2726 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2727 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2728 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2730 vp = &ec->comp_data->scaler.buffer_viewport;
2731 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2733 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2735 return ECORE_CALLBACK_PASS_ON;
2739 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2741 E_Client *ec = ev->ec;
2742 E_Comp_Wl_Buffer_Viewport *vp;
2744 if (!ec) return ECORE_CALLBACK_PASS_ON;
2745 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2746 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2747 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2749 vp = &ec->comp_data->scaler.buffer_viewport;
2750 vp->wait_for_transform_change = 0;
2752 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2754 return ECORE_CALLBACK_PASS_ON;
2758 _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)
2760 E_Client *focused_ec;
2763 focused_ec = e_client_focused_get();
2764 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2766 rotation = focused_ec->e.state.rot.ang.curr;
2767 e_pointer_rotation_set(e_comp->pointer, rotation);
2769 return ECORE_CALLBACK_PASS_ON;
2773 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2776 Eina_Rectangle *window;
2781 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2783 if ((prev_w != state->bw) ||
2784 (prev_h != state->bh))
2786 ec->changes.buf_size = EINA_TRUE;
2789 if (e_comp_object_frame_exists(ec->frame)) return;
2790 window = &ec->comp_data->shell.window;
2791 if ((!ec->borderless) && /* FIXME temporarily added this check code
2792 * to prevent updating E_Client's size by frame */
2793 (window->x || window->y || window->w || window->h))
2795 e_comp_object_frame_geometry_set(ec->frame,
2797 (window->x + window->w) - state->bw,
2799 (window->y + window->h) - state->bh);
2802 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2806 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2808 E_Comp_Wl_Surface_State *state;
2811 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2812 state->buffer = NULL;
2816 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2818 state->new_attach = EINA_FALSE;
2819 state->buffer = NULL;
2820 state->buffer_destroy_listener.notify =
2821 _e_comp_wl_surface_state_cb_buffer_destroy;
2822 state->sx = state->sy = 0;
2824 state->input = eina_tiler_new(w, h);
2825 eina_tiler_tile_size_set(state->input, 1, 1);
2827 state->opaque = eina_tiler_new(w, h);
2828 eina_tiler_tile_size_set(state->opaque, 1, 1);
2830 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2831 state->buffer_viewport.buffer.scale = 1;
2832 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2833 state->buffer_viewport.surface.width = -1;
2834 state->buffer_viewport.changed = 0;
2836 e_presentation_time_container_init(&state->presentation_container);
2840 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2842 struct wl_resource *cb;
2843 Eina_Rectangle *dmg;
2845 EINA_LIST_FREE(state->frames, cb)
2846 wl_resource_destroy(cb);
2848 EINA_LIST_FREE(state->damages, dmg)
2849 eina_rectangle_free(dmg);
2851 EINA_LIST_FREE(state->buffer_damages, dmg)
2852 eina_rectangle_free(dmg);
2854 if (state->opaque) eina_tiler_free(state->opaque);
2855 state->opaque = NULL;
2857 if (state->input) eina_tiler_free(state->input);
2858 state->input = NULL;
2860 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2861 state->buffer = NULL;
2863 e_presentation_time_container_finish(&state->presentation_container);
2867 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2869 if (state->buffer == buffer) return;
2871 wl_list_remove(&state->buffer_destroy_listener.link);
2872 state->buffer = buffer;
2874 wl_signal_add(&state->buffer->destroy_signal,
2875 &state->buffer_destroy_listener);
2879 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2881 Eina_Rectangle *dmg;
2882 Eina_Bool placed = EINA_TRUE;
2886 E_Comp_Wl_Buffer *buffer;
2887 struct wl_resource *cb;
2889 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2890 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2895 if ((ec->internal) ||
2896 (cdata->shell.surface && state->new_attach))
2900 e_comp->new_clients++;
2901 ELOGF("COMP", "Unignore", ec);
2902 e_client_unignore(ec);
2906 /* buffer transform */
2907 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2910 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2912 /* when buffer is transformed, we have to apply the new evas-map */
2913 state->buffer_viewport.changed = EINA_TRUE;
2915 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2917 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2919 if (transform_change == vp->wait_for_transform_change)
2920 vp->wait_for_transform_change = 0;
2922 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2923 // triggered by E_CLIENT_HOOK calls at those file.
2924 zone = e_comp_zone_find_by_ec(ec);
2927 eout = e_output_find(zone->output_id);
2928 if (eout && eout->hwc)
2930 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2932 if (e_comp_is_on_overlay(ec))
2933 e_comp_hwc_client_end(ec, __FUNCTION__);
2939 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2940 cdata->scaler.buffer_viewport = state->buffer_viewport;
2942 if (state->new_attach)
2944 e_comp_wl_surface_attach(ec, state->buffer);
2947 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2948 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2950 _e_comp_wl_surface_state_buffer_set(state, NULL);
2952 if ((state->new_attach) ||
2953 (state->buffer_viewport.changed))
2955 _e_comp_wl_surface_state_size_update(ec, state);
2956 e_comp_wl_map_size_cal_from_viewport(ec);
2958 /* update the position */
2959 if (ec->changes.pos)
2961 e_comp_object_frame_xy_unadjust(ec->frame,
2971 if (ec->new_client) placed = ec->placed;
2973 if (!ec->lock_client_size)
2978 ec->client.w = state->bw;
2979 ec->client.h = state->bh;
2981 e_comp_object_frame_wh_adjust(ec->frame,
2982 ec->client.w, ec->client.h,
2984 e_client_size_set(ec, nw, nh);
2986 if ((w != ec->w) || (h != ec->h))
2988 ec->changes.size = 1;
2993 if (ec->changes.buf_size)
2995 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2996 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2997 ec->changes.buf_size = EINA_FALSE;
2999 if (ec->move_after_resize)
3001 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
3002 ec->move_after_resize = EINA_FALSE;
3007 /* map or unmap ec */
3008 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
3009 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
3010 if (!pixmap_usable || hide_by_request)
3015 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
3020 if ((cdata->sub.below_obj) &&
3021 (evas_object_visible_get(cdata->sub.below_obj)))
3023 evas_object_hide(cdata->sub.below_obj);
3031 if ((cdata->sub.below_obj) &&
3032 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3033 (evas_object_visible_get(ec->frame)))
3035 evas_object_show(cdata->sub.below_obj);
3039 if ((state->new_attach) ||
3040 (state->buffer_viewport.changed))
3042 if ((e_comp_wl->drag) &&
3043 (e_comp_wl->drag_client) &&
3044 (e_comp_wl->drag_client == ec))
3046 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3048 e_drag_move(e_comp_wl->drag,
3050 e_comp_wl->drag->y);
3052 e_drag_resize(e_comp_wl->drag,
3053 state->bw, state->bh);
3055 else if ((cdata->shell.surface) &&
3056 (cdata->shell.configure))
3058 e_comp_wl_commit_sync_configure(ec);
3060 else if (!e_client_video_hw_composition_check(ec))
3062 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3067 ec->placed = placed;
3068 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3072 if (cdata->scaler.buffer_viewport.changed)
3073 e_comp_wl_map_apply(ec);
3075 /* resize transform object */
3076 if (ec->transformed)
3077 e_client_transform_update(ec);
3081 state->new_attach = EINA_FALSE;
3083 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3085 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3086 wl_resource_destroy(cb);
3089 /* insert state frame callbacks into comp_data->frames
3090 * NB: This clears state->frames list */
3091 cdata->frames = eina_list_merge(cdata->frames,
3093 state->frames = NULL;
3095 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3096 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3097 &state->presentation_container);
3099 buffer = e_pixmap_resource_get(ec->pixmap);
3101 /* put state damages into surface */
3104 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3105 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3107 if ((cdata->buffer_ref.buffer) &&
3108 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3109 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3111 e_comp_object_damage(ec->frame,
3113 cdata->buffer_ref.buffer->w,
3114 cdata->buffer_ref.buffer->h);
3119 Eina_List *damages = NULL;
3122 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3124 if (eina_list_count(state->buffer_damages))
3126 EINA_LIST_FREE(state->buffer_damages, dmg)
3129 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3130 e_comp_wl_output_buffer_transform_get(ec),
3132 dmg->x, dmg->y, dmg->w, dmg->h,
3133 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3134 damages = eina_list_append(damages, dmg);
3138 EINA_LIST_FREE(state->damages, dmg)
3139 damages = eina_list_append(damages, dmg);
3141 EINA_LIST_FREE(damages, dmg)
3143 /* not creating damage for ec that shows a underlay video */
3144 if (state->buffer_viewport.changed ||
3145 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3146 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3147 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3149 eina_rectangle_free(dmg);
3154 /* put state opaque into surface */
3155 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3158 Eina_Rectangle *rect;
3161 itr = eina_tiler_iterator_new(state->opaque);
3162 EINA_ITERATOR_FOREACH(itr, rect)
3166 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3167 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3168 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3172 eina_iterator_free(itr);
3175 /* put state input into surface */
3176 if ((state->input) &&
3177 (!eina_tiler_empty(state->input)) &&
3180 Eina_Tiler *src, *tmp;
3184 tmp = eina_tiler_new(sw, sh);
3185 eina_tiler_tile_size_set(tmp, 1, 1);
3187 eina_tiler_rect_add(tmp,
3188 &(Eina_Rectangle){0, 0, sw, sh});
3190 if ((src = eina_tiler_intersection(state->input, tmp)))
3192 Eina_Rectangle *rect;
3195 e_comp_object_input_objs_del(ec->frame);
3196 itr = eina_tiler_iterator_new(src);
3197 EINA_ITERATOR_FOREACH(itr, rect)
3199 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3200 ec, rect->x, rect->y, rect->w, rect->h,
3201 ec->w, ec->h, state->bw, state->bh);
3202 e_comp_object_input_area_set(ec->frame,
3207 eina_iterator_free(itr);
3208 eina_tiler_free(src);
3211 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3213 eina_tiler_free(tmp);
3215 /* clear input tiler */
3216 eina_tiler_clear(state->input);
3219 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3221 if ((cdata->video_client) &&
3223 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3224 (e_comp->wl_comp_data->available_hw_accel.underlay))
3226 e_pixmap_image_clear(ec->pixmap, 1);
3229 state->buffer_viewport.changed = 0;
3231 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3234 ec->exp_iconify.buffer_flush &&
3235 e_policy_visibility_client_is_iconic(ec))
3237 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3242 _e_comp_wl_surface_render_stop(E_Client *ec)
3244 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3245 //if ((!ec->internal) && (!e_comp_gl_get()))
3248 /* check if internal animation is running */
3249 if (e_comp_object_is_animating(ec->frame)) return;
3250 /* check if external animation is running */
3251 if (evas_object_data_get(ec->frame, "effect_running")) return;
3253 evas_object_hide(ec->frame);
3257 _e_input_thread_client_free(void *data)
3259 E_Input_Thread_Request_EClient_Data ec_free_data;
3260 memcpy(&ec_free_data, data, sizeof(E_Input_Thread_Request_EClient_Data));
3262 INF("[input thread|e_client_free] ec: %p, surface: %p\n", ec_free_data.ec, ec_free_data.wl_surface);
3266 e_comp_wl_client_surface_finish(E_Client *ec)
3268 struct wl_resource *res, *surface;
3269 struct wl_client *surface_client = NULL;
3272 surface = e_comp_wl_client_surface_get(ec);
3275 surface_client = wl_resource_get_client(surface);
3277 if (surface_client &&
3278 (ec == e_client_focused_get()))
3280 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
3282 if (wl_resource_get_client(res) ==
3284 e_comp_input_key->kbd.focused =
3285 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
3290 E_Input_Thread_Request_EClient_Data ec_free_data;
3291 memset(&ec_free_data, 0, sizeof(E_Input_Thread_Request_EClient_Data));
3292 ec_free_data.ec = ec;
3293 ec_free_data.wl_surface = ec->comp_data->wl_surface;
3295 INF("[e_comp_wl_client_surface_finish] surface: %p\n", ec_free_data.wl_surface);
3296 e_input_thread_safe_call(_e_input_thread_client_free, &ec_free_data, sizeof(E_Input_Thread_Request_EClient_Data));
3298 e_comp_wl_client_surface_set(ec, NULL);
3300 ec->comp_data->wl_surface = NULL;
3301 e_pixmap_win_id_del(ec->pixmap);
3303 _e_comp_wl_surface_render_stop(ec);
3304 e_object_del(E_OBJECT(ec));
3308 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3313 char proc[512], pname[512];
3316 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3318 h = fopen(proc, "r");
3321 len = fread(pname, sizeof(char), 512, h);
3323 pname[len - 1] = '\0';
3325 strncpy(pname, "NO NAME", sizeof(pname));
3331 strncpy(pname, "NO NAME", sizeof(pname));
3334 strncpy(name, pname, size);
3338 _e_comp_wl_pname_print(pid_t pid)
3341 char proc[512], pname[512];
3344 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3346 h = fopen(proc, "r");
3349 len = fread(pname, sizeof(char), 512, h);
3351 pname[len - 1] = '\0';
3353 strncpy(pname, "NO NAME", sizeof(pname));
3357 ELOGF("COMP", " |%s", NULL, pname);
3362 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3364 struct wl_client *client = data;
3365 E_Comp_Connected_Client_Info *cinfo;
3368 cinfo = wl_container_of(listener, cinfo, destroy);
3370 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3371 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3373 eai = e_appinfo_find_with_pid(cinfo->pid);
3374 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3377 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3379 wl_list_remove(&cinfo->destroy.link);
3380 eina_stringshare_del(cinfo->name);
3385 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3387 E_Comp_Connected_Client_Info *cinfo;
3389 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3390 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3392 cinfo->name = eina_stringshare_add(name);
3396 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3397 wl_client_add_destroy_listener(client, &cinfo->destroy);
3398 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3400 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3404 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3406 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3408 /* send configure */
3409 if (ec->comp_data->shell.configure_send)
3411 if (ec->comp_data->shell.surface)
3412 _e_comp_wl_configure_send(ec, 0, 0);
3415 e_comp_input_key->kbd.focus = ec->comp_data->surface;
3419 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3421 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3423 /* send configure */
3424 if (ec->comp_data->shell.configure_send)
3426 if (ec->comp_data->shell.surface)
3427 _e_comp_wl_configure_send(ec, 0, 0);
3430 _e_comp_wl_focus_check();
3432 if (e_comp_input_key->kbd.focus == ec->comp_data->surface)
3433 e_comp_input_key->kbd.focus = NULL;
3437 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3439 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3440 if (ec->keyboard_resizing) return;
3442 /* do nothing currently */
3447 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3449 if (e_object_is_del(E_OBJECT(ec))) return;
3450 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3452 e_comp_wl->resize.edges = 0;
3453 e_comp_wl->resize.resource = NULL;
3457 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3459 if (e_object_is_del(E_OBJECT(ec))) return;
3460 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3464 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3467 int ratio_w, ratio_h;
3469 phys_w = output->phys_width;
3470 phys_h = output->phys_height;
3472 if (e_config->configured_output_resolution.use)
3474 // change the configured physical size(mm) of the output
3475 if (output->w != res_w)
3477 ratio_w = res_w / output->w;
3478 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3481 if (output->h != res_h)
3483 ratio_h = res_h / output->h;
3484 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3487 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3490 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3491 NULL, res_w, res_h, phys_w, phys_h, pid);
3493 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3494 wl_output_send_scale(resource, output->scale);
3496 wl_output_send_geometry(resource, output->x, output->y,
3498 output->subpixel, output->make ?: "",
3499 output->model ?: "", output->transform);
3501 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3502 res_w, res_h, output->refresh);
3504 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3505 wl_output_send_done(resource);
3509 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3511 E_Comp_Wl_Output *output;
3513 if (!(output = wl_resource_get_user_data(resource))) return;
3515 output->resources = eina_list_remove(output->resources, resource);
3519 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3521 E_Comp_Wl_Output *output;
3522 struct wl_resource *resource;
3523 E_Appinfo *eai = NULL;
3527 if (!(output = data)) return;
3530 wl_resource_create(client, &wl_output_interface, version, id);
3533 wl_client_post_no_memory(client);
3537 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3538 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3540 output->resources = eina_list_append(output->resources, resource);
3542 wl_resource_set_implementation(resource, NULL, output,
3543 _e_comp_wl_cb_output_unbind);
3544 wl_resource_set_user_data(resource, output);
3546 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3547 if (e_config->configured_output_resolution.use)
3549 wl_client_get_credentials(client, &pid, NULL, NULL);
3552 res_w = e_config->configured_output_resolution.w;
3553 res_h = e_config->configured_output_resolution.h;
3557 eai = e_appinfo_find_with_pid(pid);
3560 res_w = e_config->configured_output_resolution.w;
3561 res_h = e_config->configured_output_resolution.h;
3565 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3567 res_w = e_config->configured_output_resolution.w;
3568 res_h = e_config->configured_output_resolution.h;
3572 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3581 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3585 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3588 Evas_GL *evasgl = NULL;
3589 Evas_GL_API *glapi = NULL;
3590 Evas_GL_Context *ctx = NULL;
3591 Evas_GL_Surface *sfc = NULL;
3592 Evas_GL_Config *cfg = NULL;
3594 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3596 if (!e_comp_gl_get()) return;
3598 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3599 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3601 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3602 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3604 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3605 * then we should get evas from ecore_evas.
3608 evas = e_comp->evas;
3610 evas = ecore_evas_get(e_comp->ee);
3612 evasgl = evas_gl_new(evas);
3613 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3615 glapi = evas_gl_api_get(evasgl);
3616 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3617 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3619 cfg = evas_gl_config_new();
3620 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3622 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3623 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3625 ctx = evas_gl_context_create(evasgl, NULL);
3626 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3628 res = evas_gl_make_current(evasgl, sfc, ctx);
3629 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3631 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3632 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3634 evas_gl_config_free(cfg);
3636 evas_gl->gl = evasgl;
3637 evas_gl->glapi = glapi;
3638 evas_gl->glsfc = sfc;
3639 evas_gl->glctx = ctx;
3641 e_comp_wl->evas_gl = evas_gl;
3643 /* for native surface */
3646 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3651 evas_gl_config_free(cfg);
3652 evas_gl_make_current(evasgl, NULL, NULL);
3653 evas_gl_context_destroy(evasgl, ctx);
3654 evas_gl_surface_destroy(evasgl, sfc);
3655 evas_gl_free(evasgl);
3662 _e_comp_wl_gl_popup_cb_close(void *data,
3663 Evas_Object *obj EINA_UNUSED,
3664 void *event_info EINA_UNUSED)
3666 evas_object_del(data);
3670 _e_comp_wl_gl_popup_cb_focus(void *data,
3671 Evas_Object *obj EINA_UNUSED,
3672 void *event_info EINA_UNUSED)
3674 elm_object_focus_set(data, EINA_TRUE);
3679 _e_comp_wl_gl_idle(void *data)
3683 /* show warning window to notify failure of gl init */
3686 Evas_Object *win, *bg, *popup, *btn;
3688 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3689 elm_win_title_set(win, "Compositor Warning");
3690 elm_win_autodel_set(win, EINA_TRUE);
3691 elm_win_borderless_set(win, EINA_TRUE);
3692 elm_win_role_set(win, "notification-low");
3693 elm_win_alpha_set(win, EINA_TRUE);
3695 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3696 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3697 elm_win_resize_object_add(win, bg);
3698 evas_object_color_set(bg, 125, 125, 125, 125);
3699 evas_object_show(bg);
3701 popup = elm_popup_add(win);
3702 elm_object_text_set(popup,
3703 _( "Your screen does not support OpenGL.<br>"
3704 "Falling back to software engine."));
3705 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3707 btn = elm_button_add(popup);
3708 elm_object_text_set(btn, "Close");
3709 elm_object_part_content_set(popup, "button1", btn);
3710 evas_object_show(btn);
3712 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3713 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3715 evas_object_show(popup);
3716 evas_object_show(win);
3720 return ECORE_CALLBACK_CANCEL;
3724 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3726 struct wl_client *client = data;
3732 wl_client_get_credentials(client, &pid, &uid, &gid);
3734 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3736 _e_comp_wl_pname_print(pid);
3737 _e_comp_wl_pname_get(pid, name, sizeof(name));
3738 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3742 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3744 char buf[1024] = {0, };
3746 vsnprintf(buf, 1024, fmt, args);
3750 DBG("[libds] %s", buf);
3753 INF("[libds] %s", buf);
3756 ERR("[libds] %s", buf);
3764 _e_comp_wl_display_create(void)
3767 E_Comp_Wl_Data *wl_cdata;
3772 /* create new compositor data */
3773 if (!(comp = E_NEW(E_Comp_Data, 1)))
3775 ERR("Could not create compositor data: %m");
3778 wl_cdata = &comp->base;
3780 /* set compositor wayland data */
3781 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3783 g_mutex_init(&connection_mutex);
3785 /* try to create a wayland display */
3786 if (!(wl_cdata->wl.disp = wl_display_create()))
3788 ERR("Could not create a Wayland display: %m");
3792 /* try to setup wayland socket */
3793 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3795 ERR("Could not create Wayland display socket: %m");
3796 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3800 res = e_comp_socket_init(name);
3801 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3802 PRCTL("[Winsys] change permission and create sym link for %s", name);
3804 /* set wayland display environment variable */
3805 e_env_set("WAYLAND_DISPLAY", name);
3807 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3808 /* wl_cdata->output.scale = e_scale; */
3810 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3812 if (!e_compositor_init(wl_cdata->wl.disp))
3814 ERR("Failed to initialize compositor");
3818 comp->client_created.notify = _e_comp_wl_cb_client_created;
3819 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3821 if (!e_comp_wl_subsurfaces_init())
3823 ERR("Failed to init_subsurfaces");
3824 goto subsurfaces_err;
3827 /* initialize shm mechanism */
3828 wl_display_init_shm(wl_cdata->wl.disp);
3830 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3832 /* try to init data manager */
3833 if (!e_comp_wl_data_manager_init())
3835 ERR("Could not initialize data manager");
3839 /* try to init input */
3840 if (!e_comp_wl_input_init())
3842 ERR("Could not initialize input");
3846 if (e_comp_gl_get())
3847 _e_comp_wl_gl_init(NULL);
3849 /* get the wayland display loop */
3850 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3852 /* get the file descriptor of the wayland event loop */
3853 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3855 /* create a listener for wayland main loop events */
3857 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3858 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3859 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3860 _e_comp_wl_cb_prepare, wl_cdata);
3862 /* add awake handler */
3863 ecore_main_awake_handler_add(_e_comp_wl_cb_awake, NULL);
3868 e_comp_wl_data_manager_shutdown();
3870 e_comp_wl_subsurfaces_shutdown();
3872 wl_list_remove(&comp->client_created.link);
3874 e_env_unset("WAYLAND_DISPLAY");
3876 wl_display_destroy(wl_cdata->wl.disp);
3878 g_mutex_clear(&connection_mutex);
3884 _e_comp_wl_gl_shutdown(void)
3886 if (!e_comp_wl->evas_gl) return;
3888 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3890 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3891 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3892 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3893 evas_gl_free(e_comp_wl->evas_gl->gl);
3895 E_FREE(e_comp_wl->evas_gl);
3898 /* public functions */
3901 * Creates and initializes a Wayland compositor with ecore.
3902 * Registers callback handlers for keyboard and mouse activity
3903 * and other client events.
3905 * @returns true on success, false if initialization failed.
3908 e_comp_wl_init(void)
3910 TRACE_DS_BEGIN(COMP_WL:INIT);
3912 /* try to create a wayland compositor */
3913 if (!_e_comp_wl_display_create())
3915 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3920 e_comp_wl_shell_init();
3922 #ifdef HAVE_WAYLAND_TBM
3923 e_comp_wl_tbm_init();
3925 e_comp_wl_remote_surface_init();
3929 e_comp_wl_screenshooter_init();
3931 if (!e_comp_wl_video_init())
3932 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3934 e_comp_wl_viewport_init();
3935 e_comp_wl_capture_init();
3936 e_comp_wl_renderer_init();
3937 _e_comp_wl_move_resize_init();
3938 e_presentation_time_init();
3939 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3941 e_blur_manager_init();
3943 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3944 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3946 /* add event handlers to catch E events */
3947 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3948 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3949 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3950 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3951 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3952 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3953 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3954 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3955 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3957 /* add hooks to catch e_client events */
3958 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3959 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3960 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3961 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3962 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3969 e_comp_wl_deferred_job(void)
3971 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3974 /* internal functions */
3976 e_comp_wl_shutdown(void)
3978 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3980 e_comp_wl_subsurfaces_shutdown();
3982 E_FREE_LIST(handlers, ecore_event_handler_del);
3983 E_FREE_LIST(hooks, e_client_hook_del);
3984 _e_comp_wl_gl_shutdown();
3986 e_presentation_time_shutdown();
3987 e_comp_wl_renderer_shutdown();
3988 e_comp_wl_capture_shutdown();
3989 e_comp_wl_viewport_shutdown();
3990 e_comp_wl_video_shutdown();
3991 e_comp_wl_screenshooter_shutdown();
3993 e_comp_wl_remote_surface_shutdown();
3995 e_pixmap_shutdown();
3997 e_wtz_shell_shutdown();
3998 e_comp_wl_shell_shutdown();
3999 e_comp_wl_input_shutdown();
4001 wl_list_remove(&comp->client_created.link);
4003 /* delete awake handler */
4004 ecore_main_awake_handler_del(_e_comp_wl_cb_awake);
4007 e_comp->wl_comp_data = NULL;
4011 E_Comp_Wl_Output *output;
4013 if (e_comp_wl->screenshooter.global)
4014 wl_global_destroy(e_comp_wl->screenshooter.global);
4016 EINA_LIST_FREE(e_comp_wl->outputs, output)
4018 if (output->id) eina_stringshare_del(output->id);
4019 if (output->make) eina_stringshare_del(output->make);
4020 if (output->model) eina_stringshare_del(output->model);
4024 /* delete fd handler */
4025 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
4027 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
4028 cursor_timer_ec = NULL;
4030 /* free allocated data structure */
4036 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4038 e_object_unref(E_OBJECT(ev->ec));
4043 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4046 ev = E_NEW(E_Event_Client, 1);
4049 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4051 /* set usable early because shell module checks this */
4052 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4053 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4055 e_pixmap_resource_set(ec->pixmap, buffer);
4056 e_pixmap_dirty(ec->pixmap);
4057 e_pixmap_refresh(ec->pixmap);
4059 e_comp_wl_map_size_cal_from_buffer(ec);
4060 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4062 /* wm-policy module uses it */
4063 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4066 e_object_ref(E_OBJECT(ec));
4067 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4068 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4072 e_comp_wl_surface_commit(E_Client *ec)
4077 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4078 if (!e_comp_object_damage_exists(ec->frame))
4080 if ((ec->comp_data->video_client) ||
4081 (!e_client_video_hw_composition_check(ec)))
4082 e_pixmap_image_clear(ec->pixmap, 1);
4085 ignored = ec->ignored;
4087 if (e_comp_wl_subsurface_order_commit(ec))
4089 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4090 e_comp_wl_subsurface_restack(topmost);
4091 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4094 ec->ignored = ignored;
4096 if (ec->is_cursor && ec->visible)
4098 /* ignore cursor changes during resize/move I guess */
4099 if (!e_client_action_get())
4101 if (e_comp->pointer)
4103 x = e_comp->pointer->hot.x;
4104 y = e_comp->pointer->hot.y;
4106 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4112 static E_Comp_Wl_Output *
4113 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4116 E_Comp_Wl_Output *output;
4118 EINA_LIST_FOREACH(outputs, l, output)
4120 if (!strcmp(output->id, id))
4128 * Initializes information about one display output.
4130 * Adds or updates the given data about a single display output,
4131 * with an id matching the provided id.
4133 * @param id identification of output to be added or changed
4134 * @param make manufacturer name of the display output
4135 * @param model model name of the display output
4136 * @param x output's top left corner x coordinate
4137 * @param y output's top left corner y coordinate
4138 * @param w output's width in pixels
4139 * @param h output's height in pixels
4140 * @param pw output's physical width in millimeters
4141 * @param ph output's physical height in millimeters
4142 * @param refresh output's refresh rate in mHz
4143 * @param subpixel output's subpixel layout
4144 * @param transform output's rotation and/or mirror transformation
4146 * @returns True if a display output object could be added or updated
4149 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4150 int x, int y, int w, int h, int pw, int ph,
4151 unsigned int refresh, unsigned int subpixel,
4152 unsigned int transform)
4154 E_Comp_Wl_Output *output;
4156 struct wl_resource *resource;
4158 /* retrieve named output; or create it if it doesn't exist */
4159 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4162 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4164 if (id) output->id = eina_stringshare_add(id);
4166 output->make = eina_stringshare_add(make);
4168 output->make = eina_stringshare_add("unknown");
4170 output->model = eina_stringshare_add(model);
4172 output->model = eina_stringshare_add("unknown");
4174 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4177 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4178 2, output, _e_comp_wl_cb_output_bind);
4180 output->resources = NULL;
4181 output->scale = e_scale;
4184 /* update the output details */
4189 output->phys_width = pw;
4190 output->phys_height = ph;
4191 output->refresh = refresh;
4192 output->subpixel = subpixel;
4193 output->transform = transform;
4195 if (output->scale <= 0)
4196 output->scale = e_scale;
4198 /* if we have bound resources, send updates */
4199 EINA_LIST_FOREACH(output->resources, l2, resource)
4201 wl_output_send_geometry(resource,
4202 output->x, output->y,
4204 output->phys_height,
4206 output->make ?: "", output->model ?: "",
4209 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4210 wl_output_send_scale(resource, output->scale);
4212 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4213 output->w, output->h, output->refresh);
4215 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4216 wl_output_send_done(resource);
4223 e_comp_wl_output_remove(const char *id)
4225 E_Comp_Wl_Output *output;
4227 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4230 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4232 /* wl_global_destroy(output->global); */
4234 /* eina_stringshare_del(output->id); */
4235 /* eina_stringshare_del(output->make); */
4236 /* eina_stringshare_del(output->model); */
4243 _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)
4245 struct wl_resource *res;
4247 uint32_t serial, keycode;
4248 struct wl_client *wc = NULL;
4249 E_Comp_Config *comp_conf = NULL;
4250 const char *device_name = NULL;
4252 keycode = (ev->keycode - 8);
4254 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4256 comp_conf = e_comp_config_get();
4258 if (ec && ec->comp_data)
4260 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4263 wc = wl_resource_get_client(surface);
4266 if (e_config->key_input_ttrace_enable)
4268 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4269 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4272 EINA_LIST_FOREACH(key_list, l, res)
4274 if (wl_resource_get_client(res) != wc) continue;
4276 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4277 if (!e_input_thread_mode_get())
4279 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4280 device_name = ecore_device_name_get(ev->dev);
4286 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4287 device_name = e_device_name_get(dev);
4291 if (comp_conf && comp_conf->input_log_enable)
4292 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4294 wl_keyboard_send_key(res, serial, ev->timestamp,
4299 if (e_config->key_input_ttrace_enable)
4302 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4307 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4309 E_Client *ec = NULL;
4311 E_Comp_Wl_Key_Data *end, *k;
4313 if (ev->window != e_comp->ee_win)
4318 keycode = (ev->keycode - 8);
4319 if (!(e_comp_wl = e_comp->wl_comp_data))
4324 #ifndef E_RELEASE_BUILD
4325 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4326 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4327 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4328 eina_streq(ev->key, "BackSpace"))
4334 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4336 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4338 /* ignore server-generated key repeats */
4339 if (k->key == keycode)
4345 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4347 ec = e_client_focused_get();
4348 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4349 if (ec && ec->comp_data && surface)
4351 if (e_comp_input_key->kbd.focused)
4353 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_input_key->kbd.focused, ec);
4355 /* A key only sent to clients is added to the list */
4356 e_comp_input_key->kbd.keys.size = (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4358 if (!(k = wl_array_add(&e_comp_input_key->kbd.keys, sizeof(*k))))
4360 DBG("wl_array_add: Out of memory\n");
4369 /* update modifier state */
4370 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4376 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4378 E_Client *ec = NULL;
4379 uint32_t keycode, delivered_key;
4380 E_Comp_Wl_Key_Data *end, *k;
4382 if (ev->window != e_comp->ee_win)
4387 keycode = (ev->keycode - 8);
4389 if (!(e_comp_wl = e_comp->wl_comp_data))
4394 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4395 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4397 if (k->key == keycode)
4404 e_comp_input_key->kbd.keys.size =
4405 (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4407 /* 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) */
4408 if ((delivered_key) ||
4409 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4411 ec = e_client_focused_get();
4413 if (e_comp_input_key->kbd.focused)
4415 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_input_key->kbd.focused, ec);
4419 /* update modifier state */
4420 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4426 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4428 Eina_Bool res = EINA_FALSE;
4430 if (type == ECORE_EVENT_KEY_DOWN)
4432 res = e_comp_wl_key_down(ev, dev);
4434 else if (type == ECORE_EVENT_KEY_UP)
4436 res = e_comp_wl_key_up(ev, dev);
4443 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4446 struct wl_client *wc;
4447 uint32_t serial, btn;
4448 struct wl_resource *res;
4449 E_Comp_Config *comp_conf = NULL;
4451 if (ec->cur_mouse_action || e_comp_wl->drag)
4453 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4454 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4458 case 1: btn = BTN_LEFT; break;
4459 case 2: btn = BTN_MIDDLE; break;
4460 case 3: btn = BTN_RIGHT; break;
4461 default: btn = button_id; break;
4464 e_comp_wl->ptr.button = btn;
4465 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4466 if (!surface) return EINA_FALSE;
4468 if (!eina_list_count(e_comp_wl->ptr.resources))
4471 wc = wl_resource_get_client(surface);
4472 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4474 comp_conf = e_comp_config_get();
4476 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4478 if (wl_resource_get_client(res) != wc) continue;
4479 if (!e_comp_wl_input_pointer_check(res)) continue;
4480 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4482 if (comp_conf && comp_conf->input_log_enable)
4483 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4485 wl_pointer_send_button(res, serial, timestamp, btn, state);
4492 e_comp_wl_touch_cancel(void)
4494 _e_comp_wl_touch_cancel();
4497 E_API E_Comp_Wl_Hook *
4498 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4502 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4503 ch = E_NEW(E_Comp_Wl_Hook, 1);
4504 if (!ch) return NULL;
4505 ch->hookpoint = hookpoint;
4507 ch->data = (void*)data;
4508 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4513 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4516 if (_e_comp_wl_hooks_walking == 0)
4518 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4522 _e_comp_wl_hooks_delete++;
4525 E_API E_Comp_Wl_Pid_Hook *
4526 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4528 E_Comp_Wl_Pid_Hook *ch;
4530 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4532 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4533 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4535 ch->hookpoint = hookpoint;
4537 ch->data = (void*)data;
4538 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4544 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4547 if (_e_comp_wl_pid_hooks_walking == 0)
4549 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4553 _e_comp_wl_pid_hooks_delete++;
4556 E_API E_Comp_Wl_Intercept_Hook *
4557 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4559 E_Comp_Wl_Intercept_Hook *ch;
4561 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4562 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4563 if (!ch) return NULL;
4564 ch->hookpoint = hookpoint;
4566 ch->data = (void*)data;
4567 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4572 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4575 if (_e_comp_wl_intercept_hooks_walking == 0)
4577 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4581 _e_comp_wl_intercept_hooks_delete++;
4585 e_comp_wl_shell_surface_ready(E_Client *ec)
4589 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4593 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4595 e_config->use_cursor_timer = !!enabled;
4597 if (e_config->use_cursor_timer)
4599 if (!e_pointer_is_hidden(e_comp->pointer))
4601 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4606 if (e_comp_wl->ptr.hide_tmr)
4608 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4609 e_comp_wl->ptr.hide_tmr = NULL;
4611 cursor_timer_ec = NULL;
4613 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4616 if (e_pointer_is_hidden(e_comp->pointer))
4618 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4624 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4626 EINA_SAFETY_ON_NULL_RETURN(wc);
4627 EINA_SAFETY_ON_NULL_RETURN(dev);
4629 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4633 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4635 EINA_SAFETY_ON_NULL_RETURN(wc);
4636 EINA_SAFETY_ON_NULL_RETURN(dev);
4638 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4642 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4644 struct wl_resource *res;
4645 struct wl_client *wc;
4647 uint32_t serial, wl_keycode;
4648 enum wl_keyboard_key_state state;
4649 E_Comp_Config *comp_conf = NULL;
4650 const char *dev_name = NULL;
4652 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4653 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4654 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4656 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4657 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4659 wl_keycode = keycode - 8;
4660 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4662 wc = wl_resource_get_client(surface);
4663 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4664 if (!time) time = e_util_timestamp_get();
4665 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4666 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4668 comp_conf = e_comp_config_get();
4669 e_keyrouter_event_surface_send(ec, keycode);
4671 if (e_config->key_input_ttrace_enable)
4673 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4674 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4677 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4679 if (wl_resource_get_client(res) != wc) continue;
4680 if (!e_input_thread_mode_get())
4684 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4685 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4689 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4696 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4697 dev_name = e_device_name_get(dev);
4701 if (comp_conf && comp_conf->input_log_enable)
4702 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4705 wl_keyboard_send_key(res, serial, time,
4709 if (e_config->key_input_ttrace_enable)
4712 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4719 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4721 struct wl_resource *res;
4722 struct wl_client *wc;
4724 uint32_t serial, wl_keycode, cancel_keycode;
4725 E_Comp_Config *comp_conf = NULL;
4726 struct xkb_keymap *keymap = NULL;
4728 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4729 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4730 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4732 keymap = e_comp_input_key->xkb.keymap;
4733 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4735 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4736 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4738 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4739 if (cancel_keycode == XKB_KEYCODE_INVALID)
4741 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4745 EINA_SAFETY_ON_TRUE_RETURN_VAL(cancel_keycode < 8, EINA_FALSE);
4747 cancel_keycode = cancel_keycode - 8;
4749 wl_keycode = keycode - 8;
4750 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4752 wc = wl_resource_get_client(surface);
4753 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4754 if (!time) time = e_util_timestamp_get();
4756 comp_conf = e_comp_config_get();
4757 e_keyrouter_event_surface_send(ec, keycode);
4759 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4761 if (wl_resource_get_client(res) != wc) continue;
4762 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4763 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4765 if (comp_conf && comp_conf->input_log_enable)
4766 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4767 wl_keyboard_send_key(res, serial, time,
4768 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4769 wl_keyboard_send_key(res, serial, time,
4770 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4771 wl_keyboard_send_key(res, serial, time,
4772 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4780 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)
4782 struct wl_client *wc;
4784 E_Devicemgr_Input_Device *device = NULL;
4786 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4787 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4788 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4790 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4791 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4793 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4795 wc = wl_resource_get_client(surface);
4796 if (!time) time = e_util_timestamp_get();
4797 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4801 _e_comp_wl_send_event_device(wc, time, dev, serial);
4802 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4806 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4807 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4810 x = x + ec->client.x;
4811 y = y + ec->client.y;
4813 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4819 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)
4821 E_Devicemgr_Input_Device *device;
4823 struct wl_client *wc;
4825 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4826 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4827 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4829 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4832 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4834 wc = wl_resource_get_client(surface);
4835 if (!time) time = e_util_timestamp_get();
4836 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4840 _e_comp_wl_send_event_device(wc, time, dev, serial);
4841 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4845 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4846 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4849 x = x + ec->client.x;
4850 y = y + ec->client.y;
4852 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4858 e_comp_wl_touch_cancel_send(E_Client *ec)
4860 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4861 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4862 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4864 _e_comp_wl_send_touch_cancel(ec);
4870 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4873 struct wl_client *wc;
4875 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4876 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4877 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4879 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4880 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4882 wc = wl_resource_get_client(surface);
4883 if (!time) time = e_util_timestamp_get();
4884 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4886 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4887 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4890 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4891 WL_POINTER_BUTTON_STATE_PRESSED);
4893 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4894 WL_POINTER_BUTTON_STATE_RELEASED);
4900 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4903 struct wl_client *wc;
4905 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4906 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4907 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4909 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4910 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4912 wc = wl_resource_get_client(surface);
4913 if (!time) time = e_util_timestamp_get();
4914 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4916 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4917 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4919 x = x + ec->client.x;
4920 y = y + ec->client.y;
4922 _e_comp_wl_send_mouse_move(ec, x, y, time);
4928 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4931 struct wl_client *wc;
4933 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4934 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4935 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4937 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4938 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4940 wc = wl_resource_get_client(surface);
4941 if (!time) time = e_util_timestamp_get();
4942 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4944 if (_e_comp_wl_check_cursor_timer_needed(ec))
4946 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4950 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4951 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4953 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4955 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4957 if (_e_comp_wl_check_cursor_timer_needed(ec))
4958 _e_comp_wl_cursor_move_timer_control(ec);
4965 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4968 struct wl_client *wc;
4969 struct wl_resource *res;
4972 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4973 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4975 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4976 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4978 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4979 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4981 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4982 wc = wl_resource_get_client(surface);
4983 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4984 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4986 if (!e_comp_wl_input_pointer_check(res)) continue;
4987 if (wl_resource_get_client(res) != wc) continue;
4989 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4990 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4992 wl_pointer_send_enter(res, serial, surface,
4993 wl_fixed_from_int(x),
4994 wl_fixed_from_int(y));
4995 ec->pointer_enter_sent = EINA_TRUE;
4997 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5003 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5006 struct wl_client *wc;
5007 struct wl_resource *res;
5010 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5011 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5012 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5013 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5014 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5015 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5017 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5018 wc = wl_resource_get_client(surface);
5019 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5020 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5022 if (!e_comp_wl_input_pointer_check(res)) continue;
5023 if (wl_resource_get_client(res) != wc) continue;
5025 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5026 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5028 wl_pointer_send_leave(res, serial, surface);
5029 ec->pointer_enter_sent = EINA_FALSE;
5031 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
5037 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)
5039 Evas_Event_Mouse_In ev_in;
5042 if (ec->pointer_enter_sent) return;
5044 ev_in.buttons = buttons;
5052 ev_in.modifiers = modifiers;
5053 ev_in.locks = locks;
5054 ev_in.timestamp = timestamp;
5055 ev_in.event_flags = event_flags;
5058 ev_in.event_src = event_src;
5060 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5064 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)
5066 Evas_Event_Mouse_Out ev_out;
5069 if (!ec->pointer_enter_sent) return;
5071 ev_out.buttons = buttons;
5073 ev_out.output.x = x;
5074 ev_out.output.y = y;
5075 ev_out.canvas.x = x;
5076 ev_out.canvas.y = y;
5079 ev_out.modifiers = modifiers;
5080 ev_out.locks = locks;
5081 ev_out.timestamp = timestamp;
5082 ev_out.event_flags = event_flags;
5085 ev_out.event_src = event_src;
5087 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5091 e_comp_wl_cursor_hide(E_Client *ec)
5093 struct wl_resource *res;
5094 struct wl_client *wc;
5098 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5100 if (e_comp_wl->ptr.hide_tmr)
5102 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5103 e_comp_wl->ptr.hide_tmr = NULL;
5105 cursor_timer_ec = NULL;
5107 if (!ec) return EINA_FALSE;
5108 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5109 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5110 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5112 wc = wl_resource_get_client(surface);
5113 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5114 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5116 if (!e_comp_wl_input_pointer_check(res)) continue;
5117 if (wl_resource_get_client(res) != wc) continue;
5118 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5119 wl_pointer_send_leave(res, serial, surface);
5120 ec->pointer_enter_sent = EINA_FALSE;
5126 /* surface to buffer
5127 * - width : surface width
5128 * - height : surface height
5129 * - transform: buffer transform
5130 * - scale : buffer scale
5132 * - width : screen width
5133 * - height : screen height
5134 * - transform: output transform
5135 * - scale : output scale
5137 static E_Util_Transform_Matrix
5138 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5140 E_Util_Transform_Matrix m;
5142 e_util_transform_matrix_load_identity(&m);
5144 if (transform & 0x4)
5146 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5147 e_util_transform_matrix_flip_x(&m);
5148 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5151 switch (transform & 0x3)
5153 case WL_OUTPUT_TRANSFORM_90:
5154 e_util_transform_matrix_translate(&m, -width, 0, 0);
5155 e_util_transform_matrix_rotation_z(&m, 270);
5157 case WL_OUTPUT_TRANSFORM_180:
5158 e_util_transform_matrix_translate(&m, -width, -height, 0);
5159 e_util_transform_matrix_rotation_z(&m, 180);
5161 case WL_OUTPUT_TRANSFORM_270:
5162 e_util_transform_matrix_translate(&m, 0, -height, 0);
5163 e_util_transform_matrix_rotation_z(&m, 90);
5169 e_util_transform_matrix_scale(&m, scale, scale, 1);
5174 /* surface to buffer
5175 * - surface width, surface height, buffer transform, buffer scale
5177 * - screen width, screen height, output transform, output scale
5180 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5182 E_Util_Transform_Matrix m;
5183 E_Util_Transform_Vertex v;
5185 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5187 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5188 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5189 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5193 * - buffer width, buffer height, buffer transform, buffer scale
5196 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5198 E_Util_Transform_Matrix m;
5199 E_Util_Transform_Vertex v;
5202 if (transform != 0 || scale > 1)
5204 tw = ((transform % 2) ? height : width) / scale;
5205 th = ((transform % 2) ? width : height) / scale;
5213 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5214 m = e_util_transform_matrix_inverse_get(&m);
5216 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5217 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5218 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5221 /* surface to buffer
5222 * - surface width, surface height, buffer transform, buffer scale
5224 * - screen width, screen height, output transform, output scale
5227 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5228 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5230 E_Util_Transform_Matrix m;
5231 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5232 E_Util_Transform_Rect_Vertex sv;
5234 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5236 sv = e_util_transform_rect_to_vertices(&sr);
5237 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5238 sr = e_util_transform_vertices_to_rect(&sv);
5247 * - buffer width, buffer height, buffer transform, buffer scale
5250 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5251 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5253 E_Util_Transform_Matrix m;
5254 E_Util_Transform_Rect br = {bx, by, bw, bh};
5255 E_Util_Transform_Rect_Vertex bv;
5258 if (transform != 0 || scale > 1)
5260 tw = ((transform % 2) ? height : width) / scale;
5261 th = ((transform % 2) ? width : height) / scale;
5269 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5270 m = e_util_transform_matrix_inverse_get(&m);
5272 bv = e_util_transform_rect_to_vertices(&br);
5273 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5274 br = e_util_transform_vertices_to_rect(&bv);
5282 EINTERN E_Comp_Wl_Output*
5283 e_comp_wl_output_find(E_Client *ec)
5286 E_Comp_Wl_Output *output;
5288 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5290 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5292 if (output->transform % 2)
5294 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5295 ec->y < output->x || ec->y >= (output->x + output->w))
5300 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5301 ec->y < output->y || ec->y >= (output->y + output->h))
5311 EINTERN Eina_Array *
5312 e_comp_wl_output_find_all(E_Client *ec)
5314 E_Comp_Wl_Output *output;
5315 Eina_Array *outputs;
5318 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5320 outputs = eina_array_new(4);
5324 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5326 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5327 output->x, output->y, output->w, output->h))
5329 eina_array_push(outputs, output);
5333 if (eina_array_count(outputs) == 0)
5335 eina_array_free(outputs);
5342 // --------------------------------------------------------
5343 // tizen_move_resize
5344 // --------------------------------------------------------
5346 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5353 E_Client_Pending_Geometry *geo;
5356 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5357 if (ec->fullscreen || ec->maximized) goto err;
5359 geo = E_NEW(E_Client_Pending_Geometry, 1);
5362 geo->serial = serial;
5368 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5369 ec->surface_sync.wait_commit = EINA_TRUE;
5374 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5381 e_comp_wl_commit_sync_configure(E_Client *ec)
5384 E_Client_Pending_Geometry *geo;
5386 Eina_Bool match_size = EINA_FALSE;
5393 if (!ec || !ec->frame) goto ret;
5394 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5397 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5398 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5400 if (eina_list_count(ec->surface_sync.pending_geometry))
5402 Eina_List *ll = NULL;
5403 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5407 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5412 if ((geo->w == bw) && (geo->h == bh))
5414 match_size = EINA_TRUE;
5419 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5426 if ((config.w != ec->w) || (config.h != ec->h))
5428 e_client_size_set(ec, config.w, config.h);
5429 ec->changes.size = EINA_TRUE;
5433 // FIXME: The geometry of the client would be better to be calculated
5434 // at e_desk or at e_desk_area. So the position(x,y) of the client
5435 // should be calcuated at the e_desk or at the e_desk_area.
5437 desk = e_comp_desk_find_by_ec(ec);
5440 ec->client.x = desk->geom.x + config.x;
5441 ec->client.y = desk->geom.y + config.y;
5445 ec->client.x = config.x;
5446 ec->client.y = config.y;
5449 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5451 e_client_pos_set(ec, ec->client.x, ec->client.y);
5453 ec->changes.pos = 1;
5457 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5461 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5462 ec->surface_sync.wait_commit = EINA_FALSE;
5464 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5466 // rollback wait_commit if there are pending requests remained
5467 if (eina_list_count(ec->surface_sync.pending_geometry))
5468 ec->surface_sync.wait_commit = EINA_TRUE;
5473 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);
5480 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5481 struct wl_resource *res_moveresize)
5483 wl_resource_destroy(res_moveresize);
5487 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5488 struct wl_resource *res_moveresize,
5489 struct wl_resource *surface,
5496 /* to be implemented */
5499 int cur_w = 0, cur_h = 0;
5501 ec = e_client_from_surface_resource(surface);
5504 pending = e_client_pending_geometry_has(ec);
5505 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5506 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);
5510 if ((cur_w == w) && (cur_h == h))
5512 e_client_pos_set(ec, x, y);
5513 ec->changes.pos = 1;
5519 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5523 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5526 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5528 _tz_move_resize_iface_cb_destroy,
5529 _tz_move_resize_iface_cb_set_geometry,
5533 _tz_moveresize_cb_bind(struct wl_client *client,
5534 void *data EINA_UNUSED,
5538 struct wl_resource *res_moveresize;
5540 res_moveresize = wl_resource_create(client,
5541 &tizen_move_resize_interface,
5544 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5547 wl_resource_set_implementation(res_moveresize,
5548 &_tz_move_resize_iface,
5554 ERR("Could not create tizen_move_resize_interface res: %m");
5555 wl_client_post_no_memory(client);
5559 _e_comp_wl_move_resize_init(void)
5561 if (!e_comp_wl) return;
5562 if (!e_comp_wl->wl.disp) return;
5564 if (!wl_global_create(e_comp_wl->wl.disp,
5565 &tizen_move_resize_interface,
5568 _tz_moveresize_cb_bind))
5570 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5577 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5579 E_Comp_Wl_Output *output;
5580 pid_t output_pid = 0;
5581 Eina_List *l = NULL, *l2 = NULL;
5582 struct wl_resource *resource = NULL;
5584 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5586 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5587 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5588 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5590 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5592 /* if we have bound resources, send updates */
5593 EINA_LIST_FOREACH(output->resources, l2, resource)
5595 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5596 if (output_pid != pid) continue;
5598 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5600 // send output information to the client
5601 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5609 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5611 _e_comp_wl_surface_state_init(state, w, h);
5615 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5617 _e_comp_wl_surface_state_commit(ec, state);
5621 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5623 _e_comp_wl_hook_call(hookpoint, ec);
5627 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5629 _e_comp_wl_surface_state_finish(state);
5633 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5635 _e_comp_wl_surface_state_buffer_set(state, buffer);
5639 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5640 int sx, int sy, int *dx, int *dy)
5644 case WL_OUTPUT_TRANSFORM_NORMAL:
5648 case WL_OUTPUT_TRANSFORM_FLIPPED:
5649 *dx = width - sx, *dy = sy;
5651 case WL_OUTPUT_TRANSFORM_90:
5652 *dx = height - sy, *dy = sx;
5654 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5655 *dx = height - sy, *dy = width - sx;
5657 case WL_OUTPUT_TRANSFORM_180:
5658 *dx = width - sx, *dy = height - sy;
5660 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5661 *dx = sx, *dy = height - sy;
5663 case WL_OUTPUT_TRANSFORM_270:
5664 *dx = sy, *dy = width - sx;
5666 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5676 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5679 int tx1, ty1, tx2, ty2;
5680 int width_from_buffer, height_from_buffer;
5682 switch (vp->buffer.transform)
5684 case WL_OUTPUT_TRANSFORM_90:
5685 case WL_OUTPUT_TRANSFORM_270:
5686 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5687 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5688 width_from_buffer = bh / vp->buffer.scale;
5689 height_from_buffer = bw / vp->buffer.scale;
5692 width_from_buffer = bw / vp->buffer.scale;
5693 height_from_buffer = bh / vp->buffer.scale;
5697 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5701 x2 = width_from_buffer;
5702 y2 = height_from_buffer;
5706 x1 = wl_fixed_to_int(vp->buffer.src_x);
5707 y1 = wl_fixed_to_int(vp->buffer.src_y);
5708 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5709 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5712 buffer_transform(width_from_buffer, height_from_buffer,
5713 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5714 buffer_transform(width_from_buffer, height_from_buffer,
5715 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5717 out->x = (tx1 <= tx2) ? tx1 : tx2;
5718 out->y = (ty1 <= ty2) ? ty1 : ty2;
5719 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5720 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5724 * Convert given four coordinates to elements of rectangle
5725 * @in p[4] Coordinates to be converted
5726 * @out rect x, y, width, and height
5727 * transform Angle which represents TDM_TRANSFORM of rectangle
5728 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5729 * 1. The given coordinates are not represented by rectangle.
5730 * 2. All angles except for 0, 90, 180, 270.
5733 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5735 Eina_Bool ret = EINA_FALSE;
5737 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))
5740 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5743 *rotation = TDM_TRANSFORM_NORMAL;
5746 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5750 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5753 *rotation = TDM_TRANSFORM_180;
5756 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5761 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))
5764 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5767 *rotation = TDM_TRANSFORM_90;
5770 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5774 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5777 *rotation = TDM_TRANSFORM_270;
5780 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5790 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5795 for (i = 0; i < 4; i++)
5796 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5798 if (!_coords_to_rectangle_convert(p, out, rotation))
5800 DBG("Cannot convert given coords to rectangle.\n"
5801 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5802 p[0].x, p[0].y, p[1].x, p[1].y,
5803 p[2].x, p[2].y, p[3].x, p[3].y);
5811 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5813 int trans_rotation, flip;
5815 trans_rotation = transform & 0x3;
5816 flip = transform & 0x4;
5818 return (flip + (trans_rotation + rotation) % 4);
5822 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5830 if (e_comp_wl_subsurface_check(ec))
5831 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5838 out->w = ec->comp_data->width_from_viewport;
5839 out->w = (out->w + 1) & ~1;
5840 out->h = ec->comp_data->height_from_viewport;
5842 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5843 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5847 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5849 E_Comp_Wl_Buffer *buffer;
5850 E_Comp_Wl_Buffer_Viewport *vp;
5852 enum wl_output_transform buffer_transform;
5853 unsigned int rotation;
5854 Eina_Bool res = EINA_FALSE;
5856 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5858 if (e_object_is_del(E_OBJECT(ec)))
5861 vp = &ec->comp_data->scaler.buffer_viewport;
5863 if (buffer_viewport)
5865 buffer = ec->comp_data->buffer_ref.buffer;
5866 /* Getting a viewport of buffer needs geometry of buffer. */
5870 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5873 if ((output_viewport) || (transform))
5875 m = e_client_map_get(ec);
5877 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5879 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5884 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5885 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5886 * Since buffer.transform isn't applied using evas_map,
5887 * it has to be taken into account here to apply buffer.transform
5888 * and rotation of e_client_transform together. */
5890 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5892 *transform = (unsigned int)buffer_transform;
5900 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5902 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5903 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5905 /* Must be called with valid comp_data */
5906 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5908 if ((ec->comp_data->role_name == NULL) ||
5909 (ec->comp_data->role_name == role_name) ||
5910 (strcmp(ec->comp_data->role_name, role_name) == 0))
5912 ec->comp_data->role_name = role_name;
5918 wl_resource_post_error(error_resource, error_code,
5919 "Cannot assign role %s to wl_surface@%d,"
5920 " already has role %s\n",
5922 ec->comp_data->wl_surface ?
5923 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5924 ec->comp_data->role_name);
5930 EINTERN const char *
5931 e_comp_wl_surface_role_get(E_Client *ec)
5933 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5934 return ec->comp_data ? ec->comp_data->role_name : NULL;
5937 EINTERN struct wl_resource *
5938 e_comp_wl_client_surface_get(E_Client *ec)
5940 struct wl_resource *surface = NULL;
5941 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5942 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5944 g_mutex_lock(&ec->comp_data->surface_mutex);
5945 surface = ec->comp_data->surface;
5946 g_mutex_unlock(&ec->comp_data->surface_mutex);
5951 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5953 EINA_SAFETY_ON_NULL_RETURN(ec);
5954 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5956 g_mutex_lock(&ec->comp_data->surface_mutex);
5957 ec->comp_data->surface = surface;
5958 g_mutex_unlock(&ec->comp_data->surface_mutex);
5962 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5964 return e_compositor_util_client_from_surface_resource(surface_resource);
5968 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5970 if (!ec->comp_data->mapped)
5972 if (ec->comp_data->shell.surface &&
5973 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5975 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5981 if (ec->comp_data->mapped)
5983 /* will be unmapped. so run capture */
5984 e_comp_wl_remote_surface_image_save(ec);
5988 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5990 ec->comp_data->pending.sx = sx;
5991 ec->comp_data->pending.sy = sy;
5992 ec->comp_data->pending.new_attach = EINA_TRUE;
5994 e_client_fps_update(ec);
5998 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6000 if (ec->comp_data->pending.opaque)
6001 eina_tiler_clear(ec->comp_data->pending.opaque);
6005 eina_tiler_union(ec->comp_data->pending.opaque, region);
6007 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6011 ec->argb = EINA_FALSE;
6012 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6014 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6015 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6023 ec->argb = EINA_TRUE;
6024 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6026 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6027 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6033 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6035 if (ec->comp_data->pending.input)
6036 eina_tiler_clear(ec->comp_data->pending.input);
6040 if (eina_tiler_empty(region))
6042 ELOGF("COMP", " |unset input rect", NULL);
6043 e_comp_object_input_objs_del(ec->frame);
6044 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6047 eina_tiler_union(ec->comp_data->pending.input, region);
6051 eina_tiler_rect_add(ec->comp_data->pending.input,
6052 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6057 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6059 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6063 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6065 E_Comp_Wl_Subsurf_Data *sdata;
6070 if (ec->comp_data->frames)
6072 ec->comp_data->frames =
6073 eina_list_remove(ec->comp_data->frames, callback_resource);
6076 if (ec->comp_data->pending.frames)
6078 ec->comp_data->pending.frames =
6079 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6082 sdata = ec->comp_data->sub.data;
6083 if ((sdata) && (sdata->cached.frames))
6085 sdata->cached.frames =
6086 eina_list_remove(sdata->cached.frames, callback_resource);
6091 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6093 if (e_object_is_del(E_OBJECT(ec))) return;
6095 if (e_comp_wl_remote_surface_commit(ec)) return;
6097 e_comp_wl_surface_commit(ec);
6099 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6103 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6105 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6106 ec->comp_data->sub.data = sub;
6108 /* set subsurface client properties */
6109 ec->borderless = EINA_TRUE;
6110 ec->argb = EINA_TRUE;
6111 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6112 ec->lock_border = EINA_TRUE;
6113 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6114 ec->netwm.state.skip_taskbar = EINA_TRUE;
6115 ec->netwm.state.skip_pager = EINA_TRUE;
6116 ec->border_size = 0;
6117 ec->lock_user_location = 0;
6118 ec->lock_client_location = 0;
6119 ec->lock_user_size = 0;
6120 ec->lock_client_size = 0;
6121 ec->lock_client_stacking = 0;
6122 ec->lock_user_maximize = 0;
6123 ec->lock_client_maximize = 0;
6124 ec->changes.need_maximize = 0;
6125 ec->maximized = E_MAXIMIZE_NONE;
6128 ec->new_client = ec->netwm.ping = EINA_TRUE;
6129 e_comp->new_clients++;
6130 e_client_unignore(ec);
6132 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6133 * It's not for subsurface. */
6134 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6138 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6140 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6143 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6145 sub->parent = parent;
6149 layer = e_client_layer_get(parent);
6150 if (layer > E_LAYER_BOTTOM)
6151 e_client_layer_set(ec, layer);
6154 if (parent->comp_data)
6156 /* append this client to the parents subsurface list */
6157 parent->comp_data->sub.list_pending =
6158 eina_list_append(parent->comp_data->sub.list_pending, ec);
6159 parent->comp_data->sub.list_changed = EINA_TRUE;
6164 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6166 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6167 E_Client *parent = sub->parent;
6169 parent->comp_data->sub.list =
6170 eina_list_remove(parent->comp_data->sub.list, ec);
6171 parent->comp_data->sub.list_pending =
6172 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6173 parent->comp_data->sub.below_list =
6174 eina_list_remove(parent->comp_data->sub.below_list, ec);
6175 parent->comp_data->sub.below_list_pending =
6176 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6182 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)
6184 sub->resource = subsurface_resource;
6185 sub->cached_buffer_ref.buffer = NULL;
6186 sub->synchronized = EINA_TRUE;
6187 sub->parent = parent;
6188 sub->remote_surface.offscreen_parent = offscreen_parent;
6189 if (offscreen_parent)
6190 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6192 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6194 _e_comp_wl_client_subsurface_set(ec, sub);
6195 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6197 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6201 e_comp_wl_client_subsurface_finish(E_Client *ec)
6203 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6206 e_comp_wl_client_subsurface_parent_unset(ec);
6208 e_comp_wl_surface_state_finish(&sub->cached);
6209 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6211 ec->comp_data->sub.data = NULL;
6215 e_comp_wl_client_evas_init(E_Client *ec)
6217 EINA_SAFETY_ON_NULL_RETURN(ec);
6219 _e_comp_wl_client_evas_init(ec);
6223 e_comp_wl_client_evas_deinit(E_Client *ec)
6225 EINA_SAFETY_ON_NULL_RETURN(ec);
6227 _e_comp_wl_client_evas_deinit(ec);
6231 e_comp_wl_focus_check(void)
6233 _e_comp_wl_focus_check();
6237 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6244 if ((parent->comp_data) && (parent->comp_data->sub.data))
6245 parent = parent->comp_data->sub.data->parent;