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"
36 #include <tizen-extension-server-protocol.h>
37 #include <relative-pointer-unstable-v1-server-protocol.h>
38 #include <pointer-constraints-unstable-v1-server-protocol.h>
40 #include <wayland-tbm-server.h>
42 #include <libds/log.h>
43 #include <libds/single_pixel_buffer_v1.h>
46 /* handle include for printing uint64_t */
47 #define __STDC_FORMAT_MACROS
50 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
52 /* Resource Data Mapping: (wl_resource_get_user_data)
54 * wl_surface == e_pixmap
55 * wl_region == eina_tiler
56 * wl_subsurface == e_client
60 typedef struct _E_Comp_Data E_Comp_Data;
65 struct wl_listener client_created;
68 static void _e_comp_wl_move_resize_init(void);
70 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
73 typedef struct _E_Comp_Wl_Key_Data
79 struct _E_Comp_Wl_Evas_Gl
82 Evas_GL_Config *glcfg;
83 Evas_GL_Context *glctx;
84 Evas_GL_Surface *glsfc;
88 static Eina_List *handlers = NULL;
89 static E_Client *cursor_timer_ec = NULL;
90 static Eina_Bool need_send_released = EINA_FALSE;
91 static Eina_Bool need_send_motion = EINA_TRUE;
93 static GMutex connection_mutex;
95 static int _e_comp_wl_hooks_delete = 0;
96 static int _e_comp_wl_hooks_walking = 0;
98 static int _e_comp_wl_pid_hooks_delete = 0;
99 static int _e_comp_wl_pid_hooks_walking = 0;
101 static int _e_comp_wl_intercept_hooks_delete = 0;
102 static int _e_comp_wl_intercept_hooks_walking = 0;
104 static Eina_Inlist *_e_comp_wl_hooks[] =
106 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
107 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
108 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
109 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
110 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
111 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
112 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
113 [E_COMP_WL_HOOK_DEL] = NULL,
114 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
115 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
116 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
119 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
121 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
124 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
126 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
127 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
128 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
129 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
130 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
131 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
134 static Eina_List *hooks = NULL;
136 /* local functions */
138 _e_comp_wl_hooks_clean(void)
143 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
144 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
146 if (!ch->delete_me) continue;
147 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
153 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
157 e_object_ref(E_OBJECT(ec));
158 _e_comp_wl_hooks_walking++;
159 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
161 if (ch->delete_me) continue;
162 ch->func(ch->data, ec);
163 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
164 (e_object_is_del(E_OBJECT(ec))))
167 _e_comp_wl_hooks_walking--;
168 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
169 _e_comp_wl_hooks_clean();
170 e_object_unref(E_OBJECT(ec));
174 _e_comp_wl_pid_hooks_clean(void)
177 E_Comp_Wl_Pid_Hook *ch;
179 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
180 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
182 if (!ch->delete_me) continue;
183 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
189 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
191 E_Comp_Wl_Pid_Hook *ch;
193 _e_comp_wl_pid_hooks_walking++;
194 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
196 if (ch->delete_me) continue;
197 ch->func(ch->data, pid);
199 _e_comp_wl_pid_hooks_walking--;
200 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
201 _e_comp_wl_pid_hooks_clean();
205 _e_comp_wl_intercept_hooks_clean(void)
208 E_Comp_Wl_Intercept_Hook *ch;
210 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
211 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
213 if (!ch->delete_me) continue;
214 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
220 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
222 E_Comp_Wl_Intercept_Hook *ch;
223 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
225 e_object_ref(E_OBJECT(ec));
226 _e_comp_wl_intercept_hooks_walking++;
227 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
229 if (ch->delete_me) continue;
230 res = ch->func(ch->data, ec);
231 if (!res) ret = EINA_FALSE;
232 if (e_object_is_del(E_OBJECT(ec)))
235 _e_comp_wl_intercept_hooks_walking--;
236 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
237 _e_comp_wl_intercept_hooks_clean();
238 e_object_unref(E_OBJECT(ec));
245 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
251 if (e_comp_object_frame_exists(ec->frame))
252 w = ec->client.w, h = ec->client.h;
254 w = ec->w, h = ec->h;
258 // Width and Height are -1 means that we don't consider size value
262 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
266 _e_comp_wl_focus_check(void)
270 if (stopping) return;
271 ec = e_client_focused_get();
273 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
277 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
279 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
281 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
282 IDLE_EXITER~CB_PREPARE);
284 return ECORE_CALLBACK_RENEW;
288 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
290 /* dispatch pending wayland events */
291 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
293 return ECORE_CALLBACK_RENEW;
297 e_comp_wl_display_flush()
299 if (e_comp_wl && e_comp_wl->wl.disp)
301 if (e_config->key_input_ttrace_enable)
303 TRACE_INPUT_BEGIN(wl_display_flush_clients);
304 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
307 g_mutex_lock(&connection_mutex);
308 wl_display_flush_clients(e_comp_wl->wl.disp);
309 g_mutex_unlock(&connection_mutex);
311 if (e_config->key_input_ttrace_enable)
314 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
320 e_comp_wl_connection_lock()
322 e_input_boost_lock(&connection_mutex);
326 e_comp_wl_connection_unlock()
328 e_input_boost_unlock(&connection_mutex);
332 e_comp_wl_focused_client_flush()
334 E_Client *focused_ec;
335 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
337 e_input_boost_lock(&connection_mutex);
338 focused_ec = e_client_focused_get();
342 struct wl_client *wc;
343 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
346 e_input_boost_unlock(&connection_mutex);
350 wc = wl_resource_get_client(surface);
354 e_input_boost_unlock(&connection_mutex);
358 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
362 if (e_comp_wl->idle_exiter_timestamp > 0.0)
364 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
365 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
367 ELOGF("E_COMP", "prepare gap time: %lfms",
372 e_comp_wl->idle_exiter_timestamp = 0.0;
374 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
376 /* flush pending client events */
377 e_comp_wl_display_flush();
379 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
380 IDLE_EXITER~CB_PREPARE);
383 E_API enum wl_output_transform
384 e_comp_wl_output_buffer_transform_get(E_Client *ec)
386 E_Comp_Wl_Buffer_Viewport *vp;
387 E_Comp_Wl_Buffer *buffer;
388 enum wl_output_transform transform, rotation;
390 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
391 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
392 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
394 vp = &ec->comp_data->scaler.buffer_viewport;
395 if (e_comp_wl_subsurface_check(ec))
396 return vp->buffer.transform;
398 buffer = ec->comp_data->buffer_ref.buffer;
401 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
402 return vp->buffer.transform;
404 rotation = buffer->transform;
406 return vp->buffer.transform;
408 /* ignore the flip value when calculating transform because the screen rotation
409 * functionality doesn't consider the flip output transform currently
411 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
413 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
414 ec, rotation, vp->buffer.transform, transform);
419 EINTERN enum wl_output_transform
420 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
422 E_Comp_Wl_Buffer_Viewport *vp;
423 E_Comp_Wl_Buffer *buffer;
424 enum wl_output_transform transform, rotation;
426 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
427 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
428 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
430 vp = &ec->comp_data->pending.buffer_viewport;
431 if (e_comp_wl_subsurface_check(ec))
432 return vp->buffer.transform;
434 buffer = ec->comp_data->pending.buffer;
437 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
438 return vp->buffer.transform;
440 rotation = buffer->transform;
442 return vp->buffer.transform;
444 /* ignore the flip value when calculating transform because the screen rotation
445 * functionality doesn't consider the flip output transform currently
447 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
449 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
450 ec, rotation, vp->buffer.transform, transform);
456 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
458 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
459 E_Comp_Wl_Buffer *buffer;
460 int32_t width, height;
462 buffer = e_pixmap_resource_get(ec->pixmap);
465 ec->comp_data->width_from_buffer = 0;
466 ec->comp_data->height_from_buffer = 0;
470 switch (e_comp_wl_output_buffer_transform_get(ec))
472 case WL_OUTPUT_TRANSFORM_90:
473 case WL_OUTPUT_TRANSFORM_270:
474 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
475 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
476 width = buffer->h / vp->buffer.scale;
477 height = buffer->w / vp->buffer.scale;
480 width = buffer->w / vp->buffer.scale;
481 height = buffer->h / vp->buffer.scale;
485 ec->comp_data->width_from_buffer = width;
486 ec->comp_data->height_from_buffer = height;
490 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
492 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
493 int32_t width, height;
495 width = ec->comp_data->width_from_buffer;
496 height = ec->comp_data->height_from_buffer;
498 if (width == 0 && height == 0) return;
500 if (width != 0 && vp->surface.width != -1)
502 ec->comp_data->width_from_viewport = vp->surface.width;
503 ec->comp_data->height_from_viewport = vp->surface.height;
507 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
509 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
510 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
511 ec->comp_data->width_from_viewport = w ?: 1;
512 ec->comp_data->height_from_viewport = h ?: 1;
516 ec->comp_data->width_from_viewport = width;
517 ec->comp_data->height_from_viewport = height;
521 e_comp_wl_topmost_parent_get(E_Client *ec)
525 if (!e_comp_wl_subsurface_check(ec))
528 parent = e_comp_wl_subsurface_parent_get(ec);
531 if (!e_comp_wl_subsurface_check(parent))
534 parent = e_comp_wl_subsurface_parent_get(parent);
541 e_comp_wl_map_apply(E_Client *ec)
543 E_Comp_Wl_Buffer_Viewport *vp;
544 E_Comp_Wl_Subsurf_Data *sdata;
545 E_Comp_Wl_Client_Data *cdata;
546 int x1, y1, x2, y2, x, y;
548 Eina_Bool zoom_animating = EINA_FALSE;
550 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
552 e_comp_object_map_update(ec->frame);
554 cdata = ec->comp_data;
555 vp = &cdata->scaler.buffer_viewport;
556 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
557 (!cdata->viewport_transform))
560 if (e_comp_wl_subsurface_check(ec))
562 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
564 sdata = ec->comp_data->sub.data;
565 if (sdata->remote_surface.offscreen_parent)
567 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
568 Eina_Rectangle *rect;
571 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
573 /* TODO: If there are one more regions, it means that provider's offscreen
574 * is displayed by one more remote_surfaces. Have to consider it later. At
575 * this time, just consider only one remote_surface.
589 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
590 if (x != dx || y != dy)
591 evas_object_move(ec->frame, dx, dy);
593 if (!cdata->viewport_transform)
595 cdata->viewport_transform = e_util_transform_new();
596 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
597 e_client_transform_core_add(ec, cdata->viewport_transform);
600 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
601 ec->comp_data->width_from_viewport,
602 ec->comp_data->height_from_viewport);
604 if (vp->buffer.src_width == wl_fixed_from_int(-1))
608 x2 = cdata->width_from_buffer;
609 y2 = cdata->height_from_buffer;
613 x1 = wl_fixed_to_int(vp->buffer.src_x);
614 y1 = wl_fixed_to_int(vp->buffer.src_y);
615 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
616 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
619 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
620 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
621 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
622 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
625 desk = e_comp_desk_find_by_ec(ec);
627 zoom_animating = e_desk_zoom_is_animating(desk);
629 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
630 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
631 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
633 /* workaround:: when the desk zoom is doing their animation,
634 the transform core update can override animation's zoom boundary.
635 so, don't doing transform core update while desk zoom animation */
637 e_client_transform_core_update(ec);
642 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
646 int map_c = 0, map_x = 0, map_y = 0;
647 double inv_x = 0.0, inv_y = 0.0;
649 EINA_SAFETY_ON_NULL_RETURN(ec);
651 map = e_client_map_get(ec);
652 map_c = e_map_count_get(map);
654 if (!map || map_c <= 0)
664 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
665 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
666 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
667 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
669 for (int i = 0; i < map_c; i++)
671 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
672 e_map_point_image_uv_set(map2, i, map_x, map_y);
674 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
684 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
690 if (!(ec = data)) return;
691 if (e_object_is_del(data)) return;
693 if (!ec->override) e_hints_window_visible_set(ec);
695 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
696 (!ec->comp_data->need_reparent))
698 ec->comp_data->need_reparent = EINA_TRUE;
699 ec->visible = EINA_TRUE;
701 if (!e_client_util_ignored_get(ec))
703 ec->take_focus = !starting;
707 if (!ec->comp_data->need_reparent)
709 if ((ec->hidden) || (ec->iconic))
711 evas_object_hide(ec->frame);
712 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
715 evas_object_show(ec->frame);
718 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
719 evas_object_show(tmp->frame);
721 topmost = e_comp_wl_topmost_parent_get(ec);
722 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
723 e_comp_wl_subsurface_show(ec);
725 if (ec->comp_data->sub.below_obj)
726 evas_object_show(ec->comp_data->sub.below_obj);
730 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
736 if (!(ec = data)) return;
737 if (e_object_is_del(E_OBJECT(ec))) return;
739 /* Uncommonly some clients's final buffer can be skipped if the client
740 * requests unmap of its surface right after wl_surface@commit.
741 * So if this client evas object is hidden state and client is already
742 * unmmapped, we can consider to clear pixmap image here mandatorily.
744 if (!ec->comp_data->mapped)
745 e_pixmap_image_clear(ec->pixmap, 1);
747 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
748 evas_object_hide(tmp->frame);
750 topmost = e_comp_wl_topmost_parent_get(ec);
751 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
752 e_comp_wl_subsurface_hide(ec);
754 if (ec->comp_data->sub.below_obj)
755 evas_object_hide(ec->comp_data->sub.below_obj);
757 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
761 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
768 if (!(ec = data)) return;
769 if (e_object_is_del(E_OBJECT(ec))) return;
771 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
773 if (!e_comp_wl_subsurface_check(subc)) continue;
774 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
775 evas_object_move(subc->frame, x, y);
777 if (subc->comp_data->scaler.viewport)
779 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
780 if (cdata->viewport_transform)
781 e_comp_wl_map_apply(subc);
785 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
787 if (!e_comp_wl_subsurface_check(subc)) continue;
788 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
789 evas_object_move(subc->frame, x, y);
791 if (subc->comp_data->scaler.viewport)
793 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
794 if (cdata->viewport_transform)
795 e_comp_wl_map_apply(subc);
799 if (ec->comp_data->sub.below_obj)
801 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
802 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
807 _e_comp_wl_send_touch_cancel(E_Client *ec)
810 struct wl_resource *res;
811 struct wl_client *wc;
812 E_Comp_Config *comp_conf = NULL;
815 if (e_object_is_del(E_OBJECT(ec))) return;
816 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
818 if (!surface) return;
819 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
821 wc = wl_resource_get_client(surface);
823 comp_conf = e_comp_config_get();
825 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
827 if (wl_resource_get_client(res) != wc) continue;
828 if (!e_comp_wl_input_touch_check(res)) continue;
830 if (comp_conf && comp_conf->input_log_enable)
831 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
833 wl_touch_send_cancel(res);
838 _e_comp_wl_touch_cancel(void)
842 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
844 if (!e_comp_wl->touch.pressed) return;
846 _e_comp_wl_send_touch_cancel(ec);
849 static E_Devicemgr_Input_Device *
850 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
852 E_Devicemgr_Input_Device *last_kbd = NULL;
855 case ECORE_DEVICE_CLASS_MOUSE:
856 return e_devicemgr->last_device_ptr;
857 case ECORE_DEVICE_CLASS_KEYBOARD:
858 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
860 case ECORE_DEVICE_CLASS_TOUCH:
861 return e_devicemgr->last_device_touch;
869 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
873 case ECORE_DEVICE_CLASS_MOUSE:
874 e_devicemgr->last_device_ptr = device;
876 case ECORE_DEVICE_CLASS_KEYBOARD:
877 atomic_store(&e_devicemgr->last_device_kbd, device);
879 case ECORE_DEVICE_CLASS_TOUCH:
880 e_devicemgr->last_device_touch = device;
887 static E_Devicemgr_Input_Device *
888 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
890 E_Devicemgr_Input_Device *last_kbd = NULL;
894 case ECORE_DEVICE_CLASS_MOUSE:
895 return ec->comp_data->last_device_ptr;
896 case ECORE_DEVICE_CLASS_KEYBOARD:
897 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
899 case ECORE_DEVICE_CLASS_TOUCH:
900 return ec->comp_data->last_device_touch;
908 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
912 case ECORE_DEVICE_CLASS_MOUSE:
913 ec->comp_data->last_device_ptr = device;
915 case ECORE_DEVICE_CLASS_KEYBOARD:
916 atomic_store(&ec->comp_data->last_device_kbd, device);
918 case ECORE_DEVICE_CLASS_TOUCH:
919 ec->comp_data->last_device_touch = device;
927 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
929 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
930 struct wl_resource *dev_res;
931 const char *dev_name;
932 Ecore_Device_Class dev_class;
933 struct wl_client *wc;
937 EINA_SAFETY_ON_NULL_RETURN(dev);
940 if (ec->cur_mouse_action || e_comp_wl->drag)
942 if (e_object_is_del(E_OBJECT(ec))) return;
943 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
944 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
945 if (!surface) return;
947 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
948 dev_name = evas_device_description_get(dev);
949 last_device = _e_comp_wl_device_last_device_get(dev_class);
950 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
952 serial = wl_display_next_serial(e_comp_wl->wl.disp);
953 wc = wl_resource_get_client(surface);
954 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
955 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
957 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
958 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
960 _e_comp_wl_device_last_device_set(dev_class, input_dev);
961 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
963 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
965 if (wl_resource_get_client(dev_res) != wc) continue;
966 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
970 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
974 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
976 E_Devicemgr_Input_Device *last_device;
977 struct wl_resource *dev_res;
978 struct wl_client *wc;
982 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
983 if (!surface) return;
985 last_device = _e_comp_wl_device_last_device_get(dev_class);
986 if (!last_device) return;
988 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
990 serial = wl_display_next_serial(e_comp_wl->wl.disp);
991 wc = wl_resource_get_client(surface);
992 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
994 if (wl_resource_get_client(dev_res) != wc) continue;
995 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
1000 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1002 E_Devicemgr_Input_Device *input_dev;
1003 struct wl_resource *dev_res;
1004 const char *dev_name;
1007 EINA_SAFETY_ON_NULL_RETURN(dev);
1009 dev_name = ecore_device_identifier_get(dev);
1011 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1012 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1014 if (!eina_streq(input_dev->identifier, dev_name) ||
1015 (input_dev->clas != ecore_device_class_get(dev))) continue;
1016 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1018 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1020 if (wl_resource_get_client(dev_res) != wc) continue;
1021 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1024 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1028 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1030 E_Devicemgr_Input_Device *input_dev;
1031 struct wl_resource *dev_res;
1032 const char *dev_name;
1035 EINA_SAFETY_ON_NULL_RETURN(dev);
1037 dev_name = e_device_identifier_get(dev);
1039 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1040 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1042 if (!eina_streq(input_dev->identifier, dev_name) ||
1043 (input_dev->clas != e_device_class_get(dev))) continue;
1044 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1046 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1048 if (wl_resource_get_client(dev_res) != wc) continue;
1049 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1052 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1056 _e_comp_wl_cursor_reload(E_Client *ec)
1058 struct wl_resource *res;
1059 struct wl_client *wc;
1065 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1066 !evas_object_visible_get(e_comp->pointer->o_ptr))
1067 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1070 if (e_object_is_del(E_OBJECT(ec))) return;
1071 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1072 if (!surface) return;
1073 if (ec->pointer_enter_sent) return;
1075 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1076 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1078 if (e_client_transform_core_enable_get(ec))
1080 double dx = 0.0, dy = 0.0;
1081 map = e_client_map_get(ec);
1082 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1088 cx = px - ec->client.x;
1089 cy = py - ec->client.y;
1091 wc = wl_resource_get_client(surface);
1092 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1093 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1095 if (!e_comp_wl_input_pointer_check(res)) continue;
1096 if (wl_resource_get_client(res) != wc) continue;
1097 wl_pointer_send_enter(res, serial, surface,
1098 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1099 ec->pointer_enter_sent = EINA_TRUE;
1101 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1105 _e_comp_wl_cursor_timer(void *data)
1107 E_Client *ec = data;
1109 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1110 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1112 e_comp_wl_cursor_hide(ec);
1114 return ECORE_CALLBACK_CANCEL;
1118 _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)
1120 E_Devicemgr_Input_Device *input_dev;
1121 struct wl_resource *dev_res;
1122 struct wl_client *wc;
1127 if (ec->cur_mouse_action) return;
1128 if (e_object_is_del(E_OBJECT(ec))) return;
1129 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1130 if (!surface) return;
1132 f_value = wl_fixed_from_double(value);
1133 wc = wl_resource_get_client(surface);
1135 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1136 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1138 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1139 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1141 if (wl_resource_get_client(dev_res) != wc) continue;
1142 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1145 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1149 _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)
1151 if (idx >= e_input_touch_max_count_get()) return;
1153 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1154 e_devicemgr->multi[idx].radius_x = radius_x;
1155 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1156 e_devicemgr->multi[idx].radius_y = radius_y;
1157 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1158 e_devicemgr->multi[idx].pressure = pressure;
1159 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1160 e_devicemgr->multi[idx].angle = angle;
1164 _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)
1166 if (idx >= e_input_touch_max_count_get()) return;
1168 if (e_devicemgr->multi[idx].radius_x != radius_x)
1170 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1171 e_devicemgr->multi[idx].radius_x = radius_x;
1173 if (e_devicemgr->multi[idx].radius_y != radius_y)
1175 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1176 e_devicemgr->multi[idx].radius_y = radius_y;
1178 if (e_devicemgr->multi[idx].pressure != pressure)
1180 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1181 e_devicemgr->multi[idx].pressure = pressure;
1183 if (e_devicemgr->multi[idx].angle != angle)
1185 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1186 e_devicemgr->multi[idx].angle = angle;
1191 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1193 Eina_Bool ret = EINA_TRUE;
1196 case EVAS_CALLBACK_MOUSE_IN:
1197 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1200 if (e_comp_wl->ptr.hide_tmr)
1202 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1203 cursor_timer_ec = ec;
1204 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1208 if (e_pointer_is_hidden(e_comp->pointer))
1213 case EVAS_CALLBACK_MOUSE_OUT:
1214 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1217 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1221 case EVAS_CALLBACK_MOUSE_MOVE:
1222 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1225 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1226 _e_comp_wl_cursor_reload(ec);
1229 case EVAS_CALLBACK_MOUSE_WHEEL:
1230 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1233 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1234 _e_comp_wl_cursor_reload(ec);
1237 case EVAS_CALLBACK_MOUSE_DOWN:
1238 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1241 if (e_comp_wl->ptr.hide_tmr)
1243 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1244 e_comp_wl->ptr.hide_tmr = NULL;
1246 cursor_timer_ec = NULL;
1248 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1249 _e_comp_wl_cursor_reload(ec);
1252 case EVAS_CALLBACK_MOUSE_UP:
1253 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1264 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1266 if (ec->has_cursor_unset)
1269 if (!e_config->show_cursor)
1272 if (!e_config->use_cursor_timer)
1279 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1282 Evas_Event_Mouse_In *ev;
1283 struct wl_resource *res;
1284 struct wl_client *wc;
1287 E_Comp_Config *comp_conf;
1288 E_Client *prev_ptr_ec;
1292 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1293 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1295 if (!(ec = data)) return;
1296 if (e_object_is_del(E_OBJECT(ec))) return;
1297 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1298 if (!surface) return;
1300 prev_ptr_ec = e_comp_wl->ptr.ec;
1303 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1304 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1307 e_comp_wl->ptr.ec = ec;
1309 comp_conf = e_comp_config_get();
1310 if (comp_conf && comp_conf->input_log_enable)
1311 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1312 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1313 e_client_util_name_get(ec));
1315 if (_e_comp_wl_check_cursor_timer_needed(ec))
1317 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1321 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1322 wc = wl_resource_get_client(surface);
1323 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1324 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1326 if (!e_comp_wl_input_pointer_check(res)) continue;
1327 if (wl_resource_get_client(res) != wc) continue;
1329 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1331 wl_pointer_send_enter(res, serial, surface,
1332 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1333 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1334 ec->pointer_enter_sent = EINA_TRUE;
1337 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1341 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1344 Evas_Event_Mouse_Out *ev;
1345 struct wl_resource *res;
1346 struct wl_client *wc;
1349 Eina_Bool inside_check;
1350 E_Comp_Config *comp_conf;
1354 if (!(ec = data)) return;
1355 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1356 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1357 if (ec->cur_mouse_action && inside_check) return;
1358 if (e_object_is_del(E_OBJECT(e_comp))) return;
1359 if (e_comp_wl->ptr.ec == ec)
1360 e_comp_wl->ptr.ec = NULL;
1361 if (e_object_is_del(E_OBJECT(ec))) return;
1363 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1364 if (!surface) return;
1366 comp_conf = e_comp_config_get();
1367 if (comp_conf && comp_conf->input_log_enable)
1368 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1369 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1370 e_client_util_name_get(ec));
1372 if (_e_comp_wl_check_cursor_timer_needed(ec))
1374 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1378 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1380 wc = wl_resource_get_client(surface);
1381 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1382 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1384 if (!e_comp_wl_input_pointer_check(res)) continue;
1385 if (wl_resource_get_client(res) != wc) continue;
1386 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1388 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1390 wl_pointer_send_leave(res, serial, surface);
1391 ec->pointer_enter_sent = EINA_FALSE;
1396 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1399 struct wl_client *wc;
1400 struct wl_resource *res;
1403 E_Comp_Config *comp_conf = NULL;
1406 if (e_object_is_del(E_OBJECT(ec))) return;
1407 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1408 if (!surface) return;
1410 wc = wl_resource_get_client(surface);
1411 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1415 x = wl_fixed_from_int(canvas_x - ec->client.x);
1416 y = wl_fixed_from_int(canvas_y - ec->client.y);
1419 comp_conf = e_comp_config_get();
1421 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1423 if (wl_resource_get_client(res) != wc) continue;
1424 if (!e_comp_wl_input_touch_check(res)) continue;
1425 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1428 if (comp_conf && comp_conf->input_log_enable)
1429 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));
1431 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1435 if (comp_conf && comp_conf->input_log_enable)
1436 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));
1438 wl_touch_send_up(res, serial, timestamp, idx);
1445 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1448 struct wl_client *wc;
1449 struct wl_resource *res;
1453 if (ec->cur_mouse_action) return;
1454 if (e_object_is_del(E_OBJECT(ec))) return;
1455 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1456 if (!surface) return;
1458 wc = wl_resource_get_client(surface);
1460 x = wl_fixed_from_int(canvas_x - ec->client.x);
1461 y = wl_fixed_from_int(canvas_y - ec->client.y);
1463 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1465 if (wl_resource_get_client(res) != wc) continue;
1466 if (!e_comp_wl_input_touch_check(res)) continue;
1467 wl_touch_send_motion(res, timestamp, idx, x, y);
1472 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1474 struct wl_resource *res;
1475 struct wl_client *wc;
1479 if (ec->cur_mouse_action) return;
1480 if (e_object_is_del(E_OBJECT(ec))) return;
1481 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1482 if (!surface) return;
1484 wc = wl_resource_get_client(surface);
1485 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1487 if (!e_comp_wl_input_pointer_check(res)) continue;
1488 if (wl_resource_get_client(res) != wc) continue;
1489 wl_pointer_send_motion(res, timestamp,
1490 wl_fixed_from_int(x - ec->client.x),
1491 wl_fixed_from_int(y - ec->client.y));
1496 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1498 if (e_comp_wl->ptr.hide_tmr)
1500 if (cursor_timer_ec == ec)
1502 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1503 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1507 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1508 cursor_timer_ec = ec;
1509 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1514 cursor_timer_ec = ec;
1515 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1520 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1523 Evas_Event_Mouse_Move *ev;
1524 Evas_Device *dev = NULL;
1525 const char *dev_name;
1526 E_Comp_Config *comp_conf;
1530 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1531 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1533 if (!(ec = data)) return;
1534 if (e_object_is_del(E_OBJECT(ec))) return;
1535 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1536 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1537 if (!surface) return;
1539 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1542 dev_name = evas_device_description_get(dev);
1544 comp_conf = e_comp_config_get();
1545 if (comp_conf && comp_conf->input_log_enable)
1546 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1547 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1548 e_client_util_name_get(ec), dev_name);
1550 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1552 if (!e_comp_wl->drag_client)
1554 e_comp_wl->touch.faked_ec = ec;
1555 if (e_comp_wl->touch.pressed & (1 << 0))
1557 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1559 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1560 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1561 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1565 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1569 if (!e_comp_wl->drag_client)
1571 if (_e_comp_wl_check_cursor_timer_needed(ec))
1573 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1577 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1578 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1580 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1582 if (_e_comp_wl_check_cursor_timer_needed(ec))
1583 _e_comp_wl_cursor_move_timer_control(ec);
1587 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1592 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1594 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1595 if (e_object_is_del(E_OBJECT(ec))) return;
1596 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1597 if (!surface) return;
1598 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1600 e_comp_wl->ptr.button = BTN_LEFT;
1602 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1606 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1608 E_Client *ec = data;
1609 Evas_Event_Mouse_Down *ev = event;
1610 Evas_Device *dev = NULL;
1611 const Evas_Device *seat_dev;
1612 const char *dev_name, *seat_name;
1613 E_Comp_Config *comp_conf = NULL;
1616 if (e_object_is_del(E_OBJECT(ec))) return;
1619 dev_name = evas_device_description_get(dev);
1621 seat_dev = evas_device_parent_get(dev);
1622 seat_name = evas_device_name_get(seat_dev);
1624 comp_conf = e_comp_config_get();
1625 if (comp_conf && comp_conf->input_log_enable)
1626 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1627 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1628 dev_name, seat_name);
1630 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1632 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1634 e_comp_wl->touch.faked_ec = ec;
1637 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1638 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1639 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1641 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1642 e_comp_wl->touch.pressed |= (1 << 0);
1646 if (_e_comp_wl_check_cursor_timer_needed(ec))
1648 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1652 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1653 WL_POINTER_BUTTON_STATE_PRESSED);
1655 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1658 need_send_released = EINA_TRUE;
1662 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1664 E_Client *ec = data;
1665 Evas_Event_Mouse_Up *ev = event;
1666 Evas_Device *dev = NULL;
1667 const Evas_Device *seat_dev;
1668 const char *dev_name, *seat_name;;
1669 Evas_Event_Flags flags;
1670 E_Comp_Config *comp_conf = NULL;
1673 if (ec->cur_mouse_action) return;
1674 if (e_object_is_del(E_OBJECT(ec))) return;
1676 if (!need_send_released)
1678 need_send_motion = EINA_TRUE;
1682 dev_name = evas_device_description_get(dev);
1684 seat_dev = evas_device_parent_get(dev);
1685 seat_name = evas_device_name_get(seat_dev);
1686 flags = evas_event_default_flags_get(evas);
1688 comp_conf = e_comp_config_get();
1689 if (comp_conf && comp_conf->input_log_enable)
1690 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1691 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1692 dev_name, seat_name);
1694 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1696 e_comp_wl->touch.pressed &= ~(1 << 0);
1698 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1699 e_comp_wl->touch.faked_ec = NULL;
1702 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1704 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1706 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1709 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1710 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1711 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1715 if (_e_comp_wl_check_cursor_timer_needed(ec))
1717 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1721 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1722 WL_POINTER_BUTTON_STATE_RELEASED);
1724 if (_e_comp_wl_check_cursor_timer_needed(ec))
1725 _e_comp_wl_cursor_move_timer_control(ec);
1729 need_send_released = EINA_FALSE;
1733 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1735 struct wl_resource *res;
1736 struct wl_client *wc;
1741 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1743 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1746 dir = -wl_fixed_from_int(abs(z));
1748 dir = wl_fixed_from_int(z);
1751 if (e_object_is_del(E_OBJECT(ec))) return;
1752 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1753 if (!surface) return;
1755 wc = wl_resource_get_client(surface);
1756 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1758 if (!e_comp_wl_input_pointer_check(res)) continue;
1759 if (wl_resource_get_client(res) != wc) continue;
1760 wl_pointer_send_axis(res, timestamp, axis, dir);
1765 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1768 Evas_Event_Mouse_Wheel *ev;
1771 if (!(ec = data)) return;
1772 if (ec->cur_mouse_action) return;
1773 if (e_object_is_del(E_OBJECT(ec))) return;
1774 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1775 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1776 if (!surface) return;
1778 if (!eina_list_count(e_comp_wl->ptr.resources))
1781 if (_e_comp_wl_check_cursor_timer_needed(ec))
1783 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1787 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1789 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1791 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1793 if (_e_comp_wl_check_cursor_timer_needed(ec))
1794 _e_comp_wl_cursor_move_timer_control(ec);
1799 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1801 E_Client *ec = data;
1802 Evas_Event_Multi_Down *ev = event;
1803 Evas_Device *dev = NULL;
1804 const Evas_Device *seat_dev;
1805 const char *dev_name, *seat_name;
1806 Evas_Device_Class dev_class;
1807 E_Comp_Config *comp_conf = NULL;
1810 if (e_object_is_del(E_OBJECT(ec))) return;
1811 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1812 if (!surface) return;
1814 /* Do not deliver emulated single touch events to client */
1815 if (ev->device == 0) return;
1818 dev_name = evas_device_description_get(dev);
1819 e_comp_wl->touch.faked_ec = ec;
1821 seat_dev = evas_device_parent_get(dev);
1822 seat_name = evas_device_name_get(seat_dev);
1824 comp_conf = e_comp_config_get();
1825 if (comp_conf && comp_conf->input_log_enable)
1826 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1827 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1828 dev_name, seat_name);
1830 if (dev && dev_name)
1832 dev_class = evas_device_class_get(dev);
1833 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1834 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1837 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1838 e_comp_wl->touch.pressed |= (1 << ev->device);
1842 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1844 E_Client *ec = data;
1845 Evas_Event_Multi_Up *ev = event;
1846 Evas_Device *dev = NULL;
1847 const Evas_Device *seat_dev;
1848 const char *dev_name, *seat_name;
1849 Evas_Device_Class dev_class;
1850 Evas_Event_Flags flags;
1851 E_Comp_Config *comp_conf = NULL;
1854 if (e_object_is_del(E_OBJECT(ec))) return;
1855 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1856 if (!surface) return;
1858 /* Do not deliver emulated single touch events to client */
1859 if (ev->device == 0) return;
1861 flags = evas_event_default_flags_get(evas);
1863 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1864 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1865 e_comp_wl->touch.faked_ec = NULL;
1867 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1870 dev_name = evas_device_description_get(dev);
1872 seat_dev = evas_device_parent_get(dev);
1873 seat_name = evas_device_name_get(seat_dev);
1875 comp_conf = e_comp_config_get();
1876 if (comp_conf && comp_conf->input_log_enable)
1877 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1878 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1879 dev_name, seat_name);
1881 if (dev && dev_name)
1883 dev_class = evas_device_class_get(dev);
1884 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1885 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1888 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1892 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1894 E_Client *ec = data;
1895 Evas_Event_Multi_Move *ev = event;
1896 Evas_Device *dev = NULL;
1897 const char *dev_name;
1898 Evas_Device_Class dev_class;
1901 if (e_object_is_del(E_OBJECT(ec))) return;
1902 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1903 if (!surface) return;
1905 /* Do not deliver emulated single touch events to client */
1906 if (ev->device == 0) return;
1908 e_comp_wl->touch.faked_ec = ec;
1910 if (e_comp_wl->touch.pressed & (1 << ev->device))
1913 if (dev && (dev_name = evas_device_description_get(dev)))
1915 dev_class = evas_device_class_get(dev);
1916 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1917 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1920 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1925 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1928 char *file, buff[PATH_MAX];
1935 n = (getpriority(PRIO_PROCESS, pid) + adj);
1939 setpriority(PRIO_PROCESS, pid, n);
1942 use_adj = EINA_TRUE;
1944 if (!do_child) return;
1946 files = ecore_file_ls("/proc");
1947 EINA_LIST_FREE(files, file)
1949 if (!isdigit(file[0]))
1952 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1953 if ((f = fopen(buff, "r")))
1957 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1959 if (num_read == 2 && ppid == pid)
1960 _e_comp_wl_client_priority_adjust(pid2, set,
1962 adj_child, do_child);
1970 _e_comp_wl_client_priority_raise(E_Client *ec)
1972 if (!e_config->priority_control) return;
1973 if (ec->netwm.pid <= 0) return;
1974 if (ec->netwm.pid == getpid()) return;
1975 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1976 e_config->priority - 1, -1,
1977 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1981 _e_comp_wl_client_priority_normal(E_Client *ec)
1983 if (!e_config->priority_control) return;
1984 if (ec->netwm.pid <= 0) return;
1985 if (ec->netwm.pid == getpid()) return;
1986 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1987 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1991 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1994 E_Comp_Wl_Key_Data *k;
1995 struct wl_resource *res;
1999 if (!ec) return EINA_FALSE;
2000 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2001 if (!ec->comp_data) return EINA_FALSE;
2003 ec->comp_data->on_focus_timer = NULL;
2004 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2005 if (!e_comp_wl->kbd.focused)
2007 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2010 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2012 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2013 t = ecore_time_unix_get();
2015 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2016 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2017 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2019 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2021 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2022 wl_keyboard_send_key(res, serial, t,
2023 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2026 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2027 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2031 /* It is called in the following cases:
2032 * When a normal ec->frame has focus.
2033 * Or launching image ec is replaced to the real ec.
2036 e_comp_wl_feed_focus_in(E_Client *ec)
2039 struct wl_resource *res;
2040 struct wl_client *wc;
2044 if (e_object_is_del(E_OBJECT(ec))) return;
2045 if (ec->iconic) return;
2047 /* block spurious focus events */
2048 focused = e_client_focused_get();
2049 if ((focused) && (ec != focused)) return;
2051 /* raise client priority */
2052 _e_comp_wl_client_priority_raise(ec);
2053 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2054 if (!surface) return;
2056 wc = wl_resource_get_client(surface);
2058 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2059 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2061 if (wl_resource_get_client(res) == wc)
2063 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2064 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2065 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2066 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2069 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2071 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2072 if (!e_comp_wl->kbd.focused)
2074 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2077 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2079 e_comp_wl->kbd.focus = surface;
2080 e_comp_wl_input_keyboard_enter_send(ec);
2081 e_comp_wl_data_device_keyboard_focus_set();
2082 ec->comp_data->on_focus_timer =
2083 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2084 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2085 int rotation = ec->e.state.rot.ang.curr;
2086 e_pointer_rotation_set(e_comp->pointer, rotation);
2090 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2093 if (!(ec = data)) return;
2094 e_comp_wl_feed_focus_in(ec);
2098 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2101 struct wl_resource *res;
2103 E_Comp_Wl_Key_Data *k;
2107 if (!(ec = data)) return;
2109 if (!ec->comp_data) return;
2111 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2113 /* lower client priority */
2114 if (!e_object_is_del(data))
2115 _e_comp_wl_client_priority_normal(ec);
2118 /* update keyboard modifier state */
2119 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2120 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2121 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2123 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2125 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2126 if (!surface) return;
2128 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2129 if (!eina_list_count(e_comp_wl->kbd.resources))
2131 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2135 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2137 /* send keyboard_leave to all keyboard resources */
2138 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2139 t = ecore_time_unix_get();
2141 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2142 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2143 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2145 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2147 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2148 wl_keyboard_send_key(res, serial, t,
2149 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2151 wl_keyboard_send_leave(res, serial, surface);
2152 e_comp_wl->kbd.focused =
2153 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2155 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2156 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2160 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2164 if (!(ec = data)) return;
2166 if (!ec->comp_data->shell.configure_send) return;
2168 /* TODO: calculate x, y with transfrom object */
2169 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2173 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2174 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2175 if (e_comp_object_frame_exists(ec->frame))
2176 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2178 switch (ec->resize_mode)
2180 case E_POINTER_RESIZE_TL:
2181 case E_POINTER_RESIZE_L:
2182 case E_POINTER_RESIZE_BL:
2183 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2184 ec->mouse.current.mx;
2186 case E_POINTER_RESIZE_TR:
2187 case E_POINTER_RESIZE_R:
2188 case E_POINTER_RESIZE_BR:
2189 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2194 switch (ec->resize_mode)
2196 case E_POINTER_RESIZE_TL:
2197 case E_POINTER_RESIZE_T:
2198 case E_POINTER_RESIZE_TR:
2199 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2200 ec->mouse.current.my;
2202 case E_POINTER_RESIZE_BL:
2203 case E_POINTER_RESIZE_B:
2204 case E_POINTER_RESIZE_BR:
2205 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2210 w = E_CLAMP(w, 1, w);
2211 h = E_CLAMP(h, 1, h);
2212 e_client_resize_limit(ec, &w, &h);
2214 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2216 else if ((!ec->fullscreen) && (!ec->maximized) &&
2217 (!ec->comp_data->maximize_pre))
2221 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2222 if ((pw != ec->w) || (ph != ec->h))
2224 _e_comp_wl_configure_send(ec, 1, 1);
2228 if (ec->comp_data->sub.below_obj)
2229 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2233 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2235 E_Client *ec = data;
2237 ec->comp_data->maximize_pre = 1;
2241 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2243 E_Client *ec = data;
2246 if (e_object_is_del(E_OBJECT(ec))) return;
2248 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2249 e_client_shell_configure_send(ec, 0, w, h);
2251 ec->comp_data->maximize_pre = 0;
2255 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2257 E_Client *ec = data;
2259 ec->comp_data->maximize_pre = 1;
2263 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2265 E_Client *ec = data;
2267 if (e_object_is_del(E_OBJECT(ec))) return;
2269 /* check for wayland pixmap */
2271 if (ec->comp_data->shell.configure_send)
2272 _e_comp_wl_configure_send(ec, 0, 0);
2274 ec->comp_data->maximize_pre = 0;
2278 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2280 E_Client *ec = data;
2282 if (e_object_is_del(E_OBJECT(ec))) return;
2284 /* check for wayland pixmap */
2286 if (ec->comp_data->shell.configure_send)
2287 _e_comp_wl_configure_send(ec, 0, 1);
2289 ec->comp_data->maximize_pre = 0;
2293 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2295 E_Client *ec = data;
2297 if (e_object_is_del(E_OBJECT(ec))) return;
2299 /* check for wayland pixmap */
2301 if (ec->comp_data->shell.configure_send)
2302 _e_comp_wl_configure_send(ec, 0, 0);
2304 ec->comp_data->maximize_pre = 0;
2308 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2312 if (!(ec = data)) return;
2314 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2316 e_object_del(E_OBJECT(ec));
2318 _e_comp_wl_focus_check();
2320 /* TODO: Delete request send ??
2321 * NB: No such animal wrt wayland */
2325 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2329 if (!(ec = data)) return;
2331 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2334 if (ec->comp_data->reparented)
2335 e_client_comp_hidden_set(ec, EINA_TRUE);
2338 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2339 if (ec->visible) evas_object_hide(ec->frame);
2340 if (!ec->internal) e_object_del(E_OBJECT(ec));
2342 _e_comp_wl_focus_check();
2346 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2350 if (!(ec = data)) return;
2352 e_client_shell_ping(ec);
2356 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2361 if (!(ec = data)) return;
2362 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2363 if (ec->netwm.opacity == a) return;
2364 ec->netwm.opacity = a;
2365 ec->netwm.opacity_changed = EINA_TRUE;
2369 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2371 Eina_Rectangle *damage_rect = NULL;
2372 Eina_Rectangle *dmg = NULL;
2373 Eina_List *l = NULL;
2375 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2376 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2379 if (!buffer->tbm_surface) return;
2383 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2387 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2388 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2391 eina_rectangle_union(damage_rect, dmg);
2396 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2397 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2400 tbm_surface_internal_set_damage(buffer->tbm_surface,
2406 eina_rectangle_free(damage_rect);
2410 _e_comp_wl_client_evas_init(E_Client *ec)
2412 if (!ec || !ec->comp_data) return;
2413 if (ec->comp_data->evas_init) return;
2415 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2416 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2417 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2420 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2421 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2422 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2423 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2424 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2425 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2427 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2428 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2429 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2431 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2432 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2436 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2437 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2438 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2439 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2440 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2441 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2442 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2445 /* setup delete/kill callbacks */
2446 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2447 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2449 /* setup ping callback */
2450 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2451 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2453 ec->comp_data->evas_init = EINA_TRUE;
2457 _e_comp_wl_client_evas_deinit(E_Client *ec)
2459 if (!ec || !ec->comp_data) return;
2460 if (!ec->comp_data->evas_init) return;
2462 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2463 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2464 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2466 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2467 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2468 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2469 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2470 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2471 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2473 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2474 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2475 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2477 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2478 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2482 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2483 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2484 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2485 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2486 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2487 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2488 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2491 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2492 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2494 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2495 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2497 ec->comp_data->evas_init = EINA_FALSE;
2501 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2505 E_Comp_Screen *e_comp_screen;
2506 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2508 if (!e_comp) return ECORE_CALLBACK_RENEW;
2509 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2510 e_comp_screen = e_comp->e_comp_screen;
2512 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2514 if (!eout->config.enabled)
2516 e_comp_wl_output_remove(eout->id);
2520 switch (eout->config.rotation)
2523 transform = WL_OUTPUT_TRANSFORM_90;
2526 transform = WL_OUTPUT_TRANSFORM_180;
2529 transform = WL_OUTPUT_TRANSFORM_270;
2533 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2537 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2539 eout->config.geom.x, eout->config.geom.y,
2540 eout->config.geom.w, eout->config.geom.h,
2541 eout->info.size.w, eout->info.size.h,
2542 eout->config.mode.refresh, 0, transform))
2543 ERR("Could not initialize screen %s", eout->info.name);
2546 return ECORE_CALLBACK_RENEW;
2550 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2554 /* try to get the client from the object */
2555 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2556 return ECORE_CALLBACK_RENEW;
2558 /* check for client being deleted */
2559 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2561 /* check for wayland pixmap */
2562 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2563 return ECORE_CALLBACK_RENEW;
2565 /* if we have not setup evas callbacks for this client, do it */
2566 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2568 return ECORE_CALLBACK_RENEW;
2572 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2576 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2577 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2579 if (e_comp_wl->selection.target &&
2582 struct wl_resource *res;
2584 E_Client *ec = NULL;
2585 E_Client *legacy_target = e_comp_wl->selection.target;
2586 int device_id = e_comp_wl_data_current_device_id_get();
2590 e_comp_wl_data_current_device_id_set(ev->multi.device);
2592 else if (device_id != ev->multi.device)
2594 return ECORE_CALLBACK_RENEW;
2597 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2598 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2600 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2601 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2603 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2604 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2606 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2607 (ec != legacy_target))
2609 e_comp_wl_data_device_send_leave(legacy_target);
2610 e_comp_wl_data_device_send_enter(ec);
2613 if (e_comp_wl->drag)
2614 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2616 if (e_client_transform_core_enable_get(ec))
2618 int trans_x, trans_y;
2619 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2620 x = trans_x - ec->client.x;
2621 y = trans_y - ec->client.y;
2625 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2630 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2633 return ECORE_CALLBACK_RENEW;
2637 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2640 struct wl_resource *surface;
2641 struct wl_resource *res;
2642 struct wl_client *wc;
2644 E_Comp_Config *comp_conf;
2646 ec = e_comp_wl->ptr_constraints.ec;
2647 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2649 surface = e_comp_wl_client_surface_get(ec);
2650 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2652 wc = wl_resource_get_client(surface);
2654 comp_conf = e_comp_config_get();
2656 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2658 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2659 if (wl_resource_get_client(res) != wc) continue;
2661 if (comp_conf && comp_conf->input_log_enable)
2662 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2663 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2664 e_client_util_name_get(ec));
2666 zwp_relative_pointer_v1_send_relative_motion(res,
2668 (uint32_t)(ev->timestamp),
2669 wl_fixed_from_int(ev->dx),
2670 wl_fixed_from_int(ev->dy),
2671 wl_fixed_from_int(ev->dx_unaccel),
2672 wl_fixed_from_int(ev->dy_unaccel));
2675 return ECORE_CALLBACK_DONE;
2679 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2681 _e_comp_wl_touch_cancel();
2683 return ECORE_CALLBACK_PASS_ON;
2687 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2689 if (!ev) return ECORE_CALLBACK_PASS_ON;
2691 E_Zone *zone = ev->zone;
2693 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2694 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2696 if (!e_zone_is_displaying(zone))
2697 _e_comp_wl_touch_cancel();
2699 return ECORE_CALLBACK_PASS_ON;
2703 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2705 E_Client *ec = ev->ec;
2706 E_Comp_Wl_Buffer_Viewport *vp;
2708 if (!ec) return ECORE_CALLBACK_PASS_ON;
2709 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2710 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2711 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2712 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2714 vp = &ec->comp_data->scaler.buffer_viewport;
2715 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2717 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2719 return ECORE_CALLBACK_PASS_ON;
2723 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2725 E_Client *ec = ev->ec;
2726 E_Comp_Wl_Buffer_Viewport *vp;
2728 if (!ec) return ECORE_CALLBACK_PASS_ON;
2729 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2730 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2731 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2733 vp = &ec->comp_data->scaler.buffer_viewport;
2734 vp->wait_for_transform_change = 0;
2736 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2738 return ECORE_CALLBACK_PASS_ON;
2742 _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)
2744 E_Client *focused_ec;
2747 focused_ec = e_client_focused_get();
2748 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2750 rotation = focused_ec->e.state.rot.ang.curr;
2751 e_pointer_rotation_set(e_comp->pointer, rotation);
2753 return ECORE_CALLBACK_PASS_ON;
2757 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2760 Eina_Rectangle *window;
2765 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2767 if ((prev_w != state->bw) ||
2768 (prev_h != state->bh))
2770 ec->changes.buf_size = EINA_TRUE;
2773 if (e_comp_object_frame_exists(ec->frame)) return;
2774 window = &ec->comp_data->shell.window;
2775 if ((!ec->borderless) && /* FIXME temporarily added this check code
2776 * to prevent updating E_Client's size by frame */
2777 (window->x || window->y || window->w || window->h))
2779 e_comp_object_frame_geometry_set(ec->frame,
2781 (window->x + window->w) - state->bw,
2783 (window->y + window->h) - state->bh);
2786 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2790 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2792 E_Comp_Wl_Surface_State *state;
2795 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2796 state->buffer = NULL;
2800 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2802 state->new_attach = EINA_FALSE;
2803 state->buffer = NULL;
2804 state->buffer_destroy_listener.notify =
2805 _e_comp_wl_surface_state_cb_buffer_destroy;
2806 state->sx = state->sy = 0;
2808 state->input = eina_tiler_new(w, h);
2809 eina_tiler_tile_size_set(state->input, 1, 1);
2811 state->opaque = eina_tiler_new(w, h);
2812 eina_tiler_tile_size_set(state->opaque, 1, 1);
2814 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2815 state->buffer_viewport.buffer.scale = 1;
2816 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2817 state->buffer_viewport.surface.width = -1;
2818 state->buffer_viewport.changed = 0;
2820 e_presentation_time_container_init(&state->presentation_container);
2824 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2826 struct wl_resource *cb;
2827 Eina_Rectangle *dmg;
2829 EINA_LIST_FREE(state->frames, cb)
2830 wl_resource_destroy(cb);
2832 EINA_LIST_FREE(state->damages, dmg)
2833 eina_rectangle_free(dmg);
2835 EINA_LIST_FREE(state->buffer_damages, dmg)
2836 eina_rectangle_free(dmg);
2838 if (state->opaque) eina_tiler_free(state->opaque);
2839 state->opaque = NULL;
2841 if (state->input) eina_tiler_free(state->input);
2842 state->input = NULL;
2844 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2845 state->buffer = NULL;
2847 e_presentation_time_container_finish(&state->presentation_container);
2851 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2853 if (state->buffer == buffer) return;
2855 wl_list_remove(&state->buffer_destroy_listener.link);
2856 state->buffer = buffer;
2858 wl_signal_add(&state->buffer->destroy_signal,
2859 &state->buffer_destroy_listener);
2863 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2865 Eina_Rectangle *dmg;
2866 Eina_Bool placed = EINA_TRUE;
2870 E_Comp_Wl_Buffer *buffer;
2871 struct wl_resource *cb;
2873 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2874 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2879 if ((ec->internal) ||
2880 (cdata->shell.surface && state->new_attach))
2884 e_comp->new_clients++;
2885 ELOGF("COMP", "Unignore", ec);
2886 e_client_unignore(ec);
2890 /* buffer transform */
2891 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2894 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2896 /* when buffer is transformed, we have to apply the new evas-map */
2897 state->buffer_viewport.changed = EINA_TRUE;
2899 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2901 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2903 if (transform_change == vp->wait_for_transform_change)
2904 vp->wait_for_transform_change = 0;
2906 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2907 // triggered by E_CLIENT_HOOK calls at those file.
2908 zone = e_comp_zone_find_by_ec(ec);
2911 eout = e_output_find(zone->output_id);
2912 if (eout && eout->hwc)
2914 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2916 if (e_comp_is_on_overlay(ec))
2917 e_comp_hwc_client_end(ec, __FUNCTION__);
2923 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2924 cdata->scaler.buffer_viewport = state->buffer_viewport;
2926 if (state->new_attach)
2928 e_comp_wl_surface_attach(ec, state->buffer);
2931 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2932 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2934 _e_comp_wl_surface_state_buffer_set(state, NULL);
2936 if ((state->new_attach) ||
2937 (state->buffer_viewport.changed))
2939 _e_comp_wl_surface_state_size_update(ec, state);
2940 e_comp_wl_map_size_cal_from_viewport(ec);
2942 /* update the position */
2943 if (ec->changes.pos)
2945 e_comp_object_frame_xy_unadjust(ec->frame,
2955 if (ec->new_client) placed = ec->placed;
2957 if (!ec->lock_client_size)
2962 ec->client.w = state->bw;
2963 ec->client.h = state->bh;
2965 e_comp_object_frame_wh_adjust(ec->frame,
2966 ec->client.w, ec->client.h,
2968 e_client_size_set(ec, nw, nh);
2970 if ((w != ec->w) || (h != ec->h))
2972 ec->changes.size = 1;
2977 if (ec->changes.buf_size)
2979 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2980 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2981 ec->changes.buf_size = EINA_FALSE;
2983 if (ec->move_after_resize)
2985 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2986 ec->move_after_resize = EINA_FALSE;
2991 /* map or unmap ec */
2992 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2993 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2994 if (!pixmap_usable || hide_by_request)
2999 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
3004 if ((cdata->sub.below_obj) &&
3005 (evas_object_visible_get(cdata->sub.below_obj)))
3007 evas_object_hide(cdata->sub.below_obj);
3015 if ((cdata->sub.below_obj) &&
3016 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3017 (evas_object_visible_get(ec->frame)))
3019 evas_object_show(cdata->sub.below_obj);
3023 if ((state->new_attach) ||
3024 (state->buffer_viewport.changed))
3026 if ((e_comp_wl->drag) &&
3027 (e_comp_wl->drag_client) &&
3028 (e_comp_wl->drag_client == ec))
3030 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3032 e_drag_move(e_comp_wl->drag,
3034 e_comp_wl->drag->y);
3036 e_drag_resize(e_comp_wl->drag,
3037 state->bw, state->bh);
3039 else if ((cdata->shell.surface) &&
3040 (cdata->shell.configure))
3042 e_comp_wl_commit_sync_configure(ec);
3044 else if (!e_client_video_hw_composition_check(ec))
3046 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3051 ec->placed = placed;
3052 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3056 if (cdata->scaler.buffer_viewport.changed)
3057 e_comp_wl_map_apply(ec);
3059 /* resize transform object */
3060 if (ec->transformed)
3061 e_client_transform_update(ec);
3065 state->new_attach = EINA_FALSE;
3067 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3069 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3070 wl_resource_destroy(cb);
3073 /* insert state frame callbacks into comp_data->frames
3074 * NB: This clears state->frames list */
3075 cdata->frames = eina_list_merge(cdata->frames,
3077 state->frames = NULL;
3079 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3080 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3081 &state->presentation_container);
3083 buffer = e_pixmap_resource_get(ec->pixmap);
3085 /* put state damages into surface */
3088 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3089 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3091 if ((cdata->buffer_ref.buffer) &&
3092 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3093 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3095 e_comp_object_damage(ec->frame,
3097 cdata->buffer_ref.buffer->w,
3098 cdata->buffer_ref.buffer->h);
3103 Eina_List *damages = NULL;
3106 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3108 if (eina_list_count(state->buffer_damages))
3110 EINA_LIST_FREE(state->buffer_damages, dmg)
3113 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3114 e_comp_wl_output_buffer_transform_get(ec),
3116 dmg->x, dmg->y, dmg->w, dmg->h,
3117 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3118 damages = eina_list_append(damages, dmg);
3122 EINA_LIST_FREE(state->damages, dmg)
3123 damages = eina_list_append(damages, dmg);
3125 EINA_LIST_FREE(damages, dmg)
3127 /* not creating damage for ec that shows a underlay video */
3128 if (state->buffer_viewport.changed ||
3129 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3130 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3131 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3133 eina_rectangle_free(dmg);
3138 /* put state opaque into surface */
3139 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3142 Eina_Rectangle *rect;
3145 itr = eina_tiler_iterator_new(state->opaque);
3146 EINA_ITERATOR_FOREACH(itr, rect)
3150 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3151 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3152 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3156 eina_iterator_free(itr);
3159 /* put state input into surface */
3160 if ((state->input) &&
3161 (!eina_tiler_empty(state->input)) &&
3164 Eina_Tiler *src, *tmp;
3168 tmp = eina_tiler_new(sw, sh);
3169 eina_tiler_tile_size_set(tmp, 1, 1);
3171 eina_tiler_rect_add(tmp,
3172 &(Eina_Rectangle){0, 0, sw, sh});
3174 if ((src = eina_tiler_intersection(state->input, tmp)))
3176 Eina_Rectangle *rect;
3179 e_comp_object_input_objs_del(ec->frame);
3180 itr = eina_tiler_iterator_new(src);
3181 EINA_ITERATOR_FOREACH(itr, rect)
3183 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3184 ec, rect->x, rect->y, rect->w, rect->h,
3185 ec->w, ec->h, state->bw, state->bh);
3186 e_comp_object_input_area_set(ec->frame,
3191 eina_iterator_free(itr);
3192 eina_tiler_free(src);
3195 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3197 eina_tiler_free(tmp);
3199 /* clear input tiler */
3200 eina_tiler_clear(state->input);
3203 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3205 if ((cdata->video_client) &&
3207 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3208 (e_comp->wl_comp_data->available_hw_accel.underlay))
3210 e_pixmap_image_clear(ec->pixmap, 1);
3213 state->buffer_viewport.changed = 0;
3215 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3218 ec->exp_iconify.buffer_flush &&
3219 e_policy_visibility_client_is_iconic(ec))
3221 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3226 _e_comp_wl_surface_render_stop(E_Client *ec)
3228 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3229 //if ((!ec->internal) && (!e_comp_gl_get()))
3232 /* check if internal animation is running */
3233 if (e_comp_object_is_animating(ec->frame)) return;
3234 /* check if external animation is running */
3235 if (evas_object_data_get(ec->frame, "effect_running")) return;
3237 evas_object_hide(ec->frame);
3241 e_comp_wl_client_surface_finish(E_Client *ec)
3243 struct wl_resource *res, *surface;
3244 struct wl_client *surface_client = NULL;
3247 surface = e_comp_wl_client_surface_get(ec);
3250 surface_client = wl_resource_get_client(surface);
3252 if (surface_client &&
3253 (ec == e_client_focused_get()))
3255 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3256 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3258 if (wl_resource_get_client(res) ==
3260 e_comp_wl->kbd.focused =
3261 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3265 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3268 e_comp_wl_client_surface_set(ec, NULL);
3270 ec->comp_data->wl_surface = NULL;
3271 e_pixmap_win_id_del(ec->pixmap);
3273 _e_comp_wl_surface_render_stop(ec);
3274 e_object_del(E_OBJECT(ec));
3278 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3283 char proc[512], pname[512];
3286 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3288 h = fopen(proc, "r");
3291 len = fread(pname, sizeof(char), 512, h);
3293 pname[len - 1] = '\0';
3295 strncpy(pname, "NO NAME", sizeof(pname));
3301 strncpy(pname, "NO NAME", sizeof(pname));
3304 strncpy(name, pname, size);
3308 _e_comp_wl_pname_print(pid_t pid)
3311 char proc[512], pname[512];
3314 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3316 h = fopen(proc, "r");
3319 len = fread(pname, sizeof(char), 512, h);
3321 pname[len - 1] = '\0';
3323 strncpy(pname, "NO NAME", sizeof(pname));
3327 ELOGF("COMP", " |%s", NULL, pname);
3332 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3334 struct wl_client *client = data;
3335 E_Comp_Connected_Client_Info *cinfo;
3338 cinfo = wl_container_of(listener, cinfo, destroy);
3340 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3341 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3343 eai = e_appinfo_find_with_pid(cinfo->pid);
3344 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3347 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3349 wl_list_remove(&cinfo->destroy.link);
3350 eina_stringshare_del(cinfo->name);
3355 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3357 E_Comp_Connected_Client_Info *cinfo;
3359 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3360 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3362 cinfo->name = eina_stringshare_add(name);
3366 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3367 wl_client_add_destroy_listener(client, &cinfo->destroy);
3368 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3370 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3374 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3376 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3378 /* send configure */
3379 if (ec->comp_data->shell.configure_send)
3381 if (ec->comp_data->shell.surface)
3382 _e_comp_wl_configure_send(ec, 0, 0);
3385 e_comp_wl->kbd.focus = ec->comp_data->surface;
3389 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3391 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3393 /* send configure */
3394 if (ec->comp_data->shell.configure_send)
3396 if (ec->comp_data->shell.surface)
3397 _e_comp_wl_configure_send(ec, 0, 0);
3400 _e_comp_wl_focus_check();
3402 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3403 e_comp_wl->kbd.focus = NULL;
3407 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3409 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3410 if (ec->keyboard_resizing) return;
3412 /* do nothing currently */
3417 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3419 if (e_object_is_del(E_OBJECT(ec))) return;
3420 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3422 e_comp_wl->resize.edges = 0;
3423 e_comp_wl->resize.resource = NULL;
3427 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3429 if (e_object_is_del(E_OBJECT(ec))) return;
3430 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3434 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3437 int ratio_w, ratio_h;
3439 phys_w = output->phys_width;
3440 phys_h = output->phys_height;
3442 if (e_config->configured_output_resolution.use)
3444 // change the configured physical size(mm) of the output
3445 if (output->w != res_w)
3447 ratio_w = res_w / output->w;
3448 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3451 if (output->h != res_h)
3453 ratio_h = res_h / output->h;
3454 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3457 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3460 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3461 NULL, res_w, res_h, phys_w, phys_h, pid);
3463 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3464 wl_output_send_scale(resource, output->scale);
3466 wl_output_send_geometry(resource, output->x, output->y,
3468 output->subpixel, output->make ?: "",
3469 output->model ?: "", output->transform);
3471 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3472 res_w, res_h, output->refresh);
3474 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3475 wl_output_send_done(resource);
3479 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3481 E_Comp_Wl_Output *output;
3483 if (!(output = wl_resource_get_user_data(resource))) return;
3485 output->resources = eina_list_remove(output->resources, resource);
3489 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3491 E_Comp_Wl_Output *output;
3492 struct wl_resource *resource;
3493 E_Appinfo *eai = NULL;
3497 if (!(output = data)) return;
3500 wl_resource_create(client, &wl_output_interface, version, id);
3503 wl_client_post_no_memory(client);
3507 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3508 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3510 output->resources = eina_list_append(output->resources, resource);
3512 wl_resource_set_implementation(resource, NULL, output,
3513 _e_comp_wl_cb_output_unbind);
3514 wl_resource_set_user_data(resource, output);
3516 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3517 if (e_config->configured_output_resolution.use)
3519 wl_client_get_credentials(client, &pid, NULL, NULL);
3522 res_w = e_config->configured_output_resolution.w;
3523 res_h = e_config->configured_output_resolution.h;
3527 eai = e_appinfo_find_with_pid(pid);
3530 res_w = e_config->configured_output_resolution.w;
3531 res_h = e_config->configured_output_resolution.h;
3535 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3537 res_w = e_config->configured_output_resolution.w;
3538 res_h = e_config->configured_output_resolution.h;
3542 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3551 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3555 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3558 Evas_GL *evasgl = NULL;
3559 Evas_GL_API *glapi = NULL;
3560 Evas_GL_Context *ctx = NULL;
3561 Evas_GL_Surface *sfc = NULL;
3562 Evas_GL_Config *cfg = NULL;
3564 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3566 if (!e_comp_gl_get()) return;
3568 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3569 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3571 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3572 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3574 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3575 * then we should get evas from ecore_evas.
3578 evas = e_comp->evas;
3580 evas = ecore_evas_get(e_comp->ee);
3582 evasgl = evas_gl_new(evas);
3583 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3585 glapi = evas_gl_api_get(evasgl);
3586 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3587 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3589 cfg = evas_gl_config_new();
3590 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3592 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3593 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3595 ctx = evas_gl_context_create(evasgl, NULL);
3596 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3598 res = evas_gl_make_current(evasgl, sfc, ctx);
3599 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3601 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3602 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3604 evas_gl_config_free(cfg);
3606 evas_gl->gl = evasgl;
3607 evas_gl->glapi = glapi;
3608 evas_gl->glsfc = sfc;
3609 evas_gl->glctx = ctx;
3611 e_comp_wl->evas_gl = evas_gl;
3613 /* for native surface */
3616 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3621 evas_gl_config_free(cfg);
3622 evas_gl_make_current(evasgl, NULL, NULL);
3623 evas_gl_context_destroy(evasgl, ctx);
3624 evas_gl_surface_destroy(evasgl, sfc);
3625 evas_gl_free(evasgl);
3632 _e_comp_wl_gl_popup_cb_close(void *data,
3633 Evas_Object *obj EINA_UNUSED,
3634 void *event_info EINA_UNUSED)
3636 evas_object_del(data);
3640 _e_comp_wl_gl_popup_cb_focus(void *data,
3641 Evas_Object *obj EINA_UNUSED,
3642 void *event_info EINA_UNUSED)
3644 elm_object_focus_set(data, EINA_TRUE);
3649 _e_comp_wl_gl_idle(void *data)
3653 /* show warning window to notify failure of gl init */
3656 Evas_Object *win, *bg, *popup, *btn;
3658 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3659 elm_win_title_set(win, "Compositor Warning");
3660 elm_win_autodel_set(win, EINA_TRUE);
3661 elm_win_borderless_set(win, EINA_TRUE);
3662 elm_win_role_set(win, "notification-low");
3663 elm_win_alpha_set(win, EINA_TRUE);
3665 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3666 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3667 elm_win_resize_object_add(win, bg);
3668 evas_object_color_set(bg, 125, 125, 125, 125);
3669 evas_object_show(bg);
3671 popup = elm_popup_add(win);
3672 elm_object_text_set(popup,
3673 _( "Your screen does not support OpenGL.<br>"
3674 "Falling back to software engine."));
3675 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3677 btn = elm_button_add(popup);
3678 elm_object_text_set(btn, "Close");
3679 elm_object_part_content_set(popup, "button1", btn);
3680 evas_object_show(btn);
3682 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3683 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3685 evas_object_show(popup);
3686 evas_object_show(win);
3690 return ECORE_CALLBACK_CANCEL;
3694 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3696 struct wl_client *client = data;
3702 wl_client_get_credentials(client, &pid, &uid, &gid);
3704 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3706 _e_comp_wl_pname_print(pid);
3707 _e_comp_wl_pname_get(pid, name, sizeof(name));
3708 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3712 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3714 char buf[1024] = {0, };
3716 vsnprintf(buf, 1024, fmt, args);
3720 DBG("[libds] %s", buf);
3723 INF("[libds] %s", buf);
3726 ERR("[libds] %s", buf);
3734 _e_comp_wl_display_create(void)
3737 E_Comp_Wl_Data *wl_cdata;
3742 /* create new compositor data */
3743 if (!(comp = E_NEW(E_Comp_Data, 1)))
3745 ERR("Could not create compositor data: %m");
3748 wl_cdata = &comp->base;
3750 /* set compositor wayland data */
3751 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3753 g_mutex_init(&connection_mutex);
3755 /* try to create a wayland display */
3756 if (!(wl_cdata->wl.disp = wl_display_create()))
3758 ERR("Could not create a Wayland display: %m");
3762 /* try to setup wayland socket */
3763 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3765 ERR("Could not create Wayland display socket: %m");
3766 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3770 res = e_comp_socket_init(name);
3771 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3772 PRCTL("[Winsys] change permission and create sym link for %s", name);
3774 /* set wayland display environment variable */
3775 e_env_set("WAYLAND_DISPLAY", name);
3777 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3778 /* wl_cdata->output.scale = e_scale; */
3780 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3782 if (!e_compositor_init(wl_cdata->wl.disp))
3784 ERR("Failed to initialize compositor");
3788 comp->client_created.notify = _e_comp_wl_cb_client_created;
3789 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3791 if (!e_comp_wl_subsurfaces_init())
3793 ERR("Failed to init_subsurfaces");
3794 goto subsurfaces_err;
3797 /* initialize shm mechanism */
3798 wl_display_init_shm(wl_cdata->wl.disp);
3800 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3802 /* try to init data manager */
3803 if (!e_comp_wl_data_manager_init())
3805 ERR("Could not initialize data manager");
3809 /* try to init input */
3810 if (!e_comp_wl_input_init())
3812 ERR("Could not initialize input");
3816 if (e_comp_gl_get())
3817 _e_comp_wl_gl_init(NULL);
3819 /* get the wayland display loop */
3820 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3822 /* get the file descriptor of the wayland event loop */
3823 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3825 /* create a listener for wayland main loop events */
3827 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3828 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3829 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3830 _e_comp_wl_cb_prepare, wl_cdata);
3835 e_comp_wl_data_manager_shutdown();
3837 e_comp_wl_subsurfaces_shutdown();
3839 wl_list_remove(&comp->client_created.link);
3841 e_env_unset("WAYLAND_DISPLAY");
3843 wl_display_destroy(wl_cdata->wl.disp);
3845 g_mutex_clear(&connection_mutex);
3851 _e_comp_wl_gl_shutdown(void)
3853 if (!e_comp_wl->evas_gl) return;
3855 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3857 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3858 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3859 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3860 evas_gl_free(e_comp_wl->evas_gl->gl);
3862 E_FREE(e_comp_wl->evas_gl);
3865 /* public functions */
3868 * Creates and initializes a Wayland compositor with ecore.
3869 * Registers callback handlers for keyboard and mouse activity
3870 * and other client events.
3872 * @returns true on success, false if initialization failed.
3875 e_comp_wl_init(void)
3877 TRACE_DS_BEGIN(COMP_WL:INIT);
3879 /* try to create a wayland compositor */
3880 if (!_e_comp_wl_display_create())
3882 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3887 e_comp_wl_shell_init();
3889 #ifdef HAVE_WAYLAND_TBM
3890 e_comp_wl_tbm_init();
3892 e_comp_wl_remote_surface_init();
3896 e_comp_wl_screenshooter_init();
3898 if (!e_comp_wl_video_init())
3899 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3901 e_comp_wl_viewport_init();
3902 e_comp_wl_capture_init();
3903 e_comp_wl_renderer_init();
3904 _e_comp_wl_move_resize_init();
3905 e_presentation_time_init();
3906 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3909 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3910 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3912 /* add event handlers to catch E events */
3913 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3914 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3915 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3916 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3917 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3918 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3919 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3920 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3921 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3923 /* add hooks to catch e_client events */
3924 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3925 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3926 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3927 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3928 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3930 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3937 e_comp_wl_deferred_job(void)
3939 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3942 /* internal functions */
3944 e_comp_wl_shutdown(void)
3946 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3948 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3950 e_comp_wl_subsurfaces_shutdown();
3952 E_FREE_LIST(handlers, ecore_event_handler_del);
3953 E_FREE_LIST(hooks, e_client_hook_del);
3954 _e_comp_wl_gl_shutdown();
3956 e_blender_shutdown();
3957 e_presentation_time_shutdown();
3958 e_comp_wl_renderer_shutdown();
3959 e_comp_wl_capture_shutdown();
3960 e_comp_wl_viewport_shutdown();
3961 e_comp_wl_video_shutdown();
3962 e_comp_wl_screenshooter_shutdown();
3964 e_comp_wl_remote_surface_shutdown();
3966 e_pixmap_shutdown();
3968 e_wtz_shell_shutdown();
3969 e_comp_wl_shell_shutdown();
3970 e_comp_wl_input_shutdown();
3972 wl_list_remove(&comp->client_created.link);
3975 e_comp->wl_comp_data = NULL;
3979 E_Comp_Wl_Output *output;
3981 if (e_comp_wl->screenshooter.global)
3982 wl_global_destroy(e_comp_wl->screenshooter.global);
3984 EINA_LIST_FREE(e_comp_wl->outputs, output)
3986 if (output->id) eina_stringshare_del(output->id);
3987 if (output->make) eina_stringshare_del(output->make);
3988 if (output->model) eina_stringshare_del(output->model);
3992 /* delete fd handler */
3993 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3995 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3996 cursor_timer_ec = NULL;
3998 /* free allocated data structure */
4004 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4006 e_object_unref(E_OBJECT(ev->ec));
4011 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4014 ev = E_NEW(E_Event_Client, 1);
4017 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4019 /* set usable early because shell module checks this */
4020 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4021 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4023 e_pixmap_resource_set(ec->pixmap, buffer);
4024 e_pixmap_dirty(ec->pixmap);
4025 e_pixmap_refresh(ec->pixmap);
4027 e_comp_wl_map_size_cal_from_buffer(ec);
4028 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4030 /* wm-policy module uses it */
4031 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4034 e_object_ref(E_OBJECT(ec));
4035 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4036 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4040 e_comp_wl_surface_commit(E_Client *ec)
4045 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4046 if (!e_comp_object_damage_exists(ec->frame))
4048 if ((ec->comp_data->video_client) ||
4049 (!e_client_video_hw_composition_check(ec)))
4050 e_pixmap_image_clear(ec->pixmap, 1);
4053 ignored = ec->ignored;
4055 if (e_comp_wl_subsurface_order_commit(ec))
4057 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4058 e_comp_wl_subsurface_restack(topmost);
4059 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4062 ec->ignored = ignored;
4064 if (ec->is_cursor && ec->visible)
4066 /* ignore cursor changes during resize/move I guess */
4067 if (!e_client_action_get())
4069 if (e_comp->pointer)
4071 x = e_comp->pointer->hot.x;
4072 y = e_comp->pointer->hot.y;
4074 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4080 static E_Comp_Wl_Output *
4081 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4084 E_Comp_Wl_Output *output;
4086 EINA_LIST_FOREACH(outputs, l, output)
4088 if (!strcmp(output->id, id))
4096 * Initializes information about one display output.
4098 * Adds or updates the given data about a single display output,
4099 * with an id matching the provided id.
4101 * @param id identification of output to be added or changed
4102 * @param make manufacturer name of the display output
4103 * @param model model name of the display output
4104 * @param x output's top left corner x coordinate
4105 * @param y output's top left corner y coordinate
4106 * @param w output's width in pixels
4107 * @param h output's height in pixels
4108 * @param pw output's physical width in millimeters
4109 * @param ph output's physical height in millimeters
4110 * @param refresh output's refresh rate in mHz
4111 * @param subpixel output's subpixel layout
4112 * @param transform output's rotation and/or mirror transformation
4114 * @returns True if a display output object could be added or updated
4117 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4118 int x, int y, int w, int h, int pw, int ph,
4119 unsigned int refresh, unsigned int subpixel,
4120 unsigned int transform)
4122 E_Comp_Wl_Output *output;
4124 struct wl_resource *resource;
4126 /* retrieve named output; or create it if it doesn't exist */
4127 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4130 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4132 if (id) output->id = eina_stringshare_add(id);
4134 output->make = eina_stringshare_add(make);
4136 output->make = eina_stringshare_add("unknown");
4138 output->model = eina_stringshare_add(model);
4140 output->model = eina_stringshare_add("unknown");
4142 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4145 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4146 2, output, _e_comp_wl_cb_output_bind);
4148 output->resources = NULL;
4149 output->scale = e_scale;
4152 /* update the output details */
4157 output->phys_width = pw;
4158 output->phys_height = ph;
4159 output->refresh = refresh;
4160 output->subpixel = subpixel;
4161 output->transform = transform;
4163 if (output->scale <= 0)
4164 output->scale = e_scale;
4166 /* if we have bound resources, send updates */
4167 EINA_LIST_FOREACH(output->resources, l2, resource)
4169 wl_output_send_geometry(resource,
4170 output->x, output->y,
4172 output->phys_height,
4174 output->make ?: "", output->model ?: "",
4177 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4178 wl_output_send_scale(resource, output->scale);
4180 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4181 output->w, output->h, output->refresh);
4183 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4184 wl_output_send_done(resource);
4191 e_comp_wl_output_remove(const char *id)
4193 E_Comp_Wl_Output *output;
4195 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4198 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4200 /* wl_global_destroy(output->global); */
4202 /* eina_stringshare_del(output->id); */
4203 /* eina_stringshare_del(output->make); */
4204 /* eina_stringshare_del(output->model); */
4211 _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)
4213 struct wl_resource *res;
4215 uint32_t serial, keycode;
4216 struct wl_client *wc = NULL;
4217 E_Comp_Config *comp_conf = NULL;
4218 const char *device_name = NULL;
4220 keycode = (ev->keycode - 8);
4222 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4224 comp_conf = e_comp_config_get();
4226 if (ec && ec->comp_data)
4228 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4231 wc = wl_resource_get_client(surface);
4234 if (e_config->key_input_ttrace_enable)
4236 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4237 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4240 EINA_LIST_FOREACH(key_list, l, res)
4242 if (wl_resource_get_client(res) != wc) continue;
4244 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4245 if (!e_input_thread_mode_get())
4247 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4248 device_name = ecore_device_name_get(ev->dev);
4254 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4255 device_name = e_device_name_get(dev);
4259 if (comp_conf && comp_conf->input_log_enable)
4260 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4262 wl_keyboard_send_key(res, serial, ev->timestamp,
4267 if (e_config->key_input_ttrace_enable)
4270 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4275 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4277 E_Client *ec = NULL;
4279 E_Comp_Wl_Key_Data *end, *k;
4281 if (ev->window != e_comp->ee_win)
4286 keycode = (ev->keycode - 8);
4287 if (!(e_comp_wl = e_comp->wl_comp_data))
4292 #ifndef E_RELEASE_BUILD
4293 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4294 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4295 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4296 eina_streq(ev->key, "BackSpace"))
4302 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4304 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4306 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4308 /* ignore server-generated key repeats */
4309 if (k->key == keycode)
4311 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4316 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4318 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4320 ec = e_client_focused_get();
4321 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4322 if (ec && ec->comp_data && surface)
4324 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4325 if (e_comp_wl->kbd.focused)
4327 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4329 /* A key only sent to clients is added to the list */
4330 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4331 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4333 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4335 DBG("wl_array_add: Out of memory\n");
4336 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4337 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4340 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4344 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4348 /* update modifier state */
4349 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4355 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4357 E_Client *ec = NULL;
4358 uint32_t keycode, delivered_key;
4359 E_Comp_Wl_Key_Data *end, *k;
4361 if (ev->window != e_comp->ee_win)
4366 keycode = (ev->keycode - 8);
4368 if (!(e_comp_wl = e_comp->wl_comp_data))
4373 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4375 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4376 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4378 if (k->key == keycode)
4385 e_comp_wl->kbd.keys.size =
4386 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4388 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4390 /* 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) */
4391 if ((delivered_key) ||
4392 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4394 ec = e_client_focused_get();
4396 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4397 if (e_comp_wl->kbd.focused)
4399 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4401 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4404 /* update modifier state */
4405 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4411 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4413 Eina_Bool res = EINA_FALSE;
4415 if (type == ECORE_EVENT_KEY_DOWN)
4417 res = e_comp_wl_key_down(ev, dev);
4419 else if (type == ECORE_EVENT_KEY_UP)
4421 res = e_comp_wl_key_up(ev, dev);
4428 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4431 struct wl_client *wc;
4432 uint32_t serial, btn;
4433 struct wl_resource *res;
4434 E_Comp_Config *comp_conf = NULL;
4436 if (ec->cur_mouse_action || e_comp_wl->drag)
4438 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4439 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4443 case 1: btn = BTN_LEFT; break;
4444 case 2: btn = BTN_MIDDLE; break;
4445 case 3: btn = BTN_RIGHT; break;
4446 default: btn = button_id; break;
4449 e_comp_wl->ptr.button = btn;
4450 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4451 if (!surface) return EINA_FALSE;
4453 if (!eina_list_count(e_comp_wl->ptr.resources))
4456 wc = wl_resource_get_client(surface);
4457 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4459 comp_conf = e_comp_config_get();
4461 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4463 if (wl_resource_get_client(res) != wc) continue;
4464 if (!e_comp_wl_input_pointer_check(res)) continue;
4465 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4467 if (comp_conf && comp_conf->input_log_enable)
4468 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4470 wl_pointer_send_button(res, serial, timestamp, btn, state);
4477 e_comp_wl_touch_cancel(void)
4479 _e_comp_wl_touch_cancel();
4482 E_API E_Comp_Wl_Hook *
4483 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4487 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4488 ch = E_NEW(E_Comp_Wl_Hook, 1);
4489 if (!ch) return NULL;
4490 ch->hookpoint = hookpoint;
4492 ch->data = (void*)data;
4493 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4498 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4501 if (_e_comp_wl_hooks_walking == 0)
4503 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4507 _e_comp_wl_hooks_delete++;
4510 E_API E_Comp_Wl_Pid_Hook *
4511 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4513 E_Comp_Wl_Pid_Hook *ch;
4515 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4517 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4518 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4520 ch->hookpoint = hookpoint;
4522 ch->data = (void*)data;
4523 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4529 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4532 if (_e_comp_wl_pid_hooks_walking == 0)
4534 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4538 _e_comp_wl_pid_hooks_delete++;
4541 E_API E_Comp_Wl_Intercept_Hook *
4542 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4544 E_Comp_Wl_Intercept_Hook *ch;
4546 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4547 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4548 if (!ch) return NULL;
4549 ch->hookpoint = hookpoint;
4551 ch->data = (void*)data;
4552 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4557 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4560 if (_e_comp_wl_intercept_hooks_walking == 0)
4562 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4566 _e_comp_wl_intercept_hooks_delete++;
4570 e_comp_wl_shell_surface_ready(E_Client *ec)
4574 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4578 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4580 e_config->use_cursor_timer = !!enabled;
4582 if (e_config->use_cursor_timer)
4584 if (!e_pointer_is_hidden(e_comp->pointer))
4586 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4591 if (e_comp_wl->ptr.hide_tmr)
4593 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4594 e_comp_wl->ptr.hide_tmr = NULL;
4596 cursor_timer_ec = NULL;
4598 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4601 if (e_pointer_is_hidden(e_comp->pointer))
4603 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4609 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4611 EINA_SAFETY_ON_NULL_RETURN(wc);
4612 EINA_SAFETY_ON_NULL_RETURN(dev);
4614 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4618 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4620 EINA_SAFETY_ON_NULL_RETURN(wc);
4621 EINA_SAFETY_ON_NULL_RETURN(dev);
4623 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4627 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4629 struct wl_resource *res;
4630 struct wl_client *wc;
4632 uint32_t serial, wl_keycode;
4633 enum wl_keyboard_key_state state;
4634 E_Comp_Config *comp_conf = NULL;
4635 const char *dev_name = NULL;
4637 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4638 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4639 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4641 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4642 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4644 wl_keycode = keycode - 8;
4645 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4647 wc = wl_resource_get_client(surface);
4648 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4649 if (!time) time = e_util_timestamp_get();
4650 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4651 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4653 comp_conf = e_comp_config_get();
4654 e_keyrouter_event_surface_send(ec, keycode);
4656 if (e_config->key_input_ttrace_enable)
4658 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4659 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4662 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4663 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4665 if (wl_resource_get_client(res) != wc) continue;
4666 if (!e_input_thread_mode_get())
4670 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4671 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4675 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4682 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4683 dev_name = e_device_name_get(dev);
4687 if (comp_conf && comp_conf->input_log_enable)
4688 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4691 wl_keyboard_send_key(res, serial, time,
4694 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4696 if (e_config->key_input_ttrace_enable)
4699 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4706 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4708 struct wl_resource *res;
4709 struct wl_client *wc;
4711 uint32_t serial, wl_keycode, cancel_keycode;
4712 E_Comp_Config *comp_conf = NULL;
4713 struct xkb_keymap *keymap = NULL;
4715 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4716 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4717 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4719 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4720 keymap = e_comp_wl->xkb.keymap;
4721 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4722 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4724 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4725 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4727 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4728 if (cancel_keycode == XKB_KEYCODE_INVALID)
4730 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4733 cancel_keycode = cancel_keycode - 8;
4735 wl_keycode = keycode - 8;
4736 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4738 wc = wl_resource_get_client(surface);
4739 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4740 if (!time) time = e_util_timestamp_get();
4742 comp_conf = e_comp_config_get();
4743 e_keyrouter_event_surface_send(ec, keycode);
4745 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4746 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4748 if (wl_resource_get_client(res) != wc) continue;
4749 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4750 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4752 if (comp_conf && comp_conf->input_log_enable)
4753 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4754 wl_keyboard_send_key(res, serial, time,
4755 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4756 wl_keyboard_send_key(res, serial, time,
4757 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4758 wl_keyboard_send_key(res, serial, time,
4759 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4761 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4768 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)
4770 struct wl_client *wc;
4772 E_Devicemgr_Input_Device *device = NULL;
4774 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4775 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4776 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4778 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4779 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4781 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4783 wc = wl_resource_get_client(surface);
4784 if (!time) time = e_util_timestamp_get();
4785 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4789 _e_comp_wl_send_event_device(wc, time, dev, serial);
4790 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4794 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4795 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4798 x = x + ec->client.x;
4799 y = y + ec->client.y;
4801 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4807 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)
4809 E_Devicemgr_Input_Device *device;
4811 struct wl_client *wc;
4813 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4814 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4815 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4817 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4818 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4820 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4822 wc = wl_resource_get_client(surface);
4823 if (!time) time = e_util_timestamp_get();
4824 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4828 _e_comp_wl_send_event_device(wc, time, dev, serial);
4829 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4833 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4834 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4837 x = x + ec->client.x;
4838 y = y + ec->client.y;
4840 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4846 e_comp_wl_touch_cancel_send(E_Client *ec)
4848 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4849 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4850 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4852 _e_comp_wl_send_touch_cancel(ec);
4858 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4861 struct wl_client *wc;
4863 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4864 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4865 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4867 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4870 wc = wl_resource_get_client(surface);
4871 if (!time) time = e_util_timestamp_get();
4872 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4874 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4875 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4878 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4879 WL_POINTER_BUTTON_STATE_PRESSED);
4881 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4882 WL_POINTER_BUTTON_STATE_RELEASED);
4888 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4891 struct wl_client *wc;
4893 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4894 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4895 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4897 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4898 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4900 wc = wl_resource_get_client(surface);
4901 if (!time) time = e_util_timestamp_get();
4902 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4904 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4905 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4907 x = x + ec->client.x;
4908 y = y + ec->client.y;
4910 _e_comp_wl_send_mouse_move(ec, x, y, time);
4916 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4919 struct wl_client *wc;
4921 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4922 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4923 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4925 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4926 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4928 wc = wl_resource_get_client(surface);
4929 if (!time) time = e_util_timestamp_get();
4930 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4932 if (_e_comp_wl_check_cursor_timer_needed(ec))
4934 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4938 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4939 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4941 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4943 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4945 if (_e_comp_wl_check_cursor_timer_needed(ec))
4946 _e_comp_wl_cursor_move_timer_control(ec);
4953 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4956 struct wl_client *wc;
4957 struct wl_resource *res;
4960 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4961 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4963 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4964 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4966 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4967 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4969 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4970 wc = wl_resource_get_client(surface);
4971 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4972 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4974 if (!e_comp_wl_input_pointer_check(res)) continue;
4975 if (wl_resource_get_client(res) != wc) continue;
4977 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4978 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4980 wl_pointer_send_enter(res, serial, surface,
4981 wl_fixed_from_int(x),
4982 wl_fixed_from_int(y));
4983 ec->pointer_enter_sent = EINA_TRUE;
4985 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4991 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4994 struct wl_client *wc;
4995 struct wl_resource *res;
4998 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4999 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5000 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5001 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5002 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5003 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5005 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5006 wc = wl_resource_get_client(surface);
5007 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5008 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5010 if (!e_comp_wl_input_pointer_check(res)) continue;
5011 if (wl_resource_get_client(res) != wc) continue;
5013 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5014 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5016 wl_pointer_send_leave(res, serial, surface);
5017 ec->pointer_enter_sent = EINA_FALSE;
5024 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)
5026 Evas_Event_Mouse_In ev_in;
5029 if (ec->pointer_enter_sent) return;
5031 ev_in.buttons = buttons;
5039 ev_in.modifiers = modifiers;
5040 ev_in.locks = locks;
5041 ev_in.timestamp = timestamp;
5042 ev_in.event_flags = event_flags;
5045 ev_in.event_src = event_src;
5047 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5051 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)
5053 Evas_Event_Mouse_Out ev_out;
5056 if (!ec->pointer_enter_sent) return;
5058 ev_out.buttons = buttons;
5060 ev_out.output.x = x;
5061 ev_out.output.y = y;
5062 ev_out.canvas.x = x;
5063 ev_out.canvas.y = y;
5066 ev_out.modifiers = modifiers;
5067 ev_out.locks = locks;
5068 ev_out.timestamp = timestamp;
5069 ev_out.event_flags = event_flags;
5072 ev_out.event_src = event_src;
5074 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5078 e_comp_wl_cursor_hide(E_Client *ec)
5080 struct wl_resource *res;
5081 struct wl_client *wc;
5085 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5087 if (e_comp_wl->ptr.hide_tmr)
5089 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5090 e_comp_wl->ptr.hide_tmr = NULL;
5092 cursor_timer_ec = NULL;
5094 if (!ec) return EINA_FALSE;
5095 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5096 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5097 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5099 wc = wl_resource_get_client(surface);
5100 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5101 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5103 if (!e_comp_wl_input_pointer_check(res)) continue;
5104 if (wl_resource_get_client(res) != wc) continue;
5105 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5106 wl_pointer_send_leave(res, serial, surface);
5107 ec->pointer_enter_sent = EINA_FALSE;
5113 /* surface to buffer
5114 * - width : surface width
5115 * - height : surface height
5116 * - transform: buffer transform
5117 * - scale : buffer scale
5119 * - width : screen width
5120 * - height : screen height
5121 * - transform: output transform
5122 * - scale : output scale
5124 static E_Util_Transform_Matrix
5125 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5127 E_Util_Transform_Matrix m;
5129 e_util_transform_matrix_load_identity(&m);
5131 if (transform & 0x4)
5133 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5134 e_util_transform_matrix_flip_x(&m);
5135 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5138 switch (transform & 0x3)
5140 case WL_OUTPUT_TRANSFORM_90:
5141 e_util_transform_matrix_translate(&m, -width, 0, 0);
5142 e_util_transform_matrix_rotation_z(&m, 270);
5144 case WL_OUTPUT_TRANSFORM_180:
5145 e_util_transform_matrix_translate(&m, -width, -height, 0);
5146 e_util_transform_matrix_rotation_z(&m, 180);
5148 case WL_OUTPUT_TRANSFORM_270:
5149 e_util_transform_matrix_translate(&m, 0, -height, 0);
5150 e_util_transform_matrix_rotation_z(&m, 90);
5156 e_util_transform_matrix_scale(&m, scale, scale, 1);
5161 /* surface to buffer
5162 * - surface width, surface height, buffer transform, buffer scale
5164 * - screen width, screen height, output transform, output scale
5167 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5169 E_Util_Transform_Matrix m;
5170 E_Util_Transform_Vertex v;
5172 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5174 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5175 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5176 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5180 * - buffer width, buffer height, buffer transform, buffer scale
5183 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5185 E_Util_Transform_Matrix m;
5186 E_Util_Transform_Vertex v;
5189 if (transform != 0 || scale > 1)
5191 tw = ((transform % 2) ? height : width) / scale;
5192 th = ((transform % 2) ? width : height) / scale;
5200 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5201 m = e_util_transform_matrix_inverse_get(&m);
5203 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5204 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5205 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5208 /* surface to buffer
5209 * - surface width, surface height, buffer transform, buffer scale
5211 * - screen width, screen height, output transform, output scale
5214 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5215 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5217 E_Util_Transform_Matrix m;
5218 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5219 E_Util_Transform_Rect_Vertex sv;
5221 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5223 sv = e_util_transform_rect_to_vertices(&sr);
5224 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5225 sr = e_util_transform_vertices_to_rect(&sv);
5234 * - buffer width, buffer height, buffer transform, buffer scale
5237 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5238 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5240 E_Util_Transform_Matrix m;
5241 E_Util_Transform_Rect br = {bx, by, bw, bh};
5242 E_Util_Transform_Rect_Vertex bv;
5245 if (transform != 0 || scale > 1)
5247 tw = ((transform % 2) ? height : width) / scale;
5248 th = ((transform % 2) ? width : height) / scale;
5256 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5257 m = e_util_transform_matrix_inverse_get(&m);
5259 bv = e_util_transform_rect_to_vertices(&br);
5260 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5261 br = e_util_transform_vertices_to_rect(&bv);
5269 EINTERN E_Comp_Wl_Output*
5270 e_comp_wl_output_find(E_Client *ec)
5273 E_Comp_Wl_Output *output;
5275 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5277 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5279 if (output->transform % 2)
5281 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5282 ec->y < output->x || ec->y >= (output->x + output->w))
5287 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5288 ec->y < output->y || ec->y >= (output->y + output->h))
5298 EINTERN Eina_Array *
5299 e_comp_wl_output_find_all(E_Client *ec)
5301 E_Comp_Wl_Output *output;
5302 Eina_Array *outputs;
5305 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5307 outputs = eina_array_new(4);
5311 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5313 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5314 output->x, output->y, output->w, output->h))
5316 eina_array_push(outputs, output);
5320 if (eina_array_count(outputs) == 0)
5322 eina_array_free(outputs);
5329 // --------------------------------------------------------
5330 // tizen_move_resize
5331 // --------------------------------------------------------
5333 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5340 E_Client_Pending_Geometry *geo;
5343 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5344 if (ec->fullscreen || ec->maximized) goto err;
5346 geo = E_NEW(E_Client_Pending_Geometry, 1);
5349 geo->serial = serial;
5355 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5356 ec->surface_sync.wait_commit = EINA_TRUE;
5361 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5368 e_comp_wl_commit_sync_configure(E_Client *ec)
5371 E_Client_Pending_Geometry *geo;
5373 Eina_Bool match_size = EINA_FALSE;
5380 if (!ec || !ec->frame) goto ret;
5381 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5384 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5385 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5387 if (eina_list_count(ec->surface_sync.pending_geometry))
5389 Eina_List *ll = NULL;
5390 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5394 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5399 if ((geo->w == bw) && (geo->h == bh))
5401 match_size = EINA_TRUE;
5406 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5413 if ((config.w != ec->w) || (config.h != ec->h))
5415 e_client_size_set(ec, config.w, config.h);
5416 ec->changes.size = EINA_TRUE;
5420 // FIXME: The geometry of the client would be better to be calculated
5421 // at e_desk or at e_desk_area. So the position(x,y) of the client
5422 // should be calcuated at the e_desk or at the e_desk_area.
5424 desk = e_comp_desk_find_by_ec(ec);
5427 ec->client.x = desk->geom.x + config.x;
5428 ec->client.y = desk->geom.y + config.y;
5432 ec->client.x = config.x;
5433 ec->client.y = config.y;
5436 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5438 e_client_pos_set(ec, ec->client.x, ec->client.y);
5440 ec->changes.pos = 1;
5444 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5448 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5449 ec->surface_sync.wait_commit = EINA_FALSE;
5451 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5453 // rollback wait_commit if there are pending requests remained
5454 if (eina_list_count(ec->surface_sync.pending_geometry))
5455 ec->surface_sync.wait_commit = EINA_TRUE;
5460 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);
5467 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5468 struct wl_resource *res_moveresize)
5470 wl_resource_destroy(res_moveresize);
5474 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5475 struct wl_resource *res_moveresize,
5476 struct wl_resource *surface,
5483 /* to be implemented */
5486 int cur_w = 0, cur_h = 0;
5488 ec = e_client_from_surface_resource(surface);
5491 pending = e_client_pending_geometry_has(ec);
5492 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5493 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);
5497 if ((cur_w == w) && (cur_h == h))
5499 e_client_pos_set(ec, x, y);
5500 ec->changes.pos = 1;
5506 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5510 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5513 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5515 _tz_move_resize_iface_cb_destroy,
5516 _tz_move_resize_iface_cb_set_geometry,
5520 _tz_moveresize_cb_bind(struct wl_client *client,
5521 void *data EINA_UNUSED,
5525 struct wl_resource *res_moveresize;
5527 res_moveresize = wl_resource_create(client,
5528 &tizen_move_resize_interface,
5531 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5534 wl_resource_set_implementation(res_moveresize,
5535 &_tz_move_resize_iface,
5541 ERR("Could not create tizen_move_resize_interface res: %m");
5542 wl_client_post_no_memory(client);
5546 _e_comp_wl_move_resize_init(void)
5548 if (!e_comp_wl) return;
5549 if (!e_comp_wl->wl.disp) return;
5551 if (!wl_global_create(e_comp_wl->wl.disp,
5552 &tizen_move_resize_interface,
5555 _tz_moveresize_cb_bind))
5557 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5564 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5566 E_Comp_Wl_Output *output;
5567 pid_t output_pid = 0;
5568 Eina_List *l = NULL, *l2 = NULL;
5569 struct wl_resource *resource = NULL;
5571 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5573 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5574 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5575 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5577 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5579 /* if we have bound resources, send updates */
5580 EINA_LIST_FOREACH(output->resources, l2, resource)
5582 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5583 if (output_pid != pid) continue;
5585 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5587 // send output information to the client
5588 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5596 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5598 _e_comp_wl_surface_state_init(state, w, h);
5602 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5604 _e_comp_wl_surface_state_commit(ec, state);
5608 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5610 _e_comp_wl_hook_call(hookpoint, ec);
5614 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5616 _e_comp_wl_surface_state_finish(state);
5620 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5622 _e_comp_wl_surface_state_buffer_set(state, buffer);
5626 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5627 int sx, int sy, int *dx, int *dy)
5631 case WL_OUTPUT_TRANSFORM_NORMAL:
5635 case WL_OUTPUT_TRANSFORM_FLIPPED:
5636 *dx = width - sx, *dy = sy;
5638 case WL_OUTPUT_TRANSFORM_90:
5639 *dx = height - sy, *dy = sx;
5641 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5642 *dx = height - sy, *dy = width - sx;
5644 case WL_OUTPUT_TRANSFORM_180:
5645 *dx = width - sx, *dy = height - sy;
5647 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5648 *dx = sx, *dy = height - sy;
5650 case WL_OUTPUT_TRANSFORM_270:
5651 *dx = sy, *dy = width - sx;
5653 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5663 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5666 int tx1, ty1, tx2, ty2;
5667 int width_from_buffer, height_from_buffer;
5669 switch (vp->buffer.transform)
5671 case WL_OUTPUT_TRANSFORM_90:
5672 case WL_OUTPUT_TRANSFORM_270:
5673 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5674 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5675 width_from_buffer = bh / vp->buffer.scale;
5676 height_from_buffer = bw / vp->buffer.scale;
5679 width_from_buffer = bw / vp->buffer.scale;
5680 height_from_buffer = bh / vp->buffer.scale;
5684 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5688 x2 = width_from_buffer;
5689 y2 = height_from_buffer;
5693 x1 = wl_fixed_to_int(vp->buffer.src_x);
5694 y1 = wl_fixed_to_int(vp->buffer.src_y);
5695 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5696 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5699 buffer_transform(width_from_buffer, height_from_buffer,
5700 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5701 buffer_transform(width_from_buffer, height_from_buffer,
5702 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5704 out->x = (tx1 <= tx2) ? tx1 : tx2;
5705 out->y = (ty1 <= ty2) ? ty1 : ty2;
5706 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5707 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5711 * Convert given four coordinates to elements of rectangle
5712 * @in p[4] Coordinates to be converted
5713 * @out rect x, y, width, and height
5714 * transform Angle which represents TDM_TRANSFORM of rectangle
5715 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5716 * 1. The given coordinates are not represented by rectangle.
5717 * 2. All angles except for 0, 90, 180, 270.
5720 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5722 Eina_Bool ret = EINA_FALSE;
5724 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))
5727 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5730 *rotation = TDM_TRANSFORM_NORMAL;
5733 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5737 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5740 *rotation = TDM_TRANSFORM_180;
5743 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5748 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))
5751 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5754 *rotation = TDM_TRANSFORM_90;
5757 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5761 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5764 *rotation = TDM_TRANSFORM_270;
5767 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5777 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5782 for (i = 0; i < 4; i++)
5783 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5785 if (!_coords_to_rectangle_convert(p, out, rotation))
5787 DBG("Cannot convert given coords to rectangle.\n"
5788 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5789 p[0].x, p[0].y, p[1].x, p[1].y,
5790 p[2].x, p[2].y, p[3].x, p[3].y);
5798 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5800 int trans_rotation, flip;
5802 trans_rotation = transform & 0x3;
5803 flip = transform & 0x4;
5805 return (flip + (trans_rotation + rotation) % 4);
5809 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5817 if (e_comp_wl_subsurface_check(ec))
5818 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5825 out->w = ec->comp_data->width_from_viewport;
5826 out->w = (out->w + 1) & ~1;
5827 out->h = ec->comp_data->height_from_viewport;
5829 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5830 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5834 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5836 E_Comp_Wl_Buffer *buffer;
5837 E_Comp_Wl_Buffer_Viewport *vp;
5839 enum wl_output_transform buffer_transform;
5840 unsigned int rotation;
5841 Eina_Bool res = EINA_FALSE;
5843 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5845 if (e_object_is_del(E_OBJECT(ec)))
5848 vp = &ec->comp_data->scaler.buffer_viewport;
5850 if (buffer_viewport)
5852 buffer = ec->comp_data->buffer_ref.buffer;
5853 /* Getting a viewport of buffer needs geometry of buffer. */
5857 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5860 if ((output_viewport) || (transform))
5862 m = e_client_map_get(ec);
5864 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5866 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5871 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5872 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5873 * Since buffer.transform isn't applied using evas_map,
5874 * it has to be taken into account here to apply buffer.transform
5875 * and rotation of e_client_transform together. */
5877 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5879 *transform = (unsigned int)buffer_transform;
5887 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5889 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5890 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5892 /* Must be called with valid comp_data */
5893 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5895 if ((ec->comp_data->role_name == NULL) ||
5896 (ec->comp_data->role_name == role_name) ||
5897 (strcmp(ec->comp_data->role_name, role_name) == 0))
5899 ec->comp_data->role_name = role_name;
5905 wl_resource_post_error(error_resource, error_code,
5906 "Cannot assign role %s to wl_surface@%d,"
5907 " already has role %s\n",
5909 ec->comp_data->wl_surface ?
5910 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5911 ec->comp_data->role_name);
5917 EINTERN const char *
5918 e_comp_wl_surface_role_get(E_Client *ec)
5920 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5921 return ec->comp_data ? ec->comp_data->role_name : NULL;
5924 EINTERN struct wl_resource *
5925 e_comp_wl_client_surface_get(E_Client *ec)
5927 struct wl_resource *surface = NULL;
5928 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5929 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5931 g_mutex_lock(&ec->comp_data->surface_mutex);
5932 surface = ec->comp_data->surface;
5933 g_mutex_unlock(&ec->comp_data->surface_mutex);
5938 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5940 EINA_SAFETY_ON_NULL_RETURN(ec);
5941 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5943 g_mutex_lock(&ec->comp_data->surface_mutex);
5944 ec->comp_data->surface = surface;
5945 g_mutex_unlock(&ec->comp_data->surface_mutex);
5949 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5951 return e_compositor_util_client_from_surface_resource(surface_resource);
5955 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5957 if (!ec->comp_data->mapped)
5959 if (ec->comp_data->shell.surface &&
5960 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5962 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5968 if (ec->comp_data->mapped)
5970 /* will be unmapped. so run capture */
5971 e_comp_wl_remote_surface_image_save(ec);
5975 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5977 ec->comp_data->pending.sx = sx;
5978 ec->comp_data->pending.sy = sy;
5979 ec->comp_data->pending.new_attach = EINA_TRUE;
5981 e_client_fps_update(ec);
5985 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5987 if (ec->comp_data->pending.opaque)
5988 eina_tiler_clear(ec->comp_data->pending.opaque);
5992 eina_tiler_union(ec->comp_data->pending.opaque, region);
5994 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5998 ec->argb = EINA_FALSE;
5999 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6001 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6002 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6010 ec->argb = EINA_TRUE;
6011 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6013 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6014 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6020 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6022 if (ec->comp_data->pending.input)
6023 eina_tiler_clear(ec->comp_data->pending.input);
6027 if (eina_tiler_empty(region))
6029 ELOGF("COMP", " |unset input rect", NULL);
6030 e_comp_object_input_objs_del(ec->frame);
6031 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6034 eina_tiler_union(ec->comp_data->pending.input, region);
6038 eina_tiler_rect_add(ec->comp_data->pending.input,
6039 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6044 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6046 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6050 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6052 E_Comp_Wl_Subsurf_Data *sdata;
6057 if (ec->comp_data->frames)
6059 ec->comp_data->frames =
6060 eina_list_remove(ec->comp_data->frames, callback_resource);
6063 if (ec->comp_data->pending.frames)
6065 ec->comp_data->pending.frames =
6066 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6069 sdata = ec->comp_data->sub.data;
6070 if ((sdata) && (sdata->cached.frames))
6072 sdata->cached.frames =
6073 eina_list_remove(sdata->cached.frames, callback_resource);
6078 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6080 if (e_object_is_del(E_OBJECT(ec))) return;
6082 if (e_comp_wl_remote_surface_commit(ec)) return;
6084 e_comp_wl_surface_commit(ec);
6086 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6090 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6092 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6093 ec->comp_data->sub.data = sub;
6095 /* set subsurface client properties */
6096 ec->borderless = EINA_TRUE;
6097 ec->argb = EINA_TRUE;
6098 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6099 ec->lock_border = EINA_TRUE;
6100 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6101 ec->netwm.state.skip_taskbar = EINA_TRUE;
6102 ec->netwm.state.skip_pager = EINA_TRUE;
6103 ec->border_size = 0;
6104 ec->lock_user_location = 0;
6105 ec->lock_client_location = 0;
6106 ec->lock_user_size = 0;
6107 ec->lock_client_size = 0;
6108 ec->lock_client_stacking = 0;
6109 ec->lock_user_maximize = 0;
6110 ec->lock_client_maximize = 0;
6111 ec->changes.need_maximize = 0;
6112 ec->maximized = E_MAXIMIZE_NONE;
6115 ec->new_client = ec->netwm.ping = EINA_TRUE;
6116 e_comp->new_clients++;
6117 e_client_unignore(ec);
6119 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6120 * It's not for subsurface. */
6121 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6125 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6127 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6130 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6132 sub->parent = parent;
6136 layer = e_client_layer_get(parent);
6137 if (layer > E_LAYER_BOTTOM)
6138 e_client_layer_set(ec, layer);
6141 if (parent->comp_data)
6143 /* append this client to the parents subsurface list */
6144 parent->comp_data->sub.list_pending =
6145 eina_list_append(parent->comp_data->sub.list_pending, ec);
6146 parent->comp_data->sub.list_changed = EINA_TRUE;
6151 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6153 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6154 E_Client *parent = sub->parent;
6156 parent->comp_data->sub.list =
6157 eina_list_remove(parent->comp_data->sub.list, ec);
6158 parent->comp_data->sub.list_pending =
6159 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6160 parent->comp_data->sub.below_list =
6161 eina_list_remove(parent->comp_data->sub.below_list, ec);
6162 parent->comp_data->sub.below_list_pending =
6163 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6169 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)
6171 sub->resource = subsurface_resource;
6172 sub->cached_buffer_ref.buffer = NULL;
6173 sub->synchronized = EINA_TRUE;
6174 sub->parent = parent;
6175 sub->remote_surface.offscreen_parent = offscreen_parent;
6176 if (offscreen_parent)
6177 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6179 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6181 _e_comp_wl_client_subsurface_set(ec, sub);
6182 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6184 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6188 e_comp_wl_client_subsurface_finish(E_Client *ec)
6190 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6193 e_comp_wl_client_subsurface_parent_unset(ec);
6195 e_comp_wl_surface_state_finish(&sub->cached);
6196 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6198 ec->comp_data->sub.data = NULL;
6202 e_comp_wl_client_evas_init(E_Client *ec)
6204 EINA_SAFETY_ON_NULL_RETURN(ec);
6206 _e_comp_wl_client_evas_init(ec);
6210 e_comp_wl_client_evas_deinit(E_Client *ec)
6212 EINA_SAFETY_ON_NULL_RETURN(ec);
6214 _e_comp_wl_client_evas_deinit(ec);
6218 e_comp_wl_focus_check(void)
6220 _e_comp_wl_focus_check();
6224 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6231 if ((parent->comp_data) && (parent->comp_data->sub.data))
6232 parent = parent->comp_data->sub.data->parent;