2 #include "e_comp_wl_intern.h"
3 #include "e_comp_wl_private.h"
4 #include "e_foreign_intern.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_comp_wl_private.h"
7 #include "e_client_intern.h"
8 #include "e_appinfo_intern.h"
9 #include "e_blender_intern.h"
10 #include "e_utils_intern.h"
11 #include "e_scale_intern.h"
12 #include "e_comp_canvas_intern.h"
13 #include "e_comp_screen_intern.h"
14 #include "e_comp_wl_capture_intern.h"
15 #include "e_comp_wl_data_intern.h"
16 #include "e_comp_wl_input_intern.h"
17 #include "e_comp_wl_renderer_intern.h"
18 #include "e_comp_wl_rsm_intern.h"
19 #include "e_comp_wl_screenshooter_intern.h"
20 #include "e_comp_wl_shell_intern.h"
21 #include "e_comp_wl_subsurface_intern.h"
22 #include "e_comp_wl_tbm_intern.h"
23 #include "e_comp_wl_viewport_intern.h"
24 #include "e_comp_intern.h"
25 #include "e_input_intern.h"
26 #include "e_keyrouter_intern.h"
27 #include "e_error_intern.h"
28 #include "e_pointer_intern.h"
29 #include "e_presentation_time_intern.h"
30 #include "e_grabinput_intern.h"
31 #include "e_env_intern.h"
32 #include "e_dnd_intern.h"
33 #include "e_policy_visibility_intern.h"
35 #include <tizen-extension-server-protocol.h>
36 #include <relative-pointer-unstable-v1-server-protocol.h>
37 #include <pointer-constraints-unstable-v1-server-protocol.h>
39 #include <wayland-tbm-server.h>
41 #include <libds/log.h>
42 #include <libds/single_pixel_buffer_v1.h>
44 /* handle include for printing uint64_t */
45 #define __STDC_FORMAT_MACROS
48 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
50 /* Resource Data Mapping: (wl_resource_get_user_data)
52 * wl_surface == e_pixmap
53 * wl_region == eina_tiler
54 * wl_subsurface == e_client
58 typedef struct _E_Comp_Data E_Comp_Data;
63 struct wl_listener client_created;
66 static void _e_comp_wl_move_resize_init(void);
68 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
71 typedef struct _E_Comp_Wl_Key_Data
77 static Eina_List *handlers = NULL;
78 static E_Client *cursor_timer_ec = NULL;
79 static Eina_Bool need_send_released = EINA_FALSE;
80 static Eina_Bool need_send_motion = EINA_TRUE;
82 static GMutex connection_mutex;
84 static int _e_comp_wl_hooks_delete = 0;
85 static int _e_comp_wl_hooks_walking = 0;
87 static int _e_comp_wl_pid_hooks_delete = 0;
88 static int _e_comp_wl_pid_hooks_walking = 0;
90 static int _e_comp_wl_intercept_hooks_delete = 0;
91 static int _e_comp_wl_intercept_hooks_walking = 0;
93 static Eina_Inlist *_e_comp_wl_hooks[] =
95 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
96 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
97 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
98 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
99 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
100 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
101 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
102 [E_COMP_WL_HOOK_DEL] = NULL,
103 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
104 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
105 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
108 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
110 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
113 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
115 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
116 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
117 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
118 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
119 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
120 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
123 static Eina_List *hooks = NULL;
125 /* local functions */
127 _e_comp_wl_hooks_clean(void)
132 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
133 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
135 if (!ch->delete_me) continue;
136 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
142 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
146 e_object_ref(E_OBJECT(ec));
147 _e_comp_wl_hooks_walking++;
148 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
150 if (ch->delete_me) continue;
151 ch->func(ch->data, ec);
152 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
153 (e_object_is_del(E_OBJECT(ec))))
156 _e_comp_wl_hooks_walking--;
157 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
158 _e_comp_wl_hooks_clean();
159 e_object_unref(E_OBJECT(ec));
163 _e_comp_wl_pid_hooks_clean(void)
166 E_Comp_Wl_Pid_Hook *ch;
168 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
169 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
171 if (!ch->delete_me) continue;
172 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
178 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
180 E_Comp_Wl_Pid_Hook *ch;
182 _e_comp_wl_pid_hooks_walking++;
183 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
185 if (ch->delete_me) continue;
186 ch->func(ch->data, pid);
188 _e_comp_wl_pid_hooks_walking--;
189 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
190 _e_comp_wl_pid_hooks_clean();
194 _e_comp_wl_intercept_hooks_clean(void)
197 E_Comp_Wl_Intercept_Hook *ch;
199 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
200 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
202 if (!ch->delete_me) continue;
203 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
209 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
211 E_Comp_Wl_Intercept_Hook *ch;
212 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
214 e_object_ref(E_OBJECT(ec));
215 _e_comp_wl_intercept_hooks_walking++;
216 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
218 if (ch->delete_me) continue;
219 res = ch->func(ch->data, ec);
220 if (!res) ret = EINA_FALSE;
221 if (e_object_is_del(E_OBJECT(ec)))
224 _e_comp_wl_intercept_hooks_walking--;
225 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
226 _e_comp_wl_intercept_hooks_clean();
227 e_object_unref(E_OBJECT(ec));
234 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
240 if (e_comp_object_frame_exists(ec->frame))
241 w = ec->client.w, h = ec->client.h;
243 w = ec->w, h = ec->h;
247 // Width and Height are -1 means that we don't consider size value
251 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
255 _e_comp_wl_focus_check(void)
259 if (stopping) return;
260 ec = e_client_focused_get();
262 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
266 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
268 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
270 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
271 IDLE_EXITER~CB_PREPARE);
273 return ECORE_CALLBACK_RENEW;
277 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
279 /* dispatch pending wayland events */
280 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
282 return ECORE_CALLBACK_RENEW;
286 e_comp_wl_display_flush()
288 if (e_comp_wl && e_comp_wl->wl.disp)
290 if (e_config->key_input_ttrace_enable)
292 TRACE_INPUT_BEGIN(wl_display_flush_clients);
293 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
296 g_mutex_lock(&connection_mutex);
297 wl_display_flush_clients(e_comp_wl->wl.disp);
298 g_mutex_unlock(&connection_mutex);
300 if (e_config->key_input_ttrace_enable)
303 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
309 e_comp_wl_connection_lock()
311 e_input_boost_lock(&connection_mutex);
315 e_comp_wl_connection_unlock()
317 e_input_boost_unlock(&connection_mutex);
321 e_comp_wl_focused_client_flush()
323 E_Client *focused_ec;
324 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
326 e_input_boost_lock(&connection_mutex);
327 focused_ec = e_client_focused_get();
331 struct wl_client *wc;
332 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
335 e_input_boost_unlock(&connection_mutex);
339 wc = wl_resource_get_client(surface);
343 e_input_boost_unlock(&connection_mutex);
347 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
351 if (e_comp_wl->idle_exiter_timestamp > 0.0)
353 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
354 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
356 ELOGF("E_COMP", "prepare gap time: %lfms",
361 e_comp_wl->idle_exiter_timestamp = 0.0;
363 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
365 /* flush pending client events */
366 e_comp_wl_display_flush();
368 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
369 IDLE_EXITER~CB_PREPARE);
372 E_API enum wl_output_transform
373 e_comp_wl_output_buffer_transform_get(E_Client *ec)
375 E_Comp_Wl_Buffer_Viewport *vp;
376 E_Comp_Wl_Buffer *buffer;
377 enum wl_output_transform transform, rotation;
379 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
380 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
381 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
383 vp = &ec->comp_data->scaler.buffer_viewport;
384 if (e_comp_wl_subsurface_check(ec))
385 return vp->buffer.transform;
387 buffer = ec->comp_data->buffer_ref.buffer;
390 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
391 return vp->buffer.transform;
393 rotation = buffer->transform;
395 return vp->buffer.transform;
397 /* ignore the flip value when calculating transform because the screen rotation
398 * functionality doesn't consider the flip output transform currently
400 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
402 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
403 ec, rotation, vp->buffer.transform, transform);
408 EINTERN enum wl_output_transform
409 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
411 E_Comp_Wl_Buffer_Viewport *vp;
412 E_Comp_Wl_Buffer *buffer;
413 enum wl_output_transform transform, rotation;
415 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
416 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
417 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
419 vp = &ec->comp_data->pending.buffer_viewport;
420 if (e_comp_wl_subsurface_check(ec))
421 return vp->buffer.transform;
423 buffer = ec->comp_data->pending.buffer;
426 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
427 return vp->buffer.transform;
429 rotation = buffer->transform;
431 return vp->buffer.transform;
433 /* ignore the flip value when calculating transform because the screen rotation
434 * functionality doesn't consider the flip output transform currently
436 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
438 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
439 ec, rotation, vp->buffer.transform, transform);
445 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
447 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
448 E_Comp_Wl_Buffer *buffer;
449 int32_t width, height;
451 buffer = e_pixmap_resource_get(ec->pixmap);
454 ec->comp_data->width_from_buffer = 0;
455 ec->comp_data->height_from_buffer = 0;
459 switch (e_comp_wl_output_buffer_transform_get(ec))
461 case WL_OUTPUT_TRANSFORM_90:
462 case WL_OUTPUT_TRANSFORM_270:
463 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
464 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
465 width = buffer->h / vp->buffer.scale;
466 height = buffer->w / vp->buffer.scale;
469 width = buffer->w / vp->buffer.scale;
470 height = buffer->h / vp->buffer.scale;
474 ec->comp_data->width_from_buffer = width;
475 ec->comp_data->height_from_buffer = height;
479 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
481 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
482 int32_t width, height;
484 width = ec->comp_data->width_from_buffer;
485 height = ec->comp_data->height_from_buffer;
487 if (width == 0 && height == 0) return;
489 if (width != 0 && vp->surface.width != -1)
491 ec->comp_data->width_from_viewport = vp->surface.width;
492 ec->comp_data->height_from_viewport = vp->surface.height;
496 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
498 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
499 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
500 ec->comp_data->width_from_viewport = w ?: 1;
501 ec->comp_data->height_from_viewport = h ?: 1;
505 ec->comp_data->width_from_viewport = width;
506 ec->comp_data->height_from_viewport = height;
510 e_comp_wl_topmost_parent_get(E_Client *ec)
514 if (!e_comp_wl_subsurface_check(ec))
517 parent = e_comp_wl_subsurface_parent_get(ec);
520 if (!e_comp_wl_subsurface_check(parent))
523 parent = e_comp_wl_subsurface_parent_get(parent);
530 e_comp_wl_map_apply(E_Client *ec)
532 E_Comp_Wl_Buffer_Viewport *vp;
533 E_Comp_Wl_Subsurf_Data *sdata;
534 E_Comp_Wl_Client_Data *cdata;
535 int x1, y1, x2, y2, x, y;
537 Eina_Bool zoom_animating = EINA_FALSE;
539 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
541 e_comp_object_map_update(ec->frame);
543 cdata = ec->comp_data;
544 vp = &cdata->scaler.buffer_viewport;
545 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
546 (!cdata->viewport_transform))
549 if (e_comp_wl_subsurface_check(ec))
551 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
553 sdata = ec->comp_data->sub.data;
554 if (sdata->remote_surface.offscreen_parent)
556 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
557 Eina_Rectangle *rect;
560 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
562 /* TODO: If there are one more regions, it means that provider's offscreen
563 * is displayed by one more remote_surfaces. Have to consider it later. At
564 * this time, just consider only one remote_surface.
578 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
579 if (x != dx || y != dy)
580 evas_object_move(ec->frame, dx, dy);
582 if (!cdata->viewport_transform)
584 cdata->viewport_transform = e_util_transform_new();
585 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
586 e_client_transform_core_add(ec, cdata->viewport_transform);
589 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
590 ec->comp_data->width_from_viewport,
591 ec->comp_data->height_from_viewport);
593 if (vp->buffer.src_width == wl_fixed_from_int(-1))
597 x2 = cdata->width_from_buffer;
598 y2 = cdata->height_from_buffer;
602 x1 = wl_fixed_to_int(vp->buffer.src_x);
603 y1 = wl_fixed_to_int(vp->buffer.src_y);
604 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
605 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
608 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
609 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
610 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
611 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
614 desk = e_comp_desk_find_by_ec(ec);
616 zoom_animating = e_desk_zoom_is_animating(desk);
618 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
619 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
620 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
622 /* workaround:: when the desk zoom is doing their animation,
623 the transform core update can override animation's zoom boundary.
624 so, don't doing transform core update while desk zoom animation */
626 e_client_transform_core_update(ec);
631 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
635 int map_c = 0, map_x = 0, map_y = 0;
636 double inv_x = 0.0, inv_y = 0.0;
638 EINA_SAFETY_ON_NULL_RETURN(ec);
640 map = e_client_map_get(ec);
641 map_c = e_map_count_get(map);
643 if (!map || map_c <= 0)
653 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
654 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
655 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
656 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
658 for (int i = 0; i < map_c; i++)
660 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
661 e_map_point_image_uv_set(map2, i, map_x, map_y);
663 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
673 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
679 if (!(ec = data)) return;
680 if (e_object_is_del(data)) return;
682 if (!ec->override) e_hints_window_visible_set(ec);
684 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
685 (!ec->comp_data->need_reparent))
687 ec->comp_data->need_reparent = EINA_TRUE;
688 ec->visible = EINA_TRUE;
690 if (!e_client_util_ignored_get(ec))
692 ec->take_focus = !starting;
696 if (!ec->comp_data->need_reparent)
698 if ((ec->hidden) || (ec->iconic))
700 evas_object_hide(ec->frame);
701 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
704 evas_object_show(ec->frame);
707 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
708 evas_object_show(tmp->frame);
710 topmost = e_comp_wl_topmost_parent_get(ec);
711 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
712 e_comp_wl_subsurface_show(ec);
714 if (ec->comp_data->sub.below_obj)
715 evas_object_show(ec->comp_data->sub.below_obj);
719 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
725 if (!(ec = data)) return;
726 if (e_object_is_del(E_OBJECT(ec))) return;
728 /* Uncommonly some clients's final buffer can be skipped if the client
729 * requests unmap of its surface right after wl_surface@commit.
730 * So if this client evas object is hidden state and client is already
731 * unmmapped, we can consider to clear pixmap image here mandatorily.
733 if (!ec->comp_data->mapped)
734 e_pixmap_image_clear(ec->pixmap, 1);
736 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
737 evas_object_hide(tmp->frame);
739 topmost = e_comp_wl_topmost_parent_get(ec);
740 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
741 e_comp_wl_subsurface_hide(ec);
743 if (ec->comp_data->sub.below_obj)
744 evas_object_hide(ec->comp_data->sub.below_obj);
746 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
750 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
757 if (!(ec = data)) return;
758 if (e_object_is_del(E_OBJECT(ec))) return;
760 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
762 if (!e_comp_wl_subsurface_check(subc)) continue;
763 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
764 evas_object_move(subc->frame, x, y);
766 if (subc->comp_data->scaler.viewport)
768 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
769 if (cdata->viewport_transform)
770 e_comp_wl_map_apply(subc);
774 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
776 if (!e_comp_wl_subsurface_check(subc)) continue;
777 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
778 evas_object_move(subc->frame, x, y);
780 if (subc->comp_data->scaler.viewport)
782 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
783 if (cdata->viewport_transform)
784 e_comp_wl_map_apply(subc);
788 if (ec->comp_data->sub.below_obj)
790 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
791 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
796 _e_comp_wl_send_touch_cancel(E_Client *ec)
799 struct wl_resource *res;
800 struct wl_client *wc;
801 E_Comp_Config *comp_conf = NULL;
804 if (e_object_is_del(E_OBJECT(ec))) return;
805 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
807 if (!surface) return;
808 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
810 wc = wl_resource_get_client(surface);
812 comp_conf = e_comp_config_get();
814 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
816 if (wl_resource_get_client(res) != wc) continue;
817 if (!e_comp_wl_input_touch_check(res)) continue;
819 if (comp_conf && comp_conf->input_log_enable)
820 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
822 wl_touch_send_cancel(res);
827 _e_comp_wl_touch_cancel(void)
831 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
833 if (!e_comp_wl->touch.pressed) return;
835 _e_comp_wl_send_touch_cancel(ec);
838 static E_Devicemgr_Input_Device *
839 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
841 E_Devicemgr_Input_Device *last_kbd = NULL;
844 case ECORE_DEVICE_CLASS_MOUSE:
845 return e_devicemgr->last_device_ptr;
846 case ECORE_DEVICE_CLASS_KEYBOARD:
847 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
849 case ECORE_DEVICE_CLASS_TOUCH:
850 return e_devicemgr->last_device_touch;
858 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
862 case ECORE_DEVICE_CLASS_MOUSE:
863 e_devicemgr->last_device_ptr = device;
865 case ECORE_DEVICE_CLASS_KEYBOARD:
866 atomic_store(&e_devicemgr->last_device_kbd, device);
868 case ECORE_DEVICE_CLASS_TOUCH:
869 e_devicemgr->last_device_touch = device;
876 static E_Devicemgr_Input_Device *
877 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
879 E_Devicemgr_Input_Device *last_kbd = NULL;
883 case ECORE_DEVICE_CLASS_MOUSE:
884 return ec->comp_data->last_device_ptr;
885 case ECORE_DEVICE_CLASS_KEYBOARD:
886 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
888 case ECORE_DEVICE_CLASS_TOUCH:
889 return ec->comp_data->last_device_touch;
897 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
901 case ECORE_DEVICE_CLASS_MOUSE:
902 ec->comp_data->last_device_ptr = device;
904 case ECORE_DEVICE_CLASS_KEYBOARD:
905 atomic_store(&ec->comp_data->last_device_kbd, device);
907 case ECORE_DEVICE_CLASS_TOUCH:
908 ec->comp_data->last_device_touch = device;
916 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
918 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
919 struct wl_resource *dev_res;
920 const char *dev_name;
921 Ecore_Device_Class dev_class;
922 struct wl_client *wc;
926 EINA_SAFETY_ON_NULL_RETURN(dev);
929 if (ec->cur_mouse_action || e_comp_wl->drag)
931 if (e_object_is_del(E_OBJECT(ec))) return;
932 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
933 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
934 if (!surface) return;
936 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
937 dev_name = evas_device_description_get(dev);
938 last_device = _e_comp_wl_device_last_device_get(dev_class);
939 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
941 serial = wl_display_next_serial(e_comp_wl->wl.disp);
942 wc = wl_resource_get_client(surface);
943 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
944 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
946 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
947 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
949 _e_comp_wl_device_last_device_set(dev_class, input_dev);
950 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
952 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
954 if (wl_resource_get_client(dev_res) != wc) continue;
955 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
959 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
963 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
965 E_Devicemgr_Input_Device *last_device;
966 struct wl_resource *dev_res;
967 struct wl_client *wc;
971 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
972 if (!surface) return;
974 last_device = _e_comp_wl_device_last_device_get(dev_class);
975 if (!last_device) return;
977 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
979 serial = wl_display_next_serial(e_comp_wl->wl.disp);
980 wc = wl_resource_get_client(surface);
981 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
983 if (wl_resource_get_client(dev_res) != wc) continue;
984 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
989 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
991 E_Devicemgr_Input_Device *input_dev;
992 struct wl_resource *dev_res;
993 const char *dev_name;
996 EINA_SAFETY_ON_NULL_RETURN(dev);
998 dev_name = ecore_device_identifier_get(dev);
1000 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1001 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1003 if (!eina_streq(input_dev->identifier, dev_name) ||
1004 (input_dev->clas != ecore_device_class_get(dev))) continue;
1005 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1007 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1009 if (wl_resource_get_client(dev_res) != wc) continue;
1010 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1013 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1017 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1019 E_Devicemgr_Input_Device *input_dev;
1020 struct wl_resource *dev_res;
1021 const char *dev_name;
1024 EINA_SAFETY_ON_NULL_RETURN(dev);
1026 dev_name = e_device_identifier_get(dev);
1028 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1029 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1031 if (!eina_streq(input_dev->identifier, dev_name) ||
1032 (input_dev->clas != e_device_class_get(dev))) continue;
1033 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1035 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1037 if (wl_resource_get_client(dev_res) != wc) continue;
1038 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1041 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1045 _e_comp_wl_cursor_reload(E_Client *ec)
1047 struct wl_resource *res;
1048 struct wl_client *wc;
1054 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1055 !evas_object_visible_get(e_comp->pointer->o_ptr))
1056 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1059 if (e_object_is_del(E_OBJECT(ec))) return;
1060 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1061 if (!surface) return;
1062 if (ec->pointer_enter_sent) return;
1064 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1065 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1067 if (e_client_transform_core_enable_get(ec))
1069 double dx = 0.0, dy = 0.0;
1070 map = e_client_map_get(ec);
1071 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1077 cx = px - ec->client.x;
1078 cy = py - ec->client.y;
1080 wc = wl_resource_get_client(surface);
1081 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1082 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1084 if (!e_comp_wl_input_pointer_check(res)) continue;
1085 if (wl_resource_get_client(res) != wc) continue;
1086 wl_pointer_send_enter(res, serial, surface,
1087 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1088 ec->pointer_enter_sent = EINA_TRUE;
1090 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1094 _e_comp_wl_cursor_timer(void *data)
1096 E_Client *ec = data;
1098 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1099 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1101 e_comp_wl_cursor_hide(ec);
1103 return ECORE_CALLBACK_CANCEL;
1107 _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)
1109 E_Devicemgr_Input_Device *input_dev;
1110 struct wl_resource *dev_res;
1111 struct wl_client *wc;
1116 if (ec->cur_mouse_action) return;
1117 if (e_object_is_del(E_OBJECT(ec))) return;
1118 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1119 if (!surface) return;
1121 f_value = wl_fixed_from_double(value);
1122 wc = wl_resource_get_client(surface);
1124 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1125 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1127 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1128 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1130 if (wl_resource_get_client(dev_res) != wc) continue;
1131 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1134 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1138 _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)
1140 if (idx >= e_input_touch_max_count_get()) return;
1142 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1143 e_devicemgr->multi[idx].radius_x = radius_x;
1144 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1145 e_devicemgr->multi[idx].radius_y = radius_y;
1146 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1147 e_devicemgr->multi[idx].pressure = pressure;
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;
1153 _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)
1155 if (idx >= e_input_touch_max_count_get()) return;
1157 if (e_devicemgr->multi[idx].radius_x != radius_x)
1159 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1160 e_devicemgr->multi[idx].radius_x = radius_x;
1162 if (e_devicemgr->multi[idx].radius_y != radius_y)
1164 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1165 e_devicemgr->multi[idx].radius_y = radius_y;
1167 if (e_devicemgr->multi[idx].pressure != pressure)
1169 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1170 e_devicemgr->multi[idx].pressure = pressure;
1172 if (e_devicemgr->multi[idx].angle != angle)
1174 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1175 e_devicemgr->multi[idx].angle = angle;
1180 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1182 Eina_Bool ret = EINA_TRUE;
1185 case EVAS_CALLBACK_MOUSE_IN:
1186 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1189 if (e_comp_wl->ptr.hide_tmr)
1191 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1192 cursor_timer_ec = ec;
1193 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1197 if (e_pointer_is_hidden(e_comp->pointer))
1202 case EVAS_CALLBACK_MOUSE_OUT:
1203 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1206 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1210 case EVAS_CALLBACK_MOUSE_MOVE:
1211 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1214 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1215 _e_comp_wl_cursor_reload(ec);
1218 case EVAS_CALLBACK_MOUSE_WHEEL:
1219 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1222 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1223 _e_comp_wl_cursor_reload(ec);
1226 case EVAS_CALLBACK_MOUSE_DOWN:
1227 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1230 if (e_comp_wl->ptr.hide_tmr)
1232 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1233 e_comp_wl->ptr.hide_tmr = NULL;
1235 cursor_timer_ec = NULL;
1237 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1238 _e_comp_wl_cursor_reload(ec);
1241 case EVAS_CALLBACK_MOUSE_UP:
1242 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1253 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1255 if (ec->has_cursor_unset)
1258 if (!e_config->show_cursor)
1261 if (!e_config->use_cursor_timer)
1268 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1271 Evas_Event_Mouse_In *ev;
1272 struct wl_resource *res;
1273 struct wl_client *wc;
1276 E_Comp_Config *comp_conf;
1277 E_Client *prev_ptr_ec;
1281 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1282 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1284 if (!(ec = data)) return;
1285 if (e_object_is_del(E_OBJECT(ec))) return;
1286 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1287 if (!surface) return;
1289 prev_ptr_ec = e_comp_wl->ptr.ec;
1292 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1293 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1296 e_comp_wl->ptr.ec = ec;
1298 comp_conf = e_comp_config_get();
1299 if (comp_conf && comp_conf->input_log_enable)
1300 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1301 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1302 e_client_util_name_get(ec));
1304 if (_e_comp_wl_check_cursor_timer_needed(ec))
1306 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1310 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1311 wc = wl_resource_get_client(surface);
1312 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1313 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1315 if (!e_comp_wl_input_pointer_check(res)) continue;
1316 if (wl_resource_get_client(res) != wc) continue;
1318 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1320 wl_pointer_send_enter(res, serial, surface,
1321 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1322 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1323 ec->pointer_enter_sent = EINA_TRUE;
1326 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1330 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1333 Evas_Event_Mouse_Out *ev;
1334 struct wl_resource *res;
1335 struct wl_client *wc;
1338 Eina_Bool inside_check;
1339 E_Comp_Config *comp_conf;
1343 if (!(ec = data)) return;
1344 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1345 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1346 if (ec->cur_mouse_action && inside_check) return;
1347 if (e_object_is_del(E_OBJECT(e_comp))) return;
1348 if (e_comp_wl->ptr.ec == ec)
1349 e_comp_wl->ptr.ec = NULL;
1350 if (e_object_is_del(E_OBJECT(ec))) return;
1352 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1353 if (!surface) return;
1355 comp_conf = e_comp_config_get();
1356 if (comp_conf && comp_conf->input_log_enable)
1357 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1358 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1359 e_client_util_name_get(ec));
1361 if (_e_comp_wl_check_cursor_timer_needed(ec))
1363 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1367 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1369 wc = wl_resource_get_client(surface);
1370 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1371 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1373 if (!e_comp_wl_input_pointer_check(res)) continue;
1374 if (wl_resource_get_client(res) != wc) continue;
1375 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1377 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1379 wl_pointer_send_leave(res, serial, surface);
1380 ec->pointer_enter_sent = EINA_FALSE;
1385 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1388 struct wl_client *wc;
1389 struct wl_resource *res;
1392 E_Comp_Config *comp_conf = NULL;
1395 if (e_object_is_del(E_OBJECT(ec))) return;
1396 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1397 if (!surface) return;
1399 wc = wl_resource_get_client(surface);
1400 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1404 x = wl_fixed_from_int(canvas_x - ec->client.x);
1405 y = wl_fixed_from_int(canvas_y - ec->client.y);
1408 comp_conf = e_comp_config_get();
1410 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1412 if (wl_resource_get_client(res) != wc) continue;
1413 if (!e_comp_wl_input_touch_check(res)) continue;
1414 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1417 if (comp_conf && comp_conf->input_log_enable)
1418 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));
1420 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1424 if (comp_conf && comp_conf->input_log_enable)
1425 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));
1427 wl_touch_send_up(res, serial, timestamp, idx);
1434 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1437 struct wl_client *wc;
1438 struct wl_resource *res;
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);
1449 x = wl_fixed_from_int(canvas_x - ec->client.x);
1450 y = wl_fixed_from_int(canvas_y - ec->client.y);
1452 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1454 if (wl_resource_get_client(res) != wc) continue;
1455 if (!e_comp_wl_input_touch_check(res)) continue;
1456 wl_touch_send_motion(res, timestamp, idx, x, y);
1461 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1463 struct wl_resource *res;
1464 struct wl_client *wc;
1468 if (ec->cur_mouse_action) return;
1469 if (e_object_is_del(E_OBJECT(ec))) return;
1470 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1471 if (!surface) return;
1473 wc = wl_resource_get_client(surface);
1474 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1476 if (!e_comp_wl_input_pointer_check(res)) continue;
1477 if (wl_resource_get_client(res) != wc) continue;
1478 wl_pointer_send_motion(res, timestamp,
1479 wl_fixed_from_int(x - ec->client.x),
1480 wl_fixed_from_int(y - ec->client.y));
1485 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1487 if (e_comp_wl->ptr.hide_tmr)
1489 if (cursor_timer_ec == ec)
1491 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1492 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1496 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1497 cursor_timer_ec = ec;
1498 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1503 cursor_timer_ec = ec;
1504 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1509 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1512 Evas_Event_Mouse_Move *ev;
1513 Evas_Device *dev = NULL;
1514 const char *dev_name;
1515 E_Comp_Config *comp_conf;
1519 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1520 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1522 if (!(ec = data)) return;
1523 if (e_object_is_del(E_OBJECT(ec))) return;
1524 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1525 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1526 if (!surface) return;
1528 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1531 dev_name = evas_device_description_get(dev);
1533 comp_conf = e_comp_config_get();
1534 if (comp_conf && comp_conf->input_log_enable)
1535 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1536 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1537 e_client_util_name_get(ec), dev_name);
1539 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1541 if (!e_comp_wl->drag_client)
1543 e_comp_wl->touch.faked_ec = ec;
1544 if (e_comp_wl->touch.pressed & (1 << 0))
1546 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1548 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1549 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1550 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1554 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1558 if (!e_comp_wl->drag_client)
1560 if (_e_comp_wl_check_cursor_timer_needed(ec))
1562 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1566 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1567 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1569 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1571 if (_e_comp_wl_check_cursor_timer_needed(ec))
1572 _e_comp_wl_cursor_move_timer_control(ec);
1576 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1581 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1583 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1584 if (e_object_is_del(E_OBJECT(ec))) return;
1585 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1586 if (!surface) return;
1587 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1589 e_comp_wl->ptr.button = BTN_LEFT;
1591 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1595 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1597 E_Client *ec = data;
1598 Evas_Event_Mouse_Down *ev = event;
1599 Evas_Device *dev = NULL;
1600 const Evas_Device *seat_dev;
1601 const char *dev_name, *seat_name;
1602 E_Comp_Config *comp_conf = NULL;
1605 if (e_object_is_del(E_OBJECT(ec))) return;
1608 dev_name = evas_device_description_get(dev);
1610 seat_dev = evas_device_parent_get(dev);
1611 seat_name = evas_device_name_get(seat_dev);
1613 comp_conf = e_comp_config_get();
1614 if (comp_conf && comp_conf->input_log_enable)
1615 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1616 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1617 dev_name, seat_name);
1619 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1621 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1623 e_comp_wl->touch.faked_ec = ec;
1626 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1627 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1628 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1630 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1631 e_comp_wl->touch.pressed |= (1 << 0);
1635 if (_e_comp_wl_check_cursor_timer_needed(ec))
1637 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1641 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1642 WL_POINTER_BUTTON_STATE_PRESSED);
1644 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1647 need_send_released = EINA_TRUE;
1651 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1653 E_Client *ec = data;
1654 Evas_Event_Mouse_Up *ev = event;
1655 Evas_Device *dev = NULL;
1656 const Evas_Device *seat_dev;
1657 const char *dev_name, *seat_name;;
1658 Evas_Event_Flags flags;
1659 E_Comp_Config *comp_conf = NULL;
1662 if (ec->cur_mouse_action) return;
1663 if (e_object_is_del(E_OBJECT(ec))) return;
1665 if (!need_send_released)
1667 need_send_motion = EINA_TRUE;
1671 dev_name = evas_device_description_get(dev);
1673 seat_dev = evas_device_parent_get(dev);
1674 seat_name = evas_device_name_get(seat_dev);
1675 flags = evas_event_default_flags_get(evas);
1677 comp_conf = e_comp_config_get();
1678 if (comp_conf && comp_conf->input_log_enable)
1679 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1680 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1681 dev_name, seat_name);
1683 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1685 e_comp_wl->touch.pressed &= ~(1 << 0);
1687 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1688 e_comp_wl->touch.faked_ec = NULL;
1691 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1693 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1695 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1698 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1699 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1700 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1704 if (_e_comp_wl_check_cursor_timer_needed(ec))
1706 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1710 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1711 WL_POINTER_BUTTON_STATE_RELEASED);
1713 if (_e_comp_wl_check_cursor_timer_needed(ec))
1714 _e_comp_wl_cursor_move_timer_control(ec);
1718 need_send_released = EINA_FALSE;
1722 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1724 struct wl_resource *res;
1725 struct wl_client *wc;
1730 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1732 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1735 dir = -wl_fixed_from_int(abs(z));
1737 dir = wl_fixed_from_int(z);
1740 if (e_object_is_del(E_OBJECT(ec))) return;
1741 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1742 if (!surface) return;
1744 wc = wl_resource_get_client(surface);
1745 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1747 if (!e_comp_wl_input_pointer_check(res)) continue;
1748 if (wl_resource_get_client(res) != wc) continue;
1749 wl_pointer_send_axis(res, timestamp, axis, dir);
1754 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1757 Evas_Event_Mouse_Wheel *ev;
1760 if (!(ec = data)) return;
1761 if (ec->cur_mouse_action) return;
1762 if (e_object_is_del(E_OBJECT(ec))) return;
1763 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1764 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1765 if (!surface) return;
1767 if (!eina_list_count(e_comp_wl->ptr.resources))
1770 if (_e_comp_wl_check_cursor_timer_needed(ec))
1772 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1776 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1778 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1780 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1782 if (_e_comp_wl_check_cursor_timer_needed(ec))
1783 _e_comp_wl_cursor_move_timer_control(ec);
1788 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1790 E_Client *ec = data;
1791 Evas_Event_Multi_Down *ev = event;
1792 Evas_Device *dev = NULL;
1793 const Evas_Device *seat_dev;
1794 const char *dev_name, *seat_name;
1795 Evas_Device_Class dev_class;
1796 E_Comp_Config *comp_conf = NULL;
1799 if (e_object_is_del(E_OBJECT(ec))) return;
1800 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1801 if (!surface) return;
1803 /* Do not deliver emulated single touch events to client */
1804 if (ev->device == 0) return;
1807 dev_name = evas_device_description_get(dev);
1808 e_comp_wl->touch.faked_ec = ec;
1810 seat_dev = evas_device_parent_get(dev);
1811 seat_name = evas_device_name_get(seat_dev);
1813 comp_conf = e_comp_config_get();
1814 if (comp_conf && comp_conf->input_log_enable)
1815 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1816 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1817 dev_name, seat_name);
1819 if (dev && dev_name)
1821 dev_class = evas_device_class_get(dev);
1822 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1823 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1826 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1827 e_comp_wl->touch.pressed |= (1 << ev->device);
1831 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1833 E_Client *ec = data;
1834 Evas_Event_Multi_Up *ev = event;
1835 Evas_Device *dev = NULL;
1836 const Evas_Device *seat_dev;
1837 const char *dev_name, *seat_name;
1838 Evas_Device_Class dev_class;
1839 Evas_Event_Flags flags;
1840 E_Comp_Config *comp_conf = NULL;
1843 if (e_object_is_del(E_OBJECT(ec))) return;
1844 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1845 if (!surface) return;
1847 /* Do not deliver emulated single touch events to client */
1848 if (ev->device == 0) return;
1850 flags = evas_event_default_flags_get(evas);
1852 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1853 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1854 e_comp_wl->touch.faked_ec = NULL;
1856 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1859 dev_name = evas_device_description_get(dev);
1861 seat_dev = evas_device_parent_get(dev);
1862 seat_name = evas_device_name_get(seat_dev);
1864 comp_conf = e_comp_config_get();
1865 if (comp_conf && comp_conf->input_log_enable)
1866 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1867 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1868 dev_name, seat_name);
1870 if (dev && dev_name)
1872 dev_class = evas_device_class_get(dev);
1873 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1874 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1877 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1881 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1883 E_Client *ec = data;
1884 Evas_Event_Multi_Move *ev = event;
1885 Evas_Device *dev = NULL;
1886 const char *dev_name;
1887 Evas_Device_Class dev_class;
1890 if (e_object_is_del(E_OBJECT(ec))) return;
1891 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1892 if (!surface) return;
1894 /* Do not deliver emulated single touch events to client */
1895 if (ev->device == 0) return;
1897 e_comp_wl->touch.faked_ec = ec;
1899 if (e_comp_wl->touch.pressed & (1 << ev->device))
1902 if (dev && (dev_name = evas_device_description_get(dev)))
1904 dev_class = evas_device_class_get(dev);
1905 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1906 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1909 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1914 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1917 char *file, buff[PATH_MAX];
1924 n = (getpriority(PRIO_PROCESS, pid) + adj);
1928 setpriority(PRIO_PROCESS, pid, n);
1931 use_adj = EINA_TRUE;
1933 if (!do_child) return;
1935 files = ecore_file_ls("/proc");
1936 EINA_LIST_FREE(files, file)
1938 if (!isdigit(file[0]))
1941 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1942 if ((f = fopen(buff, "r")))
1946 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1948 if (num_read == 2 && ppid == pid)
1949 _e_comp_wl_client_priority_adjust(pid2, set,
1951 adj_child, do_child);
1959 _e_comp_wl_client_priority_raise(E_Client *ec)
1961 if (!e_config->priority_control) return;
1962 if (ec->netwm.pid <= 0) return;
1963 if (ec->netwm.pid == getpid()) return;
1964 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1965 e_config->priority - 1, -1,
1966 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1970 _e_comp_wl_client_priority_normal(E_Client *ec)
1972 if (!e_config->priority_control) return;
1973 if (ec->netwm.pid <= 0) return;
1974 if (ec->netwm.pid == getpid()) return;
1975 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1976 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1980 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1983 E_Comp_Wl_Key_Data *k;
1984 struct wl_resource *res;
1988 if (!ec) return EINA_FALSE;
1989 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1990 if (!ec->comp_data) return EINA_FALSE;
1992 ec->comp_data->on_focus_timer = NULL;
1993 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1994 if (!e_comp_wl->kbd.focused)
1996 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1999 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2001 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2002 t = ecore_time_unix_get();
2004 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2005 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2006 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2008 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2010 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2011 wl_keyboard_send_key(res, serial, t,
2012 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2015 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2016 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2020 /* It is called in the following cases:
2021 * When a normal ec->frame has focus.
2022 * Or launching image ec is replaced to the real ec.
2025 e_comp_wl_feed_focus_in(E_Client *ec)
2028 struct wl_resource *res;
2029 struct wl_client *wc;
2033 if (e_object_is_del(E_OBJECT(ec))) return;
2034 if (ec->iconic) return;
2036 /* block spurious focus events */
2037 focused = e_client_focused_get();
2038 if ((focused) && (ec != focused)) return;
2040 /* raise client priority */
2041 _e_comp_wl_client_priority_raise(ec);
2042 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2043 if (!surface) return;
2045 wc = wl_resource_get_client(surface);
2047 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2048 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2050 if (wl_resource_get_client(res) == wc)
2052 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2053 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2054 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2055 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2058 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2060 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2061 if (!e_comp_wl->kbd.focused)
2063 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2066 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2068 e_comp_wl->kbd.focus = surface;
2069 e_comp_wl_input_keyboard_enter_send(ec);
2070 e_comp_wl_data_device_keyboard_focus_set();
2071 ec->comp_data->on_focus_timer =
2072 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2073 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2074 int rotation = ec->e.state.rot.ang.curr;
2075 e_pointer_rotation_set(e_comp->pointer, rotation);
2079 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2082 if (!(ec = data)) return;
2083 e_comp_wl_feed_focus_in(ec);
2087 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2090 struct wl_resource *res;
2092 E_Comp_Wl_Key_Data *k;
2096 if (!(ec = data)) return;
2098 if (!ec->comp_data) return;
2100 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2102 /* lower client priority */
2103 if (!e_object_is_del(data))
2104 _e_comp_wl_client_priority_normal(ec);
2107 /* update keyboard modifier state */
2108 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2109 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2110 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2112 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2114 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2115 if (!surface) return;
2117 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2118 if (!eina_list_count(e_comp_wl->kbd.resources))
2120 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2124 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2126 /* send keyboard_leave to all keyboard resources */
2127 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2128 t = ecore_time_unix_get();
2130 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2131 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2132 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2134 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2136 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2137 wl_keyboard_send_key(res, serial, t,
2138 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2140 wl_keyboard_send_leave(res, serial, surface);
2141 e_comp_wl->kbd.focused =
2142 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2144 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2145 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2149 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2153 if (!(ec = data)) return;
2155 if (!ec->comp_data->shell.configure_send) return;
2157 /* TODO: calculate x, y with transfrom object */
2158 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2162 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2163 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2164 if (e_comp_object_frame_exists(ec->frame))
2165 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2167 switch (ec->resize_mode)
2169 case E_POINTER_RESIZE_TL:
2170 case E_POINTER_RESIZE_L:
2171 case E_POINTER_RESIZE_BL:
2172 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2173 ec->mouse.current.mx;
2175 case E_POINTER_RESIZE_TR:
2176 case E_POINTER_RESIZE_R:
2177 case E_POINTER_RESIZE_BR:
2178 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2183 switch (ec->resize_mode)
2185 case E_POINTER_RESIZE_TL:
2186 case E_POINTER_RESIZE_T:
2187 case E_POINTER_RESIZE_TR:
2188 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2189 ec->mouse.current.my;
2191 case E_POINTER_RESIZE_BL:
2192 case E_POINTER_RESIZE_B:
2193 case E_POINTER_RESIZE_BR:
2194 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2199 w = E_CLAMP(w, 1, w);
2200 h = E_CLAMP(h, 1, h);
2201 e_client_resize_limit(ec, &w, &h);
2203 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2205 else if ((!ec->fullscreen) && (!ec->maximized) &&
2206 (!ec->comp_data->maximize_pre))
2210 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2211 if ((pw != ec->w) || (ph != ec->h))
2213 _e_comp_wl_configure_send(ec, 1, 1);
2217 if (ec->comp_data->sub.below_obj)
2218 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2222 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2224 E_Client *ec = data;
2226 ec->comp_data->maximize_pre = 1;
2230 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2232 E_Client *ec = data;
2235 if (e_object_is_del(E_OBJECT(ec))) return;
2237 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2238 e_client_shell_configure_send(ec, 0, w, h);
2240 ec->comp_data->maximize_pre = 0;
2244 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2246 E_Client *ec = data;
2248 ec->comp_data->maximize_pre = 1;
2252 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2254 E_Client *ec = data;
2256 if (e_object_is_del(E_OBJECT(ec))) return;
2258 /* check for wayland pixmap */
2260 if (ec->comp_data->shell.configure_send)
2261 _e_comp_wl_configure_send(ec, 0, 0);
2263 ec->comp_data->maximize_pre = 0;
2267 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2269 E_Client *ec = data;
2271 if (e_object_is_del(E_OBJECT(ec))) return;
2273 /* check for wayland pixmap */
2275 if (ec->comp_data->shell.configure_send)
2276 _e_comp_wl_configure_send(ec, 0, 1);
2278 ec->comp_data->maximize_pre = 0;
2282 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2284 E_Client *ec = data;
2286 if (e_object_is_del(E_OBJECT(ec))) return;
2288 /* check for wayland pixmap */
2290 if (ec->comp_data->shell.configure_send)
2291 _e_comp_wl_configure_send(ec, 0, 0);
2293 ec->comp_data->maximize_pre = 0;
2297 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2301 if (!(ec = data)) return;
2303 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2305 e_object_del(E_OBJECT(ec));
2307 _e_comp_wl_focus_check();
2309 /* TODO: Delete request send ??
2310 * NB: No such animal wrt wayland */
2314 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2318 if (!(ec = data)) return;
2320 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2323 if (ec->comp_data->reparented)
2324 e_client_comp_hidden_set(ec, EINA_TRUE);
2327 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2328 if (ec->visible) evas_object_hide(ec->frame);
2329 if (!ec->internal) e_object_del(E_OBJECT(ec));
2331 _e_comp_wl_focus_check();
2335 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2339 if (!(ec = data)) return;
2341 e_client_shell_ping(ec);
2345 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2350 if (!(ec = data)) return;
2351 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2352 if (ec->netwm.opacity == a) return;
2353 ec->netwm.opacity = a;
2354 ec->netwm.opacity_changed = EINA_TRUE;
2358 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2360 Eina_Rectangle *damage_rect = NULL;
2361 Eina_Rectangle *dmg = NULL;
2362 Eina_List *l = NULL;
2364 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2365 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2368 if (!buffer->tbm_surface) return;
2372 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2376 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2377 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2380 eina_rectangle_union(damage_rect, dmg);
2385 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2386 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2389 tbm_surface_internal_set_damage(buffer->tbm_surface,
2395 eina_rectangle_free(damage_rect);
2399 _e_comp_wl_client_evas_init(E_Client *ec)
2401 if (!ec || !ec->comp_data) return;
2402 if (ec->comp_data->evas_init) return;
2404 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2405 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2406 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2409 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2410 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2411 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2412 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2413 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2414 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2416 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2417 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2418 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2420 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2421 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2425 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2426 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2427 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2428 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2429 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2430 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2431 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2434 /* setup delete/kill callbacks */
2435 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2436 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2438 /* setup ping callback */
2439 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2440 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2442 ec->comp_data->evas_init = EINA_TRUE;
2446 _e_comp_wl_client_evas_deinit(E_Client *ec)
2448 if (!ec || !ec->comp_data) return;
2449 if (!ec->comp_data->evas_init) return;
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2453 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2455 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2456 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2457 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2458 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2459 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2460 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2462 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2463 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2464 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2466 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2467 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2471 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2472 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2473 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2474 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2475 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2476 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2477 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2480 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2481 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2483 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2484 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2486 ec->comp_data->evas_init = EINA_FALSE;
2490 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2494 E_Comp_Screen *e_comp_screen;
2495 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2497 if (!e_comp) return ECORE_CALLBACK_RENEW;
2498 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2499 e_comp_screen = e_comp->e_comp_screen;
2501 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2503 if (!eout->config.enabled)
2505 e_comp_wl_output_remove(eout->id);
2509 switch (eout->config.rotation)
2512 transform = WL_OUTPUT_TRANSFORM_90;
2515 transform = WL_OUTPUT_TRANSFORM_180;
2518 transform = WL_OUTPUT_TRANSFORM_270;
2522 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2526 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2528 eout->config.geom.x, eout->config.geom.y,
2529 eout->config.geom.w, eout->config.geom.h,
2530 eout->info.size.w, eout->info.size.h,
2531 eout->config.mode.refresh, 0, transform))
2532 ERR("Could not initialize screen %s", eout->info.name);
2535 return ECORE_CALLBACK_RENEW;
2539 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2543 /* try to get the client from the object */
2544 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2545 return ECORE_CALLBACK_RENEW;
2547 /* check for client being deleted */
2548 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2550 /* check for wayland pixmap */
2551 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2552 return ECORE_CALLBACK_RENEW;
2554 /* if we have not setup evas callbacks for this client, do it */
2555 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2557 return ECORE_CALLBACK_RENEW;
2561 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2565 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2566 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2568 if (e_comp_wl->selection.target &&
2571 struct wl_resource *res;
2573 E_Client *ec = NULL;
2574 E_Client *legacy_target = e_comp_wl->selection.target;
2575 int device_id = e_comp_wl_data_current_device_id_get();
2579 e_comp_wl_data_current_device_id_set(ev->multi.device);
2581 else if (device_id != ev->multi.device)
2583 return ECORE_CALLBACK_RENEW;
2586 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2587 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2589 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2590 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2592 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2593 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2595 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2596 (ec != legacy_target))
2598 e_comp_wl_data_device_send_leave(legacy_target);
2599 e_comp_wl_data_device_send_enter(ec);
2602 if (e_comp_wl->drag)
2603 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2605 if (e_client_transform_core_enable_get(ec))
2607 int trans_x, trans_y;
2608 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2609 x = trans_x - ec->client.x;
2610 y = trans_y - ec->client.y;
2614 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2619 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2622 return ECORE_CALLBACK_RENEW;
2626 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2629 struct wl_resource *surface;
2630 struct wl_resource *res;
2631 struct wl_client *wc;
2633 E_Comp_Config *comp_conf;
2635 ec = e_comp_wl->ptr_constraints.ec;
2636 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2638 surface = e_comp_wl_client_surface_get(ec);
2639 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2641 wc = wl_resource_get_client(surface);
2643 comp_conf = e_comp_config_get();
2645 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2647 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2648 if (wl_resource_get_client(res) != wc) continue;
2650 if (comp_conf && comp_conf->input_log_enable)
2651 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2652 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2653 e_client_util_name_get(ec));
2655 zwp_relative_pointer_v1_send_relative_motion(res,
2657 (uint32_t)(ev->timestamp),
2658 wl_fixed_from_int(ev->dx),
2659 wl_fixed_from_int(ev->dy),
2660 wl_fixed_from_int(ev->dx_unaccel),
2661 wl_fixed_from_int(ev->dy_unaccel));
2664 return ECORE_CALLBACK_DONE;
2668 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2670 _e_comp_wl_touch_cancel();
2672 return ECORE_CALLBACK_PASS_ON;
2676 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2678 if (!ev) return ECORE_CALLBACK_PASS_ON;
2680 E_Zone *zone = ev->zone;
2682 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2683 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2685 if (!e_zone_is_displaying(zone))
2686 _e_comp_wl_touch_cancel();
2688 return ECORE_CALLBACK_PASS_ON;
2692 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2694 E_Client *ec = ev->ec;
2695 E_Comp_Wl_Buffer_Viewport *vp;
2697 if (!ec) return ECORE_CALLBACK_PASS_ON;
2698 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2699 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2700 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2701 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2703 vp = &ec->comp_data->scaler.buffer_viewport;
2704 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2706 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2708 return ECORE_CALLBACK_PASS_ON;
2712 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2714 E_Client *ec = ev->ec;
2715 E_Comp_Wl_Buffer_Viewport *vp;
2717 if (!ec) return ECORE_CALLBACK_PASS_ON;
2718 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2719 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2720 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2722 vp = &ec->comp_data->scaler.buffer_viewport;
2723 vp->wait_for_transform_change = 0;
2725 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2727 return ECORE_CALLBACK_PASS_ON;
2731 _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)
2733 E_Client *focused_ec;
2736 focused_ec = e_client_focused_get();
2737 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2739 rotation = focused_ec->e.state.rot.ang.curr;
2740 e_pointer_rotation_set(e_comp->pointer, rotation);
2742 return ECORE_CALLBACK_PASS_ON;
2746 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2749 Eina_Rectangle *window;
2754 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2756 if ((prev_w != state->bw) ||
2757 (prev_h != state->bh))
2759 ec->changes.buf_size = EINA_TRUE;
2762 if (e_comp_object_frame_exists(ec->frame)) return;
2763 window = &ec->comp_data->shell.window;
2764 if ((!ec->borderless) && /* FIXME temporarily added this check code
2765 * to prevent updating E_Client's size by frame */
2766 (window->x || window->y || window->w || window->h))
2768 e_comp_object_frame_geometry_set(ec->frame,
2770 (window->x + window->w) - state->bw,
2772 (window->y + window->h) - state->bh);
2775 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2779 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2781 E_Comp_Wl_Surface_State *state;
2784 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2785 state->buffer = NULL;
2789 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2791 state->new_attach = EINA_FALSE;
2792 state->buffer = NULL;
2793 state->buffer_destroy_listener.notify =
2794 _e_comp_wl_surface_state_cb_buffer_destroy;
2795 state->sx = state->sy = 0;
2797 state->input = eina_tiler_new(w, h);
2798 eina_tiler_tile_size_set(state->input, 1, 1);
2800 state->opaque = eina_tiler_new(w, h);
2801 eina_tiler_tile_size_set(state->opaque, 1, 1);
2803 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2804 state->buffer_viewport.buffer.scale = 1;
2805 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2806 state->buffer_viewport.surface.width = -1;
2807 state->buffer_viewport.changed = 0;
2809 e_presentation_time_container_init(&state->presentation_container);
2813 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2815 struct wl_resource *cb;
2816 Eina_Rectangle *dmg;
2818 EINA_LIST_FREE(state->frames, cb)
2819 wl_resource_destroy(cb);
2821 EINA_LIST_FREE(state->damages, dmg)
2822 eina_rectangle_free(dmg);
2824 EINA_LIST_FREE(state->buffer_damages, dmg)
2825 eina_rectangle_free(dmg);
2827 if (state->opaque) eina_tiler_free(state->opaque);
2828 state->opaque = NULL;
2830 if (state->input) eina_tiler_free(state->input);
2831 state->input = NULL;
2833 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2834 state->buffer = NULL;
2836 e_presentation_time_container_finish(&state->presentation_container);
2840 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2842 if (state->buffer == buffer) return;
2844 wl_list_remove(&state->buffer_destroy_listener.link);
2845 state->buffer = buffer;
2847 wl_signal_add(&state->buffer->destroy_signal,
2848 &state->buffer_destroy_listener);
2852 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2854 Eina_Rectangle *dmg;
2855 Eina_Bool placed = EINA_TRUE;
2859 E_Comp_Wl_Buffer *buffer;
2860 struct wl_resource *cb;
2862 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2863 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2868 if ((ec->internal) ||
2869 (cdata->shell.surface && state->new_attach))
2873 e_comp->new_clients++;
2874 ELOGF("COMP", "Unignore", ec);
2875 e_client_unignore(ec);
2879 /* buffer transform */
2880 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2883 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2885 /* when buffer is transformed, we have to apply the new evas-map */
2886 state->buffer_viewport.changed = EINA_TRUE;
2888 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2890 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2892 if (transform_change == vp->wait_for_transform_change)
2893 vp->wait_for_transform_change = 0;
2895 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2896 // triggered by E_CLIENT_HOOK calls at those file.
2897 zone = e_comp_zone_find_by_ec(ec);
2900 eout = e_output_find(zone->output_id);
2901 if (eout && eout->hwc)
2903 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2905 if (e_comp_is_on_overlay(ec))
2906 e_comp_hwc_client_end(ec, __FUNCTION__);
2912 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2913 cdata->scaler.buffer_viewport = state->buffer_viewport;
2915 if (state->new_attach)
2917 e_comp_wl_surface_attach(ec, state->buffer);
2920 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2921 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2923 _e_comp_wl_surface_state_buffer_set(state, NULL);
2925 if ((state->new_attach) ||
2926 (state->buffer_viewport.changed))
2928 _e_comp_wl_surface_state_size_update(ec, state);
2929 e_comp_wl_map_size_cal_from_viewport(ec);
2931 /* update the position */
2932 if (ec->changes.pos)
2934 e_comp_object_frame_xy_unadjust(ec->frame,
2944 if (ec->new_client) placed = ec->placed;
2946 if (!ec->lock_client_size)
2951 ec->client.w = state->bw;
2952 ec->client.h = state->bh;
2954 e_comp_object_frame_wh_adjust(ec->frame,
2955 ec->client.w, ec->client.h,
2957 e_client_size_set(ec, nw, nh);
2959 if ((w != ec->w) || (h != ec->h))
2961 ec->changes.size = 1;
2966 if (ec->changes.buf_size)
2968 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2969 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2970 ec->changes.buf_size = EINA_FALSE;
2972 if (ec->move_after_resize)
2974 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2975 ec->move_after_resize = EINA_FALSE;
2980 /* map or unmap ec */
2981 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2982 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2983 if (!pixmap_usable || hide_by_request)
2988 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2993 if ((cdata->sub.below_obj) &&
2994 (evas_object_visible_get(cdata->sub.below_obj)))
2996 evas_object_hide(cdata->sub.below_obj);
3004 if ((cdata->sub.below_obj) &&
3005 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3006 (evas_object_visible_get(ec->frame)))
3008 evas_object_show(cdata->sub.below_obj);
3012 if ((state->new_attach) ||
3013 (state->buffer_viewport.changed))
3015 if ((e_comp_wl->drag) &&
3016 (e_comp_wl->drag_client) &&
3017 (e_comp_wl->drag_client == ec))
3019 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3021 e_drag_move(e_comp_wl->drag,
3023 e_comp_wl->drag->y);
3025 e_drag_resize(e_comp_wl->drag,
3026 state->bw, state->bh);
3028 else if ((cdata->shell.surface) &&
3029 (cdata->shell.configure))
3031 e_comp_wl_commit_sync_configure(ec);
3033 else if (!e_client_video_hw_composition_check(ec))
3035 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3040 ec->placed = placed;
3041 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3045 if (cdata->scaler.buffer_viewport.changed)
3046 e_comp_wl_map_apply(ec);
3048 /* resize transform object */
3049 if (ec->transformed)
3050 e_client_transform_update(ec);
3054 state->new_attach = EINA_FALSE;
3056 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3058 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3059 wl_resource_destroy(cb);
3062 /* insert state frame callbacks into comp_data->frames
3063 * NB: This clears state->frames list */
3064 cdata->frames = eina_list_merge(cdata->frames,
3066 state->frames = NULL;
3068 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3069 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3070 &state->presentation_container);
3072 buffer = e_pixmap_resource_get(ec->pixmap);
3074 /* put state damages into surface */
3077 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3078 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3080 if ((cdata->buffer_ref.buffer) &&
3081 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3082 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3084 e_comp_object_damage(ec->frame,
3086 cdata->buffer_ref.buffer->w,
3087 cdata->buffer_ref.buffer->h);
3092 Eina_List *damages = NULL;
3095 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3097 if (eina_list_count(state->buffer_damages))
3099 EINA_LIST_FREE(state->buffer_damages, dmg)
3102 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3103 e_comp_wl_output_buffer_transform_get(ec),
3105 dmg->x, dmg->y, dmg->w, dmg->h,
3106 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3107 damages = eina_list_append(damages, dmg);
3111 EINA_LIST_FREE(state->damages, dmg)
3112 damages = eina_list_append(damages, dmg);
3114 EINA_LIST_FREE(damages, dmg)
3116 /* not creating damage for ec that shows a underlay video */
3117 if (state->buffer_viewport.changed ||
3118 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3119 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3120 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3122 eina_rectangle_free(dmg);
3127 /* put state opaque into surface */
3128 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3131 Eina_Rectangle *rect;
3134 itr = eina_tiler_iterator_new(state->opaque);
3135 EINA_ITERATOR_FOREACH(itr, rect)
3139 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3140 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3141 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3145 eina_iterator_free(itr);
3148 /* put state input into surface */
3149 if ((state->input) &&
3150 (!eina_tiler_empty(state->input)) &&
3153 Eina_Tiler *src, *tmp;
3157 tmp = eina_tiler_new(sw, sh);
3158 eina_tiler_tile_size_set(tmp, 1, 1);
3160 eina_tiler_rect_add(tmp,
3161 &(Eina_Rectangle){0, 0, sw, sh});
3163 if ((src = eina_tiler_intersection(state->input, tmp)))
3165 Eina_Rectangle *rect;
3168 e_comp_object_input_objs_del(ec->frame);
3169 itr = eina_tiler_iterator_new(src);
3170 EINA_ITERATOR_FOREACH(itr, rect)
3172 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3173 ec, rect->x, rect->y, rect->w, rect->h,
3174 ec->w, ec->h, state->bw, state->bh);
3175 e_comp_object_input_area_set(ec->frame,
3180 eina_iterator_free(itr);
3181 eina_tiler_free(src);
3184 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3186 eina_tiler_free(tmp);
3188 /* clear input tiler */
3189 eina_tiler_clear(state->input);
3192 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3194 if ((cdata->video_client) &&
3196 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3197 (e_comp->wl_comp_data->available_hw_accel.underlay))
3199 e_pixmap_image_clear(ec->pixmap, 1);
3202 state->buffer_viewport.changed = 0;
3204 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3207 ec->exp_iconify.buffer_flush &&
3208 e_policy_visibility_client_is_iconic(ec))
3210 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3215 _e_comp_wl_surface_render_stop(E_Client *ec)
3217 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3218 //if ((!ec->internal) && (!e_comp_gl_get()))
3221 /* check if internal animation is running */
3222 if (e_comp_object_is_animating(ec->frame)) return;
3223 /* check if external animation is running */
3224 if (evas_object_data_get(ec->frame, "effect_running")) return;
3226 evas_object_hide(ec->frame);
3230 e_comp_wl_client_surface_finish(E_Client *ec)
3232 struct wl_resource *res, *surface;
3233 struct wl_client *surface_client = NULL;
3236 surface = e_comp_wl_client_surface_get(ec);
3239 surface_client = wl_resource_get_client(surface);
3241 if (surface_client &&
3242 (ec == e_client_focused_get()))
3244 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3245 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3247 if (wl_resource_get_client(res) ==
3249 e_comp_wl->kbd.focused =
3250 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3254 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3257 e_comp_wl_client_surface_set(ec, NULL);
3259 ec->comp_data->wl_surface = NULL;
3260 e_pixmap_win_id_del(ec->pixmap);
3262 _e_comp_wl_surface_render_stop(ec);
3263 e_object_del(E_OBJECT(ec));
3267 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3272 char proc[512], pname[512];
3275 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3277 h = fopen(proc, "r");
3280 len = fread(pname, sizeof(char), 512, h);
3282 pname[len - 1] = '\0';
3284 strncpy(pname, "NO NAME", sizeof(pname));
3290 strncpy(pname, "NO NAME", sizeof(pname));
3293 strncpy(name, pname, size);
3297 _e_comp_wl_pname_print(pid_t pid)
3300 char proc[512], pname[512];
3303 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3305 h = fopen(proc, "r");
3308 len = fread(pname, sizeof(char), 512, h);
3310 pname[len - 1] = '\0';
3312 strncpy(pname, "NO NAME", sizeof(pname));
3316 ELOGF("COMP", " |%s", NULL, pname);
3321 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3323 struct wl_client *client = data;
3324 E_Comp_Connected_Client_Info *cinfo;
3327 cinfo = wl_container_of(listener, cinfo, destroy);
3329 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3330 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3332 eai = e_appinfo_find_with_pid(cinfo->pid);
3333 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3336 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3338 wl_list_remove(&cinfo->destroy.link);
3339 eina_stringshare_del(cinfo->name);
3344 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3346 E_Comp_Connected_Client_Info *cinfo;
3348 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3349 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3351 cinfo->name = eina_stringshare_add(name);
3355 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3356 wl_client_add_destroy_listener(client, &cinfo->destroy);
3357 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3359 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3363 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3365 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3367 /* send configure */
3368 if (ec->comp_data->shell.configure_send)
3370 if (ec->comp_data->shell.surface)
3371 _e_comp_wl_configure_send(ec, 0, 0);
3374 e_comp_wl->kbd.focus = ec->comp_data->surface;
3378 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3380 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3382 /* send configure */
3383 if (ec->comp_data->shell.configure_send)
3385 if (ec->comp_data->shell.surface)
3386 _e_comp_wl_configure_send(ec, 0, 0);
3389 _e_comp_wl_focus_check();
3391 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3392 e_comp_wl->kbd.focus = NULL;
3396 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3398 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3399 if (ec->keyboard_resizing) return;
3401 /* do nothing currently */
3406 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3408 if (e_object_is_del(E_OBJECT(ec))) return;
3409 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3411 e_comp_wl->resize.edges = 0;
3412 e_comp_wl->resize.resource = NULL;
3416 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3418 if (e_object_is_del(E_OBJECT(ec))) return;
3419 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3423 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3426 int ratio_w, ratio_h;
3428 phys_w = output->phys_width;
3429 phys_h = output->phys_height;
3431 if (e_config->configured_output_resolution.use)
3433 // change the configured physical size(mm) of the output
3434 if (output->w != res_w)
3436 ratio_w = res_w / output->w;
3437 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3440 if (output->h != res_h)
3442 ratio_h = res_h / output->h;
3443 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3446 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3449 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3450 NULL, res_w, res_h, phys_w, phys_h, pid);
3452 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3453 wl_output_send_scale(resource, output->scale);
3455 wl_output_send_geometry(resource, output->x, output->y,
3457 output->subpixel, output->make ?: "",
3458 output->model ?: "", output->transform);
3460 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3461 res_w, res_h, output->refresh);
3463 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3464 wl_output_send_done(resource);
3468 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3470 E_Comp_Wl_Output *output;
3472 if (!(output = wl_resource_get_user_data(resource))) return;
3474 output->resources = eina_list_remove(output->resources, resource);
3478 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3480 E_Comp_Wl_Output *output;
3481 struct wl_resource *resource;
3482 E_Appinfo *eai = NULL;
3486 if (!(output = data)) return;
3489 wl_resource_create(client, &wl_output_interface, version, id);
3492 wl_client_post_no_memory(client);
3496 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3497 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3499 output->resources = eina_list_append(output->resources, resource);
3501 wl_resource_set_implementation(resource, NULL, output,
3502 _e_comp_wl_cb_output_unbind);
3503 wl_resource_set_user_data(resource, output);
3505 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3506 if (e_config->configured_output_resolution.use)
3508 wl_client_get_credentials(client, &pid, NULL, NULL);
3511 res_w = e_config->configured_output_resolution.w;
3512 res_h = e_config->configured_output_resolution.h;
3516 eai = e_appinfo_find_with_pid(pid);
3519 res_w = e_config->configured_output_resolution.w;
3520 res_h = e_config->configured_output_resolution.h;
3524 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3526 res_w = e_config->configured_output_resolution.w;
3527 res_h = e_config->configured_output_resolution.h;
3531 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3540 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3544 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3547 Evas_GL *evasgl = NULL;
3548 Evas_GL_API *glapi = NULL;
3549 Evas_GL_Context *ctx = NULL;
3550 Evas_GL_Surface *sfc = NULL;
3551 Evas_GL_Config *cfg = NULL;
3553 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3555 if (!e_comp_gl_get()) return;
3557 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3558 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3560 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3561 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3563 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3564 * then we should get evas from ecore_evas.
3567 evas = e_comp->evas;
3569 evas = ecore_evas_get(e_comp->ee);
3571 evasgl = evas_gl_new(evas);
3572 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3574 glapi = evas_gl_api_get(evasgl);
3575 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3576 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3578 cfg = evas_gl_config_new();
3579 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3581 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3582 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3584 ctx = evas_gl_context_create(evasgl, NULL);
3585 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3587 res = evas_gl_make_current(evasgl, sfc, ctx);
3588 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3590 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3591 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3593 evas_gl_config_free(cfg);
3595 evas_gl->gl = evasgl;
3596 evas_gl->glapi = glapi;
3597 evas_gl->glsfc = sfc;
3598 evas_gl->glctx = ctx;
3600 e_comp_wl->evas_gl = evas_gl;
3602 /* for native surface */
3605 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3610 evas_gl_config_free(cfg);
3611 evas_gl_make_current(evasgl, NULL, NULL);
3612 evas_gl_context_destroy(evasgl, ctx);
3613 evas_gl_surface_destroy(evasgl, sfc);
3614 evas_gl_free(evasgl);
3621 _e_comp_wl_gl_popup_cb_close(void *data,
3622 Evas_Object *obj EINA_UNUSED,
3623 void *event_info EINA_UNUSED)
3625 evas_object_del(data);
3629 _e_comp_wl_gl_popup_cb_focus(void *data,
3630 Evas_Object *obj EINA_UNUSED,
3631 void *event_info EINA_UNUSED)
3633 elm_object_focus_set(data, EINA_TRUE);
3638 _e_comp_wl_gl_idle(void *data)
3642 /* show warning window to notify failure of gl init */
3645 Evas_Object *win, *bg, *popup, *btn;
3647 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3648 elm_win_title_set(win, "Compositor Warning");
3649 elm_win_autodel_set(win, EINA_TRUE);
3650 elm_win_borderless_set(win, EINA_TRUE);
3651 elm_win_role_set(win, "notification-low");
3652 elm_win_alpha_set(win, EINA_TRUE);
3654 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3655 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3656 elm_win_resize_object_add(win, bg);
3657 evas_object_color_set(bg, 125, 125, 125, 125);
3658 evas_object_show(bg);
3660 popup = elm_popup_add(win);
3661 elm_object_text_set(popup,
3662 _( "Your screen does not support OpenGL.<br>"
3663 "Falling back to software engine."));
3664 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3666 btn = elm_button_add(popup);
3667 elm_object_text_set(btn, "Close");
3668 elm_object_part_content_set(popup, "button1", btn);
3669 evas_object_show(btn);
3671 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3672 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3674 evas_object_show(popup);
3675 evas_object_show(win);
3679 return ECORE_CALLBACK_CANCEL;
3683 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3685 struct wl_client *client = data;
3691 wl_client_get_credentials(client, &pid, &uid, &gid);
3693 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3695 _e_comp_wl_pname_print(pid);
3696 _e_comp_wl_pname_get(pid, name, sizeof(name));
3697 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3701 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3703 char buf[1024] = {0, };
3705 vsnprintf(buf, 1024, fmt, args);
3709 DBG("[libds] %s", buf);
3712 INF("[libds] %s", buf);
3715 ERR("[libds] %s", buf);
3723 _e_comp_wl_display_create(void)
3726 E_Comp_Wl_Data *wl_cdata;
3731 /* create new compositor data */
3732 if (!(comp = E_NEW(E_Comp_Data, 1)))
3734 ERR("Could not create compositor data: %m");
3737 wl_cdata = &comp->base;
3739 /* set compositor wayland data */
3740 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3742 g_mutex_init(&connection_mutex);
3744 /* try to create a wayland display */
3745 if (!(wl_cdata->wl.disp = wl_display_create()))
3747 ERR("Could not create a Wayland display: %m");
3751 /* try to setup wayland socket */
3752 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3754 ERR("Could not create Wayland display socket: %m");
3755 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3759 res = e_comp_socket_init(name);
3760 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3761 PRCTL("[Winsys] change permission and create sym link for %s", name);
3763 /* set wayland display environment variable */
3764 e_env_set("WAYLAND_DISPLAY", name);
3766 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3767 /* wl_cdata->output.scale = e_scale; */
3769 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3771 if (!e_compositor_init(wl_cdata->wl.disp))
3773 ERR("Failed to initialize compositor");
3777 comp->client_created.notify = _e_comp_wl_cb_client_created;
3778 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3780 if (!e_comp_wl_subsurfaces_init())
3782 ERR("Failed to init_subsurfaces");
3783 goto subsurfaces_err;
3786 /* initialize shm mechanism */
3787 wl_display_init_shm(wl_cdata->wl.disp);
3789 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3791 /* try to init data manager */
3792 if (!e_comp_wl_data_manager_init())
3794 ERR("Could not initialize data manager");
3798 /* try to init input */
3799 if (!e_comp_wl_input_init())
3801 ERR("Could not initialize input");
3805 if (e_comp_gl_get())
3806 _e_comp_wl_gl_init(NULL);
3808 /* get the wayland display loop */
3809 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3811 /* get the file descriptor of the wayland event loop */
3812 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3814 /* create a listener for wayland main loop events */
3816 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3817 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3818 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3819 _e_comp_wl_cb_prepare, wl_cdata);
3824 e_comp_wl_data_manager_shutdown();
3826 e_comp_wl_subsurfaces_shutdown();
3828 wl_list_remove(&comp->client_created.link);
3830 e_env_unset("WAYLAND_DISPLAY");
3832 wl_display_destroy(wl_cdata->wl.disp);
3834 g_mutex_clear(&connection_mutex);
3840 _e_comp_wl_gl_shutdown(void)
3842 if (!e_comp_wl->evas_gl) return;
3844 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3846 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3847 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3848 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3849 evas_gl_free(e_comp_wl->evas_gl->gl);
3851 E_FREE(e_comp_wl->evas_gl);
3854 /* public functions */
3857 * Creates and initializes a Wayland compositor with ecore.
3858 * Registers callback handlers for keyboard and mouse activity
3859 * and other client events.
3861 * @returns true on success, false if initialization failed.
3864 e_comp_wl_init(void)
3866 TRACE_DS_BEGIN(COMP_WL:INIT);
3868 /* try to create a wayland compositor */
3869 if (!_e_comp_wl_display_create())
3871 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3876 e_comp_wl_shell_init();
3878 #ifdef HAVE_WAYLAND_TBM
3879 e_comp_wl_tbm_init();
3881 e_comp_wl_remote_surface_init();
3885 e_comp_wl_screenshooter_init();
3887 if (!e_comp_wl_video_init())
3888 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3890 e_comp_wl_viewport_init();
3891 e_comp_wl_capture_init();
3892 e_comp_wl_renderer_init();
3893 _e_comp_wl_move_resize_init();
3894 e_presentation_time_init();
3895 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3898 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3899 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3901 /* add event handlers to catch E events */
3902 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3903 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3904 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3905 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3906 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3907 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3908 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3909 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3910 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3912 /* add hooks to catch e_client events */
3913 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3914 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3915 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3916 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3917 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3919 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3926 e_comp_wl_deferred_job(void)
3928 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3931 /* internal functions */
3933 e_comp_wl_shutdown(void)
3935 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3937 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3939 e_comp_wl_subsurfaces_shutdown();
3941 E_FREE_LIST(handlers, ecore_event_handler_del);
3942 E_FREE_LIST(hooks, e_client_hook_del);
3943 _e_comp_wl_gl_shutdown();
3945 e_blender_shutdown();
3946 e_presentation_time_shutdown();
3947 e_comp_wl_renderer_shutdown();
3948 e_comp_wl_capture_shutdown();
3949 e_comp_wl_viewport_shutdown();
3950 e_comp_wl_video_shutdown();
3951 e_comp_wl_screenshooter_shutdown();
3953 e_comp_wl_remote_surface_shutdown();
3955 e_pixmap_shutdown();
3957 e_wtz_shell_shutdown();
3958 e_comp_wl_shell_shutdown();
3959 e_comp_wl_input_shutdown();
3961 wl_list_remove(&comp->client_created.link);
3964 e_comp->wl_comp_data = NULL;
3968 E_Comp_Wl_Output *output;
3970 if (e_comp_wl->screenshooter.global)
3971 wl_global_destroy(e_comp_wl->screenshooter.global);
3973 EINA_LIST_FREE(e_comp_wl->outputs, output)
3975 if (output->id) eina_stringshare_del(output->id);
3976 if (output->make) eina_stringshare_del(output->make);
3977 if (output->model) eina_stringshare_del(output->model);
3981 /* delete fd handler */
3982 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3984 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3985 cursor_timer_ec = NULL;
3987 /* free allocated data structure */
3993 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3995 e_object_unref(E_OBJECT(ev->ec));
4000 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4003 ev = E_NEW(E_Event_Client, 1);
4006 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4008 /* set usable early because shell module checks this */
4009 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4010 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4012 e_pixmap_resource_set(ec->pixmap, buffer);
4013 e_pixmap_dirty(ec->pixmap);
4014 e_pixmap_refresh(ec->pixmap);
4016 e_comp_wl_map_size_cal_from_buffer(ec);
4017 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4019 /* wm-policy module uses it */
4020 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4023 e_object_ref(E_OBJECT(ec));
4024 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4025 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4029 e_comp_wl_surface_commit(E_Client *ec)
4034 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4035 if (!e_comp_object_damage_exists(ec->frame))
4037 if ((ec->comp_data->video_client) ||
4038 (!e_client_video_hw_composition_check(ec)))
4039 e_pixmap_image_clear(ec->pixmap, 1);
4042 ignored = ec->ignored;
4044 if (e_comp_wl_subsurface_order_commit(ec))
4046 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4047 e_comp_wl_subsurface_restack(topmost);
4048 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4051 ec->ignored = ignored;
4053 if (ec->is_cursor && ec->visible)
4055 /* ignore cursor changes during resize/move I guess */
4056 if (!e_client_action_get())
4058 if (e_comp->pointer)
4060 x = e_comp->pointer->hot.x;
4061 y = e_comp->pointer->hot.y;
4063 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4069 static E_Comp_Wl_Output *
4070 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4073 E_Comp_Wl_Output *output;
4075 EINA_LIST_FOREACH(outputs, l, output)
4077 if (!strcmp(output->id, id))
4085 * Initializes information about one display output.
4087 * Adds or updates the given data about a single display output,
4088 * with an id matching the provided id.
4090 * @param id identification of output to be added or changed
4091 * @param make manufacturer name of the display output
4092 * @param model model name of the display output
4093 * @param x output's top left corner x coordinate
4094 * @param y output's top left corner y coordinate
4095 * @param w output's width in pixels
4096 * @param h output's height in pixels
4097 * @param pw output's physical width in millimeters
4098 * @param ph output's physical height in millimeters
4099 * @param refresh output's refresh rate in mHz
4100 * @param subpixel output's subpixel layout
4101 * @param transform output's rotation and/or mirror transformation
4103 * @returns True if a display output object could be added or updated
4106 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4107 int x, int y, int w, int h, int pw, int ph,
4108 unsigned int refresh, unsigned int subpixel,
4109 unsigned int transform)
4111 E_Comp_Wl_Output *output;
4113 struct wl_resource *resource;
4115 /* retrieve named output; or create it if it doesn't exist */
4116 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4119 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4121 if (id) output->id = eina_stringshare_add(id);
4123 output->make = eina_stringshare_add(make);
4125 output->make = eina_stringshare_add("unknown");
4127 output->model = eina_stringshare_add(model);
4129 output->model = eina_stringshare_add("unknown");
4131 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4134 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4135 2, output, _e_comp_wl_cb_output_bind);
4137 output->resources = NULL;
4138 output->scale = e_scale;
4141 /* update the output details */
4146 output->phys_width = pw;
4147 output->phys_height = ph;
4148 output->refresh = refresh;
4149 output->subpixel = subpixel;
4150 output->transform = transform;
4152 if (output->scale <= 0)
4153 output->scale = e_scale;
4155 /* if we have bound resources, send updates */
4156 EINA_LIST_FOREACH(output->resources, l2, resource)
4158 wl_output_send_geometry(resource,
4159 output->x, output->y,
4161 output->phys_height,
4163 output->make ?: "", output->model ?: "",
4166 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4167 wl_output_send_scale(resource, output->scale);
4169 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4170 output->w, output->h, output->refresh);
4172 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4173 wl_output_send_done(resource);
4180 e_comp_wl_output_remove(const char *id)
4182 E_Comp_Wl_Output *output;
4184 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4187 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4189 /* wl_global_destroy(output->global); */
4191 /* eina_stringshare_del(output->id); */
4192 /* eina_stringshare_del(output->make); */
4193 /* eina_stringshare_del(output->model); */
4200 _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)
4202 struct wl_resource *res;
4204 uint32_t serial, keycode;
4205 struct wl_client *wc = NULL;
4206 E_Comp_Config *comp_conf = NULL;
4207 const char *device_name = NULL;
4209 keycode = (ev->keycode - 8);
4211 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4213 comp_conf = e_comp_config_get();
4215 if (ec && ec->comp_data)
4217 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4220 wc = wl_resource_get_client(surface);
4223 if (e_config->key_input_ttrace_enable)
4225 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4226 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4229 EINA_LIST_FOREACH(key_list, l, res)
4231 if (wl_resource_get_client(res) != wc) continue;
4233 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4234 if (!e_input_thread_mode_get())
4236 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4237 device_name = ecore_device_name_get(ev->dev);
4243 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4244 device_name = e_device_name_get(dev);
4248 if (comp_conf && comp_conf->input_log_enable)
4249 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4251 wl_keyboard_send_key(res, serial, ev->timestamp,
4256 if (e_config->key_input_ttrace_enable)
4259 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4264 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4266 E_Client *ec = NULL;
4268 E_Comp_Wl_Key_Data *end, *k;
4270 if (ev->window != e_comp->ee_win)
4275 keycode = (ev->keycode - 8);
4276 if (!(e_comp_wl = e_comp->wl_comp_data))
4281 #ifndef E_RELEASE_BUILD
4282 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4283 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4284 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4285 eina_streq(ev->key, "BackSpace"))
4291 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4293 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4295 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4297 /* ignore server-generated key repeats */
4298 if (k->key == keycode)
4300 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4305 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4307 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4309 ec = e_client_focused_get();
4310 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4311 if (ec && ec->comp_data && surface)
4313 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4314 if (e_comp_wl->kbd.focused)
4316 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4318 /* A key only sent to clients is added to the list */
4319 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4320 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4322 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4324 DBG("wl_array_add: Out of memory\n");
4325 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4326 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4329 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4333 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4337 /* update modifier state */
4338 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4344 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4346 E_Client *ec = NULL;
4347 uint32_t keycode, delivered_key;
4348 E_Comp_Wl_Key_Data *end, *k;
4350 if (ev->window != e_comp->ee_win)
4355 keycode = (ev->keycode - 8);
4357 if (!(e_comp_wl = e_comp->wl_comp_data))
4362 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4364 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4365 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4367 if (k->key == keycode)
4374 e_comp_wl->kbd.keys.size =
4375 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4377 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4379 /* 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) */
4380 if ((delivered_key) ||
4381 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4383 ec = e_client_focused_get();
4385 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4386 if (e_comp_wl->kbd.focused)
4388 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4390 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4393 /* update modifier state */
4394 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4400 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4402 Eina_Bool res = EINA_FALSE;
4404 if (type == ECORE_EVENT_KEY_DOWN)
4406 res = e_comp_wl_key_down(ev, dev);
4408 else if (type == ECORE_EVENT_KEY_UP)
4410 res = e_comp_wl_key_up(ev, dev);
4417 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4420 struct wl_client *wc;
4421 uint32_t serial, btn;
4422 struct wl_resource *res;
4423 E_Comp_Config *comp_conf = NULL;
4425 if (ec->cur_mouse_action || e_comp_wl->drag)
4427 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4428 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4432 case 1: btn = BTN_LEFT; break;
4433 case 2: btn = BTN_MIDDLE; break;
4434 case 3: btn = BTN_RIGHT; break;
4435 default: btn = button_id; break;
4438 e_comp_wl->ptr.button = btn;
4439 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4440 if (!surface) return EINA_FALSE;
4442 if (!eina_list_count(e_comp_wl->ptr.resources))
4445 wc = wl_resource_get_client(surface);
4446 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4448 comp_conf = e_comp_config_get();
4450 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4452 if (wl_resource_get_client(res) != wc) continue;
4453 if (!e_comp_wl_input_pointer_check(res)) continue;
4454 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4456 if (comp_conf && comp_conf->input_log_enable)
4457 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4459 wl_pointer_send_button(res, serial, timestamp, btn, state);
4466 e_comp_wl_touch_cancel(void)
4468 _e_comp_wl_touch_cancel();
4471 E_API E_Comp_Wl_Hook *
4472 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4476 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4477 ch = E_NEW(E_Comp_Wl_Hook, 1);
4478 if (!ch) return NULL;
4479 ch->hookpoint = hookpoint;
4481 ch->data = (void*)data;
4482 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4487 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4490 if (_e_comp_wl_hooks_walking == 0)
4492 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4496 _e_comp_wl_hooks_delete++;
4499 E_API E_Comp_Wl_Pid_Hook *
4500 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4502 E_Comp_Wl_Pid_Hook *ch;
4504 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4506 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4507 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4509 ch->hookpoint = hookpoint;
4511 ch->data = (void*)data;
4512 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4518 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4521 if (_e_comp_wl_pid_hooks_walking == 0)
4523 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4527 _e_comp_wl_pid_hooks_delete++;
4530 E_API E_Comp_Wl_Intercept_Hook *
4531 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4533 E_Comp_Wl_Intercept_Hook *ch;
4535 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4536 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4537 if (!ch) return NULL;
4538 ch->hookpoint = hookpoint;
4540 ch->data = (void*)data;
4541 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4546 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4549 if (_e_comp_wl_intercept_hooks_walking == 0)
4551 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4555 _e_comp_wl_intercept_hooks_delete++;
4559 e_comp_wl_shell_surface_ready(E_Client *ec)
4563 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4567 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4569 e_config->use_cursor_timer = !!enabled;
4571 if (e_config->use_cursor_timer)
4573 if (!e_pointer_is_hidden(e_comp->pointer))
4575 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4580 if (e_comp_wl->ptr.hide_tmr)
4582 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4583 e_comp_wl->ptr.hide_tmr = NULL;
4585 cursor_timer_ec = NULL;
4587 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4590 if (e_pointer_is_hidden(e_comp->pointer))
4592 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4598 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4600 EINA_SAFETY_ON_NULL_RETURN(wc);
4601 EINA_SAFETY_ON_NULL_RETURN(dev);
4603 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4607 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4609 EINA_SAFETY_ON_NULL_RETURN(wc);
4610 EINA_SAFETY_ON_NULL_RETURN(dev);
4612 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4616 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4618 struct wl_resource *res;
4619 struct wl_client *wc;
4621 uint32_t serial, wl_keycode;
4622 enum wl_keyboard_key_state state;
4623 E_Comp_Config *comp_conf = NULL;
4624 const char *dev_name = NULL;
4626 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4627 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4628 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4630 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4631 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4633 wl_keycode = keycode - 8;
4634 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4636 wc = wl_resource_get_client(surface);
4637 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4638 if (!time) time = e_util_timestamp_get();
4639 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4640 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4642 comp_conf = e_comp_config_get();
4643 e_keyrouter_event_surface_send(ec, keycode);
4645 if (e_config->key_input_ttrace_enable)
4647 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4648 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4651 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4652 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4654 if (wl_resource_get_client(res) != wc) continue;
4655 if (!e_input_thread_mode_get())
4659 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4660 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4664 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4671 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4672 dev_name = e_device_name_get(dev);
4676 if (comp_conf && comp_conf->input_log_enable)
4677 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4680 wl_keyboard_send_key(res, serial, time,
4683 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4685 if (e_config->key_input_ttrace_enable)
4688 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4695 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4697 struct wl_resource *res;
4698 struct wl_client *wc;
4700 uint32_t serial, wl_keycode, cancel_keycode;
4701 E_Comp_Config *comp_conf = NULL;
4702 struct xkb_keymap *keymap = NULL;
4704 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4705 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4706 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4708 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4709 keymap = e_comp_wl->xkb.keymap;
4710 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4711 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4713 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4714 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4716 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4717 if (cancel_keycode == XKB_KEYCODE_INVALID)
4719 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4722 cancel_keycode = cancel_keycode - 8;
4724 wl_keycode = keycode - 8;
4725 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4727 wc = wl_resource_get_client(surface);
4728 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4729 if (!time) time = e_util_timestamp_get();
4731 comp_conf = e_comp_config_get();
4732 e_keyrouter_event_surface_send(ec, keycode);
4734 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4735 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4737 if (wl_resource_get_client(res) != wc) continue;
4738 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4739 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4741 if (comp_conf && comp_conf->input_log_enable)
4742 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4743 wl_keyboard_send_key(res, serial, time,
4744 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4745 wl_keyboard_send_key(res, serial, time,
4746 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4747 wl_keyboard_send_key(res, serial, time,
4748 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4750 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4757 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)
4759 struct wl_client *wc;
4761 E_Devicemgr_Input_Device *device = NULL;
4763 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4764 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4765 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4767 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4768 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4770 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4772 wc = wl_resource_get_client(surface);
4773 if (!time) time = e_util_timestamp_get();
4774 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4778 _e_comp_wl_send_event_device(wc, time, dev, serial);
4779 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4783 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4784 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4787 x = x + ec->client.x;
4788 y = y + ec->client.y;
4790 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4796 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)
4798 E_Devicemgr_Input_Device *device;
4800 struct wl_client *wc;
4802 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4803 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4804 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4806 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4807 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4809 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4811 wc = wl_resource_get_client(surface);
4812 if (!time) time = e_util_timestamp_get();
4813 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4817 _e_comp_wl_send_event_device(wc, time, dev, serial);
4818 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4822 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4823 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4826 x = x + ec->client.x;
4827 y = y + ec->client.y;
4829 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4835 e_comp_wl_touch_cancel_send(E_Client *ec)
4837 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4838 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4839 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4841 _e_comp_wl_send_touch_cancel(ec);
4847 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4850 struct wl_client *wc;
4852 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4853 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4854 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4856 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4857 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4859 wc = wl_resource_get_client(surface);
4860 if (!time) time = e_util_timestamp_get();
4861 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4863 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4864 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4867 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4868 WL_POINTER_BUTTON_STATE_PRESSED);
4870 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4871 WL_POINTER_BUTTON_STATE_RELEASED);
4877 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4880 struct wl_client *wc;
4882 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4883 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4884 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4886 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4887 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4889 wc = wl_resource_get_client(surface);
4890 if (!time) time = e_util_timestamp_get();
4891 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4893 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4894 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4896 x = x + ec->client.x;
4897 y = y + ec->client.y;
4899 _e_comp_wl_send_mouse_move(ec, x, y, time);
4905 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4908 struct wl_client *wc;
4910 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4911 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4912 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4914 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4915 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4917 wc = wl_resource_get_client(surface);
4918 if (!time) time = e_util_timestamp_get();
4919 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4921 if (_e_comp_wl_check_cursor_timer_needed(ec))
4923 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4927 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4928 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4930 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4932 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4934 if (_e_comp_wl_check_cursor_timer_needed(ec))
4935 _e_comp_wl_cursor_move_timer_control(ec);
4942 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4945 struct wl_client *wc;
4946 struct wl_resource *res;
4949 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4950 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4952 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4953 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4955 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4956 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4958 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4959 wc = wl_resource_get_client(surface);
4960 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4961 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4963 if (!e_comp_wl_input_pointer_check(res)) continue;
4964 if (wl_resource_get_client(res) != wc) continue;
4966 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4967 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4969 wl_pointer_send_enter(res, serial, surface,
4970 wl_fixed_from_int(x),
4971 wl_fixed_from_int(y));
4972 ec->pointer_enter_sent = EINA_TRUE;
4974 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4980 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4983 struct wl_client *wc;
4984 struct wl_resource *res;
4987 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4988 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4989 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4990 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4991 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4992 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4994 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4995 wc = wl_resource_get_client(surface);
4996 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4997 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4999 if (!e_comp_wl_input_pointer_check(res)) continue;
5000 if (wl_resource_get_client(res) != wc) continue;
5002 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5003 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5005 wl_pointer_send_leave(res, serial, surface);
5006 ec->pointer_enter_sent = EINA_FALSE;
5013 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)
5015 Evas_Event_Mouse_In ev_in;
5018 if (ec->pointer_enter_sent) return;
5020 ev_in.buttons = buttons;
5028 ev_in.modifiers = modifiers;
5029 ev_in.locks = locks;
5030 ev_in.timestamp = timestamp;
5031 ev_in.event_flags = event_flags;
5034 ev_in.event_src = event_src;
5036 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5040 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)
5042 Evas_Event_Mouse_Out ev_out;
5045 if (!ec->pointer_enter_sent) return;
5047 ev_out.buttons = buttons;
5049 ev_out.output.x = x;
5050 ev_out.output.y = y;
5051 ev_out.canvas.x = x;
5052 ev_out.canvas.y = y;
5055 ev_out.modifiers = modifiers;
5056 ev_out.locks = locks;
5057 ev_out.timestamp = timestamp;
5058 ev_out.event_flags = event_flags;
5061 ev_out.event_src = event_src;
5063 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5067 e_comp_wl_cursor_hide(E_Client *ec)
5069 struct wl_resource *res;
5070 struct wl_client *wc;
5074 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5076 if (e_comp_wl->ptr.hide_tmr)
5078 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5079 e_comp_wl->ptr.hide_tmr = NULL;
5081 cursor_timer_ec = NULL;
5083 if (!ec) return EINA_FALSE;
5084 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5085 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5086 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5088 wc = wl_resource_get_client(surface);
5089 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5090 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5092 if (!e_comp_wl_input_pointer_check(res)) continue;
5093 if (wl_resource_get_client(res) != wc) continue;
5094 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5095 wl_pointer_send_leave(res, serial, surface);
5096 ec->pointer_enter_sent = EINA_FALSE;
5102 /* surface to buffer
5103 * - width : surface width
5104 * - height : surface height
5105 * - transform: buffer transform
5106 * - scale : buffer scale
5108 * - width : screen width
5109 * - height : screen height
5110 * - transform: output transform
5111 * - scale : output scale
5113 static E_Util_Transform_Matrix
5114 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5116 E_Util_Transform_Matrix m;
5118 e_util_transform_matrix_load_identity(&m);
5120 if (transform & 0x4)
5122 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5123 e_util_transform_matrix_flip_x(&m);
5124 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5127 switch (transform & 0x3)
5129 case WL_OUTPUT_TRANSFORM_90:
5130 e_util_transform_matrix_translate(&m, -width, 0, 0);
5131 e_util_transform_matrix_rotation_z(&m, 270);
5133 case WL_OUTPUT_TRANSFORM_180:
5134 e_util_transform_matrix_translate(&m, -width, -height, 0);
5135 e_util_transform_matrix_rotation_z(&m, 180);
5137 case WL_OUTPUT_TRANSFORM_270:
5138 e_util_transform_matrix_translate(&m, 0, -height, 0);
5139 e_util_transform_matrix_rotation_z(&m, 90);
5145 e_util_transform_matrix_scale(&m, scale, scale, 1);
5150 /* surface to buffer
5151 * - surface width, surface height, buffer transform, buffer scale
5153 * - screen width, screen height, output transform, output scale
5156 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5158 E_Util_Transform_Matrix m;
5159 E_Util_Transform_Vertex v;
5161 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5163 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5164 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5165 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5169 * - buffer width, buffer height, buffer transform, buffer scale
5172 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5174 E_Util_Transform_Matrix m;
5175 E_Util_Transform_Vertex v;
5178 if (transform != 0 || scale > 1)
5180 tw = ((transform % 2) ? height : width) / scale;
5181 th = ((transform % 2) ? width : height) / scale;
5189 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5190 m = e_util_transform_matrix_inverse_get(&m);
5192 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5193 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5194 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5197 /* surface to buffer
5198 * - surface width, surface height, buffer transform, buffer scale
5200 * - screen width, screen height, output transform, output scale
5203 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5204 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5206 E_Util_Transform_Matrix m;
5207 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5208 E_Util_Transform_Rect_Vertex sv;
5210 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5212 sv = e_util_transform_rect_to_vertices(&sr);
5213 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5214 sr = e_util_transform_vertices_to_rect(&sv);
5223 * - buffer width, buffer height, buffer transform, buffer scale
5226 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5227 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5229 E_Util_Transform_Matrix m;
5230 E_Util_Transform_Rect br = {bx, by, bw, bh};
5231 E_Util_Transform_Rect_Vertex bv;
5234 if (transform != 0 || scale > 1)
5236 tw = ((transform % 2) ? height : width) / scale;
5237 th = ((transform % 2) ? width : height) / scale;
5245 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5246 m = e_util_transform_matrix_inverse_get(&m);
5248 bv = e_util_transform_rect_to_vertices(&br);
5249 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5250 br = e_util_transform_vertices_to_rect(&bv);
5258 EINTERN E_Comp_Wl_Output*
5259 e_comp_wl_output_find(E_Client *ec)
5262 E_Comp_Wl_Output *output;
5264 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5266 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5268 if (output->transform % 2)
5270 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5271 ec->y < output->x || ec->y >= (output->x + output->w))
5276 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5277 ec->y < output->y || ec->y >= (output->y + output->h))
5287 EINTERN Eina_Array *
5288 e_comp_wl_output_find_all(E_Client *ec)
5290 E_Comp_Wl_Output *output;
5291 Eina_Array *outputs;
5294 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5296 outputs = eina_array_new(4);
5300 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5302 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5303 output->x, output->y, output->w, output->h))
5305 eina_array_push(outputs, output);
5309 if (eina_array_count(outputs) == 0)
5311 eina_array_free(outputs);
5318 // --------------------------------------------------------
5319 // tizen_move_resize
5320 // --------------------------------------------------------
5322 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5329 E_Client_Pending_Geometry *geo;
5332 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5333 if (ec->fullscreen || ec->maximized) goto err;
5335 geo = E_NEW(E_Client_Pending_Geometry, 1);
5338 geo->serial = serial;
5344 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5345 ec->surface_sync.wait_commit = EINA_TRUE;
5350 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5357 e_comp_wl_commit_sync_configure(E_Client *ec)
5360 E_Client_Pending_Geometry *geo;
5362 Eina_Bool match_size = EINA_FALSE;
5369 if (!ec || !ec->frame) goto ret;
5370 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5373 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5374 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5376 if (eina_list_count(ec->surface_sync.pending_geometry))
5378 Eina_List *ll = NULL;
5379 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5383 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5388 if ((geo->w == bw) && (geo->h == bh))
5390 match_size = EINA_TRUE;
5395 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5402 if ((config.w != ec->w) || (config.h != ec->h))
5404 e_client_size_set(ec, config.w, config.h);
5405 ec->changes.size = EINA_TRUE;
5409 // FIXME: The geometry of the client would be better to be calculated
5410 // at e_desk or at e_desk_area. So the position(x,y) of the client
5411 // should be calcuated at the e_desk or at the e_desk_area.
5413 desk = e_comp_desk_find_by_ec(ec);
5416 ec->client.x = desk->geom.x + config.x;
5417 ec->client.y = desk->geom.y + config.y;
5421 ec->client.x = config.x;
5422 ec->client.y = config.y;
5425 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5427 e_client_pos_set(ec, ec->client.x, ec->client.y);
5429 ec->changes.pos = 1;
5433 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5437 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5438 ec->surface_sync.wait_commit = EINA_FALSE;
5440 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5442 // rollback wait_commit if there are pending requests remained
5443 if (eina_list_count(ec->surface_sync.pending_geometry))
5444 ec->surface_sync.wait_commit = EINA_TRUE;
5449 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);
5456 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5457 struct wl_resource *res_moveresize)
5459 wl_resource_destroy(res_moveresize);
5463 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5464 struct wl_resource *res_moveresize,
5465 struct wl_resource *surface,
5472 /* to be implemented */
5475 int cur_w = 0, cur_h = 0;
5477 ec = e_client_from_surface_resource(surface);
5480 pending = e_client_pending_geometry_has(ec);
5481 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5482 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);
5486 if ((cur_w == w) && (cur_h == h))
5488 e_client_pos_set(ec, x, y);
5489 ec->changes.pos = 1;
5495 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5499 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5502 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5504 _tz_move_resize_iface_cb_destroy,
5505 _tz_move_resize_iface_cb_set_geometry,
5509 _tz_moveresize_cb_bind(struct wl_client *client,
5510 void *data EINA_UNUSED,
5514 struct wl_resource *res_moveresize;
5516 res_moveresize = wl_resource_create(client,
5517 &tizen_move_resize_interface,
5520 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5523 wl_resource_set_implementation(res_moveresize,
5524 &_tz_move_resize_iface,
5530 ERR("Could not create tizen_move_resize_interface res: %m");
5531 wl_client_post_no_memory(client);
5535 _e_comp_wl_move_resize_init(void)
5537 if (!e_comp_wl) return;
5538 if (!e_comp_wl->wl.disp) return;
5540 if (!wl_global_create(e_comp_wl->wl.disp,
5541 &tizen_move_resize_interface,
5544 _tz_moveresize_cb_bind))
5546 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5553 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5555 E_Comp_Wl_Output *output;
5556 pid_t output_pid = 0;
5557 Eina_List *l = NULL, *l2 = NULL;
5558 struct wl_resource *resource = NULL;
5560 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5562 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5563 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5564 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5566 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5568 /* if we have bound resources, send updates */
5569 EINA_LIST_FOREACH(output->resources, l2, resource)
5571 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5572 if (output_pid != pid) continue;
5574 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5576 // send output information to the client
5577 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5585 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5587 _e_comp_wl_surface_state_init(state, w, h);
5591 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5593 _e_comp_wl_surface_state_commit(ec, state);
5597 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5599 _e_comp_wl_hook_call(hookpoint, ec);
5603 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5605 _e_comp_wl_surface_state_finish(state);
5609 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5611 _e_comp_wl_surface_state_buffer_set(state, buffer);
5615 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5616 int sx, int sy, int *dx, int *dy)
5620 case WL_OUTPUT_TRANSFORM_NORMAL:
5624 case WL_OUTPUT_TRANSFORM_FLIPPED:
5625 *dx = width - sx, *dy = sy;
5627 case WL_OUTPUT_TRANSFORM_90:
5628 *dx = height - sy, *dy = sx;
5630 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5631 *dx = height - sy, *dy = width - sx;
5633 case WL_OUTPUT_TRANSFORM_180:
5634 *dx = width - sx, *dy = height - sy;
5636 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5637 *dx = sx, *dy = height - sy;
5639 case WL_OUTPUT_TRANSFORM_270:
5640 *dx = sy, *dy = width - sx;
5642 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5652 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5655 int tx1, ty1, tx2, ty2;
5656 int width_from_buffer, height_from_buffer;
5658 switch (vp->buffer.transform)
5660 case WL_OUTPUT_TRANSFORM_90:
5661 case WL_OUTPUT_TRANSFORM_270:
5662 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5663 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5664 width_from_buffer = bh / vp->buffer.scale;
5665 height_from_buffer = bw / vp->buffer.scale;
5668 width_from_buffer = bw / vp->buffer.scale;
5669 height_from_buffer = bh / vp->buffer.scale;
5673 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5677 x2 = width_from_buffer;
5678 y2 = height_from_buffer;
5682 x1 = wl_fixed_to_int(vp->buffer.src_x);
5683 y1 = wl_fixed_to_int(vp->buffer.src_y);
5684 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5685 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5688 buffer_transform(width_from_buffer, height_from_buffer,
5689 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5690 buffer_transform(width_from_buffer, height_from_buffer,
5691 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5693 out->x = (tx1 <= tx2) ? tx1 : tx2;
5694 out->y = (ty1 <= ty2) ? ty1 : ty2;
5695 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5696 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5700 * Convert given four coordinates to elements of rectangle
5701 * @in p[4] Coordinates to be converted
5702 * @out rect x, y, width, and height
5703 * transform Angle which represents TDM_TRANSFORM of rectangle
5704 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5705 * 1. The given coordinates are not represented by rectangle.
5706 * 2. All angles except for 0, 90, 180, 270.
5709 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5711 Eina_Bool ret = EINA_FALSE;
5713 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))
5716 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5719 *rotation = TDM_TRANSFORM_NORMAL;
5722 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5726 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5729 *rotation = TDM_TRANSFORM_180;
5732 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5737 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))
5740 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5743 *rotation = TDM_TRANSFORM_90;
5746 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5750 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5753 *rotation = TDM_TRANSFORM_270;
5756 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5766 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5771 for (i = 0; i < 4; i++)
5772 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5774 if (!_coords_to_rectangle_convert(p, out, rotation))
5776 DBG("Cannot convert given coords to rectangle.\n"
5777 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5778 p[0].x, p[0].y, p[1].x, p[1].y,
5779 p[2].x, p[2].y, p[3].x, p[3].y);
5787 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5789 int trans_rotation, flip;
5791 trans_rotation = transform & 0x3;
5792 flip = transform & 0x4;
5794 return (flip + (trans_rotation + rotation) % 4);
5798 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5806 if (e_comp_wl_subsurface_check(ec))
5807 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5814 out->w = ec->comp_data->width_from_viewport;
5815 out->w = (out->w + 1) & ~1;
5816 out->h = ec->comp_data->height_from_viewport;
5818 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5819 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5823 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5825 E_Comp_Wl_Buffer *buffer;
5826 E_Comp_Wl_Buffer_Viewport *vp;
5828 enum wl_output_transform buffer_transform;
5829 unsigned int rotation;
5830 Eina_Bool res = EINA_FALSE;
5832 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5834 if (e_object_is_del(E_OBJECT(ec)))
5837 vp = &ec->comp_data->scaler.buffer_viewport;
5839 if (buffer_viewport)
5841 buffer = ec->comp_data->buffer_ref.buffer;
5842 /* Getting a viewport of buffer needs geometry of buffer. */
5846 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5849 if ((output_viewport) || (transform))
5851 m = e_client_map_get(ec);
5853 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5855 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5860 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5861 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5862 * Since buffer.transform isn't applied using evas_map,
5863 * it has to be taken into account here to apply buffer.transform
5864 * and rotation of e_client_transform together. */
5866 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5868 *transform = (unsigned int)buffer_transform;
5876 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5878 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5879 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5881 /* Must be called with valid comp_data */
5882 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5884 if ((ec->comp_data->role_name == NULL) ||
5885 (ec->comp_data->role_name == role_name) ||
5886 (strcmp(ec->comp_data->role_name, role_name) == 0))
5888 ec->comp_data->role_name = role_name;
5894 wl_resource_post_error(error_resource, error_code,
5895 "Cannot assign role %s to wl_surface@%d,"
5896 " already has role %s\n",
5898 ec->comp_data->wl_surface ?
5899 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5900 ec->comp_data->role_name);
5906 EINTERN const char *
5907 e_comp_wl_surface_role_get(E_Client *ec)
5909 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5910 return ec->comp_data ? ec->comp_data->role_name : NULL;
5913 EINTERN struct wl_resource *
5914 e_comp_wl_client_surface_get(E_Client *ec)
5916 struct wl_resource *surface = NULL;
5917 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5918 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5920 g_mutex_lock(&ec->comp_data->surface_mutex);
5921 surface = ec->comp_data->surface;
5922 g_mutex_unlock(&ec->comp_data->surface_mutex);
5927 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5929 EINA_SAFETY_ON_NULL_RETURN(ec);
5930 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5932 g_mutex_lock(&ec->comp_data->surface_mutex);
5933 ec->comp_data->surface = surface;
5934 g_mutex_unlock(&ec->comp_data->surface_mutex);
5938 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5940 return e_compositor_util_client_from_surface_resource(surface_resource);
5944 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5946 if (!ec->comp_data->mapped)
5948 if (ec->comp_data->shell.surface &&
5949 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5951 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5957 if (ec->comp_data->mapped)
5959 /* will be unmapped. so run capture */
5960 e_comp_wl_remote_surface_image_save(ec);
5964 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5966 ec->comp_data->pending.sx = sx;
5967 ec->comp_data->pending.sy = sy;
5968 ec->comp_data->pending.new_attach = EINA_TRUE;
5970 e_client_fps_update(ec);
5974 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5976 if (ec->comp_data->pending.opaque)
5977 eina_tiler_clear(ec->comp_data->pending.opaque);
5981 eina_tiler_union(ec->comp_data->pending.opaque, region);
5983 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5987 ec->argb = EINA_FALSE;
5988 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5990 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5991 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5999 ec->argb = EINA_TRUE;
6000 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6002 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6003 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6009 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6011 if (ec->comp_data->pending.input)
6012 eina_tiler_clear(ec->comp_data->pending.input);
6016 if (eina_tiler_empty(region))
6018 ELOGF("COMP", " |unset input rect", NULL);
6019 e_comp_object_input_objs_del(ec->frame);
6020 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6023 eina_tiler_union(ec->comp_data->pending.input, region);
6027 eina_tiler_rect_add(ec->comp_data->pending.input,
6028 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6033 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6035 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6039 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6041 E_Comp_Wl_Subsurf_Data *sdata;
6046 if (ec->comp_data->frames)
6048 ec->comp_data->frames =
6049 eina_list_remove(ec->comp_data->frames, callback_resource);
6052 if (ec->comp_data->pending.frames)
6054 ec->comp_data->pending.frames =
6055 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6058 sdata = ec->comp_data->sub.data;
6059 if ((sdata) && (sdata->cached.frames))
6061 sdata->cached.frames =
6062 eina_list_remove(sdata->cached.frames, callback_resource);
6067 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6069 if (e_object_is_del(E_OBJECT(ec))) return;
6071 if (e_comp_wl_remote_surface_commit(ec)) return;
6073 e_comp_wl_surface_commit(ec);
6075 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6079 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6081 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6082 ec->comp_data->sub.data = sub;
6084 /* set subsurface client properties */
6085 ec->borderless = EINA_TRUE;
6086 ec->argb = EINA_TRUE;
6087 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6088 ec->lock_border = EINA_TRUE;
6089 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6090 ec->netwm.state.skip_taskbar = EINA_TRUE;
6091 ec->netwm.state.skip_pager = EINA_TRUE;
6092 ec->border_size = 0;
6093 ec->lock_user_location = 0;
6094 ec->lock_client_location = 0;
6095 ec->lock_user_size = 0;
6096 ec->lock_client_size = 0;
6097 ec->lock_client_stacking = 0;
6098 ec->lock_user_maximize = 0;
6099 ec->lock_client_maximize = 0;
6100 ec->changes.need_maximize = 0;
6101 ec->maximized = E_MAXIMIZE_NONE;
6104 ec->new_client = ec->netwm.ping = EINA_TRUE;
6105 e_comp->new_clients++;
6106 e_client_unignore(ec);
6108 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6109 * It's not for subsurface. */
6110 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6114 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6116 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6119 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6121 sub->parent = parent;
6125 layer = e_client_layer_get(parent);
6126 if (layer > E_LAYER_BOTTOM)
6127 e_client_layer_set(ec, layer);
6130 if (parent->comp_data)
6132 /* append this client to the parents subsurface list */
6133 parent->comp_data->sub.list_pending =
6134 eina_list_append(parent->comp_data->sub.list_pending, ec);
6135 parent->comp_data->sub.list_changed = EINA_TRUE;
6140 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6142 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6143 E_Client *parent = sub->parent;
6145 parent->comp_data->sub.list =
6146 eina_list_remove(parent->comp_data->sub.list, ec);
6147 parent->comp_data->sub.list_pending =
6148 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6149 parent->comp_data->sub.below_list =
6150 eina_list_remove(parent->comp_data->sub.below_list, ec);
6151 parent->comp_data->sub.below_list_pending =
6152 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6158 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)
6160 sub->resource = subsurface_resource;
6161 sub->cached_buffer_ref.buffer = NULL;
6162 sub->synchronized = EINA_TRUE;
6163 sub->parent = parent;
6164 sub->remote_surface.offscreen_parent = offscreen_parent;
6165 if (offscreen_parent)
6166 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6168 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6170 _e_comp_wl_client_subsurface_set(ec, sub);
6171 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6173 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6177 e_comp_wl_client_subsurface_finish(E_Client *ec)
6179 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6182 e_comp_wl_client_subsurface_parent_unset(ec);
6184 e_comp_wl_surface_state_finish(&sub->cached);
6185 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6187 ec->comp_data->sub.data = NULL;
6191 e_comp_wl_client_evas_init(E_Client *ec)
6193 EINA_SAFETY_ON_NULL_RETURN(ec);
6195 _e_comp_wl_client_evas_init(ec);
6199 e_comp_wl_client_evas_deinit(E_Client *ec)
6201 EINA_SAFETY_ON_NULL_RETURN(ec);
6203 _e_comp_wl_client_evas_deinit(ec);
6207 e_comp_wl_focus_check(void)
6209 _e_comp_wl_focus_check();
6213 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6220 if ((parent->comp_data) && (parent->comp_data->sub.data))
6221 parent = parent->comp_data->sub.data->parent;