summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2000-10-20 17:39:03 +0000
committersabetts <sabetts>2000-10-20 17:39:03 +0000
commitc32146268b261c8b2296427f476c4c1aa9e17bc7 (patch)
tree7334c8d0e0827b069209e457ccf461f08e25f128 /src
parente4d6a91e68beae9112624c6d1320b8c7c1119917 (diff)
downloadratpoison-c32146268b261c8b2296427f476c4c1aa9e17bc7.zip
added initial support for hiding the rat on key events
Diffstat (limited to 'src')
-rw-r--r--src/data.h5
-rw-r--r--src/events.c34
-rw-r--r--src/main.c4
-rw-r--r--src/manage.c6
4 files changed, 46 insertions, 3 deletions
diff --git a/src/data.h b/src/data.h
index 214a8c0..2769721 100644
--- a/src/data.h
+++ b/src/data.h
@@ -81,6 +81,11 @@ extern Atom wm_delete;
extern Atom wm_take_focus;
extern Atom wm_colormaps;
+/* mouse properties */
+extern int rat_x;
+extern int rat_y;
+extern int rat_visible;
+
/* When unmapping or deleting windows, it is sometimes helpful to
ignore a bad window when attempting to clean the window up. This
does just that when set to 1 */
diff --git a/src/events.c b/src/events.c
index 2c75b41..99788b9 100644
--- a/src/events.c
+++ b/src/events.c
@@ -302,10 +302,27 @@ key_press (XEvent *ev)
s = find_screen (ev->xkey.root);
- if (s && ks == KEY_PREFIX && (modifier & MODIFIER_PREFIX))
+ if (rat_visible)
+ {
+ XWarpPointer (dpy, None, s->root, 0, 0, 0, 0, s->root_attr.width, s->root_attr.height);
+/* rat_visible = 0; */
+ }
+
+ if (!s) return;
+
+ if (ks == KEY_PREFIX && (modifier & MODIFIER_PREFIX))
{
handle_key (s);
}
+ else
+ {
+ if (rp_current_window)
+ {
+ ev->xkey.window = rp_current_window->w;
+ XSendEvent (dpy, rp_current_window->w, False, KeyPressMask, ev);
+ XSync (dpy, False);
+ }
+ }
}
void
@@ -330,6 +347,19 @@ property_notify (XEvent *ev)
}
}
+void
+rat_motion (XMotionEvent *ev)
+{
+ if (!rat_visible)
+ {
+ XWarpPointer (dpy, None, ev->root, 0, 0, 0, 0, rat_x, rat_y);
+ /* rat_visible = 1; */
+ }
+
+ rat_x = ev->x_root;
+ rat_y = ev->y_root;
+}
+
/* Given an event, call the correct function to handle it. */
void
delegate_event (XEvent *ev)
@@ -398,7 +428,9 @@ delegate_event (XEvent *ev)
case MotionNotify:
PRINT_DEBUG ("MotionNotify\n");
+ rat_motion (&ev->xmotion);
break;
+
case Expose:
PRINT_DEBUG ("Expose\n");
break;
diff --git a/src/main.c b/src/main.c
index 8ac4bd5..8d057f2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,10 @@
static void init_screen (screen_info *s, int screen_num);
+int rat_x;
+int rat_y;
+int rat_visible = 1; /* rat is visible by default */
+
Atom wm_state;
Atom wm_change_state;
Atom wm_protocols;
diff --git a/src/manage.c b/src/manage.c
index d40fb07..3e72f5f 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -42,8 +42,10 @@ extern Atom wm_state;
static void
grab_prefix_key (Window w)
{
- XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_PREFIX ), MODIFIER_PREFIX, w, True,
+ XGrabKey(dpy, AnyKey, AnyModifier, w, True,
GrabModeAsync, GrabModeAsync);
+/* XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_PREFIX ), MODIFIER_PREFIX, w, True, */
+/* GrabModeAsync, GrabModeAsync); */
}
char *
@@ -121,7 +123,7 @@ manage (rp_window *win, screen_info *s)
PADDING_TOP,
s->root_attr.width - PADDING_LEFT - PADDING_RIGHT,
s->root_attr.height - PADDING_TOP - PADDING_BOTTOM);
- XSelectInput (dpy, win->w, PropertyChangeMask);
+ XSelectInput (dpy, win->w, PropertyChangeMask | PointerMotionMask);
XAddToSaveSet(dpy, win->w);
grab_prefix_key (win->w);