Elementary: Use ecore_evas_new if the engine fails instead of hardcoding software...
[framework/uifw/elementary.git] / src / lib / elm_win.c
index 3164354..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,7 +308,13 @@ _elm_win_focus_in(Ecore_Evas *ee)
    if (!obj) return;
    win = elm_widget_data_get(obj);
    if (!win) return;
-   if (!elm_widget_focus_get(win->win_obj))
+   _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;
@@ -330,6 +338,7 @@ _elm_win_focus_out(Ecore_Evas *ee)
    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);
@@ -433,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_set(obj, EINA_TRUE);
+   if (!win->show_count) win->show_count++;
    if (win->shot.info) _shot_handle(win);
 }
 
@@ -479,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))
      {
@@ -1338,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))
 
@@ -1377,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))
           {
@@ -1468,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);
@@ -1577,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);
@@ -1754,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
      {
@@ -1784,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);
 }
 
@@ -2415,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