diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_shm.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_shm.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_shm.c | 1114 |
1 files changed, 0 insertions, 1114 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_shm.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_shm.c deleted file mode 100644 index 4c7ee2d..0000000 --- a/libraries/ecore/src/lib/ecore_evas/ecore_evas_wayland_shm.c +++ /dev/null | |||
@@ -1,1114 +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_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_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)); | ||
55 | static void _ecore_evas_wl_move(Ecore_Evas *ee, int x, int y); | ||
56 | static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h); | ||
57 | static void _ecore_evas_wl_show(Ecore_Evas *ee); | ||
58 | static void _ecore_evas_wl_hide(Ecore_Evas *ee); | ||
59 | static void _ecore_evas_wl_raise(Ecore_Evas *ee); | ||
60 | static void _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title); | ||
61 | static void _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c); | ||
62 | static void _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h); | ||
63 | static void _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h); | ||
64 | static void _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h); | ||
65 | static void _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h); | ||
66 | static void _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer); | ||
67 | static void _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify); | ||
68 | static void _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max); | ||
69 | static void _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full); | ||
70 | static void _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore); | ||
71 | static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha); | ||
72 | static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent); | ||
73 | static int _ecore_evas_wl_render(Ecore_Evas *ee); | ||
74 | static void _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h); | ||
75 | static void _ecore_evas_wl_buffer_new(Ecore_Evas *ee, void **dest); | ||
76 | |||
77 | static Eina_Bool _ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event); | ||
78 | static Eina_Bool _ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event); | ||
79 | static Eina_Bool _ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event); | ||
80 | static Eina_Bool _ecore_evas_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event); | ||
81 | static Eina_Bool _ecore_evas_wl_cb_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event); | ||
82 | |||
83 | /* SMART stuff for frame */ | ||
84 | static Evas_Smart *_ecore_evas_wl_smart = NULL; | ||
85 | |||
86 | static void _ecore_evas_wl_smart_init(void); | ||
87 | static void _ecore_evas_wl_smart_add(Evas_Object *obj); | ||
88 | static void _ecore_evas_wl_smart_del(Evas_Object *obj); | ||
89 | static void _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); | ||
90 | static void _ecore_evas_wl_smart_show(Evas_Object *obj); | ||
91 | static void _ecore_evas_wl_smart_hide(Evas_Object *obj); | ||
92 | |||
93 | static Evas_Object *_ecore_evas_wl_frame_add(Evas *evas); | ||
94 | |||
95 | /* local variables */ | ||
96 | static int _ecore_evas_wl_init_count = 0; | ||
97 | static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[5]; | ||
98 | |||
99 | static Ecore_Evas_Engine_Func _ecore_wl_engine_func = | ||
100 | { | ||
101 | _ecore_evas_wl_free, | ||
102 | _ecore_evas_wl_callback_resize_set, | ||
103 | _ecore_evas_wl_callback_move_set, | ||
104 | NULL, | ||
105 | NULL, | ||
106 | _ecore_evas_wl_callback_delete_request_set, | ||
107 | NULL, | ||
108 | _ecore_evas_wl_callback_focus_in_set, | ||
109 | _ecore_evas_wl_callback_focus_out_set, | ||
110 | _ecore_evas_wl_callback_mouse_in_set, | ||
111 | _ecore_evas_wl_callback_mouse_out_set, | ||
112 | NULL, // sticky_set | ||
113 | NULL, // unsticky_set | ||
114 | NULL, // pre_render_set | ||
115 | NULL, // post_render_set | ||
116 | _ecore_evas_wl_move, | ||
117 | NULL, // managed_move | ||
118 | _ecore_evas_wl_resize, | ||
119 | NULL, // move_resize | ||
120 | NULL, // rotation_set | ||
121 | NULL, // shaped_set | ||
122 | _ecore_evas_wl_show, | ||
123 | _ecore_evas_wl_hide, | ||
124 | _ecore_evas_wl_raise, | ||
125 | NULL, // lower | ||
126 | NULL, // activate | ||
127 | _ecore_evas_wl_title_set, | ||
128 | _ecore_evas_wl_name_class_set, | ||
129 | _ecore_evas_wl_size_min_set, | ||
130 | _ecore_evas_wl_size_max_set, | ||
131 | _ecore_evas_wl_size_base_set, | ||
132 | _ecore_evas_wl_size_step_set, | ||
133 | NULL, // object_cursor_set | ||
134 | _ecore_evas_wl_layer_set, | ||
135 | NULL, // focus set | ||
136 | _ecore_evas_wl_iconified_set, | ||
137 | NULL, // borderless set | ||
138 | NULL, // override set | ||
139 | _ecore_evas_wl_maximized_set, | ||
140 | _ecore_evas_wl_fullscreen_set, | ||
141 | NULL, // func avoid_damage set | ||
142 | NULL, // func withdrawn set | ||
143 | NULL, // func sticky set | ||
144 | _ecore_evas_wl_ignore_events_set, | ||
145 | _ecore_evas_wl_alpha_set, | ||
146 | _ecore_evas_wl_transparent_set, | ||
147 | NULL, | ||
148 | NULL, | ||
149 | NULL, | ||
150 | NULL, | ||
151 | NULL, | ||
152 | NULL, | ||
153 | _ecore_evas_wl_render, | ||
154 | _ecore_evas_wl_screen_geometry_get | ||
155 | }; | ||
156 | |||
157 | /* external variables */ | ||
158 | |||
159 | /* external functions */ | ||
160 | EAPI Ecore_Evas * | ||
161 | ecore_evas_wayland_shm_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame) | ||
162 | { | ||
163 | Ecore_Wl_Window *p = NULL; | ||
164 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
165 | Ecore_Evas *ee; | ||
166 | int method = 0; | ||
167 | |||
168 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
169 | |||
170 | if (!(method = evas_render_method_lookup("wayland_shm"))) | ||
171 | { | ||
172 | ERR("Render method lookup failed for Wayland_Shm"); | ||
173 | return NULL; | ||
174 | } | ||
175 | |||
176 | if (!ecore_wl_init(disp_name)) | ||
177 | { | ||
178 | ERR("Failed to initialize Ecore_Wayland"); | ||
179 | return NULL; | ||
180 | } | ||
181 | |||
182 | if (!(ee = calloc(1, sizeof(Ecore_Evas)))) | ||
183 | { | ||
184 | ERR("Failed to allocate Ecore_Evas"); | ||
185 | ecore_wl_shutdown(); | ||
186 | return NULL; | ||
187 | } | ||
188 | |||
189 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
190 | |||
191 | _ecore_evas_wl_init(); | ||
192 | |||
193 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_wl_engine_func; | ||
194 | |||
195 | ee->driver = "wayland_shm"; | ||
196 | if (disp_name) ee->name = strdup(disp_name); | ||
197 | |||
198 | if (w < 1) w = 1; | ||
199 | if (h < 1) h = 1; | ||
200 | |||
201 | ee->x = x; | ||
202 | ee->y = y; | ||
203 | ee->w = w; | ||
204 | ee->h = h; | ||
205 | ee->req.x = ee->x; | ||
206 | ee->req.y = ee->y; | ||
207 | ee->req.w = ee->w; | ||
208 | ee->req.h = ee->h; | ||
209 | ee->rotation = 0; | ||
210 | ee->prop.max.w = 32767; | ||
211 | 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 | |||
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_SHM); | ||
235 | ee->prop.window = ee->engine.wl.win->id; | ||
236 | |||
237 | if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) | ||
238 | { | ||
239 | einfo->info.rotation = ee->rotation; | ||
240 | einfo->info.debug = EINA_FALSE; | ||
241 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
242 | { | ||
243 | ERR("Failed to set Evas Engine Info for '%s'", ee->driver); | ||
244 | ecore_evas_free(ee); | ||
245 | _ecore_evas_wl_shutdown(); | ||
246 | ecore_wl_shutdown(); | ||
247 | return NULL; | ||
248 | } | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | ERR("Failed to get Evas Engine Info for '%s'", ee->driver); | ||
253 | ecore_evas_free(ee); | ||
254 | _ecore_evas_wl_shutdown(); | ||
255 | ecore_wl_shutdown(); | ||
256 | return NULL; | ||
257 | } | ||
258 | |||
259 | ecore_evas_callback_pre_free_set(ee, _ecore_evas_wl_pre_free); | ||
260 | |||
261 | if (ee->prop.draw_frame) | ||
262 | { | ||
263 | ee->engine.wl.frame = _ecore_evas_wl_frame_add(ee->evas); | ||
264 | evas_object_is_frame_object_set(ee->engine.wl.frame, EINA_TRUE); | ||
265 | evas_object_move(ee->engine.wl.frame, 0, 0); | ||
266 | } | ||
267 | |||
268 | ecore_evas_input_event_register(ee); | ||
269 | _ecore_evas_register(ee); | ||
270 | |||
271 | ecore_event_window_register(ee->prop.window, ee, ee->evas, | ||
272 | (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process, | ||
273 | (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process, | ||
274 | (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process, | ||
275 | (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process); | ||
276 | |||
277 | evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); | ||
278 | |||
279 | return ee; | ||
280 | } | ||
281 | |||
282 | /* local functions */ | ||
283 | static int | ||
284 | _ecore_evas_wl_init(void) | ||
285 | { | ||
286 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
287 | |||
288 | if (++_ecore_evas_wl_init_count != 1) | ||
289 | return _ecore_evas_wl_init_count; | ||
290 | |||
291 | _ecore_evas_wl_event_hdls[0] = | ||
292 | ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_IN, | ||
293 | _ecore_evas_wl_cb_mouse_in, NULL); | ||
294 | _ecore_evas_wl_event_hdls[1] = | ||
295 | ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT, | ||
296 | _ecore_evas_wl_cb_mouse_out, NULL); | ||
297 | _ecore_evas_wl_event_hdls[2] = | ||
298 | ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, | ||
299 | _ecore_evas_wl_cb_focus_in, NULL); | ||
300 | _ecore_evas_wl_event_hdls[3] = | ||
301 | ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, | ||
302 | _ecore_evas_wl_cb_focus_out, NULL); | ||
303 | _ecore_evas_wl_event_hdls[4] = | ||
304 | ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE, | ||
305 | _ecore_evas_wl_cb_window_configure, NULL); | ||
306 | |||
307 | ecore_event_evas_init(); | ||
308 | |||
309 | return _ecore_evas_wl_init_count; | ||
310 | } | ||
311 | |||
312 | static int | ||
313 | _ecore_evas_wl_shutdown(void) | ||
314 | { | ||
315 | unsigned int i = 0; | ||
316 | |||
317 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
318 | |||
319 | if (--_ecore_evas_wl_init_count != 0) | ||
320 | return _ecore_evas_wl_init_count; | ||
321 | |||
322 | for (i = 0; i < sizeof(_ecore_evas_wl_event_hdls) / sizeof(Ecore_Event_Handler *); i++) | ||
323 | { | ||
324 | if (_ecore_evas_wl_event_hdls[i]) | ||
325 | ecore_event_handler_del(_ecore_evas_wl_event_hdls[i]); | ||
326 | } | ||
327 | |||
328 | ecore_event_evas_shutdown(); | ||
329 | |||
330 | return _ecore_evas_wl_init_count; | ||
331 | } | ||
332 | |||
333 | static void | ||
334 | _ecore_evas_wl_pre_free(Ecore_Evas *ee) | ||
335 | { | ||
336 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
337 | |||
338 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
339 | |||
340 | if (ee->engine.wl.frame) evas_object_del(ee->engine.wl.frame); | ||
341 | |||
342 | einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas); | ||
343 | if ((einfo) && (einfo->info.dest)) | ||
344 | { | ||
345 | int ret = 0; | ||
346 | |||
347 | ret = munmap(einfo->info.dest, ((ee->w * sizeof(int)) * ee->h)); | ||
348 | if (!ret) ERR("Failed to unmap engine destination: %m"); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | static void | ||
353 | _ecore_evas_wl_free(Ecore_Evas *ee) | ||
354 | { | ||
355 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
356 | |||
357 | if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer); | ||
358 | ee->engine.wl.buffer = NULL; | ||
359 | |||
360 | if (ee->engine.wl.win) ecore_wl_window_free(ee->engine.wl.win); | ||
361 | ee->engine.wl.win = NULL; | ||
362 | |||
363 | ecore_event_window_unregister(ee->prop.window); | ||
364 | ecore_evas_input_event_unregister(ee); | ||
365 | |||
366 | _ecore_evas_wl_shutdown(); | ||
367 | ecore_wl_shutdown(); | ||
368 | } | ||
369 | |||
370 | static void | ||
371 | _ecore_evas_wl_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
372 | { | ||
373 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
374 | |||
375 | if (!ee) return; | ||
376 | ee->func.fn_resize = func; | ||
377 | } | ||
378 | |||
379 | static void | ||
380 | _ecore_evas_wl_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
381 | { | ||
382 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
383 | |||
384 | if (!ee) return; | ||
385 | ee->func.fn_move = func; | ||
386 | } | ||
387 | |||
388 | static void | ||
389 | _ecore_evas_wl_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
390 | { | ||
391 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
392 | |||
393 | if (!ee) return; | ||
394 | ee->func.fn_delete_request = func; | ||
395 | } | ||
396 | |||
397 | static void | ||
398 | _ecore_evas_wl_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
399 | { | ||
400 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
401 | |||
402 | if (!ee) return; | ||
403 | ee->func.fn_focus_in = func; | ||
404 | } | ||
405 | |||
406 | static void | ||
407 | _ecore_evas_wl_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
408 | { | ||
409 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
410 | |||
411 | if (!ee) return; | ||
412 | ee->func.fn_focus_out = func; | ||
413 | } | ||
414 | |||
415 | static void | ||
416 | _ecore_evas_wl_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
417 | { | ||
418 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
419 | |||
420 | if (!ee) return; | ||
421 | ee->func.fn_mouse_in = func; | ||
422 | } | ||
423 | |||
424 | static void | ||
425 | _ecore_evas_wl_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee)) | ||
426 | { | ||
427 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
428 | |||
429 | if (!ee) return; | ||
430 | ee->func.fn_mouse_out = func; | ||
431 | } | ||
432 | |||
433 | static void | ||
434 | _ecore_evas_wl_move(Ecore_Evas *ee, int x, int y) | ||
435 | { | ||
436 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
437 | |||
438 | if (!ee) return; | ||
439 | ee->req.x = x; | ||
440 | ee->req.y = y; | ||
441 | ee->x = x; | ||
442 | ee->y = y; | ||
443 | if (ee->engine.wl.win) ecore_wl_window_move(ee->engine.wl.win, x, y); | ||
444 | if (ee->func.fn_move) ee->func.fn_move(ee); | ||
445 | } | ||
446 | |||
447 | static void | ||
448 | _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h) | ||
449 | { | ||
450 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
451 | |||
452 | if (!ee) return; | ||
453 | if (w < 1) w = 1; | ||
454 | if (h < 1) h = 1; | ||
455 | // if ((ee->w == w) && (ee->h == h)) return; | ||
456 | |||
457 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
458 | |||
459 | if (ee->prop.min.w > w) w = ee->prop.min.w; | ||
460 | else if (w > ee->prop.max.w) w = ee->prop.max.w; | ||
461 | if (ee->prop.min.h > h) h = ee->prop.min.h; | ||
462 | else if (h > ee->prop.max.h) h = ee->prop.max.h; | ||
463 | |||
464 | ee->req.w = w; | ||
465 | ee->req.h = h; | ||
466 | |||
467 | // ecore_wl_window_damage(ee->engine.wl.win, 0, 0, ee->w, ee->h); | ||
468 | |||
469 | einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas); | ||
470 | if ((einfo) && (einfo->info.dest)) | ||
471 | { | ||
472 | int ret = 0; | ||
473 | |||
474 | ret = munmap(einfo->info.dest, ((ee->w * sizeof(int)) * ee->h)); | ||
475 | if (!ret) ERR("Failed to unmap engine destination: %m"); | ||
476 | } | ||
477 | else if (!einfo) | ||
478 | { | ||
479 | ERR("Failed to get Evas Engine Info for '%s'", ee->driver); | ||
480 | return; | ||
481 | } | ||
482 | |||
483 | if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer); | ||
484 | ee->engine.wl.buffer = NULL; | ||
485 | |||
486 | ee->w = w; | ||
487 | ee->h = h; | ||
488 | |||
489 | _ecore_evas_wl_buffer_new(ee, &einfo->info.dest); | ||
490 | ecore_wl_flush(); | ||
491 | |||
492 | /* change evas output & viewport sizes */ | ||
493 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
494 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
495 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
496 | if (ee->engine.wl.frame) | ||
497 | evas_object_resize(ee->engine.wl.frame, ee->w, ee->h); | ||
498 | |||
499 | /* set new engine destination */ | ||
500 | evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); | ||
501 | |||
502 | /* damage buffer */ | ||
503 | // wl_buffer_damage(ee->engine.wl.buffer, 0, 0, ee->w, ee->h); | ||
504 | |||
505 | ecore_wl_window_buffer_attach(ee->engine.wl.win, ee->engine.wl.buffer, 0, 0); | ||
506 | /* ecore_wl_window_damage(ee->engine.wl.win, 0, 0, ee->w, ee->h); */ | ||
507 | /* ecore_wl_flush(); */ | ||
508 | |||
509 | ecore_wl_window_update_size(ee->engine.wl.win, ee->w, ee->h); | ||
510 | |||
511 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
512 | } | ||
513 | |||
514 | static void | ||
515 | _ecore_evas_wl_show(Ecore_Evas *ee) | ||
516 | { | ||
517 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
518 | |||
519 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
520 | |||
521 | if ((!ee) || (ee->visible)) return; | ||
522 | |||
523 | if (ee->engine.wl.win) | ||
524 | ecore_wl_window_show(ee->engine.wl.win); | ||
525 | |||
526 | einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas); | ||
527 | if (!einfo) | ||
528 | { | ||
529 | ERR("Failed to get Evas Engine Info for '%s'", ee->driver); | ||
530 | return; | ||
531 | } | ||
532 | |||
533 | _ecore_evas_wl_buffer_new(ee, &einfo->info.dest); | ||
534 | evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); | ||
535 | |||
536 | if (ee->engine.wl.frame) | ||
537 | { | ||
538 | evas_object_show(ee->engine.wl.frame); | ||
539 | evas_object_resize(ee->engine.wl.frame, ee->w, ee->h); | ||
540 | } | ||
541 | |||
542 | ecore_wl_flush(); | ||
543 | |||
544 | if (ee->engine.wl.win) | ||
545 | ecore_wl_window_buffer_attach(ee->engine.wl.win, ee->engine.wl.buffer, 0, 0); | ||
546 | |||
547 | ee->visible = 1; | ||
548 | if (ee->func.fn_show) ee->func.fn_show(ee); | ||
549 | } | ||
550 | |||
551 | static void | ||
552 | _ecore_evas_wl_hide(Ecore_Evas *ee) | ||
553 | { | ||
554 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
555 | |||
556 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
557 | |||
558 | if ((!ee) || (!ee->visible)) return; | ||
559 | |||
560 | einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas); | ||
561 | if ((einfo) && (einfo->info.dest)) | ||
562 | { | ||
563 | int ret = 0; | ||
564 | |||
565 | ret = munmap(einfo->info.dest, ((ee->w * sizeof(int)) * ee->h)); | ||
566 | if (!ret) ERR("Failed to unmap engine destination: %m"); | ||
567 | } | ||
568 | |||
569 | if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer); | ||
570 | ee->engine.wl.buffer = NULL; | ||
571 | |||
572 | evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); | ||
573 | |||
574 | ecore_wl_window_hide(ee->engine.wl.win); | ||
575 | |||
576 | ee->visible = 0; | ||
577 | ee->should_be_visible = 0; | ||
578 | |||
579 | if (ee->func.fn_hide) ee->func.fn_hide(ee); | ||
580 | } | ||
581 | |||
582 | static void | ||
583 | _ecore_evas_wl_raise(Ecore_Evas *ee) | ||
584 | { | ||
585 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
586 | |||
587 | if ((!ee) || (!ee->visible)) return; | ||
588 | ecore_wl_window_raise(ee->engine.wl.win); | ||
589 | } | ||
590 | |||
591 | static void | ||
592 | _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title) | ||
593 | { | ||
594 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
595 | |||
596 | if (!ee) return; | ||
597 | if (ee->prop.title) free(ee->prop.title); | ||
598 | ee->prop.title = NULL; | ||
599 | if (title) ee->prop.title = strdup(title); | ||
600 | if ((ee->prop.draw_frame) && (ee->engine.wl.frame)) | ||
601 | { | ||
602 | EE_Wl_Smart_Data *sd; | ||
603 | |||
604 | if (!(sd = evas_object_smart_data_get(ee->engine.wl.frame))) return; | ||
605 | evas_object_text_text_set(sd->text, ee->prop.title); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | static void | ||
610 | _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c) | ||
611 | { | ||
612 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
613 | |||
614 | if (!ee) return; | ||
615 | if (ee->prop.name) free(ee->prop.name); | ||
616 | if (ee->prop.clas) free(ee->prop.clas); | ||
617 | ee->prop.name = NULL; | ||
618 | ee->prop.clas = NULL; | ||
619 | if (n) ee->prop.name = strdup(n); | ||
620 | if (c) ee->prop.clas = strdup(c); | ||
621 | /* FIXME: Forward these changes to Wayland somehow */ | ||
622 | } | ||
623 | |||
624 | static void | ||
625 | _ecore_evas_wl_size_min_set(Ecore_Evas *ee, int w, int h) | ||
626 | { | ||
627 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
628 | |||
629 | if (!ee) return; | ||
630 | if (w < 0) w = 0; | ||
631 | if (h < 0) h = 0; | ||
632 | if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return; | ||
633 | ee->prop.min.w = w; | ||
634 | ee->prop.min.h = h; | ||
635 | } | ||
636 | |||
637 | static void | ||
638 | _ecore_evas_wl_size_max_set(Ecore_Evas *ee, int w, int h) | ||
639 | { | ||
640 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
641 | |||
642 | if (!ee) return; | ||
643 | if (w < 0) w = 0; | ||
644 | if (h < 0) h = 0; | ||
645 | if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return; | ||
646 | ee->prop.max.w = w; | ||
647 | ee->prop.max.h = h; | ||
648 | } | ||
649 | |||
650 | static void | ||
651 | _ecore_evas_wl_size_base_set(Ecore_Evas *ee, int w, int h) | ||
652 | { | ||
653 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
654 | |||
655 | if (!ee) return; | ||
656 | if (w < 0) w = 0; | ||
657 | if (h < 0) h = 0; | ||
658 | if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return; | ||
659 | ee->prop.base.w = w; | ||
660 | ee->prop.base.h = h; | ||
661 | } | ||
662 | |||
663 | static void | ||
664 | _ecore_evas_wl_size_step_set(Ecore_Evas *ee, int w, int h) | ||
665 | { | ||
666 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
667 | |||
668 | if (!ee) return; | ||
669 | if (w < 0) w = 0; | ||
670 | if (h < 0) h = 0; | ||
671 | if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return; | ||
672 | ee->prop.step.w = w; | ||
673 | ee->prop.step.h = h; | ||
674 | } | ||
675 | |||
676 | static void | ||
677 | _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer) | ||
678 | { | ||
679 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
680 | |||
681 | if (!ee) return; | ||
682 | if (ee->prop.layer == layer) return; | ||
683 | if (layer < 1) layer = 1; | ||
684 | else if (layer > 255) layer = 255; | ||
685 | ee->prop.layer = layer; | ||
686 | } | ||
687 | |||
688 | static void | ||
689 | _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify) | ||
690 | { | ||
691 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
692 | |||
693 | if (!ee) return; | ||
694 | if (ee->prop.iconified == iconify) return; | ||
695 | ee->prop.iconified = iconify; | ||
696 | /* FIXME: Implement this in Wayland someshow */ | ||
697 | } | ||
698 | |||
699 | static void | ||
700 | _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max) | ||
701 | { | ||
702 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
703 | |||
704 | if (!ee) return; | ||
705 | if (ee->prop.maximized == max) return; | ||
706 | ee->prop.maximized = max; | ||
707 | ecore_wl_window_maximized_set(ee->engine.wl.win, max); | ||
708 | } | ||
709 | |||
710 | static void | ||
711 | _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full) | ||
712 | { | ||
713 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
714 | |||
715 | if ((!ee) || (!ee->visible)) return; | ||
716 | if (ee->prop.fullscreen == full) return; | ||
717 | ee->prop.fullscreen = full; | ||
718 | ecore_wl_window_fullscreen_set(ee->engine.wl.win, full); | ||
719 | } | ||
720 | |||
721 | static void | ||
722 | _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore) | ||
723 | { | ||
724 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
725 | |||
726 | if (!ee) return; | ||
727 | ee->ignore_events = ignore; | ||
728 | /* NB: Hmmm, may need to pass this to ecore_wl_window in the future */ | ||
729 | } | ||
730 | |||
731 | static void | ||
732 | _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha) | ||
733 | { | ||
734 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
735 | |||
736 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
737 | |||
738 | if (!ee) return; | ||
739 | if ((ee->alpha == alpha)) return; | ||
740 | ee->alpha = alpha; | ||
741 | if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) | ||
742 | { | ||
743 | einfo->info.destination_alpha = alpha; | ||
744 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
745 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
746 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
747 | } | ||
748 | } | ||
749 | |||
750 | static void | ||
751 | _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent) | ||
752 | { | ||
753 | Evas_Engine_Info_Wayland_Shm *einfo; | ||
754 | |||
755 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
756 | |||
757 | if (!ee) return; | ||
758 | if ((ee->transparent == transparent)) return; | ||
759 | ee->transparent = transparent; | ||
760 | if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) | ||
761 | { | ||
762 | einfo->info.destination_alpha = transparent; | ||
763 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
764 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
765 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
766 | } | ||
767 | } | ||
768 | |||
769 | static int | ||
770 | _ecore_evas_wl_render(Ecore_Evas *ee) | ||
771 | { | ||
772 | int rend = 0; | ||
773 | |||
774 | if (!ee) return 0; | ||
775 | if (!ee->visible) | ||
776 | evas_norender(ee->evas); | ||
777 | else | ||
778 | { | ||
779 | Eina_List *ll = NULL, *updates = NULL; | ||
780 | Ecore_Evas *ee2 = NULL; | ||
781 | |||
782 | if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); | ||
783 | |||
784 | EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) | ||
785 | { | ||
786 | if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); | ||
787 | if (ee2->engine.func->fn_render) | ||
788 | rend |= ee2->engine.func->fn_render(ee2); | ||
789 | if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); | ||
790 | } | ||
791 | |||
792 | if ((updates = evas_render_updates(ee->evas))) | ||
793 | { | ||
794 | Eina_List *l = NULL; | ||
795 | Eina_Rectangle *r; | ||
796 | |||
797 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
798 | |||
799 | EINA_LIST_FOREACH(updates, l, r) | ||
800 | { | ||
801 | if (ee->engine.wl.buffer) | ||
802 | wl_buffer_damage(ee->engine.wl.buffer, | ||
803 | r->x, r->y, r->w, r->h); | ||
804 | |||
805 | ecore_wl_window_damage(ee->engine.wl.win, | ||
806 | r->x, r->y, r->w, r->h); | ||
807 | } | ||
808 | |||
809 | ecore_wl_flush(); | ||
810 | |||
811 | evas_render_updates_free(updates); | ||
812 | _ecore_evas_idle_timeout_update(ee); | ||
813 | rend = 1; | ||
814 | } | ||
815 | |||
816 | if (ee->func.fn_post_render) ee->func.fn_post_render(ee); | ||
817 | } | ||
818 | return rend; | ||
819 | } | ||
820 | |||
821 | static void | ||
822 | _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h) | ||
823 | { | ||
824 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
825 | |||
826 | if (x) *x = 0; | ||
827 | if (y) *y = 0; | ||
828 | ecore_wl_screen_size_get(w, h); | ||
829 | } | ||
830 | |||
831 | static void | ||
832 | _ecore_evas_wl_buffer_new(Ecore_Evas *ee, void **dest) | ||
833 | { | ||
834 | struct wl_shm *shm; | ||
835 | static unsigned int format; | ||
836 | char tmp[PATH_MAX]; | ||
837 | int fd = -1, stride = 0, size = 0; | ||
838 | void *ret; | ||
839 | |||
840 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
841 | |||
842 | if (dest) *dest = NULL; | ||
843 | if (!(shm = ecore_wl_shm_get())) return; | ||
844 | if (!format) format = WL_SHM_FORMAT_ARGB8888; //ecore_wl_format_get(); | ||
845 | |||
846 | strcpy(tmp, "/tmp/ecore-wayland_shm-XXXXXX"); | ||
847 | if ((fd = mkstemp(tmp)) < 0) | ||
848 | { | ||
849 | ERR("Could not create temporary file."); | ||
850 | return; | ||
851 | } | ||
852 | |||
853 | stride = (ee->w * sizeof(int)); | ||
854 | size = (stride * ee->h); | ||
855 | if (ftruncate(fd, size) < 0) | ||
856 | { | ||
857 | ERR("Could not truncate temporary file."); | ||
858 | close(fd); | ||
859 | return; | ||
860 | } | ||
861 | |||
862 | ret = mmap(NULL, size, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0); | ||
863 | unlink(tmp); | ||
864 | |||
865 | if (ret == MAP_FAILED) | ||
866 | { | ||
867 | ERR("mmap of temporary file failed."); | ||
868 | close(fd); | ||
869 | return; | ||
870 | } | ||
871 | |||
872 | if (dest) *dest = ret; | ||
873 | |||
874 | ee->engine.wl.buffer = | ||
875 | wl_shm_create_buffer(ecore_wl_shm_get(), fd, ee->w, ee->h, stride, format); | ||
876 | |||
877 | close(fd); | ||
878 | } | ||
879 | |||
880 | void | ||
881 | _ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location) | ||
882 | { | ||
883 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
884 | |||
885 | if (!ee) return; | ||
886 | if (ee->engine.wl.win) | ||
887 | ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location); | ||
888 | } | ||
889 | |||
890 | static Eina_Bool | ||
891 | _ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
892 | { | ||
893 | Ecore_Evas *ee; | ||
894 | Ecore_Wl_Event_Mouse_In *ev; | ||
895 | |||
896 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
897 | |||
898 | ev = event; | ||
899 | ee = ecore_event_window_match(ev->win); | ||
900 | if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; | ||
901 | if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; | ||
902 | if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee); | ||
903 | ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers); | ||
904 | evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL); | ||
905 | _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp); | ||
906 | return ECORE_CALLBACK_PASS_ON; | ||
907 | } | ||
908 | |||
909 | static Eina_Bool | ||
910 | _ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
911 | { | ||
912 | Ecore_Evas *ee; | ||
913 | Ecore_Wl_Event_Mouse_Out *ev; | ||
914 | |||
915 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
916 | |||
917 | ev = event; | ||
918 | ee = ecore_event_window_match(ev->win); | ||
919 | if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; | ||
920 | if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; | ||
921 | ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers); | ||
922 | _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp); | ||
923 | evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL); | ||
924 | if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee); | ||
925 | if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); | ||
926 | return ECORE_CALLBACK_PASS_ON; | ||
927 | } | ||
928 | |||
929 | static Eina_Bool | ||
930 | _ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
931 | { | ||
932 | Ecore_Evas *ee; | ||
933 | Ecore_Wl_Event_Focus_In *ev; | ||
934 | |||
935 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
936 | |||
937 | ev = event; | ||
938 | ee = ecore_event_window_match(ev->win); | ||
939 | if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; | ||
940 | if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; | ||
941 | ee->prop.focused = 1; | ||
942 | evas_focus_in(ee->evas); | ||
943 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
944 | return ECORE_CALLBACK_PASS_ON; | ||
945 | } | ||
946 | |||
947 | static Eina_Bool | ||
948 | _ecore_evas_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
949 | { | ||
950 | Ecore_Evas *ee; | ||
951 | Ecore_Wl_Event_Focus_In *ev; | ||
952 | |||
953 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
954 | |||
955 | ev = event; | ||
956 | ee = ecore_event_window_match(ev->win); | ||
957 | if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; | ||
958 | if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; | ||
959 | evas_focus_out(ee->evas); | ||
960 | ee->prop.focused = 0; | ||
961 | if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee); | ||
962 | return ECORE_CALLBACK_PASS_ON; | ||
963 | } | ||
964 | |||
965 | static Eina_Bool | ||
966 | _ecore_evas_wl_cb_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
967 | { | ||
968 | Ecore_Evas *ee; | ||
969 | Ecore_Wl_Event_Window_Configure *ev; | ||
970 | |||
971 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
972 | |||
973 | ev = event; | ||
974 | ee = ecore_event_window_match(ev->win); | ||
975 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
976 | if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; | ||
977 | if ((ee->x != ev->x) || (ee->y != ev->y)) | ||
978 | { | ||
979 | ee->x = ev->x; | ||
980 | ee->y = ev->y; | ||
981 | ee->req.x = ee->x; | ||
982 | ee->req.y = ee->y; | ||
983 | if (ee->func.fn_move) ee->func.fn_move(ee); | ||
984 | } | ||
985 | if ((ee->req.w != ev->w) || (ee->req.h != ev->h)) | ||
986 | { | ||
987 | /* ee->w = ev->w; */ | ||
988 | /* ee->h = ev->h; */ | ||
989 | ee->req.w = ev->w; | ||
990 | ee->req.h = ev->h; | ||
991 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
992 | } | ||
993 | |||
994 | return ECORE_CALLBACK_PASS_ON; | ||
995 | } | ||
996 | |||
997 | static void | ||
998 | _ecore_evas_wl_smart_init(void) | ||
999 | { | ||
1000 | if (_ecore_evas_wl_smart) return; | ||
1001 | { | ||
1002 | static const Evas_Smart_Class sc = | ||
1003 | { | ||
1004 | "ecore_evas_wl_frame", EVAS_SMART_CLASS_VERSION, | ||
1005 | _ecore_evas_wl_smart_add, | ||
1006 | _ecore_evas_wl_smart_del, | ||
1007 | NULL, | ||
1008 | _ecore_evas_wl_smart_resize, | ||
1009 | _ecore_evas_wl_smart_show, | ||
1010 | _ecore_evas_wl_smart_hide, | ||
1011 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL | ||
1012 | }; | ||
1013 | _ecore_evas_wl_smart = evas_smart_class_new(&sc); | ||
1014 | } | ||
1015 | } | ||
1016 | |||
1017 | static void | ||
1018 | _ecore_evas_wl_smart_add(Evas_Object *obj) | ||
1019 | { | ||
1020 | EE_Wl_Smart_Data *sd; | ||
1021 | Evas *evas; | ||
1022 | |||
1023 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1024 | |||
1025 | if (!(sd = calloc(1, sizeof(EE_Wl_Smart_Data)))) return; | ||
1026 | |||
1027 | evas = evas_object_evas_get(obj); | ||
1028 | |||
1029 | sd->x = 0; | ||
1030 | sd->y = 0; | ||
1031 | sd->w = 1; | ||
1032 | sd->h = 1; | ||
1033 | |||
1034 | sd->frame = evas_object_rectangle_add(evas); | ||
1035 | evas_object_is_frame_object_set(sd->frame, EINA_TRUE); | ||
1036 | evas_object_color_set(sd->frame, 249, 249, 249, 255); | ||
1037 | evas_object_smart_member_add(sd->frame, obj); | ||
1038 | |||
1039 | sd->text = evas_object_text_add(evas); | ||
1040 | evas_object_color_set(sd->text, 0, 0, 0, 255); | ||
1041 | evas_object_text_style_set(sd->text, EVAS_TEXT_STYLE_PLAIN); | ||
1042 | evas_object_text_font_set(sd->text, "Sans", 10); | ||
1043 | evas_object_text_text_set(sd->text, "Smart Test"); | ||
1044 | |||
1045 | evas_object_smart_data_set(obj, sd); | ||
1046 | } | ||
1047 | |||
1048 | static void | ||
1049 | _ecore_evas_wl_smart_del(Evas_Object *obj) | ||
1050 | { | ||
1051 | EE_Wl_Smart_Data *sd; | ||
1052 | |||
1053 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1054 | |||
1055 | if (!(sd = evas_object_smart_data_get(obj))) return; | ||
1056 | evas_object_del(sd->text); | ||
1057 | evas_object_del(sd->frame); | ||
1058 | free(sd); | ||
1059 | } | ||
1060 | |||
1061 | static void | ||
1062 | _ecore_evas_wl_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) | ||
1063 | { | ||
1064 | EE_Wl_Smart_Data *sd; | ||
1065 | |||
1066 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1067 | |||
1068 | if (!(sd = evas_object_smart_data_get(obj))) return; | ||
1069 | if ((sd->w == w) && (sd->h == h)) return; | ||
1070 | sd->w = w; | ||
1071 | sd->h = h; | ||
1072 | evas_object_resize(sd->frame, w, h); | ||
1073 | } | ||
1074 | |||
1075 | static void | ||
1076 | _ecore_evas_wl_smart_show(Evas_Object *obj) | ||
1077 | { | ||
1078 | EE_Wl_Smart_Data *sd; | ||
1079 | |||
1080 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1081 | |||
1082 | if (!(sd = evas_object_smart_data_get(obj))) return; | ||
1083 | evas_object_show(sd->frame); | ||
1084 | evas_object_show(sd->text); | ||
1085 | } | ||
1086 | |||
1087 | static void | ||
1088 | _ecore_evas_wl_smart_hide(Evas_Object *obj) | ||
1089 | { | ||
1090 | EE_Wl_Smart_Data *sd; | ||
1091 | |||
1092 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1093 | |||
1094 | if (!(sd = evas_object_smart_data_get(obj))) return; | ||
1095 | evas_object_hide(sd->text); | ||
1096 | evas_object_hide(sd->frame); | ||
1097 | } | ||
1098 | |||
1099 | static Evas_Object * | ||
1100 | _ecore_evas_wl_frame_add(Evas *evas) | ||
1101 | { | ||
1102 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1103 | |||
1104 | _ecore_evas_wl_smart_init(); | ||
1105 | return evas_object_smart_add(evas, _ecore_evas_wl_smart); | ||
1106 | } | ||
1107 | |||
1108 | #else | ||
1109 | EAPI Ecore_Evas * | ||
1110 | ecore_evas_wayland_shm_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__) | ||
1111 | { | ||
1112 | return NULL; | ||
1113 | } | ||
1114 | #endif | ||