diff --git a/WINGs/userdefaults.c b/WINGs/userdefaults.c index 465d6bf9..479a30ee 100644 --- a/WINGs/userdefaults.c +++ b/WINGs/userdefaults.c @@ -45,7 +45,6 @@ extern char *WMGetApplicationName(); #define DEFAULTS_DIR "/Defaults" -#define UD_SYNC_INTERVAL 2000 @@ -135,17 +134,6 @@ synchronizeUserDefaults(void *foo) } -static void -addSynchronizeTimerHandler(void) -{ - static Bool initialized = False; - - if (!initialized) { - WMAddPersistentTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults, - NULL); - initialized = True; - } -} void @@ -335,7 +323,6 @@ WMGetStandardUserDefaults(void) defaults->next = sharedUserDefaults; sharedUserDefaults = defaults; - addSynchronizeTimerHandler(); registerSaveOnExit(); return defaults; @@ -412,7 +399,6 @@ WMGetDefaultsFromPath(char *path) defaults->next = sharedUserDefaults; sharedUserDefaults = defaults; - addSynchronizeTimerHandler(); registerSaveOnExit(); return defaults; diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 342e244e..3e2035be 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -483,7 +483,6 @@ typedef struct WPreferences { unsigned int noautolaunch:1; /* don't autolaunch apps */ unsigned int norestore:1; /* don't restore session */ unsigned int create_stdcmap:1; /* create std colormap */ - unsigned int nopolling:1; /* don't poll for defaults changes */ unsigned int restarting:2; } flags; /* internal flags */ } WPreferences; diff --git a/src/defaults.c b/src/defaults.c index 0ceecacd..c07ad37b 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1348,8 +1348,6 @@ wDefaultsCheckDomains(void *foo) } #endif /* !LITE */ - if (!foo) - WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, foo); } diff --git a/src/event.c b/src/event.c index 85046d49..a4f614f4 100644 --- a/src/event.c +++ b/src/event.c @@ -319,10 +319,22 @@ void EventLoop() { XEvent event; + extern volatile int filesChanged; + extern void wDefaultsCheckDomains(); for(;;) { WMNextEvent(dpy, &event); WMHandleEvent(&event); + + /* + * If dnotify detects changes in configuration + * files we have to read them again. + */ + if (filesChanged){ + fprintf(stdout,"wmaker: reading config files in defaults database.\n"); + wDefaultsCheckDomains(NULL); + filesChanged = 0; + } } } diff --git a/src/main.c b/src/main.c index de630907..d54a6315 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,10 @@ * USA. */ +#define _GNU_SOURCE /* needed to get the defines in glibc 2.2 */ +#include /* this has the needed values defined */ +#include + #include "wconfig.h" #include @@ -62,6 +66,7 @@ Display *dpy; char *ProgName; unsigned int ValidModMask = 0xff; +volatile int filesChanged; /* locale to use. NULL==POSIX or C */ char *Locale=NULL; @@ -451,7 +456,6 @@ print_help() puts(_(" --create-stdcmap create the standard colormap hint in PseudoColor visuals")); puts(_(" --visual-id visualid visual id of visual to use")); puts(_(" --static do not update or save configurations")); - puts(_(" --no-polling do not periodically check for configuration updates")); #ifdef DEBUG puts(_(" --synchronous turn on synchronous display mode")); #endif @@ -490,10 +494,34 @@ check_defaults() } +/* + * This is the handler used to notify if configuration + * files have changed, using linux kernel'l dnotify + * mechanism (from Documentation/dnotify.txt) + */ +void handler(int sig, siginfo_t *si, void *data) +{ + filesChanged = si->si_fd; +} + static void execInitScript() { - char *file, *paths; + char *file, *path, *paths; + struct sigaction act; + volatile int fd; + + path = wstrconcat(wusergnusteppath(), "/Defaults"); + + act.sa_sigaction = handler; + sigemptyset(&act.sa_mask); + act.sa_flags = SA_SIGINFO; + sigaction(SIGRTMIN + 1, &act, NULL); + + fd = open(path, O_RDONLY); + fcntl(fd, F_SETSIG, SIGRTMIN + 1); + fcntl(fd, F_NOTIFY, DN_MODIFY|DN_MULTISHOT); + wfree(path); paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker"); paths = wstrappend(paths, ":"DEF_CONFIG_PATHS); @@ -746,10 +774,6 @@ real_main(int argc, char **argv) || strcmp(argv[i], "--static")==0) { wPreferences.flags.noupdates = 1; - } else if (strcmp(argv[i], "-nopolling")==0 - || strcmp(argv[i], "--no-polling")==0) { - - wPreferences.flags.nopolling = 1; #ifdef XSMP_ENABLED } else if (strcmp(argv[i], "-clientid")==0 || strcmp(argv[i], "-restore")==0) { diff --git a/src/startup.c b/src/startup.c index 8d3f5212..12d001de 100644 --- a/src/startup.c +++ b/src/startup.c @@ -695,8 +695,6 @@ StartUp(Bool defaultScreenOnly) XFreePixmap(dpy, cur); } - /* signal handler stuff that gets called when a signal is caught */ - WMAddPersistentTimerHandler(500, delayedAction, NULL); /* emergency exit... */ sig_action.sa_handler = handleSig; @@ -886,10 +884,6 @@ StartUp(Bool defaultScreenOnly) Exit(1); } - if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates) { - /* setup defaults file polling */ - WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL); - } } diff --git a/src/wconfig.h.in b/src/wconfig.h.in index 2d10d469..d299e51e 100644 --- a/src/wconfig.h.in +++ b/src/wconfig.h.in @@ -457,8 +457,6 @@ #define MAX_WINDOWLIST_WIDTH 160 /* max width of window title in * window list */ -#define DEFAULTS_CHECK_INTERVAL 2000 /* how often wmaker will check for - * changes in the config files */ /* if your keyboard don't have arrow keys */ #undef ARROWLESS_KBD