summaryrefslogtreecommitdiff
path: root/src/events.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2004-04-18 21:48:42 +0000
committersabetts <sabetts>2004-04-18 21:48:42 +0000
commitc9635a8c9e89c3900a210175f0d3f3cb3723931b (patch)
tree6dc9f91a58cd7df7f3cf0156e92f07b11cfcfd29 /src/events.c
parent996b6ae9e981fbafc10f59427f6a6f9057b2273c (diff)
downloadratpoison-c9635a8c9e89c3900a210175f0d3f3cb3723931b.zip
* src/manage.h (ungrab_keys_all_wins): new prototype
(grab_keys_all_wins): likewise * src/manage.c (grab_top_level_keys): renamed from grab_prefix_key (all callers updated). Grab all keys in the top level keymap. (ungrab_top_level_keys): renamed from ungrab_prefix_key (all callers updated). ungrab all keys in the top level keymap. (ungrab_keys_all_wins): new function (grab_keys_all_wins): likewise * src/globals.c: (rp_key_hook): rename from rp_prefix_hook. Dependant code updated. (set_rp_window_focus): change 'prefix' hook to 'key' hook. * src/events.c (handle_key): handle a top level key press. (handle_key): new arguments ks, and mod. (key_press): pass the keysym and modifier to handle_key * src/conf.h (TOP_KEYMAP): new define * src/actions.c (cmd_v_split, cmd_h_split): swap names. (user_commands): bind split to cmd_v_split. (initialize_default_keybindings): initialize the top level keymap (cmd_definekey): update the keys grabbed when changing a key on the top level keymap. (cmd_escape): update the escape key in the top level map. (cmd_delkmap): don't allow the deletion of the top level keymap.
Diffstat (limited to 'src/events.c')
-rw-r--r--src/events.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/events.c b/src/events.c
index 2498be2..d4520ca 100644
--- a/src/events.c
+++ b/src/events.c
@@ -362,8 +362,17 @@ client_msg (XClientMessageEvent *ev)
}
static void
-handle_key (rp_screen *s)
+handle_key (KeySym ks, unsigned int mod, rp_screen *s)
{
+ rp_action *key_action;
+ rp_keymap *map = find_keymap (TOP_KEYMAP);
+
+ if (map == NULL)
+ {
+ PRINT_ERROR (("Unable to find " TOP_KEYMAP " keymap\n"));
+ return;
+ }
+
PRINT_DEBUG (("handling key...\n"));
/* All functions hide the program bar and the frame indicator. */
@@ -374,12 +383,26 @@ handle_key (rp_screen *s)
alarm (0);
alarm_signalled = 0;
- /* Call the prefix hook. */
- hook_run (&rp_prefix_hook);
+ /* Call the top level key pressed hook. */
+ hook_run (&rp_key_hook);
+
+ PRINT_DEBUG (("handle_key\n"));
/* Read a key and execute the command associated with it on the
- default keymap. */
- cmd_readkey (1, ROOT_KEYMAP);
+ default keymap. Ignore the key if it doesn't have a binding. */
+ if ((key_action = find_keybinding (ks, x11_mask_to_rp_mask (mod), map)))
+ {
+ char *result;
+ result = command (1, key_action->data);
+
+ /* Gobble the result. */
+ if (result)
+ free (result);
+ }
+ else
+ {
+ PRINT_ERROR(("Impossible: No matching key\n"));
+ }
}
static void
@@ -403,21 +426,7 @@ key_press (XEvent *ev)
modifier = ev->xkey.state;
cook_keycode ( &ev->xkey, &ks, &modifier, NULL, 0, 1);
- if (ks == prefix_key.sym && (x11_mask_to_rp_mask (modifier) == prefix_key.state))
- {
- handle_key (s);
- }
- else
- {
- if (current_window())
- {
- ignore_badwindow++;
- ev->xkey.window = current_window()->w;
- XSendEvent (dpy, current_window()->w, False, KeyPressMask, ev);
- XSync (dpy, False);
- ignore_badwindow--;
- }
- }
+ handle_key (ks, modifier, s);
}
/* Read a command off the window and execute it. Some commands return
@@ -630,7 +639,7 @@ focus_change (XFocusChangeEvent *ev)
if (win != NULL)
{
PRINT_DEBUG (("Re-grabbing prefix key\n"));
- grab_prefix_key (win->w);
+ grab_top_level_keys (win->w);
}
}
@@ -642,7 +651,7 @@ mapping_notify (XMappingEvent *ev)
/* Remove the grab on the current prefix key */
list_for_each_entry (cur,&rp_mapped_window,node)
{
- ungrab_prefix_key (cur->w);
+ ungrab_top_level_keys (cur->w);
}
switch (ev->request)
@@ -658,7 +667,7 @@ mapping_notify (XMappingEvent *ev)
/* Add the grab on the current prefix key */
list_for_each_entry (cur, &rp_mapped_window,node)
{
- grab_prefix_key (cur->w);
+ grab_top_level_keys (cur->w);
}
}