summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-01-05 22:15:00 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-01-05 22:25:20 +0900
commitfaf2dcf9d3c164a271315b958c142bd21f01e212 (patch)
treebfce4471271d47922cfe12f0e97531497c4d271a
parentd2c779844844d673b6a6f0a209f2a607a4bdc2c6 (diff)
elm config - monitor JUST the correct files for profile and cfg change
this fixes the config monitoring to not use flush.cfg but to use the correct profie.cfg or base.cfg in the profile we are using. this is necessary to do "special" profiles per screen so apps that switched to another profile because asked by e, monitor THAT profile for changes specifically and dont also switch profiles since they have been told what to use now. @fix
-rw-r--r--src/lib/elm_config.c198
-rw-r--r--src/lib/elm_priv.h2
-rw-r--r--src/lib/elm_win.c1
3 files changed, 88 insertions, 113 deletions
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index ccf64985b..c2a02a745 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -26,8 +26,14 @@ Eina_List *_color_overlays_del = NULL;
26 26
27static Ecore_Poller *_elm_cache_flush_poller = NULL; 27static Ecore_Poller *_elm_cache_flush_poller = NULL;
28static void _elm_config_key_binding_hash(void); 28static void _elm_config_key_binding_hash(void);
29
30Eina_Bool _config_profile_lock = EINA_FALSE;
29static Ecore_Timer *_config_change_delay_timer = NULL; 31static Ecore_Timer *_config_change_delay_timer = NULL;
30Eio_Monitor *_eio_monitor = NULL; 32static Ecore_Timer *_config_profile_change_delay_timer = NULL;
33static Ecore_Event_Handler *_monitor_file_created_handler = NULL;
34static Ecore_Event_Handler *_monitor_directory_created_handler = NULL;
35static Eio_Monitor *_eio_config_monitor = NULL;
36static Eio_Monitor *_eio_profile_monitor = NULL;
31 37
32Eina_Hash *_elm_key_bindings = NULL; 38Eina_Hash *_elm_key_bindings = NULL;
33 39
@@ -1607,6 +1613,12 @@ _config_user_load(void)
1607 Eet_File *ef; 1613 Eet_File *ef;
1608 char buf[PATH_MAX]; 1614 char buf[PATH_MAX];
1609 1615
1616 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s",
1617 _elm_profile);
1618 if (_eio_config_monitor) eio_monitor_del(_eio_config_monitor);
1619 printf("monitor dir %s\n", buf);
1620 _eio_config_monitor = eio_monitor_add(buf);
1621
1610 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg", 1622 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
1611 _elm_profile); 1623 _elm_profile);
1612 1624
@@ -1800,53 +1812,13 @@ _config_load(void)
1800} 1812}
1801 1813
1802static void 1814static void
1803_config_flush_load(void)
1804{
1805 Elm_Config *cfg = NULL;
1806 Eet_File *ef;
1807 char buf[PATH_MAX];
1808
1809 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/flush.cfg");
1810
1811 ef = eet_open(buf, EET_FILE_MODE_READ);
1812 if (ef)
1813 {
1814 cfg = eet_data_read(ef, _config_edd, "config");
1815 eet_close(ef);
1816 }
1817
1818 if (cfg)
1819 {
1820 size_t len;
1821
1822 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/");
1823 if (len + 1 < sizeof(buf))
1824 ecore_file_mkpath(buf);
1825
1826 _elm_config = cfg;
1827
1828 if ((_elm_config->config_version >> ELM_CONFIG_VERSION_EPOCH_OFFSET) < ELM_CONFIG_EPOCH)
1829 {
1830 WRN("User's elementary config seems outdated and unusable. Fallback to load system config.");
1831 _config_free(_elm_config);
1832 _elm_config = NULL;
1833 }
1834 else
1835 {
1836 if (_elm_config->config_version < ELM_CONFIG_VERSION)
1837 _config_update();
1838 }
1839 }
1840}
1841
1842static void
1843_config_flush_get(void) 1815_config_flush_get(void)
1844{ 1816{
1845 _elm_config_font_overlays_cancel(); 1817 _elm_config_font_overlays_cancel();
1846 _color_overlays_cancel(); 1818 _color_overlays_cancel();
1847 _config_free(_elm_config); 1819 _config_free(_elm_config);
1848 _elm_config = NULL; 1820 _elm_config = NULL;
1849 _config_flush_load(); 1821 _config_load();
1850 _env_get(); 1822 _env_get();
1851 _config_apply(); 1823 _config_apply();
1852 _config_sub_apply(); 1824 _config_sub_apply();
@@ -3608,10 +3580,8 @@ elm_config_window_auto_focus_animate_set(Eina_Bool enable)
3608EAPI void 3580EAPI void
3609elm_config_all_flush(void) 3581elm_config_all_flush(void)
3610{ 3582{
3611 char buf[4096], buf2[4096]; 3583 char buf[PATH_MAX];
3612 int ok = 0, ret; 3584 int ok = 0;
3613 const char *err;
3614 Eet_File *ef;
3615 size_t len; 3585 size_t len;
3616 3586
3617 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/"); 3587 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/");
@@ -3644,54 +3614,8 @@ elm_config_all_flush(void)
3644 return; 3614 return;
3645 } 3615 }
3646 3616
3647 buf[len] = '/';
3648 len++;
3649
3650 if (len + sizeof("flush.cfg") >= sizeof(buf) - len)
3651 return;
3652
3653 memcpy(buf + len, "flush.cfg", sizeof("flush.cfg"));
3654 len += sizeof("flush.cfg") - 1;
3655
3656 if (len + sizeof(".tmp") >= sizeof(buf))
3657 return;
3658
3659 memcpy(buf2, buf, len);
3660 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
3661
3662 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
3663 if (!ef)
3664 return;
3665
3666 ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
3667 if (!ok)
3668 {
3669 ERR("Failed to write config (error %i)", ok);
3670 goto err;
3671 }
3672
3673 err = _elm_config_eet_close_error_get(ef, buf2);
3674 if (err)
3675 {
3676 ERR("%s", err);
3677 free((void *)err);
3678 goto err;
3679 }
3680
3681 ret = ecore_file_mv(buf2, buf);
3682 if (!ret)
3683 {
3684 ERR("Error saving Elementary's configuration file");
3685 goto err;
3686 }
3687
3688 ecore_file_unlink(buf2);
3689 elm_config_save(); 3617 elm_config_save();
3690 return; 3618 return;
3691
3692err:
3693 ecore_file_unlink(buf2);
3694 return;
3695} 3619}
3696 3620
3697static void 3621static void
@@ -3758,33 +3682,86 @@ _elm_config_sub_shutdown(void)
3758#ifdef HAVE_ELEMENTARY_WIN32 3682#ifdef HAVE_ELEMENTARY_WIN32
3759 ecore_win32_shutdown(); 3683 ecore_win32_shutdown();
3760#endif 3684#endif
3761 ELM_SAFE_FREE(_eio_monitor, eio_monitor_del); 3685 ELM_SAFE_FREE(_eio_config_monitor, eio_monitor_del);
3686 ELM_SAFE_FREE(_eio_profile_monitor, eio_monitor_del);
3762 ELM_SAFE_FREE(_config_change_delay_timer, ecore_timer_del); 3687 ELM_SAFE_FREE(_config_change_delay_timer, ecore_timer_del);
3688 ELM_SAFE_FREE(_config_profile_change_delay_timer, ecore_timer_del);
3689 ELM_SAFE_FREE(_monitor_file_created_handler, ecore_event_handler_del);
3690 ELM_SAFE_FREE(_monitor_directory_created_handler, ecore_event_handler_del);
3691}
3692
3693static Eina_Bool
3694_config_profile_change_delay_cb(void *data EINA_UNUSED)
3695{
3696 char *pprof = NULL;
3697
3698 if (_elm_profile) pprof = strdup(_elm_profile);
3699 _profile_fetch_from_conf();
3700 if ((!pprof) || (!(!strcmp(pprof, _elm_profile))))
3701 {
3702 _config_flush_get();
3703 }
3704 free(pprof);
3705 _config_profile_change_delay_timer = NULL;
3706 return ECORE_CALLBACK_CANCEL;
3763} 3707}
3764 3708
3765static Eina_Bool 3709static Eina_Bool
3766_config_change_delay_cb(void *data EINA_UNUSED) 3710_config_change_delay_cb(void *data EINA_UNUSED)
3767{ 3711{
3768 char buf[PATH_MAX]; 3712 _elm_config_reload();
3769 3713
3770 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/flush.cfg");
3771 if (ecore_file_exists(buf)) _config_flush_get();
3772 _config_change_delay_timer = NULL; 3714 _config_change_delay_timer = NULL;
3773
3774 return ECORE_CALLBACK_CANCEL; 3715 return ECORE_CALLBACK_CANCEL;
3775} 3716}
3776 3717
3777static Eina_Bool 3718static Eina_Bool
3778_elm_config_file_monitor_cb(void *data EINA_UNUSED, 3719_elm_config_file_monitor_cb(void *data EINA_UNUSED,
3779 int type EINA_UNUSED, 3720 int type,
3780 void *event) 3721 void *event)
3781{ 3722{
3782 Eio_Monitor_Event *ev = event; 3723 Eio_Monitor_Event *ev = event;
3724 const char *file = ecore_file_file_get(ev->filename);
3725 char buf[PATH_MAX];
3783 3726
3784 if (ev->monitor != _eio_monitor) return ECORE_CALLBACK_PASS_ON; 3727 if (ev->monitor == _eio_config_monitor)
3785 3728 {
3786 ecore_timer_del(_config_change_delay_timer); 3729 if (type == EIO_MONITOR_FILE_CREATED)
3787 _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL); 3730 {
3731 if (!strcmp(file, "base.cfg"))
3732 {
3733 if (_config_change_delay_timer)
3734 ecore_timer_del(_config_change_delay_timer);
3735 _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL);
3736 }
3737 }
3738 }
3739 if (ev->monitor == _eio_profile_monitor)
3740 {
3741 if (type == EIO_MONITOR_FILE_CREATED)
3742 {
3743 if ((!_config_profile_lock) && (!strcmp(file, "profile.cfg")))
3744 {
3745 if (_config_profile_change_delay_timer)
3746 ecore_timer_del(_config_profile_change_delay_timer);
3747 _config_profile_change_delay_timer = ecore_timer_add(0.1, _config_profile_change_delay_cb, NULL);
3748 }
3749 }
3750 else if (type == EIO_MONITOR_DIRECTORY_CREATED)
3751 {
3752 if (!_eio_config_monitor)
3753 {
3754 _eio_config_monitor = eio_monitor_add(ev->filename);
3755 snprintf(buf, sizeof(buf), "%s/base.cfg", ev->filename);
3756 if (ecore_file_exists(buf))
3757 {
3758 if (_config_change_delay_timer)
3759 ecore_timer_del(_config_change_delay_timer);
3760 _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL);
3761 }
3762 }
3763 }
3764 }
3788 3765
3789 return ECORE_CALLBACK_PASS_ON; 3766 return ECORE_CALLBACK_PASS_ON;
3790} 3767}
@@ -3875,13 +3852,9 @@ _elm_config_sub_init(void)
3875 ecore_win32_init(); 3852 ecore_win32_init();
3876#endif 3853#endif
3877 char buf[PATH_MAX]; 3854 char buf[PATH_MAX];
3878 size_t len;
3879 int ok = 0; 3855 int ok = 0;
3880 3856
3881 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/"); 3857 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
3882 if (len + 10 >= sizeof(buf)) // the space to add "flush.cfg"
3883 goto end;
3884
3885 ok = ecore_file_mkpath(buf); 3858 ok = ecore_file_mkpath(buf);
3886 if (!ok) 3859 if (!ok)
3887 { 3860 {
@@ -3889,12 +3862,11 @@ _elm_config_sub_init(void)
3889 buf); 3862 buf);
3890 goto end; 3863 goto end;
3891 } 3864 }
3892 3865 _eio_profile_monitor = eio_monitor_add(buf);
3893 strcat(buf, "flush.cfg"); 3866 _monitor_file_created_handler = ecore_event_handler_add
3894 if (!ecore_file_exists(buf)) elm_config_all_flush(); 3867 (EIO_MONITOR_FILE_CREATED, _elm_config_file_monitor_cb, NULL);
3895 3868 _monitor_directory_created_handler = ecore_event_handler_add
3896 _eio_monitor = eio_monitor_add(buf); 3869 (EIO_MONITOR_DIRECTORY_CREATED, _elm_config_file_monitor_cb, NULL);
3897 ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _elm_config_file_monitor_cb, NULL);
3898 3870
3899end: 3871end:
3900 _config_sub_apply(); 3872 _config_sub_apply();
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 7bd39cb92..f8ff69351 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -574,6 +574,8 @@ extern const char SIG_WIDGET_ACCESS_CHANGED[];
574extern const char SIG_LAYOUT_FOCUSED[]; 574extern const char SIG_LAYOUT_FOCUSED[];
575extern const char SIG_LAYOUT_UNFOCUSED[]; 575extern const char SIG_LAYOUT_UNFOCUSED[];
576 576
577extern Eina_Bool _config_profile_lock;
578
577#ifdef HAVE_ELEMENTARY_WL2 579#ifdef HAVE_ELEMENTARY_WL2
578extern Ecore_Wl2_Display *_elm_wl_display; 580extern Ecore_Wl2_Display *_elm_wl_display;
579#endif 581#endif
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 58bae93a1..f75ba93f2 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -1253,6 +1253,7 @@ _elm_win_profile_update(Elm_Win_Data *sd)
1253 _internal_elm_win_profile_set(sd, sd->profile.available_list[0]); 1253 _internal_elm_win_profile_set(sd, sd->profile.available_list[0]);
1254 } 1254 }
1255 1255
1256 _config_profile_lock = EINA_TRUE;
1256 _elm_config_profile_set(sd->profile.name); 1257 _elm_config_profile_set(sd->profile.name);
1257 1258
1258 /* update sub ee */ 1259 /* update sub ee */