summaryrefslogtreecommitdiff
path: root/src/events.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2000-12-09 11:34:43 +0000
committersabetts <sabetts>2000-12-09 11:34:43 +0000
commit1a8458cd5a3252f9d2141de13ef67a30b215476c (patch)
tree4d4b0b7c70c141f83c66c2adff651cb5b8c9d49e /src/events.c
parent7ee9190d0849e8df707611b63b42e976bbd8d827 (diff)
downloadratpoison-1a8458cd5a3252f9d2141de13ef67a30b215476c.zip
* input.c (cook_keycode): properly handle LockMask
* input.h: added prototype for keysym_to_string * input.c (keysym_to_string): added * bar.c (show_bar): update_window_names(s) is called whether the bar is raised or not. * conf.h: Added BAR_Y_PADDING BAR_X_PADDING * list.c (goto_window_name): return success or failure * list.h: updated prototype for goto_window_name * events.c (handle_key): Added a message indicating an unbound key. * bar.c (display_msg_in_bar): added (update_window_names): uses BAR_X_PADDING instead of `5' (update_window_names): Updated BAR_PADDING to BAR_Y_PADDING * input.c (cook_keycode): mod is now an usigned int (read_key): Ignores modifier keys. Now returns keysym and modifiers. (get_input): Updated BAR_PADDING to BAR_Y_PADDING and BAR_X_PADDING. * events.c (handle_key): uses read_key instead of XMaskEvent to read a key. * actions.c (goto_window_number): window list is displayed on failure. (bye): added (switch_to): added (execute_command): no longer seg faults when no windows exist.
Diffstat (limited to 'src/events.c')
-rw-r--r--src/events.c82
1 files changed, 35 insertions, 47 deletions
diff --git a/src/events.c b/src/events.c
index bf9c78b..d859965 100644
--- a/src/events.c
+++ b/src/events.c
@@ -239,59 +239,49 @@ client_msg (XClientMessageEvent *ev)
static void
handle_key (screen_info *s)
{
+ char *keysym_name;
+ char msg[100];
const rp_action *i;
- int revert;
- Window fwin;
- XEvent ev;
- KeySym keysym;
- int mod;
+ int revert;
+ Window fwin; /* Window currently in focus */
+ KeySym keysym; /* Key pressed */
+ unsigned int mod; /* Modifiers */
- PRINT_DEBUG ("handling key.\n");
+ PRINT_DEBUG ("handling key...\n");
- /* All functions hide the program bar. */
+ /* All functions hide the program bar. Unless the bar doesn't time
+ out. */
if (BAR_TIMEOUT > 0) hide_bar (s);
XGetInputFocus (dpy, &fwin, &revert);
XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime);
- do
- {
- XMaskEvent (dpy, KeyPressMask, &ev);
- mod = ev.xkey.state;
-
- cook_keycode (ev.xkey.keycode, &keysym, &mod);
+ read_key (&keysym, &mod);
- for (i = key_actions; i->key != 0; i++)
+ for (i = key_actions; i->key != 0; i++)
+ {
+ if (keysym == i->key)
{
- if (keysym == i->key)
- if (i->state == -1 || mod == i->state)
- {
- /* Revert focus back to the current window before
- executing the command. */
- XSetInputFocus (dpy, fwin, revert, CurrentTime);
- (*i->func)(i->data);
- goto handled_key;
- }
+ if (i->state == -1 || mod == i->state)
+ {
+ /* Revert focus back to the current window before
+ executing the command. */
+ XSetInputFocus (dpy, fwin, revert, CurrentTime);
+ (*i->func)(i->data);
+ return;
+ }
}
}
- while (1);
-
- handled_key:
-
-/* } while (keysym == XK_Shift_L */
-/* || keysym == XK_Shift_R */
-/* || keysym == XK_Control_L */
-/* || keysym == XK_Control_R */
-/* || keysym == XK_Caps_Lock */
-/* || keysym == XK_Shift_Lock */
-/* || keysym == XK_Meta_L */
-/* || keysym == XK_Meta_R */
-/* || keysym == XK_Alt_L */
-/* || keysym == XK_Alt_R */
-/* || keysym == XK_Super_L */
-/* || keysym == XK_Super_R */
-/* || keysym == XK_Hyper_L */
-/* || keysym == XK_Hyper_R); /\* ignore modifier keypresses. *\/ */
+
+ keysym_name = keysym_to_string (keysym, mod);
+ snprintf (msg, 100, "%s unbound key!", keysym_name);
+ free (keysym_name);
+
+ PRINT_DEBUG ("%s\n", msg)
+
+ /* No key match, notify user. */
+ XSetInputFocus (dpy, fwin, revert, CurrentTime);
+ display_msg_in_bar (s, msg);
}
void
@@ -404,14 +394,12 @@ delegate_event (XEvent *ev)
case KeyPress:
PRINT_DEBUG ("KeyPress %d %d\n", ev->xkey.keycode, ev->xkey.state);
- {
- KeySym thesym;
- char buf[512];
- XLookupString (&ev->xkey, buf, 512, &thesym, NULL);
- PRINT_DEBUG ("key string: '%s' %ld\n", buf, thesym);
- }
key_press (ev);
break;
+
+ case KeyRelease:
+ PRINT_DEBUG ("KeyRelease %d %d\n", ev->xkey.keycode, ev->xkey.state);
+ break;
case UnmapNotify:
PRINT_DEBUG ("UnmapNotify\n");