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"
20 #include <tizen-extension-server-protocol.h>
21 #include <relative-pointer-unstable-v1-server-protocol.h>
22 #include <pointer-constraints-unstable-v1-server-protocol.h>
24 #include <wayland-tbm-server.h>
26 #include <libds/log.h>
27 #include <libds/single_pixel_buffer_v1.h>
29 /* handle include for printing uint64_t */
30 #define __STDC_FORMAT_MACROS
33 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
35 /* Resource Data Mapping: (wl_resource_get_user_data)
37 * wl_surface == e_pixmap
38 * wl_region == eina_tiler
39 * wl_subsurface == e_client
43 typedef struct _E_Comp_Data E_Comp_Data;
48 struct wl_listener client_created;
51 static void _e_comp_wl_move_resize_init(void);
53 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
56 typedef struct _E_Comp_Wl_Key_Data
62 static Eina_List *handlers = NULL;
63 static E_Client *cursor_timer_ec = NULL;
64 static Eina_Bool need_send_released = EINA_FALSE;
65 static Eina_Bool need_send_motion = EINA_TRUE;
67 static GMutex connection_mutex;
69 static int _e_comp_wl_hooks_delete = 0;
70 static int _e_comp_wl_hooks_walking = 0;
72 static int _e_comp_wl_pid_hooks_delete = 0;
73 static int _e_comp_wl_pid_hooks_walking = 0;
75 static int _e_comp_wl_intercept_hooks_delete = 0;
76 static int _e_comp_wl_intercept_hooks_walking = 0;
78 static Eina_Inlist *_e_comp_wl_hooks[] =
80 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
81 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
82 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
83 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
84 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
85 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
86 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
87 [E_COMP_WL_HOOK_DEL] = NULL,
88 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
89 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
90 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
93 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
95 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
98 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
100 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
101 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
102 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
103 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
104 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
105 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
108 static Eina_List *hooks = NULL;
110 /* local functions */
112 _e_comp_wl_hooks_clean(void)
117 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
118 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
120 if (!ch->delete_me) continue;
121 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
127 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
131 e_object_ref(E_OBJECT(ec));
132 _e_comp_wl_hooks_walking++;
133 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
135 if (ch->delete_me) continue;
136 ch->func(ch->data, ec);
137 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
138 (e_object_is_del(E_OBJECT(ec))))
141 _e_comp_wl_hooks_walking--;
142 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
143 _e_comp_wl_hooks_clean();
144 e_object_unref(E_OBJECT(ec));
148 _e_comp_wl_pid_hooks_clean(void)
151 E_Comp_Wl_Pid_Hook *ch;
153 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
154 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
156 if (!ch->delete_me) continue;
157 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
163 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
165 E_Comp_Wl_Pid_Hook *ch;
167 _e_comp_wl_pid_hooks_walking++;
168 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
170 if (ch->delete_me) continue;
171 ch->func(ch->data, pid);
173 _e_comp_wl_pid_hooks_walking--;
174 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
175 _e_comp_wl_pid_hooks_clean();
179 _e_comp_wl_intercept_hooks_clean(void)
182 E_Comp_Wl_Intercept_Hook *ch;
184 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
185 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
187 if (!ch->delete_me) continue;
188 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
194 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
196 E_Comp_Wl_Intercept_Hook *ch;
197 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
199 e_object_ref(E_OBJECT(ec));
200 _e_comp_wl_intercept_hooks_walking++;
201 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
203 if (ch->delete_me) continue;
204 res = ch->func(ch->data, ec);
205 if (!res) ret = EINA_FALSE;
206 if (e_object_is_del(E_OBJECT(ec)))
209 _e_comp_wl_intercept_hooks_walking--;
210 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
211 _e_comp_wl_intercept_hooks_clean();
212 e_object_unref(E_OBJECT(ec));
219 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
225 if (e_comp_object_frame_exists(ec->frame))
226 w = ec->client.w, h = ec->client.h;
228 w = ec->w, h = ec->h;
232 // Width and Height are -1 means that we don't consider size value
236 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
240 _e_comp_wl_focus_check(void)
244 if (stopping) return;
245 ec = e_client_focused_get();
247 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
251 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
253 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
255 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
256 IDLE_EXITER~CB_PREPARE);
258 return ECORE_CALLBACK_RENEW;
262 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
264 /* dispatch pending wayland events */
265 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
267 return ECORE_CALLBACK_RENEW;
271 e_comp_wl_display_flush()
273 if (e_comp_wl && e_comp_wl->wl.disp)
275 if (e_config->key_input_ttrace_enable)
277 TRACE_INPUT_BEGIN(wl_display_flush_clients);
278 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
281 g_mutex_lock(&connection_mutex);
282 wl_display_flush_clients(e_comp_wl->wl.disp);
283 g_mutex_unlock(&connection_mutex);
285 if (e_config->key_input_ttrace_enable)
288 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
294 e_comp_wl_connection_lock()
296 e_input_boost_lock(&connection_mutex);
300 e_comp_wl_connection_unlock()
302 e_input_boost_unlock(&connection_mutex);
306 e_comp_wl_focused_client_flush()
308 E_Client *focused_ec;
309 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
311 e_input_boost_lock(&connection_mutex);
312 focused_ec = e_client_focused_get();
316 struct wl_client *wc;
317 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
320 e_input_boost_unlock(&connection_mutex);
324 wc = wl_resource_get_client(surface);
328 e_input_boost_unlock(&connection_mutex);
332 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
336 if (e_comp_wl->idle_exiter_timestamp > 0.0)
338 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
339 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
341 ELOGF("E_COMP", "prepare gap time: %lfms",
346 e_comp_wl->idle_exiter_timestamp = 0.0;
348 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
350 /* flush pending client events */
351 e_comp_wl_display_flush();
353 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
354 IDLE_EXITER~CB_PREPARE);
357 E_API enum wl_output_transform
358 e_comp_wl_output_buffer_transform_get(E_Client *ec)
360 E_Comp_Wl_Buffer_Viewport *vp;
361 E_Comp_Wl_Buffer *buffer;
362 enum wl_output_transform transform, rotation;
364 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
365 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
366 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
368 vp = &ec->comp_data->scaler.buffer_viewport;
369 if (e_comp_wl_subsurface_check(ec))
370 return vp->buffer.transform;
372 buffer = ec->comp_data->buffer_ref.buffer;
375 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
376 return vp->buffer.transform;
378 rotation = buffer->transform;
380 return vp->buffer.transform;
382 /* ignore the flip value when calculating transform because the screen rotation
383 * functionality doesn't consider the flip output transform currently
385 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
387 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
388 ec, rotation, vp->buffer.transform, transform);
393 EINTERN enum wl_output_transform
394 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
396 E_Comp_Wl_Buffer_Viewport *vp;
397 E_Comp_Wl_Buffer *buffer;
398 enum wl_output_transform transform, rotation;
400 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
401 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
402 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
404 vp = &ec->comp_data->pending.buffer_viewport;
405 if (e_comp_wl_subsurface_check(ec))
406 return vp->buffer.transform;
408 buffer = ec->comp_data->pending.buffer;
411 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
412 return vp->buffer.transform;
414 rotation = buffer->transform;
416 return vp->buffer.transform;
418 /* ignore the flip value when calculating transform because the screen rotation
419 * functionality doesn't consider the flip output transform currently
421 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
423 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
424 ec, rotation, vp->buffer.transform, transform);
430 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
432 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
433 E_Comp_Wl_Buffer *buffer;
434 int32_t width, height;
436 buffer = e_pixmap_resource_get(ec->pixmap);
439 ec->comp_data->width_from_buffer = 0;
440 ec->comp_data->height_from_buffer = 0;
444 switch (e_comp_wl_output_buffer_transform_get(ec))
446 case WL_OUTPUT_TRANSFORM_90:
447 case WL_OUTPUT_TRANSFORM_270:
448 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
449 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
450 width = buffer->h / vp->buffer.scale;
451 height = buffer->w / vp->buffer.scale;
454 width = buffer->w / vp->buffer.scale;
455 height = buffer->h / vp->buffer.scale;
459 ec->comp_data->width_from_buffer = width;
460 ec->comp_data->height_from_buffer = height;
464 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
466 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
467 int32_t width, height;
469 width = ec->comp_data->width_from_buffer;
470 height = ec->comp_data->height_from_buffer;
472 if (width == 0 && height == 0) return;
474 if (width != 0 && vp->surface.width != -1)
476 ec->comp_data->width_from_viewport = vp->surface.width;
477 ec->comp_data->height_from_viewport = vp->surface.height;
481 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
483 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
484 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
485 ec->comp_data->width_from_viewport = w ?: 1;
486 ec->comp_data->height_from_viewport = h ?: 1;
490 ec->comp_data->width_from_viewport = width;
491 ec->comp_data->height_from_viewport = height;
495 e_comp_wl_topmost_parent_get(E_Client *ec)
499 if (!e_comp_wl_subsurface_check(ec))
502 parent = e_comp_wl_subsurface_parent_get(ec);
505 if (!e_comp_wl_subsurface_check(parent))
508 parent = e_comp_wl_subsurface_parent_get(parent);
515 e_comp_wl_map_apply(E_Client *ec)
517 E_Comp_Wl_Buffer_Viewport *vp;
518 E_Comp_Wl_Subsurf_Data *sdata;
519 E_Comp_Wl_Client_Data *cdata;
520 int x1, y1, x2, y2, x, y;
522 Eina_Bool zoom_animating = EINA_FALSE;
524 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
526 e_comp_object_map_update(ec->frame);
528 cdata = ec->comp_data;
529 vp = &cdata->scaler.buffer_viewport;
530 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
531 (!cdata->viewport_transform))
534 if (e_comp_wl_subsurface_check(ec))
536 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
538 sdata = ec->comp_data->sub.data;
539 if (sdata->remote_surface.offscreen_parent)
541 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
542 Eina_Rectangle *rect;
545 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
547 /* TODO: If there are one more regions, it means that provider's offscreen
548 * is displayed by one more remote_surfaces. Have to consider it later. At
549 * this time, just consider only one remote_surface.
563 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
564 if (x != dx || y != dy)
565 evas_object_move(ec->frame, dx, dy);
567 if (!cdata->viewport_transform)
569 cdata->viewport_transform = e_util_transform_new();
570 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
571 e_client_transform_core_add(ec, cdata->viewport_transform);
574 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
575 ec->comp_data->width_from_viewport,
576 ec->comp_data->height_from_viewport);
578 if (vp->buffer.src_width == wl_fixed_from_int(-1))
582 x2 = cdata->width_from_buffer;
583 y2 = cdata->height_from_buffer;
587 x1 = wl_fixed_to_int(vp->buffer.src_x);
588 y1 = wl_fixed_to_int(vp->buffer.src_y);
589 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
590 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
593 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
594 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
595 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
596 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
599 desk = e_comp_desk_find_by_ec(ec);
601 zoom_animating = e_desk_zoom_is_animating(desk);
603 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
604 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
605 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
607 /* workaround:: when the desk zoom is doing their animation,
608 the transform core update can override animation's zoom boundary.
609 so, don't doing transform core update while desk zoom animation */
611 e_client_transform_core_update(ec);
616 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
620 int map_c = 0, map_x = 0, map_y = 0;
621 double inv_x = 0.0, inv_y = 0.0;
623 EINA_SAFETY_ON_NULL_RETURN(ec);
625 map = e_client_map_get(ec);
626 map_c = e_map_count_get(map);
628 if (!map || map_c <= 0)
638 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
639 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
640 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
641 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
643 for (int i = 0; i < map_c; i++)
645 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
646 e_map_point_image_uv_set(map2, i, map_x, map_y);
648 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
658 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
664 if (!(ec = data)) return;
665 if (e_object_is_del(data)) return;
667 if (!ec->override) e_hints_window_visible_set(ec);
669 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
670 (!ec->comp_data->need_reparent))
672 ec->comp_data->need_reparent = EINA_TRUE;
673 ec->visible = EINA_TRUE;
675 if (!e_client_util_ignored_get(ec))
677 ec->take_focus = !starting;
681 if (!ec->comp_data->need_reparent)
683 if ((ec->hidden) || (ec->iconic))
685 evas_object_hide(ec->frame);
686 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
689 evas_object_show(ec->frame);
692 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
693 evas_object_show(tmp->frame);
695 topmost = e_comp_wl_topmost_parent_get(ec);
696 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
697 e_comp_wl_subsurface_show(ec);
699 if (ec->comp_data->sub.below_obj)
700 evas_object_show(ec->comp_data->sub.below_obj);
704 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
710 if (!(ec = data)) return;
711 if (e_object_is_del(E_OBJECT(ec))) return;
713 /* Uncommonly some clients's final buffer can be skipped if the client
714 * requests unmap of its surface right after wl_surface@commit.
715 * So if this client evas object is hidden state and client is already
716 * unmmapped, we can consider to clear pixmap image here mandatorily.
718 if (!ec->comp_data->mapped)
719 e_pixmap_image_clear(ec->pixmap, 1);
721 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
722 evas_object_hide(tmp->frame);
724 topmost = e_comp_wl_topmost_parent_get(ec);
725 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
726 e_comp_wl_subsurface_hide(ec);
728 if (ec->comp_data->sub.below_obj)
729 evas_object_hide(ec->comp_data->sub.below_obj);
731 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
735 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
742 if (!(ec = data)) return;
743 if (e_object_is_del(E_OBJECT(ec))) return;
745 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
747 if (!e_comp_wl_subsurface_check(subc)) continue;
748 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
749 evas_object_move(subc->frame, x, y);
751 if (subc->comp_data->scaler.viewport)
753 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
754 if (cdata->viewport_transform)
755 e_comp_wl_map_apply(subc);
759 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
761 if (!e_comp_wl_subsurface_check(subc)) continue;
762 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
763 evas_object_move(subc->frame, x, y);
765 if (subc->comp_data->scaler.viewport)
767 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
768 if (cdata->viewport_transform)
769 e_comp_wl_map_apply(subc);
773 if (ec->comp_data->sub.below_obj)
775 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
776 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
781 _e_comp_wl_send_touch_cancel(E_Client *ec)
784 struct wl_resource *res;
785 struct wl_client *wc;
786 E_Comp_Config *comp_conf = NULL;
789 if (e_object_is_del(E_OBJECT(ec))) return;
790 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
792 if (!surface) return;
793 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
795 wc = wl_resource_get_client(surface);
797 comp_conf = e_comp_config_get();
799 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
801 if (wl_resource_get_client(res) != wc) continue;
802 if (!e_comp_wl_input_touch_check(res)) continue;
804 if (comp_conf && comp_conf->input_log_enable)
805 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
807 wl_touch_send_cancel(res);
812 _e_comp_wl_touch_cancel(void)
816 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
818 if (!e_comp_wl->touch.pressed) return;
820 _e_comp_wl_send_touch_cancel(ec);
823 static E_Devicemgr_Input_Device *
824 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
826 E_Devicemgr_Input_Device *last_kbd = NULL;
829 case ECORE_DEVICE_CLASS_MOUSE:
830 return e_devicemgr->last_device_ptr;
831 case ECORE_DEVICE_CLASS_KEYBOARD:
832 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
834 case ECORE_DEVICE_CLASS_TOUCH:
835 return e_devicemgr->last_device_touch;
843 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
847 case ECORE_DEVICE_CLASS_MOUSE:
848 e_devicemgr->last_device_ptr = device;
850 case ECORE_DEVICE_CLASS_KEYBOARD:
851 atomic_store(&e_devicemgr->last_device_kbd, device);
853 case ECORE_DEVICE_CLASS_TOUCH:
854 e_devicemgr->last_device_touch = device;
861 static E_Devicemgr_Input_Device *
862 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
864 E_Devicemgr_Input_Device *last_kbd = NULL;
868 case ECORE_DEVICE_CLASS_MOUSE:
869 return ec->comp_data->last_device_ptr;
870 case ECORE_DEVICE_CLASS_KEYBOARD:
871 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
873 case ECORE_DEVICE_CLASS_TOUCH:
874 return ec->comp_data->last_device_touch;
882 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
886 case ECORE_DEVICE_CLASS_MOUSE:
887 ec->comp_data->last_device_ptr = device;
889 case ECORE_DEVICE_CLASS_KEYBOARD:
890 atomic_store(&ec->comp_data->last_device_kbd, device);
892 case ECORE_DEVICE_CLASS_TOUCH:
893 ec->comp_data->last_device_touch = device;
901 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
903 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
904 struct wl_resource *dev_res;
905 const char *dev_name;
906 Ecore_Device_Class dev_class;
907 struct wl_client *wc;
911 EINA_SAFETY_ON_NULL_RETURN(dev);
914 if (ec->cur_mouse_action || e_comp_wl->drag)
916 if (e_object_is_del(E_OBJECT(ec))) return;
917 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
918 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
919 if (!surface) return;
921 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
922 dev_name = evas_device_description_get(dev);
923 last_device = _e_comp_wl_device_last_device_get(dev_class);
924 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
926 serial = wl_display_next_serial(e_comp_wl->wl.disp);
927 wc = wl_resource_get_client(surface);
928 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
929 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
931 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
932 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
934 _e_comp_wl_device_last_device_set(dev_class, input_dev);
935 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
937 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
939 if (wl_resource_get_client(dev_res) != wc) continue;
940 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
944 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
948 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
950 E_Devicemgr_Input_Device *last_device;
951 struct wl_resource *dev_res;
952 struct wl_client *wc;
956 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
957 if (!surface) return;
959 last_device = _e_comp_wl_device_last_device_get(dev_class);
960 if (!last_device) return;
962 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
964 serial = wl_display_next_serial(e_comp_wl->wl.disp);
965 wc = wl_resource_get_client(surface);
966 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
968 if (wl_resource_get_client(dev_res) != wc) continue;
969 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
974 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
976 E_Devicemgr_Input_Device *input_dev;
977 struct wl_resource *dev_res;
978 const char *dev_name;
981 EINA_SAFETY_ON_NULL_RETURN(dev);
983 dev_name = ecore_device_identifier_get(dev);
985 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
986 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
988 if (!eina_streq(input_dev->identifier, dev_name) ||
989 (input_dev->clas != ecore_device_class_get(dev))) continue;
990 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
992 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
994 if (wl_resource_get_client(dev_res) != wc) continue;
995 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
998 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1002 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1004 E_Devicemgr_Input_Device *input_dev;
1005 struct wl_resource *dev_res;
1006 const char *dev_name;
1009 EINA_SAFETY_ON_NULL_RETURN(dev);
1011 dev_name = e_device_identifier_get(dev);
1013 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1014 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1016 if (!eina_streq(input_dev->identifier, dev_name) ||
1017 (input_dev->clas != e_device_class_get(dev))) continue;
1018 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1020 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1022 if (wl_resource_get_client(dev_res) != wc) continue;
1023 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1026 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1030 _e_comp_wl_cursor_reload(E_Client *ec)
1032 struct wl_resource *res;
1033 struct wl_client *wc;
1039 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1040 !evas_object_visible_get(e_comp->pointer->o_ptr))
1041 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1044 if (e_object_is_del(E_OBJECT(ec))) return;
1045 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1046 if (!surface) return;
1047 if (ec->pointer_enter_sent) return;
1049 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1050 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1052 if (e_client_transform_core_enable_get(ec))
1054 double dx = 0.0, dy = 0.0;
1055 map = e_client_map_get(ec);
1056 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1062 cx = px - ec->client.x;
1063 cy = py - ec->client.y;
1065 wc = wl_resource_get_client(surface);
1066 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1067 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1069 if (!e_comp_wl_input_pointer_check(res)) continue;
1070 if (wl_resource_get_client(res) != wc) continue;
1071 wl_pointer_send_enter(res, serial, surface,
1072 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1073 ec->pointer_enter_sent = EINA_TRUE;
1075 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1079 _e_comp_wl_cursor_timer(void *data)
1081 E_Client *ec = data;
1083 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1084 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1086 e_comp_wl_cursor_hide(ec);
1088 return ECORE_CALLBACK_CANCEL;
1092 _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)
1094 E_Devicemgr_Input_Device *input_dev;
1095 struct wl_resource *dev_res;
1096 struct wl_client *wc;
1101 if (ec->cur_mouse_action) return;
1102 if (e_object_is_del(E_OBJECT(ec))) return;
1103 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1104 if (!surface) return;
1106 f_value = wl_fixed_from_double(value);
1107 wc = wl_resource_get_client(surface);
1109 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1110 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1112 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1113 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1115 if (wl_resource_get_client(dev_res) != wc) continue;
1116 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1119 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1123 _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)
1125 if (idx >= e_input_touch_max_count_get()) return;
1127 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1128 e_devicemgr->multi[idx].radius_x = radius_x;
1129 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1130 e_devicemgr->multi[idx].radius_y = radius_y;
1131 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1132 e_devicemgr->multi[idx].pressure = pressure;
1133 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1134 e_devicemgr->multi[idx].angle = angle;
1138 _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)
1140 if (idx >= e_input_touch_max_count_get()) return;
1142 if (e_devicemgr->multi[idx].radius_x != radius_x)
1144 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1145 e_devicemgr->multi[idx].radius_x = radius_x;
1147 if (e_devicemgr->multi[idx].radius_y != radius_y)
1149 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1150 e_devicemgr->multi[idx].radius_y = radius_y;
1152 if (e_devicemgr->multi[idx].pressure != pressure)
1154 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1155 e_devicemgr->multi[idx].pressure = pressure;
1157 if (e_devicemgr->multi[idx].angle != angle)
1159 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1160 e_devicemgr->multi[idx].angle = angle;
1165 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1167 Eina_Bool ret = EINA_TRUE;
1170 case EVAS_CALLBACK_MOUSE_IN:
1171 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1174 if (e_comp_wl->ptr.hide_tmr)
1176 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1177 cursor_timer_ec = ec;
1178 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1182 if (e_pointer_is_hidden(e_comp->pointer))
1187 case EVAS_CALLBACK_MOUSE_OUT:
1188 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1191 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1195 case EVAS_CALLBACK_MOUSE_MOVE:
1196 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1199 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1200 _e_comp_wl_cursor_reload(ec);
1203 case EVAS_CALLBACK_MOUSE_WHEEL:
1204 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1207 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1208 _e_comp_wl_cursor_reload(ec);
1211 case EVAS_CALLBACK_MOUSE_DOWN:
1212 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1215 if (e_comp_wl->ptr.hide_tmr)
1217 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1218 e_comp_wl->ptr.hide_tmr = NULL;
1220 cursor_timer_ec = NULL;
1222 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1223 _e_comp_wl_cursor_reload(ec);
1226 case EVAS_CALLBACK_MOUSE_UP:
1227 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1238 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1240 if (ec->has_cursor_unset)
1243 if (!e_config->show_cursor)
1246 if (!e_config->use_cursor_timer)
1253 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1256 Evas_Event_Mouse_In *ev;
1257 struct wl_resource *res;
1258 struct wl_client *wc;
1261 E_Comp_Config *comp_conf;
1262 E_Client *prev_ptr_ec;
1266 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1267 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1269 if (!(ec = data)) return;
1270 if (e_object_is_del(E_OBJECT(ec))) return;
1271 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1272 if (!surface) return;
1274 prev_ptr_ec = e_comp_wl->ptr.ec;
1277 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1278 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1281 e_comp_wl->ptr.ec = ec;
1283 comp_conf = e_comp_config_get();
1284 if (comp_conf && comp_conf->input_log_enable)
1285 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1286 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1287 e_client_util_name_get(ec));
1289 if (_e_comp_wl_check_cursor_timer_needed(ec))
1291 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1295 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1296 wc = wl_resource_get_client(surface);
1297 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1298 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1300 if (!e_comp_wl_input_pointer_check(res)) continue;
1301 if (wl_resource_get_client(res) != wc) continue;
1303 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1305 wl_pointer_send_enter(res, serial, surface,
1306 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1307 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1308 ec->pointer_enter_sent = EINA_TRUE;
1311 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1315 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1318 Evas_Event_Mouse_Out *ev;
1319 struct wl_resource *res;
1320 struct wl_client *wc;
1323 Eina_Bool inside_check;
1324 E_Comp_Config *comp_conf;
1328 if (!(ec = data)) return;
1329 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1330 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1331 if (ec->cur_mouse_action && inside_check) return;
1332 if (e_object_is_del(E_OBJECT(e_comp))) return;
1333 if (e_comp_wl->ptr.ec == ec)
1334 e_comp_wl->ptr.ec = NULL;
1335 if (e_object_is_del(E_OBJECT(ec))) return;
1337 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1338 if (!surface) return;
1340 comp_conf = e_comp_config_get();
1341 if (comp_conf && comp_conf->input_log_enable)
1342 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1343 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1344 e_client_util_name_get(ec));
1346 if (_e_comp_wl_check_cursor_timer_needed(ec))
1348 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1352 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1354 wc = wl_resource_get_client(surface);
1355 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1356 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1358 if (!e_comp_wl_input_pointer_check(res)) continue;
1359 if (wl_resource_get_client(res) != wc) continue;
1360 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1362 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1364 wl_pointer_send_leave(res, serial, surface);
1365 ec->pointer_enter_sent = EINA_FALSE;
1370 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1373 struct wl_client *wc;
1374 struct wl_resource *res;
1377 E_Comp_Config *comp_conf = NULL;
1380 if (e_object_is_del(E_OBJECT(ec))) return;
1381 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1382 if (!surface) return;
1384 wc = wl_resource_get_client(surface);
1385 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1389 x = wl_fixed_from_int(canvas_x - ec->client.x);
1390 y = wl_fixed_from_int(canvas_y - ec->client.y);
1393 comp_conf = e_comp_config_get();
1395 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1397 if (wl_resource_get_client(res) != wc) continue;
1398 if (!e_comp_wl_input_touch_check(res)) continue;
1399 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1402 if (comp_conf && comp_conf->input_log_enable)
1403 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));
1405 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1409 if (comp_conf && comp_conf->input_log_enable)
1410 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));
1412 wl_touch_send_up(res, serial, timestamp, idx);
1419 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1422 struct wl_client *wc;
1423 struct wl_resource *res;
1427 if (ec->cur_mouse_action) return;
1428 if (e_object_is_del(E_OBJECT(ec))) return;
1429 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1430 if (!surface) return;
1432 wc = wl_resource_get_client(surface);
1434 x = wl_fixed_from_int(canvas_x - ec->client.x);
1435 y = wl_fixed_from_int(canvas_y - ec->client.y);
1437 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1439 if (wl_resource_get_client(res) != wc) continue;
1440 if (!e_comp_wl_input_touch_check(res)) continue;
1441 wl_touch_send_motion(res, timestamp, idx, x, y);
1446 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1448 struct wl_resource *res;
1449 struct wl_client *wc;
1453 if (ec->cur_mouse_action) return;
1454 if (e_object_is_del(E_OBJECT(ec))) return;
1455 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1456 if (!surface) return;
1458 wc = wl_resource_get_client(surface);
1459 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1461 if (!e_comp_wl_input_pointer_check(res)) continue;
1462 if (wl_resource_get_client(res) != wc) continue;
1463 wl_pointer_send_motion(res, timestamp,
1464 wl_fixed_from_int(x - ec->client.x),
1465 wl_fixed_from_int(y - ec->client.y));
1470 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1472 if (e_comp_wl->ptr.hide_tmr)
1474 if (cursor_timer_ec == ec)
1476 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1477 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1481 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1482 cursor_timer_ec = ec;
1483 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1488 cursor_timer_ec = ec;
1489 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1494 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1497 Evas_Event_Mouse_Move *ev;
1498 Evas_Device *dev = NULL;
1499 const char *dev_name;
1500 E_Comp_Config *comp_conf;
1504 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1505 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1507 if (!(ec = data)) return;
1508 if (e_object_is_del(E_OBJECT(ec))) return;
1509 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1510 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1511 if (!surface) return;
1513 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1516 dev_name = evas_device_description_get(dev);
1518 comp_conf = e_comp_config_get();
1519 if (comp_conf && comp_conf->input_log_enable)
1520 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1521 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1522 e_client_util_name_get(ec), dev_name);
1524 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1526 if (!e_comp_wl->drag_client)
1528 e_comp_wl->touch.faked_ec = ec;
1529 if (e_comp_wl->touch.pressed & (1 << 0))
1531 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1533 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1534 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1535 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1539 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1543 if (!e_comp_wl->drag_client)
1545 if (_e_comp_wl_check_cursor_timer_needed(ec))
1547 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1551 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1552 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1554 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1556 if (_e_comp_wl_check_cursor_timer_needed(ec))
1557 _e_comp_wl_cursor_move_timer_control(ec);
1561 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1566 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1568 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1569 if (e_object_is_del(E_OBJECT(ec))) return;
1570 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1571 if (!surface) return;
1572 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1574 e_comp_wl->ptr.button = BTN_LEFT;
1576 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1580 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1582 E_Client *ec = data;
1583 Evas_Event_Mouse_Down *ev = event;
1584 Evas_Device *dev = NULL;
1585 const Evas_Device *seat_dev;
1586 const char *dev_name, *seat_name;
1587 E_Comp_Config *comp_conf = NULL;
1590 if (e_object_is_del(E_OBJECT(ec))) return;
1593 dev_name = evas_device_description_get(dev);
1595 seat_dev = evas_device_parent_get(dev);
1596 seat_name = evas_device_name_get(seat_dev);
1598 comp_conf = e_comp_config_get();
1599 if (comp_conf && comp_conf->input_log_enable)
1600 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1601 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1602 dev_name, seat_name);
1604 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1606 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1608 e_comp_wl->touch.faked_ec = ec;
1611 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1612 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1613 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1615 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1616 e_comp_wl->touch.pressed |= (1 << 0);
1620 if (_e_comp_wl_check_cursor_timer_needed(ec))
1622 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1626 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1627 WL_POINTER_BUTTON_STATE_PRESSED);
1629 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1632 need_send_released = EINA_TRUE;
1636 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1638 E_Client *ec = data;
1639 Evas_Event_Mouse_Up *ev = event;
1640 Evas_Device *dev = NULL;
1641 const Evas_Device *seat_dev;
1642 const char *dev_name, *seat_name;;
1643 Evas_Event_Flags flags;
1644 E_Comp_Config *comp_conf = NULL;
1647 if (ec->cur_mouse_action) return;
1648 if (e_object_is_del(E_OBJECT(ec))) return;
1650 if (!need_send_released)
1652 need_send_motion = EINA_TRUE;
1656 dev_name = evas_device_description_get(dev);
1658 seat_dev = evas_device_parent_get(dev);
1659 seat_name = evas_device_name_get(seat_dev);
1660 flags = evas_event_default_flags_get(evas);
1662 comp_conf = e_comp_config_get();
1663 if (comp_conf && comp_conf->input_log_enable)
1664 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1665 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1666 dev_name, seat_name);
1668 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1670 e_comp_wl->touch.pressed &= ~(1 << 0);
1672 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1673 e_comp_wl->touch.faked_ec = NULL;
1676 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1678 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1680 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1683 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1684 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1685 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1689 if (_e_comp_wl_check_cursor_timer_needed(ec))
1691 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1695 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1696 WL_POINTER_BUTTON_STATE_RELEASED);
1698 if (_e_comp_wl_check_cursor_timer_needed(ec))
1699 _e_comp_wl_cursor_move_timer_control(ec);
1703 need_send_released = EINA_FALSE;
1707 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1709 struct wl_resource *res;
1710 struct wl_client *wc;
1715 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1717 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1720 dir = -wl_fixed_from_int(abs(z));
1722 dir = wl_fixed_from_int(z);
1725 if (e_object_is_del(E_OBJECT(ec))) return;
1726 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1727 if (!surface) return;
1729 wc = wl_resource_get_client(surface);
1730 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1732 if (!e_comp_wl_input_pointer_check(res)) continue;
1733 if (wl_resource_get_client(res) != wc) continue;
1734 wl_pointer_send_axis(res, timestamp, axis, dir);
1739 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1742 Evas_Event_Mouse_Wheel *ev;
1745 if (!(ec = data)) return;
1746 if (ec->cur_mouse_action) return;
1747 if (e_object_is_del(E_OBJECT(ec))) return;
1748 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1749 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1750 if (!surface) return;
1752 if (!eina_list_count(e_comp_wl->ptr.resources))
1755 if (_e_comp_wl_check_cursor_timer_needed(ec))
1757 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1761 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1763 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1765 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1767 if (_e_comp_wl_check_cursor_timer_needed(ec))
1768 _e_comp_wl_cursor_move_timer_control(ec);
1773 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1775 E_Client *ec = data;
1776 Evas_Event_Multi_Down *ev = event;
1777 Evas_Device *dev = NULL;
1778 const Evas_Device *seat_dev;
1779 const char *dev_name, *seat_name;
1780 Evas_Device_Class dev_class;
1781 E_Comp_Config *comp_conf = NULL;
1784 if (e_object_is_del(E_OBJECT(ec))) return;
1785 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1786 if (!surface) return;
1788 /* Do not deliver emulated single touch events to client */
1789 if (ev->device == 0) return;
1792 dev_name = evas_device_description_get(dev);
1793 e_comp_wl->touch.faked_ec = ec;
1795 seat_dev = evas_device_parent_get(dev);
1796 seat_name = evas_device_name_get(seat_dev);
1798 comp_conf = e_comp_config_get();
1799 if (comp_conf && comp_conf->input_log_enable)
1800 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1801 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1802 dev_name, seat_name);
1804 if (dev && dev_name)
1806 dev_class = evas_device_class_get(dev);
1807 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1808 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1811 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1812 e_comp_wl->touch.pressed |= (1 << ev->device);
1816 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1818 E_Client *ec = data;
1819 Evas_Event_Multi_Up *ev = event;
1820 Evas_Device *dev = NULL;
1821 const Evas_Device *seat_dev;
1822 const char *dev_name, *seat_name;
1823 Evas_Device_Class dev_class;
1824 Evas_Event_Flags flags;
1825 E_Comp_Config *comp_conf = NULL;
1828 if (e_object_is_del(E_OBJECT(ec))) return;
1829 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1830 if (!surface) return;
1832 /* Do not deliver emulated single touch events to client */
1833 if (ev->device == 0) return;
1835 flags = evas_event_default_flags_get(evas);
1837 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1838 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1839 e_comp_wl->touch.faked_ec = NULL;
1841 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1844 dev_name = evas_device_description_get(dev);
1846 seat_dev = evas_device_parent_get(dev);
1847 seat_name = evas_device_name_get(seat_dev);
1849 comp_conf = e_comp_config_get();
1850 if (comp_conf && comp_conf->input_log_enable)
1851 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1852 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1853 dev_name, seat_name);
1855 if (dev && dev_name)
1857 dev_class = evas_device_class_get(dev);
1858 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1859 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1862 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1866 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1868 E_Client *ec = data;
1869 Evas_Event_Multi_Move *ev = event;
1870 Evas_Device *dev = NULL;
1871 const char *dev_name;
1872 Evas_Device_Class dev_class;
1875 if (e_object_is_del(E_OBJECT(ec))) return;
1876 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1877 if (!surface) return;
1879 /* Do not deliver emulated single touch events to client */
1880 if (ev->device == 0) return;
1882 e_comp_wl->touch.faked_ec = ec;
1884 if (e_comp_wl->touch.pressed & (1 << ev->device))
1887 if (dev && (dev_name = evas_device_description_get(dev)))
1889 dev_class = evas_device_class_get(dev);
1890 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1891 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1894 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1899 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1902 char *file, buff[PATH_MAX];
1909 n = (getpriority(PRIO_PROCESS, pid) + adj);
1913 setpriority(PRIO_PROCESS, pid, n);
1916 use_adj = EINA_TRUE;
1918 if (!do_child) return;
1920 files = ecore_file_ls("/proc");
1921 EINA_LIST_FREE(files, file)
1923 if (!isdigit(file[0]))
1926 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1927 if ((f = fopen(buff, "r")))
1931 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1933 if (num_read == 2 && ppid == pid)
1934 _e_comp_wl_client_priority_adjust(pid2, set,
1936 adj_child, do_child);
1944 _e_comp_wl_client_priority_raise(E_Client *ec)
1946 if (!e_config->priority_control) return;
1947 if (ec->netwm.pid <= 0) return;
1948 if (ec->netwm.pid == getpid()) return;
1949 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1950 e_config->priority - 1, -1,
1951 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1955 _e_comp_wl_client_priority_normal(E_Client *ec)
1957 if (!e_config->priority_control) return;
1958 if (ec->netwm.pid <= 0) return;
1959 if (ec->netwm.pid == getpid()) return;
1960 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1961 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1965 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1968 E_Comp_Wl_Key_Data *k;
1969 struct wl_resource *res;
1973 if (!ec) return EINA_FALSE;
1974 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1975 if (!ec->comp_data) return EINA_FALSE;
1977 ec->comp_data->on_focus_timer = NULL;
1978 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1979 if (!e_comp_wl->kbd.focused)
1981 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1984 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1986 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1987 t = ecore_time_unix_get();
1989 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1990 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1991 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1993 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1995 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1996 wl_keyboard_send_key(res, serial, t,
1997 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2000 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2001 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2005 /* It is called in the following cases:
2006 * When a normal ec->frame has focus.
2007 * Or launching image ec is replaced to the real ec.
2010 e_comp_wl_feed_focus_in(E_Client *ec)
2013 struct wl_resource *res;
2014 struct wl_client *wc;
2018 if (e_object_is_del(E_OBJECT(ec))) return;
2019 if (ec->iconic) return;
2021 /* block spurious focus events */
2022 focused = e_client_focused_get();
2023 if ((focused) && (ec != focused)) return;
2025 /* raise client priority */
2026 _e_comp_wl_client_priority_raise(ec);
2027 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2028 if (!surface) return;
2030 wc = wl_resource_get_client(surface);
2032 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2033 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2035 if (wl_resource_get_client(res) == wc)
2037 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2038 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2039 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2040 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2043 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2045 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2046 if (!e_comp_wl->kbd.focused)
2048 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2051 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2053 e_comp_wl->kbd.focus = surface;
2054 e_comp_wl_input_keyboard_enter_send(ec);
2055 e_comp_wl_data_device_keyboard_focus_set();
2056 ec->comp_data->on_focus_timer =
2057 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2058 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2059 int rotation = ec->e.state.rot.ang.curr;
2060 e_pointer_rotation_set(e_comp->pointer, rotation);
2064 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2067 if (!(ec = data)) return;
2068 e_comp_wl_feed_focus_in(ec);
2072 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2075 struct wl_resource *res;
2077 E_Comp_Wl_Key_Data *k;
2081 if (!(ec = data)) return;
2083 if (!ec->comp_data) return;
2085 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2087 /* lower client priority */
2088 if (!e_object_is_del(data))
2089 _e_comp_wl_client_priority_normal(ec);
2092 /* update keyboard modifier state */
2093 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2094 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2095 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2097 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2099 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2100 if (!surface) return;
2102 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2103 if (!eina_list_count(e_comp_wl->kbd.resources))
2105 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2109 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2111 /* send keyboard_leave to all keyboard resources */
2112 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2113 t = ecore_time_unix_get();
2115 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2116 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2117 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2119 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2121 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2122 wl_keyboard_send_key(res, serial, t,
2123 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2125 wl_keyboard_send_leave(res, serial, surface);
2126 e_comp_wl->kbd.focused =
2127 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2129 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2130 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2134 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2138 if (!(ec = data)) return;
2140 if (!ec->comp_data->shell.configure_send) return;
2142 /* TODO: calculate x, y with transfrom object */
2143 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2147 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2148 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2149 if (e_comp_object_frame_exists(ec->frame))
2150 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2152 switch (ec->resize_mode)
2154 case E_POINTER_RESIZE_TL:
2155 case E_POINTER_RESIZE_L:
2156 case E_POINTER_RESIZE_BL:
2157 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2158 ec->mouse.current.mx;
2160 case E_POINTER_RESIZE_TR:
2161 case E_POINTER_RESIZE_R:
2162 case E_POINTER_RESIZE_BR:
2163 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2168 switch (ec->resize_mode)
2170 case E_POINTER_RESIZE_TL:
2171 case E_POINTER_RESIZE_T:
2172 case E_POINTER_RESIZE_TR:
2173 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2174 ec->mouse.current.my;
2176 case E_POINTER_RESIZE_BL:
2177 case E_POINTER_RESIZE_B:
2178 case E_POINTER_RESIZE_BR:
2179 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2184 w = E_CLAMP(w, 1, w);
2185 h = E_CLAMP(h, 1, h);
2186 e_client_resize_limit(ec, &w, &h);
2188 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2190 else if ((!ec->fullscreen) && (!ec->maximized) &&
2191 (!ec->comp_data->maximize_pre))
2195 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2196 if ((pw != ec->w) || (ph != ec->h))
2198 _e_comp_wl_configure_send(ec, 1, 1);
2202 if (ec->comp_data->sub.below_obj)
2203 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2207 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2209 E_Client *ec = data;
2211 ec->comp_data->maximize_pre = 1;
2215 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2217 E_Client *ec = data;
2220 if (e_object_is_del(E_OBJECT(ec))) return;
2222 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2223 e_client_shell_configure_send(ec, 0, w, h);
2225 ec->comp_data->maximize_pre = 0;
2229 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2231 E_Client *ec = data;
2233 ec->comp_data->maximize_pre = 1;
2237 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2239 E_Client *ec = data;
2241 if (e_object_is_del(E_OBJECT(ec))) return;
2243 /* check for wayland pixmap */
2245 if (ec->comp_data->shell.configure_send)
2246 _e_comp_wl_configure_send(ec, 0, 0);
2248 ec->comp_data->maximize_pre = 0;
2252 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2254 E_Client *ec = data;
2256 if (e_object_is_del(E_OBJECT(ec))) return;
2258 /* check for wayland pixmap */
2260 if (ec->comp_data->shell.configure_send)
2261 _e_comp_wl_configure_send(ec, 0, 1);
2263 ec->comp_data->maximize_pre = 0;
2267 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2269 E_Client *ec = data;
2271 if (e_object_is_del(E_OBJECT(ec))) return;
2273 /* check for wayland pixmap */
2275 if (ec->comp_data->shell.configure_send)
2276 _e_comp_wl_configure_send(ec, 0, 0);
2278 ec->comp_data->maximize_pre = 0;
2282 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2286 if (!(ec = data)) return;
2288 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2290 e_object_del(E_OBJECT(ec));
2292 _e_comp_wl_focus_check();
2294 /* TODO: Delete request send ??
2295 * NB: No such animal wrt wayland */
2299 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2303 if (!(ec = data)) return;
2305 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2308 if (ec->comp_data->reparented)
2309 e_client_comp_hidden_set(ec, EINA_TRUE);
2312 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2313 if (ec->visible) evas_object_hide(ec->frame);
2314 if (!ec->internal) e_object_del(E_OBJECT(ec));
2316 _e_comp_wl_focus_check();
2320 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2324 if (!(ec = data)) return;
2326 e_client_shell_ping(ec);
2330 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2335 if (!(ec = data)) return;
2336 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2337 if (ec->netwm.opacity == a) return;
2338 ec->netwm.opacity = a;
2339 ec->netwm.opacity_changed = EINA_TRUE;
2343 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2345 Eina_Rectangle *damage_rect = NULL;
2346 Eina_Rectangle *dmg = NULL;
2347 Eina_List *l = NULL;
2349 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2350 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2353 if (!buffer->tbm_surface) return;
2357 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2361 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2362 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2365 eina_rectangle_union(damage_rect, dmg);
2370 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2371 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2374 tbm_surface_internal_set_damage(buffer->tbm_surface,
2380 eina_rectangle_free(damage_rect);
2384 _e_comp_wl_client_evas_init(E_Client *ec)
2386 if (!ec || !ec->comp_data) return;
2387 if (ec->comp_data->evas_init) return;
2389 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2390 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2391 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2395 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2396 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2397 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2398 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2399 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2401 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2403 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2405 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2406 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2410 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2411 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2412 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2413 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2414 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2415 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2416 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2419 /* setup delete/kill callbacks */
2420 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2421 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2423 /* setup ping callback */
2424 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2425 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2427 ec->comp_data->evas_init = EINA_TRUE;
2431 _e_comp_wl_client_evas_deinit(E_Client *ec)
2433 if (!ec || !ec->comp_data) return;
2434 if (!ec->comp_data->evas_init) return;
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2438 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2443 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2445 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2449 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2456 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2457 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2458 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2459 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2460 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2461 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2462 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2465 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2466 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2468 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2469 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2471 ec->comp_data->evas_init = EINA_FALSE;
2475 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2479 E_Comp_Screen *e_comp_screen;
2480 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2482 if (!e_comp) return ECORE_CALLBACK_RENEW;
2483 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2484 e_comp_screen = e_comp->e_comp_screen;
2486 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2488 if (!eout->config.enabled)
2490 e_comp_wl_output_remove(eout->id);
2494 switch (eout->config.rotation)
2497 transform = WL_OUTPUT_TRANSFORM_90;
2500 transform = WL_OUTPUT_TRANSFORM_180;
2503 transform = WL_OUTPUT_TRANSFORM_270;
2507 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2511 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2513 eout->config.geom.x, eout->config.geom.y,
2514 eout->config.geom.w, eout->config.geom.h,
2515 eout->info.size.w, eout->info.size.h,
2516 eout->config.mode.refresh, 0, transform))
2517 ERR("Could not initialize screen %s", eout->info.name);
2520 return ECORE_CALLBACK_RENEW;
2524 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2528 /* try to get the client from the object */
2529 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2530 return ECORE_CALLBACK_RENEW;
2532 /* check for client being deleted */
2533 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2535 /* check for wayland pixmap */
2536 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2537 return ECORE_CALLBACK_RENEW;
2539 /* if we have not setup evas callbacks for this client, do it */
2540 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2542 return ECORE_CALLBACK_RENEW;
2546 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2550 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2551 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2553 if (e_comp_wl->selection.target &&
2556 struct wl_resource *res;
2558 E_Client *ec = NULL;
2559 E_Client *legacy_target = e_comp_wl->selection.target;
2560 int device_id = e_comp_wl_data_current_device_id_get();
2564 e_comp_wl_data_current_device_id_set(ev->multi.device);
2566 else if (device_id != ev->multi.device)
2568 return ECORE_CALLBACK_RENEW;
2571 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2572 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2574 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2575 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2577 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2578 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2580 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2581 (ec != legacy_target))
2583 e_comp_wl_data_device_send_leave(legacy_target);
2584 e_comp_wl_data_device_send_enter(ec);
2587 if (e_comp_wl->drag)
2588 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2590 if (e_client_transform_core_enable_get(ec))
2592 int trans_x, trans_y;
2593 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2594 x = trans_x - ec->client.x;
2595 y = trans_y - ec->client.y;
2599 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2604 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2607 return ECORE_CALLBACK_RENEW;
2611 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2614 struct wl_resource *surface;
2615 struct wl_resource *res;
2616 struct wl_client *wc;
2618 E_Comp_Config *comp_conf;
2620 ec = e_comp_wl->ptr_constraints.ec;
2621 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2623 surface = e_comp_wl_client_surface_get(ec);
2624 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2626 wc = wl_resource_get_client(surface);
2628 comp_conf = e_comp_config_get();
2630 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2632 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2633 if (wl_resource_get_client(res) != wc) continue;
2635 if (comp_conf && comp_conf->input_log_enable)
2636 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2637 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2638 e_client_util_name_get(ec));
2640 zwp_relative_pointer_v1_send_relative_motion(res,
2642 (uint32_t)(ev->timestamp),
2643 wl_fixed_from_int(ev->dx),
2644 wl_fixed_from_int(ev->dy),
2645 wl_fixed_from_int(ev->dx_unaccel),
2646 wl_fixed_from_int(ev->dy_unaccel));
2649 return ECORE_CALLBACK_DONE;
2653 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2655 _e_comp_wl_touch_cancel();
2657 return ECORE_CALLBACK_PASS_ON;
2661 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2663 if (!ev) return ECORE_CALLBACK_PASS_ON;
2665 E_Zone *zone = ev->zone;
2667 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2668 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2670 if (!e_zone_is_displaying(zone))
2671 _e_comp_wl_touch_cancel();
2673 return ECORE_CALLBACK_PASS_ON;
2677 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2679 E_Client *ec = ev->ec;
2680 E_Comp_Wl_Buffer_Viewport *vp;
2682 if (!ec) return ECORE_CALLBACK_PASS_ON;
2683 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2684 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2685 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2686 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2688 vp = &ec->comp_data->scaler.buffer_viewport;
2689 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2691 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2693 return ECORE_CALLBACK_PASS_ON;
2697 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2699 E_Client *ec = ev->ec;
2700 E_Comp_Wl_Buffer_Viewport *vp;
2702 if (!ec) return ECORE_CALLBACK_PASS_ON;
2703 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2704 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2705 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2707 vp = &ec->comp_data->scaler.buffer_viewport;
2708 vp->wait_for_transform_change = 0;
2710 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2712 return ECORE_CALLBACK_PASS_ON;
2716 _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)
2718 E_Client *focused_ec;
2721 focused_ec = e_client_focused_get();
2722 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2724 rotation = focused_ec->e.state.rot.ang.curr;
2725 e_pointer_rotation_set(e_comp->pointer, rotation);
2727 return ECORE_CALLBACK_PASS_ON;
2731 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2734 Eina_Rectangle *window;
2739 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2741 if ((prev_w != state->bw) ||
2742 (prev_h != state->bh))
2744 ec->changes.buf_size = EINA_TRUE;
2747 if (e_comp_object_frame_exists(ec->frame)) return;
2748 window = &ec->comp_data->shell.window;
2749 if ((!ec->borderless) && /* FIXME temporarily added this check code
2750 * to prevent updating E_Client's size by frame */
2751 (window->x || window->y || window->w || window->h))
2753 e_comp_object_frame_geometry_set(ec->frame,
2755 (window->x + window->w) - state->bw,
2757 (window->y + window->h) - state->bh);
2760 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2764 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2766 E_Comp_Wl_Surface_State *state;
2769 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2770 state->buffer = NULL;
2774 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2776 state->new_attach = EINA_FALSE;
2777 state->buffer = NULL;
2778 state->buffer_destroy_listener.notify =
2779 _e_comp_wl_surface_state_cb_buffer_destroy;
2780 state->sx = state->sy = 0;
2782 state->input = eina_tiler_new(w, h);
2783 eina_tiler_tile_size_set(state->input, 1, 1);
2785 state->opaque = eina_tiler_new(w, h);
2786 eina_tiler_tile_size_set(state->opaque, 1, 1);
2788 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2789 state->buffer_viewport.buffer.scale = 1;
2790 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2791 state->buffer_viewport.surface.width = -1;
2792 state->buffer_viewport.changed = 0;
2794 e_presentation_time_container_init(&state->presentation_container);
2798 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2800 struct wl_resource *cb;
2801 Eina_Rectangle *dmg;
2803 EINA_LIST_FREE(state->frames, cb)
2804 wl_resource_destroy(cb);
2806 EINA_LIST_FREE(state->damages, dmg)
2807 eina_rectangle_free(dmg);
2809 EINA_LIST_FREE(state->buffer_damages, dmg)
2810 eina_rectangle_free(dmg);
2812 if (state->opaque) eina_tiler_free(state->opaque);
2813 state->opaque = NULL;
2815 if (state->input) eina_tiler_free(state->input);
2816 state->input = NULL;
2818 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2819 state->buffer = NULL;
2821 e_presentation_time_container_finish(&state->presentation_container);
2825 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2827 if (state->buffer == buffer) return;
2829 wl_list_remove(&state->buffer_destroy_listener.link);
2830 state->buffer = buffer;
2832 wl_signal_add(&state->buffer->destroy_signal,
2833 &state->buffer_destroy_listener);
2837 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2839 Eina_Rectangle *dmg;
2840 Eina_Bool placed = EINA_TRUE;
2844 E_Comp_Wl_Buffer *buffer;
2845 struct wl_resource *cb;
2847 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2848 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2853 if ((ec->internal) ||
2854 (cdata->shell.surface && state->new_attach))
2858 e_comp->new_clients++;
2859 ELOGF("COMP", "Unignore", ec);
2860 e_client_unignore(ec);
2864 /* buffer transform */
2865 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2868 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2870 /* when buffer is transformed, we have to apply the new evas-map */
2871 state->buffer_viewport.changed = EINA_TRUE;
2873 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2875 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2877 if (transform_change == vp->wait_for_transform_change)
2878 vp->wait_for_transform_change = 0;
2880 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2881 // triggered by E_CLIENT_HOOK calls at those file.
2882 zone = e_comp_zone_find_by_ec(ec);
2885 eout = e_output_find(zone->output_id);
2886 if (eout && eout->hwc)
2888 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2890 if (e_comp_is_on_overlay(ec))
2891 e_comp_hwc_client_end(ec, __FUNCTION__);
2897 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2898 cdata->scaler.buffer_viewport = state->buffer_viewport;
2900 if (state->new_attach)
2902 e_comp_wl_surface_attach(ec, state->buffer);
2905 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2906 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2908 _e_comp_wl_surface_state_buffer_set(state, NULL);
2910 if ((state->new_attach) ||
2911 (state->buffer_viewport.changed))
2913 _e_comp_wl_surface_state_size_update(ec, state);
2914 e_comp_wl_map_size_cal_from_viewport(ec);
2916 /* update the position */
2917 if (ec->changes.pos)
2919 e_comp_object_frame_xy_unadjust(ec->frame,
2929 if (ec->new_client) placed = ec->placed;
2931 if (!ec->lock_client_size)
2936 ec->client.w = state->bw;
2937 ec->client.h = state->bh;
2939 e_comp_object_frame_wh_adjust(ec->frame,
2940 ec->client.w, ec->client.h,
2942 e_client_size_set(ec, nw, nh);
2944 if ((w != ec->w) || (h != ec->h))
2946 ec->changes.size = 1;
2951 if (ec->changes.buf_size)
2953 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2954 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2955 ec->changes.buf_size = EINA_FALSE;
2957 if (ec->move_after_resize)
2959 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2960 ec->move_after_resize = EINA_FALSE;
2965 /* map or unmap ec */
2966 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2967 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2968 if (!pixmap_usable || hide_by_request)
2973 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2978 if ((cdata->sub.below_obj) &&
2979 (evas_object_visible_get(cdata->sub.below_obj)))
2981 evas_object_hide(cdata->sub.below_obj);
2989 if ((cdata->sub.below_obj) &&
2990 (!evas_object_visible_get(cdata->sub.below_obj)) &&
2991 (evas_object_visible_get(ec->frame)))
2993 evas_object_show(cdata->sub.below_obj);
2997 if ((state->new_attach) ||
2998 (state->buffer_viewport.changed))
3000 if ((e_comp_wl->drag) &&
3001 (e_comp_wl->drag_client) &&
3002 (e_comp_wl->drag_client == ec))
3004 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3006 e_drag_move(e_comp_wl->drag,
3008 e_comp_wl->drag->y);
3010 e_drag_resize(e_comp_wl->drag,
3011 state->bw, state->bh);
3013 else if ((cdata->shell.surface) &&
3014 (cdata->shell.configure))
3016 e_comp_wl_commit_sync_configure(ec);
3018 else if (!e_client_video_hw_composition_check(ec))
3020 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3025 ec->placed = placed;
3026 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3030 if (cdata->scaler.buffer_viewport.changed)
3031 e_comp_wl_map_apply(ec);
3033 /* resize transform object */
3034 if (ec->transformed)
3035 e_client_transform_update(ec);
3039 state->new_attach = EINA_FALSE;
3041 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3043 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3044 wl_resource_destroy(cb);
3047 /* insert state frame callbacks into comp_data->frames
3048 * NB: This clears state->frames list */
3049 cdata->frames = eina_list_merge(cdata->frames,
3051 state->frames = NULL;
3053 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3054 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3055 &state->presentation_container);
3057 buffer = e_pixmap_resource_get(ec->pixmap);
3059 /* put state damages into surface */
3062 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3063 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3065 if ((cdata->buffer_ref.buffer) &&
3066 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3067 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3069 e_comp_object_damage(ec->frame,
3071 cdata->buffer_ref.buffer->w,
3072 cdata->buffer_ref.buffer->h);
3077 Eina_List *damages = NULL;
3080 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3082 if (eina_list_count(state->buffer_damages))
3084 EINA_LIST_FREE(state->buffer_damages, dmg)
3087 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3088 e_comp_wl_output_buffer_transform_get(ec),
3090 dmg->x, dmg->y, dmg->w, dmg->h,
3091 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3092 damages = eina_list_append(damages, dmg);
3096 EINA_LIST_FREE(state->damages, dmg)
3097 damages = eina_list_append(damages, dmg);
3099 EINA_LIST_FREE(damages, dmg)
3101 /* not creating damage for ec that shows a underlay video */
3102 if (state->buffer_viewport.changed ||
3103 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3104 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3105 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3107 eina_rectangle_free(dmg);
3112 /* put state opaque into surface */
3113 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3116 Eina_Rectangle *rect;
3119 itr = eina_tiler_iterator_new(state->opaque);
3120 EINA_ITERATOR_FOREACH(itr, rect)
3124 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3125 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3126 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3130 eina_iterator_free(itr);
3133 /* put state input into surface */
3134 if ((state->input) &&
3135 (!eina_tiler_empty(state->input)) &&
3138 Eina_Tiler *src, *tmp;
3142 tmp = eina_tiler_new(sw, sh);
3143 eina_tiler_tile_size_set(tmp, 1, 1);
3145 eina_tiler_rect_add(tmp,
3146 &(Eina_Rectangle){0, 0, sw, sh});
3148 if ((src = eina_tiler_intersection(state->input, tmp)))
3150 Eina_Rectangle *rect;
3153 e_comp_object_input_objs_del(ec->frame);
3154 itr = eina_tiler_iterator_new(src);
3155 EINA_ITERATOR_FOREACH(itr, rect)
3157 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3158 ec, rect->x, rect->y, rect->w, rect->h,
3159 ec->w, ec->h, state->bw, state->bh);
3160 e_comp_object_input_area_set(ec->frame,
3165 eina_iterator_free(itr);
3166 eina_tiler_free(src);
3169 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3171 eina_tiler_free(tmp);
3173 /* clear input tiler */
3174 eina_tiler_clear(state->input);
3177 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3179 if ((cdata->video_client) &&
3181 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3182 (e_comp->wl_comp_data->available_hw_accel.underlay))
3184 e_pixmap_image_clear(ec->pixmap, 1);
3187 state->buffer_viewport.changed = 0;
3189 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3192 ec->exp_iconify.buffer_flush &&
3193 e_policy_visibility_client_is_iconic(ec))
3195 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3200 _e_comp_wl_surface_render_stop(E_Client *ec)
3202 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3203 //if ((!ec->internal) && (!e_comp_gl_get()))
3206 /* check if internal animation is running */
3207 if (e_comp_object_is_animating(ec->frame)) return;
3208 /* check if external animation is running */
3209 if (evas_object_data_get(ec->frame, "effect_running")) return;
3211 evas_object_hide(ec->frame);
3215 e_comp_wl_client_surface_finish(E_Client *ec)
3217 struct wl_resource *res, *surface;
3218 struct wl_client *surface_client = NULL;
3221 surface = e_comp_wl_client_surface_get(ec);
3224 surface_client = wl_resource_get_client(surface);
3226 if (surface_client &&
3227 (ec == e_client_focused_get()))
3229 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3230 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3232 if (wl_resource_get_client(res) ==
3234 e_comp_wl->kbd.focused =
3235 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3239 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3242 e_comp_wl_client_surface_set(ec, NULL);
3244 ec->comp_data->wl_surface = NULL;
3245 e_pixmap_win_id_del(ec->pixmap);
3247 _e_comp_wl_surface_render_stop(ec);
3248 e_object_del(E_OBJECT(ec));
3252 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3257 char proc[512], pname[512];
3260 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3262 h = fopen(proc, "r");
3265 len = fread(pname, sizeof(char), 512, h);
3267 pname[len - 1] = '\0';
3269 strncpy(pname, "NO NAME", sizeof(pname));
3275 strncpy(pname, "NO NAME", sizeof(pname));
3278 strncpy(name, pname, size);
3282 _e_comp_wl_pname_print(pid_t pid)
3285 char proc[512], pname[512];
3288 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3290 h = fopen(proc, "r");
3293 len = fread(pname, sizeof(char), 512, h);
3295 pname[len - 1] = '\0';
3297 strncpy(pname, "NO NAME", sizeof(pname));
3301 ELOGF("COMP", " |%s", NULL, pname);
3306 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3308 struct wl_client *client = data;
3309 E_Comp_Connected_Client_Info *cinfo;
3312 cinfo = wl_container_of(listener, cinfo, destroy);
3314 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3315 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3317 eai = e_appinfo_find_with_pid(cinfo->pid);
3318 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3321 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3323 wl_list_remove(&cinfo->destroy.link);
3324 eina_stringshare_del(cinfo->name);
3329 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3331 E_Comp_Connected_Client_Info *cinfo;
3333 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3334 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3336 cinfo->name = eina_stringshare_add(name);
3340 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3341 wl_client_add_destroy_listener(client, &cinfo->destroy);
3342 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3344 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3348 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3350 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3352 /* send configure */
3353 if (ec->comp_data->shell.configure_send)
3355 if (ec->comp_data->shell.surface)
3356 _e_comp_wl_configure_send(ec, 0, 0);
3359 e_comp_wl->kbd.focus = ec->comp_data->surface;
3363 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3365 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3367 /* send configure */
3368 if (ec->comp_data->shell.configure_send)
3370 if (ec->comp_data->shell.surface)
3371 _e_comp_wl_configure_send(ec, 0, 0);
3374 _e_comp_wl_focus_check();
3376 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3377 e_comp_wl->kbd.focus = NULL;
3381 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3383 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3384 if (ec->keyboard_resizing) return;
3386 /* do nothing currently */
3391 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3393 if (e_object_is_del(E_OBJECT(ec))) return;
3394 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3396 e_comp_wl->resize.edges = 0;
3397 e_comp_wl->resize.resource = NULL;
3401 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3403 if (e_object_is_del(E_OBJECT(ec))) return;
3404 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3408 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3411 int ratio_w, ratio_h;
3413 phys_w = output->phys_width;
3414 phys_h = output->phys_height;
3416 if (e_config->configured_output_resolution.use)
3418 // change the configured physical size(mm) of the output
3419 if (output->w != res_w)
3421 ratio_w = res_w / output->w;
3422 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3425 if (output->h != res_h)
3427 ratio_h = res_h / output->h;
3428 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3431 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3434 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3435 NULL, res_w, res_h, phys_w, phys_h, pid);
3437 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3438 wl_output_send_scale(resource, output->scale);
3440 wl_output_send_geometry(resource, output->x, output->y,
3442 output->subpixel, output->make ?: "",
3443 output->model ?: "", output->transform);
3445 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3446 res_w, res_h, output->refresh);
3448 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3449 wl_output_send_done(resource);
3453 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3455 E_Comp_Wl_Output *output;
3457 if (!(output = wl_resource_get_user_data(resource))) return;
3459 output->resources = eina_list_remove(output->resources, resource);
3463 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3465 E_Comp_Wl_Output *output;
3466 struct wl_resource *resource;
3467 E_Appinfo *eai = NULL;
3471 if (!(output = data)) return;
3474 wl_resource_create(client, &wl_output_interface, version, id);
3477 wl_client_post_no_memory(client);
3481 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3482 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3484 output->resources = eina_list_append(output->resources, resource);
3486 wl_resource_set_implementation(resource, NULL, output,
3487 _e_comp_wl_cb_output_unbind);
3488 wl_resource_set_user_data(resource, output);
3490 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3491 if (e_config->configured_output_resolution.use)
3493 wl_client_get_credentials(client, &pid, NULL, NULL);
3496 res_w = e_config->configured_output_resolution.w;
3497 res_h = e_config->configured_output_resolution.h;
3501 eai = e_appinfo_find_with_pid(pid);
3504 res_w = e_config->configured_output_resolution.w;
3505 res_h = e_config->configured_output_resolution.h;
3509 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3511 res_w = e_config->configured_output_resolution.w;
3512 res_h = e_config->configured_output_resolution.h;
3516 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3525 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3529 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3532 Evas_GL *evasgl = NULL;
3533 Evas_GL_API *glapi = NULL;
3534 Evas_GL_Context *ctx = NULL;
3535 Evas_GL_Surface *sfc = NULL;
3536 Evas_GL_Config *cfg = NULL;
3538 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3540 if (!e_comp_gl_get()) return;
3542 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3543 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3545 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3546 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3548 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3549 * then we should get evas from ecore_evas.
3552 evas = e_comp->evas;
3554 evas = ecore_evas_get(e_comp->ee);
3556 evasgl = evas_gl_new(evas);
3557 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3559 glapi = evas_gl_api_get(evasgl);
3560 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3561 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3563 cfg = evas_gl_config_new();
3564 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3566 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3567 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3569 ctx = evas_gl_context_create(evasgl, NULL);
3570 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3572 res = evas_gl_make_current(evasgl, sfc, ctx);
3573 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3575 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3576 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3578 evas_gl_config_free(cfg);
3580 evas_gl->gl = evasgl;
3581 evas_gl->glapi = glapi;
3582 evas_gl->glsfc = sfc;
3583 evas_gl->glctx = ctx;
3585 e_comp_wl->evas_gl = evas_gl;
3587 /* for native surface */
3590 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3595 evas_gl_config_free(cfg);
3596 evas_gl_make_current(evasgl, NULL, NULL);
3597 evas_gl_context_destroy(evasgl, ctx);
3598 evas_gl_surface_destroy(evasgl, sfc);
3599 evas_gl_free(evasgl);
3606 _e_comp_wl_gl_popup_cb_close(void *data,
3607 Evas_Object *obj EINA_UNUSED,
3608 void *event_info EINA_UNUSED)
3610 evas_object_del(data);
3614 _e_comp_wl_gl_popup_cb_focus(void *data,
3615 Evas_Object *obj EINA_UNUSED,
3616 void *event_info EINA_UNUSED)
3618 elm_object_focus_set(data, EINA_TRUE);
3623 _e_comp_wl_gl_idle(void *data)
3627 /* show warning window to notify failure of gl init */
3630 Evas_Object *win, *bg, *popup, *btn;
3632 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3633 elm_win_title_set(win, "Compositor Warning");
3634 elm_win_autodel_set(win, EINA_TRUE);
3635 elm_win_borderless_set(win, EINA_TRUE);
3636 elm_win_role_set(win, "notification-low");
3637 elm_win_alpha_set(win, EINA_TRUE);
3639 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3640 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3641 elm_win_resize_object_add(win, bg);
3642 evas_object_color_set(bg, 125, 125, 125, 125);
3643 evas_object_show(bg);
3645 popup = elm_popup_add(win);
3646 elm_object_text_set(popup,
3647 _( "Your screen does not support OpenGL.<br>"
3648 "Falling back to software engine."));
3649 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3651 btn = elm_button_add(popup);
3652 elm_object_text_set(btn, "Close");
3653 elm_object_part_content_set(popup, "button1", btn);
3654 evas_object_show(btn);
3656 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3657 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3659 evas_object_show(popup);
3660 evas_object_show(win);
3664 return ECORE_CALLBACK_CANCEL;
3668 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3670 struct wl_client *client = data;
3676 wl_client_get_credentials(client, &pid, &uid, &gid);
3678 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3680 _e_comp_wl_pname_print(pid);
3681 _e_comp_wl_pname_get(pid, name, sizeof(name));
3682 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3686 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3688 char buf[1024] = {0, };
3690 vsnprintf(buf, 1024, fmt, args);
3694 DBG("[libds] %s", buf);
3697 INF("[libds] %s", buf);
3700 ERR("[libds] %s", buf);
3708 _e_comp_wl_display_create(void)
3711 E_Comp_Wl_Data *wl_cdata;
3716 /* create new compositor data */
3717 if (!(comp = E_NEW(E_Comp_Data, 1)))
3719 ERR("Could not create compositor data: %m");
3722 wl_cdata = &comp->base;
3724 /* set compositor wayland data */
3725 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3727 g_mutex_init(&connection_mutex);
3729 /* try to create a wayland display */
3730 if (!(wl_cdata->wl.disp = wl_display_create()))
3732 ERR("Could not create a Wayland display: %m");
3736 /* try to setup wayland socket */
3737 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3739 ERR("Could not create Wayland display socket: %m");
3740 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3744 res = e_comp_socket_init(name);
3745 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3746 PRCTL("[Winsys] change permission and create sym link for %s", name);
3748 /* set wayland display environment variable */
3749 e_env_set("WAYLAND_DISPLAY", name);
3751 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3752 /* wl_cdata->output.scale = e_scale; */
3754 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3756 if (!e_compositor_init(wl_cdata->wl.disp))
3758 ERR("Failed to initialize compositor");
3762 comp->client_created.notify = _e_comp_wl_cb_client_created;
3763 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3765 if (!e_comp_wl_subsurfaces_init())
3767 ERR("Failed to init_subsurfaces");
3768 goto subsurfaces_err;
3771 /* initialize shm mechanism */
3772 wl_display_init_shm(wl_cdata->wl.disp);
3774 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3776 /* try to init data manager */
3777 if (!e_comp_wl_data_manager_init())
3779 ERR("Could not initialize data manager");
3783 /* try to init input */
3784 if (!e_comp_wl_input_init())
3786 ERR("Could not initialize input");
3790 if (e_comp_gl_get())
3791 _e_comp_wl_gl_init(NULL);
3793 /* get the wayland display loop */
3794 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3796 /* get the file descriptor of the wayland event loop */
3797 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3799 /* create a listener for wayland main loop events */
3801 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3802 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3803 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3804 _e_comp_wl_cb_prepare, wl_cdata);
3809 e_comp_wl_data_manager_shutdown();
3811 e_comp_wl_subsurfaces_shutdown();
3813 wl_list_remove(&comp->client_created.link);
3815 e_env_unset("WAYLAND_DISPLAY");
3817 wl_display_destroy(wl_cdata->wl.disp);
3819 g_mutex_clear(&connection_mutex);
3825 _e_comp_wl_gl_shutdown(void)
3827 if (!e_comp_wl->evas_gl) return;
3829 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3831 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3832 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3833 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3834 evas_gl_free(e_comp_wl->evas_gl->gl);
3836 E_FREE(e_comp_wl->evas_gl);
3839 /* public functions */
3842 * Creates and initializes a Wayland compositor with ecore.
3843 * Registers callback handlers for keyboard and mouse activity
3844 * and other client events.
3846 * @returns true on success, false if initialization failed.
3849 e_comp_wl_init(void)
3851 TRACE_DS_BEGIN(COMP_WL:INIT);
3853 /* try to create a wayland compositor */
3854 if (!_e_comp_wl_display_create())
3856 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3861 e_comp_wl_shell_init();
3863 #ifdef HAVE_WAYLAND_TBM
3864 e_comp_wl_tbm_init();
3866 e_comp_wl_remote_surface_init();
3870 e_comp_wl_screenshooter_init();
3872 if (!e_comp_wl_video_init())
3873 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3875 e_comp_wl_viewport_init();
3876 e_comp_wl_capture_init();
3877 e_comp_wl_renderer_init();
3878 _e_comp_wl_move_resize_init();
3879 e_presentation_time_init();
3880 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3883 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3884 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3886 /* add event handlers to catch E events */
3887 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3888 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3889 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3890 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3891 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3892 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3893 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3894 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3895 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3897 /* add hooks to catch e_client events */
3898 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3899 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3900 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3901 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3902 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3904 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3911 e_comp_wl_deferred_job(void)
3913 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3916 /* internal functions */
3918 e_comp_wl_shutdown(void)
3920 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3922 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3924 e_comp_wl_subsurfaces_shutdown();
3926 E_FREE_LIST(handlers, ecore_event_handler_del);
3927 E_FREE_LIST(hooks, e_client_hook_del);
3928 _e_comp_wl_gl_shutdown();
3930 e_blender_shutdown();
3931 e_presentation_time_shutdown();
3932 e_comp_wl_renderer_shutdown();
3933 e_comp_wl_capture_shutdown();
3934 e_comp_wl_viewport_shutdown();
3935 e_comp_wl_video_shutdown();
3936 e_comp_wl_screenshooter_shutdown();
3938 e_comp_wl_remote_surface_shutdown();
3940 e_pixmap_shutdown();
3942 e_wtz_shell_shutdown();
3943 e_comp_wl_shell_shutdown();
3944 e_comp_wl_input_shutdown();
3946 wl_list_remove(&comp->client_created.link);
3949 e_comp->wl_comp_data = NULL;
3953 E_Comp_Wl_Output *output;
3955 if (e_comp_wl->screenshooter.global)
3956 wl_global_destroy(e_comp_wl->screenshooter.global);
3958 EINA_LIST_FREE(e_comp_wl->outputs, output)
3960 if (output->id) eina_stringshare_del(output->id);
3961 if (output->make) eina_stringshare_del(output->make);
3962 if (output->model) eina_stringshare_del(output->model);
3966 /* delete fd handler */
3967 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3969 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3970 cursor_timer_ec = NULL;
3972 /* free allocated data structure */
3978 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3980 e_object_unref(E_OBJECT(ev->ec));
3985 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3988 ev = E_NEW(E_Event_Client, 1);
3991 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
3993 /* set usable early because shell module checks this */
3994 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
3995 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
3997 e_pixmap_resource_set(ec->pixmap, buffer);
3998 e_pixmap_dirty(ec->pixmap);
3999 e_pixmap_refresh(ec->pixmap);
4001 e_comp_wl_map_size_cal_from_buffer(ec);
4002 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4004 /* wm-policy module uses it */
4005 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4008 e_object_ref(E_OBJECT(ec));
4009 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4010 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4014 e_comp_wl_surface_commit(E_Client *ec)
4019 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4020 if (!e_comp_object_damage_exists(ec->frame))
4022 if ((ec->comp_data->video_client) ||
4023 (!e_client_video_hw_composition_check(ec)))
4024 e_pixmap_image_clear(ec->pixmap, 1);
4027 ignored = ec->ignored;
4029 if (e_comp_wl_subsurface_order_commit(ec))
4031 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4032 e_comp_wl_subsurface_restack(topmost);
4033 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4036 ec->ignored = ignored;
4038 if (ec->is_cursor && ec->visible)
4040 /* ignore cursor changes during resize/move I guess */
4041 if (!e_client_action_get())
4043 if (e_comp->pointer)
4045 x = e_comp->pointer->hot.x;
4046 y = e_comp->pointer->hot.y;
4048 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4054 static E_Comp_Wl_Output *
4055 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4058 E_Comp_Wl_Output *output;
4060 EINA_LIST_FOREACH(outputs, l, output)
4062 if (!strcmp(output->id, id))
4070 * Initializes information about one display output.
4072 * Adds or updates the given data about a single display output,
4073 * with an id matching the provided id.
4075 * @param id identification of output to be added or changed
4076 * @param make manufacturer name of the display output
4077 * @param model model name of the display output
4078 * @param x output's top left corner x coordinate
4079 * @param y output's top left corner y coordinate
4080 * @param w output's width in pixels
4081 * @param h output's height in pixels
4082 * @param pw output's physical width in millimeters
4083 * @param ph output's physical height in millimeters
4084 * @param refresh output's refresh rate in mHz
4085 * @param subpixel output's subpixel layout
4086 * @param transform output's rotation and/or mirror transformation
4088 * @returns True if a display output object could be added or updated
4091 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4092 int x, int y, int w, int h, int pw, int ph,
4093 unsigned int refresh, unsigned int subpixel,
4094 unsigned int transform)
4096 E_Comp_Wl_Output *output;
4098 struct wl_resource *resource;
4100 /* retrieve named output; or create it if it doesn't exist */
4101 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4104 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4106 if (id) output->id = eina_stringshare_add(id);
4108 output->make = eina_stringshare_add(make);
4110 output->make = eina_stringshare_add("unknown");
4112 output->model = eina_stringshare_add(model);
4114 output->model = eina_stringshare_add("unknown");
4116 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4119 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4120 2, output, _e_comp_wl_cb_output_bind);
4122 output->resources = NULL;
4123 output->scale = e_scale;
4126 /* update the output details */
4131 output->phys_width = pw;
4132 output->phys_height = ph;
4133 output->refresh = refresh;
4134 output->subpixel = subpixel;
4135 output->transform = transform;
4137 if (output->scale <= 0)
4138 output->scale = e_scale;
4140 /* if we have bound resources, send updates */
4141 EINA_LIST_FOREACH(output->resources, l2, resource)
4143 wl_output_send_geometry(resource,
4144 output->x, output->y,
4146 output->phys_height,
4148 output->make ?: "", output->model ?: "",
4151 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4152 wl_output_send_scale(resource, output->scale);
4154 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4155 output->w, output->h, output->refresh);
4157 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4158 wl_output_send_done(resource);
4165 e_comp_wl_output_remove(const char *id)
4167 E_Comp_Wl_Output *output;
4169 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4172 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4174 /* wl_global_destroy(output->global); */
4176 /* eina_stringshare_del(output->id); */
4177 /* eina_stringshare_del(output->make); */
4178 /* eina_stringshare_del(output->model); */
4185 _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)
4187 struct wl_resource *res;
4189 uint32_t serial, keycode;
4190 struct wl_client *wc = NULL;
4191 E_Comp_Config *comp_conf = NULL;
4192 const char *device_name = NULL;
4194 keycode = (ev->keycode - 8);
4196 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4198 comp_conf = e_comp_config_get();
4200 if (ec && ec->comp_data)
4202 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4205 wc = wl_resource_get_client(surface);
4208 if (e_config->key_input_ttrace_enable)
4210 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4211 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4214 EINA_LIST_FOREACH(key_list, l, res)
4216 if (wl_resource_get_client(res) != wc) continue;
4218 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4219 if (!e_input_thread_mode_get())
4221 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4222 device_name = ecore_device_name_get(ev->dev);
4228 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4229 device_name = e_device_name_get(dev);
4233 if (comp_conf && comp_conf->input_log_enable)
4234 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4236 wl_keyboard_send_key(res, serial, ev->timestamp,
4241 if (e_config->key_input_ttrace_enable)
4244 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4249 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4251 E_Client *ec = NULL;
4253 E_Comp_Wl_Key_Data *end, *k;
4255 if (ev->window != e_comp->ee_win)
4260 keycode = (ev->keycode - 8);
4261 if (!(e_comp_wl = e_comp->wl_comp_data))
4266 #ifndef E_RELEASE_BUILD
4267 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4268 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4269 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4270 eina_streq(ev->key, "BackSpace"))
4276 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4278 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4280 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4282 /* ignore server-generated key repeats */
4283 if (k->key == keycode)
4285 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4290 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4292 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4294 ec = e_client_focused_get();
4295 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4296 if (ec && ec->comp_data && surface)
4298 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4299 if (e_comp_wl->kbd.focused)
4301 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4303 /* A key only sent to clients is added to the list */
4304 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4305 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4307 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4309 DBG("wl_array_add: Out of memory\n");
4310 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4311 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4314 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4318 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4322 /* update modifier state */
4323 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4329 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4331 E_Client *ec = NULL;
4332 uint32_t keycode, delivered_key;
4333 E_Comp_Wl_Key_Data *end, *k;
4335 if (ev->window != e_comp->ee_win)
4340 keycode = (ev->keycode - 8);
4342 if (!(e_comp_wl = e_comp->wl_comp_data))
4347 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4349 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4350 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4352 if (k->key == keycode)
4359 e_comp_wl->kbd.keys.size =
4360 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4362 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4364 /* 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) */
4365 if ((delivered_key) ||
4366 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4368 ec = e_client_focused_get();
4370 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4371 if (e_comp_wl->kbd.focused)
4373 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4375 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4378 /* update modifier state */
4379 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4385 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4387 Eina_Bool res = EINA_FALSE;
4389 if (type == ECORE_EVENT_KEY_DOWN)
4391 res = e_comp_wl_key_down(ev, dev);
4393 else if (type == ECORE_EVENT_KEY_UP)
4395 res = e_comp_wl_key_up(ev, dev);
4402 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4405 struct wl_client *wc;
4406 uint32_t serial, btn;
4407 struct wl_resource *res;
4408 E_Comp_Config *comp_conf = NULL;
4410 if (ec->cur_mouse_action || e_comp_wl->drag)
4412 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4413 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4417 case 1: btn = BTN_LEFT; break;
4418 case 2: btn = BTN_MIDDLE; break;
4419 case 3: btn = BTN_RIGHT; break;
4420 default: btn = button_id; break;
4423 e_comp_wl->ptr.button = btn;
4424 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4425 if (!surface) return EINA_FALSE;
4427 if (!eina_list_count(e_comp_wl->ptr.resources))
4430 wc = wl_resource_get_client(surface);
4431 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4433 comp_conf = e_comp_config_get();
4435 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4437 if (wl_resource_get_client(res) != wc) continue;
4438 if (!e_comp_wl_input_pointer_check(res)) continue;
4439 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4441 if (comp_conf && comp_conf->input_log_enable)
4442 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4444 wl_pointer_send_button(res, serial, timestamp, btn, state);
4451 e_comp_wl_touch_cancel(void)
4453 _e_comp_wl_touch_cancel();
4456 E_API E_Comp_Wl_Hook *
4457 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4461 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4462 ch = E_NEW(E_Comp_Wl_Hook, 1);
4463 if (!ch) return NULL;
4464 ch->hookpoint = hookpoint;
4466 ch->data = (void*)data;
4467 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4472 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4475 if (_e_comp_wl_hooks_walking == 0)
4477 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4481 _e_comp_wl_hooks_delete++;
4484 E_API E_Comp_Wl_Pid_Hook *
4485 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4487 E_Comp_Wl_Pid_Hook *ch;
4489 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4491 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4492 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4494 ch->hookpoint = hookpoint;
4496 ch->data = (void*)data;
4497 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4503 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4506 if (_e_comp_wl_pid_hooks_walking == 0)
4508 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4512 _e_comp_wl_pid_hooks_delete++;
4515 E_API E_Comp_Wl_Intercept_Hook *
4516 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4518 E_Comp_Wl_Intercept_Hook *ch;
4520 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4521 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4522 if (!ch) return NULL;
4523 ch->hookpoint = hookpoint;
4525 ch->data = (void*)data;
4526 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4531 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4534 if (_e_comp_wl_intercept_hooks_walking == 0)
4536 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4540 _e_comp_wl_intercept_hooks_delete++;
4544 e_comp_wl_shell_surface_ready(E_Client *ec)
4548 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4552 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4554 e_config->use_cursor_timer = !!enabled;
4556 if (e_config->use_cursor_timer)
4558 if (!e_pointer_is_hidden(e_comp->pointer))
4560 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4565 if (e_comp_wl->ptr.hide_tmr)
4567 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4568 e_comp_wl->ptr.hide_tmr = NULL;
4570 cursor_timer_ec = NULL;
4572 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4575 if (e_pointer_is_hidden(e_comp->pointer))
4577 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4583 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4585 EINA_SAFETY_ON_NULL_RETURN(wc);
4586 EINA_SAFETY_ON_NULL_RETURN(dev);
4588 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4592 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4594 EINA_SAFETY_ON_NULL_RETURN(wc);
4595 EINA_SAFETY_ON_NULL_RETURN(dev);
4597 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4601 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4603 struct wl_resource *res;
4604 struct wl_client *wc;
4606 uint32_t serial, wl_keycode;
4607 enum wl_keyboard_key_state state;
4608 E_Comp_Config *comp_conf = NULL;
4609 const char *dev_name = NULL;
4611 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4612 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4613 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4615 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4616 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4618 wl_keycode = keycode - 8;
4619 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4621 wc = wl_resource_get_client(surface);
4622 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4623 if (!time) time = e_util_timestamp_get();
4624 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4625 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4627 comp_conf = e_comp_config_get();
4628 e_keyrouter_event_surface_send(ec, keycode);
4630 if (e_config->key_input_ttrace_enable)
4632 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4633 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4636 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4637 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4639 if (wl_resource_get_client(res) != wc) continue;
4640 if (!e_input_thread_mode_get())
4644 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4645 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4649 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4656 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4657 dev_name = e_device_name_get(dev);
4661 if (comp_conf && comp_conf->input_log_enable)
4662 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4665 wl_keyboard_send_key(res, serial, time,
4668 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4670 if (e_config->key_input_ttrace_enable)
4673 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4680 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4682 struct wl_resource *res;
4683 struct wl_client *wc;
4685 uint32_t serial, wl_keycode, cancel_keycode;
4686 E_Comp_Config *comp_conf = NULL;
4687 struct xkb_keymap *keymap = NULL;
4689 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4690 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4691 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4693 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4694 keymap = e_comp_wl->xkb.keymap;
4695 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4696 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4698 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4699 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4701 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4702 if (cancel_keycode == XKB_KEYCODE_INVALID)
4704 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4707 cancel_keycode = cancel_keycode - 8;
4709 wl_keycode = keycode - 8;
4710 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4712 wc = wl_resource_get_client(surface);
4713 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4714 if (!time) time = e_util_timestamp_get();
4716 comp_conf = e_comp_config_get();
4717 e_keyrouter_event_surface_send(ec, keycode);
4719 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4720 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4722 if (wl_resource_get_client(res) != wc) continue;
4723 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4724 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4726 if (comp_conf && comp_conf->input_log_enable)
4727 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4728 wl_keyboard_send_key(res, serial, time,
4729 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4730 wl_keyboard_send_key(res, serial, time,
4731 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4732 wl_keyboard_send_key(res, serial, time,
4733 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4735 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4742 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)
4744 struct wl_client *wc;
4746 E_Devicemgr_Input_Device *device = NULL;
4748 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4749 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4750 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4752 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4753 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4755 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4757 wc = wl_resource_get_client(surface);
4758 if (!time) time = e_util_timestamp_get();
4759 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4763 _e_comp_wl_send_event_device(wc, time, dev, serial);
4764 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4768 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4769 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4772 x = x + ec->client.x;
4773 y = y + ec->client.y;
4775 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4781 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)
4783 E_Devicemgr_Input_Device *device;
4785 struct wl_client *wc;
4787 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4788 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4789 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4791 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4792 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4794 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4796 wc = wl_resource_get_client(surface);
4797 if (!time) time = e_util_timestamp_get();
4798 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4802 _e_comp_wl_send_event_device(wc, time, dev, serial);
4803 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4807 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4808 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4811 x = x + ec->client.x;
4812 y = y + ec->client.y;
4814 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4820 e_comp_wl_touch_cancel_send(E_Client *ec)
4822 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4823 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4824 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4826 _e_comp_wl_send_touch_cancel(ec);
4832 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4835 struct wl_client *wc;
4837 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4838 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4839 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4841 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4842 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4844 wc = wl_resource_get_client(surface);
4845 if (!time) time = e_util_timestamp_get();
4846 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4848 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4849 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4852 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4853 WL_POINTER_BUTTON_STATE_PRESSED);
4855 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4856 WL_POINTER_BUTTON_STATE_RELEASED);
4862 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4865 struct wl_client *wc;
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4869 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4871 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4872 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4874 wc = wl_resource_get_client(surface);
4875 if (!time) time = e_util_timestamp_get();
4876 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4878 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4879 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4881 x = x + ec->client.x;
4882 y = y + ec->client.y;
4884 _e_comp_wl_send_mouse_move(ec, x, y, time);
4890 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4893 struct wl_client *wc;
4895 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4896 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4897 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4899 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4900 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4902 wc = wl_resource_get_client(surface);
4903 if (!time) time = e_util_timestamp_get();
4904 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4906 if (_e_comp_wl_check_cursor_timer_needed(ec))
4908 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4912 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4913 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4915 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4917 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4919 if (_e_comp_wl_check_cursor_timer_needed(ec))
4920 _e_comp_wl_cursor_move_timer_control(ec);
4927 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4930 struct wl_client *wc;
4931 struct wl_resource *res;
4934 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4935 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4937 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4938 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4940 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4941 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4943 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4944 wc = wl_resource_get_client(surface);
4945 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4946 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4948 if (!e_comp_wl_input_pointer_check(res)) continue;
4949 if (wl_resource_get_client(res) != wc) continue;
4951 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4952 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4954 wl_pointer_send_enter(res, serial, surface,
4955 wl_fixed_from_int(x),
4956 wl_fixed_from_int(y));
4957 ec->pointer_enter_sent = EINA_TRUE;
4959 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4965 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4968 struct wl_client *wc;
4969 struct wl_resource *res;
4972 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4973 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4974 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4975 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4976 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4977 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4979 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4980 wc = wl_resource_get_client(surface);
4981 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4982 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4984 if (!e_comp_wl_input_pointer_check(res)) continue;
4985 if (wl_resource_get_client(res) != wc) continue;
4987 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4988 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4990 wl_pointer_send_leave(res, serial, surface);
4991 ec->pointer_enter_sent = EINA_FALSE;
4998 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)
5000 Evas_Event_Mouse_In ev_in;
5003 if (ec->pointer_enter_sent) return;
5005 ev_in.buttons = buttons;
5013 ev_in.modifiers = modifiers;
5014 ev_in.locks = locks;
5015 ev_in.timestamp = timestamp;
5016 ev_in.event_flags = event_flags;
5019 ev_in.event_src = event_src;
5021 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5025 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)
5027 Evas_Event_Mouse_Out ev_out;
5030 if (!ec->pointer_enter_sent) return;
5032 ev_out.buttons = buttons;
5034 ev_out.output.x = x;
5035 ev_out.output.y = y;
5036 ev_out.canvas.x = x;
5037 ev_out.canvas.y = y;
5040 ev_out.modifiers = modifiers;
5041 ev_out.locks = locks;
5042 ev_out.timestamp = timestamp;
5043 ev_out.event_flags = event_flags;
5046 ev_out.event_src = event_src;
5048 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5052 e_comp_wl_cursor_hide(E_Client *ec)
5054 struct wl_resource *res;
5055 struct wl_client *wc;
5059 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5061 if (e_comp_wl->ptr.hide_tmr)
5063 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5064 e_comp_wl->ptr.hide_tmr = NULL;
5066 cursor_timer_ec = NULL;
5068 if (!ec) return EINA_FALSE;
5069 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5070 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5071 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5073 wc = wl_resource_get_client(surface);
5074 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5075 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5077 if (!e_comp_wl_input_pointer_check(res)) continue;
5078 if (wl_resource_get_client(res) != wc) continue;
5079 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5080 wl_pointer_send_leave(res, serial, surface);
5081 ec->pointer_enter_sent = EINA_FALSE;
5087 /* surface to buffer
5088 * - width : surface width
5089 * - height : surface height
5090 * - transform: buffer transform
5091 * - scale : buffer scale
5093 * - width : screen width
5094 * - height : screen height
5095 * - transform: output transform
5096 * - scale : output scale
5098 static E_Util_Transform_Matrix
5099 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5101 E_Util_Transform_Matrix m;
5103 e_util_transform_matrix_load_identity(&m);
5105 if (transform & 0x4)
5107 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5108 e_util_transform_matrix_flip_x(&m);
5109 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5112 switch (transform & 0x3)
5114 case WL_OUTPUT_TRANSFORM_90:
5115 e_util_transform_matrix_translate(&m, -width, 0, 0);
5116 e_util_transform_matrix_rotation_z(&m, 270);
5118 case WL_OUTPUT_TRANSFORM_180:
5119 e_util_transform_matrix_translate(&m, -width, -height, 0);
5120 e_util_transform_matrix_rotation_z(&m, 180);
5122 case WL_OUTPUT_TRANSFORM_270:
5123 e_util_transform_matrix_translate(&m, 0, -height, 0);
5124 e_util_transform_matrix_rotation_z(&m, 90);
5130 e_util_transform_matrix_scale(&m, scale, scale, 1);
5135 /* surface to buffer
5136 * - surface width, surface height, buffer transform, buffer scale
5138 * - screen width, screen height, output transform, output scale
5141 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5143 E_Util_Transform_Matrix m;
5144 E_Util_Transform_Vertex v;
5146 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5148 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5149 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5150 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5154 * - buffer width, buffer height, buffer transform, buffer scale
5157 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5159 E_Util_Transform_Matrix m;
5160 E_Util_Transform_Vertex v;
5163 if (transform != 0 || scale > 1)
5165 tw = ((transform % 2) ? height : width) / scale;
5166 th = ((transform % 2) ? width : height) / scale;
5174 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5175 m = e_util_transform_matrix_inverse_get(&m);
5177 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5178 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5179 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5182 /* surface to buffer
5183 * - surface width, surface height, buffer transform, buffer scale
5185 * - screen width, screen height, output transform, output scale
5188 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5189 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5191 E_Util_Transform_Matrix m;
5192 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5193 E_Util_Transform_Rect_Vertex sv;
5195 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5197 sv = e_util_transform_rect_to_vertices(&sr);
5198 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5199 sr = e_util_transform_vertices_to_rect(&sv);
5208 * - buffer width, buffer height, buffer transform, buffer scale
5211 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5212 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5214 E_Util_Transform_Matrix m;
5215 E_Util_Transform_Rect br = {bx, by, bw, bh};
5216 E_Util_Transform_Rect_Vertex bv;
5219 if (transform != 0 || scale > 1)
5221 tw = ((transform % 2) ? height : width) / scale;
5222 th = ((transform % 2) ? width : height) / scale;
5230 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5231 m = e_util_transform_matrix_inverse_get(&m);
5233 bv = e_util_transform_rect_to_vertices(&br);
5234 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5235 br = e_util_transform_vertices_to_rect(&bv);
5243 EINTERN E_Comp_Wl_Output*
5244 e_comp_wl_output_find(E_Client *ec)
5247 E_Comp_Wl_Output *output;
5249 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5251 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5253 if (output->transform % 2)
5255 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5256 ec->y < output->x || ec->y >= (output->x + output->w))
5261 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5262 ec->y < output->y || ec->y >= (output->y + output->h))
5272 EINTERN Eina_Array *
5273 e_comp_wl_output_find_all(E_Client *ec)
5275 E_Comp_Wl_Output *output;
5276 Eina_Array *outputs;
5279 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5281 outputs = eina_array_new(4);
5285 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5287 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5288 output->x, output->y, output->w, output->h))
5290 eina_array_push(outputs, output);
5294 if (eina_array_count(outputs) == 0)
5296 eina_array_free(outputs);
5303 // --------------------------------------------------------
5304 // tizen_move_resize
5305 // --------------------------------------------------------
5307 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5314 E_Client_Pending_Geometry *geo;
5317 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5318 if (ec->fullscreen || ec->maximized) goto err;
5320 geo = E_NEW(E_Client_Pending_Geometry, 1);
5323 geo->serial = serial;
5329 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5330 ec->surface_sync.wait_commit = EINA_TRUE;
5335 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5342 e_comp_wl_commit_sync_configure(E_Client *ec)
5345 E_Client_Pending_Geometry *geo;
5347 Eina_Bool match_size = EINA_FALSE;
5354 if (!ec || !ec->frame) goto ret;
5355 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5358 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5359 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5361 if (eina_list_count(ec->surface_sync.pending_geometry))
5363 Eina_List *ll = NULL;
5364 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5368 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5373 if ((geo->w == bw) && (geo->h == bh))
5375 match_size = EINA_TRUE;
5380 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5387 if ((config.w != ec->w) || (config.h != ec->h))
5389 e_client_size_set(ec, config.w, config.h);
5390 ec->changes.size = EINA_TRUE;
5394 // FIXME: The geometry of the client would be better to be calculated
5395 // at e_desk or at e_desk_area. So the position(x,y) of the client
5396 // should be calcuated at the e_desk or at the e_desk_area.
5398 desk = e_comp_desk_find_by_ec(ec);
5401 ec->client.x = desk->geom.x + config.x;
5402 ec->client.y = desk->geom.y + config.y;
5406 ec->client.x = config.x;
5407 ec->client.y = config.y;
5410 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5412 e_client_pos_set(ec, ec->client.x, ec->client.y);
5414 ec->changes.pos = 1;
5418 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5422 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5423 ec->surface_sync.wait_commit = EINA_FALSE;
5425 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5427 // rollback wait_commit if there are pending requests remained
5428 if (eina_list_count(ec->surface_sync.pending_geometry))
5429 ec->surface_sync.wait_commit = EINA_TRUE;
5434 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);
5441 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5442 struct wl_resource *res_moveresize)
5444 wl_resource_destroy(res_moveresize);
5448 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5449 struct wl_resource *res_moveresize,
5450 struct wl_resource *surface,
5457 /* to be implemented */
5460 int cur_w = 0, cur_h = 0;
5462 ec = e_client_from_surface_resource(surface);
5465 pending = e_client_pending_geometry_has(ec);
5466 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5467 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);
5471 if ((cur_w == w) && (cur_h == h))
5473 e_client_pos_set(ec, x, y);
5474 ec->changes.pos = 1;
5480 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5484 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5487 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5489 _tz_move_resize_iface_cb_destroy,
5490 _tz_move_resize_iface_cb_set_geometry,
5494 _tz_moveresize_cb_bind(struct wl_client *client,
5495 void *data EINA_UNUSED,
5499 struct wl_resource *res_moveresize;
5501 res_moveresize = wl_resource_create(client,
5502 &tizen_move_resize_interface,
5505 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5508 wl_resource_set_implementation(res_moveresize,
5509 &_tz_move_resize_iface,
5515 ERR("Could not create tizen_move_resize_interface res: %m");
5516 wl_client_post_no_memory(client);
5520 _e_comp_wl_move_resize_init(void)
5522 if (!e_comp_wl) return;
5523 if (!e_comp_wl->wl.disp) return;
5525 if (!wl_global_create(e_comp_wl->wl.disp,
5526 &tizen_move_resize_interface,
5529 _tz_moveresize_cb_bind))
5531 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5538 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5540 E_Comp_Wl_Output *output;
5541 pid_t output_pid = 0;
5542 Eina_List *l = NULL, *l2 = NULL;
5543 struct wl_resource *resource = NULL;
5545 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5547 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5548 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5549 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5551 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5553 /* if we have bound resources, send updates */
5554 EINA_LIST_FOREACH(output->resources, l2, resource)
5556 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5557 if (output_pid != pid) continue;
5559 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5561 // send output information to the client
5562 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5570 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5572 _e_comp_wl_surface_state_init(state, w, h);
5576 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5578 _e_comp_wl_surface_state_commit(ec, state);
5582 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5584 _e_comp_wl_hook_call(hookpoint, ec);
5588 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5590 _e_comp_wl_surface_state_finish(state);
5594 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5596 _e_comp_wl_surface_state_buffer_set(state, buffer);
5600 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5601 int sx, int sy, int *dx, int *dy)
5605 case WL_OUTPUT_TRANSFORM_NORMAL:
5609 case WL_OUTPUT_TRANSFORM_FLIPPED:
5610 *dx = width - sx, *dy = sy;
5612 case WL_OUTPUT_TRANSFORM_90:
5613 *dx = height - sy, *dy = sx;
5615 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5616 *dx = height - sy, *dy = width - sx;
5618 case WL_OUTPUT_TRANSFORM_180:
5619 *dx = width - sx, *dy = height - sy;
5621 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5622 *dx = sx, *dy = height - sy;
5624 case WL_OUTPUT_TRANSFORM_270:
5625 *dx = sy, *dy = width - sx;
5627 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5637 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5640 int tx1, ty1, tx2, ty2;
5641 int width_from_buffer, height_from_buffer;
5643 switch (vp->buffer.transform)
5645 case WL_OUTPUT_TRANSFORM_90:
5646 case WL_OUTPUT_TRANSFORM_270:
5647 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5648 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5649 width_from_buffer = bh / vp->buffer.scale;
5650 height_from_buffer = bw / vp->buffer.scale;
5653 width_from_buffer = bw / vp->buffer.scale;
5654 height_from_buffer = bh / vp->buffer.scale;
5658 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5662 x2 = width_from_buffer;
5663 y2 = height_from_buffer;
5667 x1 = wl_fixed_to_int(vp->buffer.src_x);
5668 y1 = wl_fixed_to_int(vp->buffer.src_y);
5669 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5670 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5673 buffer_transform(width_from_buffer, height_from_buffer,
5674 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5675 buffer_transform(width_from_buffer, height_from_buffer,
5676 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5678 out->x = (tx1 <= tx2) ? tx1 : tx2;
5679 out->y = (ty1 <= ty2) ? ty1 : ty2;
5680 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5681 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5685 * Convert given four coordinates to elements of rectangle
5686 * @in p[4] Coordinates to be converted
5687 * @out rect x, y, width, and height
5688 * transform Angle which represents TDM_TRANSFORM of rectangle
5689 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5690 * 1. The given coordinates are not represented by rectangle.
5691 * 2. All angles except for 0, 90, 180, 270.
5694 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5696 Eina_Bool ret = EINA_FALSE;
5698 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))
5701 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5704 *rotation = TDM_TRANSFORM_NORMAL;
5707 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5711 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5714 *rotation = TDM_TRANSFORM_180;
5717 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5722 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))
5725 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5728 *rotation = TDM_TRANSFORM_90;
5731 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5735 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5738 *rotation = TDM_TRANSFORM_270;
5741 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5751 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5756 for (i = 0; i < 4; i++)
5757 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5759 if (!_coords_to_rectangle_convert(p, out, rotation))
5761 DBG("Cannot convert given coords to rectangle.\n"
5762 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5763 p[0].x, p[0].y, p[1].x, p[1].y,
5764 p[2].x, p[2].y, p[3].x, p[3].y);
5772 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5774 int trans_rotation, flip;
5776 trans_rotation = transform & 0x3;
5777 flip = transform & 0x4;
5779 return (flip + (trans_rotation + rotation) % 4);
5783 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5791 if (e_comp_wl_subsurface_check(ec))
5792 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5799 out->w = ec->comp_data->width_from_viewport;
5800 out->w = (out->w + 1) & ~1;
5801 out->h = ec->comp_data->height_from_viewport;
5803 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5804 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5808 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5810 E_Comp_Wl_Buffer *buffer;
5811 E_Comp_Wl_Buffer_Viewport *vp;
5813 enum wl_output_transform buffer_transform;
5814 unsigned int rotation;
5815 Eina_Bool res = EINA_FALSE;
5817 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5819 if (e_object_is_del(E_OBJECT(ec)))
5822 vp = &ec->comp_data->scaler.buffer_viewport;
5824 if (buffer_viewport)
5826 buffer = ec->comp_data->buffer_ref.buffer;
5827 /* Getting a viewport of buffer needs geometry of buffer. */
5831 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5834 if ((output_viewport) || (transform))
5836 m = e_client_map_get(ec);
5838 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5840 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5845 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5846 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5847 * Since buffer.transform isn't applied using evas_map,
5848 * it has to be taken into account here to apply buffer.transform
5849 * and rotation of e_client_transform together. */
5851 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5853 *transform = (unsigned int)buffer_transform;
5861 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5863 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5864 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5866 /* Must be called with valid comp_data */
5867 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5869 if ((ec->comp_data->role_name == NULL) ||
5870 (ec->comp_data->role_name == role_name) ||
5871 (strcmp(ec->comp_data->role_name, role_name) == 0))
5873 ec->comp_data->role_name = role_name;
5879 wl_resource_post_error(error_resource, error_code,
5880 "Cannot assign role %s to wl_surface@%d,"
5881 " already has role %s\n",
5883 ec->comp_data->wl_surface ?
5884 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5885 ec->comp_data->role_name);
5891 EINTERN const char *
5892 e_comp_wl_surface_role_get(E_Client *ec)
5894 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5895 return ec->comp_data ? ec->comp_data->role_name : NULL;
5898 EINTERN struct wl_resource *
5899 e_comp_wl_client_surface_get(E_Client *ec)
5901 struct wl_resource *surface = NULL;
5902 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5903 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5905 g_mutex_lock(&ec->comp_data->surface_mutex);
5906 surface = ec->comp_data->surface;
5907 g_mutex_unlock(&ec->comp_data->surface_mutex);
5912 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5914 EINA_SAFETY_ON_NULL_RETURN(ec);
5915 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5917 g_mutex_lock(&ec->comp_data->surface_mutex);
5918 ec->comp_data->surface = surface;
5919 g_mutex_unlock(&ec->comp_data->surface_mutex);
5923 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5925 return e_compositor_util_client_from_surface_resource(surface_resource);
5929 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5931 if (!ec->comp_data->mapped)
5933 if (ec->comp_data->shell.surface &&
5934 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5936 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5942 if (ec->comp_data->mapped)
5944 /* will be unmapped. so run capture */
5945 e_comp_wl_remote_surface_image_save(ec);
5949 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5951 ec->comp_data->pending.sx = sx;
5952 ec->comp_data->pending.sy = sy;
5953 ec->comp_data->pending.new_attach = EINA_TRUE;
5955 e_client_fps_update(ec);
5959 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5961 if (ec->comp_data->pending.opaque)
5962 eina_tiler_clear(ec->comp_data->pending.opaque);
5966 eina_tiler_union(ec->comp_data->pending.opaque, region);
5968 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5972 ec->argb = EINA_FALSE;
5973 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5975 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5976 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5984 ec->argb = EINA_TRUE;
5985 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5987 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5988 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
5994 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
5996 if (ec->comp_data->pending.input)
5997 eina_tiler_clear(ec->comp_data->pending.input);
6001 if (eina_tiler_empty(region))
6003 ELOGF("COMP", " |unset input rect", NULL);
6004 e_comp_object_input_objs_del(ec->frame);
6005 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6008 eina_tiler_union(ec->comp_data->pending.input, region);
6012 eina_tiler_rect_add(ec->comp_data->pending.input,
6013 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6018 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6020 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6024 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6026 E_Comp_Wl_Subsurf_Data *sdata;
6031 if (ec->comp_data->frames)
6033 ec->comp_data->frames =
6034 eina_list_remove(ec->comp_data->frames, callback_resource);
6037 if (ec->comp_data->pending.frames)
6039 ec->comp_data->pending.frames =
6040 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6043 sdata = ec->comp_data->sub.data;
6044 if ((sdata) && (sdata->cached.frames))
6046 sdata->cached.frames =
6047 eina_list_remove(sdata->cached.frames, callback_resource);
6052 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6054 if (e_object_is_del(E_OBJECT(ec))) return;
6056 if (e_comp_wl_remote_surface_commit(ec)) return;
6058 e_comp_wl_surface_commit(ec);
6060 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6064 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6066 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6067 ec->comp_data->sub.data = sub;
6069 /* set subsurface client properties */
6070 ec->borderless = EINA_TRUE;
6071 ec->argb = EINA_TRUE;
6072 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6073 ec->lock_border = EINA_TRUE;
6074 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6075 ec->netwm.state.skip_taskbar = EINA_TRUE;
6076 ec->netwm.state.skip_pager = EINA_TRUE;
6077 ec->border_size = 0;
6078 ec->lock_user_location = 0;
6079 ec->lock_client_location = 0;
6080 ec->lock_user_size = 0;
6081 ec->lock_client_size = 0;
6082 ec->lock_client_stacking = 0;
6083 ec->lock_user_maximize = 0;
6084 ec->lock_client_maximize = 0;
6085 ec->changes.need_maximize = 0;
6086 ec->maximized = E_MAXIMIZE_NONE;
6089 ec->new_client = ec->netwm.ping = EINA_TRUE;
6090 e_comp->new_clients++;
6091 e_client_unignore(ec);
6093 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6094 * It's not for subsurface. */
6095 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6099 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6101 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6104 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6106 sub->parent = parent;
6110 layer = e_client_layer_get(parent);
6111 if (layer > E_LAYER_BOTTOM)
6112 e_client_layer_set(ec, layer);
6115 if (parent->comp_data)
6117 /* append this client to the parents subsurface list */
6118 parent->comp_data->sub.list_pending =
6119 eina_list_append(parent->comp_data->sub.list_pending, ec);
6120 parent->comp_data->sub.list_changed = EINA_TRUE;
6125 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6127 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6128 E_Client *parent = sub->parent;
6130 parent->comp_data->sub.list =
6131 eina_list_remove(parent->comp_data->sub.list, ec);
6132 parent->comp_data->sub.list_pending =
6133 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6134 parent->comp_data->sub.below_list =
6135 eina_list_remove(parent->comp_data->sub.below_list, ec);
6136 parent->comp_data->sub.below_list_pending =
6137 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6143 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)
6145 sub->resource = subsurface_resource;
6146 sub->cached_buffer_ref.buffer = NULL;
6147 sub->synchronized = EINA_TRUE;
6148 sub->parent = parent;
6149 sub->remote_surface.offscreen_parent = offscreen_parent;
6150 if (offscreen_parent)
6151 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6153 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6155 _e_comp_wl_client_subsurface_set(ec, sub);
6156 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6158 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6162 e_comp_wl_client_subsurface_finish(E_Client *ec)
6164 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6167 e_comp_wl_client_subsurface_parent_unset(ec);
6169 e_comp_wl_surface_state_finish(&sub->cached);
6170 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6172 ec->comp_data->sub.data = NULL;
6176 e_comp_wl_client_evas_init(E_Client *ec)
6178 EINA_SAFETY_ON_NULL_RETURN(ec);
6180 _e_comp_wl_client_evas_init(ec);
6184 e_comp_wl_client_evas_deinit(E_Client *ec)
6186 EINA_SAFETY_ON_NULL_RETURN(ec);
6188 _e_comp_wl_client_evas_deinit(ec);
6192 e_comp_wl_focus_check(void)
6194 _e_comp_wl_focus_check();
6198 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6205 if ((parent->comp_data) && (parent->comp_data->sub.data))
6206 parent = parent->comp_data->sub.data->parent;