diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data.h | 5 | ||||
-rw-r--r-- | src/events.c | 34 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/manage.c | 6 |
4 files changed, 46 insertions, 3 deletions
@@ -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; @@ -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); |