[*][Scroller] merge from upstream revision 64051, but didn't accept data/theme/widget...
[framework/uifw/elementary.git] / src / lib / elm_config.c
index f0f5a1a..033c30e 100644 (file)
@@ -9,6 +9,7 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
+
 Elm_Config *_elm_config = NULL;
 char *_elm_profile = NULL;
 static Eet_Data_Descriptor *_config_edd = NULL;
@@ -73,7 +74,7 @@ static size_t _elm_user_dir_snprintf(char       *dst,
 #ifdef HAVE_ELEMENTARY_X
 static Ecore_Event_Handler *_prop_change_handler = NULL;
 static Ecore_X_Window _root_1st = 0;
-#define ATOM_COUNT 25
+#define ATOM_COUNT 23
 static Ecore_X_Atom _atom[ATOM_COUNT];
 static Ecore_X_Atom _atom_config = 0;
 static const char *_atom_names[ATOM_COUNT] =
@@ -96,12 +97,10 @@ static const char *_atom_names[ATOM_COUNT] =
    "ENLIGHTENMENT_THUMBSCROLL_MOMENTUM_THRESHOLD",
    "ENLIGHTENMENT_THUMBSCROLL_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_BORDER_FRICTION",
+   "ENLIGHTENMENT_THUMBSCROLL_SENSITIVITY_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_PAGE_SCROLL_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_BRING_IN_SCROLL_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_ZOOM_FRICTION",
-   "ENLIGHTENMENT_INPUT_PANEL",
-   "ENLIGHTENMENT_AUTOCAPITAL_ALLOW",
-   "ENLIGHTENMENT_AUTOPERIOD_ALLOW",
    "ENLIGHTENMENT_CONFIG"
 };
 #define ATOM_E_SCALE                                0
@@ -122,13 +121,11 @@ static const char *_atom_names[ATOM_COUNT] =
 #define ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD       15
 #define ATOM_E_THUMBSCROLL_FRICTION                 16
 #define ATOM_E_THUMBSCROLL_BORDER_FRICTION          17
-#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION     18
-#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 19
-#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION            20
-#define ATOM_E_INPUT_PANEL 21
-#define ATOM_E_AUTOCAPITAL_ALLOW 22
-#define ATOM_E_AUTOPERIOD_ALLOW 23
-#define ATOM_E_CONFIG                               24
+#define ATOM_E_THUMBSCROLL_SENSITIVITY_FRICTION     18
+#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION     19
+#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 20
+#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION            21
+#define ATOM_E_CONFIG                               22
 
 static Eina_Bool _prop_config_get(void);
 static Eina_Bool _prop_change(void *data  __UNUSED__,
@@ -442,9 +439,8 @@ _prop_change(void *data  __UNUSED__,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  if (val > 0)
-                    _elm_config->thumbscroll_momentum_threshold =
-                      (double)val / 1000.0;
+                  _elm_config->thumbscroll_momentum_threshold =
+                     (double)val / 1000.0;
                }
           }
         else if (event->atom == _atom[ATOM_E_THUMBSCROLL_FRICTION])
@@ -455,8 +451,7 @@ _prop_change(void *data  __UNUSED__,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  if (val > 0)
-                    _elm_config->thumbscroll_friction = (double)val / 1000.0;
+                  _elm_config->thumbscroll_friction = (double)val / 1000.0;
                }
           }
         else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BORDER_FRICTION])
@@ -467,12 +462,11 @@ _prop_change(void *data  __UNUSED__,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  if (val > 0)
-                    _elm_config->thumbscroll_border_friction =
-                      (double)val / 1000.0;
+                  _elm_config->thumbscroll_border_friction =
+                     (double)val / 1000.0;
                }
           }
