1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

wmaker: Moved variables for Inotify into the global namespace

This commit is contained in:
Christophe CURIS
2013-10-10 20:38:26 +02:00
committed by Carlos R. Mafra
parent 6dcfdd072b
commit a79c0e76d0
4 changed files with 29 additions and 23 deletions

View File

@@ -522,6 +522,13 @@ extern struct wmaker_global_variables {
struct WMenu *drawer_menu; /* menu for the drawers */
} dock;
#ifdef HAVE_INOTIFY
struct {
int fd_event_queue; /* Inotify's queue file descriptor */
int wd_defaults; /* Watch Descriptor for the 'Defaults' configuration file */
} inotify;
#endif
/* definition for X Atoms */
struct {

View File

@@ -358,13 +358,11 @@ noreturn void EventLoop(void)
{
XEvent event;
#ifdef HAVE_INOTIFY
extern int inotifyFD;
extern int inotifyWD;
struct timeval time;
fd_set rfds;
int retVal = 0;
if (inotifyFD < 0 || inotifyWD < 0)
if (w_global.inotify.fd_event_queue < 0 || w_global.inotify.wd_defaults < 0)
retVal = -1;
#endif
@@ -377,20 +375,21 @@ noreturn void EventLoop(void)
time.tv_sec = 0;
time.tv_usec = 0;
FD_ZERO(&rfds);
FD_SET(inotifyFD, &rfds);
FD_SET(w_global.inotify.fd_event_queue, &rfds);
/* check for available read data from inotify - don't block! */
retVal = select(inotifyFD + 1, &rfds, NULL, NULL, &time);
retVal = select(w_global.inotify.fd_event_queue + 1, &rfds, NULL, NULL, &time);
if (retVal < 0) { /* an error has occured */
wwarning(_("select failed. The inotify instance will be closed."
" Changes to the defaults database will require"
" a restart to take effect."));
close(inotifyFD);
close(w_global.inotify.fd_event_queue);
w_global.inotify.fd_event_queue = -1;
continue;
}
if (FD_ISSET(inotifyFD, &rfds))
handle_inotify_events(inotifyFD, inotifyWD);
if (FD_ISSET(w_global.inotify.fd_event_queue, &rfds))
handle_inotify_events(w_global.inotify.fd_event_queue, w_global.inotify.wd_defaults);
}
#endif
}

View File

@@ -74,11 +74,6 @@ char *ProgName;
unsigned int ValidModMask = 0xff;
#ifdef HAVE_INOTIFY
int inotifyFD;
int inotifyWD;
#endif
struct WPreferences wPreferences;
WShortKey wKeyBindings[WKBD_LAST];
@@ -474,8 +469,9 @@ static void check_defaults(void)
static void inotifyWatchConfig(void)
{
char *watchPath = NULL;
inotifyFD = inotify_init(); /* Initialise an inotify instance */
if (inotifyFD < 0) {
w_global.inotify.fd_event_queue = inotify_init(); /* Initialise an inotify instance */
if (w_global.inotify.fd_event_queue < 0) {
wwarning(_("could not initialise an inotify instance."
" Changes to the defaults database will require"
" a restart to take effect. Check your kernel!"));
@@ -485,12 +481,13 @@ static void inotifyWatchConfig(void)
* but we might want more in the future so check all events for now.
* The individual events are checked for in event.c.
*/
inotifyWD = inotify_add_watch(inotifyFD, watchPath, IN_ALL_EVENTS);
if (inotifyWD < 0) {
w_global.inotify.wd_defaults = inotify_add_watch(w_global.inotify.fd_event_queue, watchPath, IN_ALL_EVENTS);
if (w_global.inotify.wd_defaults < 0) {
wwarning(_("could not add an inotify watch on path %s."
"Changes to the defaults database will require"
" a restart to take effect."), watchPath);
close(inotifyFD);
close(w_global.inotify.fd_event_queue);
w_global.inotify.fd_event_queue = -1;
}
}
wfree(watchPath);

View File

@@ -54,9 +54,6 @@ static void wipeDesktop(WScreen * scr);
void Shutdown(WShutdownMode mode)
{
int i;
#ifdef HAVE_INOTIFY
extern int inotifyFD;
#endif
switch (mode) {
case WSLogoutMode:
@@ -65,7 +62,10 @@ void Shutdown(WShutdownMode mode)
/* if there is no session manager, send SAVE_YOURSELF to
* the clients */
#ifdef HAVE_INOTIFY
close(inotifyFD);
if (w_global.inotify.fd_event_queue >= 0) {
close(w_global.inotify.fd_event_queue);
w_global.inotify.fd_event_queue = -1;
}
#endif
for (i = 0; i < w_global.screen_count; i++) {
WScreen *scr;
@@ -92,7 +92,10 @@ void Shutdown(WShutdownMode mode)
WScreen *scr;
#ifdef HAVE_INOTIFY
close(inotifyFD);
if (w_global.inotify.fd_event_queue >= 0) {
close(w_global.inotify.fd_event_queue);
w_global.inotify.fd_event_queue = -1;
}
#endif
scr = wScreenWithNumber(i);
if (scr) {