9 # define LOGFN(fl, ln, fn) \
10 printf("-ECORE_EVAS-WL: %25s: %5i - %s\n", fl, ln, fn);
12 # define LOGFN(fl, ln, fn)
15 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
19 # include <sys/types.h>
20 # include <sys/mman.h>
27 #include "ecore_evas_private.h"
28 #include "Ecore_Evas.h"
30 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
31 # include <Evas_Engine_Wayland_Egl.h>
32 # include <Ecore_Wayland.h>
34 /* local structures */
35 typedef struct _EE_Wl_Smart_Data EE_Wl_Smart_Data;
36 struct _EE_Wl_Smart_Data
40 Evas_Coord x, y, w, h;
43 /* local function prototypes */
44 static int _ecore_evas_wl_init(void);
45 static int _ecore_evas_wl_shutdown(void);
46 static void _ecore_evas_wl_pre_free(Ecore_Evas *ee);
47 static void _ecore_evas_wl_free(Ecore_Evas *ee);
48 static void _ecore_evas_wl_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
49 static void _ecore_evas_wl_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
50 static void _ecore_evas_wl_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
51 static void _ecore_evas_wl_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
52 static void _ecore_evas_wl_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
53 static void _ecore_evas_wl_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
54 static void _ecore_evas_wl_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
55 static void _ecore_evas_wl_move(Ecore_Evas *ee, int x, int y);
56 static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
57 static void _ecore_evas_wl_show(Ecore_Evas *ee);
58 static void _ecore_evas_wl_hide(Ecore_Evas *ee);
59 static void _ecore_evas_wl_raise(Ecore_Evas *ee);
60 static void _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title);
61 static void _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c);
62 static void _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h);
63 static void _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h);
64 static void _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h);
65 static void _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h);
66 static void _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer);
67 static void _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify);
68 static void _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max);
69 static void _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full);
70 static void _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore);
71 static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha);
72 static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent);
73 static int _ecore_evas_wl_render(Ecore_Evas *ee);
74 static void _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h);
76 static Eina_Bool _ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event);
77 static Eina_Bool _ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event);
78 static Eina_Bool _ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
79 static Eina_Bool _ecore_evas_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event);
80 static Eina_Bool _ecore_evas_wl_cb_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event);
82 /* SMART stuff for frame */
83 static Evas_Smart *_ecore_evas_wl_smart = NULL;
85 static void _ecore_evas_wl_smart_init(void);
86 static void _ecore_evas_wl_smart_add(Evas_Object *obj);
87 static void _ecore_evas_wl_smart_del(Evas_Object *obj);
88 static void _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
89 static void _ecore_evas_wl_smart_show(Evas_Object *obj);
90 static void _ecore_evas_wl_smart_hide(Evas_Object *obj);
92 static Evas_Object *_ecore_evas_wl_frame_add(Evas *evas);
95 static int _ecore_evas_wl_init_count = 0;
96 static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[5];
98 static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
101 _ecore_evas_wl_callback_resize_set,
102 _ecore_evas_wl_callback_move_set,
105 _ecore_evas_wl_callback_delete_request_set,
107 _ecore_evas_wl_callback_focus_in_set,
108 _ecore_evas_wl_callback_focus_out_set,
109 _ecore_evas_wl_callback_mouse_in_set,
110 _ecore_evas_wl_callback_mouse_out_set,
112 NULL, // unsticky_set
113 NULL, // pre_render_set
114 NULL, // post_render_set
116 NULL, // managed_move
117 _ecore_evas_wl_resize,
119 NULL, // rotation_set
123 _ecore_evas_wl_raise,
126 _ecore_evas_wl_title_set,
127 _ecore_evas_wl_name_class_set,
128 _ecore_evas_wl_size_min_set,
129 _ecore_evas_wl_size_max_set,
130 _ecore_evas_wl_size_base_set,
131 _ecore_evas_wl_size_step_set,
132 NULL, // object_cursor_set
133 _ecore_evas_wl_layer_set,
135 _ecore_evas_wl_iconified_set,
136 NULL, // borderless set
137 NULL, // override set
138 _ecore_evas_wl_maximized_set,
139 _ecore_evas_wl_fullscreen_set,
140 NULL, // func avoid_damage set
141 NULL, // func withdrawn set
142 NULL, // func sticky set
143 _ecore_evas_wl_ignore_events_set,
144 _ecore_evas_wl_alpha_set,
145 _ecore_evas_wl_transparent_set,
146 NULL, // func profiles set
153 _ecore_evas_wl_render,
154 _ecore_evas_wl_screen_geometry_get
157 /* external variables */
159 /* external functions */
161 ecore_evas_wayland_egl_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame)
163 Ecore_Wl_Window *p = NULL;
164 Evas_Engine_Info_Wayland_Egl *einfo;
166 int method = 0, count = 0;
168 LOGFN(__FILE__, __LINE__, __FUNCTION__);
170 if (!(method = evas_render_method_lookup("wayland_egl")))
172 ERR("Render method lookup failed for Wayland_Egl");
176 count = ecore_wl_init(disp_name);
179 ERR("Failed to initialize Ecore_Wayland");
183 ecore_wl_display_iterate();
185 if (!(ee = calloc(1, sizeof(Ecore_Evas))))
187 ERR("Failed to allocate Ecore_Evas");
192 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
194 _ecore_evas_wl_init();
196 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_wl_engine_func;
198 ee->driver = "wayland_egl";
199 if (disp_name) ee->name = strdup(disp_name);
213 ee->prop.max.w = 32767;
214 ee->prop.max.h = 32767;
216 ee->prop.request_pos = 0;
218 ee->prop.draw_frame = frame;
219 ee->alpha = EINA_FALSE;
221 ee->evas = evas_new();
222 evas_data_attach_set(ee->evas, ee);
223 evas_output_method_set(ee->evas, method);
224 evas_output_size_set(ee->evas, ee->w, ee->h);
225 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
227 /* FIXME: This needs to be set based on theme & scale */
228 if (ee->prop.draw_frame)
229 evas_output_framespace_set(ee->evas, 4, 18, 8, 22);
232 p = ecore_wl_window_find(parent);
234 /* FIXME: Get if parent is alpha, and set */
236 ee->engine.wl.parent = p;
238 ecore_wl_window_new(p, x, y, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
239 ee->prop.window = ee->engine.wl.win->id;
241 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
243 einfo->info.display = ecore_wl_display_get();
244 einfo->info.destination_alpha = ee->alpha;
245 einfo->info.rotation = ee->rotation;
246 einfo->info.depth = 32;
247 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
249 ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
251 _ecore_evas_wl_shutdown();
258 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
260 _ecore_evas_wl_shutdown();
265 ecore_evas_callback_pre_free_set(ee, _ecore_evas_wl_pre_free);
267 if (ee->prop.draw_frame)
269 ee->engine.wl.frame = _ecore_evas_wl_frame_add(ee->evas);
270 evas_object_is_frame_object_set(ee->engine.wl.frame, EINA_TRUE);
271 evas_object_move(ee->engine.wl.frame, 0, 0);
274 _ecore_evas_register(ee);
275 ecore_evas_input_event_register(ee);
277 ecore_event_window_register(ee->prop.window, ee, ee->evas,
278 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
279 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
280 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
281 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
283 /* evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); */
288 /* local functions */
290 _ecore_evas_wl_init(void)
292 LOGFN(__FILE__, __LINE__, __FUNCTION__);
294 if (++_ecore_evas_wl_init_count != 1)
295 return _ecore_evas_wl_init_count;
297 _ecore_evas_wl_event_hdls[0] =
298 ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_IN,
299 _ecore_evas_wl_cb_mouse_in, NULL);
300 _ecore_evas_wl_event_hdls[1] =
301 ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT,
302 _ecore_evas_wl_cb_mouse_out, NULL);
303 _ecore_evas_wl_event_hdls[2] =
304 ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN,
305 _ecore_evas_wl_cb_focus_in, NULL);
306 _ecore_evas_wl_event_hdls[3] =
307 ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT,
308 _ecore_evas_wl_cb_focus_out, NULL);
309 _ecore_evas_wl_event_hdls[4] =
310 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE,
311 _ecore_evas_wl_cb_window_configure, NULL);
313 ecore_event_evas_init();
315 return _ecore_evas_wl_init_count;
319 _ecore_evas_wl_shutdown(void)
323 LOGFN(__FILE__, __LINE__, __FUNCTION__);
325 if (--_ecore_evas_wl_init_count != 0)
326 return _ecore_evas_wl_init_count;
328 for (i = 0; i < sizeof(_ecore_evas_wl_event_hdls) / sizeof(Ecore_Event_Handler *); i++)
330 if (_ecore_evas_wl_event_hdls[i])
331 ecore_event_handler_del(_ecore_evas_wl_event_hdls[i]);
334 ecore_event_evas_shutdown();
336 return _ecore_evas_wl_init_count;
340 _ecore_evas_wl_pre_free(Ecore_Evas *ee)
342 LOGFN(__FILE__, __LINE__, __FUNCTION__);
345 if (ee->engine.wl.frame) evas_object_del(ee->engine.wl.frame);
349 _ecore_evas_wl_free(Ecore_Evas *ee)
351 LOGFN(__FILE__, __LINE__, __FUNCTION__);
353 if (ee->engine.wl.win) ecore_wl_window_free(ee->engine.wl.win);
354 ee->engine.wl.win = NULL;
356 ecore_event_window_unregister(ee->prop.window);
357 ecore_evas_input_event_unregister(ee);
359 _ecore_evas_wl_shutdown();
364 _ecore_evas_wl_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
366 LOGFN(__FILE__, __LINE__, __FUNCTION__);
369 ee->func.fn_resize = func;
373 _ecore_evas_wl_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
375 LOGFN(__FILE__, __LINE__, __FUNCTION__);
378 ee->func.fn_move = func;
382 _ecore_evas_wl_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
384 LOGFN(__FILE__, __LINE__, __FUNCTION__);
387 ee->func.fn_delete_request = func;
391 _ecore_evas_wl_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
393 LOGFN(__FILE__, __LINE__, __FUNCTION__);
396 ee->func.fn_focus_in = func;
400 _ecore_evas_wl_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
402 LOGFN(__FILE__, __LINE__, __FUNCTION__);
405 ee->func.fn_focus_out = func;
409 _ecore_evas_wl_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
411 LOGFN(__FILE__, __LINE__, __FUNCTION__);
414 ee->func.fn_mouse_in = func;
418 _ecore_evas_wl_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
420 LOGFN(__FILE__, __LINE__, __FUNCTION__);
423 ee->func.fn_mouse_out = func;
427 _ecore_evas_wl_move(Ecore_Evas *ee, int x, int y)
429 LOGFN(__FILE__, __LINE__, __FUNCTION__);
434 if ((ee->x != x) || (ee->y != y))
438 if (ee->engine.wl.win)
439 ecore_wl_window_update_location(ee->engine.wl.win, x, y);
440 if (ee->func.fn_move) ee->func.fn_move(ee);
445 _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
447 LOGFN(__FILE__, __LINE__, __FUNCTION__);
453 if (ee->prop.min.w > w) w = ee->prop.min.w;
454 else if (w > ee->prop.max.w) w = ee->prop.max.w;
455 if (ee->prop.min.h > h) h = ee->prop.min.h;
456 else if (h > ee->prop.max.h) h = ee->prop.max.h;
461 // ecore_wl_window_damage(ee->engine.wl.win, 0, 0, ee->w, ee->h);
463 if ((ee->w != w) || (ee->h != h))
468 if ((ee->rotation == 90) || (ee->rotation == 270))
470 evas_output_size_set(ee->evas, h, w);
471 evas_output_viewport_set(ee->evas, 0, 0, h, w);
475 evas_output_size_set(ee->evas, w, h);
476 evas_output_viewport_set(ee->evas, 0, 0, w, h);
479 if (ee->prop.avoid_damage)
483 pdam = ecore_evas_avoid_damage_get(ee);
484 ecore_evas_avoid_damage_set(ee, 0);
485 ecore_evas_avoid_damage_set(ee, pdam);
488 if (ee->engine.wl.frame)
489 evas_object_resize(ee->engine.wl.frame, ee->w, ee->h);
491 /* set new engine destination */
492 /* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */
494 /* ecore_wl_window_damage(ee->engine.wl.win, 0, 0, ee->w, ee->h); */
497 /* ecore_wl_flush(); */
499 if (ee->engine.wl.win)
500 ecore_wl_window_update_size(ee->engine.wl.win, ee->w, ee->h);
502 if (ee->func.fn_resize) ee->func.fn_resize(ee);
507 _ecore_evas_wl_show(Ecore_Evas *ee)
509 Evas_Engine_Info_Wayland_Egl *einfo;
511 LOGFN(__FILE__, __LINE__, __FUNCTION__);
513 if ((!ee) || (ee->visible)) return;
515 if (ee->engine.wl.win)
517 ecore_wl_window_show(ee->engine.wl.win);
518 ecore_wl_window_update_size(ee->engine.wl.win, ee->w, ee->h);
519 /* ecore_wl_sync(); */
521 if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
522 wl_shell_surface_set_class(ee->engine.wl.win->shell_surface,
524 if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
525 wl_shell_surface_set_title(ee->engine.wl.win->shell_surface,
529 if (ee->engine.wl.frame)
531 evas_object_show(ee->engine.wl.frame);
532 evas_object_resize(ee->engine.wl.frame, ee->w, ee->h);
535 if (ee->engine.wl.win)
537 einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
540 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
544 einfo->info.surface = ecore_wl_window_surface_get(ee->engine.wl.win);
545 /* if (einfo->info.surface) */
546 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
548 /* printf("Failed to get a Surface from Ecore_Wl\n"); */
551 /* ecore_wl_window_buffer_attach(ee->engine.wl.win, ee->engine.wl.buffer, 0, 0); */
554 if (ee->func.fn_show) ee->func.fn_show(ee);
558 _ecore_evas_wl_hide(Ecore_Evas *ee)
560 Evas_Engine_Info_Wayland_Egl *einfo;
562 LOGFN(__FILE__, __LINE__, __FUNCTION__);
564 if ((!ee) || (!ee->visible)) return;
566 einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
569 einfo->info.surface = NULL;
570 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
573 if (ee->engine.wl.win)
574 ecore_wl_window_hide(ee->engine.wl.win);
577 ee->should_be_visible = 0;
579 if (ee->func.fn_hide) ee->func.fn_hide(ee);
583 _ecore_evas_wl_raise(Ecore_Evas *ee)
585 LOGFN(__FILE__, __LINE__, __FUNCTION__);
587 if ((!ee) || (!ee->visible)) return;
588 ecore_wl_window_raise(ee->engine.wl.win);
592 _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title)
594 LOGFN(__FILE__, __LINE__, __FUNCTION__);
597 if (ee->prop.title) free(ee->prop.title);
598 ee->prop.title = NULL;
599 if (title) ee->prop.title = strdup(title);
600 if ((ee->prop.draw_frame) && (ee->engine.wl.frame))
602 EE_Wl_Smart_Data *sd;
604 if (!(sd = evas_object_smart_data_get(ee->engine.wl.frame))) return;
605 evas_object_text_text_set(sd->text, ee->prop.title);
608 if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
609 wl_shell_surface_set_title(ee->engine.wl.win->shell_surface,
614 _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
616 LOGFN(__FILE__, __LINE__, __FUNCTION__);
619 if (ee->prop.name) free(ee->prop.name);
620 if (ee->prop.clas) free(ee->prop.clas);
621 ee->prop.name = NULL;
622 ee->prop.clas = NULL;
623 if (n) ee->prop.name = strdup(n);
624 if (c) ee->prop.clas = strdup(c);
626 if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
627 wl_shell_surface_set_class(ee->engine.wl.win->shell_surface,
632 _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h)
634 LOGFN(__FILE__, __LINE__, __FUNCTION__);
639 if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return;
645 _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h)
647 LOGFN(__FILE__, __LINE__, __FUNCTION__);
652 if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return;
658 _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h)
660 LOGFN(__FILE__, __LINE__, __FUNCTION__);
665 if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return;
671 _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h)
673 LOGFN(__FILE__, __LINE__, __FUNCTION__);
678 if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return;
684 _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer)
686 LOGFN(__FILE__, __LINE__, __FUNCTION__);
689 if (ee->prop.layer == layer) return;
690 if (layer < 1) layer = 1;
691 else if (layer > 255) layer = 255;
692 ee->prop.layer = layer;
696 _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify)
698 LOGFN(__FILE__, __LINE__, __FUNCTION__);
701 if (ee->prop.iconified == iconify) return;
702 ee->prop.iconified = iconify;
703 /* FIXME: Implement this in Wayland someshow */
707 _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max)
709 LOGFN(__FILE__, __LINE__, __FUNCTION__);
712 if (ee->prop.maximized == max) return;
713 ee->prop.maximized = max;
714 ecore_wl_window_maximized_set(ee->engine.wl.win, max);
718 _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full)
720 LOGFN(__FILE__, __LINE__, __FUNCTION__);
722 if ((!ee) || (!ee->visible)) return;
723 if (ee->prop.fullscreen == full) return;
724 ee->prop.fullscreen = full;
725 ecore_wl_window_fullscreen_set(ee->engine.wl.win, full);
729 _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore)
731 LOGFN(__FILE__, __LINE__, __FUNCTION__);
734 ee->ignore_events = ignore;
735 /* NB: Hmmm, may need to pass this to ecore_wl_window in the future */
739 _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha)
741 Evas_Engine_Info_Wayland_Egl *einfo;
743 LOGFN(__FILE__, __LINE__, __FUNCTION__);
746 if ((ee->alpha == alpha)) return;
748 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
750 einfo->info.destination_alpha = alpha;
751 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
752 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
753 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
758 _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent)
760 Evas_Engine_Info_Wayland_Egl *einfo;
762 LOGFN(__FILE__, __LINE__, __FUNCTION__);
765 if ((ee->transparent == transparent)) return;
766 ee->transparent = transparent;
767 if (!ee->visible) return;
768 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
770 einfo->info.destination_alpha = transparent;
771 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
772 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
773 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
778 _ecore_evas_wl_render(Ecore_Evas *ee)
784 evas_norender(ee->evas);
787 Eina_List *ll = NULL, *updates = NULL;
788 Ecore_Evas *ee2 = NULL;
790 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
792 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
794 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
795 if (ee2->engine.func->fn_render)
796 rend |= ee2->engine.func->fn_render(ee2);
797 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
800 if ((updates = evas_render_updates(ee->evas)))
805 LOGFN(__FILE__, __LINE__, __FUNCTION__);
807 EINA_LIST_FOREACH(updates, l, r)
808 ecore_wl_window_damage(ee->engine.wl.win,
809 r->x, r->y, r->w, r->h);
813 evas_render_updates_free(updates);
814 _ecore_evas_idle_timeout_update(ee);
818 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
824 _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h)
826 LOGFN(__FILE__, __LINE__, __FUNCTION__);
830 ecore_wl_screen_size_get(w, h);
834 _ecore_evas_wayland_egl_resize(Ecore_Evas *ee, int location)
836 LOGFN(__FILE__, __LINE__, __FUNCTION__);
839 if (ee->engine.wl.win)
841 ee->engine.wl.win->resizing = EINA_TRUE;
842 ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location);
847 _ecore_evas_wayland_egl_move(Ecore_Evas *ee, int x, int y)
849 LOGFN(__FILE__, __LINE__, __FUNCTION__);
852 if (ee->engine.wl.win)
854 ee->engine.wl.win->moving = EINA_TRUE;
855 ecore_wl_window_move(ee->engine.wl.win, x, y);
860 _ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
863 Ecore_Wl_Event_Mouse_In *ev;
865 LOGFN(__FILE__, __LINE__, __FUNCTION__);
868 ee = ecore_event_window_match(ev->window);
869 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
870 if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
871 if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
872 ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
873 evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL);
874 _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
875 return ECORE_CALLBACK_PASS_ON;
879 _ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
882 Ecore_Wl_Event_Mouse_Out *ev;
884 LOGFN(__FILE__, __LINE__, __FUNCTION__);
887 ee = ecore_event_window_match(ev->window);
888 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
889 if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
890 ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
891 _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
892 evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL);
893 if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
894 if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
895 return ECORE_CALLBACK_PASS_ON;
899 _ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
902 Ecore_Wl_Event_Focus_In *ev;
904 LOGFN(__FILE__, __LINE__, __FUNCTION__);
907 ee = ecore_event_window_match(ev->win);
908 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
909 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
910 ee->prop.focused = 1;
911 evas_focus_in(ee->evas);
912 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
913 return ECORE_CALLBACK_PASS_ON;
917 _ecore_evas_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event)
920 Ecore_Wl_Event_Focus_In *ev;
922 LOGFN(__FILE__, __LINE__, __FUNCTION__);
925 ee = ecore_event_window_match(ev->win);
926 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
927 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
928 evas_focus_out(ee->evas);
929 ee->prop.focused = 0;
930 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
931 return ECORE_CALLBACK_PASS_ON;
935 _ecore_evas_wl_cb_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event)
938 Ecore_Wl_Event_Window_Configure *ev;
940 LOGFN(__FILE__, __LINE__, __FUNCTION__);
943 ee = ecore_event_window_match(ev->win);
944 if (!ee) return ECORE_CALLBACK_PASS_ON;
945 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
946 if ((ee->x != ev->x) || (ee->y != ev->y))
952 if (ee->func.fn_move) ee->func.fn_move(ee);
954 if ((ee->req.w != ev->w) || (ee->req.h != ev->h))
958 if (ee->func.fn_resize) ee->func.fn_resize(ee);
961 return ECORE_CALLBACK_PASS_ON;
965 _ecore_evas_wl_smart_init(void)
967 if (_ecore_evas_wl_smart) return;
969 static const Evas_Smart_Class sc =
971 "ecore_evas_wl_frame", EVAS_SMART_CLASS_VERSION,
972 _ecore_evas_wl_smart_add,
973 _ecore_evas_wl_smart_del,
975 _ecore_evas_wl_smart_resize,
976 _ecore_evas_wl_smart_show,
977 _ecore_evas_wl_smart_hide,
978 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
980 _ecore_evas_wl_smart = evas_smart_class_new(&sc);
985 _ecore_evas_wl_smart_add(Evas_Object *obj)
987 EE_Wl_Smart_Data *sd;
990 LOGFN(__FILE__, __LINE__, __FUNCTION__);
992 if (!(sd = calloc(1, sizeof(EE_Wl_Smart_Data)))) return;
994 evas = evas_object_evas_get(obj);
1001 sd->frame = evas_object_rectangle_add(evas);
1002 evas_object_is_frame_object_set(sd->frame, EINA_TRUE);
1003 evas_object_color_set(sd->frame, 249, 249, 249, 255);
1004 evas_object_smart_member_add(sd->frame, obj);
1006 sd->text = evas_object_text_add(evas);
1007 evas_object_color_set(sd->text, 0, 0, 0, 255);
1008 evas_object_text_style_set(sd->text, EVAS_TEXT_STYLE_PLAIN);
1009 evas_object_text_font_set(sd->text, "Sans", 10);
1010 evas_object_text_text_set(sd->text, "Smart Test");
1012 evas_object_smart_data_set(obj, sd);
1016 _ecore_evas_wl_smart_del(Evas_Object *obj)
1018 EE_Wl_Smart_Data *sd;
1020 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1022 if (!(sd = evas_object_smart_data_get(obj))) return;
1023 evas_object_del(sd->text);
1024 evas_object_del(sd->frame);
1029 _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1031 EE_Wl_Smart_Data *sd;
1033 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1035 if (!(sd = evas_object_smart_data_get(obj))) return;
1036 if ((sd->w == w) && (sd->h == h)) return;
1039 evas_object_resize(sd->frame, w, h);
1043 _ecore_evas_wl_smart_show(Evas_Object *obj)
1045 EE_Wl_Smart_Data *sd;
1047 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1049 if (!(sd = evas_object_smart_data_get(obj))) return;
1050 evas_object_show(sd->frame);
1051 evas_object_show(sd->text);
1055 _ecore_evas_wl_smart_hide(Evas_Object *obj)
1057 EE_Wl_Smart_Data *sd;
1059 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1061 if (!(sd = evas_object_smart_data_get(obj))) return;
1062 evas_object_hide(sd->text);
1063 evas_object_hide(sd->frame);
1066 static Evas_Object *
1067 _ecore_evas_wl_frame_add(Evas *evas)
1069 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1071 _ecore_evas_wl_smart_init();
1072 return evas_object_smart_add(evas, _ecore_evas_wl_smart);
1077 ecore_evas_wayland_egl_new(const char *disp_name __UNUSED__, unsigned int parent __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__, Eina_Bool frame __UNUSED__)