-        else if (event->atom == _atom[ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION])
+        else if (event->atom == _atom[ATOM_E_THUMBSCROLL_SENSITIVITY_FRICTION])
           {
              unsigned int val = 1000;
 
@@ -480,13 +474,11 @@ _prop_change(void *data  __UNUSED__,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  if (val > 0)
-                    _elm_config->page_scroll_friction =
-                      (double)val / 1000.0;
+                  _elm_config->thumbscroll_sensitivity_friction =
+                     (double)val / 1000.0;
                }
           }
-        else if (event->atom ==
-                 _atom[ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION])
+        else if (event->atom == _atom[ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION])
           {
              unsigned int val = 1000;
 
@@ -494,13 +486,12 @@ _prop_change(void *data  __UNUSED__,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  if (val > 0)
-                    _elm_config->bring_in_scroll_friction =
-                      (double)val / 1000.0;
+                  _elm_config->page_scroll_friction =
+                     (double)val / 1000.0;
                }
           }
         else if (event->atom ==
-                 _atom[ATOM_E_THUMBSCROLL_ZOOM_FRICTION])
+                 _atom[ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION])
           {
              unsigned int val = 1000;
 
@@ -508,62 +499,20 @@ _prop_change(void *data  __UNUSED__,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  if (val > 0)
-                    _elm_config->zoom_friction = (double)val / 1000.0;
+                  _elm_config->bring_in_scroll_friction =
+                     (double)val / 1000.0;
                }
           }
-        else if (event->atom == _atom[ATOM_E_INPUT_PANEL])
-          {
-             unsigned int val = 0;
-
-             if (ecore_x_window_prop_card32_get(event->win,
-                                                event->atom,
-                                                &val, 1) > 0)
-               {
-                   int input_panel_enable;
-
-                   input_panel_enable = _elm_config->input_panel_enable;
-                   _elm_config->input_panel_enable = val;
-                   if (input_panel_enable != _elm_config->input_panel_enable) 
-                     {
-                        edje_input_panel_enabled_set(_elm_config->input_panel_enable);
-                     }
-               }
-          }
-        else if (event->atom == _atom[ATOM_E_AUTOCAPITAL_ALLOW])
-          {
-             unsigned int val = 0;
-
-             if (ecore_x_window_prop_card32_get(event->win,
-                                                event->atom,
-                                                &val, 1) > 0)
-               {
-                   int autocapital_allow;
-
-                   autocapital_allow = _elm_config->autocapital_allow;
-                   _elm_config->autocapital_allow = val;
-                   if (autocapital_allow != _elm_config->autocapital_allow) 
-                     {
-                        edje_autocapitalization_allow_set(_elm_config->autocapital_allow);
-                     }
-               }
-          }            
-        else if (event->atom == _atom[ATOM_E_AUTOPERIOD_ALLOW])
+        else if (event->atom ==
+                 _atom[ATOM_E_THUMBSCROLL_ZOOM_FRICTION])
           {
-             unsigned int val = 0;
+             unsigned int val = 1000;
 
              if (ecore_x_window_prop_card32_get(event->win,
                                                 event->atom,
                                                 &val, 1) > 0)
                {
-                  int autoperiod_allow;
-
-                  autoperiod_allow = _elm_config->autoperiod_allow;
-                  _elm_config->autoperiod_allow = val;
-                  if (autoperiod_allow != _elm_config->autoperiod_allow) 
-                    {
-                       edje_autoperiod_allow_set(_elm_config->autoperiod_allow);
-                    }
+                    _elm_config->zoom_friction = (double)val / 1000.0;
                }
           }
         else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
@@ -622,16 +571,23 @@ _desc_init(void)
 #define D _config_edd
    ELM_CONFIG_VAL(D, T, config_version, T_INT);
    ELM_CONFIG_VAL(D, T, engine, T_STRING);
+   ELM_CONFIG_VAL(D, T, vsync, T_UCHAR);
    ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
    ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
    ELM_CONFIG_VAL(D, T, compositing, T_INT);
@@ -657,8 +613,10 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, inwin_dialogs_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, icon_size, T_INT);
    ELM_CONFIG_VAL(D, T, longpress_timeout, T_DOUBLE);
