aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_egl.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_egl.c')
-rw-r--r--libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_egl.c1017
1 files changed, 0 insertions, 1017 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_egl.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_egl.c
deleted file mode 100644
index e88fc35..0000000
--- a/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_egl.c
+++ /dev/null
@@ -1,1017 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5//#define LOGFNS 1
6
7#ifdef LOGFNS
8# include <stdio.h>
9# define LOGFN(fl, ln, fn) \
10 printf("-ECORE_EVAS-WL: %25s: %5i - %s\n", fl, ln, fn);
11#else
12# define LOGFN(fl, ln, fn)
13#endif
14
15#ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
16# include <stdlib.h>
17# include <string.h>
18# include <unistd.h>
19# include <sys/types.h>
20# include <sys/mman.h>
21#endif
22
23#include <Eina.h>
24#include <Evas.h>
25#include <Ecore.h>
26
27#include "ecore_evas_private.h"
28#include "Ecore_Evas.h"
29
30#ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
31# include <Evas_Engine_Wayland_Egl.h>
32# include <Ecore_Wayland.h>
33
34/* local structures */
35typedef struct _EE_Wl_Smart_Data EE_Wl_Smart_Data;
36struct _EE_Wl_Smart_Data
37{
38 Evas_Object *frame;
39 Evas_Object *text;
40 Evas_Coord x, y, w, h;
41};
42
43/* local function prototypes */
44static int _ecore_evas_wl_init(void);
45static int _ecore_evas_wl_shutdown(void);
46static void _ecore_evas_wl_pre_free(Ecore_Evas *ee);
47static void _ecore_evas_wl_free(Ecore_Evas *ee);
48static void _ecore_evas_wl_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
49static void _ecore_evas_wl_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
50static void _ecore_evas_wl_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
51static void _ecore_evas_wl_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
52static void _ecore_evas_wl_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
53static void _ecore_evas_wl_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
54static void _ecore_evas_wl_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
55static void _ecore_evas_wl_move(Ecore_Evas *ee, int x, int y);
56static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
57static void _ecore_evas_wl_show(Ecore_Evas *ee);
58static void _ecore_evas_wl_hide(Ecore_Evas *ee);
59static void _ecore_evas_wl_raise(Ecore_Evas *ee);
60static void _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title);
61static void _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c);
62static void _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h);
63static void _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h);
64static void _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h);
65static void _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h);
66static void _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer);
67static void _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify);
68static void _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max);
69static void _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full);
70static void _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore);
71static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha);
72static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent);
73static int _ecore_evas_wl_render(Ecore_Evas *ee);
74static void _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h);
75
76static Eina_Bool _ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event);
77static Eina_Bool _ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event);
78static Eina_Bool _ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
79static Eina_Bool _ecore_evas_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event);
80static Eina_Bool _ecore_evas_wl_cb_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event);
81
82/* SMART stuff for frame */
83static Evas_Smart *_ecore_evas_wl_smart = NULL;
84
85static void _ecore_evas_wl_smart_init(void);
86static void _ecore_evas_wl_smart_add(Evas_Object *obj);
87static void _ecore_evas_wl_smart_del(Evas_Object *obj);
88static void _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
89static void _ecore_evas_wl_smart_show(Evas_Object *obj);
90static void _ecore_evas_wl_smart_hide(Evas_Object *obj);
91
92static Evas_Object *_ecore_evas_wl_frame_add(Evas *evas);
93
94/* local variables */
95static int _ecore_evas_wl_init_count = 0;
96static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[5];
97
98static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
99{
100 _ecore_evas_wl_free,
101 _ecore_evas_wl_callback_resize_set,
102 _ecore_evas_wl_callback_move_set,
103 NULL,
104 NULL,
105 _ecore_evas_wl_callback_delete_request_set,
106 NULL,
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,
111 NULL, // sticky_set
112 NULL, // unsticky_set
113 NULL, // pre_render_set
114 NULL, // post_render_set
115 _ecore_evas_wl_move,
116 NULL, // managed_move
117 _ecore_evas_wl_resize,
118 NULL, // move_resize
119 NULL, // rotation_set
120 NULL, // shaped_set
121 _ecore_evas_wl_show,
122 _ecore_evas_wl_hide,
123 _ecore_evas_wl_raise,
124 NULL, // lower
125 NULL, // activate
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,
134 NULL, // focus 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,
147 NULL,
148 NULL,
149 NULL,
150 NULL,
151 NULL,
152 _ecore_evas_wl_render,
153 _ecore_evas_wl_screen_geometry_get
154};
155
156/* external variables */
157
158/* external functions */
159EAPI Ecore_Evas *
160ecore_evas_wayland_egl_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame)
161{
162 Ecore_Wl_Window *p = NULL;
163 Evas_Engine_Info_Wayland_Egl *einfo;
164 Ecore_Evas *ee;
165 int method = 0;
166
167 LOGFN(__FILE__, __LINE__, __FUNCTION__);
168
169 if (!(method = evas_render_method_lookup("wayland_egl")))
170 {
171 ERR("Render method lookup failed for Wayland_Egl");
172 return NULL;
173 }
174
175 if (!ecore_wl_init(disp_name))
176 {
177 ERR("Failed to initialize Ecore_Wayland");
178 return NULL;
179 }
180
181 if (!(ee = calloc(1, sizeof(Ecore_Evas))))
182 {
183 ERR("Failed to allocate Ecore_Evas");
184 ecore_wl_shutdown();
185 return NULL;
186 }
187
188 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
189
190 _ecore_evas_wl_init();
191
192 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_wl_engine_func;
193
194 ee->driver = "wayland_egl";
195 if (disp_name) ee->name = strdup(disp_name);
196
197 if (w < 1) w = 1;
198 if (h < 1) h = 1;
199
200 ee->x = x;
201 ee->y = y;
202 ee->w = w;
203 ee->h = h;
204 ee->req.x = ee->x;
205 ee->req.y = ee->y;
206 ee->req.w = ee->w;
207 ee->req.h = ee->h;
208 ee->rotation = 0;
209 ee->prop.max.w = 32767;
210 ee->prop.max.h = 32767;
211 ee->prop.layer = 4;
212 ee->prop.request_pos = 0;
213 ee->prop.sticky = 0;
214 ee->prop.draw_frame = frame;
215 ee->alpha = EINA_FALSE;
216
217 ee->evas = evas_new();
218 evas_data_attach_set(ee->evas, ee);
219 evas_output_method_set(ee->evas, method);
220 evas_output_size_set(ee->evas, ee->w, ee->h);
221 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
222
223 /* FIXME: This needs to be set based on theme & scale */
224 if (ee->prop.draw_frame)
225 evas_output_framespace_set(ee->evas, 4, 18, 8, 22);
226
227 if (parent)
228 p = ecore_wl_window_find(parent);
229
230 /* FIXME: Get if parent is alpha, and set */
231
232 ee->engine.wl.parent = p;
233 ee->engine.wl.win =
234 ecore_wl_window_new(p, x, y, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
235 ee->prop.window = ee->engine.wl.win->id;
236
237 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
238 {
239 einfo->info.display = ecore_wl_display_get();
240 einfo->info.destination_alpha = EINA_FALSE;
241 einfo->info.rotation = ee->rotation;
242 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
243 {
244 ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
245 ecore_evas_free(ee);
246 _ecore_evas_wl_shutdown();
247 ecore_wl_shutdown();
248 return NULL;
249 }
250 }
251 else
252 {
253 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
254 ecore_evas_free(ee);
255 _ecore_evas_wl_shutdown();
256 ecore_wl_shutdown();
257 return NULL;
258 }
259
260 ecore_evas_callback_pre_free_set(ee, _ecore_evas_wl_pre_free);
261
262 if (ee->prop.draw_frame)
263 {
264 ee->engine.wl.frame = _ecore_evas_wl_frame_add(ee->evas);
265 evas_object_is_frame_object_set(ee->engine.wl.frame, EINA_TRUE);
266 evas_object_move(ee->engine.wl.frame, 0, 0);
267 }
268
269 ecore_evas_input_event_register(ee);
270 _ecore_evas_register(ee);
271
272 ecore_event_window_register(ee->prop.window, ee, ee->evas,
273 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
274 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
275 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
276 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
277
278 evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
279
280 return ee;
281}
282
283/* local functions */
284static int
285_ecore_evas_wl_init(void)
286{
287 LOGFN(__FILE__, __LINE__, __FUNCTION__);
288
289 if (++_ecore_evas_wl_init_count != 1)
290 return _ecore_evas_wl_init_count;
291
292 _ecore_evas_wl_event_hdls[0] =
293 ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_IN,
294 _ecore_evas_wl_cb_mouse_in, NULL);
295 _ecore_evas_wl_event_hdls[1] =
296 ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT,
297 _ecore_evas_wl_cb_mouse_out, NULL);
298 _ecore_evas_wl_event_hdls[2] =
299 ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN,
300 _ecore_evas_wl_cb_focus_in, NULL);
301 _ecore_evas_wl_event_hdls[3] =
302 ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT,
303 _ecore_evas_wl_cb_focus_out, NULL);
304 _ecore_evas_wl_event_hdls[4] =
305 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE,
306 _ecore_evas_wl_cb_window_configure, NULL);
307
308 ecore_event_evas_init();
309
310 return _ecore_evas_wl_init_count;
311}
312
313static int
314_ecore_evas_wl_shutdown(void)
315{
316 unsigned int i = 0;
317
318 LOGFN(__FILE__, __LINE__, __FUNCTION__);
319
320 if (--_ecore_evas_wl_init_count != 0)
321 return _ecore_evas_wl_init_count;
322
323 for (i = 0; i < sizeof(_ecore_evas_wl_event_hdls) / sizeof(Ecore_Event_Handler *); i++)
324 {
325 if (_ecore_evas_wl_event_hdls[i])
326 ecore_event_handler_del(_ecore_evas_wl_event_hdls[i]);
327 }
328
329 ecore_event_evas_shutdown();
330
331 return _ecore_evas_wl_init_count;
332}
333
334static void
335_ecore_evas_wl_pre_free(Ecore_Evas *ee)
336{
337 LOGFN(__FILE__, __LINE__, __FUNCTION__);
338
339 if (!ee) return;
340 if (ee->engine.wl.frame) evas_object_del(ee->engine.wl.frame);
341}
342
343static void
344_ecore_evas_wl_free(Ecore_Evas *ee)
345{
346 LOGFN(__FILE__, __LINE__, __FUNCTION__);
347
348 if (ee->engine.wl.win) ecore_wl_window_free(ee->engine.wl.win);
349 ee->engine.wl.win = NULL;
350
351 ecore_event_window_unregister(ee->prop.window);
352 ecore_evas_input_event_unregister(ee);
353
354 _ecore_evas_wl_shutdown();
355 ecore_wl_shutdown();
356}
357
358static void
359_ecore_evas_wl_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
360{
361 LOGFN(__FILE__, __LINE__, __FUNCTION__);
362
363 if (!ee) return;
364 ee->func.fn_resize = func;
365}
366
367static void
368_ecore_evas_wl_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
369{
370 LOGFN(__FILE__, __LINE__, __FUNCTION__);
371
372 if (!ee) return;
373 ee->func.fn_move = func;
374}
375
376static void
377_ecore_evas_wl_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
378{
379 LOGFN(__FILE__, __LINE__, __FUNCTION__);
380
381 if (!ee) return;
382 ee->func.fn_delete_request = func;
383}
384
385static void
386_ecore_evas_wl_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
387{
388 LOGFN(__FILE__, __LINE__, __FUNCTION__);
389
390 if (!ee) return;
391 ee->func.fn_focus_in = func;
392}
393
394static void
395_ecore_evas_wl_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
396{
397 LOGFN(__FILE__, __LINE__, __FUNCTION__);
398
399 if (!ee) return;
400 ee->func.fn_focus_out = func;
401}
402
403static void
404_ecore_evas_wl_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
405{
406 LOGFN(__FILE__, __LINE__, __FUNCTION__);
407
408 if (!ee) return;
409 ee->func.fn_mouse_in = func;
410}
411
412static void
413_ecore_evas_wl_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
414{
415 LOGFN(__FILE__, __LINE__, __FUNCTION__);
416
417 if (!ee) return;
418 ee->func.fn_mouse_out = func;
419}
420
421static void
422_ecore_evas_wl_move(Ecore_Evas *ee, int x, int y)
423{
424 LOGFN(__FILE__, __LINE__, __FUNCTION__);
425
426 if (!ee) return;
427 ee->req.x = x;
428 ee->req.y = y;
429 ee->x = x;
430 ee->y = y;
431 if (ee->engine.wl.win) ecore_wl_window_move(ee->engine.wl.win, x, y);
432 if (ee->func.fn_move) ee->func.fn_move(ee);
433}
434
435static void
436_ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
437{
438 LOGFN(__FILE__, __LINE__, __FUNCTION__);
439
440 if (!ee) return;
441 if (w < 1) w = 1;
442 if (h < 1) h = 1;
443// if ((ee->w == w) && (ee->h == h)) return;
444
445 if (ee->prop.min.w > w) w = ee->prop.min.w;
446 else if (w > ee->prop.max.w) w = ee->prop.max.w;
447 if (ee->prop.min.h > h) h = ee->prop.min.h;
448 else if (h > ee->prop.max.h) h = ee->prop.max.h;
449
450 ee->req.w = w;
451 ee->req.h = h;
452
453// ecore_wl_window_damage(ee->engine.wl.win, 0, 0, ee->w, ee->h);
454
455 ee->w = w;
456 ee->h = h;
457
458 /* change evas output & viewport sizes */
459 evas_output_size_set(ee->evas, ee->w, ee->h);
460 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
461 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
462 if (ee->engine.wl.frame)
463 evas_object_resize(ee->engine.wl.frame, ee->w, ee->h);
464
465 /* set new engine destination */
466 /* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */
467
468 /* ecore_wl_window_damage(ee->engine.wl.win, 0, 0, ee->w, ee->h); */
469 ecore_wl_flush();
470
471 ecore_wl_window_update_size(ee->engine.wl.win, ee->w, ee->h);
472
473 if (ee->func.fn_resize) ee->func.fn_resize(ee);
474}
475
476static void
477_ecore_evas_wl_show(Ecore_Evas *ee)
478{
479 Evas_Engine_Info_Wayland_Egl *einfo;
480
481 LOGFN(__FILE__, __LINE__, __FUNCTION__);
482
483 if ((!ee) || (ee->visible)) return;
484
485 if (ee->engine.wl.win)
486 {
487 ecore_wl_window_show(ee->engine.wl.win);
488 ecore_wl_flush();
489 }
490
491 einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
492 if (!einfo)
493 {
494 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
495 return;
496 }
497
498 einfo->info.surface = ecore_wl_window_surface_get(ee->engine.wl.win);
499 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
500
501 if (ee->engine.wl.frame)
502 {
503 evas_object_show(ee->engine.wl.frame);
504 evas_object_resize(ee->engine.wl.frame, ee->w, ee->h);
505 }
506
507 /* ecore_wl_window_buffer_attach(ee->engine.wl.win, ee->engine.wl.buffer, 0, 0); */
508
509 ee->visible = 1;
510 if (ee->func.fn_show) ee->func.fn_show(ee);
511}
512
513static void
514_ecore_evas_wl_hide(Ecore_Evas *ee)
515{
516 Evas_Engine_Info_Wayland_Egl *einfo;
517
518 LOGFN(__FILE__, __LINE__, __FUNCTION__);
519
520 if ((!ee) || (!ee->visible)) return;
521
522 if (ee->engine.wl.win)
523 {
524 ecore_wl_window_hide(ee->engine.wl.win);
525 ecore_wl_flush();
526 }
527
528 einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
529 if (einfo)
530 {
531 einfo->info.surface = NULL;
532 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
533 }
534
535 ee->visible = 0;
536 ee->should_be_visible = 0;
537
538 if (ee->func.fn_hide) ee->func.fn_hide(ee);
539}
540
541static void
542_ecore_evas_wl_raise(Ecore_Evas *ee)
543{
544 LOGFN(__FILE__, __LINE__, __FUNCTION__);
545
546 if ((!ee) || (!ee->visible)) return;
547 ecore_wl_window_raise(ee->engine.wl.win);
548}
549
550static void
551_ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title)
552{
553 LOGFN(__FILE__, __LINE__, __FUNCTION__);
554
555 if (!ee) return;
556 if (ee->prop.title) free(ee->prop.title);
557 ee->prop.title = NULL;
558 if (title) ee->prop.title = strdup(title);
559 if ((ee->prop.draw_frame) && (ee->engine.wl.frame))
560 {
561 EE_Wl_Smart_Data *sd;
562
563 if (!(sd = evas_object_smart_data_get(ee->engine.wl.frame))) return;
564 evas_object_text_text_set(sd->text, ee->prop.title);
565 }
566}
567
568static void
569_ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
570{
571 LOGFN(__FILE__, __LINE__, __FUNCTION__);
572
573 if (!ee) return;
574 if (ee->prop.name) free(ee->prop.name);
575 if (ee->prop.clas) free(ee->prop.clas);
576 ee->prop.name = NULL;
577 ee->prop.clas = NULL;
578 if (n) ee->prop.name = strdup(n);
579 if (c) ee->prop.clas = strdup(c);
580 /* FIXME: Forward these changes to Wayland somehow */
581}
582
583static void
584_ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h)
585{
586 LOGFN(__FILE__, __LINE__, __FUNCTION__);
587
588 if (!ee) return;
589 if (w < 0) w = 0;
590 if (h < 0) h = 0;
591 if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return;
592 ee->prop.min.w = w;
593 ee->prop.min.h = h;
594}
595
596static void
597_ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h)
598{
599 LOGFN(__FILE__, __LINE__, __FUNCTION__);
600
601 if (!ee) return;
602 if (w < 0) w = 0;
603 if (h < 0) h = 0;
604 if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return;
605 ee->prop.max.w = w;
606 ee->prop.max.h = h;
607}
608
609static void
610_ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h)
611{
612 LOGFN(__FILE__, __LINE__, __FUNCTION__);
613
614 if (!ee) return;
615 if (w < 0) w = 0;
616 if (h < 0) h = 0;
617 if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return;
618 ee->prop.base.w = w;
619 ee->prop.base.h = h;
620}
621
622static void
623_ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h)
624{
625 LOGFN(__FILE__, __LINE__, __FUNCTION__);
626
627 if (!ee) return;
628 if (w < 0) w = 0;
629 if (h < 0) h = 0;
630 if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return;
631 ee->prop.step.w = w;
632 ee->prop.step.h = h;
633}
634
635static void
636_ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer)
637{
638 LOGFN(__FILE__, __LINE__, __FUNCTION__);
639
640 if (!ee) return;
641 if (ee->prop.layer == layer) return;
642 if (layer < 1) layer = 1;
643 else if (layer > 255) layer = 255;
644 ee->prop.layer = layer;
645}
646
647static void
648_ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify)
649{
650 LOGFN(__FILE__, __LINE__, __FUNCTION__);
651
652 if (!ee) return;
653 if (ee->prop.iconified == iconify) return;
654 ee->prop.iconified = iconify;
655 /* FIXME: Implement this in Wayland someshow */
656}
657
658static void
659_ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max)
660{
661 LOGFN(__FILE__, __LINE__, __FUNCTION__);
662
663 if (!ee) return;
664 if (ee->prop.maximized == max) return;
665 ee->prop.maximized = max;
666 ecore_wl_window_maximized_set(ee->engine.wl.win, max);
667}
668
669static void
670_ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full)
671{
672 LOGFN(__FILE__, __LINE__, __FUNCTION__);
673
674 if ((!ee) || (!ee->visible)) return;
675 if (ee->prop.fullscreen == full) return;
676 ee->prop.fullscreen = full;
677 ecore_wl_window_fullscreen_set(ee->engine.wl.win, full);
678}
679
680static void
681_ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore)
682{
683 LOGFN(__FILE__, __LINE__, __FUNCTION__);
684
685 if (!ee) return;
686 ee->ignore_events = ignore;
687 /* NB: Hmmm, may need to pass this to ecore_wl_window in the future */
688}
689
690static void
691_ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha)
692{
693 Evas_Engine_Info_Wayland_Egl *einfo;
694
695 LOGFN(__FILE__, __LINE__, __FUNCTION__);
696
697 if (!ee) return;
698 if ((ee->alpha == alpha)) return;
699 ee->alpha = alpha;
700 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
701 {
702 einfo->info.destination_alpha = alpha;
703 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
704 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
705 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
706 }
707}
708
709static void
710_ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent)
711{
712 Evas_Engine_Info_Wayland_Egl *einfo;
713
714 LOGFN(__FILE__, __LINE__, __FUNCTION__);
715
716 if (!ee) return;
717 if ((ee->transparent == transparent)) return;
718 ee->transparent = transparent;
719 if (!ee->visible) return;
720 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
721 {
722 einfo->info.destination_alpha = transparent;
723 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
724 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
725 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
726 }
727}
728
729static int
730_ecore_evas_wl_render(Ecore_Evas *ee)
731{
732 int rend = 0;
733
734 if (!ee) return 0;
735 if (!ee->visible)
736 evas_norender(ee->evas);
737 else
738 {
739 Eina_List *ll = NULL, *updates = NULL;
740 Ecore_Evas *ee2 = NULL;
741
742 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
743
744 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
745 {
746 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
747 if (ee2->engine.func->fn_render)
748 rend |= ee2->engine.func->fn_render(ee2);
749 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
750 }
751
752 if ((updates = evas_render_updates(ee->evas)))
753 {
754 Eina_List *l = NULL;
755 Eina_Rectangle *r;
756
757 LOGFN(__FILE__, __LINE__, __FUNCTION__);
758
759 EINA_LIST_FOREACH(updates, l, r)
760 ecore_wl_window_damage(ee->engine.wl.win,
761 r->x, r->y, r->w, r->h);
762
763 ecore_wl_flush();
764
765 evas_render_updates_free(updates);
766 _ecore_evas_idle_timeout_update(ee);
767 rend = 1;
768 }
769
770 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
771 }
772 return rend;
773}
774
775static void
776_ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h)
777{
778 LOGFN(__FILE__, __LINE__, __FUNCTION__);
779
780 if (x) *x = 0;
781 if (y) *y = 0;
782 ecore_wl_screen_size_get(w, h);
783}
784
785void
786_ecore_evas_wayland_egl_resize(Ecore_Evas *ee, int location)
787{
788 LOGFN(__FILE__, __LINE__, __FUNCTION__);
789
790 if (!ee) return;
791 if (ee->engine.wl.win)
792 ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location);
793}
794
795static Eina_Bool
796_ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
797{
798 Ecore_Evas *ee;
799 Ecore_Wl_Event_Mouse_In *ev;
800
801 LOGFN(__FILE__, __LINE__, __FUNCTION__);
802
803 ev = event;
804 ee = ecore_event_window_match(ev->win);
805 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
806 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
807 if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
808 ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
809 evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL);
810 _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
811 return ECORE_CALLBACK_PASS_ON;
812}
813
814static Eina_Bool
815_ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
816{
817 Ecore_Evas *ee;
818 Ecore_Wl_Event_Mouse_Out *ev;
819
820 LOGFN(__FILE__, __LINE__, __FUNCTION__);
821
822 ev = event;
823 ee = ecore_event_window_match(ev->win);
824 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
825 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
826 ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
827 _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
828 evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL);
829 if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
830 if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
831 return ECORE_CALLBACK_PASS_ON;
832}
833
834static Eina_Bool
835_ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
836{
837 Ecore_Evas *ee;
838 Ecore_Wl_Event_Focus_In *ev;
839
840 LOGFN(__FILE__, __LINE__, __FUNCTION__);
841
842 ev = event;
843 ee = ecore_event_window_match(ev->win);
844 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
845 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
846 ee->prop.focused = 1;
847 evas_focus_in(ee->evas);
848 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
849 return ECORE_CALLBACK_PASS_ON;
850}
851
852static Eina_Bool
853_ecore_evas_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event)
854{
855 Ecore_Evas *ee;
856 Ecore_Wl_Event_Focus_In *ev;
857
858 LOGFN(__FILE__, __LINE__, __FUNCTION__);
859
860 ev = event;
861 ee = ecore_event_window_match(ev->win);
862 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
863 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
864 evas_focus_out(ee->evas);
865 ee->prop.focused = 0;
866 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
867 return ECORE_CALLBACK_PASS_ON;
868}
869
870static Eina_Bool
871_ecore_evas_wl_cb_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event)
872{
873 Ecore_Evas *ee;
874 Ecore_Wl_Event_Window_Configure *ev;
875
876 LOGFN(__FILE__, __LINE__, __FUNCTION__);
877
878 ev = event;
879 ee = ecore_event_window_match(ev->win);
880 if (!ee) return ECORE_CALLBACK_PASS_ON;
881 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
882 if ((ee->x != ev->x) || (ee->y != ev->y))
883 {
884 ee->x = ev->x;
885 ee->y = ev->y;
886 ee->req.x = ee->x;
887 ee->req.y = ee->y;
888 if (ee->func.fn_move) ee->func.fn_move(ee);
889 }
890 if ((ee->req.w != ev->w) || (ee->req.h != ev->h))
891 {
892 ee->req.w = ev->w;
893 ee->req.h = ev->h;
894 if (ee->func.fn_resize) ee->func.fn_resize(ee);
895 }
896
897 return ECORE_CALLBACK_PASS_ON;
898}
899
900static void
901_ecore_evas_wl_smart_init(void)
902{
903 if (_ecore_evas_wl_smart) return;
904 {
905 static const Evas_Smart_Class sc =
906 {
907 "ecore_evas_wl_frame", EVAS_SMART_CLASS_VERSION,
908 _ecore_evas_wl_smart_add,
909 _ecore_evas_wl_smart_del,
910 NULL,
911 _ecore_evas_wl_smart_resize,
912 _ecore_evas_wl_smart_show,
913 _ecore_evas_wl_smart_hide,
914 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
915 };
916 _ecore_evas_wl_smart = evas_smart_class_new(&sc);
917 }
918}
919
920static void
921_ecore_evas_wl_smart_add(Evas_Object *obj)
922{
923 EE_Wl_Smart_Data *sd;
924 Evas *evas;
925
926 LOGFN(__FILE__, __LINE__, __FUNCTION__);
927
928 if (!(sd = calloc(1, sizeof(EE_Wl_Smart_Data)))) return;
929
930 evas = evas_object_evas_get(obj);
931
932 sd->x = 0;
933 sd->y = 0;
934 sd->w = 1;
935 sd->h = 1;
936
937 sd->frame = evas_object_rectangle_add(evas);
938 evas_object_is_frame_object_set(sd->frame, EINA_TRUE);
939 evas_object_color_set(sd->frame, 249, 249, 249, 255);
940 evas_object_smart_member_add(sd->frame, obj);
941
942 sd->text = evas_object_text_add(evas);
943 evas_object_color_set(sd->text, 0, 0, 0, 255);
944 evas_object_text_style_set(sd->text, EVAS_TEXT_STYLE_PLAIN);
945 evas_object_text_font_set(sd->text, "Sans", 10);
946 evas_object_text_text_set(sd->text, "Smart Test");
947
948 evas_object_smart_data_set(obj, sd);
949}
950
951static void
952_ecore_evas_wl_smart_del(Evas_Object *obj)
953{
954 EE_Wl_Smart_Data *sd;
955
956 LOGFN(__FILE__, __LINE__, __FUNCTION__);
957
958 if (!(sd = evas_object_smart_data_get(obj))) return;
959 evas_object_del(sd->text);
960 evas_object_del(sd->frame);
961 free(sd);
962}
963
964static void
965_ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
966{
967 EE_Wl_Smart_Data *sd;
968
969 LOGFN(__FILE__, __LINE__, __FUNCTION__);
970
971 if (!(sd = evas_object_smart_data_get(obj))) return;
972 if ((sd->w == w) && (sd->h == h)) return;
973 sd->w = w;
974 sd->h = h;
975 evas_object_resize(sd->frame, w, h);
976}
977
978static void
979_ecore_evas_wl_smart_show(Evas_Object *obj)
980{
981 EE_Wl_Smart_Data *sd;
982
983 LOGFN(__FILE__, __LINE__, __FUNCTION__);
984
985 if (!(sd = evas_object_smart_data_get(obj))) return;
986 evas_object_show(sd->frame);
987 evas_object_show(sd->text);
988}
989
990static void
991_ecore_evas_wl_smart_hide(Evas_Object *obj)
992{
993 EE_Wl_Smart_Data *sd;
994
995 LOGFN(__FILE__, __LINE__, __FUNCTION__);
996
997 if (!(sd = evas_object_smart_data_get(obj))) return;
998 evas_object_hide(sd->text);
999 evas_object_hide(sd->frame);
1000}
1001
1002static Evas_Object *
1003_ecore_evas_wl_frame_add(Evas *evas)
1004{
1005 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1006
1007 _ecore_evas_wl_smart_init();
1008 return evas_object_smart_add(evas, _ecore_evas_wl_smart);
1009}
1010
1011#else
1012EAPI Ecore_Evas *
1013ecore_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__)
1014{
1015 return NULL;
1016}
1017#endif