diff --git a/src/Makefile.am b/src/Makefile.am index 76fc18f9..8f1afbfa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -90,7 +90,6 @@ wmaker_SOURCES = \ xinerama.h \ xinerama.c \ xmodifier.h \ - xmodifier.c \ xutil.c \ xutil.h \ wconfig.h \ @@ -125,9 +124,11 @@ wmaker_SOURCES += osdep_stub.c endif if USE_NESTED_FUNC -wmaker_SOURCES += misc.c +wmaker_SOURCES += misc.c \ + xmodifier.c else -nodist_wmaker_SOURCES = misc.hack_nf.c +nodist_wmaker_SOURCES = misc.hack_nf.c \ + xmodifier.hack_nf.c CLEANFILES = $(nodist_wmaker_SOURCES) @@ -135,6 +136,11 @@ misc.hack_nf.c: misc.c $(top_srcdir)/script/nested-func-to-macro.sh $(AM_V_GEN)$(top_srcdir)/script/nested-func-to-macro.sh \ $(srcdir)/misc.c -o $(builddir)/misc.hack_nf.c \ -f "append_string" -f "append_modifier" + +xmodifier.hack_nf.c: xmodifier.c $(top_srcdir)/script/nested-func-to-macro.sh + $(AM_V_GEN)$(top_srcdir)/script/nested-func-to-macro.sh \ + $(srcdir)/xmodifier.c -o $(builddir)/xmodifier.hack_nf.c \ + -f "modwarn" -f "modbarf" -f "check_modifier" endif diff --git a/src/xmodifier.c b/src/xmodifier.c index 641a8e35..bc525736 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -120,51 +120,61 @@ static void x_reset_modifier_mapping(Display * display) int mode_bit = 0; XModifierKeymap *x_modifier_keymap = XGetModifierMapping(display); -#define modwarn(name,old,other) \ - wwarning ("%s (0x%x) generates %s, which is generated by %s.", \ - name, code, index_to_name (old), other) - -#define modbarf(name,other) \ - wwarning ("%s (0x%x) generates %s, which is nonsensical.", \ - name, code, other) - -#define check_modifier(name,mask) \ - if ((1<max_keypermod; for (modifier_index = 0; modifier_index < 8; modifier_index++) for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { KeySym last_sym = 0; + for (column = 0; column < 4; column += 2) { - KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm - + modifier_key]; - KeySym sym = (code ? XkbKeycodeToKeysym(display, code, 0, column) : 0); + KeyCode code; + KeySym sym; + + inline void modwarn(const char *key_name, int old_mod, const char *other_key) + { + wwarning("key %s (0x%x) generates %s, which is generated by %s", + key_name, code, index_to_name(old_mod), other_key); + } + + inline void modbarf(const char *key_name, const char *other_mod) + { + wwarning("key %s (0x%x) generates %s, which is nonsensical", + key_name, code, other_mod); + } + + inline void check_modifier(const char *key_name, int mask) + { + if ((1 << modifier_index) != mask) + modbarf(key_name, index_to_name(modifier_index)); + } + + code = x_modifier_keymap->modifiermap[modifier_index * mkpm + modifier_key]; + sym = (code ? XkbKeycodeToKeysym(display, code, 0, column) : NoSymbol); + if (sym == last_sym) continue; last_sym = sym; + switch (sym) { case XK_Mode_switch: store_modifier("Mode_switch", mode_bit); @@ -220,10 +230,6 @@ static void x_reset_modifier_mapping(Display * display) } } } -#undef store_modifier -#undef check_modifier -#undef modwarn -#undef modbarf /* If there was no Meta key, then try using the Alt key instead. If there is both a Meta key and an Alt key, then the Alt key @@ -238,7 +244,8 @@ static void x_reset_modifier_mapping(Display * display) not interpret it as Mode_switch; and interpreting it as both would be totally wrong. */ if (mode_bit) { - const char *warn = 0; + const char *warn = NULL; + if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0; else if (mode_bit == hyper_bit)