Ecore_Evas (wayland): Do not set the shell_surface_listeners until
[profile/ivi/ecore.git] / src / lib / ecore_evas / ecore_evas_wayland_shm.c
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_SHM
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_SHM
31 # include <Evas_Engine_Wayland_Shm.h>
32 # include <Ecore_Wayland.h>
33
34 /* local structures */
35 typedef struct _EE_Wl_Smart_Data EE_Wl_Smart_Data;
36 struct _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 */
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_move(Ecore_Evas *ee, int x, int y);
55 static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
56 static void _ecore_evas_wl_show(Ecore_Evas *ee);
57 static void _ecore_evas_wl_hide(Ecore_Evas *ee);
58 static void _ecore_evas_wl_raise(Ecore_Evas *ee);
59 static void _ecore_evas_wl_lower(Ecore_Evas *ee);
60 static void _ecore_evas_wl_activate(Ecore_Evas *ee);
61 static void _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *t);
62 static void _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c);
63 static void _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h);
64 static void _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h);
65 static void _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h);
66 static void _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h);
67 static void _ecore_evas_wl_object_cursor_set(Ecore_Evas *ee, Evas_Object  *obj, int layer, int hot_x, int hot_y);
68 static void _ecore_evas_wl_object_cursor_del(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__);
69 static void _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer);
70 static void _ecore_evas_wl_focus_set(Ecore_Evas *ee, int focus __UNUSED__);
71 static void _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify);
72 static void _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max);
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);
75 static void _ecore_evas_wl_buffer_new(Ecore_Evas *ee, void **dest);
76
77 static Eina_Bool _ecore_evas_wl_event_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event);
78 static Eina_Bool _ecore_evas_wl_event_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event);
79 static Eina_Bool _ecore_evas_wl_event_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event);
80 static Eina_Bool _ecore_evas_wl_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event);
81 static Eina_Bool _ecore_evas_wl_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event);
82 static Eina_Bool _ecore_evas_wl_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event);
83 static Eina_Bool _ecore_evas_wl_event_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
84 static Eina_Bool _ecore_evas_wl_event_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event);
85
86 static void _ecore_evas_wl_handle_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, uint32_t timestamp __UNUSED__, uint32_t edges __UNUSED__, int32_t width, int32_t height);
87 static void _ecore_evas_wl_handle_popup_done(void *data __UNUSED__, struct wl_shell_surface *shell_surface __UNUSED__);
88
89 /* SMART stuff for frame */
90 static Evas_Smart *_ecore_evas_wl_smart = NULL;
91
92 static void _ecore_evas_wl_smart_init(void);
93 static void _ecore_evas_wl_smart_add(Evas_Object *obj);
94 static void _ecore_evas_wl_smart_del(Evas_Object *obj);
95 static void _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
96 static void _ecore_evas_wl_smart_show(Evas_Object *obj);
97 static void _ecore_evas_wl_smart_hide(Evas_Object *obj);
98
99 static Evas_Object *_ecore_evas_wl_frame_add(Evas *evas);
100
101 /* local variables */
102 static int _ecore_evas_wl_init_count = 0;
103 static Ecore_Event_Handler *_ecore_evas_wl_event_handlers[8];
104 static uint32_t _ecore_evas_wl_btn_timestamp;
105 static const struct wl_shell_surface_listener _ecore_evas_wl_shell_surface_listener = 
106 {
107    _ecore_evas_wl_handle_configure,
108    _ecore_evas_wl_handle_popup_done
109 };
110
111 static Ecore_Evas_Engine_Func _ecore_wl_engine_func = 
112 {
113    _ecore_evas_wl_free, 
114    _ecore_evas_wl_callback_resize_set, 
115    _ecore_evas_wl_callback_move_set, 
116    NULL, // callback show set
117    NULL, // callback hide set
118    _ecore_evas_wl_callback_delete_request_set, 
119    NULL, // callback destroy set
120    _ecore_evas_wl_callback_focus_in_set, 
121    _ecore_evas_wl_callback_focus_out_set, 
122    _ecore_evas_wl_callback_mouse_in_set, 
123    NULL, // callback mouse out set
124    NULL, // callback sticky set
125    NULL, // callback unsticky set
126    NULL, // callback pre render set
127    NULL, // callback post render set
128    _ecore_evas_wl_move, 
129    NULL, // func managed move
130    _ecore_evas_wl_resize, 
131    NULL, // func move_resize
132    NULL, // func rotation set
133    NULL, // func shaped set
134    _ecore_evas_wl_show, 
135    _ecore_evas_wl_hide, 
136    _ecore_evas_wl_raise, 
137    _ecore_evas_wl_lower, 
138    _ecore_evas_wl_activate, 
139    _ecore_evas_wl_title_set, 
140    _ecore_evas_wl_name_class_set, 
141    _ecore_evas_wl_size_min_set, 
142    _ecore_evas_wl_size_max_set, 
143    _ecore_evas_wl_size_base_set, 
144    _ecore_evas_wl_size_step_set, 
145    _ecore_evas_wl_object_cursor_set, 
146    _ecore_evas_wl_layer_set, 
147    _ecore_evas_wl_focus_set, 
148    _ecore_evas_wl_iconified_set, 
149    NULL, // func borderless set
150    NULL, // func override set
151    _ecore_evas_wl_maximized_set, 
152    NULL, // func fullscreen set
153    NULL, // func avoid_damage set
154    NULL, // func withdrawn set
155    NULL, // func sticky set
156    NULL, // func ignore_events set
157    NULL, // func alpha set
158    NULL, // func transparent set
159    _ecore_evas_wl_render, 
160    _ecore_evas_wl_screen_geometry_get
161 };
162
163 /* external variables */
164 #endif
165
166 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
167 EAPI Ecore_Evas *
168 ecore_evas_wayland_shm_new(const char *disp_name, int x, int y, int w, int h, int frame)
169 {
170    Evas_Engine_Info_Wayland_Shm *einfo;
171    Ecore_Evas *ee;
172    int method = 0;
173    static int _win_id = 1;
174
175    LOGFN(__FILE__, __LINE__, __FUNCTION__);
176
177    if (!(method = evas_render_method_lookup("wayland_shm"))) 
178      {
179         ERR("Render method lookup failed.");
180         return NULL;
181      }
182
183    if (!(ecore_wl_init(disp_name))) 
184      {
185         ERR("Failed to initialize Ecore Wayland.");
186         return NULL;
187      }
188
189    if (!(ee = calloc(1, sizeof(Ecore_Evas)))) 
190      {
191         ERR("Failed to allocate Ecore_Evas.");
192         ecore_wl_shutdown();
193         return NULL;
194      }
195
196    ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
197
198    _ecore_evas_wl_init();
199
200    ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_wl_engine_func;
201
202    ee->driver = "wayland_shm";
203    if (disp_name) ee->name = strdup(disp_name);
204
205    if (w < 1) w = 1;
206    if (h < 1) h = 1;
207
208    ee->req.x = ee->x = x;
209    ee->req.y = ee->y = y;
210    ee->req.w = ee->w = w;
211    ee->req.h = ee->h = h;
212    ee->rotation = 0;
213    ee->prop.max.w = ee->prop.max.h = 32767;
214    ee->prop.layer = 4;
215    ee->prop.request_pos = 0;
216    ee->prop.sticky = 0;
217    ee->prop.draw_frame = frame;
218    ee->prop.window = _win_id++;
219
220    ee->evas = evas_new();
221    evas_data_attach_set(ee->evas, ee);
222    evas_output_method_set(ee->evas, method);
223    evas_output_size_set(ee->evas, ee->w, ee->h);
224    evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
225
226    if (ee->prop.draw_frame) 
227      evas_output_framespace_set(ee->evas, 4, 18, 8, 22);
228
229    if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) 
230      {
231         einfo->info.rotation = ee->rotation;
232         einfo->info.debug = EINA_FALSE;
233         if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) 
234           {
235              ERR("Failed to set Evas Engine Info for '%s'.", ee->driver);
236              ecore_evas_free(ee);
237              return NULL;
238           }
239      }
240    else 
241      {
242         ERR("Failed to get Evas Engine Info for '%s'.", ee->driver);
243         ecore_evas_free(ee);
244         return NULL;
245      }
246
247    /* NB: we need to be notified before 'free' so we can munmap the evas 
248     * engine destination */
249    ecore_evas_callback_pre_free_set(ee, _ecore_evas_wl_pre_free);
250
251    if (ee->prop.draw_frame) 
252      {
253         ee->engine.wl.frame = _ecore_evas_wl_frame_add(ee->evas);
254         evas_object_is_frame_object_set(ee->engine.wl.frame, EINA_TRUE);
255         evas_object_move(ee->engine.wl.frame, 0, 0);
256      }
257
258    ecore_evas_input_event_register(ee);
259    _ecore_evas_register(ee);
260
261    ecore_event_window_register(ee->prop.window, ee, ee->evas, 
262                                (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process, 
263                                (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process, 
264                                (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process, 
265                                (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
266
267    evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
268
269    return ee;
270 }
271
272 /* local functions */
273 static int 
274 _ecore_evas_wl_init(void)
275 {
276    LOGFN(__FILE__, __LINE__, __FUNCTION__);
277
278    if (++_ecore_evas_wl_init_count != 1)
279      return _ecore_evas_wl_init_count;
280
281    _ecore_evas_wl_event_handlers[0] = 
282      ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, 
283                              _ecore_evas_wl_event_mouse_down, NULL);
284    _ecore_evas_wl_event_handlers[1] = 
285      ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, 
286                              _ecore_evas_wl_event_mouse_up, NULL);
287    _ecore_evas_wl_event_handlers[2] = 
288      ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, 
289                              _ecore_evas_wl_event_mouse_move, NULL);
290    _ecore_evas_wl_event_handlers[3] = 
291      ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, 
292                              _ecore_evas_wl_event_mouse_wheel, NULL);
293    _ecore_evas_wl_event_handlers[4] = 
294      ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_IN, 
295                              _ecore_evas_wl_event_mouse_in, NULL);
296    _ecore_evas_wl_event_handlers[5] = 
297      ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT, 
298                              _ecore_evas_wl_event_mouse_out, NULL);
299    _ecore_evas_wl_event_handlers[6] = 
300      ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, 
301                              _ecore_evas_wl_event_focus_in, NULL);
302    _ecore_evas_wl_event_handlers[7] = 
303      ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, 
304                              _ecore_evas_wl_event_focus_out, NULL);
305
306    ecore_event_evas_init();
307
308    return _ecore_evas_wl_init_count;
309 }
310
311 static int 
312 _ecore_evas_wl_shutdown(void)
313 {
314    unsigned int i = 0;
315
316    LOGFN(__FILE__, __LINE__, __FUNCTION__);
317
318    if (--_ecore_evas_wl_init_count != 0)
319      return _ecore_evas_wl_init_count;
320
321    for (i = 0; i < sizeof(_ecore_evas_wl_event_handlers) / sizeof(Ecore_Event_Handler *); i++) 
322      {
323         if (_ecore_evas_wl_event_handlers[i])
324           ecore_event_handler_del(_ecore_evas_wl_event_handlers[i]);
325      }
326
327    ecore_event_evas_shutdown();
328
329    return _ecore_evas_wl_init_count;
330 }
331
332 static void 
333 _ecore_evas_wl_pre_free(Ecore_Evas *ee)
334 {
335    Evas_Engine_Info_Wayland_Shm *einfo;
336
337    LOGFN(__FILE__, __LINE__, __FUNCTION__);
338
339    /* destroy frame */
340    if (ee->engine.wl.frame) evas_object_del(ee->engine.wl.frame);
341
342    /* get engine info */
343    einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
344    if ((einfo) && (einfo->info.dest))
345      {
346         int ret = 0;
347
348         /* munmap previous engine destination */
349         ret = munmap(einfo->info.dest, ((ee->w * sizeof(int)) * ee->h));
350      }
351 }
352
353 static void 
354 _ecore_evas_wl_free(Ecore_Evas *ee)
355 {
356    LOGFN(__FILE__, __LINE__, __FUNCTION__);
357
358    /* destroy buffer */
359    if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer);
360    ee->engine.wl.buffer = NULL;
361
362    /* destroy shell surface */
363    if (ee->engine.wl.shell_surface)
364      wl_shell_surface_destroy(ee->engine.wl.shell_surface);
365    ee->engine.wl.shell_surface = NULL;
366
367    /* destroy surface */
368    if (ee->engine.wl.surface) wl_surface_destroy(ee->engine.wl.surface);
369    ee->engine.wl.surface = NULL;
370
371    ecore_event_window_unregister(ee->prop.window);
372    ecore_evas_input_event_unregister(ee);
373
374    _ecore_evas_wl_shutdown();
375    ecore_wl_shutdown();
376 }
377
378 static void 
379 _ecore_evas_wl_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
380 {
381    LOGFN(__FILE__, __LINE__, __FUNCTION__);
382
383    if (!ee) return;
384    ee->func.fn_resize = func;
385 }
386
387 static void 
388 _ecore_evas_wl_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
389 {
390    LOGFN(__FILE__, __LINE__, __FUNCTION__);
391
392    if (!ee) return;
393    ee->func.fn_move = func;
394 }
395
396 static void 
397 _ecore_evas_wl_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
398 {
399    LOGFN(__FILE__, __LINE__, __FUNCTION__);
400
401    if (!ee) return;
402    ee->func.fn_delete_request = func;
403 }
404
405 static void 
406 _ecore_evas_wl_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
407 {
408    LOGFN(__FILE__, __LINE__, __FUNCTION__);
409
410    if (!ee) return;
411    ee->func.fn_focus_in = func;
412 }
413
414 static void 
415 _ecore_evas_wl_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
416 {
417    LOGFN(__FILE__, __LINE__, __FUNCTION__);
418
419    if (!ee) return;
420    ee->func.fn_focus_out = func;
421 }
422
423 static void 
424 _ecore_evas_wl_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee))
425 {
426    LOGFN(__FILE__, __LINE__, __FUNCTION__);
427
428    if (!ee) return;
429    ee->func.fn_mouse_in = func;
430 }
431
432 static void 
433 _ecore_evas_wl_move(Ecore_Evas *ee, int x, int y) 
434 {
435    LOGFN(__FILE__, __LINE__, __FUNCTION__);
436
437    if (!ee) return;
438 //   if ((ee->x == x) && (ee->y == y)) return;
439    ee->req.x = x;
440    ee->req.y = y;
441
442    ee->x = x;
443    ee->y = y;
444
445    if (ee->engine.wl.shell_surface)
446      {
447         wl_shell_surface_move(ee->engine.wl.shell_surface, 
448                               ecore_wl_input_device_get(), 
449                               _ecore_evas_wl_btn_timestamp);
450      }
451
452    if (ee->func.fn_move) ee->func.fn_move(ee);
453 }
454
455 static void 
456 _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
457 {
458    Evas_Engine_Info_Wayland_Shm *einfo;
459
460    LOGFN(__FILE__, __LINE__, __FUNCTION__);
461
462    if (!ee) return;
463    if (w < 1) w = 1;
464    if (h < 1) h = 1;
465    if ((ee->w == w) && (ee->h == h)) return;
466
467    ee->req.w = w;
468    ee->req.h = h;
469
470    if (ee->visible) 
471      {
472         /* damage old surface, if it exists */
473
474         /* NB: This removes any lingering screen artifacts in the compositor.
475          * This may be a 'HACK' if the issue is actually in the wayland 
476          * compositor, but for now lets implement this so we don't have screen 
477          * artifacts laying around during a resize */
478         if (ee->engine.wl.surface)
479           wl_surface_damage(ee->engine.wl.surface, 0, 0, ee->w, ee->h);
480      }
481
482    /* get engine info */
483    einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
484    if (einfo->info.dest)
485      {
486         int ret = 0;
487
488         /* munmap previous engine destination */
489         ret = munmap(einfo->info.dest, ((ee->w * sizeof(int)) * ee->h));
490      }
491
492    /* free old buffer */
493    if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer);
494    ee->engine.wl.buffer = NULL;
495
496    ee->w = w;
497    ee->h = h;
498
499    /* create buffer @ new size (also mmaps the new destination) */
500    _ecore_evas_wl_buffer_new(ee, &einfo->info.dest);
501
502    /* flush new buffer fd */
503    ecore_wl_flush();
504
505    /* change evas output & viewport sizes */
506    evas_output_size_set(ee->evas, ee->w, ee->h);
507    evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
508    evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
509    if (ee->engine.wl.frame)
510      evas_object_resize(ee->engine.wl.frame, ee->w, ee->h);
511
512    /* set new engine destination */
513    evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
514
515    /* damage buffer */
516    wl_buffer_damage(ee->engine.wl.buffer, 0, 0, ee->w, ee->h);
517
518    if (ee->visible) 
519      {
520         /* damage surface */
521         wl_surface_damage(ee->engine.wl.surface, 0, 0, ee->w, ee->h);
522
523         /* if visible, attach to surface */
524         wl_surface_attach(ee->engine.wl.surface, ee->engine.wl.buffer, 0, 0);
525      }
526
527    if (ee->func.fn_resize) ee->func.fn_resize(ee);
528 }
529
530 static void 
531 _ecore_evas_wl_show(Ecore_Evas *ee)
532 {
533    Evas_Engine_Info_Wayland_Shm *einfo;
534
535    LOGFN(__FILE__, __LINE__, __FUNCTION__);
536
537    if (!ee) return;
538    if (ee->visible) return;
539
540    /* get engine info */
541    einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
542
543    /* create new surface */
544    ee->engine.wl.surface = 
545      wl_compositor_create_surface(ecore_wl_compositor_get());
546    wl_surface_set_user_data(ee->engine.wl.surface, (void *)ee->prop.window);
547
548    /* get new shell surface */
549    ee->engine.wl.shell_surface = 
550      wl_shell_get_shell_surface(ecore_wl_shell_get(), ee->engine.wl.surface);
551
552    /* set toplevel */
553    wl_shell_surface_set_toplevel(ee->engine.wl.shell_surface);
554
555    /* create buffer @ new size (also mmaps the new destination) */
556    _ecore_evas_wl_buffer_new(ee, &einfo->info.dest);
557
558    if (ee->engine.wl.frame) 
559      {
560         evas_object_show(ee->engine.wl.frame);
561         evas_object_resize(ee->engine.wl.frame, ee->w, ee->h);
562      }
563
564    /* set new engine destination */
565    evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
566
567    /* add configure listener for wayland resize events */
568    wl_shell_surface_add_listener(ee->engine.wl.shell_surface, 
569                                  &_ecore_evas_wl_shell_surface_listener, ee);
570
571    /* flush new buffer fd */
572    ecore_wl_flush();
573
574    /* attach buffer to surface */
575    wl_surface_attach(ee->engine.wl.surface, ee->engine.wl.buffer, 0, 0);
576
577    /* NB: No need to do a damage here. If we do, we end up w/ screen 
578     * artifacts in the compositor */
579    /* wl_surface_damage(ee->engine.wl.surface, 0, 0, ee->w, ee->h); */
580
581    ee->visible = 1;
582    if (ee->func.fn_show) ee->func.fn_show(ee);
583 }
584
585 static void 
586 _ecore_evas_wl_hide(Ecore_Evas *ee) 
587 {
588    Evas_Engine_Info_Wayland_Shm *einfo;
589
590    LOGFN(__FILE__, __LINE__, __FUNCTION__);
591
592    if (!ee) return;
593    if (!ee->visible) return;
594
595    /* get engine info */
596    einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
597    if (einfo->info.dest)
598      {
599         int ret = 0;
600
601         /* munmap previous engine destination */
602         ret = munmap(einfo->info.dest, ((ee->w * sizeof(int)) * ee->h));
603         einfo->info.dest = NULL;
604      }
605
606    /* free old buffer */
607    if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer);
608    ee->engine.wl.buffer = NULL;
609
610    /* set new engine destination */
611    evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
612
613    /* destroy shell surface */
614    if (ee->engine.wl.shell_surface) 
615      wl_shell_surface_destroy(ee->engine.wl.shell_surface);
616    ee->engine.wl.shell_surface = NULL;
617
618    /* destroy surface */
619    if (ee->engine.wl.surface) wl_surface_destroy(ee->engine.wl.surface);
620    ee->engine.wl.surface = NULL;
621
622    ee->visible = 0;
623    ee->should_be_visible = 0;
624    if (ee->func.fn_hide) ee->func.fn_hide(ee);
625 }
626
627 static void 
628 _ecore_evas_wl_raise(Ecore_Evas *ee)
629 {
630    LOGFN(__FILE__, __LINE__, __FUNCTION__);
631
632    if ((!ee) || (!ee->visible)) return;
633    if (!ee->engine.wl.shell_surface) return;
634    wl_shell_surface_set_toplevel(ee->engine.wl.shell_surface);
635 }
636
637 static void 
638 _ecore_evas_wl_lower(Ecore_Evas *ee)
639 {
640    LOGFN(__FILE__, __LINE__, __FUNCTION__);
641
642    if ((!ee) || (!ee->visible)) return;
643    /* FIXME: Need a way to tell Wayland to lower */
644 }
645
646 static void 
647 _ecore_evas_wl_activate(Ecore_Evas *ee)
648 {
649    LOGFN(__FILE__, __LINE__, __FUNCTION__);
650
651    if ((!ee) || (!ee->visible)) return;
652    if (!ee->engine.wl.shell_surface) return;
653    wl_shell_surface_set_toplevel(ee->engine.wl.shell_surface);
654 }
655
656 static void 
657 _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *t) 
658 {
659    LOGFN(__FILE__, __LINE__, __FUNCTION__);
660
661    if (!ee) return;
662    if (ee->prop.title) free(ee->prop.title);
663    ee->prop.title = NULL;
664    if (t) ee->prop.title = strdup(t);
665
666    if ((ee->prop.draw_frame) && (ee->engine.wl.frame)) 
667      {
668         EE_Wl_Smart_Data *sd;
669
670         if (!(sd = evas_object_smart_data_get(ee->engine.wl.frame))) return;
671         evas_object_text_text_set(sd->text, ee->prop.title);
672      }
673 }
674
675 static void 
676 _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c) 
677 {
678    LOGFN(__FILE__, __LINE__, __FUNCTION__);
679
680    if (!ee) return;
681    if (ee->prop.name) free(ee->prop.name);
682    if (ee->prop.clas) free(ee->prop.clas);
683    ee->prop.name = NULL;
684    ee->prop.clas = NULL;
685    if (n) ee->prop.name = strdup(n);
686    if (c) ee->prop.clas = strdup(c);
687    /* FIXME: Forward these changes to Wayland somehow */
688 }
689
690 static void 
691 _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h) 
692 {
693    LOGFN(__FILE__, __LINE__, __FUNCTION__);
694
695    if (!ee) return;
696    if (w < 0) w = 0;
697    if (h < 0) h = 0;
698    if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return;
699    ee->prop.min.w = w;
700    ee->prop.min.h = h;
701 }
702
703 static void 
704 _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h) 
705 {
706    LOGFN(__FILE__, __LINE__, __FUNCTION__);
707
708    if (!ee) return;
709    if (w < 0) w = 0;
710    if (h < 0) h = 0;
711    if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return;
712    ee->prop.max.w = w;
713    ee->prop.max.h = h;
714 }
715
716 static void 
717 _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h) 
718 {
719    LOGFN(__FILE__, __LINE__, __FUNCTION__);
720
721    if (!ee) return;
722    if (w < 0) w = 0;
723    if (h < 0) h = 0;
724    if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return;
725    ee->prop.base.w = w;
726    ee->prop.base.h = h;
727 }
728
729 static void 
730 _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h) 
731 {
732    LOGFN(__FILE__, __LINE__, __FUNCTION__);
733
734    if (!ee) return;
735    if (w < 0) w = 0;
736    if (h < 0) h = 0;
737    if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return;
738    ee->prop.step.w = w;
739    ee->prop.step.h = h;
740 }
741
742 static void 
743 _ecore_evas_wl_object_cursor_set(Ecore_Evas *ee, Evas_Object  *obj, int layer, int hot_x, int hot_y) 
744 {
745    int x = 0, y = 0;
746
747    LOGFN(__FILE__, __LINE__, __FUNCTION__);
748
749    if (!ee) return;
750    if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
751    ee->prop.cursor.object = NULL;
752
753    if (!obj) 
754      {
755         ee->prop.cursor.layer = 0;
756         ee->prop.cursor.hot.x = 0;
757         ee->prop.cursor.hot.y = 0;
758         return;
759      }
760
761    ee->prop.cursor.object = obj;
762    ee->prop.cursor.layer = layer;
763    ee->prop.cursor.hot.x = hot_x;
764    ee->prop.cursor.hot.y = hot_y;
765
766    evas_pointer_output_xy_get(ee->evas, &x, &y);
767    evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
768    evas_object_move(ee->prop.cursor.object, 
769                     x - ee->prop.cursor.hot.x, y - ee->prop.cursor.hot.y);
770    evas_object_pass_events_set(ee->prop.cursor.object, 1);
771    if (evas_pointer_inside_get(ee->evas))
772      evas_object_show(ee->prop.cursor.object);
773
774    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
775                                   _ecore_evas_wl_object_cursor_del, ee);
776 }
777
778 static void 
779 _ecore_evas_wl_object_cursor_del(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) 
780 {
781    Ecore_Evas *ee;
782
783    if (!(ee = data)) return;
784    ee->prop.cursor.object = NULL;
785 }
786
787 static void 
788 _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer)
789 {
790    LOGFN(__FILE__, __LINE__, __FUNCTION__);
791
792    if (!ee) return;
793    if (ee->prop.layer == layer) return;
794    if (layer < 1) layer = 1;
795    else if (layer > 255) layer = 255;
796    ee->prop.layer = layer;
797 }
798
799 static void 
800 _ecore_evas_wl_focus_set(Ecore_Evas *ee, int focus __UNUSED__)
801 {
802    LOGFN(__FILE__, __LINE__, __FUNCTION__);
803
804    if ((!ee) || (!ee->visible)) return;
805    if (!ee->engine.wl.shell_surface) return;
806    wl_shell_surface_set_toplevel(ee->engine.wl.shell_surface);
807 }
808
809 static void 
810 _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify)
811 {
812    LOGFN(__FILE__, __LINE__, __FUNCTION__);
813
814    if (!ee) return;
815    if (ee->prop.iconified == iconify) return;
816    ee->prop.iconified = iconify;
817    /* FIXME: Implement this in Wayland someshow */
818 }
819
820 static void 
821 _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max)
822 {
823    LOGFN(__FILE__, __LINE__, __FUNCTION__);
824
825    if (!ee) return;
826    if (ee->prop.maximized == max) return;
827    ee->prop.maximized = max;
828    /* FIXME: Implement this in Wayland someshow */
829 }
830
831 static int 
832 _ecore_evas_wl_render(Ecore_Evas *ee)
833 {
834    int rend = 0;
835
836    if (!ee) return 0;
837    if (!ee->visible) 
838      evas_norender(ee->evas);
839    else 
840      {
841         Eina_List *ll = NULL, *updates = NULL;
842         Ecore_Evas *ee2 = NULL;
843
844         if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
845
846         EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) 
847           {
848              if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
849              if (ee2->engine.func->fn_render)
850                rend |= ee2->engine.func->fn_render(ee2);
851              if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
852           }
853
854         if ((updates = evas_render_updates(ee->evas))) 
855           {
856              Eina_List *l = NULL;
857              Eina_Rectangle *r;
858
859              EINA_LIST_FOREACH(updates, l, r) 
860                {
861                   if (ee->engine.wl.buffer)
862                     wl_buffer_damage(ee->engine.wl.buffer, 
863                                      r->x, r->y, r->w, r->h);
864
865                   if (ee->engine.wl.surface)
866                     wl_surface_damage(ee->engine.wl.surface, 
867                                       r->x, r->y, r->w, r->h);
868                }
869
870              evas_render_updates_free(updates);
871              _ecore_evas_idle_timeout_update(ee);
872              rend = 1;
873
874              ecore_wl_flush();
875           }
876
877         if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
878      }
879
880    return rend;
881 }
882
883 static void 
884 _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h)
885 {
886    LOGFN(__FILE__, __LINE__, __FUNCTION__);
887
888    if (x) *x = 0;
889    if (y) *y = 0;
890    ecore_wl_screen_size_get(w, h);
891 }
892
893 static Eina_Bool 
894 _ecore_evas_wl_event_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event)
895 {
896    Ecore_Evas *ee;
897    Ecore_Event_Mouse_Button *ev;
898
899    LOGFN(__FILE__, __LINE__, __FUNCTION__);
900
901    ev = event;
902    _ecore_evas_wl_btn_timestamp = ev->timestamp;
903    ee = ecore_event_window_match(ev->window);
904    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
905    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
906    evas_event_feed_mouse_down(ee->evas, ev->buttons, ev->modifiers, 
907                               ev->timestamp, NULL);
908    return ECORE_CALLBACK_PASS_ON;
909 }
910
911 static Eina_Bool 
912 _ecore_evas_wl_event_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event)
913 {
914    Ecore_Evas *ee;
915    Ecore_Event_Mouse_Button *ev;
916
917    LOGFN(__FILE__, __LINE__, __FUNCTION__);
918
919    ev = event;
920    ee = ecore_event_window_match(ev->window);
921    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
922    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
923    evas_event_feed_mouse_up(ee->evas, ev->buttons, ev->modifiers, 
924                             ev->timestamp, NULL);
925    return ECORE_CALLBACK_PASS_ON;
926 }
927
928 static Eina_Bool 
929 _ecore_evas_wl_event_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
930 {
931    Ecore_Evas *ee;
932    Ecore_Event_Mouse_Move *ev;
933
934    ev = event;
935    ee = ecore_event_window_match(ev->window);
936    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
937    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
938    ee->mouse.x = ev->x;
939    ee->mouse.y = ev->y;
940    evas_event_feed_mouse_move(ee->evas, ev->x, ev->y, ev->timestamp, NULL);
941    _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
942    return ECORE_CALLBACK_PASS_ON;
943 }
944
945 static Eina_Bool 
946 _ecore_evas_wl_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
947 {
948    Ecore_Evas *ee;
949    Ecore_Event_Mouse_Wheel *ev;
950
951    LOGFN(__FILE__, __LINE__, __FUNCTION__);
952
953    ev = event;
954    ee = ecore_event_window_match(ev->window);
955    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
956    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
957    evas_event_feed_mouse_wheel(ee->evas, ev->direction, ev->z, 
958                                ev->timestamp, NULL);
959    return ECORE_CALLBACK_PASS_ON;
960 }
961
962 static Eina_Bool 
963 _ecore_evas_wl_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
964 {
965    Ecore_Evas *ee;
966    Ecore_Wl_Event_Mouse_In *ev;
967
968    LOGFN(__FILE__, __LINE__, __FUNCTION__);
969
970    ev = event;
971    ee = ecore_event_window_match(ev->window);
972    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
973    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
974    if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
975    ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
976    evas_event_feed_mouse_in(ee->evas, ev->time, NULL);
977    _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->time);
978    return ECORE_CALLBACK_PASS_ON;
979 }
980
981 static Eina_Bool 
982 _ecore_evas_wl_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
983 {
984    Ecore_Evas *ee;
985    Ecore_Wl_Event_Mouse_Out *ev;
986
987    LOGFN(__FILE__, __LINE__, __FUNCTION__);
988
989    ev = event;
990    ee = ecore_event_window_match(ev->window);
991    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
992    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
993    ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
994    _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->time);
995    evas_event_feed_mouse_out(ee->evas, ev->time, NULL);
996    if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
997    if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
998    return ECORE_CALLBACK_PASS_ON;
999 }
1000
1001 static Eina_Bool 
1002 _ecore_evas_wl_event_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
1003 {
1004    Ecore_Evas *ee;
1005    Ecore_Wl_Event_Focus_In *ev;
1006
1007    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1008
1009    ev = event;
1010    ee = ecore_event_window_match(ev->window);
1011    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
1012    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
1013    ee->prop.focused = 1;
1014    evas_focus_in(ee->evas);
1015    if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
1016    return ECORE_CALLBACK_PASS_ON;
1017 }
1018
1019 static Eina_Bool 
1020 _ecore_evas_wl_event_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event)
1021 {
1022    Ecore_Evas *ee;
1023    Ecore_Wl_Event_Focus_Out *ev;
1024
1025    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1026
1027    ev = event;
1028    ee = ecore_event_window_match(ev->window);
1029    if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
1030    if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
1031    evas_focus_out(ee->evas);
1032    ee->prop.focused = 0;
1033    if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
1034    return ECORE_CALLBACK_PASS_ON;
1035 }
1036
1037 static void 
1038 _ecore_evas_wl_handle_configure(void *data, struct wl_shell_surface *shell_surface, uint32_t timestamp __UNUSED__, uint32_t edges __UNUSED__, int32_t width, int32_t height) 
1039 {
1040    Ecore_Evas *ee;
1041
1042    /* NB: Trap to prevent compositor from crashing */
1043    if ((width <= 0) || (height <= 0)) return;
1044
1045    if (!(ee = data)) return;
1046
1047    if ((shell_surface) && (ee->engine.wl.shell_surface)) 
1048      {
1049         if (ee->engine.wl.shell_surface != shell_surface) return;
1050         ecore_evas_resize(ee, width, height);
1051      }
1052 }
1053
1054 static void 
1055 _ecore_evas_wl_handle_popup_done(void *data __UNUSED__, struct wl_shell_surface *shell_surface __UNUSED__) 
1056 {
1057
1058 }
1059
1060 static void 
1061 _ecore_evas_wl_buffer_new(Ecore_Evas *ee, void **dest)
1062 {
1063    static unsigned int format;
1064    char tmp[PATH_MAX];
1065    int fd = -1, stride = 0, size = 0;
1066    void *ret;
1067
1068    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1069
1070    if (dest) *dest = NULL;
1071
1072    if (!format) format = ecore_wl_format_get();
1073
1074    strcpy(tmp, "/tmp/ecore-wayland_shm-XXXXXX");
1075    if ((fd = mkstemp(tmp)) < 0) 
1076      {
1077         ERR("Could not create temporary file.");
1078         return;
1079      }
1080
1081    stride = (ee->w * sizeof(int));
1082    size = (stride * ee->h);
1083    if (ftruncate(fd, size) < 0) 
1084      {
1085         ERR("Could not truncate temporary file.");
1086         close(fd);
1087         return;
1088      }
1089
1090    ret = mmap(NULL, size, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
1091    unlink(tmp);
1092
1093    if (ret == MAP_FAILED) 
1094      {
1095         ERR("mmap of temporary file failed.");
1096         close(fd);
1097         return;
1098      }
1099
1100    if (dest) *dest = ret;
1101
1102    ee->engine.wl.buffer = 
1103      wl_shm_create_buffer(ecore_wl_shm_get(), fd, ee->w, ee->h, stride, format);
1104
1105    close(fd);
1106 }
1107
1108 static void 
1109 _ecore_evas_wl_smart_init(void) 
1110 {
1111    if (_ecore_evas_wl_smart) return;
1112      {
1113         static const Evas_Smart_Class sc = 
1114           {
1115              "ecore_evas_wl_frame", EVAS_SMART_CLASS_VERSION, 
1116              _ecore_evas_wl_smart_add, 
1117              _ecore_evas_wl_smart_del, 
1118              NULL, 
1119              _ecore_evas_wl_smart_resize, 
1120              _ecore_evas_wl_smart_show, 
1121              _ecore_evas_wl_smart_hide, 
1122              NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
1123           };
1124         _ecore_evas_wl_smart = evas_smart_class_new(&sc);
1125      }
1126 }
1127
1128 static void 
1129 _ecore_evas_wl_smart_add(Evas_Object *obj) 
1130 {
1131    EE_Wl_Smart_Data *sd;
1132    Evas *evas;
1133
1134    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1135
1136    if (!(sd = calloc(1, sizeof(EE_Wl_Smart_Data)))) return;
1137
1138    evas = evas_object_evas_get(obj);
1139
1140    sd->x = 0;
1141    sd->y = 0;
1142    sd->w = 1;
1143    sd->h = 1;
1144
1145    sd->frame = evas_object_rectangle_add(evas);
1146    evas_object_is_frame_object_set(sd->frame, EINA_TRUE);
1147    evas_object_color_set(sd->frame, 249, 249, 249, 255);
1148    evas_object_smart_member_add(sd->frame, obj);
1149
1150    sd->text = evas_object_text_add(evas);
1151    evas_object_color_set(sd->text, 0, 0, 0, 255);
1152    evas_object_text_style_set(sd->text, EVAS_TEXT_STYLE_PLAIN);
1153    evas_object_text_font_set(sd->text, "Sans", 10);
1154    evas_object_text_text_set(sd->text, "Smart Test");
1155
1156    evas_object_smart_data_set(obj, sd);
1157 }
1158
1159 static void 
1160 _ecore_evas_wl_smart_del(Evas_Object *obj) 
1161 {
1162    EE_Wl_Smart_Data *sd;
1163
1164    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1165
1166    if (!(sd = evas_object_smart_data_get(obj))) return;
1167    evas_object_del(sd->text);
1168    evas_object_del(sd->frame);
1169    free(sd);
1170 }
1171
1172 static void 
1173 _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) 
1174 {
1175    EE_Wl_Smart_Data *sd;
1176
1177    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1178
1179    if (!(sd = evas_object_smart_data_get(obj))) return;
1180    if ((sd->w == w) && (sd->h == h)) return;
1181    sd->w = w;
1182    sd->h = h;
1183    evas_object_resize(sd->frame, w, h);
1184 }
1185
1186 static void 
1187 _ecore_evas_wl_smart_show(Evas_Object *obj) 
1188 {
1189    EE_Wl_Smart_Data *sd;
1190
1191    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1192
1193    if (!(sd = evas_object_smart_data_get(obj))) return;
1194    evas_object_show(sd->frame);
1195    evas_object_show(sd->text);
1196 }
1197
1198 static void 
1199 _ecore_evas_wl_smart_hide(Evas_Object *obj) 
1200 {
1201    EE_Wl_Smart_Data *sd;
1202
1203    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1204
1205    if (!(sd = evas_object_smart_data_get(obj))) return;
1206    evas_object_hide(sd->text);
1207    evas_object_hide(sd->frame);
1208 }
1209
1210 static Evas_Object *
1211 _ecore_evas_wl_frame_add(Evas *evas) 
1212 {
1213    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1214
1215    _ecore_evas_wl_smart_init();
1216    return evas_object_smart_add(evas, _ecore_evas_wl_smart);
1217 }
1218
1219 void 
1220 _ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location)
1221 {
1222    LOGFN(__FILE__, __LINE__, __FUNCTION__);
1223
1224    if ((!ee) || (!ee->engine.wl.shell_surface)) return;
1225    wl_shell_surface_resize(ee->engine.wl.shell_surface, 
1226                            ecore_wl_input_device_get(), 
1227                            _ecore_evas_wl_btn_timestamp, location);
1228 }
1229
1230 #else
1231 EAPI Ecore_Evas *
1232 ecore_evas_wayland_shm_new(const char *disp_name __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__, int frame __UNUSED__)
1233 {
1234    return NULL;
1235 }
1236 #endif