diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-01-30 09:24:54 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-01-30 09:24:54 +0000 |
commit | c4df10eeca45a96ab5afe11aba9018ab4ffc773a (patch) | |
tree | 8dc461c9f5db8ee0b7820f9e13a0421a951e7a41 /Build | |
parent | ee461d9ba36cc6f3b22d7f7015a37bf8da8dfd34 (diff) |
xpdfopen 0.83
git-svn-id: svn://tug.org/texlive/trunk@25236 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/utils/README | 2 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/ChangeLog | 8 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/Makefile.am | 4 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/Makefile.in | 4 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/README | 12 | ||||
-rwxr-xr-x | Build/source/utils/xpdfopen/configure | 20 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/configure.ac | 4 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/configure.ac.orig | 2 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c | 93 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfopen.1 | 15 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfopen.c | 28 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/sendx.c | 25 |
12 files changed, 181 insertions, 36 deletions
diff --git a/Build/source/utils/README b/Build/source/utils/README index b7fd14a49b0..02dfb5cfecd 100644 --- a/Build/source/utils/README +++ b/Build/source/utils/README @@ -33,7 +33,7 @@ vlna 1.5 - checked 25apr11 xindy - see just below -xpdfopen 0.82 - checked 31may11 +xpdfopen 0.83 - checked 30jan12 http://mirror.ctan.org/support/xpdfopen/ http://cs.acadiau.ca/~jdiamond/xpdfopen/ diff --git a/Build/source/utils/xpdfopen/ChangeLog b/Build/source/utils/xpdfopen/ChangeLog index 4f1ffa7c702..127f9e0de4c 100644 --- a/Build/source/utils/xpdfopen/ChangeLog +++ b/Build/source/utils/xpdfopen/ChangeLog @@ -1,3 +1,11 @@ +2012-01-28 Jim Diamond <jim.diamond@acadiau.ca> + * sendx.c: fix (kludgily?) reset_focus() so that it actually works. + * pdfopen.c: add -r and -reset_focus options. + * pdfopen.1: update man page accordingly. + * xpdfopen.tex: update (ConTeXt) document accordingly. + * configure.ac: update for V 0.83. + * README: update for V 0.83. + 2011-05-28 Jim Diamond <jim.diamond@acadiau.ca> * pdfopen.c: add -v and --version options. * pdfopen.1: create man page: thanks to Karl Berry for numerous diff --git a/Build/source/utils/xpdfopen/Makefile.am b/Build/source/utils/xpdfopen/Makefile.am index b71783b2706..96289a5738b 100644 --- a/Build/source/utils/xpdfopen/Makefile.am +++ b/Build/source/utils/xpdfopen/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am for the TeX Live subdirectory utils/xpdfopen/ ## -## Copyright (C) 2009-2011 Peter Breitenlohner <tex-live@tug.org> +## Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org> ## You may freely use, modify and/or distribute this file. ## ACLOCAL_AMFLAGS = -I ../../m4 @@ -31,5 +31,7 @@ uninstall-hook: uninstall-man1-links EXTRA_DIST = xpdfopen.pdf xpdfopen.tex +EXTRA_DIST += pdfopen-AR-7-and-8.c + EXTRA_DIST += Makefile.am.orig configure.ac.orig diff --git a/Build/source/utils/xpdfopen/Makefile.in b/Build/source/utils/xpdfopen/Makefile.in index 1a4d8b5a9dc..0a31675f1c6 100644 --- a/Build/source/utils/xpdfopen/Makefile.in +++ b/Build/source/utils/xpdfopen/Makefile.in @@ -224,8 +224,8 @@ dist_man1_MANS = pdfopen.1 # Symlinks within $(man1dir): FILE:LINK indicates LINK.1->FILE.1 man1_links = pdfopen:pdfclose -EXTRA_DIST = xpdfopen.pdf xpdfopen.tex Makefile.am.orig \ - configure.ac.orig +EXTRA_DIST = xpdfopen.pdf xpdfopen.tex pdfopen-AR-7-and-8.c \ + Makefile.am.orig configure.ac.orig all: all-am .SUFFIXES: diff --git a/Build/source/utils/xpdfopen/README b/Build/source/utils/xpdfopen/README index 03595663786..6d0e35b29ef 100644 --- a/Build/source/utils/xpdfopen/README +++ b/Build/source/utils/xpdfopen/README @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -xpdfopen 0.82 - Send open/close commands to Acrobat Reader, xpdf and evince +xpdfopen 0.83 - Send open/close commands to Acrobat Reader, xpdf and evince --------------------------------------------------------------------------- This is a Linux (X11) implementation of Fabrice Popineau's pdfclose/ @@ -30,13 +30,17 @@ Version 0.81 adds an implementation for evince. Version 0.82 adds a man page and -v/--version options for pdfopen. +Version 0.83 adds the -r/-reset_focus option for pdfopen. + + The AR command lines do not behave precisely the same as under Windows, because the Linux Reader behaves somewhat differently: it is not scriptable, but it is possible to 'fake' key-presses. pdfopen has the following call sequence: - pdfopen [-viewer <ar9|ar9-tab|ar8|ar7|ar5|xpdf|evince>] <pdf file name> + pdfopen [-r|-reset_focus] \ + [-viewer <ar9|ar9-tab|ar8|ar7|ar5|xpdf|evince>] <pdf file name> The 'ar9' version uses the '-openInNewInstance' option, the 'ar9-tab' version does not (so if there is already an AR9 window open, a new tab will be opened in that window). @@ -48,7 +52,7 @@ This program closes an existing AR5, AR7, AR8, AR9, xpdf or evince window displaying the given PDF file. -Version 0.82 compiles on Linux (Slackware64 13.1, anyway) with +Version 0.83 compiles on Linux (Slackware64 13.37, anyway) with the following command: gcc -Wall pdfopen.c sendx.c utils.c -o pdfopen -lX11 -s should you not want to go through the process of creating and running @@ -58,7 +62,7 @@ a configure program. Taco Hoekwater <taco@metatex.org> (Version(s) up to 0.61) Dordrecht, The Netherlands, December 2008. -Jim Diamond <jim.diamond@acadiau.ca> (Version 0.80, 0.81 and 0.82) +Jim Diamond <jim.diamond@acadiau.ca> (Version 0.80, 0.81, 0.82 and 0.83) Acadia University, Wolfville, Nova Scotia, Canada; May 2011. diff --git a/Build/source/utils/xpdfopen/configure b/Build/source/utils/xpdfopen/configure index ce35debaf3e..eaf5814a3b4 100755 --- a/Build/source/utils/xpdfopen/configure +++ b/Build/source/utils/xpdfopen/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for xpdfopen for TeX Live 0.82. +# Generated by GNU Autoconf 2.68 for xpdfopen for TeX Live 0.83. # # Report bugs to <tex-k@tug.org>. # @@ -559,8 +559,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='xpdfopen for TeX Live' PACKAGE_TARNAME='xpdfopen-for-tex-live' -PACKAGE_VERSION='0.82' -PACKAGE_STRING='xpdfopen for TeX Live 0.82' +PACKAGE_VERSION='0.83' +PACKAGE_STRING='xpdfopen for TeX Live 0.83' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1217,7 +1217,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures xpdfopen for TeX Live 0.82 to adapt to many kinds of systems. +\`configure' configures xpdfopen for TeX Live 0.83 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1288,7 +1288,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xpdfopen for TeX Live 0.82:";; + short | recursive ) echo "Configuration of xpdfopen for TeX Live 0.83:";; esac cat <<\_ACEOF @@ -1386,7 +1386,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -xpdfopen for TeX Live configure 0.82 +xpdfopen for TeX Live configure 0.83 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1591,7 +1591,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by xpdfopen for TeX Live $as_me 0.82, which was +It was created by xpdfopen for TeX Live $as_me 0.83, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2410,7 +2410,7 @@ fi # Define the identity of the package. PACKAGE='xpdfopen-for-tex-live' - VERSION='0.82' + VERSION='0.83' cat >>confdefs.h <<_ACEOF @@ -4926,7 +4926,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by xpdfopen for TeX Live $as_me 0.82, which was +This file was extended by xpdfopen for TeX Live $as_me 0.83, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4983,7 +4983,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -xpdfopen for TeX Live config.status 0.82 +xpdfopen for TeX Live config.status 0.83 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/Build/source/utils/xpdfopen/configure.ac b/Build/source/utils/xpdfopen/configure.ac index 6966aac3396..4b3b0d2ea92 100644 --- a/Build/source/utils/xpdfopen/configure.ac +++ b/Build/source/utils/xpdfopen/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl Copyright (C) 2009-2011 Peter Breitenlohner <tex-live@tug.org> +dnl Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org> dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([xpdfopen for TeX Live], [0.82], [tex-k@tug.org]) +AC_INIT([xpdfopen for TeX Live], [0.83], [tex-k@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([pdfopen.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/utils/xpdfopen/configure.ac.orig b/Build/source/utils/xpdfopen/configure.ac.orig index 2e891f0834c..7c529a6d4b7 100644 --- a/Build/source/utils/xpdfopen/configure.ac.orig +++ b/Build/source/utils/xpdfopen/configure.ac.orig @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl this is for autoconf 2.5x -AC_INIT(pdfopen, 0.82, jim.diamond@acadiau.ca) +AC_INIT(pdfopen, 0.83, jim.diamond@acadiau.ca) AC_CONFIG_AUX_DIR(config) diff --git a/Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c b/Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c new file mode 100644 index 00000000000..3e6900307a9 --- /dev/null +++ b/Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c @@ -0,0 +1,93 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> + +/* returns 1 on failure */ +extern int sendx_control_token(char *,char *); +extern int sendx_alt_token(char *,char *); + +void usage (void) { + puts ("pdfopen 0.61: you are mistaking me for an actual program.\n"); + puts(" pdfopen [--file filename.pdf]"); + puts ("\nusing no arguments tells the Reader to 'go back'.\n"); +} + +#define READERFIVE "Acrobat Reader" +#define READERNAME "Adobe Reader" +#define READERWINPREFIX "Adobe Reader - " +#define READERWINPOSTFIX " - Adobe Reader" +#define SUCCESS(a) (!a) + +int main (int argc, char **argv){ + char *newargv[3]; + char *winname, *win8name; + char *filename; + char *basefile; + pid_t reader; + if (argc == 5 && + (strcmp(argv[3],"--page") == 0 + && strcmp(argv[1],"--file") == 0 )) { + argc = 3; + } + if (argc == 3 && strcmp(argv[1],"--file") == 0) { + filename = malloc(strlen(argv[2])+1); + basefile = malloc(strlen(argv[2])+1); + if (filename == NULL || basefile == NULL) { + puts ("out of memory\n"); + exit(EXIT_FAILURE); + } + strcpy(filename,argv[2]); + strcpy(basefile,filename); + if (strrchr(basefile,'/')) + basefile = strrchr(basefile,'/')+1; + + winname = malloc(strlen(basefile)+1+strlen(READERWINPREFIX)); + win8name = malloc(strlen(basefile)+1+strlen(READERWINPOSTFIX)); + if (winname == NULL || win8name == NULL) { + puts ("out of memory\n"); + exit(EXIT_FAILURE); + } + strcpy (winname,READERWINPREFIX); + strcpy ((winname+strlen(READERWINPREFIX)), basefile); + strcpy (win8name,basefile); + strcpy ((win8name+strlen(basefile)), READERWINPOSTFIX); + if (SUCCESS(sendx_control_token("W",winname)) || /* that's seven */ + SUCCESS(sendx_control_token("W",win8name))) { /* that's eight */ + sendx_alt_token("Left",READERNAME); /* seven or eight */ + sendx_control_token("Left",READERNAME); /* that's seven, with artificial five keymaps */ + } else if (SUCCESS(sendx_control_token("W",filename))) { + sendx_control_token("Left",READERFIVE); /* that's five */ + } else if (SUCCESS(sendx_control_token("W",basefile))) { + sendx_control_token("Left",READERFIVE); /* that's five */ + } else { + if((reader = fork()) >= 0) { + if (reader) { + waitpid(reader,NULL,WNOHANG); + } else { + newargv[0] = "acroread"; + newargv[1] = filename; + newargv[2] = NULL; + if(execvp("acroread",newargv)) { + puts ("acroread startup failed\n"); + exit(EXIT_FAILURE); + } + } + } else { + puts ("fork failed\n"); + exit(EXIT_FAILURE); + } + } + } else if (argc != 1) { + usage(); + } else { + sendx_alt_token("Left",READERNAME); + sendx_control_token("Left",READERNAME); /* that's seven */ + sendx_control_token("Left",READERFIVE); + } + exit(EXIT_SUCCESS); +} + diff --git a/Build/source/utils/xpdfopen/pdfopen.1 b/Build/source/utils/xpdfopen/pdfopen.1 index 9531dfadd56..82239785469 100644 --- a/Build/source/utils/xpdfopen/pdfopen.1 +++ b/Build/source/utils/xpdfopen/pdfopen.1 @@ -1,5 +1,5 @@ .\" This manpage is licensed under the GNU Public License -.TH PDFOPEN 1 2011-05-17 "pdfopen 0.82" "" +.TH PDFOPEN 1 2012-01-28 "pdfopen 0.83" "" . .SH NAME pdfopen, pdfclose \- open or close a PDF file viewer @@ -20,6 +20,10 @@ output help and exit .B -v, --version output the version number and exit .TP +.B -r, --reset_focus +after sending commands to the PDF viewer, attempt to reset the input focus to +the window which had focus before the commands were sent +.TP .B -viewer <\fIar9\fP|\fIar9-tab\fP|\fIar8\fP|\fIar7\fP|\fIar5\fP|\fIxpdf\fP|\fIevince\fP> use (respectively) Adobe Reader 9 (in a new window), Adobe Reader 9 @@ -65,7 +69,7 @@ document vary from one version of \fBacroread\fP to another; consequently, if you are using a version of \fBacroread\fP other than AR9, you should explicitly specify the viewer program. -Version 0.81 of \fBpdfopen\fP accepts the following viewer options: +Version 0.83 of \fBpdfopen\fP accepts the following viewer options: .br \fIar9\fP, \fIar9-tab\fP, \fIar8\fP, \fIar7\fP, \fIar5\fP, \fIxpdf\fP, and \fIevince\fP. @@ -98,7 +102,7 @@ to ask them to implement a "\fB-page \fP\fI<pagenumber>\fP" command line option for \fBacroread\fP. -These programs have been tested on Slackware64 Version 13.1 and a few +These programs have been tested on Slackware64 Version 13.37 and a few other versions / distributions of GNU/Linux. The code is reasonably generic and should work out of the box using most recent X11 implementations. (Reports to the contrary are welcome, particularly @@ -133,9 +137,8 @@ With at least AR9 and some window managers, using to reload the document gives focus to the .B acroread window, even though the mouse cursor is not necessarily in that -window. This can be annoying. A contribution from an X11 wizard to -retain focus in the current window (or to restore focus to that -window after reloading the PDF document) would be cheerily accepted. +window. This can be annoying. The \fB-reset_focus\fP option can be +used to deal with this problem. . .SH AUTHOR This manual page was written by Jim Diamond <Jim.Diamond@acadiau.ca>. diff --git a/Build/source/utils/xpdfopen/pdfopen.c b/Build/source/utils/xpdfopen/pdfopen.c index 53383a65ad6..a8d5775bdc8 100644 --- a/Build/source/utils/xpdfopen/pdfopen.c +++ b/Build/source/utils/xpdfopen/pdfopen.c @@ -24,7 +24,7 @@ * please send it to me for inclusion. */ -#define VERSION "0.82" +#define VERSION "0.83" #include <stdio.h> #include <stdlib.h> @@ -168,10 +168,14 @@ usage(void) fprintf(stderr, " %s [-v|--version]\n", progname); fprintf(stderr, " Show the version number and exit.\n"); - fprintf(stderr, " %s [-viewer <prog>] <file.pdf>\n", progname); + fprintf(stderr, " %s [-r|--reset_focus] [-viewer <prog>] <file.pdf>\n", + progname); fprintf(stderr, " If the PDF viewer <prog> is displaying <file.pdf>, " "reload that file.\n"); fprintf(stderr, " Otherwise call <prog> to display <file.pdf>.\n"); + fprintf(stderr, " If '-r' or '--reset_focus' is used, attempt to"); + fprintf(stderr, " reset the input focus\n"); + fprintf(stderr, " after calling the viewer program.\n"); fprintf(stderr, " The default viewer program is %s.\n", DEFAULT_VIEWER); fprintf(stderr, " Implemented viewers:"); for (i = 0; i < viewers - 1; i++) @@ -239,10 +243,14 @@ send_command(const char * window_name, const char * reload_cmd) * Try to reload the file. * If not successful, try to start up a new instance of the viewer program. * Return 0 on success, non-0 otherwise. + * + * If reset_focus is true, (attempt to) reset the input focus to the + * window which had focus when this program was called. This is + * currently only implemented for the USE_SENDX case. */ static int -view_file(const char * filename, int viewer_index) +view_file(const char * filename, int viewer_index, int focus_reset) { char * window_name; pid_t pid; @@ -257,6 +265,8 @@ view_file(const char * filename, int viewer_index) window_name = make_window_name(pdf_viewer.window_name_fmt, filename); if (window_name == NULL) return 99; + if (focus_reset) + (void)set_focus(window_name); while (*reload_cmds) { /* @@ -286,6 +296,8 @@ view_file(const char * filename, int viewer_index) break; reload_cmds++; } + if (focus_reset) + (void)reset_focus(); break; case USE_FORK_EXEC: @@ -344,6 +356,7 @@ main(int argc, char * argv[]) char * env_viewer; int i; int viewer_index = -1; + int focus_reset = 0; progname = argv[0]; @@ -363,6 +376,13 @@ main(int argc, char * argv[]) return EXIT_SUCCESS; } + if (!strcmp(argv[1], "--reset_focus") || !strcmp(argv[1], "-r")) + { + argc--; + argv++; + focus_reset = 1; + } + if (argc == 4 && !strcmp(argv[1], "-viewer")) { viewer = argv[2]; @@ -394,7 +414,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - if (view_file(argv[1], viewer_index)) + if (view_file(argv[1], viewer_index, focus_reset)) return EXIT_FAILURE; return EXIT_SUCCESS; diff --git a/Build/source/utils/xpdfopen/sendx.c b/Build/source/utils/xpdfopen/sendx.c index f97cfb59d5a..a056279a48b 100644 --- a/Build/source/utils/xpdfopen/sendx.c +++ b/Build/source/utils/xpdfopen/sendx.c @@ -8,15 +8,23 @@ * Thing. * * Also added set_focus() and reset_focus() functions. - * NOTE: they do not work, at least under FVWM2 on Slackware64-13.0. - * They return success, but the focus never changes (or is reverted to the - * window containing the mouse before a call to sendx_token() can do its - * work). + * + * January 27, 2012 note: + * NOTE: to make reset_focus() work, at least under FVWM2 on + * Slackware64-13.37 when using AR9, I needed to call XOpenDisplay() + * again (since close_channel() has generally been called since + * set_focus() was called), I needed to sleep a bit (perhaps < 1 second + * is fine, and perhaps other systems might need more, I dunno), and I + * needed to call XFlush(). If someone who understands why the code + * here opens and closes the display for every sendx_<something>() can + * explain why that makes sense, or why I need the sleep() and the + * XFlush(), I'd be happy to be enlightened. */ #include <stdio.h> #include <string.h> #include <ctype.h> +#include <unistd.h> #include <X11/Xlib.h> #include <X11/Xatom.h> @@ -384,13 +392,20 @@ set_focus(const char * wname) } - int reset_focus(void) { if (previous_window_set) { + sleep(1); + if ((display = XOpenDisplay(display_name)) == NULL) + { + throw_exception("can't open display"); + return 1; + } + XSetInputFocus(display, previous_window, revert_to, CurrentTime); + XFlush(display); previous_window_set = 0; return 0; } |