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