summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ratpoison.18
-rw-r--r--src/actions.c54
-rw-r--r--src/actions.h3
3 files changed, 65 insertions, 0 deletions
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1
index d2abf49..ef2acc9 100644
--- a/doc/ratpoison.1
+++ b/doc/ratpoison.1
@@ -225,6 +225,10 @@ Add \fIalias\fP as new way to call \fIcommand\fP.
alias for "\fBdefinekey root\fP \fIkey\fP \fIcommand\fP"
.cmd banish ( C\-t b )
Banish the rat cursor to the lower right corner of the screen.
+.cmd banishrel
+Banish the rat cursor to the lower right corner of the curren window.
+If there isn't a window in the current frame, it banishes the rat cursor
+to the lower right corner of the screen.
.cmd chdir [ directory ]
If the optional argument is given, change the current directory
of ratpoison to \fIdirectory\fP.
@@ -469,6 +473,10 @@ Replace the X selection with the text \fIx\-selection\fP. It can be
inserted into the current window with \fBgetsel\fP.
.cmd quit
Quit ratpoison.
+.cmd ratinfo
+Display the x y coordinates of the rat cursor relative to the screen.
+.cmd ratrelinfo
+Display the x y coordinates of the rat cursor relative to the window.
.cmd ratwarp x y
Move the rat cursor to the position (\fIx\fP,\fIy\fP).
.cmd ratrelwarp deltax deltay
diff --git a/src/actions.c b/src/actions.c
index 731e343..7e587b7 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -303,6 +303,9 @@ init_user_commands(void)
add_command ("prev", cmd_prev, 0, 0, 0);
add_command ("prevscreen", cmd_prevscreen, 0, 0, 0);
add_command ("quit", cmd_quit, 0, 0, 0);
+ add_command ("ratinfo", cmd_ratinfo, 0, 0, 0);
+ add_command ("ratrelinfo", cmd_ratrelinfo, 0, 0, 0);
+ add_command ("banishrel", cmd_banishrel, 0, 0, 0);
add_command ("ratwarp", cmd_ratwarp, 2, 2, 2,
"X: ", arg_NUMBER,
"Y: ", arg_NUMBER);
@@ -3101,6 +3104,57 @@ cmd_banish (int interactive, struct cmdarg **args)
}
cmdret *
+cmd_banishrel (int interactive, struct cmdarg **args)
+{
+ rp_screen *s;
+ rp_window *w;
+
+ s = current_screen();
+ w = current_window();
+ if (!w)
+ cmd_banish (interactive, args);
+
+ XWarpPointer (dpy, None, w->w, 0, 0, 0, 0, w->x + w->width - 2, w->y + w->height - 2);
+ return cmdret_new (RET_SUCCESS, NULL);
+}
+
+cmdret *
+cmd_ratinfo (int interactive, struct cmdarg **args)
+{
+ rp_screen *s;
+ Window root_win, child_win;
+ int mouse_x, mouse_y, root_x, root_y;
+ unsigned int mask;
+
+ s = current_screen();
+ XQueryPointer (dpy, s->root, &root_win, &child_win, &mouse_x, &mouse_y, &root_x, &root_y, &mask);
+ marked_message_printf (0, 0, "%d %d", mouse_x, mouse_y );
+
+ return cmdret_new (RET_SUCCESS, NULL);
+}
+
+cmdret *
+cmd_ratrelinfo (int interactive, struct cmdarg **args)
+{
+ rp_screen *s;
+ rp_window *rpw;
+ Window root_win, child_win;
+ int mouse_x, mouse_y, root_x, root_y;
+ unsigned int mask;
+
+ s = current_screen();
+ rpw = current_window();
+
+ if (!rpw)
+ return cmd_ratinfo (interactive, args);
+
+ XQueryPointer (dpy, rpw->w, &root_win, &child_win, &mouse_x, &mouse_y, &root_x, &root_y, &mask);
+ marked_message_printf (0, 0, "%d %d", root_x, root_y );
+
+ return cmdret_new (RET_SUCCESS, NULL);
+}
+
+cmdret *
cmd_ratwarp (int interactive, struct cmdarg **args)
{
rp_screen *s;
diff --git a/src/actions.h b/src/actions.h
index 3fcd3b7..5db4a56 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -105,6 +105,7 @@ RP_CMD (abort);
RP_CMD (addhook);
RP_CMD (alias);
RP_CMD (banish);
+RP_CMD (banishrel);
RP_CMD (bind);
RP_CMD (compat);
RP_CMD (chdir);
@@ -196,6 +197,8 @@ RP_CMD (undefinekey);
RP_CMD (set);
RP_CMD (sselect);
RP_CMD (ratwarp);
+RP_CMD (ratinfo);
+RP_CMD (ratrelinfo);
RP_CMD (ratclick);
RP_CMD (ratrelwarp);
RP_CMD (rathold);