summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--NEWS2
-rw-r--r--configure.in3
-rwxr-xr-xcontrib/genrpbindings54
-rw-r--r--doc/ratpoison.texi14
-rw-r--r--src/actions.c71
-rw-r--r--src/actions.h3
7 files changed, 152 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index a745445..285882b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-11-11 Shawn Betts <katia_dilkina@verizon.net>
+
+ * src/actions.c (cmd_ratclick): new function
+ (cmd_ratrelwarp): likewise
+ (cmd_ratwarp): likewise
+ (user_commands): new commands ratclick, ratrelwarp, ratwarp.
+
+ * contrib/genrpbindings: add common lisp bindings
+
2004-11-03 Shawn Betts <sabetts@vcn.bc.ca>
* src/input.c (get_more_input): call history_reset
diff --git a/NEWS b/NEWS
index bd10519..cabf64a 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ sselect lets you jump to an X11 screen by number.
** configure script warns about missing history lib
Rather than error out, now, ratpoison will just be built without history.
+** new commands ratwarp, ratrelwarp, and ratclick
+
* Changes since 1.3.0-rc2-beta2
** new format option %f
This options displays the frame number the window is in or a space if
diff --git a/configure.in b/configure.in
index 291f5d3..5bc3ffa 100644
--- a/configure.in
+++ b/configure.in
@@ -17,7 +17,7 @@ dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
-dnl $Id: configure.in,v 1.46 2004/10/05 16:45:24 sabetts Exp $
+dnl $Id: configure.in,v 1.47 2004/11/12 01:55:04 sabetts Exp $
AC_INIT(src/main.c)
AM_INIT_AUTOMAKE(ratpoison, 1.3.1-CVS)
@@ -94,6 +94,7 @@ AC_CHECK_HEADERS([X11/extensions/Xinerama.h], [], [], [
])
AC_CHECK_LIB(Xext, XMissingExtension, [LIBS="-lXext $LIBS"],, $CFLAGS $LDFLAGS)
AC_CHECK_LIB(Xinerama, XineramaQueryScreens, [LIBS="-lXinerama $LIBS"],, $CFLAGS $LDFLAGS)
+AC_CHECK_LIB(Xtst, XTestFakeButtonEvent, [LIBS="-lXtst $LIBS"],, $CFLAGS $LDFLAGS)
dnl Check for electric fence library
diff --git a/contrib/genrpbindings b/contrib/genrpbindings
index e1d8a0b..224a84c 100755
--- a/contrib/genrpbindings
+++ b/contrib/genrpbindings
@@ -27,11 +27,14 @@
# require "ratpoison"
# Ratpoison.echo ("hello world")
#
+# ;;; Common Lisp
+# (load "ratpoison.lisp")
+# (ratpoison:rp-echo "hello world")
$\="\n";
# set this to your rp binary
-$RATPOISON="/usr/local/bin/ratpoison";
+$RATPOISON="/home/sabetts/src/ratpoison/src/ratpoison";
# open source file
$ACTIONS_C="../src/actions.c";
@@ -41,9 +44,11 @@ open ACTIONS_C or die "Can't open $ACTIONS_C";
$PERL_FILE="./Ratpoison.pm";
$ELISP_FILE="./ratpoison-cmd.el";
$RUBY_FILE="./ratpoison.rb";
+$COMMONLISP_FILE="./ratpoison.lisp";
open PERL, ">$PERL_FILE" or die "Can't create $PERL_FILE";
open ELISP, ">$ELISP_FILE" or die "Can't create $ELISP_FILE";
open RUBY, ">$RUBY_FILE" or die "Can't create $RUBY_FILE";
+open COMMONLISP, ">$COMMONLISP_FILE" or die "Can't create $COMMONLISP_FILE";
# PERL preamble
print PERL 'package Ratpoison;';
@@ -55,8 +60,8 @@ print ELISP '(defvar ratpoison-program "',$RATPOISON,'")';
print ELISP <<PREAMBLE;
(defmacro defun-ratpoison (cmd)
- `(defun ,(intern (concat "ratpoison-" (symbol-name cmd))) (&rest args)
- (apply 'ratpoison-cmd ,(symbol-name cmd) args)))
+ `(progn (defun ,(intern (concat "ratpoison-" (symbol-name cmd))) (&rest args)
+ (apply 'ratpoison-cmd ,(symbol-name cmd) args)))
(defun ratpoison-cmd (cmd &rest args)
(with-temp-buffer
@@ -85,6 +90,46 @@ module Ratpoison
module_function :command
PREAMBLE
+# Scheme preamble
+
+print COMMONLISP <<PREAMBLE;
+(defpackage :ratpoison
+ (:use :cl))
+
+;; Needs the CLOCC PORT package
+(asdf:operate 'asdf:load-op :port)
+
+(in-package :ratpoison)
+
+(defvar ratpoison-program "/home/sabetts/src/ratpoison/src/ratpoison")
+
+(defmacro defun-ratpoison (cmd)
+ (let ((sym (intern (concatenate 'string "RP-" (symbol-name cmd)))))
+ `(progn (defun ,sym (&rest args)
+ (apply 'ratpoison-cmd ,(string-downcase (symbol-name cmd)) args))
+ (export ',sym))))
+
+(defun ratpoison-cmd (cmd &rest args)
+ (labels ((mapconcat (fn list sep)
+ (apply 'concatenate 'string
+ (loop for x on list
+ collect (if (cdr x)
+ (concatenate 'string (funcall fn (car x)) sep)
+ (funcall fn (car x))))))
+ (build-cmd (cmd args)
+ (mapconcat (lambda (x)
+ (if (stringp x)
+ x
+ (prin1-to-string x)))
+ (nconc (list cmd) args) " ")))
+ (let ((stream (port:pipe-input ratpoison-program
+ "-c" (build-cmd cmd args))))
+ (do ((line (read-line stream nil nil)
+ (read-line stream nil nil))
+ (accum nil (cons line accum)))
+ ((null line) accum)))))
+PREAMBLE
+
# bindings
while (<ACTIONS_C>) {
if (m!/\*\@begin !) {
@@ -95,6 +140,7 @@ while (<ACTIONS_C>) {
$nbindings++;
print PERL "sub $1 { return command (\"$1\", \@_); }";
print ELISP "(defun-ratpoison $1)";
+ print COMMONLISP "(defun-ratpoison $1)";
print RUBY " def $1 (*args)";
print RUBY " return command (\"$1\", args)";
print RUBY " end";
@@ -120,3 +166,5 @@ close ELISP;
print "Created $ELISP_FILE";
close RUBY;
print "Created $RUBY_FILE";
+close COMMONLISP;
+print "Created $COMMONLISP_FILE";
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index 8a6e89e..7433e99 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -1310,6 +1310,20 @@ Send a @kbd{C-t} to the current window.
Quit ratpoison.
@end deffn
+@deffn Command ratrelwarp @var{x} @var{y}
+Warp the rat to the specified location relative to the current rat
+position.
+@end deffn
+
+@deffn Command ratwarp @var{x} @var{y}
+Warp the rat to the specified absolute location.
+@end deffn
+
+@deffn Command ratclick @var{button}
+click the rat. @var{button} is either 1, 2, or 3. @var{button}
+defaults to button 1.
+@end deffn
+
@deffn Command redisplay
Redisplay the current window. This is often used to fix xterms that
didn't catch ratpoison's initial maximize event.
diff --git a/src/actions.c b/src/actions.c
index 6040d96..8f4ea6f 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <X11/keysym.h>
+#include <X11/extensions/XTest.h>
#include <string.h>
#include <strings.h>
#include <time.h>
@@ -88,6 +89,9 @@ static user_command user_commands[] =
{"prev", cmd_prev, arg_VOID},
{"prevscreen", cmd_prevscreen, arg_VOID},
{"quit", cmd_quit, arg_VOID},
+ {"ratwarp", cmd_ratwarp, arg_VOID},
+ {"ratrelwarp", cmd_ratrelwarp, arg_VOID},
+ {"ratclick", cmd_ratclick, arg_VOID},
{"readkey", cmd_readkey, arg_STRING},
{"redisplay", cmd_redisplay, arg_VOID},
{"remhook", cmd_remhook, arg_STRING},
@@ -1879,6 +1883,73 @@ cmd_banish (int interactive, char *data)
}
char *
+cmd_ratwarp (int interactive, char *data)
+{
+ rp_screen *s;
+ int x, y;
+
+ s = current_screen ();
+
+ if (data == NULL)
+ {
+ message("ratwarp: 2 arguments required");
+ return NULL;
+ }
+
+ if (sscanf(data, "%d %d", &x, &y) < 2 || x < 0 || y < 0)
+ {
+ message("ratwarp: Invalid arguments");
+ return NULL;
+ }
+
+ XWarpPointer (dpy, None, s->root, 0, 0, 0, 0, x, y);
+ return NULL;
+}
+
+char *
+cmd_ratrelwarp (int interactive, char *data)
+{
+ rp_screen *s;
+ int x, y;
+
+ s = current_screen ();
+
+ if (data == NULL)
+ {
+ message("ratrelwarp: 2 arguments required");
+ return NULL;
+ }
+
+ if (sscanf(data, "%d %d", &x, &y) < 2)
+ {
+ message("ratrelwarp: Invalid arguments");
+ return NULL;
+ }
+
+ XWarpPointer (dpy, None, None, 0, 0, 0, 0, x, y);
+ return NULL;
+}
+
+char *
+cmd_ratclick (int interactive, char *data)
+{
+ int button = 1;
+
+ if (data != NULL)
+ {
+ if (sscanf (data, "%d", &button) < 1 || button < 1 || button > 3)
+ {
+ message("ratclick: invalid argument");
+ }
+ }
+
+ XTestFakeButtonEvent(dpy, button, True, CurrentTime);
+ XTestFakeButtonEvent(dpy, button, False, CurrentTime);
+ return NULL;
+}
+
+
+char *
cmd_curframe (int interactive, char *data)
{
show_frame_indicator();
diff --git a/src/actions.h b/src/actions.h
index 62e5df5..b55a5d3 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -125,6 +125,9 @@ char *cmd_delkmap (int interactive, char *data);
char *cmd_definekey (int interactive, char *data);
char *cmd_set (int interactive, char *data);
char *cmd_sselect(int interactive, char *data);
+char *cmd_ratwarp (int interactive, char *data);
+char *cmd_ratclick (int interactive, char *data);
+char * cmd_ratrelwarp (int interactive, char *data);
rp_keymap *find_keymap (char *name);
void initialize_default_keybindings (void);