From 4f187c8e8252056974a9fb85cf2959fe9f96c501 Mon Sep 17 00:00:00 2001 From: Chris Parker Date: Sat, 23 Jan 2010 00:48:25 +0000 Subject: [PATCH] Revision 0.2 --- Makefile.in | 17 +-- README | 60 ++++++++++- configure.ac | 39 ++++--- install-sh | 296 +--------------------------------------------------- src/Makefile.in | 15 +-- src/xaut_display.c | 4 +- src/xaut_display.h | 2 +- src/xaut_keyboard.h | 2 +- 8 files changed, 109 insertions(+), 326 deletions(-) rewrite install-sh (99%) diff --git a/Makefile.in b/Makefile.in index f1fd2c8..9209e1a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,7 +5,6 @@ # $Date$ # $Rev$ - basedir = @srcdir@ srcdir = $(basedir)/src VPATH = @srcdir@ @@ -13,6 +12,7 @@ package = @PACKAGE_NAME@ version = @PACKAGE_VERSION@ tarname = $(package) distdir = $(tarname)-$(version) +LOCAL_PYTHON_VERSION = @LOCAL_PYTHON_VERSION@ #DO NOT add "$(MAKE) -C src $@" to this target! $(package): build link copy @@ -42,6 +42,12 @@ copy: build link clean_lib -mkdir -p python/build/lib cp python/$(package)/$(package).py python/build/lib cp python/$(package)/_$(package)* python/build/lib + @echo + @echo "********************************************************************************" + @echo xaut is ready for use. Copy ./python/xaut/xaut.py and ./python/xaut/_xautpy.so + @echo to the same directory as your script. + @echo "********************************************************************************" + @echo dist: $(distdir).tar.gz @@ -69,8 +75,8 @@ $(distdir): cp COPYRIGHT $(distdir) cp Makefile.in $(distdir) cp README $(distdir) - cp install-sh $(distdir) cp config.h.in $(distdir) + cp install.sh $(distdir) cp $(srcdir)/config.h $(distdir)/src cp $(srcdir)/main.c $(distdir)/src cp $(srcdir)/Makefile.in $(distdir)/src @@ -83,7 +89,6 @@ $(distdir): cp $(srcdir)/xaut_mouse.c $(distdir)/src cp $(srcdir)/xaut_mouse.h $(distdir)/src cp $(srcdir)/xautpy.i $(distdir)/src - cp $(srcdir)/xautpy_wrap.c $(distdir)/src cp $(srcdir)/xaut_types.h $(distdir)/src cp $(srcdir)/xaut_window.c $(distdir)/src cp $(srcdir)/xaut_window.h $(distdir)/src @@ -101,7 +106,7 @@ $(distdir): cp $(basedir)/docs/html/xaut.css $(distdir)/docs/html FORCE: - -rm $(distdir).tar.gz &> /dev/null - -rm -rf $(distdir) &> /dev/null + -rm $(distdir).tar.gz + -rm -rf $(distdir) -.PHONY: $(package) dist FORCE clean \ No newline at end of file +.PHONY: $(package) dist FORCE clean diff --git a/README b/README index 2c1cabc..91285d4 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ $Author$ $Date$ $Rev$ -=== PREAMBLE +=== Preamble === This software is intended to help users of XWindows automate basic windowing tasks. For example you can open, move, and close windows based on title, you can move the mouse, or send keystrokes. @@ -12,3 +12,61 @@ I provide this software free of charge without warranty of any type. I provide this in the hopes that it will be useful. In the event you break this software, you are entitled to a full refund of the amount I charged. :) + +=== My Rationale === +There are a few X11 control libraries out there. My basic problem with +most of them are that they are all called from the bash prompt. This is fine, +but it makes it difficult to do things like track window state. At each call +to the program, window information is gathered again, and the request is +processed. + + +=== What you'll need to compile this === +Note that Ubuntu (along with some other distributions of Linux) do not come +with a development environment installed. You'll need to install a development +environment if you do not already have one. + +Ubuntu (and similar): + -- build-essential + +Programs: + -- swig + +Libraries: + -- x11proto-xext-dev + -- libx11-dev + -- libxtst-dev + +Specifically if you are using Ubuntu and wish to compile this software, you can +use the following command: + +$ sudo aptitude install build-essential swig x11proto-xext-dev libx11-dev \ + libxtst-dev + + +=== If you want to modify the build === + -- autoconf + -- automake + -- libtool + +=== What you'll need to run this === +This software was originally written against Python 2.6. It's likely that +there are few (if any) things which will prevent this code from running in +Python 3.x. However, I do not have Python 3.x installed, and cannot test it. + +To run this software - like say for example you compile it on one machine, and +then transport the binary to another machine - make sure you have the following +libraries installed: + -- libx11-dev + -- libxtst-dev + +=== Installing this software === +I highly recommend that you do not install this software. It is simply beyond +my resources to test this software in a wide variety of environments, and it's +likely that automated update tools and the like will cause problems on your +computer if you ignore this advice. Note that there is a "make install" build +target, which is installed for completeness sake, but I suggest you ignore it. + +All you need to do to use this software is make sure that xaut.py and +_xautpy.so are in the same directory as your script. + diff --git a/configure.ac b/configure.ac index 0df6f5a..a2b9f28 100644 --- a/configure.ac +++ b/configure.ac @@ -1,34 +1,43 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -# $URL$ -# $Author$ -# $Date$ -# $Rev$ - -AC_PREREQ(2.61) -AC_INIT([xaut], [0.1.1], [chrsprkr3@gmail.com]) -AC_CONFIG_SRCDIR([src/main.c]) -AC_CONFIG_HEADER([config.h]) +AC_PREREQ([2.64]) +AC_INIT([xaut], [0.2.0], [chrsprkr3@gmail.com]) +AC_CONFIG_SRCDIR([config.h.in]) +AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL # Checks for libraries. -# FIXME: Replace `main' with a function in `-lX11': -AC_CHECK_LIB([X11], [main]) -# FIXME: Replace `main' with a function in `-lXtst': -AC_CHECK_LIB([Xtst], [main]) +AC_CHECK_LIB([X11], [XOpenDisplay], [], [AC_MSG_ERROR([X11 development libraries not found. Exiting.])]) +AC_CHECK_LIB([Xtst], [XTestFakeButtonEvent], [], [AC_MSG_ERROR([X11 test libraries not found. Exiting.])]) + +#Selects the current python version - the pattern should be obvious +AC_CHECK_LIB([python2.5], [Py_Main], [LOCAL_PYTHON_VERSION="2.5"]) +AC_CHECK_LIB([python2.6], [Py_Main], [LOCAL_PYTHON_VERSION="2.6"]) + +if test "x$LOCAL_PYTHON_VERSION" = "x"; then + echo Python library not found. Exiting. + exit -1 +else + echo Using python$LOCAL_PYTHON_VERSION + AC_SUBST(LOCAL_PYTHON_VERSION) +fi + +AC_CHECK_PROG([swig_prog], [swig], [swig], []) +if test "x$swig_prog" = "x"; then + echo swig not found. Exiting. + exit -1 +fi # Checks for header files. AC_PATH_X -AC_HEADER_STDC AC_CHECK_HEADERS([float.h limits.h stdlib.h string.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL -AC_C_CONST AC_TYPE_SIZE_T # Checks for library functions. diff --git a/install-sh b/install-sh dissimilarity index 99% index 6ce63b9..133408c 100755 --- a/install-sh +++ b/install-sh @@ -1,294 +1,2 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd=$cpprog - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd=$stripprog - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "$0: no input file specified" >&2 - exit 1 -else - : -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d "$dst" ]; then - instcmd=: - chmodcmd="" - else - instcmd=$mkdirprog - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f "$src" ] || [ -d "$src" ] - then - : - else - echo "$0: $src does not exist" >&2 - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "$0: no destination specified" >&2 - exit 1 - else - : - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d "$dst" ] - then - dst=$dst/`basename "$src"` - else - : - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' - ' -IFS="${IFS-$defaultIFS}" - -oIFS=$IFS -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS=$oIFS - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp=$pathcomp$1 - shift - - if [ ! -d "$pathcomp" ] ; - then - $mkdirprog "$pathcomp" - else - : - fi - - pathcomp=$pathcomp/ -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd "$dst" && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename "$dst"` - else - dstfile=`basename "$dst" $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename "$dst"` - else - : - fi - -# Make a couple of temp file names in the proper directory. - - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - -# Trap to clean up temp files at exit. - - trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 - trap '(exit $?); exit' 1 2 13 15 - -# Move or copy the file name to the temp name - - $doit $instcmd "$src" "$dsttmp" && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && - -# Now remove or move aside any old file at destination location. We try this -# two ways since rm can't unlink itself on some systems and the destination -# file might be busy for other reasons. In this case, the final cleanup -# might fail but the new file should still install successfully. - -{ - if [ -f "$dstdir/$dstfile" ] - then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || - $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || - { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 - (exit 1); exit - } - else - : - fi -} && - -# Now rename the file to the real destination. - - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" - -fi && - -# The final little trick to "correctly" pass the exit status to the exit trap. - -{ - (exit 0); exit -} +#!/bin/sh +echo DO NOT USE THIS SCRIPT! Read README before proceeding. \ No newline at end of file diff --git a/src/Makefile.in b/src/Makefile.in index d07c833..dd4e9fb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -5,18 +5,19 @@ # $Date$ # $Rev$ - -srcdir = @srcdir@ -VPATH = @srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ package = @PACKAGE_NAME@ version = @PACKAGE_VERSION@ -CC = gcc +CC = @CC@ CFLAGS = -Wall LIBFLAGS = -c DBGFLAGS = -g +LOCAL_PYTHON_VERSION = @LOCAL_PYTHON_VERSION@ + #User should not be here, but I don't want this to fail user_error: @@ -29,17 +30,19 @@ cleanup: #Compile the source code - DO NOT COMPILE "main.c" - that is a separate test executable build: + swig -python xautpy.i + rm xautpy.py $(CC) $(CFLAGS) $(LIBFLAGS) \ $(srcdir)/xaut.c $(srcdir)/xaut_display.c $(srcdir)/xaut_keyboard.c \ $(srcdir)/xaut_mouse.c $(srcdir)/xaut_window.c $(srcdir)/xautpy_wrap.c \ - -I/usr/include/python2.6/ -I/usr/include/X11/ \ + -I/usr/include/python$(LOCAL_PYTHON_VERSION)/ -I/usr/include/X11/ \ -DHAVE_CONFIG_H -DEN_US -DLESS_THAN_FIX build_test: $(CC) $(CFLAGS) $(DBGFLAGS) \ $(srcdir)/xaut.c $(srcdir)/xaut_display.c $(srcdir)/xaut_keyboard.c \ $(srcdir)/xaut_mouse.c $(srcdir)/xaut_window.c $(srcdir)/main.c \ - -I/usr/include/python2.6/ -I/usr/include/X11/ \ + -I/usr/include/python$(LOCAL_PYTHON_VERSION)/ -I/usr/include/X11/ \ -lX11 -lXtst \ -DHAVE_CONFIG_H -DEN_US -DLESS_THAN_FIX \ -o $(package)_test diff --git a/src/xaut_display.c b/src/xaut_display.c index 630585b..cbf4784 100644 --- a/src/xaut_display.c +++ b/src/xaut_display.c @@ -17,8 +17,8 @@ $Date$ $Rev$ */ -#import "xaut_display.h" -#import "xaut_window.h" +#include "xaut_display.h" +#include "xaut_window.h" int display_h() { if (!_check_init()) { diff --git a/src/xaut_display.h b/src/xaut_display.h index 8d5161b..980c9f7 100644 --- a/src/xaut_display.h +++ b/src/xaut_display.h @@ -20,7 +20,7 @@ $Rev$ #ifndef XAUT_DISPLAY_H_ #define XAUT_DISPLAY_H_ -#import "xaut.h" +#include "xaut.h" /** * Returns the height of the screen in pixels. diff --git a/src/xaut_keyboard.h b/src/xaut_keyboard.h index 5019e01..d8c5d30 100644 --- a/src/xaut_keyboard.h +++ b/src/xaut_keyboard.h @@ -20,7 +20,7 @@ $Rev$ #ifndef XAUT_KEYBOARD_H_ #define XAUT_KEYBOARD_H_ -#import "xaut.h" +#include "xaut.h" /** * How long the keyboard key stays down when "clicked" in milliseconds. -- 2.11.4.GIT