mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +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:
36
src/main.c
36
src/main.c
@@ -19,6 +19,10 @@
|
||||
* 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 <stdio.h>
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user