3 #include "e_wtz_shell.h"
4 #include "e_comp_wl_private.h"
5 #include <tizen-extension-server-protocol.h>
7 #include <relative-pointer-unstable-v1-server-protocol.h>
8 #include <pointer-constraints-unstable-v1-server-protocol.h>
10 #include <wayland-tbm-server.h>
13 #include <libds/log.h>
14 #include <libds/single_pixel_buffer_v1.h>
16 /* handle include for printing uint64_t */
17 #define __STDC_FORMAT_MACROS
20 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
22 /* Resource Data Mapping: (wl_resource_get_user_data)
24 * wl_surface == e_pixmap
25 * wl_region == eina_tiler
26 * wl_subsurface == e_client
30 typedef struct _E_Comp_Data E_Comp_Data;
35 struct wl_listener client_created;
38 static void _e_comp_wl_move_resize_init(void);
40 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
43 typedef struct _E_Comp_Wl_Key_Data
49 static Eina_List *handlers = NULL;
50 static E_Client *cursor_timer_ec = NULL;
51 static Eina_Bool need_send_released = EINA_FALSE;
52 static Eina_Bool need_send_motion = EINA_TRUE;
54 static GMutex flush_mutex;
56 static int _e_comp_wl_hooks_delete = 0;
57 static int _e_comp_wl_hooks_walking = 0;
59 static int _e_comp_wl_pid_hooks_delete = 0;
60 static int _e_comp_wl_pid_hooks_walking = 0;
62 static int _e_comp_wl_intercept_hooks_delete = 0;
63 static int _e_comp_wl_intercept_hooks_walking = 0;
65 static Eina_Inlist *_e_comp_wl_hooks[] =
67 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
68 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
69 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
70 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
71 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
72 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
73 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
74 [E_COMP_WL_HOOK_DEL] = NULL,
75 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
76 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
77 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
80 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
82 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
85 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
87 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
88 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
89 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
90 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
91 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
92 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
95 static Eina_List *hooks = NULL;
99 _e_comp_wl_hooks_clean(void)
104 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
105 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
107 if (!ch->delete_me) continue;
108 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
114 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
118 e_object_ref(E_OBJECT(ec));
119 _e_comp_wl_hooks_walking++;
120 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
122 if (ch->delete_me) continue;
123 ch->func(ch->data, ec);
124 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
125 (e_object_is_del(E_OBJECT(ec))))
128 _e_comp_wl_hooks_walking--;
129 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
130 _e_comp_wl_hooks_clean();
131 e_object_unref(E_OBJECT(ec));
135 _e_comp_wl_pid_hooks_clean(void)
138 E_Comp_Wl_Pid_Hook *ch;
140 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
141 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
143 if (!ch->delete_me) continue;
144 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
150 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
152 E_Comp_Wl_Pid_Hook *ch;
154 _e_comp_wl_pid_hooks_walking++;
155 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
157 if (ch->delete_me) continue;
158 ch->func(ch->data, pid);
160 _e_comp_wl_pid_hooks_walking--;
161 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
162 _e_comp_wl_pid_hooks_clean();
166 _e_comp_wl_intercept_hooks_clean(void)
169 E_Comp_Wl_Intercept_Hook *ch;
171 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
172 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
174 if (!ch->delete_me) continue;
175 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
181 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
183 E_Comp_Wl_Intercept_Hook *ch;
184 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
186 e_object_ref(E_OBJECT(ec));
187 _e_comp_wl_intercept_hooks_walking++;
188 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
190 if (ch->delete_me) continue;
191 res = ch->func(ch->data, ec);
192 if (!res) ret = EINA_FALSE;
193 if (e_object_is_del(E_OBJECT(ec)))
196 _e_comp_wl_intercept_hooks_walking--;
197 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
198 _e_comp_wl_intercept_hooks_clean();
199 e_object_unref(E_OBJECT(ec));
206 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
212 if (e_comp_object_frame_exists(ec->frame))
213 w = ec->client.w, h = ec->client.h;
215 w = ec->w, h = ec->h;
219 // Width and Height are -1 means that we don't consider size value
223 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
224 edges * e_comp_wl->resize.edges,
229 _e_comp_wl_focus_check(void)
233 if (stopping) return;
234 ec = e_client_focused_get();
236 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
240 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
242 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
244 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
245 IDLE_EXITER~CB_PREPARE);
247 return ECORE_CALLBACK_RENEW;
251 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
253 /* dispatch pending wayland events */
254 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
256 return ECORE_CALLBACK_RENEW;
260 e_comp_wl_display_flush()
262 if (e_comp_wl && e_comp_wl->wl.disp)
264 g_mutex_lock(&flush_mutex);
265 wl_display_flush_clients(e_comp_wl->wl.disp);
266 g_mutex_unlock(&flush_mutex);
271 e_comp_wl_focused_client_flush()
273 E_Client *focused_ec;
274 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
276 g_mutex_lock(&flush_mutex);
277 focused_ec = e_client_focused_get();
281 struct wl_client *wc;
282 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
285 g_mutex_unlock(&flush_mutex);
289 wc = wl_resource_get_client(surface);
293 g_mutex_unlock(&flush_mutex);
297 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
301 if (e_comp_wl->idle_exiter_timestamp > 0.0)
303 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
304 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
306 ELOGF("E_COMP", "prepare gap time: %lfms",
311 e_comp_wl->idle_exiter_timestamp = 0.0;
313 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
315 /* flush pending client events */
316 e_comp_wl_display_flush();
318 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
319 IDLE_EXITER~CB_PREPARE);
322 E_API enum wl_output_transform
323 e_comp_wl_output_buffer_transform_get(E_Client *ec)
325 E_Comp_Wl_Buffer_Viewport *vp;
326 E_Comp_Wl_Buffer *buffer;
327 enum wl_output_transform transform, rotation;
329 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
330 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
331 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
333 vp = &ec->comp_data->scaler.buffer_viewport;
334 if (e_comp_wl_subsurface_check(ec))
335 return vp->buffer.transform;
337 buffer = ec->comp_data->buffer_ref.buffer;
340 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
341 return vp->buffer.transform;
343 rotation = buffer->transform;
345 return vp->buffer.transform;
347 /* ignore the flip value when calculating transform because the screen rotation
348 * functionality doesn't consider the flip output transform currently
350 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
352 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
353 ec, rotation, vp->buffer.transform, transform);
358 EINTERN enum wl_output_transform
359 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
361 E_Comp_Wl_Buffer_Viewport *vp;
362 E_Comp_Wl_Buffer *buffer;
363 enum wl_output_transform transform, rotation;
365 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
366 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
367 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
369 vp = &ec->comp_data->pending.buffer_viewport;
370 if (e_comp_wl_subsurface_check(ec))
371 return vp->buffer.transform;
373 buffer = ec->comp_data->pending.buffer;
376 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
377 return vp->buffer.transform;
379 rotation = buffer->transform;
381 return vp->buffer.transform;
383 /* ignore the flip value when calculating transform because the screen rotation
384 * functionality doesn't consider the flip output transform currently
386 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
388 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
389 ec, rotation, vp->buffer.transform, transform);
395 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
397 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
398 E_Comp_Wl_Buffer *buffer;
399 int32_t width, height;
401 buffer = e_pixmap_resource_get(ec->pixmap);
404 ec->comp_data->width_from_buffer = 0;
405 ec->comp_data->height_from_buffer = 0;
409 switch (e_comp_wl_output_buffer_transform_get(ec))
411 case WL_OUTPUT_TRANSFORM_90:
412 case WL_OUTPUT_TRANSFORM_270:
413 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
414 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
415 width = buffer->h / vp->buffer.scale;
416 height = buffer->w / vp->buffer.scale;
419 width = buffer->w / vp->buffer.scale;
420 height = buffer->h / vp->buffer.scale;
424 ec->comp_data->width_from_buffer = width;
425 ec->comp_data->height_from_buffer = height;
429 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
431 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
432 int32_t width, height;
434 width = ec->comp_data->width_from_buffer;
435 height = ec->comp_data->height_from_buffer;
437 if (width == 0 && height == 0) return;
439 if (width != 0 && vp->surface.width != -1)
441 ec->comp_data->width_from_viewport = vp->surface.width;
442 ec->comp_data->height_from_viewport = vp->surface.height;
446 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
448 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
449 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
450 ec->comp_data->width_from_viewport = w ?: 1;
451 ec->comp_data->height_from_viewport = h ?: 1;
455 ec->comp_data->width_from_viewport = width;
456 ec->comp_data->height_from_viewport = height;
460 e_comp_wl_topmost_parent_get(E_Client *ec)
464 if (!e_comp_wl_subsurface_check(ec))
467 parent = e_comp_wl_subsurface_parent_get(ec);
470 if (!e_comp_wl_subsurface_check(parent))
473 parent = e_comp_wl_subsurface_parent_get(parent);
480 e_comp_wl_map_apply(E_Client *ec)
482 E_Comp_Wl_Buffer_Viewport *vp;
483 E_Comp_Wl_Subsurf_Data *sdata;
484 E_Comp_Wl_Client_Data *cdata;
485 int x1, y1, x2, y2, x, y;
487 Eina_Bool zoom_animating = EINA_FALSE;
489 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
491 e_comp_object_map_update(ec->frame);
493 cdata = ec->comp_data;
494 vp = &cdata->scaler.buffer_viewport;
495 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
496 (!cdata->viewport_transform))
499 if (e_comp_wl_subsurface_check(ec))
501 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
503 sdata = ec->comp_data->sub.data;
504 if (sdata->remote_surface.offscreen_parent)
506 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
507 Eina_Rectangle *rect;
510 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
512 /* TODO: If there are one more regions, it means that provider's offscreen
513 * is displayed by one more remote_surfaces. Have to consider it later. At
514 * this time, just consider only one remote_surface.
528 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
529 if (x != dx || y != dy)
530 evas_object_move(ec->frame, dx, dy);
532 if (!cdata->viewport_transform)
534 cdata->viewport_transform = e_util_transform_new();
535 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
536 e_client_transform_core_add(ec, cdata->viewport_transform);
539 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
540 ec->comp_data->width_from_viewport,
541 ec->comp_data->height_from_viewport);
543 if (vp->buffer.src_width == wl_fixed_from_int(-1))
547 x2 = cdata->width_from_buffer;
548 y2 = cdata->height_from_buffer;
552 x1 = wl_fixed_to_int(vp->buffer.src_x);
553 y1 = wl_fixed_to_int(vp->buffer.src_y);
554 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
555 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
558 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
559 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
560 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
561 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
564 desk = e_comp_desk_find_by_ec(ec);
566 zoom_animating = e_desk_zoom_is_animating(desk);
568 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
569 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
570 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
572 /* workaround:: when the desk zoom is doing their animation,
573 the transform core update can override animation's zoom boundary.
574 so, don't doing transform core update while desk zoom animation */
576 e_client_transform_core_update(ec);
581 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
585 int map_c = 0, map_x = 0, map_y = 0;
586 double inv_x = 0.0, inv_y = 0.0;
588 EINA_SAFETY_ON_NULL_RETURN(ec);
590 map = e_client_map_get(ec);
591 map_c = e_map_count_get(map);
593 if (!map || map_c <= 0)
603 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
604 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
605 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
606 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
608 for (int i = 0; i < map_c; i++)
610 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
611 e_map_point_image_uv_set(map2, i, map_x, map_y);
613 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
623 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
629 if (!(ec = data)) return;
630 if (e_object_is_del(data)) return;
632 if (!ec->override) e_hints_window_visible_set(ec);
634 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
635 (!ec->comp_data->need_reparent))
637 ec->comp_data->need_reparent = EINA_TRUE;
638 ec->visible = EINA_TRUE;
640 if (!e_client_util_ignored_get(ec))
642 ec->take_focus = !starting;
646 if (!ec->comp_data->need_reparent)
648 if ((ec->hidden) || (ec->iconic))
650 evas_object_hide(ec->frame);
651 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
654 evas_object_show(ec->frame);
657 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
658 evas_object_show(tmp->frame);
660 topmost = e_comp_wl_topmost_parent_get(ec);
661 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
662 e_comp_wl_subsurface_show(ec);
664 if (ec->comp_data->sub.below_obj)
665 evas_object_show(ec->comp_data->sub.below_obj);
669 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
675 if (!(ec = data)) return;
676 if (e_object_is_del(E_OBJECT(ec))) return;
678 /* Uncommonly some clients's final buffer can be skipped if the client
679 * requests unmap of its surface right after wl_surface@commit.
680 * So if this client evas object is hidden state and client is already
681 * unmmapped, we can consider to clear pixmap image here mandatorily.
683 if (!ec->comp_data->mapped)
684 e_pixmap_image_clear(ec->pixmap, 1);
686 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
687 evas_object_hide(tmp->frame);
689 topmost = e_comp_wl_topmost_parent_get(ec);
690 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
691 e_comp_wl_subsurface_hide(ec);
693 if (ec->comp_data->sub.below_obj)
694 evas_object_hide(ec->comp_data->sub.below_obj);
696 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
700 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
707 if (!(ec = data)) return;
708 if (e_object_is_del(E_OBJECT(ec))) return;
710 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
712 if (!e_comp_wl_subsurface_check(subc)) continue;
713 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
714 evas_object_move(subc->frame, x, y);
716 if (subc->comp_data->scaler.viewport)
718 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
719 if (cdata->viewport_transform)
720 e_comp_wl_map_apply(subc);
724 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
726 if (!e_comp_wl_subsurface_check(subc)) continue;
727 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
728 evas_object_move(subc->frame, x, y);
730 if (subc->comp_data->scaler.viewport)
732 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
733 if (cdata->viewport_transform)
734 e_comp_wl_map_apply(subc);
738 if (ec->comp_data->sub.below_obj)
740 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
741 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
746 _e_comp_wl_send_touch_cancel(E_Client *ec)
749 struct wl_resource *res;
750 struct wl_client *wc;
751 E_Comp_Config *comp_conf = NULL;
754 if (e_object_is_del(E_OBJECT(ec))) return;
755 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
757 if (!surface) return;
758 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
760 wc = wl_resource_get_client(surface);
762 comp_conf = e_comp_config_get();
764 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
766 if (wl_resource_get_client(res) != wc) continue;
767 if (!e_comp_wl_input_touch_check(res)) continue;
769 if (comp_conf && comp_conf->input_log_enable)
770 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
772 wl_touch_send_cancel(res);
777 _e_comp_wl_touch_cancel(void)
781 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
783 if (!e_comp_wl->touch.pressed) return;
785 _e_comp_wl_send_touch_cancel(ec);
788 static E_Devicemgr_Input_Device *
789 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
791 E_Devicemgr_Input_Device *last_kbd = NULL;
794 case ECORE_DEVICE_CLASS_MOUSE:
795 return e_devicemgr->last_device_ptr;
796 case ECORE_DEVICE_CLASS_KEYBOARD:
797 g_rec_mutex_lock(&e_devicemgr->last_device_kbd_mutex);
798 last_kbd = e_devicemgr->last_device_kbd;
799 g_rec_mutex_unlock(&e_devicemgr->last_device_kbd_mutex);
801 case ECORE_DEVICE_CLASS_TOUCH:
802 return e_devicemgr->last_device_touch;
810 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
814 case ECORE_DEVICE_CLASS_MOUSE:
815 e_devicemgr->last_device_ptr = device;
817 case ECORE_DEVICE_CLASS_KEYBOARD:
818 g_rec_mutex_lock(&e_devicemgr->last_device_kbd_mutex);
819 e_devicemgr->last_device_kbd = device;
820 g_rec_mutex_unlock(&e_devicemgr->last_device_kbd_mutex);
822 case ECORE_DEVICE_CLASS_TOUCH:
823 e_devicemgr->last_device_touch = device;
830 static E_Devicemgr_Input_Device *
831 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
833 E_Devicemgr_Input_Device *last_kbd = NULL;
837 case ECORE_DEVICE_CLASS_MOUSE:
838 return ec->comp_data->last_device_ptr;
839 case ECORE_DEVICE_CLASS_KEYBOARD:
840 g_rec_mutex_lock(&ec->comp_data->last_device_kbd_mutex);
841 last_kbd = ec->comp_data->last_device_kbd;
842 g_rec_mutex_unlock(&ec->comp_data->last_device_kbd_mutex);
844 case ECORE_DEVICE_CLASS_TOUCH:
845 return ec->comp_data->last_device_touch;
853 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
857 case ECORE_DEVICE_CLASS_MOUSE:
858 ec->comp_data->last_device_ptr = device;
860 case ECORE_DEVICE_CLASS_KEYBOARD:
861 g_rec_mutex_lock(&ec->comp_data->last_device_kbd_mutex);
862 ec->comp_data->last_device_kbd = device;
863 g_rec_mutex_unlock(&ec->comp_data->last_device_kbd_mutex);
865 case ECORE_DEVICE_CLASS_TOUCH:
866 ec->comp_data->last_device_touch = device;
874 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
876 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
877 struct wl_resource *dev_res;
878 const char *dev_name;
879 Ecore_Device_Class dev_class;
880 struct wl_client *wc;
884 EINA_SAFETY_ON_NULL_RETURN(dev);
887 if (ec->cur_mouse_action || e_comp_wl->drag)
889 if (e_object_is_del(E_OBJECT(ec))) return;
890 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
891 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
892 if (!surface) return;
894 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
895 dev_name = evas_device_description_get(dev);
896 last_device = _e_comp_wl_device_last_device_get(dev_class);
897 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
899 serial = wl_display_next_serial(e_comp_wl->wl.disp);
900 wc = wl_resource_get_client(surface);
901 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
902 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
904 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
905 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
907 _e_comp_wl_device_last_device_set(dev_class, input_dev);
908 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
910 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
912 if (wl_resource_get_client(dev_res) != wc) continue;
913 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
917 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
921 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
923 E_Devicemgr_Input_Device *last_device;
924 struct wl_resource *dev_res;
925 struct wl_client *wc;
929 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
930 if (!surface) return;
932 last_device = _e_comp_wl_device_last_device_get(dev_class);
933 if (!last_device) return;
935 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
937 serial = wl_display_next_serial(e_comp_wl->wl.disp);
938 wc = wl_resource_get_client(surface);
939 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
941 if (wl_resource_get_client(dev_res) != wc) continue;
942 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
947 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
949 E_Devicemgr_Input_Device *input_dev;
950 struct wl_resource *dev_res;
951 const char *dev_name;
954 EINA_SAFETY_ON_NULL_RETURN(dev);
956 dev_name = ecore_device_identifier_get(dev);
958 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
959 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
961 if (!eina_streq(input_dev->identifier, dev_name) ||
962 (input_dev->clas != ecore_device_class_get(dev))) continue;
963 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
965 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
967 if (wl_resource_get_client(dev_res) != wc) continue;
968 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
971 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
975 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
977 E_Devicemgr_Input_Device *input_dev;
978 struct wl_resource *dev_res;
979 const char *dev_name;
982 EINA_SAFETY_ON_NULL_RETURN(dev);
984 dev_name = e_device_identifier_get(dev);
986 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
987 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
989 if (!eina_streq(input_dev->identifier, dev_name) ||
990 (input_dev->clas != e_device_class_get(dev))) continue;
991 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
993 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
995 if (wl_resource_get_client(dev_res) != wc) continue;
996 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
999 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1003 _e_comp_wl_cursor_reload(E_Client *ec)
1005 struct wl_resource *res;
1006 struct wl_client *wc;
1012 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1013 !evas_object_visible_get(e_comp->pointer->o_ptr))
1014 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1017 if (e_object_is_del(E_OBJECT(ec))) return;
1018 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1019 if (!surface) return;
1020 if (ec->pointer_enter_sent) return;
1022 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1023 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1025 if (e_client_transform_core_enable_get(ec))
1027 double dx = 0.0, dy = 0.0;
1028 map = e_client_map_get(ec);
1029 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1035 cx = px - ec->client.x;
1036 cy = py - ec->client.y;
1038 wc = wl_resource_get_client(surface);
1039 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1040 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1042 if (!e_comp_wl_input_pointer_check(res)) continue;
1043 if (wl_resource_get_client(res) != wc) continue;
1044 wl_pointer_send_enter(res, serial, surface,
1045 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1046 ec->pointer_enter_sent = EINA_TRUE;
1048 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1052 _e_comp_wl_cursor_timer(void *data)
1054 E_Client *ec = data;
1056 e_comp_wl_cursor_hide(ec);
1058 return ECORE_CALLBACK_CANCEL;
1062 _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)
1064 E_Devicemgr_Input_Device *input_dev;
1065 struct wl_resource *dev_res;
1066 struct wl_client *wc;
1071 if (ec->cur_mouse_action) return;
1072 if (e_object_is_del(E_OBJECT(ec))) return;
1073 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1074 if (!surface) return;
1076 f_value = wl_fixed_from_double(value);
1077 wc = wl_resource_get_client(surface);
1079 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1080 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1082 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1083 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1085 if (wl_resource_get_client(dev_res) != wc) continue;
1086 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1089 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1093 _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)
1095 if (idx >= e_input_touch_max_count_get()) return;
1097 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1098 e_devicemgr->multi[idx].radius_x = radius_x;
1099 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1100 e_devicemgr->multi[idx].radius_y = radius_y;
1101 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1102 e_devicemgr->multi[idx].pressure = pressure;
1103 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1104 e_devicemgr->multi[idx].angle = angle;
1108 _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)
1110 if (idx >= e_input_touch_max_count_get()) return;
1112 if (e_devicemgr->multi[idx].radius_x != radius_x)
1114 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1115 e_devicemgr->multi[idx].radius_x = radius_x;
1117 if (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_RADIUS_Y, radius_y);
1120 e_devicemgr->multi[idx].radius_y = radius_y;
1122 if (e_devicemgr->multi[idx].pressure != pressure)
1124 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1125 e_devicemgr->multi[idx].pressure = pressure;
1127 if (e_devicemgr->multi[idx].angle != angle)
1129 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1130 e_devicemgr->multi[idx].angle = angle;
1135 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1137 Eina_Bool ret = EINA_TRUE;
1140 case EVAS_CALLBACK_MOUSE_IN:
1141 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1144 if (e_comp_wl->ptr.hide_tmr)
1146 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1147 cursor_timer_ec = ec;
1148 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1152 if (e_pointer_is_hidden(e_comp->pointer))
1157 case EVAS_CALLBACK_MOUSE_OUT:
1158 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1161 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1165 case EVAS_CALLBACK_MOUSE_MOVE:
1166 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1169 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1170 _e_comp_wl_cursor_reload(ec);
1173 case EVAS_CALLBACK_MOUSE_WHEEL:
1174 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1177 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1178 _e_comp_wl_cursor_reload(ec);
1181 case EVAS_CALLBACK_MOUSE_DOWN:
1182 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1185 if (e_comp_wl->ptr.hide_tmr)
1187 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1188 e_comp_wl->ptr.hide_tmr = NULL;
1190 cursor_timer_ec = NULL;
1192 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1193 _e_comp_wl_cursor_reload(ec);
1196 case EVAS_CALLBACK_MOUSE_UP:
1197 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1208 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1210 if (ec->has_cursor_unset)
1213 if (!e_config->show_cursor)
1216 if (!e_config->use_cursor_timer)
1223 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1226 Evas_Event_Mouse_In *ev;
1227 struct wl_resource *res;
1228 struct wl_client *wc;
1231 E_Comp_Config *comp_conf;
1232 E_Client *prev_ptr_ec;
1236 e_comp_wl->ptr.x = wl_fixed_from_int(ev->canvas.x);
1237 e_comp_wl->ptr.y = wl_fixed_from_int(ev->canvas.y);
1239 if (!(ec = data)) return;
1240 if (e_object_is_del(E_OBJECT(ec))) return;
1241 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1242 if (!surface) return;
1244 prev_ptr_ec = e_comp_wl->ptr.ec;
1247 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1248 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1251 e_comp_wl->ptr.ec = ec;
1253 comp_conf = e_comp_config_get();
1254 if (comp_conf && comp_conf->input_log_enable)
1255 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1256 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1257 e_client_util_name_get(ec));
1259 if (_e_comp_wl_check_cursor_timer_needed(ec))
1261 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1265 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1266 wc = wl_resource_get_client(surface);
1267 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1268 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1270 if (!e_comp_wl_input_pointer_check(res)) continue;
1271 if (wl_resource_get_client(res) != wc) continue;
1273 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1275 wl_pointer_send_enter(res, serial, surface,
1276 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1277 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1278 ec->pointer_enter_sent = EINA_TRUE;
1281 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1285 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1288 Evas_Event_Mouse_Out *ev;
1289 struct wl_resource *res;
1290 struct wl_client *wc;
1293 Eina_Bool inside_check;
1294 E_Comp_Config *comp_conf;
1298 if (!(ec = data)) return;
1299 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1300 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1301 if (ec->cur_mouse_action && inside_check) return;
1302 if (e_object_is_del(E_OBJECT(e_comp))) return;
1303 if (e_comp_wl->ptr.ec == ec)
1304 e_comp_wl->ptr.ec = NULL;
1305 if (e_object_is_del(E_OBJECT(ec))) return;
1307 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1308 if (!surface) return;
1310 comp_conf = e_comp_config_get();
1311 if (comp_conf && comp_conf->input_log_enable)
1312 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1313 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1314 e_client_util_name_get(ec));
1316 if (_e_comp_wl_check_cursor_timer_needed(ec))
1318 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1322 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1324 wc = wl_resource_get_client(surface);
1325 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1326 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1328 if (!e_comp_wl_input_pointer_check(res)) continue;
1329 if (wl_resource_get_client(res) != wc) continue;
1330 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1332 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1334 wl_pointer_send_leave(res, serial, surface);
1335 ec->pointer_enter_sent = EINA_FALSE;
1340 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1343 struct wl_client *wc;
1344 struct wl_resource *res;
1347 E_Comp_Config *comp_conf = NULL;
1350 if (e_object_is_del(E_OBJECT(ec))) return;
1351 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1352 if (!surface) return;
1354 wc = wl_resource_get_client(surface);
1355 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1359 x = wl_fixed_from_int(canvas_x - ec->client.x);
1360 y = wl_fixed_from_int(canvas_y - ec->client.y);
1363 comp_conf = e_comp_config_get();
1365 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1367 if (wl_resource_get_client(res) != wc) continue;
1368 if (!e_comp_wl_input_touch_check(res)) continue;
1369 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1372 if (comp_conf && comp_conf->input_log_enable)
1373 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));
1375 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1379 if (comp_conf && comp_conf->input_log_enable)
1380 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));
1382 wl_touch_send_up(res, serial, timestamp, idx);
1389 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1392 struct wl_client *wc;
1393 struct wl_resource *res;
1397 if (ec->cur_mouse_action) return;
1398 if (e_object_is_del(E_OBJECT(ec))) return;
1399 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1400 if (!surface) return;
1402 wc = wl_resource_get_client(surface);
1404 x = wl_fixed_from_int(canvas_x - ec->client.x);
1405 y = wl_fixed_from_int(canvas_y - ec->client.y);
1407 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1409 if (wl_resource_get_client(res) != wc) continue;
1410 if (!e_comp_wl_input_touch_check(res)) continue;
1411 wl_touch_send_motion(res, timestamp, idx, x, y);
1416 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1418 struct wl_resource *res;
1419 struct wl_client *wc;
1423 if (ec->cur_mouse_action) return;
1424 if (e_object_is_del(E_OBJECT(ec))) return;
1425 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1426 if (!surface) return;
1428 wc = wl_resource_get_client(surface);
1429 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1431 if (!e_comp_wl_input_pointer_check(res)) continue;
1432 if (wl_resource_get_client(res) != wc) continue;
1433 wl_pointer_send_motion(res, timestamp,
1434 wl_fixed_from_int(x - ec->client.x),
1435 wl_fixed_from_int(y - ec->client.y));
1440 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1442 if (e_comp_wl->ptr.hide_tmr)
1444 if (cursor_timer_ec == ec)
1446 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1447 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1451 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1452 cursor_timer_ec = ec;
1453 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1458 cursor_timer_ec = ec;
1459 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1464 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1467 Evas_Event_Mouse_Move *ev;
1468 Evas_Device *dev = NULL;
1469 const char *dev_name;
1470 E_Comp_Config *comp_conf;
1474 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1475 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1477 if (!(ec = data)) return;
1478 if (e_object_is_del(E_OBJECT(ec))) return;
1479 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1480 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1481 if (!surface) return;
1483 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1486 dev_name = evas_device_description_get(dev);
1488 comp_conf = e_comp_config_get();
1489 if (comp_conf && comp_conf->input_log_enable)
1490 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1491 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1492 e_client_util_name_get(ec), dev_name);
1494 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1496 if (!e_comp_wl->drag_client)
1498 e_comp_wl->touch.faked_ec = ec;
1499 if (e_comp_wl->touch.pressed & (1 << 0))
1501 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1503 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1504 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1505 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1509 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1513 if (!e_comp_wl->drag_client)
1515 if (_e_comp_wl_check_cursor_timer_needed(ec))
1517 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1521 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1522 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1524 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1526 if (_e_comp_wl_check_cursor_timer_needed(ec))
1527 _e_comp_wl_cursor_move_timer_control(ec);
1531 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1536 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1538 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1539 if (e_object_is_del(E_OBJECT(ec))) return;
1540 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1541 if (!surface) return;
1542 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1544 e_comp_wl->ptr.button = BTN_LEFT;
1546 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1550 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1552 E_Client *ec = data;
1553 Evas_Event_Mouse_Down *ev = event;
1554 Evas_Device *dev = NULL;
1555 const Evas_Device *seat_dev;
1556 const char *dev_name, *seat_name;
1557 E_Comp_Config *comp_conf = NULL;
1560 if (e_object_is_del(E_OBJECT(ec))) return;
1563 dev_name = evas_device_description_get(dev);
1565 seat_dev = evas_device_parent_get(dev);
1566 seat_name = evas_device_name_get(seat_dev);
1568 comp_conf = e_comp_config_get();
1569 if (comp_conf && comp_conf->input_log_enable)
1570 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1571 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1572 dev_name, seat_name);
1574 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1576 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1578 e_comp_wl->touch.faked_ec = ec;
1581 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1582 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1583 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1585 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1586 e_comp_wl->touch.pressed |= (1 << 0);
1590 if (_e_comp_wl_check_cursor_timer_needed(ec))
1592 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1596 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1597 WL_POINTER_BUTTON_STATE_PRESSED);
1599 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1602 need_send_released = EINA_TRUE;
1606 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1608 E_Client *ec = data;
1609 Evas_Event_Mouse_Up *ev = event;
1610 Evas_Device *dev = NULL;
1611 const Evas_Device *seat_dev;
1612 const char *dev_name, *seat_name;;
1613 Evas_Event_Flags flags;
1614 E_Comp_Config *comp_conf = NULL;
1617 if (ec->cur_mouse_action) return;
1618 if (e_object_is_del(E_OBJECT(ec))) return;
1620 if (!need_send_released)
1622 need_send_motion = EINA_TRUE;
1626 dev_name = evas_device_description_get(dev);
1628 seat_dev = evas_device_parent_get(dev);
1629 seat_name = evas_device_name_get(seat_dev);
1630 flags = evas_event_default_flags_get(evas);
1632 comp_conf = e_comp_config_get();
1633 if (comp_conf && comp_conf->input_log_enable)
1634 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1635 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1636 dev_name, seat_name);
1638 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1640 e_comp_wl->touch.pressed &= ~(1 << 0);
1642 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1643 e_comp_wl->touch.faked_ec = NULL;
1646 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1648 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1650 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1653 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1654 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1655 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1659 if (_e_comp_wl_check_cursor_timer_needed(ec))
1661 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1665 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1666 WL_POINTER_BUTTON_STATE_RELEASED);
1668 if (_e_comp_wl_check_cursor_timer_needed(ec))
1669 _e_comp_wl_cursor_move_timer_control(ec);
1673 need_send_released = EINA_FALSE;
1677 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1679 struct wl_resource *res;
1680 struct wl_client *wc;
1685 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1687 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1690 dir = -wl_fixed_from_int(abs(z));
1692 dir = wl_fixed_from_int(z);
1695 if (e_object_is_del(E_OBJECT(ec))) return;
1696 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1697 if (!surface) return;
1699 wc = wl_resource_get_client(surface);
1700 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1702 if (!e_comp_wl_input_pointer_check(res)) continue;
1703 if (wl_resource_get_client(res) != wc) continue;
1704 wl_pointer_send_axis(res, timestamp, axis, dir);
1709 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1712 Evas_Event_Mouse_Wheel *ev;
1715 if (!(ec = data)) return;
1716 if (ec->cur_mouse_action) return;
1717 if (e_object_is_del(E_OBJECT(ec))) return;
1718 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1719 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1720 if (!surface) return;
1722 if (!eina_list_count(e_comp_wl->ptr.resources))
1725 if (_e_comp_wl_check_cursor_timer_needed(ec))
1727 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1731 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1733 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1735 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1737 if (_e_comp_wl_check_cursor_timer_needed(ec))
1738 _e_comp_wl_cursor_move_timer_control(ec);
1743 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1745 E_Client *ec = data;
1746 Evas_Event_Multi_Down *ev = event;
1747 Evas_Device *dev = NULL;
1748 const Evas_Device *seat_dev;
1749 const char *dev_name, *seat_name;
1750 Evas_Device_Class dev_class;
1751 E_Comp_Config *comp_conf = NULL;
1754 if (e_object_is_del(E_OBJECT(ec))) return;
1755 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1756 if (!surface) return;
1758 /* Do not deliver emulated single touch events to client */
1759 if (ev->device == 0) return;
1762 dev_name = evas_device_description_get(dev);
1763 e_comp_wl->touch.faked_ec = ec;
1765 seat_dev = evas_device_parent_get(dev);
1766 seat_name = evas_device_name_get(seat_dev);
1768 comp_conf = e_comp_config_get();
1769 if (comp_conf && comp_conf->input_log_enable)
1770 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1771 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1772 dev_name, seat_name);
1774 if (dev && dev_name)
1776 dev_class = evas_device_class_get(dev);
1777 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1778 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1781 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1782 e_comp_wl->touch.pressed |= (1 << ev->device);
1786 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1788 E_Client *ec = data;
1789 Evas_Event_Multi_Up *ev = event;
1790 Evas_Device *dev = NULL;
1791 const Evas_Device *seat_dev;
1792 const char *dev_name, *seat_name;
1793 Evas_Device_Class dev_class;
1794 Evas_Event_Flags flags;
1795 E_Comp_Config *comp_conf = NULL;
1798 if (e_object_is_del(E_OBJECT(ec))) return;
1799 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1800 if (!surface) return;
1802 /* Do not deliver emulated single touch events to client */
1803 if (ev->device == 0) return;
1805 flags = evas_event_default_flags_get(evas);
1807 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1808 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1809 e_comp_wl->touch.faked_ec = NULL;
1811 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1814 dev_name = evas_device_description_get(dev);
1816 seat_dev = evas_device_parent_get(dev);
1817 seat_name = evas_device_name_get(seat_dev);
1819 comp_conf = e_comp_config_get();
1820 if (comp_conf && comp_conf->input_log_enable)
1821 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1822 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1823 dev_name, seat_name);
1825 if (dev && dev_name)
1827 dev_class = evas_device_class_get(dev);
1828 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1829 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1832 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1836 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1838 E_Client *ec = data;
1839 Evas_Event_Multi_Move *ev = event;
1840 Evas_Device *dev = NULL;
1841 const char *dev_name;
1842 Evas_Device_Class dev_class;
1845 if (e_object_is_del(E_OBJECT(ec))) return;
1846 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1847 if (!surface) return;
1849 /* Do not deliver emulated single touch events to client */
1850 if (ev->device == 0) return;
1852 e_comp_wl->touch.faked_ec = ec;
1854 if (e_comp_wl->touch.pressed & (1 << ev->device))
1857 if (dev && (dev_name = evas_device_description_get(dev)))
1859 dev_class = evas_device_class_get(dev);
1860 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1861 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1864 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1869 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1872 char *file, buff[PATH_MAX];
1879 n = (getpriority(PRIO_PROCESS, pid) + adj);
1883 setpriority(PRIO_PROCESS, pid, n);
1886 use_adj = EINA_TRUE;
1888 if (!do_child) return;
1890 files = ecore_file_ls("/proc");
1891 EINA_LIST_FREE(files, file)
1893 if (!isdigit(file[0]))
1896 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1897 if ((f = fopen(buff, "r")))
1901 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1903 if (num_read == 2 && ppid == pid)
1904 _e_comp_wl_client_priority_adjust(pid2, set,
1906 adj_child, do_child);
1914 _e_comp_wl_client_priority_raise(E_Client *ec)
1916 if (!e_config->priority_control) return;
1917 if (ec->netwm.pid <= 0) return;
1918 if (ec->netwm.pid == getpid()) return;
1919 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1920 e_config->priority - 1, -1,
1921 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1925 _e_comp_wl_client_priority_normal(E_Client *ec)
1927 if (!e_config->priority_control) return;
1928 if (ec->netwm.pid <= 0) return;
1929 if (ec->netwm.pid == getpid()) return;
1930 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1931 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1935 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1938 E_Comp_Wl_Key_Data *k;
1939 struct wl_resource *res;
1943 if (!ec) return EINA_FALSE;
1944 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1945 if (!ec->comp_data) return EINA_FALSE;
1947 ec->comp_data->on_focus_timer = NULL;
1948 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1949 if (!e_comp_wl->kbd.focused)
1951 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1954 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1956 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1957 t = ecore_time_unix_get();
1959 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1960 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1961 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1963 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1965 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1966 wl_keyboard_send_key(res, serial, t,
1967 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1970 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1971 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1975 /* It is called in the following cases:
1976 * When a normal ec->frame has focus.
1977 * Or launching image ec is replaced to the real ec.
1980 e_comp_wl_feed_focus_in(E_Client *ec)
1983 struct wl_resource *res;
1984 struct wl_client *wc;
1988 if (e_object_is_del(E_OBJECT(ec))) return;
1989 if (ec->iconic) return;
1991 /* block spurious focus events */
1992 focused = e_client_focused_get();
1993 if ((focused) && (ec != focused)) return;
1995 /* raise client priority */
1996 _e_comp_wl_client_priority_raise(ec);
1997 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1998 if (!surface) return;
2000 wc = wl_resource_get_client(surface);
2002 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2003 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2005 if (wl_resource_get_client(res) == wc)
2007 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2008 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2009 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2010 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2013 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2015 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2016 if (!e_comp_wl->kbd.focused)
2018 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2021 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2023 e_comp_wl->kbd.focus = surface;
2024 e_comp_wl_input_keyboard_enter_send(ec);
2025 e_comp_wl_data_device_keyboard_focus_set();
2026 ec->comp_data->on_focus_timer =
2027 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2028 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2029 int rotation = ec->e.state.rot.ang.curr;
2030 e_pointer_rotation_set(e_comp->pointer, rotation);
2034 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2037 if (!(ec = data)) return;
2038 e_comp_wl_feed_focus_in(ec);
2042 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2045 struct wl_resource *res;
2047 E_Comp_Wl_Key_Data *k;
2051 if (!(ec = data)) return;
2053 if (!ec->comp_data) return;
2055 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2057 /* lower client priority */
2058 if (!e_object_is_del(data))
2059 _e_comp_wl_client_priority_normal(ec);
2062 /* update keyboard modifier state */
2063 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2064 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2065 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2067 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2069 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2070 if (!surface) return;
2072 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2073 if (!eina_list_count(e_comp_wl->kbd.resources))
2075 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2079 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2081 /* send keyboard_leave to all keyboard resources */
2082 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2083 t = ecore_time_unix_get();
2085 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2086 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2087 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2089 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2091 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2092 wl_keyboard_send_key(res, serial, t,
2093 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2095 wl_keyboard_send_leave(res, serial, surface);
2096 e_comp_wl->kbd.focused =
2097 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2099 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2100 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2104 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2108 if (!(ec = data)) return;
2110 if ((ec->shading) || (ec->shaded)) return;
2111 if (!ec->comp_data->shell.configure_send) return;
2113 /* TODO: calculate x, y with transfrom object */
2114 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2118 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2119 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2120 if (e_comp_object_frame_exists(ec->frame))
2121 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2123 switch (ec->resize_mode)
2125 case E_POINTER_RESIZE_TL:
2126 case E_POINTER_RESIZE_L:
2127 case E_POINTER_RESIZE_BL:
2128 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2129 ec->mouse.current.mx;
2131 case E_POINTER_RESIZE_TR:
2132 case E_POINTER_RESIZE_R:
2133 case E_POINTER_RESIZE_BR:
2134 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2139 switch (ec->resize_mode)
2141 case E_POINTER_RESIZE_TL:
2142 case E_POINTER_RESIZE_T:
2143 case E_POINTER_RESIZE_TR:
2144 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2145 ec->mouse.current.my;
2147 case E_POINTER_RESIZE_BL:
2148 case E_POINTER_RESIZE_B:
2149 case E_POINTER_RESIZE_BR:
2150 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2155 w = E_CLAMP(w, 1, w);
2156 h = E_CLAMP(h, 1, h);
2157 e_client_resize_limit(ec, &w, &h);
2159 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
2160 e_comp_wl->resize.edges,
2163 else if ((!ec->fullscreen) && (!ec->maximized) &&
2164 (!ec->comp_data->maximize_pre))
2168 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2169 if ((pw != ec->w) || (ph != ec->h))
2171 _e_comp_wl_configure_send(ec, 1, 1);
2175 if (ec->comp_data->sub.below_obj)
2176 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2180 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2182 E_Client *ec = data;
2184 ec->comp_data->maximize_pre = 1;
2188 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2190 E_Client *ec = data;
2193 if (e_object_is_del(E_OBJECT(ec))) return;
2195 if (ec->comp_data->shell.configure_send)
2197 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2198 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, 0, w, h);
2200 ec->comp_data->maximize_pre = 0;
2204 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2206 E_Client *ec = data;
2208 ec->comp_data->maximize_pre = 1;
2212 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2214 E_Client *ec = data;
2216 if (e_object_is_del(E_OBJECT(ec))) return;
2218 /* check for wayland pixmap */
2220 if (ec->comp_data->shell.configure_send)
2221 _e_comp_wl_configure_send(ec, 0, 0);
2223 ec->comp_data->maximize_pre = 0;
2227 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2229 E_Client *ec = data;
2231 if (e_object_is_del(E_OBJECT(ec))) return;
2233 /* check for wayland pixmap */
2235 if (ec->comp_data->shell.configure_send)
2236 _e_comp_wl_configure_send(ec, 0, 1);
2238 ec->comp_data->maximize_pre = 0;
2242 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2244 E_Client *ec = data;
2246 if (e_object_is_del(E_OBJECT(ec))) return;
2248 /* check for wayland pixmap */
2250 if (ec->comp_data->shell.configure_send)
2251 _e_comp_wl_configure_send(ec, 0, 0);
2253 ec->comp_data->maximize_pre = 0;
2257 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2261 if (!(ec = data)) return;
2263 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2265 e_object_del(E_OBJECT(ec));
2267 _e_comp_wl_focus_check();
2269 /* TODO: Delete request send ??
2270 * NB: No such animal wrt wayland */
2274 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2278 if (!(ec = data)) return;
2280 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2283 if (ec->comp_data->reparented)
2284 e_client_comp_hidden_set(ec, EINA_TRUE);
2287 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2288 if (ec->visible) evas_object_hide(ec->frame);
2289 if (!ec->internal) e_object_del(E_OBJECT(ec));
2291 _e_comp_wl_focus_check();
2295 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2299 if (!(ec = data)) return;
2300 if (!(ec->comp_data)) return;
2301 if (!(ec->comp_data->shell.ping)) return;
2302 if (!(ec->comp_data->shell.surface)) return;
2304 ec->comp_data->shell.ping(ec->comp_data->shell.surface);
2308 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2313 if (!(ec = data)) return;
2314 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2315 if (ec->netwm.opacity == a) return;
2316 ec->netwm.opacity = a;
2317 ec->netwm.opacity_changed = EINA_TRUE;
2321 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2323 Eina_Rectangle *damage_rect = NULL;
2324 Eina_Rectangle *dmg = NULL;
2325 Eina_List *l = NULL;
2327 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2328 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2331 if (!buffer->tbm_surface) return;
2335 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2339 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2340 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2343 eina_rectangle_union(damage_rect, dmg);
2348 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2349 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2352 tbm_surface_internal_set_damage(buffer->tbm_surface,
2358 eina_rectangle_free(damage_rect);
2362 _e_comp_wl_client_evas_init(E_Client *ec)
2364 if (!ec || !ec->comp_data) return;
2365 if (ec->comp_data->evas_init) return;
2367 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2368 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2369 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2372 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2373 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2374 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2375 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2376 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2377 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2379 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2380 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2381 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2383 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2384 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2388 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2389 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2390 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2391 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2392 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2393 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2394 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2397 /* setup delete/kill callbacks */
2398 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2399 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2401 /* setup ping callback */
2402 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2403 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2405 ec->comp_data->evas_init = EINA_TRUE;
2409 _e_comp_wl_client_evas_deinit(E_Client *ec)
2411 if (!ec || !ec->comp_data) return;
2412 if (!ec->comp_data->evas_init) return;
2414 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2415 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2416 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2418 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2419 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2420 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2421 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2422 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2423 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2425 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2426 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2427 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2429 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2430 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2434 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2435 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2436 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2437 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2438 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2439 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2440 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2443 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2444 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2446 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2447 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2449 ec->comp_data->evas_init = EINA_FALSE;
2453 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2457 E_Comp_Screen *e_comp_screen;
2458 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2460 if (!e_comp) return ECORE_CALLBACK_RENEW;
2461 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2462 e_comp_screen = e_comp->e_comp_screen;
2464 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2466 if (!eout->config.enabled)
2468 e_comp_wl_output_remove(eout->id);
2472 switch (eout->config.rotation)
2475 transform = WL_OUTPUT_TRANSFORM_90;
2478 transform = WL_OUTPUT_TRANSFORM_180;
2481 transform = WL_OUTPUT_TRANSFORM_270;
2485 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2489 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2491 eout->config.geom.x, eout->config.geom.y,
2492 eout->config.geom.w, eout->config.geom.h,
2493 eout->info.size.w, eout->info.size.h,
2494 eout->config.mode.refresh, 0, transform))
2495 ERR("Could not initialize screen %s", eout->info.name);
2498 return ECORE_CALLBACK_RENEW;
2502 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2506 /* try to get the client from the object */
2507 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2508 return ECORE_CALLBACK_RENEW;
2510 /* check for client being deleted */
2511 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2513 /* check for wayland pixmap */
2514 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2515 return ECORE_CALLBACK_RENEW;
2517 /* if we have not setup evas callbacks for this client, do it */
2518 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2520 return ECORE_CALLBACK_RENEW;
2524 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2528 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2529 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2531 if (e_comp_wl->selection.target &&
2534 struct wl_resource *res;
2536 E_Client *ec = NULL;
2537 E_Client *legacy_target = e_comp_wl->selection.target;
2538 int device_id = e_comp_wl_data_current_device_id_get();
2542 e_comp_wl_data_current_device_id_set(ev->multi.device);
2544 else if (device_id != ev->multi.device)
2546 return ECORE_CALLBACK_RENEW;
2549 ec = e_client_input_rect_under_pointer_get(legacy_target->desk, e_comp_wl->drag_client);
2550 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2552 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2553 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2555 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2556 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2558 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2559 (ec != legacy_target))
2561 e_comp_wl_data_device_send_leave(legacy_target);
2562 e_comp_wl_data_device_send_enter(ec);
2565 if (e_comp_wl->drag)
2566 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2568 if (e_client_transform_core_enable_get(ec))
2570 int trans_x, trans_y;
2571 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2572 x = trans_x - ec->client.x;
2573 y = trans_y - ec->client.y;
2577 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2582 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2585 return ECORE_CALLBACK_RENEW;
2589 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2592 struct wl_resource *surface;
2593 struct wl_resource *res;
2594 struct wl_client *wc;
2596 E_Comp_Config *comp_conf;
2598 ec = e_comp_wl->ptr_constraints.ec;
2599 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2601 surface = e_comp_wl_client_surface_get(ec);
2602 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2604 wc = wl_resource_get_client(surface);
2606 comp_conf = e_comp_config_get();
2608 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2610 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2611 if (wl_resource_get_client(res) != wc) continue;
2613 if (comp_conf && comp_conf->input_log_enable)
2614 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2615 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2616 e_client_util_name_get(ec));
2618 zwp_relative_pointer_v1_send_relative_motion(res,
2620 (uint32_t)(ev->timestamp),
2621 wl_fixed_from_int(ev->dx),
2622 wl_fixed_from_int(ev->dy),
2623 wl_fixed_from_int(ev->dx_unaccel),
2624 wl_fixed_from_int(ev->dy_unaccel));
2627 return ECORE_CALLBACK_DONE;
2631 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2633 _e_comp_wl_touch_cancel();
2635 return ECORE_CALLBACK_PASS_ON;
2639 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2641 if (!ev) return ECORE_CALLBACK_PASS_ON;
2643 E_Zone *zone = ev->zone;
2645 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2646 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2648 if (!e_zone_is_displaying(zone))
2649 _e_comp_wl_touch_cancel();
2651 return ECORE_CALLBACK_PASS_ON;
2655 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2657 E_Client *ec = ev->ec;
2658 E_Comp_Wl_Buffer_Viewport *vp;
2660 if (!ec) return ECORE_CALLBACK_PASS_ON;
2661 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2662 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2663 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2664 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2666 vp = &ec->comp_data->scaler.buffer_viewport;
2667 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2669 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2671 return ECORE_CALLBACK_PASS_ON;
2675 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2677 E_Client *ec = ev->ec;
2678 E_Comp_Wl_Buffer_Viewport *vp;
2680 if (!ec) return ECORE_CALLBACK_PASS_ON;
2681 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2682 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2683 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2685 vp = &ec->comp_data->scaler.buffer_viewport;
2686 vp->wait_for_transform_change = 0;
2688 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2690 return ECORE_CALLBACK_PASS_ON;
2694 _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)
2696 E_Client *focused_ec;
2699 focused_ec = e_client_focused_get();
2700 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2702 rotation = focused_ec->e.state.rot.ang.curr;
2703 e_pointer_rotation_set(e_comp->pointer, rotation);
2705 return ECORE_CALLBACK_PASS_ON;
2709 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2712 Eina_Rectangle *window;
2717 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2719 if ((prev_w != state->bw) ||
2720 (prev_h != state->bh))
2722 ec->changes.buf_size = EINA_TRUE;
2725 if (e_comp_object_frame_exists(ec->frame)) return;
2726 window = &ec->comp_data->shell.window;
2727 if ((!ec->borderless) && /* FIXME temporarily added this check code
2728 * to prevent updating E_Client's size by frame */
2729 (window->x || window->y || window->w || window->h))
2731 e_comp_object_frame_geometry_set(ec->frame,
2733 (window->x + window->w) - state->bw,
2735 (window->y + window->h) - state->bh);
2738 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2742 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2744 E_Comp_Wl_Surface_State *state;
2747 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2748 state->buffer = NULL;
2752 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2754 state->new_attach = EINA_FALSE;
2755 state->buffer = NULL;
2756 state->buffer_destroy_listener.notify =
2757 _e_comp_wl_surface_state_cb_buffer_destroy;
2758 state->sx = state->sy = 0;
2760 state->input = eina_tiler_new(w, h);
2761 eina_tiler_tile_size_set(state->input, 1, 1);
2763 state->opaque = eina_tiler_new(w, h);
2764 eina_tiler_tile_size_set(state->opaque, 1, 1);
2766 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2767 state->buffer_viewport.buffer.scale = 1;
2768 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2769 state->buffer_viewport.surface.width = -1;
2770 state->buffer_viewport.changed = 0;
2772 e_presentation_time_container_init(&state->presentation_container);
2776 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2778 struct wl_resource *cb;
2779 Eina_Rectangle *dmg;
2781 EINA_LIST_FREE(state->frames, cb)
2782 wl_resource_destroy(cb);
2784 EINA_LIST_FREE(state->damages, dmg)
2785 eina_rectangle_free(dmg);
2787 EINA_LIST_FREE(state->buffer_damages, dmg)
2788 eina_rectangle_free(dmg);
2790 if (state->opaque) eina_tiler_free(state->opaque);
2791 state->opaque = NULL;
2793 if (state->input) eina_tiler_free(state->input);
2794 state->input = NULL;
2796 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2797 state->buffer = NULL;
2799 e_presentation_time_container_finish(&state->presentation_container);
2803 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2805 if (state->buffer == buffer) return;
2807 wl_list_remove(&state->buffer_destroy_listener.link);
2808 state->buffer = buffer;
2810 wl_signal_add(&state->buffer->destroy_signal,
2811 &state->buffer_destroy_listener);
2815 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2817 Eina_Rectangle *dmg;
2818 Eina_Bool placed = EINA_TRUE;
2822 E_Comp_Wl_Buffer *buffer;
2823 struct wl_resource *cb;
2825 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2826 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2831 if ((ec->internal) ||
2832 (cdata->shell.surface && state->new_attach))
2836 e_comp->new_clients++;
2837 ELOGF("COMP", "Unignore", ec);
2838 e_client_unignore(ec);
2842 /* buffer transform */
2843 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2846 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2848 /* when buffer is transformed, we have to apply the new evas-map */
2849 state->buffer_viewport.changed = EINA_TRUE;
2851 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2853 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2855 if (transform_change == vp->wait_for_transform_change)
2856 vp->wait_for_transform_change = 0;
2858 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2859 // triggered by E_CLIENT_HOOK calls at those file.
2860 zone = e_comp_zone_find_by_ec(ec);
2863 eout = e_output_find(zone->output_id);
2864 if (eout && eout->hwc)
2866 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2868 if (e_comp_is_on_overlay(ec))
2869 e_comp_hwc_client_end(ec, __FUNCTION__);
2875 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2876 cdata->scaler.buffer_viewport = state->buffer_viewport;
2878 if (state->new_attach)
2880 e_comp_wl_surface_attach(ec, state->buffer);
2883 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2884 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2886 _e_comp_wl_surface_state_buffer_set(state, NULL);
2888 if ((state->new_attach) ||
2889 (state->buffer_viewport.changed))
2891 _e_comp_wl_surface_state_size_update(ec, state);
2892 e_comp_wl_map_size_cal_from_viewport(ec);
2894 /* update the position */
2895 if (ec->changes.pos)
2897 e_comp_object_frame_xy_unadjust(ec->frame,
2907 if (ec->new_client) placed = ec->placed;
2909 if (!ec->lock_client_size)
2914 ec->client.w = state->bw;
2915 ec->client.h = state->bh;
2917 e_comp_object_frame_wh_adjust(ec->frame,
2918 ec->client.w, ec->client.h,
2920 e_client_size_set(ec, nw, nh);
2922 if ((w != ec->w) || (h != ec->h))
2924 ec->changes.size = 1;
2929 if (ec->changes.buf_size)
2931 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2932 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2933 ec->changes.buf_size = EINA_FALSE;
2935 if (ec->move_after_resize)
2937 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2938 ec->move_after_resize = EINA_FALSE;
2943 /* map or unmap ec */
2944 if (!e_pixmap_usable_get(ec->pixmap))
2949 if ((cdata->shell.surface) &&
2950 (cdata->shell.unmap))
2952 ELOGF("COMP", "Try to unmap. Call shell.unmap.", ec);
2953 if (ec->show_pending.count > 0)
2955 ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
2956 ec->show_pending.count = 0;
2957 if (ec->show_pending.running)
2959 // need to send visibility false;
2960 ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
2961 ELOGF("POL_VIS", "CLIENT VIS ON (fake). argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
2964 ec->show_pending.running = EINA_FALSE;
2966 cdata->shell.unmap(cdata->shell.surface);
2968 else if ((ec->internal) ||
2969 (e_comp_wl_subsurface_check(ec)) ||
2970 (ec == e_comp_wl->drag_client))
2972 ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
2973 ec, ec->internal, cdata->sub.data, (ec == e_comp_wl->drag_client));
2974 ec->visible = EINA_FALSE;
2975 evas_object_hide(ec->frame);
2980 if ((cdata->sub.below_obj) &&
2981 (evas_object_visible_get(cdata->sub.below_obj)))
2983 evas_object_hide(cdata->sub.below_obj);
2991 if ((cdata->shell.surface) &&
2992 (cdata->shell.map) &&
2995 ELOGF("COMP", "Try to map. Call shell.map.", ec);
2996 cdata->shell.map(cdata->shell.surface);
2998 else if ((ec->internal) ||
2999 (e_comp_wl_subsurface_can_show(ec)) ||
3000 (ec == e_comp_wl->drag_client))
3002 ELOGF("COMP", "Try to map. Show window. internal:%d, drag:%d",
3003 ec, ec->internal, (ec == e_comp_wl->drag_client));
3004 ec->visible = EINA_TRUE;
3006 evas_object_show(ec->frame);
3011 if ((cdata->sub.below_obj) &&
3012 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3013 (evas_object_visible_get(ec->frame)))
3015 evas_object_show(cdata->sub.below_obj);
3019 if ((state->new_attach) ||
3020 (state->buffer_viewport.changed))
3022 if ((e_comp_wl->drag) &&
3023 (e_comp_wl->drag_client) &&
3024 (e_comp_wl->drag_client == ec))
3026 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3028 e_drag_move(e_comp_wl->drag,
3030 e_comp_wl->drag->y);
3032 e_drag_resize(e_comp_wl->drag,
3033 state->bw, state->bh);
3035 else if ((cdata->shell.surface) &&
3036 (cdata->shell.configure))
3038 e_comp_wl_commit_sync_configure(ec);
3040 else if (!e_client_video_hw_composition_check(ec))
3042 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3047 ec->placed = placed;
3048 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3052 if (cdata->scaler.buffer_viewport.changed)
3053 e_comp_wl_map_apply(ec);
3055 /* resize transform object */
3056 if (ec->transformed)
3057 e_client_transform_update(ec);
3061 state->new_attach = EINA_FALSE;
3063 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3065 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3066 wl_resource_destroy(cb);
3069 /* insert state frame callbacks into comp_data->frames
3070 * NB: This clears state->frames list */
3071 cdata->frames = eina_list_merge(cdata->frames,
3073 state->frames = NULL;
3075 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3076 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3077 &state->presentation_container);
3079 buffer = e_pixmap_resource_get(ec->pixmap);
3081 /* put state damages into surface */
3084 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3085 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3087 if ((cdata->buffer_ref.buffer) &&
3088 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3089 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3091 e_comp_object_damage(ec->frame,
3093 cdata->buffer_ref.buffer->w,
3094 cdata->buffer_ref.buffer->h);
3099 Eina_List *damages = NULL;
3102 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3104 if (eina_list_count(state->buffer_damages))
3106 EINA_LIST_FREE(state->buffer_damages, dmg)
3109 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3110 e_comp_wl_output_buffer_transform_get(ec),
3112 dmg->x, dmg->y, dmg->w, dmg->h,
3113 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3114 damages = eina_list_append(damages, dmg);
3118 EINA_LIST_FREE(state->damages, dmg)
3119 damages = eina_list_append(damages, dmg);
3121 EINA_LIST_FREE(damages, dmg)
3123 /* not creating damage for ec that shows a underlay video */
3124 if (state->buffer_viewport.changed ||
3125 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3126 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3127 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3129 eina_rectangle_free(dmg);
3134 /* put state opaque into surface */
3135 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3138 Eina_Rectangle *rect;
3141 itr = eina_tiler_iterator_new(state->opaque);
3142 EINA_ITERATOR_FOREACH(itr, rect)
3146 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3147 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3148 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3152 eina_iterator_free(itr);
3155 /* put state input into surface */
3156 if ((state->input) &&
3157 (!eina_tiler_empty(state->input)) &&
3160 Eina_Tiler *src, *tmp;
3164 tmp = eina_tiler_new(sw, sh);
3165 eina_tiler_tile_size_set(tmp, 1, 1);
3167 eina_tiler_rect_add(tmp,
3168 &(Eina_Rectangle){0, 0, sw, sh});
3170 if ((src = eina_tiler_intersection(state->input, tmp)))
3172 Eina_Rectangle *rect;
3175 e_comp_object_input_objs_del(ec->frame);
3176 itr = eina_tiler_iterator_new(src);
3177 EINA_ITERATOR_FOREACH(itr, rect)
3179 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3180 ec, rect->x, rect->y, rect->w, rect->h,
3181 ec->w, ec->h, state->bw, state->bh);
3182 e_comp_object_input_area_set(ec->frame,
3187 eina_iterator_free(itr);
3188 eina_tiler_free(src);
3191 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3193 eina_tiler_free(tmp);
3195 /* clear input tiler */
3196 eina_tiler_clear(state->input);
3199 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3201 if ((cdata->video_client) &&
3203 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3204 (e_comp->wl_comp_data->available_hw_accel.underlay))
3206 e_pixmap_image_clear(ec->pixmap, 1);
3209 state->buffer_viewport.changed = 0;
3211 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3214 ec->exp_iconify.buffer_flush &&
3215 e_policy_visibility_client_is_iconic(ec))
3217 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3222 _e_comp_wl_surface_render_stop(E_Client *ec)
3224 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3225 //if ((!ec->internal) && (!e_comp_gl_get()))
3228 /* check if internal animation is running */
3229 if (e_comp_object_is_animating(ec->frame)) return;
3230 /* check if external animation is running */
3231 if (evas_object_data_get(ec->frame, "effect_running")) return;
3233 evas_object_hide(ec->frame);
3237 e_comp_wl_client_surface_finish(E_Client *ec)
3239 struct wl_resource *res, *surface;
3240 struct wl_client *surface_client = NULL;
3243 surface = e_comp_wl_client_surface_get(ec);
3246 surface_client = wl_resource_get_client(surface);
3248 if (surface_client &&
3249 (ec == e_client_focused_get()))
3251 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3252 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3254 if (wl_resource_get_client(res) ==
3256 e_comp_wl->kbd.focused =
3257 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3261 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3264 e_comp_wl_client_surface_set(ec, NULL);
3266 ec->comp_data->wl_surface = NULL;
3267 e_pixmap_win_id_del(ec->pixmap);
3269 _e_comp_wl_surface_render_stop(ec);
3270 e_object_del(E_OBJECT(ec));
3274 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3279 char proc[512], pname[512];
3282 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3284 h = fopen(proc, "r");
3287 len = fread(pname, sizeof(char), 512, h);
3289 pname[len - 1] = '\0';
3291 strncpy(pname, "NO NAME", sizeof(pname));
3297 strncpy(pname, "NO NAME", sizeof(pname));
3300 strncpy(name, pname, size);
3304 _e_comp_wl_pname_print(pid_t pid)
3307 char proc[512], pname[512];
3310 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3312 h = fopen(proc, "r");
3315 len = fread(pname, sizeof(char), 512, h);
3317 pname[len - 1] = '\0';
3319 strncpy(pname, "NO NAME", sizeof(pname));
3323 ELOGF("COMP", " |%s", NULL, pname);
3328 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3330 struct wl_client *client = data;
3331 E_Comp_Connected_Client_Info *cinfo;
3334 cinfo = wl_container_of(listener, cinfo, destroy);
3336 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3337 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3339 eai = e_appinfo_find_with_pid(cinfo->pid);
3340 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3343 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3345 wl_list_remove(&cinfo->destroy.link);
3346 eina_stringshare_del(cinfo->name);
3351 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3353 E_Comp_Connected_Client_Info *cinfo;
3355 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3356 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3358 cinfo->name = eina_stringshare_add(name);
3362 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3363 wl_client_add_destroy_listener(client, &cinfo->destroy);
3364 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3366 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3370 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3372 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3374 /* send configure */
3375 if (ec->comp_data->shell.configure_send)
3377 if (ec->comp_data->shell.surface)
3378 _e_comp_wl_configure_send(ec, 0, 0);
3381 e_comp_wl->kbd.focus = ec->comp_data->surface;
3385 _e_comp_wl_client_cb_focus_unset(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_focus_check();
3398 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3399 e_comp_wl->kbd.focus = NULL;
3403 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3405 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3406 if (ec->keyboard_resizing) return;
3408 /* do nothing currently */
3413 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3415 if (e_object_is_del(E_OBJECT(ec))) return;
3416 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3418 e_comp_wl->resize.edges = 0;
3419 e_comp_wl->resize.resource = NULL;
3421 if (ec->pending_resize)
3423 ec->changes.pos = EINA_TRUE;
3424 ec->changes.size = EINA_TRUE;
3428 E_FREE_LIST(ec->pending_resize, free);
3432 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3434 if (e_object_is_del(E_OBJECT(ec))) return;
3435 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3439 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3442 int ratio_w, ratio_h;
3444 phys_w = output->phys_width;
3445 phys_h = output->phys_height;
3447 if (e_config->configured_output_resolution.use)
3449 // change the configured physical size(mm) of the output
3450 if (output->w != res_w)
3452 ratio_w = res_w / output->w;
3453 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3456 if (output->h != res_h)
3458 ratio_h = res_h / output->h;
3459 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3462 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3465 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3466 NULL, res_w, res_h, phys_w, phys_h, pid);
3468 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3469 wl_output_send_scale(resource, output->scale);
3471 wl_output_send_geometry(resource, output->x, output->y,
3473 output->subpixel, output->make ?: "",
3474 output->model ?: "", output->transform);
3476 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3477 res_w, res_h, output->refresh);
3479 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3480 wl_output_send_done(resource);
3484 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3486 E_Comp_Wl_Output *output;
3488 if (!(output = wl_resource_get_user_data(resource))) return;
3490 output->resources = eina_list_remove(output->resources, resource);
3494 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3496 E_Comp_Wl_Output *output;
3497 struct wl_resource *resource;
3498 E_Appinfo *eai = NULL;
3502 if (!(output = data)) return;
3505 wl_resource_create(client, &wl_output_interface, version, id);
3508 wl_client_post_no_memory(client);
3512 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3513 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3515 output->resources = eina_list_append(output->resources, resource);
3517 wl_resource_set_implementation(resource, NULL, output,
3518 _e_comp_wl_cb_output_unbind);
3519 wl_resource_set_user_data(resource, output);
3521 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3522 if (e_config->configured_output_resolution.use)
3524 wl_client_get_credentials(client, &pid, NULL, NULL);
3527 res_w = e_config->configured_output_resolution.w;
3528 res_h = e_config->configured_output_resolution.h;
3532 eai = e_appinfo_find_with_pid(pid);
3535 res_w = e_config->configured_output_resolution.w;
3536 res_h = e_config->configured_output_resolution.h;
3540 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3542 res_w = e_config->configured_output_resolution.w;
3543 res_h = e_config->configured_output_resolution.h;
3547 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3556 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3560 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3563 Evas_GL *evasgl = NULL;
3564 Evas_GL_API *glapi = NULL;
3565 Evas_GL_Context *ctx = NULL;
3566 Evas_GL_Surface *sfc = NULL;
3567 Evas_GL_Config *cfg = NULL;
3569 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3571 if (!e_comp_gl_get()) return;
3573 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3574 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3576 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3577 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3579 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3580 * then we should get evas from ecore_evas.
3583 evas = e_comp->evas;
3585 evas = ecore_evas_get(e_comp->ee);
3587 evasgl = evas_gl_new(evas);
3588 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3590 glapi = evas_gl_api_get(evasgl);
3591 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3592 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3594 cfg = evas_gl_config_new();
3595 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3597 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3598 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3600 ctx = evas_gl_context_create(evasgl, NULL);
3601 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3603 res = evas_gl_make_current(evasgl, sfc, ctx);
3604 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3606 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3607 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3609 evas_gl_config_free(cfg);
3611 evas_gl->gl = evasgl;
3612 evas_gl->glapi = glapi;
3613 evas_gl->glsfc = sfc;
3614 evas_gl->glctx = ctx;
3616 e_comp_wl->evas_gl = evas_gl;
3618 /* for native surface */
3621 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3626 evas_gl_config_free(cfg);
3627 evas_gl_make_current(evasgl, NULL, NULL);
3628 evas_gl_context_destroy(evasgl, ctx);
3629 evas_gl_surface_destroy(evasgl, sfc);
3630 evas_gl_free(evasgl);
3637 _e_comp_wl_gl_popup_cb_close(void *data,
3638 Evas_Object *obj EINA_UNUSED,
3639 void *event_info EINA_UNUSED)
3641 evas_object_del(data);
3645 _e_comp_wl_gl_popup_cb_focus(void *data,
3646 Evas_Object *obj EINA_UNUSED,
3647 void *event_info EINA_UNUSED)
3649 elm_object_focus_set(data, EINA_TRUE);
3654 _e_comp_wl_gl_idle(void *data)
3658 /* show warning window to notify failure of gl init */
3661 Evas_Object *win, *bg, *popup, *btn;
3663 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3664 elm_win_title_set(win, "Compositor Warning");
3665 elm_win_autodel_set(win, EINA_TRUE);
3666 elm_win_borderless_set(win, EINA_TRUE);
3667 elm_win_role_set(win, "notification-low");
3668 elm_win_alpha_set(win, EINA_TRUE);
3670 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3671 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3672 elm_win_resize_object_add(win, bg);
3673 evas_object_color_set(bg, 125, 125, 125, 125);
3674 evas_object_show(bg);
3676 popup = elm_popup_add(win);
3677 elm_object_text_set(popup,
3678 _( "Your screen does not support OpenGL.<br>"
3679 "Falling back to software engine."));
3680 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3682 btn = elm_button_add(popup);
3683 elm_object_text_set(btn, "Close");
3684 elm_object_part_content_set(popup, "button1", btn);
3685 evas_object_show(btn);
3687 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3688 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3690 evas_object_show(popup);
3691 evas_object_show(win);
3695 return ECORE_CALLBACK_CANCEL;
3699 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3701 struct wl_client *client = data;
3707 wl_client_get_credentials(client, &pid, &uid, &gid);
3709 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3711 _e_comp_wl_pname_print(pid);
3712 _e_comp_wl_pname_get(pid, name, sizeof(name));
3713 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3717 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3719 char buf[1024] = {0, };
3721 vsnprintf(buf, 1024, fmt, args);
3725 DBG("[libds] %s", buf);
3728 INF("[libds] %s", buf);
3731 ERR("[libds] %s", buf);
3739 _e_comp_wl_display_create(void)
3742 E_Comp_Wl_Data *wl_cdata;
3747 /* create new compositor data */
3748 if (!(comp = E_NEW(E_Comp_Data, 1)))
3750 ERR("Could not create compositor data: %m");
3753 wl_cdata = &comp->base;
3755 /* set compositor wayland data */
3756 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3758 g_mutex_init(&flush_mutex);
3760 /* try to create a wayland display */
3761 if (!(wl_cdata->wl.disp = wl_display_create()))
3763 ERR("Could not create a Wayland display: %m");
3767 /* try to setup wayland socket */
3768 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3770 ERR("Could not create Wayland display socket: %m");
3771 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3775 res = e_comp_socket_init(name);
3776 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3777 PRCTL("[Winsys] change permission and create sym link for %s", name);
3779 /* set wayland display environment variable */
3780 e_env_set("WAYLAND_DISPLAY", name);
3782 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3783 /* wl_cdata->output.scale = e_scale; */
3785 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3787 if (!e_compositor_init(wl_cdata->wl.disp))
3789 ERR("Failed to initialize compositor");
3793 comp->client_created.notify = _e_comp_wl_cb_client_created;
3794 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3796 if (!e_comp_wl_subsurfaces_init())
3798 ERR("Failed to init_subsurfaces");
3799 goto subsurfaces_err;
3802 /* initialize shm mechanism */
3803 wl_display_init_shm(wl_cdata->wl.disp);
3805 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3807 /* try to init data manager */
3808 if (!e_comp_wl_data_manager_init())
3810 ERR("Could not initialize data manager");
3814 /* try to init input */
3815 if (!e_comp_wl_input_init())
3817 ERR("Could not initialize input");
3821 if (e_comp_gl_get())
3822 _e_comp_wl_gl_init(NULL);
3824 /* get the wayland display loop */
3825 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3827 /* get the file descriptor of the wayland event loop */
3828 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3830 /* create a listener for wayland main loop events */
3832 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3833 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3834 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3835 _e_comp_wl_cb_prepare, wl_cdata);
3840 e_comp_wl_data_manager_shutdown();
3842 e_comp_wl_subsurfaces_shutdown();
3844 wl_list_remove(&comp->client_created.link);
3846 e_env_unset("WAYLAND_DISPLAY");
3848 wl_display_destroy(wl_cdata->wl.disp);
3850 g_mutex_clear(&flush_mutex);
3856 _e_comp_wl_gl_shutdown(void)
3858 if (!e_comp_wl->evas_gl) return;
3860 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3862 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3863 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3864 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3865 evas_gl_free(e_comp_wl->evas_gl->gl);
3867 E_FREE(e_comp_wl->evas_gl);
3870 /* public functions */
3873 * Creates and initializes a Wayland compositor with ecore.
3874 * Registers callback handlers for keyboard and mouse activity
3875 * and other client events.
3877 * @returns true on success, false if initialization failed.
3880 e_comp_wl_init(void)
3882 TRACE_DS_BEGIN(COMP_WL:INIT);
3884 /* try to create a wayland compositor */
3885 if (!_e_comp_wl_display_create())
3887 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3892 e_comp_wl_shell_init();
3894 #ifdef HAVE_WAYLAND_TBM
3895 e_comp_wl_tbm_init();
3897 e_comp_wl_remote_surface_init();
3901 e_comp_wl_screenshooter_init();
3903 if (!e_comp_wl_video_init())
3904 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3906 e_comp_wl_viewport_init();
3907 e_comp_wl_capture_init();
3908 e_comp_wl_renderer_init();
3909 _e_comp_wl_move_resize_init();
3910 e_presentation_time_init();
3911 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3914 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3915 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3917 /* add event handlers to catch E events */
3918 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3919 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3920 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3921 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3922 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3923 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3924 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3925 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3926 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3928 /* add hooks to catch e_client events */
3929 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3930 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3931 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3932 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3933 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3935 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3942 e_comp_wl_deferred_job(void)
3944 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3947 /* internal functions */
3949 e_comp_wl_shutdown(void)
3951 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3953 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3955 e_comp_wl_subsurfaces_shutdown();
3957 E_FREE_LIST(handlers, ecore_event_handler_del);
3958 E_FREE_LIST(hooks, e_client_hook_del);
3959 _e_comp_wl_gl_shutdown();
3961 e_blender_shutdown();
3962 e_presentation_time_shutdown();
3963 e_comp_wl_renderer_shutdown();
3964 e_comp_wl_capture_shutdown();
3965 e_comp_wl_viewport_shutdown();
3966 e_comp_wl_video_shutdown();
3967 e_comp_wl_screenshooter_shutdown();
3969 e_comp_wl_remote_surface_shutdown();
3971 e_pixmap_shutdown();
3973 e_wtz_shell_shutdown();
3974 e_comp_wl_shell_shutdown();
3975 e_comp_wl_input_shutdown();
3977 wl_list_remove(&comp->client_created.link);
3980 e_comp->wl_comp_data = NULL;
3984 E_Comp_Wl_Output *output;
3986 if (e_comp_wl->screenshooter.global)
3987 wl_global_destroy(e_comp_wl->screenshooter.global);
3989 EINA_LIST_FREE(e_comp_wl->outputs, output)
3991 if (output->id) eina_stringshare_del(output->id);
3992 if (output->make) eina_stringshare_del(output->make);
3993 if (output->model) eina_stringshare_del(output->model);
3997 /* delete fd handler */
3998 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
4000 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
4001 cursor_timer_ec = NULL;
4003 /* free allocated data structure */
4009 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4011 e_object_unref(E_OBJECT(ev->ec));
4016 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4019 ev = E_NEW(E_Event_Client, 1);
4022 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4024 /* set usable early because shell module checks this */
4025 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4026 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4028 e_pixmap_resource_set(ec->pixmap, buffer);
4029 e_pixmap_dirty(ec->pixmap);
4030 e_pixmap_refresh(ec->pixmap);
4032 e_comp_wl_map_size_cal_from_buffer(ec);
4033 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4035 /* wm-policy module uses it */
4036 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4039 e_object_ref(E_OBJECT(ec));
4040 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4041 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4045 e_comp_wl_surface_commit(E_Client *ec)
4050 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4051 if (!e_comp_object_damage_exists(ec->frame))
4053 if ((ec->comp_data->video_client) ||
4054 (!e_client_video_hw_composition_check(ec)))
4055 e_pixmap_image_clear(ec->pixmap, 1);
4058 ignored = ec->ignored;
4060 if (e_comp_wl_subsurface_order_commit(ec))
4062 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4063 e_comp_wl_subsurface_restack(topmost);
4064 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4067 if (!e_pixmap_usable_get(ec->pixmap))
4069 if (ec->comp_data->mapped)
4071 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
4073 ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
4074 ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
4076 else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
4077 (ec == e_comp_wl->drag_client))
4079 ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
4080 ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
4081 ec->visible = EINA_FALSE;
4082 evas_object_hide(ec->frame);
4083 ec->comp_data->mapped = 0;
4087 if (ec->comp_data->sub.below_obj && evas_object_visible_get(ec->comp_data->sub.below_obj))
4088 evas_object_hide(ec->comp_data->sub.below_obj);
4092 if (!ec->comp_data->mapped)
4094 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
4097 ELOGF("COMP", "Try to map2. Call shell.map.", ec);
4098 ec->comp_data->shell.map(ec->comp_data->shell.surface);
4100 else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
4101 (ec == e_comp_wl->drag_client))
4103 ELOGF("COMP", "Try to map2. Show window. internal:%d, drag:%d",
4104 ec, ec->internal, (ec == e_comp_wl->drag_client));
4105 ec->visible = EINA_TRUE;
4107 evas_object_show(ec->frame);
4108 ec->comp_data->mapped = 1;
4112 if (ec->comp_data->sub.below_obj && !evas_object_visible_get(ec->comp_data->sub.below_obj)
4113 && evas_object_visible_get(ec->frame))
4114 evas_object_show(ec->comp_data->sub.below_obj);
4116 ec->ignored = ignored;
4118 if (ec->is_cursor && ec->visible)
4120 /* ignore cursor changes during resize/move I guess */
4121 if (!e_client_action_get())
4123 if (e_comp->pointer)
4125 x = e_comp->pointer->hot.x;
4126 y = e_comp->pointer->hot.y;
4128 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4134 static E_Comp_Wl_Output *
4135 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4138 E_Comp_Wl_Output *output;
4140 EINA_LIST_FOREACH(outputs, l, output)
4142 if (!strcmp(output->id, id))
4150 * Initializes information about one display output.
4152 * Adds or updates the given data about a single display output,
4153 * with an id matching the provided id.
4155 * @param id identification of output to be added or changed
4156 * @param make manufacturer name of the display output
4157 * @param model model name of the display output
4158 * @param x output's top left corner x coordinate
4159 * @param y output's top left corner y coordinate
4160 * @param w output's width in pixels
4161 * @param h output's height in pixels
4162 * @param pw output's physical width in millimeters
4163 * @param ph output's physical height in millimeters
4164 * @param refresh output's refresh rate in mHz
4165 * @param subpixel output's subpixel layout
4166 * @param transform output's rotation and/or mirror transformation
4168 * @returns True if a display output object could be added or updated
4171 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4172 int x, int y, int w, int h, int pw, int ph,
4173 unsigned int refresh, unsigned int subpixel,
4174 unsigned int transform)
4176 E_Comp_Wl_Output *output;
4178 struct wl_resource *resource;
4180 /* retrieve named output; or create it if it doesn't exist */
4181 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4184 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4186 if (id) output->id = eina_stringshare_add(id);
4188 output->make = eina_stringshare_add(make);
4190 output->make = eina_stringshare_add("unknown");
4192 output->model = eina_stringshare_add(model);
4194 output->model = eina_stringshare_add("unknown");
4196 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4199 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4200 2, output, _e_comp_wl_cb_output_bind);
4202 output->resources = NULL;
4203 output->scale = e_scale;
4206 /* update the output details */
4211 output->phys_width = pw;
4212 output->phys_height = ph;
4213 output->refresh = refresh;
4214 output->subpixel = subpixel;
4215 output->transform = transform;
4217 if (output->scale <= 0)
4218 output->scale = e_scale;
4220 /* if we have bound resources, send updates */
4221 EINA_LIST_FOREACH(output->resources, l2, resource)
4223 wl_output_send_geometry(resource,
4224 output->x, output->y,
4226 output->phys_height,
4228 output->make ?: "", output->model ?: "",
4231 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4232 wl_output_send_scale(resource, output->scale);
4234 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4235 output->w, output->h, output->refresh);
4237 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4238 wl_output_send_done(resource);
4245 e_comp_wl_output_remove(const char *id)
4247 E_Comp_Wl_Output *output;
4249 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4252 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4254 /* wl_global_destroy(output->global); */
4256 /* eina_stringshare_del(output->id); */
4257 /* eina_stringshare_del(output->make); */
4258 /* eina_stringshare_del(output->model); */
4265 _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)
4267 struct wl_resource *res;
4269 uint32_t serial, keycode;
4270 struct wl_client *wc = NULL;
4271 E_Comp_Config *comp_conf = NULL;
4272 const char *device_name = NULL;
4274 keycode = (ev->keycode - 8);
4276 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4278 comp_conf = e_comp_config_get();
4280 if (ec && ec->comp_data)
4282 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4285 wc = wl_resource_get_client(surface);
4288 EINA_LIST_FOREACH(key_list, l, res)
4290 if (wl_resource_get_client(res) != wc) continue;
4292 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4293 if (!e_input_thread_mode_get())
4295 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4296 device_name = ecore_device_name_get(ev->dev);
4302 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4303 device_name = e_device_name_get(dev);
4307 if (comp_conf && comp_conf->input_log_enable)
4308 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4310 wl_keyboard_send_key(res, serial, ev->timestamp,
4317 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4319 E_Client *ec = NULL;
4321 E_Comp_Wl_Key_Data *end, *k;
4323 if (ev->window != e_comp->ee_win)
4328 keycode = (ev->keycode - 8);
4329 if (!(e_comp_wl = e_comp->wl_comp_data))
4334 #ifndef E_RELEASE_BUILD
4335 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4336 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4337 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4338 eina_streq(ev->key, "BackSpace"))
4344 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4346 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4348 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4350 /* ignore server-generated key repeats */
4351 if (k->key == keycode)
4353 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4358 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4359 g_rec_mutex_lock(&e_comp->input_key_grabs_mutex);
4361 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4363 ec = e_client_focused_get();
4364 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4365 if (ec && ec->comp_data && surface)
4367 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4368 if (e_comp_wl->kbd.focused)
4370 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4372 /* A key only sent to clients is added to the list */
4373 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4374 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4376 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4378 DBG("wl_array_add: Out of memory\n");
4379 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4380 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4381 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4384 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4388 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4392 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4394 /* update modifier state */
4395 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4401 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4403 E_Client *ec = NULL;
4404 uint32_t keycode, delivered_key;
4405 E_Comp_Wl_Key_Data *end, *k;
4407 if (ev->window != e_comp->ee_win)
4412 keycode = (ev->keycode - 8);
4414 if (!(e_comp_wl = e_comp->wl_comp_data))
4419 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4421 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4422 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4424 if (k->key == keycode)
4431 e_comp_wl->kbd.keys.size =
4432 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4434 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4436 /* 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) */
4437 g_rec_mutex_lock(&e_comp->input_key_grabs_mutex);
4438 if ((delivered_key) ||
4439 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4441 ec = e_client_focused_get();
4443 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4444 if (e_comp_wl->kbd.focused)
4446 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4448 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4450 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4452 /* update modifier state */
4453 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4459 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4461 Eina_Bool res = EINA_FALSE;
4463 if (type == ECORE_EVENT_KEY_DOWN)
4465 res = e_comp_wl_key_down(ev, dev);
4467 else if (type == ECORE_EVENT_KEY_UP)
4469 res = e_comp_wl_key_up(ev, dev);
4476 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4479 struct wl_client *wc;
4480 uint32_t serial, btn;
4481 struct wl_resource *res;
4482 E_Comp_Config *comp_conf = NULL;
4484 if (ec->cur_mouse_action || e_comp_wl->drag)
4486 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4487 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4491 case 1: btn = BTN_LEFT; break;
4492 case 2: btn = BTN_MIDDLE; break;
4493 case 3: btn = BTN_RIGHT; break;
4494 default: btn = button_id; break;
4497 e_comp_wl->ptr.button = btn;
4498 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4499 if (!surface) return EINA_FALSE;
4501 if (!eina_list_count(e_comp_wl->ptr.resources))
4504 wc = wl_resource_get_client(surface);
4505 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4507 comp_conf = e_comp_config_get();
4509 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4511 if (wl_resource_get_client(res) != wc) continue;
4512 if (!e_comp_wl_input_pointer_check(res)) continue;
4513 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4515 if (comp_conf && comp_conf->input_log_enable)
4516 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4518 wl_pointer_send_button(res, serial, timestamp, btn, state);
4525 e_comp_wl_touch_cancel(void)
4527 _e_comp_wl_touch_cancel();
4530 E_API E_Comp_Wl_Hook *
4531 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4535 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4536 ch = E_NEW(E_Comp_Wl_Hook, 1);
4537 if (!ch) return NULL;
4538 ch->hookpoint = hookpoint;
4540 ch->data = (void*)data;
4541 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4546 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4549 if (_e_comp_wl_hooks_walking == 0)
4551 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4555 _e_comp_wl_hooks_delete++;
4558 E_API E_Comp_Wl_Pid_Hook *
4559 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4561 E_Comp_Wl_Pid_Hook *ch;
4563 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4565 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4566 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4568 ch->hookpoint = hookpoint;
4570 ch->data = (void*)data;
4571 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4577 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4580 if (_e_comp_wl_pid_hooks_walking == 0)
4582 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4586 _e_comp_wl_pid_hooks_delete++;
4589 E_API E_Comp_Wl_Intercept_Hook *
4590 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4592 E_Comp_Wl_Intercept_Hook *ch;
4594 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4595 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4596 if (!ch) return NULL;
4597 ch->hookpoint = hookpoint;
4599 ch->data = (void*)data;
4600 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4605 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4608 if (_e_comp_wl_intercept_hooks_walking == 0)
4610 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4614 _e_comp_wl_intercept_hooks_delete++;
4618 e_comp_wl_shell_surface_ready(E_Client *ec)
4622 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4626 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4628 e_config->use_cursor_timer = !!enabled;
4630 if (e_config->use_cursor_timer == EINA_FALSE)
4632 if (e_comp_wl->ptr.hide_tmr)
4634 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4635 e_comp_wl->ptr.hide_tmr = NULL;
4637 cursor_timer_ec = NULL;
4639 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4642 if (e_pointer_is_hidden(e_comp->pointer))
4644 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4650 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4652 EINA_SAFETY_ON_NULL_RETURN(wc);
4653 EINA_SAFETY_ON_NULL_RETURN(dev);
4655 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4659 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4661 EINA_SAFETY_ON_NULL_RETURN(wc);
4662 EINA_SAFETY_ON_NULL_RETURN(dev);
4664 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4668 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4670 struct wl_resource *res;
4671 struct wl_client *wc;
4673 uint32_t serial, wl_keycode;
4674 enum wl_keyboard_key_state state;
4675 E_Comp_Config *comp_conf = NULL;
4676 const char *dev_name = NULL;
4678 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4679 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4680 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4682 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4683 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4685 wl_keycode = keycode - 8;
4686 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4688 wc = wl_resource_get_client(surface);
4689 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4690 if (!time) time = e_util_timestamp_get();
4691 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4692 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4694 comp_conf = e_comp_config_get();
4695 e_keyrouter_event_surface_send(ec, keycode);
4697 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4698 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4700 if (wl_resource_get_client(res) != wc) continue;
4701 if (!e_input_thread_mode_get())
4705 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4706 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4710 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4717 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4718 dev_name = e_device_name_get(dev);
4722 if (comp_conf && comp_conf->input_log_enable)
4723 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4726 wl_keyboard_send_key(res, serial, time,
4729 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4735 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4737 struct wl_resource *res;
4738 struct wl_client *wc;
4740 uint32_t serial, wl_keycode, cancel_keycode;
4741 E_Comp_Config *comp_conf = NULL;
4743 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4744 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4745 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4746 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->xkb.keymap, EINA_FALSE);
4748 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4749 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4751 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4752 if (cancel_keycode == XKB_KEYCODE_INVALID)
4754 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4757 cancel_keycode = cancel_keycode - 8;
4759 wl_keycode = keycode - 8;
4760 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4762 wc = wl_resource_get_client(surface);
4763 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4764 if (!time) time = e_util_timestamp_get();
4766 comp_conf = e_comp_config_get();
4767 e_keyrouter_event_surface_send(ec, keycode);
4769 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4770 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4772 if (wl_resource_get_client(res) != wc) continue;
4773 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4774 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4776 if (comp_conf && comp_conf->input_log_enable)
4777 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4778 wl_keyboard_send_key(res, serial, time,
4779 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4780 wl_keyboard_send_key(res, serial, time,
4781 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4782 wl_keyboard_send_key(res, serial, time,
4783 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4785 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4792 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)
4794 struct wl_client *wc;
4796 E_Devicemgr_Input_Device *device = NULL;
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4799 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4800 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4802 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4803 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4805 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4807 wc = wl_resource_get_client(surface);
4808 if (!time) time = e_util_timestamp_get();
4809 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4813 _e_comp_wl_send_event_device(wc, time, dev, serial);
4814 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4818 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4819 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4822 x = x + ec->client.x;
4823 y = y + ec->client.y;
4825 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4831 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)
4833 E_Devicemgr_Input_Device *device;
4835 struct wl_client *wc;
4837 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4838 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4839 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4841 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4842 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4844 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4846 wc = wl_resource_get_client(surface);
4847 if (!time) time = e_util_timestamp_get();
4848 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4852 _e_comp_wl_send_event_device(wc, time, dev, serial);
4853 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4857 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4858 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4861 x = x + ec->client.x;
4862 y = y + ec->client.y;
4864 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4870 e_comp_wl_touch_cancel_send(E_Client *ec)
4872 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4874 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4876 _e_comp_wl_send_touch_cancel(ec);
4882 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4885 struct wl_client *wc;
4887 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4888 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4889 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4891 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4892 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4894 wc = wl_resource_get_client(surface);
4895 if (!time) time = e_util_timestamp_get();
4896 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4898 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4899 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4902 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4903 WL_POINTER_BUTTON_STATE_PRESSED);
4905 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4906 WL_POINTER_BUTTON_STATE_RELEASED);
4912 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4915 struct wl_client *wc;
4917 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4918 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4919 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4921 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4922 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4924 wc = wl_resource_get_client(surface);
4925 if (!time) time = e_util_timestamp_get();
4926 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4928 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4929 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4931 x = x + ec->client.x;
4932 y = y + ec->client.y;
4934 _e_comp_wl_send_mouse_move(ec, x, y, time);
4940 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4943 struct wl_client *wc;
4945 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4946 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4947 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4949 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4950 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4952 wc = wl_resource_get_client(surface);
4953 if (!time) time = e_util_timestamp_get();
4954 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4956 if (_e_comp_wl_check_cursor_timer_needed(ec))
4958 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4962 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4963 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4965 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4967 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4969 if (_e_comp_wl_check_cursor_timer_needed(ec))
4970 _e_comp_wl_cursor_move_timer_control(ec);
4977 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4980 struct wl_client *wc;
4981 struct wl_resource *res;
4984 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4985 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4987 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4988 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4990 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4991 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4993 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4994 wc = wl_resource_get_client(surface);
4995 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4996 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4998 if (!e_comp_wl_input_pointer_check(res)) continue;
4999 if (wl_resource_get_client(res) != wc) continue;
5001 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5002 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5004 wl_pointer_send_enter(res, serial, surface,
5005 wl_fixed_from_int(x),
5006 wl_fixed_from_int(y));
5007 ec->pointer_enter_sent = EINA_TRUE;
5009 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5015 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5018 struct wl_client *wc;
5019 struct wl_resource *res;
5022 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5023 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5024 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5025 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5026 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5027 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5029 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5030 wc = wl_resource_get_client(surface);
5031 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5032 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5034 if (!e_comp_wl_input_pointer_check(res)) continue;
5035 if (wl_resource_get_client(res) != wc) continue;
5037 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5038 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5040 wl_pointer_send_leave(res, serial, surface);
5041 ec->pointer_enter_sent = EINA_FALSE;
5048 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)
5050 Evas_Event_Mouse_In ev_in;
5053 if (ec->pointer_enter_sent) return;
5055 ev_in.buttons = buttons;
5063 ev_in.modifiers = modifiers;
5064 ev_in.locks = locks;
5065 ev_in.timestamp = timestamp;
5066 ev_in.event_flags = event_flags;
5069 ev_in.event_src = event_src;
5071 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5075 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)
5077 Evas_Event_Mouse_Out ev_out;
5080 if (!ec->pointer_enter_sent) return;
5082 ev_out.buttons = buttons;
5084 ev_out.output.x = x;
5085 ev_out.output.y = y;
5086 ev_out.canvas.x = x;
5087 ev_out.canvas.y = y;
5090 ev_out.modifiers = modifiers;
5091 ev_out.locks = locks;
5092 ev_out.timestamp = timestamp;
5093 ev_out.event_flags = event_flags;
5096 ev_out.event_src = event_src;
5098 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5102 e_comp_wl_cursor_hide(E_Client *ec)
5104 struct wl_resource *res;
5105 struct wl_client *wc;
5109 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5111 if (e_comp_wl->ptr.hide_tmr)
5113 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5114 e_comp_wl->ptr.hide_tmr = NULL;
5116 cursor_timer_ec = NULL;
5118 if (!ec) return EINA_FALSE;
5119 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5120 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5121 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5123 wc = wl_resource_get_client(surface);
5124 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5125 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5127 if (!e_comp_wl_input_pointer_check(res)) continue;
5128 if (wl_resource_get_client(res) != wc) continue;
5129 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5130 wl_pointer_send_leave(res, serial, surface);
5131 ec->pointer_enter_sent = EINA_FALSE;
5137 /* surface to buffer
5138 * - width : surface width
5139 * - height : surface height
5140 * - transform: buffer transform
5141 * - scale : buffer scale
5143 * - width : screen width
5144 * - height : screen height
5145 * - transform: output transform
5146 * - scale : output scale
5148 static E_Util_Transform_Matrix
5149 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5151 E_Util_Transform_Matrix m;
5153 e_util_transform_matrix_load_identity(&m);
5155 if (transform & 0x4)
5157 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5158 e_util_transform_matrix_flip_x(&m);
5159 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5162 switch (transform & 0x3)
5164 case WL_OUTPUT_TRANSFORM_90:
5165 e_util_transform_matrix_translate(&m, -width, 0, 0);
5166 e_util_transform_matrix_rotation_z(&m, 270);
5168 case WL_OUTPUT_TRANSFORM_180:
5169 e_util_transform_matrix_translate(&m, -width, -height, 0);
5170 e_util_transform_matrix_rotation_z(&m, 180);
5172 case WL_OUTPUT_TRANSFORM_270:
5173 e_util_transform_matrix_translate(&m, 0, -height, 0);
5174 e_util_transform_matrix_rotation_z(&m, 90);
5180 e_util_transform_matrix_scale(&m, scale, scale, 1);
5185 /* surface to buffer
5186 * - surface width, surface height, buffer transform, buffer scale
5188 * - screen width, screen height, output transform, output scale
5191 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5193 E_Util_Transform_Matrix m;
5194 E_Util_Transform_Vertex v;
5196 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5198 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5199 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5200 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5204 * - buffer width, buffer height, buffer transform, buffer scale
5207 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5209 E_Util_Transform_Matrix m;
5210 E_Util_Transform_Vertex v;
5213 if (transform != 0 || scale > 1)
5215 tw = ((transform % 2) ? height : width) / scale;
5216 th = ((transform % 2) ? width : height) / scale;
5224 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5225 m = e_util_transform_matrix_inverse_get(&m);
5227 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5228 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5229 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5232 /* surface to buffer
5233 * - surface width, surface height, buffer transform, buffer scale
5235 * - screen width, screen height, output transform, output scale
5238 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5239 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5241 E_Util_Transform_Matrix m;
5242 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5243 E_Util_Transform_Rect_Vertex sv;
5245 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5247 sv = e_util_transform_rect_to_vertices(&sr);
5248 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5249 sr = e_util_transform_vertices_to_rect(&sv);
5258 * - buffer width, buffer height, buffer transform, buffer scale
5261 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5262 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5264 E_Util_Transform_Matrix m;
5265 E_Util_Transform_Rect br = {bx, by, bw, bh};
5266 E_Util_Transform_Rect_Vertex bv;
5269 if (transform != 0 || scale > 1)
5271 tw = ((transform % 2) ? height : width) / scale;
5272 th = ((transform % 2) ? width : height) / scale;
5280 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5281 m = e_util_transform_matrix_inverse_get(&m);
5283 bv = e_util_transform_rect_to_vertices(&br);
5284 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5285 br = e_util_transform_vertices_to_rect(&bv);
5293 EINTERN E_Comp_Wl_Output*
5294 e_comp_wl_output_find(E_Client *ec)
5297 E_Comp_Wl_Output *output;
5299 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5301 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5303 if (output->transform % 2)
5305 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5306 ec->y < output->x || ec->y >= (output->x + output->w))
5311 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5312 ec->y < output->y || ec->y >= (output->y + output->h))
5322 EINTERN Eina_Array *
5323 e_comp_wl_output_find_all(E_Client *ec)
5325 E_Comp_Wl_Output *output;
5326 Eina_Array *outputs;
5329 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5331 outputs = eina_array_new(4);
5335 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5337 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5338 output->x, output->y, output->w, output->h))
5340 eina_array_push(outputs, output);
5344 if (eina_array_count(outputs) == 0)
5346 eina_array_free(outputs);
5353 // --------------------------------------------------------
5354 // tizen_move_resize
5355 // --------------------------------------------------------
5357 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5364 E_Client_Pending_Geometry *geo;
5367 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5368 if (ec->fullscreen || ec->maximized) goto err;
5370 geo = E_NEW(E_Client_Pending_Geometry, 1);
5373 geo->serial = serial;
5379 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5380 ec->surface_sync.wait_commit = EINA_TRUE;
5385 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5392 e_comp_wl_commit_sync_configure(E_Client *ec)
5395 E_Client_Pending_Geometry *geo;
5397 Eina_Bool match_size = EINA_FALSE;
5404 if (!ec || !ec->frame) goto ret;
5405 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5408 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5409 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5411 if (eina_list_count(ec->surface_sync.pending_geometry))
5413 Eina_List *ll = NULL;
5414 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5418 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5423 if ((geo->w == bw) && (geo->h == bh))
5425 match_size = EINA_TRUE;
5430 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5437 if ((config.w != ec->w) || (config.h != ec->h))
5439 e_client_size_set(ec, config.w, config.h);
5440 ec->changes.size = EINA_TRUE;
5444 // FIXME: The geometry of the client would be better to be calculated
5445 // at e_desk or at e_desk_area. So the position(x,y) of the client
5446 // should be calcuated at the e_desk or at the e_desk_area.
5448 desk = e_comp_desk_find_by_ec(ec);
5451 ec->client.x = desk->geom.x + config.x;
5452 ec->client.y = desk->geom.y + config.y;
5456 ec->client.x = config.x;
5457 ec->client.y = config.y;
5460 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5462 e_client_pos_set(ec, ec->client.x, ec->client.y);
5464 ec->changes.pos = 1;
5468 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5472 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5473 ec->surface_sync.wait_commit = EINA_FALSE;
5475 if ((ec->comp_data->shell.surface) &&
5476 (ec->comp_data->shell.configure))
5478 ec->comp_data->shell.configure(ec->comp_data->shell.surface,
5483 // rollback wait_commit if there are pending requests remained
5484 if (eina_list_count(ec->surface_sync.pending_geometry))
5485 ec->surface_sync.wait_commit = EINA_TRUE;
5490 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);
5497 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5498 struct wl_resource *res_moveresize)
5500 wl_resource_destroy(res_moveresize);
5504 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5505 struct wl_resource *res_moveresize,
5506 struct wl_resource *surface,
5513 /* to be implemented */
5516 int cur_w = 0, cur_h = 0;
5518 ec = e_client_from_surface_resource(surface);
5521 pending = e_client_pending_geometry_has(ec);
5522 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5523 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);
5527 if ((cur_w == w) && (cur_h == h))
5529 e_client_pos_set(ec, x, y);
5530 ec->changes.pos = 1;
5536 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5540 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5543 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5545 _tz_move_resize_iface_cb_destroy,
5546 _tz_move_resize_iface_cb_set_geometry,
5550 _tz_moveresize_cb_bind(struct wl_client *client,
5551 void *data EINA_UNUSED,
5555 struct wl_resource *res_moveresize;
5557 res_moveresize = wl_resource_create(client,
5558 &tizen_move_resize_interface,
5561 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5564 wl_resource_set_implementation(res_moveresize,
5565 &_tz_move_resize_iface,
5571 ERR("Could not create tizen_move_resize_interface res: %m");
5572 wl_client_post_no_memory(client);
5576 _e_comp_wl_move_resize_init(void)
5578 if (!e_comp_wl) return;
5579 if (!e_comp_wl->wl.disp) return;
5581 if (!wl_global_create(e_comp_wl->wl.disp,
5582 &tizen_move_resize_interface,
5585 _tz_moveresize_cb_bind))
5587 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5594 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5596 E_Comp_Wl_Output *output;
5597 pid_t output_pid = 0;
5598 Eina_List *l = NULL, *l2 = NULL;
5599 struct wl_resource *resource = NULL;
5601 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5603 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5604 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5605 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5607 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5609 /* if we have bound resources, send updates */
5610 EINA_LIST_FOREACH(output->resources, l2, resource)
5612 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5613 if (output_pid != pid) continue;
5615 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5617 // send output information to the client
5618 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5626 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5628 _e_comp_wl_surface_state_init(state, w, h);
5632 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5634 _e_comp_wl_surface_state_commit(ec, state);
5638 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5640 _e_comp_wl_hook_call(hookpoint, ec);
5644 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5646 _e_comp_wl_surface_state_finish(state);
5650 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5652 _e_comp_wl_surface_state_buffer_set(state, buffer);
5656 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5657 int sx, int sy, int *dx, int *dy)
5661 case WL_OUTPUT_TRANSFORM_NORMAL:
5665 case WL_OUTPUT_TRANSFORM_FLIPPED:
5666 *dx = width - sx, *dy = sy;
5668 case WL_OUTPUT_TRANSFORM_90:
5669 *dx = height - sy, *dy = sx;
5671 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5672 *dx = height - sy, *dy = width - sx;
5674 case WL_OUTPUT_TRANSFORM_180:
5675 *dx = width - sx, *dy = height - sy;
5677 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5678 *dx = sx, *dy = height - sy;
5680 case WL_OUTPUT_TRANSFORM_270:
5681 *dx = sy, *dy = width - sx;
5683 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5693 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5696 int tx1, ty1, tx2, ty2;
5697 int width_from_buffer, height_from_buffer;
5699 switch (vp->buffer.transform)
5701 case WL_OUTPUT_TRANSFORM_90:
5702 case WL_OUTPUT_TRANSFORM_270:
5703 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5704 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5705 width_from_buffer = bh / vp->buffer.scale;
5706 height_from_buffer = bw / vp->buffer.scale;
5709 width_from_buffer = bw / vp->buffer.scale;
5710 height_from_buffer = bh / vp->buffer.scale;
5714 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5718 x2 = width_from_buffer;
5719 y2 = height_from_buffer;
5723 x1 = wl_fixed_to_int(vp->buffer.src_x);
5724 y1 = wl_fixed_to_int(vp->buffer.src_y);
5725 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5726 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5729 buffer_transform(width_from_buffer, height_from_buffer,
5730 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5731 buffer_transform(width_from_buffer, height_from_buffer,
5732 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5734 out->x = (tx1 <= tx2) ? tx1 : tx2;
5735 out->y = (ty1 <= ty2) ? ty1 : ty2;
5736 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5737 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5741 * Convert given four coordinates to elements of rectangle
5742 * @in p[4] Coordinates to be converted
5743 * @out rect x, y, width, and height
5744 * transform Angle which represents TDM_TRANSFORM of rectangle
5745 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5746 * 1. The given coordinates are not represented by rectangle.
5747 * 2. All angles except for 0, 90, 180, 270.
5750 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5752 Eina_Bool ret = EINA_FALSE;
5754 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))
5757 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5760 *rotation = TDM_TRANSFORM_NORMAL;
5763 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5767 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5770 *rotation = TDM_TRANSFORM_180;
5773 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5778 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))
5781 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5784 *rotation = TDM_TRANSFORM_90;
5787 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5791 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5794 *rotation = TDM_TRANSFORM_270;
5797 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5807 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5812 for (i = 0; i < 4; i++)
5813 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5815 if (!_coords_to_rectangle_convert(p, out, rotation))
5817 DBG("Cannot convert given coords to rectangle.\n"
5818 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5819 p[0].x, p[0].y, p[1].x, p[1].y,
5820 p[2].x, p[2].y, p[3].x, p[3].y);
5828 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5830 int trans_rotation, flip;
5832 trans_rotation = transform & 0x3;
5833 flip = transform & 0x4;
5835 return (flip + (trans_rotation + rotation) % 4);
5839 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5847 if (e_comp_wl_subsurface_check(ec))
5848 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5855 out->w = ec->comp_data->width_from_viewport;
5856 out->w = (out->w + 1) & ~1;
5857 out->h = ec->comp_data->height_from_viewport;
5859 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5860 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5864 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5866 E_Comp_Wl_Buffer *buffer;
5867 E_Comp_Wl_Buffer_Viewport *vp;
5869 enum wl_output_transform buffer_transform;
5870 unsigned int rotation;
5871 Eina_Bool res = EINA_FALSE;
5873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5875 if (e_object_is_del(E_OBJECT(ec)))
5878 vp = &ec->comp_data->scaler.buffer_viewport;
5880 if (buffer_viewport)
5882 buffer = ec->comp_data->buffer_ref.buffer;
5883 /* Getting a viewport of buffer needs geometry of buffer. */
5887 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5890 if ((output_viewport) || (transform))
5892 m = e_client_map_get(ec);
5894 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5896 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5901 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5902 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5903 * Since buffer.transform isn't applied using evas_map,
5904 * it has to be taken into account here to apply buffer.transform
5905 * and rotation of e_client_transform together. */
5907 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5909 *transform = (unsigned int)buffer_transform;
5917 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5919 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5920 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5922 /* Must be called with valid comp_data */
5923 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5925 if ((ec->comp_data->role_name == NULL) ||
5926 (ec->comp_data->role_name == role_name) ||
5927 (strcmp(ec->comp_data->role_name, role_name) == 0))
5929 ec->comp_data->role_name = role_name;
5935 wl_resource_post_error(error_resource, error_code,
5936 "Cannot assign role %s to wl_surface@%d,"
5937 " already has role %s\n",
5939 ec->comp_data->wl_surface ?
5940 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5941 ec->comp_data->role_name);
5947 EINTERN const char *
5948 e_comp_wl_surface_role_get(E_Client *ec)
5950 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5951 return ec->comp_data ? ec->comp_data->role_name : NULL;
5954 EINTERN struct wl_resource *
5955 e_comp_wl_client_surface_get(E_Client *ec)
5957 struct wl_resource *surface = NULL;
5958 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5959 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5961 g_mutex_lock(&ec->comp_data->surface_mutex);
5962 surface = ec->comp_data->surface;
5963 g_mutex_unlock(&ec->comp_data->surface_mutex);
5968 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5970 EINA_SAFETY_ON_NULL_RETURN(ec);
5971 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5973 g_mutex_lock(&ec->comp_data->surface_mutex);
5974 ec->comp_data->surface = surface;
5975 g_mutex_unlock(&ec->comp_data->surface_mutex);
5979 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5981 return e_compositor_util_client_from_surface_resource(surface_resource);
5985 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5987 if (!ec->comp_data->mapped)
5989 if (ec->comp_data->shell.surface &&
5990 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5992 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5998 if (ec->comp_data->mapped)
6000 /* will be unmapped. so run capture */
6001 e_comp_wl_remote_surface_image_save(ec);
6005 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
6007 ec->comp_data->pending.sx = sx;
6008 ec->comp_data->pending.sy = sy;
6009 ec->comp_data->pending.new_attach = EINA_TRUE;
6011 e_client_fps_update(ec);
6015 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6017 if (ec->comp_data->pending.opaque)
6018 eina_tiler_clear(ec->comp_data->pending.opaque);
6022 eina_tiler_union(ec->comp_data->pending.opaque, region);
6024 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6028 ec->argb = EINA_FALSE;
6029 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6031 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6032 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6040 ec->argb = EINA_TRUE;
6041 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6043 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6044 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6050 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6052 if (ec->comp_data->pending.input)
6053 eina_tiler_clear(ec->comp_data->pending.input);
6057 if (eina_tiler_empty(region))
6059 ELOGF("COMP", " |unset input rect", NULL);
6060 e_comp_object_input_objs_del(ec->frame);
6061 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6064 eina_tiler_union(ec->comp_data->pending.input, region);
6068 eina_tiler_rect_add(ec->comp_data->pending.input,
6069 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6074 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6076 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6080 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6082 E_Comp_Wl_Subsurf_Data *sdata;
6087 if (ec->comp_data->frames)
6089 ec->comp_data->frames =
6090 eina_list_remove(ec->comp_data->frames, callback_resource);
6093 if (ec->comp_data->pending.frames)
6095 ec->comp_data->pending.frames =
6096 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6099 sdata = ec->comp_data->sub.data;
6100 if ((sdata) && (sdata->cached.frames))
6102 sdata->cached.frames =
6103 eina_list_remove(sdata->cached.frames, callback_resource);
6108 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6110 if (e_object_is_del(E_OBJECT(ec))) return;
6112 if (e_comp_wl_remote_surface_commit(ec)) return;
6114 e_comp_wl_surface_commit(ec);
6116 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6120 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6122 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6123 ec->comp_data->sub.data = sub;
6125 /* set subsurface client properties */
6126 ec->borderless = EINA_TRUE;
6127 ec->argb = EINA_TRUE;
6128 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6129 ec->lock_border = EINA_TRUE;
6130 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6131 ec->netwm.state.skip_taskbar = EINA_TRUE;
6132 ec->netwm.state.skip_pager = EINA_TRUE;
6133 ec->no_shape_cut = EINA_TRUE;
6134 ec->border_size = 0;
6135 ec->lock_user_location = 0;
6136 ec->lock_client_location = 0;
6137 ec->lock_user_size = 0;
6138 ec->lock_client_size = 0;
6139 ec->lock_client_stacking = 0;
6140 ec->lock_user_shade = 0;
6141 ec->lock_client_shade = 0;
6142 ec->lock_user_maximize = 0;
6143 ec->lock_client_maximize = 0;
6144 ec->changes.need_maximize = 0;
6145 ec->maximized = E_MAXIMIZE_NONE;
6148 ec->new_client = ec->netwm.ping = EINA_TRUE;
6149 e_comp->new_clients++;
6150 e_client_unignore(ec);
6152 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6153 * It's not for subsurface. */
6154 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6158 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6160 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6163 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6165 sub->parent = parent;
6169 layer = e_client_layer_get(parent);
6170 if (layer > E_LAYER_BOTTOM)
6171 e_client_layer_set(ec, layer);
6174 if (parent->comp_data)
6176 /* append this client to the parents subsurface list */
6177 parent->comp_data->sub.list_pending =
6178 eina_list_append(parent->comp_data->sub.list_pending, ec);
6179 parent->comp_data->sub.list_changed = EINA_TRUE;
6184 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6186 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6187 E_Client *parent = sub->parent;
6189 parent->comp_data->sub.list =
6190 eina_list_remove(parent->comp_data->sub.list, ec);
6191 parent->comp_data->sub.list_pending =
6192 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6193 parent->comp_data->sub.below_list =
6194 eina_list_remove(parent->comp_data->sub.below_list, ec);
6195 parent->comp_data->sub.below_list_pending =
6196 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6202 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)
6204 sub->resource = subsurface_resource;
6205 sub->cached_buffer_ref.buffer = NULL;
6206 sub->synchronized = EINA_TRUE;
6207 sub->parent = parent;
6208 sub->remote_surface.offscreen_parent = offscreen_parent;
6209 if (offscreen_parent)
6210 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6212 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6214 _e_comp_wl_client_subsurface_set(ec, sub);
6215 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6217 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6221 e_comp_wl_client_subsurface_finish(E_Client *ec)
6223 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6226 e_comp_wl_client_subsurface_parent_unset(ec);
6228 e_comp_wl_surface_state_finish(&sub->cached);
6229 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6231 ec->comp_data->sub.data = NULL;
6235 e_comp_wl_client_evas_init(E_Client *ec)
6237 EINA_SAFETY_ON_NULL_RETURN(ec);
6239 _e_comp_wl_client_evas_init(ec);
6243 e_comp_wl_client_evas_deinit(E_Client *ec)
6245 EINA_SAFETY_ON_NULL_RETURN(ec);
6247 _e_comp_wl_client_evas_deinit(ec);
6251 e_comp_wl_focus_check(void)
6253 _e_comp_wl_focus_check();
6257 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6264 if ((parent->comp_data) && (parent->comp_data->sub.data))
6265 parent = parent->comp_data->sub.data->parent;