Elementary: Use ecore_evas_new if the engine fails instead of hardcoding software...
[framework/uifw/elementary.git] / src / lib / elm_win.c
index 098b9db..6f826e0 100644 (file)
@@ -26,6 +26,7 @@ struct _Elm_Win
    } shot;
    Eina_Bool autodel : 1;
    int *autodel_clear, rot;
+   int show_count;
    struct {
       int x, y;
    } screen;
@@ -77,6 +78,7 @@ static const char SIG_DELETE_REQUEST[] = "delete,request";
 static const char SIG_FOCUS_OUT[] = "focus,out";
 static const char SIG_FOCUS_IN[] = "focus,in";
 static const char SIG_MOVED[] = "moved";
+static const char SIG_THEME_CHANGED[] = "theme,changed";
 
 static const Evas_Smart_Cb_Description _signals[] = {
    {SIG_DELETE_REQUEST, ""},
@@ -306,6 +308,14 @@ _elm_win_focus_in(Ecore_Evas *ee)
    if (!obj) return;
    win = elm_widget_data_get(obj);
    if (!win) return;
+   _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
+   if (win->show_count == 1)
+     {
+        elm_object_focus_set(win->win_obj, EINA_TRUE);
+        win->show_count++;
+     }
+   else
+     elm_widget_focus_restore(win->win_obj);
    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
    win->focus_highlight.cur.visible = EINA_TRUE;
    _elm_win_focus_highlight_reconfigure_job_start(win);
@@ -327,6 +337,8 @@ _elm_win_focus_out(Ecore_Evas *ee)
    if (!obj) return;
    win = elm_widget_data_get(obj);
    if (!win) return;
+   elm_object_focus_set(win->win_obj, EINA_FALSE);
+   _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
    win->focus_highlight.cur.visible = EINA_FALSE;
    _elm_win_focus_highlight_reconfigure_job_start(win);
@@ -397,6 +409,26 @@ _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_T
              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
              return EINA_TRUE;
           }
+        else if ((!strcmp(ev->keyname, "Left")) ||
+                 (!strcmp(ev->keyname, "KP_Left")))
+          {
+             //TODO : woohyun jung
+          }
+        else if ((!strcmp(ev->keyname, "Right")) ||
+                 (!strcmp(ev->keyname, "KP_Right")))
+          {
+             //TODO : woohyun jung
+          }
+        else if ((!strcmp(ev->keyname, "Up")) ||
+                 (!strcmp(ev->keyname, "KP_Up")))
+          {
+             //TODO : woohyun jung
+          }
+        else if ((!strcmp(ev->keyname, "Down")) ||
+                 (!strcmp(ev->keyname, "KP_Down")))
+          {
+             //TODO : woohyun jung
+          }
      }
 
    return EINA_FALSE;
@@ -410,11 +442,11 @@ _deferred_ecore_evas_free(void *data)
 }
 
 static void
-_elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+_elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Elm_Win *win = data;
 
-   elm_object_focus(obj);
+   if (!win->show_count) win->show_count++;
    if (win->shot.info) _shot_handle(win);
 }
 
@@ -456,6 +488,8 @@ _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_inf
    if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
    if (win->shot.info) eina_stringshare_del(win->shot.info);
    if (win->shot.timer) ecore_timer_del(win->shot.timer);
+   evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL,
+                                       _elm_win_obj_callback_del, win);
    while (((child = evas_object_bottom_get(win->evas))) &&
           (child != obj))
      {
@@ -1257,13 +1291,15 @@ _win_img_hide(void        *data,
 }
 
 static void
-_win_img_mouse_down(void        *data,
-                    Evas        *e __UNUSED__,
-                    Evas_Object *obj __UNUSED__,
-                    void        *event_info __UNUSED__)
+_win_img_mouse_up(void        *data,
+                  Evas        *e __UNUSED__,
+                  Evas_Object *obj __UNUSED__,
+                  void        *event_info)
 {
    Elm_Win *win = data;
-   elm_widget_focus_mouse_down_handle(win->win_obj);
+   Evas_Event_Mouse_Up *ev = event_info;
+   if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
+      elm_widget_focus_mouse_up_handle(win->win_obj);
 }
 
 static void
@@ -1296,8 +1332,8 @@ _win_inlined_image_set(Elm_Win *win)
 
    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
                                   _win_img_hide, win);
-   evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_DOWN,
-                                  _win_img_mouse_down, win);
+   evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP,
+                                  _win_img_mouse_up, win);
    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
                                   _win_img_focus_in, win);
    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