-   ELM_CONFIG_VAL(D, T, password_show_last_character, T_UCHAR);
-   ELM_CONFIG_VAL(D, T, input_panel_enable, T_INT);
+   ELM_CONFIG_VAL(D, T, effect_enable, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, desktop_entry, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, password_show_last, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, password_show_last_timeout, T_DOUBLE);
 #undef T
 #undef D
 #undef T_INT
@@ -731,7 +689,11 @@ _elm_user_dir_snprintf(char       *dst,
    size_t user_dir_len, off;
    va_list ap;
 
+#ifdef _WIN32
+   home = evil_homedir_get();
+#else
    home = getenv("HOME");
+#endif
    if (!home)
      home = "/";
 
@@ -955,9 +917,8 @@ sys:
              continue;
           }
      }
-   return flist;
-
    eina_iterator_free(file_it);
+   return flist;
 
 list_free:
    EINA_LIST_FREE(flist, dir)
@@ -1057,10 +1018,9 @@ _config_sub_apply(void)
 {
    edje_frametime_set(1.0 / _elm_config->fps);
    edje_scale_set(_elm_config->scale);
+   edje_password_show_last_set(_elm_config->password_show_last);
+   edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
    if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
-   edje_input_panel_enabled_set(_elm_config->input_panel_enable);
-   edje_autocapitalization_allow_set(_elm_config->autocapital_allow);
-   edje_autoperiod_allow_set(_elm_config->autoperiod_allow);
 }
 
 static Eina_Bool
@@ -1084,8 +1044,8 @@ _elm_recache(void)
    EINA_LIST_FOREACH(_elm_win_list, l, win)
      {
         Evas *e = evas_object_evas_get(win);
-        evas_image_cache_set(e, _elm_config->image_cache);
-        evas_font_cache_set(e, _elm_config->font_cache);
+        evas_image_cache_set(e, _elm_config->image_cache * 1024);
+        evas_font_cache_set(e, _elm_config->font_cache * 1024);
      }
    edje_file_cache_set(_elm_config->edje_cache);
    edje_collection_cache_set(_elm_config->edje_collection_cache);
@@ -1170,6 +1130,7 @@ _config_load(void)
    _elm_config = ELM_NEW(Elm_Config);
    _elm_config->config_version = ELM_CONFIG_VERSION;
    _elm_config->engine = eina_stringshare_add("software_x11");
+   _elm_config->vsync = 0;
    _elm_config->thumbscroll_enable = EINA_TRUE;
    _elm_config->thumbscroll_threshold = 24;
    _elm_config->thumbscroll_momentum_threshold = 100.0;
@@ -1180,6 +1141,12 @@ _config_load(void)
    _elm_config->bring_in_scroll_friction = 0.5;
    _elm_config->zoom_friction = 0.5;
    _elm_config->thumbscroll_border_friction = 0.5;
+   _elm_config->thumbscroll_sensitivity_friction = 0.25; // magic number! just trial and error shows this makes it behave "nicer" and not run off at high speed all the time
+   _elm_config->scroll_smooth_time_interval = 0.008;
+   _elm_config->scroll_smooth_amount = 1.0;
+   _elm_config->scroll_smooth_history_weight = 0.3;
+   _elm_config->scroll_smooth_future_time = 0.0;
+   _elm_config->scroll_smooth_time_window = 0.2;
    _elm_config->scale = 1.0;
    _elm_config->bgpixmap = 0;
    _elm_config->compositing = 1;
@@ -1204,7 +1171,11 @@ _config_load(void)
    _elm_config->inwin_dialogs_enable = EINA_FALSE;
    _elm_config->icon_size = 32;
    _elm_config->longpress_timeout = 1.0;
-   _elm_config->password_show_last_character = EINA_FALSE;
+   _elm_config->effect_enable = EINA_TRUE;
+   _elm_config->desktop_entry = EINA_FALSE;
+   _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
+   _elm_config->password_show_last = EINA_FALSE;
+   _elm_config->password_show_last_timeout = 2.0;
 }
 
 static const char *
