3 #include "e_wtz_shell.h"
4 #include "e_comp_wl_private.h"
5 #include "e_client_intern.h"
6 #include <tizen-extension-server-protocol.h>
8 #include <relative-pointer-unstable-v1-server-protocol.h>
9 #include <pointer-constraints-unstable-v1-server-protocol.h>
11 #include <wayland-tbm-server.h>
14 #include <libds/log.h>
15 #include <libds/single_pixel_buffer_v1.h>
17 /* handle include for printing uint64_t */
18 #define __STDC_FORMAT_MACROS
21 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
23 /* Resource Data Mapping: (wl_resource_get_user_data)
25 * wl_surface == e_pixmap
26 * wl_region == eina_tiler
27 * wl_subsurface == e_client
31 typedef struct _E_Comp_Data E_Comp_Data;
36 struct wl_listener client_created;
39 static void _e_comp_wl_move_resize_init(void);
41 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
44 typedef struct _E_Comp_Wl_Key_Data
50 static Eina_List *handlers = NULL;
51 static E_Client *cursor_timer_ec = NULL;
52 static Eina_Bool need_send_released = EINA_FALSE;
53 static Eina_Bool need_send_motion = EINA_TRUE;
55 static GMutex connection_mutex;
57 static int _e_comp_wl_hooks_delete = 0;
58 static int _e_comp_wl_hooks_walking = 0;
60 static int _e_comp_wl_pid_hooks_delete = 0;
61 static int _e_comp_wl_pid_hooks_walking = 0;
63 static int _e_comp_wl_intercept_hooks_delete = 0;
64 static int _e_comp_wl_intercept_hooks_walking = 0;
66 static Eina_Inlist *_e_comp_wl_hooks[] =
68 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
69 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
70 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
71 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
72 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
73 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
74 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
75 [E_COMP_WL_HOOK_DEL] = NULL,
76 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
77 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
78 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
81 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
83 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
86 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
88 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
89 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
90 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
91 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
92 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
93 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
96 static Eina_List *hooks = NULL;
100 _e_comp_wl_hooks_clean(void)
105 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
106 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
108 if (!ch->delete_me) continue;
109 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
115 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
119 e_object_ref(E_OBJECT(ec));
120 _e_comp_wl_hooks_walking++;
121 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
123 if (ch->delete_me) continue;
124 ch->func(ch->data, ec);
125 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
126 (e_object_is_del(E_OBJECT(ec))))
129 _e_comp_wl_hooks_walking--;
130 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
131 _e_comp_wl_hooks_clean();
132 e_object_unref(E_OBJECT(ec));
136 _e_comp_wl_pid_hooks_clean(void)
139 E_Comp_Wl_Pid_Hook *ch;
141 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
142 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
144 if (!ch->delete_me) continue;
145 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
151 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
153 E_Comp_Wl_Pid_Hook *ch;
155 _e_comp_wl_pid_hooks_walking++;
156 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
158 if (ch->delete_me) continue;
159 ch->func(ch->data, pid);
161 _e_comp_wl_pid_hooks_walking--;
162 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
163 _e_comp_wl_pid_hooks_clean();
167 _e_comp_wl_intercept_hooks_clean(void)
170 E_Comp_Wl_Intercept_Hook *ch;
172 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
173 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
175 if (!ch->delete_me) continue;
176 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
182 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
184 E_Comp_Wl_Intercept_Hook *ch;
185 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
187 e_object_ref(E_OBJECT(ec));
188 _e_comp_wl_intercept_hooks_walking++;
189 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
191 if (ch->delete_me) continue;
192 res = ch->func(ch->data, ec);
193 if (!res) ret = EINA_FALSE;
194 if (e_object_is_del(E_OBJECT(ec)))
197 _e_comp_wl_intercept_hooks_walking--;
198 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
199 _e_comp_wl_intercept_hooks_clean();
200 e_object_unref(E_OBJECT(ec));
207 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
213 if (e_comp_object_frame_exists(ec->frame))
214 w = ec->client.w, h = ec->client.h;
216 w = ec->w, h = ec->h;
220 // Width and Height are -1 means that we don't consider size value
224 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
228 _e_comp_wl_focus_check(void)
232 if (stopping) return;
233 ec = e_client_focused_get();
235 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
239 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
241 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
243 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
244 IDLE_EXITER~CB_PREPARE);
246 return ECORE_CALLBACK_RENEW;
250 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
252 /* dispatch pending wayland events */
253 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
255 return ECORE_CALLBACK_RENEW;
259 e_comp_wl_display_flush()
261 if (e_comp_wl && e_comp_wl->wl.disp)
263 if (e_config->key_input_ttrace_enable)
265 TRACE_INPUT_BEGIN(wl_display_flush_clients);
266 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
269 g_mutex_lock(&connection_mutex);
270 wl_display_flush_clients(e_comp_wl->wl.disp);
271 g_mutex_unlock(&connection_mutex);
273 if (e_config->key_input_ttrace_enable)
276 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
282 e_comp_wl_connection_lock()
284 e_input_boost_lock(&connection_mutex);
288 e_comp_wl_connection_unlock()
290 e_input_boost_unlock(&connection_mutex);
294 e_comp_wl_focused_client_flush()
296 E_Client *focused_ec;
297 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
299 e_input_boost_lock(&connection_mutex);
300 focused_ec = e_client_focused_get();
304 struct wl_client *wc;
305 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
308 e_input_boost_unlock(&connection_mutex);
312 wc = wl_resource_get_client(surface);
316 e_input_boost_unlock(&connection_mutex);
320 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
324 if (e_comp_wl->idle_exiter_timestamp > 0.0)
326 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
327 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
329 ELOGF("E_COMP", "prepare gap time: %lfms",
334 e_comp_wl->idle_exiter_timestamp = 0.0;
336 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
338 /* flush pending client events */
339 e_comp_wl_display_flush();
341 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
342 IDLE_EXITER~CB_PREPARE);
345 E_API enum wl_output_transform
346 e_comp_wl_output_buffer_transform_get(E_Client *ec)
348 E_Comp_Wl_Buffer_Viewport *vp;
349 E_Comp_Wl_Buffer *buffer;
350 enum wl_output_transform transform, rotation;
352 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
353 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
354 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
356 vp = &ec->comp_data->scaler.buffer_viewport;
357 if (e_comp_wl_subsurface_check(ec))
358 return vp->buffer.transform;
360 buffer = ec->comp_data->buffer_ref.buffer;
363 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
364 return vp->buffer.transform;
366 rotation = buffer->transform;
368 return vp->buffer.transform;
370 /* ignore the flip value when calculating transform because the screen rotation
371 * functionality doesn't consider the flip output transform currently
373 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
375 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
376 ec, rotation, vp->buffer.transform, transform);
381 EINTERN enum wl_output_transform
382 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
384 E_Comp_Wl_Buffer_Viewport *vp;
385 E_Comp_Wl_Buffer *buffer;
386 enum wl_output_transform transform, rotation;
388 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
389 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
390 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
392 vp = &ec->comp_data->pending.buffer_viewport;
393 if (e_comp_wl_subsurface_check(ec))
394 return vp->buffer.transform;
396 buffer = ec->comp_data->pending.buffer;
399 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
400 return vp->buffer.transform;
402 rotation = buffer->transform;
404 return vp->buffer.transform;
406 /* ignore the flip value when calculating transform because the screen rotation
407 * functionality doesn't consider the flip output transform currently
409 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
411 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
412 ec, rotation, vp->buffer.transform, transform);
418 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
420 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
421 E_Comp_Wl_Buffer *buffer;
422 int32_t width, height;
424 buffer = e_pixmap_resource_get(ec->pixmap);
427 ec->comp_data->width_from_buffer = 0;
428 ec->comp_data->height_from_buffer = 0;
432 switch (e_comp_wl_output_buffer_transform_get(ec))
434 case WL_OUTPUT_TRANSFORM_90:
435 case WL_OUTPUT_TRANSFORM_270:
436 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
437 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
438 width = buffer->h / vp->buffer.scale;
439 height = buffer->w / vp->buffer.scale;
442 width = buffer->w / vp->buffer.scale;
443 height = buffer->h / vp->buffer.scale;
447 ec->comp_data->width_from_buffer = width;
448 ec->comp_data->height_from_buffer = height;
452 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
454 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
455 int32_t width, height;
457 width = ec->comp_data->width_from_buffer;
458 height = ec->comp_data->height_from_buffer;
460 if (width == 0 && height == 0) return;
462 if (width != 0 && vp->surface.width != -1)
464 ec->comp_data->width_from_viewport = vp->surface.width;
465 ec->comp_data->height_from_viewport = vp->surface.height;
469 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
471 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
472 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
473 ec->comp_data->width_from_viewport = w ?: 1;
474 ec->comp_data->height_from_viewport = h ?: 1;
478 ec->comp_data->width_from_viewport = width;
479 ec->comp_data->height_from_viewport = height;
483 e_comp_wl_topmost_parent_get(E_Client *ec)
487 if (!e_comp_wl_subsurface_check(ec))
490 parent = e_comp_wl_subsurface_parent_get(ec);
493 if (!e_comp_wl_subsurface_check(parent))
496 parent = e_comp_wl_subsurface_parent_get(parent);
503 e_comp_wl_map_apply(E_Client *ec)
505 E_Comp_Wl_Buffer_Viewport *vp;
506 E_Comp_Wl_Subsurf_Data *sdata;
507 E_Comp_Wl_Client_Data *cdata;
508 int x1, y1, x2, y2, x, y;
510 Eina_Bool zoom_animating = EINA_FALSE;
512 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
514 e_comp_object_map_update(ec->frame);
516 cdata = ec->comp_data;
517 vp = &cdata->scaler.buffer_viewport;
518 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
519 (!cdata->viewport_transform))
522 if (e_comp_wl_subsurface_check(ec))
524 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
526 sdata = ec->comp_data->sub.data;
527 if (sdata->remote_surface.offscreen_parent)
529 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
530 Eina_Rectangle *rect;
533 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
535 /* TODO: If there are one more regions, it means that provider's offscreen
536 * is displayed by one more remote_surfaces. Have to consider it later. At
537 * this time, just consider only one remote_surface.
551 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
552 if (x != dx || y != dy)
553 evas_object_move(ec->frame, dx, dy);
555 if (!cdata->viewport_transform)
557 cdata->viewport_transform = e_util_transform_new();
558 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
559 e_client_transform_core_add(ec, cdata->viewport_transform);
562 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
563 ec->comp_data->width_from_viewport,
564 ec->comp_data->height_from_viewport);
566 if (vp->buffer.src_width == wl_fixed_from_int(-1))
570 x2 = cdata->width_from_buffer;
571 y2 = cdata->height_from_buffer;
575 x1 = wl_fixed_to_int(vp->buffer.src_x);
576 y1 = wl_fixed_to_int(vp->buffer.src_y);
577 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
578 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
581 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
582 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
583 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
584 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
587 desk = e_comp_desk_find_by_ec(ec);
589 zoom_animating = e_desk_zoom_is_animating(desk);
591 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
592 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
593 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
595 /* workaround:: when the desk zoom is doing their animation,
596 the transform core update can override animation's zoom boundary.
597 so, don't doing transform core update while desk zoom animation */
599 e_client_transform_core_update(ec);
604 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
608 int map_c = 0, map_x = 0, map_y = 0;
609 double inv_x = 0.0, inv_y = 0.0;
611 EINA_SAFETY_ON_NULL_RETURN(ec);
613 map = e_client_map_get(ec);
614 map_c = e_map_count_get(map);
616 if (!map || map_c <= 0)
626 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
627 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
628 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
629 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
631 for (int i = 0; i < map_c; i++)
633 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
634 e_map_point_image_uv_set(map2, i, map_x, map_y);
636 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
646 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
652 if (!(ec = data)) return;
653 if (e_object_is_del(data)) return;
655 if (!ec->override) e_hints_window_visible_set(ec);
657 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
658 (!ec->comp_data->need_reparent))
660 ec->comp_data->need_reparent = EINA_TRUE;
661 ec->visible = EINA_TRUE;
663 if (!e_client_util_ignored_get(ec))
665 ec->take_focus = !starting;
669 if (!ec->comp_data->need_reparent)
671 if ((ec->hidden) || (ec->iconic))
673 evas_object_hide(ec->frame);
674 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
677 evas_object_show(ec->frame);
680 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
681 evas_object_show(tmp->frame);
683 topmost = e_comp_wl_topmost_parent_get(ec);
684 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
685 e_comp_wl_subsurface_show(ec);
687 if (ec->comp_data->sub.below_obj)
688 evas_object_show(ec->comp_data->sub.below_obj);
692 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
698 if (!(ec = data)) return;
699 if (e_object_is_del(E_OBJECT(ec))) return;
701 /* Uncommonly some clients's final buffer can be skipped if the client
702 * requests unmap of its surface right after wl_surface@commit.
703 * So if this client evas object is hidden state and client is already
704 * unmmapped, we can consider to clear pixmap image here mandatorily.
706 if (!ec->comp_data->mapped)
707 e_pixmap_image_clear(ec->pixmap, 1);
709 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
710 evas_object_hide(tmp->frame);
712 topmost = e_comp_wl_topmost_parent_get(ec);
713 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
714 e_comp_wl_subsurface_hide(ec);
716 if (ec->comp_data->sub.below_obj)
717 evas_object_hide(ec->comp_data->sub.below_obj);
719 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
723 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
730 if (!(ec = data)) return;
731 if (e_object_is_del(E_OBJECT(ec))) return;
733 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
735 if (!e_comp_wl_subsurface_check(subc)) continue;
736 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
737 evas_object_move(subc->frame, x, y);
739 if (subc->comp_data->scaler.viewport)
741 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
742 if (cdata->viewport_transform)
743 e_comp_wl_map_apply(subc);
747 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
749 if (!e_comp_wl_subsurface_check(subc)) continue;
750 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
751 evas_object_move(subc->frame, x, y);
753 if (subc->comp_data->scaler.viewport)
755 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
756 if (cdata->viewport_transform)
757 e_comp_wl_map_apply(subc);
761 if (ec->comp_data->sub.below_obj)
763 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
764 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
769 _e_comp_wl_send_touch_cancel(E_Client *ec)
772 struct wl_resource *res;
773 struct wl_client *wc;
774 E_Comp_Config *comp_conf = NULL;
777 if (e_object_is_del(E_OBJECT(ec))) return;
778 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
780 if (!surface) return;
781 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
783 wc = wl_resource_get_client(surface);
785 comp_conf = e_comp_config_get();
787 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
789 if (wl_resource_get_client(res) != wc) continue;
790 if (!e_comp_wl_input_touch_check(res)) continue;
792 if (comp_conf && comp_conf->input_log_enable)
793 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
795 wl_touch_send_cancel(res);
800 _e_comp_wl_touch_cancel(void)
804 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
806 if (!e_comp_wl->touch.pressed) return;
808 _e_comp_wl_send_touch_cancel(ec);
811 static E_Devicemgr_Input_Device *
812 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
814 E_Devicemgr_Input_Device *last_kbd = NULL;
817 case ECORE_DEVICE_CLASS_MOUSE:
818 return e_devicemgr->last_device_ptr;
819 case ECORE_DEVICE_CLASS_KEYBOARD:
820 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
822 case ECORE_DEVICE_CLASS_TOUCH:
823 return e_devicemgr->last_device_touch;
831 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
835 case ECORE_DEVICE_CLASS_MOUSE:
836 e_devicemgr->last_device_ptr = device;
838 case ECORE_DEVICE_CLASS_KEYBOARD:
839 atomic_store(&e_devicemgr->last_device_kbd, device);
841 case ECORE_DEVICE_CLASS_TOUCH:
842 e_devicemgr->last_device_touch = device;
849 static E_Devicemgr_Input_Device *
850 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
852 E_Devicemgr_Input_Device *last_kbd = NULL;
856 case ECORE_DEVICE_CLASS_MOUSE:
857 return ec->comp_data->last_device_ptr;
858 case ECORE_DEVICE_CLASS_KEYBOARD:
859 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
861 case ECORE_DEVICE_CLASS_TOUCH:
862 return ec->comp_data->last_device_touch;
870 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
874 case ECORE_DEVICE_CLASS_MOUSE:
875 ec->comp_data->last_device_ptr = device;
877 case ECORE_DEVICE_CLASS_KEYBOARD:
878 atomic_store(&ec->comp_data->last_device_kbd, device);
880 case ECORE_DEVICE_CLASS_TOUCH:
881 ec->comp_data->last_device_touch = device;
889 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
891 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
892 struct wl_resource *dev_res;
893 const char *dev_name;
894 Ecore_Device_Class dev_class;
895 struct wl_client *wc;
899 EINA_SAFETY_ON_NULL_RETURN(dev);
902 if (ec->cur_mouse_action || e_comp_wl->drag)
904 if (e_object_is_del(E_OBJECT(ec))) return;
905 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
906 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
907 if (!surface) return;
909 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
910 dev_name = evas_device_description_get(dev);
911 last_device = _e_comp_wl_device_last_device_get(dev_class);
912 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
914 serial = wl_display_next_serial(e_comp_wl->wl.disp);
915 wc = wl_resource_get_client(surface);
916 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
917 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
919 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
920 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
922 _e_comp_wl_device_last_device_set(dev_class, input_dev);
923 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
925 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
927 if (wl_resource_get_client(dev_res) != wc) continue;
928 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
932 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
936 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
938 E_Devicemgr_Input_Device *last_device;
939 struct wl_resource *dev_res;
940 struct wl_client *wc;
944 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
945 if (!surface) return;
947 last_device = _e_comp_wl_device_last_device_get(dev_class);
948 if (!last_device) return;
950 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
952 serial = wl_display_next_serial(e_comp_wl->wl.disp);
953 wc = wl_resource_get_client(surface);
954 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
956 if (wl_resource_get_client(dev_res) != wc) continue;
957 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
962 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
964 E_Devicemgr_Input_Device *input_dev;
965 struct wl_resource *dev_res;
966 const char *dev_name;
969 EINA_SAFETY_ON_NULL_RETURN(dev);
971 dev_name = ecore_device_identifier_get(dev);
973 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
974 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
976 if (!eina_streq(input_dev->identifier, dev_name) ||
977 (input_dev->clas != ecore_device_class_get(dev))) continue;
978 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
980 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
982 if (wl_resource_get_client(dev_res) != wc) continue;
983 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
986 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
990 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
992 E_Devicemgr_Input_Device *input_dev;
993 struct wl_resource *dev_res;
994 const char *dev_name;
997 EINA_SAFETY_ON_NULL_RETURN(dev);
999 dev_name = e_device_identifier_get(dev);
1001 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1002 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1004 if (!eina_streq(input_dev->identifier, dev_name) ||
1005 (input_dev->clas != e_device_class_get(dev))) continue;
1006 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1008 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1010 if (wl_resource_get_client(dev_res) != wc) continue;
1011 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1014 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1018 _e_comp_wl_cursor_reload(E_Client *ec)
1020 struct wl_resource *res;
1021 struct wl_client *wc;
1027 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1028 !evas_object_visible_get(e_comp->pointer->o_ptr))
1029 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1032 if (e_object_is_del(E_OBJECT(ec))) return;
1033 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1034 if (!surface) return;
1035 if (ec->pointer_enter_sent) return;
1037 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1038 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1040 if (e_client_transform_core_enable_get(ec))
1042 double dx = 0.0, dy = 0.0;
1043 map = e_client_map_get(ec);
1044 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1050 cx = px - ec->client.x;
1051 cy = py - ec->client.y;
1053 wc = wl_resource_get_client(surface);
1054 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1055 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1057 if (!e_comp_wl_input_pointer_check(res)) continue;
1058 if (wl_resource_get_client(res) != wc) continue;
1059 wl_pointer_send_enter(res, serial, surface,
1060 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1061 ec->pointer_enter_sent = EINA_TRUE;
1063 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1067 _e_comp_wl_cursor_timer(void *data)
1069 E_Client *ec = data;
1071 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1072 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1074 e_comp_wl_cursor_hide(ec);
1076 return ECORE_CALLBACK_CANCEL;
1080 _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)
1082 E_Devicemgr_Input_Device *input_dev;
1083 struct wl_resource *dev_res;
1084 struct wl_client *wc;
1089 if (ec->cur_mouse_action) return;
1090 if (e_object_is_del(E_OBJECT(ec))) return;
1091 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1092 if (!surface) return;
1094 f_value = wl_fixed_from_double(value);
1095 wc = wl_resource_get_client(surface);
1097 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1098 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1100 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1101 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1103 if (wl_resource_get_client(dev_res) != wc) continue;
1104 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1107 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1111 _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)
1113 if (idx >= e_input_touch_max_count_get()) return;
1115 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1116 e_devicemgr->multi[idx].radius_x = radius_x;
1117 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1118 e_devicemgr->multi[idx].radius_y = radius_y;
1119 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1120 e_devicemgr->multi[idx].pressure = pressure;
1121 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1122 e_devicemgr->multi[idx].angle = angle;
1126 _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)
1128 if (idx >= e_input_touch_max_count_get()) return;
1130 if (e_devicemgr->multi[idx].radius_x != radius_x)
1132 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1133 e_devicemgr->multi[idx].radius_x = radius_x;
1135 if (e_devicemgr->multi[idx].radius_y != radius_y)
1137 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1138 e_devicemgr->multi[idx].radius_y = radius_y;
1140 if (e_devicemgr->multi[idx].pressure != pressure)
1142 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1143 e_devicemgr->multi[idx].pressure = pressure;
1145 if (e_devicemgr->multi[idx].angle != angle)
1147 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1148 e_devicemgr->multi[idx].angle = angle;
1153 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1155 Eina_Bool ret = EINA_TRUE;
1158 case EVAS_CALLBACK_MOUSE_IN:
1159 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1162 if (e_comp_wl->ptr.hide_tmr)
1164 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1165 cursor_timer_ec = ec;
1166 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1170 if (e_pointer_is_hidden(e_comp->pointer))
1175 case EVAS_CALLBACK_MOUSE_OUT:
1176 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1179 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1183 case EVAS_CALLBACK_MOUSE_MOVE:
1184 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1187 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1188 _e_comp_wl_cursor_reload(ec);
1191 case EVAS_CALLBACK_MOUSE_WHEEL:
1192 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1195 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1196 _e_comp_wl_cursor_reload(ec);
1199 case EVAS_CALLBACK_MOUSE_DOWN:
1200 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1203 if (e_comp_wl->ptr.hide_tmr)
1205 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1206 e_comp_wl->ptr.hide_tmr = NULL;
1208 cursor_timer_ec = NULL;
1210 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1211 _e_comp_wl_cursor_reload(ec);
1214 case EVAS_CALLBACK_MOUSE_UP:
1215 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1226 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1228 if (ec->has_cursor_unset)
1231 if (!e_config->show_cursor)
1234 if (!e_config->use_cursor_timer)
1241 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1244 Evas_Event_Mouse_In *ev;
1245 struct wl_resource *res;
1246 struct wl_client *wc;
1249 E_Comp_Config *comp_conf;
1250 E_Client *prev_ptr_ec;
1254 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1255 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1257 if (!(ec = data)) return;
1258 if (e_object_is_del(E_OBJECT(ec))) return;
1259 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1260 if (!surface) return;
1262 prev_ptr_ec = e_comp_wl->ptr.ec;
1265 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1266 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1269 e_comp_wl->ptr.ec = ec;
1271 comp_conf = e_comp_config_get();
1272 if (comp_conf && comp_conf->input_log_enable)
1273 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1274 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1275 e_client_util_name_get(ec));
1277 if (_e_comp_wl_check_cursor_timer_needed(ec))
1279 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1283 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1284 wc = wl_resource_get_client(surface);
1285 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1286 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1288 if (!e_comp_wl_input_pointer_check(res)) continue;
1289 if (wl_resource_get_client(res) != wc) continue;
1291 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1293 wl_pointer_send_enter(res, serial, surface,
1294 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1295 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1296 ec->pointer_enter_sent = EINA_TRUE;
1299 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1303 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1306 Evas_Event_Mouse_Out *ev;
1307 struct wl_resource *res;
1308 struct wl_client *wc;
1311 Eina_Bool inside_check;
1312 E_Comp_Config *comp_conf;
1316 if (!(ec = data)) return;
1317 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1318 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1319 if (ec->cur_mouse_action && inside_check) return;
1320 if (e_object_is_del(E_OBJECT(e_comp))) return;
1321 if (e_comp_wl->ptr.ec == ec)
1322 e_comp_wl->ptr.ec = NULL;
1323 if (e_object_is_del(E_OBJECT(ec))) return;
1325 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1326 if (!surface) return;
1328 comp_conf = e_comp_config_get();
1329 if (comp_conf && comp_conf->input_log_enable)
1330 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1331 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1332 e_client_util_name_get(ec));
1334 if (_e_comp_wl_check_cursor_timer_needed(ec))
1336 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1340 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1342 wc = wl_resource_get_client(surface);
1343 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1344 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1346 if (!e_comp_wl_input_pointer_check(res)) continue;
1347 if (wl_resource_get_client(res) != wc) continue;
1348 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1350 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1352 wl_pointer_send_leave(res, serial, surface);
1353 ec->pointer_enter_sent = EINA_FALSE;
1358 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1361 struct wl_client *wc;
1362 struct wl_resource *res;
1365 E_Comp_Config *comp_conf = NULL;
1368 if (e_object_is_del(E_OBJECT(ec))) return;
1369 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1370 if (!surface) return;
1372 wc = wl_resource_get_client(surface);
1373 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1377 x = wl_fixed_from_int(canvas_x - ec->client.x);
1378 y = wl_fixed_from_int(canvas_y - ec->client.y);
1381 comp_conf = e_comp_config_get();
1383 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1385 if (wl_resource_get_client(res) != wc) continue;
1386 if (!e_comp_wl_input_touch_check(res)) continue;
1387 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1390 if (comp_conf && comp_conf->input_log_enable)
1391 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));
1393 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1397 if (comp_conf && comp_conf->input_log_enable)
1398 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));
1400 wl_touch_send_up(res, serial, timestamp, idx);
1407 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1410 struct wl_client *wc;
1411 struct wl_resource *res;
1415 if (ec->cur_mouse_action) return;
1416 if (e_object_is_del(E_OBJECT(ec))) return;
1417 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1418 if (!surface) return;
1420 wc = wl_resource_get_client(surface);
1422 x = wl_fixed_from_int(canvas_x - ec->client.x);
1423 y = wl_fixed_from_int(canvas_y - ec->client.y);
1425 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1427 if (wl_resource_get_client(res) != wc) continue;
1428 if (!e_comp_wl_input_touch_check(res)) continue;
1429 wl_touch_send_motion(res, timestamp, idx, x, y);
1434 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1436 struct wl_resource *res;
1437 struct wl_client *wc;
1441 if (ec->cur_mouse_action) return;
1442 if (e_object_is_del(E_OBJECT(ec))) return;
1443 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1444 if (!surface) return;
1446 wc = wl_resource_get_client(surface);
1447 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1449 if (!e_comp_wl_input_pointer_check(res)) continue;
1450 if (wl_resource_get_client(res) != wc) continue;
1451 wl_pointer_send_motion(res, timestamp,
1452 wl_fixed_from_int(x - ec->client.x),
1453 wl_fixed_from_int(y - ec->client.y));
1458 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1460 if (e_comp_wl->ptr.hide_tmr)
1462 if (cursor_timer_ec == ec)
1464 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1465 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1469 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1470 cursor_timer_ec = ec;
1471 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1476 cursor_timer_ec = ec;
1477 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1482 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1485 Evas_Event_Mouse_Move *ev;
1486 Evas_Device *dev = NULL;
1487 const char *dev_name;
1488 E_Comp_Config *comp_conf;
1492 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1493 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1495 if (!(ec = data)) return;
1496 if (e_object_is_del(E_OBJECT(ec))) return;
1497 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1498 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1499 if (!surface) return;
1501 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1504 dev_name = evas_device_description_get(dev);
1506 comp_conf = e_comp_config_get();
1507 if (comp_conf && comp_conf->input_log_enable)
1508 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1509 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1510 e_client_util_name_get(ec), dev_name);
1512 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1514 if (!e_comp_wl->drag_client)
1516 e_comp_wl->touch.faked_ec = ec;
1517 if (e_comp_wl->touch.pressed & (1 << 0))
1519 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1521 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1522 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1523 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1527 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1531 if (!e_comp_wl->drag_client)
1533 if (_e_comp_wl_check_cursor_timer_needed(ec))
1535 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1539 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1540 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1542 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1544 if (_e_comp_wl_check_cursor_timer_needed(ec))
1545 _e_comp_wl_cursor_move_timer_control(ec);
1549 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1554 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1556 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1557 if (e_object_is_del(E_OBJECT(ec))) return;
1558 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1559 if (!surface) return;
1560 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1562 e_comp_wl->ptr.button = BTN_LEFT;
1564 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1568 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1570 E_Client *ec = data;
1571 Evas_Event_Mouse_Down *ev = event;
1572 Evas_Device *dev = NULL;
1573 const Evas_Device *seat_dev;
1574 const char *dev_name, *seat_name;
1575 E_Comp_Config *comp_conf = NULL;
1578 if (e_object_is_del(E_OBJECT(ec))) return;
1581 dev_name = evas_device_description_get(dev);
1583 seat_dev = evas_device_parent_get(dev);
1584 seat_name = evas_device_name_get(seat_dev);
1586 comp_conf = e_comp_config_get();
1587 if (comp_conf && comp_conf->input_log_enable)
1588 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1589 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1590 dev_name, seat_name);
1592 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1594 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1596 e_comp_wl->touch.faked_ec = ec;
1599 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1600 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1601 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1603 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1604 e_comp_wl->touch.pressed |= (1 << 0);
1608 if (_e_comp_wl_check_cursor_timer_needed(ec))
1610 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1614 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1615 WL_POINTER_BUTTON_STATE_PRESSED);
1617 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1620 need_send_released = EINA_TRUE;
1624 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1626 E_Client *ec = data;
1627 Evas_Event_Mouse_Up *ev = event;
1628 Evas_Device *dev = NULL;
1629 const Evas_Device *seat_dev;
1630 const char *dev_name, *seat_name;;
1631 Evas_Event_Flags flags;
1632 E_Comp_Config *comp_conf = NULL;
1635 if (ec->cur_mouse_action) return;
1636 if (e_object_is_del(E_OBJECT(ec))) return;
1638 if (!need_send_released)
1640 need_send_motion = EINA_TRUE;
1644 dev_name = evas_device_description_get(dev);
1646 seat_dev = evas_device_parent_get(dev);
1647 seat_name = evas_device_name_get(seat_dev);
1648 flags = evas_event_default_flags_get(evas);
1650 comp_conf = e_comp_config_get();
1651 if (comp_conf && comp_conf->input_log_enable)
1652 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1653 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1654 dev_name, seat_name);
1656 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1658 e_comp_wl->touch.pressed &= ~(1 << 0);
1660 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1661 e_comp_wl->touch.faked_ec = NULL;
1664 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1666 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1668 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1671 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1672 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1673 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1677 if (_e_comp_wl_check_cursor_timer_needed(ec))
1679 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1683 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1684 WL_POINTER_BUTTON_STATE_RELEASED);
1686 if (_e_comp_wl_check_cursor_timer_needed(ec))
1687 _e_comp_wl_cursor_move_timer_control(ec);
1691 need_send_released = EINA_FALSE;
1695 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1697 struct wl_resource *res;
1698 struct wl_client *wc;
1703 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1705 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1708 dir = -wl_fixed_from_int(abs(z));
1710 dir = wl_fixed_from_int(z);
1713 if (e_object_is_del(E_OBJECT(ec))) return;
1714 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1715 if (!surface) return;
1717 wc = wl_resource_get_client(surface);
1718 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1720 if (!e_comp_wl_input_pointer_check(res)) continue;
1721 if (wl_resource_get_client(res) != wc) continue;
1722 wl_pointer_send_axis(res, timestamp, axis, dir);
1727 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1730 Evas_Event_Mouse_Wheel *ev;
1733 if (!(ec = data)) return;
1734 if (ec->cur_mouse_action) return;
1735 if (e_object_is_del(E_OBJECT(ec))) return;
1736 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1737 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1738 if (!surface) return;
1740 if (!eina_list_count(e_comp_wl->ptr.resources))
1743 if (_e_comp_wl_check_cursor_timer_needed(ec))
1745 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1749 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1751 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1753 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1755 if (_e_comp_wl_check_cursor_timer_needed(ec))
1756 _e_comp_wl_cursor_move_timer_control(ec);
1761 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1763 E_Client *ec = data;
1764 Evas_Event_Multi_Down *ev = event;
1765 Evas_Device *dev = NULL;
1766 const Evas_Device *seat_dev;
1767 const char *dev_name, *seat_name;
1768 Evas_Device_Class dev_class;
1769 E_Comp_Config *comp_conf = NULL;
1772 if (e_object_is_del(E_OBJECT(ec))) return;
1773 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1774 if (!surface) return;
1776 /* Do not deliver emulated single touch events to client */
1777 if (ev->device == 0) return;
1780 dev_name = evas_device_description_get(dev);
1781 e_comp_wl->touch.faked_ec = ec;
1783 seat_dev = evas_device_parent_get(dev);
1784 seat_name = evas_device_name_get(seat_dev);
1786 comp_conf = e_comp_config_get();
1787 if (comp_conf && comp_conf->input_log_enable)
1788 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1789 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1790 dev_name, seat_name);
1792 if (dev && dev_name)
1794 dev_class = evas_device_class_get(dev);
1795 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1796 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1799 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1800 e_comp_wl->touch.pressed |= (1 << ev->device);
1804 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1806 E_Client *ec = data;
1807 Evas_Event_Multi_Up *ev = event;
1808 Evas_Device *dev = NULL;
1809 const Evas_Device *seat_dev;
1810 const char *dev_name, *seat_name;
1811 Evas_Device_Class dev_class;
1812 Evas_Event_Flags flags;
1813 E_Comp_Config *comp_conf = NULL;
1816 if (e_object_is_del(E_OBJECT(ec))) return;
1817 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1818 if (!surface) return;
1820 /* Do not deliver emulated single touch events to client */
1821 if (ev->device == 0) return;
1823 flags = evas_event_default_flags_get(evas);
1825 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1826 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1827 e_comp_wl->touch.faked_ec = NULL;
1829 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1832 dev_name = evas_device_description_get(dev);
1834 seat_dev = evas_device_parent_get(dev);
1835 seat_name = evas_device_name_get(seat_dev);
1837 comp_conf = e_comp_config_get();
1838 if (comp_conf && comp_conf->input_log_enable)
1839 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1840 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1841 dev_name, seat_name);
1843 if (dev && dev_name)
1845 dev_class = evas_device_class_get(dev);
1846 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1847 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1850 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1854 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1856 E_Client *ec = data;
1857 Evas_Event_Multi_Move *ev = event;
1858 Evas_Device *dev = NULL;
1859 const char *dev_name;
1860 Evas_Device_Class dev_class;
1863 if (e_object_is_del(E_OBJECT(ec))) return;
1864 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1865 if (!surface) return;
1867 /* Do not deliver emulated single touch events to client */
1868 if (ev->device == 0) return;
1870 e_comp_wl->touch.faked_ec = ec;
1872 if (e_comp_wl->touch.pressed & (1 << ev->device))
1875 if (dev && (dev_name = evas_device_description_get(dev)))
1877 dev_class = evas_device_class_get(dev);
1878 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1879 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1882 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1887 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1890 char *file, buff[PATH_MAX];
1897 n = (getpriority(PRIO_PROCESS, pid) + adj);
1901 setpriority(PRIO_PROCESS, pid, n);
1904 use_adj = EINA_TRUE;
1906 if (!do_child) return;
1908 files = ecore_file_ls("/proc");
1909 EINA_LIST_FREE(files, file)
1911 if (!isdigit(file[0]))
1914 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1915 if ((f = fopen(buff, "r")))
1919 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1921 if (num_read == 2 && ppid == pid)
1922 _e_comp_wl_client_priority_adjust(pid2, set,
1924 adj_child, do_child);
1932 _e_comp_wl_client_priority_raise(E_Client *ec)
1934 if (!e_config->priority_control) return;
1935 if (ec->netwm.pid <= 0) return;
1936 if (ec->netwm.pid == getpid()) return;
1937 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1938 e_config->priority - 1, -1,
1939 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1943 _e_comp_wl_client_priority_normal(E_Client *ec)
1945 if (!e_config->priority_control) return;
1946 if (ec->netwm.pid <= 0) return;
1947 if (ec->netwm.pid == getpid()) return;
1948 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1949 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1953 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1956 E_Comp_Wl_Key_Data *k;
1957 struct wl_resource *res;
1961 if (!ec) return EINA_FALSE;
1962 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1963 if (!ec->comp_data) return EINA_FALSE;
1965 ec->comp_data->on_focus_timer = NULL;
1966 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1967 if (!e_comp_wl->kbd.focused)
1969 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1972 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1974 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1975 t = ecore_time_unix_get();
1977 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1978 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1979 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1981 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1983 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1984 wl_keyboard_send_key(res, serial, t,
1985 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1988 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1989 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1993 /* It is called in the following cases:
1994 * When a normal ec->frame has focus.
1995 * Or launching image ec is replaced to the real ec.
1998 e_comp_wl_feed_focus_in(E_Client *ec)
2001 struct wl_resource *res;
2002 struct wl_client *wc;
2006 if (e_object_is_del(E_OBJECT(ec))) return;
2007 if (ec->iconic) return;
2009 /* block spurious focus events */
2010 focused = e_client_focused_get();
2011 if ((focused) && (ec != focused)) return;
2013 /* raise client priority */
2014 _e_comp_wl_client_priority_raise(ec);
2015 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2016 if (!surface) return;
2018 wc = wl_resource_get_client(surface);
2020 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2021 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2023 if (wl_resource_get_client(res) == wc)
2025 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2026 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2027 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2028 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2031 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2033 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2034 if (!e_comp_wl->kbd.focused)
2036 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2039 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2041 e_comp_wl->kbd.focus = surface;
2042 e_comp_wl_input_keyboard_enter_send(ec);
2043 e_comp_wl_data_device_keyboard_focus_set();
2044 ec->comp_data->on_focus_timer =
2045 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2046 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2047 int rotation = ec->e.state.rot.ang.curr;
2048 e_pointer_rotation_set(e_comp->pointer, rotation);
2052 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2055 if (!(ec = data)) return;
2056 e_comp_wl_feed_focus_in(ec);
2060 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2063 struct wl_resource *res;
2065 E_Comp_Wl_Key_Data *k;
2069 if (!(ec = data)) return;
2071 if (!ec->comp_data) return;
2073 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2075 /* lower client priority */
2076 if (!e_object_is_del(data))
2077 _e_comp_wl_client_priority_normal(ec);
2080 /* update keyboard modifier state */
2081 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2082 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2083 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2085 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2087 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2088 if (!surface) return;
2090 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2091 if (!eina_list_count(e_comp_wl->kbd.resources))
2093 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2097 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2099 /* send keyboard_leave to all keyboard resources */
2100 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2101 t = ecore_time_unix_get();
2103 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2104 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2105 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2107 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2109 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2110 wl_keyboard_send_key(res, serial, t,
2111 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2113 wl_keyboard_send_leave(res, serial, surface);
2114 e_comp_wl->kbd.focused =
2115 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2117 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2118 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2122 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2126 if (!(ec = data)) return;
2128 if (!ec->comp_data->shell.configure_send) return;
2130 /* TODO: calculate x, y with transfrom object */
2131 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2135 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2136 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2137 if (e_comp_object_frame_exists(ec->frame))
2138 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2140 switch (ec->resize_mode)
2142 case E_POINTER_RESIZE_TL:
2143 case E_POINTER_RESIZE_L:
2144 case E_POINTER_RESIZE_BL:
2145 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2146 ec->mouse.current.mx;
2148 case E_POINTER_RESIZE_TR:
2149 case E_POINTER_RESIZE_R:
2150 case E_POINTER_RESIZE_BR:
2151 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2156 switch (ec->resize_mode)
2158 case E_POINTER_RESIZE_TL:
2159 case E_POINTER_RESIZE_T:
2160 case E_POINTER_RESIZE_TR:
2161 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2162 ec->mouse.current.my;
2164 case E_POINTER_RESIZE_BL:
2165 case E_POINTER_RESIZE_B:
2166 case E_POINTER_RESIZE_BR:
2167 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2172 w = E_CLAMP(w, 1, w);
2173 h = E_CLAMP(h, 1, h);
2174 e_client_resize_limit(ec, &w, &h);
2176 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2178 else if ((!ec->fullscreen) && (!ec->maximized) &&
2179 (!ec->comp_data->maximize_pre))
2183 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2184 if ((pw != ec->w) || (ph != ec->h))
2186 _e_comp_wl_configure_send(ec, 1, 1);
2190 if (ec->comp_data->sub.below_obj)
2191 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2195 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2197 E_Client *ec = data;
2199 ec->comp_data->maximize_pre = 1;
2203 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2205 E_Client *ec = data;
2208 if (e_object_is_del(E_OBJECT(ec))) return;
2210 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2211 e_client_shell_configure_send(ec, 0, w, h);
2213 ec->comp_data->maximize_pre = 0;
2217 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2219 E_Client *ec = data;
2221 ec->comp_data->maximize_pre = 1;
2225 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2227 E_Client *ec = data;
2229 if (e_object_is_del(E_OBJECT(ec))) return;
2231 /* check for wayland pixmap */
2233 if (ec->comp_data->shell.configure_send)
2234 _e_comp_wl_configure_send(ec, 0, 0);
2236 ec->comp_data->maximize_pre = 0;
2240 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2242 E_Client *ec = data;
2244 if (e_object_is_del(E_OBJECT(ec))) return;
2246 /* check for wayland pixmap */
2248 if (ec->comp_data->shell.configure_send)
2249 _e_comp_wl_configure_send(ec, 0, 1);
2251 ec->comp_data->maximize_pre = 0;
2255 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2257 E_Client *ec = data;
2259 if (e_object_is_del(E_OBJECT(ec))) return;
2261 /* check for wayland pixmap */
2263 if (ec->comp_data->shell.configure_send)
2264 _e_comp_wl_configure_send(ec, 0, 0);
2266 ec->comp_data->maximize_pre = 0;
2270 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2274 if (!(ec = data)) return;
2276 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2278 e_object_del(E_OBJECT(ec));
2280 _e_comp_wl_focus_check();
2282 /* TODO: Delete request send ??
2283 * NB: No such animal wrt wayland */
2287 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2291 if (!(ec = data)) return;
2293 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2296 if (ec->comp_data->reparented)
2297 e_client_comp_hidden_set(ec, EINA_TRUE);
2300 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2301 if (ec->visible) evas_object_hide(ec->frame);
2302 if (!ec->internal) e_object_del(E_OBJECT(ec));
2304 _e_comp_wl_focus_check();
2308 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2312 if (!(ec = data)) return;
2314 e_client_shell_ping(ec);
2318 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2323 if (!(ec = data)) return;
2324 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2325 if (ec->netwm.opacity == a) return;
2326 ec->netwm.opacity = a;
2327 ec->netwm.opacity_changed = EINA_TRUE;
2331 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2333 Eina_Rectangle *damage_rect = NULL;
2334 Eina_Rectangle *dmg = NULL;
2335 Eina_List *l = NULL;
2337 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2338 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2341 if (!buffer->tbm_surface) return;
2345 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2349 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2350 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2353 eina_rectangle_union(damage_rect, dmg);
2358 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2359 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2362 tbm_surface_internal_set_damage(buffer->tbm_surface,
2368 eina_rectangle_free(damage_rect);
2372 _e_comp_wl_client_evas_init(E_Client *ec)
2374 if (!ec || !ec->comp_data) return;
2375 if (ec->comp_data->evas_init) return;
2377 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2378 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2379 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2382 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2383 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2384 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2385 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2386 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2387 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2389 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2390 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2391 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2393 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2398 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2399 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2400 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2401 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2402 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2403 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2404 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2407 /* setup delete/kill callbacks */
2408 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2409 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2411 /* setup ping callback */
2412 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2413 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2415 ec->comp_data->evas_init = EINA_TRUE;
2419 _e_comp_wl_client_evas_deinit(E_Client *ec)
2421 if (!ec || !ec->comp_data) return;
2422 if (!ec->comp_data->evas_init) return;
2424 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2425 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2426 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2428 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2429 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2430 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2431 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2432 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2433 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2436 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2444 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2445 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2446 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2447 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2448 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2449 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2450 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2453 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2454 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2456 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2457 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2459 ec->comp_data->evas_init = EINA_FALSE;
2463 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2467 E_Comp_Screen *e_comp_screen;
2468 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2470 if (!e_comp) return ECORE_CALLBACK_RENEW;
2471 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2472 e_comp_screen = e_comp->e_comp_screen;
2474 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2476 if (!eout->config.enabled)
2478 e_comp_wl_output_remove(eout->id);
2482 switch (eout->config.rotation)
2485 transform = WL_OUTPUT_TRANSFORM_90;
2488 transform = WL_OUTPUT_TRANSFORM_180;
2491 transform = WL_OUTPUT_TRANSFORM_270;
2495 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2499 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2501 eout->config.geom.x, eout->config.geom.y,
2502 eout->config.geom.w, eout->config.geom.h,
2503 eout->info.size.w, eout->info.size.h,
2504 eout->config.mode.refresh, 0, transform))
2505 ERR("Could not initialize screen %s", eout->info.name);
2508 return ECORE_CALLBACK_RENEW;
2512 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2516 /* try to get the client from the object */
2517 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2518 return ECORE_CALLBACK_RENEW;
2520 /* check for client being deleted */
2521 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2523 /* check for wayland pixmap */
2524 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2525 return ECORE_CALLBACK_RENEW;
2527 /* if we have not setup evas callbacks for this client, do it */
2528 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2530 return ECORE_CALLBACK_RENEW;
2534 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2538 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2539 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2541 if (e_comp_wl->selection.target &&
2544 struct wl_resource *res;
2546 E_Client *ec = NULL;
2547 E_Client *legacy_target = e_comp_wl->selection.target;
2548 int device_id = e_comp_wl_data_current_device_id_get();
2552 e_comp_wl_data_current_device_id_set(ev->multi.device);
2554 else if (device_id != ev->multi.device)
2556 return ECORE_CALLBACK_RENEW;
2559 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2560 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2562 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2563 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2565 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2566 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2568 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2569 (ec != legacy_target))
2571 e_comp_wl_data_device_send_leave(legacy_target);
2572 e_comp_wl_data_device_send_enter(ec);
2575 if (e_comp_wl->drag)
2576 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2578 if (e_client_transform_core_enable_get(ec))
2580 int trans_x, trans_y;
2581 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2582 x = trans_x - ec->client.x;
2583 y = trans_y - ec->client.y;
2587 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2592 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2595 return ECORE_CALLBACK_RENEW;
2599 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2602 struct wl_resource *surface;
2603 struct wl_resource *res;
2604 struct wl_client *wc;
2606 E_Comp_Config *comp_conf;
2608 ec = e_comp_wl->ptr_constraints.ec;
2609 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2611 surface = e_comp_wl_client_surface_get(ec);
2612 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2614 wc = wl_resource_get_client(surface);
2616 comp_conf = e_comp_config_get();
2618 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2620 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2621 if (wl_resource_get_client(res) != wc) continue;
2623 if (comp_conf && comp_conf->input_log_enable)
2624 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2625 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2626 e_client_util_name_get(ec));
2628 zwp_relative_pointer_v1_send_relative_motion(res,
2630 (uint32_t)(ev->timestamp),
2631 wl_fixed_from_int(ev->dx),
2632 wl_fixed_from_int(ev->dy),
2633 wl_fixed_from_int(ev->dx_unaccel),
2634 wl_fixed_from_int(ev->dy_unaccel));
2637 return ECORE_CALLBACK_DONE;
2641 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2643 _e_comp_wl_touch_cancel();
2645 return ECORE_CALLBACK_PASS_ON;
2649 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2651 if (!ev) return ECORE_CALLBACK_PASS_ON;
2653 E_Zone *zone = ev->zone;
2655 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2656 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2658 if (!e_zone_is_displaying(zone))
2659 _e_comp_wl_touch_cancel();
2661 return ECORE_CALLBACK_PASS_ON;
2665 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2667 E_Client *ec = ev->ec;
2668 E_Comp_Wl_Buffer_Viewport *vp;
2670 if (!ec) return ECORE_CALLBACK_PASS_ON;
2671 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2672 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2673 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2674 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2676 vp = &ec->comp_data->scaler.buffer_viewport;
2677 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2679 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2681 return ECORE_CALLBACK_PASS_ON;
2685 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2687 E_Client *ec = ev->ec;
2688 E_Comp_Wl_Buffer_Viewport *vp;
2690 if (!ec) return ECORE_CALLBACK_PASS_ON;
2691 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2692 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2693 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2695 vp = &ec->comp_data->scaler.buffer_viewport;
2696 vp->wait_for_transform_change = 0;
2698 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2700 return ECORE_CALLBACK_PASS_ON;
2704 _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)
2706 E_Client *focused_ec;
2709 focused_ec = e_client_focused_get();
2710 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2712 rotation = focused_ec->e.state.rot.ang.curr;
2713 e_pointer_rotation_set(e_comp->pointer, rotation);
2715 return ECORE_CALLBACK_PASS_ON;
2719 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2722 Eina_Rectangle *window;
2727 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2729 if ((prev_w != state->bw) ||
2730 (prev_h != state->bh))
2732 ec->changes.buf_size = EINA_TRUE;
2735 if (e_comp_object_frame_exists(ec->frame)) return;
2736 window = &ec->comp_data->shell.window;
2737 if ((!ec->borderless) && /* FIXME temporarily added this check code
2738 * to prevent updating E_Client's size by frame */
2739 (window->x || window->y || window->w || window->h))
2741 e_comp_object_frame_geometry_set(ec->frame,
2743 (window->x + window->w) - state->bw,
2745 (window->y + window->h) - state->bh);
2748 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2752 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2754 E_Comp_Wl_Surface_State *state;
2757 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2758 state->buffer = NULL;
2762 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2764 state->new_attach = EINA_FALSE;
2765 state->buffer = NULL;
2766 state->buffer_destroy_listener.notify =
2767 _e_comp_wl_surface_state_cb_buffer_destroy;
2768 state->sx = state->sy = 0;
2770 state->input = eina_tiler_new(w, h);
2771 eina_tiler_tile_size_set(state->input, 1, 1);
2773 state->opaque = eina_tiler_new(w, h);
2774 eina_tiler_tile_size_set(state->opaque, 1, 1);
2776 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2777 state->buffer_viewport.buffer.scale = 1;
2778 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2779 state->buffer_viewport.surface.width = -1;
2780 state->buffer_viewport.changed = 0;
2782 e_presentation_time_container_init(&state->presentation_container);
2786 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2788 struct wl_resource *cb;
2789 Eina_Rectangle *dmg;
2791 EINA_LIST_FREE(state->frames, cb)
2792 wl_resource_destroy(cb);
2794 EINA_LIST_FREE(state->damages, dmg)
2795 eina_rectangle_free(dmg);
2797 EINA_LIST_FREE(state->buffer_damages, dmg)
2798 eina_rectangle_free(dmg);
2800 if (state->opaque) eina_tiler_free(state->opaque);
2801 state->opaque = NULL;
2803 if (state->input) eina_tiler_free(state->input);
2804 state->input = NULL;
2806 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2807 state->buffer = NULL;
2809 e_presentation_time_container_finish(&state->presentation_container);
2813 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2815 if (state->buffer == buffer) return;
2817 wl_list_remove(&state->buffer_destroy_listener.link);
2818 state->buffer = buffer;
2820 wl_signal_add(&state->buffer->destroy_signal,
2821 &state->buffer_destroy_listener);
2825 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2827 Eina_Rectangle *dmg;
2828 Eina_Bool placed = EINA_TRUE;
2832 E_Comp_Wl_Buffer *buffer;
2833 struct wl_resource *cb;
2835 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2836 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2841 if ((ec->internal) ||
2842 (cdata->shell.surface && state->new_attach))
2846 e_comp->new_clients++;
2847 ELOGF("COMP", "Unignore", ec);
2848 e_client_unignore(ec);
2852 /* buffer transform */
2853 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2856 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2858 /* when buffer is transformed, we have to apply the new evas-map */
2859 state->buffer_viewport.changed = EINA_TRUE;
2861 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2863 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2865 if (transform_change == vp->wait_for_transform_change)
2866 vp->wait_for_transform_change = 0;
2868 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2869 // triggered by E_CLIENT_HOOK calls at those file.
2870 zone = e_comp_zone_find_by_ec(ec);
2873 eout = e_output_find(zone->output_id);
2874 if (eout && eout->hwc)
2876 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2878 if (e_comp_is_on_overlay(ec))
2879 e_comp_hwc_client_end(ec, __FUNCTION__);
2885 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2886 cdata->scaler.buffer_viewport = state->buffer_viewport;
2888 if (state->new_attach)
2890 e_comp_wl_surface_attach(ec, state->buffer);
2893 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2894 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2896 _e_comp_wl_surface_state_buffer_set(state, NULL);
2898 if ((state->new_attach) ||
2899 (state->buffer_viewport.changed))
2901 _e_comp_wl_surface_state_size_update(ec, state);
2902 e_comp_wl_map_size_cal_from_viewport(ec);
2904 /* update the position */
2905 if (ec->changes.pos)
2907 e_comp_object_frame_xy_unadjust(ec->frame,
2917 if (ec->new_client) placed = ec->placed;
2919 if (!ec->lock_client_size)
2924 ec->client.w = state->bw;
2925 ec->client.h = state->bh;
2927 e_comp_object_frame_wh_adjust(ec->frame,
2928 ec->client.w, ec->client.h,
2930 e_client_size_set(ec, nw, nh);
2932 if ((w != ec->w) || (h != ec->h))
2934 ec->changes.size = 1;
2939 if (ec->changes.buf_size)
2941 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2942 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2943 ec->changes.buf_size = EINA_FALSE;
2945 if (ec->move_after_resize)
2947 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2948 ec->move_after_resize = EINA_FALSE;
2953 /* map or unmap ec */
2954 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2955 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2956 if (!pixmap_usable || hide_by_request)
2961 if (hide_by_request)
2962 ELOGF("COMP", "Currenlty hide_by_request state. pixmap_usable:%d", ec, pixmap_usable);
2964 if ((cdata->shell.surface) &&
2965 (cdata->shell.unmap))
2967 ELOGF("COMP", "Try to unmap. Call shell.unmap.", ec);
2968 if (ec->show_pending.count > 0)
2970 ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
2971 ec->show_pending.count = 0;
2972 if (ec->show_pending.running)
2974 // need to send visibility false;
2975 ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
2976 ELOGF("POL_VIS", "CLIENT VIS ON (fake). argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
2979 ec->show_pending.running = EINA_FALSE;
2981 e_client_shell_unmap(ec);
2983 else if ((ec->internal) ||
2984 (e_comp_wl_subsurface_check(ec)) ||
2985 (ec == e_comp_wl->drag_client))
2987 ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
2988 ec, ec->internal, cdata->sub.data, (ec == e_comp_wl->drag_client));
2989 ec->visible = EINA_FALSE;
2990 evas_object_hide(ec->frame);
2995 if ((cdata->sub.below_obj) &&
2996 (evas_object_visible_get(cdata->sub.below_obj)))
2998 evas_object_hide(cdata->sub.below_obj);
3006 if ((cdata->shell.surface) &&
3007 (cdata->shell.map) &&
3010 ELOGF("COMP", "Try to map. Call shell.map.", ec);
3011 e_client_shell_map(ec);
3013 else if ((ec->internal) ||
3014 (e_comp_wl_subsurface_can_show(ec)) ||
3015 (ec == e_comp_wl->drag_client))
3017 ELOGF("COMP", "Try to map. Show window. internal:%d, drag:%d",
3018 ec, ec->internal, (ec == e_comp_wl->drag_client));
3019 ec->visible = EINA_TRUE;
3021 evas_object_show(ec->frame);
3026 if ((cdata->sub.below_obj) &&
3027 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3028 (evas_object_visible_get(ec->frame)))
3030 evas_object_show(cdata->sub.below_obj);
3034 if ((state->new_attach) ||
3035 (state->buffer_viewport.changed))
3037 if ((e_comp_wl->drag) &&
3038 (e_comp_wl->drag_client) &&
3039 (e_comp_wl->drag_client == ec))
3041 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3043 e_drag_move(e_comp_wl->drag,
3045 e_comp_wl->drag->y);
3047 e_drag_resize(e_comp_wl->drag,
3048 state->bw, state->bh);
3050 else if ((cdata->shell.surface) &&
3051 (cdata->shell.configure))
3053 e_comp_wl_commit_sync_configure(ec);
3055 else if (!e_client_video_hw_composition_check(ec))
3057 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3062 ec->placed = placed;
3063 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3067 if (cdata->scaler.buffer_viewport.changed)
3068 e_comp_wl_map_apply(ec);
3070 /* resize transform object */
3071 if (ec->transformed)
3072 e_client_transform_update(ec);
3076 state->new_attach = EINA_FALSE;
3078 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3080 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3081 wl_resource_destroy(cb);
3084 /* insert state frame callbacks into comp_data->frames
3085 * NB: This clears state->frames list */
3086 cdata->frames = eina_list_merge(cdata->frames,
3088 state->frames = NULL;
3090 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3091 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3092 &state->presentation_container);
3094 buffer = e_pixmap_resource_get(ec->pixmap);
3096 /* put state damages into surface */
3099 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3100 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3102 if ((cdata->buffer_ref.buffer) &&
3103 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3104 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3106 e_comp_object_damage(ec->frame,
3108 cdata->buffer_ref.buffer->w,
3109 cdata->buffer_ref.buffer->h);
3114 Eina_List *damages = NULL;
3117 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3119 if (eina_list_count(state->buffer_damages))
3121 EINA_LIST_FREE(state->buffer_damages, dmg)
3124 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3125 e_comp_wl_output_buffer_transform_get(ec),
3127 dmg->x, dmg->y, dmg->w, dmg->h,
3128 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3129 damages = eina_list_append(damages, dmg);
3133 EINA_LIST_FREE(state->damages, dmg)
3134 damages = eina_list_append(damages, dmg);
3136 EINA_LIST_FREE(damages, dmg)
3138 /* not creating damage for ec that shows a underlay video */
3139 if (state->buffer_viewport.changed ||
3140 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3141 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3142 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3144 eina_rectangle_free(dmg);
3149 /* put state opaque into surface */
3150 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3153 Eina_Rectangle *rect;
3156 itr = eina_tiler_iterator_new(state->opaque);
3157 EINA_ITERATOR_FOREACH(itr, rect)
3161 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3162 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3163 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3167 eina_iterator_free(itr);
3170 /* put state input into surface */
3171 if ((state->input) &&
3172 (!eina_tiler_empty(state->input)) &&
3175 Eina_Tiler *src, *tmp;
3179 tmp = eina_tiler_new(sw, sh);
3180 eina_tiler_tile_size_set(tmp, 1, 1);
3182 eina_tiler_rect_add(tmp,
3183 &(Eina_Rectangle){0, 0, sw, sh});
3185 if ((src = eina_tiler_intersection(state->input, tmp)))
3187 Eina_Rectangle *rect;
3190 e_comp_object_input_objs_del(ec->frame);
3191 itr = eina_tiler_iterator_new(src);
3192 EINA_ITERATOR_FOREACH(itr, rect)
3194 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3195 ec, rect->x, rect->y, rect->w, rect->h,
3196 ec->w, ec->h, state->bw, state->bh);
3197 e_comp_object_input_area_set(ec->frame,
3202 eina_iterator_free(itr);
3203 eina_tiler_free(src);
3206 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3208 eina_tiler_free(tmp);
3210 /* clear input tiler */
3211 eina_tiler_clear(state->input);
3214 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3216 if ((cdata->video_client) &&
3218 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3219 (e_comp->wl_comp_data->available_hw_accel.underlay))
3221 e_pixmap_image_clear(ec->pixmap, 1);
3224 state->buffer_viewport.changed = 0;
3226 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3229 ec->exp_iconify.buffer_flush &&
3230 e_policy_visibility_client_is_iconic(ec))
3232 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3237 _e_comp_wl_surface_render_stop(E_Client *ec)
3239 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3240 //if ((!ec->internal) && (!e_comp_gl_get()))
3243 /* check if internal animation is running */
3244 if (e_comp_object_is_animating(ec->frame)) return;
3245 /* check if external animation is running */
3246 if (evas_object_data_get(ec->frame, "effect_running")) return;
3248 evas_object_hide(ec->frame);
3252 e_comp_wl_client_surface_finish(E_Client *ec)
3254 struct wl_resource *res, *surface;
3255 struct wl_client *surface_client = NULL;
3258 surface = e_comp_wl_client_surface_get(ec);
3261 surface_client = wl_resource_get_client(surface);
3263 if (surface_client &&
3264 (ec == e_client_focused_get()))
3266 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3267 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3269 if (wl_resource_get_client(res) ==
3271 e_comp_wl->kbd.focused =
3272 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3276 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3279 e_comp_wl_client_surface_set(ec, NULL);
3281 ec->comp_data->wl_surface = NULL;
3282 e_pixmap_win_id_del(ec->pixmap);
3284 _e_comp_wl_surface_render_stop(ec);
3285 e_object_del(E_OBJECT(ec));
3289 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3294 char proc[512], pname[512];
3297 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3299 h = fopen(proc, "r");
3302 len = fread(pname, sizeof(char), 512, h);
3304 pname[len - 1] = '\0';
3306 strncpy(pname, "NO NAME", sizeof(pname));
3312 strncpy(pname, "NO NAME", sizeof(pname));
3315 strncpy(name, pname, size);
3319 _e_comp_wl_pname_print(pid_t pid)
3322 char proc[512], pname[512];
3325 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3327 h = fopen(proc, "r");
3330 len = fread(pname, sizeof(char), 512, h);
3332 pname[len - 1] = '\0';
3334 strncpy(pname, "NO NAME", sizeof(pname));
3338 ELOGF("COMP", " |%s", NULL, pname);
3343 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3345 struct wl_client *client = data;
3346 E_Comp_Connected_Client_Info *cinfo;
3349 cinfo = wl_container_of(listener, cinfo, destroy);
3351 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3352 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3354 eai = e_appinfo_find_with_pid(cinfo->pid);
3355 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3358 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3360 wl_list_remove(&cinfo->destroy.link);
3361 eina_stringshare_del(cinfo->name);
3366 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3368 E_Comp_Connected_Client_Info *cinfo;
3370 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3371 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3373 cinfo->name = eina_stringshare_add(name);
3377 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3378 wl_client_add_destroy_listener(client, &cinfo->destroy);
3379 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3381 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3385 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3387 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3389 /* send configure */
3390 if (ec->comp_data->shell.configure_send)
3392 if (ec->comp_data->shell.surface)
3393 _e_comp_wl_configure_send(ec, 0, 0);
3396 e_comp_wl->kbd.focus = ec->comp_data->surface;
3400 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3402 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3404 /* send configure */
3405 if (ec->comp_data->shell.configure_send)
3407 if (ec->comp_data->shell.surface)
3408 _e_comp_wl_configure_send(ec, 0, 0);
3411 _e_comp_wl_focus_check();
3413 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3414 e_comp_wl->kbd.focus = NULL;
3418 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3420 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3421 if (ec->keyboard_resizing) return;
3423 /* do nothing currently */
3428 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3430 if (e_object_is_del(E_OBJECT(ec))) return;
3431 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3433 e_comp_wl->resize.edges = 0;
3434 e_comp_wl->resize.resource = NULL;
3438 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3440 if (e_object_is_del(E_OBJECT(ec))) return;
3441 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3445 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3448 int ratio_w, ratio_h;
3450 phys_w = output->phys_width;
3451 phys_h = output->phys_height;
3453 if (e_config->configured_output_resolution.use)
3455 // change the configured physical size(mm) of the output
3456 if (output->w != res_w)
3458 ratio_w = res_w / output->w;
3459 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3462 if (output->h != res_h)
3464 ratio_h = res_h / output->h;
3465 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3468 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3471 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3472 NULL, res_w, res_h, phys_w, phys_h, pid);
3474 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3475 wl_output_send_scale(resource, output->scale);
3477 wl_output_send_geometry(resource, output->x, output->y,
3479 output->subpixel, output->make ?: "",
3480 output->model ?: "", output->transform);
3482 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3483 res_w, res_h, output->refresh);
3485 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3486 wl_output_send_done(resource);
3490 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3492 E_Comp_Wl_Output *output;
3494 if (!(output = wl_resource_get_user_data(resource))) return;
3496 output->resources = eina_list_remove(output->resources, resource);
3500 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3502 E_Comp_Wl_Output *output;
3503 struct wl_resource *resource;
3504 E_Appinfo *eai = NULL;
3508 if (!(output = data)) return;
3511 wl_resource_create(client, &wl_output_interface, version, id);
3514 wl_client_post_no_memory(client);
3518 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3519 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3521 output->resources = eina_list_append(output->resources, resource);
3523 wl_resource_set_implementation(resource, NULL, output,
3524 _e_comp_wl_cb_output_unbind);
3525 wl_resource_set_user_data(resource, output);
3527 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3528 if (e_config->configured_output_resolution.use)
3530 wl_client_get_credentials(client, &pid, NULL, NULL);
3533 res_w = e_config->configured_output_resolution.w;
3534 res_h = e_config->configured_output_resolution.h;
3538 eai = e_appinfo_find_with_pid(pid);
3541 res_w = e_config->configured_output_resolution.w;
3542 res_h = e_config->configured_output_resolution.h;
3546 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3548 res_w = e_config->configured_output_resolution.w;
3549 res_h = e_config->configured_output_resolution.h;
3553 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3562 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3566 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3569 Evas_GL *evasgl = NULL;
3570 Evas_GL_API *glapi = NULL;
3571 Evas_GL_Context *ctx = NULL;
3572 Evas_GL_Surface *sfc = NULL;
3573 Evas_GL_Config *cfg = NULL;
3575 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3577 if (!e_comp_gl_get()) return;
3579 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3580 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3582 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3583 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3585 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3586 * then we should get evas from ecore_evas.
3589 evas = e_comp->evas;
3591 evas = ecore_evas_get(e_comp->ee);
3593 evasgl = evas_gl_new(evas);
3594 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3596 glapi = evas_gl_api_get(evasgl);
3597 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3598 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3600 cfg = evas_gl_config_new();
3601 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3603 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3604 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3606 ctx = evas_gl_context_create(evasgl, NULL);
3607 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3609 res = evas_gl_make_current(evasgl, sfc, ctx);
3610 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3612 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3613 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3615 evas_gl_config_free(cfg);
3617 evas_gl->gl = evasgl;
3618 evas_gl->glapi = glapi;
3619 evas_gl->glsfc = sfc;
3620 evas_gl->glctx = ctx;
3622 e_comp_wl->evas_gl = evas_gl;
3624 /* for native surface */
3627 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3632 evas_gl_config_free(cfg);
3633 evas_gl_make_current(evasgl, NULL, NULL);
3634 evas_gl_context_destroy(evasgl, ctx);
3635 evas_gl_surface_destroy(evasgl, sfc);
3636 evas_gl_free(evasgl);
3643 _e_comp_wl_gl_popup_cb_close(void *data,
3644 Evas_Object *obj EINA_UNUSED,
3645 void *event_info EINA_UNUSED)
3647 evas_object_del(data);
3651 _e_comp_wl_gl_popup_cb_focus(void *data,
3652 Evas_Object *obj EINA_UNUSED,
3653 void *event_info EINA_UNUSED)
3655 elm_object_focus_set(data, EINA_TRUE);
3660 _e_comp_wl_gl_idle(void *data)
3664 /* show warning window to notify failure of gl init */
3667 Evas_Object *win, *bg, *popup, *btn;
3669 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3670 elm_win_title_set(win, "Compositor Warning");
3671 elm_win_autodel_set(win, EINA_TRUE);
3672 elm_win_borderless_set(win, EINA_TRUE);
3673 elm_win_role_set(win, "notification-low");
3674 elm_win_alpha_set(win, EINA_TRUE);
3676 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3677 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3678 elm_win_resize_object_add(win, bg);
3679 evas_object_color_set(bg, 125, 125, 125, 125);
3680 evas_object_show(bg);
3682 popup = elm_popup_add(win);
3683 elm_object_text_set(popup,
3684 _( "Your screen does not support OpenGL.<br>"
3685 "Falling back to software engine."));
3686 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3688 btn = elm_button_add(popup);
3689 elm_object_text_set(btn, "Close");
3690 elm_object_part_content_set(popup, "button1", btn);
3691 evas_object_show(btn);
3693 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3694 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3696 evas_object_show(popup);
3697 evas_object_show(win);
3701 return ECORE_CALLBACK_CANCEL;
3705 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3707 struct wl_client *client = data;
3713 wl_client_get_credentials(client, &pid, &uid, &gid);
3715 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3717 _e_comp_wl_pname_print(pid);
3718 _e_comp_wl_pname_get(pid, name, sizeof(name));
3719 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3723 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3725 char buf[1024] = {0, };
3727 vsnprintf(buf, 1024, fmt, args);
3731 DBG("[libds] %s", buf);
3734 INF("[libds] %s", buf);
3737 ERR("[libds] %s", buf);
3745 _e_comp_wl_display_create(void)
3748 E_Comp_Wl_Data *wl_cdata;
3753 /* create new compositor data */
3754 if (!(comp = E_NEW(E_Comp_Data, 1)))
3756 ERR("Could not create compositor data: %m");
3759 wl_cdata = &comp->base;
3761 /* set compositor wayland data */
3762 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3764 g_mutex_init(&connection_mutex);
3766 /* try to create a wayland display */
3767 if (!(wl_cdata->wl.disp = wl_display_create()))
3769 ERR("Could not create a Wayland display: %m");
3773 /* try to setup wayland socket */
3774 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3776 ERR("Could not create Wayland display socket: %m");
3777 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3781 res = e_comp_socket_init(name);
3782 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3783 PRCTL("[Winsys] change permission and create sym link for %s", name);
3785 /* set wayland display environment variable */
3786 e_env_set("WAYLAND_DISPLAY", name);
3788 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3789 /* wl_cdata->output.scale = e_scale; */
3791 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3793 if (!e_compositor_init(wl_cdata->wl.disp))
3795 ERR("Failed to initialize compositor");
3799 comp->client_created.notify = _e_comp_wl_cb_client_created;
3800 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3802 if (!e_comp_wl_subsurfaces_init())
3804 ERR("Failed to init_subsurfaces");
3805 goto subsurfaces_err;
3808 /* initialize shm mechanism */
3809 wl_display_init_shm(wl_cdata->wl.disp);
3811 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3813 /* try to init data manager */
3814 if (!e_comp_wl_data_manager_init())
3816 ERR("Could not initialize data manager");
3820 /* try to init input */
3821 if (!e_comp_wl_input_init())
3823 ERR("Could not initialize input");
3827 if (e_comp_gl_get())
3828 _e_comp_wl_gl_init(NULL);
3830 /* get the wayland display loop */
3831 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3833 /* get the file descriptor of the wayland event loop */
3834 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3836 /* create a listener for wayland main loop events */
3838 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3839 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3840 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3841 _e_comp_wl_cb_prepare, wl_cdata);
3846 e_comp_wl_data_manager_shutdown();
3848 e_comp_wl_subsurfaces_shutdown();
3850 wl_list_remove(&comp->client_created.link);
3852 e_env_unset("WAYLAND_DISPLAY");
3854 wl_display_destroy(wl_cdata->wl.disp);
3856 g_mutex_clear(&connection_mutex);
3862 _e_comp_wl_gl_shutdown(void)
3864 if (!e_comp_wl->evas_gl) return;
3866 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3868 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3869 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3870 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3871 evas_gl_free(e_comp_wl->evas_gl->gl);
3873 E_FREE(e_comp_wl->evas_gl);
3876 /* public functions */
3879 * Creates and initializes a Wayland compositor with ecore.
3880 * Registers callback handlers for keyboard and mouse activity
3881 * and other client events.
3883 * @returns true on success, false if initialization failed.
3886 e_comp_wl_init(void)
3888 TRACE_DS_BEGIN(COMP_WL:INIT);
3890 /* try to create a wayland compositor */
3891 if (!_e_comp_wl_display_create())
3893 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3898 e_comp_wl_shell_init();
3900 #ifdef HAVE_WAYLAND_TBM
3901 e_comp_wl_tbm_init();
3903 e_comp_wl_remote_surface_init();
3907 e_comp_wl_screenshooter_init();
3909 if (!e_comp_wl_video_init())
3910 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3912 e_comp_wl_viewport_init();
3913 e_comp_wl_capture_init();
3914 e_comp_wl_renderer_init();
3915 _e_comp_wl_move_resize_init();
3916 e_presentation_time_init();
3917 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3920 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3921 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3923 /* add event handlers to catch E events */
3924 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3925 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3926 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3927 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3928 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3929 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3930 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3931 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3932 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3934 /* add hooks to catch e_client events */
3935 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3936 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3937 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3938 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3939 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3941 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3948 e_comp_wl_deferred_job(void)
3950 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3953 /* internal functions */
3955 e_comp_wl_shutdown(void)
3957 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3959 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3961 e_comp_wl_subsurfaces_shutdown();
3963 E_FREE_LIST(handlers, ecore_event_handler_del);
3964 E_FREE_LIST(hooks, e_client_hook_del);
3965 _e_comp_wl_gl_shutdown();
3967 e_blender_shutdown();
3968 e_presentation_time_shutdown();
3969 e_comp_wl_renderer_shutdown();
3970 e_comp_wl_capture_shutdown();
3971 e_comp_wl_viewport_shutdown();
3972 e_comp_wl_video_shutdown();
3973 e_comp_wl_screenshooter_shutdown();
3975 e_comp_wl_remote_surface_shutdown();
3977 e_pixmap_shutdown();
3979 e_wtz_shell_shutdown();
3980 e_comp_wl_shell_shutdown();
3981 e_comp_wl_input_shutdown();
3983 wl_list_remove(&comp->client_created.link);
3986 e_comp->wl_comp_data = NULL;
3990 E_Comp_Wl_Output *output;
3992 if (e_comp_wl->screenshooter.global)
3993 wl_global_destroy(e_comp_wl->screenshooter.global);
3995 EINA_LIST_FREE(e_comp_wl->outputs, output)
3997 if (output->id) eina_stringshare_del(output->id);
3998 if (output->make) eina_stringshare_del(output->make);
3999 if (output->model) eina_stringshare_del(output->model);
4003 /* delete fd handler */
4004 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
4006 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
4007 cursor_timer_ec = NULL;
4009 /* free allocated data structure */
4015 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4017 e_object_unref(E_OBJECT(ev->ec));
4022 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4025 ev = E_NEW(E_Event_Client, 1);
4028 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4030 /* set usable early because shell module checks this */
4031 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4032 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4034 e_pixmap_resource_set(ec->pixmap, buffer);
4035 e_pixmap_dirty(ec->pixmap);
4036 e_pixmap_refresh(ec->pixmap);
4038 e_comp_wl_map_size_cal_from_buffer(ec);
4039 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4041 /* wm-policy module uses it */
4042 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4045 e_object_ref(E_OBJECT(ec));
4046 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4047 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4051 e_comp_wl_surface_commit(E_Client *ec)
4056 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4057 if (!e_comp_object_damage_exists(ec->frame))
4059 if ((ec->comp_data->video_client) ||
4060 (!e_client_video_hw_composition_check(ec)))
4061 e_pixmap_image_clear(ec->pixmap, 1);
4064 ignored = ec->ignored;
4066 if (e_comp_wl_subsurface_order_commit(ec))
4068 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4069 e_comp_wl_subsurface_restack(topmost);
4070 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4073 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
4074 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
4075 if (!pixmap_usable || hide_by_request)
4077 if (ec->comp_data->mapped)
4079 if (hide_by_request)
4080 ELOGF("COMP", "Currenlty hide_by_request state2. pixmap_usable:%d", ec, pixmap_usable);
4082 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
4084 ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
4085 e_client_shell_unmap(ec);
4087 else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
4088 (ec == e_comp_wl->drag_client))
4090 ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
4091 ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
4092 ec->visible = EINA_FALSE;
4093 evas_object_hide(ec->frame);
4094 ec->comp_data->mapped = 0;
4098 if (ec->comp_data->sub.below_obj && evas_object_visible_get(ec->comp_data->sub.below_obj))
4099 evas_object_hide(ec->comp_data->sub.below_obj);
4103 if (!ec->comp_data->mapped)
4105 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
4108 ELOGF("COMP", "Try to map2. Call shell.map.", ec);
4109 e_client_shell_map(ec);
4111 else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
4112 (ec == e_comp_wl->drag_client))
4114 ELOGF("COMP", "Try to map2. Show window. internal:%d, drag:%d",
4115 ec, ec->internal, (ec == e_comp_wl->drag_client));
4116 ec->visible = EINA_TRUE;
4118 evas_object_show(ec->frame);
4119 ec->comp_data->mapped = 1;
4123 if (ec->comp_data->sub.below_obj && !evas_object_visible_get(ec->comp_data->sub.below_obj)
4124 && evas_object_visible_get(ec->frame))
4125 evas_object_show(ec->comp_data->sub.below_obj);
4127 ec->ignored = ignored;
4129 if (ec->is_cursor && ec->visible)
4131 /* ignore cursor changes during resize/move I guess */
4132 if (!e_client_action_get())
4134 if (e_comp->pointer)
4136 x = e_comp->pointer->hot.x;
4137 y = e_comp->pointer->hot.y;
4139 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4145 static E_Comp_Wl_Output *
4146 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4149 E_Comp_Wl_Output *output;
4151 EINA_LIST_FOREACH(outputs, l, output)
4153 if (!strcmp(output->id, id))
4161 * Initializes information about one display output.
4163 * Adds or updates the given data about a single display output,
4164 * with an id matching the provided id.
4166 * @param id identification of output to be added or changed
4167 * @param make manufacturer name of the display output
4168 * @param model model name of the display output
4169 * @param x output's top left corner x coordinate
4170 * @param y output's top left corner y coordinate
4171 * @param w output's width in pixels
4172 * @param h output's height in pixels
4173 * @param pw output's physical width in millimeters
4174 * @param ph output's physical height in millimeters
4175 * @param refresh output's refresh rate in mHz
4176 * @param subpixel output's subpixel layout
4177 * @param transform output's rotation and/or mirror transformation
4179 * @returns True if a display output object could be added or updated
4182 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4183 int x, int y, int w, int h, int pw, int ph,
4184 unsigned int refresh, unsigned int subpixel,
4185 unsigned int transform)
4187 E_Comp_Wl_Output *output;
4189 struct wl_resource *resource;
4191 /* retrieve named output; or create it if it doesn't exist */
4192 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4195 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4197 if (id) output->id = eina_stringshare_add(id);
4199 output->make = eina_stringshare_add(make);
4201 output->make = eina_stringshare_add("unknown");
4203 output->model = eina_stringshare_add(model);
4205 output->model = eina_stringshare_add("unknown");
4207 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4210 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4211 2, output, _e_comp_wl_cb_output_bind);
4213 output->resources = NULL;
4214 output->scale = e_scale;
4217 /* update the output details */
4222 output->phys_width = pw;
4223 output->phys_height = ph;
4224 output->refresh = refresh;
4225 output->subpixel = subpixel;
4226 output->transform = transform;
4228 if (output->scale <= 0)
4229 output->scale = e_scale;
4231 /* if we have bound resources, send updates */
4232 EINA_LIST_FOREACH(output->resources, l2, resource)
4234 wl_output_send_geometry(resource,
4235 output->x, output->y,
4237 output->phys_height,
4239 output->make ?: "", output->model ?: "",
4242 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4243 wl_output_send_scale(resource, output->scale);
4245 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4246 output->w, output->h, output->refresh);
4248 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4249 wl_output_send_done(resource);
4256 e_comp_wl_output_remove(const char *id)
4258 E_Comp_Wl_Output *output;
4260 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4263 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4265 /* wl_global_destroy(output->global); */
4267 /* eina_stringshare_del(output->id); */
4268 /* eina_stringshare_del(output->make); */
4269 /* eina_stringshare_del(output->model); */
4276 _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)
4278 struct wl_resource *res;
4280 uint32_t serial, keycode;
4281 struct wl_client *wc = NULL;
4282 E_Comp_Config *comp_conf = NULL;
4283 const char *device_name = NULL;
4285 keycode = (ev->keycode - 8);
4287 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4289 comp_conf = e_comp_config_get();
4291 if (ec && ec->comp_data)
4293 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4296 wc = wl_resource_get_client(surface);
4299 if (e_config->key_input_ttrace_enable)
4301 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4302 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4305 EINA_LIST_FOREACH(key_list, l, res)
4307 if (wl_resource_get_client(res) != wc) continue;
4309 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4310 if (!e_input_thread_mode_get())
4312 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4313 device_name = ecore_device_name_get(ev->dev);
4319 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4320 device_name = e_device_name_get(dev);
4324 if (comp_conf && comp_conf->input_log_enable)
4325 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4327 wl_keyboard_send_key(res, serial, ev->timestamp,
4332 if (e_config->key_input_ttrace_enable)
4335 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4340 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4342 E_Client *ec = NULL;
4344 E_Comp_Wl_Key_Data *end, *k;
4346 if (ev->window != e_comp->ee_win)
4351 keycode = (ev->keycode - 8);
4352 if (!(e_comp_wl = e_comp->wl_comp_data))
4357 #ifndef E_RELEASE_BUILD
4358 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4359 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4360 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4361 eina_streq(ev->key, "BackSpace"))
4367 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4369 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4371 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4373 /* ignore server-generated key repeats */
4374 if (k->key == keycode)
4376 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4381 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4383 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4385 ec = e_client_focused_get();
4386 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4387 if (ec && ec->comp_data && surface)
4389 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4390 if (e_comp_wl->kbd.focused)
4392 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4394 /* A key only sent to clients is added to the list */
4395 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4396 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4398 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4400 DBG("wl_array_add: Out of memory\n");
4401 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4402 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4405 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4409 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4413 /* update modifier state */
4414 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4420 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4422 E_Client *ec = NULL;
4423 uint32_t keycode, delivered_key;
4424 E_Comp_Wl_Key_Data *end, *k;
4426 if (ev->window != e_comp->ee_win)
4431 keycode = (ev->keycode - 8);
4433 if (!(e_comp_wl = e_comp->wl_comp_data))
4438 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4440 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4441 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4443 if (k->key == keycode)
4450 e_comp_wl->kbd.keys.size =
4451 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4453 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4455 /* 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) */
4456 if ((delivered_key) ||
4457 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4459 ec = e_client_focused_get();
4461 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4462 if (e_comp_wl->kbd.focused)
4464 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4466 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4469 /* update modifier state */
4470 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4476 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4478 Eina_Bool res = EINA_FALSE;
4480 if (type == ECORE_EVENT_KEY_DOWN)
4482 res = e_comp_wl_key_down(ev, dev);
4484 else if (type == ECORE_EVENT_KEY_UP)
4486 res = e_comp_wl_key_up(ev, dev);
4493 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4496 struct wl_client *wc;
4497 uint32_t serial, btn;
4498 struct wl_resource *res;
4499 E_Comp_Config *comp_conf = NULL;
4501 if (ec->cur_mouse_action || e_comp_wl->drag)
4503 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4504 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4508 case 1: btn = BTN_LEFT; break;
4509 case 2: btn = BTN_MIDDLE; break;
4510 case 3: btn = BTN_RIGHT; break;
4511 default: btn = button_id; break;
4514 e_comp_wl->ptr.button = btn;
4515 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4516 if (!surface) return EINA_FALSE;
4518 if (!eina_list_count(e_comp_wl->ptr.resources))
4521 wc = wl_resource_get_client(surface);
4522 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4524 comp_conf = e_comp_config_get();
4526 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4528 if (wl_resource_get_client(res) != wc) continue;
4529 if (!e_comp_wl_input_pointer_check(res)) continue;
4530 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4532 if (comp_conf && comp_conf->input_log_enable)
4533 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4535 wl_pointer_send_button(res, serial, timestamp, btn, state);
4542 e_comp_wl_touch_cancel(void)
4544 _e_comp_wl_touch_cancel();
4547 E_API E_Comp_Wl_Hook *
4548 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4552 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4553 ch = E_NEW(E_Comp_Wl_Hook, 1);
4554 if (!ch) return NULL;
4555 ch->hookpoint = hookpoint;
4557 ch->data = (void*)data;
4558 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4563 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4566 if (_e_comp_wl_hooks_walking == 0)
4568 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4572 _e_comp_wl_hooks_delete++;
4575 E_API E_Comp_Wl_Pid_Hook *
4576 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4578 E_Comp_Wl_Pid_Hook *ch;
4580 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4582 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4583 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4585 ch->hookpoint = hookpoint;
4587 ch->data = (void*)data;
4588 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4594 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4597 if (_e_comp_wl_pid_hooks_walking == 0)
4599 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4603 _e_comp_wl_pid_hooks_delete++;
4606 E_API E_Comp_Wl_Intercept_Hook *
4607 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4609 E_Comp_Wl_Intercept_Hook *ch;
4611 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4612 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4613 if (!ch) return NULL;
4614 ch->hookpoint = hookpoint;
4616 ch->data = (void*)data;
4617 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4622 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4625 if (_e_comp_wl_intercept_hooks_walking == 0)
4627 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4631 _e_comp_wl_intercept_hooks_delete++;
4635 e_comp_wl_shell_surface_ready(E_Client *ec)
4639 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4643 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4645 e_config->use_cursor_timer = !!enabled;
4647 if (e_config->use_cursor_timer)
4649 if (!e_pointer_is_hidden(e_comp->pointer))
4651 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4656 if (e_comp_wl->ptr.hide_tmr)
4658 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4659 e_comp_wl->ptr.hide_tmr = NULL;
4661 cursor_timer_ec = NULL;
4663 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4666 if (e_pointer_is_hidden(e_comp->pointer))
4668 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4674 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4676 EINA_SAFETY_ON_NULL_RETURN(wc);
4677 EINA_SAFETY_ON_NULL_RETURN(dev);
4679 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4683 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4685 EINA_SAFETY_ON_NULL_RETURN(wc);
4686 EINA_SAFETY_ON_NULL_RETURN(dev);
4688 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4692 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4694 struct wl_resource *res;
4695 struct wl_client *wc;
4697 uint32_t serial, wl_keycode;
4698 enum wl_keyboard_key_state state;
4699 E_Comp_Config *comp_conf = NULL;
4700 const char *dev_name = NULL;
4702 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4703 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4704 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4706 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4707 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
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();
4715 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4716 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4718 comp_conf = e_comp_config_get();
4719 e_keyrouter_event_surface_send(ec, keycode);
4721 if (e_config->key_input_ttrace_enable)
4723 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4724 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4727 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4728 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4730 if (wl_resource_get_client(res) != wc) continue;
4731 if (!e_input_thread_mode_get())
4735 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4736 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4740 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4747 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4748 dev_name = e_device_name_get(dev);
4752 if (comp_conf && comp_conf->input_log_enable)
4753 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4756 wl_keyboard_send_key(res, serial, time,
4759 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4761 if (e_config->key_input_ttrace_enable)
4764 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4771 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4773 struct wl_resource *res;
4774 struct wl_client *wc;
4776 uint32_t serial, wl_keycode, cancel_keycode;
4777 E_Comp_Config *comp_conf = NULL;
4778 struct xkb_keymap *keymap = NULL;
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4781 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4782 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4784 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4785 keymap = e_comp_wl->xkb.keymap;
4786 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4787 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4789 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4790 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4792 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4793 if (cancel_keycode == XKB_KEYCODE_INVALID)
4795 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4798 cancel_keycode = cancel_keycode - 8;
4800 wl_keycode = keycode - 8;
4801 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4803 wc = wl_resource_get_client(surface);
4804 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4805 if (!time) time = e_util_timestamp_get();
4807 comp_conf = e_comp_config_get();
4808 e_keyrouter_event_surface_send(ec, keycode);
4810 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4811 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4813 if (wl_resource_get_client(res) != wc) continue;
4814 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4815 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4817 if (comp_conf && comp_conf->input_log_enable)
4818 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4819 wl_keyboard_send_key(res, serial, time,
4820 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4821 wl_keyboard_send_key(res, serial, time,
4822 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4823 wl_keyboard_send_key(res, serial, time,
4824 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4826 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4833 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)
4835 struct wl_client *wc;
4837 E_Devicemgr_Input_Device *device = NULL;
4839 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4840 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4841 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4843 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4844 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4846 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4848 wc = wl_resource_get_client(surface);
4849 if (!time) time = e_util_timestamp_get();
4850 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4854 _e_comp_wl_send_event_device(wc, time, dev, serial);
4855 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4859 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4860 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4863 x = x + ec->client.x;
4864 y = y + ec->client.y;
4866 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4872 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)
4874 E_Devicemgr_Input_Device *device;
4876 struct wl_client *wc;
4878 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4880 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4882 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4883 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4885 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4887 wc = wl_resource_get_client(surface);
4888 if (!time) time = e_util_timestamp_get();
4889 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4893 _e_comp_wl_send_event_device(wc, time, dev, serial);
4894 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4898 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4899 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4902 x = x + ec->client.x;
4903 y = y + ec->client.y;
4905 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4911 e_comp_wl_touch_cancel_send(E_Client *ec)
4913 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4914 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4915 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4917 _e_comp_wl_send_touch_cancel(ec);
4923 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4926 struct wl_client *wc;
4928 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4929 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4930 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4932 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4933 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4935 wc = wl_resource_get_client(surface);
4936 if (!time) time = e_util_timestamp_get();
4937 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4939 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4940 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4943 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4944 WL_POINTER_BUTTON_STATE_PRESSED);
4946 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4947 WL_POINTER_BUTTON_STATE_RELEASED);
4953 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4956 struct wl_client *wc;
4958 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4959 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4960 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4962 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4963 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4965 wc = wl_resource_get_client(surface);
4966 if (!time) time = e_util_timestamp_get();
4967 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4969 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4970 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4972 x = x + ec->client.x;
4973 y = y + ec->client.y;
4975 _e_comp_wl_send_mouse_move(ec, x, y, time);
4981 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4984 struct wl_client *wc;
4986 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4987 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4988 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4990 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4991 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4993 wc = wl_resource_get_client(surface);
4994 if (!time) time = e_util_timestamp_get();
4995 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4997 if (_e_comp_wl_check_cursor_timer_needed(ec))
4999 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
5003 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5004 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5006 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
5008 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
5010 if (_e_comp_wl_check_cursor_timer_needed(ec))
5011 _e_comp_wl_cursor_move_timer_control(ec);
5018 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
5021 struct wl_client *wc;
5022 struct wl_resource *res;
5025 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5026 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5028 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5029 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5031 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5032 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5034 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5035 wc = wl_resource_get_client(surface);
5036 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5037 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5039 if (!e_comp_wl_input_pointer_check(res)) continue;
5040 if (wl_resource_get_client(res) != wc) continue;
5042 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5043 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5045 wl_pointer_send_enter(res, serial, surface,
5046 wl_fixed_from_int(x),
5047 wl_fixed_from_int(y));
5048 ec->pointer_enter_sent = EINA_TRUE;
5050 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5056 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5059 struct wl_client *wc;
5060 struct wl_resource *res;
5063 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5064 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5065 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5066 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5067 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5068 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5070 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5071 wc = wl_resource_get_client(surface);
5072 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5073 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5075 if (!e_comp_wl_input_pointer_check(res)) continue;
5076 if (wl_resource_get_client(res) != wc) continue;
5078 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5079 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5081 wl_pointer_send_leave(res, serial, surface);
5082 ec->pointer_enter_sent = EINA_FALSE;
5089 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)
5091 Evas_Event_Mouse_In ev_in;
5094 if (ec->pointer_enter_sent) return;
5096 ev_in.buttons = buttons;
5104 ev_in.modifiers = modifiers;
5105 ev_in.locks = locks;
5106 ev_in.timestamp = timestamp;
5107 ev_in.event_flags = event_flags;
5110 ev_in.event_src = event_src;
5112 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5116 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)
5118 Evas_Event_Mouse_Out ev_out;
5121 if (!ec->pointer_enter_sent) return;
5123 ev_out.buttons = buttons;
5125 ev_out.output.x = x;
5126 ev_out.output.y = y;
5127 ev_out.canvas.x = x;
5128 ev_out.canvas.y = y;
5131 ev_out.modifiers = modifiers;
5132 ev_out.locks = locks;
5133 ev_out.timestamp = timestamp;
5134 ev_out.event_flags = event_flags;
5137 ev_out.event_src = event_src;
5139 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5143 e_comp_wl_cursor_hide(E_Client *ec)
5145 struct wl_resource *res;
5146 struct wl_client *wc;
5150 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5152 if (e_comp_wl->ptr.hide_tmr)
5154 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5155 e_comp_wl->ptr.hide_tmr = NULL;
5157 cursor_timer_ec = NULL;
5159 if (!ec) return EINA_FALSE;
5160 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5161 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5162 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5164 wc = wl_resource_get_client(surface);
5165 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5166 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5168 if (!e_comp_wl_input_pointer_check(res)) continue;
5169 if (wl_resource_get_client(res) != wc) continue;
5170 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5171 wl_pointer_send_leave(res, serial, surface);
5172 ec->pointer_enter_sent = EINA_FALSE;
5178 /* surface to buffer
5179 * - width : surface width
5180 * - height : surface height
5181 * - transform: buffer transform
5182 * - scale : buffer scale
5184 * - width : screen width
5185 * - height : screen height
5186 * - transform: output transform
5187 * - scale : output scale
5189 static E_Util_Transform_Matrix
5190 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5192 E_Util_Transform_Matrix m;
5194 e_util_transform_matrix_load_identity(&m);
5196 if (transform & 0x4)
5198 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5199 e_util_transform_matrix_flip_x(&m);
5200 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5203 switch (transform & 0x3)
5205 case WL_OUTPUT_TRANSFORM_90:
5206 e_util_transform_matrix_translate(&m, -width, 0, 0);
5207 e_util_transform_matrix_rotation_z(&m, 270);
5209 case WL_OUTPUT_TRANSFORM_180:
5210 e_util_transform_matrix_translate(&m, -width, -height, 0);
5211 e_util_transform_matrix_rotation_z(&m, 180);
5213 case WL_OUTPUT_TRANSFORM_270:
5214 e_util_transform_matrix_translate(&m, 0, -height, 0);
5215 e_util_transform_matrix_rotation_z(&m, 90);
5221 e_util_transform_matrix_scale(&m, scale, scale, 1);
5226 /* surface to buffer
5227 * - surface width, surface height, buffer transform, buffer scale
5229 * - screen width, screen height, output transform, output scale
5232 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5234 E_Util_Transform_Matrix m;
5235 E_Util_Transform_Vertex v;
5237 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5239 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5240 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5241 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5245 * - buffer width, buffer height, buffer transform, buffer scale
5248 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5250 E_Util_Transform_Matrix m;
5251 E_Util_Transform_Vertex v;
5254 if (transform != 0 || scale > 1)
5256 tw = ((transform % 2) ? height : width) / scale;
5257 th = ((transform % 2) ? width : height) / scale;
5265 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5266 m = e_util_transform_matrix_inverse_get(&m);
5268 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5269 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5270 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5273 /* surface to buffer
5274 * - surface width, surface height, buffer transform, buffer scale
5276 * - screen width, screen height, output transform, output scale
5279 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5280 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5282 E_Util_Transform_Matrix m;
5283 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5284 E_Util_Transform_Rect_Vertex sv;
5286 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5288 sv = e_util_transform_rect_to_vertices(&sr);
5289 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5290 sr = e_util_transform_vertices_to_rect(&sv);
5299 * - buffer width, buffer height, buffer transform, buffer scale
5302 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5303 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5305 E_Util_Transform_Matrix m;
5306 E_Util_Transform_Rect br = {bx, by, bw, bh};
5307 E_Util_Transform_Rect_Vertex bv;
5310 if (transform != 0 || scale > 1)
5312 tw = ((transform % 2) ? height : width) / scale;
5313 th = ((transform % 2) ? width : height) / scale;
5321 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5322 m = e_util_transform_matrix_inverse_get(&m);
5324 bv = e_util_transform_rect_to_vertices(&br);
5325 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5326 br = e_util_transform_vertices_to_rect(&bv);
5334 EINTERN E_Comp_Wl_Output*
5335 e_comp_wl_output_find(E_Client *ec)
5338 E_Comp_Wl_Output *output;
5340 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5342 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5344 if (output->transform % 2)
5346 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5347 ec->y < output->x || ec->y >= (output->x + output->w))
5352 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5353 ec->y < output->y || ec->y >= (output->y + output->h))
5363 EINTERN Eina_Array *
5364 e_comp_wl_output_find_all(E_Client *ec)
5366 E_Comp_Wl_Output *output;
5367 Eina_Array *outputs;
5370 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5372 outputs = eina_array_new(4);
5376 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5378 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5379 output->x, output->y, output->w, output->h))
5381 eina_array_push(outputs, output);
5385 if (eina_array_count(outputs) == 0)
5387 eina_array_free(outputs);
5394 // --------------------------------------------------------
5395 // tizen_move_resize
5396 // --------------------------------------------------------
5398 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5405 E_Client_Pending_Geometry *geo;
5408 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5409 if (ec->fullscreen || ec->maximized) goto err;
5411 geo = E_NEW(E_Client_Pending_Geometry, 1);
5414 geo->serial = serial;
5420 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5421 ec->surface_sync.wait_commit = EINA_TRUE;
5426 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5433 e_comp_wl_commit_sync_configure(E_Client *ec)
5436 E_Client_Pending_Geometry *geo;
5438 Eina_Bool match_size = EINA_FALSE;
5445 if (!ec || !ec->frame) goto ret;
5446 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5449 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5450 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5452 if (eina_list_count(ec->surface_sync.pending_geometry))
5454 Eina_List *ll = NULL;
5455 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5459 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5464 if ((geo->w == bw) && (geo->h == bh))
5466 match_size = EINA_TRUE;
5471 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5478 if ((config.w != ec->w) || (config.h != ec->h))
5480 e_client_size_set(ec, config.w, config.h);
5481 ec->changes.size = EINA_TRUE;
5485 // FIXME: The geometry of the client would be better to be calculated
5486 // at e_desk or at e_desk_area. So the position(x,y) of the client
5487 // should be calcuated at the e_desk or at the e_desk_area.
5489 desk = e_comp_desk_find_by_ec(ec);
5492 ec->client.x = desk->geom.x + config.x;
5493 ec->client.y = desk->geom.y + config.y;
5497 ec->client.x = config.x;
5498 ec->client.y = config.y;
5501 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5503 e_client_pos_set(ec, ec->client.x, ec->client.y);
5505 ec->changes.pos = 1;
5509 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5513 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5514 ec->surface_sync.wait_commit = EINA_FALSE;
5516 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5518 // rollback wait_commit if there are pending requests remained
5519 if (eina_list_count(ec->surface_sync.pending_geometry))
5520 ec->surface_sync.wait_commit = EINA_TRUE;
5525 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);
5532 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5533 struct wl_resource *res_moveresize)
5535 wl_resource_destroy(res_moveresize);
5539 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5540 struct wl_resource *res_moveresize,
5541 struct wl_resource *surface,
5548 /* to be implemented */
5551 int cur_w = 0, cur_h = 0;
5553 ec = e_client_from_surface_resource(surface);
5556 pending = e_client_pending_geometry_has(ec);
5557 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5558 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);
5562 if ((cur_w == w) && (cur_h == h))
5564 e_client_pos_set(ec, x, y);
5565 ec->changes.pos = 1;
5571 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5575 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5578 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5580 _tz_move_resize_iface_cb_destroy,
5581 _tz_move_resize_iface_cb_set_geometry,
5585 _tz_moveresize_cb_bind(struct wl_client *client,
5586 void *data EINA_UNUSED,
5590 struct wl_resource *res_moveresize;
5592 res_moveresize = wl_resource_create(client,
5593 &tizen_move_resize_interface,
5596 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5599 wl_resource_set_implementation(res_moveresize,
5600 &_tz_move_resize_iface,
5606 ERR("Could not create tizen_move_resize_interface res: %m");
5607 wl_client_post_no_memory(client);
5611 _e_comp_wl_move_resize_init(void)
5613 if (!e_comp_wl) return;
5614 if (!e_comp_wl->wl.disp) return;
5616 if (!wl_global_create(e_comp_wl->wl.disp,
5617 &tizen_move_resize_interface,
5620 _tz_moveresize_cb_bind))
5622 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5629 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5631 E_Comp_Wl_Output *output;
5632 pid_t output_pid = 0;
5633 Eina_List *l = NULL, *l2 = NULL;
5634 struct wl_resource *resource = NULL;
5636 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5638 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5639 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5640 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5642 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5644 /* if we have bound resources, send updates */
5645 EINA_LIST_FOREACH(output->resources, l2, resource)
5647 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5648 if (output_pid != pid) continue;
5650 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5652 // send output information to the client
5653 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5661 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5663 _e_comp_wl_surface_state_init(state, w, h);
5667 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5669 _e_comp_wl_surface_state_commit(ec, state);
5673 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5675 _e_comp_wl_hook_call(hookpoint, ec);
5679 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5681 _e_comp_wl_surface_state_finish(state);
5685 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5687 _e_comp_wl_surface_state_buffer_set(state, buffer);
5691 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5692 int sx, int sy, int *dx, int *dy)
5696 case WL_OUTPUT_TRANSFORM_NORMAL:
5700 case WL_OUTPUT_TRANSFORM_FLIPPED:
5701 *dx = width - sx, *dy = sy;
5703 case WL_OUTPUT_TRANSFORM_90:
5704 *dx = height - sy, *dy = sx;
5706 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5707 *dx = height - sy, *dy = width - sx;
5709 case WL_OUTPUT_TRANSFORM_180:
5710 *dx = width - sx, *dy = height - sy;
5712 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5713 *dx = sx, *dy = height - sy;
5715 case WL_OUTPUT_TRANSFORM_270:
5716 *dx = sy, *dy = width - sx;
5718 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5728 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5731 int tx1, ty1, tx2, ty2;
5732 int width_from_buffer, height_from_buffer;
5734 switch (vp->buffer.transform)
5736 case WL_OUTPUT_TRANSFORM_90:
5737 case WL_OUTPUT_TRANSFORM_270:
5738 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5739 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5740 width_from_buffer = bh / vp->buffer.scale;
5741 height_from_buffer = bw / vp->buffer.scale;
5744 width_from_buffer = bw / vp->buffer.scale;
5745 height_from_buffer = bh / vp->buffer.scale;
5749 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5753 x2 = width_from_buffer;
5754 y2 = height_from_buffer;
5758 x1 = wl_fixed_to_int(vp->buffer.src_x);
5759 y1 = wl_fixed_to_int(vp->buffer.src_y);
5760 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5761 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5764 buffer_transform(width_from_buffer, height_from_buffer,
5765 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5766 buffer_transform(width_from_buffer, height_from_buffer,
5767 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5769 out->x = (tx1 <= tx2) ? tx1 : tx2;
5770 out->y = (ty1 <= ty2) ? ty1 : ty2;
5771 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5772 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5776 * Convert given four coordinates to elements of rectangle
5777 * @in p[4] Coordinates to be converted
5778 * @out rect x, y, width, and height
5779 * transform Angle which represents TDM_TRANSFORM of rectangle
5780 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5781 * 1. The given coordinates are not represented by rectangle.
5782 * 2. All angles except for 0, 90, 180, 270.
5785 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5787 Eina_Bool ret = EINA_FALSE;
5789 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))
5792 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5795 *rotation = TDM_TRANSFORM_NORMAL;
5798 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5802 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5805 *rotation = TDM_TRANSFORM_180;
5808 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5813 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))
5816 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5819 *rotation = TDM_TRANSFORM_90;
5822 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5826 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5829 *rotation = TDM_TRANSFORM_270;
5832 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5842 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5847 for (i = 0; i < 4; i++)
5848 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5850 if (!_coords_to_rectangle_convert(p, out, rotation))
5852 DBG("Cannot convert given coords to rectangle.\n"
5853 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5854 p[0].x, p[0].y, p[1].x, p[1].y,
5855 p[2].x, p[2].y, p[3].x, p[3].y);
5863 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5865 int trans_rotation, flip;
5867 trans_rotation = transform & 0x3;
5868 flip = transform & 0x4;
5870 return (flip + (trans_rotation + rotation) % 4);
5874 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5882 if (e_comp_wl_subsurface_check(ec))
5883 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5890 out->w = ec->comp_data->width_from_viewport;
5891 out->w = (out->w + 1) & ~1;
5892 out->h = ec->comp_data->height_from_viewport;
5894 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5895 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5899 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5901 E_Comp_Wl_Buffer *buffer;
5902 E_Comp_Wl_Buffer_Viewport *vp;
5904 enum wl_output_transform buffer_transform;
5905 unsigned int rotation;
5906 Eina_Bool res = EINA_FALSE;
5908 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5910 if (e_object_is_del(E_OBJECT(ec)))
5913 vp = &ec->comp_data->scaler.buffer_viewport;
5915 if (buffer_viewport)
5917 buffer = ec->comp_data->buffer_ref.buffer;
5918 /* Getting a viewport of buffer needs geometry of buffer. */
5922 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5925 if ((output_viewport) || (transform))
5927 m = e_client_map_get(ec);
5929 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5931 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5936 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5937 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5938 * Since buffer.transform isn't applied using evas_map,
5939 * it has to be taken into account here to apply buffer.transform
5940 * and rotation of e_client_transform together. */
5942 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5944 *transform = (unsigned int)buffer_transform;
5952 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5954 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5955 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5957 /* Must be called with valid comp_data */
5958 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5960 if ((ec->comp_data->role_name == NULL) ||
5961 (ec->comp_data->role_name == role_name) ||
5962 (strcmp(ec->comp_data->role_name, role_name) == 0))
5964 ec->comp_data->role_name = role_name;
5970 wl_resource_post_error(error_resource, error_code,
5971 "Cannot assign role %s to wl_surface@%d,"
5972 " already has role %s\n",
5974 ec->comp_data->wl_surface ?
5975 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5976 ec->comp_data->role_name);
5982 EINTERN const char *
5983 e_comp_wl_surface_role_get(E_Client *ec)
5985 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5986 return ec->comp_data ? ec->comp_data->role_name : NULL;
5989 EINTERN struct wl_resource *
5990 e_comp_wl_client_surface_get(E_Client *ec)
5992 struct wl_resource *surface = NULL;
5993 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5994 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5996 g_mutex_lock(&ec->comp_data->surface_mutex);
5997 surface = ec->comp_data->surface;
5998 g_mutex_unlock(&ec->comp_data->surface_mutex);
6003 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
6005 EINA_SAFETY_ON_NULL_RETURN(ec);
6006 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
6008 g_mutex_lock(&ec->comp_data->surface_mutex);
6009 ec->comp_data->surface = surface;
6010 g_mutex_unlock(&ec->comp_data->surface_mutex);
6014 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
6016 return e_compositor_util_client_from_surface_resource(surface_resource);
6020 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
6022 if (!ec->comp_data->mapped)
6024 if (ec->comp_data->shell.surface &&
6025 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
6027 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
6033 if (ec->comp_data->mapped)
6035 /* will be unmapped. so run capture */
6036 e_comp_wl_remote_surface_image_save(ec);
6040 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
6042 ec->comp_data->pending.sx = sx;
6043 ec->comp_data->pending.sy = sy;
6044 ec->comp_data->pending.new_attach = EINA_TRUE;
6046 e_client_fps_update(ec);
6050 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6052 if (ec->comp_data->pending.opaque)
6053 eina_tiler_clear(ec->comp_data->pending.opaque);
6057 eina_tiler_union(ec->comp_data->pending.opaque, region);
6059 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6063 ec->argb = EINA_FALSE;
6064 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6066 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6067 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6075 ec->argb = EINA_TRUE;
6076 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6078 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6079 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6085 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6087 if (ec->comp_data->pending.input)
6088 eina_tiler_clear(ec->comp_data->pending.input);
6092 if (eina_tiler_empty(region))
6094 ELOGF("COMP", " |unset input rect", NULL);
6095 e_comp_object_input_objs_del(ec->frame);
6096 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6099 eina_tiler_union(ec->comp_data->pending.input, region);
6103 eina_tiler_rect_add(ec->comp_data->pending.input,
6104 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6109 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6111 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6115 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6117 E_Comp_Wl_Subsurf_Data *sdata;
6122 if (ec->comp_data->frames)
6124 ec->comp_data->frames =
6125 eina_list_remove(ec->comp_data->frames, callback_resource);
6128 if (ec->comp_data->pending.frames)
6130 ec->comp_data->pending.frames =
6131 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6134 sdata = ec->comp_data->sub.data;
6135 if ((sdata) && (sdata->cached.frames))
6137 sdata->cached.frames =
6138 eina_list_remove(sdata->cached.frames, callback_resource);
6143 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6145 if (e_object_is_del(E_OBJECT(ec))) return;
6147 if (e_comp_wl_remote_surface_commit(ec)) return;
6149 e_comp_wl_surface_commit(ec);
6151 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6155 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6157 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6158 ec->comp_data->sub.data = sub;
6160 /* set subsurface client properties */
6161 ec->borderless = EINA_TRUE;
6162 ec->argb = EINA_TRUE;
6163 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6164 ec->lock_border = EINA_TRUE;
6165 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6166 ec->netwm.state.skip_taskbar = EINA_TRUE;
6167 ec->netwm.state.skip_pager = EINA_TRUE;
6168 ec->border_size = 0;
6169 ec->lock_user_location = 0;
6170 ec->lock_client_location = 0;
6171 ec->lock_user_size = 0;
6172 ec->lock_client_size = 0;
6173 ec->lock_client_stacking = 0;
6174 ec->lock_user_maximize = 0;
6175 ec->lock_client_maximize = 0;
6176 ec->changes.need_maximize = 0;
6177 ec->maximized = E_MAXIMIZE_NONE;
6180 ec->new_client = ec->netwm.ping = EINA_TRUE;
6181 e_comp->new_clients++;
6182 e_client_unignore(ec);
6184 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6185 * It's not for subsurface. */
6186 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6190 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6192 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6195 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6197 sub->parent = parent;
6201 layer = e_client_layer_get(parent);
6202 if (layer > E_LAYER_BOTTOM)
6203 e_client_layer_set(ec, layer);
6206 if (parent->comp_data)
6208 /* append this client to the parents subsurface list */
6209 parent->comp_data->sub.list_pending =
6210 eina_list_append(parent->comp_data->sub.list_pending, ec);
6211 parent->comp_data->sub.list_changed = EINA_TRUE;
6216 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6218 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6219 E_Client *parent = sub->parent;
6221 parent->comp_data->sub.list =
6222 eina_list_remove(parent->comp_data->sub.list, ec);
6223 parent->comp_data->sub.list_pending =
6224 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6225 parent->comp_data->sub.below_list =
6226 eina_list_remove(parent->comp_data->sub.below_list, ec);
6227 parent->comp_data->sub.below_list_pending =
6228 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6234 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)
6236 sub->resource = subsurface_resource;
6237 sub->cached_buffer_ref.buffer = NULL;
6238 sub->synchronized = EINA_TRUE;
6239 sub->parent = parent;
6240 sub->remote_surface.offscreen_parent = offscreen_parent;
6241 if (offscreen_parent)
6242 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6244 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6246 _e_comp_wl_client_subsurface_set(ec, sub);
6247 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6249 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6253 e_comp_wl_client_subsurface_finish(E_Client *ec)
6255 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6258 e_comp_wl_client_subsurface_parent_unset(ec);
6260 e_comp_wl_surface_state_finish(&sub->cached);
6261 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6263 ec->comp_data->sub.data = NULL;
6267 e_comp_wl_client_evas_init(E_Client *ec)
6269 EINA_SAFETY_ON_NULL_RETURN(ec);
6271 _e_comp_wl_client_evas_init(ec);
6275 e_comp_wl_client_evas_deinit(E_Client *ec)
6277 EINA_SAFETY_ON_NULL_RETURN(ec);
6279 _e_comp_wl_client_evas_deinit(ec);
6283 e_comp_wl_focus_check(void)
6285 _e_comp_wl_focus_check();
6289 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6296 if ((parent->comp_data) && (parent->comp_data->sub.data))
6297 parent = parent->comp_data->sub.data->parent;