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"
32 #include <tizen-extension-server-protocol.h>
33 #include <relative-pointer-unstable-v1-server-protocol.h>
34 #include <pointer-constraints-unstable-v1-server-protocol.h>
36 #include <wayland-tbm-server.h>
38 #include <libds/log.h>
39 #include <libds/single_pixel_buffer_v1.h>
41 /* handle include for printing uint64_t */
42 #define __STDC_FORMAT_MACROS
45 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
47 /* Resource Data Mapping: (wl_resource_get_user_data)
49 * wl_surface == e_pixmap
50 * wl_region == eina_tiler
51 * wl_subsurface == e_client
55 typedef struct _E_Comp_Data E_Comp_Data;
60 struct wl_listener client_created;
63 static void _e_comp_wl_move_resize_init(void);
65 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
68 typedef struct _E_Comp_Wl_Key_Data
74 static Eina_List *handlers = NULL;
75 static E_Client *cursor_timer_ec = NULL;
76 static Eina_Bool need_send_released = EINA_FALSE;
77 static Eina_Bool need_send_motion = EINA_TRUE;
79 static GMutex connection_mutex;
81 static int _e_comp_wl_hooks_delete = 0;
82 static int _e_comp_wl_hooks_walking = 0;
84 static int _e_comp_wl_pid_hooks_delete = 0;
85 static int _e_comp_wl_pid_hooks_walking = 0;
87 static int _e_comp_wl_intercept_hooks_delete = 0;
88 static int _e_comp_wl_intercept_hooks_walking = 0;
90 static Eina_Inlist *_e_comp_wl_hooks[] =
92 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
93 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
94 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
95 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
96 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
97 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
98 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
99 [E_COMP_WL_HOOK_DEL] = NULL,
100 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
101 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
102 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
105 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
107 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
110 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
112 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
113 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
114 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
115 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
116 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
117 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
120 static Eina_List *hooks = NULL;
122 /* local functions */
124 _e_comp_wl_hooks_clean(void)
129 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
130 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
132 if (!ch->delete_me) continue;
133 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
139 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
143 e_object_ref(E_OBJECT(ec));
144 _e_comp_wl_hooks_walking++;
145 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
147 if (ch->delete_me) continue;
148 ch->func(ch->data, ec);
149 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
150 (e_object_is_del(E_OBJECT(ec))))
153 _e_comp_wl_hooks_walking--;
154 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
155 _e_comp_wl_hooks_clean();
156 e_object_unref(E_OBJECT(ec));
160 _e_comp_wl_pid_hooks_clean(void)
163 E_Comp_Wl_Pid_Hook *ch;
165 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
166 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
168 if (!ch->delete_me) continue;
169 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
175 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
177 E_Comp_Wl_Pid_Hook *ch;
179 _e_comp_wl_pid_hooks_walking++;
180 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
182 if (ch->delete_me) continue;
183 ch->func(ch->data, pid);
185 _e_comp_wl_pid_hooks_walking--;
186 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
187 _e_comp_wl_pid_hooks_clean();
191 _e_comp_wl_intercept_hooks_clean(void)
194 E_Comp_Wl_Intercept_Hook *ch;
196 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
197 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
199 if (!ch->delete_me) continue;
200 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
206 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
208 E_Comp_Wl_Intercept_Hook *ch;
209 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
211 e_object_ref(E_OBJECT(ec));
212 _e_comp_wl_intercept_hooks_walking++;
213 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
215 if (ch->delete_me) continue;
216 res = ch->func(ch->data, ec);
217 if (!res) ret = EINA_FALSE;
218 if (e_object_is_del(E_OBJECT(ec)))
221 _e_comp_wl_intercept_hooks_walking--;
222 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
223 _e_comp_wl_intercept_hooks_clean();
224 e_object_unref(E_OBJECT(ec));
231 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
237 if (e_comp_object_frame_exists(ec->frame))
238 w = ec->client.w, h = ec->client.h;
240 w = ec->w, h = ec->h;
244 // Width and Height are -1 means that we don't consider size value
248 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
252 _e_comp_wl_focus_check(void)
256 if (stopping) return;
257 ec = e_client_focused_get();
259 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
263 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
265 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
267 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
268 IDLE_EXITER~CB_PREPARE);
270 return ECORE_CALLBACK_RENEW;
274 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
276 /* dispatch pending wayland events */
277 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
279 return ECORE_CALLBACK_RENEW;
283 e_comp_wl_display_flush()
285 if (e_comp_wl && e_comp_wl->wl.disp)
287 if (e_config->key_input_ttrace_enable)
289 TRACE_INPUT_BEGIN(wl_display_flush_clients);
290 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
293 g_mutex_lock(&connection_mutex);
294 wl_display_flush_clients(e_comp_wl->wl.disp);
295 g_mutex_unlock(&connection_mutex);
297 if (e_config->key_input_ttrace_enable)
300 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
306 e_comp_wl_connection_lock()
308 e_input_boost_lock(&connection_mutex);
312 e_comp_wl_connection_unlock()
314 e_input_boost_unlock(&connection_mutex);
318 e_comp_wl_focused_client_flush()
320 E_Client *focused_ec;
321 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
323 e_input_boost_lock(&connection_mutex);
324 focused_ec = e_client_focused_get();
328 struct wl_client *wc;
329 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
332 e_input_boost_unlock(&connection_mutex);
336 wc = wl_resource_get_client(surface);
340 e_input_boost_unlock(&connection_mutex);
344 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
348 if (e_comp_wl->idle_exiter_timestamp > 0.0)
350 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
351 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
353 ELOGF("E_COMP", "prepare gap time: %lfms",
358 e_comp_wl->idle_exiter_timestamp = 0.0;
360 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
362 /* flush pending client events */
363 e_comp_wl_display_flush();
365 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
366 IDLE_EXITER~CB_PREPARE);
369 E_API enum wl_output_transform
370 e_comp_wl_output_buffer_transform_get(E_Client *ec)
372 E_Comp_Wl_Buffer_Viewport *vp;
373 E_Comp_Wl_Buffer *buffer;
374 enum wl_output_transform transform, rotation;
376 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
377 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
378 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
380 vp = &ec->comp_data->scaler.buffer_viewport;
381 if (e_comp_wl_subsurface_check(ec))
382 return vp->buffer.transform;
384 buffer = ec->comp_data->buffer_ref.buffer;
387 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
388 return vp->buffer.transform;
390 rotation = buffer->transform;
392 return vp->buffer.transform;
394 /* ignore the flip value when calculating transform because the screen rotation
395 * functionality doesn't consider the flip output transform currently
397 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
399 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
400 ec, rotation, vp->buffer.transform, transform);
405 EINTERN enum wl_output_transform
406 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
408 E_Comp_Wl_Buffer_Viewport *vp;
409 E_Comp_Wl_Buffer *buffer;
410 enum wl_output_transform transform, rotation;
412 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
413 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
414 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
416 vp = &ec->comp_data->pending.buffer_viewport;
417 if (e_comp_wl_subsurface_check(ec))
418 return vp->buffer.transform;
420 buffer = ec->comp_data->pending.buffer;
423 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
424 return vp->buffer.transform;
426 rotation = buffer->transform;
428 return vp->buffer.transform;
430 /* ignore the flip value when calculating transform because the screen rotation
431 * functionality doesn't consider the flip output transform currently
433 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
435 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
436 ec, rotation, vp->buffer.transform, transform);
442 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
444 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
445 E_Comp_Wl_Buffer *buffer;
446 int32_t width, height;
448 buffer = e_pixmap_resource_get(ec->pixmap);
451 ec->comp_data->width_from_buffer = 0;
452 ec->comp_data->height_from_buffer = 0;
456 switch (e_comp_wl_output_buffer_transform_get(ec))
458 case WL_OUTPUT_TRANSFORM_90:
459 case WL_OUTPUT_TRANSFORM_270:
460 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
461 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
462 width = buffer->h / vp->buffer.scale;
463 height = buffer->w / vp->buffer.scale;
466 width = buffer->w / vp->buffer.scale;
467 height = buffer->h / vp->buffer.scale;
471 ec->comp_data->width_from_buffer = width;
472 ec->comp_data->height_from_buffer = height;
476 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
478 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
479 int32_t width, height;
481 width = ec->comp_data->width_from_buffer;
482 height = ec->comp_data->height_from_buffer;
484 if (width == 0 && height == 0) return;
486 if (width != 0 && vp->surface.width != -1)
488 ec->comp_data->width_from_viewport = vp->surface.width;
489 ec->comp_data->height_from_viewport = vp->surface.height;
493 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
495 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
496 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
497 ec->comp_data->width_from_viewport = w ?: 1;
498 ec->comp_data->height_from_viewport = h ?: 1;
502 ec->comp_data->width_from_viewport = width;
503 ec->comp_data->height_from_viewport = height;
507 e_comp_wl_topmost_parent_get(E_Client *ec)
511 if (!e_comp_wl_subsurface_check(ec))
514 parent = e_comp_wl_subsurface_parent_get(ec);
517 if (!e_comp_wl_subsurface_check(parent))
520 parent = e_comp_wl_subsurface_parent_get(parent);
527 e_comp_wl_map_apply(E_Client *ec)
529 E_Comp_Wl_Buffer_Viewport *vp;
530 E_Comp_Wl_Subsurf_Data *sdata;
531 E_Comp_Wl_Client_Data *cdata;
532 int x1, y1, x2, y2, x, y;
534 Eina_Bool zoom_animating = EINA_FALSE;
536 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
538 e_comp_object_map_update(ec->frame);
540 cdata = ec->comp_data;
541 vp = &cdata->scaler.buffer_viewport;
542 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
543 (!cdata->viewport_transform))
546 if (e_comp_wl_subsurface_check(ec))
548 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
550 sdata = ec->comp_data->sub.data;
551 if (sdata->remote_surface.offscreen_parent)
553 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
554 Eina_Rectangle *rect;
557 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
559 /* TODO: If there are one more regions, it means that provider's offscreen
560 * is displayed by one more remote_surfaces. Have to consider it later. At
561 * this time, just consider only one remote_surface.
575 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
576 if (x != dx || y != dy)
577 evas_object_move(ec->frame, dx, dy);
579 if (!cdata->viewport_transform)
581 cdata->viewport_transform = e_util_transform_new();
582 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
583 e_client_transform_core_add(ec, cdata->viewport_transform);
586 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
587 ec->comp_data->width_from_viewport,
588 ec->comp_data->height_from_viewport);
590 if (vp->buffer.src_width == wl_fixed_from_int(-1))
594 x2 = cdata->width_from_buffer;
595 y2 = cdata->height_from_buffer;
599 x1 = wl_fixed_to_int(vp->buffer.src_x);
600 y1 = wl_fixed_to_int(vp->buffer.src_y);
601 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
602 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
605 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
606 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
607 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
608 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
611 desk = e_comp_desk_find_by_ec(ec);
613 zoom_animating = e_desk_zoom_is_animating(desk);
615 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
616 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
617 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
619 /* workaround:: when the desk zoom is doing their animation,
620 the transform core update can override animation's zoom boundary.
621 so, don't doing transform core update while desk zoom animation */
623 e_client_transform_core_update(ec);
628 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
632 int map_c = 0, map_x = 0, map_y = 0;
633 double inv_x = 0.0, inv_y = 0.0;
635 EINA_SAFETY_ON_NULL_RETURN(ec);
637 map = e_client_map_get(ec);
638 map_c = e_map_count_get(map);
640 if (!map || map_c <= 0)
650 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
651 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
652 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
653 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
655 for (int i = 0; i < map_c; i++)
657 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
658 e_map_point_image_uv_set(map2, i, map_x, map_y);
660 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
670 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
676 if (!(ec = data)) return;
677 if (e_object_is_del(data)) return;
679 if (!ec->override) e_hints_window_visible_set(ec);
681 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
682 (!ec->comp_data->need_reparent))
684 ec->comp_data->need_reparent = EINA_TRUE;
685 ec->visible = EINA_TRUE;
687 if (!e_client_util_ignored_get(ec))
689 ec->take_focus = !starting;
693 if (!ec->comp_data->need_reparent)
695 if ((ec->hidden) || (ec->iconic))
697 evas_object_hide(ec->frame);
698 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
701 evas_object_show(ec->frame);
704 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
705 evas_object_show(tmp->frame);
707 topmost = e_comp_wl_topmost_parent_get(ec);
708 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
709 e_comp_wl_subsurface_show(ec);
711 if (ec->comp_data->sub.below_obj)
712 evas_object_show(ec->comp_data->sub.below_obj);
716 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
722 if (!(ec = data)) return;
723 if (e_object_is_del(E_OBJECT(ec))) return;
725 /* Uncommonly some clients's final buffer can be skipped if the client
726 * requests unmap of its surface right after wl_surface@commit.
727 * So if this client evas object is hidden state and client is already
728 * unmmapped, we can consider to clear pixmap image here mandatorily.
730 if (!ec->comp_data->mapped)
731 e_pixmap_image_clear(ec->pixmap, 1);
733 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
734 evas_object_hide(tmp->frame);
736 topmost = e_comp_wl_topmost_parent_get(ec);
737 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
738 e_comp_wl_subsurface_hide(ec);
740 if (ec->comp_data->sub.below_obj)
741 evas_object_hide(ec->comp_data->sub.below_obj);
743 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
747 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
754 if (!(ec = data)) return;
755 if (e_object_is_del(E_OBJECT(ec))) return;
757 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
759 if (!e_comp_wl_subsurface_check(subc)) continue;
760 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
761 evas_object_move(subc->frame, x, y);
763 if (subc->comp_data->scaler.viewport)
765 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
766 if (cdata->viewport_transform)
767 e_comp_wl_map_apply(subc);
771 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
773 if (!e_comp_wl_subsurface_check(subc)) continue;
774 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
775 evas_object_move(subc->frame, x, y);
777 if (subc->comp_data->scaler.viewport)
779 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
780 if (cdata->viewport_transform)
781 e_comp_wl_map_apply(subc);
785 if (ec->comp_data->sub.below_obj)
787 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
788 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
793 _e_comp_wl_send_touch_cancel(E_Client *ec)
796 struct wl_resource *res;
797 struct wl_client *wc;
798 E_Comp_Config *comp_conf = NULL;
801 if (e_object_is_del(E_OBJECT(ec))) return;
802 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
804 if (!surface) return;
805 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
807 wc = wl_resource_get_client(surface);
809 comp_conf = e_comp_config_get();
811 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
813 if (wl_resource_get_client(res) != wc) continue;
814 if (!e_comp_wl_input_touch_check(res)) continue;
816 if (comp_conf && comp_conf->input_log_enable)
817 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
819 wl_touch_send_cancel(res);
824 _e_comp_wl_touch_cancel(void)
828 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
830 if (!e_comp_wl->touch.pressed) return;
832 _e_comp_wl_send_touch_cancel(ec);
835 static E_Devicemgr_Input_Device *
836 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
838 E_Devicemgr_Input_Device *last_kbd = NULL;
841 case ECORE_DEVICE_CLASS_MOUSE:
842 return e_devicemgr->last_device_ptr;
843 case ECORE_DEVICE_CLASS_KEYBOARD:
844 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
846 case ECORE_DEVICE_CLASS_TOUCH:
847 return e_devicemgr->last_device_touch;
855 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
859 case ECORE_DEVICE_CLASS_MOUSE:
860 e_devicemgr->last_device_ptr = device;
862 case ECORE_DEVICE_CLASS_KEYBOARD:
863 atomic_store(&e_devicemgr->last_device_kbd, device);
865 case ECORE_DEVICE_CLASS_TOUCH:
866 e_devicemgr->last_device_touch = device;
873 static E_Devicemgr_Input_Device *
874 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
876 E_Devicemgr_Input_Device *last_kbd = NULL;
880 case ECORE_DEVICE_CLASS_MOUSE:
881 return ec->comp_data->last_device_ptr;
882 case ECORE_DEVICE_CLASS_KEYBOARD:
883 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
885 case ECORE_DEVICE_CLASS_TOUCH:
886 return ec->comp_data->last_device_touch;
894 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
898 case ECORE_DEVICE_CLASS_MOUSE:
899 ec->comp_data->last_device_ptr = device;
901 case ECORE_DEVICE_CLASS_KEYBOARD:
902 atomic_store(&ec->comp_data->last_device_kbd, device);
904 case ECORE_DEVICE_CLASS_TOUCH:
905 ec->comp_data->last_device_touch = device;
913 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
915 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
916 struct wl_resource *dev_res;
917 const char *dev_name;
918 Ecore_Device_Class dev_class;
919 struct wl_client *wc;
923 EINA_SAFETY_ON_NULL_RETURN(dev);
926 if (ec->cur_mouse_action || e_comp_wl->drag)
928 if (e_object_is_del(E_OBJECT(ec))) return;
929 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
930 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
931 if (!surface) return;
933 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
934 dev_name = evas_device_description_get(dev);
935 last_device = _e_comp_wl_device_last_device_get(dev_class);
936 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
938 serial = wl_display_next_serial(e_comp_wl->wl.disp);
939 wc = wl_resource_get_client(surface);
940 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
941 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
943 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
944 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
946 _e_comp_wl_device_last_device_set(dev_class, input_dev);
947 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
949 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
951 if (wl_resource_get_client(dev_res) != wc) continue;
952 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
956 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
960 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
962 E_Devicemgr_Input_Device *last_device;
963 struct wl_resource *dev_res;
964 struct wl_client *wc;
968 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
969 if (!surface) return;
971 last_device = _e_comp_wl_device_last_device_get(dev_class);
972 if (!last_device) return;
974 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
976 serial = wl_display_next_serial(e_comp_wl->wl.disp);
977 wc = wl_resource_get_client(surface);
978 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
980 if (wl_resource_get_client(dev_res) != wc) continue;
981 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
986 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
988 E_Devicemgr_Input_Device *input_dev;
989 struct wl_resource *dev_res;
990 const char *dev_name;
993 EINA_SAFETY_ON_NULL_RETURN(dev);
995 dev_name = ecore_device_identifier_get(dev);
997 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
998 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1000 if (!eina_streq(input_dev->identifier, dev_name) ||
1001 (input_dev->clas != ecore_device_class_get(dev))) continue;
1002 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1004 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1006 if (wl_resource_get_client(dev_res) != wc) continue;
1007 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1010 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1014 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1016 E_Devicemgr_Input_Device *input_dev;
1017 struct wl_resource *dev_res;
1018 const char *dev_name;
1021 EINA_SAFETY_ON_NULL_RETURN(dev);
1023 dev_name = e_device_identifier_get(dev);
1025 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1026 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1028 if (!eina_streq(input_dev->identifier, dev_name) ||
1029 (input_dev->clas != e_device_class_get(dev))) continue;
1030 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1032 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1034 if (wl_resource_get_client(dev_res) != wc) continue;
1035 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1038 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1042 _e_comp_wl_cursor_reload(E_Client *ec)
1044 struct wl_resource *res;
1045 struct wl_client *wc;
1051 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1052 !evas_object_visible_get(e_comp->pointer->o_ptr))
1053 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1056 if (e_object_is_del(E_OBJECT(ec))) return;
1057 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1058 if (!surface) return;
1059 if (ec->pointer_enter_sent) return;
1061 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1062 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1064 if (e_client_transform_core_enable_get(ec))
1066 double dx = 0.0, dy = 0.0;
1067 map = e_client_map_get(ec);
1068 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1074 cx = px - ec->client.x;
1075 cy = py - ec->client.y;
1077 wc = wl_resource_get_client(surface);
1078 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1079 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1081 if (!e_comp_wl_input_pointer_check(res)) continue;
1082 if (wl_resource_get_client(res) != wc) continue;
1083 wl_pointer_send_enter(res, serial, surface,
1084 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1085 ec->pointer_enter_sent = EINA_TRUE;
1087 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1091 _e_comp_wl_cursor_timer(void *data)
1093 E_Client *ec = data;
1095 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1096 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1098 e_comp_wl_cursor_hide(ec);
1100 return ECORE_CALLBACK_CANCEL;
1104 _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)
1106 E_Devicemgr_Input_Device *input_dev;
1107 struct wl_resource *dev_res;
1108 struct wl_client *wc;
1113 if (ec->cur_mouse_action) return;
1114 if (e_object_is_del(E_OBJECT(ec))) return;
1115 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1116 if (!surface) return;
1118 f_value = wl_fixed_from_double(value);
1119 wc = wl_resource_get_client(surface);
1121 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1122 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1124 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1125 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1127 if (wl_resource_get_client(dev_res) != wc) continue;
1128 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1131 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1135 _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)
1137 if (idx >= e_input_touch_max_count_get()) return;
1139 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1140 e_devicemgr->multi[idx].radius_x = radius_x;
1141 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1142 e_devicemgr->multi[idx].radius_y = radius_y;
1143 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1144 e_devicemgr->multi[idx].pressure = pressure;
1145 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1146 e_devicemgr->multi[idx].angle = angle;
1150 _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)
1152 if (idx >= e_input_touch_max_count_get()) return;
1154 if (e_devicemgr->multi[idx].radius_x != radius_x)
1156 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1157 e_devicemgr->multi[idx].radius_x = radius_x;
1159 if (e_devicemgr->multi[idx].radius_y != radius_y)
1161 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1162 e_devicemgr->multi[idx].radius_y = radius_y;
1164 if (e_devicemgr->multi[idx].pressure != pressure)
1166 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1167 e_devicemgr->multi[idx].pressure = pressure;
1169 if (e_devicemgr->multi[idx].angle != angle)
1171 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1172 e_devicemgr->multi[idx].angle = angle;
1177 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1179 Eina_Bool ret = EINA_TRUE;
1182 case EVAS_CALLBACK_MOUSE_IN:
1183 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1186 if (e_comp_wl->ptr.hide_tmr)
1188 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1189 cursor_timer_ec = ec;
1190 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1194 if (e_pointer_is_hidden(e_comp->pointer))
1199 case EVAS_CALLBACK_MOUSE_OUT:
1200 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1203 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1207 case EVAS_CALLBACK_MOUSE_MOVE:
1208 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1211 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1212 _e_comp_wl_cursor_reload(ec);
1215 case EVAS_CALLBACK_MOUSE_WHEEL:
1216 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1219 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1220 _e_comp_wl_cursor_reload(ec);
1223 case EVAS_CALLBACK_MOUSE_DOWN:
1224 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1227 if (e_comp_wl->ptr.hide_tmr)
1229 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1230 e_comp_wl->ptr.hide_tmr = NULL;
1232 cursor_timer_ec = NULL;
1234 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1235 _e_comp_wl_cursor_reload(ec);
1238 case EVAS_CALLBACK_MOUSE_UP:
1239 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1250 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1252 if (ec->has_cursor_unset)
1255 if (!e_config->show_cursor)
1258 if (!e_config->use_cursor_timer)
1265 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1268 Evas_Event_Mouse_In *ev;
1269 struct wl_resource *res;
1270 struct wl_client *wc;
1273 E_Comp_Config *comp_conf;
1274 E_Client *prev_ptr_ec;
1278 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1279 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1281 if (!(ec = data)) return;
1282 if (e_object_is_del(E_OBJECT(ec))) return;
1283 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1284 if (!surface) return;
1286 prev_ptr_ec = e_comp_wl->ptr.ec;
1289 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1290 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1293 e_comp_wl->ptr.ec = ec;
1295 comp_conf = e_comp_config_get();
1296 if (comp_conf && comp_conf->input_log_enable)
1297 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1298 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1299 e_client_util_name_get(ec));
1301 if (_e_comp_wl_check_cursor_timer_needed(ec))
1303 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1307 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1308 wc = wl_resource_get_client(surface);
1309 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1310 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1312 if (!e_comp_wl_input_pointer_check(res)) continue;
1313 if (wl_resource_get_client(res) != wc) continue;
1315 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1317 wl_pointer_send_enter(res, serial, surface,
1318 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1319 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1320 ec->pointer_enter_sent = EINA_TRUE;
1323 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1327 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1330 Evas_Event_Mouse_Out *ev;
1331 struct wl_resource *res;
1332 struct wl_client *wc;
1335 Eina_Bool inside_check;
1336 E_Comp_Config *comp_conf;
1340 if (!(ec = data)) return;
1341 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1342 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1343 if (ec->cur_mouse_action && inside_check) return;
1344 if (e_object_is_del(E_OBJECT(e_comp))) return;
1345 if (e_comp_wl->ptr.ec == ec)
1346 e_comp_wl->ptr.ec = NULL;
1347 if (e_object_is_del(E_OBJECT(ec))) return;
1349 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1350 if (!surface) return;
1352 comp_conf = e_comp_config_get();
1353 if (comp_conf && comp_conf->input_log_enable)
1354 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1355 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1356 e_client_util_name_get(ec));
1358 if (_e_comp_wl_check_cursor_timer_needed(ec))
1360 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1364 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1366 wc = wl_resource_get_client(surface);
1367 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1368 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1370 if (!e_comp_wl_input_pointer_check(res)) continue;
1371 if (wl_resource_get_client(res) != wc) continue;
1372 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1374 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1376 wl_pointer_send_leave(res, serial, surface);
1377 ec->pointer_enter_sent = EINA_FALSE;
1382 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1385 struct wl_client *wc;
1386 struct wl_resource *res;
1389 E_Comp_Config *comp_conf = NULL;
1392 if (e_object_is_del(E_OBJECT(ec))) return;
1393 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1394 if (!surface) return;
1396 wc = wl_resource_get_client(surface);
1397 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1401 x = wl_fixed_from_int(canvas_x - ec->client.x);
1402 y = wl_fixed_from_int(canvas_y - ec->client.y);
1405 comp_conf = e_comp_config_get();
1407 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1409 if (wl_resource_get_client(res) != wc) continue;
1410 if (!e_comp_wl_input_touch_check(res)) continue;
1411 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1414 if (comp_conf && comp_conf->input_log_enable)
1415 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));
1417 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1421 if (comp_conf && comp_conf->input_log_enable)
1422 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));
1424 wl_touch_send_up(res, serial, timestamp, idx);
1431 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1434 struct wl_client *wc;
1435 struct wl_resource *res;
1439 if (ec->cur_mouse_action) return;
1440 if (e_object_is_del(E_OBJECT(ec))) return;
1441 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1442 if (!surface) return;
1444 wc = wl_resource_get_client(surface);
1446 x = wl_fixed_from_int(canvas_x - ec->client.x);
1447 y = wl_fixed_from_int(canvas_y - ec->client.y);
1449 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1451 if (wl_resource_get_client(res) != wc) continue;
1452 if (!e_comp_wl_input_touch_check(res)) continue;
1453 wl_touch_send_motion(res, timestamp, idx, x, y);
1458 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1460 struct wl_resource *res;
1461 struct wl_client *wc;
1465 if (ec->cur_mouse_action) return;
1466 if (e_object_is_del(E_OBJECT(ec))) return;
1467 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1468 if (!surface) return;
1470 wc = wl_resource_get_client(surface);
1471 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1473 if (!e_comp_wl_input_pointer_check(res)) continue;
1474 if (wl_resource_get_client(res) != wc) continue;
1475 wl_pointer_send_motion(res, timestamp,
1476 wl_fixed_from_int(x - ec->client.x),
1477 wl_fixed_from_int(y - ec->client.y));
1482 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1484 if (e_comp_wl->ptr.hide_tmr)
1486 if (cursor_timer_ec == ec)
1488 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1489 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1493 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1494 cursor_timer_ec = ec;
1495 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1500 cursor_timer_ec = ec;
1501 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1506 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1509 Evas_Event_Mouse_Move *ev;
1510 Evas_Device *dev = NULL;
1511 const char *dev_name;
1512 E_Comp_Config *comp_conf;
1516 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1517 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1519 if (!(ec = data)) return;
1520 if (e_object_is_del(E_OBJECT(ec))) return;
1521 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1522 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1523 if (!surface) return;
1525 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1528 dev_name = evas_device_description_get(dev);
1530 comp_conf = e_comp_config_get();
1531 if (comp_conf && comp_conf->input_log_enable)
1532 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1533 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1534 e_client_util_name_get(ec), dev_name);
1536 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1538 if (!e_comp_wl->drag_client)
1540 e_comp_wl->touch.faked_ec = ec;
1541 if (e_comp_wl->touch.pressed & (1 << 0))
1543 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1545 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1546 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1547 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1551 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1555 if (!e_comp_wl->drag_client)
1557 if (_e_comp_wl_check_cursor_timer_needed(ec))
1559 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1563 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1564 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1566 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1568 if (_e_comp_wl_check_cursor_timer_needed(ec))
1569 _e_comp_wl_cursor_move_timer_control(ec);
1573 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1578 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1580 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1581 if (e_object_is_del(E_OBJECT(ec))) return;
1582 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1583 if (!surface) return;
1584 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1586 e_comp_wl->ptr.button = BTN_LEFT;
1588 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1592 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1594 E_Client *ec = data;
1595 Evas_Event_Mouse_Down *ev = event;
1596 Evas_Device *dev = NULL;
1597 const Evas_Device *seat_dev;
1598 const char *dev_name, *seat_name;
1599 E_Comp_Config *comp_conf = NULL;
1602 if (e_object_is_del(E_OBJECT(ec))) return;
1605 dev_name = evas_device_description_get(dev);
1607 seat_dev = evas_device_parent_get(dev);
1608 seat_name = evas_device_name_get(seat_dev);
1610 comp_conf = e_comp_config_get();
1611 if (comp_conf && comp_conf->input_log_enable)
1612 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1613 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1614 dev_name, seat_name);
1616 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1618 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1620 e_comp_wl->touch.faked_ec = ec;
1623 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1624 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1625 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1627 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1628 e_comp_wl->touch.pressed |= (1 << 0);
1632 if (_e_comp_wl_check_cursor_timer_needed(ec))
1634 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1638 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1639 WL_POINTER_BUTTON_STATE_PRESSED);
1641 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1644 need_send_released = EINA_TRUE;
1648 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1650 E_Client *ec = data;
1651 Evas_Event_Mouse_Up *ev = event;
1652 Evas_Device *dev = NULL;
1653 const Evas_Device *seat_dev;
1654 const char *dev_name, *seat_name;;
1655 Evas_Event_Flags flags;
1656 E_Comp_Config *comp_conf = NULL;
1659 if (ec->cur_mouse_action) return;
1660 if (e_object_is_del(E_OBJECT(ec))) return;
1662 if (!need_send_released)
1664 need_send_motion = EINA_TRUE;
1668 dev_name = evas_device_description_get(dev);
1670 seat_dev = evas_device_parent_get(dev);
1671 seat_name = evas_device_name_get(seat_dev);
1672 flags = evas_event_default_flags_get(evas);
1674 comp_conf = e_comp_config_get();
1675 if (comp_conf && comp_conf->input_log_enable)
1676 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1677 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1678 dev_name, seat_name);
1680 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1682 e_comp_wl->touch.pressed &= ~(1 << 0);
1684 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1685 e_comp_wl->touch.faked_ec = NULL;
1688 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1690 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1692 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1695 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1696 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1697 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1701 if (_e_comp_wl_check_cursor_timer_needed(ec))
1703 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1707 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1708 WL_POINTER_BUTTON_STATE_RELEASED);
1710 if (_e_comp_wl_check_cursor_timer_needed(ec))
1711 _e_comp_wl_cursor_move_timer_control(ec);
1715 need_send_released = EINA_FALSE;
1719 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1721 struct wl_resource *res;
1722 struct wl_client *wc;
1727 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1729 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1732 dir = -wl_fixed_from_int(abs(z));
1734 dir = wl_fixed_from_int(z);
1737 if (e_object_is_del(E_OBJECT(ec))) return;
1738 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1739 if (!surface) return;
1741 wc = wl_resource_get_client(surface);
1742 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1744 if (!e_comp_wl_input_pointer_check(res)) continue;
1745 if (wl_resource_get_client(res) != wc) continue;
1746 wl_pointer_send_axis(res, timestamp, axis, dir);
1751 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1754 Evas_Event_Mouse_Wheel *ev;
1757 if (!(ec = data)) return;
1758 if (ec->cur_mouse_action) return;
1759 if (e_object_is_del(E_OBJECT(ec))) return;
1760 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1761 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1762 if (!surface) return;
1764 if (!eina_list_count(e_comp_wl->ptr.resources))
1767 if (_e_comp_wl_check_cursor_timer_needed(ec))
1769 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1773 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1775 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1777 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1779 if (_e_comp_wl_check_cursor_timer_needed(ec))
1780 _e_comp_wl_cursor_move_timer_control(ec);
1785 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1787 E_Client *ec = data;
1788 Evas_Event_Multi_Down *ev = event;
1789 Evas_Device *dev = NULL;
1790 const Evas_Device *seat_dev;
1791 const char *dev_name, *seat_name;
1792 Evas_Device_Class dev_class;
1793 E_Comp_Config *comp_conf = NULL;
1796 if (e_object_is_del(E_OBJECT(ec))) return;
1797 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1798 if (!surface) return;
1800 /* Do not deliver emulated single touch events to client */
1801 if (ev->device == 0) return;
1804 dev_name = evas_device_description_get(dev);
1805 e_comp_wl->touch.faked_ec = ec;
1807 seat_dev = evas_device_parent_get(dev);
1808 seat_name = evas_device_name_get(seat_dev);
1810 comp_conf = e_comp_config_get();
1811 if (comp_conf && comp_conf->input_log_enable)
1812 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1813 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1814 dev_name, seat_name);
1816 if (dev && dev_name)
1818 dev_class = evas_device_class_get(dev);
1819 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1820 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1823 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1824 e_comp_wl->touch.pressed |= (1 << ev->device);
1828 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1830 E_Client *ec = data;
1831 Evas_Event_Multi_Up *ev = event;
1832 Evas_Device *dev = NULL;
1833 const Evas_Device *seat_dev;
1834 const char *dev_name, *seat_name;
1835 Evas_Device_Class dev_class;
1836 Evas_Event_Flags flags;
1837 E_Comp_Config *comp_conf = NULL;
1840 if (e_object_is_del(E_OBJECT(ec))) return;
1841 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1842 if (!surface) return;
1844 /* Do not deliver emulated single touch events to client */
1845 if (ev->device == 0) return;
1847 flags = evas_event_default_flags_get(evas);
1849 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1850 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1851 e_comp_wl->touch.faked_ec = NULL;
1853 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1856 dev_name = evas_device_description_get(dev);
1858 seat_dev = evas_device_parent_get(dev);
1859 seat_name = evas_device_name_get(seat_dev);
1861 comp_conf = e_comp_config_get();
1862 if (comp_conf && comp_conf->input_log_enable)
1863 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1864 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1865 dev_name, seat_name);
1867 if (dev && dev_name)
1869 dev_class = evas_device_class_get(dev);
1870 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1871 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1874 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1878 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1880 E_Client *ec = data;
1881 Evas_Event_Multi_Move *ev = event;
1882 Evas_Device *dev = NULL;
1883 const char *dev_name;
1884 Evas_Device_Class dev_class;
1887 if (e_object_is_del(E_OBJECT(ec))) return;
1888 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1889 if (!surface) return;
1891 /* Do not deliver emulated single touch events to client */
1892 if (ev->device == 0) return;
1894 e_comp_wl->touch.faked_ec = ec;
1896 if (e_comp_wl->touch.pressed & (1 << ev->device))
1899 if (dev && (dev_name = evas_device_description_get(dev)))
1901 dev_class = evas_device_class_get(dev);
1902 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1903 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1906 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1911 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1914 char *file, buff[PATH_MAX];
1921 n = (getpriority(PRIO_PROCESS, pid) + adj);
1925 setpriority(PRIO_PROCESS, pid, n);
1928 use_adj = EINA_TRUE;
1930 if (!do_child) return;
1932 files = ecore_file_ls("/proc");
1933 EINA_LIST_FREE(files, file)
1935 if (!isdigit(file[0]))
1938 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1939 if ((f = fopen(buff, "r")))
1943 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1945 if (num_read == 2 && ppid == pid)
1946 _e_comp_wl_client_priority_adjust(pid2, set,
1948 adj_child, do_child);
1956 _e_comp_wl_client_priority_raise(E_Client *ec)
1958 if (!e_config->priority_control) return;
1959 if (ec->netwm.pid <= 0) return;
1960 if (ec->netwm.pid == getpid()) return;
1961 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1962 e_config->priority - 1, -1,
1963 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1967 _e_comp_wl_client_priority_normal(E_Client *ec)
1969 if (!e_config->priority_control) return;
1970 if (ec->netwm.pid <= 0) return;
1971 if (ec->netwm.pid == getpid()) return;
1972 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1973 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1977 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1980 E_Comp_Wl_Key_Data *k;
1981 struct wl_resource *res;
1985 if (!ec) return EINA_FALSE;
1986 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1987 if (!ec->comp_data) return EINA_FALSE;
1989 ec->comp_data->on_focus_timer = NULL;
1990 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1991 if (!e_comp_wl->kbd.focused)
1993 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1996 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1998 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1999 t = ecore_time_unix_get();
2001 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2002 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2003 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2005 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2007 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2008 wl_keyboard_send_key(res, serial, t,
2009 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2012 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2013 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2017 /* It is called in the following cases:
2018 * When a normal ec->frame has focus.
2019 * Or launching image ec is replaced to the real ec.
2022 e_comp_wl_feed_focus_in(E_Client *ec)
2025 struct wl_resource *res;
2026 struct wl_client *wc;
2030 if (e_object_is_del(E_OBJECT(ec))) return;
2031 if (ec->iconic) return;
2033 /* block spurious focus events */
2034 focused = e_client_focused_get();
2035 if ((focused) && (ec != focused)) return;
2037 /* raise client priority */
2038 _e_comp_wl_client_priority_raise(ec);
2039 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2040 if (!surface) return;
2042 wc = wl_resource_get_client(surface);
2044 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2045 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2047 if (wl_resource_get_client(res) == wc)
2049 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2050 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2051 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2052 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2055 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2057 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2058 if (!e_comp_wl->kbd.focused)
2060 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2063 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2065 e_comp_wl->kbd.focus = surface;
2066 e_comp_wl_input_keyboard_enter_send(ec);
2067 e_comp_wl_data_device_keyboard_focus_set();
2068 ec->comp_data->on_focus_timer =
2069 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2070 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2071 int rotation = ec->e.state.rot.ang.curr;
2072 e_pointer_rotation_set(e_comp->pointer, rotation);
2076 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2079 if (!(ec = data)) return;
2080 e_comp_wl_feed_focus_in(ec);
2084 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2087 struct wl_resource *res;
2089 E_Comp_Wl_Key_Data *k;
2093 if (!(ec = data)) return;
2095 if (!ec->comp_data) return;
2097 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2099 /* lower client priority */
2100 if (!e_object_is_del(data))
2101 _e_comp_wl_client_priority_normal(ec);
2104 /* update keyboard modifier state */
2105 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2106 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2107 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2109 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2111 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2112 if (!surface) return;
2114 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2115 if (!eina_list_count(e_comp_wl->kbd.resources))
2117 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2121 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2123 /* send keyboard_leave to all keyboard resources */
2124 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2125 t = ecore_time_unix_get();
2127 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2128 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2129 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2131 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2133 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2134 wl_keyboard_send_key(res, serial, t,
2135 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2137 wl_keyboard_send_leave(res, serial, surface);
2138 e_comp_wl->kbd.focused =
2139 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2141 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2142 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2146 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2150 if (!(ec = data)) return;
2152 if (!ec->comp_data->shell.configure_send) return;
2154 /* TODO: calculate x, y with transfrom object */
2155 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2159 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2160 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2161 if (e_comp_object_frame_exists(ec->frame))
2162 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2164 switch (ec->resize_mode)
2166 case E_POINTER_RESIZE_TL:
2167 case E_POINTER_RESIZE_L:
2168 case E_POINTER_RESIZE_BL:
2169 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2170 ec->mouse.current.mx;
2172 case E_POINTER_RESIZE_TR:
2173 case E_POINTER_RESIZE_R:
2174 case E_POINTER_RESIZE_BR:
2175 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2180 switch (ec->resize_mode)
2182 case E_POINTER_RESIZE_TL:
2183 case E_POINTER_RESIZE_T:
2184 case E_POINTER_RESIZE_TR:
2185 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2186 ec->mouse.current.my;
2188 case E_POINTER_RESIZE_BL:
2189 case E_POINTER_RESIZE_B:
2190 case E_POINTER_RESIZE_BR:
2191 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2196 w = E_CLAMP(w, 1, w);
2197 h = E_CLAMP(h, 1, h);
2198 e_client_resize_limit(ec, &w, &h);
2200 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2202 else if ((!ec->fullscreen) && (!ec->maximized) &&
2203 (!ec->comp_data->maximize_pre))
2207 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2208 if ((pw != ec->w) || (ph != ec->h))
2210 _e_comp_wl_configure_send(ec, 1, 1);
2214 if (ec->comp_data->sub.below_obj)
2215 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2219 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2221 E_Client *ec = data;
2223 ec->comp_data->maximize_pre = 1;
2227 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2229 E_Client *ec = data;
2232 if (e_object_is_del(E_OBJECT(ec))) return;
2234 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2235 e_client_shell_configure_send(ec, 0, w, h);
2237 ec->comp_data->maximize_pre = 0;
2241 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2243 E_Client *ec = data;
2245 ec->comp_data->maximize_pre = 1;
2249 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2251 E_Client *ec = data;
2253 if (e_object_is_del(E_OBJECT(ec))) return;
2255 /* check for wayland pixmap */
2257 if (ec->comp_data->shell.configure_send)
2258 _e_comp_wl_configure_send(ec, 0, 0);
2260 ec->comp_data->maximize_pre = 0;
2264 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2266 E_Client *ec = data;
2268 if (e_object_is_del(E_OBJECT(ec))) return;
2270 /* check for wayland pixmap */
2272 if (ec->comp_data->shell.configure_send)
2273 _e_comp_wl_configure_send(ec, 0, 1);
2275 ec->comp_data->maximize_pre = 0;
2279 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2281 E_Client *ec = data;
2283 if (e_object_is_del(E_OBJECT(ec))) return;
2285 /* check for wayland pixmap */
2287 if (ec->comp_data->shell.configure_send)
2288 _e_comp_wl_configure_send(ec, 0, 0);
2290 ec->comp_data->maximize_pre = 0;
2294 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2298 if (!(ec = data)) return;
2300 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2302 e_object_del(E_OBJECT(ec));
2304 _e_comp_wl_focus_check();
2306 /* TODO: Delete request send ??
2307 * NB: No such animal wrt wayland */
2311 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2315 if (!(ec = data)) return;
2317 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2320 if (ec->comp_data->reparented)
2321 e_client_comp_hidden_set(ec, EINA_TRUE);
2324 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2325 if (ec->visible) evas_object_hide(ec->frame);
2326 if (!ec->internal) e_object_del(E_OBJECT(ec));
2328 _e_comp_wl_focus_check();
2332 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2336 if (!(ec = data)) return;
2338 e_client_shell_ping(ec);
2342 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2347 if (!(ec = data)) return;
2348 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2349 if (ec->netwm.opacity == a) return;
2350 ec->netwm.opacity = a;
2351 ec->netwm.opacity_changed = EINA_TRUE;
2355 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2357 Eina_Rectangle *damage_rect = NULL;
2358 Eina_Rectangle *dmg = NULL;
2359 Eina_List *l = NULL;
2361 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2362 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2365 if (!buffer->tbm_surface) return;
2369 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2373 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2374 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2377 eina_rectangle_union(damage_rect, dmg);
2382 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2383 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2386 tbm_surface_internal_set_damage(buffer->tbm_surface,
2392 eina_rectangle_free(damage_rect);
2396 _e_comp_wl_client_evas_init(E_Client *ec)
2398 if (!ec || !ec->comp_data) return;
2399 if (ec->comp_data->evas_init) return;
2401 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2402 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2403 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2406 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2407 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2408 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2409 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2410 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2411 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2413 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2414 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2415 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2417 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2418 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2422 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2423 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2424 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2425 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2426 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2427 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2428 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2431 /* setup delete/kill callbacks */
2432 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2433 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2435 /* setup ping callback */
2436 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2437 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2439 ec->comp_data->evas_init = EINA_TRUE;
2443 _e_comp_wl_client_evas_deinit(E_Client *ec)
2445 if (!ec || !ec->comp_data) return;
2446 if (!ec->comp_data->evas_init) return;
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2449 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2453 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2454 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2455 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2456 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2457 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2459 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2460 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2461 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2463 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2464 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2468 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2469 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2470 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2471 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2472 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2473 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2474 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2477 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2478 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2480 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2481 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2483 ec->comp_data->evas_init = EINA_FALSE;
2487 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2491 E_Comp_Screen *e_comp_screen;
2492 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2494 if (!e_comp) return ECORE_CALLBACK_RENEW;
2495 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2496 e_comp_screen = e_comp->e_comp_screen;
2498 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2500 if (!eout->config.enabled)
2502 e_comp_wl_output_remove(eout->id);
2506 switch (eout->config.rotation)
2509 transform = WL_OUTPUT_TRANSFORM_90;
2512 transform = WL_OUTPUT_TRANSFORM_180;
2515 transform = WL_OUTPUT_TRANSFORM_270;
2519 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2523 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2525 eout->config.geom.x, eout->config.geom.y,
2526 eout->config.geom.w, eout->config.geom.h,
2527 eout->info.size.w, eout->info.size.h,
2528 eout->config.mode.refresh, 0, transform))
2529 ERR("Could not initialize screen %s", eout->info.name);
2532 return ECORE_CALLBACK_RENEW;
2536 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2540 /* try to get the client from the object */
2541 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2542 return ECORE_CALLBACK_RENEW;
2544 /* check for client being deleted */
2545 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2547 /* check for wayland pixmap */
2548 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2549 return ECORE_CALLBACK_RENEW;
2551 /* if we have not setup evas callbacks for this client, do it */
2552 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2554 return ECORE_CALLBACK_RENEW;
2558 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2562 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2563 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2565 if (e_comp_wl->selection.target &&
2568 struct wl_resource *res;
2570 E_Client *ec = NULL;
2571 E_Client *legacy_target = e_comp_wl->selection.target;
2572 int device_id = e_comp_wl_data_current_device_id_get();
2576 e_comp_wl_data_current_device_id_set(ev->multi.device);
2578 else if (device_id != ev->multi.device)
2580 return ECORE_CALLBACK_RENEW;
2583 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2584 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2586 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2587 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2589 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2590 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2592 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2593 (ec != legacy_target))
2595 e_comp_wl_data_device_send_leave(legacy_target);
2596 e_comp_wl_data_device_send_enter(ec);
2599 if (e_comp_wl->drag)
2600 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2602 if (e_client_transform_core_enable_get(ec))
2604 int trans_x, trans_y;
2605 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2606 x = trans_x - ec->client.x;
2607 y = trans_y - ec->client.y;
2611 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2616 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2619 return ECORE_CALLBACK_RENEW;
2623 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2626 struct wl_resource *surface;
2627 struct wl_resource *res;
2628 struct wl_client *wc;
2630 E_Comp_Config *comp_conf;
2632 ec = e_comp_wl->ptr_constraints.ec;
2633 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2635 surface = e_comp_wl_client_surface_get(ec);
2636 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2638 wc = wl_resource_get_client(surface);
2640 comp_conf = e_comp_config_get();
2642 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2644 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2645 if (wl_resource_get_client(res) != wc) continue;
2647 if (comp_conf && comp_conf->input_log_enable)
2648 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2649 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2650 e_client_util_name_get(ec));
2652 zwp_relative_pointer_v1_send_relative_motion(res,
2654 (uint32_t)(ev->timestamp),
2655 wl_fixed_from_int(ev->dx),
2656 wl_fixed_from_int(ev->dy),
2657 wl_fixed_from_int(ev->dx_unaccel),
2658 wl_fixed_from_int(ev->dy_unaccel));
2661 return ECORE_CALLBACK_DONE;
2665 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2667 _e_comp_wl_touch_cancel();
2669 return ECORE_CALLBACK_PASS_ON;
2673 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2675 if (!ev) return ECORE_CALLBACK_PASS_ON;
2677 E_Zone *zone = ev->zone;
2679 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2680 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2682 if (!e_zone_is_displaying(zone))
2683 _e_comp_wl_touch_cancel();
2685 return ECORE_CALLBACK_PASS_ON;
2689 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2691 E_Client *ec = ev->ec;
2692 E_Comp_Wl_Buffer_Viewport *vp;
2694 if (!ec) return ECORE_CALLBACK_PASS_ON;
2695 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2696 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2697 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2698 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2700 vp = &ec->comp_data->scaler.buffer_viewport;
2701 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2703 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2705 return ECORE_CALLBACK_PASS_ON;
2709 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2711 E_Client *ec = ev->ec;
2712 E_Comp_Wl_Buffer_Viewport *vp;
2714 if (!ec) return ECORE_CALLBACK_PASS_ON;
2715 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2716 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2717 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2719 vp = &ec->comp_data->scaler.buffer_viewport;
2720 vp->wait_for_transform_change = 0;
2722 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2724 return ECORE_CALLBACK_PASS_ON;
2728 _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)
2730 E_Client *focused_ec;
2733 focused_ec = e_client_focused_get();
2734 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2736 rotation = focused_ec->e.state.rot.ang.curr;
2737 e_pointer_rotation_set(e_comp->pointer, rotation);
2739 return ECORE_CALLBACK_PASS_ON;
2743 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2746 Eina_Rectangle *window;
2751 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2753 if ((prev_w != state->bw) ||
2754 (prev_h != state->bh))
2756 ec->changes.buf_size = EINA_TRUE;
2759 if (e_comp_object_frame_exists(ec->frame)) return;
2760 window = &ec->comp_data->shell.window;
2761 if ((!ec->borderless) && /* FIXME temporarily added this check code
2762 * to prevent updating E_Client's size by frame */
2763 (window->x || window->y || window->w || window->h))
2765 e_comp_object_frame_geometry_set(ec->frame,
2767 (window->x + window->w) - state->bw,
2769 (window->y + window->h) - state->bh);
2772 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2776 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2778 E_Comp_Wl_Surface_State *state;
2781 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2782 state->buffer = NULL;
2786 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2788 state->new_attach = EINA_FALSE;
2789 state->buffer = NULL;
2790 state->buffer_destroy_listener.notify =
2791 _e_comp_wl_surface_state_cb_buffer_destroy;
2792 state->sx = state->sy = 0;
2794 state->input = eina_tiler_new(w, h);
2795 eina_tiler_tile_size_set(state->input, 1, 1);
2797 state->opaque = eina_tiler_new(w, h);
2798 eina_tiler_tile_size_set(state->opaque, 1, 1);
2800 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2801 state->buffer_viewport.buffer.scale = 1;
2802 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2803 state->buffer_viewport.surface.width = -1;
2804 state->buffer_viewport.changed = 0;
2806 e_presentation_time_container_init(&state->presentation_container);
2810 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2812 struct wl_resource *cb;
2813 Eina_Rectangle *dmg;
2815 EINA_LIST_FREE(state->frames, cb)
2816 wl_resource_destroy(cb);
2818 EINA_LIST_FREE(state->damages, dmg)
2819 eina_rectangle_free(dmg);
2821 EINA_LIST_FREE(state->buffer_damages, dmg)
2822 eina_rectangle_free(dmg);
2824 if (state->opaque) eina_tiler_free(state->opaque);
2825 state->opaque = NULL;
2827 if (state->input) eina_tiler_free(state->input);
2828 state->input = NULL;
2830 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2831 state->buffer = NULL;
2833 e_presentation_time_container_finish(&state->presentation_container);
2837 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2839 if (state->buffer == buffer) return;
2841 wl_list_remove(&state->buffer_destroy_listener.link);
2842 state->buffer = buffer;
2844 wl_signal_add(&state->buffer->destroy_signal,
2845 &state->buffer_destroy_listener);
2849 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2851 Eina_Rectangle *dmg;
2852 Eina_Bool placed = EINA_TRUE;
2856 E_Comp_Wl_Buffer *buffer;
2857 struct wl_resource *cb;
2859 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2860 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2865 if ((ec->internal) ||
2866 (cdata->shell.surface && state->new_attach))
2870 e_comp->new_clients++;
2871 ELOGF("COMP", "Unignore", ec);
2872 e_client_unignore(ec);
2876 /* buffer transform */
2877 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2880 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2882 /* when buffer is transformed, we have to apply the new evas-map */
2883 state->buffer_viewport.changed = EINA_TRUE;
2885 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2887 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2889 if (transform_change == vp->wait_for_transform_change)
2890 vp->wait_for_transform_change = 0;
2892 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2893 // triggered by E_CLIENT_HOOK calls at those file.
2894 zone = e_comp_zone_find_by_ec(ec);
2897 eout = e_output_find(zone->output_id);
2898 if (eout && eout->hwc)
2900 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2902 if (e_comp_is_on_overlay(ec))
2903 e_comp_hwc_client_end(ec, __FUNCTION__);
2909 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2910 cdata->scaler.buffer_viewport = state->buffer_viewport;
2912 if (state->new_attach)
2914 e_comp_wl_surface_attach(ec, state->buffer);
2917 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2918 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2920 _e_comp_wl_surface_state_buffer_set(state, NULL);
2922 if ((state->new_attach) ||
2923 (state->buffer_viewport.changed))
2925 _e_comp_wl_surface_state_size_update(ec, state);
2926 e_comp_wl_map_size_cal_from_viewport(ec);
2928 /* update the position */
2929 if (ec->changes.pos)
2931 e_comp_object_frame_xy_unadjust(ec->frame,
2941 if (ec->new_client) placed = ec->placed;
2943 if (!ec->lock_client_size)
2948 ec->client.w = state->bw;
2949 ec->client.h = state->bh;
2951 e_comp_object_frame_wh_adjust(ec->frame,
2952 ec->client.w, ec->client.h,
2954 e_client_size_set(ec, nw, nh);
2956 if ((w != ec->w) || (h != ec->h))
2958 ec->changes.size = 1;
2963 if (ec->changes.buf_size)
2965 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2966 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2967 ec->changes.buf_size = EINA_FALSE;
2969 if (ec->move_after_resize)
2971 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2972 ec->move_after_resize = EINA_FALSE;
2977 /* map or unmap ec */
2978 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2979 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2980 if (!pixmap_usable || hide_by_request)
2985 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2990 if ((cdata->sub.below_obj) &&
2991 (evas_object_visible_get(cdata->sub.below_obj)))
2993 evas_object_hide(cdata->sub.below_obj);
3001 if ((cdata->sub.below_obj) &&
3002 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3003 (evas_object_visible_get(ec->frame)))
3005 evas_object_show(cdata->sub.below_obj);
3009 if ((state->new_attach) ||
3010 (state->buffer_viewport.changed))
3012 if ((e_comp_wl->drag) &&
3013 (e_comp_wl->drag_client) &&
3014 (e_comp_wl->drag_client == ec))
3016 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3018 e_drag_move(e_comp_wl->drag,
3020 e_comp_wl->drag->y);
3022 e_drag_resize(e_comp_wl->drag,
3023 state->bw, state->bh);
3025 else if ((cdata->shell.surface) &&
3026 (cdata->shell.configure))
3028 e_comp_wl_commit_sync_configure(ec);
3030 else if (!e_client_video_hw_composition_check(ec))
3032 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3037 ec->placed = placed;
3038 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3042 if (cdata->scaler.buffer_viewport.changed)
3043 e_comp_wl_map_apply(ec);
3045 /* resize transform object */
3046 if (ec->transformed)
3047 e_client_transform_update(ec);
3051 state->new_attach = EINA_FALSE;
3053 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3055 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3056 wl_resource_destroy(cb);
3059 /* insert state frame callbacks into comp_data->frames
3060 * NB: This clears state->frames list */
3061 cdata->frames = eina_list_merge(cdata->frames,
3063 state->frames = NULL;
3065 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3066 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3067 &state->presentation_container);
3069 buffer = e_pixmap_resource_get(ec->pixmap);
3071 /* put state damages into surface */
3074 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3075 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3077 if ((cdata->buffer_ref.buffer) &&
3078 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3079 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3081 e_comp_object_damage(ec->frame,
3083 cdata->buffer_ref.buffer->w,
3084 cdata->buffer_ref.buffer->h);
3089 Eina_List *damages = NULL;
3092 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3094 if (eina_list_count(state->buffer_damages))
3096 EINA_LIST_FREE(state->buffer_damages, dmg)
3099 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3100 e_comp_wl_output_buffer_transform_get(ec),
3102 dmg->x, dmg->y, dmg->w, dmg->h,
3103 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3104 damages = eina_list_append(damages, dmg);
3108 EINA_LIST_FREE(state->damages, dmg)
3109 damages = eina_list_append(damages, dmg);
3111 EINA_LIST_FREE(damages, dmg)
3113 /* not creating damage for ec that shows a underlay video */
3114 if (state->buffer_viewport.changed ||
3115 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3116 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3117 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3119 eina_rectangle_free(dmg);
3124 /* put state opaque into surface */
3125 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3128 Eina_Rectangle *rect;
3131 itr = eina_tiler_iterator_new(state->opaque);
3132 EINA_ITERATOR_FOREACH(itr, rect)
3136 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3137 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3138 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3142 eina_iterator_free(itr);
3145 /* put state input into surface */
3146 if ((state->input) &&
3147 (!eina_tiler_empty(state->input)) &&
3150 Eina_Tiler *src, *tmp;
3154 tmp = eina_tiler_new(sw, sh);
3155 eina_tiler_tile_size_set(tmp, 1, 1);
3157 eina_tiler_rect_add(tmp,
3158 &(Eina_Rectangle){0, 0, sw, sh});
3160 if ((src = eina_tiler_intersection(state->input, tmp)))
3162 Eina_Rectangle *rect;
3165 e_comp_object_input_objs_del(ec->frame);
3166 itr = eina_tiler_iterator_new(src);
3167 EINA_ITERATOR_FOREACH(itr, rect)
3169 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3170 ec, rect->x, rect->y, rect->w, rect->h,
3171 ec->w, ec->h, state->bw, state->bh);
3172 e_comp_object_input_area_set(ec->frame,
3177 eina_iterator_free(itr);
3178 eina_tiler_free(src);
3181 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3183 eina_tiler_free(tmp);
3185 /* clear input tiler */
3186 eina_tiler_clear(state->input);
3189 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3191 if ((cdata->video_client) &&
3193 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3194 (e_comp->wl_comp_data->available_hw_accel.underlay))
3196 e_pixmap_image_clear(ec->pixmap, 1);
3199 state->buffer_viewport.changed = 0;
3201 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3204 ec->exp_iconify.buffer_flush &&
3205 e_policy_visibility_client_is_iconic(ec))
3207 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3212 _e_comp_wl_surface_render_stop(E_Client *ec)
3214 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3215 //if ((!ec->internal) && (!e_comp_gl_get()))
3218 /* check if internal animation is running */
3219 if (e_comp_object_is_animating(ec->frame)) return;
3220 /* check if external animation is running */
3221 if (evas_object_data_get(ec->frame, "effect_running")) return;
3223 evas_object_hide(ec->frame);
3227 e_comp_wl_client_surface_finish(E_Client *ec)
3229 struct wl_resource *res, *surface;
3230 struct wl_client *surface_client = NULL;
3233 surface = e_comp_wl_client_surface_get(ec);
3236 surface_client = wl_resource_get_client(surface);
3238 if (surface_client &&
3239 (ec == e_client_focused_get()))
3241 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3242 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3244 if (wl_resource_get_client(res) ==
3246 e_comp_wl->kbd.focused =
3247 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3251 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3254 e_comp_wl_client_surface_set(ec, NULL);
3256 ec->comp_data->wl_surface = NULL;
3257 e_pixmap_win_id_del(ec->pixmap);
3259 _e_comp_wl_surface_render_stop(ec);
3260 e_object_del(E_OBJECT(ec));
3264 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3269 char proc[512], pname[512];
3272 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3274 h = fopen(proc, "r");
3277 len = fread(pname, sizeof(char), 512, h);
3279 pname[len - 1] = '\0';
3281 strncpy(pname, "NO NAME", sizeof(pname));
3287 strncpy(pname, "NO NAME", sizeof(pname));
3290 strncpy(name, pname, size);
3294 _e_comp_wl_pname_print(pid_t pid)
3297 char proc[512], pname[512];
3300 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3302 h = fopen(proc, "r");
3305 len = fread(pname, sizeof(char), 512, h);
3307 pname[len - 1] = '\0';
3309 strncpy(pname, "NO NAME", sizeof(pname));
3313 ELOGF("COMP", " |%s", NULL, pname);
3318 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3320 struct wl_client *client = data;
3321 E_Comp_Connected_Client_Info *cinfo;
3324 cinfo = wl_container_of(listener, cinfo, destroy);
3326 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3327 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3329 eai = e_appinfo_find_with_pid(cinfo->pid);
3330 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3333 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3335 wl_list_remove(&cinfo->destroy.link);
3336 eina_stringshare_del(cinfo->name);
3341 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3343 E_Comp_Connected_Client_Info *cinfo;
3345 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3346 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3348 cinfo->name = eina_stringshare_add(name);
3352 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3353 wl_client_add_destroy_listener(client, &cinfo->destroy);
3354 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3356 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3360 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3362 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3364 /* send configure */
3365 if (ec->comp_data->shell.configure_send)
3367 if (ec->comp_data->shell.surface)
3368 _e_comp_wl_configure_send(ec, 0, 0);
3371 e_comp_wl->kbd.focus = ec->comp_data->surface;
3375 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3377 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3379 /* send configure */
3380 if (ec->comp_data->shell.configure_send)
3382 if (ec->comp_data->shell.surface)
3383 _e_comp_wl_configure_send(ec, 0, 0);
3386 _e_comp_wl_focus_check();
3388 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3389 e_comp_wl->kbd.focus = NULL;
3393 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3395 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3396 if (ec->keyboard_resizing) return;
3398 /* do nothing currently */
3403 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3405 if (e_object_is_del(E_OBJECT(ec))) return;
3406 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3408 e_comp_wl->resize.edges = 0;
3409 e_comp_wl->resize.resource = NULL;
3413 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3415 if (e_object_is_del(E_OBJECT(ec))) return;
3416 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3420 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3423 int ratio_w, ratio_h;
3425 phys_w = output->phys_width;
3426 phys_h = output->phys_height;
3428 if (e_config->configured_output_resolution.use)
3430 // change the configured physical size(mm) of the output
3431 if (output->w != res_w)
3433 ratio_w = res_w / output->w;
3434 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3437 if (output->h != res_h)
3439 ratio_h = res_h / output->h;
3440 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3443 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3446 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3447 NULL, res_w, res_h, phys_w, phys_h, pid);
3449 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3450 wl_output_send_scale(resource, output->scale);
3452 wl_output_send_geometry(resource, output->x, output->y,
3454 output->subpixel, output->make ?: "",
3455 output->model ?: "", output->transform);
3457 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3458 res_w, res_h, output->refresh);
3460 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3461 wl_output_send_done(resource);
3465 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3467 E_Comp_Wl_Output *output;
3469 if (!(output = wl_resource_get_user_data(resource))) return;
3471 output->resources = eina_list_remove(output->resources, resource);
3475 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3477 E_Comp_Wl_Output *output;
3478 struct wl_resource *resource;
3479 E_Appinfo *eai = NULL;
3483 if (!(output = data)) return;
3486 wl_resource_create(client, &wl_output_interface, version, id);
3489 wl_client_post_no_memory(client);
3493 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3494 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3496 output->resources = eina_list_append(output->resources, resource);
3498 wl_resource_set_implementation(resource, NULL, output,
3499 _e_comp_wl_cb_output_unbind);
3500 wl_resource_set_user_data(resource, output);
3502 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3503 if (e_config->configured_output_resolution.use)
3505 wl_client_get_credentials(client, &pid, NULL, NULL);
3508 res_w = e_config->configured_output_resolution.w;
3509 res_h = e_config->configured_output_resolution.h;
3513 eai = e_appinfo_find_with_pid(pid);
3516 res_w = e_config->configured_output_resolution.w;
3517 res_h = e_config->configured_output_resolution.h;
3521 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3523 res_w = e_config->configured_output_resolution.w;
3524 res_h = e_config->configured_output_resolution.h;
3528 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3537 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3541 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3544 Evas_GL *evasgl = NULL;
3545 Evas_GL_API *glapi = NULL;
3546 Evas_GL_Context *ctx = NULL;
3547 Evas_GL_Surface *sfc = NULL;
3548 Evas_GL_Config *cfg = NULL;
3550 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3552 if (!e_comp_gl_get()) return;
3554 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3555 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3557 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3558 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3560 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3561 * then we should get evas from ecore_evas.
3564 evas = e_comp->evas;
3566 evas = ecore_evas_get(e_comp->ee);
3568 evasgl = evas_gl_new(evas);
3569 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3571 glapi = evas_gl_api_get(evasgl);
3572 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3573 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3575 cfg = evas_gl_config_new();
3576 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3578 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3579 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3581 ctx = evas_gl_context_create(evasgl, NULL);
3582 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3584 res = evas_gl_make_current(evasgl, sfc, ctx);
3585 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3587 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3588 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3590 evas_gl_config_free(cfg);
3592 evas_gl->gl = evasgl;
3593 evas_gl->glapi = glapi;
3594 evas_gl->glsfc = sfc;
3595 evas_gl->glctx = ctx;
3597 e_comp_wl->evas_gl = evas_gl;
3599 /* for native surface */
3602 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3607 evas_gl_config_free(cfg);
3608 evas_gl_make_current(evasgl, NULL, NULL);
3609 evas_gl_context_destroy(evasgl, ctx);
3610 evas_gl_surface_destroy(evasgl, sfc);
3611 evas_gl_free(evasgl);
3618 _e_comp_wl_gl_popup_cb_close(void *data,
3619 Evas_Object *obj EINA_UNUSED,
3620 void *event_info EINA_UNUSED)
3622 evas_object_del(data);
3626 _e_comp_wl_gl_popup_cb_focus(void *data,
3627 Evas_Object *obj EINA_UNUSED,
3628 void *event_info EINA_UNUSED)
3630 elm_object_focus_set(data, EINA_TRUE);
3635 _e_comp_wl_gl_idle(void *data)
3639 /* show warning window to notify failure of gl init */
3642 Evas_Object *win, *bg, *popup, *btn;
3644 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3645 elm_win_title_set(win, "Compositor Warning");
3646 elm_win_autodel_set(win, EINA_TRUE);
3647 elm_win_borderless_set(win, EINA_TRUE);
3648 elm_win_role_set(win, "notification-low");
3649 elm_win_alpha_set(win, EINA_TRUE);
3651 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3652 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3653 elm_win_resize_object_add(win, bg);
3654 evas_object_color_set(bg, 125, 125, 125, 125);
3655 evas_object_show(bg);
3657 popup = elm_popup_add(win);
3658 elm_object_text_set(popup,
3659 _( "Your screen does not support OpenGL.<br>"
3660 "Falling back to software engine."));
3661 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3663 btn = elm_button_add(popup);
3664 elm_object_text_set(btn, "Close");
3665 elm_object_part_content_set(popup, "button1", btn);
3666 evas_object_show(btn);
3668 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3669 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3671 evas_object_show(popup);
3672 evas_object_show(win);
3676 return ECORE_CALLBACK_CANCEL;
3680 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3682 struct wl_client *client = data;
3688 wl_client_get_credentials(client, &pid, &uid, &gid);
3690 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3692 _e_comp_wl_pname_print(pid);
3693 _e_comp_wl_pname_get(pid, name, sizeof(name));
3694 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3698 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3700 char buf[1024] = {0, };
3702 vsnprintf(buf, 1024, fmt, args);
3706 DBG("[libds] %s", buf);
3709 INF("[libds] %s", buf);
3712 ERR("[libds] %s", buf);
3720 _e_comp_wl_display_create(void)
3723 E_Comp_Wl_Data *wl_cdata;
3728 /* create new compositor data */
3729 if (!(comp = E_NEW(E_Comp_Data, 1)))
3731 ERR("Could not create compositor data: %m");
3734 wl_cdata = &comp->base;
3736 /* set compositor wayland data */
3737 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3739 g_mutex_init(&connection_mutex);
3741 /* try to create a wayland display */
3742 if (!(wl_cdata->wl.disp = wl_display_create()))
3744 ERR("Could not create a Wayland display: %m");
3748 /* try to setup wayland socket */
3749 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3751 ERR("Could not create Wayland display socket: %m");
3752 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3756 res = e_comp_socket_init(name);
3757 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3758 PRCTL("[Winsys] change permission and create sym link for %s", name);
3760 /* set wayland display environment variable */
3761 e_env_set("WAYLAND_DISPLAY", name);
3763 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3764 /* wl_cdata->output.scale = e_scale; */
3766 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3768 if (!e_compositor_init(wl_cdata->wl.disp))
3770 ERR("Failed to initialize compositor");
3774 comp->client_created.notify = _e_comp_wl_cb_client_created;
3775 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3777 if (!e_comp_wl_subsurfaces_init())
3779 ERR("Failed to init_subsurfaces");
3780 goto subsurfaces_err;
3783 /* initialize shm mechanism */
3784 wl_display_init_shm(wl_cdata->wl.disp);
3786 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3788 /* try to init data manager */
3789 if (!e_comp_wl_data_manager_init())
3791 ERR("Could not initialize data manager");
3795 /* try to init input */
3796 if (!e_comp_wl_input_init())
3798 ERR("Could not initialize input");
3802 if (e_comp_gl_get())
3803 _e_comp_wl_gl_init(NULL);
3805 /* get the wayland display loop */
3806 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3808 /* get the file descriptor of the wayland event loop */
3809 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3811 /* create a listener for wayland main loop events */
3813 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3814 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3815 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3816 _e_comp_wl_cb_prepare, wl_cdata);
3821 e_comp_wl_data_manager_shutdown();
3823 e_comp_wl_subsurfaces_shutdown();
3825 wl_list_remove(&comp->client_created.link);
3827 e_env_unset("WAYLAND_DISPLAY");
3829 wl_display_destroy(wl_cdata->wl.disp);
3831 g_mutex_clear(&connection_mutex);
3837 _e_comp_wl_gl_shutdown(void)
3839 if (!e_comp_wl->evas_gl) return;
3841 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3843 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3844 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3845 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3846 evas_gl_free(e_comp_wl->evas_gl->gl);
3848 E_FREE(e_comp_wl->evas_gl);
3851 /* public functions */
3854 * Creates and initializes a Wayland compositor with ecore.
3855 * Registers callback handlers for keyboard and mouse activity
3856 * and other client events.
3858 * @returns true on success, false if initialization failed.
3861 e_comp_wl_init(void)
3863 TRACE_DS_BEGIN(COMP_WL:INIT);
3865 /* try to create a wayland compositor */
3866 if (!_e_comp_wl_display_create())
3868 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3873 e_comp_wl_shell_init();
3875 #ifdef HAVE_WAYLAND_TBM
3876 e_comp_wl_tbm_init();
3878 e_comp_wl_remote_surface_init();
3882 e_comp_wl_screenshooter_init();
3884 if (!e_comp_wl_video_init())
3885 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3887 e_comp_wl_viewport_init();
3888 e_comp_wl_capture_init();
3889 e_comp_wl_renderer_init();
3890 _e_comp_wl_move_resize_init();
3891 e_presentation_time_init();
3892 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3895 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3896 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3898 /* add event handlers to catch E events */
3899 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3900 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3901 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3902 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3903 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3904 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3905 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3906 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3907 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3909 /* add hooks to catch e_client events */
3910 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3911 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3912 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3913 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3914 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3916 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3923 e_comp_wl_deferred_job(void)
3925 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3928 /* internal functions */
3930 e_comp_wl_shutdown(void)
3932 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3934 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3936 e_comp_wl_subsurfaces_shutdown();
3938 E_FREE_LIST(handlers, ecore_event_handler_del);
3939 E_FREE_LIST(hooks, e_client_hook_del);
3940 _e_comp_wl_gl_shutdown();
3942 e_blender_shutdown();
3943 e_presentation_time_shutdown();
3944 e_comp_wl_renderer_shutdown();
3945 e_comp_wl_capture_shutdown();
3946 e_comp_wl_viewport_shutdown();
3947 e_comp_wl_video_shutdown();
3948 e_comp_wl_screenshooter_shutdown();
3950 e_comp_wl_remote_surface_shutdown();
3952 e_pixmap_shutdown();
3954 e_wtz_shell_shutdown();
3955 e_comp_wl_shell_shutdown();
3956 e_comp_wl_input_shutdown();
3958 wl_list_remove(&comp->client_created.link);
3961 e_comp->wl_comp_data = NULL;
3965 E_Comp_Wl_Output *output;
3967 if (e_comp_wl->screenshooter.global)
3968 wl_global_destroy(e_comp_wl->screenshooter.global);
3970 EINA_LIST_FREE(e_comp_wl->outputs, output)
3972 if (output->id) eina_stringshare_del(output->id);
3973 if (output->make) eina_stringshare_del(output->make);
3974 if (output->model) eina_stringshare_del(output->model);
3978 /* delete fd handler */
3979 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3981 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3982 cursor_timer_ec = NULL;
3984 /* free allocated data structure */
3990 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3992 e_object_unref(E_OBJECT(ev->ec));
3997 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4000 ev = E_NEW(E_Event_Client, 1);
4003 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4005 /* set usable early because shell module checks this */
4006 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4007 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4009 e_pixmap_resource_set(ec->pixmap, buffer);
4010 e_pixmap_dirty(ec->pixmap);
4011 e_pixmap_refresh(ec->pixmap);
4013 e_comp_wl_map_size_cal_from_buffer(ec);
4014 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4016 /* wm-policy module uses it */
4017 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4020 e_object_ref(E_OBJECT(ec));
4021 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4022 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4026 e_comp_wl_surface_commit(E_Client *ec)
4031 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4032 if (!e_comp_object_damage_exists(ec->frame))
4034 if ((ec->comp_data->video_client) ||
4035 (!e_client_video_hw_composition_check(ec)))
4036 e_pixmap_image_clear(ec->pixmap, 1);
4039 ignored = ec->ignored;
4041 if (e_comp_wl_subsurface_order_commit(ec))
4043 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4044 e_comp_wl_subsurface_restack(topmost);
4045 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4048 ec->ignored = ignored;
4050 if (ec->is_cursor && ec->visible)
4052 /* ignore cursor changes during resize/move I guess */
4053 if (!e_client_action_get())
4055 if (e_comp->pointer)
4057 x = e_comp->pointer->hot.x;
4058 y = e_comp->pointer->hot.y;
4060 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4066 static E_Comp_Wl_Output *
4067 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4070 E_Comp_Wl_Output *output;
4072 EINA_LIST_FOREACH(outputs, l, output)
4074 if (!strcmp(output->id, id))
4082 * Initializes information about one display output.
4084 * Adds or updates the given data about a single display output,
4085 * with an id matching the provided id.
4087 * @param id identification of output to be added or changed
4088 * @param make manufacturer name of the display output
4089 * @param model model name of the display output
4090 * @param x output's top left corner x coordinate
4091 * @param y output's top left corner y coordinate
4092 * @param w output's width in pixels
4093 * @param h output's height in pixels
4094 * @param pw output's physical width in millimeters
4095 * @param ph output's physical height in millimeters
4096 * @param refresh output's refresh rate in mHz
4097 * @param subpixel output's subpixel layout
4098 * @param transform output's rotation and/or mirror transformation
4100 * @returns True if a display output object could be added or updated
4103 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4104 int x, int y, int w, int h, int pw, int ph,
4105 unsigned int refresh, unsigned int subpixel,
4106 unsigned int transform)
4108 E_Comp_Wl_Output *output;
4110 struct wl_resource *resource;
4112 /* retrieve named output; or create it if it doesn't exist */
4113 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4116 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4118 if (id) output->id = eina_stringshare_add(id);
4120 output->make = eina_stringshare_add(make);
4122 output->make = eina_stringshare_add("unknown");
4124 output->model = eina_stringshare_add(model);
4126 output->model = eina_stringshare_add("unknown");
4128 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4131 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4132 2, output, _e_comp_wl_cb_output_bind);
4134 output->resources = NULL;
4135 output->scale = e_scale;
4138 /* update the output details */
4143 output->phys_width = pw;
4144 output->phys_height = ph;
4145 output->refresh = refresh;
4146 output->subpixel = subpixel;
4147 output->transform = transform;
4149 if (output->scale <= 0)
4150 output->scale = e_scale;
4152 /* if we have bound resources, send updates */
4153 EINA_LIST_FOREACH(output->resources, l2, resource)
4155 wl_output_send_geometry(resource,
4156 output->x, output->y,
4158 output->phys_height,
4160 output->make ?: "", output->model ?: "",
4163 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4164 wl_output_send_scale(resource, output->scale);
4166 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4167 output->w, output->h, output->refresh);
4169 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4170 wl_output_send_done(resource);
4177 e_comp_wl_output_remove(const char *id)
4179 E_Comp_Wl_Output *output;
4181 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4184 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4186 /* wl_global_destroy(output->global); */
4188 /* eina_stringshare_del(output->id); */
4189 /* eina_stringshare_del(output->make); */
4190 /* eina_stringshare_del(output->model); */
4197 _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)
4199 struct wl_resource *res;
4201 uint32_t serial, keycode;
4202 struct wl_client *wc = NULL;
4203 E_Comp_Config *comp_conf = NULL;
4204 const char *device_name = NULL;
4206 keycode = (ev->keycode - 8);
4208 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4210 comp_conf = e_comp_config_get();
4212 if (ec && ec->comp_data)
4214 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4217 wc = wl_resource_get_client(surface);
4220 if (e_config->key_input_ttrace_enable)
4222 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4223 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4226 EINA_LIST_FOREACH(key_list, l, res)
4228 if (wl_resource_get_client(res) != wc) continue;
4230 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4231 if (!e_input_thread_mode_get())
4233 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4234 device_name = ecore_device_name_get(ev->dev);
4240 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4241 device_name = e_device_name_get(dev);
4245 if (comp_conf && comp_conf->input_log_enable)
4246 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4248 wl_keyboard_send_key(res, serial, ev->timestamp,
4253 if (e_config->key_input_ttrace_enable)
4256 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4261 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4263 E_Client *ec = NULL;
4265 E_Comp_Wl_Key_Data *end, *k;
4267 if (ev->window != e_comp->ee_win)
4272 keycode = (ev->keycode - 8);
4273 if (!(e_comp_wl = e_comp->wl_comp_data))
4278 #ifndef E_RELEASE_BUILD
4279 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4280 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4281 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4282 eina_streq(ev->key, "BackSpace"))
4288 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4290 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4292 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4294 /* ignore server-generated key repeats */
4295 if (k->key == keycode)
4297 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4302 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4304 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4306 ec = e_client_focused_get();
4307 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4308 if (ec && ec->comp_data && surface)
4310 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4311 if (e_comp_wl->kbd.focused)
4313 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4315 /* A key only sent to clients is added to the list */
4316 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4317 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4319 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4321 DBG("wl_array_add: Out of memory\n");
4322 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4323 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4326 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4330 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4334 /* update modifier state */
4335 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4341 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4343 E_Client *ec = NULL;
4344 uint32_t keycode, delivered_key;
4345 E_Comp_Wl_Key_Data *end, *k;
4347 if (ev->window != e_comp->ee_win)
4352 keycode = (ev->keycode - 8);
4354 if (!(e_comp_wl = e_comp->wl_comp_data))
4359 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4361 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4362 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4364 if (k->key == keycode)
4371 e_comp_wl->kbd.keys.size =
4372 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4374 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4376 /* 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) */
4377 if ((delivered_key) ||
4378 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4380 ec = e_client_focused_get();
4382 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4383 if (e_comp_wl->kbd.focused)
4385 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4387 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4390 /* update modifier state */
4391 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4397 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4399 Eina_Bool res = EINA_FALSE;
4401 if (type == ECORE_EVENT_KEY_DOWN)
4403 res = e_comp_wl_key_down(ev, dev);
4405 else if (type == ECORE_EVENT_KEY_UP)
4407 res = e_comp_wl_key_up(ev, dev);
4414 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4417 struct wl_client *wc;
4418 uint32_t serial, btn;
4419 struct wl_resource *res;
4420 E_Comp_Config *comp_conf = NULL;
4422 if (ec->cur_mouse_action || e_comp_wl->drag)
4424 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4425 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4429 case 1: btn = BTN_LEFT; break;
4430 case 2: btn = BTN_MIDDLE; break;
4431 case 3: btn = BTN_RIGHT; break;
4432 default: btn = button_id; break;
4435 e_comp_wl->ptr.button = btn;
4436 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4437 if (!surface) return EINA_FALSE;
4439 if (!eina_list_count(e_comp_wl->ptr.resources))
4442 wc = wl_resource_get_client(surface);
4443 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4445 comp_conf = e_comp_config_get();
4447 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4449 if (wl_resource_get_client(res) != wc) continue;
4450 if (!e_comp_wl_input_pointer_check(res)) continue;
4451 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4453 if (comp_conf && comp_conf->input_log_enable)
4454 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4456 wl_pointer_send_button(res, serial, timestamp, btn, state);
4463 e_comp_wl_touch_cancel(void)
4465 _e_comp_wl_touch_cancel();
4468 E_API E_Comp_Wl_Hook *
4469 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4473 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4474 ch = E_NEW(E_Comp_Wl_Hook, 1);
4475 if (!ch) return NULL;
4476 ch->hookpoint = hookpoint;
4478 ch->data = (void*)data;
4479 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4484 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4487 if (_e_comp_wl_hooks_walking == 0)
4489 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4493 _e_comp_wl_hooks_delete++;
4496 E_API E_Comp_Wl_Pid_Hook *
4497 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4499 E_Comp_Wl_Pid_Hook *ch;
4501 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4503 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4504 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4506 ch->hookpoint = hookpoint;
4508 ch->data = (void*)data;
4509 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4515 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4518 if (_e_comp_wl_pid_hooks_walking == 0)
4520 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4524 _e_comp_wl_pid_hooks_delete++;
4527 E_API E_Comp_Wl_Intercept_Hook *
4528 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4530 E_Comp_Wl_Intercept_Hook *ch;
4532 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4533 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4534 if (!ch) return NULL;
4535 ch->hookpoint = hookpoint;
4537 ch->data = (void*)data;
4538 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4543 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4546 if (_e_comp_wl_intercept_hooks_walking == 0)
4548 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4552 _e_comp_wl_intercept_hooks_delete++;
4556 e_comp_wl_shell_surface_ready(E_Client *ec)
4560 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4564 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4566 e_config->use_cursor_timer = !!enabled;
4568 if (e_config->use_cursor_timer)
4570 if (!e_pointer_is_hidden(e_comp->pointer))
4572 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4577 if (e_comp_wl->ptr.hide_tmr)
4579 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4580 e_comp_wl->ptr.hide_tmr = NULL;
4582 cursor_timer_ec = NULL;
4584 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4587 if (e_pointer_is_hidden(e_comp->pointer))
4589 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4595 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4597 EINA_SAFETY_ON_NULL_RETURN(wc);
4598 EINA_SAFETY_ON_NULL_RETURN(dev);
4600 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4604 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4606 EINA_SAFETY_ON_NULL_RETURN(wc);
4607 EINA_SAFETY_ON_NULL_RETURN(dev);
4609 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4613 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4615 struct wl_resource *res;
4616 struct wl_client *wc;
4618 uint32_t serial, wl_keycode;
4619 enum wl_keyboard_key_state state;
4620 E_Comp_Config *comp_conf = NULL;
4621 const char *dev_name = NULL;
4623 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4624 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4625 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4627 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4628 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4630 wl_keycode = keycode - 8;
4631 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4633 wc = wl_resource_get_client(surface);
4634 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4635 if (!time) time = e_util_timestamp_get();
4636 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4637 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4639 comp_conf = e_comp_config_get();
4640 e_keyrouter_event_surface_send(ec, keycode);
4642 if (e_config->key_input_ttrace_enable)
4644 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4645 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4648 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4649 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4651 if (wl_resource_get_client(res) != wc) continue;
4652 if (!e_input_thread_mode_get())
4656 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4657 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4661 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4668 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4669 dev_name = e_device_name_get(dev);
4673 if (comp_conf && comp_conf->input_log_enable)
4674 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4677 wl_keyboard_send_key(res, serial, time,
4680 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4682 if (e_config->key_input_ttrace_enable)
4685 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4692 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4694 struct wl_resource *res;
4695 struct wl_client *wc;
4697 uint32_t serial, wl_keycode, cancel_keycode;
4698 E_Comp_Config *comp_conf = NULL;
4699 struct xkb_keymap *keymap = NULL;
4701 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4702 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4703 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4705 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4706 keymap = e_comp_wl->xkb.keymap;
4707 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4708 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4710 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4711 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4713 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4714 if (cancel_keycode == XKB_KEYCODE_INVALID)
4716 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4719 cancel_keycode = cancel_keycode - 8;
4721 wl_keycode = keycode - 8;
4722 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4724 wc = wl_resource_get_client(surface);
4725 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4726 if (!time) time = e_util_timestamp_get();
4728 comp_conf = e_comp_config_get();
4729 e_keyrouter_event_surface_send(ec, keycode);
4731 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4732 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4734 if (wl_resource_get_client(res) != wc) continue;
4735 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4736 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4738 if (comp_conf && comp_conf->input_log_enable)
4739 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4740 wl_keyboard_send_key(res, serial, time,
4741 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4742 wl_keyboard_send_key(res, serial, time,
4743 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4744 wl_keyboard_send_key(res, serial, time,
4745 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4747 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4754 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)
4756 struct wl_client *wc;
4758 E_Devicemgr_Input_Device *device = NULL;
4760 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4761 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4762 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4764 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4765 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4767 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4769 wc = wl_resource_get_client(surface);
4770 if (!time) time = e_util_timestamp_get();
4771 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4775 _e_comp_wl_send_event_device(wc, time, dev, serial);
4776 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4780 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4781 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4784 x = x + ec->client.x;
4785 y = y + ec->client.y;
4787 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4793 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)
4795 E_Devicemgr_Input_Device *device;
4797 struct wl_client *wc;
4799 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4800 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4801 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4803 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4804 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4806 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4808 wc = wl_resource_get_client(surface);
4809 if (!time) time = e_util_timestamp_get();
4810 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4814 _e_comp_wl_send_event_device(wc, time, dev, serial);
4815 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4819 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4820 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4823 x = x + ec->client.x;
4824 y = y + ec->client.y;
4826 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4832 e_comp_wl_touch_cancel_send(E_Client *ec)
4834 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4835 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4836 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4838 _e_comp_wl_send_touch_cancel(ec);
4844 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4847 struct wl_client *wc;
4849 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4850 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4851 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4853 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4854 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4856 wc = wl_resource_get_client(surface);
4857 if (!time) time = e_util_timestamp_get();
4858 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4860 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4861 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4864 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4865 WL_POINTER_BUTTON_STATE_PRESSED);
4867 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4868 WL_POINTER_BUTTON_STATE_RELEASED);
4874 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4877 struct wl_client *wc;
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4880 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4881 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4883 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4884 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4886 wc = wl_resource_get_client(surface);
4887 if (!time) time = e_util_timestamp_get();
4888 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4890 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4891 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4893 x = x + ec->client.x;
4894 y = y + ec->client.y;
4896 _e_comp_wl_send_mouse_move(ec, x, y, time);
4902 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4905 struct wl_client *wc;
4907 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4908 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4909 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4911 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4912 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4914 wc = wl_resource_get_client(surface);
4915 if (!time) time = e_util_timestamp_get();
4916 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4918 if (_e_comp_wl_check_cursor_timer_needed(ec))
4920 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4924 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4925 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4927 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4929 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4931 if (_e_comp_wl_check_cursor_timer_needed(ec))
4932 _e_comp_wl_cursor_move_timer_control(ec);
4939 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4942 struct wl_client *wc;
4943 struct wl_resource *res;
4946 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4947 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4949 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4950 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4952 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4953 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4955 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4956 wc = wl_resource_get_client(surface);
4957 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4958 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4960 if (!e_comp_wl_input_pointer_check(res)) continue;
4961 if (wl_resource_get_client(res) != wc) continue;
4963 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4964 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4966 wl_pointer_send_enter(res, serial, surface,
4967 wl_fixed_from_int(x),
4968 wl_fixed_from_int(y));
4969 ec->pointer_enter_sent = EINA_TRUE;
4971 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4977 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4980 struct wl_client *wc;
4981 struct wl_resource *res;
4984 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4985 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4986 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4987 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4988 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4989 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4991 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4992 wc = wl_resource_get_client(surface);
4993 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4994 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4996 if (!e_comp_wl_input_pointer_check(res)) continue;
4997 if (wl_resource_get_client(res) != wc) continue;
4999 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5000 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5002 wl_pointer_send_leave(res, serial, surface);
5003 ec->pointer_enter_sent = EINA_FALSE;
5010 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)
5012 Evas_Event_Mouse_In ev_in;
5015 if (ec->pointer_enter_sent) return;
5017 ev_in.buttons = buttons;
5025 ev_in.modifiers = modifiers;
5026 ev_in.locks = locks;
5027 ev_in.timestamp = timestamp;
5028 ev_in.event_flags = event_flags;
5031 ev_in.event_src = event_src;
5033 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5037 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)
5039 Evas_Event_Mouse_Out ev_out;
5042 if (!ec->pointer_enter_sent) return;
5044 ev_out.buttons = buttons;
5046 ev_out.output.x = x;
5047 ev_out.output.y = y;
5048 ev_out.canvas.x = x;
5049 ev_out.canvas.y = y;
5052 ev_out.modifiers = modifiers;
5053 ev_out.locks = locks;
5054 ev_out.timestamp = timestamp;
5055 ev_out.event_flags = event_flags;
5058 ev_out.event_src = event_src;
5060 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5064 e_comp_wl_cursor_hide(E_Client *ec)
5066 struct wl_resource *res;
5067 struct wl_client *wc;
5071 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5073 if (e_comp_wl->ptr.hide_tmr)
5075 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5076 e_comp_wl->ptr.hide_tmr = NULL;
5078 cursor_timer_ec = NULL;
5080 if (!ec) return EINA_FALSE;
5081 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5082 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5083 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5085 wc = wl_resource_get_client(surface);
5086 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5087 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5089 if (!e_comp_wl_input_pointer_check(res)) continue;
5090 if (wl_resource_get_client(res) != wc) continue;
5091 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5092 wl_pointer_send_leave(res, serial, surface);
5093 ec->pointer_enter_sent = EINA_FALSE;
5099 /* surface to buffer
5100 * - width : surface width
5101 * - height : surface height
5102 * - transform: buffer transform
5103 * - scale : buffer scale
5105 * - width : screen width
5106 * - height : screen height
5107 * - transform: output transform
5108 * - scale : output scale
5110 static E_Util_Transform_Matrix
5111 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5113 E_Util_Transform_Matrix m;
5115 e_util_transform_matrix_load_identity(&m);
5117 if (transform & 0x4)
5119 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5120 e_util_transform_matrix_flip_x(&m);
5121 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5124 switch (transform & 0x3)
5126 case WL_OUTPUT_TRANSFORM_90:
5127 e_util_transform_matrix_translate(&m, -width, 0, 0);
5128 e_util_transform_matrix_rotation_z(&m, 270);
5130 case WL_OUTPUT_TRANSFORM_180:
5131 e_util_transform_matrix_translate(&m, -width, -height, 0);
5132 e_util_transform_matrix_rotation_z(&m, 180);
5134 case WL_OUTPUT_TRANSFORM_270:
5135 e_util_transform_matrix_translate(&m, 0, -height, 0);
5136 e_util_transform_matrix_rotation_z(&m, 90);
5142 e_util_transform_matrix_scale(&m, scale, scale, 1);
5147 /* surface to buffer
5148 * - surface width, surface height, buffer transform, buffer scale
5150 * - screen width, screen height, output transform, output scale
5153 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5155 E_Util_Transform_Matrix m;
5156 E_Util_Transform_Vertex v;
5158 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5160 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5161 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5162 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5166 * - buffer width, buffer height, buffer transform, buffer scale
5169 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5171 E_Util_Transform_Matrix m;
5172 E_Util_Transform_Vertex v;
5175 if (transform != 0 || scale > 1)
5177 tw = ((transform % 2) ? height : width) / scale;
5178 th = ((transform % 2) ? width : height) / scale;
5186 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5187 m = e_util_transform_matrix_inverse_get(&m);
5189 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5190 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5191 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5194 /* surface to buffer
5195 * - surface width, surface height, buffer transform, buffer scale
5197 * - screen width, screen height, output transform, output scale
5200 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5201 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5203 E_Util_Transform_Matrix m;
5204 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5205 E_Util_Transform_Rect_Vertex sv;
5207 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5209 sv = e_util_transform_rect_to_vertices(&sr);
5210 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5211 sr = e_util_transform_vertices_to_rect(&sv);
5220 * - buffer width, buffer height, buffer transform, buffer scale
5223 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5224 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5226 E_Util_Transform_Matrix m;
5227 E_Util_Transform_Rect br = {bx, by, bw, bh};
5228 E_Util_Transform_Rect_Vertex bv;
5231 if (transform != 0 || scale > 1)
5233 tw = ((transform % 2) ? height : width) / scale;
5234 th = ((transform % 2) ? width : height) / scale;
5242 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5243 m = e_util_transform_matrix_inverse_get(&m);
5245 bv = e_util_transform_rect_to_vertices(&br);
5246 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5247 br = e_util_transform_vertices_to_rect(&bv);
5255 EINTERN E_Comp_Wl_Output*
5256 e_comp_wl_output_find(E_Client *ec)
5259 E_Comp_Wl_Output *output;
5261 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5263 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5265 if (output->transform % 2)
5267 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5268 ec->y < output->x || ec->y >= (output->x + output->w))
5273 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5274 ec->y < output->y || ec->y >= (output->y + output->h))
5284 EINTERN Eina_Array *
5285 e_comp_wl_output_find_all(E_Client *ec)
5287 E_Comp_Wl_Output *output;
5288 Eina_Array *outputs;
5291 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5293 outputs = eina_array_new(4);
5297 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5299 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5300 output->x, output->y, output->w, output->h))
5302 eina_array_push(outputs, output);
5306 if (eina_array_count(outputs) == 0)
5308 eina_array_free(outputs);
5315 // --------------------------------------------------------
5316 // tizen_move_resize
5317 // --------------------------------------------------------
5319 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5326 E_Client_Pending_Geometry *geo;
5329 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5330 if (ec->fullscreen || ec->maximized) goto err;
5332 geo = E_NEW(E_Client_Pending_Geometry, 1);
5335 geo->serial = serial;
5341 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5342 ec->surface_sync.wait_commit = EINA_TRUE;
5347 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5354 e_comp_wl_commit_sync_configure(E_Client *ec)
5357 E_Client_Pending_Geometry *geo;
5359 Eina_Bool match_size = EINA_FALSE;
5366 if (!ec || !ec->frame) goto ret;
5367 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5370 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5371 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5373 if (eina_list_count(ec->surface_sync.pending_geometry))
5375 Eina_List *ll = NULL;
5376 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5380 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5385 if ((geo->w == bw) && (geo->h == bh))
5387 match_size = EINA_TRUE;
5392 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5399 if ((config.w != ec->w) || (config.h != ec->h))
5401 e_client_size_set(ec, config.w, config.h);
5402 ec->changes.size = EINA_TRUE;
5406 // FIXME: The geometry of the client would be better to be calculated
5407 // at e_desk or at e_desk_area. So the position(x,y) of the client
5408 // should be calcuated at the e_desk or at the e_desk_area.
5410 desk = e_comp_desk_find_by_ec(ec);
5413 ec->client.x = desk->geom.x + config.x;
5414 ec->client.y = desk->geom.y + config.y;
5418 ec->client.x = config.x;
5419 ec->client.y = config.y;
5422 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5424 e_client_pos_set(ec, ec->client.x, ec->client.y);
5426 ec->changes.pos = 1;
5430 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5434 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5435 ec->surface_sync.wait_commit = EINA_FALSE;
5437 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5439 // rollback wait_commit if there are pending requests remained
5440 if (eina_list_count(ec->surface_sync.pending_geometry))
5441 ec->surface_sync.wait_commit = EINA_TRUE;
5446 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);
5453 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5454 struct wl_resource *res_moveresize)
5456 wl_resource_destroy(res_moveresize);
5460 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5461 struct wl_resource *res_moveresize,
5462 struct wl_resource *surface,
5469 /* to be implemented */
5472 int cur_w = 0, cur_h = 0;
5474 ec = e_client_from_surface_resource(surface);
5477 pending = e_client_pending_geometry_has(ec);
5478 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5479 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);
5483 if ((cur_w == w) && (cur_h == h))
5485 e_client_pos_set(ec, x, y);
5486 ec->changes.pos = 1;
5492 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5496 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5499 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5501 _tz_move_resize_iface_cb_destroy,
5502 _tz_move_resize_iface_cb_set_geometry,
5506 _tz_moveresize_cb_bind(struct wl_client *client,
5507 void *data EINA_UNUSED,
5511 struct wl_resource *res_moveresize;
5513 res_moveresize = wl_resource_create(client,
5514 &tizen_move_resize_interface,
5517 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5520 wl_resource_set_implementation(res_moveresize,
5521 &_tz_move_resize_iface,
5527 ERR("Could not create tizen_move_resize_interface res: %m");
5528 wl_client_post_no_memory(client);
5532 _e_comp_wl_move_resize_init(void)
5534 if (!e_comp_wl) return;
5535 if (!e_comp_wl->wl.disp) return;
5537 if (!wl_global_create(e_comp_wl->wl.disp,
5538 &tizen_move_resize_interface,
5541 _tz_moveresize_cb_bind))
5543 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5550 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5552 E_Comp_Wl_Output *output;
5553 pid_t output_pid = 0;
5554 Eina_List *l = NULL, *l2 = NULL;
5555 struct wl_resource *resource = NULL;
5557 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5559 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5560 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5561 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5563 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5565 /* if we have bound resources, send updates */
5566 EINA_LIST_FOREACH(output->resources, l2, resource)
5568 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5569 if (output_pid != pid) continue;
5571 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5573 // send output information to the client
5574 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5582 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5584 _e_comp_wl_surface_state_init(state, w, h);
5588 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5590 _e_comp_wl_surface_state_commit(ec, state);
5594 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5596 _e_comp_wl_hook_call(hookpoint, ec);
5600 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5602 _e_comp_wl_surface_state_finish(state);
5606 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5608 _e_comp_wl_surface_state_buffer_set(state, buffer);
5612 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5613 int sx, int sy, int *dx, int *dy)
5617 case WL_OUTPUT_TRANSFORM_NORMAL:
5621 case WL_OUTPUT_TRANSFORM_FLIPPED:
5622 *dx = width - sx, *dy = sy;
5624 case WL_OUTPUT_TRANSFORM_90:
5625 *dx = height - sy, *dy = sx;
5627 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5628 *dx = height - sy, *dy = width - sx;
5630 case WL_OUTPUT_TRANSFORM_180:
5631 *dx = width - sx, *dy = height - sy;
5633 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5634 *dx = sx, *dy = height - sy;
5636 case WL_OUTPUT_TRANSFORM_270:
5637 *dx = sy, *dy = width - sx;
5639 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5649 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5652 int tx1, ty1, tx2, ty2;
5653 int width_from_buffer, height_from_buffer;
5655 switch (vp->buffer.transform)
5657 case WL_OUTPUT_TRANSFORM_90:
5658 case WL_OUTPUT_TRANSFORM_270:
5659 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5660 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5661 width_from_buffer = bh / vp->buffer.scale;
5662 height_from_buffer = bw / vp->buffer.scale;
5665 width_from_buffer = bw / vp->buffer.scale;
5666 height_from_buffer = bh / vp->buffer.scale;
5670 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5674 x2 = width_from_buffer;
5675 y2 = height_from_buffer;
5679 x1 = wl_fixed_to_int(vp->buffer.src_x);
5680 y1 = wl_fixed_to_int(vp->buffer.src_y);
5681 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5682 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5685 buffer_transform(width_from_buffer, height_from_buffer,
5686 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5687 buffer_transform(width_from_buffer, height_from_buffer,
5688 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5690 out->x = (tx1 <= tx2) ? tx1 : tx2;
5691 out->y = (ty1 <= ty2) ? ty1 : ty2;
5692 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5693 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5697 * Convert given four coordinates to elements of rectangle
5698 * @in p[4] Coordinates to be converted
5699 * @out rect x, y, width, and height
5700 * transform Angle which represents TDM_TRANSFORM of rectangle
5701 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5702 * 1. The given coordinates are not represented by rectangle.
5703 * 2. All angles except for 0, 90, 180, 270.
5706 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5708 Eina_Bool ret = EINA_FALSE;
5710 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))
5713 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5716 *rotation = TDM_TRANSFORM_NORMAL;
5719 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5723 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5726 *rotation = TDM_TRANSFORM_180;
5729 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5734 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))
5737 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5740 *rotation = TDM_TRANSFORM_90;
5743 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5747 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5750 *rotation = TDM_TRANSFORM_270;
5753 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5763 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5768 for (i = 0; i < 4; i++)
5769 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5771 if (!_coords_to_rectangle_convert(p, out, rotation))
5773 DBG("Cannot convert given coords to rectangle.\n"
5774 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5775 p[0].x, p[0].y, p[1].x, p[1].y,
5776 p[2].x, p[2].y, p[3].x, p[3].y);
5784 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5786 int trans_rotation, flip;
5788 trans_rotation = transform & 0x3;
5789 flip = transform & 0x4;
5791 return (flip + (trans_rotation + rotation) % 4);
5795 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5803 if (e_comp_wl_subsurface_check(ec))
5804 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5811 out->w = ec->comp_data->width_from_viewport;
5812 out->w = (out->w + 1) & ~1;
5813 out->h = ec->comp_data->height_from_viewport;
5815 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5816 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5820 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5822 E_Comp_Wl_Buffer *buffer;
5823 E_Comp_Wl_Buffer_Viewport *vp;
5825 enum wl_output_transform buffer_transform;
5826 unsigned int rotation;
5827 Eina_Bool res = EINA_FALSE;
5829 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5831 if (e_object_is_del(E_OBJECT(ec)))
5834 vp = &ec->comp_data->scaler.buffer_viewport;
5836 if (buffer_viewport)
5838 buffer = ec->comp_data->buffer_ref.buffer;
5839 /* Getting a viewport of buffer needs geometry of buffer. */
5843 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5846 if ((output_viewport) || (transform))
5848 m = e_client_map_get(ec);
5850 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5852 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5857 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5858 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5859 * Since buffer.transform isn't applied using evas_map,
5860 * it has to be taken into account here to apply buffer.transform
5861 * and rotation of e_client_transform together. */
5863 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5865 *transform = (unsigned int)buffer_transform;
5873 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5875 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5876 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5878 /* Must be called with valid comp_data */
5879 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5881 if ((ec->comp_data->role_name == NULL) ||
5882 (ec->comp_data->role_name == role_name) ||
5883 (strcmp(ec->comp_data->role_name, role_name) == 0))
5885 ec->comp_data->role_name = role_name;
5891 wl_resource_post_error(error_resource, error_code,
5892 "Cannot assign role %s to wl_surface@%d,"
5893 " already has role %s\n",
5895 ec->comp_data->wl_surface ?
5896 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5897 ec->comp_data->role_name);
5903 EINTERN const char *
5904 e_comp_wl_surface_role_get(E_Client *ec)
5906 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5907 return ec->comp_data ? ec->comp_data->role_name : NULL;
5910 EINTERN struct wl_resource *
5911 e_comp_wl_client_surface_get(E_Client *ec)
5913 struct wl_resource *surface = NULL;
5914 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5915 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5917 g_mutex_lock(&ec->comp_data->surface_mutex);
5918 surface = ec->comp_data->surface;
5919 g_mutex_unlock(&ec->comp_data->surface_mutex);
5924 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5926 EINA_SAFETY_ON_NULL_RETURN(ec);
5927 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5929 g_mutex_lock(&ec->comp_data->surface_mutex);
5930 ec->comp_data->surface = surface;
5931 g_mutex_unlock(&ec->comp_data->surface_mutex);
5935 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5937 return e_compositor_util_client_from_surface_resource(surface_resource);
5941 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5943 if (!ec->comp_data->mapped)
5945 if (ec->comp_data->shell.surface &&
5946 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5948 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5954 if (ec->comp_data->mapped)
5956 /* will be unmapped. so run capture */
5957 e_comp_wl_remote_surface_image_save(ec);
5961 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5963 ec->comp_data->pending.sx = sx;
5964 ec->comp_data->pending.sy = sy;
5965 ec->comp_data->pending.new_attach = EINA_TRUE;
5967 e_client_fps_update(ec);
5971 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5973 if (ec->comp_data->pending.opaque)
5974 eina_tiler_clear(ec->comp_data->pending.opaque);
5978 eina_tiler_union(ec->comp_data->pending.opaque, region);
5980 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5984 ec->argb = EINA_FALSE;
5985 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5987 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5988 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5996 ec->argb = EINA_TRUE;
5997 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5999 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6000 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6006 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6008 if (ec->comp_data->pending.input)
6009 eina_tiler_clear(ec->comp_data->pending.input);
6013 if (eina_tiler_empty(region))
6015 ELOGF("COMP", " |unset input rect", NULL);
6016 e_comp_object_input_objs_del(ec->frame);
6017 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6020 eina_tiler_union(ec->comp_data->pending.input, region);
6024 eina_tiler_rect_add(ec->comp_data->pending.input,
6025 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6030 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6032 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6036 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6038 E_Comp_Wl_Subsurf_Data *sdata;
6043 if (ec->comp_data->frames)
6045 ec->comp_data->frames =
6046 eina_list_remove(ec->comp_data->frames, callback_resource);
6049 if (ec->comp_data->pending.frames)
6051 ec->comp_data->pending.frames =
6052 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6055 sdata = ec->comp_data->sub.data;
6056 if ((sdata) && (sdata->cached.frames))
6058 sdata->cached.frames =
6059 eina_list_remove(sdata->cached.frames, callback_resource);
6064 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6066 if (e_object_is_del(E_OBJECT(ec))) return;
6068 if (e_comp_wl_remote_surface_commit(ec)) return;
6070 e_comp_wl_surface_commit(ec);
6072 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6076 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6078 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6079 ec->comp_data->sub.data = sub;
6081 /* set subsurface client properties */
6082 ec->borderless = EINA_TRUE;
6083 ec->argb = EINA_TRUE;
6084 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6085 ec->lock_border = EINA_TRUE;
6086 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6087 ec->netwm.state.skip_taskbar = EINA_TRUE;
6088 ec->netwm.state.skip_pager = EINA_TRUE;
6089 ec->border_size = 0;
6090 ec->lock_user_location = 0;
6091 ec->lock_client_location = 0;
6092 ec->lock_user_size = 0;
6093 ec->lock_client_size = 0;
6094 ec->lock_client_stacking = 0;
6095 ec->lock_user_maximize = 0;
6096 ec->lock_client_maximize = 0;
6097 ec->changes.need_maximize = 0;
6098 ec->maximized = E_MAXIMIZE_NONE;
6101 ec->new_client = ec->netwm.ping = EINA_TRUE;
6102 e_comp->new_clients++;
6103 e_client_unignore(ec);
6105 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6106 * It's not for subsurface. */
6107 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6111 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6113 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6116 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6118 sub->parent = parent;
6122 layer = e_client_layer_get(parent);
6123 if (layer > E_LAYER_BOTTOM)
6124 e_client_layer_set(ec, layer);
6127 if (parent->comp_data)
6129 /* append this client to the parents subsurface list */
6130 parent->comp_data->sub.list_pending =
6131 eina_list_append(parent->comp_data->sub.list_pending, ec);
6132 parent->comp_data->sub.list_changed = EINA_TRUE;
6137 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6139 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6140 E_Client *parent = sub->parent;
6142 parent->comp_data->sub.list =
6143 eina_list_remove(parent->comp_data->sub.list, ec);
6144 parent->comp_data->sub.list_pending =
6145 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6146 parent->comp_data->sub.below_list =
6147 eina_list_remove(parent->comp_data->sub.below_list, ec);
6148 parent->comp_data->sub.below_list_pending =
6149 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6155 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)
6157 sub->resource = subsurface_resource;
6158 sub->cached_buffer_ref.buffer = NULL;
6159 sub->synchronized = EINA_TRUE;
6160 sub->parent = parent;
6161 sub->remote_surface.offscreen_parent = offscreen_parent;
6162 if (offscreen_parent)
6163 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6165 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6167 _e_comp_wl_client_subsurface_set(ec, sub);
6168 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6170 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6174 e_comp_wl_client_subsurface_finish(E_Client *ec)
6176 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6179 e_comp_wl_client_subsurface_parent_unset(ec);
6181 e_comp_wl_surface_state_finish(&sub->cached);
6182 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6184 ec->comp_data->sub.data = NULL;
6188 e_comp_wl_client_evas_init(E_Client *ec)
6190 EINA_SAFETY_ON_NULL_RETURN(ec);
6192 _e_comp_wl_client_evas_init(ec);
6196 e_comp_wl_client_evas_deinit(E_Client *ec)
6198 EINA_SAFETY_ON_NULL_RETURN(ec);
6200 _e_comp_wl_client_evas_deinit(ec);
6204 e_comp_wl_focus_check(void)
6206 _e_comp_wl_focus_check();
6210 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6217 if ((parent->comp_data) && (parent->comp_data->sub.data))
6218 parent = parent->comp_data->sub.data->parent;