summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--TODO11
-rw-r--r--src/data.h5
-rw-r--r--src/events.c2
-rw-r--r--src/input.c117
-rw-r--r--src/input.h3
-rw-r--r--src/manage.c5
7 files changed, 111 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index bbb1d70..ab2c118 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2001-09-06 shawn <sabetts@diggin.lamenet.tmp>
+
+ * src/manage.c (grab_prefix_key): call grab_key.
+ (ungrab_prefix_key): use AnyModifier as the modifier mask param to
+ XUngrabKey.
+
+ * src/input.h (grab_key): new protoype
+
+ * src/input.c (update_modifier_map): find the numlock and scroll
+ lock modifiers.
+ (grab_key): new function
+ (cook_keycode): new param ignore_mad_mods. protoype updated. all
+ callers updated.
+ (cook_keycode): ignore caps lock, numlock and scroll lock
+ modifiers when ignore_bad_mods param is non-zero.
+
+ * src/events.c (key_press): ignore numlock, scroll lock, and caps
+ lock modifiers when cooking the prefix key.
+
+ * src/data.h (struct modifier_info): new fields num_lock_mask,
+ scroll_lock_mask.
+
2001-09-05 shawn <sabetts@diggin.lamenet.tmp>
* src/main.c (show_welcome_message): If the help key is bound to ?
diff --git a/TODO b/TODO
index b6f5f19..af02035 100644
--- a/TODO
+++ b/TODO
@@ -1,12 +1,6 @@
-*- outline -*-
-* split screen
-shawn
-
* command stuff
-** adding new keybinding should wipe out the old one
-ryan
-
** binding an empty string should wipe out old binding
ryan
@@ -14,11 +8,8 @@ ryan
ryan
* implement these screen commands (see the screen info for documentation):
-echo
command ???
-focus (after we have split screen)
hardcopy (screenshot)
-help
lastmsg
license
lockscreen
@@ -26,7 +17,6 @@ meta
msgwait
msgminwait
nethack
-quit
redisplay
screen (ratpoison)
setenv
@@ -34,6 +24,5 @@ shell
shelltitle
sleep
sorendition
-split
startup_message
stuff ???
diff --git a/src/data.h b/src/data.h
index 7bad7f1..6ed2d44 100644
--- a/src/data.h
+++ b/src/data.h
@@ -172,6 +172,11 @@ struct modifier_info
unsigned int alt_mod_mask;
unsigned int super_mod_mask;
unsigned int hyper_mod_mask;
+
+ /* Keep track of these because they mess up the grab and should be
+ ignored. */
+ unsigned int num_lock_mask;
+ unsigned int scroll_lock_mask;
};
/* Keeps track of which mod mask each modifier is under. */
diff --git a/src/events.c b/src/events.c
index 9fe9c24..98ffa11 100644
--- a/src/events.c
+++ b/src/events.c
@@ -458,7 +458,7 @@ key_press (XEvent *ev)
if (!s) return;
modifier = ev->xkey.state;
- cook_keycode ( &ev->xkey, &ks, &modifier, NULL, 0);
+ cook_keycode ( &ev->xkey, &ks, &modifier, NULL, 0, 1);
if (ks == prefix_key.sym && (modifier == prefix_key.state))
{
diff --git a/src/input.c b/src/input.c
index a0523eb..afb3c71 100644
--- a/src/input.c
+++ b/src/input.c
@@ -37,11 +37,12 @@ update_modifier_map ()
int row, col; /* The row and column in the modifier table. */
XModifierKeymap *mods;
-/* rp_modifier_info.mode_switch_mask = 0; */
rp_modifier_info.meta_mod_mask = 0;
rp_modifier_info.alt_mod_mask = 0;
rp_modifier_info.super_mod_mask = 0;
rp_modifier_info.hyper_mod_mask = 0;
+ rp_modifier_info.num_lock_mask = 0;
+ rp_modifier_info.scroll_lock_mask = 0;
mods = XGetModifierMapping (dpy);
@@ -54,40 +55,45 @@ update_modifier_map ()
switch (XKeycodeToKeysym(dpy, code, 0))
{
- case XK_Meta_L:
- case XK_Meta_R:
- rp_modifier_info.meta_mod_mask |= modmasks[row - 3];
- PRINT_DEBUG ("Found Meta on %d\n",
- rp_modifier_info.meta_mod_mask);
- break;
-
- case XK_Alt_L:
- case XK_Alt_R:
- rp_modifier_info.alt_mod_mask |= modmasks[row - 3];
- PRINT_DEBUG ("Found Alt on %d\n",
- rp_modifier_info.alt_mod_mask);
- break;
-
- case XK_Super_L:
- case XK_Super_R:
- rp_modifier_info.super_mod_mask |= modmasks[row - 3];
- PRINT_DEBUG ("Found Super on %d\n",
- rp_modifier_info.super_mod_mask);
- break;
-
- case XK_Hyper_L:
- case XK_Hyper_R:
- rp_modifier_info.hyper_mod_mask |= modmasks[row - 3];
- PRINT_DEBUG ("Found Hyper on %d\n",
- rp_modifier_info.hyper_mod_mask);
- break;
-
-/* case XK_Mode_switch: */
-/* rp_modifier_info.mode_switch_mask |= modmasks[row - 3]; */
-/* PRINT_DEBUG ("Found Mode_switch on %d\n", */
-/* rp_modifier_info.mode_switch_mask); */
-/* break; */
+ case XK_Meta_L:
+ case XK_Meta_R:
+ rp_modifier_info.meta_mod_mask |= modmasks[row - 3];
+ PRINT_DEBUG ("Found Meta on %d\n",
+ rp_modifier_info.meta_mod_mask);
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ rp_modifier_info.alt_mod_mask |= modmasks[row - 3];
+ PRINT_DEBUG ("Found Alt on %d\n",
+ rp_modifier_info.alt_mod_mask);
+ break;
+
+ case XK_Super_L:
+ case XK_Super_R:
+ rp_modifier_info.super_mod_mask |= modmasks[row - 3];
+ PRINT_DEBUG ("Found Super on %d\n",
+ rp_modifier_info.super_mod_mask);
+ break;
+ case XK_Hyper_L:
+ case XK_Hyper_R:
+ rp_modifier_info.hyper_mod_mask |= modmasks[row - 3];
+ PRINT_DEBUG ("Found Hyper on %d\n",
+ rp_modifier_info.hyper_mod_mask);
+ break;
+
+ case XK_Num_Lock:
+ rp_modifier_info.num_lock_mask |= modmasks[row - 3];
+ PRINT_DEBUG ("Found NumLock on %d\n",
+ rp_modifier_info.num_lock_mask);
+ break;
+
+ case XK_Scroll_Lock:
+ rp_modifier_info.scroll_lock_mask |= modmasks[row - 3];
+ PRINT_DEBUG ("Found ScrollLock on %d\n",
+ rp_modifier_info.scroll_lock_mask);
+ break;
default:
break;
}
@@ -111,6 +117,34 @@ update_modifier_map ()
XFreeModifiermap (mods);
}
+/* Grab the key while ignoring annoying modifier keys including
+ caps lock, num lock, and scroll lock. */
+void
+grab_key (int keycode, unsigned int modifiers, Window grab_window)
+{
+ unsigned int mod_list[8];
+ int i;
+
+ /* Create a list of all possible combinations of ignored
+ modifiers. Assumes there are only 3 ignored modifiers. */
+ mod_list[0] = 0;
+ mod_list[1] = LockMask;
+ mod_list[2] = rp_modifier_info.num_lock_mask;
+ mod_list[3] = mod_list[1] | mod_list[2];
+ mod_list[4] = rp_modifier_info.scroll_lock_mask;
+ mod_list[5] = mod_list[1] | mod_list[4];
+ mod_list[6] = mod_list[2] | mod_list[4];
+ mod_list[7] = mod_list[1] | mod_list[2] | mod_list[4];
+
+ /* Grab every combination of ignored modifiers. */
+ for (i=0; i<8; i++)
+ {
+ XGrabKey(dpy, keycode, modifiers | mod_list[i],
+ grab_window, True, GrabModeAsync, GrabModeAsync);
+ }
+}
+
+
/* Return the name of the keysym. caller must free returned pointer */
char *
keysym_to_string (KeySym keysym, unsigned int modifier)
@@ -143,11 +177,18 @@ keysym_to_string (KeySym keysym, unsigned int modifier)
interested in the keysym name pass in NULL for keysym_name and 0
for len. */
int
-cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char *keysym_name, int len)
+cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char *keysym_name, int len, int ignore_bad_mods)
{
-int nbytes;
+ int nbytes;
+
+ if (ignore_bad_mods)
+ {
+ ev->state &= ~(LockMask
+ | rp_modifier_info.num_lock_mask
+ | rp_modifier_info.scroll_lock_mask);
+ }
- nbytes = XLookupString (ev, keysym_name, len, keysym, NULL);
+ nbytes = XLookupString (ev, keysym_name, len, keysym, NULL);
*mod = ev->state;
*mod &= (rp_modifier_info.meta_mod_mask
@@ -234,7 +275,7 @@ read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len)
{
XMaskEvent (dpy, KeyPressMask, &ev);
*modifiers = ev.xkey.state;
- nbytes = cook_keycode (&ev.xkey, keysym, modifiers, keysym_name, len);
+ nbytes = cook_keycode (&ev.xkey, keysym, modifiers, keysym_name, len, 0);
} while (IsModifierKey (*keysym));
return nbytes;
diff --git a/src/input.h b/src/input.h
index 4a74ac3..44f009d 100644
--- a/src/input.h
+++ b/src/input.h
@@ -23,10 +23,11 @@
#define _RATPOISON_INPUT_H 1
char *keysym_to_string (KeySym keysym, unsigned int modifier);
-int cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char *keysym_name, int len);
+int cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char *keysym_name, int len, int ignore_bad_mods);
char *get_input (char *prompt);
char *get_more_input (char *prompt, char *preinput);
int read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len);
void update_modifier_map ();
+void grab_key (int keycode, unsigned int modifiers, Window grab_window);
#endif /* ! _RATPOISON_INPUT_H */
diff --git a/src/manage.c b/src/manage.c
index 6f2357d..47e5574 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -48,8 +48,7 @@ grab_prefix_key (Window w)
XGrabKey(dpy, AnyKey, AnyModifier, w, True,
GrabModeAsync, GrabModeAsync);
#else
- XGrabKey(dpy, XKeysymToKeycode (dpy, prefix_key.sym ), prefix_key.state,
- w, True, GrabModeAsync, GrabModeAsync);
+ grab_key (XKeysymToKeycode (dpy, prefix_key.sym), prefix_key.state, w);
#endif
}
@@ -58,7 +57,7 @@ ungrab_prefix_key (Window w)
{
#ifdef HIDE_MOUSE
#else
- XUngrabKey(dpy, XKeysymToKeycode (dpy, prefix_key.sym ), prefix_key.state, w);
+ XUngrabKey(dpy, XKeysymToKeycode (dpy, prefix_key.sym), AnyModifier, w);
#endif
}