1 #include <Elementary.h>
3 #include "elm_widget_conform.h"
6 # define MIN(a, b) ((a) < (b)) ? (a) : (b)
10 # define MAX(a, b) ((a) < (b)) ? (b) : (a)
13 EAPI const char ELM_CONFORMANT_SMART_NAME[] = "elm_conformant";
14 static char CONFORMANT_KEY[] = "_elm_conform_key";
16 #ifdef HAVE_ELEMENTARY_X
17 #define SUB_TYPE_COUNT 2
18 static char *sub_type[SUB_TYPE_COUNT] = { "elm_scroller", "elm_genlist" };
22 static const char INDICATOR_PART[] = "elm.swallow.indicator";
23 static const char VIRTUALKEYPAD_PART[] = "elm.swallow.virtualkeypad";
24 static const char CLIPBOARD_PART[] = "elm.swallow.clipboard";
25 static const char SOFTKEY_PART[] = "elm.swallow.softkey";
27 static const char SIG_VIRTUALKEYPAD_STATE_ON[] = "virtualkeypad,state,on";
28 static const char SIG_VIRTUALKEYPAD_STATE_OFF[] = "virtualkeypad,state,off";
29 static const char SIG_CLIPBOARD_STATE_ON[] = "clipboard,state,on";
30 static const char SIG_CLIPBOARD_STATE_OFF[] = "clipboard,state,off";
32 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
33 {SIG_VIRTUALKEYPAD_STATE_ON, ""},
34 {SIG_VIRTUALKEYPAD_STATE_OFF, ""},
35 {SIG_CLIPBOARD_STATE_ON, ""},
36 {SIG_CLIPBOARD_STATE_OFF, ""},
40 static const Elm_Layout_Part_Alias_Description _content_aliases[] =
42 {"icon", "elm.swallow.content"},
46 EVAS_SMART_SUBCLASS_NEW
47 (ELM_CONFORMANT_SMART_NAME, _elm_conformant, Elm_Conformant_Smart_Class,
48 Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
50 /* Example of env vars:
51 * ILLUME_KBD="0, 0, 800, 301"
52 * ILLUME_IND="0, 0, 800, 32"
53 * ILLUME_STK="0, 568, 800, 32"
56 _conformant_part_geometry_get_from_env(const char *part,
62 const char delimiters[] = " ,;";
63 char *env_val, *token;
67 if (!(env_val = getenv(part))) return EINA_FALSE;
69 /* strtok would modify env var if not copied to a buffer */
70 strncpy(buf, env_val, sizeof(buf));
71 buf[PATH_MAX - 1] = '\0';
73 token = strtok(buf, delimiters);
74 if (!token) return EINA_FALSE;
77 token = strtok(NULL, delimiters);
78 if (!token) return EINA_FALSE;
81 token = strtok(NULL, delimiters);
82 if (!token) return EINA_FALSE;
85 token = strtok(NULL, delimiters);
86 if (!token) return EINA_FALSE;
97 _conformant_part_size_hints_set(Evas_Object *obj,
104 Evas_Coord cx, cy, cw, ch;
105 Evas_Coord part_height = 0, part_width = 0;
107 evas_object_geometry_get(obj, &cx, &cy, &cw, &ch);
109 /* Part overlapping with conformant */
110 if ((cx < (sx + sw)) && ((cx + cw) > sx)
111 && (cy < (sy + sh)) && ((cy + ch) > sy))
113 part_height = MIN((cy + ch), (sy + sh)) - MAX(cy, sy);
114 part_width = MIN((cx + cw), (sx + sw)) - MAX(cx, sx);
117 evas_object_size_hint_min_set(sobj, part_width, part_height);
118 evas_object_size_hint_max_set(sobj, part_width, part_height);
122 _conformant_part_sizing_eval(Evas_Object *obj,
123 Conformant_Part_Type part_type)
125 #ifdef HAVE_ELEMENTARY_X
126 Ecore_X_Window zone = 0;
130 int sx = -1, sy = -1, sw = -1, sh = -1;
132 ELM_CONFORMANT_DATA_GET(obj, sd);
134 #ifdef HAVE_ELEMENTARY_X
135 top = elm_widget_top_get(obj);
136 xwin = elm_win_xwindow_get(top);
139 zone = ecore_x_e_illume_zone_get(xwin);
142 if (part_type & ELM_CONFORMANT_INDICATOR_PART)
144 if ((!_conformant_part_geometry_get_from_env
145 ("ILLUME_IND", &sx, &sy, &sw, &sh)) && (xwin))
147 #ifdef HAVE_ELEMENTARY_X
148 //No information of the indicator geometry, reset the geometry.
149 if (!ecore_x_e_illume_indicator_geometry_get
150 (zone, &sx, &sy, &sw, &sh))
151 sx = sy = sw = sh = 0;
156 if (((sd->rot == 90) || (sd->rot == 270)) && sd->landscape_indicator)
157 _conformant_part_size_hints_set(obj, sd->landscape_indicator, sx, sy, sw, sh);
158 else if (((sd->rot == 0) || (sd->rot == 180)) && sd->portrait_indicator)
159 _conformant_part_size_hints_set(obj, sd->portrait_indicator, sx, sy, sw, sh);
162 if (part_type & ELM_CONFORMANT_VIRTUAL_KEYPAD_PART)
164 if ((!_conformant_part_geometry_get_from_env
165 ("ILLUME_KBD", &sx, &sy, &sw, &sh)) && (xwin))
167 #ifdef HAVE_ELEMENTARY_X
168 //No information of the keyboard geometry, reset the geometry.
170 DBG("[KEYPAD]:pid=%d, xwin=0x%x, zone=0x%x: no env value and check window property.", getpid(), xwin, zone);
172 if (!ecore_x_e_illume_keyboard_geometry_get(xwin, &sx, &sy, &sw, &sh))
174 DBG("[KEYPAD]:no window property, check zone property.");
175 if (!ecore_x_e_illume_keyboard_geometry_get(zone, &sx, &sy, &sw, &sh))
177 DBG("[KEYPAD]:no zone property, reset value.");
178 sx = sy = sw = sh = 0;
185 DBG("[KEYPAD]: size(%d,%d, %dx%d).", sx, sy, sw, sh);
186 _conformant_part_size_hints_set
187 (obj, sd->virtualkeypad, sx, sy, sw, sh);
190 if (part_type & ELM_CONFORMANT_SOFTKEY_PART)
192 if ((!_conformant_part_geometry_get_from_env
193 ("ILLUME_STK", &sx, &sy, &sw, &sh)) && (xwin))
195 #ifdef HAVE_ELEMENTARY_X
196 //No information of the softkey geometry, reset the geometry.
197 if (!ecore_x_e_illume_softkey_geometry_get
198 (zone, &sx, &sy, &sw, &sh))
199 sx = sy = sw = sh = 0;
204 _conformant_part_size_hints_set(obj, sd->softkey, sx, sy, sw, sh);
206 if (part_type & ELM_CONFORMANT_CLIPBOARD_PART)
208 if ((!_conformant_part_geometry_get_from_env
209 ("ILLUME_CB", &sx, &sy, &sw, &sh)) && (xwin))
211 #ifdef HAVE_ELEMENTARY_X
212 //No information of the clipboard geometry, reset the geometry.
213 if (!ecore_x_e_illume_clipboard_geometry_get
214 (zone, &sx, &sy, &sw, &sh))
215 sx = sy = sw = sh = 0;
220 _conformant_part_size_hints_set(obj, sd->clipboard, sx, sy, sw, sh);
225 _conformant_parts_swallow(Evas_Object *obj)
228 Elm_Widget_Smart_Data *wd;
230 ELM_CONFORMANT_DATA_GET(obj, sd);
232 wd = ELM_WIDGET_DATA(sd);
233 e = evas_object_evas_get(obj);
238 if (edje_object_part_exists(wd->resize_obj, VIRTUALKEYPAD_PART))
240 if (!sd->virtualkeypad)
242 sd->virtualkeypad = evas_object_rectangle_add(e);
243 elm_widget_sub_object_add(obj, sd->virtualkeypad);
244 evas_object_size_hint_max_set(sd->virtualkeypad, -1, 0);
247 _conformant_part_sizing_eval(obj, ELM_CONFORMANT_VIRTUAL_KEYPAD_PART);
249 evas_object_color_set(sd->virtualkeypad, 0, 0, 0, 0);
250 elm_layout_content_set(obj, VIRTUALKEYPAD_PART, sd->virtualkeypad);
252 else if (sd->virtualkeypad)
254 evas_object_del(sd->virtualkeypad);
255 sd->virtualkeypad = NULL;
259 if (edje_object_part_exists(wd->resize_obj, CLIPBOARD_PART))
263 sd->clipboard = evas_object_rectangle_add(e);
264 evas_object_size_hint_min_set(sd->clipboard, -1, 0);
265 evas_object_size_hint_max_set(sd->clipboard, -1, 0);
268 _conformant_part_sizing_eval(obj, ELM_CONFORMANT_CLIPBOARD_PART);
270 evas_object_color_set(sd->clipboard, 0, 0, 0, 0);
271 elm_layout_content_set(obj, CLIPBOARD_PART, sd->clipboard);
273 else if (sd->clipboard)
275 evas_object_del(sd->clipboard);
276 sd->clipboard = NULL;
280 if (edje_object_part_exists(wd->resize_obj, SOFTKEY_PART))
284 sd->softkey = evas_object_rectangle_add(e);
285 evas_object_size_hint_min_set(sd->softkey, -1, 0);
286 evas_object_size_hint_max_set(sd->softkey, -1, 0);
289 _conformant_part_sizing_eval(obj, ELM_CONFORMANT_SOFTKEY_PART);
291 evas_object_color_set(sd->softkey, 0, 0, 0, 0);
292 elm_layout_content_set(obj, SOFTKEY_PART, sd->softkey);
294 else if (sd->softkey)
296 evas_object_del(sd->softkey);
302 _port_indicator_connect_cb(void *data)
304 const char *indicator_serv_name;
305 Elm_Conformant_Smart_Data *sd = data;
308 if (!sd) return ECORE_CALLBACK_CANCEL;
309 if (sd->indmode != ELM_WIN_INDICATOR_SHOW)
311 sd->port_indi_timer = NULL;
312 return ECORE_CALLBACK_CANCEL;
314 rot = (int) evas_object_data_get(sd->portrait_indicator, CONFORMANT_KEY);
315 indicator_serv_name = elm_config_indicator_service_get(rot);
316 if (!indicator_serv_name)
318 DBG("Conformant cannot find indicator service name: Rotation=%d\n",rot);
319 sd->port_indi_timer = NULL;
320 return ECORE_CALLBACK_CANCEL;
322 if (elm_plug_connect(sd->portrait_indicator, indicator_serv_name, 0, EINA_FALSE))
324 DBG("Conformant connect to server[%s]\n", indicator_serv_name);
325 sd->port_indi_timer = NULL;
326 return ECORE_CALLBACK_CANCEL;
328 return ECORE_CALLBACK_RENEW;
333 _land_indicator_connect_cb(void *data)
335 const char *indicator_serv_name;
336 Elm_Conformant_Smart_Data *sd = data;
339 if (!sd) return ECORE_CALLBACK_CANCEL;
340 if (sd->indmode != ELM_WIN_INDICATOR_SHOW)
342 sd->land_indi_timer = NULL;
343 return ECORE_CALLBACK_CANCEL;
345 rot = (int) evas_object_data_get(sd->landscape_indicator, CONFORMANT_KEY);
346 indicator_serv_name = elm_config_indicator_service_get(rot);
347 if (!indicator_serv_name)
349 DBG("Conformant cannot find indicator service name: Rotation=%d\n",rot);
350 sd->land_indi_timer = NULL;
351 return ECORE_CALLBACK_CANCEL;
353 if (elm_plug_connect(sd->landscape_indicator, indicator_serv_name, 0, EINA_FALSE))
355 DBG("Conformant connect to server[%s]\n", indicator_serv_name);
356 sd->land_indi_timer = NULL;
357 return ECORE_CALLBACK_CANCEL;
359 return ECORE_CALLBACK_RENEW;
363 _land_indicator_disconnected(void *data,
364 Evas_Object *obj __UNUSED__,
365 void *event_info __UNUSED__)
367 Evas_Object *conform = data;
369 ELM_CONFORMANT_DATA_GET(conform, sd);
371 sd->land_indi_timer = ecore_timer_add(1, _land_indicator_connect_cb, sd);
375 _port_indicator_disconnected(void *data,
376 Evas_Object *obj __UNUSED__,
377 void *event_info __UNUSED__)
379 Evas_Object *conform = data;
381 ELM_CONFORMANT_DATA_GET(conform, sd);
383 sd->port_indi_timer = ecore_timer_add(1, _port_indicator_connect_cb, sd);
387 _access_activate_cb(void *data,
388 Evas_Object *part_obj,
389 Elm_Object_Item *item __UNUSED__)
391 Evas_Coord x, y, w, h;
393 #ifdef HAVE_ELEMENTARY_X
394 Evas_Object *top = elm_widget_top_get(data);
395 Ecore_X_Window xwin = elm_win_xwindow_get(top);
397 evas_object_geometry_get(part_obj, &x, &y, &w, &h);
399 ecore_x_mouse_down_send(xwin, (x + (w / 2)), (y + (h / 2)), 1);
400 ecore_x_mouse_up_send(xwin, (x + (w / 2)), (y + (h / 2)), 1);
405 _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
409 ELM_CONFORMANT_DATA_GET(obj, sd);
413 ao = _elm_access_edje_object_part_object_register
414 (obj, ELM_WIDGET_DATA(sd)->resize_obj, "access");
416 _elm_access_text_set(_elm_access_object_get(ao),
417 ELM_ACCESS_TYPE, "Indicator, Double Tap To Open");
418 _elm_access_activate_callback_set
419 (_elm_access_object_get(ao), _access_activate_cb, obj);
421 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
422 "elm,state,access,on", "elm");
426 _elm_access_edje_object_part_object_unregister
427 (obj, ELM_WIDGET_DATA(sd)->resize_obj, "access");
429 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
430 "elm,state,access,off", "elm");
434 static const char PLUG_KEY[] = "__Plug_Ecore_Evas";
435 // procotol version - change this as needed
436 #define MSG_DOMAIN_CONTROL_INDICATOR 0x10001
437 #define MSG_ID_INDICATOR_REPEAT_EVENT 0x10002
438 #define MSG_ID_INDICATOR_ROTATION 0x10003
439 #define MSG_ID_INDICATOR_OPACITY 0X1004
440 #define MSG_ID_INDICATOR_TYPE 0X1005
443 _plug_msg_handle(Ecore_Evas *ee, int msg_domain, int msg_id, void *data, int size)
445 Evas_Object *conformant;
448 DBG("Receive msg from plug ee=%p msg_domain=%x msg_id=%x size=%d", ee, msg_domain, msg_id, size);
449 //get plug object form ee
450 conformant = (Evas_Object *)ecore_evas_data_get(ee, CONFORMANT_KEY);
451 ELM_CONFORMANT_DATA_GET(conformant, sd);
452 if (msg_domain == MSG_DOMAIN_CONTROL_INDICATOR)
454 if (msg_id == MSG_ID_INDICATOR_REPEAT_EVENT)
457 DBG("Receive repeat event change message:(%d)", *repeat);
459 if (msg_id == MSG_ID_INDICATOR_TYPE)
461 Elm_Win_Indicator_Type_Mode *indi_t_mode = data;
462 Evas_Object *win = elm_widget_top_get(conformant);
463 DBG("Receive indicator type change message:(%d)", *indi_t_mode);
464 elm_win_indicator_type_set(win, *indi_t_mode);
470 _create_portrait_indicator(Evas_Object *obj)
472 Evas_Object *port_indicator = NULL;
473 Ecore_Evas *indicator_ee = NULL;
474 const char *port_indicator_serv_name;
476 ELM_CONFORMANT_DATA_GET(obj, sd);
478 port_indicator_serv_name = elm_config_indicator_service_get(sd->rot);
479 if (!port_indicator_serv_name)
481 DBG("Conformant cannot get portrait indicator service name\n");
485 port_indicator = elm_plug_add(obj);
488 DBG("Conformant cannot create plug to server[%s]\n", port_indicator_serv_name);
492 if (!elm_plug_connect(port_indicator, port_indicator_serv_name, 0, EINA_FALSE))
494 DBG("Conformant cannot connect to server[%s]\n", port_indicator_serv_name);
498 //callback to deal with extn socket message
499 indicator_ee = ecore_evas_object_ecore_evas_get(elm_plug_image_object_get(port_indicator));
500 DBG("This is portrait indicator's ee=%p.", indicator_ee);
501 ecore_evas_callback_msg_handle_set(indicator_ee, _plug_msg_handle);
502 ecore_evas_data_set(indicator_ee, CONFORMANT_KEY, obj);
504 DBG("The rotation value of portrait indicator was changed:(%d)", sd->rot);
505 ecore_evas_msg_parent_send(indicator_ee, MSG_DOMAIN_CONTROL_INDICATOR, MSG_ID_INDICATOR_ROTATION, &(sd->rot), sizeof(int));
507 elm_widget_sub_object_add(obj, port_indicator);
508 evas_object_smart_callback_add(port_indicator, "image.deleted", _port_indicator_disconnected, obj);
510 evas_object_size_hint_min_set(port_indicator, -1, 0);
511 evas_object_size_hint_max_set(port_indicator, -1, 0);
514 if (_elm_config->access_mode) _access_obj_process(obj, EINA_TRUE);
516 return port_indicator;
520 _create_landscape_indicator(Evas_Object *obj)
522 Ecore_Evas *indicator_ee = NULL;
523 Evas_Object *land_indicator = NULL;
524 const char *land_indicator_serv_name;
526 ELM_CONFORMANT_DATA_GET(obj, sd);
528 land_indicator_serv_name = elm_config_indicator_service_get(sd->rot);
529 if (!land_indicator_serv_name)
531 DBG("Conformant cannot get portrait indicator service name\n");
535 land_indicator = elm_plug_add(obj);
538 DBG("Conformant cannot create plug to server[%s]\n", land_indicator_serv_name);
542 if (!elm_plug_connect(land_indicator, land_indicator_serv_name, 0, EINA_FALSE))
544 DBG("Conformant cannot connect to server[%s]\n", land_indicator_serv_name);
548 //callback to deal with extn socket message
549 indicator_ee = ecore_evas_object_ecore_evas_get(elm_plug_image_object_get(land_indicator));
550 ecore_evas_data_set(indicator_ee, CONFORMANT_KEY, obj);
551 DBG("This is landscape indicator's ee=%p.", indicator_ee);
552 ecore_evas_callback_msg_handle_set(indicator_ee, _plug_msg_handle);
553 DBG("The rotation value of landscape indicator was changed:(%d)", sd->rot);
554 ecore_evas_msg_parent_send(indicator_ee, MSG_DOMAIN_CONTROL_INDICATOR, MSG_ID_INDICATOR_ROTATION, &(sd->rot), sizeof(int));
556 elm_widget_sub_object_add(obj, land_indicator);
557 evas_object_smart_callback_add(land_indicator, "image.deleted",_land_indicator_disconnected, obj);
559 evas_object_size_hint_min_set(land_indicator, -1, 0);
560 evas_object_size_hint_max_set(land_indicator, -1, 0);
563 if (_elm_config->access_mode) _access_obj_process(obj, EINA_TRUE);
565 return land_indicator;
569 _indicator_mode_set(Evas_Object *conformant, Elm_Win_Indicator_Mode indmode)
571 Evas_Object *old_indi = NULL;
572 Elm_Widget_Smart_Data *wd;
573 ELM_CONFORMANT_DATA_GET(conformant, sd);
574 sd->indmode = indmode;
576 wd = ELM_WIDGET_DATA(sd);
578 if (!edje_object_part_exists(wd->resize_obj, INDICATOR_PART))
581 if (indmode == ELM_WIN_INDICATOR_SHOW)
583 old_indi = elm_layout_content_get(conformant, INDICATOR_PART);
585 //create new indicator
588 if ((sd->rot == 90)||(sd->rot == 270))
590 if (!sd->landscape_indicator)
591 sd->landscape_indicator = _create_landscape_indicator(conformant);
593 if (!sd->landscape_indicator) return;
595 evas_object_show(sd->landscape_indicator);
596 elm_layout_content_set(conformant, INDICATOR_PART, sd->landscape_indicator);
600 if (!sd->portrait_indicator)
601 sd->portrait_indicator = _create_portrait_indicator(conformant);
603 if (!sd->portrait_indicator) return;
605 evas_object_show(sd->portrait_indicator);
606 elm_layout_content_set(conformant, INDICATOR_PART, sd->portrait_indicator);
610 elm_object_signal_emit(conformant, "elm,state,indicator,show", "elm");
614 old_indi = elm_layout_content_get(conformant, INDICATOR_PART);
617 evas_object_hide(old_indi);
619 elm_object_signal_emit(conformant, "elm,state,indicator,hide", "elm");
624 _indicator_opacity_set(Evas_Object *conformant, Elm_Win_Indicator_Opacity_Mode ind_o_mode)
626 ELM_CONFORMANT_DATA_GET(conformant, sd);
627 sd->ind_o_mode = ind_o_mode;
628 //TODO: opacity change
629 //send indicator information
630 if (sd->landscape_indicator)
632 Ecore_Evas *indicator_ee = NULL;
633 DBG("The opacity mode of landscape indicator was changed:(%d)", ind_o_mode);
634 indicator_ee = ecore_evas_object_ecore_evas_get(elm_plug_image_object_get(sd->landscape_indicator));
635 ecore_evas_msg_parent_send(indicator_ee, MSG_DOMAIN_CONTROL_INDICATOR, MSG_ID_INDICATOR_OPACITY, &(sd->ind_o_mode), sizeof(Elm_Win_Indicator_Opacity_Mode));
637 if (sd->portrait_indicator)
639 Ecore_Evas *indicator_ee = NULL;
640 DBG("The opacity mode of portrait indicator was changed:(%d)", ind_o_mode);
641 indicator_ee = ecore_evas_object_ecore_evas_get(elm_plug_image_object_get(sd->portrait_indicator));
642 ecore_evas_msg_parent_send(indicator_ee, MSG_DOMAIN_CONTROL_INDICATOR, MSG_ID_INDICATOR_OPACITY, &(sd->ind_o_mode), sizeof(Elm_Win_Indicator_Opacity_Mode));
647 _on_indicator_mode_changed(void *data,
649 void *event_info __UNUSED__)
651 Evas_Object *conformant = data;
652 Evas_Object *win = obj;
654 Elm_Win_Indicator_Mode indmode;
655 Elm_Win_Indicator_Opacity_Mode ind_o_mode;
657 ELM_CONFORMANT_DATA_GET(conformant, sd);
659 indmode = elm_win_indicator_mode_get(win);
660 ind_o_mode = elm_win_indicator_opacity_get(win);
661 if (indmode != sd->indmode)
662 _indicator_mode_set(conformant, indmode);
663 if (ind_o_mode != sd->ind_o_mode)
664 _indicator_opacity_set(conformant, ind_o_mode);
668 _on_rotation_changed(void *data,
670 void *event_info __UNUSED__)
673 Evas_Object *win = obj;
674 Evas_Object *conformant = data;
675 Evas_Object *old_indi = NULL;
677 ELM_CONFORMANT_DATA_GET(data, sd);
679 rot = elm_win_rotation_get(win);
681 if (rot == sd->rot) return;
684 //send indicator information
685 if (sd->landscape_indicator)
687 Ecore_Evas *indicator_ee = NULL;
688 DBG("The rotation value of landscape indicator was changed:(%d)", rot);
689 indicator_ee = ecore_evas_object_ecore_evas_get(elm_plug_image_object_get(sd->landscape_indicator));
690 ecore_evas_msg_parent_send(indicator_ee, MSG_DOMAIN_CONTROL_INDICATOR, MSG_ID_INDICATOR_ROTATION, &(sd->rot), sizeof(int));
692 if (sd->portrait_indicator)
694 Ecore_Evas *indicator_ee = NULL;
695 DBG("The rotation value of portrait indicator was changed:(%d)", rot);
696 indicator_ee = ecore_evas_object_ecore_evas_get(elm_plug_image_object_get(sd->portrait_indicator));
697 ecore_evas_msg_parent_send(indicator_ee, MSG_DOMAIN_CONTROL_INDICATOR, MSG_ID_INDICATOR_ROTATION, &(sd->rot), sizeof(int));
699 old_indi = elm_layout_content_unset(conformant, INDICATOR_PART);
700 /* this means ELM_WIN_INDICATOR_SHOW never be set.we don't need to change indicator type*/
701 if (!old_indi) return;
702 evas_object_hide(old_indi);
704 if ((rot == 90) || (rot == 270))
706 if (!sd->landscape_indicator)
707 sd->landscape_indicator = _create_landscape_indicator(conformant);
709 if (!sd->landscape_indicator) return;
711 evas_object_show(sd->landscape_indicator);
712 evas_object_data_set(sd->landscape_indicator, CONFORMANT_KEY, (void *) rot);
713 elm_layout_content_set(conformant, INDICATOR_PART, sd->landscape_indicator);
717 if (!sd->portrait_indicator)
718 sd->portrait_indicator = _create_portrait_indicator(conformant);
720 if (!sd->portrait_indicator) return;
722 evas_object_show(sd->portrait_indicator);
723 evas_object_data_set(sd->portrait_indicator, CONFORMANT_KEY, (void *) rot);
724 elm_layout_content_set(conformant, INDICATOR_PART, sd->portrait_indicator);
729 _elm_conformant_smart_theme(Evas_Object *obj)
731 if (!ELM_WIDGET_CLASS(_elm_conformant_parent_sc)->theme(obj))
734 _conformant_parts_swallow(obj);
736 elm_layout_sizing_eval(obj);
741 // unused now - but meant to be for making sure the focused widget is always
742 // visible when the vkbd comes and goes by moving the conformant obj (and thus
743 // its children) to show the focused widget (and if focus changes follow)
746 _focus_object_get(const Evas_Object *obj)
748 Evas_Object *win, *foc;
750 win = elm_widget_top_get(obj);
751 if (!win) return NULL;
752 foc = elm_widget_top_get(win);
756 _focus_object_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
758 evas_object_geometry_get(obj, x, y, w, h);
762 _focus_change_del(void *data, Evas_Object *obj, void *event_info)
764 // called from toplevel when the focused window shanges
768 _autoscroll_move(Evas_Object *obj)
770 // move conformant edje by delta to show focused widget
774 _autoscroll_mode_enable(Evas_Object *obj)
776 // called when autoscroll mode should be on - content area smaller than
778 // 1. get focused object
779 // 2. if not in visible conformant area calculate delta needed to
781 // 3. store delta and call _autoscroll_move() which either asanimates
782 // or jumps right there
786 _autoscroll_mode_disable(Evas_Object *obj)
788 // called when autoscroll mode should be off - set delta to 0 and
789 // call _autoscroll_move()
794 _move_resize_cb(void *data __UNUSED__,
797 void *event_info __UNUSED__)
799 Conformant_Part_Type part_type;
801 part_type = (ELM_CONFORMANT_INDICATOR_PART |
802 ELM_CONFORMANT_SOFTKEY_PART |
803 ELM_CONFORMANT_VIRTUAL_KEYPAD_PART |
804 ELM_CONFORMANT_CLIPBOARD_PART);
806 _conformant_part_sizing_eval(obj, part_type);
810 _show_region_job(void *data)
812 Evas_Object *focus_obj;
814 ELM_CONFORMANT_DATA_GET(data, sd);
816 focus_obj = elm_widget_focused_object_get(data);
819 Evas_Coord x, y, w, h;
821 elm_widget_show_region_get(focus_obj, &x, &y, &w, &h);
824 if (h < _elm_config->finger_size)
825 h = _elm_config->finger_size;
827 elm_widget_show_region_set(focus_obj, x, y, w, h, EINA_TRUE);
830 sd->show_region_job = NULL;
833 // showing the focused/important region.
834 #ifdef HAVE_ELEMENTARY_X
836 _on_content_resize(void *data,
838 Evas_Object *obj __UNUSED__,
839 void *event_info __UNUSED__)
841 ELM_CONFORMANT_DATA_GET(data, sd);
843 if ((sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF) &&
844 (sd->clipboard_state == ECORE_X_ILLUME_CLIPBOARD_STATE_OFF))
847 if (sd->show_region_job) ecore_job_del(sd->show_region_job);
848 sd->show_region_job = ecore_job_add(_show_region_job, data);
853 #ifdef HAVE_ELEMENTARY_X
855 _autoscroll_objects_update(void *data)
859 Evas_Object *sub, *top_scroller = NULL;
861 ELM_CONFORMANT_DATA_GET(data, sd);
863 sub = elm_widget_focused_object_get(data);
864 //Look up for top most scroller in the focus object hierarchy
869 type = elm_widget_type_get(sub);
870 if (!strcmp(type, ELM_CONFORMANT_SMART_NAME)) break;
872 for (i = 0; i < SUB_TYPE_COUNT; i++)
873 if (!strcmp(type, sub_type[i]))
878 sub = elm_object_parent_widget_get(sub);
881 //If the scroller got changed by app, replace it.
882 if (top_scroller != sd->scroller)
885 evas_object_event_callback_del
886 (sd->scroller, EVAS_CALLBACK_RESIZE, _on_content_resize);
887 sd->scroller = top_scroller;
890 evas_object_event_callback_add
891 (sd->scroller, EVAS_CALLBACK_RESIZE, _on_content_resize, data);
896 _virtualkeypad_state_change(Evas_Object *obj, Ecore_X_Event_Window_Property *ev)
898 ELM_CONFORMANT_DATA_GET(obj, sd);
900 Ecore_X_Window zone = ecore_x_e_illume_zone_get(ev->win);
901 Ecore_X_Virtual_Keyboard_State state =
902 ecore_x_e_virtual_keyboard_state_get(ev->win);
904 DBG("[KEYPAD]:window's state win=0x%x, state=%d.", ev->win, state);
905 if (state == ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN)
907 state = ecore_x_e_virtual_keyboard_state_get(zone);
908 DBG("[KEYPAD]:zone's state zone=0x%x, state=%d.", zone, state);
911 if (sd->vkb_state == state) return;
912 sd->vkb_state = state;
914 if (state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
916 DBG("[KEYPAD]:ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF");
917 _conformant_part_sizing_eval(obj, ELM_CONFORMANT_VIRTUAL_KEYPAD_PART);
918 // Tizen Only - SIP regions for virtual keypad and clipboard are the same in Tizen
919 if (sd->clipboard_state == ECORE_X_ILLUME_CLIPBOARD_STATE_OFF)
920 elm_widget_display_mode_set(obj, EVAS_DISPLAY_MODE_NONE);
921 evas_object_smart_callback_call(obj, SIG_VIRTUALKEYPAD_STATE_OFF, NULL);
923 else if (state == ECORE_X_VIRTUAL_KEYBOARD_STATE_ON)
925 DBG("[KEYPAD]:ECORE_X_VIRTUAL_KEYBOARD_STATE_ON");
926 _conformant_part_sizing_eval(obj, ELM_CONFORMANT_VIRTUAL_KEYPAD_PART);
927 elm_widget_display_mode_set(obj, EVAS_DISPLAY_MODE_COMPRESS);
928 _autoscroll_objects_update(obj);
929 evas_object_smart_callback_call(obj, SIG_VIRTUALKEYPAD_STATE_ON, NULL);
934 _clipboard_state_change(Evas_Object *obj, Ecore_X_Event_Window_Property *ev)
936 ELM_CONFORMANT_DATA_GET(obj, sd);
938 Ecore_X_Window zone = ecore_x_e_illume_zone_get(ev->win);
939 Ecore_X_Illume_Clipboard_State state =
940 ecore_x_e_illume_clipboard_state_get(ev->win);
942 DBG("[CLIPBOARD]:window's state win=0x%x, state=%d.", ev->win, state);
944 if (state == ECORE_X_ILLUME_CLIPBOARD_STATE_UNKNOWN)
946 state = ecore_x_e_illume_clipboard_state_get(ev->win);
947 DBG("[CLIPBOARD]:zone's state zone=0x%x, state=%d.", zone, state);
950 if (sd->clipboard_state == state) return;
951 sd->clipboard_state = state;
953 if (state == ECORE_X_ILLUME_CLIPBOARD_STATE_OFF)
955 evas_object_size_hint_min_set(sd->clipboard, -1, 0);
956 evas_object_size_hint_max_set(sd->clipboard, -1, 0);
957 // Tizen Only - SIP regions for virtual keypad and clipboard are the same in Tizen
958 if (sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
959 elm_widget_display_mode_set(obj, EVAS_DISPLAY_MODE_NONE);
960 evas_object_smart_callback_call(obj, SIG_CLIPBOARD_STATE_OFF, NULL);
962 else if(state == ECORE_X_ILLUME_CLIPBOARD_STATE_ON)
964 elm_widget_display_mode_set(obj, EVAS_DISPLAY_MODE_COMPRESS);
965 _autoscroll_objects_update(obj);
966 evas_object_smart_callback_call(obj, SIG_CLIPBOARD_STATE_ON, NULL);
971 _on_prop_change(void *data,
975 Ecore_X_Event_Window_Property *ev = event;
983 if (ev->atom == ECORE_X_ATOM_E_ILLUME_ZONE)
985 DBG("pid=%d, win=0x%x, ECORE_X_ATOM_E_ILLUME_ZONE.\n", pid, ev->win);
986 Conformant_Part_Type part_type;
988 part_type = (ELM_CONFORMANT_INDICATOR_PART |
989 ELM_CONFORMANT_SOFTKEY_PART |
990 ELM_CONFORMANT_VIRTUAL_KEYPAD_PART |
991 ELM_CONFORMANT_CLIPBOARD_PART);
993 _conformant_part_sizing_eval(data, part_type);
995 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY)
997 DBG("pid=%d, win=0x%x, ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY.", pid, ev->win);
998 _conformant_part_sizing_eval(data, ELM_CONFORMANT_INDICATOR_PART);
1000 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY)
1002 DBG("pid=%d, win=0x%x, ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY.", pid, ev->win);
1003 _conformant_part_sizing_eval(data, ELM_CONFORMANT_SOFTKEY_PART);
1005 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY)
1007 DBG("[KEYPAD]:pid=%d, win=0x%x, ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY.", pid, ev->win);
1008 _conformant_part_sizing_eval(data, ELM_CONFORMANT_VIRTUAL_KEYPAD_PART);
1010 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_GEOMETRY)
1012 DBG("pid=%d, win=0x%x, ECORE_X_ATOM_E_ILLUME_CLIPBOARD_GEOMETRY.", pid, ev->win);
1013 _conformant_part_sizing_eval(data, ELM_CONFORMANT_CLIPBOARD_PART);
1015 else if (ev->atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE)
1017 DBG("[KEYPAD]:pid=%d, win=0x%x, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE.", pid, ev->win);
1018 _virtualkeypad_state_change(data, ev);
1020 else if (ev->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
1022 DBG("pid=%d, win=0x%x, ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE.", pid, ev->win);
1023 _clipboard_state_change(data, ev);
1026 return ECORE_CALLBACK_PASS_ON;
1032 _elm_conformant_smart_add(Evas_Object *obj)
1034 EVAS_SMART_DATA_ALLOC(obj, Elm_Conformant_Smart_Data);
1036 ELM_WIDGET_CLASS(_elm_conformant_parent_sc)->base.add(obj);
1038 elm_widget_can_focus_set(obj, EINA_FALSE);
1040 elm_layout_theme_set(obj, "conformant", "base", elm_widget_style_get(obj));
1042 _conformant_parts_swallow(obj);
1044 evas_object_event_callback_add
1045 (obj, EVAS_CALLBACK_RESIZE, _move_resize_cb, obj);
1046 evas_object_event_callback_add
1047 (obj, EVAS_CALLBACK_MOVE, _move_resize_cb, obj);
1049 elm_layout_sizing_eval(obj);
1053 _elm_conformant_smart_del(Evas_Object *obj)
1056 ELM_CONFORMANT_DATA_GET(obj, sd);
1058 #ifdef HAVE_ELEMENTARY_X
1059 if (sd->prop_hdl) ecore_event_handler_del(sd->prop_hdl);
1062 if (sd->show_region_job) ecore_job_del(sd->show_region_job);
1063 if (sd->port_indi_timer) ecore_timer_del(sd->port_indi_timer);
1064 if (sd->land_indi_timer) ecore_timer_del(sd->land_indi_timer);
1065 if (sd->portrait_indicator)
1066 evas_object_del(sd->portrait_indicator);
1067 if (sd->landscape_indicator)
1068 evas_object_del(sd->landscape_indicator);
1069 top = elm_widget_top_get(obj);
1070 evas_object_data_set(top, "\377 elm,conformant", NULL);
1072 ELM_WIDGET_CLASS(_elm_conformant_parent_sc)->base.del(obj);
1076 _elm_conformant_smart_parent_set(Evas_Object *obj,
1077 Evas_Object *parent)
1079 #ifdef HAVE_ELEMENTARY_X
1080 Evas_Object *top = elm_widget_top_get(parent);
1081 Ecore_X_Window xwin = elm_win_xwindow_get(parent);
1083 if ((xwin) && (!elm_win_inlined_image_object_get(top)))
1085 ELM_CONFORMANT_DATA_GET(obj, sd);
1087 sd->prop_hdl = ecore_event_handler_add
1088 (ECORE_X_EVENT_WINDOW_PROPERTY, _on_prop_change, obj);
1089 sd->vkb_state = ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF;
1090 sd->clipboard_state = ECORE_X_ILLUME_CLIPBOARD_STATE_OFF;
1092 // FIXME: get kbd region prop
1097 _elm_conformant_smart_access(Evas_Object *obj, Eina_Bool is_access)
1099 ELM_CONFORMANT_CHECK(obj);
1101 _access_obj_process(obj, is_access);
1105 _elm_conformant_smart_set_user(Elm_Conformant_Smart_Class *sc)
1107 ELM_WIDGET_CLASS(sc)->base.add = _elm_conformant_smart_add;
1108 ELM_WIDGET_CLASS(sc)->base.del = _elm_conformant_smart_del;
1110 ELM_WIDGET_CLASS(sc)->parent_set = _elm_conformant_smart_parent_set;
1111 ELM_WIDGET_CLASS(sc)->theme = _elm_conformant_smart_theme;
1112 ELM_WIDGET_CLASS(sc)->access = _elm_conformant_smart_access;
1114 ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
1117 EAPI const Elm_Conformant_Smart_Class *
1118 elm_conformant_smart_class_get(void)
1120 static Elm_Conformant_Smart_Class _sc =
1121 ELM_CONFORMANT_SMART_CLASS_INIT_NAME_VERSION(ELM_CONFORMANT_SMART_NAME);
1122 static const Elm_Conformant_Smart_Class *class = NULL;
1123 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
1128 _elm_conformant_smart_set(&_sc);
1129 esc->callbacks = _smart_callbacks;
1136 elm_conformant_add(Evas_Object *parent)
1141 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
1143 obj = elm_widget_add(_elm_conformant_smart_class_new(), parent);
1144 if (!obj) return NULL;
1146 if (!elm_widget_sub_object_add(parent, obj))
1147 ERR("could not add %p as sub object of %p", obj, parent);
1149 ELM_CONFORMANT_DATA_GET(obj, sd);
1151 top = elm_widget_top_get(obj);
1152 _on_indicator_mode_changed(obj, top, NULL);
1153 _on_rotation_changed(obj, top, NULL);
1155 sd->indmode = elm_win_indicator_mode_get(top);
1156 sd->ind_o_mode = elm_win_indicator_opacity_get(top);
1157 sd->rot = elm_win_rotation_get(top);
1158 evas_object_data_set(top, "\377 elm,conformant", obj);
1160 evas_object_smart_callback_add
1161 (top, "indicator,prop,changed", _on_indicator_mode_changed, obj);
1162 evas_object_smart_callback_add
1163 (top, "rotation,changed", _on_rotation_changed, obj);