2 #include "e_comp_wl_intern.h"
3 #include "e_foreign_intern.h"
4 #include "e_wtz_shell_intern.h"
5 #include "e_client_intern.h"
6 #include "e_appinfo_intern.h"
7 #include "e_blender_intern.h"
8 #include "e_utils_intern.h"
9 #include "e_scale_intern.h"
10 #include "e_comp_canvas_intern.h"
11 #include "e_comp_screen_intern.h"
12 #include "e_comp_wl_capture_intern.h"
13 #include "e_comp_wl_data_intern.h"
14 #include "e_comp_wl_input_intern.h"
15 #include "e_comp_wl_renderer_intern.h"
16 #include "e_comp_wl_rsm_intern.h"
17 #include "e_comp_wl_screenshooter_intern.h"
18 #include "e_comp_wl_shell_intern.h"
19 #include "e_comp_wl_subsurface_intern.h"
20 #include "e_comp_wl_tbm_intern.h"
21 #include "e_comp_wl_viewport_intern.h"
22 #include "e_comp_intern.h"
23 #include "e_input_intern.h"
24 #include "e_keyrouter_intern.h"
25 #include "e_error_intern.h"
26 #include "e_pointer_intern.h"
27 #include "e_presentation_time_intern.h"
28 #include "e_grabinput_intern.h"
29 #include "e_env_intern.h"
30 #include "e_dnd_intern.h"
31 #include "e_policy_visibility_intern.h"
32 #include "e_compositor_intern.h"
33 #include "e_client_video_intern.h"
34 #include "e_comp_wl_video_intern.h"
35 #include "e_comp_object_intern.h"
36 #include "e_desk_intern.h"
37 #include "e_zone_intern.h"
39 #include <tizen-extension-server-protocol.h>
40 #include <relative-pointer-unstable-v1-server-protocol.h>
41 #include <pointer-constraints-unstable-v1-server-protocol.h>
43 #include <wayland-tbm-server.h>
45 #include <libds/log.h>
46 #include <libds/single_pixel_buffer_v1.h>
49 /* handle include for printing uint64_t */
50 #define __STDC_FORMAT_MACROS
53 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
55 /* Resource Data Mapping: (wl_resource_get_user_data)
57 * wl_surface == e_pixmap
58 * wl_region == eina_tiler
59 * wl_subsurface == e_client
63 typedef struct _E_Comp_Data E_Comp_Data;
68 struct wl_listener client_created;
71 static void _e_comp_wl_move_resize_init(void);
73 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
76 typedef struct _E_Comp_Wl_Key_Data
82 struct _E_Comp_Wl_Evas_Gl
85 Evas_GL_Config *glcfg;
86 Evas_GL_Context *glctx;
87 Evas_GL_Surface *glsfc;
91 static Eina_List *handlers = NULL;
92 static E_Client *cursor_timer_ec = NULL;
93 static Eina_Bool need_send_released = EINA_FALSE;
94 static Eina_Bool need_send_motion = EINA_TRUE;
96 static GMutex connection_mutex;
98 static int _e_comp_wl_hooks_delete = 0;
99 static int _e_comp_wl_hooks_walking = 0;
101 static int _e_comp_wl_pid_hooks_delete = 0;
102 static int _e_comp_wl_pid_hooks_walking = 0;
104 static int _e_comp_wl_intercept_hooks_delete = 0;
105 static int _e_comp_wl_intercept_hooks_walking = 0;
107 static Eina_Inlist *_e_comp_wl_hooks[] =
109 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
110 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
111 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
112 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
113 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
114 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
115 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
116 [E_COMP_WL_HOOK_DEL] = NULL,
117 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
118 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
119 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
122 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
124 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
127 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
129 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
130 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
131 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
132 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
133 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
134 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
137 static Eina_List *hooks = NULL;
139 /* local functions */
141 _e_comp_wl_hooks_clean(void)
146 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
147 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
149 if (!ch->delete_me) continue;
150 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
156 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
160 e_object_ref(E_OBJECT(ec));
161 _e_comp_wl_hooks_walking++;
162 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
164 if (ch->delete_me) continue;
165 ch->func(ch->data, ec);
166 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
167 (e_object_is_del(E_OBJECT(ec))))
170 _e_comp_wl_hooks_walking--;
171 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
172 _e_comp_wl_hooks_clean();
173 e_object_unref(E_OBJECT(ec));
177 _e_comp_wl_pid_hooks_clean(void)
180 E_Comp_Wl_Pid_Hook *ch;
182 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
183 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
185 if (!ch->delete_me) continue;
186 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
192 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
194 E_Comp_Wl_Pid_Hook *ch;
196 _e_comp_wl_pid_hooks_walking++;
197 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
199 if (ch->delete_me) continue;
200 ch->func(ch->data, pid);
202 _e_comp_wl_pid_hooks_walking--;
203 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
204 _e_comp_wl_pid_hooks_clean();
208 _e_comp_wl_intercept_hooks_clean(void)
211 E_Comp_Wl_Intercept_Hook *ch;
213 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
214 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
216 if (!ch->delete_me) continue;
217 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
223 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
225 E_Comp_Wl_Intercept_Hook *ch;
226 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
228 e_object_ref(E_OBJECT(ec));
229 _e_comp_wl_intercept_hooks_walking++;
230 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
232 if (ch->delete_me) continue;
233 res = ch->func(ch->data, ec);
234 if (!res) ret = EINA_FALSE;
235 if (e_object_is_del(E_OBJECT(ec)))
238 _e_comp_wl_intercept_hooks_walking--;
239 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
240 _e_comp_wl_intercept_hooks_clean();
241 e_object_unref(E_OBJECT(ec));
248 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
254 if (e_comp_object_frame_exists(ec->frame))
255 w = ec->client.w, h = ec->client.h;
257 w = ec->w, h = ec->h;
261 // Width and Height are -1 means that we don't consider size value
265 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
269 _e_comp_wl_focus_check(void)
273 if (stopping) return;
274 ec = e_client_focused_get();
276 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
280 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
282 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
284 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
285 IDLE_EXITER~CB_PREPARE);
287 return ECORE_CALLBACK_RENEW;
291 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
293 /* dispatch pending wayland events */
294 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
296 return ECORE_CALLBACK_RENEW;
300 e_comp_wl_display_flush()
302 if (e_comp_wl && e_comp_wl->wl.disp)
304 if (e_config->key_input_ttrace_enable)
306 TRACE_INPUT_BEGIN(wl_display_flush_clients);
307 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
310 g_mutex_lock(&connection_mutex);
311 wl_display_flush_clients(e_comp_wl->wl.disp);
312 g_mutex_unlock(&connection_mutex);
314 if (e_config->key_input_ttrace_enable)
317 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
323 e_comp_wl_connection_lock()
325 e_input_boost_lock(&connection_mutex);
329 e_comp_wl_connection_unlock()
331 e_input_boost_unlock(&connection_mutex);
335 e_comp_wl_focused_client_flush()
337 E_Client *focused_ec;
338 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
340 e_input_boost_lock(&connection_mutex);
341 focused_ec = e_client_focused_get();
345 struct wl_client *wc;
346 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
349 e_input_boost_unlock(&connection_mutex);
353 wc = wl_resource_get_client(surface);
357 e_input_boost_unlock(&connection_mutex);
361 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
365 if (e_comp_wl->idle_exiter_timestamp > 0.0)
367 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
368 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
370 ELOGF("E_COMP", "prepare gap time: %lfms",
375 e_comp_wl->idle_exiter_timestamp = 0.0;
377 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
379 /* flush pending client events */
380 e_comp_wl_display_flush();
382 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
383 IDLE_EXITER~CB_PREPARE);
386 E_API enum wl_output_transform
387 e_comp_wl_output_buffer_transform_get(E_Client *ec)
389 E_Comp_Wl_Buffer_Viewport *vp;
390 E_Comp_Wl_Buffer *buffer;
391 enum wl_output_transform transform, rotation;
393 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
394 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
395 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
397 vp = &ec->comp_data->scaler.buffer_viewport;
398 if (e_comp_wl_subsurface_check(ec))
399 return vp->buffer.transform;
401 buffer = ec->comp_data->buffer_ref.buffer;
404 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
405 return vp->buffer.transform;
407 rotation = buffer->transform;
409 return vp->buffer.transform;
411 /* ignore the flip value when calculating transform because the screen rotation
412 * functionality doesn't consider the flip output transform currently
414 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
416 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
417 ec, rotation, vp->buffer.transform, transform);
422 EINTERN enum wl_output_transform
423 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
425 E_Comp_Wl_Buffer_Viewport *vp;
426 E_Comp_Wl_Buffer *buffer;
427 enum wl_output_transform transform, rotation;
429 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
430 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
431 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
433 vp = &ec->comp_data->pending.buffer_viewport;
434 if (e_comp_wl_subsurface_check(ec))
435 return vp->buffer.transform;
437 buffer = ec->comp_data->pending.buffer;
440 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
441 return vp->buffer.transform;
443 rotation = buffer->transform;
445 return vp->buffer.transform;
447 /* ignore the flip value when calculating transform because the screen rotation
448 * functionality doesn't consider the flip output transform currently
450 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
452 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
453 ec, rotation, vp->buffer.transform, transform);
459 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
461 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
462 E_Comp_Wl_Buffer *buffer;
463 int32_t width, height;
465 buffer = e_pixmap_resource_get(ec->pixmap);
468 ec->comp_data->width_from_buffer = 0;
469 ec->comp_data->height_from_buffer = 0;
473 switch (e_comp_wl_output_buffer_transform_get(ec))
475 case WL_OUTPUT_TRANSFORM_90:
476 case WL_OUTPUT_TRANSFORM_270:
477 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
478 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
479 width = buffer->h / vp->buffer.scale;
480 height = buffer->w / vp->buffer.scale;
483 width = buffer->w / vp->buffer.scale;
484 height = buffer->h / vp->buffer.scale;
488 ec->comp_data->width_from_buffer = width;
489 ec->comp_data->height_from_buffer = height;
493 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
495 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
496 int32_t width, height;
498 width = ec->comp_data->width_from_buffer;
499 height = ec->comp_data->height_from_buffer;
501 if (width == 0 && height == 0) return;
503 if (width != 0 && vp->surface.width != -1)
505 ec->comp_data->width_from_viewport = vp->surface.width;
506 ec->comp_data->height_from_viewport = vp->surface.height;
510 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
512 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
513 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
514 ec->comp_data->width_from_viewport = w ?: 1;
515 ec->comp_data->height_from_viewport = h ?: 1;
519 ec->comp_data->width_from_viewport = width;
520 ec->comp_data->height_from_viewport = height;
524 e_comp_wl_topmost_parent_get(E_Client *ec)
528 if (!e_comp_wl_subsurface_check(ec))
531 parent = e_comp_wl_subsurface_parent_get(ec);
534 if (!e_comp_wl_subsurface_check(parent))
537 parent = e_comp_wl_subsurface_parent_get(parent);
544 e_comp_wl_map_apply(E_Client *ec)
546 E_Comp_Wl_Buffer_Viewport *vp;
547 E_Comp_Wl_Subsurf_Data *sdata;
548 E_Comp_Wl_Client_Data *cdata;
549 int x1, y1, x2, y2, x, y;
551 Eina_Bool zoom_animating = EINA_FALSE;
553 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
555 e_comp_object_map_update(ec->frame);
557 cdata = ec->comp_data;
558 vp = &cdata->scaler.buffer_viewport;
559 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
560 (!cdata->viewport_transform))
563 if (e_comp_wl_subsurface_check(ec))
565 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
567 sdata = ec->comp_data->sub.data;
568 if (sdata->remote_surface.offscreen_parent)
570 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
571 Eina_Rectangle *rect;
574 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
576 /* TODO: If there are one more regions, it means that provider's offscreen
577 * is displayed by one more remote_surfaces. Have to consider it later. At
578 * this time, just consider only one remote_surface.
592 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
593 if (x != dx || y != dy)
594 evas_object_move(ec->frame, dx, dy);
596 if (!cdata->viewport_transform)
598 cdata->viewport_transform = e_util_transform_new();
599 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
600 e_client_transform_core_add(ec, cdata->viewport_transform);
603 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
604 ec->comp_data->width_from_viewport,
605 ec->comp_data->height_from_viewport);
607 if (vp->buffer.src_width == wl_fixed_from_int(-1))
611 x2 = cdata->width_from_buffer;
612 y2 = cdata->height_from_buffer;
616 x1 = wl_fixed_to_int(vp->buffer.src_x);
617 y1 = wl_fixed_to_int(vp->buffer.src_y);
618 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
619 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
622 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
623 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
624 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
625 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
628 desk = e_comp_desk_find_by_ec(ec);
630 zoom_animating = e_desk_zoom_is_animating(desk);
632 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
633 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
634 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
636 /* workaround:: when the desk zoom is doing their animation,
637 the transform core update can override animation's zoom boundary.
638 so, don't doing transform core update while desk zoom animation */
640 e_client_transform_core_update(ec);
645 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
649 int map_c = 0, map_x = 0, map_y = 0;
650 double inv_x = 0.0, inv_y = 0.0;
652 EINA_SAFETY_ON_NULL_RETURN(ec);
654 map = e_client_map_get(ec);
655 map_c = e_map_count_get(map);
657 if (!map || map_c <= 0)
667 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
668 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
669 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
670 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
672 for (int i = 0; i < map_c; i++)
674 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
675 e_map_point_image_uv_set(map2, i, map_x, map_y);
677 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
687 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
693 if (!(ec = data)) return;
694 if (e_object_is_del(data)) return;
696 if (!ec->override) e_hints_window_visible_set(ec);
698 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
699 (!ec->comp_data->need_reparent))
701 ec->comp_data->need_reparent = EINA_TRUE;
702 ec->visible = EINA_TRUE;
704 if (!e_client_util_ignored_get(ec))
706 ec->take_focus = !starting;
710 if (!ec->comp_data->need_reparent)
712 if ((ec->hidden) || (ec->iconic))
714 evas_object_hide(ec->frame);
715 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
718 evas_object_show(ec->frame);
721 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
722 evas_object_show(tmp->frame);
724 topmost = e_comp_wl_topmost_parent_get(ec);
725 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
726 e_comp_wl_subsurface_show(ec);
728 if (ec->comp_data->sub.below_obj)
729 evas_object_show(ec->comp_data->sub.below_obj);
733 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
739 if (!(ec = data)) return;
740 if (e_object_is_del(E_OBJECT(ec))) return;
742 /* Uncommonly some clients's final buffer can be skipped if the client
743 * requests unmap of its surface right after wl_surface@commit.
744 * So if this client evas object is hidden state and client is already
745 * unmmapped, we can consider to clear pixmap image here mandatorily.
747 if (!ec->comp_data->mapped)
748 e_pixmap_image_clear(ec->pixmap, 1);
750 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
751 evas_object_hide(tmp->frame);
753 topmost = e_comp_wl_topmost_parent_get(ec);
754 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
755 e_comp_wl_subsurface_hide(ec);
757 if (ec->comp_data->sub.below_obj)
758 evas_object_hide(ec->comp_data->sub.below_obj);
760 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
764 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
771 if (!(ec = data)) return;
772 if (e_object_is_del(E_OBJECT(ec))) return;
774 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
776 if (!e_comp_wl_subsurface_check(subc)) continue;
777 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
778 evas_object_move(subc->frame, x, y);
780 if (subc->comp_data->scaler.viewport)
782 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
783 if (cdata->viewport_transform)
784 e_comp_wl_map_apply(subc);
788 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
790 if (!e_comp_wl_subsurface_check(subc)) continue;
791 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
792 evas_object_move(subc->frame, x, y);
794 if (subc->comp_data->scaler.viewport)
796 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
797 if (cdata->viewport_transform)
798 e_comp_wl_map_apply(subc);
802 if (ec->comp_data->sub.below_obj)
804 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
805 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
810 _e_comp_wl_send_touch_cancel(E_Client *ec)
813 struct wl_resource *res;
814 struct wl_client *wc;
815 E_Comp_Config *comp_conf = NULL;
818 if (e_object_is_del(E_OBJECT(ec))) return;
819 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
821 if (!surface) return;
822 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
824 wc = wl_resource_get_client(surface);
826 comp_conf = e_comp_config_get();
828 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
830 if (wl_resource_get_client(res) != wc) continue;
831 if (!e_comp_wl_input_touch_check(res)) continue;
833 if (comp_conf && comp_conf->input_log_enable)
834 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
836 wl_touch_send_cancel(res);
841 _e_comp_wl_touch_cancel(void)
845 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
847 if (!e_comp_wl->touch.pressed) return;
849 _e_comp_wl_send_touch_cancel(ec);
852 static E_Devicemgr_Input_Device *
853 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
855 E_Devicemgr_Input_Device *last_kbd = NULL;
858 case ECORE_DEVICE_CLASS_MOUSE:
859 return e_devicemgr->last_device_ptr;
860 case ECORE_DEVICE_CLASS_KEYBOARD:
861 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
863 case ECORE_DEVICE_CLASS_TOUCH:
864 return e_devicemgr->last_device_touch;
872 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
876 case ECORE_DEVICE_CLASS_MOUSE:
877 e_devicemgr->last_device_ptr = device;
879 case ECORE_DEVICE_CLASS_KEYBOARD:
880 atomic_store(&e_devicemgr->last_device_kbd, device);
882 case ECORE_DEVICE_CLASS_TOUCH:
883 e_devicemgr->last_device_touch = device;
890 static E_Devicemgr_Input_Device *
891 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
893 E_Devicemgr_Input_Device *last_kbd = NULL;
897 case ECORE_DEVICE_CLASS_MOUSE:
898 return ec->comp_data->last_device_ptr;
899 case ECORE_DEVICE_CLASS_KEYBOARD:
900 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
902 case ECORE_DEVICE_CLASS_TOUCH:
903 return ec->comp_data->last_device_touch;
911 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
915 case ECORE_DEVICE_CLASS_MOUSE:
916 ec->comp_data->last_device_ptr = device;
918 case ECORE_DEVICE_CLASS_KEYBOARD:
919 atomic_store(&ec->comp_data->last_device_kbd, device);
921 case ECORE_DEVICE_CLASS_TOUCH:
922 ec->comp_data->last_device_touch = device;
930 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
932 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
933 struct wl_resource *dev_res;
934 const char *dev_name;
935 Ecore_Device_Class dev_class;
936 struct wl_client *wc;
940 EINA_SAFETY_ON_NULL_RETURN(dev);
943 if (ec->cur_mouse_action || e_comp_wl->drag)
945 if (e_object_is_del(E_OBJECT(ec))) return;
946 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
947 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
948 if (!surface) return;
950 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
951 dev_name = evas_device_description_get(dev);
952 last_device = _e_comp_wl_device_last_device_get(dev_class);
953 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
955 serial = wl_display_next_serial(e_comp_wl->wl.disp);
956 wc = wl_resource_get_client(surface);
957 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
958 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
960 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
961 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
963 _e_comp_wl_device_last_device_set(dev_class, input_dev);
964 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
966 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
968 if (wl_resource_get_client(dev_res) != wc) continue;
969 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
973 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
977 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
979 E_Devicemgr_Input_Device *last_device;
980 struct wl_resource *dev_res;
981 struct wl_client *wc;
985 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
986 if (!surface) return;
988 last_device = _e_comp_wl_device_last_device_get(dev_class);
989 if (!last_device) return;
991 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
993 serial = wl_display_next_serial(e_comp_wl->wl.disp);
994 wc = wl_resource_get_client(surface);
995 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
997 if (wl_resource_get_client(dev_res) != wc) continue;
998 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
1003 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1005 E_Devicemgr_Input_Device *input_dev;
1006 struct wl_resource *dev_res;
1007 const char *dev_name;
1010 EINA_SAFETY_ON_NULL_RETURN(dev);
1012 dev_name = ecore_device_identifier_get(dev);
1014 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1015 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1017 if (!eina_streq(input_dev->identifier, dev_name) ||
1018 (input_dev->clas != ecore_device_class_get(dev))) continue;
1019 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1021 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1023 if (wl_resource_get_client(dev_res) != wc) continue;
1024 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1027 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1031 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1033 E_Devicemgr_Input_Device *input_dev;
1034 struct wl_resource *dev_res;
1035 const char *dev_name;
1038 EINA_SAFETY_ON_NULL_RETURN(dev);
1040 dev_name = e_device_identifier_get(dev);
1042 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1043 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1045 if (!eina_streq(input_dev->identifier, dev_name) ||
1046 (input_dev->clas != e_device_class_get(dev))) continue;
1047 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1049 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1051 if (wl_resource_get_client(dev_res) != wc) continue;
1052 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1055 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1059 _e_comp_wl_cursor_reload(E_Client *ec)
1061 struct wl_resource *res;
1062 struct wl_client *wc;
1068 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1069 !evas_object_visible_get(e_comp->pointer->o_ptr))
1070 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1073 if (e_object_is_del(E_OBJECT(ec))) return;
1074 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1075 if (!surface) return;
1076 if (ec->pointer_enter_sent) return;
1078 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1079 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1081 if (e_client_transform_core_enable_get(ec))
1083 double dx = 0.0, dy = 0.0;
1084 map = e_client_map_get(ec);
1085 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1091 cx = px - ec->client.x;
1092 cy = py - ec->client.y;
1094 wc = wl_resource_get_client(surface);
1095 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1096 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1098 if (!e_comp_wl_input_pointer_check(res)) continue;
1099 if (wl_resource_get_client(res) != wc) continue;
1100 wl_pointer_send_enter(res, serial, surface,
1101 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1102 ec->pointer_enter_sent = EINA_TRUE;
1104 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1108 _e_comp_wl_cursor_timer(void *data)
1110 E_Client *ec = data;
1112 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1113 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1115 e_comp_wl_cursor_hide(ec);
1117 return ECORE_CALLBACK_CANCEL;
1121 _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)
1123 E_Devicemgr_Input_Device *input_dev;
1124 struct wl_resource *dev_res;
1125 struct wl_client *wc;
1130 if (ec->cur_mouse_action) return;
1131 if (e_object_is_del(E_OBJECT(ec))) return;
1132 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1133 if (!surface) return;
1135 f_value = wl_fixed_from_double(value);
1136 wc = wl_resource_get_client(surface);
1138 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1139 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1141 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1142 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1144 if (wl_resource_get_client(dev_res) != wc) continue;
1145 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1148 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1152 _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)
1154 if (idx >= e_input_touch_max_count_get()) return;
1156 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1157 e_devicemgr->multi[idx].radius_x = radius_x;
1158 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1159 e_devicemgr->multi[idx].radius_y = radius_y;
1160 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1161 e_devicemgr->multi[idx].pressure = pressure;
1162 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1163 e_devicemgr->multi[idx].angle = angle;
1167 _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)
1169 if (idx >= e_input_touch_max_count_get()) return;
1171 if (e_devicemgr->multi[idx].radius_x != radius_x)
1173 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1174 e_devicemgr->multi[idx].radius_x = radius_x;
1176 if (e_devicemgr->multi[idx].radius_y != radius_y)
1178 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1179 e_devicemgr->multi[idx].radius_y = radius_y;
1181 if (e_devicemgr->multi[idx].pressure != pressure)
1183 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1184 e_devicemgr->multi[idx].pressure = pressure;
1186 if (e_devicemgr->multi[idx].angle != angle)
1188 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1189 e_devicemgr->multi[idx].angle = angle;
1194 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1196 Eina_Bool ret = EINA_TRUE;
1199 case EVAS_CALLBACK_MOUSE_IN:
1200 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1203 if (e_comp_wl->ptr.hide_tmr)
1205 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1206 cursor_timer_ec = ec;
1207 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1211 if (e_pointer_is_hidden(e_comp->pointer))
1216 case EVAS_CALLBACK_MOUSE_OUT:
1217 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1220 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1224 case EVAS_CALLBACK_MOUSE_MOVE:
1225 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1228 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1229 _e_comp_wl_cursor_reload(ec);
1232 case EVAS_CALLBACK_MOUSE_WHEEL:
1233 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1236 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1237 _e_comp_wl_cursor_reload(ec);
1240 case EVAS_CALLBACK_MOUSE_DOWN:
1241 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1244 if (e_comp_wl->ptr.hide_tmr)
1246 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1247 e_comp_wl->ptr.hide_tmr = NULL;
1249 cursor_timer_ec = NULL;
1251 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1252 _e_comp_wl_cursor_reload(ec);
1255 case EVAS_CALLBACK_MOUSE_UP:
1256 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1267 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1269 if (ec->has_cursor_unset)
1272 if (!e_config->show_cursor)
1275 if (!e_config->use_cursor_timer)
1282 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1285 Evas_Event_Mouse_In *ev;
1286 struct wl_resource *res;
1287 struct wl_client *wc;
1290 E_Comp_Config *comp_conf;
1291 E_Client *prev_ptr_ec;
1295 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1296 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1298 if (!(ec = data)) return;
1299 if (e_object_is_del(E_OBJECT(ec))) return;
1300 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1301 if (!surface) return;
1303 prev_ptr_ec = e_comp_wl->ptr.ec;
1306 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1307 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1310 e_comp_wl->ptr.ec = ec;
1312 comp_conf = e_comp_config_get();
1313 if (comp_conf && comp_conf->input_log_enable)
1314 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1315 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1316 e_client_util_name_get(ec));
1318 if (_e_comp_wl_check_cursor_timer_needed(ec))
1320 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1324 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1325 wc = wl_resource_get_client(surface);
1326 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1327 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1329 if (!e_comp_wl_input_pointer_check(res)) continue;
1330 if (wl_resource_get_client(res) != wc) continue;
1332 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1334 wl_pointer_send_enter(res, serial, surface,
1335 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1336 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1337 ec->pointer_enter_sent = EINA_TRUE;
1340 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1344 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1347 Evas_Event_Mouse_Out *ev;
1348 struct wl_resource *res;
1349 struct wl_client *wc;
1352 Eina_Bool inside_check;
1353 E_Comp_Config *comp_conf;
1357 if (!(ec = data)) return;
1358 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1359 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1360 if (ec->cur_mouse_action && inside_check) return;
1361 if (e_object_is_del(E_OBJECT(e_comp))) return;
1362 if (e_comp_wl->ptr.ec == ec)
1363 e_comp_wl->ptr.ec = NULL;
1364 if (e_object_is_del(E_OBJECT(ec))) return;
1366 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1367 if (!surface) return;
1369 comp_conf = e_comp_config_get();
1370 if (comp_conf && comp_conf->input_log_enable)
1371 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1372 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1373 e_client_util_name_get(ec));
1375 if (_e_comp_wl_check_cursor_timer_needed(ec))
1377 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1381 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1383 wc = wl_resource_get_client(surface);
1384 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1385 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1387 if (!e_comp_wl_input_pointer_check(res)) continue;
1388 if (wl_resource_get_client(res) != wc) continue;
1389 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1391 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1393 wl_pointer_send_leave(res, serial, surface);
1394 ec->pointer_enter_sent = EINA_FALSE;
1399 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1402 struct wl_client *wc;
1403 struct wl_resource *res;
1406 E_Comp_Config *comp_conf = NULL;
1409 if (e_object_is_del(E_OBJECT(ec))) return;
1410 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1411 if (!surface) return;
1413 wc = wl_resource_get_client(surface);
1414 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1418 x = wl_fixed_from_int(canvas_x - ec->client.x);
1419 y = wl_fixed_from_int(canvas_y - ec->client.y);
1422 comp_conf = e_comp_config_get();
1424 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1426 if (wl_resource_get_client(res) != wc) continue;
1427 if (!e_comp_wl_input_touch_check(res)) continue;
1428 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1431 if (comp_conf && comp_conf->input_log_enable)
1432 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));
1434 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1438 if (comp_conf && comp_conf->input_log_enable)
1439 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));
1441 wl_touch_send_up(res, serial, timestamp, idx);
1448 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1451 struct wl_client *wc;
1452 struct wl_resource *res;
1456 if (ec->cur_mouse_action) return;
1457 if (e_object_is_del(E_OBJECT(ec))) return;
1458 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1459 if (!surface) return;
1461 wc = wl_resource_get_client(surface);
1463 x = wl_fixed_from_int(canvas_x - ec->client.x);
1464 y = wl_fixed_from_int(canvas_y - ec->client.y);
1466 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1468 if (wl_resource_get_client(res) != wc) continue;
1469 if (!e_comp_wl_input_touch_check(res)) continue;
1470 wl_touch_send_motion(res, timestamp, idx, x, y);
1475 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1477 struct wl_resource *res;
1478 struct wl_client *wc;
1482 if (ec->cur_mouse_action) return;
1483 if (e_object_is_del(E_OBJECT(ec))) return;
1484 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1485 if (!surface) return;
1487 wc = wl_resource_get_client(surface);
1488 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1490 if (!e_comp_wl_input_pointer_check(res)) continue;
1491 if (wl_resource_get_client(res) != wc) continue;
1492 wl_pointer_send_motion(res, timestamp,
1493 wl_fixed_from_int(x - ec->client.x),
1494 wl_fixed_from_int(y - ec->client.y));
1499 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1501 if (e_comp_wl->ptr.hide_tmr)
1503 if (cursor_timer_ec == ec)
1505 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1506 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1510 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1511 cursor_timer_ec = ec;
1512 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1517 cursor_timer_ec = ec;
1518 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1523 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1526 Evas_Event_Mouse_Move *ev;
1527 Evas_Device *dev = NULL;
1528 const char *dev_name;
1529 E_Comp_Config *comp_conf;
1533 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1534 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1536 if (!(ec = data)) return;
1537 if (e_object_is_del(E_OBJECT(ec))) return;
1538 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1539 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1540 if (!surface) return;
1542 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1545 dev_name = evas_device_description_get(dev);
1547 comp_conf = e_comp_config_get();
1548 if (comp_conf && comp_conf->input_log_enable)
1549 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1550 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1551 e_client_util_name_get(ec), dev_name);
1553 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1555 if (!e_comp_wl->drag_client)
1557 e_comp_wl->touch.faked_ec = ec;
1558 if (e_comp_wl->touch.pressed & (1 << 0))
1560 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1562 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1563 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1564 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1568 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1572 if (!e_comp_wl->drag_client)
1574 if (_e_comp_wl_check_cursor_timer_needed(ec))
1576 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1580 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1581 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1583 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1585 if (_e_comp_wl_check_cursor_timer_needed(ec))
1586 _e_comp_wl_cursor_move_timer_control(ec);
1590 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1595 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1597 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1598 if (e_object_is_del(E_OBJECT(ec))) return;
1599 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1600 if (!surface) return;
1601 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1603 e_comp_wl->ptr.button = BTN_LEFT;
1605 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1609 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1611 E_Client *ec = data;
1612 Evas_Event_Mouse_Down *ev = event;
1613 Evas_Device *dev = NULL;
1614 const Evas_Device *seat_dev;
1615 const char *dev_name, *seat_name;
1616 E_Comp_Config *comp_conf = NULL;
1619 if (e_object_is_del(E_OBJECT(ec))) return;
1622 dev_name = evas_device_description_get(dev);
1624 seat_dev = evas_device_parent_get(dev);
1625 seat_name = evas_device_name_get(seat_dev);
1627 comp_conf = e_comp_config_get();
1628 if (comp_conf && comp_conf->input_log_enable)
1629 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1630 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1631 dev_name, seat_name);
1633 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1635 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1637 e_comp_wl->touch.faked_ec = ec;
1640 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1641 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1642 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1644 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1645 e_comp_wl->touch.pressed |= (1 << 0);
1649 if (_e_comp_wl_check_cursor_timer_needed(ec))
1651 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1655 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1656 WL_POINTER_BUTTON_STATE_PRESSED);
1658 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1661 need_send_released = EINA_TRUE;
1665 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1667 E_Client *ec = data;
1668 Evas_Event_Mouse_Up *ev = event;
1669 Evas_Device *dev = NULL;
1670 const Evas_Device *seat_dev;
1671 const char *dev_name, *seat_name;;
1672 Evas_Event_Flags flags;
1673 E_Comp_Config *comp_conf = NULL;
1676 if (ec->cur_mouse_action) return;
1677 if (e_object_is_del(E_OBJECT(ec))) return;
1679 if (!need_send_released)
1681 need_send_motion = EINA_TRUE;
1685 dev_name = evas_device_description_get(dev);
1687 seat_dev = evas_device_parent_get(dev);
1688 seat_name = evas_device_name_get(seat_dev);
1689 flags = evas_event_default_flags_get(evas);
1691 comp_conf = e_comp_config_get();
1692 if (comp_conf && comp_conf->input_log_enable)
1693 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1694 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1695 dev_name, seat_name);
1697 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1699 e_comp_wl->touch.pressed &= ~(1 << 0);
1701 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1702 e_comp_wl->touch.faked_ec = NULL;
1705 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1707 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1709 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1712 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1713 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1714 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1718 if (_e_comp_wl_check_cursor_timer_needed(ec))
1720 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1724 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1725 WL_POINTER_BUTTON_STATE_RELEASED);
1727 if (_e_comp_wl_check_cursor_timer_needed(ec))
1728 _e_comp_wl_cursor_move_timer_control(ec);
1732 need_send_released = EINA_FALSE;
1736 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1738 struct wl_resource *res;
1739 struct wl_client *wc;
1744 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1746 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1749 dir = -wl_fixed_from_int(abs(z));
1751 dir = wl_fixed_from_int(z);
1754 if (e_object_is_del(E_OBJECT(ec))) return;
1755 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1756 if (!surface) return;
1758 wc = wl_resource_get_client(surface);
1759 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1761 if (!e_comp_wl_input_pointer_check(res)) continue;
1762 if (wl_resource_get_client(res) != wc) continue;
1763 wl_pointer_send_axis(res, timestamp, axis, dir);
1768 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1771 Evas_Event_Mouse_Wheel *ev;
1774 if (!(ec = data)) return;
1775 if (ec->cur_mouse_action) return;
1776 if (e_object_is_del(E_OBJECT(ec))) return;
1777 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1778 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1779 if (!surface) return;
1781 if (!eina_list_count(e_comp_wl->ptr.resources))
1784 if (_e_comp_wl_check_cursor_timer_needed(ec))
1786 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1790 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1792 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1794 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1796 if (_e_comp_wl_check_cursor_timer_needed(ec))
1797 _e_comp_wl_cursor_move_timer_control(ec);
1802 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1804 E_Client *ec = data;
1805 Evas_Event_Multi_Down *ev = event;
1806 Evas_Device *dev = NULL;
1807 const Evas_Device *seat_dev;
1808 const char *dev_name, *seat_name;
1809 Evas_Device_Class dev_class;
1810 E_Comp_Config *comp_conf = NULL;
1813 if (e_object_is_del(E_OBJECT(ec))) return;
1814 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1815 if (!surface) return;
1817 /* Do not deliver emulated single touch events to client */
1818 if (ev->device == 0) return;
1821 dev_name = evas_device_description_get(dev);
1822 e_comp_wl->touch.faked_ec = ec;
1824 seat_dev = evas_device_parent_get(dev);
1825 seat_name = evas_device_name_get(seat_dev);
1827 comp_conf = e_comp_config_get();
1828 if (comp_conf && comp_conf->input_log_enable)
1829 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1830 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1831 dev_name, seat_name);
1833 if (dev && dev_name)
1835 dev_class = evas_device_class_get(dev);
1836 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1837 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1840 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1841 e_comp_wl->touch.pressed |= (1 << ev->device);
1845 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1847 E_Client *ec = data;
1848 Evas_Event_Multi_Up *ev = event;
1849 Evas_Device *dev = NULL;
1850 const Evas_Device *seat_dev;
1851 const char *dev_name, *seat_name;
1852 Evas_Device_Class dev_class;
1853 Evas_Event_Flags flags;
1854 E_Comp_Config *comp_conf = NULL;
1857 if (e_object_is_del(E_OBJECT(ec))) return;
1858 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1859 if (!surface) return;
1861 /* Do not deliver emulated single touch events to client */
1862 if (ev->device == 0) return;
1864 flags = evas_event_default_flags_get(evas);
1866 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1867 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1868 e_comp_wl->touch.faked_ec = NULL;
1870 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1873 dev_name = evas_device_description_get(dev);
1875 seat_dev = evas_device_parent_get(dev);
1876 seat_name = evas_device_name_get(seat_dev);
1878 comp_conf = e_comp_config_get();
1879 if (comp_conf && comp_conf->input_log_enable)
1880 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1881 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1882 dev_name, seat_name);
1884 if (dev && dev_name)
1886 dev_class = evas_device_class_get(dev);
1887 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1888 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1891 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1895 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1897 E_Client *ec = data;
1898 Evas_Event_Multi_Move *ev = event;
1899 Evas_Device *dev = NULL;
1900 const char *dev_name;
1901 Evas_Device_Class dev_class;
1904 if (e_object_is_del(E_OBJECT(ec))) return;
1905 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1906 if (!surface) return;
1908 /* Do not deliver emulated single touch events to client */
1909 if (ev->device == 0) return;
1911 e_comp_wl->touch.faked_ec = ec;
1913 if (e_comp_wl->touch.pressed & (1 << ev->device))
1916 if (dev && (dev_name = evas_device_description_get(dev)))
1918 dev_class = evas_device_class_get(dev);
1919 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1920 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1923 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1928 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1931 char *file, buff[PATH_MAX];
1938 n = (getpriority(PRIO_PROCESS, pid) + adj);
1942 setpriority(PRIO_PROCESS, pid, n);
1945 use_adj = EINA_TRUE;
1947 if (!do_child) return;
1949 files = ecore_file_ls("/proc");
1950 EINA_LIST_FREE(files, file)
1952 if (!isdigit(file[0]))
1955 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1956 if ((f = fopen(buff, "r")))
1960 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1962 if (num_read == 2 && ppid == pid)
1963 _e_comp_wl_client_priority_adjust(pid2, set,
1965 adj_child, do_child);
1973 _e_comp_wl_client_priority_raise(E_Client *ec)
1975 if (!e_config->priority_control) return;
1976 if (ec->netwm.pid <= 0) return;
1977 if (ec->netwm.pid == getpid()) return;
1978 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1979 e_config->priority - 1, -1,
1980 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1984 _e_comp_wl_client_priority_normal(E_Client *ec)
1986 if (!e_config->priority_control) return;
1987 if (ec->netwm.pid <= 0) return;
1988 if (ec->netwm.pid == getpid()) return;
1989 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1990 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1994 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1997 E_Comp_Wl_Key_Data *k;
1998 struct wl_resource *res;
2002 if (!ec) return EINA_FALSE;
2003 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2004 if (!ec->comp_data) return EINA_FALSE;
2006 ec->comp_data->on_focus_timer = NULL;
2007 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2008 if (!e_comp_wl->kbd.focused)
2010 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2013 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2015 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2016 t = ecore_time_unix_get();
2018 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2019 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2020 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2022 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2024 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2025 wl_keyboard_send_key(res, serial, t,
2026 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2029 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2030 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2034 /* It is called in the following cases:
2035 * When a normal ec->frame has focus.
2036 * Or launching image ec is replaced to the real ec.
2039 e_comp_wl_feed_focus_in(E_Client *ec)
2042 struct wl_resource *res;
2043 struct wl_client *wc;
2047 if (e_object_is_del(E_OBJECT(ec))) return;
2048 if (ec->iconic) return;
2050 /* block spurious focus events */
2051 focused = e_client_focused_get();
2052 if ((focused) && (ec != focused)) return;
2054 /* raise client priority */
2055 _e_comp_wl_client_priority_raise(ec);
2056 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2057 if (!surface) return;
2059 wc = wl_resource_get_client(surface);
2061 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2062 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2064 if (wl_resource_get_client(res) == wc)
2066 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2067 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2068 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2069 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2072 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2074 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2075 if (!e_comp_wl->kbd.focused)
2077 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2080 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2082 e_comp_wl->kbd.focus = surface;
2083 e_comp_wl_input_keyboard_enter_send(ec);
2084 e_comp_wl_data_device_keyboard_focus_set();
2085 ec->comp_data->on_focus_timer =
2086 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2087 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2088 int rotation = ec->e.state.rot.ang.curr;
2089 e_pointer_rotation_set(e_comp->pointer, rotation);
2093 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2096 if (!(ec = data)) return;
2097 e_comp_wl_feed_focus_in(ec);
2101 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2104 struct wl_resource *res;
2106 E_Comp_Wl_Key_Data *k;
2110 if (!(ec = data)) return;
2112 if (!ec->comp_data) return;
2114 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2116 /* lower client priority */
2117 if (!e_object_is_del(data))
2118 _e_comp_wl_client_priority_normal(ec);
2121 /* update keyboard modifier state */
2122 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2123 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2124 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2126 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2128 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2129 if (!surface) return;
2131 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2132 if (!eina_list_count(e_comp_wl->kbd.resources))
2134 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2138 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2140 /* send keyboard_leave to all keyboard resources */
2141 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2142 t = ecore_time_unix_get();
2144 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2145 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2146 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2148 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2150 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2151 wl_keyboard_send_key(res, serial, t,
2152 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2154 wl_keyboard_send_leave(res, serial, surface);
2155 e_comp_wl->kbd.focused =
2156 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2158 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2159 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2163 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2167 if (!(ec = data)) return;
2169 if (!ec->comp_data->shell.configure_send) return;
2171 /* TODO: calculate x, y with transfrom object */
2172 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2176 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2177 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2178 if (e_comp_object_frame_exists(ec->frame))
2179 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2181 switch (ec->resize_mode)
2183 case E_POINTER_RESIZE_TL:
2184 case E_POINTER_RESIZE_L:
2185 case E_POINTER_RESIZE_BL:
2186 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2187 ec->mouse.current.mx;
2189 case E_POINTER_RESIZE_TR:
2190 case E_POINTER_RESIZE_R:
2191 case E_POINTER_RESIZE_BR:
2192 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2197 switch (ec->resize_mode)
2199 case E_POINTER_RESIZE_TL:
2200 case E_POINTER_RESIZE_T:
2201 case E_POINTER_RESIZE_TR:
2202 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2203 ec->mouse.current.my;
2205 case E_POINTER_RESIZE_BL:
2206 case E_POINTER_RESIZE_B:
2207 case E_POINTER_RESIZE_BR:
2208 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2213 w = E_CLAMP(w, 1, w);
2214 h = E_CLAMP(h, 1, h);
2215 e_client_resize_limit(ec, &w, &h);
2217 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2219 else if ((!ec->fullscreen) && (!ec->maximized) &&
2220 (!ec->comp_data->maximize_pre))
2224 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2225 if ((pw != ec->w) || (ph != ec->h))
2227 _e_comp_wl_configure_send(ec, 1, 1);
2231 if (ec->comp_data->sub.below_obj)
2232 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2236 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2238 E_Client *ec = data;
2240 ec->comp_data->maximize_pre = 1;
2244 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2246 E_Client *ec = data;
2249 if (e_object_is_del(E_OBJECT(ec))) return;
2251 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2252 e_client_shell_configure_send(ec, 0, w, h);
2254 ec->comp_data->maximize_pre = 0;
2258 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2260 E_Client *ec = data;
2262 ec->comp_data->maximize_pre = 1;
2266 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2268 E_Client *ec = data;
2270 if (e_object_is_del(E_OBJECT(ec))) return;
2272 /* check for wayland pixmap */
2274 if (ec->comp_data->shell.configure_send)
2275 _e_comp_wl_configure_send(ec, 0, 0);
2277 ec->comp_data->maximize_pre = 0;
2281 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2283 E_Client *ec = data;
2285 if (e_object_is_del(E_OBJECT(ec))) return;
2287 /* check for wayland pixmap */
2289 if (ec->comp_data->shell.configure_send)
2290 _e_comp_wl_configure_send(ec, 0, 1);
2292 ec->comp_data->maximize_pre = 0;
2296 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2298 E_Client *ec = data;
2300 if (e_object_is_del(E_OBJECT(ec))) return;
2302 /* check for wayland pixmap */
2304 if (ec->comp_data->shell.configure_send)
2305 _e_comp_wl_configure_send(ec, 0, 0);
2307 ec->comp_data->maximize_pre = 0;
2311 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2315 if (!(ec = data)) return;
2317 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2319 e_object_del(E_OBJECT(ec));
2321 _e_comp_wl_focus_check();
2323 /* TODO: Delete request send ??
2324 * NB: No such animal wrt wayland */
2328 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2332 if (!(ec = data)) return;
2334 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2337 if (ec->comp_data->reparented)
2338 e_client_comp_hidden_set(ec, EINA_TRUE);
2341 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2342 if (ec->visible) evas_object_hide(ec->frame);
2343 if (!ec->internal) e_object_del(E_OBJECT(ec));
2345 _e_comp_wl_focus_check();
2349 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2353 if (!(ec = data)) return;
2355 e_client_shell_ping(ec);
2359 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2364 if (!(ec = data)) return;
2365 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2366 if (ec->netwm.opacity == a) return;
2367 ec->netwm.opacity = a;
2368 ec->netwm.opacity_changed = EINA_TRUE;
2372 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2374 Eina_Rectangle *damage_rect = NULL;
2375 Eina_Rectangle *dmg = NULL;
2376 Eina_List *l = NULL;
2378 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2379 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2382 if (!buffer->tbm_surface) return;
2386 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2390 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2391 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2394 eina_rectangle_union(damage_rect, dmg);
2399 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2400 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2403 tbm_surface_internal_set_damage(buffer->tbm_surface,
2409 eina_rectangle_free(damage_rect);
2413 _e_comp_wl_client_evas_init(E_Client *ec)
2415 if (!ec || !ec->comp_data) return;
2416 if (ec->comp_data->evas_init) return;
2418 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2419 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2420 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2423 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2424 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2425 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2426 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2427 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2428 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2430 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2431 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2432 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2434 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2435 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2439 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2440 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2441 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2442 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2443 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2444 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2445 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2448 /* setup delete/kill callbacks */
2449 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2450 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2452 /* setup ping callback */
2453 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2454 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2456 ec->comp_data->evas_init = EINA_TRUE;
2460 _e_comp_wl_client_evas_deinit(E_Client *ec)
2462 if (!ec || !ec->comp_data) return;
2463 if (!ec->comp_data->evas_init) return;
2465 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2466 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2467 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2469 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2470 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2471 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2472 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2473 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2474 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2476 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2477 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2478 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2480 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2481 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2485 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2486 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2487 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2488 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2489 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2490 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2491 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2494 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2495 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2497 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2498 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2500 ec->comp_data->evas_init = EINA_FALSE;
2504 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2508 E_Comp_Screen *e_comp_screen;
2509 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2511 if (!e_comp) return ECORE_CALLBACK_RENEW;
2512 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2513 e_comp_screen = e_comp->e_comp_screen;
2515 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2517 if (!eout->config.enabled)
2519 e_comp_wl_output_remove(eout->id);
2523 switch (eout->config.rotation)
2526 transform = WL_OUTPUT_TRANSFORM_90;
2529 transform = WL_OUTPUT_TRANSFORM_180;
2532 transform = WL_OUTPUT_TRANSFORM_270;
2536 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2540 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2542 eout->config.geom.x, eout->config.geom.y,
2543 eout->config.geom.w, eout->config.geom.h,
2544 eout->info.size.w, eout->info.size.h,
2545 eout->config.mode.refresh, 0, transform))
2546 ERR("Could not initialize screen %s", eout->info.name);
2549 return ECORE_CALLBACK_RENEW;
2553 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2557 /* try to get the client from the object */
2558 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2559 return ECORE_CALLBACK_RENEW;
2561 /* check for client being deleted */
2562 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2564 /* check for wayland pixmap */
2565 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2566 return ECORE_CALLBACK_RENEW;
2568 /* if we have not setup evas callbacks for this client, do it */
2569 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2571 return ECORE_CALLBACK_RENEW;
2575 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2579 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2580 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2582 if (e_comp_wl->selection.target &&
2585 struct wl_resource *res;
2587 E_Client *ec = NULL;
2588 E_Client *legacy_target = e_comp_wl->selection.target;
2589 int device_id = e_comp_wl_data_current_device_id_get();
2593 e_comp_wl_data_current_device_id_set(ev->multi.device);
2595 else if (device_id != ev->multi.device)
2597 return ECORE_CALLBACK_RENEW;
2600 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2601 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2603 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2604 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2606 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2607 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2609 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2610 (ec != legacy_target))
2612 e_comp_wl_data_device_send_leave(legacy_target);
2613 e_comp_wl_data_device_send_enter(ec);
2616 if (e_comp_wl->drag)
2617 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2619 if (e_client_transform_core_enable_get(ec))
2621 int trans_x, trans_y;
2622 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2623 x = trans_x - ec->client.x;
2624 y = trans_y - ec->client.y;
2628 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2633 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2636 return ECORE_CALLBACK_RENEW;
2640 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2643 struct wl_resource *surface;
2644 struct wl_resource *res;
2645 struct wl_client *wc;
2647 E_Comp_Config *comp_conf;
2649 ec = e_comp_wl->ptr_constraints.ec;
2650 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2652 surface = e_comp_wl_client_surface_get(ec);
2653 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2655 wc = wl_resource_get_client(surface);
2657 comp_conf = e_comp_config_get();
2659 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2661 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2662 if (wl_resource_get_client(res) != wc) continue;
2664 if (comp_conf && comp_conf->input_log_enable)
2665 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2666 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2667 e_client_util_name_get(ec));
2669 zwp_relative_pointer_v1_send_relative_motion(res,
2671 (uint32_t)(ev->timestamp),
2672 wl_fixed_from_int(ev->dx),
2673 wl_fixed_from_int(ev->dy),
2674 wl_fixed_from_int(ev->dx_unaccel),
2675 wl_fixed_from_int(ev->dy_unaccel));
2678 return ECORE_CALLBACK_DONE;
2682 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2684 _e_comp_wl_touch_cancel();
2686 return ECORE_CALLBACK_PASS_ON;
2690 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2692 if (!ev) return ECORE_CALLBACK_PASS_ON;
2694 E_Zone *zone = ev->zone;
2696 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2697 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2699 if (!e_zone_is_displaying(zone))
2700 _e_comp_wl_touch_cancel();
2702 return ECORE_CALLBACK_PASS_ON;
2706 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2708 E_Client *ec = ev->ec;
2709 E_Comp_Wl_Buffer_Viewport *vp;
2711 if (!ec) return ECORE_CALLBACK_PASS_ON;
2712 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2713 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2714 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2715 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2717 vp = &ec->comp_data->scaler.buffer_viewport;
2718 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2720 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2722 return ECORE_CALLBACK_PASS_ON;
2726 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2728 E_Client *ec = ev->ec;
2729 E_Comp_Wl_Buffer_Viewport *vp;
2731 if (!ec) return ECORE_CALLBACK_PASS_ON;
2732 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2733 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2734 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2736 vp = &ec->comp_data->scaler.buffer_viewport;
2737 vp->wait_for_transform_change = 0;
2739 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2741 return ECORE_CALLBACK_PASS_ON;
2745 _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)
2747 E_Client *focused_ec;
2750 focused_ec = e_client_focused_get();
2751 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2753 rotation = focused_ec->e.state.rot.ang.curr;
2754 e_pointer_rotation_set(e_comp->pointer, rotation);
2756 return ECORE_CALLBACK_PASS_ON;
2760 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2763 Eina_Rectangle *window;
2768 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2770 if ((prev_w != state->bw) ||
2771 (prev_h != state->bh))
2773 ec->changes.buf_size = EINA_TRUE;
2776 if (e_comp_object_frame_exists(ec->frame)) return;
2777 window = &ec->comp_data->shell.window;
2778 if ((!ec->borderless) && /* FIXME temporarily added this check code
2779 * to prevent updating E_Client's size by frame */
2780 (window->x || window->y || window->w || window->h))
2782 e_comp_object_frame_geometry_set(ec->frame,
2784 (window->x + window->w) - state->bw,
2786 (window->y + window->h) - state->bh);
2789 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2793 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2795 E_Comp_Wl_Surface_State *state;
2798 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2799 state->buffer = NULL;
2803 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2805 state->new_attach = EINA_FALSE;
2806 state->buffer = NULL;
2807 state->buffer_destroy_listener.notify =
2808 _e_comp_wl_surface_state_cb_buffer_destroy;
2809 state->sx = state->sy = 0;
2811 state->input = eina_tiler_new(w, h);
2812 eina_tiler_tile_size_set(state->input, 1, 1);
2814 state->opaque = eina_tiler_new(w, h);
2815 eina_tiler_tile_size_set(state->opaque, 1, 1);
2817 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2818 state->buffer_viewport.buffer.scale = 1;
2819 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2820 state->buffer_viewport.surface.width = -1;
2821 state->buffer_viewport.changed = 0;
2823 e_presentation_time_container_init(&state->presentation_container);
2827 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2829 struct wl_resource *cb;
2830 Eina_Rectangle *dmg;
2832 EINA_LIST_FREE(state->frames, cb)
2833 wl_resource_destroy(cb);
2835 EINA_LIST_FREE(state->damages, dmg)
2836 eina_rectangle_free(dmg);
2838 EINA_LIST_FREE(state->buffer_damages, dmg)
2839 eina_rectangle_free(dmg);
2841 if (state->opaque) eina_tiler_free(state->opaque);
2842 state->opaque = NULL;
2844 if (state->input) eina_tiler_free(state->input);
2845 state->input = NULL;
2847 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2848 state->buffer = NULL;
2850 e_presentation_time_container_finish(&state->presentation_container);
2854 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2856 if (state->buffer == buffer) return;
2858 wl_list_remove(&state->buffer_destroy_listener.link);
2859 state->buffer = buffer;
2861 wl_signal_add(&state->buffer->destroy_signal,
2862 &state->buffer_destroy_listener);
2866 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2868 Eina_Rectangle *dmg;
2869 Eina_Bool placed = EINA_TRUE;
2873 E_Comp_Wl_Buffer *buffer;
2874 struct wl_resource *cb;
2876 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2877 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2882 if ((ec->internal) ||
2883 (cdata->shell.surface && state->new_attach))
2887 e_comp->new_clients++;
2888 ELOGF("COMP", "Unignore", ec);
2889 e_client_unignore(ec);
2893 /* buffer transform */
2894 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2897 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2899 /* when buffer is transformed, we have to apply the new evas-map */
2900 state->buffer_viewport.changed = EINA_TRUE;
2902 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2904 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2906 if (transform_change == vp->wait_for_transform_change)
2907 vp->wait_for_transform_change = 0;
2909 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2910 // triggered by E_CLIENT_HOOK calls at those file.
2911 zone = e_comp_zone_find_by_ec(ec);
2914 eout = e_output_find(zone->output_id);
2915 if (eout && eout->hwc)
2917 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2919 if (e_comp_is_on_overlay(ec))
2920 e_comp_hwc_client_end(ec, __FUNCTION__);
2926 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2927 cdata->scaler.buffer_viewport = state->buffer_viewport;
2929 if (state->new_attach)
2931 e_comp_wl_surface_attach(ec, state->buffer);
2934 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2935 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2937 _e_comp_wl_surface_state_buffer_set(state, NULL);
2939 if ((state->new_attach) ||
2940 (state->buffer_viewport.changed))
2942 _e_comp_wl_surface_state_size_update(ec, state);
2943 e_comp_wl_map_size_cal_from_viewport(ec);
2945 /* update the position */
2946 if (ec->changes.pos)
2948 e_comp_object_frame_xy_unadjust(ec->frame,
2958 if (ec->new_client) placed = ec->placed;
2960 if (!ec->lock_client_size)
2965 ec->client.w = state->bw;
2966 ec->client.h = state->bh;
2968 e_comp_object_frame_wh_adjust(ec->frame,
2969 ec->client.w, ec->client.h,
2971 e_client_size_set(ec, nw, nh);
2973 if ((w != ec->w) || (h != ec->h))
2975 ec->changes.size = 1;
2980 if (ec->changes.buf_size)
2982 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2983 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2984 ec->changes.buf_size = EINA_FALSE;
2986 if (ec->move_after_resize)
2988 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2989 ec->move_after_resize = EINA_FALSE;
2994 /* map or unmap ec */
2995 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2996 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2997 if (!pixmap_usable || hide_by_request)
3002 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
3007 if ((cdata->sub.below_obj) &&
3008 (evas_object_visible_get(cdata->sub.below_obj)))
3010 evas_object_hide(cdata->sub.below_obj);
3018 if ((cdata->sub.below_obj) &&
3019 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3020 (evas_object_visible_get(ec->frame)))
3022 evas_object_show(cdata->sub.below_obj);
3026 if ((state->new_attach) ||
3027 (state->buffer_viewport.changed))
3029 if ((e_comp_wl->drag) &&
3030 (e_comp_wl->drag_client) &&
3031 (e_comp_wl->drag_client == ec))
3033 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3035 e_drag_move(e_comp_wl->drag,
3037 e_comp_wl->drag->y);
3039 e_drag_resize(e_comp_wl->drag,
3040 state->bw, state->bh);
3042 else if ((cdata->shell.surface) &&
3043 (cdata->shell.configure))
3045 e_comp_wl_commit_sync_configure(ec);
3047 else if (!e_client_video_hw_composition_check(ec))
3049 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3054 ec->placed = placed;
3055 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3059 if (cdata->scaler.buffer_viewport.changed)
3060 e_comp_wl_map_apply(ec);
3062 /* resize transform object */
3063 if (ec->transformed)
3064 e_client_transform_update(ec);
3068 state->new_attach = EINA_FALSE;
3070 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3072 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3073 wl_resource_destroy(cb);
3076 /* insert state frame callbacks into comp_data->frames
3077 * NB: This clears state->frames list */
3078 cdata->frames = eina_list_merge(cdata->frames,
3080 state->frames = NULL;
3082 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3083 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3084 &state->presentation_container);
3086 buffer = e_pixmap_resource_get(ec->pixmap);
3088 /* put state damages into surface */
3091 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3092 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3094 if ((cdata->buffer_ref.buffer) &&
3095 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3096 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3098 e_comp_object_damage(ec->frame,
3100 cdata->buffer_ref.buffer->w,
3101 cdata->buffer_ref.buffer->h);
3106 Eina_List *damages = NULL;
3109 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3111 if (eina_list_count(state->buffer_damages))
3113 EINA_LIST_FREE(state->buffer_damages, dmg)
3116 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3117 e_comp_wl_output_buffer_transform_get(ec),
3119 dmg->x, dmg->y, dmg->w, dmg->h,
3120 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3121 damages = eina_list_append(damages, dmg);
3125 EINA_LIST_FREE(state->damages, dmg)
3126 damages = eina_list_append(damages, dmg);
3128 EINA_LIST_FREE(damages, dmg)
3130 /* not creating damage for ec that shows a underlay video */
3131 if (state->buffer_viewport.changed ||
3132 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3133 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3134 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3136 eina_rectangle_free(dmg);
3141 /* put state opaque into surface */
3142 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3145 Eina_Rectangle *rect;
3148 itr = eina_tiler_iterator_new(state->opaque);
3149 EINA_ITERATOR_FOREACH(itr, rect)
3153 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3154 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3155 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3159 eina_iterator_free(itr);
3162 /* put state input into surface */
3163 if ((state->input) &&
3164 (!eina_tiler_empty(state->input)) &&
3167 Eina_Tiler *src, *tmp;
3171 tmp = eina_tiler_new(sw, sh);
3172 eina_tiler_tile_size_set(tmp, 1, 1);
3174 eina_tiler_rect_add(tmp,
3175 &(Eina_Rectangle){0, 0, sw, sh});
3177 if ((src = eina_tiler_intersection(state->input, tmp)))
3179 Eina_Rectangle *rect;
3182 e_comp_object_input_objs_del(ec->frame);
3183 itr = eina_tiler_iterator_new(src);
3184 EINA_ITERATOR_FOREACH(itr, rect)
3186 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3187 ec, rect->x, rect->y, rect->w, rect->h,
3188 ec->w, ec->h, state->bw, state->bh);
3189 e_comp_object_input_area_set(ec->frame,
3194 eina_iterator_free(itr);
3195 eina_tiler_free(src);
3198 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3200 eina_tiler_free(tmp);
3202 /* clear input tiler */
3203 eina_tiler_clear(state->input);
3206 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3208 if ((cdata->video_client) &&
3210 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3211 (e_comp->wl_comp_data->available_hw_accel.underlay))
3213 e_pixmap_image_clear(ec->pixmap, 1);
3216 state->buffer_viewport.changed = 0;
3218 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3221 ec->exp_iconify.buffer_flush &&
3222 e_policy_visibility_client_is_iconic(ec))
3224 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3229 _e_comp_wl_surface_render_stop(E_Client *ec)
3231 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3232 //if ((!ec->internal) && (!e_comp_gl_get()))
3235 /* check if internal animation is running */
3236 if (e_comp_object_is_animating(ec->frame)) return;
3237 /* check if external animation is running */
3238 if (evas_object_data_get(ec->frame, "effect_running")) return;
3240 evas_object_hide(ec->frame);
3244 e_comp_wl_client_surface_finish(E_Client *ec)
3246 struct wl_resource *res, *surface;
3247 struct wl_client *surface_client = NULL;
3250 surface = e_comp_wl_client_surface_get(ec);
3253 surface_client = wl_resource_get_client(surface);
3255 if (surface_client &&
3256 (ec == e_client_focused_get()))
3258 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3259 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3261 if (wl_resource_get_client(res) ==
3263 e_comp_wl->kbd.focused =
3264 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3268 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3271 e_comp_wl_client_surface_set(ec, NULL);
3273 ec->comp_data->wl_surface = NULL;
3274 e_pixmap_win_id_del(ec->pixmap);
3276 _e_comp_wl_surface_render_stop(ec);
3277 e_object_del(E_OBJECT(ec));
3281 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3286 char proc[512], pname[512];
3289 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3291 h = fopen(proc, "r");
3294 len = fread(pname, sizeof(char), 512, h);
3296 pname[len - 1] = '\0';
3298 strncpy(pname, "NO NAME", sizeof(pname));
3304 strncpy(pname, "NO NAME", sizeof(pname));
3307 strncpy(name, pname, size);
3311 _e_comp_wl_pname_print(pid_t pid)
3314 char proc[512], pname[512];
3317 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3319 h = fopen(proc, "r");
3322 len = fread(pname, sizeof(char), 512, h);
3324 pname[len - 1] = '\0';
3326 strncpy(pname, "NO NAME", sizeof(pname));
3330 ELOGF("COMP", " |%s", NULL, pname);
3335 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3337 struct wl_client *client = data;
3338 E_Comp_Connected_Client_Info *cinfo;
3341 cinfo = wl_container_of(listener, cinfo, destroy);
3343 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3344 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3346 eai = e_appinfo_find_with_pid(cinfo->pid);
3347 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3350 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3352 wl_list_remove(&cinfo->destroy.link);
3353 eina_stringshare_del(cinfo->name);
3358 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3360 E_Comp_Connected_Client_Info *cinfo;
3362 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3363 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3365 cinfo->name = eina_stringshare_add(name);
3369 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3370 wl_client_add_destroy_listener(client, &cinfo->destroy);
3371 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3373 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3377 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3379 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3381 /* send configure */
3382 if (ec->comp_data->shell.configure_send)
3384 if (ec->comp_data->shell.surface)
3385 _e_comp_wl_configure_send(ec, 0, 0);
3388 e_comp_wl->kbd.focus = ec->comp_data->surface;
3392 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3394 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3396 /* send configure */
3397 if (ec->comp_data->shell.configure_send)
3399 if (ec->comp_data->shell.surface)
3400 _e_comp_wl_configure_send(ec, 0, 0);
3403 _e_comp_wl_focus_check();
3405 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3406 e_comp_wl->kbd.focus = NULL;
3410 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3412 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3413 if (ec->keyboard_resizing) return;
3415 /* do nothing currently */
3420 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3422 if (e_object_is_del(E_OBJECT(ec))) return;
3423 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3425 e_comp_wl->resize.edges = 0;
3426 e_comp_wl->resize.resource = NULL;
3430 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3432 if (e_object_is_del(E_OBJECT(ec))) return;
3433 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3437 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3440 int ratio_w, ratio_h;
3442 phys_w = output->phys_width;
3443 phys_h = output->phys_height;
3445 if (e_config->configured_output_resolution.use)
3447 // change the configured physical size(mm) of the output
3448 if (output->w != res_w)
3450 ratio_w = res_w / output->w;
3451 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3454 if (output->h != res_h)
3456 ratio_h = res_h / output->h;
3457 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3460 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3463 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3464 NULL, res_w, res_h, phys_w, phys_h, pid);
3466 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3467 wl_output_send_scale(resource, output->scale);
3469 wl_output_send_geometry(resource, output->x, output->y,
3471 output->subpixel, output->make ?: "",
3472 output->model ?: "", output->transform);
3474 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3475 res_w, res_h, output->refresh);
3477 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3478 wl_output_send_done(resource);
3482 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3484 E_Comp_Wl_Output *output;
3486 if (!(output = wl_resource_get_user_data(resource))) return;
3488 output->resources = eina_list_remove(output->resources, resource);
3492 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3494 E_Comp_Wl_Output *output;
3495 struct wl_resource *resource;
3496 E_Appinfo *eai = NULL;
3500 if (!(output = data)) return;
3503 wl_resource_create(client, &wl_output_interface, version, id);
3506 wl_client_post_no_memory(client);
3510 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3511 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3513 output->resources = eina_list_append(output->resources, resource);
3515 wl_resource_set_implementation(resource, NULL, output,
3516 _e_comp_wl_cb_output_unbind);
3517 wl_resource_set_user_data(resource, output);
3519 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3520 if (e_config->configured_output_resolution.use)
3522 wl_client_get_credentials(client, &pid, NULL, NULL);
3525 res_w = e_config->configured_output_resolution.w;
3526 res_h = e_config->configured_output_resolution.h;
3530 eai = e_appinfo_find_with_pid(pid);
3533 res_w = e_config->configured_output_resolution.w;
3534 res_h = e_config->configured_output_resolution.h;
3538 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3540 res_w = e_config->configured_output_resolution.w;
3541 res_h = e_config->configured_output_resolution.h;
3545 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3554 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3558 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3561 Evas_GL *evasgl = NULL;
3562 Evas_GL_API *glapi = NULL;
3563 Evas_GL_Context *ctx = NULL;
3564 Evas_GL_Surface *sfc = NULL;
3565 Evas_GL_Config *cfg = NULL;
3567 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3569 if (!e_comp_gl_get()) return;
3571 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3572 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3574 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3575 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3577 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3578 * then we should get evas from ecore_evas.
3581 evas = e_comp->evas;
3583 evas = ecore_evas_get(e_comp->ee);
3585 evasgl = evas_gl_new(evas);
3586 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3588 glapi = evas_gl_api_get(evasgl);
3589 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3590 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3592 cfg = evas_gl_config_new();
3593 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3595 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3596 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3598 ctx = evas_gl_context_create(evasgl, NULL);
3599 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3601 res = evas_gl_make_current(evasgl, sfc, ctx);
3602 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3604 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3605 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3607 evas_gl_config_free(cfg);
3609 evas_gl->gl = evasgl;
3610 evas_gl->glapi = glapi;
3611 evas_gl->glsfc = sfc;
3612 evas_gl->glctx = ctx;
3614 e_comp_wl->evas_gl = evas_gl;
3616 /* for native surface */
3619 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3624 evas_gl_config_free(cfg);
3625 evas_gl_make_current(evasgl, NULL, NULL);
3626 evas_gl_context_destroy(evasgl, ctx);
3627 evas_gl_surface_destroy(evasgl, sfc);
3628 evas_gl_free(evasgl);
3635 _e_comp_wl_gl_popup_cb_close(void *data,
3636 Evas_Object *obj EINA_UNUSED,
3637 void *event_info EINA_UNUSED)
3639 evas_object_del(data);
3643 _e_comp_wl_gl_popup_cb_focus(void *data,
3644 Evas_Object *obj EINA_UNUSED,
3645 void *event_info EINA_UNUSED)
3647 elm_object_focus_set(data, EINA_TRUE);
3652 _e_comp_wl_gl_idle(void *data)
3656 /* show warning window to notify failure of gl init */
3659 Evas_Object *win, *bg, *popup, *btn;
3661 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3662 elm_win_title_set(win, "Compositor Warning");
3663 elm_win_autodel_set(win, EINA_TRUE);
3664 elm_win_borderless_set(win, EINA_TRUE);
3665 elm_win_role_set(win, "notification-low");
3666 elm_win_alpha_set(win, EINA_TRUE);
3668 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3669 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3670 elm_win_resize_object_add(win, bg);
3671 evas_object_color_set(bg, 125, 125, 125, 125);
3672 evas_object_show(bg);
3674 popup = elm_popup_add(win);
3675 elm_object_text_set(popup,
3676 _( "Your screen does not support OpenGL.<br>"
3677 "Falling back to software engine."));
3678 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3680 btn = elm_button_add(popup);
3681 elm_object_text_set(btn, "Close");
3682 elm_object_part_content_set(popup, "button1", btn);
3683 evas_object_show(btn);
3685 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3686 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3688 evas_object_show(popup);
3689 evas_object_show(win);
3693 return ECORE_CALLBACK_CANCEL;
3697 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3699 struct wl_client *client = data;
3705 wl_client_get_credentials(client, &pid, &uid, &gid);
3707 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3709 _e_comp_wl_pname_print(pid);
3710 _e_comp_wl_pname_get(pid, name, sizeof(name));
3711 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3715 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3717 char buf[1024] = {0, };
3719 vsnprintf(buf, 1024, fmt, args);
3723 DBG("[libds] %s", buf);
3726 INF("[libds] %s", buf);
3729 ERR("[libds] %s", buf);
3737 _e_comp_wl_display_create(void)
3740 E_Comp_Wl_Data *wl_cdata;
3745 /* create new compositor data */
3746 if (!(comp = E_NEW(E_Comp_Data, 1)))
3748 ERR("Could not create compositor data: %m");
3751 wl_cdata = &comp->base;
3753 /* set compositor wayland data */
3754 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3756 g_mutex_init(&connection_mutex);
3758 /* try to create a wayland display */
3759 if (!(wl_cdata->wl.disp = wl_display_create()))
3761 ERR("Could not create a Wayland display: %m");
3765 /* try to setup wayland socket */
3766 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3768 ERR("Could not create Wayland display socket: %m");
3769 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3773 res = e_comp_socket_init(name);
3774 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3775 PRCTL("[Winsys] change permission and create sym link for %s", name);
3777 /* set wayland display environment variable */
3778 e_env_set("WAYLAND_DISPLAY", name);
3780 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3781 /* wl_cdata->output.scale = e_scale; */
3783 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3785 if (!e_compositor_init(wl_cdata->wl.disp))
3787 ERR("Failed to initialize compositor");
3791 comp->client_created.notify = _e_comp_wl_cb_client_created;
3792 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3794 if (!e_comp_wl_subsurfaces_init())
3796 ERR("Failed to init_subsurfaces");
3797 goto subsurfaces_err;
3800 /* initialize shm mechanism */
3801 wl_display_init_shm(wl_cdata->wl.disp);
3803 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3805 /* try to init data manager */
3806 if (!e_comp_wl_data_manager_init())
3808 ERR("Could not initialize data manager");
3812 /* try to init input */
3813 if (!e_comp_wl_input_init())
3815 ERR("Could not initialize input");
3819 if (e_comp_gl_get())
3820 _e_comp_wl_gl_init(NULL);
3822 /* get the wayland display loop */
3823 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3825 /* get the file descriptor of the wayland event loop */
3826 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3828 /* create a listener for wayland main loop events */
3830 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3831 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3832 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3833 _e_comp_wl_cb_prepare, wl_cdata);
3838 e_comp_wl_data_manager_shutdown();
3840 e_comp_wl_subsurfaces_shutdown();
3842 wl_list_remove(&comp->client_created.link);
3844 e_env_unset("WAYLAND_DISPLAY");
3846 wl_display_destroy(wl_cdata->wl.disp);
3848 g_mutex_clear(&connection_mutex);
3854 _e_comp_wl_gl_shutdown(void)
3856 if (!e_comp_wl->evas_gl) return;
3858 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3860 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3861 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3862 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3863 evas_gl_free(e_comp_wl->evas_gl->gl);
3865 E_FREE(e_comp_wl->evas_gl);
3868 /* public functions */
3871 * Creates and initializes a Wayland compositor with ecore.
3872 * Registers callback handlers for keyboard and mouse activity
3873 * and other client events.
3875 * @returns true on success, false if initialization failed.
3878 e_comp_wl_init(void)
3880 TRACE_DS_BEGIN(COMP_WL:INIT);
3882 /* try to create a wayland compositor */
3883 if (!_e_comp_wl_display_create())
3885 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3890 e_comp_wl_shell_init();
3892 #ifdef HAVE_WAYLAND_TBM
3893 e_comp_wl_tbm_init();
3895 e_comp_wl_remote_surface_init();
3899 e_comp_wl_screenshooter_init();
3901 if (!e_comp_wl_video_init())
3902 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3904 e_comp_wl_viewport_init();
3905 e_comp_wl_capture_init();
3906 e_comp_wl_renderer_init();
3907 _e_comp_wl_move_resize_init();
3908 e_presentation_time_init();
3909 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3912 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3913 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3915 /* add event handlers to catch E events */
3916 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3917 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3918 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3919 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3920 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3921 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3922 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3923 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3924 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3926 /* add hooks to catch e_client events */
3927 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3928 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3929 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3930 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3931 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3933 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3940 e_comp_wl_deferred_job(void)
3942 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3945 /* internal functions */
3947 e_comp_wl_shutdown(void)
3949 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3951 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3953 e_comp_wl_subsurfaces_shutdown();
3955 E_FREE_LIST(handlers, ecore_event_handler_del);
3956 E_FREE_LIST(hooks, e_client_hook_del);
3957 _e_comp_wl_gl_shutdown();
3959 e_blender_shutdown();
3960 e_presentation_time_shutdown();
3961 e_comp_wl_renderer_shutdown();
3962 e_comp_wl_capture_shutdown();
3963 e_comp_wl_viewport_shutdown();
3964 e_comp_wl_video_shutdown();
3965 e_comp_wl_screenshooter_shutdown();
3967 e_comp_wl_remote_surface_shutdown();
3969 e_pixmap_shutdown();
3971 e_wtz_shell_shutdown();
3972 e_comp_wl_shell_shutdown();
3973 e_comp_wl_input_shutdown();
3975 wl_list_remove(&comp->client_created.link);
3978 e_comp->wl_comp_data = NULL;
3982 E_Comp_Wl_Output *output;
3984 if (e_comp_wl->screenshooter.global)
3985 wl_global_destroy(e_comp_wl->screenshooter.global);
3987 EINA_LIST_FREE(e_comp_wl->outputs, output)
3989 if (output->id) eina_stringshare_del(output->id);
3990 if (output->make) eina_stringshare_del(output->make);
3991 if (output->model) eina_stringshare_del(output->model);
3995 /* delete fd handler */
3996 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3998 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3999 cursor_timer_ec = NULL;
4001 /* free allocated data structure */
4007 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4009 e_object_unref(E_OBJECT(ev->ec));
4014 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4017 ev = E_NEW(E_Event_Client, 1);
4020 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4022 /* set usable early because shell module checks this */
4023 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4024 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4026 e_pixmap_resource_set(ec->pixmap, buffer);
4027 e_pixmap_dirty(ec->pixmap);
4028 e_pixmap_refresh(ec->pixmap);
4030 e_comp_wl_map_size_cal_from_buffer(ec);
4031 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4033 /* wm-policy module uses it */
4034 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4037 e_object_ref(E_OBJECT(ec));
4038 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4039 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4043 e_comp_wl_surface_commit(E_Client *ec)
4048 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4049 if (!e_comp_object_damage_exists(ec->frame))
4051 if ((ec->comp_data->video_client) ||
4052 (!e_client_video_hw_composition_check(ec)))
4053 e_pixmap_image_clear(ec->pixmap, 1);
4056 ignored = ec->ignored;
4058 if (e_comp_wl_subsurface_order_commit(ec))
4060 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4061 e_comp_wl_subsurface_restack(topmost);
4062 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4065 ec->ignored = ignored;
4067 if (ec->is_cursor && ec->visible)
4069 /* ignore cursor changes during resize/move I guess */
4070 if (!e_client_action_get())
4072 if (e_comp->pointer)
4074 x = e_comp->pointer->hot.x;
4075 y = e_comp->pointer->hot.y;
4077 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4083 static E_Comp_Wl_Output *
4084 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4087 E_Comp_Wl_Output *output;
4089 EINA_LIST_FOREACH(outputs, l, output)
4091 if (!strcmp(output->id, id))
4099 * Initializes information about one display output.
4101 * Adds or updates the given data about a single display output,
4102 * with an id matching the provided id.
4104 * @param id identification of output to be added or changed
4105 * @param make manufacturer name of the display output
4106 * @param model model name of the display output
4107 * @param x output's top left corner x coordinate
4108 * @param y output's top left corner y coordinate
4109 * @param w output's width in pixels
4110 * @param h output's height in pixels
4111 * @param pw output's physical width in millimeters
4112 * @param ph output's physical height in millimeters
4113 * @param refresh output's refresh rate in mHz
4114 * @param subpixel output's subpixel layout
4115 * @param transform output's rotation and/or mirror transformation
4117 * @returns True if a display output object could be added or updated
4120 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4121 int x, int y, int w, int h, int pw, int ph,
4122 unsigned int refresh, unsigned int subpixel,
4123 unsigned int transform)
4125 E_Comp_Wl_Output *output;
4127 struct wl_resource *resource;
4129 /* retrieve named output; or create it if it doesn't exist */
4130 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4133 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4135 if (id) output->id = eina_stringshare_add(id);
4137 output->make = eina_stringshare_add(make);
4139 output->make = eina_stringshare_add("unknown");
4141 output->model = eina_stringshare_add(model);
4143 output->model = eina_stringshare_add("unknown");
4145 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4148 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4149 2, output, _e_comp_wl_cb_output_bind);
4151 output->resources = NULL;
4152 output->scale = e_scale;
4155 /* update the output details */
4160 output->phys_width = pw;
4161 output->phys_height = ph;
4162 output->refresh = refresh;
4163 output->subpixel = subpixel;
4164 output->transform = transform;
4166 if (output->scale <= 0)
4167 output->scale = e_scale;
4169 /* if we have bound resources, send updates */
4170 EINA_LIST_FOREACH(output->resources, l2, resource)
4172 wl_output_send_geometry(resource,
4173 output->x, output->y,
4175 output->phys_height,
4177 output->make ?: "", output->model ?: "",
4180 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4181 wl_output_send_scale(resource, output->scale);
4183 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4184 output->w, output->h, output->refresh);
4186 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4187 wl_output_send_done(resource);
4194 e_comp_wl_output_remove(const char *id)
4196 E_Comp_Wl_Output *output;
4198 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4201 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4203 /* wl_global_destroy(output->global); */
4205 /* eina_stringshare_del(output->id); */
4206 /* eina_stringshare_del(output->make); */
4207 /* eina_stringshare_del(output->model); */
4214 _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)
4216 struct wl_resource *res;
4218 uint32_t serial, keycode;
4219 struct wl_client *wc = NULL;
4220 E_Comp_Config *comp_conf = NULL;
4221 const char *device_name = NULL;
4223 keycode = (ev->keycode - 8);
4225 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4227 comp_conf = e_comp_config_get();
4229 if (ec && ec->comp_data)
4231 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4234 wc = wl_resource_get_client(surface);
4237 if (e_config->key_input_ttrace_enable)
4239 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4240 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4243 EINA_LIST_FOREACH(key_list, l, res)
4245 if (wl_resource_get_client(res) != wc) continue;
4247 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4248 if (!e_input_thread_mode_get())
4250 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4251 device_name = ecore_device_name_get(ev->dev);
4257 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4258 device_name = e_device_name_get(dev);
4262 if (comp_conf && comp_conf->input_log_enable)
4263 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4265 wl_keyboard_send_key(res, serial, ev->timestamp,
4270 if (e_config->key_input_ttrace_enable)
4273 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4278 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4280 E_Client *ec = NULL;
4282 E_Comp_Wl_Key_Data *end, *k;
4284 if (ev->window != e_comp->ee_win)
4289 keycode = (ev->keycode - 8);
4290 if (!(e_comp_wl = e_comp->wl_comp_data))
4295 #ifndef E_RELEASE_BUILD
4296 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4297 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4298 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4299 eina_streq(ev->key, "BackSpace"))
4305 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4307 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4309 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4311 /* ignore server-generated key repeats */
4312 if (k->key == keycode)
4314 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4319 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4321 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4323 ec = e_client_focused_get();
4324 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4325 if (ec && ec->comp_data && surface)
4327 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4328 if (e_comp_wl->kbd.focused)
4330 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4332 /* A key only sent to clients is added to the list */
4333 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4334 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4336 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4338 DBG("wl_array_add: Out of memory\n");
4339 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4340 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4343 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4347 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4351 /* update modifier state */
4352 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4358 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4360 E_Client *ec = NULL;
4361 uint32_t keycode, delivered_key;
4362 E_Comp_Wl_Key_Data *end, *k;
4364 if (ev->window != e_comp->ee_win)
4369 keycode = (ev->keycode - 8);
4371 if (!(e_comp_wl = e_comp->wl_comp_data))
4376 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4378 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4379 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4381 if (k->key == keycode)
4388 e_comp_wl->kbd.keys.size =
4389 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4391 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4393 /* 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) */
4394 if ((delivered_key) ||
4395 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4397 ec = e_client_focused_get();
4399 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4400 if (e_comp_wl->kbd.focused)
4402 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4404 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4407 /* update modifier state */
4408 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4414 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4416 Eina_Bool res = EINA_FALSE;
4418 if (type == ECORE_EVENT_KEY_DOWN)
4420 res = e_comp_wl_key_down(ev, dev);
4422 else if (type == ECORE_EVENT_KEY_UP)
4424 res = e_comp_wl_key_up(ev, dev);
4431 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4434 struct wl_client *wc;
4435 uint32_t serial, btn;
4436 struct wl_resource *res;
4437 E_Comp_Config *comp_conf = NULL;
4439 if (ec->cur_mouse_action || e_comp_wl->drag)
4441 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4442 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4446 case 1: btn = BTN_LEFT; break;
4447 case 2: btn = BTN_MIDDLE; break;
4448 case 3: btn = BTN_RIGHT; break;
4449 default: btn = button_id; break;
4452 e_comp_wl->ptr.button = btn;
4453 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4454 if (!surface) return EINA_FALSE;
4456 if (!eina_list_count(e_comp_wl->ptr.resources))
4459 wc = wl_resource_get_client(surface);
4460 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4462 comp_conf = e_comp_config_get();
4464 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4466 if (wl_resource_get_client(res) != wc) continue;
4467 if (!e_comp_wl_input_pointer_check(res)) continue;
4468 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4470 if (comp_conf && comp_conf->input_log_enable)
4471 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4473 wl_pointer_send_button(res, serial, timestamp, btn, state);
4480 e_comp_wl_touch_cancel(void)
4482 _e_comp_wl_touch_cancel();
4485 E_API E_Comp_Wl_Hook *
4486 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4490 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4491 ch = E_NEW(E_Comp_Wl_Hook, 1);
4492 if (!ch) return NULL;
4493 ch->hookpoint = hookpoint;
4495 ch->data = (void*)data;
4496 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4501 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4504 if (_e_comp_wl_hooks_walking == 0)
4506 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4510 _e_comp_wl_hooks_delete++;
4513 E_API E_Comp_Wl_Pid_Hook *
4514 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4516 E_Comp_Wl_Pid_Hook *ch;
4518 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4520 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4521 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4523 ch->hookpoint = hookpoint;
4525 ch->data = (void*)data;
4526 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4532 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4535 if (_e_comp_wl_pid_hooks_walking == 0)
4537 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4541 _e_comp_wl_pid_hooks_delete++;
4544 E_API E_Comp_Wl_Intercept_Hook *
4545 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4547 E_Comp_Wl_Intercept_Hook *ch;
4549 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4550 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4551 if (!ch) return NULL;
4552 ch->hookpoint = hookpoint;
4554 ch->data = (void*)data;
4555 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4560 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4563 if (_e_comp_wl_intercept_hooks_walking == 0)
4565 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4569 _e_comp_wl_intercept_hooks_delete++;
4573 e_comp_wl_shell_surface_ready(E_Client *ec)
4577 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4581 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4583 e_config->use_cursor_timer = !!enabled;
4585 if (e_config->use_cursor_timer)
4587 if (!e_pointer_is_hidden(e_comp->pointer))
4589 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4594 if (e_comp_wl->ptr.hide_tmr)
4596 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4597 e_comp_wl->ptr.hide_tmr = NULL;
4599 cursor_timer_ec = NULL;
4601 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4604 if (e_pointer_is_hidden(e_comp->pointer))
4606 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4612 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4614 EINA_SAFETY_ON_NULL_RETURN(wc);
4615 EINA_SAFETY_ON_NULL_RETURN(dev);
4617 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4621 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4623 EINA_SAFETY_ON_NULL_RETURN(wc);
4624 EINA_SAFETY_ON_NULL_RETURN(dev);
4626 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4630 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4632 struct wl_resource *res;
4633 struct wl_client *wc;
4635 uint32_t serial, wl_keycode;
4636 enum wl_keyboard_key_state state;
4637 E_Comp_Config *comp_conf = NULL;
4638 const char *dev_name = NULL;
4640 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4641 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4642 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4644 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4645 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4647 wl_keycode = keycode - 8;
4648 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4650 wc = wl_resource_get_client(surface);
4651 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4652 if (!time) time = e_util_timestamp_get();
4653 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4654 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4656 comp_conf = e_comp_config_get();
4657 e_keyrouter_event_surface_send(ec, keycode);
4659 if (e_config->key_input_ttrace_enable)
4661 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4662 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4665 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4666 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4668 if (wl_resource_get_client(res) != wc) continue;
4669 if (!e_input_thread_mode_get())
4673 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4674 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4678 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4685 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4686 dev_name = e_device_name_get(dev);
4690 if (comp_conf && comp_conf->input_log_enable)
4691 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4694 wl_keyboard_send_key(res, serial, time,
4697 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4699 if (e_config->key_input_ttrace_enable)
4702 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4709 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4711 struct wl_resource *res;
4712 struct wl_client *wc;
4714 uint32_t serial, wl_keycode, cancel_keycode;
4715 E_Comp_Config *comp_conf = NULL;
4716 struct xkb_keymap *keymap = NULL;
4718 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4719 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4720 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4722 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4723 keymap = e_comp_wl->xkb.keymap;
4724 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4725 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4727 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4728 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4730 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4731 if (cancel_keycode == XKB_KEYCODE_INVALID)
4733 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4736 cancel_keycode = cancel_keycode - 8;
4738 wl_keycode = keycode - 8;
4739 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4741 wc = wl_resource_get_client(surface);
4742 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4743 if (!time) time = e_util_timestamp_get();
4745 comp_conf = e_comp_config_get();
4746 e_keyrouter_event_surface_send(ec, keycode);
4748 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4749 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4751 if (wl_resource_get_client(res) != wc) continue;
4752 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4753 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4755 if (comp_conf && comp_conf->input_log_enable)
4756 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4757 wl_keyboard_send_key(res, serial, time,
4758 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4759 wl_keyboard_send_key(res, serial, time,
4760 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4761 wl_keyboard_send_key(res, serial, time,
4762 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4764 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4771 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)
4773 struct wl_client *wc;
4775 E_Devicemgr_Input_Device *device = NULL;
4777 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4778 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4779 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4781 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4782 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4784 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4786 wc = wl_resource_get_client(surface);
4787 if (!time) time = e_util_timestamp_get();
4788 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4792 _e_comp_wl_send_event_device(wc, time, dev, serial);
4793 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4797 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4798 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4801 x = x + ec->client.x;
4802 y = y + ec->client.y;
4804 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4810 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)
4812 E_Devicemgr_Input_Device *device;
4814 struct wl_client *wc;
4816 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4817 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4818 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4820 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4821 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4823 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4825 wc = wl_resource_get_client(surface);
4826 if (!time) time = e_util_timestamp_get();
4827 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4831 _e_comp_wl_send_event_device(wc, time, dev, serial);
4832 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4836 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4837 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4840 x = x + ec->client.x;
4841 y = y + ec->client.y;
4843 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4849 e_comp_wl_touch_cancel_send(E_Client *ec)
4851 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4852 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4853 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4855 _e_comp_wl_send_touch_cancel(ec);
4861 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4864 struct wl_client *wc;
4866 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4870 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4871 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4873 wc = wl_resource_get_client(surface);
4874 if (!time) time = e_util_timestamp_get();
4875 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4877 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4878 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4881 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4882 WL_POINTER_BUTTON_STATE_PRESSED);
4884 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4885 WL_POINTER_BUTTON_STATE_RELEASED);
4891 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4894 struct wl_client *wc;
4896 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4897 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4898 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4900 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4901 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4903 wc = wl_resource_get_client(surface);
4904 if (!time) time = e_util_timestamp_get();
4905 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4907 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4908 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4910 x = x + ec->client.x;
4911 y = y + ec->client.y;
4913 _e_comp_wl_send_mouse_move(ec, x, y, time);
4919 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4922 struct wl_client *wc;
4924 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4925 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4926 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4928 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4929 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4931 wc = wl_resource_get_client(surface);
4932 if (!time) time = e_util_timestamp_get();
4933 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4935 if (_e_comp_wl_check_cursor_timer_needed(ec))
4937 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4941 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4942 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4944 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4946 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4948 if (_e_comp_wl_check_cursor_timer_needed(ec))
4949 _e_comp_wl_cursor_move_timer_control(ec);
4956 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4959 struct wl_client *wc;
4960 struct wl_resource *res;
4963 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4964 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4966 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4967 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4969 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4970 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4972 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4973 wc = wl_resource_get_client(surface);
4974 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4975 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4977 if (!e_comp_wl_input_pointer_check(res)) continue;
4978 if (wl_resource_get_client(res) != wc) continue;
4980 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4981 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4983 wl_pointer_send_enter(res, serial, surface,
4984 wl_fixed_from_int(x),
4985 wl_fixed_from_int(y));
4986 ec->pointer_enter_sent = EINA_TRUE;
4988 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4994 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4997 struct wl_client *wc;
4998 struct wl_resource *res;
5001 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5002 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5003 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5004 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5005 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5006 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5008 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5009 wc = wl_resource_get_client(surface);
5010 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5011 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5013 if (!e_comp_wl_input_pointer_check(res)) continue;
5014 if (wl_resource_get_client(res) != wc) continue;
5016 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5017 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5019 wl_pointer_send_leave(res, serial, surface);
5020 ec->pointer_enter_sent = EINA_FALSE;
5027 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)
5029 Evas_Event_Mouse_In ev_in;
5032 if (ec->pointer_enter_sent) return;
5034 ev_in.buttons = buttons;
5042 ev_in.modifiers = modifiers;
5043 ev_in.locks = locks;
5044 ev_in.timestamp = timestamp;
5045 ev_in.event_flags = event_flags;
5048 ev_in.event_src = event_src;
5050 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5054 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)
5056 Evas_Event_Mouse_Out ev_out;
5059 if (!ec->pointer_enter_sent) return;
5061 ev_out.buttons = buttons;
5063 ev_out.output.x = x;
5064 ev_out.output.y = y;
5065 ev_out.canvas.x = x;
5066 ev_out.canvas.y = y;
5069 ev_out.modifiers = modifiers;
5070 ev_out.locks = locks;
5071 ev_out.timestamp = timestamp;
5072 ev_out.event_flags = event_flags;
5075 ev_out.event_src = event_src;
5077 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5081 e_comp_wl_cursor_hide(E_Client *ec)
5083 struct wl_resource *res;
5084 struct wl_client *wc;
5088 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5090 if (e_comp_wl->ptr.hide_tmr)
5092 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5093 e_comp_wl->ptr.hide_tmr = NULL;
5095 cursor_timer_ec = NULL;
5097 if (!ec) return EINA_FALSE;
5098 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5099 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5100 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5102 wc = wl_resource_get_client(surface);
5103 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5104 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5106 if (!e_comp_wl_input_pointer_check(res)) continue;
5107 if (wl_resource_get_client(res) != wc) continue;
5108 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5109 wl_pointer_send_leave(res, serial, surface);
5110 ec->pointer_enter_sent = EINA_FALSE;
5116 /* surface to buffer
5117 * - width : surface width
5118 * - height : surface height
5119 * - transform: buffer transform
5120 * - scale : buffer scale
5122 * - width : screen width
5123 * - height : screen height
5124 * - transform: output transform
5125 * - scale : output scale
5127 static E_Util_Transform_Matrix
5128 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5130 E_Util_Transform_Matrix m;
5132 e_util_transform_matrix_load_identity(&m);
5134 if (transform & 0x4)
5136 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5137 e_util_transform_matrix_flip_x(&m);
5138 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5141 switch (transform & 0x3)
5143 case WL_OUTPUT_TRANSFORM_90:
5144 e_util_transform_matrix_translate(&m, -width, 0, 0);
5145 e_util_transform_matrix_rotation_z(&m, 270);
5147 case WL_OUTPUT_TRANSFORM_180:
5148 e_util_transform_matrix_translate(&m, -width, -height, 0);
5149 e_util_transform_matrix_rotation_z(&m, 180);
5151 case WL_OUTPUT_TRANSFORM_270:
5152 e_util_transform_matrix_translate(&m, 0, -height, 0);
5153 e_util_transform_matrix_rotation_z(&m, 90);
5159 e_util_transform_matrix_scale(&m, scale, scale, 1);
5164 /* surface to buffer
5165 * - surface width, surface height, buffer transform, buffer scale
5167 * - screen width, screen height, output transform, output scale
5170 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5172 E_Util_Transform_Matrix m;
5173 E_Util_Transform_Vertex v;
5175 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5177 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5178 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5179 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5183 * - buffer width, buffer height, buffer transform, buffer scale
5186 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5188 E_Util_Transform_Matrix m;
5189 E_Util_Transform_Vertex v;
5192 if (transform != 0 || scale > 1)
5194 tw = ((transform % 2) ? height : width) / scale;
5195 th = ((transform % 2) ? width : height) / scale;
5203 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5204 m = e_util_transform_matrix_inverse_get(&m);
5206 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5207 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5208 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5211 /* surface to buffer
5212 * - surface width, surface height, buffer transform, buffer scale
5214 * - screen width, screen height, output transform, output scale
5217 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5218 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5220 E_Util_Transform_Matrix m;
5221 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5222 E_Util_Transform_Rect_Vertex sv;
5224 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5226 sv = e_util_transform_rect_to_vertices(&sr);
5227 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5228 sr = e_util_transform_vertices_to_rect(&sv);
5237 * - buffer width, buffer height, buffer transform, buffer scale
5240 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5241 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5243 E_Util_Transform_Matrix m;
5244 E_Util_Transform_Rect br = {bx, by, bw, bh};
5245 E_Util_Transform_Rect_Vertex bv;
5248 if (transform != 0 || scale > 1)
5250 tw = ((transform % 2) ? height : width) / scale;
5251 th = ((transform % 2) ? width : height) / scale;
5259 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5260 m = e_util_transform_matrix_inverse_get(&m);
5262 bv = e_util_transform_rect_to_vertices(&br);
5263 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5264 br = e_util_transform_vertices_to_rect(&bv);
5272 EINTERN E_Comp_Wl_Output*
5273 e_comp_wl_output_find(E_Client *ec)
5276 E_Comp_Wl_Output *output;
5278 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5280 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5282 if (output->transform % 2)
5284 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5285 ec->y < output->x || ec->y >= (output->x + output->w))
5290 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5291 ec->y < output->y || ec->y >= (output->y + output->h))
5301 EINTERN Eina_Array *
5302 e_comp_wl_output_find_all(E_Client *ec)
5304 E_Comp_Wl_Output *output;
5305 Eina_Array *outputs;
5308 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5310 outputs = eina_array_new(4);
5314 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5316 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5317 output->x, output->y, output->w, output->h))
5319 eina_array_push(outputs, output);
5323 if (eina_array_count(outputs) == 0)
5325 eina_array_free(outputs);
5332 // --------------------------------------------------------
5333 // tizen_move_resize
5334 // --------------------------------------------------------
5336 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5343 E_Client_Pending_Geometry *geo;
5346 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5347 if (ec->fullscreen || ec->maximized) goto err;
5349 geo = E_NEW(E_Client_Pending_Geometry, 1);
5352 geo->serial = serial;
5358 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5359 ec->surface_sync.wait_commit = EINA_TRUE;
5364 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5371 e_comp_wl_commit_sync_configure(E_Client *ec)
5374 E_Client_Pending_Geometry *geo;
5376 Eina_Bool match_size = EINA_FALSE;
5383 if (!ec || !ec->frame) goto ret;
5384 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5387 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5388 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5390 if (eina_list_count(ec->surface_sync.pending_geometry))
5392 Eina_List *ll = NULL;
5393 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5397 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5402 if ((geo->w == bw) && (geo->h == bh))
5404 match_size = EINA_TRUE;
5409 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5416 if ((config.w != ec->w) || (config.h != ec->h))
5418 e_client_size_set(ec, config.w, config.h);
5419 ec->changes.size = EINA_TRUE;
5423 // FIXME: The geometry of the client would be better to be calculated
5424 // at e_desk or at e_desk_area. So the position(x,y) of the client
5425 // should be calcuated at the e_desk or at the e_desk_area.
5427 desk = e_comp_desk_find_by_ec(ec);
5430 ec->client.x = desk->geom.x + config.x;
5431 ec->client.y = desk->geom.y + config.y;
5435 ec->client.x = config.x;
5436 ec->client.y = config.y;
5439 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5441 e_client_pos_set(ec, ec->client.x, ec->client.y);
5443 ec->changes.pos = 1;
5447 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5451 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5452 ec->surface_sync.wait_commit = EINA_FALSE;
5454 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5456 // rollback wait_commit if there are pending requests remained
5457 if (eina_list_count(ec->surface_sync.pending_geometry))
5458 ec->surface_sync.wait_commit = EINA_TRUE;
5463 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);
5470 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5471 struct wl_resource *res_moveresize)
5473 wl_resource_destroy(res_moveresize);
5477 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5478 struct wl_resource *res_moveresize,
5479 struct wl_resource *surface,
5486 /* to be implemented */
5489 int cur_w = 0, cur_h = 0;
5491 ec = e_client_from_surface_resource(surface);
5494 pending = e_client_pending_geometry_has(ec);
5495 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5496 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);
5500 if ((cur_w == w) && (cur_h == h))
5502 e_client_pos_set(ec, x, y);
5503 ec->changes.pos = 1;
5509 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5513 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5516 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5518 _tz_move_resize_iface_cb_destroy,
5519 _tz_move_resize_iface_cb_set_geometry,
5523 _tz_moveresize_cb_bind(struct wl_client *client,
5524 void *data EINA_UNUSED,
5528 struct wl_resource *res_moveresize;
5530 res_moveresize = wl_resource_create(client,
5531 &tizen_move_resize_interface,
5534 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5537 wl_resource_set_implementation(res_moveresize,
5538 &_tz_move_resize_iface,
5544 ERR("Could not create tizen_move_resize_interface res: %m");
5545 wl_client_post_no_memory(client);
5549 _e_comp_wl_move_resize_init(void)
5551 if (!e_comp_wl) return;
5552 if (!e_comp_wl->wl.disp) return;
5554 if (!wl_global_create(e_comp_wl->wl.disp,
5555 &tizen_move_resize_interface,
5558 _tz_moveresize_cb_bind))
5560 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5567 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5569 E_Comp_Wl_Output *output;
5570 pid_t output_pid = 0;
5571 Eina_List *l = NULL, *l2 = NULL;
5572 struct wl_resource *resource = NULL;
5574 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5576 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5577 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5578 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5580 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5582 /* if we have bound resources, send updates */
5583 EINA_LIST_FOREACH(output->resources, l2, resource)
5585 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5586 if (output_pid != pid) continue;
5588 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5590 // send output information to the client
5591 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5599 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5601 _e_comp_wl_surface_state_init(state, w, h);
5605 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5607 _e_comp_wl_surface_state_commit(ec, state);
5611 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5613 _e_comp_wl_hook_call(hookpoint, ec);
5617 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5619 _e_comp_wl_surface_state_finish(state);
5623 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5625 _e_comp_wl_surface_state_buffer_set(state, buffer);
5629 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5630 int sx, int sy, int *dx, int *dy)
5634 case WL_OUTPUT_TRANSFORM_NORMAL:
5638 case WL_OUTPUT_TRANSFORM_FLIPPED:
5639 *dx = width - sx, *dy = sy;
5641 case WL_OUTPUT_TRANSFORM_90:
5642 *dx = height - sy, *dy = sx;
5644 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5645 *dx = height - sy, *dy = width - sx;
5647 case WL_OUTPUT_TRANSFORM_180:
5648 *dx = width - sx, *dy = height - sy;
5650 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5651 *dx = sx, *dy = height - sy;
5653 case WL_OUTPUT_TRANSFORM_270:
5654 *dx = sy, *dy = width - sx;
5656 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5666 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5669 int tx1, ty1, tx2, ty2;
5670 int width_from_buffer, height_from_buffer;
5672 switch (vp->buffer.transform)
5674 case WL_OUTPUT_TRANSFORM_90:
5675 case WL_OUTPUT_TRANSFORM_270:
5676 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5677 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5678 width_from_buffer = bh / vp->buffer.scale;
5679 height_from_buffer = bw / vp->buffer.scale;
5682 width_from_buffer = bw / vp->buffer.scale;
5683 height_from_buffer = bh / vp->buffer.scale;
5687 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5691 x2 = width_from_buffer;
5692 y2 = height_from_buffer;
5696 x1 = wl_fixed_to_int(vp->buffer.src_x);
5697 y1 = wl_fixed_to_int(vp->buffer.src_y);
5698 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5699 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5702 buffer_transform(width_from_buffer, height_from_buffer,
5703 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5704 buffer_transform(width_from_buffer, height_from_buffer,
5705 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5707 out->x = (tx1 <= tx2) ? tx1 : tx2;
5708 out->y = (ty1 <= ty2) ? ty1 : ty2;
5709 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5710 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5714 * Convert given four coordinates to elements of rectangle
5715 * @in p[4] Coordinates to be converted
5716 * @out rect x, y, width, and height
5717 * transform Angle which represents TDM_TRANSFORM of rectangle
5718 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5719 * 1. The given coordinates are not represented by rectangle.
5720 * 2. All angles except for 0, 90, 180, 270.
5723 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5725 Eina_Bool ret = EINA_FALSE;
5727 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))
5730 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5733 *rotation = TDM_TRANSFORM_NORMAL;
5736 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5740 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5743 *rotation = TDM_TRANSFORM_180;
5746 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5751 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))
5754 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5757 *rotation = TDM_TRANSFORM_90;
5760 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5764 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5767 *rotation = TDM_TRANSFORM_270;
5770 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5780 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5785 for (i = 0; i < 4; i++)
5786 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5788 if (!_coords_to_rectangle_convert(p, out, rotation))
5790 DBG("Cannot convert given coords to rectangle.\n"
5791 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5792 p[0].x, p[0].y, p[1].x, p[1].y,
5793 p[2].x, p[2].y, p[3].x, p[3].y);
5801 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5803 int trans_rotation, flip;
5805 trans_rotation = transform & 0x3;
5806 flip = transform & 0x4;
5808 return (flip + (trans_rotation + rotation) % 4);
5812 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5820 if (e_comp_wl_subsurface_check(ec))
5821 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5828 out->w = ec->comp_data->width_from_viewport;
5829 out->w = (out->w + 1) & ~1;
5830 out->h = ec->comp_data->height_from_viewport;
5832 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5833 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5837 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5839 E_Comp_Wl_Buffer *buffer;
5840 E_Comp_Wl_Buffer_Viewport *vp;
5842 enum wl_output_transform buffer_transform;
5843 unsigned int rotation;
5844 Eina_Bool res = EINA_FALSE;
5846 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5848 if (e_object_is_del(E_OBJECT(ec)))
5851 vp = &ec->comp_data->scaler.buffer_viewport;
5853 if (buffer_viewport)
5855 buffer = ec->comp_data->buffer_ref.buffer;
5856 /* Getting a viewport of buffer needs geometry of buffer. */
5860 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5863 if ((output_viewport) || (transform))
5865 m = e_client_map_get(ec);
5867 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5869 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5874 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5875 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5876 * Since buffer.transform isn't applied using evas_map,
5877 * it has to be taken into account here to apply buffer.transform
5878 * and rotation of e_client_transform together. */
5880 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5882 *transform = (unsigned int)buffer_transform;
5890 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5892 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5893 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5895 /* Must be called with valid comp_data */
5896 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5898 if ((ec->comp_data->role_name == NULL) ||
5899 (ec->comp_data->role_name == role_name) ||
5900 (strcmp(ec->comp_data->role_name, role_name) == 0))
5902 ec->comp_data->role_name = role_name;
5908 wl_resource_post_error(error_resource, error_code,
5909 "Cannot assign role %s to wl_surface@%d,"
5910 " already has role %s\n",
5912 ec->comp_data->wl_surface ?
5913 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5914 ec->comp_data->role_name);
5920 EINTERN const char *
5921 e_comp_wl_surface_role_get(E_Client *ec)
5923 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5924 return ec->comp_data ? ec->comp_data->role_name : NULL;
5927 EINTERN struct wl_resource *
5928 e_comp_wl_client_surface_get(E_Client *ec)
5930 struct wl_resource *surface = NULL;
5931 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5932 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5934 g_mutex_lock(&ec->comp_data->surface_mutex);
5935 surface = ec->comp_data->surface;
5936 g_mutex_unlock(&ec->comp_data->surface_mutex);
5941 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5943 EINA_SAFETY_ON_NULL_RETURN(ec);
5944 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5946 g_mutex_lock(&ec->comp_data->surface_mutex);
5947 ec->comp_data->surface = surface;
5948 g_mutex_unlock(&ec->comp_data->surface_mutex);
5952 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5954 return e_compositor_util_client_from_surface_resource(surface_resource);
5958 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5960 if (!ec->comp_data->mapped)
5962 if (ec->comp_data->shell.surface &&
5963 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5965 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5971 if (ec->comp_data->mapped)
5973 /* will be unmapped. so run capture */
5974 e_comp_wl_remote_surface_image_save(ec);
5978 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5980 ec->comp_data->pending.sx = sx;
5981 ec->comp_data->pending.sy = sy;
5982 ec->comp_data->pending.new_attach = EINA_TRUE;
5984 e_client_fps_update(ec);
5988 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5990 if (ec->comp_data->pending.opaque)
5991 eina_tiler_clear(ec->comp_data->pending.opaque);
5995 eina_tiler_union(ec->comp_data->pending.opaque, region);
5997 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6001 ec->argb = EINA_FALSE;
6002 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6004 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6005 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6013 ec->argb = EINA_TRUE;
6014 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6016 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6017 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6023 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6025 if (ec->comp_data->pending.input)
6026 eina_tiler_clear(ec->comp_data->pending.input);
6030 if (eina_tiler_empty(region))
6032 ELOGF("COMP", " |unset input rect", NULL);
6033 e_comp_object_input_objs_del(ec->frame);
6034 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6037 eina_tiler_union(ec->comp_data->pending.input, region);
6041 eina_tiler_rect_add(ec->comp_data->pending.input,
6042 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6047 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6049 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6053 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6055 E_Comp_Wl_Subsurf_Data *sdata;
6060 if (ec->comp_data->frames)
6062 ec->comp_data->frames =
6063 eina_list_remove(ec->comp_data->frames, callback_resource);
6066 if (ec->comp_data->pending.frames)
6068 ec->comp_data->pending.frames =
6069 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6072 sdata = ec->comp_data->sub.data;
6073 if ((sdata) && (sdata->cached.frames))
6075 sdata->cached.frames =
6076 eina_list_remove(sdata->cached.frames, callback_resource);
6081 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6083 if (e_object_is_del(E_OBJECT(ec))) return;
6085 if (e_comp_wl_remote_surface_commit(ec)) return;
6087 e_comp_wl_surface_commit(ec);
6089 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6093 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6095 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6096 ec->comp_data->sub.data = sub;
6098 /* set subsurface client properties */
6099 ec->borderless = EINA_TRUE;
6100 ec->argb = EINA_TRUE;
6101 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6102 ec->lock_border = EINA_TRUE;
6103 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6104 ec->netwm.state.skip_taskbar = EINA_TRUE;
6105 ec->netwm.state.skip_pager = EINA_TRUE;
6106 ec->border_size = 0;
6107 ec->lock_user_location = 0;
6108 ec->lock_client_location = 0;
6109 ec->lock_user_size = 0;
6110 ec->lock_client_size = 0;
6111 ec->lock_client_stacking = 0;
6112 ec->lock_user_maximize = 0;
6113 ec->lock_client_maximize = 0;
6114 ec->changes.need_maximize = 0;
6115 ec->maximized = E_MAXIMIZE_NONE;
6118 ec->new_client = ec->netwm.ping = EINA_TRUE;
6119 e_comp->new_clients++;
6120 e_client_unignore(ec);
6122 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6123 * It's not for subsurface. */
6124 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6128 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6130 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6133 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6135 sub->parent = parent;
6139 layer = e_client_layer_get(parent);
6140 if (layer > E_LAYER_BOTTOM)
6141 e_client_layer_set(ec, layer);
6144 if (parent->comp_data)
6146 /* append this client to the parents subsurface list */
6147 parent->comp_data->sub.list_pending =
6148 eina_list_append(parent->comp_data->sub.list_pending, ec);
6149 parent->comp_data->sub.list_changed = EINA_TRUE;
6154 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6156 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6157 E_Client *parent = sub->parent;
6159 parent->comp_data->sub.list =
6160 eina_list_remove(parent->comp_data->sub.list, ec);
6161 parent->comp_data->sub.list_pending =
6162 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6163 parent->comp_data->sub.below_list =
6164 eina_list_remove(parent->comp_data->sub.below_list, ec);
6165 parent->comp_data->sub.below_list_pending =
6166 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6172 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)
6174 sub->resource = subsurface_resource;
6175 sub->cached_buffer_ref.buffer = NULL;
6176 sub->synchronized = EINA_TRUE;
6177 sub->parent = parent;
6178 sub->remote_surface.offscreen_parent = offscreen_parent;
6179 if (offscreen_parent)
6180 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6182 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6184 _e_comp_wl_client_subsurface_set(ec, sub);
6185 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6187 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6191 e_comp_wl_client_subsurface_finish(E_Client *ec)
6193 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6196 e_comp_wl_client_subsurface_parent_unset(ec);
6198 e_comp_wl_surface_state_finish(&sub->cached);
6199 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6201 ec->comp_data->sub.data = NULL;
6205 e_comp_wl_client_evas_init(E_Client *ec)
6207 EINA_SAFETY_ON_NULL_RETURN(ec);
6209 _e_comp_wl_client_evas_init(ec);
6213 e_comp_wl_client_evas_deinit(E_Client *ec)
6215 EINA_SAFETY_ON_NULL_RETURN(ec);
6217 _e_comp_wl_client_evas_deinit(ec);
6221 e_comp_wl_focus_check(void)
6223 _e_comp_wl_focus_check();
6227 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6234 if ((parent->comp_data) && (parent->comp_data->sub.data))
6235 parent = parent->comp_data->sub.data->parent;