diff options
Diffstat (limited to 'libraries/elementary/src/lib/elm_win.c')
-rw-r--r-- | libraries/elementary/src/lib/elm_win.c | 3428 |
1 files changed, 3428 insertions, 0 deletions
diff --git a/libraries/elementary/src/lib/elm_win.c b/libraries/elementary/src/lib/elm_win.c new file mode 100644 index 0000000..54127c0 --- /dev/null +++ b/libraries/elementary/src/lib/elm_win.c | |||
@@ -0,0 +1,3428 @@ | |||
1 | #include <Elementary.h> | ||
2 | #include "elm_priv.h" | ||
3 | |||
4 | typedef struct _Elm_Win Elm_Win; | ||
5 | |||
6 | struct _Elm_Win | ||
7 | { | ||
8 | Ecore_Evas *ee; | ||
9 | Evas *evas; | ||
10 | Evas_Object *parent, *win_obj, *img_obj, *frame_obj; | ||
11 | Eina_List *subobjs; | ||
12 | #ifdef HAVE_ELEMENTARY_X | ||
13 | Ecore_X_Window xwin; | ||
14 | Ecore_Event_Handler *client_message_handler; | ||
15 | #endif | ||
16 | Ecore_Job *deferred_resize_job; | ||
17 | Ecore_Job *deferred_child_eval_job; | ||
18 | |||
19 | Elm_Win_Type type; | ||
20 | Elm_Win_Keyboard_Mode kbdmode; | ||
21 | Elm_Win_Indicator_Mode indmode; | ||
22 | Elm_Win_Indicator_Opacity_Mode ind_o_mode; | ||
23 | struct | ||
24 | { | ||
25 | const char *info; | ||
26 | Ecore_Timer *timer; | ||
27 | int repeat_count; | ||
28 | int shot_counter; | ||
29 | } shot; | ||
30 | int resize_location; | ||
31 | int *autodel_clear, rot; | ||
32 | int show_count; | ||
33 | struct | ||
34 | { | ||
35 | int x, y; | ||
36 | } screen; | ||
37 | struct | ||
38 | { | ||
39 | Ecore_Evas *ee; | ||
40 | Evas *evas; | ||
41 | Evas_Object *obj, *hot_obj; | ||
42 | int hot_x, hot_y; | ||
43 | } pointer; | ||
44 | struct | ||
45 | { | ||
46 | Evas_Object *top; | ||
47 | |||
48 | struct | ||
49 | { | ||
50 | Evas_Object *target; | ||
51 | Eina_Bool visible : 1; | ||
52 | Eina_Bool handled : 1; | ||
53 | } cur, prev; | ||
54 | |||
55 | const char *style; | ||
56 | Ecore_Job *reconf_job; | ||
57 | |||
58 | Eina_Bool enabled : 1; | ||
59 | Eina_Bool changed_theme : 1; | ||
60 | Eina_Bool top_animate : 1; | ||
61 | Eina_Bool geometry_changed : 1; | ||
62 | } focus_highlight; | ||
63 | |||
64 | Evas_Object *icon; | ||
65 | const char *title; | ||
66 | const char *icon_name; | ||
67 | const char *role; | ||
68 | |||
69 | double aspect; | ||
70 | Eina_Bool urgent : 1; | ||
71 | Eina_Bool modal : 1; | ||
72 | Eina_Bool demand_attention : 1; | ||
73 | Eina_Bool autodel : 1; | ||
74 | Eina_Bool constrain : 1; | ||
75 | Eina_Bool resizing : 1; | ||
76 | Eina_Bool iconified : 1; | ||
77 | Eina_Bool withdrawn : 1; | ||
78 | Eina_Bool sticky : 1; | ||
79 | Eina_Bool fullscreen : 1; | ||
80 | Eina_Bool maximized : 1; | ||
81 | Eina_Bool skip_focus : 1; | ||
82 | }; | ||
83 | |||
84 | static const char *widtype = NULL; | ||
85 | static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
86 | static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
87 | static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
88 | static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); | ||
89 | static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj); | ||
90 | static void _elm_win_move(Ecore_Evas *ee); | ||
91 | static void _elm_win_resize(Ecore_Evas *ee); | ||
92 | static void _elm_win_delete_request(Ecore_Evas *ee); | ||
93 | static void _elm_win_resize_job(void *data); | ||
94 | #ifdef HAVE_ELEMENTARY_X | ||
95 | static void _elm_win_xwin_update(Elm_Win *win); | ||
96 | #endif | ||
97 | static void _elm_win_eval_subobjs(Evas_Object *obj); | ||
98 | static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
99 | static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
100 | static void _elm_win_focus_highlight_init(Elm_Win *win); | ||
101 | static void _elm_win_focus_highlight_shutdown(Elm_Win *win); | ||
102 | static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible); | ||
103 | static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win); | ||
104 | static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win); | ||
105 | static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source); | ||
106 | static void _elm_win_focus_highlight_reconfigure(Elm_Win *win); | ||
107 | |||
108 | static void _elm_win_frame_add(Elm_Win *win, const char *style); | ||
109 | static void _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__); | ||
110 | static void _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source); | ||
111 | static void _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__); | ||
112 | static void _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__); | ||
113 | static void _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__); | ||
114 | |||
115 | //static void _elm_win_pointer_add(Elm_Win *win, const char *style); | ||
116 | |||
117 | static const char SIG_DELETE_REQUEST[] = "delete,request"; | ||
118 | static const char SIG_FOCUS_OUT[] = "focus,out"; | ||
119 | static const char SIG_FOCUS_IN[] = "focus,in"; | ||
120 | static const char SIG_MOVED[] = "moved"; | ||
121 | static const char SIG_THEME_CHANGED[] = "theme,changed"; | ||
122 | static const char SIG_WITHDRAWN[] = "withdrawn"; | ||
123 | static const char SIG_ICONIFIED[] = "iconified"; | ||
124 | static const char SIG_NORMAL[] = "normal"; | ||
125 | static const char SIG_STICK[] = "stick"; | ||
126 | static const char SIG_UNSTICK[] = "unstick"; | ||
127 | static const char SIG_FULLSCREEN[] = "fullscreen"; | ||
128 | static const char SIG_UNFULLSCREEN[] = "unfullscreen"; | ||
129 | static const char SIG_MAXIMIZED[] = "maximized"; | ||
130 | static const char SIG_UNMAXIMIZED[] = "unmaximized"; | ||
131 | |||
132 | static const Evas_Smart_Cb_Description _signals[] = { | ||
133 | {SIG_DELETE_REQUEST, ""}, | ||
134 | {SIG_FOCUS_OUT, ""}, | ||
135 | {SIG_FOCUS_IN, ""}, | ||
136 | {SIG_MOVED, ""}, | ||
137 | {SIG_WITHDRAWN, ""}, | ||
138 | {SIG_ICONIFIED, ""}, | ||
139 | {SIG_NORMAL, ""}, | ||
140 | {SIG_STICK, ""}, | ||
141 | {SIG_UNSTICK, ""}, | ||
142 | {SIG_FULLSCREEN, ""}, | ||
143 | {SIG_UNFULLSCREEN, ""}, | ||
144 | {SIG_MAXIMIZED, ""}, | ||
145 | {SIG_UNMAXIMIZED, ""}, | ||
146 | {NULL, NULL} | ||
147 | }; | ||
148 | |||
149 | |||
150 | |||
151 | Eina_List *_elm_win_list = NULL; | ||
152 | int _elm_win_deferred_free = 0; | ||
153 | |||
154 | // exmaple shot spec (wait 0.1 sec then save as my-window.png): | ||
155 | // ELM_ENGINE="shot:delay=0.1:file=my-window.png" | ||
156 | |||
157 | static double | ||
158 | _shot_delay_get(Elm_Win *win) | ||
159 | { | ||
160 | char *p, *pd; | ||
161 | char *d = strdup(win->shot.info); | ||
162 | |||
163 | if (!d) return 0.5; | ||
164 | for (p = (char *)win->shot.info; *p; p++) | ||
165 | { | ||
166 | if (!strncmp(p, "delay=", 6)) | ||
167 | { | ||
168 | double v; | ||
169 | |||
170 | for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++) | ||
171 | { | ||
172 | *pd = *p; | ||
173 | } | ||
174 | *pd = 0; | ||
175 | v = atof(d); | ||
176 | free(d); | ||
177 | return v; | ||
178 | } | ||
179 | } | ||
180 | free(d); | ||
181 | return 0.5; | ||
182 | } | ||
183 | |||
184 | static char * | ||
185 | _shot_file_get(Elm_Win *win) | ||
186 | { | ||
187 | char *p; | ||
188 | char *tmp = strdup(win->shot.info); | ||
189 | char *repname = NULL; | ||
190 | |||
191 | if (!tmp) return NULL; | ||
192 | |||
193 | for (p = (char *)win->shot.info; *p; p++) | ||
194 | { | ||
195 | if (!strncmp(p, "file=", 5)) | ||
196 | { | ||
197 | strcpy(tmp, p + 5); | ||
198 | if (!win->shot.repeat_count) return tmp; | ||
199 | else | ||
200 | { | ||
201 | char *dotptr = strrchr(tmp, '.'); | ||
202 | if (dotptr) | ||
203 | { | ||
204 | size_t size = sizeof(char)*(strlen(tmp) + 16); | ||
205 | repname = malloc(size); | ||
206 | strncpy(repname, tmp, dotptr - tmp); | ||
207 | snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i", | ||
208 | win->shot.shot_counter + 1); | ||
209 | strcat(repname, dotptr); | ||
210 | free(tmp); | ||
211 | return repname; | ||
212 | } | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | free(tmp); | ||
217 | if (!win->shot.repeat_count) return strdup("out.png"); | ||
218 | |||
219 | repname = malloc(sizeof(char) * 24); | ||
220 | snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1); | ||
221 | return repname; | ||
222 | } | ||
223 | |||
224 | static int | ||
225 | _shot_repeat_count_get(Elm_Win *win) | ||
226 | { | ||
227 | char *p, *pd; | ||
228 | char *d = strdup(win->shot.info); | ||
229 | |||
230 | if (!d) return 0; | ||
231 | for (p = (char *)win->shot.info; *p; p++) | ||
232 | { | ||
233 | if (!strncmp(p, "repeat=", 7)) | ||
234 | { | ||
235 | int v; | ||
236 | |||
237 | for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++) | ||
238 | { | ||
239 | *pd = *p; | ||
240 | } | ||
241 | *pd = 0; | ||
242 | v = atoi(d); | ||
243 | if (v < 0) v = 0; | ||
244 | if (v > 1000) v = 999; | ||
245 | free(d); | ||
246 | return v; | ||
247 | } | ||
248 | } | ||
249 | free(d); | ||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static char * | ||
254 | _shot_key_get(Elm_Win *win __UNUSED__) | ||
255 | { | ||
256 | return NULL; | ||
257 | } | ||
258 | |||
259 | static char * | ||
260 | _shot_flags_get(Elm_Win *win __UNUSED__) | ||
261 | { | ||
262 | return NULL; | ||
263 | } | ||
264 | |||
265 | static void | ||
266 | _shot_do(Elm_Win *win) | ||
267 | { | ||
268 | Ecore_Evas *ee; | ||
269 | Evas_Object *o; | ||
270 | unsigned int *pixels; | ||
271 | int w, h; | ||
272 | char *file, *key, *flags; | ||
273 | |||
274 | ecore_evas_manual_render(win->ee); | ||
275 | pixels = (void *)ecore_evas_buffer_pixels_get(win->ee); | ||
276 | if (!pixels) return; | ||
277 | ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h); | ||
278 | if ((w < 1) || (h < 1)) return; | ||
279 | file = _shot_file_get(win); | ||
280 | if (!file) return; | ||
281 | key = _shot_key_get(win); | ||
282 | flags = _shot_flags_get(win); | ||
283 | ee = ecore_evas_buffer_new(1, 1); | ||
284 | o = evas_object_image_add(ecore_evas_get(ee)); | ||
285 | evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee)); | ||
286 | evas_object_image_size_set(o, w, h); | ||
287 | evas_object_image_data_set(o, pixels); | ||
288 | if (!evas_object_image_save(o, file, key, flags)) | ||
289 | { | ||
290 | ERR("Cannot save window to '%s' (key '%s', flags '%s')", | ||
291 | file, key, flags); | ||
292 | } | ||
293 | free(file); | ||
294 | if (key) free(key); | ||
295 | if (flags) free(flags); | ||
296 | ecore_evas_free(ee); | ||
297 | if (win->shot.repeat_count) win->shot.shot_counter++; | ||
298 | } | ||
299 | |||
300 | static Eina_Bool | ||
301 | _shot_delay(void *data) | ||
302 | { | ||
303 | Elm_Win *win = data; | ||
304 | _shot_do(win); | ||
305 | if (win->shot.repeat_count) | ||
306 | { | ||
307 | int remainshot = (win->shot.repeat_count - win->shot.shot_counter); | ||
308 | if (remainshot > 0) return EINA_TRUE; | ||
309 | } | ||
310 | win->shot.timer = NULL; | ||
311 | elm_exit(); | ||
312 | return EINA_FALSE; | ||
313 | } | ||
314 | |||
315 | static void | ||
316 | _shot_init(Elm_Win *win) | ||
317 | { | ||
318 | if (!win->shot.info) return; | ||
319 | win->shot.repeat_count = _shot_repeat_count_get(win); | ||
320 | win->shot.shot_counter = 0; | ||
321 | } | ||
322 | |||
323 | static void | ||
324 | _shot_handle(Elm_Win *win) | ||
325 | { | ||
326 | if (!win->shot.info) return; | ||
327 | win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win); | ||
328 | } | ||
329 | |||
330 | static void | ||
331 | _elm_win_move(Ecore_Evas *ee) | ||
332 | { | ||
333 | Evas_Object *obj = ecore_evas_object_associate_get(ee); | ||
334 | Elm_Win *win; | ||
335 | int x, y; | ||
336 | |||
337 | if (!obj) return; | ||
338 | win = elm_widget_data_get(obj); | ||
339 | if (!win) return; | ||
340 | ecore_evas_geometry_get(ee, &x, &y, NULL, NULL); | ||
341 | win->screen.x = x; | ||
342 | win->screen.y = y; | ||
343 | evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL); | ||
344 | } | ||
345 | |||
346 | static void | ||
347 | _elm_win_resize(Ecore_Evas *ee) | ||
348 | { | ||
349 | Evas_Object *obj = ecore_evas_object_associate_get(ee); | ||
350 | Elm_Win *win; | ||
351 | |||
352 | if (!obj) return; | ||
353 | win = elm_widget_data_get(obj); | ||
354 | if (!win) return; | ||
355 | if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job); | ||
356 | win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win); | ||
357 | } | ||
358 | |||
359 | static void | ||
360 | _elm_win_mouse_in(Ecore_Evas *ee) | ||
361 | { | ||
362 | Evas_Object *obj; | ||
363 | Elm_Win *win; | ||
364 | |||
365 | if (!(obj = ecore_evas_object_associate_get(ee))) return; | ||
366 | if (!(win = elm_widget_data_get(obj))) return; | ||
367 | if (win->resizing) win->resizing = EINA_FALSE; | ||
368 | } | ||
369 | |||
370 | static void | ||
371 | _elm_win_focus_in(Ecore_Evas *ee) | ||
372 | { | ||
373 | Evas_Object *obj = ecore_evas_object_associate_get(ee); | ||
374 | Elm_Win *win; | ||
375 | |||
376 | if (!obj) return; | ||
377 | win = elm_widget_data_get(obj); | ||
378 | if (!win) return; | ||
379 | _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE); | ||
380 | if (!elm_widget_focus_order_get(obj)) | ||
381 | { | ||
382 | elm_widget_focus_steal(win->win_obj); | ||
383 | win->show_count++; | ||
384 | } | ||
385 | else | ||
386 | elm_widget_focus_restore(win->win_obj); | ||
387 | evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL); | ||
388 | win->focus_highlight.cur.visible = EINA_TRUE; | ||
389 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
390 | if (win->frame_obj) | ||
391 | { | ||
392 | edje_object_signal_emit(win->frame_obj, "elm,action,focus", "elm"); | ||
393 | } | ||
394 | else if (win->img_obj) | ||
395 | { | ||
396 | /* do nothing */ | ||
397 | } | ||
398 | } | ||
399 | |||
400 | static void | ||
401 | _elm_win_focus_out(Ecore_Evas *ee) | ||
402 | { | ||
403 | Evas_Object *obj = ecore_evas_object_associate_get(ee); | ||
404 | Elm_Win *win; | ||
405 | |||
406 | if (!obj) return; | ||
407 | win = elm_widget_data_get(obj); | ||
408 | if (!win) return; | ||
409 | elm_object_focus_set(win->win_obj, EINA_FALSE); | ||
410 | _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE); | ||
411 | evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL); | ||
412 | win->focus_highlight.cur.visible = EINA_FALSE; | ||
413 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
414 | if (win->frame_obj) | ||
415 | { | ||
416 | edje_object_signal_emit(win->frame_obj, "elm,action,unfocus", "elm"); | ||
417 | } | ||
418 | else if (win->img_obj) | ||
419 | { | ||
420 | /* do nothing */ | ||
421 | } | ||
422 | } | ||
423 | |||
424 | static void | ||
425 | _elm_win_state_change(Ecore_Evas *ee) | ||
426 | { | ||
427 | Evas_Object *obj; | ||
428 | Elm_Win *win; | ||
429 | Eina_Bool ch_withdrawn = EINA_FALSE; | ||
430 | Eina_Bool ch_sticky = EINA_FALSE; | ||
431 | Eina_Bool ch_iconified = EINA_FALSE; | ||
432 | Eina_Bool ch_fullscreen = EINA_FALSE; | ||
433 | Eina_Bool ch_maximized = EINA_FALSE; | ||
434 | |||
435 | if (!(obj = ecore_evas_object_associate_get(ee))) return; | ||
436 | |||
437 | if (!(win = elm_widget_data_get(obj))) return; | ||
438 | |||
439 | if (win->withdrawn != ecore_evas_withdrawn_get(win->ee)) | ||
440 | { | ||
441 | win->withdrawn = ecore_evas_withdrawn_get(win->ee); | ||
442 | ch_withdrawn = EINA_TRUE; | ||
443 | } | ||
444 | if (win->sticky != ecore_evas_sticky_get(win->ee)) | ||
445 | { | ||
446 | win->sticky = ecore_evas_sticky_get(win->ee); | ||
447 | ch_sticky = EINA_TRUE; | ||
448 | } | ||
449 | if (win->iconified != ecore_evas_iconified_get(win->ee)) | ||
450 | { | ||
451 | win->iconified = ecore_evas_iconified_get(win->ee); | ||
452 | ch_iconified = EINA_TRUE; | ||
453 | } | ||
454 | if (win->fullscreen != ecore_evas_fullscreen_get(win->ee)) | ||
455 | { | ||
456 | win->fullscreen = ecore_evas_fullscreen_get(win->ee); | ||
457 | ch_fullscreen = EINA_TRUE; | ||
458 | } | ||
459 | if (win->maximized != ecore_evas_maximized_get(win->ee)) | ||
460 | { | ||
461 | win->maximized = ecore_evas_maximized_get(win->ee); | ||
462 | ch_maximized = EINA_TRUE; | ||
463 | } | ||
464 | if ((ch_withdrawn) || (ch_iconified)) | ||
465 | { | ||
466 | if (win->withdrawn) | ||
467 | evas_object_smart_callback_call(win->win_obj, SIG_WITHDRAWN, NULL); | ||
468 | else if (win->iconified) | ||
469 | evas_object_smart_callback_call(win->win_obj, SIG_ICONIFIED, NULL); | ||
470 | else | ||
471 | evas_object_smart_callback_call(win->win_obj, SIG_NORMAL, NULL); | ||
472 | } | ||
473 | if (ch_sticky) | ||
474 | { | ||
475 | if (win->sticky) | ||
476 | evas_object_smart_callback_call(win->win_obj, SIG_STICK, NULL); | ||
477 | else | ||
478 | evas_object_smart_callback_call(win->win_obj, SIG_UNSTICK, NULL); | ||
479 | } | ||
480 | if (ch_fullscreen) | ||
481 | { | ||
482 | if (win->fullscreen) | ||
483 | evas_object_smart_callback_call(win->win_obj, SIG_FULLSCREEN, NULL); | ||
484 | else | ||
485 | evas_object_smart_callback_call(win->win_obj, SIG_UNFULLSCREEN, NULL); | ||
486 | } | ||
487 | if (ch_maximized) | ||
488 | { | ||
489 | if (win->maximized) | ||
490 | evas_object_smart_callback_call(win->win_obj, SIG_MAXIMIZED, NULL); | ||
491 | else | ||
492 | evas_object_smart_callback_call(win->win_obj, SIG_UNMAXIMIZED, NULL); | ||
493 | } | ||
494 | } | ||
495 | |||
496 | static Eina_Bool | ||
497 | _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next) | ||
498 | { | ||
499 | Elm_Win *wd = elm_widget_data_get(obj); | ||
500 | const Eina_List *items; | ||
501 | const Eina_List *list; | ||
502 | void *(*list_data_get) (const Eina_List *list); | ||
503 | |||
504 | if (!wd) | ||
505 | return EINA_FALSE; | ||
506 | list = elm_widget_sub_object_list_get(obj); | ||
507 | |||
508 | /* Focus chain */ | ||
509 | if (list) | ||
510 | { | ||
511 | if (!(items = elm_widget_focus_custom_chain_get(obj))) | ||
512 | items = list; | ||
513 | |||
514 | list_data_get = eina_list_data_get; | ||
515 | |||
516 | elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next); | ||
517 | |||
518 | if (*next) | ||
519 | return EINA_TRUE; | ||
520 | } | ||
521 | *next = (Evas_Object *)obj; | ||
522 | return EINA_FALSE; | ||
523 | } | ||
524 | |||
525 | static void | ||
526 | _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj) | ||
527 | { | ||
528 | Elm_Win *win = elm_widget_data_get(obj); | ||
529 | if (!win) return; | ||
530 | |||
531 | if (win->img_obj) | ||
532 | evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj)); | ||
533 | else | ||
534 | evas_object_focus_set(obj, elm_widget_focus_get(obj)); | ||
535 | } | ||
536 | |||
537 | static Eina_Bool | ||
538 | _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info) | ||
539 | { | ||
540 | if (type == EVAS_CALLBACK_KEY_DOWN) | ||
541 | { | ||
542 | Evas_Event_Key_Down *ev = event_info; | ||
543 | if (!strcmp(ev->keyname, "Tab")) | ||
544 | { | ||
545 | if (evas_key_modifier_is_set(ev->modifiers, "Shift")) | ||
546 | elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS); | ||
547 | else | ||
548 | elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT); | ||
549 | ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; | ||
550 | return EINA_TRUE; | ||
551 | } | ||
552 | else if ((!strcmp(ev->keyname, "Left")) || | ||
553 | ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string))) | ||
554 | { | ||
555 | //TODO : woohyun jung | ||
556 | } | ||
557 | else if ((!strcmp(ev->keyname, "Right")) || | ||
558 | ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string))) | ||
559 | { | ||
560 | //TODO : woohyun jung | ||
561 | } | ||
562 | else if ((!strcmp(ev->keyname, "Up")) || | ||
563 | ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string))) | ||
564 | { | ||
565 | //TODO : woohyun jung | ||
566 | } | ||
567 | else if ((!strcmp(ev->keyname, "Down")) || | ||
568 | ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string))) | ||
569 | { | ||
570 | //TODO : woohyun jung | ||
571 | } | ||
572 | } | ||
573 | |||
574 | return EINA_FALSE; | ||
575 | } | ||
576 | |||
577 | static void | ||
578 | _deferred_ecore_evas_free(void *data) | ||
579 | { | ||
580 | ecore_evas_free(data); | ||
581 | _elm_win_deferred_free--; | ||
582 | } | ||
583 | |||
584 | static void | ||
585 | _elm_win_obj_callback_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
586 | { | ||
587 | Elm_Win *win = data; | ||
588 | |||
589 | if (!win->show_count) win->show_count++; | ||
590 | if (win->shot.info) _shot_handle(win); | ||
591 | } | ||
592 | |||
593 | static void | ||
594 | _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
595 | { | ||
596 | Elm_Win *win = data; | ||
597 | |||
598 | if (win->frame_obj) | ||
599 | { | ||
600 | evas_object_hide(win->frame_obj); | ||
601 | } | ||
602 | else if (win->img_obj) | ||
603 | { | ||
604 | evas_object_hide(win->img_obj); | ||
605 | } | ||
606 | if (win->pointer.obj) | ||
607 | { | ||
608 | evas_object_hide(win->pointer.obj); | ||
609 | ecore_evas_hide(win->pointer.ee); | ||
610 | } | ||
611 | } | ||
612 | |||
613 | static void | ||
614 | _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__) | ||
615 | { | ||
616 | Elm_Win *win = data; | ||
617 | Evas_Object *child, *child2 = NULL; | ||
618 | |||
619 | if (win->parent) | ||
620 | { | ||
621 | evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL, | ||
622 | _elm_win_obj_callback_parent_del, win); | ||
623 | win->parent = NULL; | ||
624 | } | ||
625 | if (win->autodel_clear) *(win->autodel_clear) = -1; | ||
626 | _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj); | ||
627 | while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data); | ||
628 | if (win->ee) | ||
629 | { | ||
630 | ecore_evas_callback_delete_request_set(win->ee, NULL); | ||
631 | ecore_evas_callback_resize_set(win->ee, NULL); | ||
632 | } | ||
633 | if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job); | ||
634 | if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job); | ||
635 | if (win->shot.info) eina_stringshare_del(win->shot.info); | ||
636 | if (win->shot.timer) ecore_timer_del(win->shot.timer); | ||
637 | evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL, | ||
638 | _elm_win_obj_callback_del, win); | ||
639 | child = evas_object_bottom_get(win->evas); | ||
640 | while (child) | ||
641 | { | ||
642 | /* if the object we see *IS* the window object (because we are | ||
643 | * faking a parent object inside the canvas), then skip it and | ||
644 | * go to the next one */ | ||
645 | if (child == obj) | ||
646 | { | ||
647 | child = evas_object_above_get(child); | ||
648 | if (!child) break; | ||
649 | } | ||
650 | /* if we are using the next object above from the previous loop */ | ||
651 | if (child == child2) | ||
652 | { | ||
653 | /* this object has refcounts from the previous loop */ | ||
654 | child2 = evas_object_above_get(child); | ||
655 | if (child2) evas_object_ref(child2); | ||
656 | evas_object_del(child); | ||
657 | /* so unref from previous loop */ | ||
658 | evas_object_unref(child); | ||
659 | child = child2; | ||
660 | } | ||
661 | else | ||
662 | { | ||
663 | /* just delete as normal (probably only first object */ | ||
664 | child2 = evas_object_above_get(child); | ||
665 | if (child2) evas_object_ref(child2); | ||
666 | evas_object_del(child); | ||
667 | child = child2; | ||
668 | } | ||
669 | } | ||
670 | #ifdef HAVE_ELEMENTARY_X | ||
671 | if (win->client_message_handler) | ||
672 | ecore_event_handler_del(win->client_message_handler); | ||
673 | #endif | ||
674 | // FIXME: Why are we flushing edje on every window destroy ?? | ||
675 | // edje_file_cache_flush(); | ||
676 | // edje_collection_cache_flush(); | ||
677 | // evas_image_cache_flush(win->evas); | ||
678 | // evas_font_cache_flush(win->evas); | ||
679 | // FIXME: we are in the del handler for the object and delete the canvas | ||
680 | // that lives under it from the handler... nasty. deferring doesn't help either | ||
681 | |||
682 | if (win->img_obj) | ||
683 | { | ||
684 | win->img_obj = NULL; | ||
685 | } | ||
686 | else | ||
687 | { | ||
688 | if (win->ee) | ||
689 | { | ||
690 | ecore_job_add(_deferred_ecore_evas_free, win->ee); | ||
691 | _elm_win_deferred_free++; | ||
692 | } | ||
693 | } | ||
694 | |||
695 | _elm_win_focus_highlight_shutdown(win); | ||
696 | eina_stringshare_del(win->focus_highlight.style); | ||
697 | |||
698 | if (win->title) eina_stringshare_del(win->title); | ||
699 | if (win->icon_name) eina_stringshare_del(win->icon_name); | ||
700 | if (win->role) eina_stringshare_del(win->role); | ||
701 | if (win->icon) evas_object_del(win->icon); | ||
702 | |||
703 | free(win); | ||
704 | |||
705 | if ((!_elm_win_list) && | ||
706 | (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)) | ||
707 | { | ||
708 | edje_file_cache_flush(); | ||
709 | edje_collection_cache_flush(); | ||
710 | evas_image_cache_flush(e); | ||
711 | evas_font_cache_flush(e); | ||
712 | elm_exit(); | ||
713 | } | ||
714 | } | ||
715 | |||
716 | static void | ||
717 | _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
718 | { | ||
719 | Elm_Win *win = data; | ||
720 | if (!win->img_obj) return; | ||
721 | evas_object_event_callback_del_full | ||
722 | (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win); | ||
723 | evas_object_del(win->img_obj); | ||
724 | } | ||
725 | |||
726 | static void | ||
727 | _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
728 | { | ||
729 | Elm_Win *win = data; | ||
730 | if (obj == win->parent) win->parent = NULL; | ||
731 | } | ||
732 | |||
733 | static void | ||
734 | _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y) | ||
735 | { | ||
736 | Elm_Win *win = data; | ||
737 | |||
738 | if (win->img_obj) | ||
739 | { | ||
740 | if ((x != win->screen.x) || (y != win->screen.y)) | ||
741 | { | ||
742 | win->screen.x = x; | ||
743 | win->screen.y = y; | ||
744 | evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL); | ||
745 | } | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | evas_object_move(obj, x, y); | ||
750 | } | ||
751 | } | ||
752 | |||
753 | static void | ||
754 | _elm_win_obj_intercept_show(void *data, Evas_Object *obj) | ||
755 | { | ||
756 | Elm_Win *win = data; | ||
757 | // this is called to make sure all smart containers have calculated their | ||
758 | // sizes BEFORE we show the window to make sure it initially appears at | ||
759 | // our desired size (ie min size is known first) | ||
760 | evas_smart_objects_calculate(evas_object_evas_get(obj)); | ||
761 | if (win->frame_obj) | ||
762 | { | ||
763 | evas_object_show(win->frame_obj); | ||
764 | } | ||
765 | else if (win->img_obj) | ||
766 | { | ||
767 | evas_object_show(win->img_obj); | ||
768 | } | ||
769 | if (win->pointer.obj) | ||
770 | { | ||
771 | ecore_evas_show(win->pointer.ee); | ||
772 | evas_object_show(win->pointer.obj); | ||
773 | /* ecore_evas_wayland_pointer_set(win->pointer.ee, 10, 10); */ | ||
774 | } | ||
775 | evas_object_show(obj); | ||
776 | } | ||
777 | |||
778 | static void | ||
779 | _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
780 | { | ||
781 | Elm_Win *win = data; | ||
782 | |||
783 | if (ecore_evas_override_get(win->ee)) | ||
784 | { | ||
785 | Evas_Coord x, y; | ||
786 | |||
787 | evas_object_geometry_get(obj, &x, &y, NULL, NULL); | ||
788 | win->screen.x = x; | ||
789 | win->screen.y = y; | ||
790 | evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL); | ||
791 | } | ||
792 | if (win->frame_obj) | ||
793 | { | ||
794 | Evas_Coord x, y; | ||
795 | |||
796 | evas_object_geometry_get(obj, &x, &y, NULL, NULL); | ||
797 | win->screen.x = x; | ||
798 | win->screen.y = y; | ||
799 | } | ||
800 | else if (win->img_obj) | ||
801 | { | ||
802 | Evas_Coord x, y; | ||
803 | |||
804 | evas_object_geometry_get(obj, &x, &y, NULL, NULL); | ||
805 | win->screen.x = x; | ||
806 | win->screen.y = y; | ||
807 | // evas_object_move(win->img_obj, x, y); | ||
808 | } | ||
809 | } | ||
810 | |||
811 | static void | ||
812 | _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
813 | { | ||
814 | Elm_Win *win = data; | ||
815 | |||
816 | if (win->frame_obj) | ||
817 | { | ||
818 | } | ||
819 | else if (win->img_obj) | ||
820 | { | ||
821 | Evas_Coord w = 1, h = 1; | ||
822 | |||
823 | evas_object_geometry_get(obj, NULL, NULL, &w, &h); | ||
824 | if (win->constrain) | ||
825 | { | ||
826 | int sw, sh; | ||
827 | ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh); | ||
828 | w = MIN(w, sw); | ||
829 | h = MIN(h, sh); | ||
830 | } | ||
831 | if (w < 1) w = 1; | ||
832 | if (h < 1) h = 1; | ||
833 | evas_object_image_size_set(win->img_obj, w, h); | ||
834 | } | ||
835 | } | ||
836 | |||
837 | static void | ||
838 | _elm_win_delete_request(Ecore_Evas *ee) | ||
839 | { | ||
840 | Evas_Object *obj = ecore_evas_object_associate_get(ee); | ||
841 | Elm_Win *win; | ||
842 | if (strcmp(elm_widget_type_get(obj), "win")) return; | ||
843 | |||
844 | win = elm_widget_data_get(obj); | ||
845 | if (!win) return; | ||
846 | int autodel = win->autodel; | ||
847 | win->autodel_clear = &autodel; | ||
848 | evas_object_ref(win->win_obj); | ||
849 | evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL); | ||
850 | // FIXME: if above callback deletes - then the below will be invalid | ||
851 | if (autodel) evas_object_del(win->win_obj); | ||
852 | else win->autodel_clear = NULL; | ||
853 | evas_object_unref(win->win_obj); | ||
854 | } | ||
855 | |||
856 | static void | ||
857 | _elm_win_resize_job(void *data) | ||
858 | { | ||
859 | Elm_Win *win = data; | ||
860 | const Eina_List *l; | ||
861 | Evas_Object *obj; | ||
862 | int w, h; | ||
863 | |||
864 | win->deferred_resize_job = NULL; | ||
865 | ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h); | ||
866 | if (win->constrain) | ||
867 | { | ||
868 | int sw, sh; | ||
869 | ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh); | ||
870 | w = MIN(w, sw); | ||
871 | h = MIN(h, sh); | ||
872 | } | ||
873 | if (win->frame_obj) | ||
874 | { | ||
875 | evas_object_resize(win->frame_obj, w, h); | ||
876 | } | ||
877 | else if (win->img_obj) | ||
878 | { | ||
879 | } | ||
880 | evas_object_resize(win->win_obj, w, h); | ||
881 | EINA_LIST_FOREACH(win->subobjs, l, obj) | ||
882 | { | ||
883 | evas_object_move(obj, 0, 0); | ||
884 | evas_object_resize(obj, w, h); | ||
885 | } | ||
886 | } | ||
887 | |||
888 | #ifdef HAVE_ELEMENTARY_X | ||
889 | static void | ||
890 | _elm_win_xwindow_get(Elm_Win *win) | ||
891 | { | ||
892 | win->xwin = 0; | ||
893 | |||
894 | #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name)) | ||
895 | if (ENGINE_COMPARE(ELM_SOFTWARE_X11)) | ||
896 | { | ||
897 | if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee); | ||
898 | } | ||
899 | else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) || | ||
900 | ENGINE_COMPARE(ELM_SOFTWARE_FB) || | ||
901 | ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) || | ||
902 | ENGINE_COMPARE(ELM_SOFTWARE_SDL) || | ||
903 | ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) || | ||
904 | ENGINE_COMPARE(ELM_OPENGL_SDL) || | ||
905 | ENGINE_COMPARE(ELM_OPENGL_COCOA)) | ||
906 | { | ||
907 | } | ||
908 | else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11)) | ||
909 | { | ||
910 | if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee); | ||
911 | } | ||
912 | else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11)) | ||
913 | { | ||
914 | if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee); | ||
915 | } | ||
916 | /* killed | ||
917 | else if (ENGINE_COMPARE(ELM_XRENDER_X11)) | ||
918 | { | ||
919 | if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee); | ||
920 | } | ||
921 | */ | ||
922 | else if (ENGINE_COMPARE(ELM_OPENGL_X11)) | ||
923 | { | ||
924 | if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee); | ||
925 | } | ||
926 | else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32)) | ||
927 | { | ||
928 | if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee); | ||
929 | } | ||
930 | #undef ENGINE_COMPARE | ||
931 | } | ||
932 | #endif | ||
933 | |||
934 | #ifdef HAVE_ELEMENTARY_X | ||
935 | static void | ||
936 | _elm_win_xwin_update(Elm_Win *win) | ||
937 | { | ||
938 | const char *s; | ||
939 | |||
940 | _elm_win_xwindow_get(win); | ||
941 | if (win->parent) | ||
942 | { | ||
943 | Elm_Win *win2; | ||
944 | |||
945 | win2 = elm_widget_data_get(win->parent); | ||
946 | if (win2) | ||
947 | { | ||
948 | if (win->xwin) | ||
949 | ecore_x_icccm_transient_for_set(win->xwin, win2->xwin); | ||
950 | } | ||
951 | } | ||
952 | |||
953 | if (!win->xwin) return; /* nothing more to do */ | ||
954 | |||
955 | s = win->title; | ||
956 | if (!s) s = _elm_appname; | ||
957 | if (!s) s = ""; | ||
958 | if (win->icon_name) s = win->icon_name; | ||
959 | ecore_x_icccm_icon_name_set(win->xwin, s); | ||
960 | ecore_x_netwm_icon_name_set(win->xwin, s); | ||
961 | |||
962 | s = win->role; | ||
963 | if (s) ecore_x_icccm_window_role_set(win->xwin, s); | ||
964 | |||
965 | // set window icon | ||
966 | if (win->icon) | ||
967 | { | ||
968 | void *data; | ||
969 | |||
970 | data = evas_object_image_data_get(win->icon, EINA_FALSE); | ||
971 | if (data) | ||
972 | { | ||
973 | Ecore_X_Icon ic; | ||
974 | int w = 0, h = 0, stride, x, y; | ||
975 | unsigned char *p; | ||
976 | unsigned int *p2; | ||
977 | |||
978 | evas_object_image_size_get(win->icon, &w, &h); | ||
979 | stride = evas_object_image_stride_get(win->icon); | ||
980 | if ((w > 0) && (h > 0) && | ||
981 | (stride >= (int)(w * sizeof(unsigned int)))) | ||
982 | { | ||
983 | ic.width = w; | ||
984 | ic.height = h; | ||
985 | ic.data = malloc(w * h * sizeof(unsigned int)); | ||
986 | |||
987 | if (ic.data) | ||
988 | { | ||
989 | p = (unsigned char *)data; | ||
990 | p2 = (unsigned int *)ic.data; | ||
991 | for (y = 0; y < h; y++) | ||
992 | { | ||
993 | for (x = 0; x < w; x++) | ||
994 | { | ||
995 | *p2 = *((unsigned int *)p); | ||
996 | p += sizeof(unsigned int); | ||
997 | p2++; | ||
998 | } | ||
999 | p += (stride - (w * sizeof(unsigned int))); | ||
1000 | } | ||
1001 | ecore_x_netwm_icons_set(win->xwin, &ic, 1); | ||
1002 | free(ic.data); | ||
1003 | } | ||
1004 | } | ||
1005 | evas_object_image_data_set(win->icon, data); | ||
1006 | } | ||
1007 | } | ||
1008 | |||
1009 | switch (win->type) | ||
1010 | { | ||
1011 | case ELM_WIN_BASIC: | ||
1012 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL); | ||
1013 | break; | ||
1014 | case ELM_WIN_DIALOG_BASIC: | ||
1015 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG); | ||
1016 | break; | ||
1017 | case ELM_WIN_DESKTOP: | ||
1018 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP); | ||
1019 | break; | ||
1020 | case ELM_WIN_DOCK: | ||
1021 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK); | ||
1022 | break; | ||
1023 | case ELM_WIN_TOOLBAR: | ||
1024 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR); | ||
1025 | break; | ||
1026 | case ELM_WIN_MENU: | ||
1027 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU); | ||
1028 | break; | ||
1029 | case ELM_WIN_UTILITY: | ||
1030 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY); | ||
1031 | break; | ||
1032 | case ELM_WIN_SPLASH: | ||
1033 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH); | ||
1034 | break; | ||
1035 | case ELM_WIN_DROPDOWN_MENU: | ||
1036 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU); | ||
1037 | break; | ||
1038 | case ELM_WIN_POPUP_MENU: | ||
1039 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU); | ||
1040 | break; | ||
1041 | case ELM_WIN_TOOLTIP: | ||
1042 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP); | ||
1043 | break; | ||
1044 | case ELM_WIN_NOTIFICATION: | ||
1045 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION); | ||
1046 | break; | ||
1047 | case ELM_WIN_COMBO: | ||
1048 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO); | ||
1049 | break; | ||
1050 | case ELM_WIN_DND: | ||
1051 | ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND); | ||
1052 | break; | ||
1053 | default: | ||
1054 | break; | ||
1055 | } | ||
1056 | ecore_x_e_virtual_keyboard_state_set | ||
1057 | (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode); | ||
1058 | if (win->indmode == ELM_WIN_INDICATOR_SHOW) | ||
1059 | ecore_x_e_illume_indicator_state_set | ||
1060 | (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON); | ||
1061 | else if (win->indmode == ELM_WIN_INDICATOR_HIDE) | ||
1062 | ecore_x_e_illume_indicator_state_set | ||
1063 | (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF); | ||
1064 | } | ||
1065 | #endif | ||
1066 | |||
1067 | static void | ||
1068 | _elm_win_eval_subobjs(Evas_Object *obj) | ||
1069 | { | ||
1070 | const Eina_List *l; | ||
1071 | const Evas_Object *child; | ||
1072 | |||
1073 | Elm_Win *win = elm_widget_data_get(obj); | ||
1074 | Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1; | ||
1075 | int xx = 1, xy = 1; | ||
1076 | double wx, wy; | ||
1077 | |||
1078 | EINA_LIST_FOREACH(win->subobjs, l, child) | ||
1079 | { | ||
1080 | evas_object_size_hint_weight_get(child, &wx, &wy); | ||
1081 | if (wx == 0.0) xx = 0; | ||
1082 | if (wy == 0.0) xy = 0; | ||
1083 | |||
1084 | evas_object_size_hint_min_get(child, &w, &h); | ||
1085 | if (w < 1) w = 1; | ||
1086 | if (h < 1) h = 1; | ||
1087 | if (w > minw) minw = w; | ||
1088 | if (h > minh) minh = h; | ||
1089 | |||
1090 | evas_object_size_hint_max_get(child, &w, &h); | ||
1091 | if (w < 1) w = -1; | ||
1092 | if (h < 1) h = -1; | ||
1093 | if (maxw == -1) maxw = w; | ||
1094 | else if ((w > 0) && (w < maxw)) maxw = w; | ||
1095 | if (maxh == -1) maxh = h; | ||
1096 | else if ((h > 0) && (h < maxh)) maxh = h; | ||
1097 | } | ||
1098 | if (!xx) maxw = minw; | ||
1099 | else maxw = 32767; | ||
1100 | if (!xy) maxh = minh; | ||
1101 | else maxh = 32767; | ||
1102 | evas_object_size_hint_min_set(obj, minw, minh); | ||
1103 | evas_object_size_hint_max_set(obj, maxw, maxh); | ||
1104 | evas_object_geometry_get(obj, NULL, NULL, &w, &h); | ||
1105 | if (w < minw) w = minw; | ||
1106 | if (h < minh) h = minh; | ||
1107 | if ((maxw >= 0) && (w > maxw)) w = maxw; | ||
1108 | if ((maxh >= 0) && (h > maxh)) h = maxh; | ||
1109 | evas_object_resize(obj, w, h); | ||
1110 | } | ||
1111 | |||
1112 | static void | ||
1113 | _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
1114 | { | ||
1115 | Elm_Win *win = elm_widget_data_get(data); | ||
1116 | win->subobjs = eina_list_remove(win->subobjs, obj); | ||
1117 | _elm_win_eval_subobjs(win->win_obj); | ||
1118 | } | ||
1119 | |||
1120 | static void | ||
1121 | _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1122 | { | ||
1123 | _elm_win_eval_subobjs(data); | ||
1124 | } | ||
1125 | |||
1126 | void | ||
1127 | _elm_win_shutdown(void) | ||
1128 | { | ||
1129 | while (_elm_win_list) | ||
1130 | evas_object_del(_elm_win_list->data); | ||
1131 | } | ||
1132 | |||
1133 | void | ||
1134 | _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme) | ||
1135 | { | ||
1136 | const Eina_List *l; | ||
1137 | Evas_Object *obj; | ||
1138 | |||
1139 | if (!use_theme) | ||
1140 | { | ||
1141 | EINA_LIST_FOREACH(_elm_win_list, l, obj) | ||
1142 | elm_widget_theme(obj); | ||
1143 | } | ||
1144 | else | ||
1145 | { | ||
1146 | EINA_LIST_FOREACH(_elm_win_list, l, obj) | ||
1147 | elm_widget_theme_specific(obj, th, EINA_FALSE); | ||
1148 | } | ||
1149 | } | ||
1150 | |||
1151 | void | ||
1152 | _elm_win_translate(void) | ||
1153 | { | ||
1154 | const Eina_List *l; | ||
1155 | Evas_Object *obj; | ||
1156 | |||
1157 | EINA_LIST_FOREACH(_elm_win_list, l, obj) | ||
1158 | elm_widget_translate(obj); | ||
1159 | } | ||
1160 | |||
1161 | #ifdef HAVE_ELEMENTARY_X | ||
1162 | static Eina_Bool | ||
1163 | _elm_win_client_message(void *data, int type __UNUSED__, void *event) | ||
1164 | { | ||
1165 | Elm_Win *win = data; | ||
1166 | Ecore_X_Event_Client_Message *e = event; | ||
1167 | |||
1168 | if (e->format != 32) return ECORE_CALLBACK_PASS_ON; | ||
1169 | if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH) | ||
1170 | { | ||
1171 | if ((unsigned)e->data.l[0] == win->xwin) | ||
1172 | { | ||
1173 | Evas *evas = evas_object_evas_get(win->win_obj); | ||
1174 | if (evas) | ||
1175 | { | ||
1176 | edje_file_cache_flush(); | ||
1177 | edje_collection_cache_flush(); | ||
1178 | evas_image_cache_flush(evas); | ||
1179 | evas_font_cache_flush(evas); | ||
1180 | } | ||
1181 | } | ||
1182 | } | ||
1183 | else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP) | ||
1184 | { | ||
1185 | if ((unsigned)e->data.l[0] == win->xwin) | ||
1186 | { | ||
1187 | Evas *evas = evas_object_evas_get(win->win_obj); | ||
1188 | if (evas) | ||
1189 | { | ||
1190 | edje_file_cache_flush(); | ||
1191 | edje_collection_cache_flush(); | ||
1192 | evas_image_cache_flush(evas); | ||
1193 | evas_font_cache_flush(evas); | ||
1194 | evas_render_dump(evas); | ||
1195 | } | ||
1196 | } | ||
1197 | } | ||
1198 | return ECORE_CALLBACK_PASS_ON; | ||
1199 | } | ||
1200 | #endif | ||
1201 | |||
1202 | static void | ||
1203 | _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1204 | { | ||
1205 | Elm_Win *win = data; | ||
1206 | |||
1207 | win->focus_highlight.geometry_changed = EINA_TRUE; | ||
1208 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
1209 | } | ||
1210 | |||
1211 | static void | ||
1212 | _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1213 | { | ||
1214 | Elm_Win *win = data; | ||
1215 | |||
1216 | win->focus_highlight.geometry_changed = EINA_TRUE; | ||
1217 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
1218 | } | ||
1219 | |||
1220 | static void | ||
1221 | _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1222 | { | ||
1223 | Elm_Win *win = data; | ||
1224 | |||
1225 | win->focus_highlight.cur.target = NULL; | ||
1226 | |||
1227 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
1228 | } | ||
1229 | |||
1230 | static void | ||
1231 | _elm_win_focus_target_callbacks_add(Elm_Win *win) | ||
1232 | { | ||
1233 | Evas_Object *obj = win->focus_highlight.cur.target; | ||
1234 | |||
1235 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, | ||
1236 | _elm_win_focus_target_move, win); | ||
1237 | evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, | ||
1238 | _elm_win_focus_target_resize, win); | ||
1239 | evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, | ||
1240 | _elm_win_focus_target_del, win); | ||
1241 | } | ||
1242 | |||
1243 | static void | ||
1244 | _elm_win_focus_target_callbacks_del(Elm_Win *win) | ||
1245 | { | ||
1246 | Evas_Object *obj = win->focus_highlight.cur.target; | ||
1247 | |||
1248 | evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE, | ||
1249 | _elm_win_focus_target_move, win); | ||
1250 | evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE, | ||
1251 | _elm_win_focus_target_resize, win); | ||
1252 | evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, | ||
1253 | _elm_win_focus_target_del, win); | ||
1254 | } | ||
1255 | |||
1256 | static Evas_Object * | ||
1257 | _elm_win_focus_target_get(Evas_Object *obj) | ||
1258 | { | ||
1259 | Evas_Object *o = obj; | ||
1260 | |||
1261 | do | ||
1262 | { | ||
1263 | if (elm_widget_is(o)) | ||
1264 | { | ||
1265 | if (!elm_widget_highlight_ignore_get(o)) | ||
1266 | break; | ||
1267 | o = elm_widget_parent_get(o); | ||
1268 | if (!o) | ||
1269 | o = evas_object_smart_parent_get(o); | ||
1270 | } | ||
1271 | else | ||
1272 | { | ||
1273 | o = elm_widget_parent_widget_get(o); | ||
1274 | if (!o) | ||
1275 | o = evas_object_smart_parent_get(o); | ||
1276 | } | ||
1277 | } | ||
1278 | while (o); | ||
1279 | |||
1280 | return o; | ||
1281 | } | ||
1282 | |||
1283 | static void | ||
1284 | _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info) | ||
1285 | { | ||
1286 | Evas_Object *obj = event_info, *target; | ||
1287 | Elm_Win *win = data; | ||
1288 | |||
1289 | if (win->focus_highlight.cur.target == obj) | ||
1290 | return; | ||
1291 | |||
1292 | target = _elm_win_focus_target_get(obj); | ||
1293 | win->focus_highlight.cur.target = target; | ||
1294 | if (elm_widget_highlight_in_theme_get(target)) | ||
1295 | win->focus_highlight.cur.handled = EINA_TRUE; | ||
1296 | else | ||
1297 | _elm_win_focus_target_callbacks_add(win); | ||
1298 | |||
1299 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
1300 | } | ||
1301 | |||
1302 | static void | ||
1303 | _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__) | ||
1304 | { | ||
1305 | Elm_Win *win = data; | ||
1306 | |||
1307 | if (!win->focus_highlight.cur.target) | ||
1308 | return; | ||
1309 | |||
1310 | if (!win->focus_highlight.cur.handled) | ||
1311 | _elm_win_focus_target_callbacks_del(win); | ||
1312 | win->focus_highlight.cur.target = NULL; | ||
1313 | win->focus_highlight.cur.handled = EINA_FALSE; | ||
1314 | |||
1315 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
1316 | } | ||
1317 | |||
1318 | static void | ||
1319 | _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__) | ||
1320 | { | ||
1321 | evas_object_hide(obj); | ||
1322 | } | ||
1323 | |||
1324 | static void | ||
1325 | _elm_win_focus_highlight_init(Elm_Win *win) | ||
1326 | { | ||
1327 | evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, | ||
1328 | _elm_win_object_focus_in, win); | ||
1329 | evas_event_callback_add(win->evas, | ||
1330 | EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, | ||
1331 | _elm_win_object_focus_out, win); | ||
1332 | |||
1333 | win->focus_highlight.cur.target = evas_focus_get(win->evas); | ||
1334 | |||
1335 | win->focus_highlight.top = edje_object_add(win->evas); | ||
1336 | win->focus_highlight.changed_theme = EINA_TRUE; | ||
1337 | edje_object_signal_callback_add(win->focus_highlight.top, | ||
1338 | "elm,action,focus,hide,end", "", | ||
1339 | _elm_win_focus_highlight_hide, NULL); | ||
1340 | edje_object_signal_callback_add(win->focus_highlight.top, | ||
1341 | "elm,action,focus,anim,end", "", | ||
1342 | _elm_win_focus_highlight_anim_end, win); | ||
1343 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
1344 | } | ||
1345 | |||
1346 | static void | ||
1347 | _elm_win_focus_highlight_shutdown(Elm_Win *win) | ||
1348 | { | ||
1349 | _elm_win_focus_highlight_reconfigure_job_stop(win); | ||
1350 | if (win->focus_highlight.cur.target) | ||
1351 | { | ||
1352 | _elm_win_focus_target_callbacks_del(win); | ||
1353 | win->focus_highlight.cur.target = NULL; | ||
1354 | } | ||
1355 | if (win->focus_highlight.top) | ||
1356 | { | ||
1357 | evas_object_del(win->focus_highlight.top); | ||
1358 | win->focus_highlight.top = NULL; | ||
1359 | } | ||
1360 | |||
1361 | evas_event_callback_del_full(win->evas, | ||
1362 | EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, | ||
1363 | _elm_win_object_focus_in, win); | ||
1364 | evas_event_callback_del_full(win->evas, | ||
1365 | EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, | ||
1366 | _elm_win_object_focus_out, win); | ||
1367 | } | ||
1368 | |||
1369 | static void | ||
1370 | _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible) | ||
1371 | { | ||
1372 | Evas_Object *top; | ||
1373 | |||
1374 | top = win->focus_highlight.top; | ||
1375 | if (visible) | ||
1376 | { | ||
1377 | if (top) | ||
1378 | { | ||
1379 | evas_object_show(top); | ||
1380 | edje_object_signal_emit(top, "elm,action,focus,show", "elm"); | ||
1381 | } | ||
1382 | } | ||
1383 | else | ||
1384 | { | ||
1385 | if (top) | ||
1386 | edje_object_signal_emit(top, "elm,action,focus,hide", "elm"); | ||
1387 | } | ||
1388 | } | ||
1389 | |||
1390 | static void | ||
1391 | _elm_win_focus_highlight_reconfigure_job(void *data) | ||
1392 | { | ||
1393 | _elm_win_focus_highlight_reconfigure((Elm_Win *)data); | ||
1394 | } | ||
1395 | |||
1396 | static void | ||
1397 | _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win) | ||
1398 | { | ||
1399 | if (win->focus_highlight.reconf_job) | ||
1400 | ecore_job_del(win->focus_highlight.reconf_job); | ||
1401 | win->focus_highlight.reconf_job = ecore_job_add( | ||
1402 | _elm_win_focus_highlight_reconfigure_job, win); | ||
1403 | } | ||
1404 | |||
1405 | static void | ||
1406 | _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win) | ||
1407 | { | ||
1408 | if (win->focus_highlight.reconf_job) | ||
1409 | ecore_job_del(win->focus_highlight.reconf_job); | ||
1410 | win->focus_highlight.reconf_job = NULL; | ||
1411 | } | ||
1412 | |||
1413 | static void | ||
1414 | _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj) | ||
1415 | { | ||
1416 | Evas_Object *clip, *target = win->focus_highlight.cur.target; | ||
1417 | Evas_Coord x, y, w, h; | ||
1418 | |||
1419 | clip = evas_object_clip_get(target); | ||
1420 | evas_object_geometry_get(target, &x, &y, &w, &h); | ||
1421 | |||
1422 | evas_object_move(obj, x, y); | ||
1423 | evas_object_resize(obj, w, h); | ||
1424 | evas_object_clip_set(obj, clip); | ||
1425 | } | ||
1426 | |||
1427 | static void | ||
1428 | _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj) | ||
1429 | { | ||
1430 | Evas_Coord tx, ty, tw, th; | ||
1431 | Evas_Coord w, h, px, py, pw, ph; | ||
1432 | Edje_Message_Int_Set *m; | ||
1433 | Evas_Object *previous = win->focus_highlight.prev.target; | ||
1434 | Evas_Object *target = win->focus_highlight.cur.target; | ||
1435 | |||
1436 | evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h); | ||
1437 | evas_object_geometry_get(target, &tx, &ty, &tw, &th); | ||
1438 | evas_object_geometry_get(previous, &px, &py, &pw, &ph); | ||
1439 | evas_object_move(obj, 0, 0); | ||
1440 | evas_object_resize(obj, tw, th); | ||
1441 | evas_object_clip_unset(obj); | ||
1442 | |||
1443 | m = alloca(sizeof(*m) + (sizeof(int) * 8)); | ||
1444 | m->count = 8; | ||
1445 | m->val[0] = px; | ||
1446 | m->val[1] = py; | ||
1447 | m->val[2] = pw; | ||
1448 | m->val[3] = ph; | ||
1449 | m->val[4] = tx; | ||
1450 | m->val[5] = ty; | ||
1451 | m->val[6] = tw; | ||
1452 | m->val[7] = th; | ||
1453 | edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m); | ||
1454 | } | ||
1455 | |||
1456 | static void | ||
1457 | _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__) | ||
1458 | { | ||
1459 | Elm_Win *win = data; | ||
1460 | _elm_win_focus_highlight_simple_setup(win, obj); | ||
1461 | } | ||
1462 | |||
1463 | static void | ||
1464 | _elm_win_focus_highlight_reconfigure(Elm_Win *win) | ||
1465 | { | ||
1466 | Evas_Object *target = win->focus_highlight.cur.target; | ||
1467 | Evas_Object *previous = win->focus_highlight.prev.target; | ||
1468 | Evas_Object *top = win->focus_highlight.top; | ||
1469 | Eina_Bool visible_changed; | ||
1470 | Eina_Bool common_visible; | ||
1471 | const char *sig = NULL; | ||
1472 | |||
1473 | _elm_win_focus_highlight_reconfigure_job_stop(win); | ||
1474 | |||
1475 | visible_changed = (win->focus_highlight.cur.visible != | ||
1476 | win->focus_highlight.prev.visible); | ||
1477 | |||
1478 | if ((target == previous) && (!visible_changed) && | ||
1479 | (!win->focus_highlight.geometry_changed)) | ||
1480 | return; | ||
1481 | |||
1482 | if ((previous) && (win->focus_highlight.prev.handled)) | ||
1483 | elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm"); | ||
1484 | |||
1485 | if (!target) | ||
1486 | common_visible = EINA_FALSE; | ||
1487 | else if (win->focus_highlight.cur.handled) | ||
1488 | { | ||
1489 | common_visible = EINA_FALSE; | ||
1490 | if (win->focus_highlight.cur.visible) | ||
1491 | sig = "elm,action,focus_highlight,show"; | ||
1492 | else | ||
1493 | sig = "elm,action,focus_highlight,hide"; | ||
1494 | } | ||
1495 | else | ||
1496 | common_visible = win->focus_highlight.cur.visible; | ||
1497 | |||
1498 | _elm_win_focus_highlight_visible_set(win, common_visible); | ||
1499 | if (sig) | ||
1500 | elm_widget_signal_emit(target, sig, "elm"); | ||
1501 | |||
1502 | if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled)) | ||
1503 | goto the_end; | ||
1504 | |||
1505 | if (win->focus_highlight.changed_theme) | ||
1506 | { | ||
1507 | const char *str; | ||
1508 | if (win->focus_highlight.style) | ||
1509 | str = win->focus_highlight.style; | ||
1510 | else | ||
1511 | str = "default"; | ||
1512 | _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top", | ||
1513 | str); | ||
1514 | win->focus_highlight.changed_theme = EINA_FALSE; | ||
1515 | |||
1516 | if (_elm_config->focus_highlight_animate) | ||
1517 | { | ||
1518 | str = edje_object_data_get(win->focus_highlight.top, "animate"); | ||
1519 | win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on"))); | ||
1520 | } | ||
1521 | } | ||
1522 | |||
1523 | if ((win->focus_highlight.top_animate) && (previous) && | ||
1524 | (!win->focus_highlight.prev.handled)) | ||
1525 | _elm_win_focus_highlight_anim_setup(win, top); | ||
1526 | else | ||
1527 | _elm_win_focus_highlight_simple_setup(win, top); | ||
1528 | evas_object_raise(top); | ||
1529 | |||
1530 | the_end: | ||
1531 | win->focus_highlight.geometry_changed = EINA_FALSE; | ||
1532 | win->focus_highlight.prev = win->focus_highlight.cur; | ||
1533 | } | ||
1534 | |||
1535 | static void | ||
1536 | _elm_win_frame_add(Elm_Win *win, const char *style) | ||
1537 | { | ||
1538 | evas_output_framespace_set(win->evas, 0, 22, 0, 26); | ||
1539 | |||
1540 | win->frame_obj = edje_object_add(win->evas); | ||
1541 | _elm_theme_set(NULL, win->frame_obj, "border", "base", style); | ||
1542 | evas_object_is_frame_object_set(win->frame_obj, EINA_TRUE); | ||
1543 | evas_object_move(win->frame_obj, 0, 0); | ||
1544 | evas_object_resize(win->frame_obj, 1, 1); | ||
1545 | |||
1546 | edje_object_signal_callback_add(win->frame_obj, "elm,action,move,start", | ||
1547 | "elm", _elm_win_frame_cb_move_start, win); | ||
1548 | edje_object_signal_callback_add(win->frame_obj, "elm,action,resize,start", | ||
1549 | "*", _elm_win_frame_cb_resize_start, win); | ||
1550 | edje_object_signal_callback_add(win->frame_obj, "elm,action,minimize", | ||
1551 | "elm", _elm_win_frame_cb_minimize, win); | ||
1552 | edje_object_signal_callback_add(win->frame_obj, "elm,action,maximize", | ||
1553 | "elm", _elm_win_frame_cb_maximize, win); | ||
1554 | edje_object_signal_callback_add(win->frame_obj, "elm,action,close", | ||
1555 | "elm", _elm_win_frame_cb_close, win); | ||
1556 | } | ||
1557 | |||
1558 | static void | ||
1559 | _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__) | ||
1560 | { | ||
1561 | Elm_Win *win; | ||
1562 | |||
1563 | if (!(win = data)) return; | ||
1564 | /* FIXME: Change mouse pointer */ | ||
1565 | |||
1566 | /* NB: 0,0 are dummy values. Wayland handles the move by itself */ | ||
1567 | ecore_evas_move(win->ee, 0, 0); | ||
1568 | } | ||
1569 | |||
1570 | static void | ||
1571 | _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source) | ||
1572 | { | ||
1573 | Elm_Win *win; | ||
1574 | |||
1575 | if (!(win = data)) return; | ||
1576 | if (win->resizing) return; | ||
1577 | win->resizing = EINA_TRUE; | ||
1578 | |||
1579 | /* FIXME: Change mouse pointer */ | ||
1580 | |||
1581 | if (!strcmp(source, "elm.event.resize.t")) | ||
1582 | win->resize_location = 1; | ||
1583 | else if (!strcmp(source, "elm.event.resize.b")) | ||
1584 | win->resize_location = 2; | ||
1585 | else if (!strcmp(source, "elm.event.resize.l")) | ||
1586 | win->resize_location = 4; | ||
1587 | else if (!strcmp(source, "elm.event.resize.r")) | ||
1588 | win->resize_location = 8; | ||
1589 | else if (!strcmp(source, "elm.event.resize.tl")) | ||
1590 | win->resize_location = 5; | ||
1591 | else if (!strcmp(source, "elm.event.resize.tr")) | ||
1592 | win->resize_location = 9; | ||
1593 | else if (!strcmp(source, "elm.event.resize.bl")) | ||
1594 | win->resize_location = 6; | ||
1595 | else if (!strcmp(source, "elm.event.resize.br")) | ||
1596 | win->resize_location = 10; | ||
1597 | else | ||
1598 | win->resize_location = 0; | ||
1599 | |||
1600 | if (win->resize_location > 0) | ||
1601 | ecore_evas_wayland_resize(win->ee, win->resize_location); | ||
1602 | } | ||
1603 | |||
1604 | static void | ||
1605 | _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__) | ||
1606 | { | ||
1607 | Elm_Win *win; | ||
1608 | |||
1609 | if (!(win = data)) return; | ||
1610 | win->iconified = EINA_TRUE; | ||
1611 | ecore_evas_iconified_set(win->ee, EINA_TRUE); | ||
1612 | } | ||
1613 | |||
1614 | static void | ||
1615 | _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__) | ||
1616 | { | ||
1617 | Elm_Win *win; | ||
1618 | |||
1619 | if (!(win = data)) return; | ||
1620 | if (win->maximized) win->maximized = EINA_FALSE; | ||
1621 | else win->maximized = EINA_TRUE; | ||
1622 | ecore_evas_maximized_set(win->ee, win->maximized); | ||
1623 | } | ||
1624 | |||
1625 | static void | ||
1626 | _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__) | ||
1627 | { | ||
1628 | Elm_Win *win; | ||
1629 | |||
1630 | if (!(win = data)) return; | ||
1631 | evas_object_del(win->win_obj); | ||
1632 | } | ||
1633 | |||
1634 | /* | ||
1635 | static void | ||
1636 | _elm_win_pointer_add(Elm_Win *win, const char *style) | ||
1637 | { | ||
1638 | int mw, mh; | ||
1639 | |||
1640 | return; | ||
1641 | |||
1642 | win->pointer.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 32, 32, 0); | ||
1643 | ecore_evas_resize(win->pointer.ee, 32, 32); | ||
1644 | |||
1645 | win->pointer.evas = ecore_evas_get(win->ee); | ||
1646 | |||
1647 | win->pointer.obj = edje_object_add(win->pointer.evas); | ||
1648 | _elm_theme_set(NULL, win->pointer.obj, "pointer", "base", style); | ||
1649 | edje_object_size_min_calc(win->pointer.obj, &mw, &mh); | ||
1650 | evas_object_move(win->pointer.obj, 0, 0); | ||
1651 | evas_object_resize(win->pointer.obj, 32, 32); | ||
1652 | evas_object_show(win->pointer.obj); | ||
1653 | } | ||
1654 | */ | ||
1655 | |||
1656 | #ifdef ELM_DEBUG | ||
1657 | static void | ||
1658 | _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) | ||
1659 | { | ||
1660 | Evas_Event_Key_Down *ev = event_info; | ||
1661 | |||
1662 | if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) | ||
1663 | return; | ||
1664 | |||
1665 | if ((strcmp(ev->keyname, "F12")) || | ||
1666 | (!evas_key_modifier_is_set(ev->modifiers, "Control"))) | ||
1667 | return; | ||
1668 | |||
1669 | printf("Tree graph generated.\n"); | ||
1670 | elm_object_tree_dot_dump(obj, "./dump.dot"); | ||
1671 | } | ||
1672 | #endif | ||
1673 | |||
1674 | static void | ||
1675 | _win_img_hide(void *data, | ||
1676 | Evas *e __UNUSED__, | ||
1677 | Evas_Object *obj __UNUSED__, | ||
1678 | void *event_info __UNUSED__) | ||
1679 | { | ||
1680 | Elm_Win *win = data; | ||
1681 | |||
1682 | elm_widget_focus_hide_handle(win->win_obj); | ||
1683 | } | ||
1684 | |||
1685 | static void | ||
1686 | _win_img_mouse_up(void *data, | ||
1687 | Evas *e __UNUSED__, | ||
1688 | Evas_Object *obj __UNUSED__, | ||
1689 | void *event_info) | ||
1690 | { | ||
1691 | Elm_Win *win = data; | ||
1692 | Evas_Event_Mouse_Up *ev = event_info; | ||
1693 | if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)) | ||
1694 | elm_widget_focus_mouse_up_handle(win->win_obj); | ||
1695 | } | ||
1696 | |||
1697 | static void | ||
1698 | _win_img_focus_in(void *data, | ||
1699 | Evas *e __UNUSED__, | ||
1700 | Evas_Object *obj __UNUSED__, | ||
1701 | void *event_info __UNUSED__) | ||
1702 | { | ||
1703 | Elm_Win *win = data; | ||
1704 | elm_widget_focus_steal(win->win_obj); | ||
1705 | } | ||
1706 | |||
1707 | static void | ||
1708 | _win_img_focus_out(void *data, | ||
1709 | Evas *e __UNUSED__, | ||
1710 | Evas_Object *obj __UNUSED__, | ||
1711 | void *event_info __UNUSED__) | ||
1712 | { | ||
1713 | Elm_Win *win = data; | ||
1714 | elm_widget_focused_object_clear(win->win_obj); | ||
1715 | } | ||
1716 | |||
1717 | static void | ||
1718 | _win_inlined_image_set(Elm_Win *win) | ||
1719 | { | ||
1720 | evas_object_image_alpha_set(win->img_obj, EINA_FALSE); | ||
1721 | evas_object_image_filled_set(win->img_obj, EINA_TRUE); | ||
1722 | evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL, | ||
1723 | _elm_win_obj_callback_img_obj_del, win); | ||
1724 | |||
1725 | evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE, | ||
1726 | _win_img_hide, win); | ||
1727 | evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP, | ||
1728 | _win_img_mouse_up, win); | ||
1729 | evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN, | ||
1730 | _win_img_focus_in, win); | ||
1731 | evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT, | ||
1732 | _win_img_focus_out, win); | ||
1733 | } | ||
1734 | |||
1735 | static void | ||
1736 | _subobj_del(Elm_Win *win, Evas_Object *obj, Evas_Object *subobj) | ||
1737 | { | ||
1738 | evas_object_event_callback_del_full(subobj, | ||
1739 | EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
1740 | _elm_win_subobj_callback_changed_size_hints, | ||
1741 | obj); | ||
1742 | evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL, | ||
1743 | _elm_win_subobj_callback_del, obj); | ||
1744 | win->subobjs = eina_list_remove(win->subobjs, subobj); | ||
1745 | _elm_win_eval_subobjs(obj); | ||
1746 | } | ||
1747 | |||
1748 | static void | ||
1749 | _elm_win_obj_icon_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
1750 | { | ||
1751 | Elm_Win *win = data; | ||
1752 | if (win->icon == obj) win->icon = NULL; | ||
1753 | } | ||
1754 | |||
1755 | EAPI Evas_Object * | ||
1756 | elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) | ||
1757 | { | ||
1758 | Elm_Win *win; | ||
1759 | const Eina_List *l; | ||
1760 | const char *fontpath; | ||
1761 | |||
1762 | win = ELM_NEW(Elm_Win); | ||
1763 | |||
1764 | #define FALLBACK_TRY(engine) \ | ||
1765 | if (!win->ee) \ | ||
1766 | do { \ | ||
1767 | CRITICAL(engine " engine creation failed. Trying default."); \ | ||
1768 | win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL); \ | ||
1769 | if (win->ee) \ | ||
1770 | elm_config_preferred_engine_set(ecore_evas_engine_name_get(win->ee)); \ | ||
1771 | } while (0) | ||
1772 | #define ENGINE_COMPARE(name) (_elm_preferred_engine && !strcmp(_elm_preferred_engine, name)) | ||
1773 | |||
1774 | win->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN; | ||
1775 | win->indmode = ELM_WIN_INDICATOR_UNKNOWN; | ||
1776 | |||
1777 | switch (type) | ||
1778 | { | ||
1779 | case ELM_WIN_INLINED_IMAGE: | ||
1780 | if (!parent) break; | ||
1781 | { | ||
1782 | Evas *e = evas_object_evas_get(parent); | ||
1783 | Ecore_Evas *ee; | ||
1784 | if (!e) break; | ||
1785 | ee = ecore_evas_ecore_evas_get(e); | ||
1786 | if (!ee) break; | ||
1787 | win->img_obj = ecore_evas_object_image_new(ee); | ||
1788 | if (!win->img_obj) break; | ||
1789 | win->ee = ecore_evas_object_ecore_evas_get(win->img_obj); | ||
1790 | if (win->ee) | ||
1791 | { | ||
1792 | _win_inlined_image_set(win); | ||
1793 | break; | ||
1794 | } | ||
1795 | evas_object_del(win->img_obj); | ||
1796 | win->img_obj = NULL; | ||
1797 | } | ||
1798 | break; | ||
1799 | |||
1800 | case ELM_WIN_SOCKET_IMAGE: | ||
1801 | win->ee = ecore_evas_extn_socket_new(1, 1); | ||
1802 | break; | ||
1803 | |||
1804 | default: | ||
1805 | if (ENGINE_COMPARE(ELM_SOFTWARE_X11)) | ||
1806 | { | ||
1807 | win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1); | ||
1808 | #ifdef HAVE_ELEMENTARY_X | ||
1809 | win->client_message_handler = ecore_event_handler_add | ||
1810 | (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win); | ||
1811 | #endif | ||
1812 | FALLBACK_TRY("Sofware X11"); | ||
1813 | } | ||
1814 | else if (ENGINE_COMPARE(ELM_SOFTWARE_FB)) | ||
1815 | { | ||
1816 | win->ee = ecore_evas_fb_new(NULL, 0, 1, 1); | ||
1817 | FALLBACK_TRY("Sofware FB"); | ||
1818 | } | ||
1819 | else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB)) | ||
1820 | { | ||
1821 | win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1); | ||
1822 | FALLBACK_TRY("Sofware DirectFB"); | ||
1823 | } | ||
1824 | else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11)) | ||
1825 | { | ||
1826 | win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1); | ||
1827 | FALLBACK_TRY("Sofware-16"); | ||
1828 | #ifdef HAVE_ELEMENTARY_X | ||
1829 | win->client_message_handler = ecore_event_handler_add | ||
1830 | (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win); | ||
1831 | #endif | ||
1832 | } | ||
1833 | else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11)) | ||
1834 | { | ||
1835 | win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1); | ||
1836 | FALLBACK_TRY("Sofware-8"); | ||
1837 | #ifdef HAVE_ELEMENTARY_X | ||
1838 | win->client_message_handler = ecore_event_handler_add | ||
1839 | (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win); | ||
1840 | #endif | ||
1841 | } | ||
1842 | /* killed | ||
1843 | else if (ENGINE_COMPARE(ELM_XRENDER_X11)) | ||
1844 | { | ||
1845 | win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1); | ||
1846 | FALLBACK_TRY("XRender"); | ||
1847 | #ifdef HAVE_ELEMENTARY_X | ||
1848 | win->client_message_handler = ecore_event_handler_add | ||
1849 | (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win); | ||
1850 | #endif | ||
1851 | } | ||
1852 | */ | ||
1853 | else if (ENGINE_COMPARE(ELM_OPENGL_X11)) | ||
1854 | { | ||
1855 | int opt[10]; | ||
1856 | int opt_i = 0; | ||
1857 | |||
1858 | if (_elm_config->vsync) | ||
1859 | { | ||
1860 | opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC; | ||
1861 | opt_i++; | ||
1862 | opt[opt_i] = 1; | ||
1863 | opt_i++; | ||
1864 | } | ||
1865 | if (opt_i > 0) | ||
1866 | win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt); | ||
1867 | else | ||
1868 | win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1); | ||
1869 | FALLBACK_TRY("OpenGL"); | ||
1870 | #ifdef HAVE_ELEMENTARY_X | ||
1871 | win->client_message_handler = ecore_event_handler_add | ||
1872 | (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win); | ||
1873 | #endif | ||
1874 | } | ||
1875 | else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32)) | ||
1876 | { | ||
1877 | win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1); | ||
1878 | FALLBACK_TRY("Sofware Win32"); | ||
1879 | } | ||
1880 | else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE)) | ||
1881 | { | ||
1882 | win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1); | ||
1883 | FALLBACK_TRY("Sofware-16-WinCE"); | ||
1884 | } | ||
1885 | else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT)) | ||
1886 | { | ||
1887 | win->ee = ecore_evas_psl1ght_new(NULL, 1, 1); | ||
1888 | FALLBACK_TRY("PSL1GHT"); | ||
1889 | } | ||
1890 | else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL)) | ||
1891 | { | ||
1892 | win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1); | ||
1893 | FALLBACK_TRY("Sofware SDL"); | ||
1894 | } | ||
1895 | else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL)) | ||
1896 | { | ||
1897 | win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1); | ||
1898 | FALLBACK_TRY("Sofware-16-SDL"); | ||
1899 | } | ||
1900 | else if (ENGINE_COMPARE(ELM_OPENGL_SDL)) | ||
1901 | { | ||
1902 | win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0); | ||
1903 | FALLBACK_TRY("OpenGL SDL"); | ||
1904 | } | ||
1905 | else if (ENGINE_COMPARE(ELM_OPENGL_COCOA)) | ||
1906 | { | ||
1907 | win->ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0); | ||
1908 | FALLBACK_TRY("OpenGL Cocoa"); | ||
1909 | } | ||
1910 | else if (ENGINE_COMPARE(ELM_BUFFER)) | ||
1911 | { | ||
1912 | win->ee = ecore_evas_buffer_new(1, 1); | ||
1913 | } | ||
1914 | else if (ENGINE_COMPARE(ELM_EWS)) | ||
1915 | { | ||
1916 | win->ee = ecore_evas_ews_new(0, 0, 1, 1); | ||
1917 | } | ||
1918 | else if (ENGINE_COMPARE(ELM_WAYLAND_SHM)) | ||
1919 | { | ||
1920 | win->ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0); | ||
1921 | win->evas = ecore_evas_get(win->ee); | ||
1922 | |||
1923 | _elm_win_frame_add(win, "default"); | ||
1924 | // _elm_win_pointer_add(win, "default"); | ||
1925 | } | ||
1926 | else if (ENGINE_COMPARE(ELM_WAYLAND_EGL)) | ||
1927 | { | ||
1928 | win->ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0); | ||
1929 | win->evas = ecore_evas_get(win->ee); | ||
1930 | |||
1931 | _elm_win_frame_add(win, "default"); | ||
1932 | // _elm_win_pointer_add(win, "default"); | ||
1933 | } | ||
1934 | else if (!strncmp(_elm_preferred_engine, "shot:", 5)) | ||
1935 | { | ||
1936 | win->ee = ecore_evas_buffer_new(1, 1); | ||
1937 | ecore_evas_manual_render_set(win->ee, EINA_TRUE); | ||
1938 | win->shot.info = eina_stringshare_add(_elm_preferred_engine + 5); | ||
1939 | _shot_init(win); | ||
1940 | } | ||
1941 | #undef FALLBACK_TRY | ||
1942 | break; | ||
1943 | } | ||
1944 | |||
1945 | if (!win->ee) | ||
1946 | { | ||
1947 | ERR("Cannot create window."); | ||
1948 | free(win); | ||
1949 | return NULL; | ||
1950 | } | ||
1951 | #ifdef HAVE_ELEMENTARY_X | ||
1952 | _elm_win_xwindow_get(win); | ||
1953 | #endif | ||
1954 | if ((_elm_config->bgpixmap) && (!_elm_config->compositing)) | ||
1955 | ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE); | ||
1956 | // bg pixmap done by x - has other issues like can be redrawn by x before it | ||
1957 | // is filled/ready by app | ||
1958 | // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN); | ||
1959 | |||
1960 | win->type = type; | ||
1961 | win->parent = parent; | ||
1962 | if (win->parent) | ||
1963 | evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL, | ||
1964 | _elm_win_obj_callback_parent_del, win); | ||
1965 | |||
1966 | win->evas = ecore_evas_get(win->ee); | ||
1967 | win->win_obj = elm_widget_add(win->evas); | ||
1968 | elm_widget_type_set(win->win_obj, "win"); | ||
1969 | ELM_SET_WIDTYPE(widtype, "win"); | ||
1970 | elm_widget_data_set(win->win_obj, win); | ||
1971 | elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb); | ||
1972 | elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL); | ||
1973 | elm_widget_can_focus_set(win->win_obj, EINA_TRUE); | ||
1974 | elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE); | ||
1975 | elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook); | ||
1976 | evas_object_color_set(win->win_obj, 0, 0, 0, 0); | ||
1977 | evas_object_move(win->win_obj, 0, 0); | ||
1978 | evas_object_resize(win->win_obj, 1, 1); | ||
1979 | evas_object_layer_set(win->win_obj, 50); | ||
1980 | evas_object_pass_events_set(win->win_obj, EINA_TRUE); | ||
1981 | |||
1982 | if (win->frame_obj) | ||
1983 | { | ||
1984 | evas_object_clip_set(win->win_obj, win->frame_obj); | ||
1985 | evas_object_stack_below(win->frame_obj, win->win_obj); | ||
1986 | } | ||
1987 | |||
1988 | if (type == ELM_WIN_INLINED_IMAGE) | ||
1989 | elm_widget_parent2_set(win->win_obj, parent); | ||
1990 | ecore_evas_object_associate(win->ee, win->win_obj, | ||
1991 | ECORE_EVAS_OBJECT_ASSOCIATE_BASE | | ||
1992 | ECORE_EVAS_OBJECT_ASSOCIATE_STACK | | ||
1993 | ECORE_EVAS_OBJECT_ASSOCIATE_LAYER); | ||
1994 | evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW, | ||
1995 | _elm_win_obj_callback_show, win); | ||
1996 | evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE, | ||
1997 | _elm_win_obj_callback_hide, win); | ||
1998 | evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL, | ||
1999 | _elm_win_obj_callback_del, win); | ||
2000 | evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE, | ||
2001 | _elm_win_obj_callback_move, win); | ||
2002 | evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE, | ||
2003 | _elm_win_obj_callback_resize, win); | ||
2004 | if (win->img_obj) | ||
2005 | evas_object_intercept_move_callback_add(win->win_obj, | ||
2006 | _elm_win_obj_intercept_move, win); | ||
2007 | evas_object_intercept_show_callback_add(win->win_obj, | ||
2008 | _elm_win_obj_intercept_show, win); | ||
2009 | |||
2010 | evas_object_smart_callback_add(win->win_obj, "sub-object-del", (Evas_Smart_Cb)_subobj_del, win); | ||
2011 | ecore_evas_name_class_set(win->ee, name, _elm_appname); | ||
2012 | ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request); | ||
2013 | ecore_evas_callback_resize_set(win->ee, _elm_win_resize); | ||
2014 | ecore_evas_callback_mouse_in_set(win->ee, _elm_win_mouse_in); | ||
2015 | ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in); | ||
2016 | ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out); | ||
2017 | ecore_evas_callback_move_set(win->ee, _elm_win_move); | ||
2018 | ecore_evas_callback_state_change_set(win->ee, _elm_win_state_change); | ||
2019 | evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024)); | ||
2020 | evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024)); | ||
2021 | EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath) | ||
2022 | evas_font_path_append(win->evas, fontpath); | ||
2023 | if (!_elm_config->font_hinting) | ||
2024 | evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE); | ||
2025 | else if (_elm_config->font_hinting == 1) | ||
2026 | evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO); | ||
2027 | else if (_elm_config->font_hinting == 2) | ||
2028 | evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE); | ||
2029 | |||
2030 | #ifdef HAVE_ELEMENTARY_X | ||
2031 | _elm_win_xwin_update(win); | ||
2032 | #endif | ||
2033 | |||
2034 | _elm_win_list = eina_list_append(_elm_win_list, win->win_obj); | ||
2035 | |||
2036 | if (ENGINE_COMPARE(ELM_SOFTWARE_FB)) | ||
2037 | { | ||
2038 | ecore_evas_fullscreen_set(win->ee, 1); | ||
2039 | } | ||
2040 | #undef ENGINE_COMPARE | ||
2041 | |||
2042 | if (_elm_config->focus_highlight_enable) | ||
2043 | elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE); | ||
2044 | |||
2045 | #ifdef ELM_DEBUG | ||
2046 | Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control"); | ||
2047 | evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN, | ||
2048 | _debug_key_down, win); | ||
2049 | |||
2050 | Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0, | ||
2051 | EINA_TRUE); | ||
2052 | printf("Ctrl+F12 key combination exclusive for dot tree generation\n"); | ||
2053 | #endif | ||
2054 | |||
2055 | evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals); | ||
2056 | |||
2057 | return win->win_obj; | ||
2058 | } | ||
2059 | |||
2060 | EAPI Evas_Object * | ||
2061 | elm_win_util_standard_add(const char *name, const char *title) | ||
2062 | { | ||
2063 | Evas_Object *win, *bg; | ||
2064 | |||
2065 | win = elm_win_add(NULL, name, ELM_WIN_BASIC); | ||
2066 | if (!win) return NULL; | ||
2067 | elm_win_title_set(win, title); | ||
2068 | bg = elm_bg_add(win); | ||
2069 | if (!bg) | ||
2070 | { | ||
2071 | evas_object_del(win); | ||
2072 | return NULL; | ||
2073 | } | ||
2074 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
2075 | elm_win_resize_object_add(win, bg); | ||
2076 | evas_object_show(bg); | ||
2077 | return win; | ||
2078 | } | ||
2079 | |||
2080 | EAPI void | ||
2081 | elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj) | ||
2082 | { | ||
2083 | Evas_Coord w, h; | ||
2084 | Elm_Win *win; | ||
2085 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2086 | win = elm_widget_data_get(obj); | ||
2087 | if (!win) return; | ||
2088 | if (eina_list_data_find(win->subobjs, subobj)) return; | ||
2089 | win->subobjs = eina_list_append(win->subobjs, subobj); | ||
2090 | elm_widget_sub_object_add(obj, subobj); | ||
2091 | evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL, | ||
2092 | _elm_win_subobj_callback_del, obj); | ||
2093 | evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
2094 | _elm_win_subobj_callback_changed_size_hints, | ||
2095 | obj); | ||
2096 | evas_object_geometry_get(obj, NULL, NULL, &w, &h); | ||
2097 | evas_object_move(subobj, 0, 0); | ||
2098 | evas_object_resize(subobj, w, h); | ||
2099 | _elm_win_eval_subobjs(obj); | ||
2100 | } | ||
2101 | |||
2102 | EAPI void | ||
2103 | elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj) | ||
2104 | { | ||
2105 | Elm_Win *win; | ||
2106 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2107 | win = elm_widget_data_get(obj); | ||
2108 | if (!win) return; | ||
2109 | evas_object_event_callback_del_full(subobj, | ||
2110 | EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
2111 | _elm_win_subobj_callback_changed_size_hints, | ||
2112 | obj); | ||
2113 | evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL, | ||
2114 | _elm_win_subobj_callback_del, obj); | ||
2115 | win->subobjs = eina_list_remove(win->subobjs, subobj); | ||
2116 | elm_widget_sub_object_del(obj, subobj); | ||
2117 | _elm_win_eval_subobjs(obj); | ||
2118 | } | ||
2119 | |||
2120 | EAPI void | ||
2121 | elm_win_title_set(Evas_Object *obj, const char *title) | ||
2122 | { | ||
2123 | Elm_Win *win; | ||
2124 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2125 | win = elm_widget_data_get(obj); | ||
2126 | if (!win || !title) return; | ||
2127 | eina_stringshare_replace(&(win->title), title); | ||
2128 | ecore_evas_title_set(win->ee, win->title); | ||
2129 | if (win->frame_obj) | ||
2130 | edje_object_part_text_escaped_set(win->frame_obj, "elm.text.title", win->title); | ||
2131 | } | ||
2132 | |||
2133 | EAPI const char * | ||
2134 | elm_win_title_get(const Evas_Object *obj) | ||
2135 | { | ||
2136 | Elm_Win *win; | ||
2137 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
2138 | win = elm_widget_data_get(obj); | ||
2139 | if (!win) return NULL; | ||
2140 | return win->title; | ||
2141 | } | ||
2142 | |||
2143 | EAPI void | ||
2144 | elm_win_icon_name_set(Evas_Object *obj, const char *icon_name) | ||
2145 | { | ||
2146 | Elm_Win *win; | ||
2147 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2148 | win = elm_widget_data_get(obj); | ||
2149 | if (!win || !icon_name) return; | ||
2150 | eina_stringshare_replace(&(win->icon_name), icon_name); | ||
2151 | #ifdef HAVE_ELEMENTARY_X | ||
2152 | _elm_win_xwin_update(win); | ||
2153 | #endif | ||
2154 | } | ||
2155 | |||
2156 | EAPI const char * | ||
2157 | elm_win_icon_name_get(const Evas_Object *obj) | ||
2158 | { | ||
2159 | Elm_Win *win; | ||
2160 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
2161 | win = elm_widget_data_get(obj); | ||
2162 | if (!win) return NULL; | ||
2163 | return win->icon_name; | ||
2164 | } | ||
2165 | |||
2166 | EAPI void | ||
2167 | elm_win_role_set(Evas_Object *obj, const char *role) | ||
2168 | { | ||
2169 | Elm_Win *win; | ||
2170 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2171 | win = elm_widget_data_get(obj); | ||
2172 | if (!win || !role) return; | ||
2173 | eina_stringshare_replace(&(win->role), role); | ||
2174 | #ifdef HAVE_ELEMENTARY_X | ||
2175 | _elm_win_xwin_update(win); | ||
2176 | #endif | ||
2177 | } | ||
2178 | |||
2179 | EAPI const char * | ||
2180 | elm_win_role_get(const Evas_Object *obj) | ||
2181 | { | ||
2182 | Elm_Win *win; | ||
2183 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
2184 | win = elm_widget_data_get(obj); | ||
2185 | if (!win) return NULL; | ||
2186 | return win->role; | ||
2187 | } | ||
2188 | |||
2189 | EAPI void | ||
2190 | elm_win_icon_object_set(Evas_Object *obj, Evas_Object *icon) | ||
2191 | { | ||
2192 | Elm_Win *win; | ||
2193 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2194 | win = elm_widget_data_get(obj); | ||
2195 | if (!win) return; | ||
2196 | if (win->icon) | ||
2197 | evas_object_event_callback_del_full(win->icon, EVAS_CALLBACK_DEL, | ||
2198 | _elm_win_obj_icon_callback_del, win); | ||
2199 | win->icon = icon; | ||
2200 | if (win->icon) | ||
2201 | evas_object_event_callback_add(win->icon, EVAS_CALLBACK_DEL, | ||
2202 | _elm_win_obj_icon_callback_del, win); | ||
2203 | #ifdef HAVE_ELEMENTARY_X | ||
2204 | _elm_win_xwin_update(win); | ||
2205 | #endif | ||
2206 | } | ||
2207 | |||
2208 | EAPI const Evas_Object * | ||
2209 | elm_win_icon_object_get(const Evas_Object *obj) | ||
2210 | { | ||
2211 | Elm_Win *win; | ||
2212 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
2213 | win = elm_widget_data_get(obj); | ||
2214 | if (!win) return NULL; | ||
2215 | return win->icon; | ||
2216 | } | ||
2217 | |||
2218 | EAPI void | ||
2219 | elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel) | ||
2220 | { | ||
2221 | Elm_Win *win; | ||
2222 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2223 | win = elm_widget_data_get(obj); | ||
2224 | if (!win) return; | ||
2225 | win->autodel = autodel; | ||
2226 | } | ||
2227 | |||
2228 | EAPI Eina_Bool | ||
2229 | elm_win_autodel_get(const Evas_Object *obj) | ||
2230 | { | ||
2231 | Elm_Win *win; | ||
2232 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2233 | win = elm_widget_data_get(obj); | ||
2234 | if (!win) return EINA_FALSE; | ||
2235 | return win->autodel; | ||
2236 | } | ||
2237 | |||
2238 | EAPI void | ||
2239 | elm_win_activate(Evas_Object *obj) | ||
2240 | { | ||
2241 | Elm_Win *win; | ||
2242 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2243 | win = elm_widget_data_get(obj); | ||
2244 | if (!win) return; | ||
2245 | ecore_evas_activate(win->ee); | ||
2246 | } | ||
2247 | |||
2248 | EAPI void | ||
2249 | elm_win_lower(Evas_Object *obj) | ||
2250 | { | ||
2251 | Elm_Win *win; | ||
2252 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2253 | win = elm_widget_data_get(obj); | ||
2254 | if (!win) return; | ||
2255 | ecore_evas_lower(win->ee); | ||
2256 | } | ||
2257 | |||
2258 | EAPI void | ||
2259 | elm_win_raise(Evas_Object *obj) | ||
2260 | { | ||
2261 | Elm_Win *win; | ||
2262 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2263 | win = elm_widget_data_get(obj); | ||
2264 | if (!win) return; | ||
2265 | ecore_evas_raise(win->ee); | ||
2266 | } | ||
2267 | |||
2268 | EAPI void | ||
2269 | elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v) | ||
2270 | { | ||
2271 | Elm_Win *win; | ||
2272 | int win_w, win_h, screen_w, screen_h, nx, ny; | ||
2273 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2274 | win = elm_widget_data_get(obj); | ||
2275 | if (!win) return; | ||
2276 | ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h); | ||
2277 | if ((!screen_w) || (!screen_h)) return; | ||
2278 | evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h); | ||
2279 | if ((!win_w) || (!win_h)) return; | ||
2280 | if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2); | ||
2281 | else nx = win->screen.x; | ||
2282 | if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2); | ||
2283 | else ny = win->screen.y; | ||
2284 | if (nx < 0) nx = 0; | ||
2285 | if (ny < 0) ny = 0; | ||
2286 | evas_object_move(obj, nx, ny); | ||
2287 | } | ||
2288 | |||
2289 | EAPI void | ||
2290 | elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless) | ||
2291 | { | ||
2292 | Elm_Win *win; | ||
2293 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2294 | win = elm_widget_data_get(obj); | ||
2295 | if (!win) return; | ||
2296 | ecore_evas_borderless_set(win->ee, borderless); | ||
2297 | #ifdef HAVE_ELEMENTARY_X | ||
2298 | _elm_win_xwin_update(win); | ||
2299 | #endif | ||
2300 | } | ||
2301 | |||
2302 | EAPI Eina_Bool | ||
2303 | elm_win_borderless_get(const Evas_Object *obj) | ||
2304 | { | ||
2305 | Elm_Win *win; | ||
2306 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2307 | win = elm_widget_data_get(obj); | ||
2308 | if (!win) return EINA_FALSE; | ||
2309 | return ecore_evas_borderless_get(win->ee); | ||
2310 | } | ||
2311 | |||
2312 | EAPI void | ||
2313 | elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped) | ||
2314 | { | ||
2315 | Elm_Win *win; | ||
2316 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2317 | win = elm_widget_data_get(obj); | ||
2318 | if (!win) return; | ||
2319 | ecore_evas_shaped_set(win->ee, shaped); | ||
2320 | #ifdef HAVE_ELEMENTARY_X | ||
2321 | _elm_win_xwin_update(win); | ||
2322 | #endif | ||
2323 | } | ||
2324 | |||
2325 | EAPI Eina_Bool | ||
2326 | elm_win_shaped_get(const Evas_Object *obj) | ||
2327 | { | ||
2328 | Elm_Win *win; | ||
2329 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2330 | win = elm_widget_data_get(obj); | ||
2331 | if (!win) return EINA_FALSE; | ||
2332 | return ecore_evas_shaped_get(win->ee); | ||
2333 | } | ||
2334 | |||
2335 | EAPI void | ||
2336 | elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha) | ||
2337 | { | ||
2338 | Elm_Win *win; | ||
2339 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2340 | win = elm_widget_data_get(obj); | ||
2341 | if (!win) return; | ||
2342 | if (win->frame_obj) | ||
2343 | { | ||
2344 | } | ||
2345 | else if (win->img_obj) | ||
2346 | { | ||
2347 | evas_object_image_alpha_set(win->img_obj, alpha); | ||
2348 | ecore_evas_alpha_set(win->ee, alpha); | ||
2349 | } | ||
2350 | else | ||
2351 | { | ||
2352 | #ifdef HAVE_ELEMENTARY_X | ||
2353 | if (win->xwin) | ||
2354 | { | ||
2355 | if (alpha) | ||
2356 | { | ||
2357 | if (!_elm_config->compositing) | ||
2358 | elm_win_shaped_set(obj, alpha); | ||
2359 | else | ||
2360 | ecore_evas_alpha_set(win->ee, alpha); | ||
2361 | } | ||
2362 | else | ||
2363 | ecore_evas_alpha_set(win->ee, alpha); | ||
2364 | _elm_win_xwin_update(win); | ||
2365 | } | ||
2366 | else | ||
2367 | #endif | ||
2368 | ecore_evas_alpha_set(win->ee, alpha); | ||
2369 | } | ||
2370 | } | ||
2371 | |||
2372 | EAPI Eina_Bool | ||
2373 | elm_win_alpha_get(const Evas_Object *obj) | ||
2374 | { | ||
2375 | Elm_Win *win; | ||
2376 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2377 | win = elm_widget_data_get(obj); | ||
2378 | if (!win) return EINA_FALSE; | ||
2379 | if (win->frame_obj) | ||
2380 | { | ||
2381 | } | ||
2382 | else if (win->img_obj) | ||
2383 | { | ||
2384 | return evas_object_image_alpha_get(win->img_obj); | ||
2385 | } | ||
2386 | return ecore_evas_alpha_get(win->ee); | ||
2387 | } | ||
2388 | |||
2389 | EAPI void | ||
2390 | elm_win_override_set(Evas_Object *obj, Eina_Bool override) | ||
2391 | { | ||
2392 | Elm_Win *win; | ||
2393 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2394 | win = elm_widget_data_get(obj); | ||
2395 | if (!win) return; | ||
2396 | ecore_evas_override_set(win->ee, override); | ||
2397 | #ifdef HAVE_ELEMENTARY_X | ||
2398 | _elm_win_xwin_update(win); | ||
2399 | #endif | ||
2400 | } | ||
2401 | |||
2402 | EAPI Eina_Bool | ||
2403 | elm_win_override_get(const Evas_Object *obj) | ||
2404 | { | ||
2405 | Elm_Win *win; | ||
2406 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2407 | win = elm_widget_data_get(obj); | ||
2408 | if (!win) return EINA_FALSE; | ||
2409 | return ecore_evas_override_get(win->ee); | ||
2410 | } | ||
2411 | |||
2412 | EAPI void | ||
2413 | elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen) | ||
2414 | { | ||
2415 | Elm_Win *win; | ||
2416 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2417 | win = elm_widget_data_get(obj); | ||
2418 | if (!win) return; | ||
2419 | // YYY: handle if win->img_obj | ||
2420 | #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name)) | ||
2421 | if (ENGINE_COMPARE(ELM_SOFTWARE_FB) || | ||
2422 | ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE)) | ||
2423 | { | ||
2424 | // these engines... can ONLY be fullscreen | ||
2425 | return; | ||
2426 | } | ||
2427 | else | ||
2428 | { | ||
2429 | win->fullscreen = fullscreen; | ||
2430 | ecore_evas_fullscreen_set(win->ee, fullscreen); | ||
2431 | #ifdef HAVE_ELEMENTARY_X | ||
2432 | _elm_win_xwin_update(win); | ||
2433 | #endif | ||
2434 | } | ||
2435 | #undef ENGINE_COMPARE | ||
2436 | } | ||
2437 | |||
2438 | EAPI Eina_Bool | ||
2439 | elm_win_fullscreen_get(const Evas_Object *obj) | ||
2440 | { | ||
2441 | Elm_Win *win; | ||
2442 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2443 | win = elm_widget_data_get(obj); | ||
2444 | if (!win) return EINA_FALSE; | ||
2445 | #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name)) | ||
2446 | if (ENGINE_COMPARE(ELM_SOFTWARE_FB) || | ||
2447 | ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE)) | ||
2448 | { | ||
2449 | // these engines... can ONLY be fullscreen | ||
2450 | return EINA_TRUE; | ||
2451 | } | ||
2452 | else | ||
2453 | { | ||
2454 | return win->fullscreen; | ||
2455 | } | ||
2456 | #undef ENGINE_COMPARE | ||
2457 | } | ||
2458 | |||
2459 | EAPI void | ||
2460 | elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized) | ||
2461 | { | ||
2462 | Elm_Win *win; | ||
2463 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2464 | win = elm_widget_data_get(obj); | ||
2465 | if (!win) return; | ||
2466 | win->maximized = maximized; | ||
2467 | // YYY: handle if win->img_obj | ||
2468 | ecore_evas_maximized_set(win->ee, maximized); | ||
2469 | #ifdef HAVE_ELEMENTARY_X | ||
2470 | _elm_win_xwin_update(win); | ||
2471 | #endif | ||
2472 | } | ||
2473 | |||
2474 | EAPI Eina_Bool | ||
2475 | elm_win_maximized_get(const Evas_Object *obj) | ||
2476 | { | ||
2477 | Elm_Win *win; | ||
2478 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2479 | win = elm_widget_data_get(obj); | ||
2480 | if (!win) return EINA_FALSE; | ||
2481 | return win->maximized; | ||
2482 | } | ||
2483 | |||
2484 | EAPI void | ||
2485 | elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified) | ||
2486 | { | ||
2487 | Elm_Win *win; | ||
2488 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2489 | win = elm_widget_data_get(obj); | ||
2490 | if (!win) return; | ||
2491 | win->iconified = iconified; | ||
2492 | ecore_evas_iconified_set(win->ee, iconified); | ||
2493 | #ifdef HAVE_ELEMENTARY_X | ||
2494 | _elm_win_xwin_update(win); | ||
2495 | #endif | ||
2496 | } | ||
2497 | |||
2498 | EAPI Eina_Bool | ||
2499 | elm_win_iconified_get(const Evas_Object *obj) | ||
2500 | { | ||
2501 | Elm_Win *win; | ||
2502 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2503 | win = elm_widget_data_get(obj); | ||
2504 | if (!win) return EINA_FALSE; | ||
2505 | return win->iconified; | ||
2506 | } | ||
2507 | |||
2508 | EAPI void | ||
2509 | elm_win_withdrawn_set(Evas_Object *obj, Eina_Bool withdrawn) | ||
2510 | { | ||
2511 | Elm_Win *win; | ||
2512 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2513 | win = elm_widget_data_get(obj); | ||
2514 | if (!win) return; | ||
2515 | win->withdrawn = withdrawn; | ||
2516 | ecore_evas_withdrawn_set(win->ee, withdrawn); | ||
2517 | #ifdef HAVE_ELEMENTARY_X | ||
2518 | _elm_win_xwin_update(win); | ||
2519 | #endif | ||
2520 | } | ||
2521 | |||
2522 | EAPI Eina_Bool | ||
2523 | elm_win_withdrawn_get(const Evas_Object *obj) | ||
2524 | { | ||
2525 | Elm_Win *win; | ||
2526 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2527 | win = elm_widget_data_get(obj); | ||
2528 | if (!win) return EINA_FALSE; | ||
2529 | return win->withdrawn; | ||
2530 | } | ||
2531 | |||
2532 | EAPI void | ||
2533 | elm_win_urgent_set(Evas_Object *obj, Eina_Bool urgent) | ||
2534 | { | ||
2535 | Elm_Win *win; | ||
2536 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2537 | win = elm_widget_data_get(obj); | ||
2538 | if (!win) return; | ||
2539 | win->urgent = urgent; | ||
2540 | ecore_evas_urgent_set(win->ee, urgent); | ||
2541 | #ifdef HAVE_ELEMENTARY_X | ||
2542 | _elm_win_xwin_update(win); | ||
2543 | #endif | ||
2544 | } | ||
2545 | |||
2546 | EAPI Eina_Bool | ||
2547 | elm_win_urgent_get(const Evas_Object *obj) | ||
2548 | { | ||
2549 | Elm_Win *win; | ||
2550 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2551 | win = elm_widget_data_get(obj); | ||
2552 | if (!win) return EINA_FALSE; | ||
2553 | return win->urgent; | ||
2554 | } | ||
2555 | |||
2556 | EAPI void | ||
2557 | elm_win_demand_attention_set(Evas_Object *obj, Eina_Bool demand_attention) | ||
2558 | { | ||
2559 | Elm_Win *win; | ||
2560 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2561 | win = elm_widget_data_get(obj); | ||
2562 | if (!win) return; | ||
2563 | win->demand_attention = demand_attention; | ||
2564 | ecore_evas_demand_attention_set(win->ee, demand_attention); | ||
2565 | #ifdef HAVE_ELEMENTARY_X | ||
2566 | _elm_win_xwin_update(win); | ||
2567 | #endif | ||
2568 | } | ||
2569 | |||
2570 | EAPI Eina_Bool | ||
2571 | elm_win_demand_attention_get(const Evas_Object *obj) | ||
2572 | { | ||
2573 | Elm_Win *win; | ||
2574 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2575 | win = elm_widget_data_get(obj); | ||
2576 | if (!win) return EINA_FALSE; | ||
2577 | return win->demand_attention; | ||
2578 | } | ||
2579 | |||
2580 | EAPI void | ||
2581 | elm_win_modal_set(Evas_Object *obj, Eina_Bool modal) | ||
2582 | { | ||
2583 | Elm_Win *win; | ||
2584 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2585 | win = elm_widget_data_get(obj); | ||
2586 | if (!win) return; | ||
2587 | win->modal = modal; | ||
2588 | ecore_evas_modal_set(win->ee, modal); | ||
2589 | #ifdef HAVE_ELEMENTARY_X | ||
2590 | _elm_win_xwin_update(win); | ||
2591 | #endif | ||
2592 | } | ||
2593 | |||
2594 | EAPI Eina_Bool | ||
2595 | elm_win_modal_get(const Evas_Object *obj) | ||
2596 | { | ||
2597 | Elm_Win *win; | ||
2598 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2599 | win = elm_widget_data_get(obj); | ||
2600 | if (!win) return EINA_FALSE; | ||
2601 | return win->modal; | ||
2602 | } | ||
2603 | |||
2604 | EAPI void | ||
2605 | elm_win_aspect_set(Evas_Object *obj, double aspect) | ||
2606 | { | ||
2607 | Elm_Win *win; | ||
2608 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2609 | win = elm_widget_data_get(obj); | ||
2610 | if (!win) return; | ||
2611 | win->aspect = aspect; | ||
2612 | ecore_evas_aspect_set(win->ee, aspect); | ||
2613 | #ifdef HAVE_ELEMENTARY_X | ||
2614 | _elm_win_xwin_update(win); | ||
2615 | #endif | ||
2616 | } | ||
2617 | |||
2618 | EAPI double | ||
2619 | elm_win_aspect_get(const Evas_Object *obj) | ||
2620 | { | ||
2621 | Elm_Win *win; | ||
2622 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2623 | win = elm_widget_data_get(obj); | ||
2624 | if (!win) return EINA_FALSE; | ||
2625 | return win->aspect; | ||
2626 | } | ||
2627 | |||
2628 | EAPI void | ||
2629 | elm_win_layer_set(Evas_Object *obj, int layer) | ||
2630 | { | ||
2631 | Elm_Win *win; | ||
2632 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2633 | win = elm_widget_data_get(obj); | ||
2634 | if (!win) return; | ||
2635 | ecore_evas_layer_set(win->ee, layer); | ||
2636 | #ifdef HAVE_ELEMENTARY_X | ||
2637 | _elm_win_xwin_update(win); | ||
2638 | #endif | ||
2639 | } | ||
2640 | |||
2641 | EAPI int | ||
2642 | elm_win_layer_get(const Evas_Object *obj) | ||
2643 | { | ||
2644 | Elm_Win *win; | ||
2645 | ELM_CHECK_WIDTYPE(obj, widtype) -1; | ||
2646 | win = elm_widget_data_get(obj); | ||
2647 | if (!win) return -1; | ||
2648 | return ecore_evas_layer_get(win->ee); | ||
2649 | } | ||
2650 | |||
2651 | EAPI void | ||
2652 | elm_win_rotation_set(Evas_Object *obj, int rotation) | ||
2653 | { | ||
2654 | Elm_Win *win; | ||
2655 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2656 | win = elm_widget_data_get(obj); | ||
2657 | if (!win) return; | ||
2658 | if (win->rot == rotation) return; | ||
2659 | win->rot = rotation; | ||
2660 | ecore_evas_rotation_set(win->ee, rotation); | ||
2661 | evas_object_size_hint_min_set(obj, -1, -1); | ||
2662 | evas_object_size_hint_max_set(obj, -1, -1); | ||
2663 | _elm_win_eval_subobjs(obj); | ||
2664 | #ifdef HAVE_ELEMENTARY_X | ||
2665 | _elm_win_xwin_update(win); | ||
2666 | #endif | ||
2667 | } | ||
2668 | |||
2669 | EAPI void | ||
2670 | elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation) | ||
2671 | { | ||
2672 | Elm_Win *win; | ||
2673 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2674 | win = elm_widget_data_get(obj); | ||
2675 | if (!win) return; | ||
2676 | if (win->rot == rotation) return; | ||
2677 | win->rot = rotation; | ||
2678 | ecore_evas_rotation_with_resize_set(win->ee, rotation); | ||
2679 | evas_object_size_hint_min_set(obj, -1, -1); | ||
2680 | evas_object_size_hint_max_set(obj, -1, -1); | ||
2681 | _elm_win_eval_subobjs(obj); | ||
2682 | #ifdef HAVE_ELEMENTARY_X | ||
2683 | _elm_win_xwin_update(win); | ||
2684 | #endif | ||
2685 | } | ||
2686 | |||
2687 | EAPI int | ||
2688 | elm_win_rotation_get(const Evas_Object *obj) | ||
2689 | { | ||
2690 | Elm_Win *win; | ||
2691 | ELM_CHECK_WIDTYPE(obj, widtype) -1; | ||
2692 | win = elm_widget_data_get(obj); | ||
2693 | if (!win) return -1; | ||
2694 | return win->rot; | ||
2695 | } | ||
2696 | |||
2697 | EAPI void | ||
2698 | elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky) | ||
2699 | { | ||
2700 | Elm_Win *win; | ||
2701 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2702 | win = elm_widget_data_get(obj); | ||
2703 | if (!win) return; | ||
2704 | win->sticky = sticky; | ||
2705 | ecore_evas_sticky_set(win->ee, sticky); | ||
2706 | #ifdef HAVE_ELEMENTARY_X | ||
2707 | _elm_win_xwin_update(win); | ||
2708 | #endif | ||
2709 | } | ||
2710 | |||
2711 | EAPI Eina_Bool | ||
2712 | elm_win_sticky_get(const Evas_Object *obj) | ||
2713 | { | ||
2714 | Elm_Win *win; | ||
2715 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2716 | win = elm_widget_data_get(obj); | ||
2717 | if (!win) return EINA_FALSE; | ||
2718 | return win->sticky; | ||
2719 | } | ||
2720 | |||
2721 | EAPI void | ||
2722 | elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode) | ||
2723 | { | ||
2724 | Elm_Win *win; | ||
2725 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2726 | win = elm_widget_data_get(obj); | ||
2727 | if (!win) return; | ||
2728 | if (mode == win->kbdmode) return; | ||
2729 | #ifdef HAVE_ELEMENTARY_X | ||
2730 | _elm_win_xwindow_get(win); | ||
2731 | #endif | ||
2732 | win->kbdmode = mode; | ||
2733 | #ifdef HAVE_ELEMENTARY_X | ||
2734 | if (win->xwin) | ||
2735 | ecore_x_e_virtual_keyboard_state_set | ||
2736 | (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode); | ||
2737 | #endif | ||
2738 | } | ||
2739 | |||
2740 | EAPI Elm_Win_Keyboard_Mode | ||
2741 | elm_win_keyboard_mode_get(const Evas_Object *obj) | ||
2742 | { | ||
2743 | Elm_Win *win; | ||
2744 | ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN; | ||
2745 | win = elm_widget_data_get(obj); | ||
2746 | if (!win) return ELM_WIN_KEYBOARD_UNKNOWN; | ||
2747 | return win->kbdmode; | ||
2748 | } | ||
2749 | |||
2750 | EAPI void | ||
2751 | elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard) | ||
2752 | { | ||
2753 | Elm_Win *win; | ||
2754 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2755 | win = elm_widget_data_get(obj); | ||
2756 | if (!win) return; | ||
2757 | #ifdef HAVE_ELEMENTARY_X | ||
2758 | _elm_win_xwindow_get(win); | ||
2759 | if (win->xwin) | ||
2760 | ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard); | ||
2761 | #else | ||
2762 | (void) is_keyboard; | ||
2763 | #endif | ||
2764 | } | ||
2765 | |||
2766 | EAPI Eina_Bool | ||
2767 | elm_win_keyboard_win_get(const Evas_Object *obj) | ||
2768 | { | ||
2769 | Elm_Win *win; | ||
2770 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2771 | win = elm_widget_data_get(obj); | ||
2772 | if (!win) return EINA_FALSE; | ||
2773 | #ifdef HAVE_ELEMENTARY_X | ||
2774 | _elm_win_xwindow_get(win); | ||
2775 | if (win->xwin) | ||
2776 | return ecore_x_e_virtual_keyboard_get(win->xwin); | ||
2777 | #endif | ||
2778 | return EINA_FALSE; | ||
2779 | } | ||
2780 | |||
2781 | EAPI void | ||
2782 | elm_win_indicator_mode_set(Evas_Object *obj, Elm_Win_Indicator_Mode mode) | ||
2783 | { | ||
2784 | Elm_Win *win; | ||
2785 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2786 | win = elm_widget_data_get(obj); | ||
2787 | if (!win) return; | ||
2788 | if (mode == win->indmode) return; | ||
2789 | #ifdef HAVE_ELEMENTARY_X | ||
2790 | _elm_win_xwindow_get(win); | ||
2791 | #endif | ||
2792 | win->indmode = mode; | ||
2793 | #ifdef HAVE_ELEMENTARY_X | ||
2794 | if (win->xwin) | ||
2795 | { | ||
2796 | if (win->indmode == ELM_WIN_INDICATOR_SHOW) | ||
2797 | ecore_x_e_illume_indicator_state_set | ||
2798 | (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON); | ||
2799 | else if (win->indmode == ELM_WIN_INDICATOR_HIDE) | ||
2800 | ecore_x_e_illume_indicator_state_set | ||
2801 | (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF); | ||
2802 | } | ||
2803 | #endif | ||
2804 | } | ||
2805 | |||
2806 | EAPI Elm_Win_Indicator_Mode | ||
2807 | elm_win_indicator_mode_get(const Evas_Object *obj) | ||
2808 | { | ||
2809 | Elm_Win *win; | ||
2810 | ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_UNKNOWN; | ||
2811 | win = elm_widget_data_get(obj); | ||
2812 | if (!win) return ELM_WIN_INDICATOR_UNKNOWN; | ||
2813 | return win->indmode; | ||
2814 | } | ||
2815 | |||
2816 | EAPI void | ||
2817 | elm_win_indicator_opacity_set(Evas_Object *obj, Elm_Win_Indicator_Opacity_Mode mode) | ||
2818 | { | ||
2819 | Elm_Win *win; | ||
2820 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2821 | win = elm_widget_data_get(obj); | ||
2822 | if (!win) return; | ||
2823 | if (mode == win->ind_o_mode) return; | ||
2824 | win->ind_o_mode = mode; | ||
2825 | #ifdef HAVE_ELEMENTARY_X | ||
2826 | _elm_win_xwindow_get(win); | ||
2827 | if (win->xwin) | ||
2828 | { | ||
2829 | if (win->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE) | ||
2830 | ecore_x_e_illume_indicator_opacity_set | ||
2831 | (win->xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE); | ||
2832 | else if (win->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT) | ||
2833 | ecore_x_e_illume_indicator_opacity_set | ||
2834 | (win->xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT); | ||
2835 | else if (win->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT) | ||
2836 | ecore_x_e_illume_indicator_opacity_set | ||
2837 | (win->xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); | ||
2838 | |||
2839 | } | ||
2840 | #endif | ||
2841 | } | ||
2842 | |||
2843 | EAPI Elm_Win_Indicator_Opacity_Mode | ||
2844 | elm_win_indicator_opacity_get(const Evas_Object *obj) | ||
2845 | { | ||
2846 | Elm_Win *win; | ||
2847 | ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_OPACITY_UNKNOWN; | ||
2848 | win = elm_widget_data_get(obj); | ||
2849 | if (!win) return ELM_WIN_INDICATOR_OPACITY_UNKNOWN; | ||
2850 | return win->ind_o_mode; | ||
2851 | } | ||
2852 | |||
2853 | EAPI void | ||
2854 | elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y) | ||
2855 | { | ||
2856 | Elm_Win *win; | ||
2857 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2858 | win = elm_widget_data_get(obj); | ||
2859 | if (!win) return; | ||
2860 | if (x) *x = win->screen.x; | ||
2861 | if (y) *y = win->screen.y; | ||
2862 | } | ||
2863 | |||
2864 | EAPI Eina_Bool | ||
2865 | elm_win_focus_get(const Evas_Object *obj) | ||
2866 | { | ||
2867 | Elm_Win *win; | ||
2868 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2869 | win = elm_widget_data_get(obj); | ||
2870 | if (!win) return EINA_FALSE; | ||
2871 | return ecore_evas_focus_get(win->ee); | ||
2872 | } | ||
2873 | |||
2874 | EAPI void | ||
2875 | elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain) | ||
2876 | { | ||
2877 | Elm_Win *win; | ||
2878 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2879 | win = elm_widget_data_get(obj); | ||
2880 | if (!win) return; | ||
2881 | win->constrain = !!constrain; | ||
2882 | } | ||
2883 | |||
2884 | EAPI Eina_Bool | ||
2885 | elm_win_screen_constrain_get(Evas_Object *obj) | ||
2886 | { | ||
2887 | Elm_Win *win; | ||
2888 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2889 | win = elm_widget_data_get(obj); | ||
2890 | if (!win) return EINA_FALSE; | ||
2891 | return win->constrain; | ||
2892 | } | ||
2893 | |||
2894 | EAPI void | ||
2895 | elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h) | ||
2896 | { | ||
2897 | Elm_Win *win; | ||
2898 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2899 | win = elm_widget_data_get(obj); | ||
2900 | if (!win) return; | ||
2901 | ecore_evas_screen_geometry_get(win->ee, x, y, w, h); | ||
2902 | } | ||
2903 | |||
2904 | EAPI void | ||
2905 | elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant) | ||
2906 | { | ||
2907 | Elm_Win *win; | ||
2908 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2909 | win = elm_widget_data_get(obj); | ||
2910 | if (!win) return; | ||
2911 | #ifdef HAVE_ELEMENTARY_X | ||
2912 | _elm_win_xwindow_get(win); | ||
2913 | if (win->xwin) | ||
2914 | ecore_x_e_illume_conformant_set(win->xwin, conformant); | ||
2915 | #else | ||
2916 | (void) conformant; | ||
2917 | #endif | ||
2918 | } | ||
2919 | |||
2920 | EAPI Eina_Bool | ||
2921 | elm_win_conformant_get(const Evas_Object *obj) | ||
2922 | { | ||
2923 | Elm_Win *win; | ||
2924 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2925 | win = elm_widget_data_get(obj); | ||
2926 | if (!win) return EINA_FALSE; | ||
2927 | #ifdef HAVE_ELEMENTARY_X | ||
2928 | _elm_win_xwindow_get(win); | ||
2929 | if (win->xwin) | ||
2930 | return ecore_x_e_illume_conformant_get(win->xwin); | ||
2931 | #endif | ||
2932 | return EINA_FALSE; | ||
2933 | } | ||
2934 | |||
2935 | EAPI void | ||
2936 | elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel) | ||
2937 | { | ||
2938 | Elm_Win *win; | ||
2939 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2940 | win = elm_widget_data_get(obj); | ||
2941 | if (!win) return; | ||
2942 | #ifdef HAVE_ELEMENTARY_X | ||
2943 | _elm_win_xwindow_get(win); | ||
2944 | if (win->xwin) | ||
2945 | { | ||
2946 | ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel); | ||
2947 | if (quickpanel) | ||
2948 | { | ||
2949 | Ecore_X_Window_State states[2]; | ||
2950 | |||
2951 | states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR; | ||
2952 | states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER; | ||
2953 | ecore_x_netwm_window_state_set(win->xwin, states, 2); | ||
2954 | ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0); | ||
2955 | } | ||
2956 | } | ||
2957 | #else | ||
2958 | (void) quickpanel; | ||
2959 | #endif | ||
2960 | } | ||
2961 | |||
2962 | EAPI Eina_Bool | ||
2963 | elm_win_quickpanel_get(const Evas_Object *obj) | ||
2964 | { | ||
2965 | Elm_Win *win; | ||
2966 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
2967 | win = elm_widget_data_get(obj); | ||
2968 | if (!win) return EINA_FALSE; | ||
2969 | #ifdef HAVE_ELEMENTARY_X | ||
2970 | _elm_win_xwindow_get(win); | ||
2971 | if (win->xwin) | ||
2972 | return ecore_x_e_illume_quickpanel_get(win->xwin); | ||
2973 | #endif | ||
2974 | return EINA_FALSE; | ||
2975 | } | ||
2976 | |||
2977 | EAPI void | ||
2978 | elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority) | ||
2979 | { | ||
2980 | Elm_Win *win; | ||
2981 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
2982 | win = elm_widget_data_get(obj); | ||
2983 | if (!win) return; | ||
2984 | #ifdef HAVE_ELEMENTARY_X | ||
2985 | _elm_win_xwindow_get(win); | ||
2986 | if (win->xwin) | ||
2987 | ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority); | ||
2988 | #else | ||
2989 | (void) priority; | ||
2990 | #endif | ||
2991 | } | ||
2992 | |||
2993 | EAPI int | ||
2994 | elm_win_quickpanel_priority_major_get(const Evas_Object *obj) | ||
2995 | { | ||
2996 | Elm_Win *win; | ||
2997 | ELM_CHECK_WIDTYPE(obj, widtype) -1; | ||
2998 | win = elm_widget_data_get(obj); | ||
2999 | if (!win) return -1; | ||
3000 | #ifdef HAVE_ELEMENTARY_X | ||
3001 | _elm_win_xwindow_get(win); | ||
3002 | if (win->xwin) | ||
3003 | return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin); | ||
3004 | #endif | ||
3005 | return -1; | ||
3006 | } | ||
3007 | |||
3008 | EAPI void | ||
3009 | elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority) | ||
3010 | { | ||
3011 | Elm_Win *win; | ||
3012 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
3013 | win = elm_widget_data_get(obj); | ||
3014 | if (!win) return; | ||
3015 | #ifdef HAVE_ELEMENTARY_X | ||
3016 | _elm_win_xwindow_get(win); | ||
3017 | if (win->xwin) | ||
3018 | ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority); | ||
3019 | #else | ||
3020 | (void) priority; | ||
3021 | #endif | ||
3022 | } | ||
3023 | |||
3024 | EAPI int | ||
3025 | elm_win_quickpanel_priority_minor_get(const Evas_Object *obj) | ||
3026 | { | ||
3027 | Elm_Win *win; | ||
3028 | ELM_CHECK_WIDTYPE(obj, widtype) -1; | ||
3029 | win = elm_widget_data_get(obj); | ||
3030 | if (!win) return -1; | ||
3031 | #ifdef HAVE_ELEMENTARY_X | ||
3032 | _elm_win_xwindow_get(win); | ||
3033 | if (win->xwin) | ||
3034 | return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin); | ||
3035 | #endif | ||
3036 | return -1; | ||
3037 | } | ||
3038 | |||
3039 | EAPI void | ||
3040 | elm_win_quickpanel_zone_set(Evas_Object *obj, int zone) | ||
3041 | { | ||
3042 | Elm_Win *win; | ||
3043 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
3044 | win = elm_widget_data_get(obj); | ||
3045 | if (!win) return; | ||
3046 | #ifdef HAVE_ELEMENTARY_X | ||
3047 | _elm_win_xwindow_get(win); | ||
3048 | if (win->xwin) | ||
3049 | ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone); | ||
3050 | #else | ||
3051 | (void) zone; | ||
3052 | #endif | ||
3053 | } | ||
3054 | |||
3055 | EAPI int | ||
3056 | elm_win_quickpanel_zone_get(const Evas_Object *obj) | ||
3057 | { | ||
3058 | Elm_Win *win; | ||
3059 | ELM_CHECK_WIDTYPE(obj, widtype) 0; | ||
3060 | win = elm_widget_data_get(obj); | ||
3061 | if (!win) return 0; | ||
3062 | #ifdef HAVE_ELEMENTARY_X | ||
3063 | _elm_win_xwindow_get(win); | ||
3064 | if (win->xwin) | ||
3065 | return ecore_x_e_illume_quickpanel_zone_get(win->xwin); | ||
3066 | #endif | ||
3067 | return 0; | ||
3068 | } | ||
3069 | |||
3070 | EAPI void | ||
3071 | elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip) | ||
3072 | { | ||
3073 | Elm_Win *win; | ||
3074 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
3075 | win = elm_widget_data_get(obj); | ||
3076 | if (!win) return; | ||
3077 | win->skip_focus = skip; | ||
3078 | ecore_evas_focus_skip_set(win->ee, skip); | ||
3079 | } | ||
3080 | |||
3081 | EAPI void | ||
3082 | elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__) | ||
3083 | { | ||
3084 | Elm_Win *win; | ||
3085 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
3086 | win = elm_widget_data_get(obj); | ||
3087 | if (!win) return; | ||
3088 | #ifdef HAVE_ELEMENTARY_X | ||
3089 | _elm_win_xwindow_get(win); | ||
3090 | if (win->xwin) | ||
3091 | { | ||
3092 | switch (command) | ||
3093 | { | ||
3094 | case ELM_ILLUME_COMMAND_FOCUS_BACK: | ||
3095 | ecore_x_e_illume_focus_back_send(win->xwin); | ||
3096 | break; | ||
3097 | case ELM_ILLUME_COMMAND_FOCUS_FORWARD: | ||
3098 | ecore_x_e_illume_focus_forward_send(win->xwin); | ||
3099 | break; | ||
3100 | case ELM_ILLUME_COMMAND_FOCUS_HOME: | ||
3101 | ecore_x_e_illume_focus_home_send(win->xwin); | ||
3102 | break; | ||
3103 | case ELM_ILLUME_COMMAND_CLOSE: | ||
3104 | ecore_x_e_illume_close_send(win->xwin); | ||
3105 | break; | ||
3106 | default: | ||
3107 | break; | ||
3108 | } | ||
3109 | } | ||
3110 | #else | ||
3111 | (void) command; | ||
3112 | #endif | ||
3113 | } | ||
3114 | |||
3115 | EAPI Evas_Object * | ||
3116 | elm_win_inlined_image_object_get(Evas_Object *obj) | ||
3117 | { | ||
3118 | Elm_Win *win; | ||
3119 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
3120 | win = elm_widget_data_get(obj); | ||
3121 | if (!win) return NULL; | ||
3122 | return win->img_obj; | ||
3123 | } | ||
3124 | |||
3125 | EAPI void | ||
3126 | elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled) | ||
3127 | { | ||
3128 | Elm_Win *win; | ||
3129 | |||
3130 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
3131 | |||
3132 | win = elm_widget_data_get(obj); | ||
3133 | enabled = !!enabled; | ||
3134 | if (win->focus_highlight.enabled == enabled) | ||
3135 | return; | ||
3136 | |||
3137 | win->focus_highlight.enabled = enabled; | ||
3138 | |||
3139 | if (win->focus_highlight.enabled) | ||
3140 | _elm_win_focus_highlight_init(win); | ||
3141 | else | ||
3142 | _elm_win_focus_highlight_shutdown(win); | ||
3143 | } | ||
3144 | |||
3145 | EAPI Eina_Bool | ||
3146 | elm_win_focus_highlight_enabled_get(const Evas_Object *obj) | ||
3147 | { | ||
3148 | Elm_Win *win; | ||
3149 | |||
3150 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
3151 | |||
3152 | win = elm_widget_data_get(obj); | ||
3153 | return win->focus_highlight.enabled; | ||
3154 | } | ||
3155 | |||
3156 | EAPI void | ||
3157 | elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style) | ||
3158 | { | ||
3159 | Elm_Win *win; | ||
3160 | |||
3161 | ELM_CHECK_WIDTYPE(obj, widtype); | ||
3162 | |||
3163 | win = elm_widget_data_get(obj); | ||
3164 | eina_stringshare_replace(&win->focus_highlight.style, style); | ||
3165 | win->focus_highlight.changed_theme = EINA_TRUE; | ||
3166 | _elm_win_focus_highlight_reconfigure_job_start(win); | ||
3167 | } | ||
3168 | |||
3169 | EAPI const char * | ||
3170 | elm_win_focus_highlight_style_get(const Evas_Object *obj) | ||
3171 | { | ||
3172 | Elm_Win *win; | ||
3173 | |||
3174 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
3175 | |||
3176 | win = elm_widget_data_get(obj); | ||
3177 | return win->focus_highlight.style; | ||
3178 | } | ||
3179 | |||
3180 | typedef struct _Widget_Data Widget_Data; | ||
3181 | |||
3182 | struct _Widget_Data | ||
3183 | { | ||
3184 | Evas_Object *frm; | ||
3185 | Evas_Object *content; | ||
3186 | }; | ||
3187 | |||
3188 | static void _del_hook(Evas_Object *obj); | ||
3189 | static void _theme_hook(Evas_Object *obj); | ||
3190 | static void _sizing_eval(Evas_Object *obj); | ||
3191 | static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); | ||
3192 | static void _sub_del(void *data, Evas_Object *obj, void *event_info); | ||
3193 | |||
3194 | static const char *widtype2 = NULL; | ||
3195 | |||
3196 | static void | ||
3197 | _del_hook(Evas_Object *obj) | ||
3198 | { | ||
3199 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3200 | if (!wd) return; | ||
3201 | free(wd); | ||
3202 | } | ||
3203 | |||
3204 | static void | ||
3205 | _theme_hook(Evas_Object *obj) | ||
3206 | { | ||
3207 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3208 | _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj)); | ||
3209 | if (wd->content) | ||
3210 | edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content); | ||
3211 | _sizing_eval(obj); | ||
3212 | |||
3213 | evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL); | ||
3214 | } | ||
3215 | |||
3216 | static Eina_Bool | ||
3217 | _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next) | ||
3218 | { | ||
3219 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3220 | |||
3221 | if (!wd) | ||
3222 | return EINA_FALSE; | ||
3223 | |||
3224 | /* Try Focus cycle in subitem */ | ||
3225 | if (wd->content) | ||
3226 | { | ||
3227 | elm_widget_focus_next_get(wd->content, dir, next); | ||
3228 | if (*next) | ||
3229 | return EINA_TRUE; | ||
3230 | } | ||
3231 | |||
3232 | *next = (Evas_Object *)obj; | ||
3233 | return EINA_FALSE; | ||
3234 | } | ||
3235 | |||
3236 | static void | ||
3237 | _elm_inwin_text_set_hook(Evas_Object *obj, const char *item, const char *text) | ||
3238 | { | ||
3239 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3240 | |||
3241 | if (!wd || !item) return; | ||
3242 | edje_object_part_text_escaped_set(wd->frm, item, text); | ||
3243 | _sizing_eval(obj); | ||
3244 | } | ||
3245 | |||
3246 | static const char * | ||
3247 | _elm_inwin_text_get_hook(const Evas_Object *obj, const char *item) | ||
3248 | { | ||
3249 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3250 | |||
3251 | if (!item || !wd || !wd->frm) return NULL; | ||
3252 | return edje_object_part_text_get(wd->frm, item); | ||
3253 | } | ||
3254 | |||
3255 | static void | ||
3256 | _sizing_eval(Evas_Object *obj) | ||
3257 | { | ||
3258 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3259 | Evas_Coord minw = -1, minh = -1; | ||
3260 | |||
3261 | evas_object_size_hint_min_get(wd->content, &minw, &minh); | ||
3262 | edje_object_size_min_calc(wd->frm, &minw, &minh); | ||
3263 | evas_object_size_hint_min_set(obj, minw, minh); | ||
3264 | evas_object_size_hint_max_set(obj, -1, -1); | ||
3265 | } | ||
3266 | |||
3267 | static void | ||
3268 | _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
3269 | { | ||
3270 | _sizing_eval(data); | ||
3271 | } | ||
3272 | |||
3273 | static void | ||
3274 | _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info) | ||
3275 | { | ||
3276 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3277 | Evas_Object *sub = event_info; | ||
3278 | if (sub == wd->content) | ||
3279 | { | ||
3280 | evas_object_event_callback_del_full | ||
3281 | (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj); | ||
3282 | wd->content = NULL; | ||
3283 | _sizing_eval(obj); | ||
3284 | } | ||
3285 | } | ||
3286 | |||
3287 | EAPI Evas_Object * | ||
3288 | elm_win_inwin_add(Evas_Object *obj) | ||
3289 | { | ||
3290 | Evas_Object *obj2; | ||
3291 | Widget_Data *wd; | ||
3292 | Elm_Win *win; | ||
3293 | |||
3294 | ELM_CHECK_WIDTYPE(obj, widtype) NULL; | ||
3295 | win = elm_widget_data_get(obj); | ||
3296 | if (!win) return NULL; | ||
3297 | wd = ELM_NEW(Widget_Data); | ||
3298 | obj2 = elm_widget_add(win->evas); | ||
3299 | elm_widget_type_set(obj2, "inwin"); | ||
3300 | ELM_SET_WIDTYPE(widtype2, "inwin"); | ||
3301 | elm_widget_sub_object_add(obj, obj2); | ||
3302 | evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
3303 | evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
3304 | elm_win_resize_object_add(obj, obj2); | ||
3305 | |||
3306 | elm_widget_data_set(obj2, wd); | ||
3307 | elm_widget_del_hook_set(obj2, _del_hook); | ||
3308 | elm_widget_theme_hook_set(obj2, _theme_hook); | ||
3309 | elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook); | ||
3310 | elm_widget_text_set_hook_set(obj2, _elm_inwin_text_set_hook); | ||
3311 | elm_widget_text_get_hook_set(obj2, _elm_inwin_text_get_hook); | ||
3312 | elm_widget_can_focus_set(obj2, EINA_TRUE); | ||
3313 | elm_widget_highlight_ignore_set(obj2, EINA_TRUE); | ||
3314 | |||
3315 | wd->frm = edje_object_add(win->evas); | ||
3316 | _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default"); | ||
3317 | elm_widget_resize_object_set(obj2, wd->frm); | ||
3318 | |||
3319 | evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2); | ||
3320 | |||
3321 | _sizing_eval(obj2); | ||
3322 | return obj2; | ||
3323 | } | ||
3324 | |||
3325 | EAPI void | ||
3326 | elm_win_inwin_activate(Evas_Object *obj) | ||
3327 | { | ||
3328 | ELM_CHECK_WIDTYPE(obj, widtype2); | ||
3329 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3330 | if (!wd) return; | ||
3331 | evas_object_raise(obj); | ||
3332 | evas_object_show(obj); | ||
3333 | edje_object_signal_emit(wd->frm, "elm,action,show", "elm"); | ||
3334 | elm_object_focus_set(obj, EINA_TRUE); | ||
3335 | } | ||
3336 | |||
3337 | EAPI void | ||
3338 | elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content) | ||
3339 | { | ||
3340 | ELM_CHECK_WIDTYPE(obj, widtype2); | ||
3341 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3342 | if (!wd) return; | ||
3343 | if (wd->content == content) return; | ||
3344 | if (wd->content) evas_object_del(wd->content); | ||
3345 | wd->content = content; | ||
3346 | if (content) | ||
3347 | { | ||
3348 | elm_widget_sub_object_add(obj, content); | ||
3349 | evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
3350 | _changed_size_hints, obj); | ||
3351 | edje_object_part_swallow(wd->frm, "elm.swallow.content", content); | ||
3352 | } | ||
3353 | _sizing_eval(obj); | ||
3354 | } | ||
3355 | |||
3356 | EAPI Evas_Object * | ||
3357 | elm_win_inwin_content_get(const Evas_Object *obj) | ||
3358 | { | ||
3359 | ELM_CHECK_WIDTYPE(obj, widtype2) NULL; | ||
3360 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3361 | if (!wd) return NULL; | ||
3362 | return wd->content; | ||
3363 | } | ||
3364 | |||
3365 | EAPI Evas_Object * | ||
3366 | elm_win_inwin_content_unset(Evas_Object *obj) | ||
3367 | { | ||
3368 | ELM_CHECK_WIDTYPE(obj, widtype2) NULL; | ||
3369 | Widget_Data *wd = elm_widget_data_get(obj); | ||
3370 | if (!wd) return NULL; | ||
3371 | if (!wd->content) return NULL; | ||
3372 | Evas_Object *content = wd->content; | ||
3373 | elm_widget_sub_object_del(obj, wd->content); | ||
3374 | evas_object_event_callback_del_full(wd->content, | ||
3375 | EVAS_CALLBACK_CHANGED_SIZE_HINTS, | ||
3376 | _changed_size_hints, obj); | ||
3377 | edje_object_part_unswallow(wd->frm, wd->content); | ||
3378 | wd->content = NULL; | ||
3379 | return content; | ||
3380 | } | ||
3381 | |||
3382 | EAPI Eina_Bool | ||
3383 | elm_win_socket_listen(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys) | ||
3384 | { | ||
3385 | |||
3386 | Elm_Win *win; | ||
3387 | |||
3388 | ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; | ||
3389 | win = elm_widget_data_get(obj); | ||
3390 | if (!win) return EINA_FALSE; | ||
3391 | if (!win->ee) return EINA_FALSE; | ||
3392 | |||
3393 | if (!ecore_evas_extn_socket_listen(win->ee, svcname, svcnum, svcsys)) | ||
3394 | return EINA_FALSE; | ||
3395 | |||
3396 | return EINA_TRUE; | ||
3397 | } | ||
3398 | |||
3399 | /* windowing specific calls - shall we do this differently? */ | ||
3400 | |||
3401 | static Ecore_X_Window | ||
3402 | _elm_ee_win_get(const Evas_Object *obj) | ||
3403 | { | ||
3404 | if (!obj) return 0; | ||
3405 | #ifdef HAVE_ELEMENTARY_X | ||
3406 | Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); | ||
3407 | if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee); | ||
3408 | #endif | ||
3409 | return 0; | ||
3410 | } | ||
3411 | |||
3412 | EAPI Ecore_X_Window | ||
3413 | elm_win_xwindow_get(const Evas_Object *obj) | ||
3414 | { | ||
3415 | Elm_Win *win; | ||
3416 | const char *type; | ||
3417 | |||
3418 | if (!obj) return 0; | ||
3419 | type = elm_widget_type_get(obj); | ||
3420 | if ((!type) || (type != widtype)) return _elm_ee_win_get(obj); | ||
3421 | win = elm_widget_data_get(obj); | ||
3422 | if (!win) return 0; | ||
3423 | #ifdef HAVE_ELEMENTARY_X | ||
3424 | if (win->xwin) return win->xwin; | ||
3425 | if (win->parent) return elm_win_xwindow_get(win->parent); | ||
3426 | #endif | ||
3427 | return 0; | ||
3428 | } | ||