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"
35 #include <tizen-extension-server-protocol.h>
36 #include <relative-pointer-unstable-v1-server-protocol.h>
37 #include <pointer-constraints-unstable-v1-server-protocol.h>
39 #include <wayland-tbm-server.h>
41 #include <libds/log.h>
42 #include <libds/single_pixel_buffer_v1.h>
45 /* handle include for printing uint64_t */
46 #define __STDC_FORMAT_MACROS
49 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
51 /* Resource Data Mapping: (wl_resource_get_user_data)
53 * wl_surface == e_pixmap
54 * wl_region == eina_tiler
55 * wl_subsurface == e_client
59 typedef struct _E_Comp_Data E_Comp_Data;
64 struct wl_listener client_created;
67 static void _e_comp_wl_move_resize_init(void);
69 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
72 typedef struct _E_Comp_Wl_Key_Data
78 struct _E_Comp_Wl_Evas_Gl
81 Evas_GL_Config *glcfg;
82 Evas_GL_Context *glctx;
83 Evas_GL_Surface *glsfc;
87 static Eina_List *handlers = NULL;
88 static E_Client *cursor_timer_ec = NULL;
89 static Eina_Bool need_send_released = EINA_FALSE;
90 static Eina_Bool need_send_motion = EINA_TRUE;
92 static GMutex connection_mutex;
94 static int _e_comp_wl_hooks_delete = 0;
95 static int _e_comp_wl_hooks_walking = 0;
97 static int _e_comp_wl_pid_hooks_delete = 0;
98 static int _e_comp_wl_pid_hooks_walking = 0;
100 static int _e_comp_wl_intercept_hooks_delete = 0;
101 static int _e_comp_wl_intercept_hooks_walking = 0;
103 static Eina_Inlist *_e_comp_wl_hooks[] =
105 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
106 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
107 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
108 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
109 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
110 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
111 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
112 [E_COMP_WL_HOOK_DEL] = NULL,
113 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
114 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
115 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
118 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
120 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
123 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
125 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
126 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
127 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
128 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
129 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
130 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
133 static Eina_List *hooks = NULL;
135 /* local functions */
137 _e_comp_wl_hooks_clean(void)
142 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
143 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
145 if (!ch->delete_me) continue;
146 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
152 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
156 e_object_ref(E_OBJECT(ec));
157 _e_comp_wl_hooks_walking++;
158 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
160 if (ch->delete_me) continue;
161 ch->func(ch->data, ec);
162 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
163 (e_object_is_del(E_OBJECT(ec))))
166 _e_comp_wl_hooks_walking--;
167 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
168 _e_comp_wl_hooks_clean();
169 e_object_unref(E_OBJECT(ec));
173 _e_comp_wl_pid_hooks_clean(void)
176 E_Comp_Wl_Pid_Hook *ch;
178 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
179 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
181 if (!ch->delete_me) continue;
182 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
188 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
190 E_Comp_Wl_Pid_Hook *ch;
192 _e_comp_wl_pid_hooks_walking++;
193 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
195 if (ch->delete_me) continue;
196 ch->func(ch->data, pid);
198 _e_comp_wl_pid_hooks_walking--;
199 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
200 _e_comp_wl_pid_hooks_clean();
204 _e_comp_wl_intercept_hooks_clean(void)
207 E_Comp_Wl_Intercept_Hook *ch;
209 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
210 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
212 if (!ch->delete_me) continue;
213 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
219 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
221 E_Comp_Wl_Intercept_Hook *ch;
222 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
224 e_object_ref(E_OBJECT(ec));
225 _e_comp_wl_intercept_hooks_walking++;
226 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
228 if (ch->delete_me) continue;
229 res = ch->func(ch->data, ec);
230 if (!res) ret = EINA_FALSE;
231 if (e_object_is_del(E_OBJECT(ec)))
234 _e_comp_wl_intercept_hooks_walking--;
235 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
236 _e_comp_wl_intercept_hooks_clean();
237 e_object_unref(E_OBJECT(ec));
244 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
250 if (e_comp_object_frame_exists(ec->frame))
251 w = ec->client.w, h = ec->client.h;
253 w = ec->w, h = ec->h;
257 // Width and Height are -1 means that we don't consider size value
261 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
265 _e_comp_wl_focus_check(void)
269 if (stopping) return;
270 ec = e_client_focused_get();
272 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
276 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
278 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
280 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
281 IDLE_EXITER~CB_PREPARE);
283 return ECORE_CALLBACK_RENEW;
287 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
289 /* dispatch pending wayland events */
290 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
292 return ECORE_CALLBACK_RENEW;
296 e_comp_wl_display_flush()
298 if (e_comp_wl && e_comp_wl->wl.disp)
300 if (e_config->key_input_ttrace_enable)
302 TRACE_INPUT_BEGIN(wl_display_flush_clients);
303 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
306 g_mutex_lock(&connection_mutex);
307 wl_display_flush_clients(e_comp_wl->wl.disp);
308 g_mutex_unlock(&connection_mutex);
310 if (e_config->key_input_ttrace_enable)
313 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
319 e_comp_wl_connection_lock()
321 e_input_boost_lock(&connection_mutex);
325 e_comp_wl_connection_unlock()
327 e_input_boost_unlock(&connection_mutex);
331 e_comp_wl_focused_client_flush()
333 E_Client *focused_ec;
334 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
336 e_input_boost_lock(&connection_mutex);
337 focused_ec = e_client_focused_get();
341 struct wl_client *wc;
342 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
345 e_input_boost_unlock(&connection_mutex);
349 wc = wl_resource_get_client(surface);
353 e_input_boost_unlock(&connection_mutex);
357 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
361 if (e_comp_wl->idle_exiter_timestamp > 0.0)
363 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
364 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
366 ELOGF("E_COMP", "prepare gap time: %lfms",
371 e_comp_wl->idle_exiter_timestamp = 0.0;
373 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
375 /* flush pending client events */
376 e_comp_wl_display_flush();
378 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
379 IDLE_EXITER~CB_PREPARE);
382 E_API enum wl_output_transform
383 e_comp_wl_output_buffer_transform_get(E_Client *ec)
385 E_Comp_Wl_Buffer_Viewport *vp;
386 E_Comp_Wl_Buffer *buffer;
387 enum wl_output_transform transform, rotation;
389 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
390 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
391 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
393 vp = &ec->comp_data->scaler.buffer_viewport;
394 if (e_comp_wl_subsurface_check(ec))
395 return vp->buffer.transform;
397 buffer = ec->comp_data->buffer_ref.buffer;
400 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
401 return vp->buffer.transform;
403 rotation = buffer->transform;
405 return vp->buffer.transform;
407 /* ignore the flip value when calculating transform because the screen rotation
408 * functionality doesn't consider the flip output transform currently
410 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
412 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
413 ec, rotation, vp->buffer.transform, transform);
418 EINTERN enum wl_output_transform
419 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
421 E_Comp_Wl_Buffer_Viewport *vp;
422 E_Comp_Wl_Buffer *buffer;
423 enum wl_output_transform transform, rotation;
425 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
426 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
427 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
429 vp = &ec->comp_data->pending.buffer_viewport;
430 if (e_comp_wl_subsurface_check(ec))
431 return vp->buffer.transform;
433 buffer = ec->comp_data->pending.buffer;
436 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
437 return vp->buffer.transform;
439 rotation = buffer->transform;
441 return vp->buffer.transform;
443 /* ignore the flip value when calculating transform because the screen rotation
444 * functionality doesn't consider the flip output transform currently
446 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
448 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
449 ec, rotation, vp->buffer.transform, transform);
455 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
457 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
458 E_Comp_Wl_Buffer *buffer;
459 int32_t width, height;
461 buffer = e_pixmap_resource_get(ec->pixmap);
464 ec->comp_data->width_from_buffer = 0;
465 ec->comp_data->height_from_buffer = 0;
469 switch (e_comp_wl_output_buffer_transform_get(ec))
471 case WL_OUTPUT_TRANSFORM_90:
472 case WL_OUTPUT_TRANSFORM_270:
473 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
474 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
475 width = buffer->h / vp->buffer.scale;
476 height = buffer->w / vp->buffer.scale;
479 width = buffer->w / vp->buffer.scale;
480 height = buffer->h / vp->buffer.scale;
484 ec->comp_data->width_from_buffer = width;
485 ec->comp_data->height_from_buffer = height;
489 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
491 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
492 int32_t width, height;
494 width = ec->comp_data->width_from_buffer;
495 height = ec->comp_data->height_from_buffer;
497 if (width == 0 && height == 0) return;
499 if (width != 0 && vp->surface.width != -1)
501 ec->comp_data->width_from_viewport = vp->surface.width;
502 ec->comp_data->height_from_viewport = vp->surface.height;
506 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
508 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
509 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
510 ec->comp_data->width_from_viewport = w ?: 1;
511 ec->comp_data->height_from_viewport = h ?: 1;
515 ec->comp_data->width_from_viewport = width;
516 ec->comp_data->height_from_viewport = height;
520 e_comp_wl_topmost_parent_get(E_Client *ec)
524 if (!e_comp_wl_subsurface_check(ec))
527 parent = e_comp_wl_subsurface_parent_get(ec);
530 if (!e_comp_wl_subsurface_check(parent))
533 parent = e_comp_wl_subsurface_parent_get(parent);
540 e_comp_wl_map_apply(E_Client *ec)
542 E_Comp_Wl_Buffer_Viewport *vp;
543 E_Comp_Wl_Subsurf_Data *sdata;
544 E_Comp_Wl_Client_Data *cdata;
545 int x1, y1, x2, y2, x, y;
547 Eina_Bool zoom_animating = EINA_FALSE;
549 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
551 e_comp_object_map_update(ec->frame);
553 cdata = ec->comp_data;
554 vp = &cdata->scaler.buffer_viewport;
555 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
556 (!cdata->viewport_transform))
559 if (e_comp_wl_subsurface_check(ec))
561 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
563 sdata = ec->comp_data->sub.data;
564 if (sdata->remote_surface.offscreen_parent)
566 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
567 Eina_Rectangle *rect;
570 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
572 /* TODO: If there are one more regions, it means that provider's offscreen
573 * is displayed by one more remote_surfaces. Have to consider it later. At
574 * this time, just consider only one remote_surface.
588 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
589 if (x != dx || y != dy)
590 evas_object_move(ec->frame, dx, dy);
592 if (!cdata->viewport_transform)
594 cdata->viewport_transform = e_util_transform_new();
595 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
596 e_client_transform_core_add(ec, cdata->viewport_transform);
599 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
600 ec->comp_data->width_from_viewport,
601 ec->comp_data->height_from_viewport);
603 if (vp->buffer.src_width == wl_fixed_from_int(-1))
607 x2 = cdata->width_from_buffer;
608 y2 = cdata->height_from_buffer;
612 x1 = wl_fixed_to_int(vp->buffer.src_x);
613 y1 = wl_fixed_to_int(vp->buffer.src_y);
614 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
615 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
618 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
619 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
620 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
621 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
624 desk = e_comp_desk_find_by_ec(ec);
626 zoom_animating = e_desk_zoom_is_animating(desk);
628 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
629 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
630 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
632 /* workaround:: when the desk zoom is doing their animation,
633 the transform core update can override animation's zoom boundary.
634 so, don't doing transform core update while desk zoom animation */
636 e_client_transform_core_update(ec);
641 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
645 int map_c = 0, map_x = 0, map_y = 0;
646 double inv_x = 0.0, inv_y = 0.0;
648 EINA_SAFETY_ON_NULL_RETURN(ec);
650 map = e_client_map_get(ec);
651 map_c = e_map_count_get(map);
653 if (!map || map_c <= 0)
663 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
664 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
665 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
666 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
668 for (int i = 0; i < map_c; i++)
670 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
671 e_map_point_image_uv_set(map2, i, map_x, map_y);
673 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
683 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
689 if (!(ec = data)) return;
690 if (e_object_is_del(data)) return;
692 if (!ec->override) e_hints_window_visible_set(ec);
694 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
695 (!ec->comp_data->need_reparent))
697 ec->comp_data->need_reparent = EINA_TRUE;
698 ec->visible = EINA_TRUE;
700 if (!e_client_util_ignored_get(ec))
702 ec->take_focus = !starting;
706 if (!ec->comp_data->need_reparent)
708 if ((ec->hidden) || (ec->iconic))
710 evas_object_hide(ec->frame);
711 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
714 evas_object_show(ec->frame);
717 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
718 evas_object_show(tmp->frame);
720 topmost = e_comp_wl_topmost_parent_get(ec);
721 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
722 e_comp_wl_subsurface_show(ec);
724 if (ec->comp_data->sub.below_obj)
725 evas_object_show(ec->comp_data->sub.below_obj);
729 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
735 if (!(ec = data)) return;
736 if (e_object_is_del(E_OBJECT(ec))) return;
738 /* Uncommonly some clients's final buffer can be skipped if the client
739 * requests unmap of its surface right after wl_surface@commit.
740 * So if this client evas object is hidden state and client is already
741 * unmmapped, we can consider to clear pixmap image here mandatorily.
743 if (!ec->comp_data->mapped)
744 e_pixmap_image_clear(ec->pixmap, 1);
746 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
747 evas_object_hide(tmp->frame);
749 topmost = e_comp_wl_topmost_parent_get(ec);
750 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
751 e_comp_wl_subsurface_hide(ec);
753 if (ec->comp_data->sub.below_obj)
754 evas_object_hide(ec->comp_data->sub.below_obj);
756 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
760 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
767 if (!(ec = data)) return;
768 if (e_object_is_del(E_OBJECT(ec))) return;
770 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
772 if (!e_comp_wl_subsurface_check(subc)) continue;
773 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
774 evas_object_move(subc->frame, x, y);
776 if (subc->comp_data->scaler.viewport)
778 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
779 if (cdata->viewport_transform)
780 e_comp_wl_map_apply(subc);
784 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
786 if (!e_comp_wl_subsurface_check(subc)) continue;
787 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
788 evas_object_move(subc->frame, x, y);
790 if (subc->comp_data->scaler.viewport)
792 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
793 if (cdata->viewport_transform)
794 e_comp_wl_map_apply(subc);
798 if (ec->comp_data->sub.below_obj)
800 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
801 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
806 _e_comp_wl_send_touch_cancel(E_Client *ec)
809 struct wl_resource *res;
810 struct wl_client *wc;
811 E_Comp_Config *comp_conf = NULL;
814 if (e_object_is_del(E_OBJECT(ec))) return;
815 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
817 if (!surface) return;
818 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
820 wc = wl_resource_get_client(surface);
822 comp_conf = e_comp_config_get();
824 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
826 if (wl_resource_get_client(res) != wc) continue;
827 if (!e_comp_wl_input_touch_check(res)) continue;
829 if (comp_conf && comp_conf->input_log_enable)
830 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
832 wl_touch_send_cancel(res);
837 _e_comp_wl_touch_cancel(void)
841 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
843 if (!e_comp_wl->touch.pressed) return;
845 _e_comp_wl_send_touch_cancel(ec);
848 static E_Devicemgr_Input_Device *
849 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
851 E_Devicemgr_Input_Device *last_kbd = NULL;
854 case ECORE_DEVICE_CLASS_MOUSE:
855 return e_devicemgr->last_device_ptr;
856 case ECORE_DEVICE_CLASS_KEYBOARD:
857 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
859 case ECORE_DEVICE_CLASS_TOUCH:
860 return e_devicemgr->last_device_touch;
868 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
872 case ECORE_DEVICE_CLASS_MOUSE:
873 e_devicemgr->last_device_ptr = device;
875 case ECORE_DEVICE_CLASS_KEYBOARD:
876 atomic_store(&e_devicemgr->last_device_kbd, device);
878 case ECORE_DEVICE_CLASS_TOUCH:
879 e_devicemgr->last_device_touch = device;
886 static E_Devicemgr_Input_Device *
887 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
889 E_Devicemgr_Input_Device *last_kbd = NULL;
893 case ECORE_DEVICE_CLASS_MOUSE:
894 return ec->comp_data->last_device_ptr;
895 case ECORE_DEVICE_CLASS_KEYBOARD:
896 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
898 case ECORE_DEVICE_CLASS_TOUCH:
899 return ec->comp_data->last_device_touch;
907 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
911 case ECORE_DEVICE_CLASS_MOUSE:
912 ec->comp_data->last_device_ptr = device;
914 case ECORE_DEVICE_CLASS_KEYBOARD:
915 atomic_store(&ec->comp_data->last_device_kbd, device);
917 case ECORE_DEVICE_CLASS_TOUCH:
918 ec->comp_data->last_device_touch = device;
926 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
928 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
929 struct wl_resource *dev_res;
930 const char *dev_name;
931 Ecore_Device_Class dev_class;
932 struct wl_client *wc;
936 EINA_SAFETY_ON_NULL_RETURN(dev);
939 if (ec->cur_mouse_action || e_comp_wl->drag)
941 if (e_object_is_del(E_OBJECT(ec))) return;
942 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
943 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
944 if (!surface) return;
946 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
947 dev_name = evas_device_description_get(dev);
948 last_device = _e_comp_wl_device_last_device_get(dev_class);
949 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
951 serial = wl_display_next_serial(e_comp_wl->wl.disp);
952 wc = wl_resource_get_client(surface);
953 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
954 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
956 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
957 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
959 _e_comp_wl_device_last_device_set(dev_class, input_dev);
960 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
962 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
964 if (wl_resource_get_client(dev_res) != wc) continue;
965 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
969 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
973 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
975 E_Devicemgr_Input_Device *last_device;
976 struct wl_resource *dev_res;
977 struct wl_client *wc;
981 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
982 if (!surface) return;
984 last_device = _e_comp_wl_device_last_device_get(dev_class);
985 if (!last_device) return;
987 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
989 serial = wl_display_next_serial(e_comp_wl->wl.disp);
990 wc = wl_resource_get_client(surface);
991 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
993 if (wl_resource_get_client(dev_res) != wc) continue;
994 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
999 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1001 E_Devicemgr_Input_Device *input_dev;
1002 struct wl_resource *dev_res;
1003 const char *dev_name;
1006 EINA_SAFETY_ON_NULL_RETURN(dev);
1008 dev_name = ecore_device_identifier_get(dev);
1010 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1011 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1013 if (!eina_streq(input_dev->identifier, dev_name) ||
1014 (input_dev->clas != ecore_device_class_get(dev))) continue;
1015 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1017 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1019 if (wl_resource_get_client(dev_res) != wc) continue;
1020 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1023 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1027 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1029 E_Devicemgr_Input_Device *input_dev;
1030 struct wl_resource *dev_res;
1031 const char *dev_name;
1034 EINA_SAFETY_ON_NULL_RETURN(dev);
1036 dev_name = e_device_identifier_get(dev);
1038 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1039 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1041 if (!eina_streq(input_dev->identifier, dev_name) ||
1042 (input_dev->clas != e_device_class_get(dev))) continue;
1043 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1045 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1047 if (wl_resource_get_client(dev_res) != wc) continue;
1048 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1051 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1055 _e_comp_wl_cursor_reload(E_Client *ec)
1057 struct wl_resource *res;
1058 struct wl_client *wc;
1064 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1065 !evas_object_visible_get(e_comp->pointer->o_ptr))
1066 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1069 if (e_object_is_del(E_OBJECT(ec))) return;
1070 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1071 if (!surface) return;
1072 if (ec->pointer_enter_sent) return;
1074 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1075 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1077 if (e_client_transform_core_enable_get(ec))
1079 double dx = 0.0, dy = 0.0;
1080 map = e_client_map_get(ec);
1081 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1087 cx = px - ec->client.x;
1088 cy = py - ec->client.y;
1090 wc = wl_resource_get_client(surface);
1091 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1092 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1094 if (!e_comp_wl_input_pointer_check(res)) continue;
1095 if (wl_resource_get_client(res) != wc) continue;
1096 wl_pointer_send_enter(res, serial, surface,
1097 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1098 ec->pointer_enter_sent = EINA_TRUE;
1100 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1104 _e_comp_wl_cursor_timer(void *data)
1106 E_Client *ec = data;
1108 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1109 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1111 e_comp_wl_cursor_hide(ec);
1113 return ECORE_CALLBACK_CANCEL;
1117 _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)
1119 E_Devicemgr_Input_Device *input_dev;
1120 struct wl_resource *dev_res;
1121 struct wl_client *wc;
1126 if (ec->cur_mouse_action) return;
1127 if (e_object_is_del(E_OBJECT(ec))) return;
1128 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1129 if (!surface) return;
1131 f_value = wl_fixed_from_double(value);
1132 wc = wl_resource_get_client(surface);
1134 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1135 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1137 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1138 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1140 if (wl_resource_get_client(dev_res) != wc) continue;
1141 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1144 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1148 _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)
1150 if (idx >= e_input_touch_max_count_get()) return;
1152 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1153 e_devicemgr->multi[idx].radius_x = radius_x;
1154 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1155 e_devicemgr->multi[idx].radius_y = radius_y;
1156 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1157 e_devicemgr->multi[idx].pressure = pressure;
1158 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1159 e_devicemgr->multi[idx].angle = angle;
1163 _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)
1165 if (idx >= e_input_touch_max_count_get()) return;
1167 if (e_devicemgr->multi[idx].radius_x != radius_x)
1169 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1170 e_devicemgr->multi[idx].radius_x = radius_x;
1172 if (e_devicemgr->multi[idx].radius_y != radius_y)
1174 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1175 e_devicemgr->multi[idx].radius_y = radius_y;
1177 if (e_devicemgr->multi[idx].pressure != pressure)
1179 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1180 e_devicemgr->multi[idx].pressure = pressure;
1182 if (e_devicemgr->multi[idx].angle != angle)
1184 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1185 e_devicemgr->multi[idx].angle = angle;
1190 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1192 Eina_Bool ret = EINA_TRUE;
1195 case EVAS_CALLBACK_MOUSE_IN:
1196 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1199 if (e_comp_wl->ptr.hide_tmr)
1201 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1202 cursor_timer_ec = ec;
1203 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1207 if (e_pointer_is_hidden(e_comp->pointer))
1212 case EVAS_CALLBACK_MOUSE_OUT:
1213 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1216 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1220 case EVAS_CALLBACK_MOUSE_MOVE:
1221 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1224 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1225 _e_comp_wl_cursor_reload(ec);
1228 case EVAS_CALLBACK_MOUSE_WHEEL:
1229 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1232 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1233 _e_comp_wl_cursor_reload(ec);
1236 case EVAS_CALLBACK_MOUSE_DOWN:
1237 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1240 if (e_comp_wl->ptr.hide_tmr)
1242 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1243 e_comp_wl->ptr.hide_tmr = NULL;
1245 cursor_timer_ec = NULL;
1247 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1248 _e_comp_wl_cursor_reload(ec);
1251 case EVAS_CALLBACK_MOUSE_UP:
1252 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1263 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1265 if (ec->has_cursor_unset)
1268 if (!e_config->show_cursor)
1271 if (!e_config->use_cursor_timer)
1278 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1281 Evas_Event_Mouse_In *ev;
1282 struct wl_resource *res;
1283 struct wl_client *wc;
1286 E_Comp_Config *comp_conf;
1287 E_Client *prev_ptr_ec;
1291 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1292 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1294 if (!(ec = data)) return;
1295 if (e_object_is_del(E_OBJECT(ec))) return;
1296 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1297 if (!surface) return;
1299 prev_ptr_ec = e_comp_wl->ptr.ec;
1302 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1303 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1306 e_comp_wl->ptr.ec = ec;
1308 comp_conf = e_comp_config_get();
1309 if (comp_conf && comp_conf->input_log_enable)
1310 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1311 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1312 e_client_util_name_get(ec));
1314 if (_e_comp_wl_check_cursor_timer_needed(ec))
1316 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1320 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1321 wc = wl_resource_get_client(surface);
1322 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1323 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1325 if (!e_comp_wl_input_pointer_check(res)) continue;
1326 if (wl_resource_get_client(res) != wc) continue;
1328 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1330 wl_pointer_send_enter(res, serial, surface,
1331 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1332 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1333 ec->pointer_enter_sent = EINA_TRUE;
1336 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1340 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1343 Evas_Event_Mouse_Out *ev;
1344 struct wl_resource *res;
1345 struct wl_client *wc;
1348 Eina_Bool inside_check;
1349 E_Comp_Config *comp_conf;
1353 if (!(ec = data)) return;
1354 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1355 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1356 if (ec->cur_mouse_action && inside_check) return;
1357 if (e_object_is_del(E_OBJECT(e_comp))) return;
1358 if (e_comp_wl->ptr.ec == ec)
1359 e_comp_wl->ptr.ec = NULL;
1360 if (e_object_is_del(E_OBJECT(ec))) return;
1362 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1363 if (!surface) return;
1365 comp_conf = e_comp_config_get();
1366 if (comp_conf && comp_conf->input_log_enable)
1367 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1368 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1369 e_client_util_name_get(ec));
1371 if (_e_comp_wl_check_cursor_timer_needed(ec))
1373 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1377 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1379 wc = wl_resource_get_client(surface);
1380 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1381 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1383 if (!e_comp_wl_input_pointer_check(res)) continue;
1384 if (wl_resource_get_client(res) != wc) continue;
1385 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1387 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1389 wl_pointer_send_leave(res, serial, surface);
1390 ec->pointer_enter_sent = EINA_FALSE;
1395 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1398 struct wl_client *wc;
1399 struct wl_resource *res;
1402 E_Comp_Config *comp_conf = NULL;
1405 if (e_object_is_del(E_OBJECT(ec))) return;
1406 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1407 if (!surface) return;
1409 wc = wl_resource_get_client(surface);
1410 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1414 x = wl_fixed_from_int(canvas_x - ec->client.x);
1415 y = wl_fixed_from_int(canvas_y - ec->client.y);
1418 comp_conf = e_comp_config_get();
1420 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1422 if (wl_resource_get_client(res) != wc) continue;
1423 if (!e_comp_wl_input_touch_check(res)) continue;
1424 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1427 if (comp_conf && comp_conf->input_log_enable)
1428 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));
1430 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1434 if (comp_conf && comp_conf->input_log_enable)
1435 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));
1437 wl_touch_send_up(res, serial, timestamp, idx);
1444 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1447 struct wl_client *wc;
1448 struct wl_resource *res;
1452 if (ec->cur_mouse_action) return;
1453 if (e_object_is_del(E_OBJECT(ec))) return;
1454 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1455 if (!surface) return;
1457 wc = wl_resource_get_client(surface);
1459 x = wl_fixed_from_int(canvas_x - ec->client.x);
1460 y = wl_fixed_from_int(canvas_y - ec->client.y);
1462 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1464 if (wl_resource_get_client(res) != wc) continue;
1465 if (!e_comp_wl_input_touch_check(res)) continue;
1466 wl_touch_send_motion(res, timestamp, idx, x, y);
1471 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1473 struct wl_resource *res;
1474 struct wl_client *wc;
1478 if (ec->cur_mouse_action) return;
1479 if (e_object_is_del(E_OBJECT(ec))) return;
1480 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1481 if (!surface) return;
1483 wc = wl_resource_get_client(surface);
1484 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1486 if (!e_comp_wl_input_pointer_check(res)) continue;
1487 if (wl_resource_get_client(res) != wc) continue;
1488 wl_pointer_send_motion(res, timestamp,
1489 wl_fixed_from_int(x - ec->client.x),
1490 wl_fixed_from_int(y - ec->client.y));
1495 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1497 if (e_comp_wl->ptr.hide_tmr)
1499 if (cursor_timer_ec == ec)
1501 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1502 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1506 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1507 cursor_timer_ec = ec;
1508 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1513 cursor_timer_ec = ec;
1514 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1519 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1522 Evas_Event_Mouse_Move *ev;
1523 Evas_Device *dev = NULL;
1524 const char *dev_name;
1525 E_Comp_Config *comp_conf;
1529 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1530 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1532 if (!(ec = data)) return;
1533 if (e_object_is_del(E_OBJECT(ec))) return;
1534 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1535 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1536 if (!surface) return;
1538 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1541 dev_name = evas_device_description_get(dev);
1543 comp_conf = e_comp_config_get();
1544 if (comp_conf && comp_conf->input_log_enable)
1545 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1546 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1547 e_client_util_name_get(ec), dev_name);
1549 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1551 if (!e_comp_wl->drag_client)
1553 e_comp_wl->touch.faked_ec = ec;
1554 if (e_comp_wl->touch.pressed & (1 << 0))
1556 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1558 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1559 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1560 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1564 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1568 if (!e_comp_wl->drag_client)
1570 if (_e_comp_wl_check_cursor_timer_needed(ec))
1572 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1576 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1577 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1579 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1581 if (_e_comp_wl_check_cursor_timer_needed(ec))
1582 _e_comp_wl_cursor_move_timer_control(ec);
1586 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1591 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1593 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1594 if (e_object_is_del(E_OBJECT(ec))) return;
1595 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1596 if (!surface) return;
1597 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1599 e_comp_wl->ptr.button = BTN_LEFT;
1601 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1605 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1607 E_Client *ec = data;
1608 Evas_Event_Mouse_Down *ev = event;
1609 Evas_Device *dev = NULL;
1610 const Evas_Device *seat_dev;
1611 const char *dev_name, *seat_name;
1612 E_Comp_Config *comp_conf = NULL;
1615 if (e_object_is_del(E_OBJECT(ec))) return;
1618 dev_name = evas_device_description_get(dev);
1620 seat_dev = evas_device_parent_get(dev);
1621 seat_name = evas_device_name_get(seat_dev);
1623 comp_conf = e_comp_config_get();
1624 if (comp_conf && comp_conf->input_log_enable)
1625 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1626 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1627 dev_name, seat_name);
1629 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1631 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1633 e_comp_wl->touch.faked_ec = ec;
1636 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1637 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1638 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1640 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1641 e_comp_wl->touch.pressed |= (1 << 0);
1645 if (_e_comp_wl_check_cursor_timer_needed(ec))
1647 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1651 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1652 WL_POINTER_BUTTON_STATE_PRESSED);
1654 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1657 need_send_released = EINA_TRUE;
1661 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1663 E_Client *ec = data;
1664 Evas_Event_Mouse_Up *ev = event;
1665 Evas_Device *dev = NULL;
1666 const Evas_Device *seat_dev;
1667 const char *dev_name, *seat_name;;
1668 Evas_Event_Flags flags;
1669 E_Comp_Config *comp_conf = NULL;
1672 if (ec->cur_mouse_action) return;
1673 if (e_object_is_del(E_OBJECT(ec))) return;
1675 if (!need_send_released)
1677 need_send_motion = EINA_TRUE;
1681 dev_name = evas_device_description_get(dev);
1683 seat_dev = evas_device_parent_get(dev);
1684 seat_name = evas_device_name_get(seat_dev);
1685 flags = evas_event_default_flags_get(evas);
1687 comp_conf = e_comp_config_get();
1688 if (comp_conf && comp_conf->input_log_enable)
1689 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1690 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1691 dev_name, seat_name);
1693 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1695 e_comp_wl->touch.pressed &= ~(1 << 0);
1697 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1698 e_comp_wl->touch.faked_ec = NULL;
1701 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1703 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1705 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1708 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1709 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1710 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1714 if (_e_comp_wl_check_cursor_timer_needed(ec))
1716 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1720 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1721 WL_POINTER_BUTTON_STATE_RELEASED);
1723 if (_e_comp_wl_check_cursor_timer_needed(ec))
1724 _e_comp_wl_cursor_move_timer_control(ec);
1728 need_send_released = EINA_FALSE;
1732 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1734 struct wl_resource *res;
1735 struct wl_client *wc;
1740 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1742 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1745 dir = -wl_fixed_from_int(abs(z));
1747 dir = wl_fixed_from_int(z);
1750 if (e_object_is_del(E_OBJECT(ec))) return;
1751 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1752 if (!surface) return;
1754 wc = wl_resource_get_client(surface);
1755 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1757 if (!e_comp_wl_input_pointer_check(res)) continue;
1758 if (wl_resource_get_client(res) != wc) continue;
1759 wl_pointer_send_axis(res, timestamp, axis, dir);
1764 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1767 Evas_Event_Mouse_Wheel *ev;
1770 if (!(ec = data)) return;
1771 if (ec->cur_mouse_action) return;
1772 if (e_object_is_del(E_OBJECT(ec))) return;
1773 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1774 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1775 if (!surface) return;
1777 if (!eina_list_count(e_comp_wl->ptr.resources))
1780 if (_e_comp_wl_check_cursor_timer_needed(ec))
1782 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1786 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1788 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1790 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1792 if (_e_comp_wl_check_cursor_timer_needed(ec))
1793 _e_comp_wl_cursor_move_timer_control(ec);
1798 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1800 E_Client *ec = data;
1801 Evas_Event_Multi_Down *ev = event;
1802 Evas_Device *dev = NULL;
1803 const Evas_Device *seat_dev;
1804 const char *dev_name, *seat_name;
1805 Evas_Device_Class dev_class;
1806 E_Comp_Config *comp_conf = NULL;
1809 if (e_object_is_del(E_OBJECT(ec))) return;
1810 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1811 if (!surface) return;
1813 /* Do not deliver emulated single touch events to client */
1814 if (ev->device == 0) return;
1817 dev_name = evas_device_description_get(dev);
1818 e_comp_wl->touch.faked_ec = ec;
1820 seat_dev = evas_device_parent_get(dev);
1821 seat_name = evas_device_name_get(seat_dev);
1823 comp_conf = e_comp_config_get();
1824 if (comp_conf && comp_conf->input_log_enable)
1825 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1826 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1827 dev_name, seat_name);
1829 if (dev && dev_name)
1831 dev_class = evas_device_class_get(dev);
1832 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1833 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1836 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1837 e_comp_wl->touch.pressed |= (1 << ev->device);
1841 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1843 E_Client *ec = data;
1844 Evas_Event_Multi_Up *ev = event;
1845 Evas_Device *dev = NULL;
1846 const Evas_Device *seat_dev;
1847 const char *dev_name, *seat_name;
1848 Evas_Device_Class dev_class;
1849 Evas_Event_Flags flags;
1850 E_Comp_Config *comp_conf = NULL;
1853 if (e_object_is_del(E_OBJECT(ec))) return;
1854 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1855 if (!surface) return;
1857 /* Do not deliver emulated single touch events to client */
1858 if (ev->device == 0) return;
1860 flags = evas_event_default_flags_get(evas);
1862 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1863 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1864 e_comp_wl->touch.faked_ec = NULL;
1866 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1869 dev_name = evas_device_description_get(dev);
1871 seat_dev = evas_device_parent_get(dev);
1872 seat_name = evas_device_name_get(seat_dev);
1874 comp_conf = e_comp_config_get();
1875 if (comp_conf && comp_conf->input_log_enable)
1876 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1877 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1878 dev_name, seat_name);
1880 if (dev && dev_name)
1882 dev_class = evas_device_class_get(dev);
1883 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1884 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1887 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1891 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1893 E_Client *ec = data;
1894 Evas_Event_Multi_Move *ev = event;
1895 Evas_Device *dev = NULL;
1896 const char *dev_name;
1897 Evas_Device_Class dev_class;
1900 if (e_object_is_del(E_OBJECT(ec))) return;
1901 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1902 if (!surface) return;
1904 /* Do not deliver emulated single touch events to client */
1905 if (ev->device == 0) return;
1907 e_comp_wl->touch.faked_ec = ec;
1909 if (e_comp_wl->touch.pressed & (1 << ev->device))
1912 if (dev && (dev_name = evas_device_description_get(dev)))
1914 dev_class = evas_device_class_get(dev);
1915 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1916 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1919 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1924 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1927 char *file, buff[PATH_MAX];
1934 n = (getpriority(PRIO_PROCESS, pid) + adj);
1938 setpriority(PRIO_PROCESS, pid, n);
1941 use_adj = EINA_TRUE;
1943 if (!do_child) return;
1945 files = ecore_file_ls("/proc");
1946 EINA_LIST_FREE(files, file)
1948 if (!isdigit(file[0]))
1951 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1952 if ((f = fopen(buff, "r")))
1956 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1958 if (num_read == 2 && ppid == pid)
1959 _e_comp_wl_client_priority_adjust(pid2, set,
1961 adj_child, do_child);
1969 _e_comp_wl_client_priority_raise(E_Client *ec)
1971 if (!e_config->priority_control) return;
1972 if (ec->netwm.pid <= 0) return;
1973 if (ec->netwm.pid == getpid()) return;
1974 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1975 e_config->priority - 1, -1,
1976 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1980 _e_comp_wl_client_priority_normal(E_Client *ec)
1982 if (!e_config->priority_control) return;
1983 if (ec->netwm.pid <= 0) return;
1984 if (ec->netwm.pid == getpid()) return;
1985 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1986 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1990 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1993 E_Comp_Wl_Key_Data *k;
1994 struct wl_resource *res;
1998 if (!ec) return EINA_FALSE;
1999 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2000 if (!ec->comp_data) return EINA_FALSE;
2002 ec->comp_data->on_focus_timer = NULL;
2003 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2004 if (!e_comp_wl->kbd.focused)
2006 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2009 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2011 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2012 t = ecore_time_unix_get();
2014 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2015 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2016 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2018 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2020 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2021 wl_keyboard_send_key(res, serial, t,
2022 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2025 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2026 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2030 /* It is called in the following cases:
2031 * When a normal ec->frame has focus.
2032 * Or launching image ec is replaced to the real ec.
2035 e_comp_wl_feed_focus_in(E_Client *ec)
2038 struct wl_resource *res;
2039 struct wl_client *wc;
2043 if (e_object_is_del(E_OBJECT(ec))) return;
2044 if (ec->iconic) return;
2046 /* block spurious focus events */
2047 focused = e_client_focused_get();
2048 if ((focused) && (ec != focused)) return;
2050 /* raise client priority */
2051 _e_comp_wl_client_priority_raise(ec);
2052 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2053 if (!surface) return;
2055 wc = wl_resource_get_client(surface);
2057 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2058 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2060 if (wl_resource_get_client(res) == wc)
2062 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2063 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2064 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2065 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2068 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2070 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2071 if (!e_comp_wl->kbd.focused)
2073 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2076 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2078 e_comp_wl->kbd.focus = surface;
2079 e_comp_wl_input_keyboard_enter_send(ec);
2080 e_comp_wl_data_device_keyboard_focus_set();
2081 ec->comp_data->on_focus_timer =
2082 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2083 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2084 int rotation = ec->e.state.rot.ang.curr;
2085 e_pointer_rotation_set(e_comp->pointer, rotation);
2089 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2092 if (!(ec = data)) return;
2093 e_comp_wl_feed_focus_in(ec);
2097 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2100 struct wl_resource *res;
2102 E_Comp_Wl_Key_Data *k;
2106 if (!(ec = data)) return;
2108 if (!ec->comp_data) return;
2110 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2112 /* lower client priority */
2113 if (!e_object_is_del(data))
2114 _e_comp_wl_client_priority_normal(ec);
2117 /* update keyboard modifier state */
2118 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2119 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2120 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2122 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2124 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2125 if (!surface) return;
2127 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2128 if (!eina_list_count(e_comp_wl->kbd.resources))
2130 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2134 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2136 /* send keyboard_leave to all keyboard resources */
2137 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2138 t = ecore_time_unix_get();
2140 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2141 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2142 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2144 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2146 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2147 wl_keyboard_send_key(res, serial, t,
2148 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2150 wl_keyboard_send_leave(res, serial, surface);
2151 e_comp_wl->kbd.focused =
2152 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2154 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2155 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2159 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2163 if (!(ec = data)) return;
2165 if (!ec->comp_data->shell.configure_send) return;
2167 /* TODO: calculate x, y with transfrom object */
2168 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2172 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2173 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2174 if (e_comp_object_frame_exists(ec->frame))
2175 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2177 switch (ec->resize_mode)
2179 case E_POINTER_RESIZE_TL:
2180 case E_POINTER_RESIZE_L:
2181 case E_POINTER_RESIZE_BL:
2182 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2183 ec->mouse.current.mx;
2185 case E_POINTER_RESIZE_TR:
2186 case E_POINTER_RESIZE_R:
2187 case E_POINTER_RESIZE_BR:
2188 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2193 switch (ec->resize_mode)
2195 case E_POINTER_RESIZE_TL:
2196 case E_POINTER_RESIZE_T:
2197 case E_POINTER_RESIZE_TR:
2198 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2199 ec->mouse.current.my;
2201 case E_POINTER_RESIZE_BL:
2202 case E_POINTER_RESIZE_B:
2203 case E_POINTER_RESIZE_BR:
2204 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2209 w = E_CLAMP(w, 1, w);
2210 h = E_CLAMP(h, 1, h);
2211 e_client_resize_limit(ec, &w, &h);
2213 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2215 else if ((!ec->fullscreen) && (!ec->maximized) &&
2216 (!ec->comp_data->maximize_pre))
2220 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2221 if ((pw != ec->w) || (ph != ec->h))
2223 _e_comp_wl_configure_send(ec, 1, 1);
2227 if (ec->comp_data->sub.below_obj)
2228 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2232 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2234 E_Client *ec = data;
2236 ec->comp_data->maximize_pre = 1;
2240 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2242 E_Client *ec = data;
2245 if (e_object_is_del(E_OBJECT(ec))) return;
2247 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2248 e_client_shell_configure_send(ec, 0, w, h);
2250 ec->comp_data->maximize_pre = 0;
2254 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2256 E_Client *ec = data;
2258 ec->comp_data->maximize_pre = 1;
2262 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2264 E_Client *ec = data;
2266 if (e_object_is_del(E_OBJECT(ec))) return;
2268 /* check for wayland pixmap */
2270 if (ec->comp_data->shell.configure_send)
2271 _e_comp_wl_configure_send(ec, 0, 0);
2273 ec->comp_data->maximize_pre = 0;
2277 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2279 E_Client *ec = data;
2281 if (e_object_is_del(E_OBJECT(ec))) return;
2283 /* check for wayland pixmap */
2285 if (ec->comp_data->shell.configure_send)
2286 _e_comp_wl_configure_send(ec, 0, 1);
2288 ec->comp_data->maximize_pre = 0;
2292 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2294 E_Client *ec = data;
2296 if (e_object_is_del(E_OBJECT(ec))) return;
2298 /* check for wayland pixmap */
2300 if (ec->comp_data->shell.configure_send)
2301 _e_comp_wl_configure_send(ec, 0, 0);
2303 ec->comp_data->maximize_pre = 0;
2307 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2311 if (!(ec = data)) return;
2313 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2315 e_object_del(E_OBJECT(ec));
2317 _e_comp_wl_focus_check();
2319 /* TODO: Delete request send ??
2320 * NB: No such animal wrt wayland */
2324 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2328 if (!(ec = data)) return;
2330 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2333 if (ec->comp_data->reparented)
2334 e_client_comp_hidden_set(ec, EINA_TRUE);
2337 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2338 if (ec->visible) evas_object_hide(ec->frame);
2339 if (!ec->internal) e_object_del(E_OBJECT(ec));
2341 _e_comp_wl_focus_check();
2345 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2349 if (!(ec = data)) return;
2351 e_client_shell_ping(ec);
2355 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2360 if (!(ec = data)) return;
2361 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2362 if (ec->netwm.opacity == a) return;
2363 ec->netwm.opacity = a;
2364 ec->netwm.opacity_changed = EINA_TRUE;
2368 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2370 Eina_Rectangle *damage_rect = NULL;
2371 Eina_Rectangle *dmg = NULL;
2372 Eina_List *l = NULL;
2374 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2375 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2378 if (!buffer->tbm_surface) return;
2382 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2386 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2387 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2390 eina_rectangle_union(damage_rect, dmg);
2395 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2396 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2399 tbm_surface_internal_set_damage(buffer->tbm_surface,
2405 eina_rectangle_free(damage_rect);
2409 _e_comp_wl_client_evas_init(E_Client *ec)
2411 if (!ec || !ec->comp_data) return;
2412 if (ec->comp_data->evas_init) return;
2414 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2415 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2416 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2419 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2420 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2421 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2422 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2423 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2424 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2426 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2427 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2428 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2430 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2431 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2435 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2436 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2437 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2438 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2439 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2440 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2441 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2444 /* setup delete/kill callbacks */
2445 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2446 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2448 /* setup ping callback */
2449 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2450 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2452 ec->comp_data->evas_init = EINA_TRUE;
2456 _e_comp_wl_client_evas_deinit(E_Client *ec)
2458 if (!ec || !ec->comp_data) return;
2459 if (!ec->comp_data->evas_init) return;
2461 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2462 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2463 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2465 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2466 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2467 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2468 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2469 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2470 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2472 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2473 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2474 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2476 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2477 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2481 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2482 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2483 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2484 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2485 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2486 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2487 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2490 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2491 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2493 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2494 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2496 ec->comp_data->evas_init = EINA_FALSE;
2500 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2504 E_Comp_Screen *e_comp_screen;
2505 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2507 if (!e_comp) return ECORE_CALLBACK_RENEW;
2508 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2509 e_comp_screen = e_comp->e_comp_screen;
2511 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2513 if (!eout->config.enabled)
2515 e_comp_wl_output_remove(eout->id);
2519 switch (eout->config.rotation)
2522 transform = WL_OUTPUT_TRANSFORM_90;
2525 transform = WL_OUTPUT_TRANSFORM_180;
2528 transform = WL_OUTPUT_TRANSFORM_270;
2532 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2536 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2538 eout->config.geom.x, eout->config.geom.y,
2539 eout->config.geom.w, eout->config.geom.h,
2540 eout->info.size.w, eout->info.size.h,
2541 eout->config.mode.refresh, 0, transform))
2542 ERR("Could not initialize screen %s", eout->info.name);
2545 return ECORE_CALLBACK_RENEW;
2549 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2553 /* try to get the client from the object */
2554 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2555 return ECORE_CALLBACK_RENEW;
2557 /* check for client being deleted */
2558 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2560 /* check for wayland pixmap */
2561 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2562 return ECORE_CALLBACK_RENEW;
2564 /* if we have not setup evas callbacks for this client, do it */
2565 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2567 return ECORE_CALLBACK_RENEW;
2571 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2575 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2576 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2578 if (e_comp_wl->selection.target &&
2581 struct wl_resource *res;
2583 E_Client *ec = NULL;
2584 E_Client *legacy_target = e_comp_wl->selection.target;
2585 int device_id = e_comp_wl_data_current_device_id_get();
2589 e_comp_wl_data_current_device_id_set(ev->multi.device);
2591 else if (device_id != ev->multi.device)
2593 return ECORE_CALLBACK_RENEW;
2596 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2597 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2599 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2600 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2602 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2603 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2605 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2606 (ec != legacy_target))
2608 e_comp_wl_data_device_send_leave(legacy_target);
2609 e_comp_wl_data_device_send_enter(ec);
2612 if (e_comp_wl->drag)
2613 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2615 if (e_client_transform_core_enable_get(ec))
2617 int trans_x, trans_y;
2618 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2619 x = trans_x - ec->client.x;
2620 y = trans_y - ec->client.y;
2624 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2629 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2632 return ECORE_CALLBACK_RENEW;
2636 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2639 struct wl_resource *surface;
2640 struct wl_resource *res;
2641 struct wl_client *wc;
2643 E_Comp_Config *comp_conf;
2645 ec = e_comp_wl->ptr_constraints.ec;
2646 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2648 surface = e_comp_wl_client_surface_get(ec);
2649 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2651 wc = wl_resource_get_client(surface);
2653 comp_conf = e_comp_config_get();
2655 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2657 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2658 if (wl_resource_get_client(res) != wc) continue;
2660 if (comp_conf && comp_conf->input_log_enable)
2661 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2662 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2663 e_client_util_name_get(ec));
2665 zwp_relative_pointer_v1_send_relative_motion(res,
2667 (uint32_t)(ev->timestamp),
2668 wl_fixed_from_int(ev->dx),
2669 wl_fixed_from_int(ev->dy),
2670 wl_fixed_from_int(ev->dx_unaccel),
2671 wl_fixed_from_int(ev->dy_unaccel));
2674 return ECORE_CALLBACK_DONE;
2678 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2680 _e_comp_wl_touch_cancel();
2682 return ECORE_CALLBACK_PASS_ON;
2686 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2688 if (!ev) return ECORE_CALLBACK_PASS_ON;
2690 E_Zone *zone = ev->zone;
2692 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2693 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2695 if (!e_zone_is_displaying(zone))
2696 _e_comp_wl_touch_cancel();
2698 return ECORE_CALLBACK_PASS_ON;
2702 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2704 E_Client *ec = ev->ec;
2705 E_Comp_Wl_Buffer_Viewport *vp;
2707 if (!ec) return ECORE_CALLBACK_PASS_ON;
2708 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2709 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2710 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2711 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2713 vp = &ec->comp_data->scaler.buffer_viewport;
2714 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2716 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2718 return ECORE_CALLBACK_PASS_ON;
2722 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2724 E_Client *ec = ev->ec;
2725 E_Comp_Wl_Buffer_Viewport *vp;
2727 if (!ec) return ECORE_CALLBACK_PASS_ON;
2728 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2729 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2730 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2732 vp = &ec->comp_data->scaler.buffer_viewport;
2733 vp->wait_for_transform_change = 0;
2735 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2737 return ECORE_CALLBACK_PASS_ON;
2741 _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)
2743 E_Client *focused_ec;
2746 focused_ec = e_client_focused_get();
2747 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2749 rotation = focused_ec->e.state.rot.ang.curr;
2750 e_pointer_rotation_set(e_comp->pointer, rotation);
2752 return ECORE_CALLBACK_PASS_ON;
2756 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2759 Eina_Rectangle *window;
2764 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2766 if ((prev_w != state->bw) ||
2767 (prev_h != state->bh))
2769 ec->changes.buf_size = EINA_TRUE;
2772 if (e_comp_object_frame_exists(ec->frame)) return;
2773 window = &ec->comp_data->shell.window;
2774 if ((!ec->borderless) && /* FIXME temporarily added this check code
2775 * to prevent updating E_Client's size by frame */
2776 (window->x || window->y || window->w || window->h))
2778 e_comp_object_frame_geometry_set(ec->frame,
2780 (window->x + window->w) - state->bw,
2782 (window->y + window->h) - state->bh);
2785 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2789 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2791 E_Comp_Wl_Surface_State *state;
2794 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2795 state->buffer = NULL;
2799 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2801 state->new_attach = EINA_FALSE;
2802 state->buffer = NULL;
2803 state->buffer_destroy_listener.notify =
2804 _e_comp_wl_surface_state_cb_buffer_destroy;
2805 state->sx = state->sy = 0;
2807 state->input = eina_tiler_new(w, h);
2808 eina_tiler_tile_size_set(state->input, 1, 1);
2810 state->opaque = eina_tiler_new(w, h);
2811 eina_tiler_tile_size_set(state->opaque, 1, 1);
2813 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2814 state->buffer_viewport.buffer.scale = 1;
2815 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2816 state->buffer_viewport.surface.width = -1;
2817 state->buffer_viewport.changed = 0;
2819 e_presentation_time_container_init(&state->presentation_container);
2823 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2825 struct wl_resource *cb;
2826 Eina_Rectangle *dmg;
2828 EINA_LIST_FREE(state->frames, cb)
2829 wl_resource_destroy(cb);
2831 EINA_LIST_FREE(state->damages, dmg)
2832 eina_rectangle_free(dmg);
2834 EINA_LIST_FREE(state->buffer_damages, dmg)
2835 eina_rectangle_free(dmg);
2837 if (state->opaque) eina_tiler_free(state->opaque);
2838 state->opaque = NULL;
2840 if (state->input) eina_tiler_free(state->input);
2841 state->input = NULL;
2843 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2844 state->buffer = NULL;
2846 e_presentation_time_container_finish(&state->presentation_container);
2850 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2852 if (state->buffer == buffer) return;
2854 wl_list_remove(&state->buffer_destroy_listener.link);
2855 state->buffer = buffer;
2857 wl_signal_add(&state->buffer->destroy_signal,
2858 &state->buffer_destroy_listener);
2862 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2864 Eina_Rectangle *dmg;
2865 Eina_Bool placed = EINA_TRUE;
2869 E_Comp_Wl_Buffer *buffer;
2870 struct wl_resource *cb;
2872 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2873 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2878 if ((ec->internal) ||
2879 (cdata->shell.surface && state->new_attach))
2883 e_comp->new_clients++;
2884 ELOGF("COMP", "Unignore", ec);
2885 e_client_unignore(ec);
2889 /* buffer transform */
2890 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2893 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2895 /* when buffer is transformed, we have to apply the new evas-map */
2896 state->buffer_viewport.changed = EINA_TRUE;
2898 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2900 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2902 if (transform_change == vp->wait_for_transform_change)
2903 vp->wait_for_transform_change = 0;
2905 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2906 // triggered by E_CLIENT_HOOK calls at those file.
2907 zone = e_comp_zone_find_by_ec(ec);
2910 eout = e_output_find(zone->output_id);
2911 if (eout && eout->hwc)
2913 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2915 if (e_comp_is_on_overlay(ec))
2916 e_comp_hwc_client_end(ec, __FUNCTION__);
2922 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2923 cdata->scaler.buffer_viewport = state->buffer_viewport;
2925 if (state->new_attach)
2927 e_comp_wl_surface_attach(ec, state->buffer);
2930 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2931 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2933 _e_comp_wl_surface_state_buffer_set(state, NULL);
2935 if ((state->new_attach) ||
2936 (state->buffer_viewport.changed))
2938 _e_comp_wl_surface_state_size_update(ec, state);
2939 e_comp_wl_map_size_cal_from_viewport(ec);
2941 /* update the position */
2942 if (ec->changes.pos)
2944 e_comp_object_frame_xy_unadjust(ec->frame,
2954 if (ec->new_client) placed = ec->placed;
2956 if (!ec->lock_client_size)
2961 ec->client.w = state->bw;
2962 ec->client.h = state->bh;
2964 e_comp_object_frame_wh_adjust(ec->frame,
2965 ec->client.w, ec->client.h,
2967 e_client_size_set(ec, nw, nh);
2969 if ((w != ec->w) || (h != ec->h))
2971 ec->changes.size = 1;
2976 if (ec->changes.buf_size)
2978 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2979 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2980 ec->changes.buf_size = EINA_FALSE;
2982 if (ec->move_after_resize)
2984 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2985 ec->move_after_resize = EINA_FALSE;
2990 /* map or unmap ec */
2991 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2992 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2993 if (!pixmap_usable || hide_by_request)
2998 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
3003 if ((cdata->sub.below_obj) &&
3004 (evas_object_visible_get(cdata->sub.below_obj)))
3006 evas_object_hide(cdata->sub.below_obj);
3014 if ((cdata->sub.below_obj) &&
3015 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3016 (evas_object_visible_get(ec->frame)))
3018 evas_object_show(cdata->sub.below_obj);
3022 if ((state->new_attach) ||
3023 (state->buffer_viewport.changed))
3025 if ((e_comp_wl->drag) &&
3026 (e_comp_wl->drag_client) &&
3027 (e_comp_wl->drag_client == ec))
3029 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3031 e_drag_move(e_comp_wl->drag,
3033 e_comp_wl->drag->y);
3035 e_drag_resize(e_comp_wl->drag,
3036 state->bw, state->bh);
3038 else if ((cdata->shell.surface) &&
3039 (cdata->shell.configure))
3041 e_comp_wl_commit_sync_configure(ec);
3043 else if (!e_client_video_hw_composition_check(ec))
3045 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3050 ec->placed = placed;
3051 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3055 if (cdata->scaler.buffer_viewport.changed)
3056 e_comp_wl_map_apply(ec);
3058 /* resize transform object */
3059 if (ec->transformed)
3060 e_client_transform_update(ec);
3064 state->new_attach = EINA_FALSE;
3066 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3068 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3069 wl_resource_destroy(cb);
3072 /* insert state frame callbacks into comp_data->frames
3073 * NB: This clears state->frames list */
3074 cdata->frames = eina_list_merge(cdata->frames,
3076 state->frames = NULL;
3078 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3079 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3080 &state->presentation_container);
3082 buffer = e_pixmap_resource_get(ec->pixmap);
3084 /* put state damages into surface */
3087 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3088 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3090 if ((cdata->buffer_ref.buffer) &&
3091 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3092 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3094 e_comp_object_damage(ec->frame,
3096 cdata->buffer_ref.buffer->w,
3097 cdata->buffer_ref.buffer->h);
3102 Eina_List *damages = NULL;
3105 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3107 if (eina_list_count(state->buffer_damages))
3109 EINA_LIST_FREE(state->buffer_damages, dmg)
3112 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3113 e_comp_wl_output_buffer_transform_get(ec),
3115 dmg->x, dmg->y, dmg->w, dmg->h,
3116 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3117 damages = eina_list_append(damages, dmg);
3121 EINA_LIST_FREE(state->damages, dmg)
3122 damages = eina_list_append(damages, dmg);
3124 EINA_LIST_FREE(damages, dmg)
3126 /* not creating damage for ec that shows a underlay video */
3127 if (state->buffer_viewport.changed ||
3128 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3129 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3130 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3132 eina_rectangle_free(dmg);
3137 /* put state opaque into surface */
3138 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3141 Eina_Rectangle *rect;
3144 itr = eina_tiler_iterator_new(state->opaque);
3145 EINA_ITERATOR_FOREACH(itr, rect)
3149 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3150 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3151 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3155 eina_iterator_free(itr);
3158 /* put state input into surface */
3159 if ((state->input) &&
3160 (!eina_tiler_empty(state->input)) &&
3163 Eina_Tiler *src, *tmp;
3167 tmp = eina_tiler_new(sw, sh);
3168 eina_tiler_tile_size_set(tmp, 1, 1);
3170 eina_tiler_rect_add(tmp,
3171 &(Eina_Rectangle){0, 0, sw, sh});
3173 if ((src = eina_tiler_intersection(state->input, tmp)))
3175 Eina_Rectangle *rect;
3178 e_comp_object_input_objs_del(ec->frame);
3179 itr = eina_tiler_iterator_new(src);
3180 EINA_ITERATOR_FOREACH(itr, rect)
3182 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3183 ec, rect->x, rect->y, rect->w, rect->h,
3184 ec->w, ec->h, state->bw, state->bh);
3185 e_comp_object_input_area_set(ec->frame,
3190 eina_iterator_free(itr);
3191 eina_tiler_free(src);
3194 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3196 eina_tiler_free(tmp);
3198 /* clear input tiler */
3199 eina_tiler_clear(state->input);
3202 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3204 if ((cdata->video_client) &&
3206 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3207 (e_comp->wl_comp_data->available_hw_accel.underlay))
3209 e_pixmap_image_clear(ec->pixmap, 1);
3212 state->buffer_viewport.changed = 0;
3214 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3217 ec->exp_iconify.buffer_flush &&
3218 e_policy_visibility_client_is_iconic(ec))
3220 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3225 _e_comp_wl_surface_render_stop(E_Client *ec)
3227 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3228 //if ((!ec->internal) && (!e_comp_gl_get()))
3231 /* check if internal animation is running */
3232 if (e_comp_object_is_animating(ec->frame)) return;
3233 /* check if external animation is running */
3234 if (evas_object_data_get(ec->frame, "effect_running")) return;
3236 evas_object_hide(ec->frame);
3240 e_comp_wl_client_surface_finish(E_Client *ec)
3242 struct wl_resource *res, *surface;
3243 struct wl_client *surface_client = NULL;
3246 surface = e_comp_wl_client_surface_get(ec);
3249 surface_client = wl_resource_get_client(surface);
3251 if (surface_client &&
3252 (ec == e_client_focused_get()))
3254 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3255 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3257 if (wl_resource_get_client(res) ==
3259 e_comp_wl->kbd.focused =
3260 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3264 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3267 e_comp_wl_client_surface_set(ec, NULL);
3269 ec->comp_data->wl_surface = NULL;
3270 e_pixmap_win_id_del(ec->pixmap);
3272 _e_comp_wl_surface_render_stop(ec);
3273 e_object_del(E_OBJECT(ec));
3277 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3282 char proc[512], pname[512];
3285 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3287 h = fopen(proc, "r");
3290 len = fread(pname, sizeof(char), 512, h);
3292 pname[len - 1] = '\0';
3294 strncpy(pname, "NO NAME", sizeof(pname));
3300 strncpy(pname, "NO NAME", sizeof(pname));
3303 strncpy(name, pname, size);
3307 _e_comp_wl_pname_print(pid_t pid)
3310 char proc[512], pname[512];
3313 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3315 h = fopen(proc, "r");
3318 len = fread(pname, sizeof(char), 512, h);
3320 pname[len - 1] = '\0';
3322 strncpy(pname, "NO NAME", sizeof(pname));
3326 ELOGF("COMP", " |%s", NULL, pname);
3331 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3333 struct wl_client *client = data;
3334 E_Comp_Connected_Client_Info *cinfo;
3337 cinfo = wl_container_of(listener, cinfo, destroy);
3339 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3340 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3342 eai = e_appinfo_find_with_pid(cinfo->pid);
3343 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3346 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3348 wl_list_remove(&cinfo->destroy.link);
3349 eina_stringshare_del(cinfo->name);
3354 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3356 E_Comp_Connected_Client_Info *cinfo;
3358 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3359 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3361 cinfo->name = eina_stringshare_add(name);
3365 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3366 wl_client_add_destroy_listener(client, &cinfo->destroy);
3367 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3369 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3373 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3375 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3377 /* send configure */
3378 if (ec->comp_data->shell.configure_send)
3380 if (ec->comp_data->shell.surface)
3381 _e_comp_wl_configure_send(ec, 0, 0);
3384 e_comp_wl->kbd.focus = ec->comp_data->surface;
3388 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3390 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3392 /* send configure */
3393 if (ec->comp_data->shell.configure_send)
3395 if (ec->comp_data->shell.surface)
3396 _e_comp_wl_configure_send(ec, 0, 0);
3399 _e_comp_wl_focus_check();
3401 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3402 e_comp_wl->kbd.focus = NULL;
3406 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3408 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3409 if (ec->keyboard_resizing) return;
3411 /* do nothing currently */
3416 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3418 if (e_object_is_del(E_OBJECT(ec))) return;
3419 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3421 e_comp_wl->resize.edges = 0;
3422 e_comp_wl->resize.resource = NULL;
3426 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3428 if (e_object_is_del(E_OBJECT(ec))) return;
3429 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3433 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3436 int ratio_w, ratio_h;
3438 phys_w = output->phys_width;
3439 phys_h = output->phys_height;
3441 if (e_config->configured_output_resolution.use)
3443 // change the configured physical size(mm) of the output
3444 if (output->w != res_w)
3446 ratio_w = res_w / output->w;
3447 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3450 if (output->h != res_h)
3452 ratio_h = res_h / output->h;
3453 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3456 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3459 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3460 NULL, res_w, res_h, phys_w, phys_h, pid);
3462 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3463 wl_output_send_scale(resource, output->scale);
3465 wl_output_send_geometry(resource, output->x, output->y,
3467 output->subpixel, output->make ?: "",
3468 output->model ?: "", output->transform);
3470 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3471 res_w, res_h, output->refresh);
3473 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3474 wl_output_send_done(resource);
3478 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3480 E_Comp_Wl_Output *output;
3482 if (!(output = wl_resource_get_user_data(resource))) return;
3484 output->resources = eina_list_remove(output->resources, resource);
3488 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3490 E_Comp_Wl_Output *output;
3491 struct wl_resource *resource;
3492 E_Appinfo *eai = NULL;
3496 if (!(output = data)) return;
3499 wl_resource_create(client, &wl_output_interface, version, id);
3502 wl_client_post_no_memory(client);
3506 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3507 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3509 output->resources = eina_list_append(output->resources, resource);
3511 wl_resource_set_implementation(resource, NULL, output,
3512 _e_comp_wl_cb_output_unbind);
3513 wl_resource_set_user_data(resource, output);
3515 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3516 if (e_config->configured_output_resolution.use)
3518 wl_client_get_credentials(client, &pid, NULL, NULL);
3521 res_w = e_config->configured_output_resolution.w;
3522 res_h = e_config->configured_output_resolution.h;
3526 eai = e_appinfo_find_with_pid(pid);
3529 res_w = e_config->configured_output_resolution.w;
3530 res_h = e_config->configured_output_resolution.h;
3534 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3536 res_w = e_config->configured_output_resolution.w;
3537 res_h = e_config->configured_output_resolution.h;
3541 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3550 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3554 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3557 Evas_GL *evasgl = NULL;
3558 Evas_GL_API *glapi = NULL;
3559 Evas_GL_Context *ctx = NULL;
3560 Evas_GL_Surface *sfc = NULL;
3561 Evas_GL_Config *cfg = NULL;
3563 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3565 if (!e_comp_gl_get()) return;
3567 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3568 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3570 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3571 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3573 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3574 * then we should get evas from ecore_evas.
3577 evas = e_comp->evas;
3579 evas = ecore_evas_get(e_comp->ee);
3581 evasgl = evas_gl_new(evas);
3582 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3584 glapi = evas_gl_api_get(evasgl);
3585 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3586 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3588 cfg = evas_gl_config_new();
3589 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3591 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3592 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3594 ctx = evas_gl_context_create(evasgl, NULL);
3595 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3597 res = evas_gl_make_current(evasgl, sfc, ctx);
3598 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3600 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3601 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3603 evas_gl_config_free(cfg);
3605 evas_gl->gl = evasgl;
3606 evas_gl->glapi = glapi;
3607 evas_gl->glsfc = sfc;
3608 evas_gl->glctx = ctx;
3610 e_comp_wl->evas_gl = evas_gl;
3612 /* for native surface */
3615 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3620 evas_gl_config_free(cfg);
3621 evas_gl_make_current(evasgl, NULL, NULL);
3622 evas_gl_context_destroy(evasgl, ctx);
3623 evas_gl_surface_destroy(evasgl, sfc);
3624 evas_gl_free(evasgl);
3631 _e_comp_wl_gl_popup_cb_close(void *data,
3632 Evas_Object *obj EINA_UNUSED,
3633 void *event_info EINA_UNUSED)
3635 evas_object_del(data);
3639 _e_comp_wl_gl_popup_cb_focus(void *data,
3640 Evas_Object *obj EINA_UNUSED,
3641 void *event_info EINA_UNUSED)
3643 elm_object_focus_set(data, EINA_TRUE);
3648 _e_comp_wl_gl_idle(void *data)
3652 /* show warning window to notify failure of gl init */
3655 Evas_Object *win, *bg, *popup, *btn;
3657 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3658 elm_win_title_set(win, "Compositor Warning");
3659 elm_win_autodel_set(win, EINA_TRUE);
3660 elm_win_borderless_set(win, EINA_TRUE);
3661 elm_win_role_set(win, "notification-low");
3662 elm_win_alpha_set(win, EINA_TRUE);
3664 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3665 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3666 elm_win_resize_object_add(win, bg);
3667 evas_object_color_set(bg, 125, 125, 125, 125);
3668 evas_object_show(bg);
3670 popup = elm_popup_add(win);
3671 elm_object_text_set(popup,
3672 _( "Your screen does not support OpenGL.<br>"
3673 "Falling back to software engine."));
3674 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3676 btn = elm_button_add(popup);
3677 elm_object_text_set(btn, "Close");
3678 elm_object_part_content_set(popup, "button1", btn);
3679 evas_object_show(btn);
3681 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3682 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3684 evas_object_show(popup);
3685 evas_object_show(win);
3689 return ECORE_CALLBACK_CANCEL;
3693 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3695 struct wl_client *client = data;
3701 wl_client_get_credentials(client, &pid, &uid, &gid);
3703 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3705 _e_comp_wl_pname_print(pid);
3706 _e_comp_wl_pname_get(pid, name, sizeof(name));
3707 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3711 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3713 char buf[1024] = {0, };
3715 vsnprintf(buf, 1024, fmt, args);
3719 DBG("[libds] %s", buf);
3722 INF("[libds] %s", buf);
3725 ERR("[libds] %s", buf);
3733 _e_comp_wl_display_create(void)
3736 E_Comp_Wl_Data *wl_cdata;
3741 /* create new compositor data */
3742 if (!(comp = E_NEW(E_Comp_Data, 1)))
3744 ERR("Could not create compositor data: %m");
3747 wl_cdata = &comp->base;
3749 /* set compositor wayland data */
3750 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3752 g_mutex_init(&connection_mutex);
3754 /* try to create a wayland display */
3755 if (!(wl_cdata->wl.disp = wl_display_create()))
3757 ERR("Could not create a Wayland display: %m");
3761 /* try to setup wayland socket */
3762 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3764 ERR("Could not create Wayland display socket: %m");
3765 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3769 res = e_comp_socket_init(name);
3770 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3771 PRCTL("[Winsys] change permission and create sym link for %s", name);
3773 /* set wayland display environment variable */
3774 e_env_set("WAYLAND_DISPLAY", name);
3776 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3777 /* wl_cdata->output.scale = e_scale; */
3779 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3781 if (!e_compositor_init(wl_cdata->wl.disp))
3783 ERR("Failed to initialize compositor");
3787 comp->client_created.notify = _e_comp_wl_cb_client_created;
3788 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3790 if (!e_comp_wl_subsurfaces_init())
3792 ERR("Failed to init_subsurfaces");
3793 goto subsurfaces_err;
3796 /* initialize shm mechanism */
3797 wl_display_init_shm(wl_cdata->wl.disp);
3799 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3801 /* try to init data manager */
3802 if (!e_comp_wl_data_manager_init())
3804 ERR("Could not initialize data manager");
3808 /* try to init input */
3809 if (!e_comp_wl_input_init())
3811 ERR("Could not initialize input");
3815 if (e_comp_gl_get())
3816 _e_comp_wl_gl_init(NULL);
3818 /* get the wayland display loop */
3819 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3821 /* get the file descriptor of the wayland event loop */
3822 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3824 /* create a listener for wayland main loop events */
3826 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3827 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3828 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3829 _e_comp_wl_cb_prepare, wl_cdata);
3834 e_comp_wl_data_manager_shutdown();
3836 e_comp_wl_subsurfaces_shutdown();
3838 wl_list_remove(&comp->client_created.link);
3840 e_env_unset("WAYLAND_DISPLAY");
3842 wl_display_destroy(wl_cdata->wl.disp);
3844 g_mutex_clear(&connection_mutex);
3850 _e_comp_wl_gl_shutdown(void)
3852 if (!e_comp_wl->evas_gl) return;
3854 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3856 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3857 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3858 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3859 evas_gl_free(e_comp_wl->evas_gl->gl);
3861 E_FREE(e_comp_wl->evas_gl);
3864 /* public functions */
3867 * Creates and initializes a Wayland compositor with ecore.
3868 * Registers callback handlers for keyboard and mouse activity
3869 * and other client events.
3871 * @returns true on success, false if initialization failed.
3874 e_comp_wl_init(void)
3876 TRACE_DS_BEGIN(COMP_WL:INIT);
3878 /* try to create a wayland compositor */
3879 if (!_e_comp_wl_display_create())
3881 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3886 e_comp_wl_shell_init();
3888 #ifdef HAVE_WAYLAND_TBM
3889 e_comp_wl_tbm_init();
3891 e_comp_wl_remote_surface_init();
3895 e_comp_wl_screenshooter_init();
3897 if (!e_comp_wl_video_init())
3898 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3900 e_comp_wl_viewport_init();
3901 e_comp_wl_capture_init();
3902 e_comp_wl_renderer_init();
3903 _e_comp_wl_move_resize_init();
3904 e_presentation_time_init();
3905 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3908 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3909 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3911 /* add event handlers to catch E events */
3912 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3913 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3914 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3915 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3916 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3917 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3918 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3919 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3920 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3922 /* add hooks to catch e_client events */
3923 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3924 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3925 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3926 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3927 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3929 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3936 e_comp_wl_deferred_job(void)
3938 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3941 /* internal functions */
3943 e_comp_wl_shutdown(void)
3945 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3947 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3949 e_comp_wl_subsurfaces_shutdown();
3951 E_FREE_LIST(handlers, ecore_event_handler_del);
3952 E_FREE_LIST(hooks, e_client_hook_del);
3953 _e_comp_wl_gl_shutdown();
3955 e_blender_shutdown();
3956 e_presentation_time_shutdown();
3957 e_comp_wl_renderer_shutdown();
3958 e_comp_wl_capture_shutdown();
3959 e_comp_wl_viewport_shutdown();
3960 e_comp_wl_video_shutdown();
3961 e_comp_wl_screenshooter_shutdown();
3963 e_comp_wl_remote_surface_shutdown();
3965 e_pixmap_shutdown();
3967 e_wtz_shell_shutdown();
3968 e_comp_wl_shell_shutdown();
3969 e_comp_wl_input_shutdown();
3971 wl_list_remove(&comp->client_created.link);
3974 e_comp->wl_comp_data = NULL;
3978 E_Comp_Wl_Output *output;
3980 if (e_comp_wl->screenshooter.global)
3981 wl_global_destroy(e_comp_wl->screenshooter.global);
3983 EINA_LIST_FREE(e_comp_wl->outputs, output)
3985 if (output->id) eina_stringshare_del(output->id);
3986 if (output->make) eina_stringshare_del(output->make);
3987 if (output->model) eina_stringshare_del(output->model);
3991 /* delete fd handler */
3992 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3994 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3995 cursor_timer_ec = NULL;
3997 /* free allocated data structure */
4003 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4005 e_object_unref(E_OBJECT(ev->ec));
4010 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4013 ev = E_NEW(E_Event_Client, 1);
4016 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4018 /* set usable early because shell module checks this */
4019 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4020 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4022 e_pixmap_resource_set(ec->pixmap, buffer);
4023 e_pixmap_dirty(ec->pixmap);
4024 e_pixmap_refresh(ec->pixmap);
4026 e_comp_wl_map_size_cal_from_buffer(ec);
4027 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4029 /* wm-policy module uses it */
4030 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4033 e_object_ref(E_OBJECT(ec));
4034 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4035 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4039 e_comp_wl_surface_commit(E_Client *ec)
4044 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4045 if (!e_comp_object_damage_exists(ec->frame))
4047 if ((ec->comp_data->video_client) ||
4048 (!e_client_video_hw_composition_check(ec)))
4049 e_pixmap_image_clear(ec->pixmap, 1);
4052 ignored = ec->ignored;
4054 if (e_comp_wl_subsurface_order_commit(ec))
4056 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4057 e_comp_wl_subsurface_restack(topmost);
4058 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4061 ec->ignored = ignored;
4063 if (ec->is_cursor && ec->visible)
4065 /* ignore cursor changes during resize/move I guess */
4066 if (!e_client_action_get())
4068 if (e_comp->pointer)
4070 x = e_comp->pointer->hot.x;
4071 y = e_comp->pointer->hot.y;
4073 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4079 static E_Comp_Wl_Output *
4080 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4083 E_Comp_Wl_Output *output;
4085 EINA_LIST_FOREACH(outputs, l, output)
4087 if (!strcmp(output->id, id))
4095 * Initializes information about one display output.
4097 * Adds or updates the given data about a single display output,
4098 * with an id matching the provided id.
4100 * @param id identification of output to be added or changed
4101 * @param make manufacturer name of the display output
4102 * @param model model name of the display output
4103 * @param x output's top left corner x coordinate
4104 * @param y output's top left corner y coordinate
4105 * @param w output's width in pixels
4106 * @param h output's height in pixels
4107 * @param pw output's physical width in millimeters
4108 * @param ph output's physical height in millimeters
4109 * @param refresh output's refresh rate in mHz
4110 * @param subpixel output's subpixel layout
4111 * @param transform output's rotation and/or mirror transformation
4113 * @returns True if a display output object could be added or updated
4116 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4117 int x, int y, int w, int h, int pw, int ph,
4118 unsigned int refresh, unsigned int subpixel,
4119 unsigned int transform)
4121 E_Comp_Wl_Output *output;
4123 struct wl_resource *resource;
4125 /* retrieve named output; or create it if it doesn't exist */
4126 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4129 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4131 if (id) output->id = eina_stringshare_add(id);
4133 output->make = eina_stringshare_add(make);
4135 output->make = eina_stringshare_add("unknown");
4137 output->model = eina_stringshare_add(model);
4139 output->model = eina_stringshare_add("unknown");
4141 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4144 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4145 2, output, _e_comp_wl_cb_output_bind);
4147 output->resources = NULL;
4148 output->scale = e_scale;
4151 /* update the output details */
4156 output->phys_width = pw;
4157 output->phys_height = ph;
4158 output->refresh = refresh;
4159 output->subpixel = subpixel;
4160 output->transform = transform;
4162 if (output->scale <= 0)
4163 output->scale = e_scale;
4165 /* if we have bound resources, send updates */
4166 EINA_LIST_FOREACH(output->resources, l2, resource)
4168 wl_output_send_geometry(resource,
4169 output->x, output->y,
4171 output->phys_height,
4173 output->make ?: "", output->model ?: "",
4176 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4177 wl_output_send_scale(resource, output->scale);
4179 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4180 output->w, output->h, output->refresh);
4182 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4183 wl_output_send_done(resource);
4190 e_comp_wl_output_remove(const char *id)
4192 E_Comp_Wl_Output *output;
4194 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4197 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4199 /* wl_global_destroy(output->global); */
4201 /* eina_stringshare_del(output->id); */
4202 /* eina_stringshare_del(output->make); */
4203 /* eina_stringshare_del(output->model); */
4210 _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)
4212 struct wl_resource *res;
4214 uint32_t serial, keycode;
4215 struct wl_client *wc = NULL;
4216 E_Comp_Config *comp_conf = NULL;
4217 const char *device_name = NULL;
4219 keycode = (ev->keycode - 8);
4221 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4223 comp_conf = e_comp_config_get();
4225 if (ec && ec->comp_data)
4227 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4230 wc = wl_resource_get_client(surface);
4233 if (e_config->key_input_ttrace_enable)
4235 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4236 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4239 EINA_LIST_FOREACH(key_list, l, res)
4241 if (wl_resource_get_client(res) != wc) continue;
4243 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4244 if (!e_input_thread_mode_get())
4246 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4247 device_name = ecore_device_name_get(ev->dev);
4253 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4254 device_name = e_device_name_get(dev);
4258 if (comp_conf && comp_conf->input_log_enable)
4259 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4261 wl_keyboard_send_key(res, serial, ev->timestamp,
4266 if (e_config->key_input_ttrace_enable)
4269 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4274 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4276 E_Client *ec = NULL;
4278 E_Comp_Wl_Key_Data *end, *k;
4280 if (ev->window != e_comp->ee_win)
4285 keycode = (ev->keycode - 8);
4286 if (!(e_comp_wl = e_comp->wl_comp_data))
4291 #ifndef E_RELEASE_BUILD
4292 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4293 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4294 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4295 eina_streq(ev->key, "BackSpace"))
4301 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4303 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4305 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4307 /* ignore server-generated key repeats */
4308 if (k->key == keycode)
4310 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4315 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4317 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4319 ec = e_client_focused_get();
4320 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4321 if (ec && ec->comp_data && surface)
4323 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4324 if (e_comp_wl->kbd.focused)
4326 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4328 /* A key only sent to clients is added to the list */
4329 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4330 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4332 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4334 DBG("wl_array_add: Out of memory\n");
4335 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4336 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4339 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4343 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4347 /* update modifier state */
4348 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4354 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4356 E_Client *ec = NULL;
4357 uint32_t keycode, delivered_key;
4358 E_Comp_Wl_Key_Data *end, *k;
4360 if (ev->window != e_comp->ee_win)
4365 keycode = (ev->keycode - 8);
4367 if (!(e_comp_wl = e_comp->wl_comp_data))
4372 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4374 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4375 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4377 if (k->key == keycode)
4384 e_comp_wl->kbd.keys.size =
4385 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4387 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4389 /* 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) */
4390 if ((delivered_key) ||
4391 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4393 ec = e_client_focused_get();
4395 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4396 if (e_comp_wl->kbd.focused)
4398 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4400 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4403 /* update modifier state */
4404 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4410 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4412 Eina_Bool res = EINA_FALSE;
4414 if (type == ECORE_EVENT_KEY_DOWN)
4416 res = e_comp_wl_key_down(ev, dev);
4418 else if (type == ECORE_EVENT_KEY_UP)
4420 res = e_comp_wl_key_up(ev, dev);
4427 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4430 struct wl_client *wc;
4431 uint32_t serial, btn;
4432 struct wl_resource *res;
4433 E_Comp_Config *comp_conf = NULL;
4435 if (ec->cur_mouse_action || e_comp_wl->drag)
4437 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4438 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4442 case 1: btn = BTN_LEFT; break;
4443 case 2: btn = BTN_MIDDLE; break;
4444 case 3: btn = BTN_RIGHT; break;
4445 default: btn = button_id; break;
4448 e_comp_wl->ptr.button = btn;
4449 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4450 if (!surface) return EINA_FALSE;
4452 if (!eina_list_count(e_comp_wl->ptr.resources))
4455 wc = wl_resource_get_client(surface);
4456 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4458 comp_conf = e_comp_config_get();
4460 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4462 if (wl_resource_get_client(res) != wc) continue;
4463 if (!e_comp_wl_input_pointer_check(res)) continue;
4464 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4466 if (comp_conf && comp_conf->input_log_enable)
4467 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4469 wl_pointer_send_button(res, serial, timestamp, btn, state);
4476 e_comp_wl_touch_cancel(void)
4478 _e_comp_wl_touch_cancel();
4481 E_API E_Comp_Wl_Hook *
4482 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4486 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4487 ch = E_NEW(E_Comp_Wl_Hook, 1);
4488 if (!ch) return NULL;
4489 ch->hookpoint = hookpoint;
4491 ch->data = (void*)data;
4492 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4497 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4500 if (_e_comp_wl_hooks_walking == 0)
4502 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4506 _e_comp_wl_hooks_delete++;
4509 E_API E_Comp_Wl_Pid_Hook *
4510 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4512 E_Comp_Wl_Pid_Hook *ch;
4514 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4516 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4517 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4519 ch->hookpoint = hookpoint;
4521 ch->data = (void*)data;
4522 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4528 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4531 if (_e_comp_wl_pid_hooks_walking == 0)
4533 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4537 _e_comp_wl_pid_hooks_delete++;
4540 E_API E_Comp_Wl_Intercept_Hook *
4541 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4543 E_Comp_Wl_Intercept_Hook *ch;
4545 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4546 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4547 if (!ch) return NULL;
4548 ch->hookpoint = hookpoint;
4550 ch->data = (void*)data;
4551 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4556 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4559 if (_e_comp_wl_intercept_hooks_walking == 0)
4561 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4565 _e_comp_wl_intercept_hooks_delete++;
4569 e_comp_wl_shell_surface_ready(E_Client *ec)
4573 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4577 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4579 e_config->use_cursor_timer = !!enabled;
4581 if (e_config->use_cursor_timer)
4583 if (!e_pointer_is_hidden(e_comp->pointer))
4585 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4590 if (e_comp_wl->ptr.hide_tmr)
4592 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4593 e_comp_wl->ptr.hide_tmr = NULL;
4595 cursor_timer_ec = NULL;
4597 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4600 if (e_pointer_is_hidden(e_comp->pointer))
4602 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4608 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4610 EINA_SAFETY_ON_NULL_RETURN(wc);
4611 EINA_SAFETY_ON_NULL_RETURN(dev);
4613 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4617 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4619 EINA_SAFETY_ON_NULL_RETURN(wc);
4620 EINA_SAFETY_ON_NULL_RETURN(dev);
4622 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4626 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4628 struct wl_resource *res;
4629 struct wl_client *wc;
4631 uint32_t serial, wl_keycode;
4632 enum wl_keyboard_key_state state;
4633 E_Comp_Config *comp_conf = NULL;
4634 const char *dev_name = NULL;
4636 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4637 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4638 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4640 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4641 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4643 wl_keycode = keycode - 8;
4644 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4646 wc = wl_resource_get_client(surface);
4647 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4648 if (!time) time = e_util_timestamp_get();
4649 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4650 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4652 comp_conf = e_comp_config_get();
4653 e_keyrouter_event_surface_send(ec, keycode);
4655 if (e_config->key_input_ttrace_enable)
4657 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4658 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4661 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4662 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4664 if (wl_resource_get_client(res) != wc) continue;
4665 if (!e_input_thread_mode_get())
4669 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4670 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4674 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4681 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4682 dev_name = e_device_name_get(dev);
4686 if (comp_conf && comp_conf->input_log_enable)
4687 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4690 wl_keyboard_send_key(res, serial, time,
4693 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4695 if (e_config->key_input_ttrace_enable)
4698 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4705 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4707 struct wl_resource *res;
4708 struct wl_client *wc;
4710 uint32_t serial, wl_keycode, cancel_keycode;
4711 E_Comp_Config *comp_conf = NULL;
4712 struct xkb_keymap *keymap = NULL;
4714 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4715 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4716 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4718 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4719 keymap = e_comp_wl->xkb.keymap;
4720 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4721 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4723 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4724 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4726 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4727 if (cancel_keycode == XKB_KEYCODE_INVALID)
4729 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4732 cancel_keycode = cancel_keycode - 8;
4734 wl_keycode = keycode - 8;
4735 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4737 wc = wl_resource_get_client(surface);
4738 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4739 if (!time) time = e_util_timestamp_get();
4741 comp_conf = e_comp_config_get();
4742 e_keyrouter_event_surface_send(ec, keycode);
4744 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4745 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4747 if (wl_resource_get_client(res) != wc) continue;
4748 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4749 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4751 if (comp_conf && comp_conf->input_log_enable)
4752 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4753 wl_keyboard_send_key(res, serial, time,
4754 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4755 wl_keyboard_send_key(res, serial, time,
4756 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4757 wl_keyboard_send_key(res, serial, time,
4758 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4760 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4767 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)
4769 struct wl_client *wc;
4771 E_Devicemgr_Input_Device *device = NULL;
4773 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4774 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4775 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4777 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4778 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4780 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4782 wc = wl_resource_get_client(surface);
4783 if (!time) time = e_util_timestamp_get();
4784 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4788 _e_comp_wl_send_event_device(wc, time, dev, serial);
4789 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4793 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4794 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4797 x = x + ec->client.x;
4798 y = y + ec->client.y;
4800 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4806 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)
4808 E_Devicemgr_Input_Device *device;
4810 struct wl_client *wc;
4812 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4813 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4814 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4816 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4817 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4819 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4821 wc = wl_resource_get_client(surface);
4822 if (!time) time = e_util_timestamp_get();
4823 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4827 _e_comp_wl_send_event_device(wc, time, dev, serial);
4828 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4832 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4833 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4836 x = x + ec->client.x;
4837 y = y + ec->client.y;
4839 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4845 e_comp_wl_touch_cancel_send(E_Client *ec)
4847 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4848 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4849 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4851 _e_comp_wl_send_touch_cancel(ec);
4857 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4860 struct wl_client *wc;
4862 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4863 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4864 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4866 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4869 wc = wl_resource_get_client(surface);
4870 if (!time) time = e_util_timestamp_get();
4871 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4873 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4874 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4877 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4878 WL_POINTER_BUTTON_STATE_PRESSED);
4880 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4881 WL_POINTER_BUTTON_STATE_RELEASED);
4887 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4890 struct wl_client *wc;
4892 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4893 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4894 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4896 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4897 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4899 wc = wl_resource_get_client(surface);
4900 if (!time) time = e_util_timestamp_get();
4901 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4903 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4904 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4906 x = x + ec->client.x;
4907 y = y + ec->client.y;
4909 _e_comp_wl_send_mouse_move(ec, x, y, time);
4915 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4918 struct wl_client *wc;
4920 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4921 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4922 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4924 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4925 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4927 wc = wl_resource_get_client(surface);
4928 if (!time) time = e_util_timestamp_get();
4929 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4931 if (_e_comp_wl_check_cursor_timer_needed(ec))
4933 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4937 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4938 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4940 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4942 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4944 if (_e_comp_wl_check_cursor_timer_needed(ec))
4945 _e_comp_wl_cursor_move_timer_control(ec);
4952 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4955 struct wl_client *wc;
4956 struct wl_resource *res;
4959 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4960 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4962 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4963 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4965 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4966 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4968 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4969 wc = wl_resource_get_client(surface);
4970 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4971 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4973 if (!e_comp_wl_input_pointer_check(res)) continue;
4974 if (wl_resource_get_client(res) != wc) continue;
4976 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4977 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4979 wl_pointer_send_enter(res, serial, surface,
4980 wl_fixed_from_int(x),
4981 wl_fixed_from_int(y));
4982 ec->pointer_enter_sent = EINA_TRUE;
4984 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4990 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4993 struct wl_client *wc;
4994 struct wl_resource *res;
4997 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4998 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4999 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5000 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5001 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5002 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5004 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5005 wc = wl_resource_get_client(surface);
5006 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5007 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5009 if (!e_comp_wl_input_pointer_check(res)) continue;
5010 if (wl_resource_get_client(res) != wc) continue;
5012 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5013 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5015 wl_pointer_send_leave(res, serial, surface);
5016 ec->pointer_enter_sent = EINA_FALSE;
5023 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)
5025 Evas_Event_Mouse_In ev_in;
5028 if (ec->pointer_enter_sent) return;
5030 ev_in.buttons = buttons;
5038 ev_in.modifiers = modifiers;
5039 ev_in.locks = locks;
5040 ev_in.timestamp = timestamp;
5041 ev_in.event_flags = event_flags;
5044 ev_in.event_src = event_src;
5046 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5050 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)
5052 Evas_Event_Mouse_Out ev_out;
5055 if (!ec->pointer_enter_sent) return;
5057 ev_out.buttons = buttons;
5059 ev_out.output.x = x;
5060 ev_out.output.y = y;
5061 ev_out.canvas.x = x;
5062 ev_out.canvas.y = y;
5065 ev_out.modifiers = modifiers;
5066 ev_out.locks = locks;
5067 ev_out.timestamp = timestamp;
5068 ev_out.event_flags = event_flags;
5071 ev_out.event_src = event_src;
5073 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5077 e_comp_wl_cursor_hide(E_Client *ec)
5079 struct wl_resource *res;
5080 struct wl_client *wc;
5084 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5086 if (e_comp_wl->ptr.hide_tmr)
5088 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5089 e_comp_wl->ptr.hide_tmr = NULL;
5091 cursor_timer_ec = NULL;
5093 if (!ec) return EINA_FALSE;
5094 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5095 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5096 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5098 wc = wl_resource_get_client(surface);
5099 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5100 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5102 if (!e_comp_wl_input_pointer_check(res)) continue;
5103 if (wl_resource_get_client(res) != wc) continue;
5104 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5105 wl_pointer_send_leave(res, serial, surface);
5106 ec->pointer_enter_sent = EINA_FALSE;
5112 /* surface to buffer
5113 * - width : surface width
5114 * - height : surface height
5115 * - transform: buffer transform
5116 * - scale : buffer scale
5118 * - width : screen width
5119 * - height : screen height
5120 * - transform: output transform
5121 * - scale : output scale
5123 static E_Util_Transform_Matrix
5124 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5126 E_Util_Transform_Matrix m;
5128 e_util_transform_matrix_load_identity(&m);
5130 if (transform & 0x4)
5132 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5133 e_util_transform_matrix_flip_x(&m);
5134 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5137 switch (transform & 0x3)
5139 case WL_OUTPUT_TRANSFORM_90:
5140 e_util_transform_matrix_translate(&m, -width, 0, 0);
5141 e_util_transform_matrix_rotation_z(&m, 270);
5143 case WL_OUTPUT_TRANSFORM_180:
5144 e_util_transform_matrix_translate(&m, -width, -height, 0);
5145 e_util_transform_matrix_rotation_z(&m, 180);
5147 case WL_OUTPUT_TRANSFORM_270:
5148 e_util_transform_matrix_translate(&m, 0, -height, 0);
5149 e_util_transform_matrix_rotation_z(&m, 90);
5155 e_util_transform_matrix_scale(&m, scale, scale, 1);
5160 /* surface to buffer
5161 * - surface width, surface height, buffer transform, buffer scale
5163 * - screen width, screen height, output transform, output scale
5166 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5168 E_Util_Transform_Matrix m;
5169 E_Util_Transform_Vertex v;
5171 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5173 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5174 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5175 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5179 * - buffer width, buffer height, buffer transform, buffer scale
5182 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5184 E_Util_Transform_Matrix m;
5185 E_Util_Transform_Vertex v;
5188 if (transform != 0 || scale > 1)
5190 tw = ((transform % 2) ? height : width) / scale;
5191 th = ((transform % 2) ? width : height) / scale;
5199 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5200 m = e_util_transform_matrix_inverse_get(&m);
5202 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5203 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5204 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5207 /* surface to buffer
5208 * - surface width, surface height, buffer transform, buffer scale
5210 * - screen width, screen height, output transform, output scale
5213 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5214 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5216 E_Util_Transform_Matrix m;
5217 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5218 E_Util_Transform_Rect_Vertex sv;
5220 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5222 sv = e_util_transform_rect_to_vertices(&sr);
5223 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5224 sr = e_util_transform_vertices_to_rect(&sv);
5233 * - buffer width, buffer height, buffer transform, buffer scale
5236 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5237 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5239 E_Util_Transform_Matrix m;
5240 E_Util_Transform_Rect br = {bx, by, bw, bh};
5241 E_Util_Transform_Rect_Vertex bv;
5244 if (transform != 0 || scale > 1)
5246 tw = ((transform % 2) ? height : width) / scale;
5247 th = ((transform % 2) ? width : height) / scale;
5255 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5256 m = e_util_transform_matrix_inverse_get(&m);
5258 bv = e_util_transform_rect_to_vertices(&br);
5259 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5260 br = e_util_transform_vertices_to_rect(&bv);
5268 EINTERN E_Comp_Wl_Output*
5269 e_comp_wl_output_find(E_Client *ec)
5272 E_Comp_Wl_Output *output;
5274 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5276 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5278 if (output->transform % 2)
5280 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5281 ec->y < output->x || ec->y >= (output->x + output->w))
5286 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5287 ec->y < output->y || ec->y >= (output->y + output->h))
5297 EINTERN Eina_Array *
5298 e_comp_wl_output_find_all(E_Client *ec)
5300 E_Comp_Wl_Output *output;
5301 Eina_Array *outputs;
5304 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5306 outputs = eina_array_new(4);
5310 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5312 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5313 output->x, output->y, output->w, output->h))
5315 eina_array_push(outputs, output);
5319 if (eina_array_count(outputs) == 0)
5321 eina_array_free(outputs);
5328 // --------------------------------------------------------
5329 // tizen_move_resize
5330 // --------------------------------------------------------
5332 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5339 E_Client_Pending_Geometry *geo;
5342 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5343 if (ec->fullscreen || ec->maximized) goto err;
5345 geo = E_NEW(E_Client_Pending_Geometry, 1);
5348 geo->serial = serial;
5354 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5355 ec->surface_sync.wait_commit = EINA_TRUE;
5360 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5367 e_comp_wl_commit_sync_configure(E_Client *ec)
5370 E_Client_Pending_Geometry *geo;
5372 Eina_Bool match_size = EINA_FALSE;
5379 if (!ec || !ec->frame) goto ret;
5380 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5383 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5384 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5386 if (eina_list_count(ec->surface_sync.pending_geometry))
5388 Eina_List *ll = NULL;
5389 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5393 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5398 if ((geo->w == bw) && (geo->h == bh))
5400 match_size = EINA_TRUE;
5405 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5412 if ((config.w != ec->w) || (config.h != ec->h))
5414 e_client_size_set(ec, config.w, config.h);
5415 ec->changes.size = EINA_TRUE;
5419 // FIXME: The geometry of the client would be better to be calculated
5420 // at e_desk or at e_desk_area. So the position(x,y) of the client
5421 // should be calcuated at the e_desk or at the e_desk_area.
5423 desk = e_comp_desk_find_by_ec(ec);
5426 ec->client.x = desk->geom.x + config.x;
5427 ec->client.y = desk->geom.y + config.y;
5431 ec->client.x = config.x;
5432 ec->client.y = config.y;
5435 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5437 e_client_pos_set(ec, ec->client.x, ec->client.y);
5439 ec->changes.pos = 1;
5443 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5447 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5448 ec->surface_sync.wait_commit = EINA_FALSE;
5450 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5452 // rollback wait_commit if there are pending requests remained
5453 if (eina_list_count(ec->surface_sync.pending_geometry))
5454 ec->surface_sync.wait_commit = EINA_TRUE;
5459 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);
5466 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5467 struct wl_resource *res_moveresize)
5469 wl_resource_destroy(res_moveresize);
5473 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5474 struct wl_resource *res_moveresize,
5475 struct wl_resource *surface,
5482 /* to be implemented */
5485 int cur_w = 0, cur_h = 0;
5487 ec = e_client_from_surface_resource(surface);
5490 pending = e_client_pending_geometry_has(ec);
5491 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5492 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);
5496 if ((cur_w == w) && (cur_h == h))
5498 e_client_pos_set(ec, x, y);
5499 ec->changes.pos = 1;
5505 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5509 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5512 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5514 _tz_move_resize_iface_cb_destroy,
5515 _tz_move_resize_iface_cb_set_geometry,
5519 _tz_moveresize_cb_bind(struct wl_client *client,
5520 void *data EINA_UNUSED,
5524 struct wl_resource *res_moveresize;
5526 res_moveresize = wl_resource_create(client,
5527 &tizen_move_resize_interface,
5530 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5533 wl_resource_set_implementation(res_moveresize,
5534 &_tz_move_resize_iface,
5540 ERR("Could not create tizen_move_resize_interface res: %m");
5541 wl_client_post_no_memory(client);
5545 _e_comp_wl_move_resize_init(void)
5547 if (!e_comp_wl) return;
5548 if (!e_comp_wl->wl.disp) return;
5550 if (!wl_global_create(e_comp_wl->wl.disp,
5551 &tizen_move_resize_interface,
5554 _tz_moveresize_cb_bind))
5556 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5563 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5565 E_Comp_Wl_Output *output;
5566 pid_t output_pid = 0;
5567 Eina_List *l = NULL, *l2 = NULL;
5568 struct wl_resource *resource = NULL;
5570 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5572 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5573 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5574 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5576 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5578 /* if we have bound resources, send updates */
5579 EINA_LIST_FOREACH(output->resources, l2, resource)
5581 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5582 if (output_pid != pid) continue;
5584 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5586 // send output information to the client
5587 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5595 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5597 _e_comp_wl_surface_state_init(state, w, h);
5601 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5603 _e_comp_wl_surface_state_commit(ec, state);
5607 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5609 _e_comp_wl_hook_call(hookpoint, ec);
5613 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5615 _e_comp_wl_surface_state_finish(state);
5619 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5621 _e_comp_wl_surface_state_buffer_set(state, buffer);
5625 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5626 int sx, int sy, int *dx, int *dy)
5630 case WL_OUTPUT_TRANSFORM_NORMAL:
5634 case WL_OUTPUT_TRANSFORM_FLIPPED:
5635 *dx = width - sx, *dy = sy;
5637 case WL_OUTPUT_TRANSFORM_90:
5638 *dx = height - sy, *dy = sx;
5640 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5641 *dx = height - sy, *dy = width - sx;
5643 case WL_OUTPUT_TRANSFORM_180:
5644 *dx = width - sx, *dy = height - sy;
5646 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5647 *dx = sx, *dy = height - sy;
5649 case WL_OUTPUT_TRANSFORM_270:
5650 *dx = sy, *dy = width - sx;
5652 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5662 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5665 int tx1, ty1, tx2, ty2;
5666 int width_from_buffer, height_from_buffer;
5668 switch (vp->buffer.transform)
5670 case WL_OUTPUT_TRANSFORM_90:
5671 case WL_OUTPUT_TRANSFORM_270:
5672 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5673 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5674 width_from_buffer = bh / vp->buffer.scale;
5675 height_from_buffer = bw / vp->buffer.scale;
5678 width_from_buffer = bw / vp->buffer.scale;
5679 height_from_buffer = bh / vp->buffer.scale;
5683 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5687 x2 = width_from_buffer;
5688 y2 = height_from_buffer;
5692 x1 = wl_fixed_to_int(vp->buffer.src_x);
5693 y1 = wl_fixed_to_int(vp->buffer.src_y);
5694 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5695 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5698 buffer_transform(width_from_buffer, height_from_buffer,
5699 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5700 buffer_transform(width_from_buffer, height_from_buffer,
5701 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5703 out->x = (tx1 <= tx2) ? tx1 : tx2;
5704 out->y = (ty1 <= ty2) ? ty1 : ty2;
5705 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5706 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5710 * Convert given four coordinates to elements of rectangle
5711 * @in p[4] Coordinates to be converted
5712 * @out rect x, y, width, and height
5713 * transform Angle which represents TDM_TRANSFORM of rectangle
5714 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5715 * 1. The given coordinates are not represented by rectangle.
5716 * 2. All angles except for 0, 90, 180, 270.
5719 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5721 Eina_Bool ret = EINA_FALSE;
5723 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))
5726 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5729 *rotation = TDM_TRANSFORM_NORMAL;
5732 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5736 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5739 *rotation = TDM_TRANSFORM_180;
5742 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5747 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))
5750 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5753 *rotation = TDM_TRANSFORM_90;
5756 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5760 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5763 *rotation = TDM_TRANSFORM_270;
5766 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5776 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5781 for (i = 0; i < 4; i++)
5782 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5784 if (!_coords_to_rectangle_convert(p, out, rotation))
5786 DBG("Cannot convert given coords to rectangle.\n"
5787 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5788 p[0].x, p[0].y, p[1].x, p[1].y,
5789 p[2].x, p[2].y, p[3].x, p[3].y);
5797 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5799 int trans_rotation, flip;
5801 trans_rotation = transform & 0x3;
5802 flip = transform & 0x4;
5804 return (flip + (trans_rotation + rotation) % 4);
5808 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5816 if (e_comp_wl_subsurface_check(ec))
5817 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5824 out->w = ec->comp_data->width_from_viewport;
5825 out->w = (out->w + 1) & ~1;
5826 out->h = ec->comp_data->height_from_viewport;
5828 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5829 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5833 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5835 E_Comp_Wl_Buffer *buffer;
5836 E_Comp_Wl_Buffer_Viewport *vp;
5838 enum wl_output_transform buffer_transform;
5839 unsigned int rotation;
5840 Eina_Bool res = EINA_FALSE;
5842 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5844 if (e_object_is_del(E_OBJECT(ec)))
5847 vp = &ec->comp_data->scaler.buffer_viewport;
5849 if (buffer_viewport)
5851 buffer = ec->comp_data->buffer_ref.buffer;
5852 /* Getting a viewport of buffer needs geometry of buffer. */
5856 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5859 if ((output_viewport) || (transform))
5861 m = e_client_map_get(ec);
5863 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5865 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5870 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5871 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5872 * Since buffer.transform isn't applied using evas_map,
5873 * it has to be taken into account here to apply buffer.transform
5874 * and rotation of e_client_transform together. */
5876 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5878 *transform = (unsigned int)buffer_transform;
5886 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5888 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5889 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5891 /* Must be called with valid comp_data */
5892 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5894 if ((ec->comp_data->role_name == NULL) ||
5895 (ec->comp_data->role_name == role_name) ||
5896 (strcmp(ec->comp_data->role_name, role_name) == 0))
5898 ec->comp_data->role_name = role_name;
5904 wl_resource_post_error(error_resource, error_code,
5905 "Cannot assign role %s to wl_surface@%d,"
5906 " already has role %s\n",
5908 ec->comp_data->wl_surface ?
5909 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5910 ec->comp_data->role_name);
5916 EINTERN const char *
5917 e_comp_wl_surface_role_get(E_Client *ec)
5919 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5920 return ec->comp_data ? ec->comp_data->role_name : NULL;
5923 EINTERN struct wl_resource *
5924 e_comp_wl_client_surface_get(E_Client *ec)
5926 struct wl_resource *surface = NULL;
5927 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5928 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5930 g_mutex_lock(&ec->comp_data->surface_mutex);
5931 surface = ec->comp_data->surface;
5932 g_mutex_unlock(&ec->comp_data->surface_mutex);
5937 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5939 EINA_SAFETY_ON_NULL_RETURN(ec);
5940 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5942 g_mutex_lock(&ec->comp_data->surface_mutex);
5943 ec->comp_data->surface = surface;
5944 g_mutex_unlock(&ec->comp_data->surface_mutex);
5948 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5950 return e_compositor_util_client_from_surface_resource(surface_resource);
5954 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5956 if (!ec->comp_data->mapped)
5958 if (ec->comp_data->shell.surface &&
5959 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5961 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5967 if (ec->comp_data->mapped)
5969 /* will be unmapped. so run capture */
5970 e_comp_wl_remote_surface_image_save(ec);
5974 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5976 ec->comp_data->pending.sx = sx;
5977 ec->comp_data->pending.sy = sy;
5978 ec->comp_data->pending.new_attach = EINA_TRUE;
5980 e_client_fps_update(ec);
5984 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5986 if (ec->comp_data->pending.opaque)
5987 eina_tiler_clear(ec->comp_data->pending.opaque);
5991 eina_tiler_union(ec->comp_data->pending.opaque, region);
5993 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5997 ec->argb = EINA_FALSE;
5998 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6000 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6001 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6009 ec->argb = EINA_TRUE;
6010 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6012 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6013 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6019 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6021 if (ec->comp_data->pending.input)
6022 eina_tiler_clear(ec->comp_data->pending.input);
6026 if (eina_tiler_empty(region))
6028 ELOGF("COMP", " |unset input rect", NULL);
6029 e_comp_object_input_objs_del(ec->frame);
6030 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6033 eina_tiler_union(ec->comp_data->pending.input, region);
6037 eina_tiler_rect_add(ec->comp_data->pending.input,
6038 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6043 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6045 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6049 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6051 E_Comp_Wl_Subsurf_Data *sdata;
6056 if (ec->comp_data->frames)
6058 ec->comp_data->frames =
6059 eina_list_remove(ec->comp_data->frames, callback_resource);
6062 if (ec->comp_data->pending.frames)
6064 ec->comp_data->pending.frames =
6065 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6068 sdata = ec->comp_data->sub.data;
6069 if ((sdata) && (sdata->cached.frames))
6071 sdata->cached.frames =
6072 eina_list_remove(sdata->cached.frames, callback_resource);
6077 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6079 if (e_object_is_del(E_OBJECT(ec))) return;
6081 if (e_comp_wl_remote_surface_commit(ec)) return;
6083 e_comp_wl_surface_commit(ec);
6085 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6089 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6091 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6092 ec->comp_data->sub.data = sub;
6094 /* set subsurface client properties */
6095 ec->borderless = EINA_TRUE;
6096 ec->argb = EINA_TRUE;
6097 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6098 ec->lock_border = EINA_TRUE;
6099 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6100 ec->netwm.state.skip_taskbar = EINA_TRUE;
6101 ec->netwm.state.skip_pager = EINA_TRUE;
6102 ec->border_size = 0;
6103 ec->lock_user_location = 0;
6104 ec->lock_client_location = 0;
6105 ec->lock_user_size = 0;
6106 ec->lock_client_size = 0;
6107 ec->lock_client_stacking = 0;
6108 ec->lock_user_maximize = 0;
6109 ec->lock_client_maximize = 0;
6110 ec->changes.need_maximize = 0;
6111 ec->maximized = E_MAXIMIZE_NONE;
6114 ec->new_client = ec->netwm.ping = EINA_TRUE;
6115 e_comp->new_clients++;
6116 e_client_unignore(ec);
6118 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6119 * It's not for subsurface. */
6120 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6124 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6126 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6129 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6131 sub->parent = parent;
6135 layer = e_client_layer_get(parent);
6136 if (layer > E_LAYER_BOTTOM)
6137 e_client_layer_set(ec, layer);
6140 if (parent->comp_data)
6142 /* append this client to the parents subsurface list */
6143 parent->comp_data->sub.list_pending =
6144 eina_list_append(parent->comp_data->sub.list_pending, ec);
6145 parent->comp_data->sub.list_changed = EINA_TRUE;
6150 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6152 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6153 E_Client *parent = sub->parent;
6155 parent->comp_data->sub.list =
6156 eina_list_remove(parent->comp_data->sub.list, ec);
6157 parent->comp_data->sub.list_pending =
6158 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6159 parent->comp_data->sub.below_list =
6160 eina_list_remove(parent->comp_data->sub.below_list, ec);
6161 parent->comp_data->sub.below_list_pending =
6162 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6168 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)
6170 sub->resource = subsurface_resource;
6171 sub->cached_buffer_ref.buffer = NULL;
6172 sub->synchronized = EINA_TRUE;
6173 sub->parent = parent;
6174 sub->remote_surface.offscreen_parent = offscreen_parent;
6175 if (offscreen_parent)
6176 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6178 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6180 _e_comp_wl_client_subsurface_set(ec, sub);
6181 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6183 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6187 e_comp_wl_client_subsurface_finish(E_Client *ec)
6189 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6192 e_comp_wl_client_subsurface_parent_unset(ec);
6194 e_comp_wl_surface_state_finish(&sub->cached);
6195 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6197 ec->comp_data->sub.data = NULL;
6201 e_comp_wl_client_evas_init(E_Client *ec)
6203 EINA_SAFETY_ON_NULL_RETURN(ec);
6205 _e_comp_wl_client_evas_init(ec);
6209 e_comp_wl_client_evas_deinit(E_Client *ec)
6211 EINA_SAFETY_ON_NULL_RETURN(ec);
6213 _e_comp_wl_client_evas_deinit(ec);
6217 e_comp_wl_focus_check(void)
6219 _e_comp_wl_focus_check();
6223 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6230 if ((parent->comp_data) && (parent->comp_data->sub.data))
6231 parent = parent->comp_data->sub.data->parent;