@@ -1313,12 +1349,13 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
 
    win = ELM_NEW(Elm_Win);
 
-#define FALLBACK_TRY(engine)                                              \
-   if (!win->ee)                                                          \
-   do {                                                                   \
-        CRITICAL(engine " engine creation failed. Trying software X11."); \
-        elm_engine_set(ELM_SOFTWARE_X11);                                 \
-        win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);       \
+#define FALLBACK_TRY(engine)                                            \
+   if (!win->ee)                                                        \
+      do {                                                              \
+         CRITICAL(engine " engine creation failed. Trying default.");   \
+         win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);              \
+         if (win->ee)                                                   \
+            elm_engine_set(ecore_evas_engine_name_get(win->ee));        \
    } while (0)
 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
 
@@ -1352,6 +1389,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
              win->client_message_handler = ecore_event_handler_add
                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
 #endif
+             FALLBACK_TRY("Sofware X11");
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
           {
@@ -1443,6 +1481,10 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
           {
              win->ee = ecore_evas_buffer_new(1, 1);
           }
+        else if (ENGINE_COMPARE(ELM_EWS))
+          {
+             win->ee = ecore_evas_ews_new(0, 0, 1, 1);
+          }
         else if (!strncmp(_elm_config->engine, "shot:", 5))
           {
              win->ee = ecore_evas_buffer_new(1, 1);
@@ -1491,6 +1533,8 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
    evas_object_layer_set(win->win_obj, 50);
    evas_object_pass_events_set(win->win_obj, EINA_TRUE);
 
+   if (type == ELM_WIN_INLINED_IMAGE)
+     elm_widget_parent2_set(win->win_obj, parent);
    ecore_evas_object_associate(win->ee, win->win_obj,
                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
@@ -1506,8 +1550,8 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
                                   _elm_win_obj_callback_resize, win);
    if (win->img_obj)
-      evas_object_intercept_move_callback_add(win->win_obj,
-                                              _elm_win_obj_intercept_move, win);
+     evas_object_intercept_move_callback_add(win->win_obj,
+                                             _elm_win_obj_intercept_move, win);
    evas_object_intercept_show_callback_add(win->win_obj,
                                            _elm_win_obj_intercept_show, win);
 
@@ -1520,7 +1564,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
-      evas_font_path_append(win->evas, fontpath);
+     evas_font_path_append(win->evas, fontpath);
    if (!_elm_config->font_hinting)
      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
    else if (_elm_config->font_hinting == 1)
@@ -1550,7 +1594,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
 
    Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
                                         EINA_TRUE);
-   printf("Key F12 exclusive for dot tree generation. (%d)\n", ret);
+   printf("Ctrl+F12 key combination exclusive for dot tree generation\n");
 #endif
 
    evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
@@ -1727,6 +1771,7 @@ elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
    else if (win->img_obj)
      {
         evas_object_image_alpha_set(win->img_obj, alpha);
+        ecore_evas_alpha_set(win->ee, alpha);
      }
    else
      {
@@ -1757,6 +1802,13 @@ elm_win_alpha_get(const Evas_Object *obj)
    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
    win = elm_widget_data_get(obj);
    if (!win) return EINA_FALSE;
+   if (win->frame_obj)
+     {
+     }
+   else if (win->img_obj)
+     {
+        return evas_object_image_alpha_get(win->img_obj);
+     }
    return ecore_evas_alpha_get(win->ee);
 }
 
@@ -2388,6 +2440,8 @@ _theme_hook(Evas_Object *obj)
    if (wd->content)
      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
    _sizing_eval(obj);
+
+   evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
 }
 
 static Eina_Bool
@@ -2487,7 +2541,7 @@ elm_win_inwin_activate(Evas_Object *obj)
    evas_object_raise(obj);
    evas_object_show(obj);
    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
-   elm_object_focus(obj);
+   elm_object_focus_set(obj, EINA_TRUE);
 }
 
 EAPI void
@@ -2545,15 +2599,6 @@ _elm_ee_win_get(const Evas_Object *obj)
    return 0;
 }
 
-/**
- * Get the Ecore_X_Window of an Evas_Object
- *
- * @param obj The object
- *
- * @return The Ecore_X_Window of @p obj
- *
- * @ingroup Win
- */
 EAPI Ecore_X_Window
 elm_win_xwindow_get(const Evas_Object *obj)
 {