@@ -1446,7 +1417,7 @@ _env_get(void)
                  (!strcasecmp(s, "opengl_x11")))
           eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_X11);
         else if ((!strcasecmp(s, "x11-8")) ||
-                 (!strcasecmp(s, "x18")) ||
+                 (!strcasecmp(s, "x8")) ||
                  (!strcasecmp(s, "software-8-x11")) ||
                  (!strcasecmp(s, "software_8_x11")))
           eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_8_X11);
@@ -1455,11 +1426,13 @@ _env_get(void)
                  (!strcasecmp(s, "software-16-x11")) ||
                  (!strcasecmp(s, "software_16_x11")))
           eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_X11);
+/*
         else if ((!strcasecmp(s, "xrender")) ||
                  (!strcasecmp(s, "xr")) ||
                  (!strcasecmp(s, "xrender-x11")) ||
                  (!strcasecmp(s, "xrender_x11")))
           eina_stringshare_replace(&_elm_config->engine, ELM_XRENDER_X11);
+ */
         else if ((!strcasecmp(s, "fb")) ||
                  (!strcasecmp(s, "software-fb")) ||
                  (!strcasecmp(s, "software_fb")))
@@ -1488,8 +1461,13 @@ _env_get(void)
                  (!strcasecmp(s, "software-16-wince-gdi")) ||
                  (!strcasecmp(s, "software_16_wince_gdi")))
           eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_WINCE);
+        else if ((!strncmp(s, "shot:", 5)))
+          eina_stringshare_replace(&_elm_config->engine, s);
      }
 
+   s = getenv("ELM_VSYNC");
+   if (s) _elm_config->vsync = !!atoi(s);
+
    s = getenv("ELM_THUMBSCROLL_ENABLE");
    if (s) _elm_config->thumbscroll_enable = !!atoi(s);
    s = getenv("ELM_THUMBSCROLL_THRESHOLD");
@@ -1521,6 +1499,28 @@ _env_get(void)
 
         _elm_config->thumbscroll_border_friction = friction;
      }
+   s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
+   if (s)
+     {
+        friction = atof(s);
+        if (friction < 0.1)
+          friction = 0.1;
+
+        if (friction > 1.0)
+          friction = 1.0;
+
+        _elm_config->thumbscroll_sensitivity_friction = friction;
+     }
+   s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL");
+   if (s) _elm_config->scroll_smooth_time_interval = atof(s);
+   s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
+   if (s) _elm_config->scroll_smooth_amount = atof(s);
+   s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
+   if (s) _elm_config->scroll_smooth_history_weight = atof(s);
+   s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
+   if (s) _elm_config->scroll_smooth_future_time = atof(s);
+   s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
+   if (s) _elm_config->scroll_smooth_time_window = atof(s);
    s = getenv("ELM_THEME");
    if (s) eina_stringshare_replace(&_elm_config->theme, s);
 
@@ -1586,8 +1586,16 @@ _env_get(void)
    s = getenv("ELM_FINGER_SIZE");
    if (s) _elm_config->finger_size = atoi(s);
 
-   s = getenv("ELM_PASSWORD_SHOW_LAST_CHARACTER");
-   if (s) _elm_config->password_show_last_character = !!atoi(s);
+   s = getenv("ELM_PASSWORD_SHOW_LAST");
+   if (s) _elm_config->password_show_last = !!atoi(s);
+
+   s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
+   if (s)
+     {
+        double pw_show_last_timeout = atof(s);
+        if (pw_show_last_timeout >= 0.0)
+          _elm_config->password_show_last_timeout = pw_show_last_timeout;
+     }
 
    s = getenv("ELM_FPS");
    if (s) _elm_config->fps = atof(s);
@@ -1596,6 +1604,11 @@ _env_get(void)
    s = getenv("ELM_MODULES");
    if (s) eina_stringshare_replace(&_elm_config->modules, s);
 
