fix several elm+fb related issues and add a feature.
authorCarsten Haitzler <raster@rasterman.com>
Thu, 5 Jul 2012 09:23:38 +0000 (09:23 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Thu, 5 Jul 2012 09:23:38 +0000 (09:23 +0000)
SVN revision: 73334

ChangeLog
config/default/base.src
config/illume/base.src
config/standard/base.src
src/lib/elm_config.c
src/lib/elm_config.h
src/lib/elm_priv.h
src/lib/elm_win.c

index 832b550..ac8aa40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * Add access hook to widget infra.
 
+2012-07-5  Carsten Haitzler (The Rasterman)
+
+       * Fix several FB related issues:
+          * Fallback to FB from X11 so it "just works"
+          * Config expected x11 and failed to start app if engine not
+            explicitly set to non-x11
+          * No mouse cursor displayed in fb when needed, so add a
+            softcursor mode defaulting to auto.
+        
+
index 52398e8..bad7bf3 100644 (file)
@@ -62,6 +62,7 @@ group "Elm_Config" struct {
   value "weekend_len" int: 2;
   value "year_min" int: 2;
   value "year_max" int: 137;
+  value "softcursor_mode" uchar: 0;
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
index 4e0844b..df2735b 100644 (file)
@@ -62,6 +62,7 @@ group "Elm_Config" struct {
   value "weekend_len" int: 2;
   value "year_min" int: 2;
   value "year_max" int: 137;
+  value "softcursor_mode" uchar: 0;
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
index b607816..40d207d 100644 (file)
@@ -60,6 +60,7 @@ group "Elm_Config" struct {
   value "week_start" int: 1;
   value "weekend_start" int: 6;
   value "weekend_len" int: 2;
+  value "softcursor_mode" uchar: 0;
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
index 7736aa3..cb8ff67 100644 (file)
@@ -386,6 +386,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, year_min, T_INT);
    ELM_CONFIG_VAL(D, T, year_max, T_INT);
    ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
+   ELM_CONFIG_VAL(D, T, softcursor_mode, T_UCHAR);
 #undef T
 #undef D
 #undef T_INT
@@ -1053,6 +1054,7 @@ _config_load(void)
    _elm_config->weekend_len = 2;
    _elm_config->year_min = 2;
    _elm_config->year_max = 137;
+   _elm_config->softcursor_mode = 0; /* 0 = auto, 1 = on, 2 = off */
    _elm_config->color_palette = NULL;
 }
 
@@ -2020,6 +2022,18 @@ elm_config_longpress_timeout_get(void)
 }
 
 EAPI void
+elm_config_softcursor_mode_set(Elm_Softcursor_Mode mode)
+{
+   _elm_config->softcursor_mode = mode;
+}
+
+EAPI Elm_Softcursor_Mode
+elm_config_softcursor_mode_get(void)
+{
+   return _elm_config->softcursor_mode;
+}
+
+EAPI void
 elm_config_all_flush(void)
 {
 #ifdef HAVE_ELEMENTARY_X
@@ -2104,40 +2118,40 @@ _elm_config_sub_init(void)
 #undef ENGINE_COMPARE
      {
 #ifdef HAVE_ELEMENTARY_X
-        if (!ecore_x_init(NULL))
+        if (ecore_x_init(NULL))
           {
-             ERR("Cannot connect to X11 display. check $DISPLAY variable");
-             exit(1);
-          }
-        _root_1st = ecore_x_window_root_first_get();
-
-        if (!ecore_x_screen_is_composited(0))
-          _elm_config->compositing = 0;
-
-        ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
-        ecore_x_event_mask_set(_root_1st,
-                               ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
-        _prop_change_handler = ecore_event_handler_add
-            (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
-        if (!getenv("ELM_PROFILE"))
-          {
-             char *s;
-
-             s = ecore_x_window_prop_string_get(_root_1st,
-                                                _atom[ATOM_E_PROFILE]);
-             if (s)
+             _root_1st = ecore_x_window_root_first_get();
+             
+             if (!ecore_x_screen_is_composited(0))
+               _elm_config->compositing = 0;
+             
+             ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
+             ecore_x_event_mask_set(_root_1st,
+                                    ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
+             _prop_change_handler = ecore_event_handler_add
+               (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
+             if (!getenv("ELM_PROFILE"))
                {
-                  int changed = 0;
-
-                  if (_elm_profile)
+                  char *s;
+                  
+                  s = ecore_x_window_prop_string_get(_root_1st,
+                                                     _atom[ATOM_E_PROFILE]);
+                  if (s)
                     {
-                       if (strcmp(_elm_profile, s)) changed = 1;
-                       free(_elm_profile);
+                       int changed = 0;
+                       
+                       if (_elm_profile)
+                         {
+                            if (strcmp(_elm_profile, s)) changed = 1;
+                            free(_elm_profile);
+                         }
+                       _elm_profile = s;
+                       if (changed) _prop_config_get();
                     }
-                  _elm_profile = s;
-                  if (changed) _prop_config_get();
                }
           }
+        else
+          ERR("Cannot connect to X11 display. check $DISPLAY variable");
 #endif
      }
    _config_sub_apply();
index 3128f46..c7b8e67 100644 (file)
@@ -421,6 +421,41 @@ EAPI double       elm_config_longpress_timeout_get(void);
  */
 EAPI void         elm_config_longpress_timeout_set(double longpress_timeout);
 
+typedef enum _Elm_Softcursor_Mode
+{
+   ELM_SOFTCURSOR_MODE_AUTO, /**< Auto-detect if a software cursor should be used (default) */
+   ELM_SOFTCURSOR_MODE_ON, /**< Always use a softcursor */
+   ELM_SOFTCURSOR_MODE_OFF /**< Never use a softcursor */
+} Elm_Softcursor_Mode; /**< @since 1.1 */
+
+/**
+ * Set the mode used for software provided mouse cursors inline in the window
+ * canvas.
+ * 
+ * A software rendered cursor can be provided for rendering inline inside the
+ * canvas windows in the event the native display system does not provide one
+ * or the native oneis not wanted.
+ *
+ * @param lonpress_timeout Timeout for long press event
+ * @ingroup Softcursor
+ * 
+ * @see elm_config_softcursor_mode_get()
+ * @since 1.1
+ */
+EAPI void         elm_config_softcursor_mode_set(Elm_Softcursor_Mode mode);
+
+/**
+ * Get the software cursor mode
+ *
+ * @return The mode used for software cursors
+ * @ingroup Softcursor
+ * 
+ * @see elm_config_softcursor_mode_set()
+ * @since 1.1
+ */
+EAPI Elm_Softcursor_Mode elm_config_softcursor_mode_get(void);
+
+
 /**
  * Get the duration after which tooltip will be shown.
  *
index fd2bc4b..ea2f4a1 100644 (file)
@@ -189,6 +189,7 @@ struct _Elm_Config
    int           year_min;
    int           year_max;
    Eina_List    *color_palette;
+   unsigned char softcursor_mode;
 
    /* Not part of the EET file */
    Eina_Bool     is_mirrored : 1;
index 044df18..0d2f585 100644 (file)
@@ -1963,6 +1963,13 @@ elm_win_add(Evas_Object *parent,
            elm_config_preferred_engine_set                            \
              (ecore_evas_engine_name_get(tmp_sd.ee));                 \
       } while (0)
+#define FALLBACK_STORE(engine)                                        \
+  if (tmp_sd.ee)                                                      \
+    do {                                                              \
+         CRITICAL(engine "Fallback to %s successful.", engine);       \
+         elm_config_preferred_engine_set                              \
+           (ecore_evas_engine_name_get(tmp_sd.ee));                   \
+      } while (0)
 
    switch (type)
      {
@@ -1998,26 +2005,66 @@ elm_win_add(Evas_Object *parent,
           {
              tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
              FALLBACK_TRY("Sofware X11");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                  FALLBACK_STORE("Sofware FB");
+               }
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
           {
              tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
              FALLBACK_TRY("Sofware FB");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+               }
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
           {
              tmp_sd.ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
              FALLBACK_TRY("Sofware DirectFB");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
           {
              tmp_sd.ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
              FALLBACK_TRY("Sofware-16");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
           {
              tmp_sd.ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
              FALLBACK_TRY("Sofware-8");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
           {
@@ -2037,6 +2084,16 @@ elm_win_add(Evas_Object *parent,
              else
                tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
              FALLBACK_TRY("OpenGL");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
           {
@@ -2057,16 +2114,46 @@ elm_win_add(Evas_Object *parent,
           {
              tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
              FALLBACK_TRY("Sofware SDL");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
           {
              tmp_sd.ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
              FALLBACK_TRY("Sofware-16-SDL");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
           {
              tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
              FALLBACK_TRY("OpenGL SDL");
+             if (!tmp_sd.ee)
+               {
+                  tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
+                  FALLBACK_STORE("Sofware X11");
+                  if (!tmp_sd.ee)
+                    {
+                       tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
+                       FALLBACK_STORE("Sofware FB");
+                    }
+               }
           }
         else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
           {
@@ -2105,7 +2192,7 @@ elm_win_add(Evas_Object *parent,
         ERR("Cannot create window.");
         return NULL;
      }
-
+   
    obj = evas_object_smart_add
        (ecore_evas_get(tmp_sd.ee), _elm_win_smart_class_new());
 
@@ -2249,6 +2336,30 @@ elm_win_add(Evas_Object *parent,
      ERR("failed to grab F12 key to elm widgets (dot) tree generation");
 #endif
 
+   if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
+       ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
+           elm_config_preferred_engine_get() &&
+           (!strcmp(elm_config_preferred_engine_get(), "fb"))))
+     {
+        Evas_Object *o;
+        Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
+        
+        sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
+        _elm_theme_object_set(obj, o, "pointer", "base", "default");
+        edje_object_size_min_calc(o, &mw, &mh);
+        evas_object_resize(o, mw, mh);
+        edje_object_part_geometry_get(o, "elm.swallow.hotspot",
+                                      &hx, &hy, NULL, NULL);
+        sd->pointer.hot_x = hx;
+        sd->pointer.hot_y = hy;
+        evas_object_show(o);
+        ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
+     }
+   else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
+     {
+        // do nothing
+     }
+
    return obj;
 }