summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--keys.c35
-rw-r--r--options.c15
-rw-r--r--xbindkeys.c47
4 files changed, 61 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 10987b0..113f1fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-23 Philippe Brochard <hocwp@free.fr>
+
+ * xbindkeys.c (event_loop): Stat both default rc file and guile rc
+ file for reloading them when they change.
+
xbindkeys changelog by Philippe Brochard <hocwp@free.fr>
diff --git a/keys.c b/keys.c
index 79900e7..a150ed5 100644
--- a/keys.c
+++ b/keys.c
@@ -276,10 +276,17 @@ set_keysym (Keys_t * key, EventType_t event_type, KeySym keysym,
}
key->function = function;
+
+ // printf("******************* ICICICICICI *********************\n");
+ //#ifdef GUILE_FLAG
+ // printf(" name=%d\n", SCM_IMP (key->function));
+ //#endif
+
+ // scm_permanent_object (key->function);
}
void
-set_keycode (Keys_t * key, EventType_t event_type, KeyCode keycode,
+set_keycode (Keys_t * key, EventType_t event_type, KeyCode keycode,
unsigned int modifier, char *command, SCM function)
{
key->type = CODE;
@@ -290,7 +297,7 @@ set_keycode (Keys_t * key, EventType_t event_type, KeyCode keycode,
if (command != NULL)
{
key->command = (char *) malloc ((strlen (command) + 1) * sizeof (char));
-
+
if (key->command != NULL)
strncpy (key->command, command, strlen (command) + 1);
}
@@ -298,24 +305,24 @@ set_keycode (Keys_t * key, EventType_t event_type, KeyCode keycode,
{
key->command = NULL;
}
-
+
key->function = function;
}
void
-set_button (Keys_t * key, EventType_t event_type, unsigned int button,
+set_button (Keys_t * key, EventType_t event_type, unsigned int button,
unsigned int modifier, char *command, SCM function)
{
key->type = BUTTON;
key->event_type = event_type;
key->key.button = button;
key->modifier = modifier;
-
+
if (command != NULL)
{
key->command = (char *) malloc ((strlen (command) + 1) * sizeof (char));
-
+
if (key->command != NULL)
strncpy (key->command, command, strlen (command) + 1);
}
@@ -323,7 +330,7 @@ set_button (Keys_t * key, EventType_t event_type, unsigned int button,
{
key->command = NULL;
}
-
+
key->function = function;
}
@@ -358,7 +365,7 @@ remove_key (KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keyco
{
return (-1);
}
-
+
modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask);
for (i = 0; i < nb_keys; i++)
@@ -376,7 +383,7 @@ remove_key (KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keyco
{
if (verbose)
printf ("Removing key index %d\n", found_index);
-
+
/* make new array keys_bis */
keys_bis = (Keys_t *) malloc ((nb_keys - 1) * sizeof (Keys_t));
if (keys_bis == NULL)
@@ -384,7 +391,7 @@ remove_key (KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keyco
for (i = 0; i < found_index; i++)
keys_bis[i] = keys[i];
-
+
for (i = found_index + 1; i < nb_keys; i++)
keys_bis[i - 1] = keys[i];
@@ -410,11 +417,11 @@ void
run_command (char *command)
{
pid_t pid;
-
-#ifdef FORK_FLAG
+
+#ifdef FORK_FLAG
if (verbose)
printf ("Start program with fork+exec call\n");
-
+
// if (fork() == 0)
// execlp ("sh", "sh", "-c", key->command, NULL);
if (!(pid = fork()))
@@ -433,7 +440,7 @@ run_command (char *command)
#else
if (verbose)
printf ("Start program with system call\n");
-
+
system (command);
#endif
}
diff --git a/options.c b/options.c
index 61b3186..87ba9ad 100644
--- a/options.c
+++ b/options.c
@@ -15,6 +15,7 @@
* *
***************************************************************************/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -24,10 +25,10 @@
#include "xbindkeys.h"
#include "keys.h"
#include "grab_key.h"
+
#ifdef GUILE_FLAG
#include <libguile.h>
#endif
-#include "config.h"
char *display_name = NULL;
@@ -1017,6 +1018,8 @@ SCM xbindkey_wrapper(SCM key, SCM cmd)
}
+SCM tab_scm[2];
+
SCM xbindkey_function_wrapper (SCM key, SCM fun)
{
KeyType_t type = SYM;
@@ -1032,12 +1035,20 @@ SCM xbindkey_function_wrapper (SCM key, SCM fun)
return SCM_BOOL_F;
}
+ tab_scm[0] = fun;
+
if (add_key (type, event_type, keysym, keycode,
- button, modifier, NULL, fun) != 0)
+ button, modifier, NULL, tab_scm[0]) != 0)
{
printf("add_key didn't return 0!!!\n");
return SCM_BOOL_F;
}
+ else {
+ printf ("add_key ok!!! fun=%d\n", gh_procedure_p (fun));
+ }
+
+ //scm_permanent_object (tab_scm[0]);
+ scm_remember_upto_here_1 (tab_scm[0]);
return SCM_UNSPECIFIED;
}
diff --git a/xbindkeys.c b/xbindkeys.c
index d88b34e..0178718 100644
--- a/xbindkeys.c
+++ b/xbindkeys.c
@@ -51,9 +51,8 @@ static void start_as_daemon (void);
Display *current_display; // The current display
-#ifndef GUILE_FLAG
extern char rc_file[512];
-#else
+#ifdef GUILE_FLAG
extern char rc_guile_file[512];
#endif
@@ -232,54 +231,52 @@ event_loop (Display * d)
XEvent e;
int i;
struct stat rc_file_info;
-#ifndef GUILE_FLAG
time_t rc_file_changed;
-#else
+#ifdef GUILE_FLAG
time_t rc_guile_file_changed;
+ struct stat rc_guile_file_info;
#endif
-
XSetErrorHandler ((XErrorHandler) null_X_error);
-#ifndef GUILE_FLAG
stat(rc_file, &rc_file_info);
rc_file_changed = rc_file_info.st_mtime;
-#else
- stat (rc_guile_file, &rc_file_info);
- rc_guile_file_changed = rc_file_info.st_mtime;
+#ifdef GUILE_FLAG
+ stat (rc_guile_file, &rc_guile_file_info);
+ rc_guile_file_changed = rc_guile_file_info.st_mtime;
#endif
+
while (True)
{
while(!XPending(d))
{
-#ifndef GUILE_FLAG
+
// if the rc file has been modified, reload it
stat (rc_file, &rc_file_info);
- if (rc_file_info.st_mtime != rc_file_changed)
- {
- reload_rc_file ();
- if (verbose)
- {
- printf ("The rc file has been modified, reload it\n");
- }
- rc_file_changed = rc_file_info.st_mtime;
- }
-#else
+#ifdef GUILE_FLAG
// if the rc guile file has been modified, reload it
- stat (rc_guile_file, &rc_file_info);
- if (rc_file_info.st_mtime != rc_guile_file_changed)
+ stat (rc_guile_file, &rc_guile_file_info);
+#endif
+
+ if (rc_file_info.st_mtime != rc_file_changed
+#ifdef GUILE_FLAG
+ || rc_guile_file_info.st_mtime != rc_guile_file_changed
+#endif
+ )
{
reload_rc_file ();
if (verbose)
{
- printf ("The rc guile file has been modified, reload it\n");
+ printf ("The configuration file has been modified, reload it\n");
}
- rc_guile_file_changed = rc_file_info.st_mtime;
- }
+ rc_file_changed = rc_file_info.st_mtime;
+#ifdef GUILE_FLAG
+ rc_guile_file_changed = rc_guile_file_info.st_mtime;
#endif
+ }
usleep(SLEEP_TIME*1000);
}