2 #include "e_comp_wl_intern.h"
3 #include "e_comp_wl_private.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"
30 #include <tizen-extension-server-protocol.h>
31 #include <relative-pointer-unstable-v1-server-protocol.h>
32 #include <pointer-constraints-unstable-v1-server-protocol.h>
34 #include <wayland-tbm-server.h>
36 #include <libds/log.h>
37 #include <libds/single_pixel_buffer_v1.h>
39 /* handle include for printing uint64_t */
40 #define __STDC_FORMAT_MACROS
43 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
45 /* Resource Data Mapping: (wl_resource_get_user_data)
47 * wl_surface == e_pixmap
48 * wl_region == eina_tiler
49 * wl_subsurface == e_client
53 typedef struct _E_Comp_Data E_Comp_Data;
58 struct wl_listener client_created;
61 static void _e_comp_wl_move_resize_init(void);
63 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
66 typedef struct _E_Comp_Wl_Key_Data
72 static Eina_List *handlers = NULL;
73 static E_Client *cursor_timer_ec = NULL;
74 static Eina_Bool need_send_released = EINA_FALSE;
75 static Eina_Bool need_send_motion = EINA_TRUE;
77 static GMutex connection_mutex;
79 static int _e_comp_wl_hooks_delete = 0;
80 static int _e_comp_wl_hooks_walking = 0;
82 static int _e_comp_wl_pid_hooks_delete = 0;
83 static int _e_comp_wl_pid_hooks_walking = 0;
85 static int _e_comp_wl_intercept_hooks_delete = 0;
86 static int _e_comp_wl_intercept_hooks_walking = 0;
88 static Eina_Inlist *_e_comp_wl_hooks[] =
90 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
91 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
92 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
93 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
94 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
95 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
96 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
97 [E_COMP_WL_HOOK_DEL] = NULL,
98 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
99 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
100 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
103 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
105 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
108 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
110 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
111 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
112 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
113 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
114 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
115 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
118 static Eina_List *hooks = NULL;
120 /* local functions */
122 _e_comp_wl_hooks_clean(void)
127 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
128 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
130 if (!ch->delete_me) continue;
131 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
137 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
141 e_object_ref(E_OBJECT(ec));
142 _e_comp_wl_hooks_walking++;
143 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
145 if (ch->delete_me) continue;
146 ch->func(ch->data, ec);
147 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
148 (e_object_is_del(E_OBJECT(ec))))
151 _e_comp_wl_hooks_walking--;
152 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
153 _e_comp_wl_hooks_clean();
154 e_object_unref(E_OBJECT(ec));
158 _e_comp_wl_pid_hooks_clean(void)
161 E_Comp_Wl_Pid_Hook *ch;
163 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
164 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
166 if (!ch->delete_me) continue;
167 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
173 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
175 E_Comp_Wl_Pid_Hook *ch;
177 _e_comp_wl_pid_hooks_walking++;
178 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
180 if (ch->delete_me) continue;
181 ch->func(ch->data, pid);
183 _e_comp_wl_pid_hooks_walking--;
184 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
185 _e_comp_wl_pid_hooks_clean();
189 _e_comp_wl_intercept_hooks_clean(void)
192 E_Comp_Wl_Intercept_Hook *ch;
194 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
195 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
197 if (!ch->delete_me) continue;
198 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
204 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
206 E_Comp_Wl_Intercept_Hook *ch;
207 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
209 e_object_ref(E_OBJECT(ec));
210 _e_comp_wl_intercept_hooks_walking++;
211 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
213 if (ch->delete_me) continue;
214 res = ch->func(ch->data, ec);
215 if (!res) ret = EINA_FALSE;
216 if (e_object_is_del(E_OBJECT(ec)))
219 _e_comp_wl_intercept_hooks_walking--;
220 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
221 _e_comp_wl_intercept_hooks_clean();
222 e_object_unref(E_OBJECT(ec));
229 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
235 if (e_comp_object_frame_exists(ec->frame))
236 w = ec->client.w, h = ec->client.h;
238 w = ec->w, h = ec->h;
242 // Width and Height are -1 means that we don't consider size value
246 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
250 _e_comp_wl_focus_check(void)
254 if (stopping) return;
255 ec = e_client_focused_get();
257 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
261 _e_comp_wl_cb_idle_exiter(void *data EINA_UNUSED)
263 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
265 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
266 IDLE_EXITER~CB_PREPARE);
268 return ECORE_CALLBACK_RENEW;
272 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
274 /* dispatch pending wayland events */
275 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
277 return ECORE_CALLBACK_RENEW;
281 e_comp_wl_display_flush()
283 if (e_comp_wl && e_comp_wl->wl.disp)
285 if (e_config->key_input_ttrace_enable)
287 TRACE_INPUT_BEGIN(wl_display_flush_clients);
288 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
291 g_mutex_lock(&connection_mutex);
292 wl_display_flush_clients(e_comp_wl->wl.disp);
293 g_mutex_unlock(&connection_mutex);
295 if (e_config->key_input_ttrace_enable)
298 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
304 e_comp_wl_connection_lock()
306 e_input_boost_lock(&connection_mutex);
310 e_comp_wl_connection_unlock()
312 e_input_boost_unlock(&connection_mutex);
316 e_comp_wl_focused_client_flush()
318 E_Client *focused_ec;
319 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
321 e_input_boost_lock(&connection_mutex);
322 focused_ec = e_client_focused_get();
326 struct wl_client *wc;
327 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
330 e_input_boost_unlock(&connection_mutex);
334 wc = wl_resource_get_client(surface);
338 e_input_boost_unlock(&connection_mutex);
342 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
346 if (e_comp_wl->idle_exiter_timestamp > 0.0)
348 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
349 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
351 ELOGF("E_COMP", "prepare gap time: %lfms",
356 e_comp_wl->idle_exiter_timestamp = 0.0;
358 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
360 /* flush pending client events */
361 e_comp_wl_display_flush();
363 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
364 IDLE_EXITER~CB_PREPARE);
367 E_API enum wl_output_transform
368 e_comp_wl_output_buffer_transform_get(E_Client *ec)
370 E_Comp_Wl_Buffer_Viewport *vp;
371 E_Comp_Wl_Buffer *buffer;
372 enum wl_output_transform transform, rotation;
374 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
375 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
376 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
378 vp = &ec->comp_data->scaler.buffer_viewport;
379 if (e_comp_wl_subsurface_check(ec))
380 return vp->buffer.transform;
382 buffer = ec->comp_data->buffer_ref.buffer;
385 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
386 return vp->buffer.transform;
388 rotation = buffer->transform;
390 return vp->buffer.transform;
392 /* ignore the flip value when calculating transform because the screen rotation
393 * functionality doesn't consider the flip output transform currently
395 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
397 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
398 ec, rotation, vp->buffer.transform, transform);
403 EINTERN enum wl_output_transform
404 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
406 E_Comp_Wl_Buffer_Viewport *vp;
407 E_Comp_Wl_Buffer *buffer;
408 enum wl_output_transform transform, rotation;
410 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
411 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
412 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
414 vp = &ec->comp_data->pending.buffer_viewport;
415 if (e_comp_wl_subsurface_check(ec))
416 return vp->buffer.transform;
418 buffer = ec->comp_data->pending.buffer;
421 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
422 return vp->buffer.transform;
424 rotation = buffer->transform;
426 return vp->buffer.transform;
428 /* ignore the flip value when calculating transform because the screen rotation
429 * functionality doesn't consider the flip output transform currently
431 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
433 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
434 ec, rotation, vp->buffer.transform, transform);
440 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
442 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
443 E_Comp_Wl_Buffer *buffer;
444 int32_t width, height;
446 buffer = e_pixmap_resource_get(ec->pixmap);
449 ec->comp_data->width_from_buffer = 0;
450 ec->comp_data->height_from_buffer = 0;
454 switch (e_comp_wl_output_buffer_transform_get(ec))
456 case WL_OUTPUT_TRANSFORM_90:
457 case WL_OUTPUT_TRANSFORM_270:
458 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
459 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
460 width = buffer->h / vp->buffer.scale;
461 height = buffer->w / vp->buffer.scale;
464 width = buffer->w / vp->buffer.scale;
465 height = buffer->h / vp->buffer.scale;
469 ec->comp_data->width_from_buffer = width;
470 ec->comp_data->height_from_buffer = height;
474 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
476 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
477 int32_t width, height;
479 width = ec->comp_data->width_from_buffer;
480 height = ec->comp_data->height_from_buffer;
482 if (width == 0 && height == 0) return;
484 if (width != 0 && vp->surface.width != -1)
486 ec->comp_data->width_from_viewport = vp->surface.width;
487 ec->comp_data->height_from_viewport = vp->surface.height;
491 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
493 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
494 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
495 ec->comp_data->width_from_viewport = w ?: 1;
496 ec->comp_data->height_from_viewport = h ?: 1;
500 ec->comp_data->width_from_viewport = width;
501 ec->comp_data->height_from_viewport = height;
505 e_comp_wl_topmost_parent_get(E_Client *ec)
509 if (!e_comp_wl_subsurface_check(ec))
512 parent = e_comp_wl_subsurface_parent_get(ec);
515 if (!e_comp_wl_subsurface_check(parent))
518 parent = e_comp_wl_subsurface_parent_get(parent);
525 e_comp_wl_map_apply(E_Client *ec)
527 E_Comp_Wl_Buffer_Viewport *vp;
528 E_Comp_Wl_Subsurf_Data *sdata;
529 E_Comp_Wl_Client_Data *cdata;
530 int x1, y1, x2, y2, x, y;
532 Eina_Bool zoom_animating = EINA_FALSE;
534 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
536 e_comp_object_map_update(ec->frame);
538 cdata = ec->comp_data;
539 vp = &cdata->scaler.buffer_viewport;
540 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
541 (!cdata->viewport_transform))
544 if (e_comp_wl_subsurface_check(ec))
546 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
548 sdata = ec->comp_data->sub.data;
549 if (sdata->remote_surface.offscreen_parent)
551 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
552 Eina_Rectangle *rect;
555 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
557 /* TODO: If there are one more regions, it means that provider's offscreen
558 * is displayed by one more remote_surfaces. Have to consider it later. At
559 * this time, just consider only one remote_surface.
573 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
574 if (x != dx || y != dy)
575 evas_object_move(ec->frame, dx, dy);
577 if (!cdata->viewport_transform)
579 cdata->viewport_transform = e_util_transform_new();
580 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
581 e_client_transform_core_add(ec, cdata->viewport_transform);
584 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
585 ec->comp_data->width_from_viewport,
586 ec->comp_data->height_from_viewport);
588 if (vp->buffer.src_width == wl_fixed_from_int(-1))
592 x2 = cdata->width_from_buffer;
593 y2 = cdata->height_from_buffer;
597 x1 = wl_fixed_to_int(vp->buffer.src_x);
598 y1 = wl_fixed_to_int(vp->buffer.src_y);
599 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
600 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
603 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
604 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
605 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
606 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
609 desk = e_comp_desk_find_by_ec(ec);
611 zoom_animating = e_desk_zoom_is_animating(desk);
613 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
614 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
615 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
617 /* workaround:: when the desk zoom is doing their animation,
618 the transform core update can override animation's zoom boundary.
619 so, don't doing transform core update while desk zoom animation */
621 e_client_transform_core_update(ec);
626 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
630 int map_c = 0, map_x = 0, map_y = 0;
631 double inv_x = 0.0, inv_y = 0.0;
633 EINA_SAFETY_ON_NULL_RETURN(ec);
635 map = e_client_map_get(ec);
636 map_c = e_map_count_get(map);
638 if (!map || map_c <= 0)
648 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
649 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
650 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
651 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
653 for (int i = 0; i < map_c; i++)
655 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
656 e_map_point_image_uv_set(map2, i, map_x, map_y);
658 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
668 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
674 if (!(ec = data)) return;
675 if (e_object_is_del(data)) return;
677 if (!ec->override) e_hints_window_visible_set(ec);
679 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
680 (!ec->comp_data->need_reparent))
682 ec->comp_data->need_reparent = EINA_TRUE;
683 ec->visible = EINA_TRUE;
685 if (!e_client_util_ignored_get(ec))
687 ec->take_focus = !starting;
691 if (!ec->comp_data->need_reparent)
693 if ((ec->hidden) || (ec->iconic))
695 evas_object_hide(ec->frame);
696 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
699 evas_object_show(ec->frame);
702 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
703 evas_object_show(tmp->frame);
705 topmost = e_comp_wl_topmost_parent_get(ec);
706 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
707 e_comp_wl_subsurface_show(ec);
709 if (ec->comp_data->sub.below_obj)
710 evas_object_show(ec->comp_data->sub.below_obj);
714 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
720 if (!(ec = data)) return;
721 if (e_object_is_del(E_OBJECT(ec))) return;
723 /* Uncommonly some clients's final buffer can be skipped if the client
724 * requests unmap of its surface right after wl_surface@commit.
725 * So if this client evas object is hidden state and client is already
726 * unmmapped, we can consider to clear pixmap image here mandatorily.
728 if (!ec->comp_data->mapped)
729 e_pixmap_image_clear(ec->pixmap, 1);
731 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
732 evas_object_hide(tmp->frame);
734 topmost = e_comp_wl_topmost_parent_get(ec);
735 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
736 e_comp_wl_subsurface_hide(ec);
738 if (ec->comp_data->sub.below_obj)
739 evas_object_hide(ec->comp_data->sub.below_obj);
741 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
745 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
752 if (!(ec = data)) return;
753 if (e_object_is_del(E_OBJECT(ec))) return;
755 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
757 if (!e_comp_wl_subsurface_check(subc)) continue;
758 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
759 evas_object_move(subc->frame, x, y);
761 if (subc->comp_data->scaler.viewport)
763 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
764 if (cdata->viewport_transform)
765 e_comp_wl_map_apply(subc);
769 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
771 if (!e_comp_wl_subsurface_check(subc)) continue;
772 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
773 evas_object_move(subc->frame, x, y);
775 if (subc->comp_data->scaler.viewport)
777 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
778 if (cdata->viewport_transform)
779 e_comp_wl_map_apply(subc);
783 if (ec->comp_data->sub.below_obj)
785 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
786 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
791 _e_comp_wl_send_touch_cancel(E_Client *ec)
794 struct wl_resource *res;
795 struct wl_client *wc;
796 E_Comp_Config *comp_conf = NULL;
799 if (e_object_is_del(E_OBJECT(ec))) return;
800 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
802 if (!surface) return;
803 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
805 wc = wl_resource_get_client(surface);
807 comp_conf = e_comp_config_get();
809 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
811 if (wl_resource_get_client(res) != wc) continue;
812 if (!e_comp_wl_input_touch_check(res)) continue;
814 if (comp_conf && comp_conf->input_log_enable)
815 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
817 wl_touch_send_cancel(res);
822 _e_comp_wl_touch_cancel(void)
826 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
828 if (!e_comp_wl->touch.pressed) return;
830 _e_comp_wl_send_touch_cancel(ec);
833 static E_Devicemgr_Input_Device *
834 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
836 E_Devicemgr_Input_Device *last_kbd = NULL;
839 case ECORE_DEVICE_CLASS_MOUSE:
840 return e_devicemgr->last_device_ptr;
841 case ECORE_DEVICE_CLASS_KEYBOARD:
842 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
844 case ECORE_DEVICE_CLASS_TOUCH:
845 return e_devicemgr->last_device_touch;
853 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
857 case ECORE_DEVICE_CLASS_MOUSE:
858 e_devicemgr->last_device_ptr = device;
860 case ECORE_DEVICE_CLASS_KEYBOARD:
861 atomic_store(&e_devicemgr->last_device_kbd, device);
863 case ECORE_DEVICE_CLASS_TOUCH:
864 e_devicemgr->last_device_touch = device;
871 static E_Devicemgr_Input_Device *
872 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
874 E_Devicemgr_Input_Device *last_kbd = NULL;
878 case ECORE_DEVICE_CLASS_MOUSE:
879 return ec->comp_data->last_device_ptr;
880 case ECORE_DEVICE_CLASS_KEYBOARD:
881 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
883 case ECORE_DEVICE_CLASS_TOUCH:
884 return ec->comp_data->last_device_touch;
892 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
896 case ECORE_DEVICE_CLASS_MOUSE:
897 ec->comp_data->last_device_ptr = device;
899 case ECORE_DEVICE_CLASS_KEYBOARD:
900 atomic_store(&ec->comp_data->last_device_kbd, device);
902 case ECORE_DEVICE_CLASS_TOUCH:
903 ec->comp_data->last_device_touch = device;
911 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
913 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
914 struct wl_resource *dev_res;
915 const char *dev_name;
916 Ecore_Device_Class dev_class;
917 struct wl_client *wc;
921 EINA_SAFETY_ON_NULL_RETURN(dev);
924 if (ec->cur_mouse_action || e_comp_wl->drag)
926 if (e_object_is_del(E_OBJECT(ec))) return;
927 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
928 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
929 if (!surface) return;
931 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
932 dev_name = evas_device_description_get(dev);
933 last_device = _e_comp_wl_device_last_device_get(dev_class);
934 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
936 serial = wl_display_next_serial(e_comp_wl->wl.disp);
937 wc = wl_resource_get_client(surface);
938 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
939 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
941 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
942 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
944 _e_comp_wl_device_last_device_set(dev_class, input_dev);
945 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
947 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
949 if (wl_resource_get_client(dev_res) != wc) continue;
950 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
954 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
958 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
960 E_Devicemgr_Input_Device *last_device;
961 struct wl_resource *dev_res;
962 struct wl_client *wc;
966 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
967 if (!surface) return;
969 last_device = _e_comp_wl_device_last_device_get(dev_class);
970 if (!last_device) return;
972 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
974 serial = wl_display_next_serial(e_comp_wl->wl.disp);
975 wc = wl_resource_get_client(surface);
976 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
978 if (wl_resource_get_client(dev_res) != wc) continue;
979 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
984 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
986 E_Devicemgr_Input_Device *input_dev;
987 struct wl_resource *dev_res;
988 const char *dev_name;
991 EINA_SAFETY_ON_NULL_RETURN(dev);
993 dev_name = ecore_device_identifier_get(dev);
995 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
996 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
998 if (!eina_streq(input_dev->identifier, dev_name) ||
999 (input_dev->clas != ecore_device_class_get(dev))) continue;
1000 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1002 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1004 if (wl_resource_get_client(dev_res) != wc) continue;
1005 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1008 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1012 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1014 E_Devicemgr_Input_Device *input_dev;
1015 struct wl_resource *dev_res;
1016 const char *dev_name;
1019 EINA_SAFETY_ON_NULL_RETURN(dev);
1021 dev_name = e_device_identifier_get(dev);
1023 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1024 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1026 if (!eina_streq(input_dev->identifier, dev_name) ||
1027 (input_dev->clas != e_device_class_get(dev))) continue;
1028 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1030 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1032 if (wl_resource_get_client(dev_res) != wc) continue;
1033 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1036 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1040 _e_comp_wl_cursor_reload(E_Client *ec)
1042 struct wl_resource *res;
1043 struct wl_client *wc;
1049 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1050 !evas_object_visible_get(e_comp->pointer->o_ptr))
1051 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1054 if (e_object_is_del(E_OBJECT(ec))) return;
1055 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1056 if (!surface) return;
1057 if (ec->pointer_enter_sent) return;
1059 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1060 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1062 if (e_client_transform_core_enable_get(ec))
1064 double dx = 0.0, dy = 0.0;
1065 map = e_client_map_get(ec);
1066 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1072 cx = px - ec->client.x;
1073 cy = py - ec->client.y;
1075 wc = wl_resource_get_client(surface);
1076 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1077 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1079 if (!e_comp_wl_input_pointer_check(res)) continue;
1080 if (wl_resource_get_client(res) != wc) continue;
1081 wl_pointer_send_enter(res, serial, surface,
1082 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1083 ec->pointer_enter_sent = EINA_TRUE;
1085 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1089 _e_comp_wl_cursor_timer(void *data)
1091 E_Client *ec = data;
1093 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1094 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1096 e_comp_wl_cursor_hide(ec);
1098 return ECORE_CALLBACK_CANCEL;
1102 _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)
1104 E_Devicemgr_Input_Device *input_dev;
1105 struct wl_resource *dev_res;
1106 struct wl_client *wc;
1111 if (ec->cur_mouse_action) return;
1112 if (e_object_is_del(E_OBJECT(ec))) return;
1113 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1114 if (!surface) return;
1116 f_value = wl_fixed_from_double(value);
1117 wc = wl_resource_get_client(surface);
1119 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1120 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1122 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1123 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1125 if (wl_resource_get_client(dev_res) != wc) continue;
1126 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1129 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1133 _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)
1135 if (idx >= e_input_touch_max_count_get()) return;
1137 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1138 e_devicemgr->multi[idx].radius_x = radius_x;
1139 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1140 e_devicemgr->multi[idx].radius_y = radius_y;
1141 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1142 e_devicemgr->multi[idx].pressure = pressure;
1143 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1144 e_devicemgr->multi[idx].angle = angle;
1148 _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)
1150 if (idx >= e_input_touch_max_count_get()) return;
1152 if (e_devicemgr->multi[idx].radius_x != radius_x)
1154 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1155 e_devicemgr->multi[idx].radius_x = radius_x;
1157 if (e_devicemgr->multi[idx].radius_y != radius_y)
1159 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1160 e_devicemgr->multi[idx].radius_y = radius_y;
1162 if (e_devicemgr->multi[idx].pressure != pressure)
1164 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1165 e_devicemgr->multi[idx].pressure = pressure;
1167 if (e_devicemgr->multi[idx].angle != angle)
1169 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1170 e_devicemgr->multi[idx].angle = angle;
1175 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1177 Eina_Bool ret = EINA_TRUE;
1180 case EVAS_CALLBACK_MOUSE_IN:
1181 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1184 if (e_comp_wl->ptr.hide_tmr)
1186 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1187 cursor_timer_ec = ec;
1188 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1192 if (e_pointer_is_hidden(e_comp->pointer))
1197 case EVAS_CALLBACK_MOUSE_OUT:
1198 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1201 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1205 case EVAS_CALLBACK_MOUSE_MOVE:
1206 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1209 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1210 _e_comp_wl_cursor_reload(ec);
1213 case EVAS_CALLBACK_MOUSE_WHEEL:
1214 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1217 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1218 _e_comp_wl_cursor_reload(ec);
1221 case EVAS_CALLBACK_MOUSE_DOWN:
1222 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1225 if (e_comp_wl->ptr.hide_tmr)
1227 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1228 e_comp_wl->ptr.hide_tmr = NULL;
1230 cursor_timer_ec = NULL;
1232 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1233 _e_comp_wl_cursor_reload(ec);
1236 case EVAS_CALLBACK_MOUSE_UP:
1237 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1248 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1250 if (ec->has_cursor_unset)
1253 if (!e_config->show_cursor)
1256 if (!e_config->use_cursor_timer)
1263 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1266 Evas_Event_Mouse_In *ev;
1267 struct wl_resource *res;
1268 struct wl_client *wc;
1271 E_Comp_Config *comp_conf;
1272 E_Client *prev_ptr_ec;
1276 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1277 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1279 if (!(ec = data)) return;
1280 if (e_object_is_del(E_OBJECT(ec))) return;
1281 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1282 if (!surface) return;
1284 prev_ptr_ec = e_comp_wl->ptr.ec;
1287 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1288 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1291 e_comp_wl->ptr.ec = ec;
1293 comp_conf = e_comp_config_get();
1294 if (comp_conf && comp_conf->input_log_enable)
1295 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1296 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1297 e_client_util_name_get(ec));
1299 if (_e_comp_wl_check_cursor_timer_needed(ec))
1301 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1305 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1306 wc = wl_resource_get_client(surface);
1307 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1308 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1310 if (!e_comp_wl_input_pointer_check(res)) continue;
1311 if (wl_resource_get_client(res) != wc) continue;
1313 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1315 wl_pointer_send_enter(res, serial, surface,
1316 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1317 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1318 ec->pointer_enter_sent = EINA_TRUE;
1321 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1325 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1328 Evas_Event_Mouse_Out *ev;
1329 struct wl_resource *res;
1330 struct wl_client *wc;
1333 Eina_Bool inside_check;
1334 E_Comp_Config *comp_conf;
1338 if (!(ec = data)) return;
1339 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1340 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1341 if (ec->cur_mouse_action && inside_check) return;
1342 if (e_object_is_del(E_OBJECT(e_comp))) return;
1343 if (e_comp_wl->ptr.ec == ec)
1344 e_comp_wl->ptr.ec = NULL;
1345 if (e_object_is_del(E_OBJECT(ec))) return;
1347 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1348 if (!surface) return;
1350 comp_conf = e_comp_config_get();
1351 if (comp_conf && comp_conf->input_log_enable)
1352 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1353 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1354 e_client_util_name_get(ec));
1356 if (_e_comp_wl_check_cursor_timer_needed(ec))
1358 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1362 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1364 wc = wl_resource_get_client(surface);
1365 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1366 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1368 if (!e_comp_wl_input_pointer_check(res)) continue;
1369 if (wl_resource_get_client(res) != wc) continue;
1370 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1372 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1374 wl_pointer_send_leave(res, serial, surface);
1375 ec->pointer_enter_sent = EINA_FALSE;
1380 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1383 struct wl_client *wc;
1384 struct wl_resource *res;
1387 E_Comp_Config *comp_conf = NULL;
1390 if (e_object_is_del(E_OBJECT(ec))) return;
1391 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1392 if (!surface) return;
1394 wc = wl_resource_get_client(surface);
1395 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1399 x = wl_fixed_from_int(canvas_x - ec->client.x);
1400 y = wl_fixed_from_int(canvas_y - ec->client.y);
1403 comp_conf = e_comp_config_get();
1405 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1407 if (wl_resource_get_client(res) != wc) continue;
1408 if (!e_comp_wl_input_touch_check(res)) continue;
1409 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1412 if (comp_conf && comp_conf->input_log_enable)
1413 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));
1415 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1419 if (comp_conf && comp_conf->input_log_enable)
1420 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));
1422 wl_touch_send_up(res, serial, timestamp, idx);
1429 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1432 struct wl_client *wc;
1433 struct wl_resource *res;
1437 if (ec->cur_mouse_action) return;
1438 if (e_object_is_del(E_OBJECT(ec))) return;
1439 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1440 if (!surface) return;
1442 wc = wl_resource_get_client(surface);
1444 x = wl_fixed_from_int(canvas_x - ec->client.x);
1445 y = wl_fixed_from_int(canvas_y - ec->client.y);
1447 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1449 if (wl_resource_get_client(res) != wc) continue;
1450 if (!e_comp_wl_input_touch_check(res)) continue;
1451 wl_touch_send_motion(res, timestamp, idx, x, y);
1456 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1458 struct wl_resource *res;
1459 struct wl_client *wc;
1463 if (ec->cur_mouse_action) return;
1464 if (e_object_is_del(E_OBJECT(ec))) return;
1465 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1466 if (!surface) return;
1468 wc = wl_resource_get_client(surface);
1469 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1471 if (!e_comp_wl_input_pointer_check(res)) continue;
1472 if (wl_resource_get_client(res) != wc) continue;
1473 wl_pointer_send_motion(res, timestamp,
1474 wl_fixed_from_int(x - ec->client.x),
1475 wl_fixed_from_int(y - ec->client.y));
1480 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1482 if (e_comp_wl->ptr.hide_tmr)
1484 if (cursor_timer_ec == ec)
1486 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1487 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1491 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1492 cursor_timer_ec = ec;
1493 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1498 cursor_timer_ec = ec;
1499 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1504 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1507 Evas_Event_Mouse_Move *ev;
1508 Evas_Device *dev = NULL;
1509 const char *dev_name;
1510 E_Comp_Config *comp_conf;
1514 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1515 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1517 if (!(ec = data)) return;
1518 if (e_object_is_del(E_OBJECT(ec))) return;
1519 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1520 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1521 if (!surface) return;
1523 if ((!need_send_motion) && (!need_send_released) && (ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED)) return;
1526 dev_name = evas_device_description_get(dev);
1528 comp_conf = e_comp_config_get();
1529 if (comp_conf && comp_conf->input_log_enable)
1530 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1531 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1532 e_client_util_name_get(ec), dev_name);
1534 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1536 if (!e_comp_wl->drag_client)
1538 e_comp_wl->touch.faked_ec = ec;
1539 if (e_comp_wl->touch.pressed & (1 << 0))
1541 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1543 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1544 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1545 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1549 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1553 if (!e_comp_wl->drag_client)
1555 if (_e_comp_wl_check_cursor_timer_needed(ec))
1557 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1561 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1562 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1564 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1566 if (_e_comp_wl_check_cursor_timer_needed(ec))
1567 _e_comp_wl_cursor_move_timer_control(ec);
1571 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1576 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1578 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1579 if (e_object_is_del(E_OBJECT(ec))) return;
1580 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1581 if (!surface) return;
1582 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1584 e_comp_wl->ptr.button = BTN_LEFT;
1586 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1590 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1592 E_Client *ec = data;
1593 Evas_Event_Mouse_Down *ev = event;
1594 Evas_Device *dev = NULL;
1595 const Evas_Device *seat_dev;
1596 const char *dev_name, *seat_name;
1597 E_Comp_Config *comp_conf = NULL;
1600 if (e_object_is_del(E_OBJECT(ec))) return;
1603 dev_name = evas_device_description_get(dev);
1605 seat_dev = evas_device_parent_get(dev);
1606 seat_name = evas_device_name_get(seat_dev);
1608 comp_conf = e_comp_config_get();
1609 if (comp_conf && comp_conf->input_log_enable)
1610 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1611 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1612 dev_name, seat_name);
1614 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1616 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1618 e_comp_wl->touch.faked_ec = ec;
1621 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1622 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1623 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1625 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1626 e_comp_wl->touch.pressed |= (1 << 0);
1630 if (_e_comp_wl_check_cursor_timer_needed(ec))
1632 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1636 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1637 WL_POINTER_BUTTON_STATE_PRESSED);
1639 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1642 need_send_released = EINA_TRUE;
1646 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1648 E_Client *ec = data;
1649 Evas_Event_Mouse_Up *ev = event;
1650 Evas_Device *dev = NULL;
1651 const Evas_Device *seat_dev;
1652 const char *dev_name, *seat_name;;
1653 Evas_Event_Flags flags;
1654 E_Comp_Config *comp_conf = NULL;
1657 if (ec->cur_mouse_action) return;
1658 if (e_object_is_del(E_OBJECT(ec))) return;
1660 if (!need_send_released)
1662 need_send_motion = EINA_TRUE;
1666 dev_name = evas_device_description_get(dev);
1668 seat_dev = evas_device_parent_get(dev);
1669 seat_name = evas_device_name_get(seat_dev);
1670 flags = evas_event_default_flags_get(evas);
1672 comp_conf = e_comp_config_get();
1673 if (comp_conf && comp_conf->input_log_enable)
1674 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1675 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1676 dev_name, seat_name);
1678 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1680 e_comp_wl->touch.pressed &= ~(1 << 0);
1682 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1683 e_comp_wl->touch.faked_ec = NULL;
1686 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1688 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1690 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1693 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1694 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1695 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1699 if (_e_comp_wl_check_cursor_timer_needed(ec))
1701 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1705 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1706 WL_POINTER_BUTTON_STATE_RELEASED);
1708 if (_e_comp_wl_check_cursor_timer_needed(ec))
1709 _e_comp_wl_cursor_move_timer_control(ec);
1713 need_send_released = EINA_FALSE;
1717 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1719 struct wl_resource *res;
1720 struct wl_client *wc;
1725 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1727 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1730 dir = -wl_fixed_from_int(abs(z));
1732 dir = wl_fixed_from_int(z);
1735 if (e_object_is_del(E_OBJECT(ec))) return;
1736 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1737 if (!surface) return;
1739 wc = wl_resource_get_client(surface);
1740 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1742 if (!e_comp_wl_input_pointer_check(res)) continue;
1743 if (wl_resource_get_client(res) != wc) continue;
1744 wl_pointer_send_axis(res, timestamp, axis, dir);
1749 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1752 Evas_Event_Mouse_Wheel *ev;
1755 if (!(ec = data)) return;
1756 if (ec->cur_mouse_action) return;
1757 if (e_object_is_del(E_OBJECT(ec))) return;
1758 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1759 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1760 if (!surface) return;
1762 if (!eina_list_count(e_comp_wl->ptr.resources))
1765 if (_e_comp_wl_check_cursor_timer_needed(ec))
1767 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1771 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1773 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1775 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1777 if (_e_comp_wl_check_cursor_timer_needed(ec))
1778 _e_comp_wl_cursor_move_timer_control(ec);
1783 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1785 E_Client *ec = data;
1786 Evas_Event_Multi_Down *ev = event;
1787 Evas_Device *dev = NULL;
1788 const Evas_Device *seat_dev;
1789 const char *dev_name, *seat_name;
1790 Evas_Device_Class dev_class;
1791 E_Comp_Config *comp_conf = NULL;
1794 if (e_object_is_del(E_OBJECT(ec))) return;
1795 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1796 if (!surface) return;
1798 /* Do not deliver emulated single touch events to client */
1799 if (ev->device == 0) return;
1802 dev_name = evas_device_description_get(dev);
1803 e_comp_wl->touch.faked_ec = ec;
1805 seat_dev = evas_device_parent_get(dev);
1806 seat_name = evas_device_name_get(seat_dev);
1808 comp_conf = e_comp_config_get();
1809 if (comp_conf && comp_conf->input_log_enable)
1810 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1811 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1812 dev_name, seat_name);
1814 if (dev && dev_name)
1816 dev_class = evas_device_class_get(dev);
1817 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1818 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1821 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1822 e_comp_wl->touch.pressed |= (1 << ev->device);
1826 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1828 E_Client *ec = data;
1829 Evas_Event_Multi_Up *ev = event;
1830 Evas_Device *dev = NULL;
1831 const Evas_Device *seat_dev;
1832 const char *dev_name, *seat_name;
1833 Evas_Device_Class dev_class;
1834 Evas_Event_Flags flags;
1835 E_Comp_Config *comp_conf = NULL;
1838 if (e_object_is_del(E_OBJECT(ec))) return;
1839 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1840 if (!surface) return;
1842 /* Do not deliver emulated single touch events to client */
1843 if (ev->device == 0) return;
1845 flags = evas_event_default_flags_get(evas);
1847 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1848 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1849 e_comp_wl->touch.faked_ec = NULL;
1851 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1854 dev_name = evas_device_description_get(dev);
1856 seat_dev = evas_device_parent_get(dev);
1857 seat_name = evas_device_name_get(seat_dev);
1859 comp_conf = e_comp_config_get();
1860 if (comp_conf && comp_conf->input_log_enable)
1861 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1862 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1863 dev_name, seat_name);
1865 if (dev && dev_name)
1867 dev_class = evas_device_class_get(dev);
1868 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1869 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1872 _e_comp_wl_send_touch(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1876 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1878 E_Client *ec = data;
1879 Evas_Event_Multi_Move *ev = event;
1880 Evas_Device *dev = NULL;
1881 const char *dev_name;
1882 Evas_Device_Class dev_class;
1885 if (e_object_is_del(E_OBJECT(ec))) return;
1886 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1887 if (!surface) return;
1889 /* Do not deliver emulated single touch events to client */
1890 if (ev->device == 0) return;
1892 e_comp_wl->touch.faked_ec = ec;
1894 if (e_comp_wl->touch.pressed & (1 << ev->device))
1897 if (dev && (dev_name = evas_device_description_get(dev)))
1899 dev_class = evas_device_class_get(dev);
1900 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1901 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1904 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1909 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1912 char *file, buff[PATH_MAX];
1919 n = (getpriority(PRIO_PROCESS, pid) + adj);
1923 setpriority(PRIO_PROCESS, pid, n);
1926 use_adj = EINA_TRUE;
1928 if (!do_child) return;
1930 files = ecore_file_ls("/proc");
1931 EINA_LIST_FREE(files, file)
1933 if (!isdigit(file[0]))
1936 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1937 if ((f = fopen(buff, "r")))
1941 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1943 if (num_read == 2 && ppid == pid)
1944 _e_comp_wl_client_priority_adjust(pid2, set,
1946 adj_child, do_child);
1954 _e_comp_wl_client_priority_raise(E_Client *ec)
1956 if (!e_config->priority_control) return;
1957 if (ec->netwm.pid <= 0) return;
1958 if (ec->netwm.pid == getpid()) return;
1959 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1960 e_config->priority - 1, -1,
1961 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1965 _e_comp_wl_client_priority_normal(E_Client *ec)
1967 if (!e_config->priority_control) return;
1968 if (ec->netwm.pid <= 0) return;
1969 if (ec->netwm.pid == getpid()) return;
1970 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
1971 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1975 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
1978 E_Comp_Wl_Key_Data *k;
1979 struct wl_resource *res;
1983 if (!ec) return EINA_FALSE;
1984 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
1985 if (!ec->comp_data) return EINA_FALSE;
1987 ec->comp_data->on_focus_timer = NULL;
1988 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
1989 if (!e_comp_wl->kbd.focused)
1991 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1994 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
1996 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1997 t = ecore_time_unix_get();
1999 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2000 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2001 EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
2003 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2005 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2006 wl_keyboard_send_key(res, serial, t,
2007 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2010 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2011 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2015 /* It is called in the following cases:
2016 * When a normal ec->frame has focus.
2017 * Or launching image ec is replaced to the real ec.
2020 e_comp_wl_feed_focus_in(E_Client *ec)
2023 struct wl_resource *res;
2024 struct wl_client *wc;
2028 if (e_object_is_del(E_OBJECT(ec))) return;
2029 if (ec->iconic) return;
2031 /* block spurious focus events */
2032 focused = e_client_focused_get();
2033 if ((focused) && (ec != focused)) return;
2035 /* raise client priority */
2036 _e_comp_wl_client_priority_raise(ec);
2037 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2038 if (!surface) return;
2040 wc = wl_resource_get_client(surface);
2042 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2043 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2045 if (wl_resource_get_client(res) == wc)
2047 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2048 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2049 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2050 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2053 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2055 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2056 if (!e_comp_wl->kbd.focused)
2058 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2061 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2063 e_comp_wl->kbd.focus = surface;
2064 e_comp_wl_input_keyboard_enter_send(ec);
2065 e_comp_wl_data_device_keyboard_focus_set();
2066 ec->comp_data->on_focus_timer =
2067 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2068 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2069 int rotation = ec->e.state.rot.ang.curr;
2070 e_pointer_rotation_set(e_comp->pointer, rotation);
2074 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2077 if (!(ec = data)) return;
2078 e_comp_wl_feed_focus_in(ec);
2082 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2085 struct wl_resource *res;
2087 E_Comp_Wl_Key_Data *k;
2091 if (!(ec = data)) return;
2093 if (!ec->comp_data) return;
2095 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2097 /* lower client priority */
2098 if (!e_object_is_del(data))
2099 _e_comp_wl_client_priority_normal(ec);
2102 /* update keyboard modifier state */
2103 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2104 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2105 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2107 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2109 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2110 if (!surface) return;
2112 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
2113 if (!eina_list_count(e_comp_wl->kbd.resources))
2115 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2119 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
2121 /* send keyboard_leave to all keyboard resources */
2122 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2123 t = ecore_time_unix_get();
2125 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
2126 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
2127 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2129 wl_array_for_each(k, &e_comp_wl->kbd.keys)
2131 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2132 wl_keyboard_send_key(res, serial, t,
2133 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2135 wl_keyboard_send_leave(res, serial, surface);
2136 e_comp_wl->kbd.focused =
2137 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2139 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
2140 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
2144 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2148 if (!(ec = data)) return;
2150 if (!ec->comp_data->shell.configure_send) return;
2152 /* TODO: calculate x, y with transfrom object */
2153 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2157 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2158 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2159 if (e_comp_object_frame_exists(ec->frame))
2160 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2162 switch (ec->resize_mode)
2164 case E_POINTER_RESIZE_TL:
2165 case E_POINTER_RESIZE_L:
2166 case E_POINTER_RESIZE_BL:
2167 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2168 ec->mouse.current.mx;
2170 case E_POINTER_RESIZE_TR:
2171 case E_POINTER_RESIZE_R:
2172 case E_POINTER_RESIZE_BR:
2173 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2178 switch (ec->resize_mode)
2180 case E_POINTER_RESIZE_TL:
2181 case E_POINTER_RESIZE_T:
2182 case E_POINTER_RESIZE_TR:
2183 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2184 ec->mouse.current.my;
2186 case E_POINTER_RESIZE_BL:
2187 case E_POINTER_RESIZE_B:
2188 case E_POINTER_RESIZE_BR:
2189 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2194 w = E_CLAMP(w, 1, w);
2195 h = E_CLAMP(h, 1, h);
2196 e_client_resize_limit(ec, &w, &h);
2198 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2200 else if ((!ec->fullscreen) && (!ec->maximized) &&
2201 (!ec->comp_data->maximize_pre))
2205 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2206 if ((pw != ec->w) || (ph != ec->h))
2208 _e_comp_wl_configure_send(ec, 1, 1);
2212 if (ec->comp_data->sub.below_obj)
2213 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2217 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2219 E_Client *ec = data;
2221 ec->comp_data->maximize_pre = 1;
2225 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2227 E_Client *ec = data;
2230 if (e_object_is_del(E_OBJECT(ec))) return;
2232 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2233 e_client_shell_configure_send(ec, 0, w, h);
2235 ec->comp_data->maximize_pre = 0;
2239 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2241 E_Client *ec = data;
2243 ec->comp_data->maximize_pre = 1;
2247 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2249 E_Client *ec = data;
2251 if (e_object_is_del(E_OBJECT(ec))) return;
2253 /* check for wayland pixmap */
2255 if (ec->comp_data->shell.configure_send)
2256 _e_comp_wl_configure_send(ec, 0, 0);
2258 ec->comp_data->maximize_pre = 0;
2262 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2264 E_Client *ec = data;
2266 if (e_object_is_del(E_OBJECT(ec))) return;
2268 /* check for wayland pixmap */
2270 if (ec->comp_data->shell.configure_send)
2271 _e_comp_wl_configure_send(ec, 0, 1);
2273 ec->comp_data->maximize_pre = 0;
2277 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2279 E_Client *ec = data;
2281 if (e_object_is_del(E_OBJECT(ec))) return;
2283 /* check for wayland pixmap */
2285 if (ec->comp_data->shell.configure_send)
2286 _e_comp_wl_configure_send(ec, 0, 0);
2288 ec->comp_data->maximize_pre = 0;
2292 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2296 if (!(ec = data)) return;
2298 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2300 e_object_del(E_OBJECT(ec));
2302 _e_comp_wl_focus_check();
2304 /* TODO: Delete request send ??
2305 * NB: No such animal wrt wayland */
2309 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2313 if (!(ec = data)) return;
2315 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2318 if (ec->comp_data->reparented)
2319 e_client_comp_hidden_set(ec, EINA_TRUE);
2322 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2323 if (ec->visible) evas_object_hide(ec->frame);
2324 if (!ec->internal) e_object_del(E_OBJECT(ec));
2326 _e_comp_wl_focus_check();
2330 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2334 if (!(ec = data)) return;
2336 e_client_shell_ping(ec);
2340 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2345 if (!(ec = data)) return;
2346 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2347 if (ec->netwm.opacity == a) return;
2348 ec->netwm.opacity = a;
2349 ec->netwm.opacity_changed = EINA_TRUE;
2353 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2355 Eina_Rectangle *damage_rect = NULL;
2356 Eina_Rectangle *dmg = NULL;
2357 Eina_List *l = NULL;
2359 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2360 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2363 if (!buffer->tbm_surface) return;
2367 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2371 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2372 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2375 eina_rectangle_union(damage_rect, dmg);
2380 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2381 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2384 tbm_surface_internal_set_damage(buffer->tbm_surface,
2390 eina_rectangle_free(damage_rect);
2394 _e_comp_wl_client_evas_init(E_Client *ec)
2396 if (!ec || !ec->comp_data) return;
2397 if (ec->comp_data->evas_init) return;
2399 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2400 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2401 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2404 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2405 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2406 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2407 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2408 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2409 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2411 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2412 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2413 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2415 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2416 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2420 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2421 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2422 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2423 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2424 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2425 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2426 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2429 /* setup delete/kill callbacks */
2430 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2431 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2433 /* setup ping callback */
2434 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2435 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2437 ec->comp_data->evas_init = EINA_TRUE;
2441 _e_comp_wl_client_evas_deinit(E_Client *ec)
2443 if (!ec || !ec->comp_data) return;
2444 if (!ec->comp_data->evas_init) return;
2446 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2447 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2448 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2450 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2451 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2452 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2453 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2454 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2455 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2457 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2458 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2459 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2461 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2462 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2466 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2467 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2468 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2469 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2470 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2471 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2472 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2475 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2476 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2478 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2479 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2481 ec->comp_data->evas_init = EINA_FALSE;
2485 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2489 E_Comp_Screen *e_comp_screen;
2490 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2492 if (!e_comp) return ECORE_CALLBACK_RENEW;
2493 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2494 e_comp_screen = e_comp->e_comp_screen;
2496 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2498 if (!eout->config.enabled)
2500 e_comp_wl_output_remove(eout->id);
2504 switch (eout->config.rotation)
2507 transform = WL_OUTPUT_TRANSFORM_90;
2510 transform = WL_OUTPUT_TRANSFORM_180;
2513 transform = WL_OUTPUT_TRANSFORM_270;
2517 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2521 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2523 eout->config.geom.x, eout->config.geom.y,
2524 eout->config.geom.w, eout->config.geom.h,
2525 eout->info.size.w, eout->info.size.h,
2526 eout->config.mode.refresh, 0, transform))
2527 ERR("Could not initialize screen %s", eout->info.name);
2530 return ECORE_CALLBACK_RENEW;
2534 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2538 /* try to get the client from the object */
2539 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2540 return ECORE_CALLBACK_RENEW;
2542 /* check for client being deleted */
2543 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2545 /* check for wayland pixmap */
2546 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2547 return ECORE_CALLBACK_RENEW;
2549 /* if we have not setup evas callbacks for this client, do it */
2550 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2552 return ECORE_CALLBACK_RENEW;
2556 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2560 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2561 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2563 if (e_comp_wl->selection.target &&
2566 struct wl_resource *res;
2568 E_Client *ec = NULL;
2569 E_Client *legacy_target = e_comp_wl->selection.target;
2570 int device_id = e_comp_wl_data_current_device_id_get();
2574 e_comp_wl_data_current_device_id_set(ev->multi.device);
2576 else if (device_id != ev->multi.device)
2578 return ECORE_CALLBACK_RENEW;
2581 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2582 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2584 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2585 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2587 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2588 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2590 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2591 (ec != legacy_target))
2593 e_comp_wl_data_device_send_leave(legacy_target);
2594 e_comp_wl_data_device_send_enter(ec);
2597 if (e_comp_wl->drag)
2598 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2600 if (e_client_transform_core_enable_get(ec))
2602 int trans_x, trans_y;
2603 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2604 x = trans_x - ec->client.x;
2605 y = trans_y - ec->client.y;
2609 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2614 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2617 return ECORE_CALLBACK_RENEW;
2621 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2624 struct wl_resource *surface;
2625 struct wl_resource *res;
2626 struct wl_client *wc;
2628 E_Comp_Config *comp_conf;
2630 ec = e_comp_wl->ptr_constraints.ec;
2631 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2633 surface = e_comp_wl_client_surface_get(ec);
2634 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2636 wc = wl_resource_get_client(surface);
2638 comp_conf = e_comp_config_get();
2640 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2642 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2643 if (wl_resource_get_client(res) != wc) continue;
2645 if (comp_conf && comp_conf->input_log_enable)
2646 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2647 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2648 e_client_util_name_get(ec));
2650 zwp_relative_pointer_v1_send_relative_motion(res,
2652 (uint32_t)(ev->timestamp),
2653 wl_fixed_from_int(ev->dx),
2654 wl_fixed_from_int(ev->dy),
2655 wl_fixed_from_int(ev->dx_unaccel),
2656 wl_fixed_from_int(ev->dy_unaccel));
2659 return ECORE_CALLBACK_DONE;
2663 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2665 _e_comp_wl_touch_cancel();
2667 return ECORE_CALLBACK_PASS_ON;
2671 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2673 if (!ev) return ECORE_CALLBACK_PASS_ON;
2675 E_Zone *zone = ev->zone;
2677 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2678 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2680 if (!e_zone_is_displaying(zone))
2681 _e_comp_wl_touch_cancel();
2683 return ECORE_CALLBACK_PASS_ON;
2687 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2689 E_Client *ec = ev->ec;
2690 E_Comp_Wl_Buffer_Viewport *vp;
2692 if (!ec) return ECORE_CALLBACK_PASS_ON;
2693 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2694 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2695 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2696 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2698 vp = &ec->comp_data->scaler.buffer_viewport;
2699 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2701 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2703 return ECORE_CALLBACK_PASS_ON;
2707 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2709 E_Client *ec = ev->ec;
2710 E_Comp_Wl_Buffer_Viewport *vp;
2712 if (!ec) return ECORE_CALLBACK_PASS_ON;
2713 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2714 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2715 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2717 vp = &ec->comp_data->scaler.buffer_viewport;
2718 vp->wait_for_transform_change = 0;
2720 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2722 return ECORE_CALLBACK_PASS_ON;
2726 _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)
2728 E_Client *focused_ec;
2731 focused_ec = e_client_focused_get();
2732 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2734 rotation = focused_ec->e.state.rot.ang.curr;
2735 e_pointer_rotation_set(e_comp->pointer, rotation);
2737 return ECORE_CALLBACK_PASS_ON;
2741 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2744 Eina_Rectangle *window;
2749 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2751 if ((prev_w != state->bw) ||
2752 (prev_h != state->bh))
2754 ec->changes.buf_size = EINA_TRUE;
2757 if (e_comp_object_frame_exists(ec->frame)) return;
2758 window = &ec->comp_data->shell.window;
2759 if ((!ec->borderless) && /* FIXME temporarily added this check code
2760 * to prevent updating E_Client's size by frame */
2761 (window->x || window->y || window->w || window->h))
2763 e_comp_object_frame_geometry_set(ec->frame,
2765 (window->x + window->w) - state->bw,
2767 (window->y + window->h) - state->bh);
2770 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2774 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2776 E_Comp_Wl_Surface_State *state;
2779 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2780 state->buffer = NULL;
2784 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2786 state->new_attach = EINA_FALSE;
2787 state->buffer = NULL;
2788 state->buffer_destroy_listener.notify =
2789 _e_comp_wl_surface_state_cb_buffer_destroy;
2790 state->sx = state->sy = 0;
2792 state->input = eina_tiler_new(w, h);
2793 eina_tiler_tile_size_set(state->input, 1, 1);
2795 state->opaque = eina_tiler_new(w, h);
2796 eina_tiler_tile_size_set(state->opaque, 1, 1);
2798 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2799 state->buffer_viewport.buffer.scale = 1;
2800 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2801 state->buffer_viewport.surface.width = -1;
2802 state->buffer_viewport.changed = 0;
2804 e_presentation_time_container_init(&state->presentation_container);
2808 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2810 struct wl_resource *cb;
2811 Eina_Rectangle *dmg;
2813 EINA_LIST_FREE(state->frames, cb)
2814 wl_resource_destroy(cb);
2816 EINA_LIST_FREE(state->damages, dmg)
2817 eina_rectangle_free(dmg);
2819 EINA_LIST_FREE(state->buffer_damages, dmg)
2820 eina_rectangle_free(dmg);
2822 if (state->opaque) eina_tiler_free(state->opaque);
2823 state->opaque = NULL;
2825 if (state->input) eina_tiler_free(state->input);
2826 state->input = NULL;
2828 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2829 state->buffer = NULL;
2831 e_presentation_time_container_finish(&state->presentation_container);
2835 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2837 if (state->buffer == buffer) return;
2839 wl_list_remove(&state->buffer_destroy_listener.link);
2840 state->buffer = buffer;
2842 wl_signal_add(&state->buffer->destroy_signal,
2843 &state->buffer_destroy_listener);
2847 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2849 Eina_Rectangle *dmg;
2850 Eina_Bool placed = EINA_TRUE;
2854 E_Comp_Wl_Buffer *buffer;
2855 struct wl_resource *cb;
2857 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2858 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2863 if ((ec->internal) ||
2864 (cdata->shell.surface && state->new_attach))
2868 e_comp->new_clients++;
2869 ELOGF("COMP", "Unignore", ec);
2870 e_client_unignore(ec);
2874 /* buffer transform */
2875 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2878 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2880 /* when buffer is transformed, we have to apply the new evas-map */
2881 state->buffer_viewport.changed = EINA_TRUE;
2883 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2885 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2887 if (transform_change == vp->wait_for_transform_change)
2888 vp->wait_for_transform_change = 0;
2890 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2891 // triggered by E_CLIENT_HOOK calls at those file.
2892 zone = e_comp_zone_find_by_ec(ec);
2895 eout = e_output_find(zone->output_id);
2896 if (eout && eout->hwc)
2898 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2900 if (e_comp_is_on_overlay(ec))
2901 e_comp_hwc_client_end(ec, __FUNCTION__);
2907 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2908 cdata->scaler.buffer_viewport = state->buffer_viewport;
2910 if (state->new_attach)
2912 e_comp_wl_surface_attach(ec, state->buffer);
2915 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2916 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2918 _e_comp_wl_surface_state_buffer_set(state, NULL);
2920 if ((state->new_attach) ||
2921 (state->buffer_viewport.changed))
2923 _e_comp_wl_surface_state_size_update(ec, state);
2924 e_comp_wl_map_size_cal_from_viewport(ec);
2926 /* update the position */
2927 if (ec->changes.pos)
2929 e_comp_object_frame_xy_unadjust(ec->frame,
2939 if (ec->new_client) placed = ec->placed;
2941 if (!ec->lock_client_size)
2946 ec->client.w = state->bw;
2947 ec->client.h = state->bh;
2949 e_comp_object_frame_wh_adjust(ec->frame,
2950 ec->client.w, ec->client.h,
2952 e_client_size_set(ec, nw, nh);
2954 if ((w != ec->w) || (h != ec->h))
2956 ec->changes.size = 1;
2961 if (ec->changes.buf_size)
2963 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
2964 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
2965 ec->changes.buf_size = EINA_FALSE;
2967 if (ec->move_after_resize)
2969 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
2970 ec->move_after_resize = EINA_FALSE;
2975 /* map or unmap ec */
2976 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
2977 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
2978 if (!pixmap_usable || hide_by_request)
2983 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
2988 if ((cdata->sub.below_obj) &&
2989 (evas_object_visible_get(cdata->sub.below_obj)))
2991 evas_object_hide(cdata->sub.below_obj);
2999 if ((cdata->sub.below_obj) &&
3000 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3001 (evas_object_visible_get(ec->frame)))
3003 evas_object_show(cdata->sub.below_obj);
3007 if ((state->new_attach) ||
3008 (state->buffer_viewport.changed))
3010 if ((e_comp_wl->drag) &&
3011 (e_comp_wl->drag_client) &&
3012 (e_comp_wl->drag_client == ec))
3014 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3016 e_drag_move(e_comp_wl->drag,
3018 e_comp_wl->drag->y);
3020 e_drag_resize(e_comp_wl->drag,
3021 state->bw, state->bh);
3023 else if ((cdata->shell.surface) &&
3024 (cdata->shell.configure))
3026 e_comp_wl_commit_sync_configure(ec);
3028 else if (!e_client_video_hw_composition_check(ec))
3030 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3035 ec->placed = placed;
3036 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3040 if (cdata->scaler.buffer_viewport.changed)
3041 e_comp_wl_map_apply(ec);
3043 /* resize transform object */
3044 if (ec->transformed)
3045 e_client_transform_update(ec);
3049 state->new_attach = EINA_FALSE;
3051 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3053 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3054 wl_resource_destroy(cb);
3057 /* insert state frame callbacks into comp_data->frames
3058 * NB: This clears state->frames list */
3059 cdata->frames = eina_list_merge(cdata->frames,
3061 state->frames = NULL;
3063 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3064 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3065 &state->presentation_container);
3067 buffer = e_pixmap_resource_get(ec->pixmap);
3069 /* put state damages into surface */
3072 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3073 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3075 if ((cdata->buffer_ref.buffer) &&
3076 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3077 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3079 e_comp_object_damage(ec->frame,
3081 cdata->buffer_ref.buffer->w,
3082 cdata->buffer_ref.buffer->h);
3087 Eina_List *damages = NULL;
3090 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3092 if (eina_list_count(state->buffer_damages))
3094 EINA_LIST_FREE(state->buffer_damages, dmg)
3097 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3098 e_comp_wl_output_buffer_transform_get(ec),
3100 dmg->x, dmg->y, dmg->w, dmg->h,
3101 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3102 damages = eina_list_append(damages, dmg);
3106 EINA_LIST_FREE(state->damages, dmg)
3107 damages = eina_list_append(damages, dmg);
3109 EINA_LIST_FREE(damages, dmg)
3111 /* not creating damage for ec that shows a underlay video */
3112 if (state->buffer_viewport.changed ||
3113 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3114 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3115 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3117 eina_rectangle_free(dmg);
3122 /* put state opaque into surface */
3123 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3126 Eina_Rectangle *rect;
3129 itr = eina_tiler_iterator_new(state->opaque);
3130 EINA_ITERATOR_FOREACH(itr, rect)
3134 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3135 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3136 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3140 eina_iterator_free(itr);
3143 /* put state input into surface */
3144 if ((state->input) &&
3145 (!eina_tiler_empty(state->input)) &&
3148 Eina_Tiler *src, *tmp;
3152 tmp = eina_tiler_new(sw, sh);
3153 eina_tiler_tile_size_set(tmp, 1, 1);
3155 eina_tiler_rect_add(tmp,
3156 &(Eina_Rectangle){0, 0, sw, sh});
3158 if ((src = eina_tiler_intersection(state->input, tmp)))
3160 Eina_Rectangle *rect;
3163 e_comp_object_input_objs_del(ec->frame);
3164 itr = eina_tiler_iterator_new(src);
3165 EINA_ITERATOR_FOREACH(itr, rect)
3167 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3168 ec, rect->x, rect->y, rect->w, rect->h,
3169 ec->w, ec->h, state->bw, state->bh);
3170 e_comp_object_input_area_set(ec->frame,
3175 eina_iterator_free(itr);
3176 eina_tiler_free(src);
3179 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3181 eina_tiler_free(tmp);
3183 /* clear input tiler */
3184 eina_tiler_clear(state->input);
3187 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3189 if ((cdata->video_client) &&
3191 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3192 (e_comp->wl_comp_data->available_hw_accel.underlay))
3194 e_pixmap_image_clear(ec->pixmap, 1);
3197 state->buffer_viewport.changed = 0;
3199 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3202 ec->exp_iconify.buffer_flush &&
3203 e_policy_visibility_client_is_iconic(ec))
3205 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3210 _e_comp_wl_surface_render_stop(E_Client *ec)
3212 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3213 //if ((!ec->internal) && (!e_comp_gl_get()))
3216 /* check if internal animation is running */
3217 if (e_comp_object_is_animating(ec->frame)) return;
3218 /* check if external animation is running */
3219 if (evas_object_data_get(ec->frame, "effect_running")) return;
3221 evas_object_hide(ec->frame);
3225 e_comp_wl_client_surface_finish(E_Client *ec)
3227 struct wl_resource *res, *surface;
3228 struct wl_client *surface_client = NULL;
3231 surface = e_comp_wl_client_surface_get(ec);
3234 surface_client = wl_resource_get_client(surface);
3236 if (surface_client &&
3237 (ec == e_client_focused_get()))
3239 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
3240 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
3242 if (wl_resource_get_client(res) ==
3244 e_comp_wl->kbd.focused =
3245 eina_list_remove_list(e_comp_wl->kbd.focused, l);
3249 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
3252 e_comp_wl_client_surface_set(ec, NULL);
3254 ec->comp_data->wl_surface = NULL;
3255 e_pixmap_win_id_del(ec->pixmap);
3257 _e_comp_wl_surface_render_stop(ec);
3258 e_object_del(E_OBJECT(ec));
3262 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3267 char proc[512], pname[512];
3270 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3272 h = fopen(proc, "r");
3275 len = fread(pname, sizeof(char), 512, h);
3277 pname[len - 1] = '\0';
3279 strncpy(pname, "NO NAME", sizeof(pname));
3285 strncpy(pname, "NO NAME", sizeof(pname));
3288 strncpy(name, pname, size);
3292 _e_comp_wl_pname_print(pid_t pid)
3295 char proc[512], pname[512];
3298 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3300 h = fopen(proc, "r");
3303 len = fread(pname, sizeof(char), 512, h);
3305 pname[len - 1] = '\0';
3307 strncpy(pname, "NO NAME", sizeof(pname));
3311 ELOGF("COMP", " |%s", NULL, pname);
3316 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3318 struct wl_client *client = data;
3319 E_Comp_Connected_Client_Info *cinfo;
3322 cinfo = wl_container_of(listener, cinfo, destroy);
3324 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3325 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3327 eai = e_appinfo_find_with_pid(cinfo->pid);
3328 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3331 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3333 wl_list_remove(&cinfo->destroy.link);
3334 eina_stringshare_del(cinfo->name);
3339 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3341 E_Comp_Connected_Client_Info *cinfo;
3343 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3344 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3346 cinfo->name = eina_stringshare_add(name);
3350 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3351 wl_client_add_destroy_listener(client, &cinfo->destroy);
3352 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3354 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3358 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3360 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3362 /* send configure */
3363 if (ec->comp_data->shell.configure_send)
3365 if (ec->comp_data->shell.surface)
3366 _e_comp_wl_configure_send(ec, 0, 0);
3369 e_comp_wl->kbd.focus = ec->comp_data->surface;
3373 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3375 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3377 /* send configure */
3378 if (ec->comp_data->shell.configure_send)
3380 if (ec->comp_data->shell.surface)
3381 _e_comp_wl_configure_send(ec, 0, 0);
3384 _e_comp_wl_focus_check();
3386 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3387 e_comp_wl->kbd.focus = NULL;
3391 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3393 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3394 if (ec->keyboard_resizing) return;
3396 /* do nothing currently */
3401 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3403 if (e_object_is_del(E_OBJECT(ec))) return;
3404 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3406 e_comp_wl->resize.edges = 0;
3407 e_comp_wl->resize.resource = NULL;
3411 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3413 if (e_object_is_del(E_OBJECT(ec))) return;
3414 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3418 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3421 int ratio_w, ratio_h;
3423 phys_w = output->phys_width;
3424 phys_h = output->phys_height;
3426 if (e_config->configured_output_resolution.use)
3428 // change the configured physical size(mm) of the output
3429 if (output->w != res_w)
3431 ratio_w = res_w / output->w;
3432 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3435 if (output->h != res_h)
3437 ratio_h = res_h / output->h;
3438 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3441 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3444 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3445 NULL, res_w, res_h, phys_w, phys_h, pid);
3447 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3448 wl_output_send_scale(resource, output->scale);
3450 wl_output_send_geometry(resource, output->x, output->y,
3452 output->subpixel, output->make ?: "",
3453 output->model ?: "", output->transform);
3455 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3456 res_w, res_h, output->refresh);
3458 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3459 wl_output_send_done(resource);
3463 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3465 E_Comp_Wl_Output *output;
3467 if (!(output = wl_resource_get_user_data(resource))) return;
3469 output->resources = eina_list_remove(output->resources, resource);
3473 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3475 E_Comp_Wl_Output *output;
3476 struct wl_resource *resource;
3477 E_Appinfo *eai = NULL;
3481 if (!(output = data)) return;
3484 wl_resource_create(client, &wl_output_interface, version, id);
3487 wl_client_post_no_memory(client);
3491 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3492 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3494 output->resources = eina_list_append(output->resources, resource);
3496 wl_resource_set_implementation(resource, NULL, output,
3497 _e_comp_wl_cb_output_unbind);
3498 wl_resource_set_user_data(resource, output);
3500 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3501 if (e_config->configured_output_resolution.use)
3503 wl_client_get_credentials(client, &pid, NULL, NULL);
3506 res_w = e_config->configured_output_resolution.w;
3507 res_h = e_config->configured_output_resolution.h;
3511 eai = e_appinfo_find_with_pid(pid);
3514 res_w = e_config->configured_output_resolution.w;
3515 res_h = e_config->configured_output_resolution.h;
3519 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3521 res_w = e_config->configured_output_resolution.w;
3522 res_h = e_config->configured_output_resolution.h;
3526 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3535 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3539 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3542 Evas_GL *evasgl = NULL;
3543 Evas_GL_API *glapi = NULL;
3544 Evas_GL_Context *ctx = NULL;
3545 Evas_GL_Surface *sfc = NULL;
3546 Evas_GL_Config *cfg = NULL;
3548 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3550 if (!e_comp_gl_get()) return;
3552 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3553 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3555 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3556 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3558 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3559 * then we should get evas from ecore_evas.
3562 evas = e_comp->evas;
3564 evas = ecore_evas_get(e_comp->ee);
3566 evasgl = evas_gl_new(evas);
3567 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3569 glapi = evas_gl_api_get(evasgl);
3570 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3571 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3573 cfg = evas_gl_config_new();
3574 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3576 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3577 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3579 ctx = evas_gl_context_create(evasgl, NULL);
3580 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3582 res = evas_gl_make_current(evasgl, sfc, ctx);
3583 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3585 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3586 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3588 evas_gl_config_free(cfg);
3590 evas_gl->gl = evasgl;
3591 evas_gl->glapi = glapi;
3592 evas_gl->glsfc = sfc;
3593 evas_gl->glctx = ctx;
3595 e_comp_wl->evas_gl = evas_gl;
3597 /* for native surface */
3600 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3605 evas_gl_config_free(cfg);
3606 evas_gl_make_current(evasgl, NULL, NULL);
3607 evas_gl_context_destroy(evasgl, ctx);
3608 evas_gl_surface_destroy(evasgl, sfc);
3609 evas_gl_free(evasgl);
3616 _e_comp_wl_gl_popup_cb_close(void *data,
3617 Evas_Object *obj EINA_UNUSED,
3618 void *event_info EINA_UNUSED)
3620 evas_object_del(data);
3624 _e_comp_wl_gl_popup_cb_focus(void *data,
3625 Evas_Object *obj EINA_UNUSED,
3626 void *event_info EINA_UNUSED)
3628 elm_object_focus_set(data, EINA_TRUE);
3633 _e_comp_wl_gl_idle(void *data)
3637 /* show warning window to notify failure of gl init */
3640 Evas_Object *win, *bg, *popup, *btn;
3642 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3643 elm_win_title_set(win, "Compositor Warning");
3644 elm_win_autodel_set(win, EINA_TRUE);
3645 elm_win_borderless_set(win, EINA_TRUE);
3646 elm_win_role_set(win, "notification-low");
3647 elm_win_alpha_set(win, EINA_TRUE);
3649 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3650 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3651 elm_win_resize_object_add(win, bg);
3652 evas_object_color_set(bg, 125, 125, 125, 125);
3653 evas_object_show(bg);
3655 popup = elm_popup_add(win);
3656 elm_object_text_set(popup,
3657 _( "Your screen does not support OpenGL.<br>"
3658 "Falling back to software engine."));
3659 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3661 btn = elm_button_add(popup);
3662 elm_object_text_set(btn, "Close");
3663 elm_object_part_content_set(popup, "button1", btn);
3664 evas_object_show(btn);
3666 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3667 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3669 evas_object_show(popup);
3670 evas_object_show(win);
3674 return ECORE_CALLBACK_CANCEL;
3678 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3680 struct wl_client *client = data;
3686 wl_client_get_credentials(client, &pid, &uid, &gid);
3688 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3690 _e_comp_wl_pname_print(pid);
3691 _e_comp_wl_pname_get(pid, name, sizeof(name));
3692 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3696 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3698 char buf[1024] = {0, };
3700 vsnprintf(buf, 1024, fmt, args);
3704 DBG("[libds] %s", buf);
3707 INF("[libds] %s", buf);
3710 ERR("[libds] %s", buf);
3718 _e_comp_wl_display_create(void)
3721 E_Comp_Wl_Data *wl_cdata;
3726 /* create new compositor data */
3727 if (!(comp = E_NEW(E_Comp_Data, 1)))
3729 ERR("Could not create compositor data: %m");
3732 wl_cdata = &comp->base;
3734 /* set compositor wayland data */
3735 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3737 g_mutex_init(&connection_mutex);
3739 /* try to create a wayland display */
3740 if (!(wl_cdata->wl.disp = wl_display_create()))
3742 ERR("Could not create a Wayland display: %m");
3746 /* try to setup wayland socket */
3747 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3749 ERR("Could not create Wayland display socket: %m");
3750 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3754 res = e_comp_socket_init(name);
3755 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3756 PRCTL("[Winsys] change permission and create sym link for %s", name);
3758 /* set wayland display environment variable */
3759 e_env_set("WAYLAND_DISPLAY", name);
3761 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3762 /* wl_cdata->output.scale = e_scale; */
3764 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3766 if (!e_compositor_init(wl_cdata->wl.disp))
3768 ERR("Failed to initialize compositor");
3772 comp->client_created.notify = _e_comp_wl_cb_client_created;
3773 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3775 if (!e_comp_wl_subsurfaces_init())
3777 ERR("Failed to init_subsurfaces");
3778 goto subsurfaces_err;
3781 /* initialize shm mechanism */
3782 wl_display_init_shm(wl_cdata->wl.disp);
3784 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3786 /* try to init data manager */
3787 if (!e_comp_wl_data_manager_init())
3789 ERR("Could not initialize data manager");
3793 /* try to init input */
3794 if (!e_comp_wl_input_init())
3796 ERR("Could not initialize input");
3800 if (e_comp_gl_get())
3801 _e_comp_wl_gl_init(NULL);
3803 /* get the wayland display loop */
3804 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3806 /* get the file descriptor of the wayland event loop */
3807 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3809 /* create a listener for wayland main loop events */
3811 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3812 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3813 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3814 _e_comp_wl_cb_prepare, wl_cdata);
3819 e_comp_wl_data_manager_shutdown();
3821 e_comp_wl_subsurfaces_shutdown();
3823 wl_list_remove(&comp->client_created.link);
3825 e_env_unset("WAYLAND_DISPLAY");
3827 wl_display_destroy(wl_cdata->wl.disp);
3829 g_mutex_clear(&connection_mutex);
3835 _e_comp_wl_gl_shutdown(void)
3837 if (!e_comp_wl->evas_gl) return;
3839 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3841 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3842 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3843 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3844 evas_gl_free(e_comp_wl->evas_gl->gl);
3846 E_FREE(e_comp_wl->evas_gl);
3849 /* public functions */
3852 * Creates and initializes a Wayland compositor with ecore.
3853 * Registers callback handlers for keyboard and mouse activity
3854 * and other client events.
3856 * @returns true on success, false if initialization failed.
3859 e_comp_wl_init(void)
3861 TRACE_DS_BEGIN(COMP_WL:INIT);
3863 /* try to create a wayland compositor */
3864 if (!_e_comp_wl_display_create())
3866 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3871 e_comp_wl_shell_init();
3873 #ifdef HAVE_WAYLAND_TBM
3874 e_comp_wl_tbm_init();
3876 e_comp_wl_remote_surface_init();
3880 e_comp_wl_screenshooter_init();
3882 if (!e_comp_wl_video_init())
3883 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3885 e_comp_wl_viewport_init();
3886 e_comp_wl_capture_init();
3887 e_comp_wl_renderer_init();
3888 _e_comp_wl_move_resize_init();
3889 e_presentation_time_init();
3890 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3893 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3894 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3896 /* add event handlers to catch E events */
3897 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3898 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3899 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3900 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3901 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3902 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3903 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3904 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3905 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3907 /* add hooks to catch e_client events */
3908 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3909 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3910 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3911 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3912 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3914 e_comp_wl->idle_exiter = ecore_idle_exiter_add(_e_comp_wl_cb_idle_exiter, NULL);
3921 e_comp_wl_deferred_job(void)
3923 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3926 /* internal functions */
3928 e_comp_wl_shutdown(void)
3930 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3932 ecore_idle_exiter_del(e_comp_wl->idle_exiter);
3934 e_comp_wl_subsurfaces_shutdown();
3936 E_FREE_LIST(handlers, ecore_event_handler_del);
3937 E_FREE_LIST(hooks, e_client_hook_del);
3938 _e_comp_wl_gl_shutdown();
3940 e_blender_shutdown();
3941 e_presentation_time_shutdown();
3942 e_comp_wl_renderer_shutdown();
3943 e_comp_wl_capture_shutdown();
3944 e_comp_wl_viewport_shutdown();
3945 e_comp_wl_video_shutdown();
3946 e_comp_wl_screenshooter_shutdown();
3948 e_comp_wl_remote_surface_shutdown();
3950 e_pixmap_shutdown();
3952 e_wtz_shell_shutdown();
3953 e_comp_wl_shell_shutdown();
3954 e_comp_wl_input_shutdown();
3956 wl_list_remove(&comp->client_created.link);
3959 e_comp->wl_comp_data = NULL;
3963 E_Comp_Wl_Output *output;
3965 if (e_comp_wl->screenshooter.global)
3966 wl_global_destroy(e_comp_wl->screenshooter.global);
3968 EINA_LIST_FREE(e_comp_wl->outputs, output)
3970 if (output->id) eina_stringshare_del(output->id);
3971 if (output->make) eina_stringshare_del(output->make);
3972 if (output->model) eina_stringshare_del(output->model);
3976 /* delete fd handler */
3977 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
3979 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
3980 cursor_timer_ec = NULL;
3982 /* free allocated data structure */
3988 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
3990 e_object_unref(E_OBJECT(ev->ec));
3995 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
3998 ev = E_NEW(E_Event_Client, 1);
4001 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4003 /* set usable early because shell module checks this */
4004 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4005 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4007 e_pixmap_resource_set(ec->pixmap, buffer);
4008 e_pixmap_dirty(ec->pixmap);
4009 e_pixmap_refresh(ec->pixmap);
4011 e_comp_wl_map_size_cal_from_buffer(ec);
4012 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4014 /* wm-policy module uses it */
4015 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4018 e_object_ref(E_OBJECT(ec));
4019 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4020 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4024 e_comp_wl_surface_commit(E_Client *ec)
4029 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4030 if (!e_comp_object_damage_exists(ec->frame))
4032 if ((ec->comp_data->video_client) ||
4033 (!e_client_video_hw_composition_check(ec)))
4034 e_pixmap_image_clear(ec->pixmap, 1);
4037 ignored = ec->ignored;
4039 if (e_comp_wl_subsurface_order_commit(ec))
4041 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4042 e_comp_wl_subsurface_restack(topmost);
4043 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4046 ec->ignored = ignored;
4048 if (ec->is_cursor && ec->visible)
4050 /* ignore cursor changes during resize/move I guess */
4051 if (!e_client_action_get())
4053 if (e_comp->pointer)
4055 x = e_comp->pointer->hot.x;
4056 y = e_comp->pointer->hot.y;
4058 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4064 static E_Comp_Wl_Output *
4065 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4068 E_Comp_Wl_Output *output;
4070 EINA_LIST_FOREACH(outputs, l, output)
4072 if (!strcmp(output->id, id))
4080 * Initializes information about one display output.
4082 * Adds or updates the given data about a single display output,
4083 * with an id matching the provided id.
4085 * @param id identification of output to be added or changed
4086 * @param make manufacturer name of the display output
4087 * @param model model name of the display output
4088 * @param x output's top left corner x coordinate
4089 * @param y output's top left corner y coordinate
4090 * @param w output's width in pixels
4091 * @param h output's height in pixels
4092 * @param pw output's physical width in millimeters
4093 * @param ph output's physical height in millimeters
4094 * @param refresh output's refresh rate in mHz
4095 * @param subpixel output's subpixel layout
4096 * @param transform output's rotation and/or mirror transformation
4098 * @returns True if a display output object could be added or updated
4101 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4102 int x, int y, int w, int h, int pw, int ph,
4103 unsigned int refresh, unsigned int subpixel,
4104 unsigned int transform)
4106 E_Comp_Wl_Output *output;
4108 struct wl_resource *resource;
4110 /* retrieve named output; or create it if it doesn't exist */
4111 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4114 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4116 if (id) output->id = eina_stringshare_add(id);
4118 output->make = eina_stringshare_add(make);
4120 output->make = eina_stringshare_add("unknown");
4122 output->model = eina_stringshare_add(model);
4124 output->model = eina_stringshare_add("unknown");
4126 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4129 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4130 2, output, _e_comp_wl_cb_output_bind);
4132 output->resources = NULL;
4133 output->scale = e_scale;
4136 /* update the output details */
4141 output->phys_width = pw;
4142 output->phys_height = ph;
4143 output->refresh = refresh;
4144 output->subpixel = subpixel;
4145 output->transform = transform;
4147 if (output->scale <= 0)
4148 output->scale = e_scale;
4150 /* if we have bound resources, send updates */
4151 EINA_LIST_FOREACH(output->resources, l2, resource)
4153 wl_output_send_geometry(resource,
4154 output->x, output->y,
4156 output->phys_height,
4158 output->make ?: "", output->model ?: "",
4161 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4162 wl_output_send_scale(resource, output->scale);
4164 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4165 output->w, output->h, output->refresh);
4167 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4168 wl_output_send_done(resource);
4175 e_comp_wl_output_remove(const char *id)
4177 E_Comp_Wl_Output *output;
4179 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4182 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4184 /* wl_global_destroy(output->global); */
4186 /* eina_stringshare_del(output->id); */
4187 /* eina_stringshare_del(output->make); */
4188 /* eina_stringshare_del(output->model); */
4195 _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)
4197 struct wl_resource *res;
4199 uint32_t serial, keycode;
4200 struct wl_client *wc = NULL;
4201 E_Comp_Config *comp_conf = NULL;
4202 const char *device_name = NULL;
4204 keycode = (ev->keycode - 8);
4206 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4208 comp_conf = e_comp_config_get();
4210 if (ec && ec->comp_data)
4212 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4215 wc = wl_resource_get_client(surface);
4218 if (e_config->key_input_ttrace_enable)
4220 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4221 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4224 EINA_LIST_FOREACH(key_list, l, res)
4226 if (wl_resource_get_client(res) != wc) continue;
4228 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4229 if (!e_input_thread_mode_get())
4231 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4232 device_name = ecore_device_name_get(ev->dev);
4238 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4239 device_name = e_device_name_get(dev);
4243 if (comp_conf && comp_conf->input_log_enable)
4244 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4246 wl_keyboard_send_key(res, serial, ev->timestamp,
4251 if (e_config->key_input_ttrace_enable)
4254 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4259 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4261 E_Client *ec = NULL;
4263 E_Comp_Wl_Key_Data *end, *k;
4265 if (ev->window != e_comp->ee_win)
4270 keycode = (ev->keycode - 8);
4271 if (!(e_comp_wl = e_comp->wl_comp_data))
4276 #ifndef E_RELEASE_BUILD
4277 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4278 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4279 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4280 eina_streq(ev->key, "BackSpace"))
4286 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4288 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4290 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4292 /* ignore server-generated key repeats */
4293 if (k->key == keycode)
4295 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4300 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4302 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4304 ec = e_client_focused_get();
4305 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4306 if (ec && ec->comp_data && surface)
4308 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4309 if (e_comp_wl->kbd.focused)
4311 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
4313 /* A key only sent to clients is added to the list */
4314 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4315 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4317 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4319 DBG("wl_array_add: Out of memory\n");
4320 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4321 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4324 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4328 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4332 /* update modifier state */
4333 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4339 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4341 E_Client *ec = NULL;
4342 uint32_t keycode, delivered_key;
4343 E_Comp_Wl_Key_Data *end, *k;
4345 if (ev->window != e_comp->ee_win)
4350 keycode = (ev->keycode - 8);
4352 if (!(e_comp_wl = e_comp->wl_comp_data))
4357 g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
4359 end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
4360 for (k = e_comp_wl->kbd.keys.data; k < end; k++)
4362 if (k->key == keycode)
4369 e_comp_wl->kbd.keys.size =
4370 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4372 g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
4374 /* 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) */
4375 if ((delivered_key) ||
4376 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4378 ec = e_client_focused_get();
4380 g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
4381 if (e_comp_wl->kbd.focused)
4383 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
4385 g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
4388 /* update modifier state */
4389 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4395 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4397 Eina_Bool res = EINA_FALSE;
4399 if (type == ECORE_EVENT_KEY_DOWN)
4401 res = e_comp_wl_key_down(ev, dev);
4403 else if (type == ECORE_EVENT_KEY_UP)
4405 res = e_comp_wl_key_up(ev, dev);
4412 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4415 struct wl_client *wc;
4416 uint32_t serial, btn;
4417 struct wl_resource *res;
4418 E_Comp_Config *comp_conf = NULL;
4420 if (ec->cur_mouse_action || e_comp_wl->drag)
4422 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4423 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4427 case 1: btn = BTN_LEFT; break;
4428 case 2: btn = BTN_MIDDLE; break;
4429 case 3: btn = BTN_RIGHT; break;
4430 default: btn = button_id; break;
4433 e_comp_wl->ptr.button = btn;
4434 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4435 if (!surface) return EINA_FALSE;
4437 if (!eina_list_count(e_comp_wl->ptr.resources))
4440 wc = wl_resource_get_client(surface);
4441 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4443 comp_conf = e_comp_config_get();
4445 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4447 if (wl_resource_get_client(res) != wc) continue;
4448 if (!e_comp_wl_input_pointer_check(res)) continue;
4449 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4451 if (comp_conf && comp_conf->input_log_enable)
4452 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4454 wl_pointer_send_button(res, serial, timestamp, btn, state);
4461 e_comp_wl_touch_cancel(void)
4463 _e_comp_wl_touch_cancel();
4466 E_API E_Comp_Wl_Hook *
4467 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4471 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4472 ch = E_NEW(E_Comp_Wl_Hook, 1);
4473 if (!ch) return NULL;
4474 ch->hookpoint = hookpoint;
4476 ch->data = (void*)data;
4477 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4482 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4485 if (_e_comp_wl_hooks_walking == 0)
4487 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4491 _e_comp_wl_hooks_delete++;
4494 E_API E_Comp_Wl_Pid_Hook *
4495 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4497 E_Comp_Wl_Pid_Hook *ch;
4499 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4501 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4502 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4504 ch->hookpoint = hookpoint;
4506 ch->data = (void*)data;
4507 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4513 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4516 if (_e_comp_wl_pid_hooks_walking == 0)
4518 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4522 _e_comp_wl_pid_hooks_delete++;
4525 E_API E_Comp_Wl_Intercept_Hook *
4526 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4528 E_Comp_Wl_Intercept_Hook *ch;
4530 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4531 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4532 if (!ch) return NULL;
4533 ch->hookpoint = hookpoint;
4535 ch->data = (void*)data;
4536 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4541 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4544 if (_e_comp_wl_intercept_hooks_walking == 0)
4546 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4550 _e_comp_wl_intercept_hooks_delete++;
4554 e_comp_wl_shell_surface_ready(E_Client *ec)
4558 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4562 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4564 e_config->use_cursor_timer = !!enabled;
4566 if (e_config->use_cursor_timer)
4568 if (!e_pointer_is_hidden(e_comp->pointer))
4570 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4575 if (e_comp_wl->ptr.hide_tmr)
4577 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4578 e_comp_wl->ptr.hide_tmr = NULL;
4580 cursor_timer_ec = NULL;
4582 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4585 if (e_pointer_is_hidden(e_comp->pointer))
4587 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4593 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4595 EINA_SAFETY_ON_NULL_RETURN(wc);
4596 EINA_SAFETY_ON_NULL_RETURN(dev);
4598 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4602 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4604 EINA_SAFETY_ON_NULL_RETURN(wc);
4605 EINA_SAFETY_ON_NULL_RETURN(dev);
4607 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4611 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4613 struct wl_resource *res;
4614 struct wl_client *wc;
4616 uint32_t serial, wl_keycode;
4617 enum wl_keyboard_key_state state;
4618 E_Comp_Config *comp_conf = NULL;
4619 const char *dev_name = NULL;
4621 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4622 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4623 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4625 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4626 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4628 wl_keycode = keycode - 8;
4629 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4631 wc = wl_resource_get_client(surface);
4632 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4633 if (!time) time = e_util_timestamp_get();
4634 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4635 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4637 comp_conf = e_comp_config_get();
4638 e_keyrouter_event_surface_send(ec, keycode);
4640 if (e_config->key_input_ttrace_enable)
4642 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4643 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4646 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4647 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4649 if (wl_resource_get_client(res) != wc) continue;
4650 if (!e_input_thread_mode_get())
4654 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4655 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4659 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4666 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4667 dev_name = e_device_name_get(dev);
4671 if (comp_conf && comp_conf->input_log_enable)
4672 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4675 wl_keyboard_send_key(res, serial, time,
4678 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4680 if (e_config->key_input_ttrace_enable)
4683 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4690 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4692 struct wl_resource *res;
4693 struct wl_client *wc;
4695 uint32_t serial, wl_keycode, cancel_keycode;
4696 E_Comp_Config *comp_conf = NULL;
4697 struct xkb_keymap *keymap = NULL;
4699 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4700 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4701 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4703 g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
4704 keymap = e_comp_wl->xkb.keymap;
4705 g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
4706 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4708 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4709 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4711 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4712 if (cancel_keycode == XKB_KEYCODE_INVALID)
4714 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4717 cancel_keycode = cancel_keycode - 8;
4719 wl_keycode = keycode - 8;
4720 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4722 wc = wl_resource_get_client(surface);
4723 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4724 if (!time) time = e_util_timestamp_get();
4726 comp_conf = e_comp_config_get();
4727 e_keyrouter_event_surface_send(ec, keycode);
4729 g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
4730 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
4732 if (wl_resource_get_client(res) != wc) continue;
4733 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4734 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4736 if (comp_conf && comp_conf->input_log_enable)
4737 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4738 wl_keyboard_send_key(res, serial, time,
4739 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4740 wl_keyboard_send_key(res, serial, time,
4741 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4742 wl_keyboard_send_key(res, serial, time,
4743 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4745 g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
4752 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)
4754 struct wl_client *wc;
4756 E_Devicemgr_Input_Device *device = NULL;
4758 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4759 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4760 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4762 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4763 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4765 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4767 wc = wl_resource_get_client(surface);
4768 if (!time) time = e_util_timestamp_get();
4769 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4773 _e_comp_wl_send_event_device(wc, time, dev, serial);
4774 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4778 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4779 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4782 x = x + ec->client.x;
4783 y = y + ec->client.y;
4785 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4791 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)
4793 E_Devicemgr_Input_Device *device;
4795 struct wl_client *wc;
4797 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4798 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4799 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4801 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4802 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4804 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4806 wc = wl_resource_get_client(surface);
4807 if (!time) time = e_util_timestamp_get();
4808 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4812 _e_comp_wl_send_event_device(wc, time, dev, serial);
4813 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4817 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4818 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4821 x = x + ec->client.x;
4822 y = y + ec->client.y;
4824 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4830 e_comp_wl_touch_cancel_send(E_Client *ec)
4832 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4833 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4834 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4836 _e_comp_wl_send_touch_cancel(ec);
4842 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4845 struct wl_client *wc;
4847 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4848 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4849 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4851 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4852 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4854 wc = wl_resource_get_client(surface);
4855 if (!time) time = e_util_timestamp_get();
4856 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4858 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4859 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4862 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4863 WL_POINTER_BUTTON_STATE_PRESSED);
4865 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4866 WL_POINTER_BUTTON_STATE_RELEASED);
4872 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4875 struct wl_client *wc;
4877 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4878 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4881 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4882 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4884 wc = wl_resource_get_client(surface);
4885 if (!time) time = e_util_timestamp_get();
4886 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4888 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4889 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4891 x = x + ec->client.x;
4892 y = y + ec->client.y;
4894 _e_comp_wl_send_mouse_move(ec, x, y, time);
4900 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4903 struct wl_client *wc;
4905 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4906 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4907 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4909 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4910 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4912 wc = wl_resource_get_client(surface);
4913 if (!time) time = e_util_timestamp_get();
4914 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4916 if (_e_comp_wl_check_cursor_timer_needed(ec))
4918 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4922 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4923 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4925 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4927 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4929 if (_e_comp_wl_check_cursor_timer_needed(ec))
4930 _e_comp_wl_cursor_move_timer_control(ec);
4937 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4940 struct wl_client *wc;
4941 struct wl_resource *res;
4944 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4945 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4947 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4948 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4950 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4951 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4953 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4954 wc = wl_resource_get_client(surface);
4955 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4956 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4958 if (!e_comp_wl_input_pointer_check(res)) continue;
4959 if (wl_resource_get_client(res) != wc) continue;
4961 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4962 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4964 wl_pointer_send_enter(res, serial, surface,
4965 wl_fixed_from_int(x),
4966 wl_fixed_from_int(y));
4967 ec->pointer_enter_sent = EINA_TRUE;
4969 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
4975 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
4978 struct wl_client *wc;
4979 struct wl_resource *res;
4982 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4983 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4984 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4985 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4986 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4987 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4989 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
4990 wc = wl_resource_get_client(surface);
4991 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4992 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4994 if (!e_comp_wl_input_pointer_check(res)) continue;
4995 if (wl_resource_get_client(res) != wc) continue;
4997 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4998 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5000 wl_pointer_send_leave(res, serial, surface);
5001 ec->pointer_enter_sent = EINA_FALSE;
5008 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)
5010 Evas_Event_Mouse_In ev_in;
5013 if (ec->pointer_enter_sent) return;
5015 ev_in.buttons = buttons;
5023 ev_in.modifiers = modifiers;
5024 ev_in.locks = locks;
5025 ev_in.timestamp = timestamp;
5026 ev_in.event_flags = event_flags;
5029 ev_in.event_src = event_src;
5031 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5035 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)
5037 Evas_Event_Mouse_Out ev_out;
5040 if (!ec->pointer_enter_sent) return;
5042 ev_out.buttons = buttons;
5044 ev_out.output.x = x;
5045 ev_out.output.y = y;
5046 ev_out.canvas.x = x;
5047 ev_out.canvas.y = y;
5050 ev_out.modifiers = modifiers;
5051 ev_out.locks = locks;
5052 ev_out.timestamp = timestamp;
5053 ev_out.event_flags = event_flags;
5056 ev_out.event_src = event_src;
5058 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5062 e_comp_wl_cursor_hide(E_Client *ec)
5064 struct wl_resource *res;
5065 struct wl_client *wc;
5069 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5071 if (e_comp_wl->ptr.hide_tmr)
5073 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5074 e_comp_wl->ptr.hide_tmr = NULL;
5076 cursor_timer_ec = NULL;
5078 if (!ec) return EINA_FALSE;
5079 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5080 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5081 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5083 wc = wl_resource_get_client(surface);
5084 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5085 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5087 if (!e_comp_wl_input_pointer_check(res)) continue;
5088 if (wl_resource_get_client(res) != wc) continue;
5089 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5090 wl_pointer_send_leave(res, serial, surface);
5091 ec->pointer_enter_sent = EINA_FALSE;
5097 /* surface to buffer
5098 * - width : surface width
5099 * - height : surface height
5100 * - transform: buffer transform
5101 * - scale : buffer scale
5103 * - width : screen width
5104 * - height : screen height
5105 * - transform: output transform
5106 * - scale : output scale
5108 static E_Util_Transform_Matrix
5109 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5111 E_Util_Transform_Matrix m;
5113 e_util_transform_matrix_load_identity(&m);
5115 if (transform & 0x4)
5117 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5118 e_util_transform_matrix_flip_x(&m);
5119 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5122 switch (transform & 0x3)
5124 case WL_OUTPUT_TRANSFORM_90:
5125 e_util_transform_matrix_translate(&m, -width, 0, 0);
5126 e_util_transform_matrix_rotation_z(&m, 270);
5128 case WL_OUTPUT_TRANSFORM_180:
5129 e_util_transform_matrix_translate(&m, -width, -height, 0);
5130 e_util_transform_matrix_rotation_z(&m, 180);
5132 case WL_OUTPUT_TRANSFORM_270:
5133 e_util_transform_matrix_translate(&m, 0, -height, 0);
5134 e_util_transform_matrix_rotation_z(&m, 90);
5140 e_util_transform_matrix_scale(&m, scale, scale, 1);
5145 /* surface to buffer
5146 * - surface width, surface height, buffer transform, buffer scale
5148 * - screen width, screen height, output transform, output scale
5151 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5153 E_Util_Transform_Matrix m;
5154 E_Util_Transform_Vertex v;
5156 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5158 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5159 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5160 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5164 * - buffer width, buffer height, buffer transform, buffer scale
5167 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5169 E_Util_Transform_Matrix m;
5170 E_Util_Transform_Vertex v;
5173 if (transform != 0 || scale > 1)
5175 tw = ((transform % 2) ? height : width) / scale;
5176 th = ((transform % 2) ? width : height) / scale;
5184 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5185 m = e_util_transform_matrix_inverse_get(&m);
5187 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5188 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5189 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5192 /* surface to buffer
5193 * - surface width, surface height, buffer transform, buffer scale
5195 * - screen width, screen height, output transform, output scale
5198 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5199 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5201 E_Util_Transform_Matrix m;
5202 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5203 E_Util_Transform_Rect_Vertex sv;
5205 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5207 sv = e_util_transform_rect_to_vertices(&sr);
5208 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5209 sr = e_util_transform_vertices_to_rect(&sv);
5218 * - buffer width, buffer height, buffer transform, buffer scale
5221 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5222 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5224 E_Util_Transform_Matrix m;
5225 E_Util_Transform_Rect br = {bx, by, bw, bh};
5226 E_Util_Transform_Rect_Vertex bv;
5229 if (transform != 0 || scale > 1)
5231 tw = ((transform % 2) ? height : width) / scale;
5232 th = ((transform % 2) ? width : height) / scale;
5240 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5241 m = e_util_transform_matrix_inverse_get(&m);
5243 bv = e_util_transform_rect_to_vertices(&br);
5244 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5245 br = e_util_transform_vertices_to_rect(&bv);
5253 EINTERN E_Comp_Wl_Output*
5254 e_comp_wl_output_find(E_Client *ec)
5257 E_Comp_Wl_Output *output;
5259 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5261 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5263 if (output->transform % 2)
5265 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5266 ec->y < output->x || ec->y >= (output->x + output->w))
5271 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5272 ec->y < output->y || ec->y >= (output->y + output->h))
5282 EINTERN Eina_Array *
5283 e_comp_wl_output_find_all(E_Client *ec)
5285 E_Comp_Wl_Output *output;
5286 Eina_Array *outputs;
5289 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5291 outputs = eina_array_new(4);
5295 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5297 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5298 output->x, output->y, output->w, output->h))
5300 eina_array_push(outputs, output);
5304 if (eina_array_count(outputs) == 0)
5306 eina_array_free(outputs);
5313 // --------------------------------------------------------
5314 // tizen_move_resize
5315 // --------------------------------------------------------
5317 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5324 E_Client_Pending_Geometry *geo;
5327 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5328 if (ec->fullscreen || ec->maximized) goto err;
5330 geo = E_NEW(E_Client_Pending_Geometry, 1);
5333 geo->serial = serial;
5339 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5340 ec->surface_sync.wait_commit = EINA_TRUE;
5345 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5352 e_comp_wl_commit_sync_configure(E_Client *ec)
5355 E_Client_Pending_Geometry *geo;
5357 Eina_Bool match_size = EINA_FALSE;
5364 if (!ec || !ec->frame) goto ret;
5365 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5368 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5369 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5371 if (eina_list_count(ec->surface_sync.pending_geometry))
5373 Eina_List *ll = NULL;
5374 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5378 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5383 if ((geo->w == bw) && (geo->h == bh))
5385 match_size = EINA_TRUE;
5390 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5397 if ((config.w != ec->w) || (config.h != ec->h))
5399 e_client_size_set(ec, config.w, config.h);
5400 ec->changes.size = EINA_TRUE;
5404 // FIXME: The geometry of the client would be better to be calculated
5405 // at e_desk or at e_desk_area. So the position(x,y) of the client
5406 // should be calcuated at the e_desk or at the e_desk_area.
5408 desk = e_comp_desk_find_by_ec(ec);
5411 ec->client.x = desk->geom.x + config.x;
5412 ec->client.y = desk->geom.y + config.y;
5416 ec->client.x = config.x;
5417 ec->client.y = config.y;
5420 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5422 e_client_pos_set(ec, ec->client.x, ec->client.y);
5424 ec->changes.pos = 1;
5428 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5432 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5433 ec->surface_sync.wait_commit = EINA_FALSE;
5435 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5437 // rollback wait_commit if there are pending requests remained
5438 if (eina_list_count(ec->surface_sync.pending_geometry))
5439 ec->surface_sync.wait_commit = EINA_TRUE;
5444 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);
5451 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5452 struct wl_resource *res_moveresize)
5454 wl_resource_destroy(res_moveresize);
5458 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5459 struct wl_resource *res_moveresize,
5460 struct wl_resource *surface,
5467 /* to be implemented */
5470 int cur_w = 0, cur_h = 0;
5472 ec = e_client_from_surface_resource(surface);
5475 pending = e_client_pending_geometry_has(ec);
5476 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5477 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);
5481 if ((cur_w == w) && (cur_h == h))
5483 e_client_pos_set(ec, x, y);
5484 ec->changes.pos = 1;
5490 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5494 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5497 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5499 _tz_move_resize_iface_cb_destroy,
5500 _tz_move_resize_iface_cb_set_geometry,
5504 _tz_moveresize_cb_bind(struct wl_client *client,
5505 void *data EINA_UNUSED,
5509 struct wl_resource *res_moveresize;
5511 res_moveresize = wl_resource_create(client,
5512 &tizen_move_resize_interface,
5515 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5518 wl_resource_set_implementation(res_moveresize,
5519 &_tz_move_resize_iface,
5525 ERR("Could not create tizen_move_resize_interface res: %m");
5526 wl_client_post_no_memory(client);
5530 _e_comp_wl_move_resize_init(void)
5532 if (!e_comp_wl) return;
5533 if (!e_comp_wl->wl.disp) return;
5535 if (!wl_global_create(e_comp_wl->wl.disp,
5536 &tizen_move_resize_interface,
5539 _tz_moveresize_cb_bind))
5541 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5548 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5550 E_Comp_Wl_Output *output;
5551 pid_t output_pid = 0;
5552 Eina_List *l = NULL, *l2 = NULL;
5553 struct wl_resource *resource = NULL;
5555 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5557 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5558 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5559 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5561 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5563 /* if we have bound resources, send updates */
5564 EINA_LIST_FOREACH(output->resources, l2, resource)
5566 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5567 if (output_pid != pid) continue;
5569 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5571 // send output information to the client
5572 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5580 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5582 _e_comp_wl_surface_state_init(state, w, h);
5586 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5588 _e_comp_wl_surface_state_commit(ec, state);
5592 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5594 _e_comp_wl_hook_call(hookpoint, ec);
5598 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5600 _e_comp_wl_surface_state_finish(state);
5604 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5606 _e_comp_wl_surface_state_buffer_set(state, buffer);
5610 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5611 int sx, int sy, int *dx, int *dy)
5615 case WL_OUTPUT_TRANSFORM_NORMAL:
5619 case WL_OUTPUT_TRANSFORM_FLIPPED:
5620 *dx = width - sx, *dy = sy;
5622 case WL_OUTPUT_TRANSFORM_90:
5623 *dx = height - sy, *dy = sx;
5625 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5626 *dx = height - sy, *dy = width - sx;
5628 case WL_OUTPUT_TRANSFORM_180:
5629 *dx = width - sx, *dy = height - sy;
5631 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5632 *dx = sx, *dy = height - sy;
5634 case WL_OUTPUT_TRANSFORM_270:
5635 *dx = sy, *dy = width - sx;
5637 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5647 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5650 int tx1, ty1, tx2, ty2;
5651 int width_from_buffer, height_from_buffer;
5653 switch (vp->buffer.transform)
5655 case WL_OUTPUT_TRANSFORM_90:
5656 case WL_OUTPUT_TRANSFORM_270:
5657 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5658 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5659 width_from_buffer = bh / vp->buffer.scale;
5660 height_from_buffer = bw / vp->buffer.scale;
5663 width_from_buffer = bw / vp->buffer.scale;
5664 height_from_buffer = bh / vp->buffer.scale;
5668 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5672 x2 = width_from_buffer;
5673 y2 = height_from_buffer;
5677 x1 = wl_fixed_to_int(vp->buffer.src_x);
5678 y1 = wl_fixed_to_int(vp->buffer.src_y);
5679 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5680 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5683 buffer_transform(width_from_buffer, height_from_buffer,
5684 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5685 buffer_transform(width_from_buffer, height_from_buffer,
5686 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5688 out->x = (tx1 <= tx2) ? tx1 : tx2;
5689 out->y = (ty1 <= ty2) ? ty1 : ty2;
5690 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5691 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5695 * Convert given four coordinates to elements of rectangle
5696 * @in p[4] Coordinates to be converted
5697 * @out rect x, y, width, and height
5698 * transform Angle which represents TDM_TRANSFORM of rectangle
5699 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5700 * 1. The given coordinates are not represented by rectangle.
5701 * 2. All angles except for 0, 90, 180, 270.
5704 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5706 Eina_Bool ret = EINA_FALSE;
5708 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))
5711 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5714 *rotation = TDM_TRANSFORM_NORMAL;
5717 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5721 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5724 *rotation = TDM_TRANSFORM_180;
5727 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5732 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))
5735 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5738 *rotation = TDM_TRANSFORM_90;
5741 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5745 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5748 *rotation = TDM_TRANSFORM_270;
5751 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5761 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5766 for (i = 0; i < 4; i++)
5767 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5769 if (!_coords_to_rectangle_convert(p, out, rotation))
5771 DBG("Cannot convert given coords to rectangle.\n"
5772 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5773 p[0].x, p[0].y, p[1].x, p[1].y,
5774 p[2].x, p[2].y, p[3].x, p[3].y);
5782 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5784 int trans_rotation, flip;
5786 trans_rotation = transform & 0x3;
5787 flip = transform & 0x4;
5789 return (flip + (trans_rotation + rotation) % 4);
5793 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5801 if (e_comp_wl_subsurface_check(ec))
5802 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5809 out->w = ec->comp_data->width_from_viewport;
5810 out->w = (out->w + 1) & ~1;
5811 out->h = ec->comp_data->height_from_viewport;
5813 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5814 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5818 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5820 E_Comp_Wl_Buffer *buffer;
5821 E_Comp_Wl_Buffer_Viewport *vp;
5823 enum wl_output_transform buffer_transform;
5824 unsigned int rotation;
5825 Eina_Bool res = EINA_FALSE;
5827 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5829 if (e_object_is_del(E_OBJECT(ec)))
5832 vp = &ec->comp_data->scaler.buffer_viewport;
5834 if (buffer_viewport)
5836 buffer = ec->comp_data->buffer_ref.buffer;
5837 /* Getting a viewport of buffer needs geometry of buffer. */
5841 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5844 if ((output_viewport) || (transform))
5846 m = e_client_map_get(ec);
5848 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5850 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5855 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5856 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5857 * Since buffer.transform isn't applied using evas_map,
5858 * it has to be taken into account here to apply buffer.transform
5859 * and rotation of e_client_transform together. */
5861 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5863 *transform = (unsigned int)buffer_transform;
5871 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5874 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5876 /* Must be called with valid comp_data */
5877 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5879 if ((ec->comp_data->role_name == NULL) ||
5880 (ec->comp_data->role_name == role_name) ||
5881 (strcmp(ec->comp_data->role_name, role_name) == 0))
5883 ec->comp_data->role_name = role_name;
5889 wl_resource_post_error(error_resource, error_code,
5890 "Cannot assign role %s to wl_surface@%d,"
5891 " already has role %s\n",
5893 ec->comp_data->wl_surface ?
5894 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5895 ec->comp_data->role_name);
5901 EINTERN const char *
5902 e_comp_wl_surface_role_get(E_Client *ec)
5904 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5905 return ec->comp_data ? ec->comp_data->role_name : NULL;
5908 EINTERN struct wl_resource *
5909 e_comp_wl_client_surface_get(E_Client *ec)
5911 struct wl_resource *surface = NULL;
5912 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5913 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5915 g_mutex_lock(&ec->comp_data->surface_mutex);
5916 surface = ec->comp_data->surface;
5917 g_mutex_unlock(&ec->comp_data->surface_mutex);
5922 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5924 EINA_SAFETY_ON_NULL_RETURN(ec);
5925 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5927 g_mutex_lock(&ec->comp_data->surface_mutex);
5928 ec->comp_data->surface = surface;
5929 g_mutex_unlock(&ec->comp_data->surface_mutex);
5933 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5935 return e_compositor_util_client_from_surface_resource(surface_resource);
5939 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5941 if (!ec->comp_data->mapped)
5943 if (ec->comp_data->shell.surface &&
5944 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5946 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5952 if (ec->comp_data->mapped)
5954 /* will be unmapped. so run capture */
5955 e_comp_wl_remote_surface_image_save(ec);
5959 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
5961 ec->comp_data->pending.sx = sx;
5962 ec->comp_data->pending.sy = sy;
5963 ec->comp_data->pending.new_attach = EINA_TRUE;
5965 e_client_fps_update(ec);
5969 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
5971 if (ec->comp_data->pending.opaque)
5972 eina_tiler_clear(ec->comp_data->pending.opaque);
5976 eina_tiler_union(ec->comp_data->pending.opaque, region);
5978 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
5982 ec->argb = EINA_FALSE;
5983 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5985 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5986 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
5994 ec->argb = EINA_TRUE;
5995 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
5997 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
5998 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6004 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6006 if (ec->comp_data->pending.input)
6007 eina_tiler_clear(ec->comp_data->pending.input);
6011 if (eina_tiler_empty(region))
6013 ELOGF("COMP", " |unset input rect", NULL);
6014 e_comp_object_input_objs_del(ec->frame);
6015 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6018 eina_tiler_union(ec->comp_data->pending.input, region);
6022 eina_tiler_rect_add(ec->comp_data->pending.input,
6023 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6028 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6030 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6034 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6036 E_Comp_Wl_Subsurf_Data *sdata;
6041 if (ec->comp_data->frames)
6043 ec->comp_data->frames =
6044 eina_list_remove(ec->comp_data->frames, callback_resource);
6047 if (ec->comp_data->pending.frames)
6049 ec->comp_data->pending.frames =
6050 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6053 sdata = ec->comp_data->sub.data;
6054 if ((sdata) && (sdata->cached.frames))
6056 sdata->cached.frames =
6057 eina_list_remove(sdata->cached.frames, callback_resource);
6062 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6064 if (e_object_is_del(E_OBJECT(ec))) return;
6066 if (e_comp_wl_remote_surface_commit(ec)) return;
6068 e_comp_wl_surface_commit(ec);
6070 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6074 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6076 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6077 ec->comp_data->sub.data = sub;
6079 /* set subsurface client properties */
6080 ec->borderless = EINA_TRUE;
6081 ec->argb = EINA_TRUE;
6082 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6083 ec->lock_border = EINA_TRUE;
6084 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6085 ec->netwm.state.skip_taskbar = EINA_TRUE;
6086 ec->netwm.state.skip_pager = EINA_TRUE;
6087 ec->border_size = 0;
6088 ec->lock_user_location = 0;
6089 ec->lock_client_location = 0;
6090 ec->lock_user_size = 0;
6091 ec->lock_client_size = 0;
6092 ec->lock_client_stacking = 0;
6093 ec->lock_user_maximize = 0;
6094 ec->lock_client_maximize = 0;
6095 ec->changes.need_maximize = 0;
6096 ec->maximized = E_MAXIMIZE_NONE;
6099 ec->new_client = ec->netwm.ping = EINA_TRUE;
6100 e_comp->new_clients++;
6101 e_client_unignore(ec);
6103 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6104 * It's not for subsurface. */
6105 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6109 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6111 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6114 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6116 sub->parent = parent;
6120 layer = e_client_layer_get(parent);
6121 if (layer > E_LAYER_BOTTOM)
6122 e_client_layer_set(ec, layer);
6125 if (parent->comp_data)
6127 /* append this client to the parents subsurface list */
6128 parent->comp_data->sub.list_pending =
6129 eina_list_append(parent->comp_data->sub.list_pending, ec);
6130 parent->comp_data->sub.list_changed = EINA_TRUE;
6135 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6137 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6138 E_Client *parent = sub->parent;
6140 parent->comp_data->sub.list =
6141 eina_list_remove(parent->comp_data->sub.list, ec);
6142 parent->comp_data->sub.list_pending =
6143 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6144 parent->comp_data->sub.below_list =
6145 eina_list_remove(parent->comp_data->sub.below_list, ec);
6146 parent->comp_data->sub.below_list_pending =
6147 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6153 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)
6155 sub->resource = subsurface_resource;
6156 sub->cached_buffer_ref.buffer = NULL;
6157 sub->synchronized = EINA_TRUE;
6158 sub->parent = parent;
6159 sub->remote_surface.offscreen_parent = offscreen_parent;
6160 if (offscreen_parent)
6161 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6163 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6165 _e_comp_wl_client_subsurface_set(ec, sub);
6166 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6168 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6172 e_comp_wl_client_subsurface_finish(E_Client *ec)
6174 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6177 e_comp_wl_client_subsurface_parent_unset(ec);
6179 e_comp_wl_surface_state_finish(&sub->cached);
6180 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6182 ec->comp_data->sub.data = NULL;
6186 e_comp_wl_client_evas_init(E_Client *ec)
6188 EINA_SAFETY_ON_NULL_RETURN(ec);
6190 _e_comp_wl_client_evas_init(ec);
6194 e_comp_wl_client_evas_deinit(E_Client *ec)
6196 EINA_SAFETY_ON_NULL_RETURN(ec);
6198 _e_comp_wl_client_evas_deinit(ec);
6202 e_comp_wl_focus_check(void)
6204 _e_comp_wl_focus_check();
6208 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6215 if ((parent->comp_data) && (parent->comp_data->sub.data))
6216 parent = parent->comp_data->sub.data->parent;