mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
wmaker: Reduce wakeups to zero
This patch removes wmaker from PowerTop's shame list, where it appeared with ~3-4 wakeups/second. It adds the linux kernel's dnotify mechanism (adapted from the example in Documentation/dnotify.txt in the kernel source), to detect when a configuration file in ~/GNUStep/Defaults has changed to load it again on-the-fly. For me it usually means that modifications to ~/GNUStep/Defaults/WMRootMenu via the 'genmenu' script are automatically detected and loaded. The use of dnotify makes the ancient behaviour of polling unecessary and cuts down the wakeups count. Other 'apparently' useless timers are also deleted and it's been almost one year now that I use this patched exclusively without problems, so I am pretty sure that it doesn't hurt to remove them. The end result of all this is that wmaker generates 0 (zero) wakeups when idle in a Linux system. Signed-off-by: Carlos R. Mafra <crmafra@ift.unesp.br>
This commit is contained in:
@@ -45,7 +45,6 @@ extern char *WMGetApplicationName();
|
|||||||
|
|
||||||
#define DEFAULTS_DIR "/Defaults"
|
#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
|
void
|
||||||
@@ -335,7 +323,6 @@ WMGetStandardUserDefaults(void)
|
|||||||
defaults->next = sharedUserDefaults;
|
defaults->next = sharedUserDefaults;
|
||||||
sharedUserDefaults = defaults;
|
sharedUserDefaults = defaults;
|
||||||
|
|
||||||
addSynchronizeTimerHandler();
|
|
||||||
registerSaveOnExit();
|
registerSaveOnExit();
|
||||||
|
|
||||||
return defaults;
|
return defaults;
|
||||||
@@ -412,7 +399,6 @@ WMGetDefaultsFromPath(char *path)
|
|||||||
defaults->next = sharedUserDefaults;
|
defaults->next = sharedUserDefaults;
|
||||||
sharedUserDefaults = defaults;
|
sharedUserDefaults = defaults;
|
||||||
|
|
||||||
addSynchronizeTimerHandler();
|
|
||||||
registerSaveOnExit();
|
registerSaveOnExit();
|
||||||
|
|
||||||
return defaults;
|
return defaults;
|
||||||
|
|||||||
@@ -483,7 +483,6 @@ typedef struct WPreferences {
|
|||||||
unsigned int noautolaunch:1; /* don't autolaunch apps */
|
unsigned int noautolaunch:1; /* don't autolaunch apps */
|
||||||
unsigned int norestore:1; /* don't restore session */
|
unsigned int norestore:1; /* don't restore session */
|
||||||
unsigned int create_stdcmap:1; /* create std colormap */
|
unsigned int create_stdcmap:1; /* create std colormap */
|
||||||
unsigned int nopolling:1; /* don't poll for defaults changes */
|
|
||||||
unsigned int restarting:2;
|
unsigned int restarting:2;
|
||||||
} flags; /* internal flags */
|
} flags; /* internal flags */
|
||||||
} WPreferences;
|
} WPreferences;
|
||||||
|
|||||||
@@ -1348,8 +1348,6 @@ wDefaultsCheckDomains(void *foo)
|
|||||||
}
|
}
|
||||||
#endif /* !LITE */
|
#endif /* !LITE */
|
||||||
|
|
||||||
if (!foo)
|
|
||||||
WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, foo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
12
src/event.c
12
src/event.c
@@ -319,10 +319,22 @@ void
|
|||||||
EventLoop()
|
EventLoop()
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
extern volatile int filesChanged;
|
||||||
|
extern void wDefaultsCheckDomains();
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
WMNextEvent(dpy, &event);
|
WMNextEvent(dpy, &event);
|
||||||
WMHandleEvent(&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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
36
src/main.c
36
src/main.c
@@ -19,6 +19,10 @@
|
|||||||
* USA.
|
* USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE /* needed to get the defines in glibc 2.2 */
|
||||||
|
#include <fcntl.h> /* this has the needed values defined */
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "wconfig.h"
|
#include "wconfig.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -62,6 +66,7 @@ Display *dpy;
|
|||||||
char *ProgName;
|
char *ProgName;
|
||||||
|
|
||||||
unsigned int ValidModMask = 0xff;
|
unsigned int ValidModMask = 0xff;
|
||||||
|
volatile int filesChanged;
|
||||||
|
|
||||||
/* locale to use. NULL==POSIX or C */
|
/* locale to use. NULL==POSIX or C */
|
||||||
char *Locale=NULL;
|
char *Locale=NULL;
|
||||||
@@ -451,7 +456,6 @@ print_help()
|
|||||||
puts(_(" --create-stdcmap create the standard colormap hint in PseudoColor visuals"));
|
puts(_(" --create-stdcmap create the standard colormap hint in PseudoColor visuals"));
|
||||||
puts(_(" --visual-id visualid visual id of visual to use"));
|
puts(_(" --visual-id visualid visual id of visual to use"));
|
||||||
puts(_(" --static do not update or save configurations"));
|
puts(_(" --static do not update or save configurations"));
|
||||||
puts(_(" --no-polling do not periodically check for configuration updates"));
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
puts(_(" --synchronous turn on synchronous display mode"));
|
puts(_(" --synchronous turn on synchronous display mode"));
|
||||||
#endif
|
#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
|
static void
|
||||||
execInitScript()
|
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 = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
|
||||||
paths = wstrappend(paths, ":"DEF_CONFIG_PATHS);
|
paths = wstrappend(paths, ":"DEF_CONFIG_PATHS);
|
||||||
@@ -746,10 +774,6 @@ real_main(int argc, char **argv)
|
|||||||
|| strcmp(argv[i], "--static")==0) {
|
|| strcmp(argv[i], "--static")==0) {
|
||||||
|
|
||||||
wPreferences.flags.noupdates = 1;
|
wPreferences.flags.noupdates = 1;
|
||||||
} else if (strcmp(argv[i], "-nopolling")==0
|
|
||||||
|| strcmp(argv[i], "--no-polling")==0) {
|
|
||||||
|
|
||||||
wPreferences.flags.nopolling = 1;
|
|
||||||
#ifdef XSMP_ENABLED
|
#ifdef XSMP_ENABLED
|
||||||
} else if (strcmp(argv[i], "-clientid")==0
|
} else if (strcmp(argv[i], "-clientid")==0
|
||||||
|| strcmp(argv[i], "-restore")==0) {
|
|| strcmp(argv[i], "-restore")==0) {
|
||||||
|
|||||||
@@ -695,8 +695,6 @@ StartUp(Bool defaultScreenOnly)
|
|||||||
XFreePixmap(dpy, cur);
|
XFreePixmap(dpy, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* signal handler stuff that gets called when a signal is caught */
|
|
||||||
WMAddPersistentTimerHandler(500, delayedAction, NULL);
|
|
||||||
|
|
||||||
/* emergency exit... */
|
/* emergency exit... */
|
||||||
sig_action.sa_handler = handleSig;
|
sig_action.sa_handler = handleSig;
|
||||||
@@ -886,10 +884,6 @@ StartUp(Bool defaultScreenOnly)
|
|||||||
Exit(1);
|
Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates) {
|
|
||||||
/* setup defaults file polling */
|
|
||||||
WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -457,8 +457,6 @@
|
|||||||
#define MAX_WINDOWLIST_WIDTH 160 /* max width of window title in
|
#define MAX_WINDOWLIST_WIDTH 160 /* max width of window title in
|
||||||
* window list */
|
* 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 */
|
/* if your keyboard don't have arrow keys */
|
||||||
#undef ARROWLESS_KBD
|
#undef ARROWLESS_KBD
|
||||||
|
|||||||
Reference in New Issue
Block a user