summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2000-11-27 10:07:47 +0000
committersabetts <sabetts>2000-11-27 10:07:47 +0000
commit4d5c1a6c9a9aef8e3386d2a643e7ce4f9e44f201 (patch)
treebf0fd6de6018b6efc901e08ca5eaefe5d7e55233
parent87283e809fe6377b7991c98a09de72247b71936d (diff)
downloadratpoison-4d5c1a6c9a9aef8e3386d2a643e7ce4f9e44f201.zip
fixed some problems with modifiers for key events
-rw-r--r--NEWS4
-rw-r--r--src/ChangeLog11
-rw-r--r--src/actions.c23
-rw-r--r--src/actions.h2
-rw-r--r--src/data.h2
-rw-r--r--src/events.c69
6 files changed, 75 insertions, 36 deletions
diff --git a/NEWS b/NEWS
index c18a2ea..dee72fa 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ ratpoison NEWS --- history of user-visible changes. -*- outline -*-
These command line options allow the restarting and killing of a
running ratpoison process.
+** Mouse jumps to the bottom of the screen on keypresses
+This is pretty annoying if you're using anything other than keyboard
+apps. It is disabled by default.
+
* Changes Since 0.0.3
** Added --enable-debug
This turns on debugging messages
diff --git a/src/ChangeLog b/src/ChangeLog
index 0c0441c..1ad09f5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2000-11-27 shawn <sabetts@diggin.lamenet.tmp>
+
+ * events.c (handle_key): Code to generate the prefix event has
+ been moved to generate_prefix().
+
+ * actions.h (toggle_bar): added prefixes for generate_prefix, and
+ abort_keypress.
+
+ * actions.c (generate_prefix): added.
+ (abort_keypress): added.
+
2000-11-04 Ryan Yeske <rcyeske@vcn.bc.ca>
* Makefile.am (ratpoison_SOURCES): added getopt.c, getopt1.c and
diff --git a/src/actions.c b/src/actions.c
index e9e0867..09e5bd2 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -7,7 +7,8 @@
#include "ratpoison.h"
/* Initialization of the key structure */
-rp_action key_actions[] = { {'c', -1, "xterm", spawn},
+rp_action key_actions[] = { {KEY_PREFIX, 0, 0, generate_prefix},
+ {'c', -1, "xterm", spawn},
{'e', -1, "emacs", spawn},
{'p', -1, 0, prev_window},
{'n', -1, 0, next_window},
@@ -18,6 +19,7 @@ rp_action key_actions[] = { {'c', -1, "xterm", spawn},
{'k', 0, 0, delete_window},
{'\'', -1, 0, goto_win_by_name},
{'a', -1, 0, rename_current_window},
+ {'g', ControlMask, 0, abort_keypress},
{'0', -1, 0, goto_window_0},
{'1', -1, 0, goto_window_1},
{'2', -1, 0, goto_window_2},
@@ -256,3 +258,22 @@ toggle_bar (void *data)
if (!hide_bar (s)) show_bar (s);
}
}
+
+
+void
+abort_keypress (void *data)
+{
+}
+
+/* Send the current window the prefix key event */
+void
+generate_prefix (void *data)
+{
+ XEvent ev;
+ ev = *rp_current_event;
+
+ ev.xkey.window = rp_current_window->w;
+ ev.xkey.state = MODIFIER_PREFIX;
+ XSendEvent (dpy, rp_current_window->w, False, KeyPressMask, &ev);
+ XSync (dpy, False);
+}
diff --git a/src/actions.h b/src/actions.h
index 7cfb111..793064d 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -1,6 +1,8 @@
/* actions.h -- prototypes of all actions that can be performed with
keystrokes */
+void generate_prefix (void *data);
+void abort_keypress (void *data);
void goto_window_9 (void *data);
void goto_window_8 (void *data);
void goto_window_7 (void *data);
diff --git a/src/data.h b/src/data.h
index 2769721..da10642 100644
--- a/src/data.h
+++ b/src/data.h
@@ -70,6 +70,8 @@ extern rp_window *rp_current_window;
extern screen_info *screens;
extern int num_screens;
+extern XEvent *rp_current_event;
+
extern Display *dpy;
extern Atom rp_restart;
extern Atom rp_kill;
diff --git a/src/events.c b/src/events.c
index 6030242..313a538 100644
--- a/src/events.c
+++ b/src/events.c
@@ -27,7 +27,9 @@
#include "ratpoison.h"
-extern Display *dpy;
+/* The event currently being processed. Mostly used in functions from
+ action.c which need to forward events to other windows. */
+XEvent *rp_current_event;
void
new_window (XCreateWindowEvent *e)
@@ -241,7 +243,7 @@ handle_key (screen_info *s)
int revert;
Window fwin;
XEvent ev;
- int keysym;
+ int keysym, mod;
PRINT_DEBUG ("handling key.\n");
@@ -255,42 +257,38 @@ handle_key (screen_info *s)
{
XMaskEvent (dpy, KeyPressMask, &ev);
keysym = XLookupKeysym((XKeyEvent *) &ev, 0);
- } 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. */
+ mod = ev.xkey.state;
- XSetInputFocus (dpy, fwin, revert, CurrentTime);
-
- if (keysym == KEY_PREFIX && !ev.xkey.state)
- {
- /* Generate the prefix keystroke for the app */
- ev.xkey.window = fwin;
- ev.xkey.state = MODIFIER_PREFIX;
- XSendEvent (dpy, fwin, False, KeyPressMask, &ev);
- XSync (dpy, False);
- return;
+ for (i = key_actions; i->key != 0; i++)
+ {
+ if (keysym == i->key)
+ if (i->state == -1 || mod == i->state)
+ {
+ (*i->func)(i->data);
+ goto handled_key;
+ }
+ }
}
+ 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. *\/ */
- for (i = key_actions; i->key != 0; i++)
- {
- if (keysym == i->key)
- if (i->state == -1 || ev.xkey.state == i->state)
- {
- (*i->func)(i->data);
- break;
- }
- }
+ XSetInputFocus (dpy, fwin, revert, CurrentTime);
}
void
@@ -443,6 +441,7 @@ handle_events ()
for (;;)
{
XNextEvent (dpy, &ev);
+ rp_current_event = &ev;
delegate_event (&ev);
}
}