2 #include "e_comp_wl_intern.h"
3 #include "e_comp_wl_private.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_comp_wl_private.h"
7 #include "e_client_intern.h"
8 #include "e_appinfo_intern.h"
9 #include "e_blender_intern.h"
10 #include "e_utils_intern.h"
11 #include "e_scale_intern.h"
12 #include "e_comp_canvas_intern.h"
13 #include "e_comp_screen_intern.h"
14 #include "e_comp_wl_capture_intern.h"
15 #include "e_comp_wl_data_intern.h"
16 #include "e_comp_wl_input_intern.h"
17 #include "e_comp_wl_renderer_intern.h"
18 #include "e_comp_wl_rsm_intern.h"
19 #include "e_comp_wl_screenshooter_intern.h"
20 #include "e_comp_wl_shell_intern.h"
21 #include "e_comp_wl_subsurface_intern.h"
22 #include "e_comp_wl_tbm_intern.h"
23 #include "e_comp_wl_viewport_intern.h"
24 #include "e_comp_intern.h"
25 #include "e_input_intern.h"
27 #include <tizen-extension-server-protocol.h>
28 #include <relative-pointer-unstable-v1-server-protocol.h>
29 #include <pointer-constraints-unstable-v1-server-protocol.h>
31 #include <wayland-tbm-server.h>
33 #include <libds/log.h>
34 #include <libds/single_pixel_buffer_v1.h>
36 /* handle include for printing uint64_t */
37 #define __STDC_FORMAT_MACROS
40 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
42 /* Resource Data Mapping: (wl_resource_get_user_data)
44 * wl_surface == e_pixmap
45 * wl_region == eina_tiler
46 * wl_subsurface == e_client
50 typedef struct _E_Comp_Data E_Comp_Data;
55 struct wl_listener client_created;
58 static void _e_comp_wl_move_resize_init(void);
60 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
63 typedef struct _E_Comp_Wl_Key_Data
69 static Eina_List *handlers = NULL;
70 static E_Client *cursor_timer_ec = NULL;
71 static Eina_Bool need_send_released = EINA_FALSE;
72 static Eina_Bool need_send_motion = EINA_TRUE;
74 static GMutex connection_mutex;
76 static int _e_comp_wl_hooks_delete = 0;
77 static int _e_comp_wl_hooks_walking = 0;
79 static int _e_comp_wl_pid_hooks_delete = 0;
80 static int _e_comp_wl_pid_hooks_walking = 0;
82 static int _e_comp_wl_intercept_hooks_delete = 0;
83 static int _e_comp_wl_intercept_hooks_walking = 0;
85 static Eina_Inlist *_e_comp_wl_hooks[] =
87 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
88 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
89 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
90 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
91 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
92 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
93 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
94 [E_COMP_WL_HOOK_DEL] = NULL,
95 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
96 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
97 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
100 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
102 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
105 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
107 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
108 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
109 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
110 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
111 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
112 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
115 static Eina_List *hooks = NULL;
117 /* local functions */
119 _e_comp_wl_hooks_clean(void)
124 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
125 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
127 if (!ch->delete_me) continue;
128 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
134 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
138 e_object_ref(E_OBJECT(ec));
139 _e_comp_wl_hooks_walking++;
140 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
142 if (ch->delete_me) continue;
143 ch->func(ch->data, ec);
144 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
145 (e_object_is_del(E_OBJECT(ec))))
148 _e_comp_wl_hooks_walking--;
149 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
150 _e_comp_wl_hooks_clean();
151 e_object_unref(E_OBJECT(ec));
155 _e_comp_wl_pid_hooks_clean(void)
158 E_Comp_Wl_Pid_Hook *ch;
160 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
161 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
163 if (!ch->delete_me) continue;
164 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
170 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
172 E_Comp_Wl_Pid_Hook *ch;
174 _e_comp_wl_pid_hooks_walking++;
175 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
177 if (ch->delete_me) continue;
178 ch->func(ch->data, pid);
180 _e_comp_wl_pid_hooks_walking--;
181 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
182 _e_comp_wl_pid_hooks_clean();
186 _e_comp_wl_intercept_hooks_clean(void)
189 E_Comp_Wl_Intercept_Hook *ch;
191 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
192 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
194 if (!ch->delete_me) continue;
195 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
201 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
203 E_Comp_Wl_Intercept_Hook *ch;
204 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
206 e_object_ref(E_OBJECT(ec));
207 _e_comp_wl_intercept_hooks_walking++;
208 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
210 if (ch->delete_me) continue;
211 res = ch->func(ch->data, ec);
212 if (!res) ret = EINA_FALSE;
213 if (e_object_is_del(E_OBJECT(ec)))
216 _e_comp_wl_intercept_hooks_walking--;
217 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
218 _e_comp_wl_intercept_hooks_clean();
219 e_object_unref(E_OBJECT(ec));
226 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
232 if (e_comp_object_frame_exists(ec->frame))
233 w = ec->client.w, h = ec->client.h;
235 w = ec->w, h = ec->h;
239 // Width and Height are -1 means that we don't consider size value
243 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
247 _e_comp_wl_focus_check(void)
251 if (stopping) return;
252 ec = e_client_focused_get();
254 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
258 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
260 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
262 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
263 IDLE_EXITER~CB_PREPARE);
265 return ECORE_CALLBACK_RENEW;
269 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
271 /* dispatch pending wayland events */
272 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
274 return ECORE_CALLBACK_RENEW;
278 e_comp_wl_display_flush()
280 if (e_comp_wl && e_comp_wl->wl.disp)
282 if (e_config->key_input_ttrace_enable)
284 TRACE_INPUT_BEGIN(wl_display_flush_clients);
285 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
288 g_mutex_lock(&connection_mutex);
289 wl_display_flush_clients(e_comp_wl->wl.disp);
290 g_mutex_unlock(&connection_mutex);
292 if (e_config->key_input_ttrace_enable)
295 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
301 e_comp_wl_connection_lock()
303 e_input_boost_lock(&connection_mutex);
307 e_comp_wl_connection_unlock()
309 e_input_boost_unlock(&connection_mutex);
313 e_comp_wl_focused_client_flush()
315 E_Client *focused_ec;
316 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
318 e_input_boost_lock(&connection_mutex);
319 focused_ec = e_client_focused_get();
323 struct wl_client *wc;
324 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
327 e_input_boost_unlock(&connection_mutex);
331 wc = wl_resource_get_client(surface);
335 e_input_boost_unlock(&connection_mutex);
339 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
343 if (e_comp_wl->idle_exiter_timestamp > 0.0)
345 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
346 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
348 ELOGF("E_COMP", "prepare gap time: %lfms",
353 e_comp_wl->idle_exiter_timestamp = 0.0;
355 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
357 /* flush pending client events */
358 e_comp_wl_display_flush();
360 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
361 IDLE_EXITER~CB_PREPARE);
364 E_API enum wl_output_transform
365 e_comp_wl_output_buffer_transform_get(E_Client *ec)
367 E_Comp_Wl_Buffer_Viewport *vp;
368 E_Comp_Wl_Buffer *buffer;
369 enum wl_output_transform transform, rotation;
371 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
372 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
373 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
375 vp = &ec->comp_data->scaler.buffer_viewport;
376 if (e_comp_wl_subsurface_check(ec))
377 return vp->buffer.transform;
379 buffer = ec->comp_data->buffer_ref.buffer;
382 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
383 return vp->buffer.transform;
385 rotation = buffer->transform;
387 return vp->buffer.transform;
389 /* ignore the flip value when calculating transform because the screen rotation
390 * functionality doesn't consider the flip output transform currently
392 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
394 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
395 ec, rotation, vp->buffer.transform, transform);
400 EINTERN enum wl_output_transform
401 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
403 E_Comp_Wl_Buffer_Viewport *vp;
404 E_Comp_Wl_Buffer *buffer;
405 enum wl_output_transform transform, rotation;
407 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
408 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
409 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
411 vp = &ec->comp_data->pending.buffer_viewport;
412 if (e_comp_wl_subsurface_check(ec))
413 return vp->buffer.transform;
415 buffer = ec->comp_data->pending.buffer;
418 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
419 return vp->buffer.transform;
421 rotation = buffer->transform;
423 return vp->buffer.transform;
425 /* ignore the flip value when calculating transform because the screen rotation
426 * functionality doesn't consider the flip output transform currently
428 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
430 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
431 ec, rotation, vp->buffer.transform, transform);
437 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
439 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
440 E_Comp_Wl_Buffer *buffer;
441 int32_t width, height;
443 buffer = e_pixmap_resource_get(ec->pixmap);
446 ec->comp_data->width_from_buffer = 0;
447 ec->comp_data->height_from_buffer = 0;
451 switch (e_comp_wl_output_buffer_transform_get(ec))
453 case WL_OUTPUT_TRANSFORM_90:
454 case WL_OUTPUT_TRANSFORM_270:
455 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
456 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
457 width = buffer->h / vp->buffer.scale;
458 height = buffer->w / vp->buffer.scale;
461 width = buffer->w / vp->buffer.scale;
462 height = buffer->h / vp->buffer.scale;
466 ec->comp_data->width_from_buffer = width;
467 ec->comp_data->height_from_buffer = height;
471 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
473 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
474 int32_t width, height;
476 width = ec->comp_data->width_from_buffer;
477 height = ec->comp_data->height_from_buffer;
479 if (width == 0 && height == 0) return;
481 if (width != 0 && vp->surface.width != -1)
483 ec->comp_data->width_from_viewport = vp->surface.width;
484 ec->comp_data->height_from_viewport = vp->surface.height;
488 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
490 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
491 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
492 ec->comp_data->width_from_viewport = w ?: 1;
493 ec->comp_data->height_from_viewport = h ?: 1;
497 ec->comp_data->width_from_viewport = width;
498 ec->comp_data->height_from_viewport = height;
502 e_comp_wl_topmost_parent_get(E_Client *ec)
506 if (!e_comp_wl_subsurface_check(ec))
509 parent = e_comp_wl_subsurface_parent_get(ec);
512 if (!e_comp_wl_subsurface_check(parent))
515 parent = e_comp_wl_subsurface_parent_get(parent);
522 e_comp_wl_map_apply(E_Client *ec)
524 E_Comp_Wl_Buffer_Viewport *vp;
525 E_Comp_Wl_Subsurf_Data *sdata;
526 E_Comp_Wl_Client_Data *cdata;
527 int x1, y1, x2, y2, x, y;
529 Eina_Bool zoom_animating = EINA_FALSE;
531 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
533 e_comp_object_map_update(ec->frame);
535 cdata = ec->comp_data;
536 vp = &cdata->scaler.buffer_viewport;
537 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
538 (!cdata->viewport_transform))
541 if (e_comp_wl_subsurface_check(ec))
543 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
545 sdata = ec->comp_data->sub.data;
546 if (sdata->remote_surface.offscreen_parent)
548 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
549 Eina_Rectangle *rect;
552 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
554 /* TODO: If there are one more regions, it means that provider's offscreen
555 * is displayed by one more remote_surfaces. Have to consider it later. At
556 * this time, just consider only one remote_surface.
570 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
571 if (x != dx || y != dy)
572 evas_object_move(ec->frame, dx, dy);
574 if (!cdata->viewport_transform)
576 cdata->viewport_transform = e_util_transform_new();
577 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
578 e_client_transform_core_add(ec, cdata->viewport_transform);
581 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
582 ec->comp_data->width_from_viewport,
583 ec->comp_data->height_from_viewport);
585 if (vp->buffer.src_width == wl_fixed_from_int(-1))
589 x2 = cdata->width_from_buffer;
590 y2 = cdata->height_from_buffer;
594 x1 = wl_fixed_to_int(vp->buffer.src_x);
595 y1 = wl_fixed_to_int(vp->buffer.src_y);
596 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
597 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
600 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
601 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
602 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
603 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
606 desk = e_comp_desk_find_by_ec(ec);
608 zoom_animating = e_desk_zoom_is_animating(desk);
610 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
611 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
612 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
614 /* workaround:: when the desk zoom is doing their animation,
615 the transform core update can override animation's zoom boundary.
616 so, don't doing transform core update while desk zoom animation */
618 e_client_transform_core_update(ec);
623 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
627 int map_c = 0, map_x = 0, map_y = 0;
628 double inv_x = 0.0, inv_y = 0.0;
630 EINA_SAFETY_ON_NULL_RETURN(ec);
632 map = e_client_map_get(ec);
633 map_c = e_map_count_get(map);
635 if (!map || map_c <= 0)
645 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
646 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
647 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
648 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
650 for (int i = 0; i < map_c; i++)
652 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
653 e_map_point_image_uv_set(map2, i, map_x, map_y);
655 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
665 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
671 if (!(ec = data)) return;
672 if (e_object_is_del(data)) return;
674 if (!ec->override) e_hints_window_visible_set(ec);
676 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
677 (!ec->comp_data->need_reparent))
679 ec->comp_data->need_reparent = EINA_TRUE;
680 ec->visible = EINA_TRUE;
682 if (!e_client_util_ignored_get(ec))
684 ec->take_focus = !starting;
688 if (!ec->comp_data->need_reparent)
690 if ((ec->hidden) || (ec->iconic))
692 evas_object_hide(ec->frame);
693 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
696 evas_object_show(ec->frame);
699 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
700 evas_object_show(tmp->frame);
702 topmost = e_comp_wl_topmost_parent_get(ec);
703 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
704 e_comp_wl_subsurface_show(ec);
706 if (ec->comp_data->sub.below_obj)
707 evas_object_show(ec->comp_data->sub.below_obj);
711 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
717 if (!(ec = data)) return;
718 if (e_object_is_del(E_OBJECT(ec))) return;
720 /* Uncommonly some clients's final buffer can be skipped if the client
721 * requests unmap of its surface right after wl_surface@commit.
722 * So if this client evas object is hidden state and client is already
723 * unmmapped, we can consider to clear pixmap image here mandatorily.
725 if (!ec->comp_data->mapped)
726 e_pixmap_image_clear(ec->pixmap, 1);
728 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
729 evas_object_hide(tmp->frame);
731 topmost = e_comp_wl_topmost_parent_get(ec);
732 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
733 e_comp_wl_subsurface_hide(ec);
735 if (ec->comp_data->sub.below_obj)
736 evas_object_hide(ec->comp_data->sub.below_obj);
738 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
742 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
749 if (!(ec = data)) return;
750 if (e_object_is_del(E_OBJECT(ec))) return;
752 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
754 if (!e_comp_wl_subsurface_check(subc)) continue;
755 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
756 evas_object_move(subc->frame, x, y);
758 if (subc->comp_data->scaler.viewport)
760 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
761 if (cdata->viewport_transform)
762 e_comp_wl_map_apply(subc);
766 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
768 if (!e_comp_wl_subsurface_check(subc)) continue;
769 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
770 evas_object_move(subc->frame, x, y);
772 if (subc->comp_data->scaler.viewport)
774 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
775 if (cdata->viewport_transform)
776 e_comp_wl_map_apply(subc);
780 if (ec->comp_data->sub.below_obj)
782 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
783 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
788 _e_comp_wl_send_touch_cancel(E_Client *ec)
791 struct wl_resource *res;
792 struct wl_client *wc;
793 E_Comp_Config *comp_conf = NULL;
796 if (e_object_is_del(E_OBJECT(ec))) return;
797 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
799 if (!surface) return;
800 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
802 wc = wl_resource_get_client(surface);
804 comp_conf = e_comp_config_get();
806 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
808 if (wl_resource_get_client(res) != wc) continue;
809 if (!e_comp_wl_input_touch_check(res)) continue;
811 if (comp_conf && comp_conf->input_log_enable)
812 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
814 wl_touch_send_cancel(res);
819 _e_comp_wl_touch_cancel(void)
823 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
825 if (!e_comp_wl->touch.pressed) return;
827 _e_comp_wl_send_touch_cancel(ec);
830 static E_Devicemgr_Input_Device *
831 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
833 E_Devicemgr_Input_Device *last_kbd = NULL;
836 case ECORE_DEVICE_CLASS_MOUSE:
837 return e_devicemgr->last_device_ptr;
838 case ECORE_DEVICE_CLASS_KEYBOARD:
839 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
841 case ECORE_DEVICE_CLASS_TOUCH:
842 return e_devicemgr->last_device_touch;
850 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
854 case ECORE_DEVICE_CLASS_MOUSE:
855 e_devicemgr->last_device_ptr = device;
857 case ECORE_DEVICE_CLASS_KEYBOARD:
858 atomic_store(&e_devicemgr->last_device_kbd, device);
860 case ECORE_DEVICE_CLASS_TOUCH:
861 e_devicemgr->last_device_touch = device;
868 static E_Devicemgr_Input_Device *
869 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
871 E_Devicemgr_Input_Device *last_kbd = NULL;
875 case ECORE_DEVICE_CLASS_MOUSE:
876 return ec->comp_data->last_device_ptr;
877 case ECORE_DEVICE_CLASS_KEYBOARD:
878 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
880 case ECORE_DEVICE_CLASS_TOUCH:
881 return ec->comp_data->last_device_touch;
889 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
893 case ECORE_DEVICE_CLASS_MOUSE:
894 ec->comp_data->last_device_ptr = device;
896 case ECORE_DEVICE_CLASS_KEYBOARD:
897 atomic_store(&ec->comp_data->last_device_kbd, device);
899 case ECORE_DEVICE_CLASS_TOUCH:
900 ec->comp_data->last_device_touch = device;
908 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
910 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
911 struct wl_resource *dev_res;
912 const char *dev_name;
913 Ecore_Device_Class dev_class;
914 struct wl_client *wc;
918 EINA_SAFETY_ON_NULL_RETURN(dev);
921 if (ec->cur_mouse_action || e_comp_wl->drag)
923 if (e_object_is_del(E_OBJECT(ec))) return;
924 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
925 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
926 if (!surface) return;
928 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
929 dev_name = evas_device_description_get(dev);
930 last_device = _e_comp_wl_device_last_device_get(dev_class);
931 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
933 serial = wl_display_next_serial(e_comp_wl->wl.disp);
934 wc = wl_resource_get_client(surface);
935 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
936 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
938 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
939 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
941 _e_comp_wl_device_last_device_set(dev_class, input_dev);
942 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
944 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
946 if (wl_resource_get_client(dev_res) != wc) continue;
947 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
951 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
955 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
957 E_Devicemgr_Input_Device *last_device;
958 struct wl_resource *dev_res;
959 struct wl_client *wc;
963 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
964 if (!surface) return;
966 last_device = _e_comp_wl_device_last_device_get(dev_class);
967 if (!last_device) return;
969 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
971 serial = wl_display_next_serial(e_comp_wl->wl.disp);
972 wc = wl_resource_get_client(surface);
973 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
975 if (wl_resource_get_client(dev_res) != wc) continue;
976 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
981 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
983 E_Devicemgr_Input_Device *input_dev;
984 struct wl_resource *dev_res;
985 const char *dev_name;
988 EINA_SAFETY_ON_NULL_RETURN(dev);
990 dev_name = ecore_device_identifier_get(dev);
992 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
993 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
995 if (!eina_streq(input_dev->identifier, dev_name) ||
996 (input_dev->clas != ecore_device_class_get(dev))) continue;
997 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
999 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1001 if (wl_resource_get_client(dev_res) != wc) continue;
1002 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1005 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1009 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1011 E_Devicemgr_Input_Device *input_dev;
1012 struct wl_resource *dev_res;
1013 const char *dev_name;
1016 EINA_SAFETY_ON_NULL_RETURN(dev);
1018 dev_name = e_device_identifier_get(dev);
1020 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1021 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1023 if (!eina_streq(input_dev->identifier, dev_name) ||
1024 (input_dev->clas != e_device_class_get(dev))) continue;
1025 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1027 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1029 if (wl_resource_get_client(dev_res) != wc) continue;
1030 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1033 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1037 _e_comp_wl_cursor_reload(E_Client *ec)
1039 struct wl_resource *res;
1040 struct wl_client *wc;
1046 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1047 !evas_object_visible_get(e_comp->pointer->o_ptr))
1048 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1051 if (e_object_is_del(E_OBJECT(ec))) return;
1052 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1053 if (!surface) return;
1054 if (ec->pointer_enter_sent) return;
1056 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1057 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1059 if (e_client_transform_core_enable_get(ec))
1061 double dx = 0.0, dy = 0.0;
1062 map = e_client_map_get(ec);
1063 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1069 cx = px - ec->client.x;
1070 cy = py - ec->client.y;
1072 wc = wl_resource_get_client(surface);
1073 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1074 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1076 if (!e_comp_wl_input_pointer_check(res)) continue;
1077 if (wl_resource_get_client(res) != wc) continue;
1078 wl_pointer_send_enter(res, serial, surface,
1079 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1080 ec->pointer_enter_sent = EINA_TRUE;
1082 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1086 _e_comp_wl_cursor_timer(void *data)
1088 E_Client *ec = data;
1090 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1091 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1093 e_comp_wl_cursor_hide(ec);
1095 return ECORE_CALLBACK_CANCEL;
1099 _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)
1101 E_Devicemgr_Input_Device *input_dev;
1102 struct wl_resource *dev_res;
1103 struct wl_client *wc;
1108 if (ec->cur_mouse_action) return;
1109 if (e_object_is_del(E_OBJECT(ec))) return;
1110 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1111 if (!surface) return;
1113 f_value = wl_fixed_from_double(value);
1114 wc = wl_resource_get_client(surface);
1116 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1117 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1119 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1120 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1122 if (wl_resource_get_client(dev_res) != wc) continue;
1123 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1126 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1130 _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)
1132 if (idx >= e_input_touch_max_count_get()) return;
1134 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1135 e_devicemgr->multi[idx].radius_x = radius_x;
1136 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1137 e_devicemgr->multi[idx].radius_y = radius_y;
1138 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1139 e_devicemgr->multi[idx].pressure = pressure;
1140 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1141 e_devicemgr->multi[idx].angle = angle;
1145 _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)
1147 if (idx >= e_input_touch_max_count_get()) return;
1149 if (e_devicemgr->multi[idx].radius_x != radius_x)
1151 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1152 e_devicemgr->multi[idx].radius_x = radius_x;
1154 if (e_devicemgr->multi[idx].radius_y != radius_y)
1156 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1157 e_devicemgr->multi[idx].radius_y = radius_y;
1159 if (e_devicemgr->multi[idx].pressure != pressure)
1161 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1162 e_devicemgr->multi[idx].pressure = pressure;
1164 if (e_devicemgr->multi[idx].angle != angle)
1166 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1167 e_devicemgr->multi[idx].angle = angle;
1172 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1174 Eina_Bool ret = EINA_TRUE;
1177 case EVAS_CALLBACK_MOUSE_IN:
1178 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1181 if (e_comp_wl->ptr.hide_tmr)
1183 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1184 cursor_timer_ec = ec;
1185 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1189 if (e_pointer_is_hidden(e_comp->pointer))
1194 case EVAS_CALLBACK_MOUSE_OUT:
1195 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1198 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1202 case EVAS_CALLBACK_MOUSE_MOVE:
1203 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1206 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1207 _e_comp_wl_cursor_reload(ec);
1210 case EVAS_CALLBACK_MOUSE_WHEEL:
1211 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1214 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1215 _e_comp_wl_cursor_reload(ec);
1218 case EVAS_CALLBACK_MOUSE_DOWN:
1219 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1222 if (e_comp_wl->ptr.hide_tmr)
1224 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1225 e_comp_wl->ptr.hide_tmr = NULL;
1227 cursor_timer_ec = NULL;
1229 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1230 _e_comp_wl_cursor_reload(ec);
1233 case EVAS_CALLBACK_MOUSE_UP:
1234 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1245 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1247 if (ec->has_cursor_unset)
1250 if (!e_config->show_cursor)
1253 if (!e_config->use_cursor_timer)
1260 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1263 Evas_Event_Mouse_In *ev;
1264 struct wl_resource *res;
1265 struct wl_client *wc;
1268 E_Comp_Config *comp_conf;
1269 E_Client *prev_ptr_ec;
1273 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1274 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1276 if (!(ec = data)) return;
1277 if (e_object_is_del(E_OBJECT(ec))) return;
1278 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1279 if (!surface) return;
1281 prev_ptr_ec = e_comp_wl->ptr.ec;
1284 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1285 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1288 e_comp_wl->ptr.ec = ec;
1290 comp_conf = e_comp_config_get();
1291 if (comp_conf && comp_conf->input_log_enable)
1292 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1293 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1294 e_client_util_name_get(ec));
1296 if (_e_comp_wl_check_cursor_timer_needed(ec))
1298 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1302 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1303 wc = wl_resource_get_client(surface);
1304 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1305 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1307 if (!e_comp_wl_input_pointer_check(res)) continue;
1308 if (wl_resource_get_client(res) != wc) continue;
1310 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1312 wl_pointer_send_enter(res, serial, surface,
1313 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1314 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1315 ec->pointer_enter_sent = EINA_TRUE;
1318 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1322 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1325 Evas_Event_Mouse_Out *ev;
1326 struct wl_resource *res;
1327 struct wl_client *wc;
1330 Eina_Bool inside_check;
1331 E_Comp_Config *comp_conf;
1335 if (!(ec = data)) return;
1336 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1337 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1338 if (ec->cur_mouse_action && inside_check) return;
1339 if (e_object_is_del(E_OBJECT(e_comp))) return;
1340 if (e_comp_wl->ptr.ec == ec)
1341 e_comp_wl->ptr.ec = NULL;
1342 if (e_object_is_del(E_OBJECT(ec))) return;
1344 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1345 if (!surface) return;
1347 comp_conf = e_comp_config_get();
1348 if (comp_conf && comp_conf->input_log_enable)
1349 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1350 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1351 e_client_util_name_get(ec));
1353 if (_e_comp_wl_check_cursor_timer_needed(ec))
1355 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1359 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1361 wc = wl_resource_get_client(surface);
1362 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1363 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1365 if (!e_comp_wl_input_pointer_check(res)) continue;
1366 if (wl_resource_get_client(res) != wc) continue;
1367 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1369 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1371 wl_pointer_send_leave(res, serial, surface);
1372 ec->pointer_enter_sent = EINA_FALSE;
1377 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1380 struct wl_client *wc;
1381 struct wl_resource *res;
1384 E_Comp_Config *comp_conf = NULL;
1387 if (e_object_is_del(E_OBJECT(ec))) return;
1388 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1389 if (!surface) return;
1391 wc = wl_resource_get_client(surface);
1392 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1396 x = wl_fixed_from_int(canvas_x - ec->client.x);
1397 y = wl_fixed_from_int(canvas_y - ec->client.y);
1400 comp_conf = e_comp_config_get();
1402 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1404 if (wl_resource_get_client(res) != wc) continue;
1405 if (!e_comp_wl_input_touch_check(res)) continue;
1406 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1409 if (comp_conf && comp_conf->input_log_enable)
1410 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));
1412 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1416 if (comp_conf && comp_conf->input_log_enable)
1417 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));
1419 wl_touch_send_up(res, serial, timestamp, idx);
1426 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1429 struct wl_client *wc;
1430 struct wl_resource *res;
1434 if (ec->cur_mouse_action) return;
1435 if (e_object_is_del(E_OBJECT(ec))) return;
1436 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1437 if (!surface) return;
1439 wc = wl_resource_get_client(surface);
1441 x = wl_fixed_from_int(canvas_x - ec->client.x);
1442 y = wl_fixed_from_int(canvas_y - ec->client.y);
1444 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1446 if (wl_resource_get_client(res) != wc) continue;
1447 if (!e_comp_wl_input_touch_check(res)) continue;
1448 wl_touch_send_motion(res, timestamp, idx, x, y);
1453 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1455 struct wl_resource *res;
1456 struct wl_client *wc;
1460 if (ec->cur_mouse_action) return;
1461 if (e_object_is_del(E_OBJECT(ec))) return;
1462 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1463 if (!surface) return;
1465 wc = wl_resource_get_client(surface);
1466 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1468 if (!e_comp_wl_input_pointer_check(res)) continue;
1469 if (wl_resource_get_client(res) != wc) continue;
1470 wl_pointer_send_motion(res, timestamp,
1471 wl_fixed_from_int(x - ec->client.x),
1472 wl_fixed_from_int(y - ec->client.y));
1477 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1479 if (e_comp_wl->ptr.hide_tmr)
1481 if (cursor_timer_ec == ec)
1483 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1484 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1488 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1489 cursor_timer_ec = ec;
1490 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1495 cursor_timer_ec = ec;
1496 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1501 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1504 Evas_Event_Mouse_Move *ev;
1505 Evas_Device *dev = NULL;
1506 const char *dev_name;
1507 E_Comp_Config *comp_conf;
1511 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1512 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1514 if (!(ec = data)) return;
1515 if (e_object_is_del(E_OBJECT(ec))) return;
1516 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1517 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1518 if (!surface) return;
1520 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1523 dev_name = evas_device_description_get(dev);
1525 comp_conf = e_comp_config_get();
1526 if (comp_conf && comp_conf->input_log_enable)
1527 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1528 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1529 e_client_util_name_get(ec), dev_name);
1531 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1533 if (!e_comp_wl->drag_client)
1535 e_comp_wl->touch.faked_ec = ec;
1536 if (e_comp_wl->touch.pressed & (1 << 0))
1538 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1540 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1541 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1542 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1546 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1550 if (!e_comp_wl->drag_client)
1552 if (_e_comp_wl_check_cursor_timer_needed(ec))
1554 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1558 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1559 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1561 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1563 if (_e_comp_wl_check_cursor_timer_needed(ec))
1564 _e_comp_wl_cursor_move_timer_control(ec);
1568 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1573 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1575 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1576 if (e_object_is_del(E_OBJECT(ec))) return;
1577 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1578 if (!surface) return;
1579 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1581 e_comp_wl->ptr.button = BTN_LEFT;
1583 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1587 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1589 E_Client *ec = data;
1590 Evas_Event_Mouse_Down *ev = event;
1591 Evas_Device *dev = NULL;
1592 const Evas_Device *seat_dev;
1593 const char *dev_name, *seat_name;
1594 E_Comp_Config *comp_conf = NULL;
1597 if (e_object_is_del(E_OBJECT(ec))) return;
1600 dev_name = evas_device_description_get(dev);
1602 seat_dev = evas_device_parent_get(dev);
1603 seat_name = evas_device_name_get(seat_dev);
1605 comp_conf = e_comp_config_get();
1606 if (comp_conf && comp_conf->input_log_enable)
1607 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1608 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1609 dev_name, seat_name);
1611 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1613 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1615 e_comp_wl->touch.faked_ec = ec;
1618 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1619 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1620 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1622 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1623 e_comp_wl->touch.pressed |= (1 << 0);
1627 if (_e_comp_wl_check_cursor_timer_needed(ec))
1629 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1633 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1634 WL_POINTER_BUTTON_STATE_PRESSED);
1636 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1639 need_send_released = EINA_TRUE;
1643 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1645 E_Client *ec = data;
1646 Evas_Event_Mouse_Up *ev = event;
1647 Evas_Device *dev = NULL;
1648 const Evas_Device *seat_dev;
1649 const char *dev_name, *seat_name;;
1650 Evas_Event_Flags flags;
1651 E_Comp_Config *comp_conf = NULL;
1654 if (ec->cur_mouse_action) return;
1655 if (e_object_is_del(E_OBJECT(ec))) return;
1657 if (!need_send_released)
1659 need_send_motion = EINA_TRUE;
1663 dev_name = evas_device_description_get(dev);
1665 seat_dev = evas_device_parent_get(dev);
1666 seat_name = evas_device_name_get(seat_dev);
1667 flags = evas_event_default_flags_get(evas);
1669 comp_conf = e_comp_config_get();
1670 if (comp_conf && comp_conf->input_log_enable)
1671 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1672 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1673 dev_name, seat_name);
1675 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1677 e_comp_wl->touch.pressed &= ~(1 << 0);
1679 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1680 e_comp_wl->touch.faked_ec = NULL;
1683 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1685 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1687 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1690 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1691 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1692 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1696 if (_e_comp_wl_check_cursor_timer_needed(ec))
1698 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1702 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1703 WL_POINTER_BUTTON_STATE_RELEASED);
1705 if (_e_comp_wl_check_cursor_timer_needed(ec))
1706 _e_comp_wl_cursor_move_timer_control(ec);
1710 need_send_released = EINA_FALSE;
1714 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1716 struct wl_resource *res;
1717 struct wl_client *wc;
1722 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1724 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1727 dir = -wl_fixed_from_int(abs(z));
1729 dir = wl_fixed_from_int(z);
1732 if (e_object_is_del(E_OBJECT(ec))) return;
1733 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1734 if (!surface) return;
1736 wc = wl_resource_get_client(surface);
1737 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1739 if (!e_comp_wl_input_pointer_check(res)) continue;
1740 if (wl_resource_get_client(res) != wc) continue;
1741 wl_pointer_send_axis(res, timestamp, axis, dir);
1746 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1749 Evas_Event_Mouse_Wheel *ev;
1752 if (!(ec = data)) return;
1753 if (ec->cur_mouse_action) return;
1754 if (e_object_is_del(E_OBJECT(ec))) return;
1755 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1756 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1757 if (!surface) return;
1759 if (!eina_list_count(e_comp_wl->ptr.resources))
1762 if (_e_comp_wl_check_cursor_timer_needed(ec))
1764 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1768 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1770 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1772 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1774 if (_e_comp_wl_check_cursor_timer_needed(ec))
1775 _e_comp_wl_cursor_move_timer_control(ec);
1780 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1782 E_Client *ec = data;
1783 Evas_Event_Multi_Down *ev = event;
1784 Evas_Device *dev = NULL;
1785 const Evas_Device *seat_dev;
1786 const char *dev_name, *seat_name;
1787 Evas_Device_Class dev_class;
1788 E_Comp_Config *comp_conf = NULL;
1791 if (e_object_is_del(E_OBJECT(ec))) return;
1792 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1793 if (!surface) return;
1795 /* Do not deliver emulated single touch events to client */
1796 if (ev->device == 0) return;
1799 dev_name = evas_device_description_get(dev);
1800 e_comp_wl->touch.faked_ec = ec;
1802 seat_dev = evas_device_parent_get(dev);
1803 seat_name = evas_device_name_get(seat_dev);
1805 comp_conf = e_comp_config_get();
1806 if (comp_conf && comp_conf->input_log_enable)
1807 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1808 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1809 dev_name, seat_name);
1811 if (dev && dev_name)
1813 dev_class = evas_device_class_get(dev);
1814 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1815 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1818 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1819 e_comp_wl->touch.pressed |= (1 << ev->device);
1823 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1825 E_Client *ec = data;
1826 Evas_Event_Multi_Up *ev = event;
1827 Evas_Device *dev = NULL;
1828 const Evas_Device *seat_dev;
1829 const char *dev_name, *seat_name;
1830 Evas_Device_Class dev_class;
1831 Evas_Event_Flags flags;
1832 E_Comp_Config *comp_conf = NULL;
1835 if (e_object_is_del(E_OBJECT(ec))) return;
1836 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1837 if (!surface) return;
1839 /* Do not deliver emulated single touch events to client */
1840 if (ev->device == 0) return;
1842 flags = evas_event_default_flags_get(evas);
1844 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1845 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1846 e_comp_wl->touch.faked_ec = NULL;
1848 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1851 dev_name = evas_device_description_get(dev);
1853 seat_dev = evas_device_parent_get(dev);
1854 seat_name = evas_device_name_get(seat_dev);
1856 comp_conf = e_comp_config_get();
1857 if (comp_conf && comp_conf->input_log_enable)
1858 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1859 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1860 dev_name, seat_name);
1862 if (dev && dev_name)
1864 dev_class = evas_device_class_get(dev);
1865 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1866 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1869 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1873 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1875 E_Client *ec = data;
1876 Evas_Event_Multi_Move *ev = event;
1877 Evas_Device *dev = NULL;
1878 const char *dev_name;
1879 Evas_Device_Class dev_class;
1882 if (e_object_is_del(E_OBJECT(ec))) return;
1883 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1884 if (!surface) return;
1886 /* Do not deliver emulated single touch events to client */
1887 if (ev->device == 0) return;
1889 e_comp_wl->touch.faked_ec = ec;
1891 if (e_comp_wl->touch.pressed & (1 << ev->device))
1894 if (dev && (dev_name = evas_device_description_get(dev)))
1896 dev_class = evas_device_class_get(dev);
1897 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1898 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1901 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1906 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1909 char *file, buff[PATH_MAX];
1916 n = (getpriority(PRIO_PROCESS, pid) + adj);
1920 setpriority(PRIO_PROCESS, pid, n);
1923 use_adj = EINA_TRUE;
1925 if (!do_child) return;
1927 files = ecore_file_ls("/proc");
1928 EINA_LIST_FREE(files, file)
1930 if (!isdigit(file[0]))
1933 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1934 if ((f = fopen(buff, "r")))
1938 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1940 if (num_read == 2 && ppid == pid)
1941 _e_comp_wl_client_priority_adjust(pid2, set,
1943 adj_child, do_child);
1951 _e_comp_wl_client_priority_raise(E_Client *ec)
1953 if (!e_config->priority_control) return;
1954 if (ec->netwm.pid <= 0) return;
1955 if (ec->netwm.pid == getpid()) return;
1956 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1957 e_config->priority - 1, -1,
1958 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1962 _e_comp_wl_client_priority_normal(E_Client *ec)
1964 if (!e_config->priority_control) return;
1965 if (ec->netwm.pid <= 0) return;
1966 if (ec->netwm.pid == getpid()) return;
1967 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1968 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1972 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1975 E_Comp_Wl_Key_Data *k;
1976 struct wl_resource *res;
1980 if (!ec) return EINA_FALSE;
1981 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1982 if (!ec->comp_data) return EINA_FALSE;
1984 ec->comp_data->on_focus_timer = NULL;
1985 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1986 if (!e_comp_wl->kbd.focused)
1988 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1991 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1993 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1994 t = ecore_time_unix_get();
1996 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1997 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1998 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2000 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2002 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2003 wl_keyboard_send_key(res, serial, t,
2004 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2007 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2008 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2012 /* It is called in the following cases:
2013 * When a normal ec->frame has focus.
2014 * Or launching image ec is replaced to the real ec.
2017 e_comp_wl_feed_focus_in(E_Client *ec)
2020 struct wl_resource *res;
2021 struct wl_client *wc;
2025 if (e_object_is_del(E_OBJECT(ec))) return;
2026 if (ec->iconic) return;
2028 /* block spurious focus events */
2029 focused = e_client_focused_get();
2030 if ((focused) && (ec != focused)) return;
2032 /* raise client priority */
2033 _e_comp_wl_client_priority_raise(ec);
2034 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2035 if (!surface) return;
2037 wc = wl_resource_get_client(surface);
2039 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2040 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2042 if (wl_resource_get_client(res) == wc)
2044 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2045 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2046 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2047 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2050 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2052 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2053 if (!e_comp_wl->kbd.focused)
2055 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2058 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2060 e_comp_wl->kbd.focus = surface;
2061 e_comp_wl_input_keyboard_enter_send(ec);
2062 e_comp_wl_data_device_keyboard_focus_set();
2063 ec->comp_data->on_focus_timer =
2064 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2065 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2066 int rotation = ec->e.state.rot.ang.curr;
2067 e_pointer_rotation_set(e_comp->pointer, rotation);
2071 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2074 if (!(ec = data)) return;
2075 e_comp_wl_feed_focus_in(ec);
2079 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2082 struct wl_resource *res;
2084 E_Comp_Wl_Key_Data *k;
2088 if (!(ec = data)) return;
2090 if (!ec->comp_data) return;
2092 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2094 /* lower client priority */
2095 if (!e_object_is_del(data))
2096 _e_comp_wl_client_priority_normal(ec);
2099 /* update keyboard modifier state */
2100 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2101 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2102 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2104 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2106 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2107 if (!surface) return;
2109 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2110 if (!eina_list_count(e_comp_wl->kbd.resources))
2112 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2116 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2118 /* send keyboard_leave to all keyboard resources */
2119 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2120 t = ecore_time_unix_get();
2122 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2123 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2124 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2126 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2128 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2129 wl_keyboard_send_key(res, serial, t,
2130 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2132 wl_keyboard_send_leave(res, serial, surface);
2133 e_comp_wl->kbd.focused =
2134 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2136 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2137 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2141 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2145 if (!(ec = data)) return;
2147 if (!ec->comp_data->shell.configure_send) return;
2149 /* TODO: calculate x, y with transfrom object */
2150 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2154 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2155 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2156 if (e_comp_object_frame_exists(ec->frame))
2157 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2159 switch (ec->resize_mode)
2161 case E_POINTER_RESIZE_TL:
2162 case E_POINTER_RESIZE_L:
2163 case E_POINTER_RESIZE_BL:
2164 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2165 ec->mouse.current.mx;
2167 case E_POINTER_RESIZE_TR:
2168 case E_POINTER_RESIZE_R:
2169 case E_POINTER_RESIZE_BR:
2170 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2175 switch (ec->resize_mode)
2177 case E_POINTER_RESIZE_TL:
2178 case E_POINTER_RESIZE_T:
2179 case E_POINTER_RESIZE_TR:
2180 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2181 ec->mouse.current.my;
2183 case E_POINTER_RESIZE_BL:
2184 case E_POINTER_RESIZE_B:
2185 case E_POINTER_RESIZE_BR:
2186 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2191 w = E_CLAMP(w, 1, w);
2192 h = E_CLAMP(h, 1, h);
2193 e_client_resize_limit(ec, &w, &h);
2195 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2197 else if ((!ec->fullscreen) && (!ec->maximized) &&
2198 (!ec->comp_data->maximize_pre))
2202 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2203 if ((pw != ec->w) || (ph != ec->h))
2205 _e_comp_wl_configure_send(ec, 1, 1);
2209 if (ec->comp_data->sub.below_obj)
2210 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2214 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2216 E_Client *ec = data;
2218 ec->comp_data->maximize_pre = 1;
2222 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2224 E_Client *ec = data;
2227 if (e_object_is_del(E_OBJECT(ec))) return;
2229 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2230 e_client_shell_configure_send(ec, 0, w, h);
2232 ec->comp_data->maximize_pre = 0;
2236 _e_comp_wl_evas_cb_unmaximize_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_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2246 E_Client *ec = data;
2248 if (e_object_is_del(E_OBJECT(ec))) return;
2250 /* check for wayland pixmap */
2252 if (ec->comp_data->shell.configure_send)
2253 _e_comp_wl_configure_send(ec, 0, 0);
2255 ec->comp_data->maximize_pre = 0;
2259 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2261 E_Client *ec = data;
2263 if (e_object_is_del(E_OBJECT(ec))) return;
2265 /* check for wayland pixmap */
2267 if (ec->comp_data->shell.configure_send)
2268 _e_comp_wl_configure_send(ec, 0, 1);
2270 ec->comp_data->maximize_pre = 0;
2274 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2276 E_Client *ec = data;
2278 if (e_object_is_del(E_OBJECT(ec))) return;
2280 /* check for wayland pixmap */
2282 if (ec->comp_data->shell.configure_send)
2283 _e_comp_wl_configure_send(ec, 0, 0);
2285 ec->comp_data->maximize_pre = 0;
2289 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2293 if (!(ec = data)) return;
2295 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2297 e_object_del(E_OBJECT(ec));
2299 _e_comp_wl_focus_check();
2301 /* TODO: Delete request send ??
2302 * NB: No such animal wrt wayland */
2306 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2310 if (!(ec = data)) return;
2312 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2315 if (ec->comp_data->reparented)
2316 e_client_comp_hidden_set(ec, EINA_TRUE);
2319 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2320 if (ec->visible) evas_object_hide(ec->frame);
2321 if (!ec->internal) e_object_del(E_OBJECT(ec));
2323 _e_comp_wl_focus_check();
2327 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2331 if (!(ec = data)) return;
2333 e_client_shell_ping(ec);
2337 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2342 if (!(ec = data)) return;
2343 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2344 if (ec->netwm.opacity == a) return;
2345 ec->netwm.opacity = a;
2346 ec->netwm.opacity_changed = EINA_TRUE;
2350 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2352 Eina_Rectangle *damage_rect = NULL;
2353 Eina_Rectangle *dmg = NULL;
2354 Eina_List *l = NULL;
2356 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2357 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2360 if (!buffer->tbm_surface) return;
2364 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2368 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2369 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2372 eina_rectangle_union(damage_rect, dmg);
2377 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2378 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2381 tbm_surface_internal_set_damage(buffer->tbm_surface,
2387 eina_rectangle_free(damage_rect);
2391 _e_comp_wl_client_evas_init(E_Client *ec)
2393 if (!ec || !ec->comp_data) return;
2394 if (ec->comp_data->evas_init) return;
2396 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2397 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2398 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2401 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2403 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2404 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2405 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2406 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2408 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2409 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2410 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2412 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2413 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2417 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2418 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2419 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2420 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2421 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2422 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2423 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2426 /* setup delete/kill callbacks */
2427 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2428 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2430 /* setup ping callback */
2431 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2432 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2434 ec->comp_data->evas_init = EINA_TRUE;
2438 _e_comp_wl_client_evas_deinit(E_Client *ec)
2440 if (!ec || !ec->comp_data) return;
2441 if (!ec->comp_data->evas_init) return;
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2445 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2449 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2454 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2455 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2456 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2458 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2459 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2463 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2464 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2465 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2466 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2467 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2468 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2469 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2472 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2473 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2475 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2476 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2478 ec->comp_data->evas_init = EINA_FALSE;
2482 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2486 E_Comp_Screen *e_comp_screen;
2487 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2489 if (!e_comp) return ECORE_CALLBACK_RENEW;
2490 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2491 e_comp_screen = e_comp->e_comp_screen;
2493 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2495 if (!eout->config.enabled)
2497 e_comp_wl_output_remove(eout->id);
2501 switch (eout->config.rotation)
2504 transform = WL_OUTPUT_TRANSFORM_90;
2507 transform = WL_OUTPUT_TRANSFORM_180;
2510 transform = WL_OUTPUT_TRANSFORM_270;
2514 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2518 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2520 eout->config.geom.x, eout->config.geom.y,
2521 eout->config.geom.w, eout->config.geom.h,
2522 eout->info.size.w, eout->info.size.h,
2523 eout->config.mode.refresh, 0, transform))
2524 ERR("Could not initialize screen %s", eout->info.name);
2527 return ECORE_CALLBACK_RENEW;
2531 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2535 /* try to get the client from the object */
2536 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2537 return ECORE_CALLBACK_RENEW;
2539 /* check for client being deleted */
2540 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2542 /* check for wayland pixmap */
2543 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2544 return ECORE_CALLBACK_RENEW;
2546 /* if we have not setup evas callbacks for this client, do it */
2547 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2549 return ECORE_CALLBACK_RENEW;
2553 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2557 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2558 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2560 if (e_comp_wl->selection.target &&
2563 struct wl_resource *res;
2565 E_Client *ec = NULL;
2566 E_Client *legacy_target = e_comp_wl->selection.target;
2567 int device_id = e_comp_wl_data_current_device_id_get();
2571 e_comp_wl_data_current_device_id_set(ev->multi.device);
2573 else if (device_id != ev->multi.device)
2575 return ECORE_CALLBACK_RENEW;
2578 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2579 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2581 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2582 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2584 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2585 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2587 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2588 (ec != legacy_target))
2590 e_comp_wl_data_device_send_leave(legacy_target);
2591 e_comp_wl_data_device_send_enter(ec);
2594 if (e_comp_wl->drag)
2595 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2597 if (e_client_transform_core_enable_get(ec))
2599 int trans_x, trans_y;
2600 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2601 x = trans_x - ec->client.x;
2602 y = trans_y - ec->client.y;
2606 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2611 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2614 return ECORE_CALLBACK_RENEW;
2618 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2621 struct wl_resource *surface;
2622 struct wl_resource *res;
2623 struct wl_client *wc;
2625 E_Comp_Config *comp_conf;
2627 ec = e_comp_wl->ptr_constraints.ec;
2628 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2630 surface = e_comp_wl_client_surface_get(ec);
2631 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2633 wc = wl_resource_get_client(surface);
2635 comp_conf = e_comp_config_get();
2637 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2639 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2640 if (wl_resource_get_client(res) != wc) continue;
2642 if (comp_conf && comp_conf->input_log_enable)
2643 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2644 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2645 e_client_util_name_get(ec));
2647 zwp_relative_pointer_v1_send_relative_motion(res,
2649 (uint32_t)(ev->timestamp),
2650 wl_fixed_from_int(ev->dx),
2651 wl_fixed_from_int(ev->dy),
2652 wl_fixed_from_int(ev->dx_unaccel),
2653 wl_fixed_from_int(ev->dy_unaccel));
2656 return ECORE_CALLBACK_DONE;
2660 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2662 _e_comp_wl_touch_cancel();
2664 return ECORE_CALLBACK_PASS_ON;
2668 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2670 if (!ev) return ECORE_CALLBACK_PASS_ON;
2672 E_Zone *zone = ev->zone;
2674 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2675 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2677 if (!e_zone_is_displaying(zone))
2678 _e_comp_wl_touch_cancel();
2680 return ECORE_CALLBACK_PASS_ON;
2684 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2686 E_Client *ec = ev->ec;
2687 E_Comp_Wl_Buffer_Viewport *vp;
2689 if (!ec) return ECORE_CALLBACK_PASS_ON;
2690 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2691 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2692 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2693 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2695 vp = &ec->comp_data->scaler.buffer_viewport;
2696 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2698 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2700 return ECORE_CALLBACK_PASS_ON;
2704 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2706 E_Client *ec = ev->ec;
2707 E_Comp_Wl_Buffer_Viewport *vp;
2709 if (!ec) return ECORE_CALLBACK_PASS_ON;
2710 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2711 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2712 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2714 vp = &ec->comp_data->scaler.buffer_viewport;
2715 vp->wait_for_transform_change = 0;
2717 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2719 return ECORE_CALLBACK_PASS_ON;
2723 _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)
2725 E_Client *focused_ec;
2728 focused_ec = e_client_focused_get();
2729 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2731 rotation = focused_ec->e.state.rot.ang.curr;
2732 e_pointer_rotation_set(e_comp->pointer, rotation);
2734 return ECORE_CALLBACK_PASS_ON;
2738 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2741 Eina_Rectangle *window;
2746 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2748 if ((prev_w != state->bw) ||
2749 (prev_h != state->bh))
2751 ec->changes.buf_size = EINA_TRUE;
2754 if (e_comp_object_frame_exists(ec->frame)) return;
2755 window = &ec->comp_data->shell.window;
2756 if ((!ec->borderless) && /* FIXME temporarily added this check code
2757 * to prevent updating E_Client's size by frame */
2758 (window->x || window->y || window->w || window->h))
2760 e_comp_object_frame_geometry_set(ec->frame,
2762 (window->x + window->w) - state->bw,
2764 (window->y + window->h) - state->bh);
2767 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2771 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2773 E_Comp_Wl_Surface_State *state;
2776 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2777 state->buffer = NULL;
2781 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2783 state->new_attach = EINA_FALSE;
2784 state->buffer = NULL;
2785 state->buffer_destroy_listener.notify =
2786 _e_comp_wl_surface_state_cb_buffer_destroy;
2787 state->sx = state->sy = 0;
2789 state->input = eina_tiler_new(w, h);
2790 eina_tiler_tile_size_set(state->input, 1, 1);
2792 state->opaque = eina_tiler_new(w, h);
2793 eina_tiler_tile_size_set(state->opaque, 1, 1);
2795 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2796 state->buffer_viewport.buffer.scale = 1;
2797 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2798 state->buffer_viewport.surface.width = -1;
2799 state->buffer_viewport.changed = 0;
2801 e_presentation_time_container_init(&state->presentation_container);
2805 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2807 struct wl_resource *cb;
2808 Eina_Rectangle *dmg;
2810 EINA_LIST_FREE(state->frames, cb)
2811 wl_resource_destroy(cb);
2813 EINA_LIST_FREE(state->damages, dmg)
2814 eina_rectangle_free(dmg);
2816 EINA_LIST_FREE(state->buffer_damages, dmg)
2817 eina_rectangle_free(dmg);
2819 if (state->opaque) eina_tiler_free(state->opaque);
2820 state->opaque = NULL;
2822 if (state->input) eina_tiler_free(state->input);
2823 state->input = NULL;
2825 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2826 state->buffer = NULL;
2828 e_presentation_time_container_finish(&state->presentation_container);
2832 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2834 if (state->buffer == buffer) return;
2836 wl_list_remove(&state->buffer_destroy_listener.link);
2837 state->buffer = buffer;
2839 wl_signal_add(&state->buffer->destroy_signal,
2840 &state->buffer_destroy_listener);
2844 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2846 Eina_Rectangle *dmg;
2847 Eina_Bool placed = EINA_TRUE;
2851 E_Comp_Wl_Buffer *buffer;
2852 struct wl_resource *cb;
2854 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2855 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2860 if ((ec->internal) ||
2861 (cdata->shell.surface && state->new_attach))
2865 e_comp->new_clients++;
2866 ELOGF("COMP", "Unignore", ec);
2867 e_client_unignore(ec);
2871 /* buffer transform */
2872 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2875 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2877 /* when buffer is transformed, we have to apply the new evas-map */
2878 state->buffer_viewport.changed = EINA_TRUE;
2880 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2882 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2884 if (transform_change == vp->wait_for_transform_change)
2885 vp->wait_for_transform_change = 0;
2887 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2888 // triggered by E_CLIENT_HOOK calls at those file.
2889 zone = e_comp_zone_find_by_ec(ec);
2892 eout = e_output_find(zone->output_id);
2893 if (eout && eout->hwc)
2895 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2897 if (e_comp_is_on_overlay(ec))
2898 e_comp_hwc_client_end(ec, __FUNCTION__);
2904 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2905 cdata->scaler.buffer_viewport = state->buffer_viewport;
2907 if (state->new_attach)
2909 e_comp_wl_surface_attach(ec, state->buffer);
2912 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2913 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2915 _e_comp_wl_surface_state_buffer_set(state, NULL);
2917 if ((state->new_attach) ||
2918 (state->buffer_viewport.changed))
2920 _e_comp_wl_surface_state_size_update(ec, state);
2921 e_comp_wl_map_size_cal_from_viewport(ec);
2923 /* update the position */
2924 if (ec->changes.pos)
2926 e_comp_object_frame_xy_unadjust(ec->frame,
2936 if (ec->new_client) placed = ec->placed;
2938 if (!ec->lock_client_size)
2943 ec->client.w = state->bw;
2944 ec->client.h = state->bh;
2946 e_comp_object_frame_wh_adjust(ec->frame,
2947 ec->client.w, ec->client.h,
2949 e_client_size_set(ec, nw, nh);
2951 if ((w != ec->w) || (h != ec->h))
2953 ec->changes.size = 1;
2958 if (ec->changes.buf_size)
2960 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2961 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2962 ec->changes.buf_size = EINA_FALSE;
2964 if (ec->move_after_resize)
2966 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2967 ec->move_after_resize = EINA_FALSE;
2972 /* map or unmap ec */
2973 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2974 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2975 if (!pixmap_usable || hide_by_request)
2980 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2985 if ((cdata->sub.below_obj) &&
2986 (evas_object_visible_get(cdata->sub.below_obj)))
2988 evas_object_hide(cdata->sub.below_obj);
2996 if ((cdata->sub.below_obj) &&
2997 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2998 (evas_object_visible_get(ec->frame)))
3000 evas_object_show(cdata->sub.below_obj);
3004 if ((state->new_attach) ||
3005 (state->buffer_viewport.changed))
3007 if ((e_comp_wl->drag) &&
3008 (e_comp_wl->drag_client) &&
3009 (e_comp_wl->drag_client == ec))
3011 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3013 e_drag_move(e_comp_wl->drag,
3015 e_comp_wl->drag->y);
3017 e_drag_resize(e_comp_wl->drag,
3018 state->bw, state->bh);
3020 else if ((cdata->shell.surface) &&
3021 (cdata->shell.configure))
3023 e_comp_wl_commit_sync_configure(ec);
3025 else if (!e_client_video_hw_composition_check(ec))
3027 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3032 ec->placed = placed;
3033 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3037 if (cdata->scaler.buffer_viewport.changed)
3038 e_comp_wl_map_apply(ec);
3040 /* resize transform object */
3041 if (ec->transformed)
3042 e_client_transform_update(ec);
3046 state->new_attach = EINA_FALSE;
3048 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3050 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3051 wl_resource_destroy(cb);
3054 /* insert state frame callbacks into comp_data->frames
3055 * NB: This clears state->frames list */
3056 cdata->frames = eina_list_merge(cdata->frames,
3058 state->frames = NULL;
3060 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3061 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3062 &state->presentation_container);
3064 buffer = e_pixmap_resource_get(ec->pixmap);
3066 /* put state damages into surface */
3069 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3070 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3072 if ((cdata->buffer_ref.buffer) &&
3073 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3074 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3076 e_comp_object_damage(ec->frame,
3078 cdata->buffer_ref.buffer->w,
3079 cdata->buffer_ref.buffer->h);
3084 Eina_List *damages = NULL;
3087 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3089 if (eina_list_count(state->buffer_damages))
3091 EINA_LIST_FREE(state->buffer_damages, dmg)
3094 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3095 e_comp_wl_output_buffer_transform_get(ec),
3097 dmg->x, dmg->y, dmg->w, dmg->h,
3098 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3099 damages = eina_list_append(damages, dmg);
3103 EINA_LIST_FREE(state->damages, dmg)
3104 damages = eina_list_append(damages, dmg);
3106 EINA_LIST_FREE(damages, dmg)
3108 /* not creating damage for ec that shows a underlay video */
3109 if (state->buffer_viewport.changed ||
3110 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3111 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3112 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3114 eina_rectangle_free(dmg);
3119 /* put state opaque into surface */
3120 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3123 Eina_Rectangle *rect;
3126 itr = eina_tiler_iterator_new(state->opaque);
3127 EINA_ITERATOR_FOREACH(itr, rect)
3131 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3132 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3133 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3137 eina_iterator_free(itr);
3140 /* put state input into surface */
3141 if ((state->input) &&
3142 (!eina_tiler_empty(state->input)) &&
3145 Eina_Tiler *src, *tmp;
3149 tmp = eina_tiler_new(sw, sh);
3150 eina_tiler_tile_size_set(tmp, 1, 1);
3152 eina_tiler_rect_add(tmp,
3153 &(Eina_Rectangle){0, 0, sw, sh});
3155 if ((src = eina_tiler_intersection(state->input, tmp)))
3157 Eina_Rectangle *rect;
3160 e_comp_object_input_objs_del(ec->frame);
3161 itr = eina_tiler_iterator_new(src);
3162 EINA_ITERATOR_FOREACH(itr, rect)
3164 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3165 ec, rect->x, rect->y, rect->w, rect->h,
3166 ec->w, ec->h, state->bw, state->bh);
3167 e_comp_object_input_area_set(ec->frame,
3172 eina_iterator_free(itr);
3173 eina_tiler_free(src);
3176 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3178 eina_tiler_free(tmp);
3180 /* clear input tiler */
3181 eina_tiler_clear(state->input);
3184 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3186 if ((cdata->video_client) &&
3188 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3189 (e_comp->wl_comp_data->available_hw_accel.underlay))
3191 e_pixmap_image_clear(ec->pixmap, 1);
3194 state->buffer_viewport.changed = 0;
3196 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3199 ec->exp_iconify.buffer_flush &&
3200 e_policy_visibility_client_is_iconic(ec))
3202 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3207 _e_comp_wl_surface_render_stop(E_Client *ec)
3209 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3210 //if ((!ec->internal) && (!e_comp_gl_get()))
3213 /* check if internal animation is running */
3214 if (e_comp_object_is_animating(ec->frame)) return;
3215 /* check if external animation is running */
3216 if (evas_object_data_get(ec->frame, "effect_running")) return;
3218 evas_object_hide(ec->frame);
3222 e_comp_wl_client_surface_finish(E_Client *ec)
3224 struct wl_resource *res, *surface;
3225 struct wl_client *surface_client = NULL;
3228 surface = e_comp_wl_client_surface_get(ec);
3231 surface_client = wl_resource_get_client(surface);
3233 if (surface_client &&
3234 (ec == e_client_focused_get()))
3236 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3237 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3239 if (wl_resource_get_client(res) ==
3241 e_comp_wl->kbd.focused =
3242 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3246 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3249 e_comp_wl_client_surface_set(ec, NULL);
3251 ec->comp_data->wl_surface = NULL;
3252 e_pixmap_win_id_del(ec->pixmap);
3254 _e_comp_wl_surface_render_stop(ec);
3255 e_object_del(E_OBJECT(ec));
3259 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3264 char proc[512], pname[512];
3267 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3269 h = fopen(proc, "r");
3272 len = fread(pname, sizeof(char), 512, h);
3274 pname[len - 1] = '\0';
3276 strncpy(pname, "NO NAME", sizeof(pname));
3282 strncpy(pname, "NO NAME", sizeof(pname));
3285 strncpy(name, pname, size);
3289 _e_comp_wl_pname_print(pid_t pid)
3292 char proc[512], pname[512];
3295 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3297 h = fopen(proc, "r");
3300 len = fread(pname, sizeof(char), 512, h);
3302 pname[len - 1] = '\0';
3304 strncpy(pname, "NO NAME", sizeof(pname));
3308 ELOGF("COMP", " |%s", NULL, pname);
3313 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3315 struct wl_client *client = data;
3316 E_Comp_Connected_Client_Info *cinfo;
3319 cinfo = wl_container_of(listener, cinfo, destroy);
3321 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3322 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3324 eai = e_appinfo_find_with_pid(cinfo->pid);
3325 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3328 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3330 wl_list_remove(&cinfo->destroy.link);
3331 eina_stringshare_del(cinfo->name);
3336 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3338 E_Comp_Connected_Client_Info *cinfo;
3340 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3341 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3343 cinfo->name = eina_stringshare_add(name);
3347 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3348 wl_client_add_destroy_listener(client, &cinfo->destroy);
3349 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3351 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3355 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3357 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3359 /* send configure */
3360 if (ec->comp_data->shell.configure_send)
3362 if (ec->comp_data->shell.surface)
3363 _e_comp_wl_configure_send(ec, 0, 0);
3366 e_comp_wl->kbd.focus = ec->comp_data->surface;
3370 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3372 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3374 /* send configure */
3375 if (ec->comp_data->shell.configure_send)
3377 if (ec->comp_data->shell.surface)
3378 _e_comp_wl_configure_send(ec, 0, 0);
3381 _e_comp_wl_focus_check();
3383 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3384 e_comp_wl->kbd.focus = NULL;
3388 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3390 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3391 if (ec->keyboard_resizing) return;
3393 /* do nothing currently */
3398 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3400 if (e_object_is_del(E_OBJECT(ec))) return;
3401 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3403 e_comp_wl->resize.edges = 0;
3404 e_comp_wl->resize.resource = NULL;
3408 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3410 if (e_object_is_del(E_OBJECT(ec))) return;
3411 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3415 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3418 int ratio_w, ratio_h;
3420 phys_w = output->phys_width;
3421 phys_h = output->phys_height;
3423 if (e_config->configured_output_resolution.use)
3425 // change the configured physical size(mm) of the output
3426 if (output->w != res_w)
3428 ratio_w = res_w / output->w;
3429 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3432 if (output->h != res_h)
3434 ratio_h = res_h / output->h;
3435 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3438 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3441 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3442 NULL, res_w, res_h, phys_w, phys_h, pid);
3444 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3445 wl_output_send_scale(resource, output->scale);
3447 wl_output_send_geometry(resource, output->x, output->y,
3449 output->subpixel, output->make ?: "",
3450 output->model ?: "", output->transform);
3452 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3453 res_w, res_h, output->refresh);
3455 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3456 wl_output_send_done(resource);
3460 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3462 E_Comp_Wl_Output *output;
3464 if (!(output = wl_resource_get_user_data(resource))) return;
3466 output->resources = eina_list_remove(output->resources, resource);
3470 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3472 E_Comp_Wl_Output *output;
3473 struct wl_resource *resource;
3474 E_Appinfo *eai = NULL;
3478 if (!(output = data)) return;
3481 wl_resource_create(client, &wl_output_interface, version, id);
3484 wl_client_post_no_memory(client);
3488 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3489 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3491 output->resources = eina_list_append(output->resources, resource);
3493 wl_resource_set_implementation(resource, NULL, output,
3494 _e_comp_wl_cb_output_unbind);
3495 wl_resource_set_user_data(resource, output);
3497 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3498 if (e_config->configured_output_resolution.use)
3500 wl_client_get_credentials(client, &pid, NULL, NULL);
3503 res_w = e_config->configured_output_resolution.w;
3504 res_h = e_config->configured_output_resolution.h;
3508 eai = e_appinfo_find_with_pid(pid);
3511 res_w = e_config->configured_output_resolution.w;
3512 res_h = e_config->configured_output_resolution.h;
3516 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3518 res_w = e_config->configured_output_resolution.w;
3519 res_h = e_config->configured_output_resolution.h;
3523 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3532 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3536 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3539 Evas_GL *evasgl = NULL;
3540 Evas_GL_API *glapi = NULL;
3541 Evas_GL_Context *ctx = NULL;
3542 Evas_GL_Surface *sfc = NULL;
3543 Evas_GL_Config *cfg = NULL;
3545 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3547 if (!e_comp_gl_get()) return;
3549 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3550 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3552 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3553 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3555 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3556 * then we should get evas from ecore_evas.
3559 evas = e_comp->evas;
3561 evas = ecore_evas_get(e_comp->ee);
3563 evasgl = evas_gl_new(evas);
3564 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3566 glapi = evas_gl_api_get(evasgl);
3567 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3568 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3570 cfg = evas_gl_config_new();
3571 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3573 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3574 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3576 ctx = evas_gl_context_create(evasgl, NULL);
3577 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3579 res = evas_gl_make_current(evasgl, sfc, ctx);
3580 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3582 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3583 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3585 evas_gl_config_free(cfg);
3587 evas_gl->gl = evasgl;
3588 evas_gl->glapi = glapi;
3589 evas_gl->glsfc = sfc;
3590 evas_gl->glctx = ctx;
3592 e_comp_wl->evas_gl = evas_gl;
3594 /* for native surface */
3597 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3602 evas_gl_config_free(cfg);
3603 evas_gl_make_current(evasgl, NULL, NULL);
3604 evas_gl_context_destroy(evasgl, ctx);
3605 evas_gl_surface_destroy(evasgl, sfc);
3606 evas_gl_free(evasgl);
3613 _e_comp_wl_gl_popup_cb_close(void *data,
3614 Evas_Object *obj EINA_UNUSED,
3615 void *event_info EINA_UNUSED)
3617 evas_object_del(data);
3621 _e_comp_wl_gl_popup_cb_focus(void *data,
3622 Evas_Object *obj EINA_UNUSED,
3623 void *event_info EINA_UNUSED)
3625 elm_object_focus_set(data, EINA_TRUE);
3630 _e_comp_wl_gl_idle(void *data)
3634 /* show warning window to notify failure of gl init */
3637 Evas_Object *win, *bg, *popup, *btn;
3639 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3640 elm_win_title_set(win, "Compositor Warning");
3641 elm_win_autodel_set(win, EINA_TRUE);
3642 elm_win_borderless_set(win, EINA_TRUE);
3643 elm_win_role_set(win, "notification-low");
3644 elm_win_alpha_set(win, EINA_TRUE);
3646 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3647 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3648 elm_win_resize_object_add(win, bg);
3649 evas_object_color_set(bg, 125, 125, 125, 125);
3650 evas_object_show(bg);
3652 popup = elm_popup_add(win);
3653 elm_object_text_set(popup,
3654 _( "Your screen does not support OpenGL.<br>"
3655 "Falling back to software engine."));
3656 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3658 btn = elm_button_add(popup);
3659 elm_object_text_set(btn, "Close");
3660 elm_object_part_content_set(popup, "button1", btn);
3661 evas_object_show(btn);
3663 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3664 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3666 evas_object_show(popup);
3667 evas_object_show(win);
3671 return ECORE_CALLBACK_CANCEL;
3675 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3677 struct wl_client *client = data;
3683 wl_client_get_credentials(client, &pid, &uid, &gid);
3685 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3687 _e_comp_wl_pname_print(pid);
3688 _e_comp_wl_pname_get(pid, name, sizeof(name));
3689 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3693 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3695 char buf[1024] = {0, };
3697 vsnprintf(buf, 1024, fmt, args);
3701 DBG("[libds] %s", buf);
3704 INF("[libds] %s", buf);
3707 ERR("[libds] %s", buf);
3715 _e_comp_wl_display_create(void)
3718 E_Comp_Wl_Data *wl_cdata;
3723 /* create new compositor data */
3724 if (!(comp = E_NEW(E_Comp_Data, 1)))
3726 ERR("Could not create compositor data: %m");
3729 wl_cdata = &comp->base;
3731 /* set compositor wayland data */
3732 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3734 g_mutex_init(&connection_mutex);
3736 /* try to create a wayland display */
3737 if (!(wl_cdata->wl.disp = wl_display_create()))
3739 ERR("Could not create a Wayland display: %m");
3743 /* try to setup wayland socket */
3744 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3746 ERR("Could not create Wayland display socket: %m");
3747 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3751 res = e_comp_socket_init(name);
3752 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3753 PRCTL("[Winsys] change permission and create sym link for %s", name);
3755 /* set wayland display environment variable */
3756 e_env_set("WAYLAND_DISPLAY", name);
3758 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3759 /* wl_cdata->output.scale = e_scale; */
3761 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3763 if (!e_compositor_init(wl_cdata->wl.disp))
3765 ERR("Failed to initialize compositor");
3769 comp->client_created.notify = _e_comp_wl_cb_client_created;
3770 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3772 if (!e_comp_wl_subsurfaces_init())
3774 ERR("Failed to init_subsurfaces");
3775 goto subsurfaces_err;
3778 /* initialize shm mechanism */
3779 wl_display_init_shm(wl_cdata->wl.disp);
3781 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3783 /* try to init data manager */
3784 if (!e_comp_wl_data_manager_init())
3786 ERR("Could not initialize data manager");
3790 /* try to init input */
3791 if (!e_comp_wl_input_init())
3793 ERR("Could not initialize input");
3797 if (e_comp_gl_get())
3798 _e_comp_wl_gl_init(NULL);
3800 /* get the wayland display loop */
3801 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3803 /* get the file descriptor of the wayland event loop */
3804 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3806 /* create a listener for wayland main loop events */
3808 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3809 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3810 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3811 _e_comp_wl_cb_prepare, wl_cdata);
3816 e_comp_wl_data_manager_shutdown();
3818 e_comp_wl_subsurfaces_shutdown();
3820 wl_list_remove(&comp->client_created.link);
3822 e_env_unset("WAYLAND_DISPLAY");
3824 wl_display_destroy(wl_cdata->wl.disp);
3826 g_mutex_clear(&connection_mutex);
3832 _e_comp_wl_gl_shutdown(void)
3834 if (!e_comp_wl->evas_gl) return;
3836 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3838 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3839 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3840 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3841 evas_gl_free(e_comp_wl->evas_gl->gl);
3843 E_FREE(e_comp_wl->evas_gl);
3846 /* public functions */
3849 * Creates and initializes a Wayland compositor with ecore.
3850 * Registers callback handlers for keyboard and mouse activity
3851 * and other client events.
3853 * @returns true on success, false if initialization failed.
3856 e_comp_wl_init(void)
3858 TRACE_DS_BEGIN(COMP_WL:INIT);
3860 /* try to create a wayland compositor */
3861 if (!_e_comp_wl_display_create())
3863 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3868 e_comp_wl_shell_init();
3870 #ifdef HAVE_WAYLAND_TBM
3871 e_comp_wl_tbm_init();
3873 e_comp_wl_remote_surface_init();
3877 e_comp_wl_screenshooter_init();
3879 if (!e_comp_wl_video_init())
3880 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3882 e_comp_wl_viewport_init();
3883 e_comp_wl_capture_init();
3884 e_comp_wl_renderer_init();
3885 _e_comp_wl_move_resize_init();
3886 e_presentation_time_init();
3887 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3890 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3891 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3893 /* add event handlers to catch E events */
3894 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3895 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3896 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3897 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3898 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3899 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3900 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3901 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3902 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3904 /* add hooks to catch e_client events */
3905 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3906 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3907 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3908 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3909 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3911 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3918 e_comp_wl_deferred_job(void)
3920 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3923 /* internal functions */
3925 e_comp_wl_shutdown(void)
3927 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3929 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3931 e_comp_wl_subsurfaces_shutdown();
3933 E_FREE_LIST(handlers, ecore_event_handler_del);
3934 E_FREE_LIST(hooks, e_client_hook_del);
3935 _e_comp_wl_gl_shutdown();
3937 e_blender_shutdown();
3938 e_presentation_time_shutdown();
3939 e_comp_wl_renderer_shutdown();
3940 e_comp_wl_capture_shutdown();
3941 e_comp_wl_viewport_shutdown();
3942 e_comp_wl_video_shutdown();
3943 e_comp_wl_screenshooter_shutdown();
3945 e_comp_wl_remote_surface_shutdown();
3947 e_pixmap_shutdown();
3949 e_wtz_shell_shutdown();
3950 e_comp_wl_shell_shutdown();
3951 e_comp_wl_input_shutdown();
3953 wl_list_remove(&comp->client_created.link);
3956 e_comp->wl_comp_data = NULL;
3960 E_Comp_Wl_Output *output;
3962 if (e_comp_wl->screenshooter.global)
3963 wl_global_destroy(e_comp_wl->screenshooter.global);
3965 EINA_LIST_FREE(e_comp_wl->outputs, output)
3967 if (output->id) eina_stringshare_del(output->id);
3968 if (output->make) eina_stringshare_del(output->make);
3969 if (output->model) eina_stringshare_del(output->model);
3973 /* delete fd handler */
3974 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3976 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3977 cursor_timer_ec = NULL;
3979 /* free allocated data structure */
3985 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3987 e_object_unref(E_OBJECT(ev->ec));
3992 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3995 ev = E_NEW(E_Event_Client, 1);
3998 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4000 /* set usable early because shell module checks this */
4001 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4002 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4004 e_pixmap_resource_set(ec->pixmap, buffer);
4005 e_pixmap_dirty(ec->pixmap);
4006 e_pixmap_refresh(ec->pixmap);
4008 e_comp_wl_map_size_cal_from_buffer(ec);
4009 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4011 /* wm-policy module uses it */
4012 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4015 e_object_ref(E_OBJECT(ec));
4016 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4017 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4021 e_comp_wl_surface_commit(E_Client *ec)
4026 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4027 if (!e_comp_object_damage_exists(ec->frame))
4029 if ((ec->comp_data->video_client) ||
4030 (!e_client_video_hw_composition_check(ec)))
4031 e_pixmap_image_clear(ec->pixmap, 1);
4034 ignored = ec->ignored;
4036 if (e_comp_wl_subsurface_order_commit(ec))
4038 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4039 e_comp_wl_subsurface_restack(topmost);
4040 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4043 ec->ignored = ignored;
4045 if (ec->is_cursor && ec->visible)
4047 /* ignore cursor changes during resize/move I guess */
4048 if (!e_client_action_get())
4050 if (e_comp->pointer)
4052 x = e_comp->pointer->hot.x;
4053 y = e_comp->pointer->hot.y;
4055 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4061 static E_Comp_Wl_Output *
4062 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4065 E_Comp_Wl_Output *output;
4067 EINA_LIST_FOREACH(outputs, l, output)
4069 if (!strcmp(output->id, id))
4077 * Initializes information about one display output.
4079 * Adds or updates the given data about a single display output,
4080 * with an id matching the provided id.
4082 * @param id identification of output to be added or changed
4083 * @param make manufacturer name of the display output
4084 * @param model model name of the display output
4085 * @param x output's top left corner x coordinate
4086 * @param y output's top left corner y coordinate
4087 * @param w output's width in pixels
4088 * @param h output's height in pixels
4089 * @param pw output's physical width in millimeters
4090 * @param ph output's physical height in millimeters
4091 * @param refresh output's refresh rate in mHz
4092 * @param subpixel output's subpixel layout
4093 * @param transform output's rotation and/or mirror transformation
4095 * @returns True if a display output object could be added or updated
4098 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4099 int x, int y, int w, int h, int pw, int ph,
4100 unsigned int refresh, unsigned int subpixel,
4101 unsigned int transform)
4103 E_Comp_Wl_Output *output;
4105 struct wl_resource *resource;
4107 /* retrieve named output; or create it if it doesn't exist */
4108 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4111 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4113 if (id) output->id = eina_stringshare_add(id);
4115 output->make = eina_stringshare_add(make);
4117 output->make = eina_stringshare_add("unknown");
4119 output->model = eina_stringshare_add(model);
4121 output->model = eina_stringshare_add("unknown");
4123 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4126 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4127 2, output, _e_comp_wl_cb_output_bind);
4129 output->resources = NULL;
4130 output->scale = e_scale;
4133 /* update the output details */
4138 output->phys_width = pw;
4139 output->phys_height = ph;
4140 output->refresh = refresh;
4141 output->subpixel = subpixel;
4142 output->transform = transform;
4144 if (output->scale <= 0)
4145 output->scale = e_scale;
4147 /* if we have bound resources, send updates */
4148 EINA_LIST_FOREACH(output->resources, l2, resource)
4150 wl_output_send_geometry(resource,
4151 output->x, output->y,
4153 output->phys_height,
4155 output->make ?: "", output->model ?: "",
4158 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4159 wl_output_send_scale(resource, output->scale);
4161 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4162 output->w, output->h, output->refresh);
4164 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4165 wl_output_send_done(resource);
4172 e_comp_wl_output_remove(const char *id)
4174 E_Comp_Wl_Output *output;
4176 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4179 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4181 /* wl_global_destroy(output->global); */
4183 /* eina_stringshare_del(output->id); */
4184 /* eina_stringshare_del(output->make); */
4185 /* eina_stringshare_del(output->model); */
4192 _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)
4194 struct wl_resource *res;
4196 uint32_t serial, keycode;
4197 struct wl_client *wc = NULL;
4198 E_Comp_Config *comp_conf = NULL;
4199 const char *device_name = NULL;
4201 keycode = (ev->keycode - 8);
4203 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4205 comp_conf = e_comp_config_get();
4207 if (ec && ec->comp_data)
4209 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4212 wc = wl_resource_get_client(surface);
4215 if (e_config->key_input_ttrace_enable)
4217 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4218 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4221 EINA_LIST_FOREACH(key_list, l, res)
4223 if (wl_resource_get_client(res) != wc) continue;
4225 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4226 if (!e_input_thread_mode_get())
4228 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4229 device_name = ecore_device_name_get(ev->dev);
4235 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4236 device_name = e_device_name_get(dev);
4240 if (comp_conf && comp_conf->input_log_enable)
4241 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4243 wl_keyboard_send_key(res, serial, ev->timestamp,
4248 if (e_config->key_input_ttrace_enable)
4251 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4256 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4258 E_Client *ec = NULL;
4260 E_Comp_Wl_Key_Data *end, *k;
4262 if (ev->window != e_comp->ee_win)
4267 keycode = (ev->keycode - 8);
4268 if (!(e_comp_wl = e_comp->wl_comp_data))
4273 #ifndef E_RELEASE_BUILD
4274 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4275 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4276 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4277 eina_streq(ev->key, "BackSpace"))
4283 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4285 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4287 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4289 /* ignore server-generated key repeats */
4290 if (k->key == keycode)
4292 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4297 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4299 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4301 ec = e_client_focused_get();
4302 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4303 if (ec && ec->comp_data && surface)
4305 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4306 if (e_comp_wl->kbd.focused)
4308 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4310 /* A key only sent to clients is added to the list */
4311 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4312 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4314 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4316 DBG("wl_array_add: Out of memory\n");
4317 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4318 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4321 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4325 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4329 /* update modifier state */
4330 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4336 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4338 E_Client *ec = NULL;
4339 uint32_t keycode, delivered_key;
4340 E_Comp_Wl_Key_Data *end, *k;
4342 if (ev->window != e_comp->ee_win)
4347 keycode = (ev->keycode - 8);
4349 if (!(e_comp_wl = e_comp->wl_comp_data))
4354 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4356 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4357 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4359 if (k->key == keycode)
4366 e_comp_wl->kbd.keys.size =
4367 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4369 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4371 /* 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) */
4372 if ((delivered_key) ||
4373 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4375 ec = e_client_focused_get();
4377 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4378 if (e_comp_wl->kbd.focused)
4380 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4382 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4385 /* update modifier state */
4386 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4392 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4394 Eina_Bool res = EINA_FALSE;
4396 if (type == ECORE_EVENT_KEY_DOWN)
4398 res = e_comp_wl_key_down(ev, dev);
4400 else if (type == ECORE_EVENT_KEY_UP)
4402 res = e_comp_wl_key_up(ev, dev);
4409 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4412 struct wl_client *wc;
4413 uint32_t serial, btn;
4414 struct wl_resource *res;
4415 E_Comp_Config *comp_conf = NULL;
4417 if (ec->cur_mouse_action || e_comp_wl->drag)
4419 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4420 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4424 case 1: btn = BTN_LEFT; break;
4425 case 2: btn = BTN_MIDDLE; break;
4426 case 3: btn = BTN_RIGHT; break;
4427 default: btn = button_id; break;
4430 e_comp_wl->ptr.button = btn;
4431 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4432 if (!surface) return EINA_FALSE;
4434 if (!eina_list_count(e_comp_wl->ptr.resources))
4437 wc = wl_resource_get_client(surface);
4438 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4440 comp_conf = e_comp_config_get();
4442 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4444 if (wl_resource_get_client(res) != wc) continue;
4445 if (!e_comp_wl_input_pointer_check(res)) continue;
4446 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4448 if (comp_conf && comp_conf->input_log_enable)
4449 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4451 wl_pointer_send_button(res, serial, timestamp, btn, state);
4458 e_comp_wl_touch_cancel(void)
4460 _e_comp_wl_touch_cancel();
4463 E_API E_Comp_Wl_Hook *
4464 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4468 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4469 ch = E_NEW(E_Comp_Wl_Hook, 1);
4470 if (!ch) return NULL;
4471 ch->hookpoint = hookpoint;
4473 ch->data = (void*)data;
4474 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4479 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4482 if (_e_comp_wl_hooks_walking == 0)
4484 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4488 _e_comp_wl_hooks_delete++;
4491 E_API E_Comp_Wl_Pid_Hook *
4492 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4494 E_Comp_Wl_Pid_Hook *ch;
4496 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4498 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4499 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4501 ch->hookpoint = hookpoint;
4503 ch->data = (void*)data;
4504 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4510 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4513 if (_e_comp_wl_pid_hooks_walking == 0)
4515 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4519 _e_comp_wl_pid_hooks_delete++;
4522 E_API E_Comp_Wl_Intercept_Hook *
4523 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4525 E_Comp_Wl_Intercept_Hook *ch;
4527 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4528 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4529 if (!ch) return NULL;
4530 ch->hookpoint = hookpoint;
4532 ch->data = (void*)data;
4533 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4538 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4541 if (_e_comp_wl_intercept_hooks_walking == 0)
4543 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4547 _e_comp_wl_intercept_hooks_delete++;
4551 e_comp_wl_shell_surface_ready(E_Client *ec)
4555 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4559 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4561 e_config->use_cursor_timer = !!enabled;
4563 if (e_config->use_cursor_timer)
4565 if (!e_pointer_is_hidden(e_comp->pointer))
4567 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4572 if (e_comp_wl->ptr.hide_tmr)
4574 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4575 e_comp_wl->ptr.hide_tmr = NULL;
4577 cursor_timer_ec = NULL;
4579 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4582 if (e_pointer_is_hidden(e_comp->pointer))
4584 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4590 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4592 EINA_SAFETY_ON_NULL_RETURN(wc);
4593 EINA_SAFETY_ON_NULL_RETURN(dev);
4595 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4599 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4601 EINA_SAFETY_ON_NULL_RETURN(wc);
4602 EINA_SAFETY_ON_NULL_RETURN(dev);
4604 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4608 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4610 struct wl_resource *res;
4611 struct wl_client *wc;
4613 uint32_t serial, wl_keycode;
4614 enum wl_keyboard_key_state state;
4615 E_Comp_Config *comp_conf = NULL;
4616 const char *dev_name = NULL;
4618 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4619 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4620 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4622 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4623 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4625 wl_keycode = keycode - 8;
4626 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4628 wc = wl_resource_get_client(surface);
4629 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4630 if (!time) time = e_util_timestamp_get();
4631 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4632 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4634 comp_conf = e_comp_config_get();
4635 e_keyrouter_event_surface_send(ec, keycode);
4637 if (e_config->key_input_ttrace_enable)
4639 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4640 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4643 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4644 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4646 if (wl_resource_get_client(res) != wc) continue;
4647 if (!e_input_thread_mode_get())
4651 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4652 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4656 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4663 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4664 dev_name = e_device_name_get(dev);
4668 if (comp_conf && comp_conf->input_log_enable)
4669 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4672 wl_keyboard_send_key(res, serial, time,
4675 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4677 if (e_config->key_input_ttrace_enable)
4680 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4687 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4689 struct wl_resource *res;
4690 struct wl_client *wc;
4692 uint32_t serial, wl_keycode, cancel_keycode;
4693 E_Comp_Config *comp_conf = NULL;
4694 struct xkb_keymap *keymap = NULL;
4696 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4697 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4698 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4700 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4701 keymap = e_comp_wl->xkb.keymap;
4702 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4703 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4705 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4706 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4708 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4709 if (cancel_keycode == XKB_KEYCODE_INVALID)
4711 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4714 cancel_keycode = cancel_keycode - 8;
4716 wl_keycode = keycode - 8;
4717 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4719 wc = wl_resource_get_client(surface);
4720 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4721 if (!time) time = e_util_timestamp_get();
4723 comp_conf = e_comp_config_get();
4724 e_keyrouter_event_surface_send(ec, keycode);
4726 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4727 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4729 if (wl_resource_get_client(res) != wc) continue;
4730 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4731 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4733 if (comp_conf && comp_conf->input_log_enable)
4734 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4735 wl_keyboard_send_key(res, serial, time,
4736 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4737 wl_keyboard_send_key(res, serial, time,
4738 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4739 wl_keyboard_send_key(res, serial, time,
4740 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4742 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4749 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)
4751 struct wl_client *wc;
4753 E_Devicemgr_Input_Device *device = NULL;
4755 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4756 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4757 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4759 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4760 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4762 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4764 wc = wl_resource_get_client(surface);
4765 if (!time) time = e_util_timestamp_get();
4766 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4770 _e_comp_wl_send_event_device(wc, time, dev, serial);
4771 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4775 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4776 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4779 x = x + ec->client.x;
4780 y = y + ec->client.y;
4782 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4788 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)
4790 E_Devicemgr_Input_Device *device;
4792 struct wl_client *wc;
4794 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4795 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4796 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4798 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4799 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4801 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4803 wc = wl_resource_get_client(surface);
4804 if (!time) time = e_util_timestamp_get();
4805 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4809 _e_comp_wl_send_event_device(wc, time, dev, serial);
4810 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4814 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4815 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4818 x = x + ec->client.x;
4819 y = y + ec->client.y;
4821 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4827 e_comp_wl_touch_cancel_send(E_Client *ec)
4829 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4830 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4831 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4833 _e_comp_wl_send_touch_cancel(ec);
4839 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4842 struct wl_client *wc;
4844 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4845 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4846 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4848 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4849 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4851 wc = wl_resource_get_client(surface);
4852 if (!time) time = e_util_timestamp_get();
4853 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4855 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4856 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4859 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4860 WL_POINTER_BUTTON_STATE_PRESSED);
4862 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4863 WL_POINTER_BUTTON_STATE_RELEASED);
4869 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4872 struct wl_client *wc;
4874 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4875 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4876 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4878 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4881 wc = wl_resource_get_client(surface);
4882 if (!time) time = e_util_timestamp_get();
4883 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4885 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4886 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4888 x = x + ec->client.x;
4889 y = y + ec->client.y;
4891 _e_comp_wl_send_mouse_move(ec, x, y, time);
4897 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4900 struct wl_client *wc;
4902 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4903 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4904 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4906 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4907 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4909 wc = wl_resource_get_client(surface);
4910 if (!time) time = e_util_timestamp_get();
4911 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4913 if (_e_comp_wl_check_cursor_timer_needed(ec))
4915 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4919 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4920 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4922 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4924 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4926 if (_e_comp_wl_check_cursor_timer_needed(ec))
4927 _e_comp_wl_cursor_move_timer_control(ec);
4934 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4937 struct wl_client *wc;
4938 struct wl_resource *res;
4941 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4942 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4944 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4945 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4947 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4948 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4950 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4951 wc = wl_resource_get_client(surface);
4952 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4953 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4955 if (!e_comp_wl_input_pointer_check(res)) continue;
4956 if (wl_resource_get_client(res) != wc) continue;
4958 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4959 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4961 wl_pointer_send_enter(res, serial, surface,
4962 wl_fixed_from_int(x),
4963 wl_fixed_from_int(y));
4964 ec->pointer_enter_sent = EINA_TRUE;
4966 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4972 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4975 struct wl_client *wc;
4976 struct wl_resource *res;
4979 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4980 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4981 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4982 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4983 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4984 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4986 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4987 wc = wl_resource_get_client(surface);
4988 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4989 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4991 if (!e_comp_wl_input_pointer_check(res)) continue;
4992 if (wl_resource_get_client(res) != wc) continue;
4994 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4995 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4997 wl_pointer_send_leave(res, serial, surface);
4998 ec->pointer_enter_sent = EINA_FALSE;
5005 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)
5007 Evas_Event_Mouse_In ev_in;
5010 if (ec->pointer_enter_sent) return;
5012 ev_in.buttons = buttons;
5020 ev_in.modifiers = modifiers;
5021 ev_in.locks = locks;
5022 ev_in.timestamp = timestamp;
5023 ev_in.event_flags = event_flags;
5026 ev_in.event_src = event_src;
5028 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5032 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)
5034 Evas_Event_Mouse_Out ev_out;
5037 if (!ec->pointer_enter_sent) return;
5039 ev_out.buttons = buttons;
5041 ev_out.output.x = x;
5042 ev_out.output.y = y;
5043 ev_out.canvas.x = x;
5044 ev_out.canvas.y = y;
5047 ev_out.modifiers = modifiers;
5048 ev_out.locks = locks;
5049 ev_out.timestamp = timestamp;
5050 ev_out.event_flags = event_flags;
5053 ev_out.event_src = event_src;
5055 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5059 e_comp_wl_cursor_hide(E_Client *ec)
5061 struct wl_resource *res;
5062 struct wl_client *wc;
5066 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5068 if (e_comp_wl->ptr.hide_tmr)
5070 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5071 e_comp_wl->ptr.hide_tmr = NULL;
5073 cursor_timer_ec = NULL;
5075 if (!ec) return EINA_FALSE;
5076 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5077 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5078 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5080 wc = wl_resource_get_client(surface);
5081 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5082 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5084 if (!e_comp_wl_input_pointer_check(res)) continue;
5085 if (wl_resource_get_client(res) != wc) continue;
5086 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5087 wl_pointer_send_leave(res, serial, surface);
5088 ec->pointer_enter_sent = EINA_FALSE;
5094 /* surface to buffer
5095 * - width : surface width
5096 * - height : surface height
5097 * - transform: buffer transform
5098 * - scale : buffer scale
5100 * - width : screen width
5101 * - height : screen height
5102 * - transform: output transform
5103 * - scale : output scale
5105 static E_Util_Transform_Matrix
5106 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5108 E_Util_Transform_Matrix m;
5110 e_util_transform_matrix_load_identity(&m);
5112 if (transform & 0x4)
5114 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5115 e_util_transform_matrix_flip_x(&m);
5116 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5119 switch (transform & 0x3)
5121 case WL_OUTPUT_TRANSFORM_90:
5122 e_util_transform_matrix_translate(&m, -width, 0, 0);
5123 e_util_transform_matrix_rotation_z(&m, 270);
5125 case WL_OUTPUT_TRANSFORM_180:
5126 e_util_transform_matrix_translate(&m, -width, -height, 0);
5127 e_util_transform_matrix_rotation_z(&m, 180);
5129 case WL_OUTPUT_TRANSFORM_270:
5130 e_util_transform_matrix_translate(&m, 0, -height, 0);
5131 e_util_transform_matrix_rotation_z(&m, 90);
5137 e_util_transform_matrix_scale(&m, scale, scale, 1);
5142 /* surface to buffer
5143 * - surface width, surface height, buffer transform, buffer scale
5145 * - screen width, screen height, output transform, output scale
5148 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5150 E_Util_Transform_Matrix m;
5151 E_Util_Transform_Vertex v;
5153 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5155 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5156 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5157 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5161 * - buffer width, buffer height, buffer transform, buffer scale
5164 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5166 E_Util_Transform_Matrix m;
5167 E_Util_Transform_Vertex v;
5170 if (transform != 0 || scale > 1)
5172 tw = ((transform % 2) ? height : width) / scale;
5173 th = ((transform % 2) ? width : height) / scale;
5181 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5182 m = e_util_transform_matrix_inverse_get(&m);
5184 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5185 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5186 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5189 /* surface to buffer
5190 * - surface width, surface height, buffer transform, buffer scale
5192 * - screen width, screen height, output transform, output scale
5195 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5196 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5198 E_Util_Transform_Matrix m;
5199 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5200 E_Util_Transform_Rect_Vertex sv;
5202 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5204 sv = e_util_transform_rect_to_vertices(&sr);
5205 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5206 sr = e_util_transform_vertices_to_rect(&sv);
5215 * - buffer width, buffer height, buffer transform, buffer scale
5218 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5219 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5221 E_Util_Transform_Matrix m;
5222 E_Util_Transform_Rect br = {bx, by, bw, bh};
5223 E_Util_Transform_Rect_Vertex bv;
5226 if (transform != 0 || scale > 1)
5228 tw = ((transform % 2) ? height : width) / scale;
5229 th = ((transform % 2) ? width : height) / scale;
5237 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5238 m = e_util_transform_matrix_inverse_get(&m);
5240 bv = e_util_transform_rect_to_vertices(&br);
5241 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5242 br = e_util_transform_vertices_to_rect(&bv);
5250 EINTERN E_Comp_Wl_Output*
5251 e_comp_wl_output_find(E_Client *ec)
5254 E_Comp_Wl_Output *output;
5256 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5258 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5260 if (output->transform % 2)
5262 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5263 ec->y < output->x || ec->y >= (output->x + output->w))
5268 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5269 ec->y < output->y || ec->y >= (output->y + output->h))
5279 EINTERN Eina_Array *
5280 e_comp_wl_output_find_all(E_Client *ec)
5282 E_Comp_Wl_Output *output;
5283 Eina_Array *outputs;
5286 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5288 outputs = eina_array_new(4);
5292 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5294 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5295 output->x, output->y, output->w, output->h))
5297 eina_array_push(outputs, output);
5301 if (eina_array_count(outputs) == 0)
5303 eina_array_free(outputs);
5310 // --------------------------------------------------------
5311 // tizen_move_resize
5312 // --------------------------------------------------------
5314 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5321 E_Client_Pending_Geometry *geo;
5324 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5325 if (ec->fullscreen || ec->maximized) goto err;
5327 geo = E_NEW(E_Client_Pending_Geometry, 1);
5330 geo->serial = serial;
5336 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5337 ec->surface_sync.wait_commit = EINA_TRUE;
5342 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5349 e_comp_wl_commit_sync_configure(E_Client *ec)
5352 E_Client_Pending_Geometry *geo;
5354 Eina_Bool match_size = EINA_FALSE;
5361 if (!ec || !ec->frame) goto ret;
5362 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5365 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5366 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5368 if (eina_list_count(ec->surface_sync.pending_geometry))
5370 Eina_List *ll = NULL;
5371 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5375 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5380 if ((geo->w == bw) && (geo->h == bh))
5382 match_size = EINA_TRUE;
5387 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5394 if ((config.w != ec->w) || (config.h != ec->h))
5396 e_client_size_set(ec, config.w, config.h);
5397 ec->changes.size = EINA_TRUE;
5401 // FIXME: The geometry of the client would be better to be calculated
5402 // at e_desk or at e_desk_area. So the position(x,y) of the client
5403 // should be calcuated at the e_desk or at the e_desk_area.
5405 desk = e_comp_desk_find_by_ec(ec);
5408 ec->client.x = desk->geom.x + config.x;
5409 ec->client.y = desk->geom.y + config.y;
5413 ec->client.x = config.x;
5414 ec->client.y = config.y;
5417 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5419 e_client_pos_set(ec, ec->client.x, ec->client.y);
5421 ec->changes.pos = 1;
5425 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5429 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5430 ec->surface_sync.wait_commit = EINA_FALSE;
5432 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5434 // rollback wait_commit if there are pending requests remained
5435 if (eina_list_count(ec->surface_sync.pending_geometry))
5436 ec->surface_sync.wait_commit = EINA_TRUE;
5441 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);
5448 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5449 struct wl_resource *res_moveresize)
5451 wl_resource_destroy(res_moveresize);
5455 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5456 struct wl_resource *res_moveresize,
5457 struct wl_resource *surface,
5464 /* to be implemented */
5467 int cur_w = 0, cur_h = 0;
5469 ec = e_client_from_surface_resource(surface);
5472 pending = e_client_pending_geometry_has(ec);
5473 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5474 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);
5478 if ((cur_w == w) && (cur_h == h))
5480 e_client_pos_set(ec, x, y);
5481 ec->changes.pos = 1;
5487 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5491 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5494 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5496 _tz_move_resize_iface_cb_destroy,
5497 _tz_move_resize_iface_cb_set_geometry,
5501 _tz_moveresize_cb_bind(struct wl_client *client,
5502 void *data EINA_UNUSED,
5506 struct wl_resource *res_moveresize;
5508 res_moveresize = wl_resource_create(client,
5509 &tizen_move_resize_interface,
5512 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5515 wl_resource_set_implementation(res_moveresize,
5516 &_tz_move_resize_iface,
5522 ERR("Could not create tizen_move_resize_interface res: %m");
5523 wl_client_post_no_memory(client);
5527 _e_comp_wl_move_resize_init(void)
5529 if (!e_comp_wl) return;
5530 if (!e_comp_wl->wl.disp) return;
5532 if (!wl_global_create(e_comp_wl->wl.disp,
5533 &tizen_move_resize_interface,
5536 _tz_moveresize_cb_bind))
5538 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5545 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5547 E_Comp_Wl_Output *output;
5548 pid_t output_pid = 0;
5549 Eina_List *l = NULL, *l2 = NULL;
5550 struct wl_resource *resource = NULL;
5552 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5554 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5555 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5556 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5558 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5560 /* if we have bound resources, send updates */
5561 EINA_LIST_FOREACH(output->resources, l2, resource)
5563 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5564 if (output_pid != pid) continue;
5566 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5568 // send output information to the client
5569 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5577 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5579 _e_comp_wl_surface_state_init(state, w, h);
5583 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5585 _e_comp_wl_surface_state_commit(ec, state);
5589 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5591 _e_comp_wl_hook_call(hookpoint, ec);
5595 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5597 _e_comp_wl_surface_state_finish(state);
5601 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5603 _e_comp_wl_surface_state_buffer_set(state, buffer);
5607 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5608 int sx, int sy, int *dx, int *dy)
5612 case WL_OUTPUT_TRANSFORM_NORMAL:
5616 case WL_OUTPUT_TRANSFORM_FLIPPED:
5617 *dx = width - sx, *dy = sy;
5619 case WL_OUTPUT_TRANSFORM_90:
5620 *dx = height - sy, *dy = sx;
5622 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5623 *dx = height - sy, *dy = width - sx;
5625 case WL_OUTPUT_TRANSFORM_180:
5626 *dx = width - sx, *dy = height - sy;
5628 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5629 *dx = sx, *dy = height - sy;
5631 case WL_OUTPUT_TRANSFORM_270:
5632 *dx = sy, *dy = width - sx;
5634 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5644 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5647 int tx1, ty1, tx2, ty2;
5648 int width_from_buffer, height_from_buffer;
5650 switch (vp->buffer.transform)
5652 case WL_OUTPUT_TRANSFORM_90:
5653 case WL_OUTPUT_TRANSFORM_270:
5654 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5655 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5656 width_from_buffer = bh / vp->buffer.scale;
5657 height_from_buffer = bw / vp->buffer.scale;
5660 width_from_buffer = bw / vp->buffer.scale;
5661 height_from_buffer = bh / vp->buffer.scale;
5665 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5669 x2 = width_from_buffer;
5670 y2 = height_from_buffer;
5674 x1 = wl_fixed_to_int(vp->buffer.src_x);
5675 y1 = wl_fixed_to_int(vp->buffer.src_y);
5676 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5677 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5680 buffer_transform(width_from_buffer, height_from_buffer,
5681 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5682 buffer_transform(width_from_buffer, height_from_buffer,
5683 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5685 out->x = (tx1 <= tx2) ? tx1 : tx2;
5686 out->y = (ty1 <= ty2) ? ty1 : ty2;
5687 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5688 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5692 * Convert given four coordinates to elements of rectangle
5693 * @in p[4] Coordinates to be converted
5694 * @out rect x, y, width, and height
5695 * transform Angle which represents TDM_TRANSFORM of rectangle
5696 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5697 * 1. The given coordinates are not represented by rectangle.
5698 * 2. All angles except for 0, 90, 180, 270.
5701 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5703 Eina_Bool ret = EINA_FALSE;
5705 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))
5708 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5711 *rotation = TDM_TRANSFORM_NORMAL;
5714 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5718 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5721 *rotation = TDM_TRANSFORM_180;
5724 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5729 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))
5732 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5735 *rotation = TDM_TRANSFORM_90;
5738 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5742 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5745 *rotation = TDM_TRANSFORM_270;
5748 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5758 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5763 for (i = 0; i < 4; i++)
5764 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5766 if (!_coords_to_rectangle_convert(p, out, rotation))
5768 DBG("Cannot convert given coords to rectangle.\n"
5769 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5770 p[0].x, p[0].y, p[1].x, p[1].y,
5771 p[2].x, p[2].y, p[3].x, p[3].y);
5779 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5781 int trans_rotation, flip;
5783 trans_rotation = transform & 0x3;
5784 flip = transform & 0x4;
5786 return (flip + (trans_rotation + rotation) % 4);
5790 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5798 if (e_comp_wl_subsurface_check(ec))
5799 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5806 out->w = ec->comp_data->width_from_viewport;
5807 out->w = (out->w + 1) & ~1;
5808 out->h = ec->comp_data->height_from_viewport;
5810 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5811 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5815 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5817 E_Comp_Wl_Buffer *buffer;
5818 E_Comp_Wl_Buffer_Viewport *vp;
5820 enum wl_output_transform buffer_transform;
5821 unsigned int rotation;
5822 Eina_Bool res = EINA_FALSE;
5824 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5826 if (e_object_is_del(E_OBJECT(ec)))
5829 vp = &ec->comp_data->scaler.buffer_viewport;
5831 if (buffer_viewport)
5833 buffer = ec->comp_data->buffer_ref.buffer;
5834 /* Getting a viewport of buffer needs geometry of buffer. */
5838 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5841 if ((output_viewport) || (transform))
5843 m = e_client_map_get(ec);
5845 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5847 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5852 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5853 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5854 * Since buffer.transform isn't applied using evas_map,
5855 * it has to be taken into account here to apply buffer.transform
5856 * and rotation of e_client_transform together. */
5858 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5860 *transform = (unsigned int)buffer_transform;
5868 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5870 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5871 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5873 /* Must be called with valid comp_data */
5874 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5876 if ((ec->comp_data->role_name == NULL) ||
5877 (ec->comp_data->role_name == role_name) ||
5878 (strcmp(ec->comp_data->role_name, role_name) == 0))
5880 ec->comp_data->role_name = role_name;
5886 wl_resource_post_error(error_resource, error_code,
5887 "Cannot assign role %s to wl_surface@%d,"
5888 " already has role %s\n",
5890 ec->comp_data->wl_surface ?
5891 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5892 ec->comp_data->role_name);
5898 EINTERN const char *
5899 e_comp_wl_surface_role_get(E_Client *ec)
5901 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5902 return ec->comp_data ? ec->comp_data->role_name : NULL;
5905 EINTERN struct wl_resource *
5906 e_comp_wl_client_surface_get(E_Client *ec)
5908 struct wl_resource *surface = NULL;
5909 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5910 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5912 g_mutex_lock(&ec->comp_data->surface_mutex);
5913 surface = ec->comp_data->surface;
5914 g_mutex_unlock(&ec->comp_data->surface_mutex);
5919 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5921 EINA_SAFETY_ON_NULL_RETURN(ec);
5922 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5924 g_mutex_lock(&ec->comp_data->surface_mutex);
5925 ec->comp_data->surface = surface;
5926 g_mutex_unlock(&ec->comp_data->surface_mutex);
5930 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5932 return e_compositor_util_client_from_surface_resource(surface_resource);
5936 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5938 if (!ec->comp_data->mapped)
5940 if (ec->comp_data->shell.surface &&
5941 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5943 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5949 if (ec->comp_data->mapped)
5951 /* will be unmapped. so run capture */
5952 e_comp_wl_remote_surface_image_save(ec);
5956 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5958 ec->comp_data->pending.sx = sx;
5959 ec->comp_data->pending.sy = sy;
5960 ec->comp_data->pending.new_attach = EINA_TRUE;
5962 e_client_fps_update(ec);
5966 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5968 if (ec->comp_data->pending.opaque)
5969 eina_tiler_clear(ec->comp_data->pending.opaque);
5973 eina_tiler_union(ec->comp_data->pending.opaque, region);
5975 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5979 ec->argb = EINA_FALSE;
5980 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5982 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5983 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5991 ec->argb = EINA_TRUE;
5992 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5994 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5995 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6001 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6003 if (ec->comp_data->pending.input)
6004 eina_tiler_clear(ec->comp_data->pending.input);
6008 if (eina_tiler_empty(region))
6010 ELOGF("COMP", " |unset input rect", NULL);
6011 e_comp_object_input_objs_del(ec->frame);
6012 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6015 eina_tiler_union(ec->comp_data->pending.input, region);
6019 eina_tiler_rect_add(ec->comp_data->pending.input,
6020 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6025 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6027 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6031 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6033 E_Comp_Wl_Subsurf_Data *sdata;
6038 if (ec->comp_data->frames)
6040 ec->comp_data->frames =
6041 eina_list_remove(ec->comp_data->frames, callback_resource);
6044 if (ec->comp_data->pending.frames)
6046 ec->comp_data->pending.frames =
6047 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6050 sdata = ec->comp_data->sub.data;
6051 if ((sdata) && (sdata->cached.frames))
6053 sdata->cached.frames =
6054 eina_list_remove(sdata->cached.frames, callback_resource);
6059 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6061 if (e_object_is_del(E_OBJECT(ec))) return;
6063 if (e_comp_wl_remote_surface_commit(ec)) return;
6065 e_comp_wl_surface_commit(ec);
6067 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6071 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6073 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6074 ec->comp_data->sub.data = sub;
6076 /* set subsurface client properties */
6077 ec->borderless = EINA_TRUE;
6078 ec->argb = EINA_TRUE;
6079 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6080 ec->lock_border = EINA_TRUE;
6081 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6082 ec->netwm.state.skip_taskbar = EINA_TRUE;
6083 ec->netwm.state.skip_pager = EINA_TRUE;
6084 ec->border_size = 0;
6085 ec->lock_user_location = 0;
6086 ec->lock_client_location = 0;
6087 ec->lock_user_size = 0;
6088 ec->lock_client_size = 0;
6089 ec->lock_client_stacking = 0;
6090 ec->lock_user_maximize = 0;
6091 ec->lock_client_maximize = 0;
6092 ec->changes.need_maximize = 0;
6093 ec->maximized = E_MAXIMIZE_NONE;
6096 ec->new_client = ec->netwm.ping = EINA_TRUE;
6097 e_comp->new_clients++;
6098 e_client_unignore(ec);
6100 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6101 * It's not for subsurface. */
6102 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6106 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6108 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6111 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6113 sub->parent = parent;
6117 layer = e_client_layer_get(parent);
6118 if (layer > E_LAYER_BOTTOM)
6119 e_client_layer_set(ec, layer);
6122 if (parent->comp_data)
6124 /* append this client to the parents subsurface list */
6125 parent->comp_data->sub.list_pending =
6126 eina_list_append(parent->comp_data->sub.list_pending, ec);
6127 parent->comp_data->sub.list_changed = EINA_TRUE;
6132 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6134 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6135 E_Client *parent = sub->parent;
6137 parent->comp_data->sub.list =
6138 eina_list_remove(parent->comp_data->sub.list, ec);
6139 parent->comp_data->sub.list_pending =
6140 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6141 parent->comp_data->sub.below_list =
6142 eina_list_remove(parent->comp_data->sub.below_list, ec);
6143 parent->comp_data->sub.below_list_pending =
6144 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6150 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)
6152 sub->resource = subsurface_resource;
6153 sub->cached_buffer_ref.buffer = NULL;
6154 sub->synchronized = EINA_TRUE;
6155 sub->parent = parent;
6156 sub->remote_surface.offscreen_parent = offscreen_parent;
6157 if (offscreen_parent)
6158 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6160 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6162 _e_comp_wl_client_subsurface_set(ec, sub);
6163 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6165 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6169 e_comp_wl_client_subsurface_finish(E_Client *ec)
6171 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6174 e_comp_wl_client_subsurface_parent_unset(ec);
6176 e_comp_wl_surface_state_finish(&sub->cached);
6177 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6179 ec->comp_data->sub.data = NULL;
6183 e_comp_wl_client_evas_init(E_Client *ec)
6185 EINA_SAFETY_ON_NULL_RETURN(ec);
6187 _e_comp_wl_client_evas_init(ec);
6191 e_comp_wl_client_evas_deinit(E_Client *ec)
6193 EINA_SAFETY_ON_NULL_RETURN(ec);
6195 _e_comp_wl_client_evas_deinit(ec);
6199 e_comp_wl_focus_check(void)
6201 _e_comp_wl_focus_check();
6205 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6212 if ((parent->comp_data) && (parent->comp_data->sub.data))
6213 parent = parent->comp_data->sub.data->parent;