+   /* Get RTL orientation from system */
+   setlocale(LC_ALL, "");
+   bindtextdomain(PACKAGE, LOCALE_DIR);
+   _elm_config->is_mirrored = !strcmp(E_("default:LTR"), "default:RTL");
+
    s = getenv("ELM_TOOLTIP_DELAY");
    if (s)
      {
@@ -1625,13 +1638,41 @@ _env_get(void)
    s = getenv("ELM_ICON_SIZE");
    if (s) _elm_config->icon_size = atoi(s);
 
-   s = getenv("ELM_INPUT_PANEL");
-   if (s) _elm_config->input_panel_enable = atoi(s);
-
    s = getenv("ELM_LONGPRESS_TIMEOUT");
    if (s) _elm_config->longpress_timeout = atof(s);
    if (_elm_config->longpress_timeout < 0.0)
      _elm_config->longpress_timeout = 0.0;
+
+   s = getenv("ELM_EFFECT_ENABLE");
+   if (s) _elm_config->effect_enable = !!atoi(s);
+
+   s = getenv("ELM_DESKTOP_ENTRY");
+   if (s) _elm_config->desktop_entry = !!atoi(s);
+}
+
+/**
+ * Get the system mirrored mode. This determines the default mirrored mode
+ * of widgets.
+ *
+ * @return EINA_TRUE if mirrored is set, EINA_FALSE otherwise
+ */
+EAPI Eina_Bool
+elm_mirrored_get(void)
+{
+   return _elm_config->is_mirrored;
+}
+
+/**
+ * Set the system mirrored mode. This determines the default mirrored mode
+ * of widgets.
+ *
+ * @param mirrored EINA_TRUE to set mirrored mode, EINA_FALSE to unset it.
+ */
+EAPI void
+elm_mirrored_set(Eina_Bool mirrored)
+{
+   _elm_config->is_mirrored = mirrored;
+   _elm_rescale();
 }
 
 void
@@ -1640,6 +1681,7 @@ _elm_config_init(void)
    _desc_init();
    _profile_fetch_from_conf();
    _config_load();
+// NOTE: Do not merge upstream code. Just leave it.
 //   _env_get();
 //   _config_apply();
 //   _elm_config_font_overlay_apply();
@@ -1649,6 +1691,7 @@ _elm_config_init(void)
 void
 _elm_config_sub_init(void)
 {
+   // NOTE: Do not merge upstream code. Just leave it.
    _env_get();
    _config_apply();
    _elm_config_font_overlay_apply();
@@ -1741,39 +1784,6 @@ _elm_config_sub_init(void)
                   if (changed) _prop_config_get();
               }
          }
-        if (!getenv("ELM_INPUT_PANEL"))
-          {
-             if (ecore_x_window_prop_card32_get(_root_1st,
-                                                _atom[ATOM_E_INPUT_PANEL],
-                                                &val, 1) > 0)
-               {
-                  if (val > 0)
-                    {
-                       _elm_config->input_panel_enable = val;
-                       edje_input_panel_enabled_set(_elm_config->input_panel_enable);
-                    }
-               }
-          }
-        if (ecore_x_window_prop_card32_get(_root_1st,
-                                           _atom[ATOM_E_AUTOCAPITAL_ALLOW],
-                                           &val, 1) > 0)
-          {
-             if (val > 0)
-               {
-                  _elm_config->autocapital_allow = val;
-                  edje_autocapitalization_allow_set(_elm_config->autocapital_allow);
-               }
-          }
-        if (ecore_x_window_prop_card32_get(_root_1st,
-                                           _atom[ATOM_E_AUTOPERIOD_ALLOW],
-                                           &val, 1) > 0)
-          {
-             if (val > 0)
-               {
-                  _elm_config->autoperiod_allow = val;
-                  edje_autoperiod_allow_set(_elm_config->autoperiod_allow);
-               }
-          }
 #endif
      }
    _config_sub_apply();