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 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
799 case ECORE_DEVICE_CLASS_TOUCH:
800 return e_devicemgr->last_device_touch;
808 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
812 case ECORE_DEVICE_CLASS_MOUSE:
813 e_devicemgr->last_device_ptr = device;
815 case ECORE_DEVICE_CLASS_KEYBOARD:
816 atomic_store(&e_devicemgr->last_device_kbd, device);
818 case ECORE_DEVICE_CLASS_TOUCH:
819 e_devicemgr->last_device_touch = device;
826 static E_Devicemgr_Input_Device *
827 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
829 E_Devicemgr_Input_Device *last_kbd = NULL;
833 case ECORE_DEVICE_CLASS_MOUSE:
834 return ec->comp_data->last_device_ptr;
835 case ECORE_DEVICE_CLASS_KEYBOARD:
836 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
838 case ECORE_DEVICE_CLASS_TOUCH:
839 return ec->comp_data->last_device_touch;
847 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
851 case ECORE_DEVICE_CLASS_MOUSE:
852 ec->comp_data->last_device_ptr = device;
854 case ECORE_DEVICE_CLASS_KEYBOARD:
855 atomic_store(&ec->comp_data->last_device_kbd, device);
857 case ECORE_DEVICE_CLASS_TOUCH:
858 ec->comp_data->last_device_touch = device;
866 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
868 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
869 struct wl_resource *dev_res;
870 const char *dev_name;
871 Ecore_Device_Class dev_class;
872 struct wl_client *wc;
876 EINA_SAFETY_ON_NULL_RETURN(dev);
879 if (ec->cur_mouse_action || e_comp_wl->drag)
881 if (e_object_is_del(E_OBJECT(ec))) return;
882 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
883 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
884 if (!surface) return;
886 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
887 dev_name = evas_device_description_get(dev);
888 last_device = _e_comp_wl_device_last_device_get(dev_class);
889 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
891 serial = wl_display_next_serial(e_comp_wl->wl.disp);
892 wc = wl_resource_get_client(surface);
893 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
894 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
896 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
897 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
899 _e_comp_wl_device_last_device_set(dev_class, input_dev);
900 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
902 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
904 if (wl_resource_get_client(dev_res) != wc) continue;
905 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
909 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
913 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
915 E_Devicemgr_Input_Device *last_device;
916 struct wl_resource *dev_res;
917 struct wl_client *wc;
921 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
922 if (!surface) return;
924 last_device = _e_comp_wl_device_last_device_get(dev_class);
925 if (!last_device) return;
927 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
929 serial = wl_display_next_serial(e_comp_wl->wl.disp);
930 wc = wl_resource_get_client(surface);
931 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
933 if (wl_resource_get_client(dev_res) != wc) continue;
934 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
939 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
941 E_Devicemgr_Input_Device *input_dev;
942 struct wl_resource *dev_res;
943 const char *dev_name;
946 EINA_SAFETY_ON_NULL_RETURN(dev);
948 dev_name = ecore_device_identifier_get(dev);
950 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
951 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
953 if (!eina_streq(input_dev->identifier, dev_name) ||
954 (input_dev->clas != ecore_device_class_get(dev))) continue;
955 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
957 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
959 if (wl_resource_get_client(dev_res) != wc) continue;
960 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
963 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
967 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
969 E_Devicemgr_Input_Device *input_dev;
970 struct wl_resource *dev_res;
971 const char *dev_name;
974 EINA_SAFETY_ON_NULL_RETURN(dev);
976 dev_name = e_device_identifier_get(dev);
978 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
979 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
981 if (!eina_streq(input_dev->identifier, dev_name) ||
982 (input_dev->clas != e_device_class_get(dev))) continue;
983 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
985 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
987 if (wl_resource_get_client(dev_res) != wc) continue;
988 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
991 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
995 _e_comp_wl_cursor_reload(E_Client *ec)
997 struct wl_resource *res;
998 struct wl_client *wc;
1004 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1005 !evas_object_visible_get(e_comp->pointer->o_ptr))
1006 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1009 if (e_object_is_del(E_OBJECT(ec))) return;
1010 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1011 if (!surface) return;
1012 if (ec->pointer_enter_sent) return;
1014 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1015 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1017 if (e_client_transform_core_enable_get(ec))
1019 double dx = 0.0, dy = 0.0;
1020 map = e_client_map_get(ec);
1021 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1027 cx = px - ec->client.x;
1028 cy = py - ec->client.y;
1030 wc = wl_resource_get_client(surface);
1031 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1032 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1034 if (!e_comp_wl_input_pointer_check(res)) continue;
1035 if (wl_resource_get_client(res) != wc) continue;
1036 wl_pointer_send_enter(res, serial, surface,
1037 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1038 ec->pointer_enter_sent = EINA_TRUE;
1040 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1044 _e_comp_wl_cursor_timer(void *data)
1046 E_Client *ec = data;
1048 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1049 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1051 e_comp_wl_cursor_hide(ec);
1053 return ECORE_CALLBACK_CANCEL;
1057 _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)
1059 E_Devicemgr_Input_Device *input_dev;
1060 struct wl_resource *dev_res;
1061 struct wl_client *wc;
1066 if (ec->cur_mouse_action) return;
1067 if (e_object_is_del(E_OBJECT(ec))) return;
1068 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1069 if (!surface) return;
1071 f_value = wl_fixed_from_double(value);
1072 wc = wl_resource_get_client(surface);
1074 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1075 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1077 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1078 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1080 if (wl_resource_get_client(dev_res) != wc) continue;
1081 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1084 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1088 _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)
1090 if (idx >= e_input_touch_max_count_get()) return;
1092 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1093 e_devicemgr->multi[idx].radius_x = radius_x;
1094 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1095 e_devicemgr->multi[idx].radius_y = radius_y;
1096 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1097 e_devicemgr->multi[idx].pressure = pressure;
1098 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1099 e_devicemgr->multi[idx].angle = angle;
1103 _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)
1105 if (idx >= e_input_touch_max_count_get()) return;
1107 if (e_devicemgr->multi[idx].radius_x != radius_x)
1109 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1110 e_devicemgr->multi[idx].radius_x = radius_x;
1112 if (e_devicemgr->multi[idx].radius_y != radius_y)
1114 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1115 e_devicemgr->multi[idx].radius_y = radius_y;
1117 if (e_devicemgr->multi[idx].pressure != pressure)
1119 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1120 e_devicemgr->multi[idx].pressure = pressure;
1122 if (e_devicemgr->multi[idx].angle != angle)
1124 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1125 e_devicemgr->multi[idx].angle = angle;
1130 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1132 Eina_Bool ret = EINA_TRUE;
1135 case EVAS_CALLBACK_MOUSE_IN:
1136 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1139 if (e_comp_wl->ptr.hide_tmr)
1141 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1142 cursor_timer_ec = ec;
1143 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1147 if (e_pointer_is_hidden(e_comp->pointer))
1152 case EVAS_CALLBACK_MOUSE_OUT:
1153 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1156 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1160 case EVAS_CALLBACK_MOUSE_MOVE:
1161 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1164 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1165 _e_comp_wl_cursor_reload(ec);
1168 case EVAS_CALLBACK_MOUSE_WHEEL:
1169 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1172 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1173 _e_comp_wl_cursor_reload(ec);
1176 case EVAS_CALLBACK_MOUSE_DOWN:
1177 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1180 if (e_comp_wl->ptr.hide_tmr)
1182 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1183 e_comp_wl->ptr.hide_tmr = NULL;
1185 cursor_timer_ec = NULL;
1187 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1188 _e_comp_wl_cursor_reload(ec);
1191 case EVAS_CALLBACK_MOUSE_UP:
1192 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1203 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1205 if (ec->has_cursor_unset)
1208 if (!e_config->show_cursor)
1211 if (!e_config->use_cursor_timer)
1218 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1221 Evas_Event_Mouse_In *ev;
1222 struct wl_resource *res;
1223 struct wl_client *wc;
1226 E_Comp_Config *comp_conf;
1227 E_Client *prev_ptr_ec;
1231 e_comp_wl->ptr.x = wl_fixed_from_int(ev->canvas.x);
1232 e_comp_wl->ptr.y = wl_fixed_from_int(ev->canvas.y);
1234 if (!(ec = data)) return;
1235 if (e_object_is_del(E_OBJECT(ec))) return;
1236 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1237 if (!surface) return;
1239 prev_ptr_ec = e_comp_wl->ptr.ec;
1242 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1243 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1246 e_comp_wl->ptr.ec = ec;
1248 comp_conf = e_comp_config_get();
1249 if (comp_conf && comp_conf->input_log_enable)
1250 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1251 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1252 e_client_util_name_get(ec));
1254 if (_e_comp_wl_check_cursor_timer_needed(ec))
1256 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1260 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1261 wc = wl_resource_get_client(surface);
1262 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1263 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1265 if (!e_comp_wl_input_pointer_check(res)) continue;
1266 if (wl_resource_get_client(res) != wc) continue;
1268 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1270 wl_pointer_send_enter(res, serial, surface,
1271 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1272 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1273 ec->pointer_enter_sent = EINA_TRUE;
1276 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1280 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1283 Evas_Event_Mouse_Out *ev;
1284 struct wl_resource *res;
1285 struct wl_client *wc;
1288 Eina_Bool inside_check;
1289 E_Comp_Config *comp_conf;
1293 if (!(ec = data)) return;
1294 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1295 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1296 if (ec->cur_mouse_action && inside_check) return;
1297 if (e_object_is_del(E_OBJECT(e_comp))) return;
1298 if (e_comp_wl->ptr.ec == ec)
1299 e_comp_wl->ptr.ec = NULL;
1300 if (e_object_is_del(E_OBJECT(ec))) return;
1302 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1303 if (!surface) return;
1305 comp_conf = e_comp_config_get();
1306 if (comp_conf && comp_conf->input_log_enable)
1307 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1308 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1309 e_client_util_name_get(ec));
1311 if (_e_comp_wl_check_cursor_timer_needed(ec))
1313 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1317 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1319 wc = wl_resource_get_client(surface);
1320 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1321 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1323 if (!e_comp_wl_input_pointer_check(res)) continue;
1324 if (wl_resource_get_client(res) != wc) continue;
1325 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1327 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1329 wl_pointer_send_leave(res, serial, surface);
1330 ec->pointer_enter_sent = EINA_FALSE;
1335 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1338 struct wl_client *wc;
1339 struct wl_resource *res;
1342 E_Comp_Config *comp_conf = NULL;
1345 if (e_object_is_del(E_OBJECT(ec))) return;
1346 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1347 if (!surface) return;
1349 wc = wl_resource_get_client(surface);
1350 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1354 x = wl_fixed_from_int(canvas_x - ec->client.x);
1355 y = wl_fixed_from_int(canvas_y - ec->client.y);
1358 comp_conf = e_comp_config_get();
1360 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1362 if (wl_resource_get_client(res) != wc) continue;
1363 if (!e_comp_wl_input_touch_check(res)) continue;
1364 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1367 if (comp_conf && comp_conf->input_log_enable)
1368 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));
1370 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1374 if (comp_conf && comp_conf->input_log_enable)
1375 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));
1377 wl_touch_send_up(res, serial, timestamp, idx);
1384 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1387 struct wl_client *wc;
1388 struct wl_resource *res;
1392 if (ec->cur_mouse_action) return;
1393 if (e_object_is_del(E_OBJECT(ec))) return;
1394 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1395 if (!surface) return;
1397 wc = wl_resource_get_client(surface);
1399 x = wl_fixed_from_int(canvas_x - ec->client.x);
1400 y = wl_fixed_from_int(canvas_y - ec->client.y);
1402 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1404 if (wl_resource_get_client(res) != wc) continue;
1405 if (!e_comp_wl_input_touch_check(res)) continue;
1406 wl_touch_send_motion(res, timestamp, idx, x, y);
1411 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1413 struct wl_resource *res;
1414 struct wl_client *wc;
1418 if (ec->cur_mouse_action) return;
1419 if (e_object_is_del(E_OBJECT(ec))) return;
1420 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1421 if (!surface) return;
1423 wc = wl_resource_get_client(surface);
1424 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1426 if (!e_comp_wl_input_pointer_check(res)) continue;
1427 if (wl_resource_get_client(res) != wc) continue;
1428 wl_pointer_send_motion(res, timestamp,
1429 wl_fixed_from_int(x - ec->client.x),
1430 wl_fixed_from_int(y - ec->client.y));
1435 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1437 if (e_comp_wl->ptr.hide_tmr)
1439 if (cursor_timer_ec == ec)
1441 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1442 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1446 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1447 cursor_timer_ec = ec;
1448 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1453 cursor_timer_ec = ec;
1454 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1459 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1462 Evas_Event_Mouse_Move *ev;
1463 Evas_Device *dev = NULL;
1464 const char *dev_name;
1465 E_Comp_Config *comp_conf;
1469 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1470 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1472 if (!(ec = data)) return;
1473 if (e_object_is_del(E_OBJECT(ec))) return;
1474 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1475 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1476 if (!surface) return;
1478 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1481 dev_name = evas_device_description_get(dev);
1483 comp_conf = e_comp_config_get();
1484 if (comp_conf && comp_conf->input_log_enable)
1485 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1486 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1487 e_client_util_name_get(ec), dev_name);
1489 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1491 if (!e_comp_wl->drag_client)
1493 e_comp_wl->touch.faked_ec = ec;
1494 if (e_comp_wl->touch.pressed & (1 << 0))
1496 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1498 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1499 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1500 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1504 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1508 if (!e_comp_wl->drag_client)
1510 if (_e_comp_wl_check_cursor_timer_needed(ec))
1512 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1516 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1517 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1519 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1521 if (_e_comp_wl_check_cursor_timer_needed(ec))
1522 _e_comp_wl_cursor_move_timer_control(ec);
1526 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1531 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1533 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1534 if (e_object_is_del(E_OBJECT(ec))) return;
1535 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1536 if (!surface) return;
1537 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1539 e_comp_wl->ptr.button = BTN_LEFT;
1541 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1545 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1547 E_Client *ec = data;
1548 Evas_Event_Mouse_Down *ev = event;
1549 Evas_Device *dev = NULL;
1550 const Evas_Device *seat_dev;
1551 const char *dev_name, *seat_name;
1552 E_Comp_Config *comp_conf = NULL;
1555 if (e_object_is_del(E_OBJECT(ec))) return;
1558 dev_name = evas_device_description_get(dev);
1560 seat_dev = evas_device_parent_get(dev);
1561 seat_name = evas_device_name_get(seat_dev);
1563 comp_conf = e_comp_config_get();
1564 if (comp_conf && comp_conf->input_log_enable)
1565 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1566 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1567 dev_name, seat_name);
1569 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1571 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1573 e_comp_wl->touch.faked_ec = ec;
1576 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1577 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1578 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1580 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1581 e_comp_wl->touch.pressed |= (1 << 0);
1585 if (_e_comp_wl_check_cursor_timer_needed(ec))
1587 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1591 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1592 WL_POINTER_BUTTON_STATE_PRESSED);
1594 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1597 need_send_released = EINA_TRUE;
1601 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1603 E_Client *ec = data;
1604 Evas_Event_Mouse_Up *ev = event;
1605 Evas_Device *dev = NULL;
1606 const Evas_Device *seat_dev;
1607 const char *dev_name, *seat_name;;
1608 Evas_Event_Flags flags;
1609 E_Comp_Config *comp_conf = NULL;
1612 if (ec->cur_mouse_action) return;
1613 if (e_object_is_del(E_OBJECT(ec))) return;
1615 if (!need_send_released)
1617 need_send_motion = EINA_TRUE;
1621 dev_name = evas_device_description_get(dev);
1623 seat_dev = evas_device_parent_get(dev);
1624 seat_name = evas_device_name_get(seat_dev);
1625 flags = evas_event_default_flags_get(evas);
1627 comp_conf = e_comp_config_get();
1628 if (comp_conf && comp_conf->input_log_enable)
1629 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1630 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1631 dev_name, seat_name);
1633 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1635 e_comp_wl->touch.pressed &= ~(1 << 0);
1637 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1638 e_comp_wl->touch.faked_ec = NULL;
1641 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1643 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1645 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1648 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1649 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1650 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1654 if (_e_comp_wl_check_cursor_timer_needed(ec))
1656 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1660 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1661 WL_POINTER_BUTTON_STATE_RELEASED);
1663 if (_e_comp_wl_check_cursor_timer_needed(ec))
1664 _e_comp_wl_cursor_move_timer_control(ec);
1668 need_send_released = EINA_FALSE;
1672 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1674 struct wl_resource *res;
1675 struct wl_client *wc;
1680 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1682 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1685 dir = -wl_fixed_from_int(abs(z));
1687 dir = wl_fixed_from_int(z);
1690 if (e_object_is_del(E_OBJECT(ec))) return;
1691 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1692 if (!surface) return;
1694 wc = wl_resource_get_client(surface);
1695 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1697 if (!e_comp_wl_input_pointer_check(res)) continue;
1698 if (wl_resource_get_client(res) != wc) continue;
1699 wl_pointer_send_axis(res, timestamp, axis, dir);
1704 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1707 Evas_Event_Mouse_Wheel *ev;
1710 if (!(ec = data)) return;
1711 if (ec->cur_mouse_action) return;
1712 if (e_object_is_del(E_OBJECT(ec))) return;
1713 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1714 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1715 if (!surface) return;
1717 if (!eina_list_count(e_comp_wl->ptr.resources))
1720 if (_e_comp_wl_check_cursor_timer_needed(ec))
1722 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1726 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1728 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1730 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1732 if (_e_comp_wl_check_cursor_timer_needed(ec))
1733 _e_comp_wl_cursor_move_timer_control(ec);
1738 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1740 E_Client *ec = data;
1741 Evas_Event_Multi_Down *ev = event;
1742 Evas_Device *dev = NULL;
1743 const Evas_Device *seat_dev;
1744 const char *dev_name, *seat_name;
1745 Evas_Device_Class dev_class;
1746 E_Comp_Config *comp_conf = NULL;
1749 if (e_object_is_del(E_OBJECT(ec))) return;
1750 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1751 if (!surface) return;
1753 /* Do not deliver emulated single touch events to client */
1754 if (ev->device == 0) return;
1757 dev_name = evas_device_description_get(dev);
1758 e_comp_wl->touch.faked_ec = ec;
1760 seat_dev = evas_device_parent_get(dev);
1761 seat_name = evas_device_name_get(seat_dev);
1763 comp_conf = e_comp_config_get();
1764 if (comp_conf && comp_conf->input_log_enable)
1765 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1766 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1767 dev_name, seat_name);
1769 if (dev && dev_name)
1771 dev_class = evas_device_class_get(dev);
1772 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1773 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1776 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1777 e_comp_wl->touch.pressed |= (1 << ev->device);
1781 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1783 E_Client *ec = data;
1784 Evas_Event_Multi_Up *ev = event;
1785 Evas_Device *dev = NULL;
1786 const Evas_Device *seat_dev;
1787 const char *dev_name, *seat_name;
1788 Evas_Device_Class dev_class;
1789 Evas_Event_Flags flags;
1790 E_Comp_Config *comp_conf = NULL;
1793 if (e_object_is_del(E_OBJECT(ec))) return;
1794 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1795 if (!surface) return;
1797 /* Do not deliver emulated single touch events to client */
1798 if (ev->device == 0) return;
1800 flags = evas_event_default_flags_get(evas);
1802 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1803 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1804 e_comp_wl->touch.faked_ec = NULL;
1806 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1809 dev_name = evas_device_description_get(dev);
1811 seat_dev = evas_device_parent_get(dev);
1812 seat_name = evas_device_name_get(seat_dev);
1814 comp_conf = e_comp_config_get();
1815 if (comp_conf && comp_conf->input_log_enable)
1816 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1817 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1818 dev_name, seat_name);
1820 if (dev && dev_name)
1822 dev_class = evas_device_class_get(dev);
1823 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1824 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1827 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1831 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1833 E_Client *ec = data;
1834 Evas_Event_Multi_Move *ev = event;
1835 Evas_Device *dev = NULL;
1836 const char *dev_name;
1837 Evas_Device_Class dev_class;
1840 if (e_object_is_del(E_OBJECT(ec))) return;
1841 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1842 if (!surface) return;
1844 /* Do not deliver emulated single touch events to client */
1845 if (ev->device == 0) return;
1847 e_comp_wl->touch.faked_ec = ec;
1849 if (e_comp_wl->touch.pressed & (1 << ev->device))
1852 if (dev && (dev_name = evas_device_description_get(dev)))
1854 dev_class = evas_device_class_get(dev);
1855 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1856 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1859 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1864 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1867 char *file, buff[PATH_MAX];
1874 n = (getpriority(PRIO_PROCESS, pid) + adj);
1878 setpriority(PRIO_PROCESS, pid, n);
1881 use_adj = EINA_TRUE;
1883 if (!do_child) return;
1885 files = ecore_file_ls("/proc");
1886 EINA_LIST_FREE(files, file)
1888 if (!isdigit(file[0]))
1891 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1892 if ((f = fopen(buff, "r")))
1896 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1898 if (num_read == 2 && ppid == pid)
1899 _e_comp_wl_client_priority_adjust(pid2, set,
1901 adj_child, do_child);
1909 _e_comp_wl_client_priority_raise(E_Client *ec)
1911 if (!e_config->priority_control) return;
1912 if (ec->netwm.pid <= 0) return;
1913 if (ec->netwm.pid == getpid()) return;
1914 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1915 e_config->priority - 1, -1,
1916 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1920 _e_comp_wl_client_priority_normal(E_Client *ec)
1922 if (!e_config->priority_control) return;
1923 if (ec->netwm.pid <= 0) return;
1924 if (ec->netwm.pid == getpid()) return;
1925 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1926 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1930 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1933 E_Comp_Wl_Key_Data *k;
1934 struct wl_resource *res;
1938 if (!ec) return EINA_FALSE;
1939 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1940 if (!ec->comp_data) return EINA_FALSE;
1942 ec->comp_data->on_focus_timer = NULL;
1943 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1944 if (!e_comp_wl->kbd.focused)
1946 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1949 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1951 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1952 t = ecore_time_unix_get();
1954 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1955 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1956 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1958 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1960 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1961 wl_keyboard_send_key(res, serial, t,
1962 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1965 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1966 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1970 /* It is called in the following cases:
1971 * When a normal ec->frame has focus.
1972 * Or launching image ec is replaced to the real ec.
1975 e_comp_wl_feed_focus_in(E_Client *ec)
1978 struct wl_resource *res;
1979 struct wl_client *wc;
1983 if (e_object_is_del(E_OBJECT(ec))) return;
1984 if (ec->iconic) return;
1986 /* block spurious focus events */
1987 focused = e_client_focused_get();
1988 if ((focused) && (ec != focused)) return;
1990 /* raise client priority */
1991 _e_comp_wl_client_priority_raise(ec);
1992 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1993 if (!surface) return;
1995 wc = wl_resource_get_client(surface);
1997 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
1998 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2000 if (wl_resource_get_client(res) == wc)
2002 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2003 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2004 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2005 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2008 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2010 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2011 if (!e_comp_wl->kbd.focused)
2013 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2016 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2018 e_comp_wl->kbd.focus = surface;
2019 e_comp_wl_input_keyboard_enter_send(ec);
2020 e_comp_wl_data_device_keyboard_focus_set();
2021 ec->comp_data->on_focus_timer =
2022 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2023 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2024 int rotation = ec->e.state.rot.ang.curr;
2025 e_pointer_rotation_set(e_comp->pointer, rotation);
2029 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2032 if (!(ec = data)) return;
2033 e_comp_wl_feed_focus_in(ec);
2037 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2040 struct wl_resource *res;
2042 E_Comp_Wl_Key_Data *k;
2046 if (!(ec = data)) return;
2048 if (!ec->comp_data) return;
2050 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2052 /* lower client priority */
2053 if (!e_object_is_del(data))
2054 _e_comp_wl_client_priority_normal(ec);
2057 /* update keyboard modifier state */
2058 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2059 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2060 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2062 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2064 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2065 if (!surface) return;
2067 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2068 if (!eina_list_count(e_comp_wl->kbd.resources))
2070 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2074 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2076 /* send keyboard_leave to all keyboard resources */
2077 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2078 t = ecore_time_unix_get();
2080 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2081 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2082 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2084 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2086 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2087 wl_keyboard_send_key(res, serial, t,
2088 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2090 wl_keyboard_send_leave(res, serial, surface);
2091 e_comp_wl->kbd.focused =
2092 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2094 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2095 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2099 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2103 if (!(ec = data)) return;
2105 if ((ec->shading) || (ec->shaded)) return;
2106 if (!ec->comp_data->shell.configure_send) return;
2108 /* TODO: calculate x, y with transfrom object */
2109 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2113 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2114 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2115 if (e_comp_object_frame_exists(ec->frame))
2116 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2118 switch (ec->resize_mode)
2120 case E_POINTER_RESIZE_TL:
2121 case E_POINTER_RESIZE_L:
2122 case E_POINTER_RESIZE_BL:
2123 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2124 ec->mouse.current.mx;
2126 case E_POINTER_RESIZE_TR:
2127 case E_POINTER_RESIZE_R:
2128 case E_POINTER_RESIZE_BR:
2129 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2134 switch (ec->resize_mode)
2136 case E_POINTER_RESIZE_TL:
2137 case E_POINTER_RESIZE_T:
2138 case E_POINTER_RESIZE_TR:
2139 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2140 ec->mouse.current.my;
2142 case E_POINTER_RESIZE_BL:
2143 case E_POINTER_RESIZE_B:
2144 case E_POINTER_RESIZE_BR:
2145 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2150 w = E_CLAMP(w, 1, w);
2151 h = E_CLAMP(h, 1, h);
2152 e_client_resize_limit(ec, &w, &h);
2154 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
2155 e_comp_wl->resize.edges,
2158 else if ((!ec->fullscreen) && (!ec->maximized) &&
2159 (!ec->comp_data->maximize_pre))
2163 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2164 if ((pw != ec->w) || (ph != ec->h))
2166 _e_comp_wl_configure_send(ec, 1, 1);
2170 if (ec->comp_data->sub.below_obj)
2171 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2175 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2177 E_Client *ec = data;
2179 ec->comp_data->maximize_pre = 1;
2183 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2185 E_Client *ec = data;
2188 if (e_object_is_del(E_OBJECT(ec))) return;
2190 if (ec->comp_data->shell.configure_send)
2192 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2193 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, 0, w, h);
2195 ec->comp_data->maximize_pre = 0;
2199 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2201 E_Client *ec = data;
2203 ec->comp_data->maximize_pre = 1;
2207 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2209 E_Client *ec = data;
2211 if (e_object_is_del(E_OBJECT(ec))) return;
2213 /* check for wayland pixmap */
2215 if (ec->comp_data->shell.configure_send)
2216 _e_comp_wl_configure_send(ec, 0, 0);
2218 ec->comp_data->maximize_pre = 0;
2222 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2224 E_Client *ec = data;
2226 if (e_object_is_del(E_OBJECT(ec))) return;
2228 /* check for wayland pixmap */
2230 if (ec->comp_data->shell.configure_send)
2231 _e_comp_wl_configure_send(ec, 0, 1);
2233 ec->comp_data->maximize_pre = 0;
2237 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2239 E_Client *ec = data;
2241 if (e_object_is_del(E_OBJECT(ec))) return;
2243 /* check for wayland pixmap */
2245 if (ec->comp_data->shell.configure_send)
2246 _e_comp_wl_configure_send(ec, 0, 0);
2248 ec->comp_data->maximize_pre = 0;
2252 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2256 if (!(ec = data)) return;
2258 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2260 e_object_del(E_OBJECT(ec));
2262 _e_comp_wl_focus_check();
2264 /* TODO: Delete request send ??
2265 * NB: No such animal wrt wayland */
2269 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2273 if (!(ec = data)) return;
2275 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2278 if (ec->comp_data->reparented)
2279 e_client_comp_hidden_set(ec, EINA_TRUE);
2282 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2283 if (ec->visible) evas_object_hide(ec->frame);
2284 if (!ec->internal) e_object_del(E_OBJECT(ec));
2286 _e_comp_wl_focus_check();
2290 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2294 if (!(ec = data)) return;
2295 if (!(ec->comp_data)) return;
2296 if (!(ec->comp_data->shell.ping)) return;
2297 if (!(ec->comp_data->shell.surface)) return;
2299 ec->comp_data->shell.ping(ec->comp_data->shell.surface);
2303 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2308 if (!(ec = data)) return;
2309 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2310 if (ec->netwm.opacity == a) return;
2311 ec->netwm.opacity = a;
2312 ec->netwm.opacity_changed = EINA_TRUE;
2316 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2318 Eina_Rectangle *damage_rect = NULL;
2319 Eina_Rectangle *dmg = NULL;
2320 Eina_List *l = NULL;
2322 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2323 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2326 if (!buffer->tbm_surface) return;
2330 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2334 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2335 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2338 eina_rectangle_union(damage_rect, dmg);
2343 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2344 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2347 tbm_surface_internal_set_damage(buffer->tbm_surface,
2353 eina_rectangle_free(damage_rect);
2357 _e_comp_wl_client_evas_init(E_Client *ec)
2359 if (!ec || !ec->comp_data) return;
2360 if (ec->comp_data->evas_init) return;
2362 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2363 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2364 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2367 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2368 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2369 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2370 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2371 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2372 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2374 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2375 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2376 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2378 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2379 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2383 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2384 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2385 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2386 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2387 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2388 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2389 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2392 /* setup delete/kill callbacks */
2393 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2394 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2396 /* setup ping callback */
2397 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2398 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2400 ec->comp_data->evas_init = EINA_TRUE;
2404 _e_comp_wl_client_evas_deinit(E_Client *ec)
2406 if (!ec || !ec->comp_data) return;
2407 if (!ec->comp_data->evas_init) return;
2409 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2410 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2411 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2413 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2414 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2415 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2416 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2417 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2418 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2420 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2421 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2422 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2424 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2425 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2429 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2430 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2431 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2432 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2433 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2434 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2435 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2438 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2439 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2441 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2442 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2444 ec->comp_data->evas_init = EINA_FALSE;
2448 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2452 E_Comp_Screen *e_comp_screen;
2453 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2455 if (!e_comp) return ECORE_CALLBACK_RENEW;
2456 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2457 e_comp_screen = e_comp->e_comp_screen;
2459 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2461 if (!eout->config.enabled)
2463 e_comp_wl_output_remove(eout->id);
2467 switch (eout->config.rotation)
2470 transform = WL_OUTPUT_TRANSFORM_90;
2473 transform = WL_OUTPUT_TRANSFORM_180;
2476 transform = WL_OUTPUT_TRANSFORM_270;
2480 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2484 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2486 eout->config.geom.x, eout->config.geom.y,
2487 eout->config.geom.w, eout->config.geom.h,
2488 eout->info.size.w, eout->info.size.h,
2489 eout->config.mode.refresh, 0, transform))
2490 ERR("Could not initialize screen %s", eout->info.name);
2493 return ECORE_CALLBACK_RENEW;
2497 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2501 /* try to get the client from the object */
2502 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2503 return ECORE_CALLBACK_RENEW;
2505 /* check for client being deleted */
2506 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2508 /* check for wayland pixmap */
2509 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2510 return ECORE_CALLBACK_RENEW;
2512 /* if we have not setup evas callbacks for this client, do it */
2513 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2515 return ECORE_CALLBACK_RENEW;
2519 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2523 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2524 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2526 if (e_comp_wl->selection.target &&
2529 struct wl_resource *res;
2531 E_Client *ec = NULL;
2532 E_Client *legacy_target = e_comp_wl->selection.target;
2533 int device_id = e_comp_wl_data_current_device_id_get();
2537 e_comp_wl_data_current_device_id_set(ev->multi.device);
2539 else if (device_id != ev->multi.device)
2541 return ECORE_CALLBACK_RENEW;
2544 ec = e_client_input_rect_under_pointer_get(legacy_target->desk, e_comp_wl->drag_client);
2545 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2547 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2548 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2550 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2551 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2553 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2554 (ec != legacy_target))
2556 e_comp_wl_data_device_send_leave(legacy_target);
2557 e_comp_wl_data_device_send_enter(ec);
2560 if (e_comp_wl->drag)
2561 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2563 if (e_client_transform_core_enable_get(ec))
2565 int trans_x, trans_y;
2566 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2567 x = trans_x - ec->client.x;
2568 y = trans_y - ec->client.y;
2572 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2577 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2580 return ECORE_CALLBACK_RENEW;
2584 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2587 struct wl_resource *surface;
2588 struct wl_resource *res;
2589 struct wl_client *wc;
2591 E_Comp_Config *comp_conf;
2593 ec = e_comp_wl->ptr_constraints.ec;
2594 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2596 surface = e_comp_wl_client_surface_get(ec);
2597 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2599 wc = wl_resource_get_client(surface);
2601 comp_conf = e_comp_config_get();
2603 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2605 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2606 if (wl_resource_get_client(res) != wc) continue;
2608 if (comp_conf && comp_conf->input_log_enable)
2609 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2610 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2611 e_client_util_name_get(ec));
2613 zwp_relative_pointer_v1_send_relative_motion(res,
2615 (uint32_t)(ev->timestamp),
2616 wl_fixed_from_int(ev->dx),
2617 wl_fixed_from_int(ev->dy),
2618 wl_fixed_from_int(ev->dx_unaccel),
2619 wl_fixed_from_int(ev->dy_unaccel));
2622 return ECORE_CALLBACK_DONE;
2626 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2628 _e_comp_wl_touch_cancel();
2630 return ECORE_CALLBACK_PASS_ON;
2634 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2636 if (!ev) return ECORE_CALLBACK_PASS_ON;
2638 E_Zone *zone = ev->zone;
2640 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2641 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2643 if (!e_zone_is_displaying(zone))
2644 _e_comp_wl_touch_cancel();
2646 return ECORE_CALLBACK_PASS_ON;
2650 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2652 E_Client *ec = ev->ec;
2653 E_Comp_Wl_Buffer_Viewport *vp;
2655 if (!ec) return ECORE_CALLBACK_PASS_ON;
2656 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2657 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2658 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2659 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2661 vp = &ec->comp_data->scaler.buffer_viewport;
2662 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2664 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2666 return ECORE_CALLBACK_PASS_ON;
2670 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2672 E_Client *ec = ev->ec;
2673 E_Comp_Wl_Buffer_Viewport *vp;
2675 if (!ec) return ECORE_CALLBACK_PASS_ON;
2676 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2677 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2678 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2680 vp = &ec->comp_data->scaler.buffer_viewport;
2681 vp->wait_for_transform_change = 0;
2683 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2685 return ECORE_CALLBACK_PASS_ON;
2689 _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)
2691 E_Client *focused_ec;
2694 focused_ec = e_client_focused_get();
2695 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2697 rotation = focused_ec->e.state.rot.ang.curr;
2698 e_pointer_rotation_set(e_comp->pointer, rotation);
2700 return ECORE_CALLBACK_PASS_ON;
2704 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2707 Eina_Rectangle *window;
2712 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2714 if ((prev_w != state->bw) ||
2715 (prev_h != state->bh))
2717 ec->changes.buf_size = EINA_TRUE;
2720 if (e_comp_object_frame_exists(ec->frame)) return;
2721 window = &ec->comp_data->shell.window;
2722 if ((!ec->borderless) && /* FIXME temporarily added this check code
2723 * to prevent updating E_Client's size by frame */
2724 (window->x || window->y || window->w || window->h))
2726 e_comp_object_frame_geometry_set(ec->frame,
2728 (window->x + window->w) - state->bw,
2730 (window->y + window->h) - state->bh);
2733 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2737 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2739 E_Comp_Wl_Surface_State *state;
2742 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2743 state->buffer = NULL;
2747 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2749 state->new_attach = EINA_FALSE;
2750 state->buffer = NULL;
2751 state->buffer_destroy_listener.notify =
2752 _e_comp_wl_surface_state_cb_buffer_destroy;
2753 state->sx = state->sy = 0;
2755 state->input = eina_tiler_new(w, h);
2756 eina_tiler_tile_size_set(state->input, 1, 1);
2758 state->opaque = eina_tiler_new(w, h);
2759 eina_tiler_tile_size_set(state->opaque, 1, 1);
2761 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2762 state->buffer_viewport.buffer.scale = 1;
2763 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2764 state->buffer_viewport.surface.width = -1;
2765 state->buffer_viewport.changed = 0;
2767 e_presentation_time_container_init(&state->presentation_container);
2771 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2773 struct wl_resource *cb;
2774 Eina_Rectangle *dmg;
2776 EINA_LIST_FREE(state->frames, cb)
2777 wl_resource_destroy(cb);
2779 EINA_LIST_FREE(state->damages, dmg)
2780 eina_rectangle_free(dmg);
2782 EINA_LIST_FREE(state->buffer_damages, dmg)
2783 eina_rectangle_free(dmg);
2785 if (state->opaque) eina_tiler_free(state->opaque);
2786 state->opaque = NULL;
2788 if (state->input) eina_tiler_free(state->input);
2789 state->input = NULL;
2791 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2792 state->buffer = NULL;
2794 e_presentation_time_container_finish(&state->presentation_container);
2798 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2800 if (state->buffer == buffer) return;
2802 wl_list_remove(&state->buffer_destroy_listener.link);
2803 state->buffer = buffer;
2805 wl_signal_add(&state->buffer->destroy_signal,
2806 &state->buffer_destroy_listener);
2810 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2812 Eina_Rectangle *dmg;
2813 Eina_Bool placed = EINA_TRUE;
2817 E_Comp_Wl_Buffer *buffer;
2818 struct wl_resource *cb;
2820 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2821 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2826 if ((ec->internal) ||
2827 (cdata->shell.surface && state->new_attach))
2831 e_comp->new_clients++;
2832 ELOGF("COMP", "Unignore", ec);
2833 e_client_unignore(ec);
2837 /* buffer transform */
2838 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2841 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2843 /* when buffer is transformed, we have to apply the new evas-map */
2844 state->buffer_viewport.changed = EINA_TRUE;
2846 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2848 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2850 if (transform_change == vp->wait_for_transform_change)
2851 vp->wait_for_transform_change = 0;
2853 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2854 // triggered by E_CLIENT_HOOK calls at those file.
2855 zone = e_comp_zone_find_by_ec(ec);
2858 eout = e_output_find(zone->output_id);
2859 if (eout && eout->hwc)
2861 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2863 if (e_comp_is_on_overlay(ec))
2864 e_comp_hwc_client_end(ec, __FUNCTION__);
2870 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2871 cdata->scaler.buffer_viewport = state->buffer_viewport;
2873 if (state->new_attach)
2875 e_comp_wl_surface_attach(ec, state->buffer);
2878 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2879 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2881 _e_comp_wl_surface_state_buffer_set(state, NULL);
2883 if ((state->new_attach) ||
2884 (state->buffer_viewport.changed))
2886 _e_comp_wl_surface_state_size_update(ec, state);
2887 e_comp_wl_map_size_cal_from_viewport(ec);
2889 /* update the position */
2890 if (ec->changes.pos)
2892 e_comp_object_frame_xy_unadjust(ec->frame,
2902 if (ec->new_client) placed = ec->placed;
2904 if (!ec->lock_client_size)
2909 ec->client.w = state->bw;
2910 ec->client.h = state->bh;
2912 e_comp_object_frame_wh_adjust(ec->frame,
2913 ec->client.w, ec->client.h,
2915 e_client_size_set(ec, nw, nh);
2917 if ((w != ec->w) || (h != ec->h))
2919 ec->changes.size = 1;
2924 if (ec->changes.buf_size)
2926 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2927 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2928 ec->changes.buf_size = EINA_FALSE;
2930 if (ec->move_after_resize)
2932 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2933 ec->move_after_resize = EINA_FALSE;
2938 /* map or unmap ec */
2939 if (!e_pixmap_usable_get(ec->pixmap))
2944 if ((cdata->shell.surface) &&
2945 (cdata->shell.unmap))
2947 ELOGF("COMP", "Try to unmap. Call shell.unmap.", ec);
2948 if (ec->show_pending.count > 0)
2950 ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
2951 ec->show_pending.count = 0;
2952 if (ec->show_pending.running)
2954 // need to send visibility false;
2955 ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
2956 ELOGF("POL_VIS", "CLIENT VIS ON (fake). argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
2959 ec->show_pending.running = EINA_FALSE;
2961 cdata->shell.unmap(cdata->shell.surface);
2963 else if ((ec->internal) ||
2964 (e_comp_wl_subsurface_check(ec)) ||
2965 (ec == e_comp_wl->drag_client))
2967 ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
2968 ec, ec->internal, cdata->sub.data, (ec == e_comp_wl->drag_client));
2969 ec->visible = EINA_FALSE;
2970 evas_object_hide(ec->frame);
2975 if ((cdata->sub.below_obj) &&
2976 (evas_object_visible_get(cdata->sub.below_obj)))
2978 evas_object_hide(cdata->sub.below_obj);
2986 if ((cdata->shell.surface) &&
2987 (cdata->shell.map) &&
2990 ELOGF("COMP", "Try to map. Call shell.map.", ec);
2991 cdata->shell.map(cdata->shell.surface);
2993 else if ((ec->internal) ||
2994 (e_comp_wl_subsurface_can_show(ec)) ||
2995 (ec == e_comp_wl->drag_client))
2997 ELOGF("COMP", "Try to map. Show window. internal:%d, drag:%d",
2998 ec, ec->internal, (ec == e_comp_wl->drag_client));
2999 ec->visible = EINA_TRUE;
3001 evas_object_show(ec->frame);
3006 if ((cdata->sub.below_obj) &&
3007 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3008 (evas_object_visible_get(ec->frame)))
3010 evas_object_show(cdata->sub.below_obj);
3014 if ((state->new_attach) ||
3015 (state->buffer_viewport.changed))
3017 if ((e_comp_wl->drag) &&
3018 (e_comp_wl->drag_client) &&
3019 (e_comp_wl->drag_client == ec))
3021 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3023 e_drag_move(e_comp_wl->drag,
3025 e_comp_wl->drag->y);
3027 e_drag_resize(e_comp_wl->drag,
3028 state->bw, state->bh);
3030 else if ((cdata->shell.surface) &&
3031 (cdata->shell.configure))
3033 e_comp_wl_commit_sync_configure(ec);
3035 else if (!e_client_video_hw_composition_check(ec))
3037 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3042 ec->placed = placed;
3043 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3047 if (cdata->scaler.buffer_viewport.changed)
3048 e_comp_wl_map_apply(ec);
3050 /* resize transform object */
3051 if (ec->transformed)
3052 e_client_transform_update(ec);
3056 state->new_attach = EINA_FALSE;
3058 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3060 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3061 wl_resource_destroy(cb);
3064 /* insert state frame callbacks into comp_data->frames
3065 * NB: This clears state->frames list */
3066 cdata->frames = eina_list_merge(cdata->frames,
3068 state->frames = NULL;
3070 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3071 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3072 &state->presentation_container);
3074 buffer = e_pixmap_resource_get(ec->pixmap);
3076 /* put state damages into surface */
3079 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3080 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3082 if ((cdata->buffer_ref.buffer) &&
3083 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3084 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3086 e_comp_object_damage(ec->frame,
3088 cdata->buffer_ref.buffer->w,
3089 cdata->buffer_ref.buffer->h);
3094 Eina_List *damages = NULL;
3097 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3099 if (eina_list_count(state->buffer_damages))
3101 EINA_LIST_FREE(state->buffer_damages, dmg)
3104 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3105 e_comp_wl_output_buffer_transform_get(ec),
3107 dmg->x, dmg->y, dmg->w, dmg->h,
3108 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3109 damages = eina_list_append(damages, dmg);
3113 EINA_LIST_FREE(state->damages, dmg)
3114 damages = eina_list_append(damages, dmg);
3116 EINA_LIST_FREE(damages, dmg)
3118 /* not creating damage for ec that shows a underlay video */
3119 if (state->buffer_viewport.changed ||
3120 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3121 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3122 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3124 eina_rectangle_free(dmg);
3129 /* put state opaque into surface */
3130 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3133 Eina_Rectangle *rect;
3136 itr = eina_tiler_iterator_new(state->opaque);
3137 EINA_ITERATOR_FOREACH(itr, rect)
3141 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3142 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3143 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3147 eina_iterator_free(itr);
3150 /* put state input into surface */
3151 if ((state->input) &&
3152 (!eina_tiler_empty(state->input)) &&
3155 Eina_Tiler *src, *tmp;
3159 tmp = eina_tiler_new(sw, sh);
3160 eina_tiler_tile_size_set(tmp, 1, 1);
3162 eina_tiler_rect_add(tmp,
3163 &(Eina_Rectangle){0, 0, sw, sh});
3165 if ((src = eina_tiler_intersection(state->input, tmp)))
3167 Eina_Rectangle *rect;
3170 e_comp_object_input_objs_del(ec->frame);
3171 itr = eina_tiler_iterator_new(src);
3172 EINA_ITERATOR_FOREACH(itr, rect)
3174 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3175 ec, rect->x, rect->y, rect->w, rect->h,
3176 ec->w, ec->h, state->bw, state->bh);
3177 e_comp_object_input_area_set(ec->frame,
3182 eina_iterator_free(itr);
3183 eina_tiler_free(src);
3186 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3188 eina_tiler_free(tmp);
3190 /* clear input tiler */
3191 eina_tiler_clear(state->input);
3194 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3196 if ((cdata->video_client) &&
3198 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3199 (e_comp->wl_comp_data->available_hw_accel.underlay))
3201 e_pixmap_image_clear(ec->pixmap, 1);
3204 state->buffer_viewport.changed = 0;
3206 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3209 ec->exp_iconify.buffer_flush &&
3210 e_policy_visibility_client_is_iconic(ec))
3212 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3217 _e_comp_wl_surface_render_stop(E_Client *ec)
3219 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3220 //if ((!ec->internal) && (!e_comp_gl_get()))
3223 /* check if internal animation is running */
3224 if (e_comp_object_is_animating(ec->frame)) return;
3225 /* check if external animation is running */
3226 if (evas_object_data_get(ec->frame, "effect_running")) return;
3228 evas_object_hide(ec->frame);
3232 e_comp_wl_client_surface_finish(E_Client *ec)
3234 struct wl_resource *res, *surface;
3235 struct wl_client *surface_client = NULL;
3238 surface = e_comp_wl_client_surface_get(ec);
3241 surface_client = wl_resource_get_client(surface);
3243 if (surface_client &&
3244 (ec == e_client_focused_get()))
3246 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3247 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3249 if (wl_resource_get_client(res) ==
3251 e_comp_wl->kbd.focused =
3252 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3256 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3259 e_comp_wl_client_surface_set(ec, NULL);
3261 ec->comp_data->wl_surface = NULL;
3262 e_pixmap_win_id_del(ec->pixmap);
3264 _e_comp_wl_surface_render_stop(ec);
3265 e_object_del(E_OBJECT(ec));
3269 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3274 char proc[512], pname[512];
3277 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3279 h = fopen(proc, "r");
3282 len = fread(pname, sizeof(char), 512, h);
3284 pname[len - 1] = '\0';
3286 strncpy(pname, "NO NAME", sizeof(pname));
3292 strncpy(pname, "NO NAME", sizeof(pname));
3295 strncpy(name, pname, size);
3299 _e_comp_wl_pname_print(pid_t pid)
3302 char proc[512], pname[512];
3305 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3307 h = fopen(proc, "r");
3310 len = fread(pname, sizeof(char), 512, h);
3312 pname[len - 1] = '\0';
3314 strncpy(pname, "NO NAME", sizeof(pname));
3318 ELOGF("COMP", " |%s", NULL, pname);
3323 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3325 struct wl_client *client = data;
3326 E_Comp_Connected_Client_Info *cinfo;
3329 cinfo = wl_container_of(listener, cinfo, destroy);
3331 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3332 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3334 eai = e_appinfo_find_with_pid(cinfo->pid);
3335 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3338 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3340 wl_list_remove(&cinfo->destroy.link);
3341 eina_stringshare_del(cinfo->name);
3346 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3348 E_Comp_Connected_Client_Info *cinfo;
3350 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3351 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3353 cinfo->name = eina_stringshare_add(name);
3357 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3358 wl_client_add_destroy_listener(client, &cinfo->destroy);
3359 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3361 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3365 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3367 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3369 /* send configure */
3370 if (ec->comp_data->shell.configure_send)
3372 if (ec->comp_data->shell.surface)
3373 _e_comp_wl_configure_send(ec, 0, 0);
3376 e_comp_wl->kbd.focus = ec->comp_data->surface;
3380 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3382 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3384 /* send configure */
3385 if (ec->comp_data->shell.configure_send)
3387 if (ec->comp_data->shell.surface)
3388 _e_comp_wl_configure_send(ec, 0, 0);
3391 _e_comp_wl_focus_check();
3393 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3394 e_comp_wl->kbd.focus = NULL;
3398 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3400 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3401 if (ec->keyboard_resizing) return;
3403 /* do nothing currently */
3408 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3410 if (e_object_is_del(E_OBJECT(ec))) return;
3411 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3413 e_comp_wl->resize.edges = 0;
3414 e_comp_wl->resize.resource = NULL;
3416 if (ec->pending_resize)
3418 ec->changes.pos = EINA_TRUE;
3419 ec->changes.size = EINA_TRUE;
3423 E_FREE_LIST(ec->pending_resize, free);
3427 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3429 if (e_object_is_del(E_OBJECT(ec))) return;
3430 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3434 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3437 int ratio_w, ratio_h;
3439 phys_w = output->phys_width;
3440 phys_h = output->phys_height;
3442 if (e_config->configured_output_resolution.use)
3444 // change the configured physical size(mm) of the output
3445 if (output->w != res_w)
3447 ratio_w = res_w / output->w;
3448 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3451 if (output->h != res_h)
3453 ratio_h = res_h / output->h;
3454 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3457 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3460 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3461 NULL, res_w, res_h, phys_w, phys_h, pid);
3463 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3464 wl_output_send_scale(resource, output->scale);
3466 wl_output_send_geometry(resource, output->x, output->y,
3468 output->subpixel, output->make ?: "",
3469 output->model ?: "", output->transform);
3471 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3472 res_w, res_h, output->refresh);
3474 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3475 wl_output_send_done(resource);
3479 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3481 E_Comp_Wl_Output *output;
3483 if (!(output = wl_resource_get_user_data(resource))) return;
3485 output->resources = eina_list_remove(output->resources, resource);
3489 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3491 E_Comp_Wl_Output *output;
3492 struct wl_resource *resource;
3493 E_Appinfo *eai = NULL;
3497 if (!(output = data)) return;
3500 wl_resource_create(client, &wl_output_interface, version, id);
3503 wl_client_post_no_memory(client);
3507 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3508 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3510 output->resources = eina_list_append(output->resources, resource);
3512 wl_resource_set_implementation(resource, NULL, output,
3513 _e_comp_wl_cb_output_unbind);
3514 wl_resource_set_user_data(resource, output);
3516 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3517 if (e_config->configured_output_resolution.use)
3519 wl_client_get_credentials(client, &pid, NULL, NULL);
3522 res_w = e_config->configured_output_resolution.w;
3523 res_h = e_config->configured_output_resolution.h;
3527 eai = e_appinfo_find_with_pid(pid);
3530 res_w = e_config->configured_output_resolution.w;
3531 res_h = e_config->configured_output_resolution.h;
3535 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3537 res_w = e_config->configured_output_resolution.w;
3538 res_h = e_config->configured_output_resolution.h;
3542 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3551 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3555 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3558 Evas_GL *evasgl = NULL;
3559 Evas_GL_API *glapi = NULL;
3560 Evas_GL_Context *ctx = NULL;
3561 Evas_GL_Surface *sfc = NULL;
3562 Evas_GL_Config *cfg = NULL;
3564 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3566 if (!e_comp_gl_get()) return;
3568 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3569 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3571 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3572 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3574 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3575 * then we should get evas from ecore_evas.
3578 evas = e_comp->evas;
3580 evas = ecore_evas_get(e_comp->ee);
3582 evasgl = evas_gl_new(evas);
3583 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3585 glapi = evas_gl_api_get(evasgl);
3586 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3587 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3589 cfg = evas_gl_config_new();
3590 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3592 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3593 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3595 ctx = evas_gl_context_create(evasgl, NULL);
3596 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3598 res = evas_gl_make_current(evasgl, sfc, ctx);
3599 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3601 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3602 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3604 evas_gl_config_free(cfg);
3606 evas_gl->gl = evasgl;
3607 evas_gl->glapi = glapi;
3608 evas_gl->glsfc = sfc;
3609 evas_gl->glctx = ctx;
3611 e_comp_wl->evas_gl = evas_gl;
3613 /* for native surface */
3616 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3621 evas_gl_config_free(cfg);
3622 evas_gl_make_current(evasgl, NULL, NULL);
3623 evas_gl_context_destroy(evasgl, ctx);
3624 evas_gl_surface_destroy(evasgl, sfc);
3625 evas_gl_free(evasgl);
3632 _e_comp_wl_gl_popup_cb_close(void *data,
3633 Evas_Object *obj EINA_UNUSED,
3634 void *event_info EINA_UNUSED)
3636 evas_object_del(data);
3640 _e_comp_wl_gl_popup_cb_focus(void *data,
3641 Evas_Object *obj EINA_UNUSED,
3642 void *event_info EINA_UNUSED)
3644 elm_object_focus_set(data, EINA_TRUE);
3649 _e_comp_wl_gl_idle(void *data)
3653 /* show warning window to notify failure of gl init */
3656 Evas_Object *win, *bg, *popup, *btn;
3658 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3659 elm_win_title_set(win, "Compositor Warning");
3660 elm_win_autodel_set(win, EINA_TRUE);
3661 elm_win_borderless_set(win, EINA_TRUE);
3662 elm_win_role_set(win, "notification-low");
3663 elm_win_alpha_set(win, EINA_TRUE);
3665 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3666 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3667 elm_win_resize_object_add(win, bg);
3668 evas_object_color_set(bg, 125, 125, 125, 125);
3669 evas_object_show(bg);
3671 popup = elm_popup_add(win);
3672 elm_object_text_set(popup,
3673 _( "Your screen does not support OpenGL.<br>"
3674 "Falling back to software engine."));
3675 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3677 btn = elm_button_add(popup);
3678 elm_object_text_set(btn, "Close");
3679 elm_object_part_content_set(popup, "button1", btn);
3680 evas_object_show(btn);
3682 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3683 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3685 evas_object_show(popup);
3686 evas_object_show(win);
3690 return ECORE_CALLBACK_CANCEL;
3694 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3696 struct wl_client *client = data;
3702 wl_client_get_credentials(client, &pid, &uid, &gid);
3704 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3706 _e_comp_wl_pname_print(pid);
3707 _e_comp_wl_pname_get(pid, name, sizeof(name));
3708 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3712 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3714 char buf[1024] = {0, };
3716 vsnprintf(buf, 1024, fmt, args);
3720 DBG("[libds] %s", buf);
3723 INF("[libds] %s", buf);
3726 ERR("[libds] %s", buf);
3734 _e_comp_wl_display_create(void)
3737 E_Comp_Wl_Data *wl_cdata;
3742 /* create new compositor data */
3743 if (!(comp = E_NEW(E_Comp_Data, 1)))
3745 ERR("Could not create compositor data: %m");
3748 wl_cdata = &comp->base;
3750 /* set compositor wayland data */
3751 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3753 g_mutex_init(&flush_mutex);
3755 /* try to create a wayland display */
3756 if (!(wl_cdata->wl.disp = wl_display_create()))
3758 ERR("Could not create a Wayland display: %m");
3762 /* try to setup wayland socket */
3763 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3765 ERR("Could not create Wayland display socket: %m");
3766 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3770 res = e_comp_socket_init(name);
3771 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3772 PRCTL("[Winsys] change permission and create sym link for %s", name);
3774 /* set wayland display environment variable */
3775 e_env_set("WAYLAND_DISPLAY", name);
3777 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3778 /* wl_cdata->output.scale = e_scale; */
3780 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3782 if (!e_compositor_init(wl_cdata->wl.disp))
3784 ERR("Failed to initialize compositor");
3788 comp->client_created.notify = _e_comp_wl_cb_client_created;
3789 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3791 if (!e_comp_wl_subsurfaces_init())
3793 ERR("Failed to init_subsurfaces");
3794 goto subsurfaces_err;
3797 /* initialize shm mechanism */
3798 wl_display_init_shm(wl_cdata->wl.disp);
3800 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3802 /* try to init data manager */
3803 if (!e_comp_wl_data_manager_init())
3805 ERR("Could not initialize data manager");
3809 /* try to init input */
3810 if (!e_comp_wl_input_init())
3812 ERR("Could not initialize input");
3816 if (e_comp_gl_get())
3817 _e_comp_wl_gl_init(NULL);
3819 /* get the wayland display loop */
3820 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3822 /* get the file descriptor of the wayland event loop */
3823 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3825 /* create a listener for wayland main loop events */
3827 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3828 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3829 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3830 _e_comp_wl_cb_prepare, wl_cdata);
3835 e_comp_wl_data_manager_shutdown();
3837 e_comp_wl_subsurfaces_shutdown();
3839 wl_list_remove(&comp->client_created.link);
3841 e_env_unset("WAYLAND_DISPLAY");
3843 wl_display_destroy(wl_cdata->wl.disp);
3845 g_mutex_clear(&flush_mutex);
3851 _e_comp_wl_gl_shutdown(void)
3853 if (!e_comp_wl->evas_gl) return;
3855 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3857 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3858 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3859 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3860 evas_gl_free(e_comp_wl->evas_gl->gl);
3862 E_FREE(e_comp_wl->evas_gl);
3865 /* public functions */
3868 * Creates and initializes a Wayland compositor with ecore.
3869 * Registers callback handlers for keyboard and mouse activity
3870 * and other client events.
3872 * @returns true on success, false if initialization failed.
3875 e_comp_wl_init(void)
3877 TRACE_DS_BEGIN(COMP_WL:INIT);
3879 /* try to create a wayland compositor */
3880 if (!_e_comp_wl_display_create())
3882 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3887 e_comp_wl_shell_init();
3889 #ifdef HAVE_WAYLAND_TBM
3890 e_comp_wl_tbm_init();
3892 e_comp_wl_remote_surface_init();
3896 e_comp_wl_screenshooter_init();
3898 if (!e_comp_wl_video_init())
3899 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3901 e_comp_wl_viewport_init();
3902 e_comp_wl_capture_init();
3903 e_comp_wl_renderer_init();
3904 _e_comp_wl_move_resize_init();
3905 e_presentation_time_init();
3906 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3909 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3910 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3912 /* add event handlers to catch E events */
3913 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3914 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3915 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3916 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3917 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3918 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3919 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3920 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3921 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3923 /* add hooks to catch e_client events */
3924 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3925 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3926 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3927 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3928 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3930 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3937 e_comp_wl_deferred_job(void)
3939 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3942 /* internal functions */
3944 e_comp_wl_shutdown(void)
3946 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3948 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3950 e_comp_wl_subsurfaces_shutdown();
3952 E_FREE_LIST(handlers, ecore_event_handler_del);
3953 E_FREE_LIST(hooks, e_client_hook_del);
3954 _e_comp_wl_gl_shutdown();
3956 e_blender_shutdown();
3957 e_presentation_time_shutdown();
3958 e_comp_wl_renderer_shutdown();
3959 e_comp_wl_capture_shutdown();
3960 e_comp_wl_viewport_shutdown();
3961 e_comp_wl_video_shutdown();
3962 e_comp_wl_screenshooter_shutdown();
3964 e_comp_wl_remote_surface_shutdown();
3966 e_pixmap_shutdown();
3968 e_wtz_shell_shutdown();
3969 e_comp_wl_shell_shutdown();
3970 e_comp_wl_input_shutdown();
3972 wl_list_remove(&comp->client_created.link);
3975 e_comp->wl_comp_data = NULL;
3979 E_Comp_Wl_Output *output;
3981 if (e_comp_wl->screenshooter.global)
3982 wl_global_destroy(e_comp_wl->screenshooter.global);
3984 EINA_LIST_FREE(e_comp_wl->outputs, output)
3986 if (output->id) eina_stringshare_del(output->id);
3987 if (output->make) eina_stringshare_del(output->make);
3988 if (output->model) eina_stringshare_del(output->model);
3992 /* delete fd handler */
3993 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3995 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3996 cursor_timer_ec = NULL;
3998 /* free allocated data structure */
4004 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4006 e_object_unref(E_OBJECT(ev->ec));
4011 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4014 ev = E_NEW(E_Event_Client, 1);
4017 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4019 /* set usable early because shell module checks this */
4020 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4021 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4023 e_pixmap_resource_set(ec->pixmap, buffer);
4024 e_pixmap_dirty(ec->pixmap);
4025 e_pixmap_refresh(ec->pixmap);
4027 e_comp_wl_map_size_cal_from_buffer(ec);
4028 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4030 /* wm-policy module uses it */
4031 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4034 e_object_ref(E_OBJECT(ec));
4035 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4036 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4040 e_comp_wl_surface_commit(E_Client *ec)
4045 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4046 if (!e_comp_object_damage_exists(ec->frame))
4048 if ((ec->comp_data->video_client) ||
4049 (!e_client_video_hw_composition_check(ec)))
4050 e_pixmap_image_clear(ec->pixmap, 1);
4053 ignored = ec->ignored;
4055 if (e_comp_wl_subsurface_order_commit(ec))
4057 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4058 e_comp_wl_subsurface_restack(topmost);
4059 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4062 if (!e_pixmap_usable_get(ec->pixmap))
4064 if (ec->comp_data->mapped)
4066 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
4068 ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
4069 ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
4071 else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
4072 (ec == e_comp_wl->drag_client))
4074 ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
4075 ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
4076 ec->visible = EINA_FALSE;
4077 evas_object_hide(ec->frame);
4078 ec->comp_data->mapped = 0;
4082 if (ec->comp_data->sub.below_obj && evas_object_visible_get(ec->comp_data->sub.below_obj))
4083 evas_object_hide(ec->comp_data->sub.below_obj);
4087 if (!ec->comp_data->mapped)
4089 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
4092 ELOGF("COMP", "Try to map2. Call shell.map.", ec);
4093 ec->comp_data->shell.map(ec->comp_data->shell.surface);
4095 else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
4096 (ec == e_comp_wl->drag_client))
4098 ELOGF("COMP", "Try to map2. Show window. internal:%d, drag:%d",
4099 ec, ec->internal, (ec == e_comp_wl->drag_client));
4100 ec->visible = EINA_TRUE;
4102 evas_object_show(ec->frame);
4103 ec->comp_data->mapped = 1;
4107 if (ec->comp_data->sub.below_obj && !evas_object_visible_get(ec->comp_data->sub.below_obj)
4108 && evas_object_visible_get(ec->frame))
4109 evas_object_show(ec->comp_data->sub.below_obj);
4111 ec->ignored = ignored;
4113 if (ec->is_cursor && ec->visible)
4115 /* ignore cursor changes during resize/move I guess */
4116 if (!e_client_action_get())
4118 if (e_comp->pointer)
4120 x = e_comp->pointer->hot.x;
4121 y = e_comp->pointer->hot.y;
4123 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4129 static E_Comp_Wl_Output *
4130 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4133 E_Comp_Wl_Output *output;
4135 EINA_LIST_FOREACH(outputs, l, output)
4137 if (!strcmp(output->id, id))
4145 * Initializes information about one display output.
4147 * Adds or updates the given data about a single display output,
4148 * with an id matching the provided id.
4150 * @param id identification of output to be added or changed
4151 * @param make manufacturer name of the display output
4152 * @param model model name of the display output
4153 * @param x output's top left corner x coordinate
4154 * @param y output's top left corner y coordinate
4155 * @param w output's width in pixels
4156 * @param h output's height in pixels
4157 * @param pw output's physical width in millimeters
4158 * @param ph output's physical height in millimeters
4159 * @param refresh output's refresh rate in mHz
4160 * @param subpixel output's subpixel layout
4161 * @param transform output's rotation and/or mirror transformation
4163 * @returns True if a display output object could be added or updated
4166 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4167 int x, int y, int w, int h, int pw, int ph,
4168 unsigned int refresh, unsigned int subpixel,
4169 unsigned int transform)
4171 E_Comp_Wl_Output *output;
4173 struct wl_resource *resource;
4175 /* retrieve named output; or create it if it doesn't exist */
4176 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4179 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4181 if (id) output->id = eina_stringshare_add(id);
4183 output->make = eina_stringshare_add(make);
4185 output->make = eina_stringshare_add("unknown");
4187 output->model = eina_stringshare_add(model);
4189 output->model = eina_stringshare_add("unknown");
4191 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4194 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4195 2, output, _e_comp_wl_cb_output_bind);
4197 output->resources = NULL;
4198 output->scale = e_scale;
4201 /* update the output details */
4206 output->phys_width = pw;
4207 output->phys_height = ph;
4208 output->refresh = refresh;
4209 output->subpixel = subpixel;
4210 output->transform = transform;
4212 if (output->scale <= 0)
4213 output->scale = e_scale;
4215 /* if we have bound resources, send updates */
4216 EINA_LIST_FOREACH(output->resources, l2, resource)
4218 wl_output_send_geometry(resource,
4219 output->x, output->y,
4221 output->phys_height,
4223 output->make ?: "", output->model ?: "",
4226 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4227 wl_output_send_scale(resource, output->scale);
4229 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4230 output->w, output->h, output->refresh);
4232 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4233 wl_output_send_done(resource);
4240 e_comp_wl_output_remove(const char *id)
4242 E_Comp_Wl_Output *output;
4244 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4247 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4249 /* wl_global_destroy(output->global); */
4251 /* eina_stringshare_del(output->id); */
4252 /* eina_stringshare_del(output->make); */
4253 /* eina_stringshare_del(output->model); */
4260 _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)
4262 struct wl_resource *res;
4264 uint32_t serial, keycode;
4265 struct wl_client *wc = NULL;
4266 E_Comp_Config *comp_conf = NULL;
4267 const char *device_name = NULL;
4269 keycode = (ev->keycode - 8);
4271 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4273 comp_conf = e_comp_config_get();
4275 if (ec && ec->comp_data)
4277 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4280 wc = wl_resource_get_client(surface);
4283 EINA_LIST_FOREACH(key_list, l, res)
4285 if (wl_resource_get_client(res) != wc) continue;
4287 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4288 if (!e_input_thread_mode_get())
4290 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4291 device_name = ecore_device_name_get(ev->dev);
4297 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4298 device_name = e_device_name_get(dev);
4302 if (comp_conf && comp_conf->input_log_enable)
4303 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4305 wl_keyboard_send_key(res, serial, ev->timestamp,
4312 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4314 E_Client *ec = NULL;
4316 E_Comp_Wl_Key_Data *end, *k;
4318 if (ev->window != e_comp->ee_win)
4323 keycode = (ev->keycode - 8);
4324 if (!(e_comp_wl = e_comp->wl_comp_data))
4329 #ifndef E_RELEASE_BUILD
4330 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4331 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4332 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4333 eina_streq(ev->key, "BackSpace"))
4339 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4341 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4343 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4345 /* ignore server-generated key repeats */
4346 if (k->key == keycode)
4348 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4353 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4354 g_rec_mutex_lock(&e_comp->input_key_grabs_mutex);
4356 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4358 ec = e_client_focused_get();
4359 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4360 if (ec && ec->comp_data && surface)
4362 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4363 if (e_comp_wl->kbd.focused)
4365 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4367 /* A key only sent to clients is added to the list */
4368 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4369 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4371 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4373 DBG("wl_array_add: Out of memory\n");
4374 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4375 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4376 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4379 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4383 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4387 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4389 /* update modifier state */
4390 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4396 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4398 E_Client *ec = NULL;
4399 uint32_t keycode, delivered_key;
4400 E_Comp_Wl_Key_Data *end, *k;
4402 if (ev->window != e_comp->ee_win)
4407 keycode = (ev->keycode - 8);
4409 if (!(e_comp_wl = e_comp->wl_comp_data))
4414 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4416 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4417 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4419 if (k->key == keycode)
4426 e_comp_wl->kbd.keys.size =
4427 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4429 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4431 /* 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) */
4432 g_rec_mutex_lock(&e_comp->input_key_grabs_mutex);
4433 if ((delivered_key) ||
4434 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4436 ec = e_client_focused_get();
4438 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4439 if (e_comp_wl->kbd.focused)
4441 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4443 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4445 g_rec_mutex_unlock(&e_comp->input_key_grabs_mutex);
4447 /* update modifier state */
4448 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4454 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4456 Eina_Bool res = EINA_FALSE;
4458 if (type == ECORE_EVENT_KEY_DOWN)
4460 res = e_comp_wl_key_down(ev, dev);
4462 else if (type == ECORE_EVENT_KEY_UP)
4464 res = e_comp_wl_key_up(ev, dev);
4471 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4474 struct wl_client *wc;
4475 uint32_t serial, btn;
4476 struct wl_resource *res;
4477 E_Comp_Config *comp_conf = NULL;
4479 if (ec->cur_mouse_action || e_comp_wl->drag)
4481 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4482 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4486 case 1: btn = BTN_LEFT; break;
4487 case 2: btn = BTN_MIDDLE; break;
4488 case 3: btn = BTN_RIGHT; break;
4489 default: btn = button_id; break;
4492 e_comp_wl->ptr.button = btn;
4493 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4494 if (!surface) return EINA_FALSE;
4496 if (!eina_list_count(e_comp_wl->ptr.resources))
4499 wc = wl_resource_get_client(surface);
4500 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4502 comp_conf = e_comp_config_get();
4504 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4506 if (wl_resource_get_client(res) != wc) continue;
4507 if (!e_comp_wl_input_pointer_check(res)) continue;
4508 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4510 if (comp_conf && comp_conf->input_log_enable)
4511 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4513 wl_pointer_send_button(res, serial, timestamp, btn, state);
4520 e_comp_wl_touch_cancel(void)
4522 _e_comp_wl_touch_cancel();
4525 E_API E_Comp_Wl_Hook *
4526 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4530 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4531 ch = E_NEW(E_Comp_Wl_Hook, 1);
4532 if (!ch) return NULL;
4533 ch->hookpoint = hookpoint;
4535 ch->data = (void*)data;
4536 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4541 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4544 if (_e_comp_wl_hooks_walking == 0)
4546 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4550 _e_comp_wl_hooks_delete++;
4553 E_API E_Comp_Wl_Pid_Hook *
4554 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4556 E_Comp_Wl_Pid_Hook *ch;
4558 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4560 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4561 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4563 ch->hookpoint = hookpoint;
4565 ch->data = (void*)data;
4566 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4572 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4575 if (_e_comp_wl_pid_hooks_walking == 0)
4577 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4581 _e_comp_wl_pid_hooks_delete++;
4584 E_API E_Comp_Wl_Intercept_Hook *
4585 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4587 E_Comp_Wl_Intercept_Hook *ch;
4589 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4590 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4591 if (!ch) return NULL;
4592 ch->hookpoint = hookpoint;
4594 ch->data = (void*)data;
4595 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4600 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4603 if (_e_comp_wl_intercept_hooks_walking == 0)
4605 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4609 _e_comp_wl_intercept_hooks_delete++;
4613 e_comp_wl_shell_surface_ready(E_Client *ec)
4617 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4621 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4623 e_config->use_cursor_timer = !!enabled;
4625 if (e_config->use_cursor_timer == EINA_FALSE)
4627 if (e_comp_wl->ptr.hide_tmr)
4629 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4630 e_comp_wl->ptr.hide_tmr = NULL;
4632 cursor_timer_ec = NULL;
4634 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4637 if (e_pointer_is_hidden(e_comp->pointer))
4639 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4645 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4647 EINA_SAFETY_ON_NULL_RETURN(wc);
4648 EINA_SAFETY_ON_NULL_RETURN(dev);
4650 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4654 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4656 EINA_SAFETY_ON_NULL_RETURN(wc);
4657 EINA_SAFETY_ON_NULL_RETURN(dev);
4659 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4663 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4665 struct wl_resource *res;
4666 struct wl_client *wc;
4668 uint32_t serial, wl_keycode;
4669 enum wl_keyboard_key_state state;
4670 E_Comp_Config *comp_conf = NULL;
4671 const char *dev_name = NULL;
4673 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4674 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4675 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4677 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4678 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4680 wl_keycode = keycode - 8;
4681 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4683 wc = wl_resource_get_client(surface);
4684 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4685 if (!time) time = e_util_timestamp_get();
4686 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4687 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4689 comp_conf = e_comp_config_get();
4690 e_keyrouter_event_surface_send(ec, keycode);
4692 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4693 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4695 if (wl_resource_get_client(res) != wc) continue;
4696 if (!e_input_thread_mode_get())
4700 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4701 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4705 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4712 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4713 dev_name = e_device_name_get(dev);
4717 if (comp_conf && comp_conf->input_log_enable)
4718 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4721 wl_keyboard_send_key(res, serial, time,
4724 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4730 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4732 struct wl_resource *res;
4733 struct wl_client *wc;
4735 uint32_t serial, wl_keycode, cancel_keycode;
4736 E_Comp_Config *comp_conf = NULL;
4738 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4739 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4740 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4741 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->xkb.keymap, EINA_FALSE);
4743 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4744 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4746 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4747 if (cancel_keycode == XKB_KEYCODE_INVALID)
4749 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4752 cancel_keycode = cancel_keycode - 8;
4754 wl_keycode = keycode - 8;
4755 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4757 wc = wl_resource_get_client(surface);
4758 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4759 if (!time) time = e_util_timestamp_get();
4761 comp_conf = e_comp_config_get();
4762 e_keyrouter_event_surface_send(ec, keycode);
4764 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4765 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4767 if (wl_resource_get_client(res) != wc) continue;
4768 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4769 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4771 if (comp_conf && comp_conf->input_log_enable)
4772 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4773 wl_keyboard_send_key(res, serial, time,
4774 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4775 wl_keyboard_send_key(res, serial, time,
4776 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4777 wl_keyboard_send_key(res, serial, time,
4778 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4780 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4787 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)
4789 struct wl_client *wc;
4791 E_Devicemgr_Input_Device *device = NULL;
4793 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4794 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4795 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4797 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4800 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4802 wc = wl_resource_get_client(surface);
4803 if (!time) time = e_util_timestamp_get();
4804 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4808 _e_comp_wl_send_event_device(wc, time, dev, serial);
4809 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4813 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4814 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4817 x = x + ec->client.x;
4818 y = y + ec->client.y;
4820 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4826 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)
4828 E_Devicemgr_Input_Device *device;
4830 struct wl_client *wc;
4832 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4833 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4834 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4836 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4837 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4839 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4841 wc = wl_resource_get_client(surface);
4842 if (!time) time = e_util_timestamp_get();
4843 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4847 _e_comp_wl_send_event_device(wc, time, dev, serial);
4848 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4852 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4853 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4856 x = x + ec->client.x;
4857 y = y + ec->client.y;
4859 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4865 e_comp_wl_touch_cancel_send(E_Client *ec)
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4869 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4871 _e_comp_wl_send_touch_cancel(ec);
4877 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4880 struct wl_client *wc;
4882 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4883 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4884 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4886 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4887 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4889 wc = wl_resource_get_client(surface);
4890 if (!time) time = e_util_timestamp_get();
4891 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4893 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4894 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4897 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4898 WL_POINTER_BUTTON_STATE_PRESSED);
4900 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4901 WL_POINTER_BUTTON_STATE_RELEASED);
4907 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4910 struct wl_client *wc;
4912 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4913 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4914 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4916 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4917 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4919 wc = wl_resource_get_client(surface);
4920 if (!time) time = e_util_timestamp_get();
4921 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4923 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4924 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4926 x = x + ec->client.x;
4927 y = y + ec->client.y;
4929 _e_comp_wl_send_mouse_move(ec, x, y, time);
4935 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4938 struct wl_client *wc;
4940 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4941 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4942 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4944 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4945 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4947 wc = wl_resource_get_client(surface);
4948 if (!time) time = e_util_timestamp_get();
4949 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4951 if (_e_comp_wl_check_cursor_timer_needed(ec))
4953 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4957 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4958 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4960 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4962 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4964 if (_e_comp_wl_check_cursor_timer_needed(ec))
4965 _e_comp_wl_cursor_move_timer_control(ec);
4972 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4975 struct wl_client *wc;
4976 struct wl_resource *res;
4979 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4980 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4982 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4983 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4985 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4986 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4988 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4989 wc = wl_resource_get_client(surface);
4990 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4991 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4993 if (!e_comp_wl_input_pointer_check(res)) continue;
4994 if (wl_resource_get_client(res) != wc) continue;
4996 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4997 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4999 wl_pointer_send_enter(res, serial, surface,
5000 wl_fixed_from_int(x),
5001 wl_fixed_from_int(y));
5002 ec->pointer_enter_sent = EINA_TRUE;
5004 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5010 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5013 struct wl_client *wc;
5014 struct wl_resource *res;
5017 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5018 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5019 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5020 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5021 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5022 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5024 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5025 wc = wl_resource_get_client(surface);
5026 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5027 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5029 if (!e_comp_wl_input_pointer_check(res)) continue;
5030 if (wl_resource_get_client(res) != wc) continue;
5032 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5033 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5035 wl_pointer_send_leave(res, serial, surface);
5036 ec->pointer_enter_sent = EINA_FALSE;
5043 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)
5045 Evas_Event_Mouse_In ev_in;
5048 if (ec->pointer_enter_sent) return;
5050 ev_in.buttons = buttons;
5058 ev_in.modifiers = modifiers;
5059 ev_in.locks = locks;
5060 ev_in.timestamp = timestamp;
5061 ev_in.event_flags = event_flags;
5064 ev_in.event_src = event_src;
5066 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5070 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)
5072 Evas_Event_Mouse_Out ev_out;
5075 if (!ec->pointer_enter_sent) return;
5077 ev_out.buttons = buttons;
5079 ev_out.output.x = x;
5080 ev_out.output.y = y;
5081 ev_out.canvas.x = x;
5082 ev_out.canvas.y = y;
5085 ev_out.modifiers = modifiers;
5086 ev_out.locks = locks;
5087 ev_out.timestamp = timestamp;
5088 ev_out.event_flags = event_flags;
5091 ev_out.event_src = event_src;
5093 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5097 e_comp_wl_cursor_hide(E_Client *ec)
5099 struct wl_resource *res;
5100 struct wl_client *wc;
5104 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5106 if (e_comp_wl->ptr.hide_tmr)
5108 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5109 e_comp_wl->ptr.hide_tmr = NULL;
5111 cursor_timer_ec = NULL;
5113 if (!ec) return EINA_FALSE;
5114 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5115 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5116 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5118 wc = wl_resource_get_client(surface);
5119 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5120 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5122 if (!e_comp_wl_input_pointer_check(res)) continue;
5123 if (wl_resource_get_client(res) != wc) continue;
5124 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5125 wl_pointer_send_leave(res, serial, surface);
5126 ec->pointer_enter_sent = EINA_FALSE;
5132 /* surface to buffer
5133 * - width : surface width
5134 * - height : surface height
5135 * - transform: buffer transform
5136 * - scale : buffer scale
5138 * - width : screen width
5139 * - height : screen height
5140 * - transform: output transform
5141 * - scale : output scale
5143 static E_Util_Transform_Matrix
5144 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5146 E_Util_Transform_Matrix m;
5148 e_util_transform_matrix_load_identity(&m);
5150 if (transform & 0x4)
5152 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5153 e_util_transform_matrix_flip_x(&m);
5154 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5157 switch (transform & 0x3)
5159 case WL_OUTPUT_TRANSFORM_90:
5160 e_util_transform_matrix_translate(&m, -width, 0, 0);
5161 e_util_transform_matrix_rotation_z(&m, 270);
5163 case WL_OUTPUT_TRANSFORM_180:
5164 e_util_transform_matrix_translate(&m, -width, -height, 0);
5165 e_util_transform_matrix_rotation_z(&m, 180);
5167 case WL_OUTPUT_TRANSFORM_270:
5168 e_util_transform_matrix_translate(&m, 0, -height, 0);
5169 e_util_transform_matrix_rotation_z(&m, 90);
5175 e_util_transform_matrix_scale(&m, scale, scale, 1);
5180 /* surface to buffer
5181 * - surface width, surface height, buffer transform, buffer scale
5183 * - screen width, screen height, output transform, output scale
5186 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5188 E_Util_Transform_Matrix m;
5189 E_Util_Transform_Vertex v;
5191 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5193 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5194 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5195 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5199 * - buffer width, buffer height, buffer transform, buffer scale
5202 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5204 E_Util_Transform_Matrix m;
5205 E_Util_Transform_Vertex v;
5208 if (transform != 0 || scale > 1)
5210 tw = ((transform % 2) ? height : width) / scale;
5211 th = ((transform % 2) ? width : height) / scale;
5219 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5220 m = e_util_transform_matrix_inverse_get(&m);
5222 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5223 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5224 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5227 /* surface to buffer
5228 * - surface width, surface height, buffer transform, buffer scale
5230 * - screen width, screen height, output transform, output scale
5233 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5234 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5236 E_Util_Transform_Matrix m;
5237 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5238 E_Util_Transform_Rect_Vertex sv;
5240 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5242 sv = e_util_transform_rect_to_vertices(&sr);
5243 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5244 sr = e_util_transform_vertices_to_rect(&sv);
5253 * - buffer width, buffer height, buffer transform, buffer scale
5256 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5257 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5259 E_Util_Transform_Matrix m;
5260 E_Util_Transform_Rect br = {bx, by, bw, bh};
5261 E_Util_Transform_Rect_Vertex bv;
5264 if (transform != 0 || scale > 1)
5266 tw = ((transform % 2) ? height : width) / scale;
5267 th = ((transform % 2) ? width : height) / scale;
5275 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5276 m = e_util_transform_matrix_inverse_get(&m);
5278 bv = e_util_transform_rect_to_vertices(&br);
5279 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5280 br = e_util_transform_vertices_to_rect(&bv);
5288 EINTERN E_Comp_Wl_Output*
5289 e_comp_wl_output_find(E_Client *ec)
5292 E_Comp_Wl_Output *output;
5294 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5296 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5298 if (output->transform % 2)
5300 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5301 ec->y < output->x || ec->y >= (output->x + output->w))
5306 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5307 ec->y < output->y || ec->y >= (output->y + output->h))
5317 EINTERN Eina_Array *
5318 e_comp_wl_output_find_all(E_Client *ec)
5320 E_Comp_Wl_Output *output;
5321 Eina_Array *outputs;
5324 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5326 outputs = eina_array_new(4);
5330 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5332 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5333 output->x, output->y, output->w, output->h))
5335 eina_array_push(outputs, output);
5339 if (eina_array_count(outputs) == 0)
5341 eina_array_free(outputs);
5348 // --------------------------------------------------------
5349 // tizen_move_resize
5350 // --------------------------------------------------------
5352 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5359 E_Client_Pending_Geometry *geo;
5362 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5363 if (ec->fullscreen || ec->maximized) goto err;
5365 geo = E_NEW(E_Client_Pending_Geometry, 1);
5368 geo->serial = serial;
5374 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5375 ec->surface_sync.wait_commit = EINA_TRUE;
5380 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5387 e_comp_wl_commit_sync_configure(E_Client *ec)
5390 E_Client_Pending_Geometry *geo;
5392 Eina_Bool match_size = EINA_FALSE;
5399 if (!ec || !ec->frame) goto ret;
5400 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5403 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5404 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5406 if (eina_list_count(ec->surface_sync.pending_geometry))
5408 Eina_List *ll = NULL;
5409 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5413 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5418 if ((geo->w == bw) && (geo->h == bh))
5420 match_size = EINA_TRUE;
5425 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5432 if ((config.w != ec->w) || (config.h != ec->h))
5434 e_client_size_set(ec, config.w, config.h);
5435 ec->changes.size = EINA_TRUE;
5439 // FIXME: The geometry of the client would be better to be calculated
5440 // at e_desk or at e_desk_area. So the position(x,y) of the client
5441 // should be calcuated at the e_desk or at the e_desk_area.
5443 desk = e_comp_desk_find_by_ec(ec);
5446 ec->client.x = desk->geom.x + config.x;
5447 ec->client.y = desk->geom.y + config.y;
5451 ec->client.x = config.x;
5452 ec->client.y = config.y;
5455 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5457 e_client_pos_set(ec, ec->client.x, ec->client.y);
5459 ec->changes.pos = 1;
5463 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5467 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5468 ec->surface_sync.wait_commit = EINA_FALSE;
5470 if ((ec->comp_data->shell.surface) &&
5471 (ec->comp_data->shell.configure))
5473 ec->comp_data->shell.configure(ec->comp_data->shell.surface,
5478 // rollback wait_commit if there are pending requests remained
5479 if (eina_list_count(ec->surface_sync.pending_geometry))
5480 ec->surface_sync.wait_commit = EINA_TRUE;
5485 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);
5492 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5493 struct wl_resource *res_moveresize)
5495 wl_resource_destroy(res_moveresize);
5499 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5500 struct wl_resource *res_moveresize,
5501 struct wl_resource *surface,
5508 /* to be implemented */
5511 int cur_w = 0, cur_h = 0;
5513 ec = e_client_from_surface_resource(surface);
5516 pending = e_client_pending_geometry_has(ec);
5517 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5518 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);
5522 if ((cur_w == w) && (cur_h == h))
5524 e_client_pos_set(ec, x, y);
5525 ec->changes.pos = 1;
5531 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5535 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5538 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5540 _tz_move_resize_iface_cb_destroy,
5541 _tz_move_resize_iface_cb_set_geometry,
5545 _tz_moveresize_cb_bind(struct wl_client *client,
5546 void *data EINA_UNUSED,
5550 struct wl_resource *res_moveresize;
5552 res_moveresize = wl_resource_create(client,
5553 &tizen_move_resize_interface,
5556 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5559 wl_resource_set_implementation(res_moveresize,
5560 &_tz_move_resize_iface,
5566 ERR("Could not create tizen_move_resize_interface res: %m");
5567 wl_client_post_no_memory(client);
5571 _e_comp_wl_move_resize_init(void)
5573 if (!e_comp_wl) return;
5574 if (!e_comp_wl->wl.disp) return;
5576 if (!wl_global_create(e_comp_wl->wl.disp,
5577 &tizen_move_resize_interface,
5580 _tz_moveresize_cb_bind))
5582 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5589 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5591 E_Comp_Wl_Output *output;
5592 pid_t output_pid = 0;
5593 Eina_List *l = NULL, *l2 = NULL;
5594 struct wl_resource *resource = NULL;
5596 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5598 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5599 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5600 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5602 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5604 /* if we have bound resources, send updates */
5605 EINA_LIST_FOREACH(output->resources, l2, resource)
5607 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5608 if (output_pid != pid) continue;
5610 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5612 // send output information to the client
5613 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5621 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5623 _e_comp_wl_surface_state_init(state, w, h);
5627 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5629 _e_comp_wl_surface_state_commit(ec, state);
5633 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5635 _e_comp_wl_hook_call(hookpoint, ec);
5639 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5641 _e_comp_wl_surface_state_finish(state);
5645 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5647 _e_comp_wl_surface_state_buffer_set(state, buffer);
5651 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5652 int sx, int sy, int *dx, int *dy)
5656 case WL_OUTPUT_TRANSFORM_NORMAL:
5660 case WL_OUTPUT_TRANSFORM_FLIPPED:
5661 *dx = width - sx, *dy = sy;
5663 case WL_OUTPUT_TRANSFORM_90:
5664 *dx = height - sy, *dy = sx;
5666 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5667 *dx = height - sy, *dy = width - sx;
5669 case WL_OUTPUT_TRANSFORM_180:
5670 *dx = width - sx, *dy = height - sy;
5672 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5673 *dx = sx, *dy = height - sy;
5675 case WL_OUTPUT_TRANSFORM_270:
5676 *dx = sy, *dy = width - sx;
5678 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5688 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5691 int tx1, ty1, tx2, ty2;
5692 int width_from_buffer, height_from_buffer;
5694 switch (vp->buffer.transform)
5696 case WL_OUTPUT_TRANSFORM_90:
5697 case WL_OUTPUT_TRANSFORM_270:
5698 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5699 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5700 width_from_buffer = bh / vp->buffer.scale;
5701 height_from_buffer = bw / vp->buffer.scale;
5704 width_from_buffer = bw / vp->buffer.scale;
5705 height_from_buffer = bh / vp->buffer.scale;
5709 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5713 x2 = width_from_buffer;
5714 y2 = height_from_buffer;
5718 x1 = wl_fixed_to_int(vp->buffer.src_x);
5719 y1 = wl_fixed_to_int(vp->buffer.src_y);
5720 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5721 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5724 buffer_transform(width_from_buffer, height_from_buffer,
5725 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5726 buffer_transform(width_from_buffer, height_from_buffer,
5727 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5729 out->x = (tx1 <= tx2) ? tx1 : tx2;
5730 out->y = (ty1 <= ty2) ? ty1 : ty2;
5731 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5732 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5736 * Convert given four coordinates to elements of rectangle
5737 * @in p[4] Coordinates to be converted
5738 * @out rect x, y, width, and height
5739 * transform Angle which represents TDM_TRANSFORM of rectangle
5740 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5741 * 1. The given coordinates are not represented by rectangle.
5742 * 2. All angles except for 0, 90, 180, 270.
5745 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5747 Eina_Bool ret = EINA_FALSE;
5749 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))
5752 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5755 *rotation = TDM_TRANSFORM_NORMAL;
5758 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5762 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5765 *rotation = TDM_TRANSFORM_180;
5768 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5773 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))
5776 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5779 *rotation = TDM_TRANSFORM_90;
5782 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5786 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5789 *rotation = TDM_TRANSFORM_270;
5792 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5802 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5807 for (i = 0; i < 4; i++)
5808 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5810 if (!_coords_to_rectangle_convert(p, out, rotation))
5812 DBG("Cannot convert given coords to rectangle.\n"
5813 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5814 p[0].x, p[0].y, p[1].x, p[1].y,
5815 p[2].x, p[2].y, p[3].x, p[3].y);
5823 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5825 int trans_rotation, flip;
5827 trans_rotation = transform & 0x3;
5828 flip = transform & 0x4;
5830 return (flip + (trans_rotation + rotation) % 4);
5834 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5842 if (e_comp_wl_subsurface_check(ec))
5843 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5850 out->w = ec->comp_data->width_from_viewport;
5851 out->w = (out->w + 1) & ~1;
5852 out->h = ec->comp_data->height_from_viewport;
5854 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5855 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5859 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5861 E_Comp_Wl_Buffer *buffer;
5862 E_Comp_Wl_Buffer_Viewport *vp;
5864 enum wl_output_transform buffer_transform;
5865 unsigned int rotation;
5866 Eina_Bool res = EINA_FALSE;
5868 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5870 if (e_object_is_del(E_OBJECT(ec)))
5873 vp = &ec->comp_data->scaler.buffer_viewport;
5875 if (buffer_viewport)
5877 buffer = ec->comp_data->buffer_ref.buffer;
5878 /* Getting a viewport of buffer needs geometry of buffer. */
5882 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5885 if ((output_viewport) || (transform))
5887 m = e_client_map_get(ec);
5889 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5891 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5896 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5897 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5898 * Since buffer.transform isn't applied using evas_map,
5899 * it has to be taken into account here to apply buffer.transform
5900 * and rotation of e_client_transform together. */
5902 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5904 *transform = (unsigned int)buffer_transform;
5912 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5914 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5915 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5917 /* Must be called with valid comp_data */
5918 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5920 if ((ec->comp_data->role_name == NULL) ||
5921 (ec->comp_data->role_name == role_name) ||
5922 (strcmp(ec->comp_data->role_name, role_name) == 0))
5924 ec->comp_data->role_name = role_name;
5930 wl_resource_post_error(error_resource, error_code,
5931 "Cannot assign role %s to wl_surface@%d,"
5932 " already has role %s\n",
5934 ec->comp_data->wl_surface ?
5935 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5936 ec->comp_data->role_name);
5942 EINTERN const char *
5943 e_comp_wl_surface_role_get(E_Client *ec)
5945 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5946 return ec->comp_data ? ec->comp_data->role_name : NULL;
5949 EINTERN struct wl_resource *
5950 e_comp_wl_client_surface_get(E_Client *ec)
5952 struct wl_resource *surface = NULL;
5953 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5954 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5956 g_mutex_lock(&ec->comp_data->surface_mutex);
5957 surface = ec->comp_data->surface;
5958 g_mutex_unlock(&ec->comp_data->surface_mutex);
5963 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5965 EINA_SAFETY_ON_NULL_RETURN(ec);
5966 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5968 g_mutex_lock(&ec->comp_data->surface_mutex);
5969 ec->comp_data->surface = surface;
5970 g_mutex_unlock(&ec->comp_data->surface_mutex);
5974 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5976 return e_compositor_util_client_from_surface_resource(surface_resource);
5980 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5982 if (!ec->comp_data->mapped)
5984 if (ec->comp_data->shell.surface &&
5985 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5987 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5993 if (ec->comp_data->mapped)
5995 /* will be unmapped. so run capture */
5996 e_comp_wl_remote_surface_image_save(ec);
6000 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
6002 ec->comp_data->pending.sx = sx;
6003 ec->comp_data->pending.sy = sy;
6004 ec->comp_data->pending.new_attach = EINA_TRUE;
6006 e_client_fps_update(ec);
6010 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6012 if (ec->comp_data->pending.opaque)
6013 eina_tiler_clear(ec->comp_data->pending.opaque);
6017 eina_tiler_union(ec->comp_data->pending.opaque, region);
6019 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6023 ec->argb = EINA_FALSE;
6024 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6026 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6027 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6035 ec->argb = EINA_TRUE;
6036 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6038 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6039 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6045 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6047 if (ec->comp_data->pending.input)
6048 eina_tiler_clear(ec->comp_data->pending.input);
6052 if (eina_tiler_empty(region))
6054 ELOGF("COMP", " |unset input rect", NULL);
6055 e_comp_object_input_objs_del(ec->frame);
6056 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6059 eina_tiler_union(ec->comp_data->pending.input, region);
6063 eina_tiler_rect_add(ec->comp_data->pending.input,
6064 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6069 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6071 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6075 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6077 E_Comp_Wl_Subsurf_Data *sdata;
6082 if (ec->comp_data->frames)
6084 ec->comp_data->frames =
6085 eina_list_remove(ec->comp_data->frames, callback_resource);
6088 if (ec->comp_data->pending.frames)
6090 ec->comp_data->pending.frames =
6091 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6094 sdata = ec->comp_data->sub.data;
6095 if ((sdata) && (sdata->cached.frames))
6097 sdata->cached.frames =
6098 eina_list_remove(sdata->cached.frames, callback_resource);
6103 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6105 if (e_object_is_del(E_OBJECT(ec))) return;
6107 if (e_comp_wl_remote_surface_commit(ec)) return;
6109 e_comp_wl_surface_commit(ec);
6111 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6115 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6117 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6118 ec->comp_data->sub.data = sub;
6120 /* set subsurface client properties */
6121 ec->borderless = EINA_TRUE;
6122 ec->argb = EINA_TRUE;
6123 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6124 ec->lock_border = EINA_TRUE;
6125 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6126 ec->netwm.state.skip_taskbar = EINA_TRUE;
6127 ec->netwm.state.skip_pager = EINA_TRUE;
6128 ec->no_shape_cut = EINA_TRUE;
6129 ec->border_size = 0;
6130 ec->lock_user_location = 0;
6131 ec->lock_client_location = 0;
6132 ec->lock_user_size = 0;
6133 ec->lock_client_size = 0;
6134 ec->lock_client_stacking = 0;
6135 ec->lock_user_shade = 0;
6136 ec->lock_client_shade = 0;
6137 ec->lock_user_maximize = 0;
6138 ec->lock_client_maximize = 0;
6139 ec->changes.need_maximize = 0;
6140 ec->maximized = E_MAXIMIZE_NONE;
6143 ec->new_client = ec->netwm.ping = EINA_TRUE;
6144 e_comp->new_clients++;
6145 e_client_unignore(ec);
6147 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6148 * It's not for subsurface. */
6149 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6153 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6155 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6158 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6160 sub->parent = parent;
6164 layer = e_client_layer_get(parent);
6165 if (layer > E_LAYER_BOTTOM)
6166 e_client_layer_set(ec, layer);
6169 if (parent->comp_data)
6171 /* append this client to the parents subsurface list */
6172 parent->comp_data->sub.list_pending =
6173 eina_list_append(parent->comp_data->sub.list_pending, ec);
6174 parent->comp_data->sub.list_changed = EINA_TRUE;
6179 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6181 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6182 E_Client *parent = sub->parent;
6184 parent->comp_data->sub.list =
6185 eina_list_remove(parent->comp_data->sub.list, ec);
6186 parent->comp_data->sub.list_pending =
6187 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6188 parent->comp_data->sub.below_list =
6189 eina_list_remove(parent->comp_data->sub.below_list, ec);
6190 parent->comp_data->sub.below_list_pending =
6191 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6197 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)
6199 sub->resource = subsurface_resource;
6200 sub->cached_buffer_ref.buffer = NULL;
6201 sub->synchronized = EINA_TRUE;
6202 sub->parent = parent;
6203 sub->remote_surface.offscreen_parent = offscreen_parent;
6204 if (offscreen_parent)
6205 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6207 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6209 _e_comp_wl_client_subsurface_set(ec, sub);
6210 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6212 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6216 e_comp_wl_client_subsurface_finish(E_Client *ec)
6218 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6221 e_comp_wl_client_subsurface_parent_unset(ec);
6223 e_comp_wl_surface_state_finish(&sub->cached);
6224 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6226 ec->comp_data->sub.data = NULL;
6230 e_comp_wl_client_evas_init(E_Client *ec)
6232 EINA_SAFETY_ON_NULL_RETURN(ec);
6234 _e_comp_wl_client_evas_init(ec);
6238 e_comp_wl_client_evas_deinit(E_Client *ec)
6240 EINA_SAFETY_ON_NULL_RETURN(ec);
6242 _e_comp_wl_client_evas_deinit(ec);
6246 e_comp_wl_focus_check(void)
6248 _e_comp_wl_focus_check();
6252 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6259 if ((parent->comp_data) && (parent->comp_data->sub.data))
6260 parent = parent->comp_data->sub.data->parent;