2 #include "e_comp_wl_intern.h"
3 #include "e_foreign_intern.h"
4 #include "e_wtz_shell_intern.h"
5 #include "e_client_intern.h"
6 #include "e_appinfo_intern.h"
7 #include "e_blender_intern.h"
8 #include "e_utils_intern.h"
9 #include "e_scale_intern.h"
10 #include "e_comp_canvas_intern.h"
11 #include "e_comp_screen_intern.h"
12 #include "e_comp_wl_capture_intern.h"
13 #include "e_comp_wl_data_intern.h"
14 #include "e_comp_wl_input_intern.h"
15 #include "e_comp_wl_renderer_intern.h"
16 #include "e_comp_wl_rsm_intern.h"
17 #include "e_comp_wl_screenshooter_intern.h"
18 #include "e_comp_wl_shell_intern.h"
19 #include "e_comp_wl_subsurface_intern.h"
20 #include "e_comp_wl_tbm_intern.h"
21 #include "e_comp_wl_viewport_intern.h"
22 #include "e_comp_intern.h"
23 #include "e_input_intern.h"
24 #include "e_keyrouter_intern.h"
25 #include "e_error_intern.h"
26 #include "e_pointer_intern.h"
27 #include "e_presentation_time_intern.h"
28 #include "e_grabinput_intern.h"
29 #include "e_env_intern.h"
30 #include "e_dnd_intern.h"
31 #include "e_policy_visibility_intern.h"
32 #include "e_compositor_intern.h"
33 #include "e_client_video_intern.h"
34 #include "e_comp_wl_video_intern.h"
35 #include "e_comp_object_intern.h"
36 #include "e_desk_intern.h"
38 #include <tizen-extension-server-protocol.h>
39 #include <relative-pointer-unstable-v1-server-protocol.h>
40 #include <pointer-constraints-unstable-v1-server-protocol.h>
42 #include <wayland-tbm-server.h>
44 #include <libds/log.h>
45 #include <libds/single_pixel_buffer_v1.h>
48 /* handle include for printing uint64_t */
49 #define __STDC_FORMAT_MACROS
52 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
54 /* Resource Data Mapping: (wl_resource_get_user_data)
56 * wl_surface == e_pixmap
57 * wl_region == eina_tiler
58 * wl_subsurface == e_client
62 typedef struct _E_Comp_Data E_Comp_Data;
67 struct wl_listener client_created;
70 static void _e_comp_wl_move_resize_init(void);
72 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
75 typedef struct _E_Comp_Wl_Key_Data
81 struct _E_Comp_Wl_Evas_Gl
84 Evas_GL_Config *glcfg;
85 Evas_GL_Context *glctx;
86 Evas_GL_Surface *glsfc;
90 static Eina_List *handlers = NULL;
91 static E_Client *cursor_timer_ec = NULL;
92 static Eina_Bool need_send_released = EINA_FALSE;
93 static Eina_Bool need_send_motion = EINA_TRUE;
95 static GMutex connection_mutex;
97 static int _e_comp_wl_hooks_delete = 0;
98 static int _e_comp_wl_hooks_walking = 0;
100 static int _e_comp_wl_pid_hooks_delete = 0;
101 static int _e_comp_wl_pid_hooks_walking = 0;
103 static int _e_comp_wl_intercept_hooks_delete = 0;
104 static int _e_comp_wl_intercept_hooks_walking = 0;
106 static Eina_Inlist *_e_comp_wl_hooks[] =
108 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
109 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
110 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
111 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
112 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
113 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
114 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
115 [E_COMP_WL_HOOK_DEL] = NULL,
116 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
117 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
118 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
121 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
123 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
126 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
128 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
129 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
130 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
131 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
132 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
133 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
136 static Eina_List *hooks = NULL;
138 /* local functions */
140 _e_comp_wl_hooks_clean(void)
145 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
146 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
148 if (!ch->delete_me) continue;
149 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
155 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
159 e_object_ref(E_OBJECT(ec));
160 _e_comp_wl_hooks_walking++;
161 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
163 if (ch->delete_me) continue;
164 ch->func(ch->data, ec);
165 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
166 (e_object_is_del(E_OBJECT(ec))))
169 _e_comp_wl_hooks_walking--;
170 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
171 _e_comp_wl_hooks_clean();
172 e_object_unref(E_OBJECT(ec));
176 _e_comp_wl_pid_hooks_clean(void)
179 E_Comp_Wl_Pid_Hook *ch;
181 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
182 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
184 if (!ch->delete_me) continue;
185 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
191 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
193 E_Comp_Wl_Pid_Hook *ch;
195 _e_comp_wl_pid_hooks_walking++;
196 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
198 if (ch->delete_me) continue;
199 ch->func(ch->data, pid);
201 _e_comp_wl_pid_hooks_walking--;
202 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
203 _e_comp_wl_pid_hooks_clean();
207 _e_comp_wl_intercept_hooks_clean(void)
210 E_Comp_Wl_Intercept_Hook *ch;
212 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
213 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
215 if (!ch->delete_me) continue;
216 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
222 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
224 E_Comp_Wl_Intercept_Hook *ch;
225 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
227 e_object_ref(E_OBJECT(ec));
228 _e_comp_wl_intercept_hooks_walking++;
229 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
231 if (ch->delete_me) continue;
232 res = ch->func(ch->data, ec);
233 if (!res) ret = EINA_FALSE;
234 if (e_object_is_del(E_OBJECT(ec)))
237 _e_comp_wl_intercept_hooks_walking--;
238 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
239 _e_comp_wl_intercept_hooks_clean();
240 e_object_unref(E_OBJECT(ec));
247 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
253 if (e_comp_object_frame_exists(ec->frame))
254 w = ec->client.w, h = ec->client.h;
256 w = ec->w, h = ec->h;
260 // Width and Height are -1 means that we don't consider size value
264 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
268 _e_comp_wl_focus_check(void)
272 if (stopping) return;
273 ec = e_client_focused_get();
275 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
279 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
281 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
283 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
284 IDLE_EXITER~CB_PREPARE);
286 return ECORE_CALLBACK_RENEW;
290 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
292 /* dispatch pending wayland events */
293 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
295 return ECORE_CALLBACK_RENEW;
299 e_comp_wl_display_flush()
301 if (e_comp_wl && e_comp_wl->wl.disp)
303 if (e_config->key_input_ttrace_enable)
305 TRACE_INPUT_BEGIN(wl_display_flush_clients);
306 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
309 g_mutex_lock(&connection_mutex);
310 wl_display_flush_clients(e_comp_wl->wl.disp);
311 g_mutex_unlock(&connection_mutex);
313 if (e_config->key_input_ttrace_enable)
316 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
322 e_comp_wl_connection_lock()
324 e_input_boost_lock(&connection_mutex);
328 e_comp_wl_connection_unlock()
330 e_input_boost_unlock(&connection_mutex);
334 e_comp_wl_focused_client_flush()
336 E_Client *focused_ec;
337 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
339 e_input_boost_lock(&connection_mutex);
340 focused_ec = e_client_focused_get();
344 struct wl_client *wc;
345 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
348 e_input_boost_unlock(&connection_mutex);
352 wc = wl_resource_get_client(surface);
356 e_input_boost_unlock(&connection_mutex);
360 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
364 if (e_comp_wl->idle_exiter_timestamp > 0.0)
366 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
367 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
369 ELOGF("E_COMP", "prepare gap time: %lfms",
374 e_comp_wl->idle_exiter_timestamp = 0.0;
376 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
378 /* flush pending client events */
379 e_comp_wl_display_flush();
381 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
382 IDLE_EXITER~CB_PREPARE);
385 E_API enum wl_output_transform
386 e_comp_wl_output_buffer_transform_get(E_Client *ec)
388 E_Comp_Wl_Buffer_Viewport *vp;
389 E_Comp_Wl_Buffer *buffer;
390 enum wl_output_transform transform, rotation;
392 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
393 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
394 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
396 vp = &ec->comp_data->scaler.buffer_viewport;
397 if (e_comp_wl_subsurface_check(ec))
398 return vp->buffer.transform;
400 buffer = ec->comp_data->buffer_ref.buffer;
403 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
404 return vp->buffer.transform;
406 rotation = buffer->transform;
408 return vp->buffer.transform;
410 /* ignore the flip value when calculating transform because the screen rotation
411 * functionality doesn't consider the flip output transform currently
413 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
415 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
416 ec, rotation, vp->buffer.transform, transform);
421 EINTERN enum wl_output_transform
422 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
424 E_Comp_Wl_Buffer_Viewport *vp;
425 E_Comp_Wl_Buffer *buffer;
426 enum wl_output_transform transform, rotation;
428 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
429 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
430 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
432 vp = &ec->comp_data->pending.buffer_viewport;
433 if (e_comp_wl_subsurface_check(ec))
434 return vp->buffer.transform;
436 buffer = ec->comp_data->pending.buffer;
439 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
440 return vp->buffer.transform;
442 rotation = buffer->transform;
444 return vp->buffer.transform;
446 /* ignore the flip value when calculating transform because the screen rotation
447 * functionality doesn't consider the flip output transform currently
449 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
451 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
452 ec, rotation, vp->buffer.transform, transform);
458 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
460 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
461 E_Comp_Wl_Buffer *buffer;
462 int32_t width, height;
464 buffer = e_pixmap_resource_get(ec->pixmap);
467 ec->comp_data->width_from_buffer = 0;
468 ec->comp_data->height_from_buffer = 0;
472 switch (e_comp_wl_output_buffer_transform_get(ec))
474 case WL_OUTPUT_TRANSFORM_90:
475 case WL_OUTPUT_TRANSFORM_270:
476 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
477 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
478 width = buffer->h / vp->buffer.scale;
479 height = buffer->w / vp->buffer.scale;
482 width = buffer->w / vp->buffer.scale;
483 height = buffer->h / vp->buffer.scale;
487 ec->comp_data->width_from_buffer = width;
488 ec->comp_data->height_from_buffer = height;
492 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
494 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
495 int32_t width, height;
497 width = ec->comp_data->width_from_buffer;
498 height = ec->comp_data->height_from_buffer;
500 if (width == 0 && height == 0) return;
502 if (width != 0 && vp->surface.width != -1)
504 ec->comp_data->width_from_viewport = vp->surface.width;
505 ec->comp_data->height_from_viewport = vp->surface.height;
509 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
511 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
512 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
513 ec->comp_data->width_from_viewport = w ?: 1;
514 ec->comp_data->height_from_viewport = h ?: 1;
518 ec->comp_data->width_from_viewport = width;
519 ec->comp_data->height_from_viewport = height;
523 e_comp_wl_topmost_parent_get(E_Client *ec)
527 if (!e_comp_wl_subsurface_check(ec))
530 parent = e_comp_wl_subsurface_parent_get(ec);
533 if (!e_comp_wl_subsurface_check(parent))
536 parent = e_comp_wl_subsurface_parent_get(parent);
543 e_comp_wl_map_apply(E_Client *ec)
545 E_Comp_Wl_Buffer_Viewport *vp;
546 E_Comp_Wl_Subsurf_Data *sdata;
547 E_Comp_Wl_Client_Data *cdata;
548 int x1, y1, x2, y2, x, y;
550 Eina_Bool zoom_animating = EINA_FALSE;
552 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
554 e_comp_object_map_update(ec->frame);
556 cdata = ec->comp_data;
557 vp = &cdata->scaler.buffer_viewport;
558 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
559 (!cdata->viewport_transform))
562 if (e_comp_wl_subsurface_check(ec))
564 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
566 sdata = ec->comp_data->sub.data;
567 if (sdata->remote_surface.offscreen_parent)
569 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
570 Eina_Rectangle *rect;
573 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
575 /* TODO: If there are one more regions, it means that provider's offscreen
576 * is displayed by one more remote_surfaces. Have to consider it later. At
577 * this time, just consider only one remote_surface.
591 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
592 if (x != dx || y != dy)
593 evas_object_move(ec->frame, dx, dy);
595 if (!cdata->viewport_transform)
597 cdata->viewport_transform = e_util_transform_new();
598 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
599 e_client_transform_core_add(ec, cdata->viewport_transform);
602 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
603 ec->comp_data->width_from_viewport,
604 ec->comp_data->height_from_viewport);
606 if (vp->buffer.src_width == wl_fixed_from_int(-1))
610 x2 = cdata->width_from_buffer;
611 y2 = cdata->height_from_buffer;
615 x1 = wl_fixed_to_int(vp->buffer.src_x);
616 y1 = wl_fixed_to_int(vp->buffer.src_y);
617 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
618 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
621 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
622 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
623 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
624 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
627 desk = e_comp_desk_find_by_ec(ec);
629 zoom_animating = e_desk_zoom_is_animating(desk);
631 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
632 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
633 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
635 /* workaround:: when the desk zoom is doing their animation,
636 the transform core update can override animation's zoom boundary.
637 so, don't doing transform core update while desk zoom animation */
639 e_client_transform_core_update(ec);
644 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
648 int map_c = 0, map_x = 0, map_y = 0;
649 double inv_x = 0.0, inv_y = 0.0;
651 EINA_SAFETY_ON_NULL_RETURN(ec);
653 map = e_client_map_get(ec);
654 map_c = e_map_count_get(map);
656 if (!map || map_c <= 0)
666 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
667 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
668 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
669 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
671 for (int i = 0; i < map_c; i++)
673 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
674 e_map_point_image_uv_set(map2, i, map_x, map_y);
676 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
686 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
692 if (!(ec = data)) return;
693 if (e_object_is_del(data)) return;
695 if (!ec->override) e_hints_window_visible_set(ec);
697 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
698 (!ec->comp_data->need_reparent))
700 ec->comp_data->need_reparent = EINA_TRUE;
701 ec->visible = EINA_TRUE;
703 if (!e_client_util_ignored_get(ec))
705 ec->take_focus = !starting;
709 if (!ec->comp_data->need_reparent)
711 if ((ec->hidden) || (ec->iconic))
713 evas_object_hide(ec->frame);
714 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
717 evas_object_show(ec->frame);
720 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
721 evas_object_show(tmp->frame);
723 topmost = e_comp_wl_topmost_parent_get(ec);
724 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
725 e_comp_wl_subsurface_show(ec);
727 if (ec->comp_data->sub.below_obj)
728 evas_object_show(ec->comp_data->sub.below_obj);
732 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
738 if (!(ec = data)) return;
739 if (e_object_is_del(E_OBJECT(ec))) return;
741 /* Uncommonly some clients's final buffer can be skipped if the client
742 * requests unmap of its surface right after wl_surface@commit.
743 * So if this client evas object is hidden state and client is already
744 * unmmapped, we can consider to clear pixmap image here mandatorily.
746 if (!ec->comp_data->mapped)
747 e_pixmap_image_clear(ec->pixmap, 1);
749 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
750 evas_object_hide(tmp->frame);
752 topmost = e_comp_wl_topmost_parent_get(ec);
753 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
754 e_comp_wl_subsurface_hide(ec);
756 if (ec->comp_data->sub.below_obj)
757 evas_object_hide(ec->comp_data->sub.below_obj);
759 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
763 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
770 if (!(ec = data)) return;
771 if (e_object_is_del(E_OBJECT(ec))) return;
773 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
775 if (!e_comp_wl_subsurface_check(subc)) continue;
776 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
777 evas_object_move(subc->frame, x, y);
779 if (subc->comp_data->scaler.viewport)
781 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
782 if (cdata->viewport_transform)
783 e_comp_wl_map_apply(subc);
787 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
789 if (!e_comp_wl_subsurface_check(subc)) continue;
790 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
791 evas_object_move(subc->frame, x, y);
793 if (subc->comp_data->scaler.viewport)
795 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
796 if (cdata->viewport_transform)
797 e_comp_wl_map_apply(subc);
801 if (ec->comp_data->sub.below_obj)
803 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
804 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
809 _e_comp_wl_send_touch_cancel(E_Client *ec)
812 struct wl_resource *res;
813 struct wl_client *wc;
814 E_Comp_Config *comp_conf = NULL;
817 if (e_object_is_del(E_OBJECT(ec))) return;
818 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
820 if (!surface) return;
821 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
823 wc = wl_resource_get_client(surface);
825 comp_conf = e_comp_config_get();
827 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
829 if (wl_resource_get_client(res) != wc) continue;
830 if (!e_comp_wl_input_touch_check(res)) continue;
832 if (comp_conf && comp_conf->input_log_enable)
833 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
835 wl_touch_send_cancel(res);
840 _e_comp_wl_touch_cancel(void)
844 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
846 if (!e_comp_wl->touch.pressed) return;
848 _e_comp_wl_send_touch_cancel(ec);
851 static E_Devicemgr_Input_Device *
852 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
854 E_Devicemgr_Input_Device *last_kbd = NULL;
857 case ECORE_DEVICE_CLASS_MOUSE:
858 return e_devicemgr->last_device_ptr;
859 case ECORE_DEVICE_CLASS_KEYBOARD:
860 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
862 case ECORE_DEVICE_CLASS_TOUCH:
863 return e_devicemgr->last_device_touch;
871 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
875 case ECORE_DEVICE_CLASS_MOUSE:
876 e_devicemgr->last_device_ptr = device;
878 case ECORE_DEVICE_CLASS_KEYBOARD:
879 atomic_store(&e_devicemgr->last_device_kbd, device);
881 case ECORE_DEVICE_CLASS_TOUCH:
882 e_devicemgr->last_device_touch = device;
889 static E_Devicemgr_Input_Device *
890 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
892 E_Devicemgr_Input_Device *last_kbd = NULL;
896 case ECORE_DEVICE_CLASS_MOUSE:
897 return ec->comp_data->last_device_ptr;
898 case ECORE_DEVICE_CLASS_KEYBOARD:
899 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
901 case ECORE_DEVICE_CLASS_TOUCH:
902 return ec->comp_data->last_device_touch;
910 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
914 case ECORE_DEVICE_CLASS_MOUSE:
915 ec->comp_data->last_device_ptr = device;
917 case ECORE_DEVICE_CLASS_KEYBOARD:
918 atomic_store(&ec->comp_data->last_device_kbd, device);
920 case ECORE_DEVICE_CLASS_TOUCH:
921 ec->comp_data->last_device_touch = device;
929 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
931 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
932 struct wl_resource *dev_res;
933 const char *dev_name;
934 Ecore_Device_Class dev_class;
935 struct wl_client *wc;
939 EINA_SAFETY_ON_NULL_RETURN(dev);
942 if (ec->cur_mouse_action || e_comp_wl->drag)
944 if (e_object_is_del(E_OBJECT(ec))) return;
945 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
946 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
947 if (!surface) return;
949 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
950 dev_name = evas_device_description_get(dev);
951 last_device = _e_comp_wl_device_last_device_get(dev_class);
952 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
954 serial = wl_display_next_serial(e_comp_wl->wl.disp);
955 wc = wl_resource_get_client(surface);
956 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
957 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
959 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
960 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
962 _e_comp_wl_device_last_device_set(dev_class, input_dev);
963 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
965 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
967 if (wl_resource_get_client(dev_res) != wc) continue;
968 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
972 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
976 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
978 E_Devicemgr_Input_Device *last_device;
979 struct wl_resource *dev_res;
980 struct wl_client *wc;
984 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
985 if (!surface) return;
987 last_device = _e_comp_wl_device_last_device_get(dev_class);
988 if (!last_device) return;
990 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
992 serial = wl_display_next_serial(e_comp_wl->wl.disp);
993 wc = wl_resource_get_client(surface);
994 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
996 if (wl_resource_get_client(dev_res) != wc) continue;
997 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
1002 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1004 E_Devicemgr_Input_Device *input_dev;
1005 struct wl_resource *dev_res;
1006 const char *dev_name;
1009 EINA_SAFETY_ON_NULL_RETURN(dev);
1011 dev_name = ecore_device_identifier_get(dev);
1013 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1014 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1016 if (!eina_streq(input_dev->identifier, dev_name) ||
1017 (input_dev->clas != ecore_device_class_get(dev))) continue;
1018 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1020 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1022 if (wl_resource_get_client(dev_res) != wc) continue;
1023 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1026 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1030 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1032 E_Devicemgr_Input_Device *input_dev;
1033 struct wl_resource *dev_res;
1034 const char *dev_name;
1037 EINA_SAFETY_ON_NULL_RETURN(dev);
1039 dev_name = e_device_identifier_get(dev);
1041 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1042 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1044 if (!eina_streq(input_dev->identifier, dev_name) ||
1045 (input_dev->clas != e_device_class_get(dev))) continue;
1046 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1048 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1050 if (wl_resource_get_client(dev_res) != wc) continue;
1051 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1054 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1058 _e_comp_wl_cursor_reload(E_Client *ec)
1060 struct wl_resource *res;
1061 struct wl_client *wc;
1067 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1068 !evas_object_visible_get(e_comp->pointer->o_ptr))
1069 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1072 if (e_object_is_del(E_OBJECT(ec))) return;
1073 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1074 if (!surface) return;
1075 if (ec->pointer_enter_sent) return;
1077 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1078 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1080 if (e_client_transform_core_enable_get(ec))
1082 double dx = 0.0, dy = 0.0;
1083 map = e_client_map_get(ec);
1084 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1090 cx = px - ec->client.x;
1091 cy = py - ec->client.y;
1093 wc = wl_resource_get_client(surface);
1094 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1095 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1097 if (!e_comp_wl_input_pointer_check(res)) continue;
1098 if (wl_resource_get_client(res) != wc) continue;
1099 wl_pointer_send_enter(res, serial, surface,
1100 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1101 ec->pointer_enter_sent = EINA_TRUE;
1103 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1107 _e_comp_wl_cursor_timer(void *data)
1109 E_Client *ec = data;
1111 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1112 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1114 e_comp_wl_cursor_hide(ec);
1116 return ECORE_CALLBACK_CANCEL;
1120 _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)
1122 E_Devicemgr_Input_Device *input_dev;
1123 struct wl_resource *dev_res;
1124 struct wl_client *wc;
1129 if (ec->cur_mouse_action) return;
1130 if (e_object_is_del(E_OBJECT(ec))) return;
1131 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1132 if (!surface) return;
1134 f_value = wl_fixed_from_double(value);
1135 wc = wl_resource_get_client(surface);
1137 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1138 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1140 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1141 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1143 if (wl_resource_get_client(dev_res) != wc) continue;
1144 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1147 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1151 _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)
1153 if (idx >= e_input_touch_max_count_get()) return;
1155 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1156 e_devicemgr->multi[idx].radius_x = radius_x;
1157 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1158 e_devicemgr->multi[idx].radius_y = radius_y;
1159 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1160 e_devicemgr->multi[idx].pressure = pressure;
1161 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1162 e_devicemgr->multi[idx].angle = angle;
1166 _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)
1168 if (idx >= e_input_touch_max_count_get()) return;
1170 if (e_devicemgr->multi[idx].radius_x != radius_x)
1172 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1173 e_devicemgr->multi[idx].radius_x = radius_x;
1175 if (e_devicemgr->multi[idx].radius_y != radius_y)
1177 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1178 e_devicemgr->multi[idx].radius_y = radius_y;
1180 if (e_devicemgr->multi[idx].pressure != pressure)
1182 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1183 e_devicemgr->multi[idx].pressure = pressure;
1185 if (e_devicemgr->multi[idx].angle != angle)
1187 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1188 e_devicemgr->multi[idx].angle = angle;
1193 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1195 Eina_Bool ret = EINA_TRUE;
1198 case EVAS_CALLBACK_MOUSE_IN:
1199 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1202 if (e_comp_wl->ptr.hide_tmr)
1204 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1205 cursor_timer_ec = ec;
1206 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1210 if (e_pointer_is_hidden(e_comp->pointer))
1215 case EVAS_CALLBACK_MOUSE_OUT:
1216 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1219 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1223 case EVAS_CALLBACK_MOUSE_MOVE:
1224 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1227 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1228 _e_comp_wl_cursor_reload(ec);
1231 case EVAS_CALLBACK_MOUSE_WHEEL:
1232 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1235 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1236 _e_comp_wl_cursor_reload(ec);
1239 case EVAS_CALLBACK_MOUSE_DOWN:
1240 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1243 if (e_comp_wl->ptr.hide_tmr)
1245 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1246 e_comp_wl->ptr.hide_tmr = NULL;
1248 cursor_timer_ec = NULL;
1250 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1251 _e_comp_wl_cursor_reload(ec);
1254 case EVAS_CALLBACK_MOUSE_UP:
1255 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1266 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1268 if (ec->has_cursor_unset)
1271 if (!e_config->show_cursor)
1274 if (!e_config->use_cursor_timer)
1281 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1284 Evas_Event_Mouse_In *ev;
1285 struct wl_resource *res;
1286 struct wl_client *wc;
1289 E_Comp_Config *comp_conf;
1290 E_Client *prev_ptr_ec;
1294 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1295 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1297 if (!(ec = data)) return;
1298 if (e_object_is_del(E_OBJECT(ec))) return;
1299 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1300 if (!surface) return;
1302 prev_ptr_ec = e_comp_wl->ptr.ec;
1305 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1306 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1309 e_comp_wl->ptr.ec = ec;
1311 comp_conf = e_comp_config_get();
1312 if (comp_conf && comp_conf->input_log_enable)
1313 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1314 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1315 e_client_util_name_get(ec));
1317 if (_e_comp_wl_check_cursor_timer_needed(ec))
1319 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1323 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1324 wc = wl_resource_get_client(surface);
1325 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1326 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1328 if (!e_comp_wl_input_pointer_check(res)) continue;
1329 if (wl_resource_get_client(res) != wc) continue;
1331 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1333 wl_pointer_send_enter(res, serial, surface,
1334 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1335 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1336 ec->pointer_enter_sent = EINA_TRUE;
1339 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1343 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1346 Evas_Event_Mouse_Out *ev;
1347 struct wl_resource *res;
1348 struct wl_client *wc;
1351 Eina_Bool inside_check;
1352 E_Comp_Config *comp_conf;
1356 if (!(ec = data)) return;
1357 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1358 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1359 if (ec->cur_mouse_action && inside_check) return;
1360 if (e_object_is_del(E_OBJECT(e_comp))) return;
1361 if (e_comp_wl->ptr.ec == ec)
1362 e_comp_wl->ptr.ec = NULL;
1363 if (e_object_is_del(E_OBJECT(ec))) return;
1365 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1366 if (!surface) return;
1368 comp_conf = e_comp_config_get();
1369 if (comp_conf && comp_conf->input_log_enable)
1370 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1371 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1372 e_client_util_name_get(ec));
1374 if (_e_comp_wl_check_cursor_timer_needed(ec))
1376 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1380 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1382 wc = wl_resource_get_client(surface);
1383 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1384 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1386 if (!e_comp_wl_input_pointer_check(res)) continue;
1387 if (wl_resource_get_client(res) != wc) continue;
1388 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1390 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1392 wl_pointer_send_leave(res, serial, surface);
1393 ec->pointer_enter_sent = EINA_FALSE;
1398 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1401 struct wl_client *wc;
1402 struct wl_resource *res;
1405 E_Comp_Config *comp_conf = NULL;
1408 if (e_object_is_del(E_OBJECT(ec))) return;
1409 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1410 if (!surface) return;
1412 wc = wl_resource_get_client(surface);
1413 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1417 x = wl_fixed_from_int(canvas_x - ec->client.x);
1418 y = wl_fixed_from_int(canvas_y - ec->client.y);
1421 comp_conf = e_comp_config_get();
1423 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1425 if (wl_resource_get_client(res) != wc) continue;
1426 if (!e_comp_wl_input_touch_check(res)) continue;
1427 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1430 if (comp_conf && comp_conf->input_log_enable)
1431 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));
1433 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1437 if (comp_conf && comp_conf->input_log_enable)
1438 ELOGF("Touch", "Up (id: %d, time: %d, x:%d, y:%d, name:%20s)\n", ec, idx, timestamp, canvas_x - ec->client.x, canvas_y - ec->client.y, e_client_util_name_get(ec));
1440 wl_touch_send_up(res, serial, timestamp, idx);
1447 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1450 struct wl_client *wc;
1451 struct wl_resource *res;
1455 if (ec->cur_mouse_action) return;
1456 if (e_object_is_del(E_OBJECT(ec))) return;
1457 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1458 if (!surface) return;
1460 wc = wl_resource_get_client(surface);
1462 x = wl_fixed_from_int(canvas_x - ec->client.x);
1463 y = wl_fixed_from_int(canvas_y - ec->client.y);
1465 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1467 if (wl_resource_get_client(res) != wc) continue;
1468 if (!e_comp_wl_input_touch_check(res)) continue;
1469 wl_touch_send_motion(res, timestamp, idx, x, y);
1474 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1476 struct wl_resource *res;
1477 struct wl_client *wc;
1481 if (ec->cur_mouse_action) return;
1482 if (e_object_is_del(E_OBJECT(ec))) return;
1483 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1484 if (!surface) return;
1486 wc = wl_resource_get_client(surface);
1487 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1489 if (!e_comp_wl_input_pointer_check(res)) continue;
1490 if (wl_resource_get_client(res) != wc) continue;
1491 wl_pointer_send_motion(res, timestamp,
1492 wl_fixed_from_int(x - ec->client.x),
1493 wl_fixed_from_int(y - ec->client.y));
1498 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1500 if (e_comp_wl->ptr.hide_tmr)
1502 if (cursor_timer_ec == ec)
1504 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1505 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1509 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1510 cursor_timer_ec = ec;
1511 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1516 cursor_timer_ec = ec;
1517 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1522 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1525 Evas_Event_Mouse_Move *ev;
1526 Evas_Device *dev = NULL;
1527 const char *dev_name;
1528 E_Comp_Config *comp_conf;
1532 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1533 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1535 if (!(ec = data)) return;
1536 if (e_object_is_del(E_OBJECT(ec))) return;
1537 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1538 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1539 if (!surface) return;
1541 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1544 dev_name = evas_device_description_get(dev);
1546 comp_conf = e_comp_config_get();
1547 if (comp_conf && comp_conf->input_log_enable)
1548 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1549 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1550 e_client_util_name_get(ec), dev_name);
1552 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1554 if (!e_comp_wl->drag_client)
1556 e_comp_wl->touch.faked_ec = ec;
1557 if (e_comp_wl->touch.pressed & (1 << 0))
1559 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1561 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1562 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1563 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1567 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1571 if (!e_comp_wl->drag_client)
1573 if (_e_comp_wl_check_cursor_timer_needed(ec))
1575 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1579 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1580 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1582 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1584 if (_e_comp_wl_check_cursor_timer_needed(ec))
1585 _e_comp_wl_cursor_move_timer_control(ec);
1589 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1594 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1596 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1597 if (e_object_is_del(E_OBJECT(ec))) return;
1598 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1599 if (!surface) return;
1600 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1602 e_comp_wl->ptr.button = BTN_LEFT;
1604 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1608 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1610 E_Client *ec = data;
1611 Evas_Event_Mouse_Down *ev = event;
1612 Evas_Device *dev = NULL;
1613 const Evas_Device *seat_dev;
1614 const char *dev_name, *seat_name;
1615 E_Comp_Config *comp_conf = NULL;
1618 if (e_object_is_del(E_OBJECT(ec))) return;
1621 dev_name = evas_device_description_get(dev);
1623 seat_dev = evas_device_parent_get(dev);
1624 seat_name = evas_device_name_get(seat_dev);
1626 comp_conf = e_comp_config_get();
1627 if (comp_conf && comp_conf->input_log_enable)
1628 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1629 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1630 dev_name, seat_name);
1632 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1634 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1636 e_comp_wl->touch.faked_ec = ec;
1639 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1640 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1641 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1643 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1644 e_comp_wl->touch.pressed |= (1 << 0);
1648 if (_e_comp_wl_check_cursor_timer_needed(ec))
1650 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1654 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1655 WL_POINTER_BUTTON_STATE_PRESSED);
1657 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1660 need_send_released = EINA_TRUE;
1664 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1666 E_Client *ec = data;
1667 Evas_Event_Mouse_Up *ev = event;
1668 Evas_Device *dev = NULL;
1669 const Evas_Device *seat_dev;
1670 const char *dev_name, *seat_name;;
1671 Evas_Event_Flags flags;
1672 E_Comp_Config *comp_conf = NULL;
1675 if (ec->cur_mouse_action) return;
1676 if (e_object_is_del(E_OBJECT(ec))) return;
1678 if (!need_send_released)
1680 need_send_motion = EINA_TRUE;
1684 dev_name = evas_device_description_get(dev);
1686 seat_dev = evas_device_parent_get(dev);
1687 seat_name = evas_device_name_get(seat_dev);
1688 flags = evas_event_default_flags_get(evas);
1690 comp_conf = e_comp_config_get();
1691 if (comp_conf && comp_conf->input_log_enable)
1692 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1693 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1694 dev_name, seat_name);
1696 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1698 e_comp_wl->touch.pressed &= ~(1 << 0);
1700 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1701 e_comp_wl->touch.faked_ec = NULL;
1704 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1706 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1708 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1711 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1712 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1713 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1717 if (_e_comp_wl_check_cursor_timer_needed(ec))
1719 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1723 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1724 WL_POINTER_BUTTON_STATE_RELEASED);
1726 if (_e_comp_wl_check_cursor_timer_needed(ec))
1727 _e_comp_wl_cursor_move_timer_control(ec);
1731 need_send_released = EINA_FALSE;
1735 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1737 struct wl_resource *res;
1738 struct wl_client *wc;
1743 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1745 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1748 dir = -wl_fixed_from_int(abs(z));
1750 dir = wl_fixed_from_int(z);
1753 if (e_object_is_del(E_OBJECT(ec))) return;
1754 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1755 if (!surface) return;
1757 wc = wl_resource_get_client(surface);
1758 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1760 if (!e_comp_wl_input_pointer_check(res)) continue;
1761 if (wl_resource_get_client(res) != wc) continue;
1762 wl_pointer_send_axis(res, timestamp, axis, dir);
1767 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1770 Evas_Event_Mouse_Wheel *ev;
1773 if (!(ec = data)) return;
1774 if (ec->cur_mouse_action) return;
1775 if (e_object_is_del(E_OBJECT(ec))) return;
1776 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1777 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1778 if (!surface) return;
1780 if (!eina_list_count(e_comp_wl->ptr.resources))
1783 if (_e_comp_wl_check_cursor_timer_needed(ec))
1785 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1789 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1791 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1793 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1795 if (_e_comp_wl_check_cursor_timer_needed(ec))
1796 _e_comp_wl_cursor_move_timer_control(ec);
1801 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1803 E_Client *ec = data;
1804 Evas_Event_Multi_Down *ev = event;
1805 Evas_Device *dev = NULL;
1806 const Evas_Device *seat_dev;
1807 const char *dev_name, *seat_name;
1808 Evas_Device_Class dev_class;
1809 E_Comp_Config *comp_conf = NULL;
1812 if (e_object_is_del(E_OBJECT(ec))) return;
1813 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1814 if (!surface) return;
1816 /* Do not deliver emulated single touch events to client */
1817 if (ev->device == 0) return;
1820 dev_name = evas_device_description_get(dev);
1821 e_comp_wl->touch.faked_ec = ec;
1823 seat_dev = evas_device_parent_get(dev);
1824 seat_name = evas_device_name_get(seat_dev);
1826 comp_conf = e_comp_config_get();
1827 if (comp_conf && comp_conf->input_log_enable)
1828 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1829 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1830 dev_name, seat_name);
1832 if (dev && dev_name)
1834 dev_class = evas_device_class_get(dev);
1835 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1836 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1839 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1840 e_comp_wl->touch.pressed |= (1 << ev->device);
1844 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1846 E_Client *ec = data;
1847 Evas_Event_Multi_Up *ev = event;
1848 Evas_Device *dev = NULL;
1849 const Evas_Device *seat_dev;
1850 const char *dev_name, *seat_name;
1851 Evas_Device_Class dev_class;
1852 Evas_Event_Flags flags;
1853 E_Comp_Config *comp_conf = NULL;
1856 if (e_object_is_del(E_OBJECT(ec))) return;
1857 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1858 if (!surface) return;
1860 /* Do not deliver emulated single touch events to client */
1861 if (ev->device == 0) return;
1863 flags = evas_event_default_flags_get(evas);
1865 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1866 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1867 e_comp_wl->touch.faked_ec = NULL;
1869 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1872 dev_name = evas_device_description_get(dev);
1874 seat_dev = evas_device_parent_get(dev);
1875 seat_name = evas_device_name_get(seat_dev);
1877 comp_conf = e_comp_config_get();
1878 if (comp_conf && comp_conf->input_log_enable)
1879 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1880 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1881 dev_name, seat_name);
1883 if (dev && dev_name)
1885 dev_class = evas_device_class_get(dev);
1886 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1887 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1890 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1894 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1896 E_Client *ec = data;
1897 Evas_Event_Multi_Move *ev = event;
1898 Evas_Device *dev = NULL;
1899 const char *dev_name;
1900 Evas_Device_Class dev_class;
1903 if (e_object_is_del(E_OBJECT(ec))) return;
1904 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1905 if (!surface) return;
1907 /* Do not deliver emulated single touch events to client */
1908 if (ev->device == 0) return;
1910 e_comp_wl->touch.faked_ec = ec;
1912 if (e_comp_wl->touch.pressed & (1 << ev->device))
1915 if (dev && (dev_name = evas_device_description_get(dev)))
1917 dev_class = evas_device_class_get(dev);
1918 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1919 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1922 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1927 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1930 char *file, buff[PATH_MAX];
1937 n = (getpriority(PRIO_PROCESS, pid) + adj);
1941 setpriority(PRIO_PROCESS, pid, n);
1944 use_adj = EINA_TRUE;
1946 if (!do_child) return;
1948 files = ecore_file_ls("/proc");
1949 EINA_LIST_FREE(files, file)
1951 if (!isdigit(file[0]))
1954 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1955 if ((f = fopen(buff, "r")))
1959 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1961 if (num_read == 2 && ppid == pid)
1962 _e_comp_wl_client_priority_adjust(pid2, set,
1964 adj_child, do_child);
1972 _e_comp_wl_client_priority_raise(E_Client *ec)
1974 if (!e_config->priority_control) return;
1975 if (ec->netwm.pid <= 0) return;
1976 if (ec->netwm.pid == getpid()) return;
1977 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1978 e_config->priority - 1, -1,
1979 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1983 _e_comp_wl_client_priority_normal(E_Client *ec)
1985 if (!e_config->priority_control) return;
1986 if (ec->netwm.pid <= 0) return;
1987 if (ec->netwm.pid == getpid()) return;
1988 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1989 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1993 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1996 E_Comp_Wl_Key_Data *k;
1997 struct wl_resource *res;
2001 if (!ec) return EINA_FALSE;
2002 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2003 if (!ec->comp_data) return EINA_FALSE;
2005 ec->comp_data->on_focus_timer = NULL;
2006 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2007 if (!e_comp_wl->kbd.focused)
2009 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2012 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2014 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2015 t = ecore_time_unix_get();
2017 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2018 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2019 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2021 wl_array_for_each(k, &e_comp_wl->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);
2028 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2029 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2033 /* It is called in the following cases:
2034 * When a normal ec->frame has focus.
2035 * Or launching image ec is replaced to the real ec.
2038 e_comp_wl_feed_focus_in(E_Client *ec)
2041 struct wl_resource *res;
2042 struct wl_client *wc;
2046 if (e_object_is_del(E_OBJECT(ec))) return;
2047 if (ec->iconic) return;
2049 /* block spurious focus events */
2050 focused = e_client_focused_get();
2051 if ((focused) && (ec != focused)) return;
2053 /* raise client priority */
2054 _e_comp_wl_client_priority_raise(ec);
2055 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2056 if (!surface) return;
2058 wc = wl_resource_get_client(surface);
2060 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2061 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2063 if (wl_resource_get_client(res) == wc)
2065 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2066 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2067 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2068 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2071 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2073 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2074 if (!e_comp_wl->kbd.focused)
2076 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2079 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2081 e_comp_wl->kbd.focus = surface;
2082 e_comp_wl_input_keyboard_enter_send(ec);
2083 e_comp_wl_data_device_keyboard_focus_set();
2084 ec->comp_data->on_focus_timer =
2085 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2086 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2087 int rotation = ec->e.state.rot.ang.curr;
2088 e_pointer_rotation_set(e_comp->pointer, rotation);
2092 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2095 if (!(ec = data)) return;
2096 e_comp_wl_feed_focus_in(ec);
2100 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2103 struct wl_resource *res;
2105 E_Comp_Wl_Key_Data *k;
2109 if (!(ec = data)) return;
2111 if (!ec->comp_data) return;
2113 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2115 /* lower client priority */
2116 if (!e_object_is_del(data))
2117 _e_comp_wl_client_priority_normal(ec);
2120 /* update keyboard modifier state */
2121 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2122 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2123 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2125 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2127 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2128 if (!surface) return;
2130 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2131 if (!eina_list_count(e_comp_wl->kbd.resources))
2133 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2137 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2139 /* send keyboard_leave to all keyboard resources */
2140 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2141 t = ecore_time_unix_get();
2143 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2144 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2145 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2147 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2149 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2150 wl_keyboard_send_key(res, serial, t,
2151 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2153 wl_keyboard_send_leave(res, serial, surface);
2154 e_comp_wl->kbd.focused =
2155 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2157 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2158 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2162 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2166 if (!(ec = data)) return;
2168 if (!ec->comp_data->shell.configure_send) return;
2170 /* TODO: calculate x, y with transfrom object */
2171 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2175 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2176 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2177 if (e_comp_object_frame_exists(ec->frame))
2178 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2180 switch (ec->resize_mode)
2182 case E_POINTER_RESIZE_TL:
2183 case E_POINTER_RESIZE_L:
2184 case E_POINTER_RESIZE_BL:
2185 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2186 ec->mouse.current.mx;
2188 case E_POINTER_RESIZE_TR:
2189 case E_POINTER_RESIZE_R:
2190 case E_POINTER_RESIZE_BR:
2191 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2196 switch (ec->resize_mode)
2198 case E_POINTER_RESIZE_TL:
2199 case E_POINTER_RESIZE_T:
2200 case E_POINTER_RESIZE_TR:
2201 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2202 ec->mouse.current.my;
2204 case E_POINTER_RESIZE_BL:
2205 case E_POINTER_RESIZE_B:
2206 case E_POINTER_RESIZE_BR:
2207 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2212 w = E_CLAMP(w, 1, w);
2213 h = E_CLAMP(h, 1, h);
2214 e_client_resize_limit(ec, &w, &h);
2216 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2218 else if ((!ec->fullscreen) && (!ec->maximized) &&
2219 (!ec->comp_data->maximize_pre))
2223 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2224 if ((pw != ec->w) || (ph != ec->h))
2226 _e_comp_wl_configure_send(ec, 1, 1);
2230 if (ec->comp_data->sub.below_obj)
2231 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2235 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2237 E_Client *ec = data;
2239 ec->comp_data->maximize_pre = 1;
2243 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2245 E_Client *ec = data;
2248 if (e_object_is_del(E_OBJECT(ec))) return;
2250 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2251 e_client_shell_configure_send(ec, 0, w, h);
2253 ec->comp_data->maximize_pre = 0;
2257 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2259 E_Client *ec = data;
2261 ec->comp_data->maximize_pre = 1;
2265 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2267 E_Client *ec = data;
2269 if (e_object_is_del(E_OBJECT(ec))) return;
2271 /* check for wayland pixmap */
2273 if (ec->comp_data->shell.configure_send)
2274 _e_comp_wl_configure_send(ec, 0, 0);
2276 ec->comp_data->maximize_pre = 0;
2280 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2282 E_Client *ec = data;
2284 if (e_object_is_del(E_OBJECT(ec))) return;
2286 /* check for wayland pixmap */
2288 if (ec->comp_data->shell.configure_send)
2289 _e_comp_wl_configure_send(ec, 0, 1);
2291 ec->comp_data->maximize_pre = 0;
2295 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2297 E_Client *ec = data;
2299 if (e_object_is_del(E_OBJECT(ec))) return;
2301 /* check for wayland pixmap */
2303 if (ec->comp_data->shell.configure_send)
2304 _e_comp_wl_configure_send(ec, 0, 0);
2306 ec->comp_data->maximize_pre = 0;
2310 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2314 if (!(ec = data)) return;
2316 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2318 e_object_del(E_OBJECT(ec));
2320 _e_comp_wl_focus_check();
2322 /* TODO: Delete request send ??
2323 * NB: No such animal wrt wayland */
2327 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2331 if (!(ec = data)) return;
2333 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2336 if (ec->comp_data->reparented)
2337 e_client_comp_hidden_set(ec, EINA_TRUE);
2340 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2341 if (ec->visible) evas_object_hide(ec->frame);
2342 if (!ec->internal) e_object_del(E_OBJECT(ec));
2344 _e_comp_wl_focus_check();
2348 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2352 if (!(ec = data)) return;
2354 e_client_shell_ping(ec);
2358 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2363 if (!(ec = data)) return;
2364 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2365 if (ec->netwm.opacity == a) return;
2366 ec->netwm.opacity = a;
2367 ec->netwm.opacity_changed = EINA_TRUE;
2371 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2373 Eina_Rectangle *damage_rect = NULL;
2374 Eina_Rectangle *dmg = NULL;
2375 Eina_List *l = NULL;
2377 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2378 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2381 if (!buffer->tbm_surface) return;
2385 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2389 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2390 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2393 eina_rectangle_union(damage_rect, dmg);
2398 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2399 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2402 tbm_surface_internal_set_damage(buffer->tbm_surface,
2408 eina_rectangle_free(damage_rect);
2412 _e_comp_wl_client_evas_init(E_Client *ec)
2414 if (!ec || !ec->comp_data) return;
2415 if (ec->comp_data->evas_init) return;
2417 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2418 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2419 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2422 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2423 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2424 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2425 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2426 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2427 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2429 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2430 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2431 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2433 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2434 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2438 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2439 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2440 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2441 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2442 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2443 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2444 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2447 /* setup delete/kill callbacks */
2448 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2449 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2451 /* setup ping callback */
2452 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2453 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2455 ec->comp_data->evas_init = EINA_TRUE;
2459 _e_comp_wl_client_evas_deinit(E_Client *ec)
2461 if (!ec || !ec->comp_data) return;
2462 if (!ec->comp_data->evas_init) return;
2464 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2465 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2466 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2468 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2469 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2470 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2471 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2472 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2473 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2475 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2476 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2477 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2479 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2480 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2484 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2485 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2486 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2487 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2488 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2489 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2490 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2493 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2494 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2496 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2497 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2499 ec->comp_data->evas_init = EINA_FALSE;
2503 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2507 E_Comp_Screen *e_comp_screen;
2508 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2510 if (!e_comp) return ECORE_CALLBACK_RENEW;
2511 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2512 e_comp_screen = e_comp->e_comp_screen;
2514 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2516 if (!eout->config.enabled)
2518 e_comp_wl_output_remove(eout->id);
2522 switch (eout->config.rotation)
2525 transform = WL_OUTPUT_TRANSFORM_90;
2528 transform = WL_OUTPUT_TRANSFORM_180;
2531 transform = WL_OUTPUT_TRANSFORM_270;
2535 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2539 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2541 eout->config.geom.x, eout->config.geom.y,
2542 eout->config.geom.w, eout->config.geom.h,
2543 eout->info.size.w, eout->info.size.h,
2544 eout->config.mode.refresh, 0, transform))
2545 ERR("Could not initialize screen %s", eout->info.name);
2548 return ECORE_CALLBACK_RENEW;
2552 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2556 /* try to get the client from the object */
2557 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2558 return ECORE_CALLBACK_RENEW;
2560 /* check for client being deleted */
2561 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2563 /* check for wayland pixmap */
2564 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2565 return ECORE_CALLBACK_RENEW;
2567 /* if we have not setup evas callbacks for this client, do it */
2568 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2570 return ECORE_CALLBACK_RENEW;
2574 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2578 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2579 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2581 if (e_comp_wl->selection.target &&
2584 struct wl_resource *res;
2586 E_Client *ec = NULL;
2587 E_Client *legacy_target = e_comp_wl->selection.target;
2588 int device_id = e_comp_wl_data_current_device_id_get();
2592 e_comp_wl_data_current_device_id_set(ev->multi.device);
2594 else if (device_id != ev->multi.device)
2596 return ECORE_CALLBACK_RENEW;
2599 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2600 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2602 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2603 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2605 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2606 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2608 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2609 (ec != legacy_target))
2611 e_comp_wl_data_device_send_leave(legacy_target);
2612 e_comp_wl_data_device_send_enter(ec);
2615 if (e_comp_wl->drag)
2616 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2618 if (e_client_transform_core_enable_get(ec))
2620 int trans_x, trans_y;
2621 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2622 x = trans_x - ec->client.x;
2623 y = trans_y - ec->client.y;
2627 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2632 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2635 return ECORE_CALLBACK_RENEW;
2639 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2642 struct wl_resource *surface;
2643 struct wl_resource *res;
2644 struct wl_client *wc;
2646 E_Comp_Config *comp_conf;
2648 ec = e_comp_wl->ptr_constraints.ec;
2649 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2651 surface = e_comp_wl_client_surface_get(ec);
2652 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2654 wc = wl_resource_get_client(surface);
2656 comp_conf = e_comp_config_get();
2658 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2660 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2661 if (wl_resource_get_client(res) != wc) continue;
2663 if (comp_conf && comp_conf->input_log_enable)
2664 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2665 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2666 e_client_util_name_get(ec));
2668 zwp_relative_pointer_v1_send_relative_motion(res,
2670 (uint32_t)(ev->timestamp),
2671 wl_fixed_from_int(ev->dx),
2672 wl_fixed_from_int(ev->dy),
2673 wl_fixed_from_int(ev->dx_unaccel),
2674 wl_fixed_from_int(ev->dy_unaccel));
2677 return ECORE_CALLBACK_DONE;
2681 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2683 _e_comp_wl_touch_cancel();
2685 return ECORE_CALLBACK_PASS_ON;
2689 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2691 if (!ev) return ECORE_CALLBACK_PASS_ON;
2693 E_Zone *zone = ev->zone;
2695 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2696 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2698 if (!e_zone_is_displaying(zone))
2699 _e_comp_wl_touch_cancel();
2701 return ECORE_CALLBACK_PASS_ON;
2705 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2707 E_Client *ec = ev->ec;
2708 E_Comp_Wl_Buffer_Viewport *vp;
2710 if (!ec) return ECORE_CALLBACK_PASS_ON;
2711 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2712 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2713 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2714 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2716 vp = &ec->comp_data->scaler.buffer_viewport;
2717 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2719 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2721 return ECORE_CALLBACK_PASS_ON;
2725 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2727 E_Client *ec = ev->ec;
2728 E_Comp_Wl_Buffer_Viewport *vp;
2730 if (!ec) return ECORE_CALLBACK_PASS_ON;
2731 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2732 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2733 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2735 vp = &ec->comp_data->scaler.buffer_viewport;
2736 vp->wait_for_transform_change = 0;
2738 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2740 return ECORE_CALLBACK_PASS_ON;
2744 _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)
2746 E_Client *focused_ec;
2749 focused_ec = e_client_focused_get();
2750 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2752 rotation = focused_ec->e.state.rot.ang.curr;
2753 e_pointer_rotation_set(e_comp->pointer, rotation);
2755 return ECORE_CALLBACK_PASS_ON;
2759 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2762 Eina_Rectangle *window;
2767 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2769 if ((prev_w != state->bw) ||
2770 (prev_h != state->bh))
2772 ec->changes.buf_size = EINA_TRUE;
2775 if (e_comp_object_frame_exists(ec->frame)) return;
2776 window = &ec->comp_data->shell.window;
2777 if ((!ec->borderless) && /* FIXME temporarily added this check code
2778 * to prevent updating E_Client's size by frame */
2779 (window->x || window->y || window->w || window->h))
2781 e_comp_object_frame_geometry_set(ec->frame,
2783 (window->x + window->w) - state->bw,
2785 (window->y + window->h) - state->bh);
2788 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2792 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2794 E_Comp_Wl_Surface_State *state;
2797 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2798 state->buffer = NULL;
2802 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2804 state->new_attach = EINA_FALSE;
2805 state->buffer = NULL;
2806 state->buffer_destroy_listener.notify =
2807 _e_comp_wl_surface_state_cb_buffer_destroy;
2808 state->sx = state->sy = 0;
2810 state->input = eina_tiler_new(w, h);
2811 eina_tiler_tile_size_set(state->input, 1, 1);
2813 state->opaque = eina_tiler_new(w, h);
2814 eina_tiler_tile_size_set(state->opaque, 1, 1);
2816 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2817 state->buffer_viewport.buffer.scale = 1;
2818 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2819 state->buffer_viewport.surface.width = -1;
2820 state->buffer_viewport.changed = 0;
2822 e_presentation_time_container_init(&state->presentation_container);
2826 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2828 struct wl_resource *cb;
2829 Eina_Rectangle *dmg;
2831 EINA_LIST_FREE(state->frames, cb)
2832 wl_resource_destroy(cb);
2834 EINA_LIST_FREE(state->damages, dmg)
2835 eina_rectangle_free(dmg);
2837 EINA_LIST_FREE(state->buffer_damages, dmg)
2838 eina_rectangle_free(dmg);
2840 if (state->opaque) eina_tiler_free(state->opaque);
2841 state->opaque = NULL;
2843 if (state->input) eina_tiler_free(state->input);
2844 state->input = NULL;
2846 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2847 state->buffer = NULL;
2849 e_presentation_time_container_finish(&state->presentation_container);
2853 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2855 if (state->buffer == buffer) return;
2857 wl_list_remove(&state->buffer_destroy_listener.link);
2858 state->buffer = buffer;
2860 wl_signal_add(&state->buffer->destroy_signal,
2861 &state->buffer_destroy_listener);
2865 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2867 Eina_Rectangle *dmg;
2868 Eina_Bool placed = EINA_TRUE;
2872 E_Comp_Wl_Buffer *buffer;
2873 struct wl_resource *cb;
2875 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2876 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2881 if ((ec->internal) ||
2882 (cdata->shell.surface && state->new_attach))
2886 e_comp->new_clients++;
2887 ELOGF("COMP", "Unignore", ec);
2888 e_client_unignore(ec);
2892 /* buffer transform */
2893 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2896 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2898 /* when buffer is transformed, we have to apply the new evas-map */
2899 state->buffer_viewport.changed = EINA_TRUE;
2901 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2903 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2905 if (transform_change == vp->wait_for_transform_change)
2906 vp->wait_for_transform_change = 0;
2908 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2909 // triggered by E_CLIENT_HOOK calls at those file.
2910 zone = e_comp_zone_find_by_ec(ec);
2913 eout = e_output_find(zone->output_id);
2914 if (eout && eout->hwc)
2916 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2918 if (e_comp_is_on_overlay(ec))
2919 e_comp_hwc_client_end(ec, __FUNCTION__);
2925 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2926 cdata->scaler.buffer_viewport = state->buffer_viewport;
2928 if (state->new_attach)
2930 e_comp_wl_surface_attach(ec, state->buffer);
2933 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2934 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2936 _e_comp_wl_surface_state_buffer_set(state, NULL);
2938 if ((state->new_attach) ||
2939 (state->buffer_viewport.changed))
2941 _e_comp_wl_surface_state_size_update(ec, state);
2942 e_comp_wl_map_size_cal_from_viewport(ec);
2944 /* update the position */
2945 if (ec->changes.pos)
2947 e_comp_object_frame_xy_unadjust(ec->frame,
2957 if (ec->new_client) placed = ec->placed;
2959 if (!ec->lock_client_size)
2964 ec->client.w = state->bw;
2965 ec->client.h = state->bh;
2967 e_comp_object_frame_wh_adjust(ec->frame,
2968 ec->client.w, ec->client.h,
2970 e_client_size_set(ec, nw, nh);
2972 if ((w != ec->w) || (h != ec->h))
2974 ec->changes.size = 1;
2979 if (ec->changes.buf_size)
2981 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2982 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2983 ec->changes.buf_size = EINA_FALSE;
2985 if (ec->move_after_resize)
2987 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2988 ec->move_after_resize = EINA_FALSE;
2993 /* map or unmap ec */
2994 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2995 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2996 if (!pixmap_usable || hide_by_request)
3001 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
3006 if ((cdata->sub.below_obj) &&
3007 (evas_object_visible_get(cdata->sub.below_obj)))
3009 evas_object_hide(cdata->sub.below_obj);
3017 if ((cdata->sub.below_obj) &&
3018 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3019 (evas_object_visible_get(ec->frame)))
3021 evas_object_show(cdata->sub.below_obj);
3025 if ((state->new_attach) ||
3026 (state->buffer_viewport.changed))
3028 if ((e_comp_wl->drag) &&
3029 (e_comp_wl->drag_client) &&
3030 (e_comp_wl->drag_client == ec))
3032 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3034 e_drag_move(e_comp_wl->drag,
3036 e_comp_wl->drag->y);
3038 e_drag_resize(e_comp_wl->drag,
3039 state->bw, state->bh);
3041 else if ((cdata->shell.surface) &&
3042 (cdata->shell.configure))
3044 e_comp_wl_commit_sync_configure(ec);
3046 else if (!e_client_video_hw_composition_check(ec))
3048 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3053 ec->placed = placed;
3054 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3058 if (cdata->scaler.buffer_viewport.changed)
3059 e_comp_wl_map_apply(ec);
3061 /* resize transform object */
3062 if (ec->transformed)
3063 e_client_transform_update(ec);
3067 state->new_attach = EINA_FALSE;
3069 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3071 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3072 wl_resource_destroy(cb);
3075 /* insert state frame callbacks into comp_data->frames
3076 * NB: This clears state->frames list */
3077 cdata->frames = eina_list_merge(cdata->frames,
3079 state->frames = NULL;
3081 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3082 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3083 &state->presentation_container);
3085 buffer = e_pixmap_resource_get(ec->pixmap);
3087 /* put state damages into surface */
3090 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3091 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3093 if ((cdata->buffer_ref.buffer) &&
3094 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3095 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3097 e_comp_object_damage(ec->frame,
3099 cdata->buffer_ref.buffer->w,
3100 cdata->buffer_ref.buffer->h);
3105 Eina_List *damages = NULL;
3108 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3110 if (eina_list_count(state->buffer_damages))
3112 EINA_LIST_FREE(state->buffer_damages, dmg)
3115 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3116 e_comp_wl_output_buffer_transform_get(ec),
3118 dmg->x, dmg->y, dmg->w, dmg->h,
3119 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3120 damages = eina_list_append(damages, dmg);
3124 EINA_LIST_FREE(state->damages, dmg)
3125 damages = eina_list_append(damages, dmg);
3127 EINA_LIST_FREE(damages, dmg)
3129 /* not creating damage for ec that shows a underlay video */
3130 if (state->buffer_viewport.changed ||
3131 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3132 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3133 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3135 eina_rectangle_free(dmg);
3140 /* put state opaque into surface */
3141 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3144 Eina_Rectangle *rect;
3147 itr = eina_tiler_iterator_new(state->opaque);
3148 EINA_ITERATOR_FOREACH(itr, rect)
3152 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3153 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3154 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3158 eina_iterator_free(itr);
3161 /* put state input into surface */
3162 if ((state->input) &&
3163 (!eina_tiler_empty(state->input)) &&
3166 Eina_Tiler *src, *tmp;
3170 tmp = eina_tiler_new(sw, sh);
3171 eina_tiler_tile_size_set(tmp, 1, 1);
3173 eina_tiler_rect_add(tmp,
3174 &(Eina_Rectangle){0, 0, sw, sh});
3176 if ((src = eina_tiler_intersection(state->input, tmp)))
3178 Eina_Rectangle *rect;
3181 e_comp_object_input_objs_del(ec->frame);
3182 itr = eina_tiler_iterator_new(src);
3183 EINA_ITERATOR_FOREACH(itr, rect)
3185 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3186 ec, rect->x, rect->y, rect->w, rect->h,
3187 ec->w, ec->h, state->bw, state->bh);
3188 e_comp_object_input_area_set(ec->frame,
3193 eina_iterator_free(itr);
3194 eina_tiler_free(src);
3197 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3199 eina_tiler_free(tmp);
3201 /* clear input tiler */
3202 eina_tiler_clear(state->input);
3205 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3207 if ((cdata->video_client) &&
3209 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3210 (e_comp->wl_comp_data->available_hw_accel.underlay))
3212 e_pixmap_image_clear(ec->pixmap, 1);
3215 state->buffer_viewport.changed = 0;
3217 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3220 ec->exp_iconify.buffer_flush &&
3221 e_policy_visibility_client_is_iconic(ec))
3223 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3228 _e_comp_wl_surface_render_stop(E_Client *ec)
3230 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3231 //if ((!ec->internal) && (!e_comp_gl_get()))
3234 /* check if internal animation is running */
3235 if (e_comp_object_is_animating(ec->frame)) return;
3236 /* check if external animation is running */
3237 if (evas_object_data_get(ec->frame, "effect_running")) return;
3239 evas_object_hide(ec->frame);
3243 e_comp_wl_client_surface_finish(E_Client *ec)
3245 struct wl_resource *res, *surface;
3246 struct wl_client *surface_client = NULL;
3249 surface = e_comp_wl_client_surface_get(ec);
3252 surface_client = wl_resource_get_client(surface);
3254 if (surface_client &&
3255 (ec == e_client_focused_get()))
3257 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3258 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3260 if (wl_resource_get_client(res) ==
3262 e_comp_wl->kbd.focused =
3263 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3267 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3270 e_comp_wl_client_surface_set(ec, NULL);
3272 ec->comp_data->wl_surface = NULL;
3273 e_pixmap_win_id_del(ec->pixmap);
3275 _e_comp_wl_surface_render_stop(ec);
3276 e_object_del(E_OBJECT(ec));
3280 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3285 char proc[512], pname[512];
3288 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3290 h = fopen(proc, "r");
3293 len = fread(pname, sizeof(char), 512, h);
3295 pname[len - 1] = '\0';
3297 strncpy(pname, "NO NAME", sizeof(pname));
3303 strncpy(pname, "NO NAME", sizeof(pname));
3306 strncpy(name, pname, size);
3310 _e_comp_wl_pname_print(pid_t pid)
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));
3329 ELOGF("COMP", " |%s", NULL, pname);
3334 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3336 struct wl_client *client = data;
3337 E_Comp_Connected_Client_Info *cinfo;
3340 cinfo = wl_container_of(listener, cinfo, destroy);
3342 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3343 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3345 eai = e_appinfo_find_with_pid(cinfo->pid);
3346 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3349 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3351 wl_list_remove(&cinfo->destroy.link);
3352 eina_stringshare_del(cinfo->name);
3357 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3359 E_Comp_Connected_Client_Info *cinfo;
3361 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3362 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3364 cinfo->name = eina_stringshare_add(name);
3368 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3369 wl_client_add_destroy_listener(client, &cinfo->destroy);
3370 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3372 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3376 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3378 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3380 /* send configure */
3381 if (ec->comp_data->shell.configure_send)
3383 if (ec->comp_data->shell.surface)
3384 _e_comp_wl_configure_send(ec, 0, 0);
3387 e_comp_wl->kbd.focus = ec->comp_data->surface;
3391 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3393 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3395 /* send configure */
3396 if (ec->comp_data->shell.configure_send)
3398 if (ec->comp_data->shell.surface)
3399 _e_comp_wl_configure_send(ec, 0, 0);
3402 _e_comp_wl_focus_check();
3404 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3405 e_comp_wl->kbd.focus = NULL;
3409 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3411 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3412 if (ec->keyboard_resizing) return;
3414 /* do nothing currently */
3419 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3421 if (e_object_is_del(E_OBJECT(ec))) return;
3422 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3424 e_comp_wl->resize.edges = 0;
3425 e_comp_wl->resize.resource = NULL;
3429 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3431 if (e_object_is_del(E_OBJECT(ec))) return;
3432 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3436 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3439 int ratio_w, ratio_h;
3441 phys_w = output->phys_width;
3442 phys_h = output->phys_height;
3444 if (e_config->configured_output_resolution.use)
3446 // change the configured physical size(mm) of the output
3447 if (output->w != res_w)
3449 ratio_w = res_w / output->w;
3450 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3453 if (output->h != res_h)
3455 ratio_h = res_h / output->h;
3456 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3459 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3462 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3463 NULL, res_w, res_h, phys_w, phys_h, pid);
3465 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3466 wl_output_send_scale(resource, output->scale);
3468 wl_output_send_geometry(resource, output->x, output->y,
3470 output->subpixel, output->make ?: "",
3471 output->model ?: "", output->transform);
3473 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3474 res_w, res_h, output->refresh);
3476 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3477 wl_output_send_done(resource);
3481 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3483 E_Comp_Wl_Output *output;
3485 if (!(output = wl_resource_get_user_data(resource))) return;
3487 output->resources = eina_list_remove(output->resources, resource);
3491 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3493 E_Comp_Wl_Output *output;
3494 struct wl_resource *resource;
3495 E_Appinfo *eai = NULL;
3499 if (!(output = data)) return;
3502 wl_resource_create(client, &wl_output_interface, version, id);
3505 wl_client_post_no_memory(client);
3509 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3510 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3512 output->resources = eina_list_append(output->resources, resource);
3514 wl_resource_set_implementation(resource, NULL, output,
3515 _e_comp_wl_cb_output_unbind);
3516 wl_resource_set_user_data(resource, output);
3518 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3519 if (e_config->configured_output_resolution.use)
3521 wl_client_get_credentials(client, &pid, NULL, NULL);
3524 res_w = e_config->configured_output_resolution.w;
3525 res_h = e_config->configured_output_resolution.h;
3529 eai = e_appinfo_find_with_pid(pid);
3532 res_w = e_config->configured_output_resolution.w;
3533 res_h = e_config->configured_output_resolution.h;
3537 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3539 res_w = e_config->configured_output_resolution.w;
3540 res_h = e_config->configured_output_resolution.h;
3544 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3553 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3557 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3560 Evas_GL *evasgl = NULL;
3561 Evas_GL_API *glapi = NULL;
3562 Evas_GL_Context *ctx = NULL;
3563 Evas_GL_Surface *sfc = NULL;
3564 Evas_GL_Config *cfg = NULL;
3566 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3568 if (!e_comp_gl_get()) return;
3570 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3571 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3573 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3574 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3576 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3577 * then we should get evas from ecore_evas.
3580 evas = e_comp->evas;
3582 evas = ecore_evas_get(e_comp->ee);
3584 evasgl = evas_gl_new(evas);
3585 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3587 glapi = evas_gl_api_get(evasgl);
3588 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3589 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3591 cfg = evas_gl_config_new();
3592 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3594 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3595 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3597 ctx = evas_gl_context_create(evasgl, NULL);
3598 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3600 res = evas_gl_make_current(evasgl, sfc, ctx);
3601 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3603 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3604 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3606 evas_gl_config_free(cfg);
3608 evas_gl->gl = evasgl;
3609 evas_gl->glapi = glapi;
3610 evas_gl->glsfc = sfc;
3611 evas_gl->glctx = ctx;
3613 e_comp_wl->evas_gl = evas_gl;
3615 /* for native surface */
3618 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3623 evas_gl_config_free(cfg);
3624 evas_gl_make_current(evasgl, NULL, NULL);
3625 evas_gl_context_destroy(evasgl, ctx);
3626 evas_gl_surface_destroy(evasgl, sfc);
3627 evas_gl_free(evasgl);
3634 _e_comp_wl_gl_popup_cb_close(void *data,
3635 Evas_Object *obj EINA_UNUSED,
3636 void *event_info EINA_UNUSED)
3638 evas_object_del(data);
3642 _e_comp_wl_gl_popup_cb_focus(void *data,
3643 Evas_Object *obj EINA_UNUSED,
3644 void *event_info EINA_UNUSED)
3646 elm_object_focus_set(data, EINA_TRUE);
3651 _e_comp_wl_gl_idle(void *data)
3655 /* show warning window to notify failure of gl init */
3658 Evas_Object *win, *bg, *popup, *btn;
3660 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3661 elm_win_title_set(win, "Compositor Warning");
3662 elm_win_autodel_set(win, EINA_TRUE);
3663 elm_win_borderless_set(win, EINA_TRUE);
3664 elm_win_role_set(win, "notification-low");
3665 elm_win_alpha_set(win, EINA_TRUE);
3667 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3668 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3669 elm_win_resize_object_add(win, bg);
3670 evas_object_color_set(bg, 125, 125, 125, 125);
3671 evas_object_show(bg);
3673 popup = elm_popup_add(win);
3674 elm_object_text_set(popup,
3675 _( "Your screen does not support OpenGL.<br>"
3676 "Falling back to software engine."));
3677 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3679 btn = elm_button_add(popup);
3680 elm_object_text_set(btn, "Close");
3681 elm_object_part_content_set(popup, "button1", btn);
3682 evas_object_show(btn);
3684 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3685 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3687 evas_object_show(popup);
3688 evas_object_show(win);
3692 return ECORE_CALLBACK_CANCEL;
3696 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3698 struct wl_client *client = data;
3704 wl_client_get_credentials(client, &pid, &uid, &gid);
3706 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3708 _e_comp_wl_pname_print(pid);
3709 _e_comp_wl_pname_get(pid, name, sizeof(name));
3710 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3714 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3716 char buf[1024] = {0, };
3718 vsnprintf(buf, 1024, fmt, args);
3722 DBG("[libds] %s", buf);
3725 INF("[libds] %s", buf);
3728 ERR("[libds] %s", buf);
3736 _e_comp_wl_display_create(void)
3739 E_Comp_Wl_Data *wl_cdata;
3744 /* create new compositor data */
3745 if (!(comp = E_NEW(E_Comp_Data, 1)))
3747 ERR("Could not create compositor data: %m");
3750 wl_cdata = &comp->base;
3752 /* set compositor wayland data */
3753 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3755 g_mutex_init(&connection_mutex);
3757 /* try to create a wayland display */
3758 if (!(wl_cdata->wl.disp = wl_display_create()))
3760 ERR("Could not create a Wayland display: %m");
3764 /* try to setup wayland socket */
3765 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3767 ERR("Could not create Wayland display socket: %m");
3768 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3772 res = e_comp_socket_init(name);
3773 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3774 PRCTL("[Winsys] change permission and create sym link for %s", name);
3776 /* set wayland display environment variable */
3777 e_env_set("WAYLAND_DISPLAY", name);
3779 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3780 /* wl_cdata->output.scale = e_scale; */
3782 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3784 if (!e_compositor_init(wl_cdata->wl.disp))
3786 ERR("Failed to initialize compositor");
3790 comp->client_created.notify = _e_comp_wl_cb_client_created;
3791 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3793 if (!e_comp_wl_subsurfaces_init())
3795 ERR("Failed to init_subsurfaces");
3796 goto subsurfaces_err;
3799 /* initialize shm mechanism */
3800 wl_display_init_shm(wl_cdata->wl.disp);
3802 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3804 /* try to init data manager */
3805 if (!e_comp_wl_data_manager_init())
3807 ERR("Could not initialize data manager");
3811 /* try to init input */
3812 if (!e_comp_wl_input_init())
3814 ERR("Could not initialize input");
3818 if (e_comp_gl_get())
3819 _e_comp_wl_gl_init(NULL);
3821 /* get the wayland display loop */
3822 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3824 /* get the file descriptor of the wayland event loop */
3825 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3827 /* create a listener for wayland main loop events */
3829 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3830 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3831 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3832 _e_comp_wl_cb_prepare, wl_cdata);
3837 e_comp_wl_data_manager_shutdown();
3839 e_comp_wl_subsurfaces_shutdown();
3841 wl_list_remove(&comp->client_created.link);
3843 e_env_unset("WAYLAND_DISPLAY");
3845 wl_display_destroy(wl_cdata->wl.disp);
3847 g_mutex_clear(&connection_mutex);
3853 _e_comp_wl_gl_shutdown(void)
3855 if (!e_comp_wl->evas_gl) return;
3857 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3859 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3860 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3861 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3862 evas_gl_free(e_comp_wl->evas_gl->gl);
3864 E_FREE(e_comp_wl->evas_gl);
3867 /* public functions */
3870 * Creates and initializes a Wayland compositor with ecore.
3871 * Registers callback handlers for keyboard and mouse activity
3872 * and other client events.
3874 * @returns true on success, false if initialization failed.
3877 e_comp_wl_init(void)
3879 TRACE_DS_BEGIN(COMP_WL:INIT);
3881 /* try to create a wayland compositor */
3882 if (!_e_comp_wl_display_create())
3884 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3889 e_comp_wl_shell_init();
3891 #ifdef HAVE_WAYLAND_TBM
3892 e_comp_wl_tbm_init();
3894 e_comp_wl_remote_surface_init();
3898 e_comp_wl_screenshooter_init();
3900 if (!e_comp_wl_video_init())
3901 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3903 e_comp_wl_viewport_init();
3904 e_comp_wl_capture_init();
3905 e_comp_wl_renderer_init();
3906 _e_comp_wl_move_resize_init();
3907 e_presentation_time_init();
3908 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3911 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3912 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3914 /* add event handlers to catch E events */
3915 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3916 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3917 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3918 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3919 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3920 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3921 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3922 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3923 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3925 /* add hooks to catch e_client events */
3926 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3927 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3928 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3929 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3930 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3932 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3939 e_comp_wl_deferred_job(void)
3941 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3944 /* internal functions */
3946 e_comp_wl_shutdown(void)
3948 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3950 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3952 e_comp_wl_subsurfaces_shutdown();
3954 E_FREE_LIST(handlers, ecore_event_handler_del);
3955 E_FREE_LIST(hooks, e_client_hook_del);
3956 _e_comp_wl_gl_shutdown();
3958 e_blender_shutdown();
3959 e_presentation_time_shutdown();
3960 e_comp_wl_renderer_shutdown();
3961 e_comp_wl_capture_shutdown();
3962 e_comp_wl_viewport_shutdown();
3963 e_comp_wl_video_shutdown();
3964 e_comp_wl_screenshooter_shutdown();
3966 e_comp_wl_remote_surface_shutdown();
3968 e_pixmap_shutdown();
3970 e_wtz_shell_shutdown();
3971 e_comp_wl_shell_shutdown();
3972 e_comp_wl_input_shutdown();
3974 wl_list_remove(&comp->client_created.link);
3977 e_comp->wl_comp_data = NULL;
3981 E_Comp_Wl_Output *output;
3983 if (e_comp_wl->screenshooter.global)
3984 wl_global_destroy(e_comp_wl->screenshooter.global);
3986 EINA_LIST_FREE(e_comp_wl->outputs, output)
3988 if (output->id) eina_stringshare_del(output->id);
3989 if (output->make) eina_stringshare_del(output->make);
3990 if (output->model) eina_stringshare_del(output->model);
3994 /* delete fd handler */
3995 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3997 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3998 cursor_timer_ec = NULL;
4000 /* free allocated data structure */
4006 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4008 e_object_unref(E_OBJECT(ev->ec));
4013 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4016 ev = E_NEW(E_Event_Client, 1);
4019 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4021 /* set usable early because shell module checks this */
4022 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4023 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4025 e_pixmap_resource_set(ec->pixmap, buffer);
4026 e_pixmap_dirty(ec->pixmap);
4027 e_pixmap_refresh(ec->pixmap);
4029 e_comp_wl_map_size_cal_from_buffer(ec);
4030 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4032 /* wm-policy module uses it */
4033 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4036 e_object_ref(E_OBJECT(ec));
4037 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4038 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4042 e_comp_wl_surface_commit(E_Client *ec)
4047 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4048 if (!e_comp_object_damage_exists(ec->frame))
4050 if ((ec->comp_data->video_client) ||
4051 (!e_client_video_hw_composition_check(ec)))
4052 e_pixmap_image_clear(ec->pixmap, 1);
4055 ignored = ec->ignored;
4057 if (e_comp_wl_subsurface_order_commit(ec))
4059 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4060 e_comp_wl_subsurface_restack(topmost);
4061 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4064 ec->ignored = ignored;
4066 if (ec->is_cursor && ec->visible)
4068 /* ignore cursor changes during resize/move I guess */
4069 if (!e_client_action_get())
4071 if (e_comp->pointer)
4073 x = e_comp->pointer->hot.x;
4074 y = e_comp->pointer->hot.y;
4076 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4082 static E_Comp_Wl_Output *
4083 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4086 E_Comp_Wl_Output *output;
4088 EINA_LIST_FOREACH(outputs, l, output)
4090 if (!strcmp(output->id, id))
4098 * Initializes information about one display output.
4100 * Adds or updates the given data about a single display output,
4101 * with an id matching the provided id.
4103 * @param id identification of output to be added or changed
4104 * @param make manufacturer name of the display output
4105 * @param model model name of the display output
4106 * @param x output's top left corner x coordinate
4107 * @param y output's top left corner y coordinate
4108 * @param w output's width in pixels
4109 * @param h output's height in pixels
4110 * @param pw output's physical width in millimeters
4111 * @param ph output's physical height in millimeters
4112 * @param refresh output's refresh rate in mHz
4113 * @param subpixel output's subpixel layout
4114 * @param transform output's rotation and/or mirror transformation
4116 * @returns True if a display output object could be added or updated
4119 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4120 int x, int y, int w, int h, int pw, int ph,
4121 unsigned int refresh, unsigned int subpixel,
4122 unsigned int transform)
4124 E_Comp_Wl_Output *output;
4126 struct wl_resource *resource;
4128 /* retrieve named output; or create it if it doesn't exist */
4129 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4132 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4134 if (id) output->id = eina_stringshare_add(id);
4136 output->make = eina_stringshare_add(make);
4138 output->make = eina_stringshare_add("unknown");
4140 output->model = eina_stringshare_add(model);
4142 output->model = eina_stringshare_add("unknown");
4144 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4147 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4148 2, output, _e_comp_wl_cb_output_bind);
4150 output->resources = NULL;
4151 output->scale = e_scale;
4154 /* update the output details */
4159 output->phys_width = pw;
4160 output->phys_height = ph;
4161 output->refresh = refresh;
4162 output->subpixel = subpixel;
4163 output->transform = transform;
4165 if (output->scale <= 0)
4166 output->scale = e_scale;
4168 /* if we have bound resources, send updates */
4169 EINA_LIST_FOREACH(output->resources, l2, resource)
4171 wl_output_send_geometry(resource,
4172 output->x, output->y,
4174 output->phys_height,
4176 output->make ?: "", output->model ?: "",
4179 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4180 wl_output_send_scale(resource, output->scale);
4182 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4183 output->w, output->h, output->refresh);
4185 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4186 wl_output_send_done(resource);
4193 e_comp_wl_output_remove(const char *id)
4195 E_Comp_Wl_Output *output;
4197 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4200 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4202 /* wl_global_destroy(output->global); */
4204 /* eina_stringshare_del(output->id); */
4205 /* eina_stringshare_del(output->make); */
4206 /* eina_stringshare_del(output->model); */
4213 _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)
4215 struct wl_resource *res;
4217 uint32_t serial, keycode;
4218 struct wl_client *wc = NULL;
4219 E_Comp_Config *comp_conf = NULL;
4220 const char *device_name = NULL;
4222 keycode = (ev->keycode - 8);
4224 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4226 comp_conf = e_comp_config_get();
4228 if (ec && ec->comp_data)
4230 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4233 wc = wl_resource_get_client(surface);
4236 if (e_config->key_input_ttrace_enable)
4238 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4239 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4242 EINA_LIST_FOREACH(key_list, l, res)
4244 if (wl_resource_get_client(res) != wc) continue;
4246 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4247 if (!e_input_thread_mode_get())
4249 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4250 device_name = ecore_device_name_get(ev->dev);
4256 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4257 device_name = e_device_name_get(dev);
4261 if (comp_conf && comp_conf->input_log_enable)
4262 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4264 wl_keyboard_send_key(res, serial, ev->timestamp,
4269 if (e_config->key_input_ttrace_enable)
4272 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4277 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4279 E_Client *ec = NULL;
4281 E_Comp_Wl_Key_Data *end, *k;
4283 if (ev->window != e_comp->ee_win)
4288 keycode = (ev->keycode - 8);
4289 if (!(e_comp_wl = e_comp->wl_comp_data))
4294 #ifndef E_RELEASE_BUILD
4295 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4296 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4297 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4298 eina_streq(ev->key, "BackSpace"))
4304 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4306 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4308 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4310 /* ignore server-generated key repeats */
4311 if (k->key == keycode)
4313 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4318 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4320 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4322 ec = e_client_focused_get();
4323 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4324 if (ec && ec->comp_data && surface)
4326 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4327 if (e_comp_wl->kbd.focused)
4329 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4331 /* A key only sent to clients is added to the list */
4332 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4333 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4335 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4337 DBG("wl_array_add: Out of memory\n");
4338 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4339 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4342 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4346 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4350 /* update modifier state */
4351 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4357 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4359 E_Client *ec = NULL;
4360 uint32_t keycode, delivered_key;
4361 E_Comp_Wl_Key_Data *end, *k;
4363 if (ev->window != e_comp->ee_win)
4368 keycode = (ev->keycode - 8);
4370 if (!(e_comp_wl = e_comp->wl_comp_data))
4375 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4377 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4378 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4380 if (k->key == keycode)
4387 e_comp_wl->kbd.keys.size =
4388 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4390 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4392 /* 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) */
4393 if ((delivered_key) ||
4394 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4396 ec = e_client_focused_get();
4398 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4399 if (e_comp_wl->kbd.focused)
4401 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4403 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4406 /* update modifier state */
4407 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4413 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4415 Eina_Bool res = EINA_FALSE;
4417 if (type == ECORE_EVENT_KEY_DOWN)
4419 res = e_comp_wl_key_down(ev, dev);
4421 else if (type == ECORE_EVENT_KEY_UP)
4423 res = e_comp_wl_key_up(ev, dev);
4430 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4433 struct wl_client *wc;
4434 uint32_t serial, btn;
4435 struct wl_resource *res;
4436 E_Comp_Config *comp_conf = NULL;
4438 if (ec->cur_mouse_action || e_comp_wl->drag)
4440 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4441 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4445 case 1: btn = BTN_LEFT; break;
4446 case 2: btn = BTN_MIDDLE; break;
4447 case 3: btn = BTN_RIGHT; break;
4448 default: btn = button_id; break;
4451 e_comp_wl->ptr.button = btn;
4452 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4453 if (!surface) return EINA_FALSE;
4455 if (!eina_list_count(e_comp_wl->ptr.resources))
4458 wc = wl_resource_get_client(surface);
4459 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4461 comp_conf = e_comp_config_get();
4463 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4465 if (wl_resource_get_client(res) != wc) continue;
4466 if (!e_comp_wl_input_pointer_check(res)) continue;
4467 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4469 if (comp_conf && comp_conf->input_log_enable)
4470 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4472 wl_pointer_send_button(res, serial, timestamp, btn, state);
4479 e_comp_wl_touch_cancel(void)
4481 _e_comp_wl_touch_cancel();
4484 E_API E_Comp_Wl_Hook *
4485 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4489 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4490 ch = E_NEW(E_Comp_Wl_Hook, 1);
4491 if (!ch) return NULL;
4492 ch->hookpoint = hookpoint;
4494 ch->data = (void*)data;
4495 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4500 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4503 if (_e_comp_wl_hooks_walking == 0)
4505 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4509 _e_comp_wl_hooks_delete++;
4512 E_API E_Comp_Wl_Pid_Hook *
4513 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4515 E_Comp_Wl_Pid_Hook *ch;
4517 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4519 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4520 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4522 ch->hookpoint = hookpoint;
4524 ch->data = (void*)data;
4525 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4531 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4534 if (_e_comp_wl_pid_hooks_walking == 0)
4536 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4540 _e_comp_wl_pid_hooks_delete++;
4543 E_API E_Comp_Wl_Intercept_Hook *
4544 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4546 E_Comp_Wl_Intercept_Hook *ch;
4548 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4549 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4550 if (!ch) return NULL;
4551 ch->hookpoint = hookpoint;
4553 ch->data = (void*)data;
4554 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4559 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4562 if (_e_comp_wl_intercept_hooks_walking == 0)
4564 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4568 _e_comp_wl_intercept_hooks_delete++;
4572 e_comp_wl_shell_surface_ready(E_Client *ec)
4576 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4580 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4582 e_config->use_cursor_timer = !!enabled;
4584 if (e_config->use_cursor_timer)
4586 if (!e_pointer_is_hidden(e_comp->pointer))
4588 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4593 if (e_comp_wl->ptr.hide_tmr)
4595 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4596 e_comp_wl->ptr.hide_tmr = NULL;
4598 cursor_timer_ec = NULL;
4600 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4603 if (e_pointer_is_hidden(e_comp->pointer))
4605 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4611 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4613 EINA_SAFETY_ON_NULL_RETURN(wc);
4614 EINA_SAFETY_ON_NULL_RETURN(dev);
4616 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4620 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4622 EINA_SAFETY_ON_NULL_RETURN(wc);
4623 EINA_SAFETY_ON_NULL_RETURN(dev);
4625 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4629 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4631 struct wl_resource *res;
4632 struct wl_client *wc;
4634 uint32_t serial, wl_keycode;
4635 enum wl_keyboard_key_state state;
4636 E_Comp_Config *comp_conf = NULL;
4637 const char *dev_name = NULL;
4639 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4640 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4641 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4643 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4644 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4646 wl_keycode = keycode - 8;
4647 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4649 wc = wl_resource_get_client(surface);
4650 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4651 if (!time) time = e_util_timestamp_get();
4652 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4653 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4655 comp_conf = e_comp_config_get();
4656 e_keyrouter_event_surface_send(ec, keycode);
4658 if (e_config->key_input_ttrace_enable)
4660 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4661 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4664 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4665 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4667 if (wl_resource_get_client(res) != wc) continue;
4668 if (!e_input_thread_mode_get())
4672 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4673 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4677 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4684 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4685 dev_name = e_device_name_get(dev);
4689 if (comp_conf && comp_conf->input_log_enable)
4690 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4693 wl_keyboard_send_key(res, serial, time,
4696 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4698 if (e_config->key_input_ttrace_enable)
4701 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4708 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4710 struct wl_resource *res;
4711 struct wl_client *wc;
4713 uint32_t serial, wl_keycode, cancel_keycode;
4714 E_Comp_Config *comp_conf = NULL;
4715 struct xkb_keymap *keymap = NULL;
4717 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4718 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4719 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4721 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4722 keymap = e_comp_wl->xkb.keymap;
4723 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4724 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4726 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4727 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4729 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4730 if (cancel_keycode == XKB_KEYCODE_INVALID)
4732 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4735 cancel_keycode = cancel_keycode - 8;
4737 wl_keycode = keycode - 8;
4738 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4740 wc = wl_resource_get_client(surface);
4741 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4742 if (!time) time = e_util_timestamp_get();
4744 comp_conf = e_comp_config_get();
4745 e_keyrouter_event_surface_send(ec, keycode);
4747 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4748 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4750 if (wl_resource_get_client(res) != wc) continue;
4751 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4752 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4754 if (comp_conf && comp_conf->input_log_enable)
4755 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4756 wl_keyboard_send_key(res, serial, time,
4757 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4758 wl_keyboard_send_key(res, serial, time,
4759 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4760 wl_keyboard_send_key(res, serial, time,
4761 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4763 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4770 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)
4772 struct wl_client *wc;
4774 E_Devicemgr_Input_Device *device = NULL;
4776 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4777 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4778 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4780 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4781 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4783 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4785 wc = wl_resource_get_client(surface);
4786 if (!time) time = e_util_timestamp_get();
4787 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4791 _e_comp_wl_send_event_device(wc, time, dev, serial);
4792 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4796 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4797 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4800 x = x + ec->client.x;
4801 y = y + ec->client.y;
4803 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4809 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)
4811 E_Devicemgr_Input_Device *device;
4813 struct wl_client *wc;
4815 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4816 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4817 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4819 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4820 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4822 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4824 wc = wl_resource_get_client(surface);
4825 if (!time) time = e_util_timestamp_get();
4826 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4830 _e_comp_wl_send_event_device(wc, time, dev, serial);
4831 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4835 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4836 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4839 x = x + ec->client.x;
4840 y = y + ec->client.y;
4842 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4848 e_comp_wl_touch_cancel_send(E_Client *ec)
4850 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4851 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4852 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4854 _e_comp_wl_send_touch_cancel(ec);
4860 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4863 struct wl_client *wc;
4865 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4866 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4869 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4870 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4872 wc = wl_resource_get_client(surface);
4873 if (!time) time = e_util_timestamp_get();
4874 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4876 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4877 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4880 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4881 WL_POINTER_BUTTON_STATE_PRESSED);
4883 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4884 WL_POINTER_BUTTON_STATE_RELEASED);
4890 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4893 struct wl_client *wc;
4895 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4896 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4897 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4899 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4900 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4902 wc = wl_resource_get_client(surface);
4903 if (!time) time = e_util_timestamp_get();
4904 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4906 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4907 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4909 x = x + ec->client.x;
4910 y = y + ec->client.y;
4912 _e_comp_wl_send_mouse_move(ec, x, y, time);
4918 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4921 struct wl_client *wc;
4923 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4924 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4925 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4927 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4928 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4930 wc = wl_resource_get_client(surface);
4931 if (!time) time = e_util_timestamp_get();
4932 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4934 if (_e_comp_wl_check_cursor_timer_needed(ec))
4936 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4940 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4941 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4943 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4945 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4947 if (_e_comp_wl_check_cursor_timer_needed(ec))
4948 _e_comp_wl_cursor_move_timer_control(ec);
4955 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4958 struct wl_client *wc;
4959 struct wl_resource *res;
4962 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4963 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4965 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4966 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4968 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4969 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4971 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4972 wc = wl_resource_get_client(surface);
4973 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4974 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4976 if (!e_comp_wl_input_pointer_check(res)) continue;
4977 if (wl_resource_get_client(res) != wc) continue;
4979 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4980 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4982 wl_pointer_send_enter(res, serial, surface,
4983 wl_fixed_from_int(x),
4984 wl_fixed_from_int(y));
4985 ec->pointer_enter_sent = EINA_TRUE;
4987 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4993 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4996 struct wl_client *wc;
4997 struct wl_resource *res;
5000 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5001 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5002 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5003 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5004 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5005 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5007 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5008 wc = wl_resource_get_client(surface);
5009 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5010 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5012 if (!e_comp_wl_input_pointer_check(res)) continue;
5013 if (wl_resource_get_client(res) != wc) continue;
5015 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5016 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5018 wl_pointer_send_leave(res, serial, surface);
5019 ec->pointer_enter_sent = EINA_FALSE;
5026 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)
5028 Evas_Event_Mouse_In ev_in;
5031 if (ec->pointer_enter_sent) return;
5033 ev_in.buttons = buttons;
5041 ev_in.modifiers = modifiers;
5042 ev_in.locks = locks;
5043 ev_in.timestamp = timestamp;
5044 ev_in.event_flags = event_flags;
5047 ev_in.event_src = event_src;
5049 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5053 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)
5055 Evas_Event_Mouse_Out ev_out;
5058 if (!ec->pointer_enter_sent) return;
5060 ev_out.buttons = buttons;
5062 ev_out.output.x = x;
5063 ev_out.output.y = y;
5064 ev_out.canvas.x = x;
5065 ev_out.canvas.y = y;
5068 ev_out.modifiers = modifiers;
5069 ev_out.locks = locks;
5070 ev_out.timestamp = timestamp;
5071 ev_out.event_flags = event_flags;
5074 ev_out.event_src = event_src;
5076 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5080 e_comp_wl_cursor_hide(E_Client *ec)
5082 struct wl_resource *res;
5083 struct wl_client *wc;
5087 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5089 if (e_comp_wl->ptr.hide_tmr)
5091 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5092 e_comp_wl->ptr.hide_tmr = NULL;
5094 cursor_timer_ec = NULL;
5096 if (!ec) return EINA_FALSE;
5097 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5098 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5099 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5101 wc = wl_resource_get_client(surface);
5102 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5103 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5105 if (!e_comp_wl_input_pointer_check(res)) continue;
5106 if (wl_resource_get_client(res) != wc) continue;
5107 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5108 wl_pointer_send_leave(res, serial, surface);
5109 ec->pointer_enter_sent = EINA_FALSE;
5115 /* surface to buffer
5116 * - width : surface width
5117 * - height : surface height
5118 * - transform: buffer transform
5119 * - scale : buffer scale
5121 * - width : screen width
5122 * - height : screen height
5123 * - transform: output transform
5124 * - scale : output scale
5126 static E_Util_Transform_Matrix
5127 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5129 E_Util_Transform_Matrix m;
5131 e_util_transform_matrix_load_identity(&m);
5133 if (transform & 0x4)
5135 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5136 e_util_transform_matrix_flip_x(&m);
5137 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5140 switch (transform & 0x3)
5142 case WL_OUTPUT_TRANSFORM_90:
5143 e_util_transform_matrix_translate(&m, -width, 0, 0);
5144 e_util_transform_matrix_rotation_z(&m, 270);
5146 case WL_OUTPUT_TRANSFORM_180:
5147 e_util_transform_matrix_translate(&m, -width, -height, 0);
5148 e_util_transform_matrix_rotation_z(&m, 180);
5150 case WL_OUTPUT_TRANSFORM_270:
5151 e_util_transform_matrix_translate(&m, 0, -height, 0);
5152 e_util_transform_matrix_rotation_z(&m, 90);
5158 e_util_transform_matrix_scale(&m, scale, scale, 1);
5163 /* surface to buffer
5164 * - surface width, surface height, buffer transform, buffer scale
5166 * - screen width, screen height, output transform, output scale
5169 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5171 E_Util_Transform_Matrix m;
5172 E_Util_Transform_Vertex v;
5174 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5176 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5177 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5178 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5182 * - buffer width, buffer height, buffer transform, buffer scale
5185 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5187 E_Util_Transform_Matrix m;
5188 E_Util_Transform_Vertex v;
5191 if (transform != 0 || scale > 1)
5193 tw = ((transform % 2) ? height : width) / scale;
5194 th = ((transform % 2) ? width : height) / scale;
5202 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5203 m = e_util_transform_matrix_inverse_get(&m);
5205 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5206 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5207 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5210 /* surface to buffer
5211 * - surface width, surface height, buffer transform, buffer scale
5213 * - screen width, screen height, output transform, output scale
5216 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5217 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5219 E_Util_Transform_Matrix m;
5220 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5221 E_Util_Transform_Rect_Vertex sv;
5223 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5225 sv = e_util_transform_rect_to_vertices(&sr);
5226 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5227 sr = e_util_transform_vertices_to_rect(&sv);
5236 * - buffer width, buffer height, buffer transform, buffer scale
5239 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5240 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5242 E_Util_Transform_Matrix m;
5243 E_Util_Transform_Rect br = {bx, by, bw, bh};
5244 E_Util_Transform_Rect_Vertex bv;
5247 if (transform != 0 || scale > 1)
5249 tw = ((transform % 2) ? height : width) / scale;
5250 th = ((transform % 2) ? width : height) / scale;
5258 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5259 m = e_util_transform_matrix_inverse_get(&m);
5261 bv = e_util_transform_rect_to_vertices(&br);
5262 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5263 br = e_util_transform_vertices_to_rect(&bv);
5271 EINTERN E_Comp_Wl_Output*
5272 e_comp_wl_output_find(E_Client *ec)
5275 E_Comp_Wl_Output *output;
5277 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5279 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5281 if (output->transform % 2)
5283 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5284 ec->y < output->x || ec->y >= (output->x + output->w))
5289 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5290 ec->y < output->y || ec->y >= (output->y + output->h))
5300 EINTERN Eina_Array *
5301 e_comp_wl_output_find_all(E_Client *ec)
5303 E_Comp_Wl_Output *output;
5304 Eina_Array *outputs;
5307 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5309 outputs = eina_array_new(4);
5313 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5315 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5316 output->x, output->y, output->w, output->h))
5318 eina_array_push(outputs, output);
5322 if (eina_array_count(outputs) == 0)
5324 eina_array_free(outputs);
5331 // --------------------------------------------------------
5332 // tizen_move_resize
5333 // --------------------------------------------------------
5335 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5342 E_Client_Pending_Geometry *geo;
5345 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5346 if (ec->fullscreen || ec->maximized) goto err;
5348 geo = E_NEW(E_Client_Pending_Geometry, 1);
5351 geo->serial = serial;
5357 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5358 ec->surface_sync.wait_commit = EINA_TRUE;
5363 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5370 e_comp_wl_commit_sync_configure(E_Client *ec)
5373 E_Client_Pending_Geometry *geo;
5375 Eina_Bool match_size = EINA_FALSE;
5382 if (!ec || !ec->frame) goto ret;
5383 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5386 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5387 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5389 if (eina_list_count(ec->surface_sync.pending_geometry))
5391 Eina_List *ll = NULL;
5392 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5396 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5401 if ((geo->w == bw) && (geo->h == bh))
5403 match_size = EINA_TRUE;
5408 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5415 if ((config.w != ec->w) || (config.h != ec->h))
5417 e_client_size_set(ec, config.w, config.h);
5418 ec->changes.size = EINA_TRUE;
5422 // FIXME: The geometry of the client would be better to be calculated
5423 // at e_desk or at e_desk_area. So the position(x,y) of the client
5424 // should be calcuated at the e_desk or at the e_desk_area.
5426 desk = e_comp_desk_find_by_ec(ec);
5429 ec->client.x = desk->geom.x + config.x;
5430 ec->client.y = desk->geom.y + config.y;
5434 ec->client.x = config.x;
5435 ec->client.y = config.y;
5438 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5440 e_client_pos_set(ec, ec->client.x, ec->client.y);
5442 ec->changes.pos = 1;
5446 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5450 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5451 ec->surface_sync.wait_commit = EINA_FALSE;
5453 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5455 // rollback wait_commit if there are pending requests remained
5456 if (eina_list_count(ec->surface_sync.pending_geometry))
5457 ec->surface_sync.wait_commit = EINA_TRUE;
5462 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);
5469 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5470 struct wl_resource *res_moveresize)
5472 wl_resource_destroy(res_moveresize);
5476 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5477 struct wl_resource *res_moveresize,
5478 struct wl_resource *surface,
5485 /* to be implemented */
5488 int cur_w = 0, cur_h = 0;
5490 ec = e_client_from_surface_resource(surface);
5493 pending = e_client_pending_geometry_has(ec);
5494 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5495 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);
5499 if ((cur_w == w) && (cur_h == h))
5501 e_client_pos_set(ec, x, y);
5502 ec->changes.pos = 1;
5508 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5512 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5515 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5517 _tz_move_resize_iface_cb_destroy,
5518 _tz_move_resize_iface_cb_set_geometry,
5522 _tz_moveresize_cb_bind(struct wl_client *client,
5523 void *data EINA_UNUSED,
5527 struct wl_resource *res_moveresize;
5529 res_moveresize = wl_resource_create(client,
5530 &tizen_move_resize_interface,
5533 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5536 wl_resource_set_implementation(res_moveresize,
5537 &_tz_move_resize_iface,
5543 ERR("Could not create tizen_move_resize_interface res: %m");
5544 wl_client_post_no_memory(client);
5548 _e_comp_wl_move_resize_init(void)
5550 if (!e_comp_wl) return;
5551 if (!e_comp_wl->wl.disp) return;
5553 if (!wl_global_create(e_comp_wl->wl.disp,
5554 &tizen_move_resize_interface,
5557 _tz_moveresize_cb_bind))
5559 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5566 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5568 E_Comp_Wl_Output *output;
5569 pid_t output_pid = 0;
5570 Eina_List *l = NULL, *l2 = NULL;
5571 struct wl_resource *resource = NULL;
5573 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5575 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5576 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5577 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5579 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5581 /* if we have bound resources, send updates */
5582 EINA_LIST_FOREACH(output->resources, l2, resource)
5584 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5585 if (output_pid != pid) continue;
5587 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5589 // send output information to the client
5590 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5598 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5600 _e_comp_wl_surface_state_init(state, w, h);
5604 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5606 _e_comp_wl_surface_state_commit(ec, state);
5610 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5612 _e_comp_wl_hook_call(hookpoint, ec);
5616 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5618 _e_comp_wl_surface_state_finish(state);
5622 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5624 _e_comp_wl_surface_state_buffer_set(state, buffer);
5628 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5629 int sx, int sy, int *dx, int *dy)
5633 case WL_OUTPUT_TRANSFORM_NORMAL:
5637 case WL_OUTPUT_TRANSFORM_FLIPPED:
5638 *dx = width - sx, *dy = sy;
5640 case WL_OUTPUT_TRANSFORM_90:
5641 *dx = height - sy, *dy = sx;
5643 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5644 *dx = height - sy, *dy = width - sx;
5646 case WL_OUTPUT_TRANSFORM_180:
5647 *dx = width - sx, *dy = height - sy;
5649 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5650 *dx = sx, *dy = height - sy;
5652 case WL_OUTPUT_TRANSFORM_270:
5653 *dx = sy, *dy = width - sx;
5655 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5665 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5668 int tx1, ty1, tx2, ty2;
5669 int width_from_buffer, height_from_buffer;
5671 switch (vp->buffer.transform)
5673 case WL_OUTPUT_TRANSFORM_90:
5674 case WL_OUTPUT_TRANSFORM_270:
5675 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5676 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5677 width_from_buffer = bh / vp->buffer.scale;
5678 height_from_buffer = bw / vp->buffer.scale;
5681 width_from_buffer = bw / vp->buffer.scale;
5682 height_from_buffer = bh / vp->buffer.scale;
5686 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5690 x2 = width_from_buffer;
5691 y2 = height_from_buffer;
5695 x1 = wl_fixed_to_int(vp->buffer.src_x);
5696 y1 = wl_fixed_to_int(vp->buffer.src_y);
5697 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5698 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5701 buffer_transform(width_from_buffer, height_from_buffer,
5702 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5703 buffer_transform(width_from_buffer, height_from_buffer,
5704 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5706 out->x = (tx1 <= tx2) ? tx1 : tx2;
5707 out->y = (ty1 <= ty2) ? ty1 : ty2;
5708 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5709 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5713 * Convert given four coordinates to elements of rectangle
5714 * @in p[4] Coordinates to be converted
5715 * @out rect x, y, width, and height
5716 * transform Angle which represents TDM_TRANSFORM of rectangle
5717 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5718 * 1. The given coordinates are not represented by rectangle.
5719 * 2. All angles except for 0, 90, 180, 270.
5722 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5724 Eina_Bool ret = EINA_FALSE;
5726 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))
5729 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5732 *rotation = TDM_TRANSFORM_NORMAL;
5735 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5739 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5742 *rotation = TDM_TRANSFORM_180;
5745 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5750 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))
5753 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5756 *rotation = TDM_TRANSFORM_90;
5759 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5763 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5766 *rotation = TDM_TRANSFORM_270;
5769 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5779 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5784 for (i = 0; i < 4; i++)
5785 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5787 if (!_coords_to_rectangle_convert(p, out, rotation))
5789 DBG("Cannot convert given coords to rectangle.\n"
5790 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5791 p[0].x, p[0].y, p[1].x, p[1].y,
5792 p[2].x, p[2].y, p[3].x, p[3].y);
5800 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5802 int trans_rotation, flip;
5804 trans_rotation = transform & 0x3;
5805 flip = transform & 0x4;
5807 return (flip + (trans_rotation + rotation) % 4);
5811 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5819 if (e_comp_wl_subsurface_check(ec))
5820 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5827 out->w = ec->comp_data->width_from_viewport;
5828 out->w = (out->w + 1) & ~1;
5829 out->h = ec->comp_data->height_from_viewport;
5831 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5832 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5836 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5838 E_Comp_Wl_Buffer *buffer;
5839 E_Comp_Wl_Buffer_Viewport *vp;
5841 enum wl_output_transform buffer_transform;
5842 unsigned int rotation;
5843 Eina_Bool res = EINA_FALSE;
5845 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5847 if (e_object_is_del(E_OBJECT(ec)))
5850 vp = &ec->comp_data->scaler.buffer_viewport;
5852 if (buffer_viewport)
5854 buffer = ec->comp_data->buffer_ref.buffer;
5855 /* Getting a viewport of buffer needs geometry of buffer. */
5859 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5862 if ((output_viewport) || (transform))
5864 m = e_client_map_get(ec);
5866 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5868 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5873 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5874 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5875 * Since buffer.transform isn't applied using evas_map,
5876 * it has to be taken into account here to apply buffer.transform
5877 * and rotation of e_client_transform together. */
5879 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5881 *transform = (unsigned int)buffer_transform;
5889 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5891 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5892 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5894 /* Must be called with valid comp_data */
5895 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5897 if ((ec->comp_data->role_name == NULL) ||
5898 (ec->comp_data->role_name == role_name) ||
5899 (strcmp(ec->comp_data->role_name, role_name) == 0))
5901 ec->comp_data->role_name = role_name;
5907 wl_resource_post_error(error_resource, error_code,
5908 "Cannot assign role %s to wl_surface@%d,"
5909 " already has role %s\n",
5911 ec->comp_data->wl_surface ?
5912 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5913 ec->comp_data->role_name);
5919 EINTERN const char *
5920 e_comp_wl_surface_role_get(E_Client *ec)
5922 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5923 return ec->comp_data ? ec->comp_data->role_name : NULL;
5926 EINTERN struct wl_resource *
5927 e_comp_wl_client_surface_get(E_Client *ec)
5929 struct wl_resource *surface = NULL;
5930 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5931 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5933 g_mutex_lock(&ec->comp_data->surface_mutex);
5934 surface = ec->comp_data->surface;
5935 g_mutex_unlock(&ec->comp_data->surface_mutex);
5940 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5942 EINA_SAFETY_ON_NULL_RETURN(ec);
5943 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5945 g_mutex_lock(&ec->comp_data->surface_mutex);
5946 ec->comp_data->surface = surface;
5947 g_mutex_unlock(&ec->comp_data->surface_mutex);
5951 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5953 return e_compositor_util_client_from_surface_resource(surface_resource);
5957 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5959 if (!ec->comp_data->mapped)
5961 if (ec->comp_data->shell.surface &&
5962 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5964 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5970 if (ec->comp_data->mapped)
5972 /* will be unmapped. so run capture */
5973 e_comp_wl_remote_surface_image_save(ec);
5977 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5979 ec->comp_data->pending.sx = sx;
5980 ec->comp_data->pending.sy = sy;
5981 ec->comp_data->pending.new_attach = EINA_TRUE;
5983 e_client_fps_update(ec);
5987 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5989 if (ec->comp_data->pending.opaque)
5990 eina_tiler_clear(ec->comp_data->pending.opaque);
5994 eina_tiler_union(ec->comp_data->pending.opaque, region);
5996 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6000 ec->argb = EINA_FALSE;
6001 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6003 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6004 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6012 ec->argb = EINA_TRUE;
6013 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6015 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6016 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6022 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6024 if (ec->comp_data->pending.input)
6025 eina_tiler_clear(ec->comp_data->pending.input);
6029 if (eina_tiler_empty(region))
6031 ELOGF("COMP", " |unset input rect", NULL);
6032 e_comp_object_input_objs_del(ec->frame);
6033 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6036 eina_tiler_union(ec->comp_data->pending.input, region);
6040 eina_tiler_rect_add(ec->comp_data->pending.input,
6041 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6046 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6048 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6052 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6054 E_Comp_Wl_Subsurf_Data *sdata;
6059 if (ec->comp_data->frames)
6061 ec->comp_data->frames =
6062 eina_list_remove(ec->comp_data->frames, callback_resource);
6065 if (ec->comp_data->pending.frames)
6067 ec->comp_data->pending.frames =
6068 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6071 sdata = ec->comp_data->sub.data;
6072 if ((sdata) && (sdata->cached.frames))
6074 sdata->cached.frames =
6075 eina_list_remove(sdata->cached.frames, callback_resource);
6080 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6082 if (e_object_is_del(E_OBJECT(ec))) return;
6084 if (e_comp_wl_remote_surface_commit(ec)) return;
6086 e_comp_wl_surface_commit(ec);
6088 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6092 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6094 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6095 ec->comp_data->sub.data = sub;
6097 /* set subsurface client properties */
6098 ec->borderless = EINA_TRUE;
6099 ec->argb = EINA_TRUE;
6100 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6101 ec->lock_border = EINA_TRUE;
6102 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6103 ec->netwm.state.skip_taskbar = EINA_TRUE;
6104 ec->netwm.state.skip_pager = EINA_TRUE;
6105 ec->border_size = 0;
6106 ec->lock_user_location = 0;
6107 ec->lock_client_location = 0;
6108 ec->lock_user_size = 0;
6109 ec->lock_client_size = 0;
6110 ec->lock_client_stacking = 0;
6111 ec->lock_user_maximize = 0;
6112 ec->lock_client_maximize = 0;
6113 ec->changes.need_maximize = 0;
6114 ec->maximized = E_MAXIMIZE_NONE;
6117 ec->new_client = ec->netwm.ping = EINA_TRUE;
6118 e_comp->new_clients++;
6119 e_client_unignore(ec);
6121 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6122 * It's not for subsurface. */
6123 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6127 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6129 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6132 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6134 sub->parent = parent;
6138 layer = e_client_layer_get(parent);
6139 if (layer > E_LAYER_BOTTOM)
6140 e_client_layer_set(ec, layer);
6143 if (parent->comp_data)
6145 /* append this client to the parents subsurface list */
6146 parent->comp_data->sub.list_pending =
6147 eina_list_append(parent->comp_data->sub.list_pending, ec);
6148 parent->comp_data->sub.list_changed = EINA_TRUE;
6153 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6155 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6156 E_Client *parent = sub->parent;
6158 parent->comp_data->sub.list =
6159 eina_list_remove(parent->comp_data->sub.list, ec);
6160 parent->comp_data->sub.list_pending =
6161 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6162 parent->comp_data->sub.below_list =
6163 eina_list_remove(parent->comp_data->sub.below_list, ec);
6164 parent->comp_data->sub.below_list_pending =
6165 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6171 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)
6173 sub->resource = subsurface_resource;
6174 sub->cached_buffer_ref.buffer = NULL;
6175 sub->synchronized = EINA_TRUE;
6176 sub->parent = parent;
6177 sub->remote_surface.offscreen_parent = offscreen_parent;
6178 if (offscreen_parent)
6179 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6181 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6183 _e_comp_wl_client_subsurface_set(ec, sub);
6184 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6186 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6190 e_comp_wl_client_subsurface_finish(E_Client *ec)
6192 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6195 e_comp_wl_client_subsurface_parent_unset(ec);
6197 e_comp_wl_surface_state_finish(&sub->cached);
6198 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6200 ec->comp_data->sub.data = NULL;
6204 e_comp_wl_client_evas_init(E_Client *ec)
6206 EINA_SAFETY_ON_NULL_RETURN(ec);
6208 _e_comp_wl_client_evas_init(ec);
6212 e_comp_wl_client_evas_deinit(E_Client *ec)
6214 EINA_SAFETY_ON_NULL_RETURN(ec);
6216 _e_comp_wl_client_evas_deinit(ec);
6220 e_comp_wl_focus_check(void)
6222 _e_comp_wl_focus_check();
6226 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6233 if ((parent->comp_data) && (parent->comp_data->sub.data))
6234 parent = parent->comp_data->sub.data->parent;