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 connection_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 if (e_config->key_input_ttrace_enable)
266 TRACE_INPUT_BEGIN(wl_display_flush_clients);
267 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
270 g_mutex_lock(&connection_mutex);
271 wl_display_flush_clients(e_comp_wl->wl.disp);
272 g_mutex_unlock(&connection_mutex);
274 if (e_config->key_input_ttrace_enable)
277 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
283 e_comp_wl_connection_lock()
285 e_input_boost_lock(&connection_mutex);
289 e_comp_wl_connection_unlock()
291 e_input_boost_unlock(&connection_mutex);
295 e_comp_wl_focused_client_flush()
297 E_Client *focused_ec;
298 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
300 e_input_boost_lock(&connection_mutex);
301 focused_ec = e_client_focused_get();
305 struct wl_client *wc;
306 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
309 e_input_boost_unlock(&connection_mutex);
313 wc = wl_resource_get_client(surface);
317 e_input_boost_unlock(&connection_mutex);
321 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
325 if (e_comp_wl->idle_exiter_timestamp > 0.0)
327 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
328 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
330 ELOGF("E_COMP", "prepare gap time: %lfms",
335 e_comp_wl->idle_exiter_timestamp = 0.0;
337 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
339 /* flush pending client events */
340 e_comp_wl_display_flush();
342 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
343 IDLE_EXITER~CB_PREPARE);
346 E_API enum wl_output_transform
347 e_comp_wl_output_buffer_transform_get(E_Client *ec)
349 E_Comp_Wl_Buffer_Viewport *vp;
350 E_Comp_Wl_Buffer *buffer;
351 enum wl_output_transform transform, rotation;
353 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
354 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
355 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
357 vp = &ec->comp_data->scaler.buffer_viewport;
358 if (e_comp_wl_subsurface_check(ec))
359 return vp->buffer.transform;
361 buffer = ec->comp_data->buffer_ref.buffer;
364 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
365 return vp->buffer.transform;
367 rotation = buffer->transform;
369 return vp->buffer.transform;
371 /* ignore the flip value when calculating transform because the screen rotation
372 * functionality doesn't consider the flip output transform currently
374 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
376 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
377 ec, rotation, vp->buffer.transform, transform);
382 EINTERN enum wl_output_transform
383 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
385 E_Comp_Wl_Buffer_Viewport *vp;
386 E_Comp_Wl_Buffer *buffer;
387 enum wl_output_transform transform, rotation;
389 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
390 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
391 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
393 vp = &ec->comp_data->pending.buffer_viewport;
394 if (e_comp_wl_subsurface_check(ec))
395 return vp->buffer.transform;
397 buffer = ec->comp_data->pending.buffer;
400 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
401 return vp->buffer.transform;
403 rotation = buffer->transform;
405 return vp->buffer.transform;
407 /* ignore the flip value when calculating transform because the screen rotation
408 * functionality doesn't consider the flip output transform currently
410 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
412 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
413 ec, rotation, vp->buffer.transform, transform);
419 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
421 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
422 E_Comp_Wl_Buffer *buffer;
423 int32_t width, height;
425 buffer = e_pixmap_resource_get(ec->pixmap);
428 ec->comp_data->width_from_buffer = 0;
429 ec->comp_data->height_from_buffer = 0;
433 switch (e_comp_wl_output_buffer_transform_get(ec))
435 case WL_OUTPUT_TRANSFORM_90:
436 case WL_OUTPUT_TRANSFORM_270:
437 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
438 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
439 width = buffer->h / vp->buffer.scale;
440 height = buffer->w / vp->buffer.scale;
443 width = buffer->w / vp->buffer.scale;
444 height = buffer->h / vp->buffer.scale;
448 ec->comp_data->width_from_buffer = width;
449 ec->comp_data->height_from_buffer = height;
453 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
455 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
456 int32_t width, height;
458 width = ec->comp_data->width_from_buffer;
459 height = ec->comp_data->height_from_buffer;
461 if (width == 0 && height == 0) return;
463 if (width != 0 && vp->surface.width != -1)
465 ec->comp_data->width_from_viewport = vp->surface.width;
466 ec->comp_data->height_from_viewport = vp->surface.height;
470 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
472 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
473 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
474 ec->comp_data->width_from_viewport = w ?: 1;
475 ec->comp_data->height_from_viewport = h ?: 1;
479 ec->comp_data->width_from_viewport = width;
480 ec->comp_data->height_from_viewport = height;
484 e_comp_wl_topmost_parent_get(E_Client *ec)
488 if (!e_comp_wl_subsurface_check(ec))
491 parent = e_comp_wl_subsurface_parent_get(ec);
494 if (!e_comp_wl_subsurface_check(parent))
497 parent = e_comp_wl_subsurface_parent_get(parent);
504 e_comp_wl_map_apply(E_Client *ec)
506 E_Comp_Wl_Buffer_Viewport *vp;
507 E_Comp_Wl_Subsurf_Data *sdata;
508 E_Comp_Wl_Client_Data *cdata;
509 int x1, y1, x2, y2, x, y;
511 Eina_Bool zoom_animating = EINA_FALSE;
513 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
515 e_comp_object_map_update(ec->frame);
517 cdata = ec->comp_data;
518 vp = &cdata->scaler.buffer_viewport;
519 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
520 (!cdata->viewport_transform))
523 if (e_comp_wl_subsurface_check(ec))
525 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
527 sdata = ec->comp_data->sub.data;
528 if (sdata->remote_surface.offscreen_parent)
530 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
531 Eina_Rectangle *rect;
534 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
536 /* TODO: If there are one more regions, it means that provider's offscreen
537 * is displayed by one more remote_surfaces. Have to consider it later. At
538 * this time, just consider only one remote_surface.
552 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
553 if (x != dx || y != dy)
554 evas_object_move(ec->frame, dx, dy);
556 if (!cdata->viewport_transform)
558 cdata->viewport_transform = e_util_transform_new();
559 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
560 e_client_transform_core_add(ec, cdata->viewport_transform);
563 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
564 ec->comp_data->width_from_viewport,
565 ec->comp_data->height_from_viewport);
567 if (vp->buffer.src_width == wl_fixed_from_int(-1))
571 x2 = cdata->width_from_buffer;
572 y2 = cdata->height_from_buffer;
576 x1 = wl_fixed_to_int(vp->buffer.src_x);
577 y1 = wl_fixed_to_int(vp->buffer.src_y);
578 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
579 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
582 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
583 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
584 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
585 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
588 desk = e_comp_desk_find_by_ec(ec);
590 zoom_animating = e_desk_zoom_is_animating(desk);
592 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
593 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
594 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
596 /* workaround:: when the desk zoom is doing their animation,
597 the transform core update can override animation's zoom boundary.
598 so, don't doing transform core update while desk zoom animation */
600 e_client_transform_core_update(ec);
605 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
609 int map_c = 0, map_x = 0, map_y = 0;
610 double inv_x = 0.0, inv_y = 0.0;
612 EINA_SAFETY_ON_NULL_RETURN(ec);
614 map = e_client_map_get(ec);
615 map_c = e_map_count_get(map);
617 if (!map || map_c <= 0)
627 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
628 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
629 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
630 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
632 for (int i = 0; i < map_c; i++)
634 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
635 e_map_point_image_uv_set(map2, i, map_x, map_y);
637 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
647 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
653 if (!(ec = data)) return;
654 if (e_object_is_del(data)) return;
656 if (!ec->override) e_hints_window_visible_set(ec);
658 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
659 (!ec->comp_data->need_reparent))
661 ec->comp_data->need_reparent = EINA_TRUE;
662 ec->visible = EINA_TRUE;
664 if (!e_client_util_ignored_get(ec))
666 ec->take_focus = !starting;
670 if (!ec->comp_data->need_reparent)
672 if ((ec->hidden) || (ec->iconic))
674 evas_object_hide(ec->frame);
675 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
678 evas_object_show(ec->frame);
681 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
682 evas_object_show(tmp->frame);
684 topmost = e_comp_wl_topmost_parent_get(ec);
685 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
686 e_comp_wl_subsurface_show(ec);
688 if (ec->comp_data->sub.below_obj)
689 evas_object_show(ec->comp_data->sub.below_obj);
693 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
699 if (!(ec = data)) return;
700 if (e_object_is_del(E_OBJECT(ec))) return;
702 /* Uncommonly some clients's final buffer can be skipped if the client
703 * requests unmap of its surface right after wl_surface@commit.
704 * So if this client evas object is hidden state and client is already
705 * unmmapped, we can consider to clear pixmap image here mandatorily.
707 if (!ec->comp_data->mapped)
708 e_pixmap_image_clear(ec->pixmap, 1);
710 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
711 evas_object_hide(tmp->frame);
713 topmost = e_comp_wl_topmost_parent_get(ec);
714 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
715 e_comp_wl_subsurface_hide(ec);
717 if (ec->comp_data->sub.below_obj)
718 evas_object_hide(ec->comp_data->sub.below_obj);
720 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
724 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
731 if (!(ec = data)) return;
732 if (e_object_is_del(E_OBJECT(ec))) return;
734 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
736 if (!e_comp_wl_subsurface_check(subc)) continue;
737 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
738 evas_object_move(subc->frame, x, y);
740 if (subc->comp_data->scaler.viewport)
742 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
743 if (cdata->viewport_transform)
744 e_comp_wl_map_apply(subc);
748 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
750 if (!e_comp_wl_subsurface_check(subc)) continue;
751 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
752 evas_object_move(subc->frame, x, y);
754 if (subc->comp_data->scaler.viewport)
756 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
757 if (cdata->viewport_transform)
758 e_comp_wl_map_apply(subc);
762 if (ec->comp_data->sub.below_obj)
764 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
765 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
770 _e_comp_wl_send_touch_cancel(E_Client *ec)
773 struct wl_resource *res;
774 struct wl_client *wc;
775 E_Comp_Config *comp_conf = NULL;
778 if (e_object_is_del(E_OBJECT(ec))) return;
779 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
781 if (!surface) return;
782 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
784 wc = wl_resource_get_client(surface);
786 comp_conf = e_comp_config_get();
788 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
790 if (wl_resource_get_client(res) != wc) continue;
791 if (!e_comp_wl_input_touch_check(res)) continue;
793 if (comp_conf && comp_conf->input_log_enable)
794 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
796 wl_touch_send_cancel(res);
801 _e_comp_wl_touch_cancel(void)
805 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
807 if (!e_comp_wl->touch.pressed) return;
809 _e_comp_wl_send_touch_cancel(ec);
812 static E_Devicemgr_Input_Device *
813 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
815 E_Devicemgr_Input_Device *last_kbd = NULL;
818 case ECORE_DEVICE_CLASS_MOUSE:
819 return e_devicemgr->last_device_ptr;
820 case ECORE_DEVICE_CLASS_KEYBOARD:
821 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
823 case ECORE_DEVICE_CLASS_TOUCH:
824 return e_devicemgr->last_device_touch;
832 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
836 case ECORE_DEVICE_CLASS_MOUSE:
837 e_devicemgr->last_device_ptr = device;
839 case ECORE_DEVICE_CLASS_KEYBOARD:
840 atomic_store(&e_devicemgr->last_device_kbd, device);
842 case ECORE_DEVICE_CLASS_TOUCH:
843 e_devicemgr->last_device_touch = device;
850 static E_Devicemgr_Input_Device *
851 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
853 E_Devicemgr_Input_Device *last_kbd = NULL;
857 case ECORE_DEVICE_CLASS_MOUSE:
858 return ec->comp_data->last_device_ptr;
859 case ECORE_DEVICE_CLASS_KEYBOARD:
860 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
862 case ECORE_DEVICE_CLASS_TOUCH:
863 return ec->comp_data->last_device_touch;
871 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
875 case ECORE_DEVICE_CLASS_MOUSE:
876 ec->comp_data->last_device_ptr = device;
878 case ECORE_DEVICE_CLASS_KEYBOARD:
879 atomic_store(&ec->comp_data->last_device_kbd, device);
881 case ECORE_DEVICE_CLASS_TOUCH:
882 ec->comp_data->last_device_touch = device;
890 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
892 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
893 struct wl_resource *dev_res;
894 const char *dev_name;
895 Ecore_Device_Class dev_class;
896 struct wl_client *wc;
900 EINA_SAFETY_ON_NULL_RETURN(dev);
903 if (ec->cur_mouse_action || e_comp_wl->drag)
905 if (e_object_is_del(E_OBJECT(ec))) return;
906 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
907 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
908 if (!surface) return;
910 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
911 dev_name = evas_device_description_get(dev);
912 last_device = _e_comp_wl_device_last_device_get(dev_class);
913 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
915 serial = wl_display_next_serial(e_comp_wl->wl.disp);
916 wc = wl_resource_get_client(surface);
917 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
918 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
920 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
921 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
923 _e_comp_wl_device_last_device_set(dev_class, input_dev);
924 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
926 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
928 if (wl_resource_get_client(dev_res) != wc) continue;
929 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
933 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
937 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
939 E_Devicemgr_Input_Device *last_device;
940 struct wl_resource *dev_res;
941 struct wl_client *wc;
945 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
946 if (!surface) return;
948 last_device = _e_comp_wl_device_last_device_get(dev_class);
949 if (!last_device) return;
951 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
953 serial = wl_display_next_serial(e_comp_wl->wl.disp);
954 wc = wl_resource_get_client(surface);
955 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
957 if (wl_resource_get_client(dev_res) != wc) continue;
958 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
963 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
965 E_Devicemgr_Input_Device *input_dev;
966 struct wl_resource *dev_res;
967 const char *dev_name;
970 EINA_SAFETY_ON_NULL_RETURN(dev);
972 dev_name = ecore_device_identifier_get(dev);
974 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
975 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
977 if (!eina_streq(input_dev->identifier, dev_name) ||
978 (input_dev->clas != ecore_device_class_get(dev))) continue;
979 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
981 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
983 if (wl_resource_get_client(dev_res) != wc) continue;
984 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
987 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
991 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
993 E_Devicemgr_Input_Device *input_dev;
994 struct wl_resource *dev_res;
995 const char *dev_name;
998 EINA_SAFETY_ON_NULL_RETURN(dev);
1000 dev_name = e_device_identifier_get(dev);
1002 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1003 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1005 if (!eina_streq(input_dev->identifier, dev_name) ||
1006 (input_dev->clas != e_device_class_get(dev))) continue;
1007 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1009 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1011 if (wl_resource_get_client(dev_res) != wc) continue;
1012 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1015 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1019 _e_comp_wl_cursor_reload(E_Client *ec)
1021 struct wl_resource *res;
1022 struct wl_client *wc;
1028 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1029 !evas_object_visible_get(e_comp->pointer->o_ptr))
1030 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1033 if (e_object_is_del(E_OBJECT(ec))) return;
1034 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1035 if (!surface) return;
1036 if (ec->pointer_enter_sent) return;
1038 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1039 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1041 if (e_client_transform_core_enable_get(ec))
1043 double dx = 0.0, dy = 0.0;
1044 map = e_client_map_get(ec);
1045 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1051 cx = px - ec->client.x;
1052 cy = py - ec->client.y;
1054 wc = wl_resource_get_client(surface);
1055 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1056 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1058 if (!e_comp_wl_input_pointer_check(res)) continue;
1059 if (wl_resource_get_client(res) != wc) continue;
1060 wl_pointer_send_enter(res, serial, surface,
1061 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1062 ec->pointer_enter_sent = EINA_TRUE;
1064 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1068 _e_comp_wl_cursor_timer(void *data)
1070 E_Client *ec = data;
1072 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1073 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1075 e_comp_wl_cursor_hide(ec);
1077 return ECORE_CALLBACK_CANCEL;
1081 _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)
1083 E_Devicemgr_Input_Device *input_dev;
1084 struct wl_resource *dev_res;
1085 struct wl_client *wc;
1090 if (ec->cur_mouse_action) return;
1091 if (e_object_is_del(E_OBJECT(ec))) return;
1092 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1093 if (!surface) return;
1095 f_value = wl_fixed_from_double(value);
1096 wc = wl_resource_get_client(surface);
1098 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1099 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1101 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1102 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1104 if (wl_resource_get_client(dev_res) != wc) continue;
1105 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1108 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1112 _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)
1114 if (idx >= e_input_touch_max_count_get()) return;
1116 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1117 e_devicemgr->multi[idx].radius_x = radius_x;
1118 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1119 e_devicemgr->multi[idx].radius_y = radius_y;
1120 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1121 e_devicemgr->multi[idx].pressure = pressure;
1122 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1123 e_devicemgr->multi[idx].angle = angle;
1127 _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)
1129 if (idx >= e_input_touch_max_count_get()) return;
1131 if (e_devicemgr->multi[idx].radius_x != radius_x)
1133 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1134 e_devicemgr->multi[idx].radius_x = radius_x;
1136 if (e_devicemgr->multi[idx].radius_y != radius_y)
1138 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1139 e_devicemgr->multi[idx].radius_y = radius_y;
1141 if (e_devicemgr->multi[idx].pressure != pressure)
1143 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1144 e_devicemgr->multi[idx].pressure = pressure;
1146 if (e_devicemgr->multi[idx].angle != angle)
1148 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1149 e_devicemgr->multi[idx].angle = angle;
1154 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1156 Eina_Bool ret = EINA_TRUE;
1159 case EVAS_CALLBACK_MOUSE_IN:
1160 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1163 if (e_comp_wl->ptr.hide_tmr)
1165 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1166 cursor_timer_ec = ec;
1167 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1171 if (e_pointer_is_hidden(e_comp->pointer))
1176 case EVAS_CALLBACK_MOUSE_OUT:
1177 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1180 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1184 case EVAS_CALLBACK_MOUSE_MOVE:
1185 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1188 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1189 _e_comp_wl_cursor_reload(ec);
1192 case EVAS_CALLBACK_MOUSE_WHEEL:
1193 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1196 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1197 _e_comp_wl_cursor_reload(ec);
1200 case EVAS_CALLBACK_MOUSE_DOWN:
1201 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1204 if (e_comp_wl->ptr.hide_tmr)
1206 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1207 e_comp_wl->ptr.hide_tmr = NULL;
1209 cursor_timer_ec = NULL;
1211 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1212 _e_comp_wl_cursor_reload(ec);
1215 case EVAS_CALLBACK_MOUSE_UP:
1216 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1227 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1229 if (ec->has_cursor_unset)
1232 if (!e_config->show_cursor)
1235 if (!e_config->use_cursor_timer)
1242 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1245 Evas_Event_Mouse_In *ev;
1246 struct wl_resource *res;
1247 struct wl_client *wc;
1250 E_Comp_Config *comp_conf;
1251 E_Client *prev_ptr_ec;
1255 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1256 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1258 if (!(ec = data)) return;
1259 if (e_object_is_del(E_OBJECT(ec))) return;
1260 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1261 if (!surface) return;
1263 prev_ptr_ec = e_comp_wl->ptr.ec;
1266 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1267 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1270 e_comp_wl->ptr.ec = ec;
1272 comp_conf = e_comp_config_get();
1273 if (comp_conf && comp_conf->input_log_enable)
1274 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1275 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1276 e_client_util_name_get(ec));
1278 if (_e_comp_wl_check_cursor_timer_needed(ec))
1280 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1284 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1285 wc = wl_resource_get_client(surface);
1286 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1287 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1289 if (!e_comp_wl_input_pointer_check(res)) continue;
1290 if (wl_resource_get_client(res) != wc) continue;
1292 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1294 wl_pointer_send_enter(res, serial, surface,
1295 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1296 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1297 ec->pointer_enter_sent = EINA_TRUE;
1300 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1304 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1307 Evas_Event_Mouse_Out *ev;
1308 struct wl_resource *res;
1309 struct wl_client *wc;
1312 Eina_Bool inside_check;
1313 E_Comp_Config *comp_conf;
1317 if (!(ec = data)) return;
1318 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1319 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1320 if (ec->cur_mouse_action && inside_check) return;
1321 if (e_object_is_del(E_OBJECT(e_comp))) return;
1322 if (e_comp_wl->ptr.ec == ec)
1323 e_comp_wl->ptr.ec = NULL;
1324 if (e_object_is_del(E_OBJECT(ec))) return;
1326 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1327 if (!surface) return;
1329 comp_conf = e_comp_config_get();
1330 if (comp_conf && comp_conf->input_log_enable)
1331 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1332 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1333 e_client_util_name_get(ec));
1335 if (_e_comp_wl_check_cursor_timer_needed(ec))
1337 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1341 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1343 wc = wl_resource_get_client(surface);
1344 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1345 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1347 if (!e_comp_wl_input_pointer_check(res)) continue;
1348 if (wl_resource_get_client(res) != wc) continue;
1349 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1351 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1353 wl_pointer_send_leave(res, serial, surface);
1354 ec->pointer_enter_sent = EINA_FALSE;
1359 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1362 struct wl_client *wc;
1363 struct wl_resource *res;
1366 E_Comp_Config *comp_conf = NULL;
1369 if (e_object_is_del(E_OBJECT(ec))) return;
1370 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1371 if (!surface) return;
1373 wc = wl_resource_get_client(surface);
1374 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1378 x = wl_fixed_from_int(canvas_x - ec->client.x);
1379 y = wl_fixed_from_int(canvas_y - ec->client.y);
1382 comp_conf = e_comp_config_get();
1384 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1386 if (wl_resource_get_client(res) != wc) continue;
1387 if (!e_comp_wl_input_touch_check(res)) continue;
1388 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1391 if (comp_conf && comp_conf->input_log_enable)
1392 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));
1394 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1398 if (comp_conf && comp_conf->input_log_enable)
1399 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));
1401 wl_touch_send_up(res, serial, timestamp, idx);
1408 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1411 struct wl_client *wc;
1412 struct wl_resource *res;
1416 if (ec->cur_mouse_action) return;
1417 if (e_object_is_del(E_OBJECT(ec))) return;
1418 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1419 if (!surface) return;
1421 wc = wl_resource_get_client(surface);
1423 x = wl_fixed_from_int(canvas_x - ec->client.x);
1424 y = wl_fixed_from_int(canvas_y - ec->client.y);
1426 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1428 if (wl_resource_get_client(res) != wc) continue;
1429 if (!e_comp_wl_input_touch_check(res)) continue;
1430 wl_touch_send_motion(res, timestamp, idx, x, y);
1435 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1437 struct wl_resource *res;
1438 struct wl_client *wc;
1442 if (ec->cur_mouse_action) return;
1443 if (e_object_is_del(E_OBJECT(ec))) return;
1444 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1445 if (!surface) return;
1447 wc = wl_resource_get_client(surface);
1448 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1450 if (!e_comp_wl_input_pointer_check(res)) continue;
1451 if (wl_resource_get_client(res) != wc) continue;
1452 wl_pointer_send_motion(res, timestamp,
1453 wl_fixed_from_int(x - ec->client.x),
1454 wl_fixed_from_int(y - ec->client.y));
1459 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1461 if (e_comp_wl->ptr.hide_tmr)
1463 if (cursor_timer_ec == ec)
1465 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1466 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1470 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1471 cursor_timer_ec = ec;
1472 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1477 cursor_timer_ec = ec;
1478 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1483 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1486 Evas_Event_Mouse_Move *ev;
1487 Evas_Device *dev = NULL;
1488 const char *dev_name;
1489 E_Comp_Config *comp_conf;
1493 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1494 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1496 if (!(ec = data)) return;
1497 if (e_object_is_del(E_OBJECT(ec))) return;
1498 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1499 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1500 if (!surface) return;
1502 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1505 dev_name = evas_device_description_get(dev);
1507 comp_conf = e_comp_config_get();
1508 if (comp_conf && comp_conf->input_log_enable)
1509 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1510 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1511 e_client_util_name_get(ec), dev_name);
1513 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1515 if (!e_comp_wl->drag_client)
1517 e_comp_wl->touch.faked_ec = ec;
1518 if (e_comp_wl->touch.pressed & (1 << 0))
1520 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1522 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1523 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1524 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1528 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1532 if (!e_comp_wl->drag_client)
1534 if (_e_comp_wl_check_cursor_timer_needed(ec))
1536 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1540 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1541 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1543 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1545 if (_e_comp_wl_check_cursor_timer_needed(ec))
1546 _e_comp_wl_cursor_move_timer_control(ec);
1550 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1555 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1557 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1558 if (e_object_is_del(E_OBJECT(ec))) return;
1559 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1560 if (!surface) return;
1561 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1563 e_comp_wl->ptr.button = BTN_LEFT;
1565 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1569 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1571 E_Client *ec = data;
1572 Evas_Event_Mouse_Down *ev = event;
1573 Evas_Device *dev = NULL;
1574 const Evas_Device *seat_dev;
1575 const char *dev_name, *seat_name;
1576 E_Comp_Config *comp_conf = NULL;
1579 if (e_object_is_del(E_OBJECT(ec))) return;
1582 dev_name = evas_device_description_get(dev);
1584 seat_dev = evas_device_parent_get(dev);
1585 seat_name = evas_device_name_get(seat_dev);
1587 comp_conf = e_comp_config_get();
1588 if (comp_conf && comp_conf->input_log_enable)
1589 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1590 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1591 dev_name, seat_name);
1593 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1595 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1597 e_comp_wl->touch.faked_ec = ec;
1600 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1601 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1602 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1604 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1605 e_comp_wl->touch.pressed |= (1 << 0);
1609 if (_e_comp_wl_check_cursor_timer_needed(ec))
1611 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1615 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1616 WL_POINTER_BUTTON_STATE_PRESSED);
1618 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1621 need_send_released = EINA_TRUE;
1625 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1627 E_Client *ec = data;
1628 Evas_Event_Mouse_Up *ev = event;
1629 Evas_Device *dev = NULL;
1630 const Evas_Device *seat_dev;
1631 const char *dev_name, *seat_name;;
1632 Evas_Event_Flags flags;
1633 E_Comp_Config *comp_conf = NULL;
1636 if (ec->cur_mouse_action) return;
1637 if (e_object_is_del(E_OBJECT(ec))) return;
1639 if (!need_send_released)
1641 need_send_motion = EINA_TRUE;
1645 dev_name = evas_device_description_get(dev);
1647 seat_dev = evas_device_parent_get(dev);
1648 seat_name = evas_device_name_get(seat_dev);
1649 flags = evas_event_default_flags_get(evas);
1651 comp_conf = e_comp_config_get();
1652 if (comp_conf && comp_conf->input_log_enable)
1653 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1654 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1655 dev_name, seat_name);
1657 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1659 e_comp_wl->touch.pressed &= ~(1 << 0);
1661 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1662 e_comp_wl->touch.faked_ec = NULL;
1665 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1667 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1669 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1672 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1673 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1674 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1678 if (_e_comp_wl_check_cursor_timer_needed(ec))
1680 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1684 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1685 WL_POINTER_BUTTON_STATE_RELEASED);
1687 if (_e_comp_wl_check_cursor_timer_needed(ec))
1688 _e_comp_wl_cursor_move_timer_control(ec);
1692 need_send_released = EINA_FALSE;
1696 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1698 struct wl_resource *res;
1699 struct wl_client *wc;
1704 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1706 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1709 dir = -wl_fixed_from_int(abs(z));
1711 dir = wl_fixed_from_int(z);
1714 if (e_object_is_del(E_OBJECT(ec))) return;
1715 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1716 if (!surface) return;
1718 wc = wl_resource_get_client(surface);
1719 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1721 if (!e_comp_wl_input_pointer_check(res)) continue;
1722 if (wl_resource_get_client(res) != wc) continue;
1723 wl_pointer_send_axis(res, timestamp, axis, dir);
1728 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1731 Evas_Event_Mouse_Wheel *ev;
1734 if (!(ec = data)) return;
1735 if (ec->cur_mouse_action) return;
1736 if (e_object_is_del(E_OBJECT(ec))) return;
1737 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1738 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1739 if (!surface) return;
1741 if (!eina_list_count(e_comp_wl->ptr.resources))
1744 if (_e_comp_wl_check_cursor_timer_needed(ec))
1746 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1750 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1752 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1754 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1756 if (_e_comp_wl_check_cursor_timer_needed(ec))
1757 _e_comp_wl_cursor_move_timer_control(ec);
1762 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1764 E_Client *ec = data;
1765 Evas_Event_Multi_Down *ev = event;
1766 Evas_Device *dev = NULL;
1767 const Evas_Device *seat_dev;
1768 const char *dev_name, *seat_name;
1769 Evas_Device_Class dev_class;
1770 E_Comp_Config *comp_conf = NULL;
1773 if (e_object_is_del(E_OBJECT(ec))) return;
1774 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1775 if (!surface) return;
1777 /* Do not deliver emulated single touch events to client */
1778 if (ev->device == 0) return;
1781 dev_name = evas_device_description_get(dev);
1782 e_comp_wl->touch.faked_ec = ec;
1784 seat_dev = evas_device_parent_get(dev);
1785 seat_name = evas_device_name_get(seat_dev);
1787 comp_conf = e_comp_config_get();
1788 if (comp_conf && comp_conf->input_log_enable)
1789 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1790 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1791 dev_name, seat_name);
1793 if (dev && dev_name)
1795 dev_class = evas_device_class_get(dev);
1796 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1797 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1800 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1801 e_comp_wl->touch.pressed |= (1 << ev->device);
1805 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1807 E_Client *ec = data;
1808 Evas_Event_Multi_Up *ev = event;
1809 Evas_Device *dev = NULL;
1810 const Evas_Device *seat_dev;
1811 const char *dev_name, *seat_name;
1812 Evas_Device_Class dev_class;
1813 Evas_Event_Flags flags;
1814 E_Comp_Config *comp_conf = NULL;
1817 if (e_object_is_del(E_OBJECT(ec))) return;
1818 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1819 if (!surface) return;
1821 /* Do not deliver emulated single touch events to client */
1822 if (ev->device == 0) return;
1824 flags = evas_event_default_flags_get(evas);
1826 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1827 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1828 e_comp_wl->touch.faked_ec = NULL;
1830 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1833 dev_name = evas_device_description_get(dev);
1835 seat_dev = evas_device_parent_get(dev);
1836 seat_name = evas_device_name_get(seat_dev);
1838 comp_conf = e_comp_config_get();
1839 if (comp_conf && comp_conf->input_log_enable)
1840 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1841 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1842 dev_name, seat_name);
1844 if (dev && dev_name)
1846 dev_class = evas_device_class_get(dev);
1847 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1848 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1851 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1855 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1857 E_Client *ec = data;
1858 Evas_Event_Multi_Move *ev = event;
1859 Evas_Device *dev = NULL;
1860 const char *dev_name;
1861 Evas_Device_Class dev_class;
1864 if (e_object_is_del(E_OBJECT(ec))) return;
1865 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1866 if (!surface) return;
1868 /* Do not deliver emulated single touch events to client */
1869 if (ev->device == 0) return;
1871 e_comp_wl->touch.faked_ec = ec;
1873 if (e_comp_wl->touch.pressed & (1 << ev->device))
1876 if (dev && (dev_name = evas_device_description_get(dev)))
1878 dev_class = evas_device_class_get(dev);
1879 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1880 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1883 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1888 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1891 char *file, buff[PATH_MAX];
1898 n = (getpriority(PRIO_PROCESS, pid) + adj);
1902 setpriority(PRIO_PROCESS, pid, n);
1905 use_adj = EINA_TRUE;
1907 if (!do_child) return;
1909 files = ecore_file_ls("/proc");
1910 EINA_LIST_FREE(files, file)
1912 if (!isdigit(file[0]))
1915 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1916 if ((f = fopen(buff, "r")))
1920 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1922 if (num_read == 2 && ppid == pid)
1923 _e_comp_wl_client_priority_adjust(pid2, set,
1925 adj_child, do_child);
1933 _e_comp_wl_client_priority_raise(E_Client *ec)
1935 if (!e_config->priority_control) return;
1936 if (ec->netwm.pid <= 0) return;
1937 if (ec->netwm.pid == getpid()) return;
1938 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1939 e_config->priority - 1, -1,
1940 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1944 _e_comp_wl_client_priority_normal(E_Client *ec)
1946 if (!e_config->priority_control) return;
1947 if (ec->netwm.pid <= 0) return;
1948 if (ec->netwm.pid == getpid()) return;
1949 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1950 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1954 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1957 E_Comp_Wl_Key_Data *k;
1958 struct wl_resource *res;
1962 if (!ec) return EINA_FALSE;
1963 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1964 if (!ec->comp_data) return EINA_FALSE;
1966 ec->comp_data->on_focus_timer = NULL;
1967 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1968 if (!e_comp_wl->kbd.focused)
1970 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1973 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1975 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1976 t = ecore_time_unix_get();
1978 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1979 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
1980 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
1982 wl_array_for_each(k, &e_comp_wl->kbd.keys)
1984 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
1985 wl_keyboard_send_key(res, serial, t,
1986 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
1989 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
1990 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1994 /* It is called in the following cases:
1995 * When a normal ec->frame has focus.
1996 * Or launching image ec is replaced to the real ec.
1999 e_comp_wl_feed_focus_in(E_Client *ec)
2002 struct wl_resource *res;
2003 struct wl_client *wc;
2007 if (e_object_is_del(E_OBJECT(ec))) return;
2008 if (ec->iconic) return;
2010 /* block spurious focus events */
2011 focused = e_client_focused_get();
2012 if ((focused) && (ec != focused)) return;
2014 /* raise client priority */
2015 _e_comp_wl_client_priority_raise(ec);
2016 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2017 if (!surface) return;
2019 wc = wl_resource_get_client(surface);
2021 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2022 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2024 if (wl_resource_get_client(res) == wc)
2026 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2027 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2028 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2029 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2032 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2034 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2035 if (!e_comp_wl->kbd.focused)
2037 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2040 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2042 e_comp_wl->kbd.focus = surface;
2043 e_comp_wl_input_keyboard_enter_send(ec);
2044 e_comp_wl_data_device_keyboard_focus_set();
2045 ec->comp_data->on_focus_timer =
2046 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2047 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2048 int rotation = ec->e.state.rot.ang.curr;
2049 e_pointer_rotation_set(e_comp->pointer, rotation);
2053 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2056 if (!(ec = data)) return;
2057 e_comp_wl_feed_focus_in(ec);
2061 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2064 struct wl_resource *res;
2066 E_Comp_Wl_Key_Data *k;
2070 if (!(ec = data)) return;
2072 if (!ec->comp_data) return;
2074 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2076 /* lower client priority */
2077 if (!e_object_is_del(data))
2078 _e_comp_wl_client_priority_normal(ec);
2081 /* update keyboard modifier state */
2082 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2083 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2084 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2086 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2088 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2089 if (!surface) return;
2091 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2092 if (!eina_list_count(e_comp_wl->kbd.resources))
2094 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2098 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2100 /* send keyboard_leave to all keyboard resources */
2101 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2102 t = ecore_time_unix_get();
2104 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2105 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2106 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2108 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2110 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2111 wl_keyboard_send_key(res, serial, t,
2112 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2114 wl_keyboard_send_leave(res, serial, surface);
2115 e_comp_wl->kbd.focused =
2116 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2118 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2119 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2123 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2127 if (!(ec = data)) return;
2129 if ((ec->shading) || (ec->shaded)) return;
2130 if (!ec->comp_data->shell.configure_send) return;
2132 /* TODO: calculate x, y with transfrom object */
2133 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2137 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2138 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2139 if (e_comp_object_frame_exists(ec->frame))
2140 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2142 switch (ec->resize_mode)
2144 case E_POINTER_RESIZE_TL:
2145 case E_POINTER_RESIZE_L:
2146 case E_POINTER_RESIZE_BL:
2147 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2148 ec->mouse.current.mx;
2150 case E_POINTER_RESIZE_TR:
2151 case E_POINTER_RESIZE_R:
2152 case E_POINTER_RESIZE_BR:
2153 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2158 switch (ec->resize_mode)
2160 case E_POINTER_RESIZE_TL:
2161 case E_POINTER_RESIZE_T:
2162 case E_POINTER_RESIZE_TR:
2163 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2164 ec->mouse.current.my;
2166 case E_POINTER_RESIZE_BL:
2167 case E_POINTER_RESIZE_B:
2168 case E_POINTER_RESIZE_BR:
2169 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2174 w = E_CLAMP(w, 1, w);
2175 h = E_CLAMP(h, 1, h);
2176 e_client_resize_limit(ec, &w, &h);
2178 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
2179 e_comp_wl->resize.edges,
2182 else if ((!ec->fullscreen) && (!ec->maximized) &&
2183 (!ec->comp_data->maximize_pre))
2187 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2188 if ((pw != ec->w) || (ph != ec->h))
2190 _e_comp_wl_configure_send(ec, 1, 1);
2194 if (ec->comp_data->sub.below_obj)
2195 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2199 _e_comp_wl_evas_cb_maximize_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_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2209 E_Client *ec = data;
2212 if (e_object_is_del(E_OBJECT(ec))) return;
2214 if (ec->comp_data->shell.configure_send)
2216 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2217 ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, 0, w, h);
2219 ec->comp_data->maximize_pre = 0;
2223 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2225 E_Client *ec = data;
2227 ec->comp_data->maximize_pre = 1;
2231 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2233 E_Client *ec = data;
2235 if (e_object_is_del(E_OBJECT(ec))) return;
2237 /* check for wayland pixmap */
2239 if (ec->comp_data->shell.configure_send)
2240 _e_comp_wl_configure_send(ec, 0, 0);
2242 ec->comp_data->maximize_pre = 0;
2246 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2248 E_Client *ec = data;
2250 if (e_object_is_del(E_OBJECT(ec))) return;
2252 /* check for wayland pixmap */
2254 if (ec->comp_data->shell.configure_send)
2255 _e_comp_wl_configure_send(ec, 0, 1);
2257 ec->comp_data->maximize_pre = 0;
2261 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2263 E_Client *ec = data;
2265 if (e_object_is_del(E_OBJECT(ec))) return;
2267 /* check for wayland pixmap */
2269 if (ec->comp_data->shell.configure_send)
2270 _e_comp_wl_configure_send(ec, 0, 0);
2272 ec->comp_data->maximize_pre = 0;
2276 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2280 if (!(ec = data)) return;
2282 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2284 e_object_del(E_OBJECT(ec));
2286 _e_comp_wl_focus_check();
2288 /* TODO: Delete request send ??
2289 * NB: No such animal wrt wayland */
2293 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2297 if (!(ec = data)) return;
2299 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2302 if (ec->comp_data->reparented)
2303 e_client_comp_hidden_set(ec, EINA_TRUE);
2306 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2307 if (ec->visible) evas_object_hide(ec->frame);
2308 if (!ec->internal) e_object_del(E_OBJECT(ec));
2310 _e_comp_wl_focus_check();
2314 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2318 if (!(ec = data)) return;
2319 if (!(ec->comp_data)) return;
2320 if (!(ec->comp_data->shell.ping)) return;
2321 if (!(ec->comp_data->shell.surface)) return;
2323 ec->comp_data->shell.ping(ec->comp_data->shell.surface);
2327 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2332 if (!(ec = data)) return;
2333 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2334 if (ec->netwm.opacity == a) return;
2335 ec->netwm.opacity = a;
2336 ec->netwm.opacity_changed = EINA_TRUE;
2340 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2342 Eina_Rectangle *damage_rect = NULL;
2343 Eina_Rectangle *dmg = NULL;
2344 Eina_List *l = NULL;
2346 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2347 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2350 if (!buffer->tbm_surface) return;
2354 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2358 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2359 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2362 eina_rectangle_union(damage_rect, dmg);
2367 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2368 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2371 tbm_surface_internal_set_damage(buffer->tbm_surface,
2377 eina_rectangle_free(damage_rect);
2381 _e_comp_wl_client_evas_init(E_Client *ec)
2383 if (!ec || !ec->comp_data) return;
2384 if (ec->comp_data->evas_init) return;
2386 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2387 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2388 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2391 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2392 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2393 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2394 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2395 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2396 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2398 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2399 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2400 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2402 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2403 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2407 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2408 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2409 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2410 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2411 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2412 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2413 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2416 /* setup delete/kill callbacks */
2417 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2418 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2420 /* setup ping callback */
2421 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2422 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2424 ec->comp_data->evas_init = EINA_TRUE;
2428 _e_comp_wl_client_evas_deinit(E_Client *ec)
2430 if (!ec || !ec->comp_data) return;
2431 if (!ec->comp_data->evas_init) return;
2433 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2434 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2435 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2437 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2438 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2439 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2440 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2441 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2442 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2444 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2445 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2446 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2449 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2453 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2454 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2455 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2456 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2457 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2458 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2459 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2462 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2463 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2465 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2466 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2468 ec->comp_data->evas_init = EINA_FALSE;
2472 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2476 E_Comp_Screen *e_comp_screen;
2477 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2479 if (!e_comp) return ECORE_CALLBACK_RENEW;
2480 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2481 e_comp_screen = e_comp->e_comp_screen;
2483 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2485 if (!eout->config.enabled)
2487 e_comp_wl_output_remove(eout->id);
2491 switch (eout->config.rotation)
2494 transform = WL_OUTPUT_TRANSFORM_90;
2497 transform = WL_OUTPUT_TRANSFORM_180;
2500 transform = WL_OUTPUT_TRANSFORM_270;
2504 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2508 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2510 eout->config.geom.x, eout->config.geom.y,
2511 eout->config.geom.w, eout->config.geom.h,
2512 eout->info.size.w, eout->info.size.h,
2513 eout->config.mode.refresh, 0, transform))
2514 ERR("Could not initialize screen %s", eout->info.name);
2517 return ECORE_CALLBACK_RENEW;
2521 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2525 /* try to get the client from the object */
2526 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2527 return ECORE_CALLBACK_RENEW;
2529 /* check for client being deleted */
2530 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2532 /* check for wayland pixmap */
2533 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2534 return ECORE_CALLBACK_RENEW;
2536 /* if we have not setup evas callbacks for this client, do it */
2537 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2539 return ECORE_CALLBACK_RENEW;
2543 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2547 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2548 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2550 if (e_comp_wl->selection.target &&
2553 struct wl_resource *res;
2555 E_Client *ec = NULL;
2556 E_Client *legacy_target = e_comp_wl->selection.target;
2557 int device_id = e_comp_wl_data_current_device_id_get();
2561 e_comp_wl_data_current_device_id_set(ev->multi.device);
2563 else if (device_id != ev->multi.device)
2565 return ECORE_CALLBACK_RENEW;
2568 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2569 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2571 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2572 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2574 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2575 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2577 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2578 (ec != legacy_target))
2580 e_comp_wl_data_device_send_leave(legacy_target);
2581 e_comp_wl_data_device_send_enter(ec);
2584 if (e_comp_wl->drag)
2585 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2587 if (e_client_transform_core_enable_get(ec))
2589 int trans_x, trans_y;
2590 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2591 x = trans_x - ec->client.x;
2592 y = trans_y - ec->client.y;
2596 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2601 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2604 return ECORE_CALLBACK_RENEW;
2608 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2611 struct wl_resource *surface;
2612 struct wl_resource *res;
2613 struct wl_client *wc;
2615 E_Comp_Config *comp_conf;
2617 ec = e_comp_wl->ptr_constraints.ec;
2618 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2620 surface = e_comp_wl_client_surface_get(ec);
2621 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2623 wc = wl_resource_get_client(surface);
2625 comp_conf = e_comp_config_get();
2627 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2629 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2630 if (wl_resource_get_client(res) != wc) continue;
2632 if (comp_conf && comp_conf->input_log_enable)
2633 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2634 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2635 e_client_util_name_get(ec));
2637 zwp_relative_pointer_v1_send_relative_motion(res,
2639 (uint32_t)(ev->timestamp),
2640 wl_fixed_from_int(ev->dx),
2641 wl_fixed_from_int(ev->dy),
2642 wl_fixed_from_int(ev->dx_unaccel),
2643 wl_fixed_from_int(ev->dy_unaccel));
2646 return ECORE_CALLBACK_DONE;
2650 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2652 _e_comp_wl_touch_cancel();
2654 return ECORE_CALLBACK_PASS_ON;
2658 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2660 if (!ev) return ECORE_CALLBACK_PASS_ON;
2662 E_Zone *zone = ev->zone;
2664 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2665 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2667 if (!e_zone_is_displaying(zone))
2668 _e_comp_wl_touch_cancel();
2670 return ECORE_CALLBACK_PASS_ON;
2674 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2676 E_Client *ec = ev->ec;
2677 E_Comp_Wl_Buffer_Viewport *vp;
2679 if (!ec) return ECORE_CALLBACK_PASS_ON;
2680 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2681 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2682 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2683 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2685 vp = &ec->comp_data->scaler.buffer_viewport;
2686 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2688 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2690 return ECORE_CALLBACK_PASS_ON;
2694 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2696 E_Client *ec = ev->ec;
2697 E_Comp_Wl_Buffer_Viewport *vp;
2699 if (!ec) return ECORE_CALLBACK_PASS_ON;
2700 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2701 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2702 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2704 vp = &ec->comp_data->scaler.buffer_viewport;
2705 vp->wait_for_transform_change = 0;
2707 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2709 return ECORE_CALLBACK_PASS_ON;
2713 _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)
2715 E_Client *focused_ec;
2718 focused_ec = e_client_focused_get();
2719 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2721 rotation = focused_ec->e.state.rot.ang.curr;
2722 e_pointer_rotation_set(e_comp->pointer, rotation);
2724 return ECORE_CALLBACK_PASS_ON;
2728 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2731 Eina_Rectangle *window;
2736 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2738 if ((prev_w != state->bw) ||
2739 (prev_h != state->bh))
2741 ec->changes.buf_size = EINA_TRUE;
2744 if (e_comp_object_frame_exists(ec->frame)) return;
2745 window = &ec->comp_data->shell.window;
2746 if ((!ec->borderless) && /* FIXME temporarily added this check code
2747 * to prevent updating E_Client's size by frame */
2748 (window->x || window->y || window->w || window->h))
2750 e_comp_object_frame_geometry_set(ec->frame,
2752 (window->x + window->w) - state->bw,
2754 (window->y + window->h) - state->bh);
2757 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2761 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2763 E_Comp_Wl_Surface_State *state;
2766 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2767 state->buffer = NULL;
2771 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2773 state->new_attach = EINA_FALSE;
2774 state->buffer = NULL;
2775 state->buffer_destroy_listener.notify =
2776 _e_comp_wl_surface_state_cb_buffer_destroy;
2777 state->sx = state->sy = 0;
2779 state->input = eina_tiler_new(w, h);
2780 eina_tiler_tile_size_set(state->input, 1, 1);
2782 state->opaque = eina_tiler_new(w, h);
2783 eina_tiler_tile_size_set(state->opaque, 1, 1);
2785 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2786 state->buffer_viewport.buffer.scale = 1;
2787 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2788 state->buffer_viewport.surface.width = -1;
2789 state->buffer_viewport.changed = 0;
2791 e_presentation_time_container_init(&state->presentation_container);
2795 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2797 struct wl_resource *cb;
2798 Eina_Rectangle *dmg;
2800 EINA_LIST_FREE(state->frames, cb)
2801 wl_resource_destroy(cb);
2803 EINA_LIST_FREE(state->damages, dmg)
2804 eina_rectangle_free(dmg);
2806 EINA_LIST_FREE(state->buffer_damages, dmg)
2807 eina_rectangle_free(dmg);
2809 if (state->opaque) eina_tiler_free(state->opaque);
2810 state->opaque = NULL;
2812 if (state->input) eina_tiler_free(state->input);
2813 state->input = NULL;
2815 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2816 state->buffer = NULL;
2818 e_presentation_time_container_finish(&state->presentation_container);
2822 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2824 if (state->buffer == buffer) return;
2826 wl_list_remove(&state->buffer_destroy_listener.link);
2827 state->buffer = buffer;
2829 wl_signal_add(&state->buffer->destroy_signal,
2830 &state->buffer_destroy_listener);
2834 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2836 Eina_Rectangle *dmg;
2837 Eina_Bool placed = EINA_TRUE;
2841 E_Comp_Wl_Buffer *buffer;
2842 struct wl_resource *cb;
2844 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2845 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2850 if ((ec->internal) ||
2851 (cdata->shell.surface && state->new_attach))
2855 e_comp->new_clients++;
2856 ELOGF("COMP", "Unignore", ec);
2857 e_client_unignore(ec);
2861 /* buffer transform */
2862 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2865 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2867 /* when buffer is transformed, we have to apply the new evas-map */
2868 state->buffer_viewport.changed = EINA_TRUE;
2870 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2872 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2874 if (transform_change == vp->wait_for_transform_change)
2875 vp->wait_for_transform_change = 0;
2877 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2878 // triggered by E_CLIENT_HOOK calls at those file.
2879 zone = e_comp_zone_find_by_ec(ec);
2882 eout = e_output_find(zone->output_id);
2883 if (eout && eout->hwc)
2885 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2887 if (e_comp_is_on_overlay(ec))
2888 e_comp_hwc_client_end(ec, __FUNCTION__);
2894 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2895 cdata->scaler.buffer_viewport = state->buffer_viewport;
2897 if (state->new_attach)
2899 e_comp_wl_surface_attach(ec, state->buffer);
2902 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2903 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2905 _e_comp_wl_surface_state_buffer_set(state, NULL);
2907 if ((state->new_attach) ||
2908 (state->buffer_viewport.changed))
2910 _e_comp_wl_surface_state_size_update(ec, state);
2911 e_comp_wl_map_size_cal_from_viewport(ec);
2913 /* update the position */
2914 if (ec->changes.pos)
2916 e_comp_object_frame_xy_unadjust(ec->frame,
2926 if (ec->new_client) placed = ec->placed;
2928 if (!ec->lock_client_size)
2933 ec->client.w = state->bw;
2934 ec->client.h = state->bh;
2936 e_comp_object_frame_wh_adjust(ec->frame,
2937 ec->client.w, ec->client.h,
2939 e_client_size_set(ec, nw, nh);
2941 if ((w != ec->w) || (h != ec->h))
2943 ec->changes.size = 1;
2948 if (ec->changes.buf_size)
2950 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2951 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2952 ec->changes.buf_size = EINA_FALSE;
2954 if (ec->move_after_resize)
2956 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2957 ec->move_after_resize = EINA_FALSE;
2962 /* map or unmap ec */
2963 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2964 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2965 if (!pixmap_usable || hide_by_request)
2970 if (hide_by_request)
2971 ELOGF("COMP", "Currenlty hide_by_request state. pixmap_usable:%d", ec, pixmap_usable);
2973 if ((cdata->shell.surface) &&
2974 (cdata->shell.unmap))
2976 ELOGF("COMP", "Try to unmap. Call shell.unmap.", ec);
2977 if (ec->show_pending.count > 0)
2979 ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
2980 ec->show_pending.count = 0;
2981 if (ec->show_pending.running)
2983 // need to send visibility false;
2984 ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
2985 ELOGF("POL_VIS", "CLIENT VIS ON (fake). argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
2988 ec->show_pending.running = EINA_FALSE;
2990 cdata->shell.unmap(cdata->shell.surface);
2992 else if ((ec->internal) ||
2993 (e_comp_wl_subsurface_check(ec)) ||
2994 (ec == e_comp_wl->drag_client))
2996 ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
2997 ec, ec->internal, cdata->sub.data, (ec == e_comp_wl->drag_client));
2998 ec->visible = EINA_FALSE;
2999 evas_object_hide(ec->frame);
3004 if ((cdata->sub.below_obj) &&
3005 (evas_object_visible_get(cdata->sub.below_obj)))
3007 evas_object_hide(cdata->sub.below_obj);
3015 if ((cdata->shell.surface) &&
3016 (cdata->shell.map) &&
3019 ELOGF("COMP", "Try to map. Call shell.map.", ec);
3020 cdata->shell.map(cdata->shell.surface);
3022 else if ((ec->internal) ||
3023 (e_comp_wl_subsurface_can_show(ec)) ||
3024 (ec == e_comp_wl->drag_client))
3026 ELOGF("COMP", "Try to map. Show window. internal:%d, drag:%d",
3027 ec, ec->internal, (ec == e_comp_wl->drag_client));
3028 ec->visible = EINA_TRUE;
3030 evas_object_show(ec->frame);
3035 if ((cdata->sub.below_obj) &&
3036 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3037 (evas_object_visible_get(ec->frame)))
3039 evas_object_show(cdata->sub.below_obj);
3043 if ((state->new_attach) ||
3044 (state->buffer_viewport.changed))
3046 if ((e_comp_wl->drag) &&
3047 (e_comp_wl->drag_client) &&
3048 (e_comp_wl->drag_client == ec))
3050 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3052 e_drag_move(e_comp_wl->drag,
3054 e_comp_wl->drag->y);
3056 e_drag_resize(e_comp_wl->drag,
3057 state->bw, state->bh);
3059 else if ((cdata->shell.surface) &&
3060 (cdata->shell.configure))
3062 e_comp_wl_commit_sync_configure(ec);
3064 else if (!e_client_video_hw_composition_check(ec))
3066 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3071 ec->placed = placed;
3072 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3076 if (cdata->scaler.buffer_viewport.changed)
3077 e_comp_wl_map_apply(ec);
3079 /* resize transform object */
3080 if (ec->transformed)
3081 e_client_transform_update(ec);
3085 state->new_attach = EINA_FALSE;
3087 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3089 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3090 wl_resource_destroy(cb);
3093 /* insert state frame callbacks into comp_data->frames
3094 * NB: This clears state->frames list */
3095 cdata->frames = eina_list_merge(cdata->frames,
3097 state->frames = NULL;
3099 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3100 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3101 &state->presentation_container);
3103 buffer = e_pixmap_resource_get(ec->pixmap);
3105 /* put state damages into surface */
3108 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3109 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3111 if ((cdata->buffer_ref.buffer) &&
3112 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3113 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3115 e_comp_object_damage(ec->frame,
3117 cdata->buffer_ref.buffer->w,
3118 cdata->buffer_ref.buffer->h);
3123 Eina_List *damages = NULL;
3126 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3128 if (eina_list_count(state->buffer_damages))
3130 EINA_LIST_FREE(state->buffer_damages, dmg)
3133 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3134 e_comp_wl_output_buffer_transform_get(ec),
3136 dmg->x, dmg->y, dmg->w, dmg->h,
3137 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3138 damages = eina_list_append(damages, dmg);
3142 EINA_LIST_FREE(state->damages, dmg)
3143 damages = eina_list_append(damages, dmg);
3145 EINA_LIST_FREE(damages, dmg)
3147 /* not creating damage for ec that shows a underlay video */
3148 if (state->buffer_viewport.changed ||
3149 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3150 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3151 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3153 eina_rectangle_free(dmg);
3158 /* put state opaque into surface */
3159 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3162 Eina_Rectangle *rect;
3165 itr = eina_tiler_iterator_new(state->opaque);
3166 EINA_ITERATOR_FOREACH(itr, rect)
3170 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3171 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3172 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3176 eina_iterator_free(itr);
3179 /* put state input into surface */
3180 if ((state->input) &&
3181 (!eina_tiler_empty(state->input)) &&
3184 Eina_Tiler *src, *tmp;
3188 tmp = eina_tiler_new(sw, sh);
3189 eina_tiler_tile_size_set(tmp, 1, 1);
3191 eina_tiler_rect_add(tmp,
3192 &(Eina_Rectangle){0, 0, sw, sh});
3194 if ((src = eina_tiler_intersection(state->input, tmp)))
3196 Eina_Rectangle *rect;
3199 e_comp_object_input_objs_del(ec->frame);
3200 itr = eina_tiler_iterator_new(src);
3201 EINA_ITERATOR_FOREACH(itr, rect)
3203 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3204 ec, rect->x, rect->y, rect->w, rect->h,
3205 ec->w, ec->h, state->bw, state->bh);
3206 e_comp_object_input_area_set(ec->frame,
3211 eina_iterator_free(itr);
3212 eina_tiler_free(src);
3215 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3217 eina_tiler_free(tmp);
3219 /* clear input tiler */
3220 eina_tiler_clear(state->input);
3223 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3225 if ((cdata->video_client) &&
3227 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3228 (e_comp->wl_comp_data->available_hw_accel.underlay))
3230 e_pixmap_image_clear(ec->pixmap, 1);
3233 state->buffer_viewport.changed = 0;
3235 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3238 ec->exp_iconify.buffer_flush &&
3239 e_policy_visibility_client_is_iconic(ec))
3241 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3246 _e_comp_wl_surface_render_stop(E_Client *ec)
3248 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3249 //if ((!ec->internal) && (!e_comp_gl_get()))
3252 /* check if internal animation is running */
3253 if (e_comp_object_is_animating(ec->frame)) return;
3254 /* check if external animation is running */
3255 if (evas_object_data_get(ec->frame, "effect_running")) return;
3257 evas_object_hide(ec->frame);
3261 e_comp_wl_client_surface_finish(E_Client *ec)
3263 struct wl_resource *res, *surface;
3264 struct wl_client *surface_client = NULL;
3267 surface = e_comp_wl_client_surface_get(ec);
3270 surface_client = wl_resource_get_client(surface);
3272 if (surface_client &&
3273 (ec == e_client_focused_get()))
3275 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3276 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3278 if (wl_resource_get_client(res) ==
3280 e_comp_wl->kbd.focused =
3281 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3285 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3288 e_comp_wl_client_surface_set(ec, NULL);
3290 ec->comp_data->wl_surface = NULL;
3291 e_pixmap_win_id_del(ec->pixmap);
3293 _e_comp_wl_surface_render_stop(ec);
3294 e_object_del(E_OBJECT(ec));
3298 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3303 char proc[512], pname[512];
3306 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3308 h = fopen(proc, "r");
3311 len = fread(pname, sizeof(char), 512, h);
3313 pname[len - 1] = '\0';
3315 strncpy(pname, "NO NAME", sizeof(pname));
3321 strncpy(pname, "NO NAME", sizeof(pname));
3324 strncpy(name, pname, size);
3328 _e_comp_wl_pname_print(pid_t pid)
3331 char proc[512], pname[512];
3334 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3336 h = fopen(proc, "r");
3339 len = fread(pname, sizeof(char), 512, h);
3341 pname[len - 1] = '\0';
3343 strncpy(pname, "NO NAME", sizeof(pname));
3347 ELOGF("COMP", " |%s", NULL, pname);
3352 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3354 struct wl_client *client = data;
3355 E_Comp_Connected_Client_Info *cinfo;
3358 cinfo = wl_container_of(listener, cinfo, destroy);
3360 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3361 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3363 eai = e_appinfo_find_with_pid(cinfo->pid);
3364 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3367 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3369 wl_list_remove(&cinfo->destroy.link);
3370 eina_stringshare_del(cinfo->name);
3375 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3377 E_Comp_Connected_Client_Info *cinfo;
3379 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3380 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3382 cinfo->name = eina_stringshare_add(name);
3386 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3387 wl_client_add_destroy_listener(client, &cinfo->destroy);
3388 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3390 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3394 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3396 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3398 /* send configure */
3399 if (ec->comp_data->shell.configure_send)
3401 if (ec->comp_data->shell.surface)
3402 _e_comp_wl_configure_send(ec, 0, 0);
3405 e_comp_wl->kbd.focus = ec->comp_data->surface;
3409 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3411 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3413 /* send configure */
3414 if (ec->comp_data->shell.configure_send)
3416 if (ec->comp_data->shell.surface)
3417 _e_comp_wl_configure_send(ec, 0, 0);
3420 _e_comp_wl_focus_check();
3422 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3423 e_comp_wl->kbd.focus = NULL;
3427 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3429 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3430 if (ec->keyboard_resizing) return;
3432 /* do nothing currently */
3437 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3439 if (e_object_is_del(E_OBJECT(ec))) return;
3440 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3442 e_comp_wl->resize.edges = 0;
3443 e_comp_wl->resize.resource = NULL;
3445 if (ec->pending_resize)
3447 ec->changes.pos = EINA_TRUE;
3448 ec->changes.size = EINA_TRUE;
3452 E_FREE_LIST(ec->pending_resize, free);
3456 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3458 if (e_object_is_del(E_OBJECT(ec))) return;
3459 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3463 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3466 int ratio_w, ratio_h;
3468 phys_w = output->phys_width;
3469 phys_h = output->phys_height;
3471 if (e_config->configured_output_resolution.use)
3473 // change the configured physical size(mm) of the output
3474 if (output->w != res_w)
3476 ratio_w = res_w / output->w;
3477 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3480 if (output->h != res_h)
3482 ratio_h = res_h / output->h;
3483 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3486 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3489 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3490 NULL, res_w, res_h, phys_w, phys_h, pid);
3492 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3493 wl_output_send_scale(resource, output->scale);
3495 wl_output_send_geometry(resource, output->x, output->y,
3497 output->subpixel, output->make ?: "",
3498 output->model ?: "", output->transform);
3500 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3501 res_w, res_h, output->refresh);
3503 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3504 wl_output_send_done(resource);
3508 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3510 E_Comp_Wl_Output *output;
3512 if (!(output = wl_resource_get_user_data(resource))) return;
3514 output->resources = eina_list_remove(output->resources, resource);
3518 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3520 E_Comp_Wl_Output *output;
3521 struct wl_resource *resource;
3522 E_Appinfo *eai = NULL;
3526 if (!(output = data)) return;
3529 wl_resource_create(client, &wl_output_interface, version, id);
3532 wl_client_post_no_memory(client);
3536 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3537 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3539 output->resources = eina_list_append(output->resources, resource);
3541 wl_resource_set_implementation(resource, NULL, output,
3542 _e_comp_wl_cb_output_unbind);
3543 wl_resource_set_user_data(resource, output);
3545 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3546 if (e_config->configured_output_resolution.use)
3548 wl_client_get_credentials(client, &pid, NULL, NULL);
3551 res_w = e_config->configured_output_resolution.w;
3552 res_h = e_config->configured_output_resolution.h;
3556 eai = e_appinfo_find_with_pid(pid);
3559 res_w = e_config->configured_output_resolution.w;
3560 res_h = e_config->configured_output_resolution.h;
3564 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3566 res_w = e_config->configured_output_resolution.w;
3567 res_h = e_config->configured_output_resolution.h;
3571 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3580 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3584 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3587 Evas_GL *evasgl = NULL;
3588 Evas_GL_API *glapi = NULL;
3589 Evas_GL_Context *ctx = NULL;
3590 Evas_GL_Surface *sfc = NULL;
3591 Evas_GL_Config *cfg = NULL;
3593 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3595 if (!e_comp_gl_get()) return;
3597 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3598 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3600 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3601 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3603 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3604 * then we should get evas from ecore_evas.
3607 evas = e_comp->evas;
3609 evas = ecore_evas_get(e_comp->ee);
3611 evasgl = evas_gl_new(evas);
3612 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3614 glapi = evas_gl_api_get(evasgl);
3615 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3616 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3618 cfg = evas_gl_config_new();
3619 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3621 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3622 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3624 ctx = evas_gl_context_create(evasgl, NULL);
3625 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3627 res = evas_gl_make_current(evasgl, sfc, ctx);
3628 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3630 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3631 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3633 evas_gl_config_free(cfg);
3635 evas_gl->gl = evasgl;
3636 evas_gl->glapi = glapi;
3637 evas_gl->glsfc = sfc;
3638 evas_gl->glctx = ctx;
3640 e_comp_wl->evas_gl = evas_gl;
3642 /* for native surface */
3645 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3650 evas_gl_config_free(cfg);
3651 evas_gl_make_current(evasgl, NULL, NULL);
3652 evas_gl_context_destroy(evasgl, ctx);
3653 evas_gl_surface_destroy(evasgl, sfc);
3654 evas_gl_free(evasgl);
3661 _e_comp_wl_gl_popup_cb_close(void *data,
3662 Evas_Object *obj EINA_UNUSED,
3663 void *event_info EINA_UNUSED)
3665 evas_object_del(data);
3669 _e_comp_wl_gl_popup_cb_focus(void *data,
3670 Evas_Object *obj EINA_UNUSED,
3671 void *event_info EINA_UNUSED)
3673 elm_object_focus_set(data, EINA_TRUE);
3678 _e_comp_wl_gl_idle(void *data)
3682 /* show warning window to notify failure of gl init */
3685 Evas_Object *win, *bg, *popup, *btn;
3687 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3688 elm_win_title_set(win, "Compositor Warning");
3689 elm_win_autodel_set(win, EINA_TRUE);
3690 elm_win_borderless_set(win, EINA_TRUE);
3691 elm_win_role_set(win, "notification-low");
3692 elm_win_alpha_set(win, EINA_TRUE);
3694 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3695 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3696 elm_win_resize_object_add(win, bg);
3697 evas_object_color_set(bg, 125, 125, 125, 125);
3698 evas_object_show(bg);
3700 popup = elm_popup_add(win);
3701 elm_object_text_set(popup,
3702 _( "Your screen does not support OpenGL.<br>"
3703 "Falling back to software engine."));
3704 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3706 btn = elm_button_add(popup);
3707 elm_object_text_set(btn, "Close");
3708 elm_object_part_content_set(popup, "button1", btn);
3709 evas_object_show(btn);
3711 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3712 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3714 evas_object_show(popup);
3715 evas_object_show(win);
3719 return ECORE_CALLBACK_CANCEL;
3723 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3725 struct wl_client *client = data;
3731 wl_client_get_credentials(client, &pid, &uid, &gid);
3733 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3735 _e_comp_wl_pname_print(pid);
3736 _e_comp_wl_pname_get(pid, name, sizeof(name));
3737 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3741 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3743 char buf[1024] = {0, };
3745 vsnprintf(buf, 1024, fmt, args);
3749 DBG("[libds] %s", buf);
3752 INF("[libds] %s", buf);
3755 ERR("[libds] %s", buf);
3763 _e_comp_wl_display_create(void)
3766 E_Comp_Wl_Data *wl_cdata;
3771 /* create new compositor data */
3772 if (!(comp = E_NEW(E_Comp_Data, 1)))
3774 ERR("Could not create compositor data: %m");
3777 wl_cdata = &comp->base;
3779 /* set compositor wayland data */
3780 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3782 g_mutex_init(&connection_mutex);
3784 /* try to create a wayland display */
3785 if (!(wl_cdata->wl.disp = wl_display_create()))
3787 ERR("Could not create a Wayland display: %m");
3791 /* try to setup wayland socket */
3792 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3794 ERR("Could not create Wayland display socket: %m");
3795 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3799 res = e_comp_socket_init(name);
3800 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3801 PRCTL("[Winsys] change permission and create sym link for %s", name);
3803 /* set wayland display environment variable */
3804 e_env_set("WAYLAND_DISPLAY", name);
3806 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3807 /* wl_cdata->output.scale = e_scale; */
3809 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3811 if (!e_compositor_init(wl_cdata->wl.disp))
3813 ERR("Failed to initialize compositor");
3817 comp->client_created.notify = _e_comp_wl_cb_client_created;
3818 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3820 if (!e_comp_wl_subsurfaces_init())
3822 ERR("Failed to init_subsurfaces");
3823 goto subsurfaces_err;
3826 /* initialize shm mechanism */
3827 wl_display_init_shm(wl_cdata->wl.disp);
3829 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3831 /* try to init data manager */
3832 if (!e_comp_wl_data_manager_init())
3834 ERR("Could not initialize data manager");
3838 /* try to init input */
3839 if (!e_comp_wl_input_init())
3841 ERR("Could not initialize input");
3845 if (e_comp_gl_get())
3846 _e_comp_wl_gl_init(NULL);
3848 /* get the wayland display loop */
3849 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3851 /* get the file descriptor of the wayland event loop */
3852 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3854 /* create a listener for wayland main loop events */
3856 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3857 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3858 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3859 _e_comp_wl_cb_prepare, wl_cdata);
3864 e_comp_wl_data_manager_shutdown();
3866 e_comp_wl_subsurfaces_shutdown();
3868 wl_list_remove(&comp->client_created.link);
3870 e_env_unset("WAYLAND_DISPLAY");
3872 wl_display_destroy(wl_cdata->wl.disp);
3874 g_mutex_clear(&connection_mutex);
3880 _e_comp_wl_gl_shutdown(void)
3882 if (!e_comp_wl->evas_gl) return;
3884 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3886 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3887 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3888 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3889 evas_gl_free(e_comp_wl->evas_gl->gl);
3891 E_FREE(e_comp_wl->evas_gl);
3894 /* public functions */
3897 * Creates and initializes a Wayland compositor with ecore.
3898 * Registers callback handlers for keyboard and mouse activity
3899 * and other client events.
3901 * @returns true on success, false if initialization failed.
3904 e_comp_wl_init(void)
3906 TRACE_DS_BEGIN(COMP_WL:INIT);
3908 /* try to create a wayland compositor */
3909 if (!_e_comp_wl_display_create())
3911 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3916 e_comp_wl_shell_init();
3918 #ifdef HAVE_WAYLAND_TBM
3919 e_comp_wl_tbm_init();
3921 e_comp_wl_remote_surface_init();
3925 e_comp_wl_screenshooter_init();
3927 if (!e_comp_wl_video_init())
3928 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3930 e_comp_wl_viewport_init();
3931 e_comp_wl_capture_init();
3932 e_comp_wl_renderer_init();
3933 _e_comp_wl_move_resize_init();
3934 e_presentation_time_init();
3935 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3938 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3939 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3941 /* add event handlers to catch E events */
3942 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3943 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3944 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3945 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3946 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3947 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3948 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3949 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3950 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3952 /* add hooks to catch e_client events */
3953 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3954 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3955 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3956 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3957 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3959 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3966 e_comp_wl_deferred_job(void)
3968 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3971 /* internal functions */
3973 e_comp_wl_shutdown(void)
3975 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3977 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3979 e_comp_wl_subsurfaces_shutdown();
3981 E_FREE_LIST(handlers, ecore_event_handler_del);
3982 E_FREE_LIST(hooks, e_client_hook_del);
3983 _e_comp_wl_gl_shutdown();
3985 e_blender_shutdown();
3986 e_presentation_time_shutdown();
3987 e_comp_wl_renderer_shutdown();
3988 e_comp_wl_capture_shutdown();
3989 e_comp_wl_viewport_shutdown();
3990 e_comp_wl_video_shutdown();
3991 e_comp_wl_screenshooter_shutdown();
3993 e_comp_wl_remote_surface_shutdown();
3995 e_pixmap_shutdown();
3997 e_wtz_shell_shutdown();
3998 e_comp_wl_shell_shutdown();
3999 e_comp_wl_input_shutdown();
4001 wl_list_remove(&comp->client_created.link);
4004 e_comp->wl_comp_data = NULL;
4008 E_Comp_Wl_Output *output;
4010 if (e_comp_wl->screenshooter.global)
4011 wl_global_destroy(e_comp_wl->screenshooter.global);
4013 EINA_LIST_FREE(e_comp_wl->outputs, output)
4015 if (output->id) eina_stringshare_del(output->id);
4016 if (output->make) eina_stringshare_del(output->make);
4017 if (output->model) eina_stringshare_del(output->model);
4021 /* delete fd handler */
4022 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
4024 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
4025 cursor_timer_ec = NULL;
4027 /* free allocated data structure */
4033 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4035 e_object_unref(E_OBJECT(ev->ec));
4040 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4043 ev = E_NEW(E_Event_Client, 1);
4046 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4048 /* set usable early because shell module checks this */
4049 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4050 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4052 e_pixmap_resource_set(ec->pixmap, buffer);
4053 e_pixmap_dirty(ec->pixmap);
4054 e_pixmap_refresh(ec->pixmap);
4056 e_comp_wl_map_size_cal_from_buffer(ec);
4057 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4059 /* wm-policy module uses it */
4060 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4063 e_object_ref(E_OBJECT(ec));
4064 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4065 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4069 e_comp_wl_surface_commit(E_Client *ec)
4074 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4075 if (!e_comp_object_damage_exists(ec->frame))
4077 if ((ec->comp_data->video_client) ||
4078 (!e_client_video_hw_composition_check(ec)))
4079 e_pixmap_image_clear(ec->pixmap, 1);
4082 ignored = ec->ignored;
4084 if (e_comp_wl_subsurface_order_commit(ec))
4086 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4087 e_comp_wl_subsurface_restack(topmost);
4088 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4091 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
4092 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
4093 if (!pixmap_usable || hide_by_request)
4095 if (ec->comp_data->mapped)
4097 if (hide_by_request)
4098 ELOGF("COMP", "Currenlty hide_by_request state2. pixmap_usable:%d", ec, pixmap_usable);
4100 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
4102 ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
4103 ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
4105 else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
4106 (ec == e_comp_wl->drag_client))
4108 ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
4109 ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
4110 ec->visible = EINA_FALSE;
4111 evas_object_hide(ec->frame);
4112 ec->comp_data->mapped = 0;
4116 if (ec->comp_data->sub.below_obj && evas_object_visible_get(ec->comp_data->sub.below_obj))
4117 evas_object_hide(ec->comp_data->sub.below_obj);
4121 if (!ec->comp_data->mapped)
4123 if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
4126 ELOGF("COMP", "Try to map2. Call shell.map.", ec);
4127 ec->comp_data->shell.map(ec->comp_data->shell.surface);
4129 else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
4130 (ec == e_comp_wl->drag_client))
4132 ELOGF("COMP", "Try to map2. Show window. internal:%d, drag:%d",
4133 ec, ec->internal, (ec == e_comp_wl->drag_client));
4134 ec->visible = EINA_TRUE;
4136 evas_object_show(ec->frame);
4137 ec->comp_data->mapped = 1;
4141 if (ec->comp_data->sub.below_obj && !evas_object_visible_get(ec->comp_data->sub.below_obj)
4142 && evas_object_visible_get(ec->frame))
4143 evas_object_show(ec->comp_data->sub.below_obj);
4145 ec->ignored = ignored;
4147 if (ec->is_cursor && ec->visible)
4149 /* ignore cursor changes during resize/move I guess */
4150 if (!e_client_action_get())
4152 if (e_comp->pointer)
4154 x = e_comp->pointer->hot.x;
4155 y = e_comp->pointer->hot.y;
4157 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4163 static E_Comp_Wl_Output *
4164 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4167 E_Comp_Wl_Output *output;
4169 EINA_LIST_FOREACH(outputs, l, output)
4171 if (!strcmp(output->id, id))
4179 * Initializes information about one display output.
4181 * Adds or updates the given data about a single display output,
4182 * with an id matching the provided id.
4184 * @param id identification of output to be added or changed
4185 * @param make manufacturer name of the display output
4186 * @param model model name of the display output
4187 * @param x output's top left corner x coordinate
4188 * @param y output's top left corner y coordinate
4189 * @param w output's width in pixels
4190 * @param h output's height in pixels
4191 * @param pw output's physical width in millimeters
4192 * @param ph output's physical height in millimeters
4193 * @param refresh output's refresh rate in mHz
4194 * @param subpixel output's subpixel layout
4195 * @param transform output's rotation and/or mirror transformation
4197 * @returns True if a display output object could be added or updated
4200 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4201 int x, int y, int w, int h, int pw, int ph,
4202 unsigned int refresh, unsigned int subpixel,
4203 unsigned int transform)
4205 E_Comp_Wl_Output *output;
4207 struct wl_resource *resource;
4209 /* retrieve named output; or create it if it doesn't exist */
4210 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4213 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4215 if (id) output->id = eina_stringshare_add(id);
4217 output->make = eina_stringshare_add(make);
4219 output->make = eina_stringshare_add("unknown");
4221 output->model = eina_stringshare_add(model);
4223 output->model = eina_stringshare_add("unknown");
4225 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4228 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4229 2, output, _e_comp_wl_cb_output_bind);
4231 output->resources = NULL;
4232 output->scale = e_scale;
4235 /* update the output details */
4240 output->phys_width = pw;
4241 output->phys_height = ph;
4242 output->refresh = refresh;
4243 output->subpixel = subpixel;
4244 output->transform = transform;
4246 if (output->scale <= 0)
4247 output->scale = e_scale;
4249 /* if we have bound resources, send updates */
4250 EINA_LIST_FOREACH(output->resources, l2, resource)
4252 wl_output_send_geometry(resource,
4253 output->x, output->y,
4255 output->phys_height,
4257 output->make ?: "", output->model ?: "",
4260 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4261 wl_output_send_scale(resource, output->scale);
4263 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4264 output->w, output->h, output->refresh);
4266 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4267 wl_output_send_done(resource);
4274 e_comp_wl_output_remove(const char *id)
4276 E_Comp_Wl_Output *output;
4278 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4281 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4283 /* wl_global_destroy(output->global); */
4285 /* eina_stringshare_del(output->id); */
4286 /* eina_stringshare_del(output->make); */
4287 /* eina_stringshare_del(output->model); */
4294 _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)
4296 struct wl_resource *res;
4298 uint32_t serial, keycode;
4299 struct wl_client *wc = NULL;
4300 E_Comp_Config *comp_conf = NULL;
4301 const char *device_name = NULL;
4303 keycode = (ev->keycode - 8);
4305 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4307 comp_conf = e_comp_config_get();
4309 if (ec && ec->comp_data)
4311 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4314 wc = wl_resource_get_client(surface);
4317 if (e_config->key_input_ttrace_enable)
4319 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4320 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4323 EINA_LIST_FOREACH(key_list, l, res)
4325 if (wl_resource_get_client(res) != wc) continue;
4327 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4328 if (!e_input_thread_mode_get())
4330 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4331 device_name = ecore_device_name_get(ev->dev);
4337 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4338 device_name = e_device_name_get(dev);
4342 if (comp_conf && comp_conf->input_log_enable)
4343 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4345 wl_keyboard_send_key(res, serial, ev->timestamp,
4350 if (e_config->key_input_ttrace_enable)
4353 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4358 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4360 E_Client *ec = NULL;
4362 E_Comp_Wl_Key_Data *end, *k;
4364 if (ev->window != e_comp->ee_win)
4369 keycode = (ev->keycode - 8);
4370 if (!(e_comp_wl = e_comp->wl_comp_data))
4375 #ifndef E_RELEASE_BUILD
4376 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4377 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4378 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4379 eina_streq(ev->key, "BackSpace"))
4385 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4387 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4389 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4391 /* ignore server-generated key repeats */
4392 if (k->key == keycode)
4394 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4399 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4401 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4403 ec = e_client_focused_get();
4404 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4405 if (ec && ec->comp_data && surface)
4407 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4408 if (e_comp_wl->kbd.focused)
4410 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4412 /* A key only sent to clients is added to the list */
4413 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4414 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4416 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4418 DBG("wl_array_add: Out of memory\n");
4419 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4420 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4423 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4427 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4431 /* update modifier state */
4432 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4438 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4440 E_Client *ec = NULL;
4441 uint32_t keycode, delivered_key;
4442 E_Comp_Wl_Key_Data *end, *k;
4444 if (ev->window != e_comp->ee_win)
4449 keycode = (ev->keycode - 8);
4451 if (!(e_comp_wl = e_comp->wl_comp_data))
4456 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4458 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4459 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4461 if (k->key == keycode)
4468 e_comp_wl->kbd.keys.size =
4469 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4471 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4473 /* 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) */
4474 if ((delivered_key) ||
4475 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4477 ec = e_client_focused_get();
4479 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4480 if (e_comp_wl->kbd.focused)
4482 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4484 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4487 /* update modifier state */
4488 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4494 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4496 Eina_Bool res = EINA_FALSE;
4498 if (type == ECORE_EVENT_KEY_DOWN)
4500 res = e_comp_wl_key_down(ev, dev);
4502 else if (type == ECORE_EVENT_KEY_UP)
4504 res = e_comp_wl_key_up(ev, dev);
4511 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4514 struct wl_client *wc;
4515 uint32_t serial, btn;
4516 struct wl_resource *res;
4517 E_Comp_Config *comp_conf = NULL;
4519 if (ec->cur_mouse_action || e_comp_wl->drag)
4521 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4522 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4526 case 1: btn = BTN_LEFT; break;
4527 case 2: btn = BTN_MIDDLE; break;
4528 case 3: btn = BTN_RIGHT; break;
4529 default: btn = button_id; break;
4532 e_comp_wl->ptr.button = btn;
4533 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4534 if (!surface) return EINA_FALSE;
4536 if (!eina_list_count(e_comp_wl->ptr.resources))
4539 wc = wl_resource_get_client(surface);
4540 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4542 comp_conf = e_comp_config_get();
4544 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4546 if (wl_resource_get_client(res) != wc) continue;
4547 if (!e_comp_wl_input_pointer_check(res)) continue;
4548 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4550 if (comp_conf && comp_conf->input_log_enable)
4551 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4553 wl_pointer_send_button(res, serial, timestamp, btn, state);
4560 e_comp_wl_touch_cancel(void)
4562 _e_comp_wl_touch_cancel();
4565 E_API E_Comp_Wl_Hook *
4566 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4570 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4571 ch = E_NEW(E_Comp_Wl_Hook, 1);
4572 if (!ch) return NULL;
4573 ch->hookpoint = hookpoint;
4575 ch->data = (void*)data;
4576 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4581 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4584 if (_e_comp_wl_hooks_walking == 0)
4586 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4590 _e_comp_wl_hooks_delete++;
4593 E_API E_Comp_Wl_Pid_Hook *
4594 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4596 E_Comp_Wl_Pid_Hook *ch;
4598 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4600 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4601 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4603 ch->hookpoint = hookpoint;
4605 ch->data = (void*)data;
4606 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4612 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4615 if (_e_comp_wl_pid_hooks_walking == 0)
4617 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4621 _e_comp_wl_pid_hooks_delete++;
4624 E_API E_Comp_Wl_Intercept_Hook *
4625 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4627 E_Comp_Wl_Intercept_Hook *ch;
4629 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4630 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4631 if (!ch) return NULL;
4632 ch->hookpoint = hookpoint;
4634 ch->data = (void*)data;
4635 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4640 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4643 if (_e_comp_wl_intercept_hooks_walking == 0)
4645 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4649 _e_comp_wl_intercept_hooks_delete++;
4653 e_comp_wl_shell_surface_ready(E_Client *ec)
4657 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4661 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4663 e_config->use_cursor_timer = !!enabled;
4665 if (e_config->use_cursor_timer)
4667 if (!e_pointer_is_hidden(e_comp->pointer))
4669 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4674 if (e_comp_wl->ptr.hide_tmr)
4676 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4677 e_comp_wl->ptr.hide_tmr = NULL;
4679 cursor_timer_ec = NULL;
4681 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4684 if (e_pointer_is_hidden(e_comp->pointer))
4686 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4692 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4694 EINA_SAFETY_ON_NULL_RETURN(wc);
4695 EINA_SAFETY_ON_NULL_RETURN(dev);
4697 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4701 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4703 EINA_SAFETY_ON_NULL_RETURN(wc);
4704 EINA_SAFETY_ON_NULL_RETURN(dev);
4706 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4710 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4712 struct wl_resource *res;
4713 struct wl_client *wc;
4715 uint32_t serial, wl_keycode;
4716 enum wl_keyboard_key_state state;
4717 E_Comp_Config *comp_conf = NULL;
4718 const char *dev_name = NULL;
4720 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4721 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4722 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4724 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4725 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4727 wl_keycode = keycode - 8;
4728 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4730 wc = wl_resource_get_client(surface);
4731 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4732 if (!time) time = e_util_timestamp_get();
4733 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4734 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4736 comp_conf = e_comp_config_get();
4737 e_keyrouter_event_surface_send(ec, keycode);
4739 if (e_config->key_input_ttrace_enable)
4741 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4742 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4745 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4746 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4748 if (wl_resource_get_client(res) != wc) continue;
4749 if (!e_input_thread_mode_get())
4753 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4754 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4758 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4765 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4766 dev_name = e_device_name_get(dev);
4770 if (comp_conf && comp_conf->input_log_enable)
4771 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4774 wl_keyboard_send_key(res, serial, time,
4777 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4779 if (e_config->key_input_ttrace_enable)
4782 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4789 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4791 struct wl_resource *res;
4792 struct wl_client *wc;
4794 uint32_t serial, wl_keycode, cancel_keycode;
4795 E_Comp_Config *comp_conf = NULL;
4796 struct xkb_keymap *keymap = NULL;
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4799 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4800 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4802 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4803 keymap = e_comp_wl->xkb.keymap;
4804 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4805 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4807 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4808 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4810 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4811 if (cancel_keycode == XKB_KEYCODE_INVALID)
4813 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4816 cancel_keycode = cancel_keycode - 8;
4818 wl_keycode = keycode - 8;
4819 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4821 wc = wl_resource_get_client(surface);
4822 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4823 if (!time) time = e_util_timestamp_get();
4825 comp_conf = e_comp_config_get();
4826 e_keyrouter_event_surface_send(ec, keycode);
4828 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4829 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4831 if (wl_resource_get_client(res) != wc) continue;
4832 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4833 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4835 if (comp_conf && comp_conf->input_log_enable)
4836 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4837 wl_keyboard_send_key(res, serial, time,
4838 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4839 wl_keyboard_send_key(res, serial, time,
4840 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4841 wl_keyboard_send_key(res, serial, time,
4842 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4844 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4851 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)
4853 struct wl_client *wc;
4855 E_Devicemgr_Input_Device *device = NULL;
4857 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4858 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4859 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4861 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4862 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4864 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4866 wc = wl_resource_get_client(surface);
4867 if (!time) time = e_util_timestamp_get();
4868 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4872 _e_comp_wl_send_event_device(wc, time, dev, serial);
4873 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4877 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4878 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4881 x = x + ec->client.x;
4882 y = y + ec->client.y;
4884 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4890 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)
4892 E_Devicemgr_Input_Device *device;
4894 struct wl_client *wc;
4896 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4897 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4898 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4900 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4901 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4903 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4905 wc = wl_resource_get_client(surface);
4906 if (!time) time = e_util_timestamp_get();
4907 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4911 _e_comp_wl_send_event_device(wc, time, dev, serial);
4912 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4916 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4917 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4920 x = x + ec->client.x;
4921 y = y + ec->client.y;
4923 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4929 e_comp_wl_touch_cancel_send(E_Client *ec)
4931 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4932 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4933 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4935 _e_comp_wl_send_touch_cancel(ec);
4941 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4944 struct wl_client *wc;
4946 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4947 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4948 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4950 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4951 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4953 wc = wl_resource_get_client(surface);
4954 if (!time) time = e_util_timestamp_get();
4955 serial = wl_display_next_serial(e_comp_wl->wl.disp);
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);
4961 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4962 WL_POINTER_BUTTON_STATE_PRESSED);
4964 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4965 WL_POINTER_BUTTON_STATE_RELEASED);
4971 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4974 struct wl_client *wc;
4976 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4977 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4978 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4980 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4981 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4983 wc = wl_resource_get_client(surface);
4984 if (!time) time = e_util_timestamp_get();
4985 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4987 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4988 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4990 x = x + ec->client.x;
4991 y = y + ec->client.y;
4993 _e_comp_wl_send_mouse_move(ec, x, y, time);
4999 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
5002 struct wl_client *wc;
5004 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5005 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5006 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5008 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5009 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5011 wc = wl_resource_get_client(surface);
5012 if (!time) time = e_util_timestamp_get();
5013 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5015 if (_e_comp_wl_check_cursor_timer_needed(ec))
5017 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
5021 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5022 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5024 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
5026 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
5028 if (_e_comp_wl_check_cursor_timer_needed(ec))
5029 _e_comp_wl_cursor_move_timer_control(ec);
5036 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
5039 struct wl_client *wc;
5040 struct wl_resource *res;
5043 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5044 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5046 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5047 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5049 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5050 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5052 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5053 wc = wl_resource_get_client(surface);
5054 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5055 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5057 if (!e_comp_wl_input_pointer_check(res)) continue;
5058 if (wl_resource_get_client(res) != wc) continue;
5060 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5061 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5063 wl_pointer_send_enter(res, serial, surface,
5064 wl_fixed_from_int(x),
5065 wl_fixed_from_int(y));
5066 ec->pointer_enter_sent = EINA_TRUE;
5068 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5074 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5077 struct wl_client *wc;
5078 struct wl_resource *res;
5081 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5082 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5083 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5084 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5085 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5086 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5088 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5089 wc = wl_resource_get_client(surface);
5090 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5091 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5093 if (!e_comp_wl_input_pointer_check(res)) continue;
5094 if (wl_resource_get_client(res) != wc) continue;
5096 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5097 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5099 wl_pointer_send_leave(res, serial, surface);
5100 ec->pointer_enter_sent = EINA_FALSE;
5107 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)
5109 Evas_Event_Mouse_In ev_in;
5112 if (ec->pointer_enter_sent) return;
5114 ev_in.buttons = buttons;
5122 ev_in.modifiers = modifiers;
5123 ev_in.locks = locks;
5124 ev_in.timestamp = timestamp;
5125 ev_in.event_flags = event_flags;
5128 ev_in.event_src = event_src;
5130 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5134 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)
5136 Evas_Event_Mouse_Out ev_out;
5139 if (!ec->pointer_enter_sent) return;
5141 ev_out.buttons = buttons;
5143 ev_out.output.x = x;
5144 ev_out.output.y = y;
5145 ev_out.canvas.x = x;
5146 ev_out.canvas.y = y;
5149 ev_out.modifiers = modifiers;
5150 ev_out.locks = locks;
5151 ev_out.timestamp = timestamp;
5152 ev_out.event_flags = event_flags;
5155 ev_out.event_src = event_src;
5157 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5161 e_comp_wl_cursor_hide(E_Client *ec)
5163 struct wl_resource *res;
5164 struct wl_client *wc;
5168 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5170 if (e_comp_wl->ptr.hide_tmr)
5172 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5173 e_comp_wl->ptr.hide_tmr = NULL;
5175 cursor_timer_ec = NULL;
5177 if (!ec) return EINA_FALSE;
5178 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5179 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5180 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5182 wc = wl_resource_get_client(surface);
5183 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5184 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5186 if (!e_comp_wl_input_pointer_check(res)) continue;
5187 if (wl_resource_get_client(res) != wc) continue;
5188 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5189 wl_pointer_send_leave(res, serial, surface);
5190 ec->pointer_enter_sent = EINA_FALSE;
5196 /* surface to buffer
5197 * - width : surface width
5198 * - height : surface height
5199 * - transform: buffer transform
5200 * - scale : buffer scale
5202 * - width : screen width
5203 * - height : screen height
5204 * - transform: output transform
5205 * - scale : output scale
5207 static E_Util_Transform_Matrix
5208 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5210 E_Util_Transform_Matrix m;
5212 e_util_transform_matrix_load_identity(&m);
5214 if (transform & 0x4)
5216 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5217 e_util_transform_matrix_flip_x(&m);
5218 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5221 switch (transform & 0x3)
5223 case WL_OUTPUT_TRANSFORM_90:
5224 e_util_transform_matrix_translate(&m, -width, 0, 0);
5225 e_util_transform_matrix_rotation_z(&m, 270);
5227 case WL_OUTPUT_TRANSFORM_180:
5228 e_util_transform_matrix_translate(&m, -width, -height, 0);
5229 e_util_transform_matrix_rotation_z(&m, 180);
5231 case WL_OUTPUT_TRANSFORM_270:
5232 e_util_transform_matrix_translate(&m, 0, -height, 0);
5233 e_util_transform_matrix_rotation_z(&m, 90);
5239 e_util_transform_matrix_scale(&m, scale, scale, 1);
5244 /* surface to buffer
5245 * - surface width, surface height, buffer transform, buffer scale
5247 * - screen width, screen height, output transform, output scale
5250 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5252 E_Util_Transform_Matrix m;
5253 E_Util_Transform_Vertex v;
5255 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5257 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5258 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5259 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5263 * - buffer width, buffer height, buffer transform, buffer scale
5266 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5268 E_Util_Transform_Matrix m;
5269 E_Util_Transform_Vertex v;
5272 if (transform != 0 || scale > 1)
5274 tw = ((transform % 2) ? height : width) / scale;
5275 th = ((transform % 2) ? width : height) / scale;
5283 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5284 m = e_util_transform_matrix_inverse_get(&m);
5286 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5287 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5288 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5291 /* surface to buffer
5292 * - surface width, surface height, buffer transform, buffer scale
5294 * - screen width, screen height, output transform, output scale
5297 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5298 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5300 E_Util_Transform_Matrix m;
5301 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5302 E_Util_Transform_Rect_Vertex sv;
5304 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5306 sv = e_util_transform_rect_to_vertices(&sr);
5307 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5308 sr = e_util_transform_vertices_to_rect(&sv);
5317 * - buffer width, buffer height, buffer transform, buffer scale
5320 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5321 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5323 E_Util_Transform_Matrix m;
5324 E_Util_Transform_Rect br = {bx, by, bw, bh};
5325 E_Util_Transform_Rect_Vertex bv;
5328 if (transform != 0 || scale > 1)
5330 tw = ((transform % 2) ? height : width) / scale;
5331 th = ((transform % 2) ? width : height) / scale;
5339 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5340 m = e_util_transform_matrix_inverse_get(&m);
5342 bv = e_util_transform_rect_to_vertices(&br);
5343 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5344 br = e_util_transform_vertices_to_rect(&bv);
5352 EINTERN E_Comp_Wl_Output*
5353 e_comp_wl_output_find(E_Client *ec)
5356 E_Comp_Wl_Output *output;
5358 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5360 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5362 if (output->transform % 2)
5364 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5365 ec->y < output->x || ec->y >= (output->x + output->w))
5370 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5371 ec->y < output->y || ec->y >= (output->y + output->h))
5381 EINTERN Eina_Array *
5382 e_comp_wl_output_find_all(E_Client *ec)
5384 E_Comp_Wl_Output *output;
5385 Eina_Array *outputs;
5388 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5390 outputs = eina_array_new(4);
5394 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5396 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5397 output->x, output->y, output->w, output->h))
5399 eina_array_push(outputs, output);
5403 if (eina_array_count(outputs) == 0)
5405 eina_array_free(outputs);
5412 // --------------------------------------------------------
5413 // tizen_move_resize
5414 // --------------------------------------------------------
5416 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5423 E_Client_Pending_Geometry *geo;
5426 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5427 if (ec->fullscreen || ec->maximized) goto err;
5429 geo = E_NEW(E_Client_Pending_Geometry, 1);
5432 geo->serial = serial;
5438 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5439 ec->surface_sync.wait_commit = EINA_TRUE;
5444 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5451 e_comp_wl_commit_sync_configure(E_Client *ec)
5454 E_Client_Pending_Geometry *geo;
5456 Eina_Bool match_size = EINA_FALSE;
5463 if (!ec || !ec->frame) goto ret;
5464 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5467 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5468 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5470 if (eina_list_count(ec->surface_sync.pending_geometry))
5472 Eina_List *ll = NULL;
5473 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5477 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5482 if ((geo->w == bw) && (geo->h == bh))
5484 match_size = EINA_TRUE;
5489 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5496 if ((config.w != ec->w) || (config.h != ec->h))
5498 e_client_size_set(ec, config.w, config.h);
5499 ec->changes.size = EINA_TRUE;
5503 // FIXME: The geometry of the client would be better to be calculated
5504 // at e_desk or at e_desk_area. So the position(x,y) of the client
5505 // should be calcuated at the e_desk or at the e_desk_area.
5507 desk = e_comp_desk_find_by_ec(ec);
5510 ec->client.x = desk->geom.x + config.x;
5511 ec->client.y = desk->geom.y + config.y;
5515 ec->client.x = config.x;
5516 ec->client.y = config.y;
5519 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5521 e_client_pos_set(ec, ec->client.x, ec->client.y);
5523 ec->changes.pos = 1;
5527 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5531 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5532 ec->surface_sync.wait_commit = EINA_FALSE;
5534 if ((ec->comp_data->shell.surface) &&
5535 (ec->comp_data->shell.configure))
5537 ec->comp_data->shell.configure(ec->comp_data->shell.surface,
5542 // rollback wait_commit if there are pending requests remained
5543 if (eina_list_count(ec->surface_sync.pending_geometry))
5544 ec->surface_sync.wait_commit = EINA_TRUE;
5549 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);
5556 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5557 struct wl_resource *res_moveresize)
5559 wl_resource_destroy(res_moveresize);
5563 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5564 struct wl_resource *res_moveresize,
5565 struct wl_resource *surface,
5572 /* to be implemented */
5575 int cur_w = 0, cur_h = 0;
5577 ec = e_client_from_surface_resource(surface);
5580 pending = e_client_pending_geometry_has(ec);
5581 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5582 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);
5586 if ((cur_w == w) && (cur_h == h))
5588 e_client_pos_set(ec, x, y);
5589 ec->changes.pos = 1;
5595 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5599 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5602 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5604 _tz_move_resize_iface_cb_destroy,
5605 _tz_move_resize_iface_cb_set_geometry,
5609 _tz_moveresize_cb_bind(struct wl_client *client,
5610 void *data EINA_UNUSED,
5614 struct wl_resource *res_moveresize;
5616 res_moveresize = wl_resource_create(client,
5617 &tizen_move_resize_interface,
5620 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5623 wl_resource_set_implementation(res_moveresize,
5624 &_tz_move_resize_iface,
5630 ERR("Could not create tizen_move_resize_interface res: %m");
5631 wl_client_post_no_memory(client);
5635 _e_comp_wl_move_resize_init(void)
5637 if (!e_comp_wl) return;
5638 if (!e_comp_wl->wl.disp) return;
5640 if (!wl_global_create(e_comp_wl->wl.disp,
5641 &tizen_move_resize_interface,
5644 _tz_moveresize_cb_bind))
5646 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5653 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5655 E_Comp_Wl_Output *output;
5656 pid_t output_pid = 0;
5657 Eina_List *l = NULL, *l2 = NULL;
5658 struct wl_resource *resource = NULL;
5660 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5662 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5663 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5664 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5666 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5668 /* if we have bound resources, send updates */
5669 EINA_LIST_FOREACH(output->resources, l2, resource)
5671 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5672 if (output_pid != pid) continue;
5674 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5676 // send output information to the client
5677 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5685 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5687 _e_comp_wl_surface_state_init(state, w, h);
5691 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5693 _e_comp_wl_surface_state_commit(ec, state);
5697 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5699 _e_comp_wl_hook_call(hookpoint, ec);
5703 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5705 _e_comp_wl_surface_state_finish(state);
5709 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5711 _e_comp_wl_surface_state_buffer_set(state, buffer);
5715 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5716 int sx, int sy, int *dx, int *dy)
5720 case WL_OUTPUT_TRANSFORM_NORMAL:
5724 case WL_OUTPUT_TRANSFORM_FLIPPED:
5725 *dx = width - sx, *dy = sy;
5727 case WL_OUTPUT_TRANSFORM_90:
5728 *dx = height - sy, *dy = sx;
5730 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5731 *dx = height - sy, *dy = width - sx;
5733 case WL_OUTPUT_TRANSFORM_180:
5734 *dx = width - sx, *dy = height - sy;
5736 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5737 *dx = sx, *dy = height - sy;
5739 case WL_OUTPUT_TRANSFORM_270:
5740 *dx = sy, *dy = width - sx;
5742 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5752 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5755 int tx1, ty1, tx2, ty2;
5756 int width_from_buffer, height_from_buffer;
5758 switch (vp->buffer.transform)
5760 case WL_OUTPUT_TRANSFORM_90:
5761 case WL_OUTPUT_TRANSFORM_270:
5762 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5763 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5764 width_from_buffer = bh / vp->buffer.scale;
5765 height_from_buffer = bw / vp->buffer.scale;
5768 width_from_buffer = bw / vp->buffer.scale;
5769 height_from_buffer = bh / vp->buffer.scale;
5773 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5777 x2 = width_from_buffer;
5778 y2 = height_from_buffer;
5782 x1 = wl_fixed_to_int(vp->buffer.src_x);
5783 y1 = wl_fixed_to_int(vp->buffer.src_y);
5784 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5785 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5788 buffer_transform(width_from_buffer, height_from_buffer,
5789 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5790 buffer_transform(width_from_buffer, height_from_buffer,
5791 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5793 out->x = (tx1 <= tx2) ? tx1 : tx2;
5794 out->y = (ty1 <= ty2) ? ty1 : ty2;
5795 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5796 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5800 * Convert given four coordinates to elements of rectangle
5801 * @in p[4] Coordinates to be converted
5802 * @out rect x, y, width, and height
5803 * transform Angle which represents TDM_TRANSFORM of rectangle
5804 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5805 * 1. The given coordinates are not represented by rectangle.
5806 * 2. All angles except for 0, 90, 180, 270.
5809 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5811 Eina_Bool ret = EINA_FALSE;
5813 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))
5816 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5819 *rotation = TDM_TRANSFORM_NORMAL;
5822 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5826 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5829 *rotation = TDM_TRANSFORM_180;
5832 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5837 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))
5840 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5843 *rotation = TDM_TRANSFORM_90;
5846 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5850 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5853 *rotation = TDM_TRANSFORM_270;
5856 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5866 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5871 for (i = 0; i < 4; i++)
5872 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5874 if (!_coords_to_rectangle_convert(p, out, rotation))
5876 DBG("Cannot convert given coords to rectangle.\n"
5877 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5878 p[0].x, p[0].y, p[1].x, p[1].y,
5879 p[2].x, p[2].y, p[3].x, p[3].y);
5887 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5889 int trans_rotation, flip;
5891 trans_rotation = transform & 0x3;
5892 flip = transform & 0x4;
5894 return (flip + (trans_rotation + rotation) % 4);
5898 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5906 if (e_comp_wl_subsurface_check(ec))
5907 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5914 out->w = ec->comp_data->width_from_viewport;
5915 out->w = (out->w + 1) & ~1;
5916 out->h = ec->comp_data->height_from_viewport;
5918 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5919 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5923 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5925 E_Comp_Wl_Buffer *buffer;
5926 E_Comp_Wl_Buffer_Viewport *vp;
5928 enum wl_output_transform buffer_transform;
5929 unsigned int rotation;
5930 Eina_Bool res = EINA_FALSE;
5932 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5934 if (e_object_is_del(E_OBJECT(ec)))
5937 vp = &ec->comp_data->scaler.buffer_viewport;
5939 if (buffer_viewport)
5941 buffer = ec->comp_data->buffer_ref.buffer;
5942 /* Getting a viewport of buffer needs geometry of buffer. */
5946 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5949 if ((output_viewport) || (transform))
5951 m = e_client_map_get(ec);
5953 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5955 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5960 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5961 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5962 * Since buffer.transform isn't applied using evas_map,
5963 * it has to be taken into account here to apply buffer.transform
5964 * and rotation of e_client_transform together. */
5966 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5968 *transform = (unsigned int)buffer_transform;
5976 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5978 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5979 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5981 /* Must be called with valid comp_data */
5982 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5984 if ((ec->comp_data->role_name == NULL) ||
5985 (ec->comp_data->role_name == role_name) ||
5986 (strcmp(ec->comp_data->role_name, role_name) == 0))
5988 ec->comp_data->role_name = role_name;
5994 wl_resource_post_error(error_resource, error_code,
5995 "Cannot assign role %s to wl_surface@%d,"
5996 " already has role %s\n",
5998 ec->comp_data->wl_surface ?
5999 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
6000 ec->comp_data->role_name);
6006 EINTERN const char *
6007 e_comp_wl_surface_role_get(E_Client *ec)
6009 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
6010 return ec->comp_data ? ec->comp_data->role_name : NULL;
6013 EINTERN struct wl_resource *
6014 e_comp_wl_client_surface_get(E_Client *ec)
6016 struct wl_resource *surface = NULL;
6017 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
6018 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
6020 g_mutex_lock(&ec->comp_data->surface_mutex);
6021 surface = ec->comp_data->surface;
6022 g_mutex_unlock(&ec->comp_data->surface_mutex);
6027 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
6029 EINA_SAFETY_ON_NULL_RETURN(ec);
6030 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
6032 g_mutex_lock(&ec->comp_data->surface_mutex);
6033 ec->comp_data->surface = surface;
6034 g_mutex_unlock(&ec->comp_data->surface_mutex);
6038 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
6040 return e_compositor_util_client_from_surface_resource(surface_resource);
6044 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
6046 if (!ec->comp_data->mapped)
6048 if (ec->comp_data->shell.surface &&
6049 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
6051 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
6057 if (ec->comp_data->mapped)
6059 /* will be unmapped. so run capture */
6060 e_comp_wl_remote_surface_image_save(ec);
6064 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
6066 ec->comp_data->pending.sx = sx;
6067 ec->comp_data->pending.sy = sy;
6068 ec->comp_data->pending.new_attach = EINA_TRUE;
6070 e_client_fps_update(ec);
6074 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6076 if (ec->comp_data->pending.opaque)
6077 eina_tiler_clear(ec->comp_data->pending.opaque);
6081 eina_tiler_union(ec->comp_data->pending.opaque, region);
6083 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6087 ec->argb = EINA_FALSE;
6088 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6090 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6091 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6099 ec->argb = EINA_TRUE;
6100 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6102 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6103 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6109 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6111 if (ec->comp_data->pending.input)
6112 eina_tiler_clear(ec->comp_data->pending.input);
6116 if (eina_tiler_empty(region))
6118 ELOGF("COMP", " |unset input rect", NULL);
6119 e_comp_object_input_objs_del(ec->frame);
6120 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6123 eina_tiler_union(ec->comp_data->pending.input, region);
6127 eina_tiler_rect_add(ec->comp_data->pending.input,
6128 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6133 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6135 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6139 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6141 E_Comp_Wl_Subsurf_Data *sdata;
6146 if (ec->comp_data->frames)
6148 ec->comp_data->frames =
6149 eina_list_remove(ec->comp_data->frames, callback_resource);
6152 if (ec->comp_data->pending.frames)
6154 ec->comp_data->pending.frames =
6155 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6158 sdata = ec->comp_data->sub.data;
6159 if ((sdata) && (sdata->cached.frames))
6161 sdata->cached.frames =
6162 eina_list_remove(sdata->cached.frames, callback_resource);
6167 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6169 if (e_object_is_del(E_OBJECT(ec))) return;
6171 if (e_comp_wl_remote_surface_commit(ec)) return;
6173 e_comp_wl_surface_commit(ec);
6175 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6179 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6181 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6182 ec->comp_data->sub.data = sub;
6184 /* set subsurface client properties */
6185 ec->borderless = EINA_TRUE;
6186 ec->argb = EINA_TRUE;
6187 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6188 ec->lock_border = EINA_TRUE;
6189 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6190 ec->netwm.state.skip_taskbar = EINA_TRUE;
6191 ec->netwm.state.skip_pager = EINA_TRUE;
6192 ec->no_shape_cut = EINA_TRUE;
6193 ec->border_size = 0;
6194 ec->lock_user_location = 0;
6195 ec->lock_client_location = 0;
6196 ec->lock_user_size = 0;
6197 ec->lock_client_size = 0;
6198 ec->lock_client_stacking = 0;
6199 ec->lock_user_shade = 0;
6200 ec->lock_client_shade = 0;
6201 ec->lock_user_maximize = 0;
6202 ec->lock_client_maximize = 0;
6203 ec->changes.need_maximize = 0;
6204 ec->maximized = E_MAXIMIZE_NONE;
6207 ec->new_client = ec->netwm.ping = EINA_TRUE;
6208 e_comp->new_clients++;
6209 e_client_unignore(ec);
6211 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6212 * It's not for subsurface. */
6213 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6217 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6219 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6222 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6224 sub->parent = parent;
6228 layer = e_client_layer_get(parent);
6229 if (layer > E_LAYER_BOTTOM)
6230 e_client_layer_set(ec, layer);
6233 if (parent->comp_data)
6235 /* append this client to the parents subsurface list */
6236 parent->comp_data->sub.list_pending =
6237 eina_list_append(parent->comp_data->sub.list_pending, ec);
6238 parent->comp_data->sub.list_changed = EINA_TRUE;
6243 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6245 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6246 E_Client *parent = sub->parent;
6248 parent->comp_data->sub.list =
6249 eina_list_remove(parent->comp_data->sub.list, ec);
6250 parent->comp_data->sub.list_pending =
6251 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6252 parent->comp_data->sub.below_list =
6253 eina_list_remove(parent->comp_data->sub.below_list, ec);
6254 parent->comp_data->sub.below_list_pending =
6255 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6261 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)
6263 sub->resource = subsurface_resource;
6264 sub->cached_buffer_ref.buffer = NULL;
6265 sub->synchronized = EINA_TRUE;
6266 sub->parent = parent;
6267 sub->remote_surface.offscreen_parent = offscreen_parent;
6268 if (offscreen_parent)
6269 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6271 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6273 _e_comp_wl_client_subsurface_set(ec, sub);
6274 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6276 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6280 e_comp_wl_client_subsurface_finish(E_Client *ec)
6282 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6285 e_comp_wl_client_subsurface_parent_unset(ec);
6287 e_comp_wl_surface_state_finish(&sub->cached);
6288 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6290 ec->comp_data->sub.data = NULL;
6294 e_comp_wl_client_evas_init(E_Client *ec)
6296 EINA_SAFETY_ON_NULL_RETURN(ec);
6298 _e_comp_wl_client_evas_init(ec);
6302 e_comp_wl_client_evas_deinit(E_Client *ec)
6304 EINA_SAFETY_ON_NULL_RETURN(ec);
6306 _e_comp_wl_client_evas_deinit(ec);
6310 e_comp_wl_focus_check(void)
6312 _e_comp_wl_focus_check();
6316 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6323 if ((parent->comp_data) && (parent->comp_data->sub.data))
6324 parent = parent->comp_data->sub.data->parent;