2 #include "e_comp_wl_intern.h"
3 #include "e_main_intern.h"
4 #include "e_foreign_intern.h"
5 #include "e_wtz_shell_intern.h"
6 #include "e_client_intern.h"
7 #include "e_appinfo_intern.h"
8 #include "e_blender_intern.h"
9 #include "e_utils_intern.h"
10 #include "e_scale_intern.h"
11 #include "e_comp_canvas_intern.h"
12 #include "e_comp_screen_intern.h"
13 #include "e_comp_wl_capture_intern.h"
14 #include "e_comp_wl_data_intern.h"
15 #include "e_comp_wl_input_intern.h"
16 #include "e_comp_wl_renderer_intern.h"
17 #include "e_comp_wl_rsm_intern.h"
18 #include "e_comp_wl_screenshooter_intern.h"
19 #include "e_comp_wl_shell_intern.h"
20 #include "e_comp_wl_subsurface_intern.h"
21 #include "e_comp_wl_tbm_intern.h"
22 #include "e_comp_wl_viewport_intern.h"
23 #include "e_comp_intern.h"
24 #include "e_input_intern.h"
25 #include "e_keyrouter_intern.h"
26 #include "e_error_intern.h"
27 #include "e_pointer_intern.h"
28 #include "e_presentation_time_intern.h"
29 #include "e_grabinput_intern.h"
30 #include "e_env_intern.h"
31 #include "e_dnd_intern.h"
32 #include "e_policy_visibility_intern.h"
33 #include "e_compositor_intern.h"
34 #include "e_client_video_intern.h"
35 #include "e_comp_wl_video_intern.h"
36 #include "e_comp_object_intern.h"
37 #include "e_desk_intern.h"
38 #include "e_zone_intern.h"
39 #include "e_hints_intern.h"
40 #include "e_comp_input_intern.h"
41 #include "e_blur_intern.h"
43 #include <tizen-extension-server-protocol.h>
44 #include <relative-pointer-unstable-v1-server-protocol.h>
45 #include <pointer-constraints-unstable-v1-server-protocol.h>
47 #include <wayland-tbm-server.h>
49 #include <libds/log.h>
50 #include <libds/single_pixel_buffer_v1.h>
54 #include <sys/resource.h>
56 /* handle include for printing uint64_t */
57 #define __STDC_FORMAT_MACROS
60 #define E_COM_WL_PREPARE_GAP_LOG_TIME 2000
62 /* Resource Data Mapping: (wl_resource_get_user_data)
64 * wl_surface == e_pixmap
65 * wl_region == eina_tiler
66 * wl_subsurface == e_client
70 typedef struct _E_Comp_Data E_Comp_Data;
75 struct wl_listener client_created;
78 static void _e_comp_wl_move_resize_init(void);
80 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec);
83 typedef struct _E_Comp_Wl_Key_Data
89 struct _E_Comp_Wl_Evas_Gl
92 Evas_GL_Config *glcfg;
93 Evas_GL_Context *glctx;
94 Evas_GL_Surface *glsfc;
98 static Eina_List *handlers = NULL;
99 static E_Client *cursor_timer_ec = NULL;
100 static Eina_Bool need_send_released = EINA_FALSE;
101 static Eina_Bool need_send_motion = EINA_TRUE;
103 static GMutex connection_mutex;
105 static int _e_comp_wl_hooks_delete = 0;
106 static int _e_comp_wl_hooks_walking = 0;
108 static int _e_comp_wl_pid_hooks_delete = 0;
109 static int _e_comp_wl_pid_hooks_walking = 0;
111 static int _e_comp_wl_intercept_hooks_delete = 0;
112 static int _e_comp_wl_intercept_hooks_walking = 0;
114 static Eina_Inlist *_e_comp_wl_hooks[] =
116 [E_COMP_WL_HOOK_SHELL_SURFACE_READY] = NULL,
117 [E_COMP_WL_HOOK_SUBSURFACE_CREATE] = NULL,
118 [E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE] = NULL,
119 [E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT] = NULL,
120 [E_COMP_WL_HOOK_BUFFER_CHANGE] = NULL,
121 [E_COMP_WL_HOOK_CLIENT_REUSE] = NULL,
122 [E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE] = NULL,
123 [E_COMP_WL_HOOK_DEL] = NULL,
124 [E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE] = NULL,
125 [E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT] = NULL,
126 [E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT] = NULL,
129 static Eina_Inlist *_e_comp_wl_pid_hooks[] =
131 [E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE] = NULL,
134 static Eina_Inlist *_e_comp_wl_intercept_hooks[] =
136 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN] = NULL,
137 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT] = NULL,
138 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE] = NULL,
139 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL] = NULL,
140 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN] = NULL,
141 [E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP] = NULL,
144 static Eina_List *hooks = NULL;
146 /* local functions */
148 _e_comp_wl_hooks_clean(void)
153 for (x = 0; x < E_COMP_WL_HOOK_LAST; x++)
154 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_hooks[x], l, ch)
156 if (!ch->delete_me) continue;
157 _e_comp_wl_hooks[x] = eina_inlist_remove(_e_comp_wl_hooks[x], EINA_INLIST_GET(ch));
163 _e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
167 e_object_ref(E_OBJECT(ec));
168 _e_comp_wl_hooks_walking++;
169 EINA_INLIST_FOREACH(_e_comp_wl_hooks[hookpoint], ch)
171 if (ch->delete_me) continue;
172 ch->func(ch->data, ec);
173 if ((hookpoint != E_COMP_WL_HOOK_DEL) &&
174 (e_object_is_del(E_OBJECT(ec))))
177 _e_comp_wl_hooks_walking--;
178 if ((_e_comp_wl_hooks_walking == 0) && (_e_comp_wl_hooks_delete > 0))
179 _e_comp_wl_hooks_clean();
180 e_object_unref(E_OBJECT(ec));
184 _e_comp_wl_pid_hooks_clean(void)
187 E_Comp_Wl_Pid_Hook *ch;
189 for (x = 0; x < E_COMP_WL_PID_HOOK_LAST; x++)
190 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_pid_hooks[x], l, ch)
192 if (!ch->delete_me) continue;
193 _e_comp_wl_pid_hooks[x] = eina_inlist_remove(_e_comp_wl_pid_hooks[x], EINA_INLIST_GET(ch));
199 _e_comp_wl_pid_hook_call(E_Comp_Wl_Pid_Hook_Point hookpoint, pid_t pid)
201 E_Comp_Wl_Pid_Hook *ch;
203 _e_comp_wl_pid_hooks_walking++;
204 EINA_INLIST_FOREACH(_e_comp_wl_pid_hooks[hookpoint], ch)
206 if (ch->delete_me) continue;
207 ch->func(ch->data, pid);
209 _e_comp_wl_pid_hooks_walking--;
210 if ((_e_comp_wl_pid_hooks_walking == 0) && (_e_comp_wl_pid_hooks_delete > 0))
211 _e_comp_wl_pid_hooks_clean();
215 _e_comp_wl_intercept_hooks_clean(void)
218 E_Comp_Wl_Intercept_Hook *ch;
220 for (x = 0; x < E_COMP_WL_INTERCEPT_HOOK_LAST; x++)
221 EINA_INLIST_FOREACH_SAFE(_e_comp_wl_intercept_hooks[x], l, ch)
223 if (!ch->delete_me) continue;
224 _e_comp_wl_intercept_hooks[x] = eina_inlist_remove(_e_comp_wl_intercept_hooks[x], EINA_INLIST_GET(ch));
230 _e_comp_wl_intercept_hook_call(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Client *ec)
232 E_Comp_Wl_Intercept_Hook *ch;
233 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
235 e_object_ref(E_OBJECT(ec));
236 _e_comp_wl_intercept_hooks_walking++;
237 EINA_INLIST_FOREACH(_e_comp_wl_intercept_hooks[hookpoint], ch)
239 if (ch->delete_me) continue;
240 res = ch->func(ch->data, ec);
241 if (!res) ret = EINA_FALSE;
242 if (e_object_is_del(E_OBJECT(ec)))
245 _e_comp_wl_intercept_hooks_walking--;
246 if ((_e_comp_wl_intercept_hooks_walking == 0) && (_e_comp_wl_intercept_hooks_delete > 0))
247 _e_comp_wl_intercept_hooks_clean();
248 e_object_unref(E_OBJECT(ec));
255 _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
261 if (e_comp_object_frame_exists(ec->frame))
262 w = ec->client.w, h = ec->client.h;
264 w = ec->w, h = ec->h;
268 // Width and Height are -1 means that we don't consider size value
272 e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
276 _e_comp_wl_focus_check(void)
280 if (stopping) return;
281 ec = e_client_focused_get();
283 e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE);
287 _e_comp_wl_cb_read(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
289 /* dispatch pending wayland events */
290 wl_event_loop_dispatch(e_comp_wl->wl.loop, 0);
292 return ECORE_CALLBACK_RENEW;
296 e_comp_wl_display_flush()
298 if (e_comp_wl && e_comp_wl->wl.disp)
300 if (e_config->key_input_ttrace_enable)
302 TRACE_INPUT_BEGIN(wl_display_flush_clients);
303 ELOGF("INPUT", "wl_display_flush_clients|B|", NULL);
306 g_mutex_lock(&connection_mutex);
307 wl_display_flush_clients(e_comp_wl->wl.disp);
308 g_mutex_unlock(&connection_mutex);
310 if (e_config->key_input_ttrace_enable)
313 ELOGF("INPUT", "wl_display_flush_clients|E|", NULL);
319 e_comp_wl_connection_lock()
321 e_input_boost_lock(&connection_mutex);
325 e_comp_wl_connection_unlock()
327 e_input_boost_unlock(&connection_mutex);
331 e_comp_wl_focused_client_flush()
333 E_Client *focused_ec;
334 if (!(e_comp_wl && e_comp_wl->wl.disp)) return;
336 e_input_boost_lock(&connection_mutex);
337 focused_ec = e_client_focused_get();
341 struct wl_client *wc;
342 struct wl_resource *surface = e_comp_wl_client_surface_get(focused_ec);
345 e_input_boost_unlock(&connection_mutex);
349 wc = wl_resource_get_client(surface);
353 e_input_boost_unlock(&connection_mutex);
357 _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED)
361 if (e_comp_wl->idle_exiter_timestamp > 0.0)
363 gap_time = (ecore_time_get() * 1000) - e_comp_wl->idle_exiter_timestamp;
364 if (gap_time > E_COM_WL_PREPARE_GAP_LOG_TIME)
366 ELOGF("E_COMP", "prepare gap time: %lfms",
371 e_comp_wl->idle_exiter_timestamp = 0.0;
373 wl_event_loop_dispatch_idle(e_comp_wl->wl.loop);
375 /* flush pending client events */
376 e_comp_wl_display_flush();
378 TRACE_DS_ASYNC_END((intptr_t)&e_comp_wl->idle_exiter_timestamp,
379 IDLE_EXITER~CB_PREPARE);
381 // _e_comp_wl_cb_prepare() function is called before idle state in ecore_main_loop.
382 // idle state means that epoll() or select() is called in ecore_main_loop.
383 e_main_hook_call(E_MAIN_HOOK_LOOP_BEFORE_IDLE_ENTER);
387 _e_comp_wl_cb_awake(void *data)
389 e_comp_wl->idle_exiter_timestamp = ecore_time_get() * 1000;
391 TRACE_DS_ASYNC_BEGIN((intptr_t)&e_comp_wl->idle_exiter_timestamp,
392 IDLE_EXITER~CB_PREPARE);
394 // _e_comp_wl_cb_awake() function is called after idle state in ecore_main_loop.
395 // ecore_main_loop awake due to returning from epoll() or select()
396 e_main_hook_call(E_MAIN_HOOK_LOOP_AFTER_IDLE_EXIT);
399 E_API enum wl_output_transform
400 e_comp_wl_output_buffer_transform_get(E_Client *ec)
402 E_Comp_Wl_Buffer_Viewport *vp;
403 E_Comp_Wl_Buffer *buffer;
404 enum wl_output_transform transform, rotation;
406 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
407 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
408 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
410 vp = &ec->comp_data->scaler.buffer_viewport;
411 if (e_comp_wl_subsurface_check(ec))
412 return vp->buffer.transform;
414 buffer = ec->comp_data->buffer_ref.buffer;
417 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
418 return vp->buffer.transform;
420 rotation = buffer->transform;
422 return vp->buffer.transform;
424 /* ignore the flip value when calculating transform because the screen rotation
425 * functionality doesn't consider the flip output transform currently
427 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
429 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
430 ec, rotation, vp->buffer.transform, transform);
435 EINTERN enum wl_output_transform
436 e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
438 E_Comp_Wl_Buffer_Viewport *vp;
439 E_Comp_Wl_Buffer *buffer;
440 enum wl_output_transform transform, rotation;
442 if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL;
443 if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL;
444 if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
446 vp = &ec->comp_data->pending.buffer_viewport;
447 if (e_comp_wl_subsurface_check(ec))
448 return vp->buffer.transform;
450 buffer = ec->comp_data->pending.buffer;
453 (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM))
454 return vp->buffer.transform;
456 rotation = buffer->transform;
458 return vp->buffer.transform;
460 /* ignore the flip value when calculating transform because the screen rotation
461 * functionality doesn't consider the flip output transform currently
463 transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3;
465 DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)",
466 ec, rotation, vp->buffer.transform, transform);
472 e_comp_wl_map_size_cal_from_buffer(E_Client *ec)
474 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
475 E_Comp_Wl_Buffer *buffer;
476 int32_t width, height;
478 buffer = e_pixmap_resource_get(ec->pixmap);
481 ec->comp_data->width_from_buffer = 0;
482 ec->comp_data->height_from_buffer = 0;
486 switch (e_comp_wl_output_buffer_transform_get(ec))
488 case WL_OUTPUT_TRANSFORM_90:
489 case WL_OUTPUT_TRANSFORM_270:
490 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
491 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
492 width = buffer->h / vp->buffer.scale;
493 height = buffer->w / vp->buffer.scale;
496 width = buffer->w / vp->buffer.scale;
497 height = buffer->h / vp->buffer.scale;
501 ec->comp_data->width_from_buffer = width;
502 ec->comp_data->height_from_buffer = height;
506 e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
508 E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
509 int32_t width, height;
511 width = ec->comp_data->width_from_buffer;
512 height = ec->comp_data->height_from_buffer;
514 if (width == 0 && height == 0) return;
516 if (width != 0 && vp->surface.width != -1)
518 ec->comp_data->width_from_viewport = vp->surface.width;
519 ec->comp_data->height_from_viewport = vp->surface.height;
523 if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
525 int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
526 int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
527 ec->comp_data->width_from_viewport = w ?: 1;
528 ec->comp_data->height_from_viewport = h ?: 1;
532 ec->comp_data->width_from_viewport = width;
533 ec->comp_data->height_from_viewport = height;
537 e_comp_wl_topmost_parent_get(E_Client *ec)
541 if (!e_comp_wl_subsurface_check(ec))
544 parent = e_comp_wl_subsurface_parent_get(ec);
547 if (!e_comp_wl_subsurface_check(parent))
550 parent = e_comp_wl_subsurface_parent_get(parent);
557 e_comp_wl_map_apply(E_Client *ec)
559 E_Comp_Wl_Buffer_Viewport *vp;
560 E_Comp_Wl_Subsurf_Data *sdata;
561 E_Comp_Wl_Client_Data *cdata;
562 int x1, y1, x2, y2, x, y;
564 Eina_Bool zoom_animating = EINA_FALSE;
566 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
568 e_comp_object_map_update(ec->frame);
570 cdata = ec->comp_data;
571 vp = &cdata->scaler.buffer_viewport;
572 if ((vp->buffer.src_width == wl_fixed_from_int(-1)) &&
573 (!cdata->viewport_transform))
576 if (e_comp_wl_subsurface_check(ec))
578 e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
580 sdata = ec->comp_data->sub.data;
581 if (sdata->remote_surface.offscreen_parent)
583 E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
584 Eina_Rectangle *rect;
587 EINA_LIST_FOREACH(offscreen_parent->comp_data->remote_surface.regions, l, rect)
589 /* TODO: If there are one more regions, it means that provider's offscreen
590 * is displayed by one more remote_surfaces. Have to consider it later. At
591 * this time, just consider only one remote_surface.
605 evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
606 if (x != dx || y != dy)
607 evas_object_move(ec->frame, dx, dy);
609 if (!cdata->viewport_transform)
611 cdata->viewport_transform = e_util_transform_new();
612 e_util_transform_role_set(cdata->viewport_transform, "viewport_transform");
613 e_client_transform_core_add(ec, cdata->viewport_transform);
616 e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
617 ec->comp_data->width_from_viewport,
618 ec->comp_data->height_from_viewport);
620 if (vp->buffer.src_width == wl_fixed_from_int(-1))
624 x2 = cdata->width_from_buffer;
625 y2 = cdata->height_from_buffer;
629 x1 = wl_fixed_to_int(vp->buffer.src_x);
630 y1 = wl_fixed_to_int(vp->buffer.src_y);
631 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
632 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
635 e_util_transform_texcoord_set(cdata->viewport_transform, 0, x1, y1);
636 e_util_transform_texcoord_set(cdata->viewport_transform, 1, x2, y1);
637 e_util_transform_texcoord_set(cdata->viewport_transform, 2, x2, y2);
638 e_util_transform_texcoord_set(cdata->viewport_transform, 3, x1, y2);
641 desk = e_comp_desk_find_by_ec(ec);
643 zoom_animating = e_desk_zoom_is_animating(desk);
645 ELOGF("TRANSFORM", "viewport map: point(%d,%d %dx%d) uv(%d,%d %d,%d %d,%d %d,%d), zoom_animating: %d",
646 ec, ec->x, ec->y, ec->comp_data->width_from_viewport,
647 ec->comp_data->height_from_viewport, x1, y1, x2, y1, x2, y2, x1, y2, zoom_animating);
649 /* workaround:: when the desk zoom is doing their animation,
650 the transform core update can override animation's zoom boundary.
651 so, don't doing transform core update while desk zoom animation */
653 e_client_transform_core_update(ec);
658 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
662 int map_c = 0, map_x = 0, map_y = 0;
663 double inv_x = 0.0, inv_y = 0.0;
665 EINA_SAFETY_ON_NULL_RETURN(ec);
667 map = e_client_map_get(ec);
668 map_c = e_map_count_get(map);
670 if (!map || map_c <= 0)
680 e_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
681 e_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
682 e_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
683 e_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
685 for (int i = 0; i < map_c; i++)
687 e_map_point_coord_get(map, i, &map_x, &map_y, NULL);
688 e_map_point_image_uv_set(map2, i, map_x, map_y);
690 e_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
700 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
706 if (!(ec = data)) return;
707 if (e_object_is_del(data)) return;
709 if (!ec->override) e_hints_window_visible_set(ec);
711 if ((!ec->override) && (!ec->re_manage) && (!ec->comp_data->reparented) &&
712 (!ec->comp_data->need_reparent))
714 ec->comp_data->need_reparent = EINA_TRUE;
715 ec->visible = EINA_TRUE;
717 if (!e_client_util_ignored_get(ec))
719 ec->take_focus = !starting;
723 if (!ec->comp_data->need_reparent)
725 if ((ec->hidden) || (ec->iconic))
727 evas_object_hide(ec->frame);
728 // e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
731 evas_object_show(ec->frame);
734 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
735 evas_object_show(tmp->frame);
737 topmost = e_comp_wl_topmost_parent_get(ec);
738 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
739 e_comp_wl_subsurface_show(ec);
741 if (ec->comp_data->sub.below_obj)
742 evas_object_show(ec->comp_data->sub.below_obj);
746 _e_comp_wl_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
752 if (!(ec = data)) return;
753 if (e_object_is_del(E_OBJECT(ec))) return;
755 /* Uncommonly some clients's final buffer can be skipped if the client
756 * requests unmap of its surface right after wl_surface@commit.
757 * So if this client evas object is hidden state and client is already
758 * unmmapped, we can consider to clear pixmap image here mandatorily.
760 if (!ec->comp_data->mapped)
761 e_pixmap_image_clear(ec->pixmap, 1);
763 EINA_LIST_FOREACH(ec->e.state.video_child, l, tmp)
764 evas_object_hide(tmp->frame);
766 topmost = e_comp_wl_topmost_parent_get(ec);
767 if (topmost == ec && (ec->comp_data->sub.list || ec->comp_data->sub.below_list))
768 e_comp_wl_subsurface_hide(ec);
770 if (ec->comp_data->sub.below_obj)
771 evas_object_hide(ec->comp_data->sub.below_obj);
773 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_unmap_signal, ec);
777 _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
784 if (!(ec = data)) return;
785 if (e_object_is_del(E_OBJECT(ec))) return;
787 EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
789 if (!e_comp_wl_subsurface_check(subc)) continue;
790 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
791 evas_object_move(subc->frame, x, y);
793 if (subc->comp_data->scaler.viewport)
795 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
796 if (cdata->viewport_transform)
797 e_comp_wl_map_apply(subc);
801 EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
803 if (!e_comp_wl_subsurface_check(subc)) continue;
804 e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
805 evas_object_move(subc->frame, x, y);
807 if (subc->comp_data->scaler.viewport)
809 E_Comp_Wl_Client_Data *cdata = subc->comp_data;
810 if (cdata->viewport_transform)
811 e_comp_wl_map_apply(subc);
815 if (ec->comp_data->sub.below_obj)
817 evas_object_move(ec->comp_data->sub.below_obj, ec->x, ec->y);
818 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
823 _e_comp_wl_send_touch_cancel(E_Client *ec)
826 struct wl_resource *res;
827 struct wl_client *wc;
828 E_Comp_Config *comp_conf = NULL;
831 if (e_object_is_del(E_OBJECT(ec))) return;
832 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
834 if (!surface) return;
835 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
837 wc = wl_resource_get_client(surface);
839 comp_conf = e_comp_config_get();
841 EINA_LIST_FOREACH(e_comp->wl_comp_data->touch.resources, l, res)
843 if (wl_resource_get_client(res) != wc) continue;
844 if (!e_comp_wl_input_touch_check(res)) continue;
846 if (comp_conf && comp_conf->input_log_enable)
847 ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
849 wl_touch_send_cancel(res);
854 _e_comp_wl_touch_cancel(void)
858 ec = e_comp_wl->ptr.ec ? e_comp_wl->ptr.ec : e_comp_wl->touch.faked_ec;
860 if (!e_comp_wl->touch.pressed) return;
862 _e_comp_wl_send_touch_cancel(ec);
865 static E_Devicemgr_Input_Device *
866 _e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
868 E_Devicemgr_Input_Device *last_kbd = NULL;
871 case ECORE_DEVICE_CLASS_MOUSE:
872 return e_devicemgr->last_device_ptr;
873 case ECORE_DEVICE_CLASS_KEYBOARD:
874 last_kbd = atomic_load(&e_devicemgr->last_device_kbd);
876 case ECORE_DEVICE_CLASS_TOUCH:
877 return e_devicemgr->last_device_touch;
885 _e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
889 case ECORE_DEVICE_CLASS_MOUSE:
890 e_devicemgr->last_device_ptr = device;
892 case ECORE_DEVICE_CLASS_KEYBOARD:
893 atomic_store(&e_devicemgr->last_device_kbd, device);
895 case ECORE_DEVICE_CLASS_TOUCH:
896 e_devicemgr->last_device_touch = device;
903 static E_Devicemgr_Input_Device *
904 _e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
906 E_Devicemgr_Input_Device *last_kbd = NULL;
910 case ECORE_DEVICE_CLASS_MOUSE:
911 return ec->comp_data->last_device_ptr;
912 case ECORE_DEVICE_CLASS_KEYBOARD:
913 last_kbd = atomic_load(&ec->comp_data->last_device_kbd);
915 case ECORE_DEVICE_CLASS_TOUCH:
916 return ec->comp_data->last_device_touch;
924 _e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device)
928 case ECORE_DEVICE_CLASS_MOUSE:
929 ec->comp_data->last_device_ptr = device;
931 case ECORE_DEVICE_CLASS_KEYBOARD:
932 atomic_store(&ec->comp_data->last_device_kbd, device);
934 case ECORE_DEVICE_CLASS_TOUCH:
935 ec->comp_data->last_device_touch = device;
943 _e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
945 E_Devicemgr_Input_Device *last_device, *ec_last_device, *input_dev;
946 struct wl_resource *dev_res;
947 const char *dev_name;
948 Ecore_Device_Class dev_class;
949 struct wl_client *wc;
953 EINA_SAFETY_ON_NULL_RETURN(dev);
956 if (ec->cur_mouse_action || e_comp_wl->drag)
958 if (e_object_is_del(E_OBJECT(ec))) return;
959 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
960 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
961 if (!surface) return;
963 dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
964 dev_name = evas_device_description_get(dev);
965 last_device = _e_comp_wl_device_last_device_get(dev_class);
966 ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
968 serial = wl_display_next_serial(e_comp_wl->wl.disp);
969 wc = wl_resource_get_client(surface);
970 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
971 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
973 if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
974 if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
976 _e_comp_wl_device_last_device_set(dev_class, input_dev);
977 _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
979 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
981 if (wl_resource_get_client(dev_res) != wc) continue;
982 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
986 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
990 _e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
992 E_Devicemgr_Input_Device *last_device;
993 struct wl_resource *dev_res;
994 struct wl_client *wc;
998 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
999 if (!surface) return;
1001 last_device = _e_comp_wl_device_last_device_get(dev_class);
1002 if (!last_device) return;
1004 _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
1006 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1007 wc = wl_resource_get_client(surface);
1008 EINA_LIST_FOREACH(last_device->resources, l, dev_res)
1010 if (wl_resource_get_client(dev_res) != wc) continue;
1011 tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
1016 _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
1018 E_Devicemgr_Input_Device *input_dev;
1019 struct wl_resource *dev_res;
1020 const char *dev_name;
1023 EINA_SAFETY_ON_NULL_RETURN(dev);
1025 dev_name = ecore_device_identifier_get(dev);
1027 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1028 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1030 if (!eina_streq(input_dev->identifier, dev_name) ||
1031 (input_dev->clas != ecore_device_class_get(dev))) continue;
1032 _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
1034 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1036 if (wl_resource_get_client(dev_res) != wc) continue;
1037 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1040 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1044 _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
1046 E_Devicemgr_Input_Device *input_dev;
1047 struct wl_resource *dev_res;
1048 const char *dev_name;
1051 EINA_SAFETY_ON_NULL_RETURN(dev);
1053 dev_name = e_device_identifier_get(dev);
1055 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1056 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1058 if (!eina_streq(input_dev->identifier, dev_name) ||
1059 (input_dev->clas != e_device_class_get(dev))) continue;
1060 _e_comp_wl_device_last_device_set(e_device_class_get(dev), input_dev);
1062 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1064 if (wl_resource_get_client(dev_res) != wc) continue;
1065 tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
1068 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1072 _e_comp_wl_cursor_reload(E_Client *ec)
1074 struct wl_resource *res;
1075 struct wl_client *wc;
1081 if (e_comp->pointer && e_comp->pointer->o_ptr &&
1082 !evas_object_visible_get(e_comp->pointer->o_ptr))
1083 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
1086 if (e_object_is_del(E_OBJECT(ec))) return;
1087 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1088 if (!surface) return;
1089 if (ec->pointer_enter_sent) return;
1091 px = wl_fixed_to_int(e_comp_wl->ptr.x);
1092 py = wl_fixed_to_int(e_comp_wl->ptr.y);
1094 if (e_client_transform_core_enable_get(ec))
1096 double dx = 0.0, dy = 0.0;
1097 map = e_client_map_get(ec);
1098 e_map_coords_get(map, (double)px, (double)py, &dx, &dy, 0);
1104 cx = px - ec->client.x;
1105 cy = py - ec->client.y;
1107 wc = wl_resource_get_client(surface);
1108 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1109 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1111 if (!e_comp_wl_input_pointer_check(res)) continue;
1112 if (wl_resource_get_client(res) != wc) continue;
1113 wl_pointer_send_enter(res, serial, surface,
1114 wl_fixed_from_int(cx), wl_fixed_from_int(cy));
1115 ec->pointer_enter_sent = EINA_TRUE;
1117 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1121 _e_comp_wl_cursor_timer(void *data)
1123 E_Client *ec = data;
1125 ELOGF("Mouse", "Cursor hide timer expired after %d sec.", ec, e_config->cursor_timer_interval);
1126 if (e_comp_wl->relative_ptr.activated) return ECORE_CALLBACK_CANCEL;
1128 e_comp_wl_cursor_hide(ec);
1130 return ECORE_CALLBACK_CANCEL;
1134 _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)
1136 E_Devicemgr_Input_Device *input_dev;
1137 struct wl_resource *dev_res;
1138 struct wl_client *wc;
1143 if (ec->cur_mouse_action) return;
1144 if (e_object_is_del(E_OBJECT(ec))) return;
1145 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1146 if (!surface) return;
1148 f_value = wl_fixed_from_double(value);
1149 wc = wl_resource_get_client(surface);
1151 g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
1152 EINA_LIST_FOREACH(e_devicemgr->device_list, l, input_dev)
1154 if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
1155 EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
1157 if (wl_resource_get_client(dev_res) != wc) continue;
1158 tizen_input_device_send_axis(dev_res, axis_type, f_value);
1161 g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
1165 _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)
1167 if (idx >= e_input_touch_max_count_get()) return;
1169 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1170 e_devicemgr->multi[idx].radius_x = radius_x;
1171 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1172 e_devicemgr->multi[idx].radius_y = radius_y;
1173 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1174 e_devicemgr->multi[idx].pressure = pressure;
1175 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1176 e_devicemgr->multi[idx].angle = angle;
1180 _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)
1182 if (idx >= e_input_touch_max_count_get()) return;
1184 if (e_devicemgr->multi[idx].radius_x != radius_x)
1186 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
1187 e_devicemgr->multi[idx].radius_x = radius_x;
1189 if (e_devicemgr->multi[idx].radius_y != radius_y)
1191 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
1192 e_devicemgr->multi[idx].radius_y = radius_y;
1194 if (e_devicemgr->multi[idx].pressure != pressure)
1196 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_PRESSURE, pressure);
1197 e_devicemgr->multi[idx].pressure = pressure;
1199 if (e_devicemgr->multi[idx].angle != angle)
1201 _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_ANGLE, angle);
1202 e_devicemgr->multi[idx].angle = angle;
1207 _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Client *ec)
1209 Eina_Bool ret = EINA_TRUE;
1212 case EVAS_CALLBACK_MOUSE_IN:
1213 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN, ec);
1216 if (e_comp_wl->ptr.hide_tmr)
1218 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1219 cursor_timer_ec = ec;
1220 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1224 if (e_pointer_is_hidden(e_comp->pointer))
1229 case EVAS_CALLBACK_MOUSE_OUT:
1230 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT, ec);
1233 if (!e_comp_wl->ptr.hide_tmr && e_pointer_is_hidden(e_comp->pointer))
1237 case EVAS_CALLBACK_MOUSE_MOVE:
1238 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE, ec);
1241 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1242 _e_comp_wl_cursor_reload(ec);
1245 case EVAS_CALLBACK_MOUSE_WHEEL:
1246 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL, ec);
1249 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1250 _e_comp_wl_cursor_reload(ec);
1253 case EVAS_CALLBACK_MOUSE_DOWN:
1254 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN, ec);
1257 if (e_comp_wl->ptr.hide_tmr)
1259 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1260 e_comp_wl->ptr.hide_tmr = NULL;
1262 cursor_timer_ec = NULL;
1264 if (e_pointer_is_hidden(e_comp->pointer) || !ec->pointer_enter_sent)
1265 _e_comp_wl_cursor_reload(ec);
1268 case EVAS_CALLBACK_MOUSE_UP:
1269 ret = _e_comp_wl_intercept_hook_call(E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP, ec);
1280 _e_comp_wl_check_cursor_timer_needed(E_Client *ec)
1282 if (ec->has_cursor_unset)
1285 if (!e_config->show_cursor)
1288 if (!e_config->use_cursor_timer)
1295 _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1298 Evas_Event_Mouse_In *ev;
1299 struct wl_resource *res;
1300 struct wl_client *wc;
1303 E_Comp_Config *comp_conf;
1304 E_Client *prev_ptr_ec;
1308 e_comp_wl->ptr.x = wl_fixed_from_int(ev->output.x);
1309 e_comp_wl->ptr.y = wl_fixed_from_int(ev->output.y);
1311 if (!(ec = data)) return;
1312 if (e_object_is_del(E_OBJECT(ec))) return;
1313 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1314 if (!surface) return;
1316 prev_ptr_ec = e_comp_wl->ptr.ec;
1319 ELOGF("Mouse", "In (prev_ptr_ec: %p pointer_enter_sent: %d)", ec, prev_ptr_ec, prev_ptr_ec->pointer_enter_sent);
1320 prev_ptr_ec->pointer_enter_sent = EINA_FALSE;
1323 e_comp_wl->ptr.ec = ec;
1325 comp_conf = e_comp_config_get();
1326 if (comp_conf && comp_conf->input_log_enable)
1327 ELOGF("Mouse", "In (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1328 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1329 e_client_util_name_get(ec));
1331 if (_e_comp_wl_check_cursor_timer_needed(ec))
1333 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_IN, ec))
1337 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1338 wc = wl_resource_get_client(surface);
1339 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1340 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1342 if (!e_comp_wl_input_pointer_check(res)) continue;
1343 if (wl_resource_get_client(res) != wc) continue;
1345 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1347 wl_pointer_send_enter(res, serial, surface,
1348 wl_fixed_from_int(ev->canvas.x - ec->client.x),
1349 wl_fixed_from_int(ev->canvas.y - ec->client.y));
1350 ec->pointer_enter_sent = EINA_TRUE;
1353 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
1357 _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1360 Evas_Event_Mouse_Out *ev;
1361 struct wl_resource *res;
1362 struct wl_client *wc;
1365 Eina_Bool inside_check;
1366 E_Comp_Config *comp_conf;
1370 if (!(ec = data)) return;
1371 inside_check = E_INSIDE(ev->canvas.x, ev->canvas.y,
1372 ec->client.x, ec->client.y, ec->client.w, ec->client.h);
1373 if (ec->cur_mouse_action && inside_check) return;
1374 if (e_object_is_del(E_OBJECT(e_comp))) return;
1375 if (e_comp_wl->ptr.ec == ec)
1376 e_comp_wl->ptr.ec = NULL;
1377 if (e_object_is_del(E_OBJECT(ec))) return;
1379 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1380 if (!surface) return;
1382 comp_conf = e_comp_config_get();
1383 if (comp_conf && comp_conf->input_log_enable)
1384 ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
1385 ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
1386 e_client_util_name_get(ec));
1388 if (_e_comp_wl_check_cursor_timer_needed(ec))
1390 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_OUT, ec))
1394 if (!eina_list_count(e_comp_wl->ptr.resources)) return;
1396 wc = wl_resource_get_client(surface);
1397 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1398 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1400 if (!e_comp_wl_input_pointer_check(res)) continue;
1401 if (wl_resource_get_client(res) != wc) continue;
1402 if (ec->pointer_enter_sent == EINA_FALSE) continue;
1404 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
1406 wl_pointer_send_leave(res, serial, surface);
1407 ec->pointer_enter_sent = EINA_FALSE;
1412 _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp, Eina_Bool pressed)
1415 struct wl_client *wc;
1416 struct wl_resource *res;
1419 E_Comp_Config *comp_conf = NULL;
1422 if (e_object_is_del(E_OBJECT(ec))) return;
1423 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1424 if (!surface) return;
1426 wc = wl_resource_get_client(surface);
1427 serial = wl_display_next_serial(e_comp_wl->wl.disp);
1431 x = wl_fixed_from_int(canvas_x - ec->client.x);
1432 y = wl_fixed_from_int(canvas_y - ec->client.y);
1435 comp_conf = e_comp_config_get();
1437 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1439 if (wl_resource_get_client(res) != wc) continue;
1440 if (!e_comp_wl_input_touch_check(res)) continue;
1441 TRACE_INPUT_BEGIN(_e_comp_wl_send_touch);
1444 if (comp_conf && comp_conf->input_log_enable)
1445 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));
1447 wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
1451 if (comp_conf && comp_conf->input_log_enable)
1452 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));
1454 wl_touch_send_up(res, serial, timestamp, idx);
1461 _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
1464 struct wl_client *wc;
1465 struct wl_resource *res;
1469 if (ec->cur_mouse_action) return;
1470 if (e_object_is_del(E_OBJECT(ec))) return;
1471 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1472 if (!surface) return;
1474 wc = wl_resource_get_client(surface);
1476 x = wl_fixed_from_int(canvas_x - ec->client.x);
1477 y = wl_fixed_from_int(canvas_y - ec->client.y);
1479 EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
1481 if (wl_resource_get_client(res) != wc) continue;
1482 if (!e_comp_wl_input_touch_check(res)) continue;
1483 wl_touch_send_motion(res, timestamp, idx, x, y);
1488 _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp)
1490 struct wl_resource *res;
1491 struct wl_client *wc;
1495 if (ec->cur_mouse_action) return;
1496 if (e_object_is_del(E_OBJECT(ec))) return;
1497 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1498 if (!surface) return;
1500 wc = wl_resource_get_client(surface);
1501 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1503 if (!e_comp_wl_input_pointer_check(res)) continue;
1504 if (wl_resource_get_client(res) != wc) continue;
1505 wl_pointer_send_motion(res, timestamp,
1506 wl_fixed_from_int(x - ec->client.x),
1507 wl_fixed_from_int(y - ec->client.y));
1512 _e_comp_wl_cursor_move_timer_control(E_Client *ec)
1514 if (e_comp_wl->ptr.hide_tmr)
1516 if (cursor_timer_ec == ec)
1518 ecore_timer_interval_set(e_comp_wl->ptr.hide_tmr, e_config->cursor_timer_interval);
1519 ecore_timer_reset(e_comp_wl->ptr.hide_tmr);
1523 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
1524 cursor_timer_ec = ec;
1525 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1530 cursor_timer_ec = ec;
1531 e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
1536 _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1539 Evas_Event_Mouse_Move *ev;
1540 Evas_Device *dev = NULL;
1541 const char *dev_name;
1542 E_Comp_Config *comp_conf;
1546 e_comp->wl_comp_data->ptr.x = wl_fixed_from_int(ev->cur.canvas.x);
1547 e_comp->wl_comp_data->ptr.y = wl_fixed_from_int(ev->cur.canvas.y);
1549 if (!(ec = data)) return;
1550 if (e_object_is_del(E_OBJECT(ec))) return;
1551 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1552 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1553 if (!surface) return;
1555 if ((!need_send_motion) && (!need_send_released) && (e_client_visibility_get(ec) == E_VISIBILITY_FULLY_OBSCURED)) return;
1558 dev_name = evas_device_description_get(dev);
1560 comp_conf = e_comp_config_get();
1561 if (comp_conf && comp_conf->input_log_enable)
1562 ELOGF("Mouse", "Move (obj: %p, time: %d, canvas(%d, %d), output(%d, %d), name:%20s) (dev:%s)",
1563 ec, obj, ev->timestamp, ev->cur.canvas.x, ev->cur.canvas.y, ev->cur.output.x, ev->cur.output.y,
1564 e_client_util_name_get(ec), dev_name);
1566 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1568 if (!e_comp_wl->drag_client)
1570 e_comp_wl->touch.faked_ec = ec;
1571 if (e_comp_wl->touch.pressed & (1 << 0))
1573 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1575 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1576 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1577 _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1581 e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1585 if (!e_comp_wl->drag_client)
1587 if (_e_comp_wl_check_cursor_timer_needed(ec))
1589 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, ec))
1593 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1594 _e_comp_wl_send_mouse_move(ec, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1596 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1598 if (_e_comp_wl_check_cursor_timer_needed(ec))
1599 _e_comp_wl_cursor_move_timer_control(ec);
1603 e_pointer_mouse_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
1608 _e_comp_wl_evas_handle_mouse_button_to_touch(E_Client *ec, uint32_t timestamp, int canvas_x, int canvas_y, Eina_Bool flag)
1610 if (ec->cur_mouse_action || e_comp_wl->drag) return;
1611 if (e_object_is_del(E_OBJECT(ec))) return;
1612 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1613 if (!surface) return;
1614 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1616 e_comp_wl->ptr.button = BTN_LEFT;
1618 _e_comp_wl_send_touch(ec, 0, canvas_x, canvas_y, timestamp, flag);
1622 _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1624 E_Client *ec = data;
1625 Evas_Event_Mouse_Down *ev = event;
1626 Evas_Device *dev = NULL;
1627 const Evas_Device *seat_dev;
1628 const char *dev_name, *seat_name;
1629 E_Comp_Config *comp_conf = NULL;
1632 if (e_object_is_del(E_OBJECT(ec))) return;
1635 dev_name = evas_device_description_get(dev);
1637 seat_dev = evas_device_parent_get(dev);
1638 seat_name = evas_device_name_get(seat_dev);
1640 comp_conf = e_comp_config_get();
1641 if (comp_conf && comp_conf->input_log_enable)
1642 ELOGF("Touch", "Down (obj: %p, button: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1643 ec, obj, ev->button, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1644 dev_name, seat_name);
1646 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1648 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1650 e_comp_wl->touch.faked_ec = ec;
1653 _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
1654 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1655 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
1657 e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
1658 e_comp_wl->touch.pressed |= (1 << 0);
1662 if (_e_comp_wl_check_cursor_timer_needed(ec))
1664 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_DOWN, ec))
1668 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1669 WL_POINTER_BUTTON_STATE_PRESSED);
1671 e_pointer_mouse_move(e_comp->pointer, ev->output.x, ev->output.y);
1674 need_send_released = EINA_TRUE;
1678 _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
1680 E_Client *ec = data;
1681 Evas_Event_Mouse_Up *ev = event;
1682 Evas_Device *dev = NULL;
1683 const Evas_Device *seat_dev;
1684 const char *dev_name, *seat_name;;
1685 Evas_Event_Flags flags;
1686 E_Comp_Config *comp_conf = NULL;
1689 if (ec->cur_mouse_action) return;
1690 if (e_object_is_del(E_OBJECT(ec))) return;
1692 if (!need_send_released)
1694 need_send_motion = EINA_TRUE;
1698 dev_name = evas_device_description_get(dev);
1700 seat_dev = evas_device_parent_get(dev);
1701 seat_name = evas_device_name_get(seat_dev);
1702 flags = evas_event_default_flags_get(evas);
1704 comp_conf = e_comp_config_get();
1705 if (comp_conf && comp_conf->input_log_enable)
1706 ELOGF("Touch", "Up (obj: %p, button: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1707 ec, obj, ev->button, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1708 dev_name, seat_name);
1710 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1712 e_comp_wl->touch.pressed &= ~(1 << 0);
1714 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1715 e_comp_wl->touch.faked_ec = NULL;
1718 if (flags & EVAS_EVENT_FLAG_ON_HOLD) goto finish;
1720 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1722 if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
1725 _e_comp_wl_device_handle_axes(dev_name, evas_device_class_get(dev),
1726 ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1727 _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_FALSE);
1731 if (_e_comp_wl_check_cursor_timer_needed(ec))
1733 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_UP, ec))
1737 e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button,
1738 WL_POINTER_BUTTON_STATE_RELEASED);
1740 if (_e_comp_wl_check_cursor_timer_needed(ec))
1741 _e_comp_wl_cursor_move_timer_control(ec);
1745 need_send_released = EINA_FALSE;
1749 _e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
1751 struct wl_resource *res;
1752 struct wl_client *wc;
1757 axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
1759 axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
1762 dir = -wl_fixed_from_int(abs(z));
1764 dir = wl_fixed_from_int(z);
1767 if (e_object_is_del(E_OBJECT(ec))) return;
1768 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1769 if (!surface) return;
1771 wc = wl_resource_get_client(surface);
1772 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
1774 if (!e_comp_wl_input_pointer_check(res)) continue;
1775 if (wl_resource_get_client(res) != wc) continue;
1776 wl_pointer_send_axis(res, timestamp, axis, dir);
1781 _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1784 Evas_Event_Mouse_Wheel *ev;
1787 if (!(ec = data)) return;
1788 if (ec->cur_mouse_action) return;
1789 if (e_object_is_del(E_OBJECT(ec))) return;
1790 if ((ec->ignored) && (!ec->remote_surface.provider)) return;
1791 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1792 if (!surface) return;
1794 if (!eina_list_count(e_comp_wl->ptr.resources))
1797 if (_e_comp_wl_check_cursor_timer_needed(ec))
1799 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
1803 _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
1805 _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
1807 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
1809 if (_e_comp_wl_check_cursor_timer_needed(ec))
1810 _e_comp_wl_cursor_move_timer_control(ec);
1815 _e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
1817 E_Client *ec = data;
1818 Evas_Event_Multi_Down *ev = event;
1819 Evas_Device *dev = NULL;
1820 const Evas_Device *seat_dev;
1821 const char *dev_name, *seat_name;
1822 Evas_Device_Class dev_class;
1823 E_Comp_Config *comp_conf = NULL;
1826 if (e_object_is_del(E_OBJECT(ec))) return;
1827 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1828 if (!surface) return;
1830 /* Do not deliver emulated single touch events to client */
1831 if (ev->device == 0) return;
1834 dev_name = evas_device_description_get(dev);
1835 e_comp_wl->touch.faked_ec = ec;
1837 seat_dev = evas_device_parent_get(dev);
1838 seat_name = evas_device_name_get(seat_dev);
1840 comp_conf = e_comp_config_get();
1841 if (comp_conf && comp_conf->input_log_enable)
1842 ELOGF("Touch", "Down (obj: %p, idx: %d, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1843 ec, obj, ev->device, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1844 dev_name, seat_name);
1846 if (dev && dev_name)
1848 dev_class = evas_device_class_get(dev);
1849 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1850 _e_comp_wl_device_renew_axis(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1853 _e_comp_wl_send_touch(ec, ev->device, ev->canvas.x, ev->canvas.y, ev->timestamp, EINA_TRUE);
1854 e_comp_wl->touch.pressed |= (1 << ev->device);
1858 _e_comp_wl_evas_cb_multi_up(void *data, Evas *evas, Evas_Object *obj EINA_UNUSED, void *event)
1860 E_Client *ec = data;
1861 Evas_Event_Multi_Up *ev = event;
1862 Evas_Device *dev = NULL;
1863 const Evas_Device *seat_dev;
1864 const char *dev_name, *seat_name;
1865 Evas_Device_Class dev_class;
1866 Evas_Event_Flags flags;
1867 E_Comp_Config *comp_conf = NULL;
1870 if (e_object_is_del(E_OBJECT(ec))) return;
1871 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1872 if (!surface) return;
1874 /* Do not deliver emulated single touch events to client */
1875 if (ev->device == 0) return;
1877 flags = evas_event_default_flags_get(evas);
1879 e_comp_wl->touch.pressed &= ~(1 << ev->device);
1880 if (!e_comp_wl->touch.pressed && e_comp_wl->touch.faked_ec)
1881 e_comp_wl->touch.faked_ec = NULL;
1883 if (flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1886 dev_name = evas_device_description_get(dev);
1888 seat_dev = evas_device_parent_get(dev);
1889 seat_name = evas_device_name_get(seat_dev);
1891 comp_conf = e_comp_config_get();
1892 if (comp_conf && comp_conf->input_log_enable)
1893 ELOGF("Touch", "Up (obj: %p, idx: %d, flag: 0x%x, time: %d, x:%d, y:%d, name:%20s) (dev:%s, seat:%s)",
1894 ec, obj, ev->device, flags, ev->timestamp, ev->output.x, ev->output.y, e_client_util_name_get(ec),
1895 dev_name, seat_name);
1897 if (dev && dev_name)
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(ec, ev->device, 0, 0, ev->timestamp, EINA_FALSE);
1908 _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
1910 E_Client *ec = data;
1911 Evas_Event_Multi_Move *ev = event;
1912 Evas_Device *dev = NULL;
1913 const char *dev_name;
1914 Evas_Device_Class dev_class;
1917 if (e_object_is_del(E_OBJECT(ec))) return;
1918 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
1919 if (!surface) return;
1921 /* Do not deliver emulated single touch events to client */
1922 if (ev->device == 0) return;
1924 e_comp_wl->touch.faked_ec = ec;
1926 if (e_comp_wl->touch.pressed & (1 << ev->device))
1929 if (dev && (dev_name = evas_device_description_get(dev)))
1931 dev_class = evas_device_class_get(dev);
1932 _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
1933 _e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->device, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
1936 _e_comp_wl_send_touch_move(ec, ev->device, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
1941 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
1944 char *file, buff[PATH_MAX];
1951 n = (getpriority(PRIO_PROCESS, pid) + adj);
1955 setpriority(PRIO_PROCESS, pid, n);
1958 use_adj = EINA_TRUE;
1960 if (!do_child) return;
1962 files = ecore_file_ls("/proc");
1963 EINA_LIST_FREE(files, file)
1965 if (!isdigit(file[0]))
1968 snprintf(buff, sizeof(buff), "/proc/%s/stat", file);
1969 if ((f = fopen(buff, "r")))
1973 num_read = fscanf(f, "%i %*s %*s %i %*s", &pid2, &ppid);
1975 if (num_read == 2 && ppid == pid)
1976 _e_comp_wl_client_priority_adjust(pid2, set,
1978 adj_child, do_child);
1986 _e_comp_wl_client_priority_raise(E_Client *ec)
1988 if (!e_config->priority_control) return;
1989 if (ec->netwm.pid <= 0) return;
1990 if (ec->netwm.pid == getpid()) return;
1991 _e_comp_wl_client_priority_adjust(ec->netwm.pid,
1992 e_config->priority - 1, -1,
1993 EINA_FALSE, EINA_TRUE, EINA_FALSE);
1997 _e_comp_wl_client_priority_normal(E_Client *ec)
1999 if (!e_config->priority_control) return;
2000 if (ec->netwm.pid <= 0) return;
2001 if (ec->netwm.pid == getpid()) return;
2002 _e_comp_wl_client_priority_adjust(ec->netwm.pid, e_config->priority, 1,
2003 EINA_FALSE, EINA_TRUE, EINA_FALSE);
2007 _e_comp_wl_input_thread_send_keys()
2012 struct wl_resource *res;
2013 E_Comp_Wl_Key_Data *k;
2015 if (!e_comp_input_key->kbd.focused)
2020 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2021 t = ecore_time_unix_get();
2023 EINA_LIST_FOREACH(e_comp_input_key->kbd.focused, l, res)
2025 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2027 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2028 wl_keyboard_send_key(res, serial, t,
2029 k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
2035 _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
2037 if (!ec) return EINA_FALSE;
2038 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
2039 if (!ec->comp_data) return EINA_FALSE;
2041 ec->comp_data->on_focus_timer = NULL;
2043 e_input_thread_safe_call(_e_comp_wl_input_thread_send_keys, NULL, 0);
2049 _e_comp_wl_input_thread_focus_in(void *data)
2051 struct wl_resource *surface = NULL;
2052 memcpy(&surface, data, sizeof(struct wl_resource *));
2053 struct wl_resource *res;
2054 struct wl_client *wc;
2057 wc = wl_resource_get_client(surface);
2059 EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
2061 if (wl_resource_get_client(res) == wc)
2063 if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
2064 e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
2068 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
2070 if (wl_resource_get_client(res) == wc)
2072 if (!eina_list_data_find(e_comp_input_key->kbd.focused, res))
2073 e_comp_input_key->kbd.focused = eina_list_append(e_comp_input_key->kbd.focused, res);
2077 if (!e_comp_input_key->kbd.focused)
2082 e_comp_wl->kbd.focus = surface;
2083 e_comp_input_key->kbd.focus = surface;
2084 e_comp_wl_input_keyboard_enter_send(surface);
2085 e_comp_wl_data_device_keyboard_focus_set();
2088 /* It is called in the following cases:
2089 * When a normal ec->frame has focus.
2090 * Or launching image ec is replaced to the real ec.
2093 e_comp_wl_feed_focus_in(E_Client *ec)
2098 if (e_object_is_del(E_OBJECT(ec))) return;
2099 if (ec->iconic) return;
2101 /* block spurious focus events */
2102 focused = e_client_focused_get();
2103 if ((focused) && (ec != focused)) return;
2105 /* raise client priority */
2106 _e_comp_wl_client_priority_raise(ec);
2108 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2109 if (!surface) return;
2111 INF("send focus in request to input thread. resource %p\n", surface);
2112 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_in, (void *)&surface, sizeof(struct wl_resource *));
2114 ec->comp_data->on_focus_timer =
2115 ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
2116 (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
2117 int rotation = ec->e.state.rot.ang.curr;
2118 e_pointer_rotation_set(e_comp->pointer, rotation);
2122 _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2125 if (!(ec = data)) return;
2126 e_comp_wl_feed_focus_in(ec);
2130 _e_comp_wl_input_thread_focus_out(void *data)
2132 struct wl_resource *surface = NULL;
2133 struct wl_resource *res;
2135 E_Comp_Wl_Key_Data *k;
2139 memcpy(&surface, data, sizeof(struct wl_resource *));
2141 /* update keyboard modifier state */
2142 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2143 e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
2145 if (!surface) return;
2147 if (!eina_list_count(e_comp_input_key->kbd.resources))
2152 /* send keyboard_leave to all keyboard resources */
2153 serial = wl_display_next_serial(e_comp_wl->wl.disp);
2154 t = ecore_time_unix_get();
2156 EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
2158 e_comp_wl->kbd.focused =
2159 eina_list_remove_list(e_comp_wl->kbd.focused, l);
2162 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
2164 wl_array_for_each(k, &e_comp_input_key->kbd.keys)
2166 _e_comp_wl_send_event_device(wl_resource_get_client(res), t, k->dev, serial);
2167 wl_keyboard_send_key(res, serial, t,
2168 k->key, WL_KEYBOARD_KEY_STATE_RELEASED);
2170 wl_keyboard_send_leave(res, serial, surface);
2171 e_comp_input_key->kbd.focused =
2172 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
2177 _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2180 if (!(ec = data)) return;
2182 if (!ec->comp_data) return;
2184 E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
2186 /* lower client priority */
2187 if (!e_object_is_del(data))
2188 _e_comp_wl_client_priority_normal(ec);
2190 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2191 INF("send focus out request to input thread. resource %p\n", surface);
2192 e_input_thread_safe_call(_e_comp_wl_input_thread_focus_out, (void *)&surface, sizeof(struct wl_resource *));
2196 _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2200 if (!(ec = data)) return;
2202 if (!ec->comp_data->shell.configure_send) return;
2204 /* TODO: calculate x, y with transfrom object */
2205 if ((e_client_util_resizing_get(ec)) && (!ec->transformed) && (e_comp_wl->resize.edges))
2209 w = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
2210 h = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
2211 if (e_comp_object_frame_exists(ec->frame))
2212 e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
2214 switch (ec->resize_mode)
2216 case E_POINTER_RESIZE_TL:
2217 case E_POINTER_RESIZE_L:
2218 case E_POINTER_RESIZE_BL:
2219 w += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
2220 ec->mouse.current.mx;
2222 case E_POINTER_RESIZE_TR:
2223 case E_POINTER_RESIZE_R:
2224 case E_POINTER_RESIZE_BR:
2225 w += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
2230 switch (ec->resize_mode)
2232 case E_POINTER_RESIZE_TL:
2233 case E_POINTER_RESIZE_T:
2234 case E_POINTER_RESIZE_TR:
2235 h += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
2236 ec->mouse.current.my;
2238 case E_POINTER_RESIZE_BL:
2239 case E_POINTER_RESIZE_B:
2240 case E_POINTER_RESIZE_BR:
2241 h += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
2246 w = E_CLAMP(w, 1, w);
2247 h = E_CLAMP(h, 1, h);
2248 e_client_resize_limit(ec, &w, &h);
2250 e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
2252 else if ((!ec->fullscreen) && (!ec->maximized) &&
2253 (!ec->comp_data->maximize_pre))
2257 e_pixmap_size_get(ec->pixmap, &pw, &ph);
2258 if ((pw != ec->w) || (ph != ec->h))
2260 _e_comp_wl_configure_send(ec, 1, 1);
2264 if (ec->comp_data->sub.below_obj)
2265 e_comp_wl_subsurface_bg_rectangle_map_apply(ec);
2269 _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2271 E_Client *ec = data;
2273 ec->comp_data->maximize_pre = 1;
2277 _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2279 E_Client *ec = data;
2282 if (e_object_is_del(E_OBJECT(ec))) return;
2284 e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
2285 e_client_shell_configure_send(ec, 0, w, h);
2287 ec->comp_data->maximize_pre = 0;
2291 _e_comp_wl_evas_cb_unmaximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2293 E_Client *ec = data;
2295 ec->comp_data->maximize_pre = 1;
2299 _e_comp_wl_evas_cb_unmaximize_done(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2301 E_Client *ec = data;
2303 if (e_object_is_del(E_OBJECT(ec))) return;
2305 /* check for wayland pixmap */
2307 if (ec->comp_data->shell.configure_send)
2308 _e_comp_wl_configure_send(ec, 0, 0);
2310 ec->comp_data->maximize_pre = 0;
2314 _e_comp_wl_evas_cb_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2316 E_Client *ec = data;
2318 if (e_object_is_del(E_OBJECT(ec))) return;
2320 /* check for wayland pixmap */
2322 if (ec->comp_data->shell.configure_send)
2323 _e_comp_wl_configure_send(ec, 0, 1);
2325 ec->comp_data->maximize_pre = 0;
2329 _e_comp_wl_evas_cb_unfullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2331 E_Client *ec = data;
2333 if (e_object_is_del(E_OBJECT(ec))) return;
2335 /* check for wayland pixmap */
2337 if (ec->comp_data->shell.configure_send)
2338 _e_comp_wl_configure_send(ec, 0, 0);
2340 ec->comp_data->maximize_pre = 0;
2344 _e_comp_wl_evas_cb_delete_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2348 if (!(ec = data)) return;
2350 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2352 e_object_del(E_OBJECT(ec));
2354 _e_comp_wl_focus_check();
2356 /* TODO: Delete request send ??
2357 * NB: No such animal wrt wayland */
2361 _e_comp_wl_evas_cb_kill_request(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2365 if (!(ec = data)) return;
2367 e_comp_ignore_win_del(E_PIXMAP_TYPE_WL, e_pixmap_window_get(ec->pixmap));
2370 if (ec->comp_data->reparented)
2371 e_client_comp_hidden_set(ec, EINA_TRUE);
2374 evas_object_pass_events_set(ec->frame, EINA_TRUE);
2375 if (ec->visible) evas_object_hide(ec->frame);
2376 if (!ec->internal) e_object_del(E_OBJECT(ec));
2378 _e_comp_wl_focus_check();
2382 _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
2386 if (!(ec = data)) return;
2388 e_client_shell_ping(ec);
2392 _e_comp_wl_evas_cb_color_set(void *data, Evas_Object *obj, void *event EINA_UNUSED)
2397 if (!(ec = data)) return;
2398 evas_object_color_get(obj, NULL, NULL, NULL, &a);
2399 if (ec->netwm.opacity == a) return;
2400 ec->netwm.opacity = a;
2401 ec->netwm.opacity_changed = EINA_TRUE;
2405 _e_comp_wl_buffer_damage_set(E_Comp_Wl_Buffer *buffer, Eina_List *buffer_damages)
2407 Eina_Rectangle *damage_rect = NULL;
2408 Eina_Rectangle *dmg = NULL;
2409 Eina_List *l = NULL;
2411 if (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE &&
2412 buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)
2415 if (!buffer->tbm_surface) return;
2419 EINA_LIST_FOREACH(buffer_damages, l, dmg)
2423 damage_rect = eina_rectangle_new(dmg->x, dmg->y, dmg->w, dmg->h);
2424 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2427 eina_rectangle_union(damage_rect, dmg);
2432 damage_rect = eina_rectangle_new(0, 0, buffer->w, buffer->h);
2433 EINA_SAFETY_ON_FALSE_RETURN(damage_rect);
2436 tbm_surface_internal_set_damage(buffer->tbm_surface,
2442 eina_rectangle_free(damage_rect);
2446 _e_comp_wl_client_evas_init(E_Client *ec)
2448 if (!ec || !ec->comp_data) return;
2449 if (ec->comp_data->evas_init) return;
2451 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show, ec);
2452 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide, ec);
2453 evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move, ec);
2456 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in, ec);
2457 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out, ec);
2458 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move, ec);
2459 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down, ec);
2460 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up, ec);
2461 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
2463 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
2464 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_up, ec);
2465 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_move, ec);
2467 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_in, ec);
2468 evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_focus_out, ec);
2472 evas_object_smart_callback_add(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize, ec);
2473 evas_object_smart_callback_add(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre, ec);
2474 evas_object_smart_callback_add(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done, ec);
2475 evas_object_smart_callback_add(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre, ec);
2476 evas_object_smart_callback_add(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done, ec);
2477 evas_object_smart_callback_add(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen, ec);
2478 evas_object_smart_callback_add(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen, ec);
2481 /* setup delete/kill callbacks */
2482 evas_object_smart_callback_add(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request, ec);
2483 evas_object_smart_callback_add(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request, ec);
2485 /* setup ping callback */
2486 evas_object_smart_callback_add(ec->frame, "ping", _e_comp_wl_evas_cb_ping, ec);
2487 evas_object_smart_callback_add(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set, ec);
2489 ec->comp_data->evas_init = EINA_TRUE;
2493 _e_comp_wl_client_evas_deinit(E_Client *ec)
2495 if (!ec || !ec->comp_data) return;
2496 if (!ec->comp_data->evas_init) return;
2498 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_SHOW, _e_comp_wl_evas_cb_show);
2499 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_HIDE, _e_comp_wl_evas_cb_hide);
2500 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOVE, _e_comp_wl_evas_cb_move);
2502 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN, _e_comp_wl_evas_cb_mouse_in);
2503 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT, _e_comp_wl_evas_cb_mouse_out);
2504 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE, _e_comp_wl_evas_cb_mouse_move);
2505 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN, _e_comp_wl_evas_cb_mouse_down);
2506 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP, _e_comp_wl_evas_cb_mouse_up);
2507 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
2509 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
2510 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_UP, _e_comp_wl_evas_cb_multi_up);
2511 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_MOVE, _e_comp_wl_evas_cb_multi_move);
2513 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_IN, _e_comp_wl_evas_cb_focus_in);
2514 evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_FOCUS_OUT, _e_comp_wl_evas_cb_focus_out);
2518 evas_object_smart_callback_del(ec->frame, "client_resize", _e_comp_wl_evas_cb_resize);
2519 evas_object_smart_callback_del(ec->frame, "maximize_pre", _e_comp_wl_evas_cb_maximize_pre);
2520 evas_object_smart_callback_del(ec->frame, "maximize_done", _e_comp_wl_evas_cb_maximize_done);
2521 evas_object_smart_callback_del(ec->frame, "unmaximize_pre", _e_comp_wl_evas_cb_unmaximize_pre);
2522 evas_object_smart_callback_del(ec->frame, "unmaximize_done", _e_comp_wl_evas_cb_unmaximize_done);
2523 evas_object_smart_callback_del(ec->frame, "fullscreen", _e_comp_wl_evas_cb_fullscreen);
2524 evas_object_smart_callback_del(ec->frame, "unfullscreen", _e_comp_wl_evas_cb_unfullscreen);
2527 evas_object_smart_callback_del(ec->frame, "delete_request", _e_comp_wl_evas_cb_delete_request);
2528 evas_object_smart_callback_del(ec->frame, "kill_request", _e_comp_wl_evas_cb_kill_request);
2530 evas_object_smart_callback_del(ec->frame, "ping", _e_comp_wl_evas_cb_ping);
2531 evas_object_smart_callback_del(ec->frame, "color_set", _e_comp_wl_evas_cb_color_set);
2533 ec->comp_data->evas_init = EINA_FALSE;
2537 _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
2541 E_Comp_Screen *e_comp_screen;
2542 unsigned int transform = WL_OUTPUT_TRANSFORM_NORMAL;
2544 if (!e_comp) return ECORE_CALLBACK_RENEW;
2545 if (!e_comp->e_comp_screen) return ECORE_CALLBACK_RENEW;
2546 e_comp_screen = e_comp->e_comp_screen;
2548 EINA_LIST_FOREACH(e_comp_screen->outputs, l, eout)
2550 if (!eout->config.enabled)
2552 e_comp_wl_output_remove(eout->id);
2556 switch (eout->config.rotation)
2559 transform = WL_OUTPUT_TRANSFORM_90;
2562 transform = WL_OUTPUT_TRANSFORM_180;
2565 transform = WL_OUTPUT_TRANSFORM_270;
2569 transform = WL_OUTPUT_TRANSFORM_NORMAL;
2573 if (!e_comp_wl_output_init(eout->id, eout->info.name,
2575 eout->config.geom.x, eout->config.geom.y,
2576 eout->config.geom.w, eout->config.geom.h,
2577 eout->info.size.w, eout->info.size.h,
2578 eout->config.mode.refresh, 0, transform))
2579 ERR("Could not initialize screen %s", eout->info.name);
2582 return ECORE_CALLBACK_RENEW;
2586 _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev)
2590 /* try to get the client from the object */
2591 if (!(ec = e_comp_object_client_get(ev->comp_object)))
2592 return ECORE_CALLBACK_RENEW;
2594 /* check for client being deleted */
2595 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_RENEW;
2597 /* check for wayland pixmap */
2598 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL)
2599 return ECORE_CALLBACK_RENEW;
2601 /* if we have not setup evas callbacks for this client, do it */
2602 if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec);
2604 return ECORE_CALLBACK_RENEW;
2608 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
2612 e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
2613 e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
2615 if (e_comp_wl->selection.target &&
2618 struct wl_resource *res;
2620 E_Client *ec = NULL;
2621 E_Client *legacy_target = e_comp_wl->selection.target;
2622 int device_id = e_comp_wl_data_current_device_id_get();
2626 e_comp_wl_data_current_device_id_set(ev->multi.device);
2628 else if (device_id != ev->multi.device)
2630 return ECORE_CALLBACK_RENEW;
2633 ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
2634 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2636 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
2637 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2639 res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
2640 EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
2642 if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
2643 (ec != legacy_target))
2645 e_comp_wl_data_device_send_leave(legacy_target);
2646 e_comp_wl_data_device_send_enter(ec);
2649 if (e_comp_wl->drag)
2650 e_drag_move(e_comp_wl->drag, ev->x, ev->y);
2652 if (e_client_transform_core_enable_get(ec))
2654 int trans_x, trans_y;
2655 e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
2656 x = trans_x - ec->client.x;
2657 y = trans_y - ec->client.y;
2661 e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
2666 wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
2669 return ECORE_CALLBACK_RENEW;
2673 _e_comp_wl_cb_mouse_relative_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Relative_Move *ev)
2676 struct wl_resource *surface;
2677 struct wl_resource *res;
2678 struct wl_client *wc;
2680 E_Comp_Config *comp_conf;
2682 ec = e_comp_wl->ptr_constraints.ec;
2683 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
2685 surface = e_comp_wl_client_surface_get(ec);
2686 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
2688 wc = wl_resource_get_client(surface);
2690 comp_conf = e_comp_config_get();
2692 EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
2694 if (!e_comp_wl_input_relative_pointer_check(res)) continue;
2695 if (wl_resource_get_client(res) != wc) continue;
2697 if (comp_conf && comp_conf->input_log_enable)
2698 ELOGF("Mouse", "Relative Move (time: %d, dx:%d dy:%d, unaccel(%d, %d) name:%20s)",
2699 ec, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel,
2700 e_client_util_name_get(ec));
2702 zwp_relative_pointer_v1_send_relative_motion(res,
2704 (uint32_t)(ev->timestamp),
2705 wl_fixed_from_int(ev->dx),
2706 wl_fixed_from_int(ev->dy),
2707 wl_fixed_from_int(ev->dx_unaccel),
2708 wl_fixed_from_int(ev->dy_unaccel));
2711 return ECORE_CALLBACK_DONE;
2715 _e_comp_wl_cb_mouse_button_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
2717 _e_comp_wl_touch_cancel();
2719 return ECORE_CALLBACK_PASS_ON;
2723 _e_comp_wl_cb_zone_display_state_change(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Display_State_Change *ev)
2725 if (!ev) return ECORE_CALLBACK_PASS_ON;
2727 E_Zone *zone = ev->zone;
2729 E_OBJECT_CHECK_RETURN(zone, ECORE_CALLBACK_PASS_ON);
2730 E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, ECORE_CALLBACK_PASS_ON);
2732 if (!e_zone_is_displaying(zone))
2733 _e_comp_wl_touch_cancel();
2735 return ECORE_CALLBACK_PASS_ON;
2739 _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Begin *ev)
2741 E_Client *ec = ev->ec;
2742 E_Comp_Wl_Buffer_Viewport *vp;
2744 if (!ec) return ECORE_CALLBACK_PASS_ON;
2745 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2746 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2747 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2748 if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
2750 vp = &ec->comp_data->scaler.buffer_viewport;
2751 vp->wait_for_transform_change = ((360 + ec->e.state.rot.ang.next - ec->e.state.rot.ang.curr) % 360) / 90;
2753 DBG("ec(%p) wait_for_transform_change(%d)", ec, vp->wait_for_transform_change);
2755 return ECORE_CALLBACK_PASS_ON;
2759 _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Rotation_Change_Cancel *ev)
2761 E_Client *ec = ev->ec;
2762 E_Comp_Wl_Buffer_Viewport *vp;
2764 if (!ec) return ECORE_CALLBACK_PASS_ON;
2765 if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
2766 if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
2767 if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
2769 vp = &ec->comp_data->scaler.buffer_viewport;
2770 vp->wait_for_transform_change = 0;
2772 DBG("ec(%p) wait_for_transform_change(%d) reset", ec, vp->wait_for_transform_change);
2774 return ECORE_CALLBACK_PASS_ON;
2778 _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)
2780 E_Client *focused_ec;
2783 focused_ec = e_client_focused_get();
2784 if (!focused_ec) return ECORE_CALLBACK_PASS_ON;
2786 rotation = focused_ec->e.state.rot.ang.curr;
2787 e_pointer_rotation_set(e_comp->pointer, rotation);
2789 return ECORE_CALLBACK_PASS_ON;
2793 _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *state)
2796 Eina_Rectangle *window;
2801 if (!e_pixmap_size_get(ec->pixmap, &state->bw, &state->bh)) return;
2803 if ((prev_w != state->bw) ||
2804 (prev_h != state->bh))
2806 ec->changes.buf_size = EINA_TRUE;
2809 if (e_comp_object_frame_exists(ec->frame)) return;
2810 window = &ec->comp_data->shell.window;
2811 if ((!ec->borderless) && /* FIXME temporarily added this check code
2812 * to prevent updating E_Client's size by frame */
2813 (window->x || window->y || window->w || window->h))
2815 e_comp_object_frame_geometry_set(ec->frame,
2817 (window->x + window->w) - state->bw,
2819 (window->y + window->h) - state->bh);
2822 e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
2826 _e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
2828 E_Comp_Wl_Surface_State *state;
2831 container_of(listener, E_Comp_Wl_Surface_State, buffer_destroy_listener);
2832 state->buffer = NULL;
2836 _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
2838 state->new_attach = EINA_FALSE;
2839 state->buffer = NULL;
2840 state->buffer_destroy_listener.notify =
2841 _e_comp_wl_surface_state_cb_buffer_destroy;
2842 state->sx = state->sy = 0;
2844 state->input = eina_tiler_new(w, h);
2845 eina_tiler_tile_size_set(state->input, 1, 1);
2847 state->opaque = eina_tiler_new(w, h);
2848 eina_tiler_tile_size_set(state->opaque, 1, 1);
2850 state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
2851 state->buffer_viewport.buffer.scale = 1;
2852 state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
2853 state->buffer_viewport.surface.width = -1;
2854 state->buffer_viewport.changed = 0;
2856 e_presentation_time_container_init(&state->presentation_container);
2860 _e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
2862 struct wl_resource *cb;
2863 Eina_Rectangle *dmg;
2865 EINA_LIST_FREE(state->frames, cb)
2866 wl_resource_destroy(cb);
2868 EINA_LIST_FREE(state->damages, dmg)
2869 eina_rectangle_free(dmg);
2871 EINA_LIST_FREE(state->buffer_damages, dmg)
2872 eina_rectangle_free(dmg);
2874 if (state->opaque) eina_tiler_free(state->opaque);
2875 state->opaque = NULL;
2877 if (state->input) eina_tiler_free(state->input);
2878 state->input = NULL;
2880 if (state->buffer) wl_list_remove(&state->buffer_destroy_listener.link);
2881 state->buffer = NULL;
2883 e_presentation_time_container_finish(&state->presentation_container);
2887 _e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
2889 if (state->buffer == buffer) return;
2891 wl_list_remove(&state->buffer_destroy_listener.link);
2892 state->buffer = buffer;
2894 wl_signal_add(&state->buffer->destroy_signal,
2895 &state->buffer_destroy_listener);
2899 _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
2901 Eina_Rectangle *dmg;
2902 Eina_Bool placed = EINA_TRUE;
2906 E_Comp_Wl_Buffer *buffer;
2907 struct wl_resource *cb;
2909 E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
2910 E_Comp_Wl_Buffer_Viewport *vp = &cdata->scaler.buffer_viewport;
2915 if ((ec->internal) ||
2916 (cdata->shell.surface && state->new_attach))
2920 e_comp->new_clients++;
2921 ELOGF("COMP", "Unignore", ec);
2922 e_client_unignore(ec);
2926 /* buffer transform */
2927 if (vp->buffer.transform != state->buffer_viewport.buffer.transform)
2930 int transform_change = (4 + state->buffer_viewport.buffer.transform - vp->buffer.transform) & 0x3;
2932 /* when buffer is transformed, we have to apply the new evas-map */
2933 state->buffer_viewport.changed = EINA_TRUE;
2935 ELOGF("TRANSFORM", "buffer_transform changed: old(%d) new(%d)",
2937 vp->buffer.transform, state->buffer_viewport.buffer.transform);
2939 if (transform_change == vp->wait_for_transform_change)
2940 vp->wait_for_transform_change = 0;
2942 // TODO: This logic has to move to e_comp_hwc or e_hwc_window and it is
2943 // triggered by E_CLIENT_HOOK calls at those file.
2944 zone = e_comp_zone_find_by_ec(ec);
2947 eout = e_output_find(zone->output_id);
2948 if (eout && eout->hwc)
2950 if (e_hwc_policy_get(eout->hwc) == E_HWC_POLICY_PLANES)
2952 if (e_comp_is_on_overlay(ec))
2953 e_comp_hwc_client_end(ec, __FUNCTION__);
2959 /* assign a new buffer_vieport to cdata->scaler.buffer_viewport */
2960 cdata->scaler.buffer_viewport = state->buffer_viewport;
2962 if (state->new_attach)
2964 e_comp_wl_surface_attach(ec, state->buffer);
2967 /* emit a apply_viewport signal when the information of viewport and buffer is ready */
2968 wl_signal_emit(&cdata->apply_viewport_signal, &cdata->surface);
2970 _e_comp_wl_surface_state_buffer_set(state, NULL);
2972 if ((state->new_attach) ||
2973 (state->buffer_viewport.changed))
2975 _e_comp_wl_surface_state_size_update(ec, state);
2976 e_comp_wl_map_size_cal_from_viewport(ec);
2978 /* update the position */
2979 if (ec->changes.pos)
2981 e_comp_object_frame_xy_unadjust(ec->frame,
2991 if (ec->new_client) placed = ec->placed;
2993 if (!ec->lock_client_size)
2998 ec->client.w = state->bw;
2999 ec->client.h = state->bh;
3001 e_comp_object_frame_wh_adjust(ec->frame,
3002 ec->client.w, ec->client.h,
3004 e_client_size_set(ec, nw, nh);
3006 if ((w != ec->w) || (h != ec->h))
3008 ec->changes.size = 1;
3013 if (ec->changes.buf_size)
3015 ELOGF("COMP", "Buffer size is changed. size(%d,%d)", ec, state->bw, state->bh);
3016 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE, ec);
3017 ec->changes.buf_size = EINA_FALSE;
3019 if (ec->move_after_resize)
3021 ELOGF("POSSIZE", "Unset move_after_resize. ec_geo(%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
3022 ec->move_after_resize = EINA_FALSE;
3027 /* map or unmap ec */
3028 Eina_Bool pixmap_usable = e_pixmap_usable_get(ec->pixmap);
3029 Eina_Bool hide_by_request = e_client_hide_by_request_get(ec);
3030 if (!pixmap_usable || hide_by_request)
3035 ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
3040 if ((cdata->sub.below_obj) &&
3041 (evas_object_visible_get(cdata->sub.below_obj)))
3043 evas_object_hide(cdata->sub.below_obj);
3051 if ((cdata->sub.below_obj) &&
3052 (!evas_object_visible_get(cdata->sub.below_obj)) &&
3053 (evas_object_visible_get(ec->frame)))
3055 evas_object_show(cdata->sub.below_obj);
3059 if ((state->new_attach) ||
3060 (state->buffer_viewport.changed))
3062 if ((e_comp_wl->drag) &&
3063 (e_comp_wl->drag_client) &&
3064 (e_comp_wl->drag_client == ec))
3066 e_drag_reference_point_set(e_comp_wl->drag, state->sx, state->sy);
3068 e_drag_move(e_comp_wl->drag,
3070 e_comp_wl->drag->y);
3072 e_drag_resize(e_comp_wl->drag,
3073 state->bw, state->bh);
3075 else if ((cdata->shell.surface) &&
3076 (cdata->shell.configure))
3078 e_comp_wl_commit_sync_configure(ec);
3080 else if (!e_client_video_hw_composition_check(ec))
3082 e_client_util_move_resize_without_frame(ec, x, y, ec->w, ec->h);
3087 ec->placed = placed;
3088 ec->want_focus |= ec->icccm.accepts_focus && (!ec->override);
3092 if (cdata->scaler.buffer_viewport.changed)
3093 e_comp_wl_map_apply(ec);
3095 /* resize transform object */
3096 if (ec->transformed)
3097 e_client_transform_update(ec);
3101 state->new_attach = EINA_FALSE;
3103 EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
3105 wl_callback_send_done(cb, (unsigned int)(ecore_loop_time_get() * 1000));
3106 wl_resource_destroy(cb);
3109 /* insert state frame callbacks into comp_data->frames
3110 * NB: This clears state->frames list */
3111 cdata->frames = eina_list_merge(cdata->frames,
3113 state->frames = NULL;
3115 e_presentation_time_container_feedback_discard(&cdata->presentation_container);
3116 e_presentation_time_container_feedback_merge(&cdata->presentation_container,
3117 &state->presentation_container);
3119 buffer = e_pixmap_resource_get(ec->pixmap);
3121 /* put state damages into surface */
3124 /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */
3125 if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages))
3127 if ((cdata->buffer_ref.buffer) &&
3128 ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) ||
3129 (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)))
3131 e_comp_object_damage(ec->frame,
3133 cdata->buffer_ref.buffer->w,
3134 cdata->buffer_ref.buffer->h);
3139 Eina_List *damages = NULL;
3142 _e_comp_wl_buffer_damage_set(buffer, state->buffer_damages);
3144 if (eina_list_count(state->buffer_damages))
3146 EINA_LIST_FREE(state->buffer_damages, dmg)
3149 e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
3150 e_comp_wl_output_buffer_transform_get(ec),
3152 dmg->x, dmg->y, dmg->w, dmg->h,
3153 &dmg->x, &dmg->y, &dmg->w, &dmg->h);
3154 damages = eina_list_append(damages, dmg);
3158 EINA_LIST_FREE(state->damages, dmg)
3159 damages = eina_list_append(damages, dmg);
3161 EINA_LIST_FREE(damages, dmg)
3163 /* not creating damage for ec that shows a underlay video */
3164 if (state->buffer_viewport.changed ||
3165 !e_comp->wl_comp_data->available_hw_accel.underlay ||
3166 !buffer || buffer->type != E_COMP_WL_BUFFER_TYPE_VIDEO)
3167 e_comp_object_damage(ec->frame, dmg->x, dmg->y, dmg->w, dmg->h);
3169 eina_rectangle_free(dmg);
3174 /* put state opaque into surface */
3175 e_pixmap_image_opaque_set(ec->pixmap, 0, 0, 0, 0);
3178 Eina_Rectangle *rect;
3181 itr = eina_tiler_iterator_new(state->opaque);
3182 EINA_ITERATOR_FOREACH(itr, rect)
3186 EINA_RECTANGLE_SET(&r, rect->x, rect->y, rect->w, rect->h);
3187 E_RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h, 0, 0, state->bw, state->bh);
3188 e_pixmap_image_opaque_set(ec->pixmap, r.x, r.y, r.w, r.h);
3192 eina_iterator_free(itr);
3195 /* put state input into surface */
3196 if ((state->input) &&
3197 (!eina_tiler_empty(state->input)) &&
3200 Eina_Tiler *src, *tmp;
3204 tmp = eina_tiler_new(sw, sh);
3205 eina_tiler_tile_size_set(tmp, 1, 1);
3207 eina_tiler_rect_add(tmp,
3208 &(Eina_Rectangle){0, 0, sw, sh});
3210 if ((src = eina_tiler_intersection(state->input, tmp)))
3212 Eina_Rectangle *rect;
3215 e_comp_object_input_objs_del(ec->frame);
3216 itr = eina_tiler_iterator_new(src);
3217 EINA_ITERATOR_FOREACH(itr, rect)
3219 ELOGF("COMP", "Set Input Area x:%d, y:%d, w:%d, h:%d, ec(%dx%d), state(%dx%d)",
3220 ec, rect->x, rect->y, rect->w, rect->h,
3221 ec->w, ec->h, state->bw, state->bh);
3222 e_comp_object_input_area_set(ec->frame,
3227 eina_iterator_free(itr);
3228 eina_tiler_free(src);
3231 e_comp_object_input_area_set(ec->frame, 0, 0, ec->w, ec->h);
3233 eina_tiler_free(tmp);
3235 /* clear input tiler */
3236 eina_tiler_clear(state->input);
3239 e_comp_wl_subsurface_check_below_bg_rectangle(ec);
3241 if ((cdata->video_client) &&
3243 (buffer->type == E_COMP_WL_BUFFER_TYPE_VIDEO)) &&
3244 (e_comp->wl_comp_data->available_hw_accel.underlay))
3246 e_pixmap_image_clear(ec->pixmap, 1);
3249 state->buffer_viewport.changed = 0;
3251 wl_signal_emit(&cdata->state_commit_signal, &cdata->surface);
3254 ec->exp_iconify.buffer_flush &&
3255 e_policy_visibility_client_is_iconic(ec))
3257 e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
3262 _e_comp_wl_surface_render_stop(E_Client *ec)
3264 /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
3265 //if ((!ec->internal) && (!e_comp_gl_get()))
3268 /* check if internal animation is running */
3269 if (e_comp_object_is_animating(ec->frame)) return;
3270 /* check if external animation is running */
3271 if (evas_object_data_get(ec->frame, "effect_running")) return;
3273 evas_object_hide(ec->frame);
3277 e_comp_wl_client_surface_finish(E_Client *ec)
3279 struct wl_resource *res, *surface;
3280 struct wl_client *surface_client = NULL;
3283 surface = e_comp_wl_client_surface_get(ec);
3286 surface_client = wl_resource_get_client(surface);
3288 if (surface_client &&
3289 (ec == e_client_focused_get()))
3291 EINA_LIST_FOREACH_SAFE(e_comp_input_key->kbd.focused, l, ll, res)
3293 if (wl_resource_get_client(res) ==
3295 e_comp_input_key->kbd.focused =
3296 eina_list_remove_list(e_comp_input_key->kbd.focused, l);
3301 e_comp_wl_client_surface_set(ec, NULL);
3303 ec->comp_data->wl_surface = NULL;
3304 e_pixmap_win_id_del(ec->pixmap);
3306 _e_comp_wl_surface_render_stop(ec);
3307 e_object_del(E_OBJECT(ec));
3311 _e_comp_wl_pname_get(pid_t pid, char *name, int size)
3316 char proc[512], pname[512];
3319 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3321 h = fopen(proc, "r");
3324 len = fread(pname, sizeof(char), 512, h);
3326 pname[len - 1] = '\0';
3328 strncpy(pname, "NO NAME", sizeof(pname));
3334 strncpy(pname, "NO NAME", sizeof(pname));
3337 strncpy(name, pname, size);
3341 _e_comp_wl_pname_print(pid_t pid)
3344 char proc[512], pname[512];
3347 snprintf(proc, 512,"/proc/%d/cmdline", pid);
3349 h = fopen(proc, "r");
3352 len = fread(pname, sizeof(char), 512, h);
3354 pname[len - 1] = '\0';
3356 strncpy(pname, "NO NAME", sizeof(pname));
3360 ELOGF("COMP", " |%s", NULL, pname);
3365 _e_comp_wl_connected_client_cb_destroy(struct wl_listener *listener, void *data)
3367 struct wl_client *client = data;
3368 E_Comp_Connected_Client_Info *cinfo;
3371 cinfo = wl_container_of(listener, cinfo, destroy);
3373 ELOGF("WL_CLIENT", "DESTROY |client:%8p|%d|%d|%d",
3374 NULL, client, cinfo->pid, cinfo->uid, cinfo->gid);
3376 eai = e_appinfo_find_with_pid(cinfo->pid);
3377 if (e_appinfo_owner_get(eai) == E_APPINFO_OWNER_SERVER)
3380 e_comp->connected_clients = eina_list_remove(e_comp->connected_clients, cinfo);
3382 wl_list_remove(&cinfo->destroy.link);
3383 eina_stringshare_del(cinfo->name);
3388 _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t pid, uid_t uid, gid_t gid)
3390 E_Comp_Connected_Client_Info *cinfo;
3392 cinfo = E_NEW(E_Comp_Connected_Client_Info, 1);
3393 EINA_SAFETY_ON_NULL_RETURN(cinfo);
3395 cinfo->name = eina_stringshare_add(name);
3399 cinfo->destroy.notify = _e_comp_wl_connected_client_cb_destroy;
3400 wl_client_add_destroy_listener(client, &cinfo->destroy);
3401 e_comp->connected_clients = eina_list_append(e_comp->connected_clients, cinfo);
3403 _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
3407 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
3409 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3411 /* send configure */
3412 if (ec->comp_data->shell.configure_send)
3414 if (ec->comp_data->shell.surface)
3415 _e_comp_wl_configure_send(ec, 0, 0);
3418 e_comp_wl->kbd.focus = ec->comp_data->surface;
3419 e_comp_input_key->kbd.focus = ec->comp_data->surface;
3423 _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
3425 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3427 /* send configure */
3428 if (ec->comp_data->shell.configure_send)
3430 if (ec->comp_data->shell.surface)
3431 _e_comp_wl_configure_send(ec, 0, 0);
3434 _e_comp_wl_focus_check();
3436 if (e_comp_wl->kbd.focus == ec->comp_data->surface)
3437 e_comp_wl->kbd.focus = NULL;
3439 if (e_comp_input_key->kbd.focus == ec->comp_data->surface)
3440 e_comp_input_key->kbd.focus = NULL;
3444 _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
3446 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3447 if (ec->keyboard_resizing) return;
3449 /* do nothing currently */
3454 _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
3456 if (e_object_is_del(E_OBJECT(ec))) return;
3457 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3459 e_comp_wl->resize.edges = 0;
3460 e_comp_wl->resize.resource = NULL;
3464 _e_comp_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
3466 if (e_object_is_del(E_OBJECT(ec))) return;
3467 if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
3471 _e_comp_wl_output_info_send(E_Comp_Wl_Output *output, struct wl_resource *resource, pid_t pid, int res_w, int res_h)
3474 int ratio_w, ratio_h;
3476 phys_w = output->phys_width;
3477 phys_h = output->phys_height;
3479 if (e_config->configured_output_resolution.use)
3481 // change the configured physical size(mm) of the output
3482 if (output->w != res_w)
3484 ratio_w = res_w / output->w;
3485 phys_w = (int)((float)output->phys_width * (float)ratio_w);
3488 if (output->h != res_h)
3490 ratio_h = res_h / output->h;
3491 phys_h = (int)((float)output->phys_height * (float)ratio_h);
3494 ELOGF("COMP_WL", "\tSend Configured Output (pid:%d)", NULL, pid);
3497 ELOGF("COMP_WL", "\t Output Resolution: res(%d, %d) phy_size(%d, %d) (pid:%d).",
3498 NULL, res_w, res_h, phys_w, phys_h, pid);
3500 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
3501 wl_output_send_scale(resource, output->scale);
3503 wl_output_send_geometry(resource, output->x, output->y,
3505 output->subpixel, output->make ?: "",
3506 output->model ?: "", output->transform);
3508 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
3509 res_w, res_h, output->refresh);
3511 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
3512 wl_output_send_done(resource);
3516 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
3518 E_Comp_Wl_Output *output;
3520 if (!(output = wl_resource_get_user_data(resource))) return;
3522 output->resources = eina_list_remove(output->resources, resource);
3526 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
3528 E_Comp_Wl_Output *output;
3529 struct wl_resource *resource;
3530 E_Appinfo *eai = NULL;
3534 if (!(output = data)) return;
3537 wl_resource_create(client, &wl_output_interface, version, id);
3540 wl_client_post_no_memory(client);
3544 ELOGF("COMP_WL", "Bound Output: %s", NULL, output->id);
3545 ELOGF("COMP_WL", "\tOutput Geom: %d %d %d %d", NULL, output->x, output->y, output->w, output->h);
3547 output->resources = eina_list_append(output->resources, resource);
3549 wl_resource_set_implementation(resource, NULL, output,
3550 _e_comp_wl_cb_output_unbind);
3551 wl_resource_set_user_data(resource, output);
3553 // set the configured_output_resolution as a resolution of the wl_output if the use is set.
3554 if (e_config->configured_output_resolution.use)
3556 wl_client_get_credentials(client, &pid, NULL, NULL);
3559 res_w = e_config->configured_output_resolution.w;
3560 res_h = e_config->configured_output_resolution.h;
3564 eai = e_appinfo_find_with_pid(pid);
3567 res_w = e_config->configured_output_resolution.w;
3568 res_h = e_config->configured_output_resolution.h;
3572 if (!e_appinfo_base_output_resolution_get(eai, &res_w, &res_h))
3574 res_w = e_config->configured_output_resolution.w;
3575 res_h = e_config->configured_output_resolution.h;
3579 ELOGF("COMP_WL", "Get base_screen_resolution. (pid:%d).", NULL, pid);
3588 _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
3592 _e_comp_wl_gl_init(void *data EINA_UNUSED)
3595 Evas_GL *evasgl = NULL;
3596 Evas_GL_API *glapi = NULL;
3597 Evas_GL_Context *ctx = NULL;
3598 Evas_GL_Surface *sfc = NULL;
3599 Evas_GL_Config *cfg = NULL;
3601 E_Comp_Wl_Evas_Gl *evas_gl = NULL;
3603 if (!e_comp_gl_get()) return;
3605 evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
3606 EINA_SAFETY_ON_NULL_RETURN(evas_gl);
3608 /* create dummy evas gl to bind wayland display of enlightenment to egl display */
3609 e_main_ts_begin("\tE_Comp_Wl_GL Init");
3611 /* if wl_drm module doesn't call e_comp_canvas_init yet,
3612 * then we should get evas from ecore_evas.
3615 evas = e_comp->evas;
3617 evas = ecore_evas_get(e_comp->ee);
3619 evasgl = evas_gl_new(evas);
3620 EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
3622 glapi = evas_gl_api_get(evasgl);
3623 EINA_SAFETY_ON_NULL_GOTO(glapi, err);
3624 EINA_SAFETY_ON_NULL_GOTO(glapi->evasglBindWaylandDisplay, err);
3626 cfg = evas_gl_config_new();
3627 EINA_SAFETY_ON_NULL_GOTO(cfg, err);
3629 sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
3630 EINA_SAFETY_ON_NULL_GOTO(sfc, err);
3632 ctx = evas_gl_context_create(evasgl, NULL);
3633 EINA_SAFETY_ON_NULL_GOTO(ctx, err);
3635 res = evas_gl_make_current(evasgl, sfc, ctx);
3636 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3638 res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_wl->wl.disp);
3639 EINA_SAFETY_ON_FALSE_GOTO(res, err);
3641 evas_gl_config_free(cfg);
3643 evas_gl->gl = evasgl;
3644 evas_gl->glapi = glapi;
3645 evas_gl->glsfc = sfc;
3646 evas_gl->glctx = ctx;
3648 e_comp_wl->evas_gl = evas_gl;
3650 /* for native surface */
3653 e_main_ts_end("\tE_Comp_Wl_GL Init Done");
3658 evas_gl_config_free(cfg);
3659 evas_gl_make_current(evasgl, NULL, NULL);
3660 evas_gl_context_destroy(evasgl, ctx);
3661 evas_gl_surface_destroy(evasgl, sfc);
3662 evas_gl_free(evasgl);
3669 _e_comp_wl_gl_popup_cb_close(void *data,
3670 Evas_Object *obj EINA_UNUSED,
3671 void *event_info EINA_UNUSED)
3673 evas_object_del(data);
3677 _e_comp_wl_gl_popup_cb_focus(void *data,
3678 Evas_Object *obj EINA_UNUSED,
3679 void *event_info EINA_UNUSED)
3681 elm_object_focus_set(data, EINA_TRUE);
3686 _e_comp_wl_gl_idle(void *data)
3690 /* show warning window to notify failure of gl init */
3693 Evas_Object *win, *bg, *popup, *btn;
3695 win = elm_win_add(NULL, "compositor warning", ELM_WIN_BASIC);
3696 elm_win_title_set(win, "Compositor Warning");
3697 elm_win_autodel_set(win, EINA_TRUE);
3698 elm_win_borderless_set(win, EINA_TRUE);
3699 elm_win_role_set(win, "notification-low");
3700 elm_win_alpha_set(win, EINA_TRUE);
3702 bg = evas_object_rectangle_add(evas_object_evas_get(win));
3703 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3704 elm_win_resize_object_add(win, bg);
3705 evas_object_color_set(bg, 125, 125, 125, 125);
3706 evas_object_show(bg);
3708 popup = elm_popup_add(win);
3709 elm_object_text_set(popup,
3710 _( "Your screen does not support OpenGL.<br>"
3711 "Falling back to software engine."));
3712 elm_object_part_text_set(popup, "title,text", "Compositor Warning");
3714 btn = elm_button_add(popup);
3715 elm_object_text_set(btn, "Close");
3716 elm_object_part_content_set(popup, "button1", btn);
3717 evas_object_show(btn);
3719 evas_object_smart_callback_add(win, "focus,in", _e_comp_wl_gl_popup_cb_focus, popup);
3720 evas_object_smart_callback_add(btn, "unpressed", _e_comp_wl_gl_popup_cb_close, win);
3722 evas_object_show(popup);
3723 evas_object_show(win);
3727 return ECORE_CALLBACK_CANCEL;
3731 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
3733 struct wl_client *client = data;
3739 wl_client_get_credentials(client, &pid, &uid, &gid);
3741 ELOGF("COMP", "WL_CLIENT|client:%8p|%d|%d|%d", NULL, client, pid, uid, gid);
3743 _e_comp_wl_pname_print(pid);
3744 _e_comp_wl_pname_get(pid, name, sizeof(name));
3745 _e_comp_wl_connected_client_create(client, name, pid, uid, gid);
3749 _e_comp_wl_ds_log_handler(enum ds_log_level level, const char *fmt, va_list args)
3751 char buf[1024] = {0, };
3753 vsnprintf(buf, 1024, fmt, args);
3757 DBG("[libds] %s", buf);
3760 INF("[libds] %s", buf);
3763 ERR("[libds] %s", buf);
3771 _e_comp_wl_display_create(void)
3774 E_Comp_Wl_Data *wl_cdata;
3779 /* create new compositor data */
3780 if (!(comp = E_NEW(E_Comp_Data, 1)))
3782 ERR("Could not create compositor data: %m");
3785 wl_cdata = &comp->base;
3787 /* set compositor wayland data */
3788 e_comp_wl = e_comp->wl_comp_data = wl_cdata;
3790 g_mutex_init(&connection_mutex);
3792 /* try to create a wayland display */
3793 if (!(wl_cdata->wl.disp = wl_display_create()))
3795 ERR("Could not create a Wayland display: %m");
3799 /* try to setup wayland socket */
3800 if (!(name = wl_display_add_socket_auto(wl_cdata->wl.disp)))
3802 ERR("Could not create Wayland display socket: %m");
3803 PRCTL("[Winsys] Could not create Wayland display socket: /run/wayland-0");
3807 res = e_comp_socket_init(name);
3808 EINA_SAFETY_ON_FALSE_GOTO(res, sock_err);
3809 PRCTL("[Winsys] change permission and create sym link for %s", name);
3811 /* set wayland display environment variable */
3812 e_env_set("WAYLAND_DISPLAY", name);
3814 /* wl_cdata->output.transform = WL_OUTPUT_TRANSFORM_NORMAL; */
3815 /* wl_cdata->output.scale = e_scale; */
3817 ds_log_init(DS_DBG, _e_comp_wl_ds_log_handler);
3819 if (!e_compositor_init(wl_cdata->wl.disp))
3821 ERR("Failed to initialize compositor");
3825 comp->client_created.notify = _e_comp_wl_cb_client_created;
3826 wl_display_add_client_created_listener(comp->base.wl.disp, &comp->client_created);
3828 if (!e_comp_wl_subsurfaces_init())
3830 ERR("Failed to init_subsurfaces");
3831 goto subsurfaces_err;
3834 /* initialize shm mechanism */
3835 wl_display_init_shm(wl_cdata->wl.disp);
3837 /* _e_comp_wl_cb_randr_change(NULL, 0, NULL); */
3839 /* try to init data manager */
3840 if (!e_comp_wl_data_manager_init())
3842 ERR("Could not initialize data manager");
3846 /* try to init input */
3847 if (!e_comp_wl_input_init())
3849 ERR("Could not initialize input");
3853 if (e_comp_gl_get())
3854 _e_comp_wl_gl_init(NULL);
3856 /* get the wayland display loop */
3857 wl_cdata->wl.loop = wl_display_get_event_loop(wl_cdata->wl.disp);
3859 /* get the file descriptor of the wayland event loop */
3860 fd = wl_event_loop_get_fd(wl_cdata->wl.loop);
3862 /* create a listener for wayland main loop events */
3864 ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
3865 _e_comp_wl_cb_read, wl_cdata, NULL, NULL);
3866 ecore_main_fd_handler_prepare_callback_set(wl_cdata->fd_hdlr,
3867 _e_comp_wl_cb_prepare, wl_cdata);
3869 /* add awake handler */
3870 ecore_main_awake_handler_add(_e_comp_wl_cb_awake, NULL);
3875 e_comp_wl_data_manager_shutdown();
3877 e_comp_wl_subsurfaces_shutdown();
3879 wl_list_remove(&comp->client_created.link);
3881 e_env_unset("WAYLAND_DISPLAY");
3883 wl_display_destroy(wl_cdata->wl.disp);
3885 g_mutex_clear(&connection_mutex);
3891 _e_comp_wl_gl_shutdown(void)
3893 if (!e_comp_wl->evas_gl) return;
3895 e_comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_wl->evas_gl->gl, e_comp_wl->wl.disp);
3897 evas_gl_make_current(e_comp_wl->evas_gl->gl, NULL, NULL);
3898 evas_gl_context_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glctx);
3899 evas_gl_surface_destroy(e_comp_wl->evas_gl->gl, e_comp_wl->evas_gl->glsfc);
3900 evas_gl_free(e_comp_wl->evas_gl->gl);
3902 E_FREE(e_comp_wl->evas_gl);
3905 /* public functions */
3908 * Creates and initializes a Wayland compositor with ecore.
3909 * Registers callback handlers for keyboard and mouse activity
3910 * and other client events.
3912 * @returns true on success, false if initialization failed.
3915 e_comp_wl_init(void)
3917 TRACE_DS_BEGIN(COMP_WL:INIT);
3919 /* try to create a wayland compositor */
3920 if (!_e_comp_wl_display_create())
3922 e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
3927 e_comp_wl_shell_init();
3929 #ifdef HAVE_WAYLAND_TBM
3930 e_comp_wl_tbm_init();
3932 e_comp_wl_remote_surface_init();
3936 e_comp_wl_screenshooter_init();
3938 if (!e_comp_wl_video_init())
3939 ELOGF("COMP", "Failed to initialize the e_comp_wl_video", NULL);
3941 e_comp_wl_viewport_init();
3942 e_comp_wl_capture_init();
3943 e_comp_wl_renderer_init();
3944 _e_comp_wl_move_resize_init();
3945 e_presentation_time_init();
3946 ds_single_pixel_buffer_manager_v1_create(e_comp_wl->wl.disp);
3948 e_blur_manager_init();
3950 if (!e_foreign_global_init(e_comp_wl->wl.disp))
3951 ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
3953 /* add event handlers to catch E events */
3954 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
3955 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
3956 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move, NULL);
3957 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_RELATIVE_MOVE, _e_comp_wl_cb_mouse_relative_move, NULL);
3958 E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_CANCEL, _e_comp_wl_cb_mouse_button_cancel, NULL);
3959 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _e_comp_wl_cb_zone_display_state_change, NULL);
3960 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
3961 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
3962 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
3964 /* add hooks to catch e_client events */
3965 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET, _e_comp_wl_client_cb_focus_set, NULL);
3966 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_UNSET, _e_comp_wl_client_cb_focus_unset, NULL);
3967 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_BEGIN, _e_comp_wl_client_cb_resize_begin, NULL);
3968 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_RESIZE_END, _e_comp_wl_client_cb_resize_end, NULL);
3969 E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_MOVE_END, _e_comp_wl_client_cb_move_end, NULL);
3976 e_comp_wl_deferred_job(void)
3978 ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
3981 /* internal functions */
3983 e_comp_wl_shutdown(void)
3985 E_Comp_Data *comp = (E_Comp_Data *)e_comp_wl;
3987 e_comp_wl_subsurfaces_shutdown();
3989 E_FREE_LIST(handlers, ecore_event_handler_del);
3990 E_FREE_LIST(hooks, e_client_hook_del);
3991 _e_comp_wl_gl_shutdown();
3993 e_presentation_time_shutdown();
3994 e_comp_wl_renderer_shutdown();
3995 e_comp_wl_capture_shutdown();
3996 e_comp_wl_viewport_shutdown();
3997 e_comp_wl_video_shutdown();
3998 e_comp_wl_screenshooter_shutdown();
4000 e_comp_wl_remote_surface_shutdown();
4002 e_pixmap_shutdown();
4004 e_wtz_shell_shutdown();
4005 e_comp_wl_shell_shutdown();
4006 e_comp_wl_input_shutdown();
4008 wl_list_remove(&comp->client_created.link);
4010 /* delete awake handler */
4011 ecore_main_awake_handler_del(_e_comp_wl_cb_awake);
4014 e_comp->wl_comp_data = NULL;
4018 E_Comp_Wl_Output *output;
4020 if (e_comp_wl->screenshooter.global)
4021 wl_global_destroy(e_comp_wl->screenshooter.global);
4023 EINA_LIST_FREE(e_comp_wl->outputs, output)
4025 if (output->id) eina_stringshare_del(output->id);
4026 if (output->make) eina_stringshare_del(output->make);
4027 if (output->model) eina_stringshare_del(output->model);
4031 /* delete fd handler */
4032 if (e_comp_wl->fd_hdlr) ecore_main_fd_handler_del(e_comp_wl->fd_hdlr);
4034 E_FREE_FUNC(e_comp_wl->ptr.hide_tmr, ecore_timer_del);
4035 cursor_timer_ec = NULL;
4037 /* free allocated data structure */
4043 e_comp_wl_surface_event_simple_free(void *d EINA_UNUSED, E_Event_Client *ev)
4045 e_object_unref(E_OBJECT(ev->ec));
4050 e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
4053 ev = E_NEW(E_Event_Client, 1);
4056 e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
4058 /* set usable early because shell module checks this */
4059 if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
4060 e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
4062 e_pixmap_resource_set(ec->pixmap, buffer);
4063 e_pixmap_dirty(ec->pixmap);
4064 e_pixmap_refresh(ec->pixmap);
4066 e_comp_wl_map_size_cal_from_buffer(ec);
4067 _e_comp_wl_surface_state_size_update(ec, &ec->comp_data->pending);
4069 /* wm-policy module uses it */
4070 _e_comp_wl_hook_call(E_COMP_WL_HOOK_BUFFER_CHANGE, ec);
4073 e_object_ref(E_OBJECT(ec));
4074 ecore_event_add(E_EVENT_CLIENT_BUFFER_CHANGE, ev,
4075 (Ecore_End_Cb)e_comp_wl_surface_event_simple_free, NULL);
4079 e_comp_wl_surface_commit(E_Client *ec)
4084 _e_comp_wl_surface_state_commit(ec, &ec->comp_data->pending);
4085 if (!e_comp_object_damage_exists(ec->frame))
4087 if ((ec->comp_data->video_client) ||
4088 (!e_client_video_hw_composition_check(ec)))
4089 e_pixmap_image_clear(ec->pixmap, 1);
4092 ignored = ec->ignored;
4094 if (e_comp_wl_subsurface_order_commit(ec))
4096 E_Client *topmost = e_comp_wl_topmost_parent_get(ec);
4097 e_comp_wl_subsurface_restack(topmost);
4098 e_comp_wl_subsurface_restack_bg_rectangle(topmost);
4101 ec->ignored = ignored;
4103 if (ec->is_cursor && ec->visible)
4105 /* ignore cursor changes during resize/move I guess */
4106 if (!e_client_action_get())
4108 if (e_comp->pointer)
4110 x = e_comp->pointer->hot.x;
4111 y = e_comp->pointer->hot.y;
4113 e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
4119 static E_Comp_Wl_Output *
4120 _e_comp_wl_output_get(Eina_List *outputs, const char *id)
4123 E_Comp_Wl_Output *output;
4125 EINA_LIST_FOREACH(outputs, l, output)
4127 if (!strcmp(output->id, id))
4135 * Initializes information about one display output.
4137 * Adds or updates the given data about a single display output,
4138 * with an id matching the provided id.
4140 * @param id identification of output to be added or changed
4141 * @param make manufacturer name of the display output
4142 * @param model model name of the display output
4143 * @param x output's top left corner x coordinate
4144 * @param y output's top left corner y coordinate
4145 * @param w output's width in pixels
4146 * @param h output's height in pixels
4147 * @param pw output's physical width in millimeters
4148 * @param ph output's physical height in millimeters
4149 * @param refresh output's refresh rate in mHz
4150 * @param subpixel output's subpixel layout
4151 * @param transform output's rotation and/or mirror transformation
4153 * @returns True if a display output object could be added or updated
4156 e_comp_wl_output_init(const char *id, const char *make, const char *model,
4157 int x, int y, int w, int h, int pw, int ph,
4158 unsigned int refresh, unsigned int subpixel,
4159 unsigned int transform)
4161 E_Comp_Wl_Output *output;
4163 struct wl_resource *resource;
4165 /* retrieve named output; or create it if it doesn't exist */
4166 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4169 if (!(output = E_NEW(E_Comp_Wl_Output, 1))) return EINA_FALSE;
4171 if (id) output->id = eina_stringshare_add(id);
4173 output->make = eina_stringshare_add(make);
4175 output->make = eina_stringshare_add("unknown");
4177 output->model = eina_stringshare_add(model);
4179 output->model = eina_stringshare_add("unknown");
4181 e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
4184 wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
4185 2, output, _e_comp_wl_cb_output_bind);
4187 output->resources = NULL;
4188 output->scale = e_scale;
4191 /* update the output details */
4196 output->phys_width = pw;
4197 output->phys_height = ph;
4198 output->refresh = refresh;
4199 output->subpixel = subpixel;
4200 output->transform = transform;
4202 if (output->scale <= 0)
4203 output->scale = e_scale;
4205 /* if we have bound resources, send updates */
4206 EINA_LIST_FOREACH(output->resources, l2, resource)
4208 wl_output_send_geometry(resource,
4209 output->x, output->y,
4211 output->phys_height,
4213 output->make ?: "", output->model ?: "",
4216 if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
4217 wl_output_send_scale(resource, output->scale);
4219 wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED,
4220 output->w, output->h, output->refresh);
4222 if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
4223 wl_output_send_done(resource);
4230 e_comp_wl_output_remove(const char *id)
4232 E_Comp_Wl_Output *output;
4234 output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
4237 e_comp_wl->outputs = eina_list_remove(e_comp_wl->outputs, output);
4239 /* wl_global_destroy(output->global); */
4241 /* eina_stringshare_del(output->id); */
4242 /* eina_stringshare_del(output->make); */
4243 /* eina_stringshare_del(output->model); */
4250 _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)
4252 struct wl_resource *res;
4254 uint32_t serial, keycode;
4255 struct wl_client *wc = NULL;
4256 E_Comp_Config *comp_conf = NULL;
4257 const char *device_name = NULL;
4259 keycode = (ev->keycode - 8);
4261 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4263 comp_conf = e_comp_config_get();
4265 if (ec && ec->comp_data)
4267 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4270 wc = wl_resource_get_client(surface);
4273 if (e_config->key_input_ttrace_enable)
4275 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname);
4276 ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
4279 EINA_LIST_FOREACH(key_list, l, res)
4281 if (wl_resource_get_client(res) != wc) continue;
4283 TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
4284 if (!e_input_thread_mode_get())
4286 _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
4287 device_name = ecore_device_name_get(ev->dev);
4293 _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
4294 device_name = e_device_name_get(dev);
4298 if (comp_conf && comp_conf->input_log_enable)
4299 ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
4301 wl_keyboard_send_key(res, serial, ev->timestamp,
4306 if (e_config->key_input_ttrace_enable)
4309 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4314 e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
4316 E_Client *ec = NULL;
4318 E_Comp_Wl_Key_Data *end, *k;
4320 if (ev->window != e_comp->ee_win)
4325 keycode = (ev->keycode - 8);
4326 if (!(e_comp_wl = e_comp->wl_comp_data))
4331 #ifndef E_RELEASE_BUILD
4332 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
4333 ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
4334 (ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
4335 eina_streq(ev->key, "BackSpace"))
4341 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4343 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4345 /* ignore server-generated key repeats */
4346 if (k->key == keycode)
4352 if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
4354 ec = e_client_focused_get();
4355 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4356 if (ec && ec->comp_data && surface)
4358 if (e_comp_input_key->kbd.focused)
4360 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_input_key->kbd.focused, ec);
4362 /* A key only sent to clients is added to the list */
4363 e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4365 if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
4367 DBG("wl_array_add: Out of memory\n");
4371 e_comp_input_key->kbd.keys.size = (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4373 if (!(k = wl_array_add(&e_comp_input_key->kbd.keys, sizeof(*k))))
4375 DBG("wl_array_add: Out of memory\n");
4384 /* update modifier state */
4385 e_comp_wl_input_keyboard_state_update(keycode, EINA_TRUE);
4391 e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
4393 E_Client *ec = NULL;
4394 uint32_t keycode, delivered_key;
4395 E_Comp_Wl_Key_Data *end, *k;
4397 if (ev->window != e_comp->ee_win)
4402 keycode = (ev->keycode - 8);
4404 if (!(e_comp_wl = e_comp->wl_comp_data))
4409 end = (E_Comp_Wl_Key_Data *)e_comp_input_key->kbd.keys.data + (e_comp_input_key->kbd.keys.size / sizeof(*k));
4410 for (k = e_comp_input_key->kbd.keys.data; k < end; k++)
4412 if (k->key == keycode)
4419 e_comp_wl->kbd.keys.size =
4420 (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
4422 e_comp_input_key->kbd.keys.size =
4423 (const char *)end - (const char *)e_comp_input_key->kbd.keys.data;
4425 /* 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) */
4426 if ((delivered_key) ||
4427 ((!e_client_action_get()) && (!e_comp->input_key_grabs)))
4429 ec = e_client_focused_get();
4431 if (e_comp_input_key->kbd.focused)
4433 _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_input_key->kbd.focused, ec);
4437 /* update modifier state */
4438 e_comp_wl_input_keyboard_state_update(keycode, EINA_FALSE);
4444 e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
4446 Eina_Bool res = EINA_FALSE;
4448 if (type == ECORE_EVENT_KEY_DOWN)
4450 res = e_comp_wl_key_down(ev, dev);
4452 else if (type == ECORE_EVENT_KEY_UP)
4454 res = e_comp_wl_key_up(ev, dev);
4461 e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state)
4464 struct wl_client *wc;
4465 uint32_t serial, btn;
4466 struct wl_resource *res;
4467 E_Comp_Config *comp_conf = NULL;
4469 if (ec->cur_mouse_action || e_comp_wl->drag)
4471 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
4472 if ((ec->ignored) && (!ec->remote_surface.provider)) return EINA_FALSE;
4476 case 1: btn = BTN_LEFT; break;
4477 case 2: btn = BTN_MIDDLE; break;
4478 case 3: btn = BTN_RIGHT; break;
4479 default: btn = button_id; break;
4482 e_comp_wl->ptr.button = btn;
4483 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4484 if (!surface) return EINA_FALSE;
4486 if (!eina_list_count(e_comp_wl->ptr.resources))
4489 wc = wl_resource_get_client(surface);
4490 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4492 comp_conf = e_comp_config_get();
4494 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
4496 if (wl_resource_get_client(res) != wc) continue;
4497 if (!e_comp_wl_input_pointer_check(res)) continue;
4498 TRACE_INPUT_BEGIN(e_comp_wl_evas_handle_mouse_button);
4500 if (comp_conf && comp_conf->input_log_enable)
4501 ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), btn, timestamp);
4503 wl_pointer_send_button(res, serial, timestamp, btn, state);
4510 e_comp_wl_touch_cancel(void)
4512 _e_comp_wl_touch_cancel();
4515 E_API E_Comp_Wl_Hook *
4516 e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data)
4520 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_HOOK_LAST, NULL);
4521 ch = E_NEW(E_Comp_Wl_Hook, 1);
4522 if (!ch) return NULL;
4523 ch->hookpoint = hookpoint;
4525 ch->data = (void*)data;
4526 _e_comp_wl_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_hooks[hookpoint], EINA_INLIST_GET(ch));
4531 e_comp_wl_hook_del(E_Comp_Wl_Hook *ch)
4534 if (_e_comp_wl_hooks_walking == 0)
4536 _e_comp_wl_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4540 _e_comp_wl_hooks_delete++;
4543 E_API E_Comp_Wl_Pid_Hook *
4544 e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data)
4546 E_Comp_Wl_Pid_Hook *ch;
4548 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_PID_HOOK_LAST, NULL);
4550 ch = E_NEW(E_Comp_Wl_Pid_Hook, 1);
4551 EINA_SAFETY_ON_NULL_RETURN_VAL(ch, NULL);
4553 ch->hookpoint = hookpoint;
4555 ch->data = (void*)data;
4556 _e_comp_wl_pid_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_pid_hooks[hookpoint], EINA_INLIST_GET(ch));
4562 e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch)
4565 if (_e_comp_wl_pid_hooks_walking == 0)
4567 _e_comp_wl_pid_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_pid_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4571 _e_comp_wl_pid_hooks_delete++;
4574 E_API E_Comp_Wl_Intercept_Hook *
4575 e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data)
4577 E_Comp_Wl_Intercept_Hook *ch;
4579 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_WL_INTERCEPT_HOOK_LAST, NULL);
4580 ch = E_NEW(E_Comp_Wl_Intercept_Hook, 1);
4581 if (!ch) return NULL;
4582 ch->hookpoint = hookpoint;
4584 ch->data = (void*)data;
4585 _e_comp_wl_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_wl_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
4590 e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch)
4593 if (_e_comp_wl_intercept_hooks_walking == 0)
4595 _e_comp_wl_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_wl_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
4599 _e_comp_wl_intercept_hooks_delete++;
4603 e_comp_wl_shell_surface_ready(E_Client *ec)
4607 _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec);
4611 e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled)
4613 e_config->use_cursor_timer = !!enabled;
4615 if (e_config->use_cursor_timer)
4617 if (!e_pointer_is_hidden(e_comp->pointer))
4619 _e_comp_wl_cursor_move_timer_control(e_comp_wl->ptr.ec);
4624 if (e_comp_wl->ptr.hide_tmr)
4626 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
4627 e_comp_wl->ptr.hide_tmr = NULL;
4629 cursor_timer_ec = NULL;
4631 if (e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->has_cursor_unset)
4634 if (e_pointer_is_hidden(e_comp->pointer))
4636 _e_comp_wl_cursor_reload(e_comp_wl->ptr.ec);
4642 e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
4644 EINA_SAFETY_ON_NULL_RETURN(wc);
4645 EINA_SAFETY_ON_NULL_RETURN(dev);
4647 _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
4651 e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial)
4653 EINA_SAFETY_ON_NULL_RETURN(wc);
4654 EINA_SAFETY_ON_NULL_RETURN(dev);
4656 _e_comp_wl_send_event_e_device(wc, timestamp, dev, serial);
4660 e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
4662 struct wl_resource *res;
4663 struct wl_client *wc;
4665 uint32_t serial, wl_keycode;
4666 enum wl_keyboard_key_state state;
4667 E_Comp_Config *comp_conf = NULL;
4668 const char *dev_name = NULL;
4670 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4671 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4672 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4674 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4675 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4677 wl_keycode = keycode - 8;
4678 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4680 wc = wl_resource_get_client(surface);
4681 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4682 if (!time) time = e_util_timestamp_get();
4683 if (pressed) state = WL_KEYBOARD_KEY_STATE_PRESSED;
4684 else state = WL_KEYBOARD_KEY_STATE_RELEASED;
4686 comp_conf = e_comp_config_get();
4687 e_keyrouter_event_surface_send(ec, keycode);
4689 if (e_config->key_input_ttrace_enable)
4691 TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode);
4692 ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
4695 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4697 if (wl_resource_get_client(res) != wc) continue;
4698 if (!e_input_thread_mode_get())
4702 _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
4703 dev_name = ecore_device_name_get((Ecore_Device *)dev);
4707 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4714 e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
4715 dev_name = e_device_name_get(dev);
4719 if (comp_conf && comp_conf->input_log_enable)
4720 ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
4723 wl_keyboard_send_key(res, serial, time,
4727 if (e_config->key_input_ttrace_enable)
4730 ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL);
4737 e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time)
4739 struct wl_resource *res;
4740 struct wl_client *wc;
4742 uint32_t serial, wl_keycode, cancel_keycode;
4743 E_Comp_Config *comp_conf = NULL;
4744 struct xkb_keymap *keymap = NULL;
4746 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4747 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4748 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4750 keymap = e_comp_input_key->xkb.keymap;
4751 EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
4753 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4754 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4756 cancel_keycode = e_comp_wl_input_keymap_keyname_to_keycode("Cancel");
4757 if (cancel_keycode == XKB_KEYCODE_INVALID)
4759 ELOGF("Key", "Failed to send key cancel for %d key, Cancel key is not supported\n", ec, keycode);
4763 EINA_SAFETY_ON_TRUE_RETURN_VAL(cancel_keycode < 8, EINA_FALSE);
4765 cancel_keycode = cancel_keycode - 8;
4767 wl_keycode = keycode - 8;
4768 EINA_SAFETY_ON_TRUE_RETURN_VAL(wl_keycode <= 0, EINA_FALSE);
4770 wc = wl_resource_get_client(surface);
4771 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4772 if (!time) time = e_util_timestamp_get();
4774 comp_conf = e_comp_config_get();
4775 e_keyrouter_event_surface_send(ec, keycode);
4777 EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
4779 if (wl_resource_get_client(res) != wc) continue;
4780 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4781 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
4783 if (comp_conf && comp_conf->input_log_enable)
4784 ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
4785 wl_keyboard_send_key(res, serial, time,
4786 cancel_keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
4787 wl_keyboard_send_key(res, serial, time,
4788 wl_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4789 wl_keyboard_send_key(res, serial, time,
4790 cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
4798 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)
4800 struct wl_client *wc;
4802 E_Devicemgr_Input_Device *device = NULL;
4804 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4805 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4806 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4808 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4809 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4811 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4813 wc = wl_resource_get_client(surface);
4814 if (!time) time = e_util_timestamp_get();
4815 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4819 _e_comp_wl_send_event_device(wc, time, dev, serial);
4820 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4824 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4825 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4828 x = x + ec->client.x;
4829 y = y + ec->client.y;
4831 _e_comp_wl_send_touch(ec, idx, x, y, time, pressed);
4837 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)
4839 E_Devicemgr_Input_Device *device;
4841 struct wl_client *wc;
4843 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4844 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4845 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4847 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4848 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4850 if (!dev) device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_TOUCH);
4852 wc = wl_resource_get_client(surface);
4853 if (!time) time = e_util_timestamp_get();
4854 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4858 _e_comp_wl_send_event_device(wc, time, dev, serial);
4859 _e_comp_wl_device_handle_axes(ecore_device_identifier_get(dev), ECORE_DEVICE_CLASS_TOUCH, ec, idx, radius_x, radius_y, pressure, angle);
4863 _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_TOUCH, time);
4864 _e_comp_wl_device_handle_axes(device->identifier, device->clas, ec, idx, radius_x, radius_y, pressure, angle);
4867 x = x + ec->client.x;
4868 y = y + ec->client.y;
4870 _e_comp_wl_send_touch_move(ec, idx, x, y, time);
4876 e_comp_wl_touch_cancel_send(E_Client *ec)
4878 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4880 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4882 _e_comp_wl_send_touch_cancel(ec);
4888 e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
4891 struct wl_client *wc;
4893 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4894 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4895 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4897 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4898 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4900 wc = wl_resource_get_client(surface);
4901 if (!time) time = e_util_timestamp_get();
4902 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4904 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4905 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4908 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4909 WL_POINTER_BUTTON_STATE_PRESSED);
4911 e_comp_wl_evas_handle_mouse_button(ec, time, buttons,
4912 WL_POINTER_BUTTON_STATE_RELEASED);
4918 e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4921 struct wl_client *wc;
4923 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4924 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4925 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4927 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4928 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4930 wc = wl_resource_get_client(surface);
4931 if (!time) time = e_util_timestamp_get();
4932 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4934 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4935 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4937 x = x + ec->client.x;
4938 y = y + ec->client.y;
4940 _e_comp_wl_send_mouse_move(ec, x, y, time);
4946 e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
4949 struct wl_client *wc;
4951 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4952 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4953 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4955 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4956 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4958 wc = wl_resource_get_client(surface);
4959 if (!time) time = e_util_timestamp_get();
4960 serial = wl_display_next_serial(e_comp_wl->wl.disp);
4962 if (_e_comp_wl_check_cursor_timer_needed(ec))
4964 if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_WHEEL, ec))
4968 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
4969 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
4971 _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
4973 if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
4975 if (_e_comp_wl_check_cursor_timer_needed(ec))
4976 _e_comp_wl_cursor_move_timer_control(ec);
4983 e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
4986 struct wl_client *wc;
4987 struct wl_resource *res;
4990 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
4991 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
4993 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
4994 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
4996 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
4997 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
4999 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5000 wc = wl_resource_get_client(surface);
5001 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5002 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5004 if (!e_comp_wl_input_pointer_check(res)) continue;
5005 if (wl_resource_get_client(res) != wc) continue;
5007 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5008 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5010 wl_pointer_send_enter(res, serial, surface,
5011 wl_fixed_from_int(x),
5012 wl_fixed_from_int(y));
5013 ec->pointer_enter_sent = EINA_TRUE;
5015 wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
5021 e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
5024 struct wl_client *wc;
5025 struct wl_resource *res;
5028 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
5029 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5030 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5031 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5032 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5033 EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
5035 if (!eina_list_count(e_comp_wl->ptr.resources)) return EINA_FALSE;
5036 wc = wl_resource_get_client(surface);
5037 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5038 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5040 if (!e_comp_wl_input_pointer_check(res)) continue;
5041 if (wl_resource_get_client(res) != wc) continue;
5043 if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
5044 else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
5046 wl_pointer_send_leave(res, serial, surface);
5047 ec->pointer_enter_sent = EINA_FALSE;
5054 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)
5056 Evas_Event_Mouse_In ev_in;
5059 if (ec->pointer_enter_sent) return;
5061 ev_in.buttons = buttons;
5069 ev_in.modifiers = modifiers;
5070 ev_in.locks = locks;
5071 ev_in.timestamp = timestamp;
5072 ev_in.event_flags = event_flags;
5075 ev_in.event_src = event_src;
5077 _e_comp_wl_evas_cb_mouse_in((void *)ec, NULL, NULL, &ev_in);
5081 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)
5083 Evas_Event_Mouse_Out ev_out;
5086 if (!ec->pointer_enter_sent) return;
5088 ev_out.buttons = buttons;
5090 ev_out.output.x = x;
5091 ev_out.output.y = y;
5092 ev_out.canvas.x = x;
5093 ev_out.canvas.y = y;
5096 ev_out.modifiers = modifiers;
5097 ev_out.locks = locks;
5098 ev_out.timestamp = timestamp;
5099 ev_out.event_flags = event_flags;
5102 ev_out.event_src = event_src;
5104 _e_comp_wl_evas_cb_mouse_out((void *)ec, NULL, NULL, &ev_out);
5108 e_comp_wl_cursor_hide(E_Client *ec)
5110 struct wl_resource *res;
5111 struct wl_client *wc;
5115 e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
5117 if (e_comp_wl->ptr.hide_tmr)
5119 ecore_timer_del(e_comp_wl->ptr.hide_tmr);
5120 e_comp_wl->ptr.hide_tmr = NULL;
5122 cursor_timer_ec = NULL;
5124 if (!ec) return EINA_FALSE;
5125 if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
5126 struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
5127 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
5129 wc = wl_resource_get_client(surface);
5130 serial = wl_display_next_serial(e_comp_wl->wl.disp);
5131 EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
5133 if (!e_comp_wl_input_pointer_check(res)) continue;
5134 if (wl_resource_get_client(res) != wc) continue;
5135 if (ec->pointer_enter_sent == EINA_FALSE) continue;
5136 wl_pointer_send_leave(res, serial, surface);
5137 ec->pointer_enter_sent = EINA_FALSE;
5143 /* surface to buffer
5144 * - width : surface width
5145 * - height : surface height
5146 * - transform: buffer transform
5147 * - scale : buffer scale
5149 * - width : screen width
5150 * - height : screen height
5151 * - transform: output transform
5152 * - scale : output scale
5154 static E_Util_Transform_Matrix
5155 _e_comp_wl_buffer_coord_get(int width, int height, int transform, int scale)
5157 E_Util_Transform_Matrix m;
5159 e_util_transform_matrix_load_identity(&m);
5161 if (transform & 0x4)
5163 e_util_transform_matrix_translate(&m, -((double)width / 2), 0, 0);
5164 e_util_transform_matrix_flip_x(&m);
5165 e_util_transform_matrix_translate(&m, (double)width / 2, 0, 0);
5168 switch (transform & 0x3)
5170 case WL_OUTPUT_TRANSFORM_90:
5171 e_util_transform_matrix_translate(&m, -width, 0, 0);
5172 e_util_transform_matrix_rotation_z(&m, 270);
5174 case WL_OUTPUT_TRANSFORM_180:
5175 e_util_transform_matrix_translate(&m, -width, -height, 0);
5176 e_util_transform_matrix_rotation_z(&m, 180);
5178 case WL_OUTPUT_TRANSFORM_270:
5179 e_util_transform_matrix_translate(&m, 0, -height, 0);
5180 e_util_transform_matrix_rotation_z(&m, 90);
5186 e_util_transform_matrix_scale(&m, scale, scale, 1);
5191 /* surface to buffer
5192 * - surface width, surface height, buffer transform, buffer scale
5194 * - screen width, screen height, output transform, output scale
5197 e_comp_wl_pos_convert(int width, int height, int transform, int scale, int sx, int sy, int *bx, int *by)
5199 E_Util_Transform_Matrix m;
5200 E_Util_Transform_Vertex v;
5202 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5204 e_util_transform_vertex_init(&v, sx, sy, 0.0, 1.0);
5205 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5206 e_util_transform_vertex_pos_round_get(&v, bx, by, NULL, NULL);
5210 * - buffer width, buffer height, buffer transform, buffer scale
5213 e_comp_wl_pos_convert_inverse(int width, int height, int transform, int scale, int bx, int by, int *sx, int *sy)
5215 E_Util_Transform_Matrix m;
5216 E_Util_Transform_Vertex v;
5219 if (transform != 0 || scale > 1)
5221 tw = ((transform % 2) ? height : width) / scale;
5222 th = ((transform % 2) ? width : height) / scale;
5230 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5231 m = e_util_transform_matrix_inverse_get(&m);
5233 e_util_transform_vertex_init(&v, bx, by, 0.0, 1.0);
5234 v = e_util_transform_matrix_multiply_vertex(&m, &v);
5235 e_util_transform_vertex_pos_round_get(&v, sx, sy, NULL, NULL);
5238 /* surface to buffer
5239 * - surface width, surface height, buffer transform, buffer scale
5241 * - screen width, screen height, output transform, output scale
5244 e_comp_wl_rect_convert(int width, int height, int transform, int scale,
5245 int sx, int sy, int sw, int sh, int *bx, int *by, int *bw, int *bh)
5247 E_Util_Transform_Matrix m;
5248 E_Util_Transform_Rect sr = {sx, sy, sw, sh};
5249 E_Util_Transform_Rect_Vertex sv;
5251 m = _e_comp_wl_buffer_coord_get(width, height, transform, scale);
5253 sv = e_util_transform_rect_to_vertices(&sr);
5254 sv = e_util_transform_matrix_multiply_rect_vertex(&m, &sv);
5255 sr = e_util_transform_vertices_to_rect(&sv);
5264 * - buffer width, buffer height, buffer transform, buffer scale
5267 e_comp_wl_rect_convert_inverse(int width, int height, int transform, int scale,
5268 int bx, int by, int bw, int bh, int *sx, int *sy, int *sw, int *sh)
5270 E_Util_Transform_Matrix m;
5271 E_Util_Transform_Rect br = {bx, by, bw, bh};
5272 E_Util_Transform_Rect_Vertex bv;
5275 if (transform != 0 || scale > 1)
5277 tw = ((transform % 2) ? height : width) / scale;
5278 th = ((transform % 2) ? width : height) / scale;
5286 m = _e_comp_wl_buffer_coord_get(tw, th, transform, scale);
5287 m = e_util_transform_matrix_inverse_get(&m);
5289 bv = e_util_transform_rect_to_vertices(&br);
5290 bv = e_util_transform_matrix_multiply_rect_vertex(&m, &bv);
5291 br = e_util_transform_vertices_to_rect(&bv);
5299 EINTERN E_Comp_Wl_Output*
5300 e_comp_wl_output_find(E_Client *ec)
5303 E_Comp_Wl_Output *output;
5305 if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return NULL;
5307 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5309 if (output->transform % 2)
5311 if (ec->x < output->y || ec->x >= (output->y + output->h) ||
5312 ec->y < output->x || ec->y >= (output->x + output->w))
5317 if (ec->x < output->x || ec->x >= (output->x + output->w) ||
5318 ec->y < output->y || ec->y >= (output->y + output->h))
5328 EINTERN Eina_Array *
5329 e_comp_wl_output_find_all(E_Client *ec)
5331 E_Comp_Wl_Output *output;
5332 Eina_Array *outputs;
5335 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5337 outputs = eina_array_new(4);
5341 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5343 if (E_INTERSECTS(ec->x, ec->y, ec->w, ec->h,
5344 output->x, output->y, output->w, output->h))
5346 eina_array_push(outputs, output);
5350 if (eina_array_count(outputs) == 0)
5352 eina_array_free(outputs);
5359 // --------------------------------------------------------
5360 // tizen_move_resize
5361 // --------------------------------------------------------
5363 e_comp_wl_commit_sync_client_geometry_add(E_Client *ec,
5370 E_Client_Pending_Geometry *geo;
5373 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5374 if (ec->fullscreen || ec->maximized) goto err;
5376 geo = E_NEW(E_Client_Pending_Geometry, 1);
5379 geo->serial = serial;
5385 ec->surface_sync.pending_geometry = eina_list_append(ec->surface_sync.pending_geometry, geo);
5386 ec->surface_sync.wait_commit = EINA_TRUE;
5391 ELOGF("POSSIZE", "Could not add geometry(new:%d full:%d max:%d)", ec, ec->new_client, ec->fullscreen, ec->maximized);
5398 e_comp_wl_commit_sync_configure(E_Client *ec)
5401 E_Client_Pending_Geometry *geo;
5403 Eina_Bool match_size = EINA_FALSE;
5410 if (!ec || !ec->frame) goto ret;
5411 if (e_object_is_del(E_OBJECT(ec))) goto ret;
5414 config.x = ec->x; config.y = ec->y; config.w = ec->w; config.h = ec->h;
5415 if (!e_pixmap_size_get(ec->pixmap, &bw, &bh)) goto err;
5417 if (eina_list_count(ec->surface_sync.pending_geometry))
5419 Eina_List *ll = NULL;
5420 EINA_LIST_REVERSE_FOREACH_SAFE(ec->surface_sync.pending_geometry, l, ll, geo)
5424 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5429 if ((geo->w == bw) && (geo->h == bh))
5431 match_size = EINA_TRUE;
5436 ec->surface_sync.pending_geometry = eina_list_remove(ec->surface_sync.pending_geometry, geo);
5443 if ((config.w != ec->w) || (config.h != ec->h))
5445 e_client_size_set(ec, config.w, config.h);
5446 ec->changes.size = EINA_TRUE;
5450 // FIXME: The geometry of the client would be better to be calculated
5451 // at e_desk or at e_desk_area. So the position(x,y) of the client
5452 // should be calcuated at the e_desk or at the e_desk_area.
5454 desk = e_comp_desk_find_by_ec(ec);
5457 ec->client.x = desk->geom.x + config.x;
5458 ec->client.y = desk->geom.y + config.y;
5462 ec->client.x = config.x;
5463 ec->client.y = config.y;
5466 if ((ec->client.x != ec->x) || (ec->client.y != ec->y))
5468 e_client_pos_set(ec, ec->client.x, ec->client.y);
5470 ec->changes.pos = 1;
5474 ELOGF("POSSIZE", "Configure pending geometry (%d,%d,%dx%d)", ec, ec->x, ec->y, ec->w, ec->h);
5478 // cw interceptor(move,resize) won't work if wait_commit is TRUE
5479 ec->surface_sync.wait_commit = EINA_FALSE;
5481 e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
5483 // rollback wait_commit if there are pending requests remained
5484 if (eina_list_count(ec->surface_sync.pending_geometry))
5485 ec->surface_sync.wait_commit = EINA_TRUE;
5490 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);
5497 _tz_move_resize_iface_cb_destroy(struct wl_client *client EINA_UNUSED,
5498 struct wl_resource *res_moveresize)
5500 wl_resource_destroy(res_moveresize);
5504 _tz_move_resize_iface_cb_set_geometry(struct wl_client *client EINA_UNUSED,
5505 struct wl_resource *res_moveresize,
5506 struct wl_resource *surface,
5513 /* to be implemented */
5516 int cur_w = 0, cur_h = 0;
5518 ec = e_client_from_surface_resource(surface);
5521 pending = e_client_pending_geometry_has(ec);
5522 e_client_geometry_get(ec, NULL, NULL, &cur_w, &cur_h);
5523 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);
5527 if ((cur_w == w) && (cur_h == h))
5529 e_client_pos_set(ec, x, y);
5530 ec->changes.pos = 1;
5536 if (!e_comp_wl_commit_sync_client_geometry_add(ec, serial, x, y, w, h)) goto err;
5540 ELOGF("POSSIZE", "Could not add set_geometry request(serial:%d, %d,%d - %dx%d)", ec, serial, x, y, w, h);
5543 static const struct tizen_move_resize_interface _tz_move_resize_iface =
5545 _tz_move_resize_iface_cb_destroy,
5546 _tz_move_resize_iface_cb_set_geometry,
5550 _tz_moveresize_cb_bind(struct wl_client *client,
5551 void *data EINA_UNUSED,
5555 struct wl_resource *res_moveresize;
5557 res_moveresize = wl_resource_create(client,
5558 &tizen_move_resize_interface,
5561 EINA_SAFETY_ON_NULL_GOTO(res_moveresize, err);
5564 wl_resource_set_implementation(res_moveresize,
5565 &_tz_move_resize_iface,
5571 ERR("Could not create tizen_move_resize_interface res: %m");
5572 wl_client_post_no_memory(client);
5576 _e_comp_wl_move_resize_init(void)
5578 if (!e_comp_wl) return;
5579 if (!e_comp_wl->wl.disp) return;
5581 if (!wl_global_create(e_comp_wl->wl.disp,
5582 &tizen_move_resize_interface,
5585 _tz_moveresize_cb_bind))
5587 ERR("Could not create tizen_move_resize_interface to wayland globals: %m");
5594 e_comp_wl_pid_output_configured_resolution_send(pid_t pid, int w, int h)
5596 E_Comp_Wl_Output *output;
5597 pid_t output_pid = 0;
5598 Eina_List *l = NULL, *l2 = NULL;
5599 struct wl_resource *resource = NULL;
5601 if (!e_config->configured_output_resolution.use) return EINA_TRUE;
5603 EINA_SAFETY_ON_TRUE_RETURN_VAL(pid <= 0, EINA_FALSE);
5604 EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0, EINA_FALSE);
5605 EINA_SAFETY_ON_TRUE_RETURN_VAL(h < 0, EINA_FALSE);
5607 EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
5609 /* if we have bound resources, send updates */
5610 EINA_LIST_FOREACH(output->resources, l2, resource)
5612 wl_client_get_credentials(wl_resource_get_client(resource), &output_pid, NULL, NULL);
5613 if (output_pid != pid) continue;
5615 ELOGF("COMP_WL", "\tSend Configured Output AGAIN ~!!!!! (pid:%d)", NULL, pid);
5617 // send output information to the client
5618 _e_comp_wl_output_info_send(output, resource, pid, w, h);
5626 e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
5628 _e_comp_wl_surface_state_init(state, w, h);
5632 e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
5634 _e_comp_wl_surface_state_commit(ec, state);
5638 e_comp_wl_hook_call(E_Comp_Wl_Hook_Point hookpoint, E_Client *ec)
5640 _e_comp_wl_hook_call(hookpoint, ec);
5644 e_comp_wl_surface_state_finish(E_Comp_Wl_Surface_State *state)
5646 _e_comp_wl_surface_state_finish(state);
5650 e_comp_wl_surface_state_buffer_set(E_Comp_Wl_Surface_State *state, E_Comp_Wl_Buffer *buffer)
5652 _e_comp_wl_surface_state_buffer_set(state, buffer);
5656 buffer_transform(int width, int height, uint32_t transform, int32_t scale,
5657 int sx, int sy, int *dx, int *dy)
5661 case WL_OUTPUT_TRANSFORM_NORMAL:
5665 case WL_OUTPUT_TRANSFORM_FLIPPED:
5666 *dx = width - sx, *dy = sy;
5668 case WL_OUTPUT_TRANSFORM_90:
5669 *dx = height - sy, *dy = sx;
5671 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5672 *dx = height - sy, *dy = width - sx;
5674 case WL_OUTPUT_TRANSFORM_180:
5675 *dx = width - sx, *dy = height - sy;
5677 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
5678 *dx = sx, *dy = height - sy;
5680 case WL_OUTPUT_TRANSFORM_270:
5681 *dx = sy, *dy = width - sx;
5683 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5693 _buffer_viewport_get(E_Comp_Wl_Buffer_Viewport *vp, int bw, int bh, Eina_Rectangle *out)
5696 int tx1, ty1, tx2, ty2;
5697 int width_from_buffer, height_from_buffer;
5699 switch (vp->buffer.transform)
5701 case WL_OUTPUT_TRANSFORM_90:
5702 case WL_OUTPUT_TRANSFORM_270:
5703 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
5704 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
5705 width_from_buffer = bh / vp->buffer.scale;
5706 height_from_buffer = bw / vp->buffer.scale;
5709 width_from_buffer = bw / vp->buffer.scale;
5710 height_from_buffer = bh / vp->buffer.scale;
5714 if (vp->buffer.src_width == wl_fixed_from_int(-1))
5718 x2 = width_from_buffer;
5719 y2 = height_from_buffer;
5723 x1 = wl_fixed_to_int(vp->buffer.src_x);
5724 y1 = wl_fixed_to_int(vp->buffer.src_y);
5725 x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
5726 y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
5729 buffer_transform(width_from_buffer, height_from_buffer,
5730 vp->buffer.transform, vp->buffer.scale, x1, y1, &tx1, &ty1);
5731 buffer_transform(width_from_buffer, height_from_buffer,
5732 vp->buffer.transform, vp->buffer.scale, x2, y2, &tx2, &ty2);
5734 out->x = (tx1 <= tx2) ? tx1 : tx2;
5735 out->y = (ty1 <= ty2) ? ty1 : ty2;
5736 out->w = (tx1 <= tx2) ? tx2 - tx1 : tx1 - tx2;
5737 out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
5741 * Convert given four coordinates to elements of rectangle
5742 * @in p[4] Coordinates to be converted
5743 * @out rect x, y, width, and height
5744 * transform Angle which represents TDM_TRANSFORM of rectangle
5745 * @return EINA_FALSE in following case, otherwise EINA_TRUE.
5746 * 1. The given coordinates are not represented by rectangle.
5747 * 2. All angles except for 0, 90, 180, 270.
5750 _coords_to_rectangle_convert(Evas_Point p[4], Eina_Rectangle *rect, uint *rotation)
5752 Eina_Bool ret = EINA_FALSE;
5754 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))
5757 if ((p[0].x < p[2].x) && (p[0].y < p[2].y))
5760 *rotation = TDM_TRANSFORM_NORMAL;
5763 EINA_RECTANGLE_SET(rect, p[0].x, p[0].y, p[2].x - p[0].x, p[2].y - p[0].y);
5767 else if ((p[0].x > p[2].x) && (p[0].y > p[2].y))
5770 *rotation = TDM_TRANSFORM_180;
5773 EINA_RECTANGLE_SET(rect, p[2].x, p[2].y, p[0].x - p[2].x, p[0].y - p[2].y);
5778 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))
5781 if ((p[0].x > p[2].x) && (p[0].y < p[2].y))
5784 *rotation = TDM_TRANSFORM_90;
5787 EINA_RECTANGLE_SET(rect, p[2].x, p[0].y, p[0].x - p[2].x, p[2].y - p[0].y);
5791 else if ((p[0].x < p[2].x) && (p[0].y > p[2].y))
5794 *rotation = TDM_TRANSFORM_270;
5797 EINA_RECTANGLE_SET(rect, p[0].x, p[2].y, p[2].x - p[0].x, p[0].y - p[2].y);
5807 _output_viewport_get_from_evas_map(E_Map *m, Eina_Rectangle *out, unsigned int *rotation)
5812 for (i = 0; i < 4; i++)
5813 e_map_point_coord_get(m, i, &p[i].x, &p[i].y, NULL);
5815 if (!_coords_to_rectangle_convert(p, out, rotation))
5817 DBG("Cannot convert given coords to rectangle.\n"
5818 "p1(%d %d) p2(%d %d) p3(%d %d) p4(%d %d)",
5819 p[0].x, p[0].y, p[1].x, p[1].y,
5820 p[2].x, p[2].y, p[3].x, p[3].y);
5828 _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int rotation)
5830 int trans_rotation, flip;
5832 trans_rotation = transform & 0x3;
5833 flip = transform & 0x4;
5835 return (flip + (trans_rotation + rotation) % 4);
5839 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
5847 if (e_comp_wl_subsurface_check(ec))
5848 e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
5855 out->w = ec->comp_data->width_from_viewport;
5856 out->w = (out->w + 1) & ~1;
5857 out->h = ec->comp_data->height_from_viewport;
5859 e_comp_object_frame_xy_unadjust(ec->frame, out->x, out->y, &out->x, &out->y);
5860 e_comp_object_frame_wh_unadjust(ec->frame, out->w, out->h, &out->w, &out->h);
5864 e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Eina_Rectangle *output_viewport, unsigned int *transform)
5866 E_Comp_Wl_Buffer *buffer;
5867 E_Comp_Wl_Buffer_Viewport *vp;
5869 enum wl_output_transform buffer_transform;
5870 unsigned int rotation;
5871 Eina_Bool res = EINA_FALSE;
5873 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5875 if (e_object_is_del(E_OBJECT(ec)))
5878 vp = &ec->comp_data->scaler.buffer_viewport;
5880 if (buffer_viewport)
5882 buffer = ec->comp_data->buffer_ref.buffer;
5883 /* Getting a viewport of buffer needs geometry of buffer. */
5887 _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport);
5890 if ((output_viewport) || (transform))
5892 m = e_client_map_get(ec);
5894 res = _output_viewport_get_from_evas_map(m, output_viewport, &rotation);
5896 _e_comp_wl_surface_output_viewport_get(ec, output_viewport);
5901 buffer_transform = e_comp_wl_output_buffer_transform_get(ec);
5902 /* NOTE Merge transform value from evas_map with E_Comp_Wl_Buffer_Viewport's one.
5903 * Since buffer.transform isn't applied using evas_map,
5904 * it has to be taken into account here to apply buffer.transform
5905 * and rotation of e_client_transform together. */
5907 *transform = _transform_merge_with_rotation(buffer_transform, rotation);
5909 *transform = (unsigned int)buffer_transform;
5917 e_comp_wl_surface_role_set(E_Client *ec, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
5919 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
5920 EINA_SAFETY_ON_NULL_RETURN_VAL(role_name, EINA_FALSE);
5922 /* Must be called with valid comp_data */
5923 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
5925 if ((ec->comp_data->role_name == NULL) ||
5926 (ec->comp_data->role_name == role_name) ||
5927 (strcmp(ec->comp_data->role_name, role_name) == 0))
5929 ec->comp_data->role_name = role_name;
5935 wl_resource_post_error(error_resource, error_code,
5936 "Cannot assign role %s to wl_surface@%d,"
5937 " already has role %s\n",
5939 ec->comp_data->wl_surface ?
5940 wl_resource_get_id(ec->comp_data->wl_surface) : -1,
5941 ec->comp_data->role_name);
5947 EINTERN const char *
5948 e_comp_wl_surface_role_get(E_Client *ec)
5950 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5951 return ec->comp_data ? ec->comp_data->role_name : NULL;
5954 EINTERN struct wl_resource *
5955 e_comp_wl_client_surface_get(E_Client *ec)
5957 struct wl_resource *surface = NULL;
5958 EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
5959 EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
5961 g_mutex_lock(&ec->comp_data->surface_mutex);
5962 surface = ec->comp_data->surface;
5963 g_mutex_unlock(&ec->comp_data->surface_mutex);
5968 EINTERN void e_comp_wl_client_surface_set(E_Client *ec, struct wl_resource *surface)
5970 EINA_SAFETY_ON_NULL_RETURN(ec);
5971 EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
5973 g_mutex_lock(&ec->comp_data->surface_mutex);
5974 ec->comp_data->surface = surface;
5975 g_mutex_unlock(&ec->comp_data->surface_mutex);
5979 e_comp_wl_util_client_from_surface_resource(struct wl_resource *surface_resource)
5981 return e_compositor_util_client_from_surface_resource(surface_resource);
5985 e_comp_wl_client_surface_pending_buffer_set(E_Client *ec, E_Comp_Wl_Buffer *buffer, int32_t sx, int32_t sy)
5987 if (!ec->comp_data->mapped)
5989 if (ec->comp_data->shell.surface &&
5990 !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
5992 ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
5998 if (ec->comp_data->mapped)
6000 /* will be unmapped. so run capture */
6001 e_comp_wl_remote_surface_image_save(ec);
6005 _e_comp_wl_surface_state_buffer_set(&ec->comp_data->pending, buffer);
6007 ec->comp_data->pending.sx = sx;
6008 ec->comp_data->pending.sy = sy;
6009 ec->comp_data->pending.new_attach = EINA_TRUE;
6011 e_client_fps_update(ec);
6015 e_comp_wl_client_surface_pending_opaque_region_set(E_Client *ec, Eina_Tiler *region)
6017 if (ec->comp_data->pending.opaque)
6018 eina_tiler_clear(ec->comp_data->pending.opaque);
6022 eina_tiler_union(ec->comp_data->pending.opaque, region);
6024 if (!eina_tiler_empty(ec->comp_data->pending.opaque))
6028 ec->argb = EINA_FALSE;
6029 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6031 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6032 e_comp_object_alpha_set(ec->frame, EINA_FALSE);
6040 ec->argb = EINA_TRUE;
6041 ELOGF("COMP", "Set argb:%d", ec, ec->argb);
6043 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, ec);
6044 e_comp_object_alpha_set(ec->frame, EINA_TRUE);
6050 e_comp_wl_client_surface_pending_input_region_set(E_Client *ec, Eina_Tiler *region)
6052 if (ec->comp_data->pending.input)
6053 eina_tiler_clear(ec->comp_data->pending.input);
6057 if (eina_tiler_empty(region))
6059 ELOGF("COMP", " |unset input rect", NULL);
6060 e_comp_object_input_objs_del(ec->frame);
6061 e_comp_object_input_area_set(ec->frame, -1, -1, 1, 1);
6064 eina_tiler_union(ec->comp_data->pending.input, region);
6068 eina_tiler_rect_add(ec->comp_data->pending.input,
6069 &(Eina_Rectangle){0, 0, ec->client.w, ec->client.h});
6074 e_comp_wl_client_surface_pending_frame_callback_add(E_Client *ec, struct wl_resource *callback_resource)
6076 ec->comp_data->pending.frames = eina_list_prepend(ec->comp_data->pending.frames, callback_resource);
6080 e_comp_wl_client_surface_frame_callback_remove(E_Client *ec, struct wl_resource *callback_resource)
6082 E_Comp_Wl_Subsurf_Data *sdata;
6087 if (ec->comp_data->frames)
6089 ec->comp_data->frames =
6090 eina_list_remove(ec->comp_data->frames, callback_resource);
6093 if (ec->comp_data->pending.frames)
6095 ec->comp_data->pending.frames =
6096 eina_list_remove(ec->comp_data->pending.frames, callback_resource);
6099 sdata = ec->comp_data->sub.data;
6100 if ((sdata) && (sdata->cached.frames))
6102 sdata->cached.frames =
6103 eina_list_remove(sdata->cached.frames, callback_resource);
6108 e_comp_wl_client_surface_pending_commit(E_Client *ec)
6110 if (e_object_is_del(E_OBJECT(ec))) return;
6112 if (e_comp_wl_remote_surface_commit(ec)) return;
6114 e_comp_wl_surface_commit(ec);
6116 _e_comp_wl_hook_call(E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT, ec);
6120 _e_comp_wl_client_subsurface_set(E_Client *ec, E_Comp_Wl_Subsurf_Data *sub)
6122 e_comp_wl_client_surface_set(ec, ec->comp_data->wl_surface);
6123 ec->comp_data->sub.data = sub;
6125 /* set subsurface client properties */
6126 ec->borderless = EINA_TRUE;
6127 ec->argb = EINA_TRUE;
6128 ELOGF("SUBSURFACE", "Set argb:%d", ec, ec->argb);
6129 ec->lock_border = EINA_TRUE;
6130 ec->lock_focus_in = ec->lock_focus_out = EINA_TRUE;
6131 ec->netwm.state.skip_taskbar = EINA_TRUE;
6132 ec->netwm.state.skip_pager = EINA_TRUE;
6133 ec->border_size = 0;
6134 ec->lock_user_location = 0;
6135 ec->lock_client_location = 0;
6136 ec->lock_user_size = 0;
6137 ec->lock_client_size = 0;
6138 ec->lock_client_stacking = 0;
6139 ec->lock_user_maximize = 0;
6140 ec->lock_client_maximize = 0;
6141 ec->changes.need_maximize = 0;
6142 ec->maximized = E_MAXIMIZE_NONE;
6145 ec->new_client = ec->netwm.ping = EINA_TRUE;
6146 e_comp->new_clients++;
6147 e_client_unignore(ec);
6149 /* Delete 'below_obj' if it was created before 'E_Client' becomes subsurface.
6150 * It's not for subsurface. */
6151 E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del);
6155 _e_comp_wl_client_subsurface_parent_set(E_Client *ec, E_Client *parent)
6157 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6160 ELOGF("COMP", " |subsurface_parent:%p", ec, parent);
6162 sub->parent = parent;
6166 layer = e_client_layer_get(parent);
6167 if (layer > E_LAYER_BOTTOM)
6168 e_client_layer_set(ec, layer);
6171 if (parent->comp_data)
6173 /* append this client to the parents subsurface list */
6174 parent->comp_data->sub.list_pending =
6175 eina_list_append(parent->comp_data->sub.list_pending, ec);
6176 parent->comp_data->sub.list_changed = EINA_TRUE;
6181 e_comp_wl_client_subsurface_parent_unset(E_Client *ec)
6183 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6184 E_Client *parent = sub->parent;
6186 parent->comp_data->sub.list =
6187 eina_list_remove(parent->comp_data->sub.list, ec);
6188 parent->comp_data->sub.list_pending =
6189 eina_list_remove(parent->comp_data->sub.list_pending, ec);
6190 parent->comp_data->sub.below_list =
6191 eina_list_remove(parent->comp_data->sub.below_list, ec);
6192 parent->comp_data->sub.below_list_pending =
6193 eina_list_remove(parent->comp_data->sub.below_list_pending, ec);
6199 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)
6201 sub->resource = subsurface_resource;
6202 sub->cached_buffer_ref.buffer = NULL;
6203 sub->synchronized = EINA_TRUE;
6204 sub->parent = parent;
6205 sub->remote_surface.offscreen_parent = offscreen_parent;
6206 if (offscreen_parent)
6207 ELOGF("SUBSURFACE", " |offscreen_parent:%p", ec, offscreen_parent);
6209 _e_comp_wl_surface_state_init(&sub->cached, ec->w, ec->h);
6211 _e_comp_wl_client_subsurface_set(ec, sub);
6212 _e_comp_wl_client_subsurface_parent_set(ec, parent);
6214 e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec);
6218 e_comp_wl_client_subsurface_finish(E_Client *ec)
6220 E_Comp_Wl_Subsurf_Data *sub = ec->comp_data->sub.data;
6223 e_comp_wl_client_subsurface_parent_unset(ec);
6225 e_comp_wl_surface_state_finish(&sub->cached);
6226 e_comp_wl_buffer_reference(&sub->cached_buffer_ref, NULL);
6228 ec->comp_data->sub.data = NULL;
6232 e_comp_wl_client_evas_init(E_Client *ec)
6234 EINA_SAFETY_ON_NULL_RETURN(ec);
6236 _e_comp_wl_client_evas_init(ec);
6240 e_comp_wl_client_evas_deinit(E_Client *ec)
6242 EINA_SAFETY_ON_NULL_RETURN(ec);
6244 _e_comp_wl_client_evas_deinit(ec);
6248 e_comp_wl_focus_check(void)
6250 _e_comp_wl_focus_check();
6254 e_comp_wl_client_subsurface_cyclic_reference_check(E_Client *ec, E_Client *parent)
6261 if ((parent->comp_data) && (parent->comp_data->sub.data))
6262 parent = parent->comp_data->sub.data->parent;