From 3e2864914687b1af9d1ce374ee11b3a799e9561a Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Wed, 18 Jun 2014 12:10:20 +0000 Subject: xpdfopen 0.86 git-svn-id: svn://tug.org/texlive/trunk@34291 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/utils/xpdfopen/ChangeLog | 128 ---- Build/source/utils/xpdfopen/Makefile.am | 28 +- Build/source/utils/xpdfopen/Makefile.am.orig | 18 - Build/source/utils/xpdfopen/Makefile.in | 129 ++-- Build/source/utils/xpdfopen/README | 103 ---- Build/source/utils/xpdfopen/configure | 26 +- Build/source/utils/xpdfopen/configure.ac | 7 +- Build/source/utils/xpdfopen/configure.ac.orig | 25 - Build/source/utils/xpdfopen/externs.h | 24 - Build/source/utils/xpdfopen/pdfclose.c | 70 --- Build/source/utils/xpdfopen/pdfopen.1 | 154 ----- Build/source/utils/xpdfopen/pdfopen.c | 540 ---------------- Build/source/utils/xpdfopen/sendx.c | 423 ------------- Build/source/utils/xpdfopen/sendx.h | 19 - Build/source/utils/xpdfopen/utils.c | 45 -- Build/source/utils/xpdfopen/utils.h | 13 - Build/source/utils/xpdfopen/version.ac | 11 + .../utils/xpdfopen/xpdfopen-0.86-PATCHES/ChangeLog | 16 + .../xpdfopen/xpdfopen-0.86-PATCHES/TL-Changes | 9 + .../xpdfopen-0.86-PATCHES/patch-01-unsigned | 14 + .../source/utils/xpdfopen/xpdfopen-0.86/ChangeLog | 136 ++++ .../utils/xpdfopen/xpdfopen-0.86/Makefile.am | 18 + Build/source/utils/xpdfopen/xpdfopen-0.86/README | 115 ++++ .../utils/xpdfopen/xpdfopen-0.86/configure.ac | 25 + .../source/utils/xpdfopen/xpdfopen-0.86/externs.h | 24 + .../source/utils/xpdfopen/xpdfopen-0.86/pdfclose.c | 75 +++ .../source/utils/xpdfopen/xpdfopen-0.86/pdfopen.1 | 166 +++++ .../source/utils/xpdfopen/xpdfopen-0.86/pdfopen.c | 681 +++++++++++++++++++++ Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.c | 424 +++++++++++++ Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.h | 19 + Build/source/utils/xpdfopen/xpdfopen-0.86/utils.c | 45 ++ Build/source/utils/xpdfopen/xpdfopen-0.86/utils.h | 13 + .../source/utils/xpdfopen/xpdfopen-0.86/xpdfopen.h | 41 ++ Build/source/utils/xpdfopen/xpdfopen.h | 41 -- 34 files changed, 1955 insertions(+), 1670 deletions(-) delete mode 100644 Build/source/utils/xpdfopen/ChangeLog delete mode 100644 Build/source/utils/xpdfopen/Makefile.am.orig delete mode 100644 Build/source/utils/xpdfopen/README delete mode 100644 Build/source/utils/xpdfopen/configure.ac.orig delete mode 100644 Build/source/utils/xpdfopen/externs.h delete mode 100644 Build/source/utils/xpdfopen/pdfclose.c delete mode 100644 Build/source/utils/xpdfopen/pdfopen.1 delete mode 100644 Build/source/utils/xpdfopen/pdfopen.c delete mode 100644 Build/source/utils/xpdfopen/sendx.c delete mode 100644 Build/source/utils/xpdfopen/sendx.h delete mode 100644 Build/source/utils/xpdfopen/utils.c delete mode 100644 Build/source/utils/xpdfopen/utils.h create mode 100644 Build/source/utils/xpdfopen/version.ac create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/ChangeLog create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/TL-Changes create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/patch-01-unsigned create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/ChangeLog create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/Makefile.am create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/README create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/configure.ac create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/externs.h create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/pdfclose.c create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.1 create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.c create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.c create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.h create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/utils.c create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/utils.h create mode 100644 Build/source/utils/xpdfopen/xpdfopen-0.86/xpdfopen.h delete mode 100644 Build/source/utils/xpdfopen/xpdfopen.h (limited to 'Build/source/utils') diff --git a/Build/source/utils/xpdfopen/ChangeLog b/Build/source/utils/xpdfopen/ChangeLog deleted file mode 100644 index 65416356847..00000000000 --- a/Build/source/utils/xpdfopen/ChangeLog +++ /dev/null @@ -1,128 +0,0 @@ -2014-05-16 Jim Diamond - - * pdfopen.c: add -p option, update for externs.h - * pdfclose.c: update for externs.h - * utils.c: update for externs.h - * externs.h: add this for cleanliness - * pdfopen.1: update man page accordingly. - * xpdfopen.tex: remove from distribution, since it is now redundant - * configure.ac: update for V 0.84. - * README: update for V 0.84. - * Makefile.am update for externs.h, remove archaic pdfopen-AR-7-and-8.c - -2013-07-05 Peter Breitenlohner - - * Makefile.am: Moved Makefile fragments to ../../am/. - -2012-12-15 Peter Breitenlohner - - * configure.ac: Use KPSE_BASIC to enable silent rules. - -2012-11-20 Peter Breitenlohner - - * Makefile.am: Avoid use of deprecated INCLUDES. - -2012-03-29 Peter Breitenlohner - - * utils.c: Move extern decl from here ... - * utils.h: ... to here. - -2012-01-28 Jim Diamond - - * 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 - - * pdfopen.c: add -v and --version options. - * pdfopen.1: create man page: thanks to Karl Berry for numerous - suggestions and improvements. - * pdfclose.1: add version number to usage information. - * configure.ac: update for V 0.82. - -2011-05-17 Jim Diamond - - * pdfopen.c: add -h and --help options. - Reformat usage information. - Add support for evince. - Replace '-openInNewWindow' with '-openInNewInstance' - since AR9 claims the former is deprecated. - * xpdfopen.h: add support for evince. - * pdfclose.c: add support for evince. - * configure.ac: update for V 0.81. - - -2010-05-03 Jim Diamond - - * pdfclose.c: make it work with all of AR{5,7,8,9} and xpdf. - * pdfopen.c: add ability to parse and send function-keys. - Add code (commented out) in an attempt to - support okular (see code comments). - * sendx.c: add code (commented out) in an attempt to - support okular (see code comments). - * configure.ac: add changes suggested by Peter Breitenlohner. - - -2010-04-24 Jim Diamond - - * utils.[ch]: put a function to create window titles there - * xpdfopen.h: put constants related to the titles of various - PDF viewers there - * pdfclose.c: modify to use utils.c and xpdfopen.h - * pdfopen.c: major modifications so it works with AR7, AR8, AR9 - xpdf and maybe AR5, and so that it might be - relatively straightforward to add other PDF viewers. - The default viewer is AR9, this can be overridden - by an environment variable and a command-line - argument. - * sendx.c: Reset the error status in open_channel() so that an - error return doesn't become permanent. - Fixed mask param in XSendEvent(). - - -2010-04-21 Jim Diamond - - * pdfopen.c: Fold in some changes submitted by - Peter Breitenlohner - * pdfopen.c: Fold in some changes submitted by - Peter Breitenlohner - and reformat the code. - - -2010-04-11 Jim Diamond - - * pdfopen.c: Update (in a non-backward-compatible way) to - work with AR 9. Save old version in pdfopen-AR-7-and-8.c. - - -2009-08-22 Peter Breitenlohner - - Avoid maximal compiler warnings. - * pdfopen.c: Use strdup'ed literal string (malloc+strcpy) to - initialize non-constant string. - * sendx.[ch]: Constify string args of all functions. - Consistently use wname for window name string param. - (close_channel): ANSI C function definition. - - -2009-08-19 Peter Breitenlohner - - * Makefile.am (AM_CFLAGS), configure.ac: Enable compiler warnings. - * pdfopen.c (usage), pdfclose.c (usage): Declare as static. - - * sendx.h (new): Declare prototypes for functions in sendx.c. - * Makefile.am (pdfopen_SOURCES, pdfclose_SOURCES): Add sendx.h. - * pdfopen.c, pdfclose.c, sendx.c: #include "sendx.h". - - * sendx.c (GetRootWindow): Slightly reformulate to avoid compiler - warning (strict-aliasing rules). - - -2009-05-06 Peter Breitenlohner - - Adapt to TL2009 build system. - diff --git a/Build/source/utils/xpdfopen/Makefile.am b/Build/source/utils/xpdfopen/Makefile.am index 56c8350f6e7..676bdcd3556 100644 --- a/Build/source/utils/xpdfopen/Makefile.am +++ b/Build/source/utils/xpdfopen/Makefile.am @@ -3,7 +3,15 @@ ## Copyright (C) 2009-2014 Peter Breitenlohner ## You may freely use, modify and/or distribute this file. ## -ACLOCAL_AMFLAGS = -I ../../m4 +EXTRA_DIST = $(XPDFOPEN_TREE) + +## Changes applied to the original source tree +## +EXTRA_DIST += $(XPDFOPEN_TREE)-PATCHES + +# in case of an SVN repository +dist-hook: + rm -rf `find $(distdir) -name .svn -o -name .deps -o -name .dirstamp -o -name '*.$(OBJEXT)'` AM_CPPFLAGS = $(X_CFLAGS) AM_CFLAGS = $(WARNING_CFLAGS) @@ -12,13 +20,19 @@ LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) bin_PROGRAMS = pdfopen pdfclose -common_sources = externs.h sendx.c sendx.h utils.c utils.h xpdfopen.h +common_sources = \ + @XPDFOPEN_TREE@/sendx.c \ + @XPDFOPEN_TREE@/utils.c -pdfopen_SOURCES = pdfopen.c $(common_sources) +nodist_pdfopen_SOURCES = \ + @XPDFOPEN_TREE@/pdfopen.c \ + $(common_sources) -pdfclose_SOURCES = pdfclose.c $(common_sources) +nodist_pdfclose_SOURCES = \ + @XPDFOPEN_TREE@/pdfclose.c \ + $(common_sources) -dist_man1_MANS = pdfopen.1 +nodist_man1_MANS = $(XPDFOPEN_TREE)/pdfopen.1 # Symlinks within $(man1dir): FILE:LINK indicates LINK.1->FILE.1 man1_links = pdfopen:pdfclose @@ -29,7 +43,5 @@ install-data-hook: install-man1-links uninstall-hook: uninstall-man1-links -EXTRA_DIST = xpdfopen.pdf xpdfopen.tex - -EXTRA_DIST += Makefile.am.orig configure.ac.orig +EXTRA_DIST += xpdfopen.pdf xpdfopen.tex diff --git a/Build/source/utils/xpdfopen/Makefile.am.orig b/Build/source/utils/xpdfopen/Makefile.am.orig deleted file mode 100644 index b41b46db6b7..00000000000 --- a/Build/source/utils/xpdfopen/Makefile.am.orig +++ /dev/null @@ -1,18 +0,0 @@ - -AM_CFLAGS = $(X_CFLAGS) -## Add warnings for gcc-3.4 -AM_CFLAGS += -Wall -Wunused -Wimplicit -Wreturn-type -AM_CFLAGS += -Wdeclaration-after-statement -Wno-unknown-pragmas -AM_CFLAGS += -Wmissing-prototypes -Wmissing-declarations -Wparentheses -AM_CFLAGS += -Wswitch -Wtrigraphs -Wpointer-arith -Wcast-qual -AM_CFLAGS += -Wcast-align -Wwrite-strings -Wold-style-definition - -LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) - -bin_PROGRAMS = pdfopen pdfclose - -pdfopen_SOURCES = externs.h pdfopen.c sendx.c utils.c sendx.h xpdfopen.h utils.h - -pdfclose_SOURCES = externs.h pdfclose.c sendx.c utils.c sendx.h xpdfopen.h utils.h - - diff --git a/Build/source/utils/xpdfopen/Makefile.in b/Build/source/utils/xpdfopen/Makefile.in index 737efaa7db8..44ccc41102d 100644 --- a/Build/source/utils/xpdfopen/Makefile.in +++ b/Build/source/utils/xpdfopen/Makefile.in @@ -80,12 +80,12 @@ bin_PROGRAMS = pdfopen$(EXEEXT) pdfclose$(EXEEXT) DIST_COMMON = $(top_srcdir)/../../am/man1_links.am \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ - $(top_srcdir)/../../build-aux/depcomp $(dist_man1_MANS) \ - ChangeLog README ../../build-aux/compile \ - ../../build-aux/config.guess ../../build-aux/config.sub \ - ../../build-aux/depcomp ../../build-aux/install-sh \ - ../../build-aux/missing ../../build-aux/texinfo.tex \ - ../../build-aux/ylwrap ../../build-aux/ltmain.sh \ + $(top_srcdir)/../../build-aux/depcomp ChangeLog \ + ../../build-aux/compile ../../build-aux/config.guess \ + ../../build-aux/config.sub ../../build-aux/depcomp \ + ../../build-aux/install-sh ../../build-aux/missing \ + ../../build-aux/texinfo.tex ../../build-aux/ylwrap \ + ../../build-aux/ltmain.sh \ $(top_srcdir)/../../build-aux/compile \ $(top_srcdir)/../../build-aux/install-sh \ $(top_srcdir)/../../build-aux/missing @@ -93,7 +93,7 @@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-warnings.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/version.ac $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ @@ -103,14 +103,18 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) -am__objects_1 = sendx.$(OBJEXT) utils.$(OBJEXT) -am_pdfclose_OBJECTS = pdfclose.$(OBJEXT) $(am__objects_1) -pdfclose_OBJECTS = $(am_pdfclose_OBJECTS) +am__dirstamp = $(am__leading_dot)dirstamp +am__objects_1 = @XPDFOPEN_TREE@/sendx.$(OBJEXT) \ + @XPDFOPEN_TREE@/utils.$(OBJEXT) +nodist_pdfclose_OBJECTS = @XPDFOPEN_TREE@/pdfclose.$(OBJEXT) \ + $(am__objects_1) +pdfclose_OBJECTS = $(nodist_pdfclose_OBJECTS) pdfclose_LDADD = $(LDADD) am__DEPENDENCIES_1 = pdfclose_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am_pdfopen_OBJECTS = pdfopen.$(OBJEXT) $(am__objects_1) -pdfopen_OBJECTS = $(am_pdfopen_OBJECTS) +nodist_pdfopen_OBJECTS = @XPDFOPEN_TREE@/pdfopen.$(OBJEXT) \ + $(am__objects_1) +pdfopen_OBJECTS = $(nodist_pdfopen_OBJECTS) pdfopen_LDADD = $(LDADD) pdfopen_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) @@ -141,8 +145,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(pdfclose_SOURCES) $(pdfopen_SOURCES) -DIST_SOURCES = $(pdfclose_SOURCES) $(pdfopen_SOURCES) +SOURCES = $(nodist_pdfclose_SOURCES) $(nodist_pdfopen_SOURCES) +DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -177,7 +181,7 @@ am__uninstall_files_from_dir = { \ } man1dir = $(mandir)/man1 NROFF = nroff -MANS = $(dist_man1_MANS) +MANS = $(nodist_man1_MANS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -262,6 +266,7 @@ STRIP = @STRIP@ VERSION = @VERSION@ WARNING_CFLAGS = @WARNING_CFLAGS@ XMKMF = @XMKMF@ +XPDFOPEN_TREE = @XPDFOPEN_TREE@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ @@ -308,19 +313,27 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ACLOCAL_AMFLAGS = -I ../../m4 +EXTRA_DIST = $(XPDFOPEN_TREE) $(XPDFOPEN_TREE)-PATCHES xpdfopen.pdf \ + xpdfopen.tex AM_CPPFLAGS = $(X_CFLAGS) AM_CFLAGS = $(WARNING_CFLAGS) LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) -common_sources = externs.h sendx.c sendx.h utils.c utils.h xpdfopen.h -pdfopen_SOURCES = pdfopen.c $(common_sources) -pdfclose_SOURCES = pdfclose.c $(common_sources) -dist_man1_MANS = pdfopen.1 +common_sources = \ + @XPDFOPEN_TREE@/sendx.c \ + @XPDFOPEN_TREE@/utils.c + +nodist_pdfopen_SOURCES = \ + @XPDFOPEN_TREE@/pdfopen.c \ + $(common_sources) + +nodist_pdfclose_SOURCES = \ + @XPDFOPEN_TREE@/pdfclose.c \ + $(common_sources) + +nodist_man1_MANS = $(XPDFOPEN_TREE)/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 all: all-am .SUFFIXES: @@ -402,10 +415,24 @@ uninstall-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +@XPDFOPEN_TREE@/$(am__dirstamp): + @$(MKDIR_P) @XPDFOPEN_TREE@ + @: > @XPDFOPEN_TREE@/$(am__dirstamp) +@XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) @XPDFOPEN_TREE@/$(DEPDIR) + @: > @XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp) +@XPDFOPEN_TREE@/pdfclose.$(OBJEXT): @XPDFOPEN_TREE@/$(am__dirstamp) \ + @XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp) +@XPDFOPEN_TREE@/sendx.$(OBJEXT): @XPDFOPEN_TREE@/$(am__dirstamp) \ + @XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp) +@XPDFOPEN_TREE@/utils.$(OBJEXT): @XPDFOPEN_TREE@/$(am__dirstamp) \ + @XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp) pdfclose$(EXEEXT): $(pdfclose_OBJECTS) $(pdfclose_DEPENDENCIES) $(EXTRA_pdfclose_DEPENDENCIES) @rm -f pdfclose$(EXEEXT) $(AM_V_CCLD)$(LINK) $(pdfclose_OBJECTS) $(pdfclose_LDADD) $(LIBS) +@XPDFOPEN_TREE@/pdfopen.$(OBJEXT): @XPDFOPEN_TREE@/$(am__dirstamp) \ + @XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp) pdfopen$(EXEEXT): $(pdfopen_OBJECTS) $(pdfopen_DEPENDENCIES) $(EXTRA_pdfopen_DEPENDENCIES) @rm -f pdfopen$(EXEEXT) @@ -413,14 +440,15 @@ pdfopen$(EXEEXT): $(pdfopen_OBJECTS) $(pdfopen_DEPENDENCIES) $(EXTRA_pdfopen_DEP mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f @XPDFOPEN_TREE@/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdfclose.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdfopen.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendx.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@XPDFOPEN_TREE@/$(DEPDIR)/pdfclose.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@XPDFOPEN_TREE@/$(DEPDIR)/pdfopen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@XPDFOPEN_TREE@/$(DEPDIR)/sendx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@XPDFOPEN_TREE@/$(DEPDIR)/utils.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -437,9 +465,9 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` -install-man1: $(dist_man1_MANS) +install-man1: $(nodist_man1_MANS) @$(NORMAL_INSTALL) - @list1='$(dist_man1_MANS)'; \ + @list1='$(nodist_man1_MANS)'; \ list2=''; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ @@ -473,7 +501,7 @@ install-man1: $(dist_man1_MANS) uninstall-man1: @$(NORMAL_UNINSTALL) - @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ + @list='$(nodist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ @@ -570,6 +598,9 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ @@ -734,6 +765,8 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f @XPDFOPEN_TREE@/$(DEPDIR)/$(am__dirstamp) + -rm -f @XPDFOPEN_TREE@/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -744,7 +777,7 @@ clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) + -rm -rf @XPDFOPEN_TREE@/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -793,7 +826,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) + -rm -rf @XPDFOPEN_TREE@/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -819,21 +852,25 @@ uninstall-man: uninstall-man1 .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ clean-binPROGRAMS clean-cscope clean-generic cscope \ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ - dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-compile distclean-generic \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am \ - install-data-hook install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-man1 install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-binPROGRAMS uninstall-hook \ - uninstall-man uninstall-man1 - + dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \ + dist-zip distcheck distclean distclean-compile \ + distclean-generic distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-data-hook install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-man1 \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-hook uninstall-man uninstall-man1 + + +# in case of an SVN repository +dist-hook: + rm -rf `find $(distdir) -name .svn -o -name .deps -o -name .dirstamp -o -name '*.$(OBJEXT)'` .PHONY: install-man1-links uninstall-man1-links install-man1-links: diff --git a/Build/source/utils/xpdfopen/README b/Build/source/utils/xpdfopen/README deleted file mode 100644 index 2b25b7782fa..00000000000 --- a/Build/source/utils/xpdfopen/README +++ /dev/null @@ -1,103 +0,0 @@ ---------------------------------------------------------------------------- -xpdfopen 0.84 - Send open/close commands to Acrobat Reader, xpdf and evince ---------------------------------------------------------------------------- - -This is a Linux (X11) implementation of Fabrice Popineau's pdfclose/ -pdfopen commands to control Acrobat Reader, xpdf and evince. - -The libX code was borrowed from Reinhard Fobbe's Sendx library for -Tcl/Tk, and the programs use the same license, copied below. - -Version 0.3 adds support for Adobe Reader 7.0 for Linux. - (different window titles and key shortcuts) - -Version 0.4 uses autoconf - -Version 0.5 fixes an incorrect autoconf variable, supports building - under X11R5, handles pathnames on the command-line, and - fixes a bug where pdfopen did not exit correctly after - (automatically) starting acroread. - -Version 0.51 uses the strrchr() function instead of rindex() - to allow compilation on non-BSD derived unix platforms. - -Version 0.61 attempts to do something useful with Adobe Reader 8, - even though it is impossible to restore the viewport. - -Version 0.80 adds an implementation for AR 9 and xpdf. - -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. - -Version 0.84 adds 'load at given page' support (-p option) for Adobe - Reader 9, evince (at least 3.12, maybe earlier) and xpdf. - - -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 [-r|-reset_focus] \ - [-viewer ] \ - [-p ] \ - - -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). - - -pdfclose has the following call sequence: - pdfclose -This program closes an existing AR5, AR7, AR8, AR9, xpdf or evince window -displaying the given PDF file. - - -Version 0.84 compiles on Linux (Slackware64 14.1, 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 -a configure program. - - -Taco Hoekwater (Version(s) up to 0.61) -Dordrecht, The Netherlands, December 2008. - -Jim Diamond (Version 0.80 through 0.84) -Acadia University, Wolfville, Nova Scotia, Canada; May 2014. - - - - -License terms: --------------- -The following terms apply to all files associated with the software -unless explicitly disclaimed in individual files. - -The authors hereby grant permission to use, copy, modify, distribute, -and license this software and its documentation for any purpose, -provided that existing copyright notices are retained in all copies -and that this notice is included verbatim in any distributions. No -written agreement, license, or royalty fee is required for any of the -authorized uses. Modifications to this software may be copyrighted by -their authors and need not follow the licensing terms described here, -provided that the new terms are clearly indicated on the first page of -each file where they apply. - -IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY -FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY -DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND -NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND -THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE -MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/Build/source/utils/xpdfopen/configure b/Build/source/utils/xpdfopen/configure index 55b0867418f..f3020eca3b4 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.69 for xpdfopen (TeX Live) 0.84. +# Generated by GNU Autoconf 2.69 for xpdfopen (TeX Live) 0.86. # # Report bugs to . # @@ -579,16 +579,17 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='xpdfopen (TeX Live)' PACKAGE_TARNAME='xpdfopen--tex-live-' -PACKAGE_VERSION='0.84' -PACKAGE_STRING='xpdfopen (TeX Live) 0.84' +PACKAGE_VERSION='0.86' +PACKAGE_STRING='xpdfopen (TeX Live) 0.86' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="pdfopen.c" +ac_unique_file="xpdfopen-0.86/pdfopen.c" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +XPDFOPEN_TREE X_EXTRA_LIBS X_LIBS X_PRE_LIBS @@ -1240,7 +1241,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 (TeX Live) 0.84 to adapt to many kinds of systems. +\`configure' configures xpdfopen (TeX Live) 0.86 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1311,7 +1312,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xpdfopen (TeX Live) 0.84:";; + short | recursive ) echo "Configuration of xpdfopen (TeX Live) 0.86:";; esac cat <<\_ACEOF @@ -1414,7 +1415,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -xpdfopen (TeX Live) configure 0.84 +xpdfopen (TeX Live) configure 0.86 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1619,7 +1620,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 (TeX Live) $as_me 0.84, which was +It was created by xpdfopen (TeX Live) $as_me 0.86, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3542,7 +3543,7 @@ fi # Define the identity of the package. PACKAGE='xpdfopen--tex-live-' - VERSION='0.84' + VERSION='0.86' cat >>confdefs.h <<_ACEOF @@ -5291,6 +5292,9 @@ fi fi +XPDFOPEN_TREE=xpdfopen-0.86 + + ac_config_files="$ac_config_files Makefile" @@ -5868,7 +5872,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 (TeX Live) $as_me 0.84, which was +This file was extended by xpdfopen (TeX Live) $as_me 0.86, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5925,7 +5929,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 (TeX Live) config.status 0.84 +xpdfopen (TeX Live) config.status 0.86 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/utils/xpdfopen/configure.ac b/Build/source/utils/xpdfopen/configure.ac index ad638dd35ae..5ca9c179ac6 100644 --- a/Build/source/utils/xpdfopen/configure.ac +++ b/Build/source/utils/xpdfopen/configure.ac @@ -6,9 +6,10 @@ 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 (TeX Live)], [0.84], [tex-k@tug.org]) +m4_include([version.ac])[] dnl define xpdfopen_version +AC_INIT([xpdfopen (TeX Live)], xpdfopen_version, [tex-k@tug.org]) AC_PREREQ([2.65]) -AC_CONFIG_SRCDIR([pdfopen.c]) +AC_CONFIG_SRCDIR([xpdfopen-]xpdfopen_version[/pdfopen.c]) AC_CONFIG_AUX_DIR([../../build-aux]) AC_CONFIG_MACRO_DIR([../../m4]) @@ -19,6 +20,8 @@ AC_PROG_CC dnl Find Xlibs. AC_PATH_XTRA +AC_SUBST([XPDFOPEN_TREE], [xpdfopen-]xpdfopen_version) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/Build/source/utils/xpdfopen/configure.ac.orig b/Build/source/utils/xpdfopen/configure.ac.orig deleted file mode 100644 index 7c529a6d4b7..00000000000 --- a/Build/source/utils/xpdfopen/configure.ac.orig +++ /dev/null @@ -1,25 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -dnl this is for autoconf 2.5x - -AC_INIT(pdfopen, 0.83, jim.diamond@acadiau.ca) - -AC_CONFIG_AUX_DIR(config) - -AM_INIT_AUTOMAKE() - -AC_CONFIG_FILES(Makefile) - -AC_PROG_CC - -dnl AC_PROG_INSTALL - -dnl Checks for header files. - -dnl Checks for typedefs, structures, and compiler characteristics. - -dnl Checks for library functions. - -dnl Find Xlibs. -AC_PATH_XTRA - -AC_OUTPUT diff --git a/Build/source/utils/xpdfopen/externs.h b/Build/source/utils/xpdfopen/externs.h deleted file mode 100644 index 2aff4f858ef..00000000000 --- a/Build/source/utils/xpdfopen/externs.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * externs.h: This file defines or declares (depending on whether - * DEFINE_EXTERNS is defined) all of the global variables - * and constants used by pdfopen and pdfclose. - * - * Copyright (C) 2014 Jim Diamond - * You may freely use, modify and/or distribute this file. - * - * This file new in Version 0.84 of pdfopen (2014/05/16). - */ - - -#ifndef EXTERNS_H -#define EXTERNS_H - -#ifdef DEFINE_EXTERNS -#define EXTERN -#else -#define EXTERN extern -#endif - -EXTERN char * progname; - -#endif diff --git a/Build/source/utils/xpdfopen/pdfclose.c b/Build/source/utils/xpdfopen/pdfclose.c deleted file mode 100644 index 1fe905e1e9b..00000000000 --- a/Build/source/utils/xpdfopen/pdfclose.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * pdfclose.c: (attempt to) close a PDF viewer displaying argv[1]. - * - * Modified by Jim Diamond (jim.diamond@acadiau.ca) 2010/04/21 (V 0.80) - * and again 2011/05/17 (V 0.81 -- 0.84) - * and Peter Breitenlohner (2009). - * - * This program does not take a viewer argument, and just tries to close - * any known viewer displaying the given file. - */ - -#include -#include -#include -#include - -#include "sendx.h" -#include "xpdfopen.h" -#include "utils.h" - -#define DEFINE_EXTERNS -#include "externs.h" - -static void -usage(void) -{ - fprintf(stderr, "%s version %s\n", progname, VERSION); - fprintf(stderr, "Usage: %s \n", progname); -} - - - -static int -try_name(const char * filename, const char * title_format) -{ - char * winname; - int ret ; - - winname = make_window_name(title_format, filename); - if (winname == NULL) - return 99; - - ret = sendx_control_token("W", winname); - free(winname); - - return ret; -} - - - -int -main (int argc, char * argv[]) -{ - progname = argv[0]; - - if (argc != 2) - { - usage(); - return EXIT_FAILURE; - } - - if (try_name(argv[1], AR9_WIN_NAME_FMT)) /* This gets both AR8 & AR9 */ - if (try_name(argv[1], XPDF_WIN_NAME_FMT)) - if (try_name(argv[1], AR7_WIN_NAME_FMT)) - if (try_name(argv[1], AR5_WIN_NAME_FMT)) - if (try_name(argv[1], EVINCE_WIN_NAME_FMT)) - return EXIT_FAILURE; - - return EXIT_SUCCESS; -} diff --git a/Build/source/utils/xpdfopen/pdfopen.1 b/Build/source/utils/xpdfopen/pdfopen.1 deleted file mode 100644 index c70cbe9594e..00000000000 --- a/Build/source/utils/xpdfopen/pdfopen.1 +++ /dev/null @@ -1,154 +0,0 @@ -.\" This manpage is licensed under the GNU Public License -.TH PDFOPEN 1 2014-05-16 "pdfopen 0.84" "" -. -.SH NAME -pdfopen, pdfclose \- open or close a PDF file viewer -. -.SH SYNOPSIS -.B pdfopen -[\fIOPTION\fP] -\fIFILE.PDF\fP -.br -.B pdfclose -\fIFILE.PDF\fP -. -.SH OPTIONS -.TP 8 -.B -h, --help -output help and exit -.TP -.B -v, --version -output the version number and exit -.TP -.B -p -when starting the viewer, display page of the document (notes: not -all viewers support this feature, and even in those cases this option -only has effect when the document is initially loaded) -.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 -(in a new tab of a running AR9, if any), -Adobe Reader 8, Adobe Reader 7, Adobe Reader 5, xpdf or evince as the -PDF viewer program. -Adobe Reader 9 (in a new window) is the default. -. -.SH RATIONALE -At certain points of TeX document preparation, many people repeat a -"edit-compile-view" cycle. Since PDF viewers such as Adobe's Acrobat -Reader ("\fBacroread\fP") do not automatically refresh the display when the -PDF file changes, this cycle can be more cumbersome than desired. -The -.B pdfopen -program provides the ability to automate the reloading of the PDF -document when it is changed. - -Note: there seems to be little need for -.B pdfclose -under GNU/Linux, since (unlike the situation for MS windows) -.B acroread -does not lock the PDF file, which would prevent -.B pdftex -(or a DVI to PDF converter) from creating a new version of the PDF -output file. However, -.B pdfclose -is provided in case someone finds it useful. -. -.SH DESCRIPTION -.B pdfopen -searches for an instance of the specified (or default) PDF viewer -displaying the specified PDF file. -If there is already an instance of the given viewer displaying the -given file, the viewer is instructed to reload the file. If no such -instance is found, \fBpdfopen\fP attempts to run the specified viewer -on the specified document. - -The default viewer is "\fBacroread\fP", which could start any one -of a number of versions of Acrobat Reader, depending on what is -installed on your system. However, the commands to reload the current -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.84 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. -.br -The difference between \fIar9\fP and \fIar9-tab\fP is significant -when there is no instance of AR9 already displaying the requested -document. In this situation, while \fIar9\fP will -request \fBacroread\fP to create a new instance of \fBacroread\fP -(and thus open a new window) by using the \fB-openInNewInstance\fP -argument, \fIar9-tab\fP starts \fBacroread\fP without this argument; -if there is already an instance of \fBacroread\fP running, a new -tab will be opened in an existing window. - -.B pdfclose -searches for one of the above PDF viewers displaying the given file -and instructs the viewer to "close" the window. In most cases, the -PDF viewer continues to run, possibly now displaying just a blank -window. (This behaviour varies somewhat from one PDF viewer to another.) -. -.SH PORTABILITY AND AVAILABILITY -These programs have been tested on Slackware64 Version 14.1 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 -if they come with robust fixes.) - -These programs are designed for X11-based systems. If you somehow -find compiled versions of these programs on a system using another -window system, they are very unlikely to be of any use to you. - -Source and binaries of the programs can be downloaded from -CTAN://support/xpdfopen/ -(e.g., http://mirror.ctan.org/support/xpdfopen). -. -.SH CAVEATS -If you use -.I ar9-tab -to reload the PDF document and the instance -of -.B acroread -with the given document is currently displaying some other document, -the command causes your document to be displayed, but not reloaded. - -.B pdfopen -works by looking for a window with a name (window title) matching that -expected for the given viewer and document. If for some reason your -viewer's window name is not as expected, -.B pdfopen -may not work for you. - -With at least AR9 and some window managers, using -.B pdfopen -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. The \fB-reset_focus\fP option can be -used to deal with this problem. -. -.SH AUTHOR -This manual page was written by Jim Diamond . -I am the current maintainer of the X11 versions of -.B pdfopen -and -\fBpdfclose\fP. -Report any bugs you find to me. Feature enhancement requests are -welcome, coded enhancements even more so. - -Past authors: -Fabrice Popineau wrote the MS-windows versions of -.B pdfopen -and -.B pdfclose -upon which these programs were originally based. -Taco Hoekwater created the GNU/Linux versions, up to Version 0.61 -(including some documentation which inspired parts of this man page). -Peter Breitenlohner has contributed both code and suggestions to -versions later than 0.61. diff --git a/Build/source/utils/xpdfopen/pdfopen.c b/Build/source/utils/xpdfopen/pdfopen.c deleted file mode 100644 index 2575e8d4bbf..00000000000 --- a/Build/source/utils/xpdfopen/pdfopen.c +++ /dev/null @@ -1,540 +0,0 @@ -/* - * pdfopen.c. - * - * Heavily modified by Jim Diamond (jim.diamond@acadiau.ca) 2010/04/11 - * to work with AR 9, xpdf and evince. - * (Also some mods by Peter Breitenlohner from 2009 - * and suggestions from 2010, and some suggestions from Karl Berry - * (2011).) - * - * Note 1: the calling sequence was changed considerably to match what - * the program actually seemed to do as well as what made sense to me. - * - * Note 2: if there are two instances of acroread displaying that file, - * only one is reloaded. - * - * Further modified 2010/05/03 to work with ar5, and to include some code - * that does *not* work with okular (see note below). - * - * Modified 2014/05/16 (V 0.84) to add capability to open a pdf file - * at a specified page (currently working with AR9, xpdf and evince). - * - * Note 3: Unlike xpdf and AR[5,7,8,9], okular will not accept X events - * from this program unless the okular window has focus. On my system - * (Slackware64 13.0, using fvwm2), the functions I added to sendx.c to try - * to change the focus to the okular window do not work. (See also the - * comments in sendx.c.) If anyone cares to contribute working code, - * please send it to me for inclusion. - */ - -#include -#include -#include -#include -#include -#include - -#include "sendx.h" -#include "xpdfopen.h" -#include "utils.h" - -#define DEFINE_EXTERNS -#include "externs.h" - -#define MAX_RELOAD_CMDS 10 -#define MAX_PRE_PAGE_OPTIONS 2 /* See struct defn below */ -#define MAX_POST_PAGE_OPTIONS 1 /* See struct defn below */ - /* Overkill ... */ -#define MAX_OPTIONS (10 + MAX_PRE_PAGE_OPTIONS \ - + MAX_POST_PAGE_OPTIONS) - -/* A string unlikely to be used as a real command by a PDF viewer */ -#define FORK_EXEC_CMD "*FORK EXEC*" - - -/* Used in the pdf_viewer_t type... see comment below */ -typedef enum -{ - USE_SENDX, USE_FORK_EXEC -} reload_method_t; - - -/* - * This struct contains the information needed for both - * (a) initially starting up a PDF viewer, and - * (b) telling the viewer to reload the document. - * Of course, the viewer has to support that functionality. - * Two possible ways are supported. - * (a) Send the viewer's window (a) simulated keypress(ss) - * (b) fork()/exec() a second instance of the program which somehow signals - * the running instance. Note that this is problematical if the - * arguments for the "reload" case are different than the options - * for the "start up the viewer" case, because the command-line - * (and environment variable) syntax have to be extended. - * Arguably, if both the start-up and reload can be done with shell - * commands, the user should just write a shell script and be done with - * it. - * These could be extended with this as well: - * (c) send a Unix signal to the currently running viewer. - * This would require augmenting reload_method_t and pdf_viewer_t. - */ - -typedef struct -{ - const char * short_name; /* cmd line option name */ - const char * program_name; /* program to exec() */ - reload_method_t method; /* method to induce reload */ - const char * window_name; /* when no file is viewed */ - const char * window_name_fmt; /* fmt string for file viewed */ - const char * exec_pre_options[MAX_OPTIONS]; /* before filename in cmd */ - const char * exec_post_options[MAX_OPTIONS];/* after filename in cmd */ - const char * reload_cmds[MAX_RELOAD_CMDS]; /* cmds to reload a file */ - /* - * If the page number goes before the filename, use these options. - * The last one must be a printf format string with a %d and - * no other conversions specs. - * End list with a NULL. - */ - const char * initial_page_pre_options[MAX_PRE_PAGE_OPTIONS + 1]; /* */ - /* - * If the page number goes after the filename, use these options. - * The last one must be a printf format string with a %d and - * no other conversions specs. - * End list with a NULL. - */ - const char * initial_page_post_options[MAX_POST_PAGE_OPTIONS + 1]; /* */ -} pdf_viewer_t; - - -/* Reload commands (or prefixes thereof) */ -#define CTRL "Ctrl-" -#define ALT "Alt-" -#define CTRL_ALT "Ctrl-Alt-" -#define FN "Fn-" -#define FOCUS_IN "FOCUS-IN" -#define FOCUS_OUT "FOCUS-OUT" - - - -/* - * The first struct represents the default viewer with the default options. - */ -static -pdf_viewer_t pdf_viewers[] = -{ - {"ar9", "acroread", USE_SENDX, - AR9_WIN_NAME, AR9_WIN_NAME_FMT, - {"-openInNewInstance", NULL}, - {NULL}, - {"Ctrl-R", NULL}, - {"/a", "page=%d", NULL}, - {NULL} - }, - {"ar9-tab", "acroread", USE_SENDX, - AR9_WIN_NAME, AR9_WIN_NAME_FMT, - {NULL}, - {NULL}, - {"Ctrl-R", NULL}, - {NULL}, - {NULL} - }, - {"ar8", "acroread", USE_SENDX, - AR8_WIN_NAME, AR8_WIN_NAME_FMT, - {NULL}, - {NULL}, - {"Ctrl-W", FORK_EXEC_CMD, NULL}, - {NULL}, - {NULL} - }, - {"ar7", "acroread", USE_SENDX, - AR7_WIN_NAME, AR7_WIN_NAME_FMT, - {NULL}, - {NULL}, - {"Ctrl-W", "Alt-Left", NULL}, - {NULL}, - {NULL} - }, - {"ar5", "acroread", USE_SENDX, - AR5_WIN_NAME, AR5_WIN_NAME_FMT, - {NULL}, - {NULL}, - {"Ctrl-W", "Alt-Left", NULL}, - {NULL}, - {NULL} - }, - /* - * xpdf also allows 'xpdf -remote tex -reload', but if that xpdf server - * is not running, rather than a failure return, a blank window is - * opened. This is not much good to us. - * Using "tex-server" as the server name is an arbitrary choice. - */ - {"xpdf", "xpdf", USE_SENDX, - XPDF_WIN_NAME, XPDF_WIN_NAME_FMT, - {"-remote", "tex-server", NULL}, - {NULL}, - {"r", NULL}, - {NULL}, - {"%d", NULL} - }, - {"evince", "evince", USE_SENDX, - EVINCE_WIN_NAME, EVINCE_WIN_NAME_FMT, - {NULL}, - {NULL}, - {"Ctrl-R", NULL}, - {"-i", "%d", NULL}, - {NULL} - }, -#ifdef TRY_OCULAR - {"okular", "okular", USE_SENDX, - OKULAR_WIN_NAME, OKULAR_WIN_NAME_FMT, - {NULL}, - {NULL}, - {FOCUS_IN, "Fn-F5", FOCUS_OUT, NULL}, - {NULL}, - {NULL} - }, -#endif -}; - -#define DEFAULT_VIEWER (pdf_viewers[0].short_name) - - - -static void -usage(void) -{ - int i; - int viewers = sizeof(pdf_viewers) / sizeof(pdf_viewers[0]); - - fprintf(stderr, "This is version %s of %s.\n", VERSION, progname); - fprintf(stderr, "Usage:\n %s [-h|--help]\n", progname); - fprintf(stderr, " Show this help and exit.\n"); - - fprintf(stderr, " %s [-v|--version]\n", progname); - fprintf(stderr, " Show the version number and exit.\n"); - - fprintf(stderr, " %s [-r|--reset_focus] [-viewer ] [-p ] " - "\n", progname); - fprintf(stderr, " If the PDF viewer is displaying , " - "reload that file.\n"); - fprintf(stderr, " Otherwise call to display .\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, " If the viewer allows it and is not already\n"); - fprintf(stderr, " running, the argument of -p specifies the\n"); - fprintf(stderr, " first page to display.\n"); - fprintf(stderr, " The default viewer program is %s.\n", DEFAULT_VIEWER); - fprintf(stderr, " Implemented viewers:"); - for (i = 0; i < viewers - 1; i++) - fprintf(stderr, " '%s'", pdf_viewers[i].short_name); - fprintf(stderr, " and '%s'.\n", pdf_viewers[viewers - 1].short_name); - fprintf(stderr, " Note: ar9 uses acroread's -openInNewInstance argument," - " ar9-tab does not.\n"); -} - - - -/* - * Send one "command" to the given window. - * The command can be of these forms (for X an upper case letter or arrow - * key, such as "Left", and D one or more digits; see sendx.c): - * - Ctrl-X - * - Alt-X - * - Ctrl-Atl-X - * - Fn-FD - * - FOCUS-[IN|OUT] - * - (not starting with any of the above prefixes) - * Allow other variations on the cases of "Ctrl" and "Alt". - * - * Return 0 on success, non-0 otherwise. - */ - -static int -send_command(const char * window_name, const char * reload_cmd) -{ - int alt_len, ctrl_len, ctrl_alt_len, fn_len, focus_len; - - if (!strcmp(reload_cmd, FORK_EXEC_CMD)) - return 999; - - ctrl_alt_len = strlen(CTRL_ALT); - if (!strncasecmp(CTRL_ALT, reload_cmd, ctrl_alt_len)) - return sendx_controlalt_token(reload_cmd + ctrl_alt_len, window_name); - - ctrl_len = strlen(CTRL); - if (!strncasecmp(CTRL, reload_cmd, ctrl_len)) - return sendx_control_token(reload_cmd + ctrl_len, window_name); - - alt_len = strlen(ALT); - if (!strncasecmp(ALT, reload_cmd, alt_len)) - return sendx_alt_token(reload_cmd + alt_len, window_name); - - fn_len = strlen(FN); - if (!strncasecmp(FN, reload_cmd, fn_len)) - return sendx_token(reload_cmd + fn_len, window_name); - - focus_len = strlen(FOCUS_IN); - if (!strncasecmp(FOCUS_IN, reload_cmd, focus_len)) - return set_focus(window_name); - - focus_len = strlen(FOCUS_OUT); - if (!strncasecmp(FOCUS_OUT, reload_cmd, focus_len)) - return reset_focus(); - - return sendx_string(reload_cmd, window_name); -} - - - -/* - * 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, int focus_reset, - int initial_page) -{ - char * window_name; - pid_t pid; - int success = 0; - pdf_viewer_t pdf_viewer = pdf_viewers[viewer_index]; - const char ** reload_cmds = pdf_viewer.reload_cmds; - - /* First try to reload the file */ - switch (pdf_viewers[viewer_index].method) - { - case USE_SENDX: - 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) - { - /* - * Note: there is a race condition in the sendx.c code which - * can cause the program to crash and burn with a 'BadWindow' - * fault. This has been observed for AR8 (but not AR7, oddly) - * after the ^W causes AR8 to change the window name. It seems - * that Window_With_Name() tries to access a BadWindow within - * its recursive call. - * If this continues to be a problem, a usleep() may make the - * problem go away. - */ - success = ! send_command(window_name, *reload_cmds); - if (! success && reload_cmds != pdf_viewer.reload_cmds) - { - /* - * In some cases the window name might be changed because - * of the first command. - * For example, in AR7 the first command (^W) "closes" - * the document, and the window title changes to reflect - * the fact there is no document. So try that command with - * the "plain" window name. - */ - success = ! send_command(pdf_viewer.window_name, *reload_cmds); - } - if (! success) - break; - reload_cmds++; - } - if (focus_reset) - (void)reset_focus(); - break; - - case USE_FORK_EXEC: - return 2; /* TODO: someone who cares can put some code here */ - break; - - default: - fprintf(stderr, "%s: internal error: invalid reload_method. Sorry.\n", - progname); - return 99; - break; - } - - if (success) - return 0; - - /* - * No luck re-loading the file. - * (Try to) start a new instance of the viewer program. - */ - if ((pid = fork()) == 0) - { - const char * argv_list[2 * MAX_OPTIONS + 3]; - const char ** p; - int i = 0; - - argv_list[i++] = pdf_viewer.program_name; - for (p = pdf_viewer.exec_pre_options; *p;) - argv_list[i++] = *p++; - - if (pdf_viewer.initial_page_pre_options[0] != NULL) - { - int j = 0; - char * buf; - - while (pdf_viewer.initial_page_pre_options[j + 1] != NULL) - argv_list[i++] = pdf_viewer.initial_page_pre_options[j++]; - - /* 10 is more than enough for the page number */ - buf = malloc(strlen(pdf_viewer.initial_page_pre_options[j]) + 10); - if (buf != NULL) - { - /* 1e8 or more pages? I doubt it. */ - sprintf(buf, pdf_viewer.initial_page_pre_options[j], - initial_page > 99999999 ? 1 : initial_page); - argv_list[i++] = buf; - } - else - fprintf(stderr, "%s: unable to allocate memory for page " - "specification!!\n" - "Crossing fingers and continuing.", progname); - } - - argv_list[i++] = filename; - - if (pdf_viewer.initial_page_post_options[0] != NULL) - { - int j = 0; - char * buf; - - while (pdf_viewer.initial_page_post_options[j + 1] != NULL) - argv_list[i++] = pdf_viewer.initial_page_post_options[j++]; - - buf = malloc(strlen(pdf_viewer.initial_page_post_options[j]) + 10); - if (buf != NULL) - { - sprintf(buf, pdf_viewer.initial_page_post_options[j], - initial_page > 99999999 ? 1 : initial_page); - argv_list[i++] = buf; - } - else - fprintf(stderr, "%s: unable to allocate memory for page " - "specification!!\n" - "Crossing fingers and continuing.", progname); - } - - argv_list[i++] = NULL; -#ifdef DEBUG - { - int k = 0; - for (; k < i-1; k++) - fprintf(stderr, "%s\n", argv_list[k]); - } -#endif - if (execvp(pdf_viewer.program_name, (char **)argv_list)) - { - fprintf(stderr, "%s: %s startup failed\n", progname, - pdf_viewer.program_name); - return 5; - } - } - else if (pid < 0) - { - fprintf(stderr, "%s: fork() failed!?\n", progname); - return 10; - } - - return 0; -} - - - -int -main(int argc, char * argv[]) -{ - const char * viewer = pdf_viewers[0].short_name; - char * env_viewer; - int i; - int initial_page = 1; - int viewer_index = -1; - int focus_reset = 0; - - progname = argv[0]; - argc--; - argv++; - - env_viewer = getenv("PDF_VIEWER"); - if (env_viewer != NULL) - viewer = env_viewer; - - if (argc < 1 || !strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) - { - usage(); - return argc < 2 ? EXIT_FAILURE : EXIT_SUCCESS; - } - - if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--version")) - { - printf("This is pdfopen version %s\n", VERSION); - return EXIT_SUCCESS; - } - - while (argc > 0) - { - if (!strcmp(argv[0], "--reset_focus") || !strcmp(argv[0], "-r")) - { - argc--; - argv++; - focus_reset = 1; - continue; - } - - if (argc >= 2 && !strcmp(argv[0], "-viewer")) - { - viewer = argv[1]; - argc -= 2; - argv += 2; - continue; - } - - if (argc >= 2 && !strcmp(argv[0], "-p")) - { - initial_page = atoi(argv[1]); - argc -= 2; - argv += 2; - continue; - } - - break; - } - - /* Should only have 1 filename left now */ - if (argc != 1) - { - fprintf(stderr, "%s: invalid argument(s)\n", progname); - usage(); - return EXIT_FAILURE; - } - - for (i = 0; i < sizeof(pdf_viewers) / sizeof(pdf_viewers[0]); i++) - { - if (!strcmp(pdf_viewers[i].short_name, viewer)) - { - viewer_index = i; - break; - } - } - - if (viewer_index < 0) - { - fprintf(stderr, "%s: Unknown PDF viewer '%s'\n", progname, viewer); - usage(); - - return EXIT_FAILURE; - } - - if (view_file(argv[0], viewer_index, focus_reset, initial_page)) - return EXIT_FAILURE; - - return EXIT_SUCCESS; -} diff --git a/Build/source/utils/xpdfopen/sendx.c b/Build/source/utils/xpdfopen/sendx.c deleted file mode 100644 index a056279a48b..00000000000 --- a/Build/source/utils/xpdfopen/sendx.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Modified by Jim Diamond (jim.diamond@acadiau.ca) April 24, 2010 - * to reset error_status to 0 at the beginning of open_channel(). - * - * Also replaced 0xfff with KeyPressMask and KeyReleaseMask (as - * appropriate) in sendx_channel(); otherwise (at least in Slackware64 13.0) - * the events also get sent to the terminal running pdfopen; this is a Bad - * Thing. - * - * Also added set_focus() and reset_focus() functions. - * - * 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_() can - * explain why that makes sense, or why I need the sleep() and the - * XFlush(), I'd be happy to be enlightened. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "sendx.h" - -static char * display_name = NULL; -static Display * display; -static Window root; -static Window window = None; -static XKeyEvent event; - -static char error_message[256]; -static int error_status = 0; - - -static void -throw_exception3(const char * msg, const char * s, int i) -{ - sprintf(error_message, msg, s, i); - error_status = 1; -} - - -static void -throw_exception3s(const char * msg1, const char * msg2, const char * msg3) -{ - sprintf(error_message, msg1, msg2, msg3); - error_status = 1; -} - - -static void -throw_exception(const char * msg) -{ - strncpy(error_message, msg, 256); - error_status = 1; -} - - - -/* - * Added for window managers like swm and tvtwm that follow solbourne's - * virtual root window concept - */ -static Window -GetRootWindow(Display * disp, int scrn) -{ - Atom __SWM_VROOT = None; - Window root, rootReturn, parentReturn, * children; - unsigned int numChildren; - unsigned i; - - root = RootWindow(disp, scrn); - - /* - * see if there is a virtual root - */ - __SWM_VROOT = XInternAtom(disp, "__SWM_VROOT", False); - XQueryTree(disp, root, &rootReturn, &parentReturn, &children, &numChildren); - - for (i = 0; i < numChildren; i++) - { - Atom actual_type; - int actual_format; - unsigned long nitems, bytesafter; - unsigned char * prop_return = NULL; - - if (XGetWindowProperty(disp, children[i], __SWM_VROOT, 0, 1, - False, XA_WINDOW, &actual_type, &actual_format, - &nitems, &bytesafter, &prop_return) - == Success && prop_return) - { - root = *(Window *)prop_return; - break; - } - } - - if (children) - XFree((char *)children); - - return (root); -} - - - -/* - * [These functions are from the file "dsimple.c" used with xwininfo.] - * - * Written by Mark Lillibridge. Last updated 7/1/87 - * - * Window_With_Name: routine to locate a window with a given name on a - * display. If no window with the given name is found, 0 is returned. - * If more than one window has the given name, the first one found - * will be returned. Only top and its subwindows are looked at. - * Normally, top should be the Root Window. - */ - -static Window -Window_With_Name(Display * dpy, Window top, const char * name) -{ - Window * children, dummy; - unsigned int nchildren; - unsigned i; - Window w = 0; - char * window_name; - - if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name)) - return (top); - - if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren)) - return (0); - - for (i = 0; i < nchildren; i++) - { - w = Window_With_Name(dpy, children[i], name); - if (w) - break; - } - - if (children) - XFree((char *)children); - - return (w); -} - - - -static int -open_channel(const char * wname) -{ - /* - * display_name = ":0.0"; - */ - - error_status = 0; - - if ((display = XOpenDisplay(display_name)) == NULL) - { - throw_exception("can't open display"); - return 1; - } - - if ((root = GetRootWindow(display, DefaultScreen(display))) == 0) - { - throw_exception("Cannot get DefaultScreen"); - return 1; - } - - if ((wname[0] == '\0') && (window != None)) - { - } /* take selected window */ - else if (wname[0] != '\0') - { - if ((window = Window_With_Name(display, root, wname)) == None) - { - throw_exception3s("Display %s: can't open window named \"%s\"", - XDisplayName(display_name), wname); - return 1; - } - } - else - { - throw_exception3("bad condition in %s at line %d", __FILE__, __LINE__); - return 1; - } - - event.type = KeyPress; - event.serial = 0; - event.send_event = False; - event.display = display; - event.x = event.y = event.x_root = event.y_root = 0; - event.time = CurrentTime; - event.same_screen = True; - event.subwindow = None; - event.window = window; - event.root = root; - - return 0; -} - - - -static void -close_channel(void) -{ - /* - * XFlush(display); - */ - XCloseDisplay(display); -} - - - -static void -sendx_channel(KeySym ks, int km) -{ - /* - * km: 0=regular, 1=shift, 2=lock, 4=control - */ - if (ks < 256) - { - event.state = isupper((char)ks); - switch (ks) - { - case 0x08: - ks = XK_BackSpace; - break; - case 0x09: - ks = XK_Tab; - break; - case 0x0A: - ks = XK_Linefeed; - break; - case 0x0B: - ks = XK_Clear; - break; - case 0x0D: - ks = XK_Return; - break; - case 0x13: - ks = XK_Pause; - break; - case 0x14: - ks = XK_Scroll_Lock; - break; - case 0x1B: - ks = XK_Escape; - break; - } - } - else - event.state = 0; - - event.type = KeyPress; - event.state = km; // Mod1Mask - event.keycode = XKeysymToKeycode(display, ks); - - if (XSendEvent(display, window, True, KeyPressMask, (XEvent *)&event) == 0) - throw_exception("Error in XSendEvent"); - - event.type = KeyRelease; - if (XSendEvent(display, window, True, KeyReleaseMask, (XEvent *)&event) - == 0) - throw_exception("Error in XSendEvent"); - - return; -} - - - -int -sendx_string(const char * string, const char * window) -{ - const char * p; - - if (open_channel(window)) - return error_status; - - p = string; - while (*p) - sendx_channel(*p++, 0); - close_channel(); - - return error_status; -} - - - -int -sendx_token(const char * string, const char * window) -{ - if (open_channel(window)) - return error_status; - - sendx_channel(XStringToKeysym(string), 0); - close_channel(); - - return error_status; -} - - - -int -sendx_alt_token(const char * string, const char * window) -{ - if (open_channel(window)) - return error_status; - - sendx_channel(XStringToKeysym(string), Mod1Mask); - close_channel(); - - return error_status; -} - - - -int -sendx_controlalt_token(const char * string, const char * window) -{ - if (open_channel(window)) - return error_status; - - sendx_channel(XStringToKeysym(string), Mod1Mask | ControlMask); - close_channel(); - - return error_status; -} - - - -int -sendx_control_token(const char * string, const char * window) -{ - if (open_channel(window)) - return error_status; - - sendx_channel(XStringToKeysym(string), ControlMask); - close_channel(); - - return error_status; -} - - - - -static Window previous_window; -static int previous_window_set = 0; -static int revert_to; - -/* - * Attempt to give focus to the given window. - * Return 0 on success, non-0 on failure. - * Record the previous window for reset_focus() on success. - */ - -int -set_focus(const char * wname) -{ - if ((display = XOpenDisplay(display_name)) == NULL) - { - throw_exception("can't open display"); - return 1; - } - - if ((root = GetRootWindow(display, DefaultScreen(display))) == 0) - { - throw_exception("Cannot get DefaultScreen"); - return 1; - } - - (void)XGetInputFocus(display, &previous_window, &revert_to); - if (XSetInputFocus(display, Window_With_Name(display, root, wname), - previous_window, CurrentTime)) - { - previous_window_set = 1; - return 0; - } - - throw_exception3s("Display %s: can't focus window named \"%s\"", - XDisplayName(display_name), wname); - return 1; -} - - -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; - } - - throw_exception("reset_focus() called when previous window not saved"); - return 1; -} - - - -/* - * void PrintKeySyms () { int i; for (i = 32; i < 127; i++) { printf ("%s[%c] - * ", XKeysymToString (i), i); } for (i = 128 + 32; i < 128 + 127; i++) { - * printf ("%s[%c] ", XKeysymToString (i), i); } printf ("\n"); } - */ diff --git a/Build/source/utils/xpdfopen/sendx.h b/Build/source/utils/xpdfopen/sendx.h deleted file mode 100644 index 569a33f9494..00000000000 --- a/Build/source/utils/xpdfopen/sendx.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * sendx.h: declare prototypes for functions defined in sendx.c - * - * Copyright (C) 2009 Peter Breitenlohner - * You may freely use, modify and/or distribute this file. - */ - -#ifndef SENDX_H -#define SENDX_H - -extern int sendx_string(const char * string, const char * wname); -extern int sendx_token(const char * string, const char * wname); -extern int sendx_alt_token(const char * string, const char * wname); -extern int sendx_controlalt_token(const char * string, const char * wname); -extern int sendx_control_token(const char * string, const char * wname); -extern int set_focus(const char * wname); -extern int reset_focus(void); - -#endif diff --git a/Build/source/utils/xpdfopen/utils.c b/Build/source/utils/xpdfopen/utils.c deleted file mode 100644 index 5201b2dba58..00000000000 --- a/Build/source/utils/xpdfopen/utils.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * utils.c: Functions common to pdfopen and pdfclose. - * - * Copyright (C) 2010--2014 Jim Diamond - * You may freely use, modify and/or distribute this file. - */ - -#include -#include -#include -#include "utils.h" -#include "xpdfopen.h" -#include "externs.h" - -/* - * Allocate memory and create a window name. - * Return a pointer to the new string or NULL on failure. - * - * The caller is responsible for free()ing the memory allocated here. - * - * Note: acroread (at least AR 7, 8, 9) uses only the basename in the - * window title. - * xpdf uses the whole file name. - * Other PDF viewers may need other treatment. - */ - -char * -make_window_name(const char * fmt, const char * filename) -{ - char * window_name; - const char * title_name; - - title_name = filename; - if (strrchr(title_name, '/') != NULL - && strncasecmp(fmt, XPDF_WIN_NAME, strlen(XPDF_WIN_NAME))) - title_name = strrchr(title_name, '/') + 1; - - window_name = malloc(strlen(fmt) + strlen(title_name) + 1); - if (window_name != NULL) - sprintf(window_name, fmt, title_name); - else - fprintf(stderr, "%s: out of memory\n", progname); - - return window_name; -} diff --git a/Build/source/utils/xpdfopen/utils.h b/Build/source/utils/xpdfopen/utils.h deleted file mode 100644 index b9fe88574cb..00000000000 --- a/Build/source/utils/xpdfopen/utils.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * utils.h: declare prototypes for functions defined in utils.c - * - * Copyright (C) 2010--2014 Jim Diamond - * You may freely use, modify and/or distribute this file. - */ - -#ifndef UTILS_H -#define UTILS_H - -char * make_window_name(const char * fmt, const char * basename); - -#endif diff --git a/Build/source/utils/xpdfopen/version.ac b/Build/source/utils/xpdfopen/version.ac new file mode 100644 index 00000000000..9dbb748cd69 --- /dev/null +++ b/Build/source/utils/xpdfopen/version.ac @@ -0,0 +1,11 @@ +dnl +dnl Copyright (C) 2014 Peter Breitenlohner +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 +dnl -------------------------------------------------------- +dnl +dnl m4-include this file to define the current xpdfopen version +m4_define([xpdfopen_version], [0.86]) diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/ChangeLog b/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/ChangeLog new file mode 100644 index 00000000000..e040c3cf9f5 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/ChangeLog @@ -0,0 +1,16 @@ +2014-06-18 Peter Breitenlohner + + * patch-01-unsigned (new): Avoid undefined behavior. + +2014-05-28 Peter Breitenlohner + + Import xpdfopen-0.86. + +2014-05-24 Peter Breitenlohner + + Import xpdfopen-0.85. + +2014-05-17 Peter Breitenlohner + + Import xpdfopen-0.84. + diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/TL-Changes b/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/TL-Changes new file mode 100644 index 00000000000..e2b63b35229 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/TL-Changes @@ -0,0 +1,9 @@ +Changes applied to the xpdfopen-0.86/ tree as obtained from: + http://cs.acadiau.ca/~jdiamond/xpdfopen/xpdfopen-0.86.tar.gz + +Removed: + Makefile.in + aclocal.m4 + configure + pdfopen.pdf + diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/patch-01-unsigned b/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/patch-01-unsigned new file mode 100644 index 00000000000..7e4a4ceaa12 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86-PATCHES/patch-01-unsigned @@ -0,0 +1,14 @@ + Avoid undefined behavior when char is signed. + +diff -ur xpdfopen-0.86.orig/sendx.c xpdfopen-0.86/sendx.c +--- xpdfopen-0.86.orig/sendx.c 2012-01-28 01:39:39.000000000 +0100 ++++ xpdfopen-0.86/sendx.c 2014-06-18 08:13:50.000000000 +0200 +@@ -229,7 +229,7 @@ + */ + if (ks < 256) + { +- event.state = isupper((char)ks); ++ event.state = isupper((unsigned char)ks); + switch (ks) + { + case 0x08: diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/ChangeLog b/Build/source/utils/xpdfopen/xpdfopen-0.86/ChangeLog new file mode 100644 index 00000000000..5e22620685f --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/ChangeLog @@ -0,0 +1,136 @@ +2014-05-24 Jim Diamond + * pdfopen.c: fixed -g (goto named destination) option for AR9. + * README: update for V 0.86. + + +2014-05-22 Jim Diamond + + * pdfopen.c: add -g (goto named destination) option. + NOTE: notwithstanding the man page for AR 9.5.5 on + Linux, I can't get -g to work with AR9. + Allow use of '--file', '-V', '-?', '--page' and + '--goto' options for compatibility with (various and + sundry versions of) ms-windows pdfopen programs. + For consistency, add a '--viewer' form of that option, + but keep the '-viewer' form for backward compatibility. + Redo help text for all this. + * pdfclose.c allow use of '--file' option for compatibility + with ms-windows pdfclose program. + * pdfopen.1: update man page accordingly. + * README: updates for V 0.85. + + +2014-05-16 Jim Diamond + + * pdfopen.c: add -p option, update for externs.h + * pdfclose.c: update for externs.h + * utils.c: update for externs.h + * externs.h: add this for cleanliness + * pdfopen.1: update man page accordingly. + * xpdfopen.tex: remove from distribution, since it is now redundant + * configure.ac: update for V 0.84. + * README: update for V 0.84. + * Makefile.am update for externs.h, remove archaic pdfopen-AR-7-and-8.c + + +2012-01-28 Jim Diamond + + * 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 + + * pdfopen.c: add -v and --version options. + * pdfopen.1: create man page: thanks to Karl Berry for numerous + suggestions and improvements. + * pdfclose.1: add version number to usage information. + * configure.ac: update for V 0.82. + + +2011-05-17 Jim Diamond + + * pdfopen.c: add -h and --help options. + Reformat usage information. + Add support for evince. + Replace '-openInNewWindow' with '-openInNewInstance' + since AR9 claims the former is deprecated. + * xpdfopen.h: add support for evince. + * pdfclose.c: add support for evince. + * configure.ac: update for V 0.81. + + +2010-05-03 Jim Diamond + + * pdfclose.c: make it work with all of AR{5,7,8,9} and xpdf. + * pdfopen.c: add ability to parse and send function-keys. + Add code (commented out) in an attempt to + support okular (see code comments). + * sendx.c: add code (commented out) in an attempt to + support okular (see code comments). + * configure.ac: add changes suggested by Peter Breitenlohner. + + +2010-04-24 Jim Diamond + + * utils.[ch]: put a function to create window titles there + * xpdfopen.h: put constants related to the titles of various + PDF viewers there + * pdfclose.c: modify to use utils.c and xpdfopen.h + * pdfopen.c: major modifications so it works with AR7, AR8, AR9 + xpdf and maybe AR5, and so that it might be + relatively straightforward to add other PDF viewers. + The default viewer is AR9, this can be overridden + by an environment variable and a command-line + argument. + * sendx.c: Reset the error status in open_channel() so that an + error return doesn't become permanent. + Fixed mask param in XSendEvent(). + + +2010-04-21 Jim Diamond + + * pdfopen.c: Fold in some changes submitted by + Peter Breitenlohner + * pdfopen.c: Fold in some changes submitted by + Peter Breitenlohner + and reformat the code. + + +2010-04-11 Jim Diamond + + * pdfopen.c: Update (in a non-backward-compatible way) to + work with AR 9. Save old version in pdfopen-AR-7-and-8.c. + + +2009-08-22 Peter Breitenlohner + + Avoid maximal compiler warnings. + * pdfopen.c: Use strdup'ed literal string (malloc+strcpy) to + initialize non-constant string. + * sendx.[ch]: Constify string args of all functions. + Consistently use wname for window name string param. + (close_channel): ANSI C function definition. + + +2009-08-19 Peter Breitenlohner + + * Makefile.am (AM_CFLAGS), configure.ac: Enable compiler warnings. + * pdfopen.c (usage), pdfclose.c (usage): Declare as static. + + * sendx.h (new): Declare prototypes for functions in sendx.c. + * Makefile.am (pdfopen_SOURCES, pdfclose_SOURCES): Add sendx.h. + * pdfopen.c, pdfclose.c, sendx.c: #include "sendx.h". + + * sendx.c (GetRootWindow): Slightly reformulate to avoid compiler + warning (strict-aliasing rules). + + +2009-05-06 Peter Breitenlohner + + Adapt to TL2009 build system. + diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/Makefile.am b/Build/source/utils/xpdfopen/xpdfopen-0.86/Makefile.am new file mode 100644 index 00000000000..b41b46db6b7 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/Makefile.am @@ -0,0 +1,18 @@ + +AM_CFLAGS = $(X_CFLAGS) +## Add warnings for gcc-3.4 +AM_CFLAGS += -Wall -Wunused -Wimplicit -Wreturn-type +AM_CFLAGS += -Wdeclaration-after-statement -Wno-unknown-pragmas +AM_CFLAGS += -Wmissing-prototypes -Wmissing-declarations -Wparentheses +AM_CFLAGS += -Wswitch -Wtrigraphs -Wpointer-arith -Wcast-qual +AM_CFLAGS += -Wcast-align -Wwrite-strings -Wold-style-definition + +LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) + +bin_PROGRAMS = pdfopen pdfclose + +pdfopen_SOURCES = externs.h pdfopen.c sendx.c utils.c sendx.h xpdfopen.h utils.h + +pdfclose_SOURCES = externs.h pdfclose.c sendx.c utils.c sendx.h xpdfopen.h utils.h + + diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/README b/Build/source/utils/xpdfopen/xpdfopen-0.86/README new file mode 100644 index 00000000000..3c7d6ba0c58 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/README @@ -0,0 +1,115 @@ +--------------------------------------------------------------------------- +xpdfopen 0.86 - Send open/close commands to Acrobat Reader, xpdf and evince +--------------------------------------------------------------------------- + +This is a Linux (X11) implementation of Fabrice Popineau's pdfclose/ +pdfopen commands to control Acrobat Reader, xpdf and evince. + +The libX code was borrowed from Reinhard Fobbe's Sendx library for +Tcl/Tk, and the programs use the same license, copied below. + +Version 0.3 adds support for Adobe Reader 7.0 for Linux. + (different window titles and key shortcuts) + +Version 0.4 uses autoconf + +Version 0.5 fixes an incorrect autoconf variable, supports building + under X11R5, handles pathnames on the command-line, and + fixes a bug where pdfopen did not exit correctly after + (automatically) starting acroread. + +Version 0.51 uses the strrchr() function instead of rindex() + to allow compilation on non-BSD derived unix platforms. + +Version 0.61 attempts to do something useful with Adobe Reader 8, + even though it is impossible to restore the viewport. + +Version 0.80 adds an implementation for AR 9 and xpdf. + +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. + +Version 0.84 adds 'load at given page' support (-p option) for Adobe + Reader 9, evince (at least 3.12, maybe earlier) and xpdf. + +Version 0.85 adds 'load at named destination' support (-g/--goto option) + for xpdf, evince and (supposedly) AR9. The AR9 man page + claims it should work, but it doesn't for me. I left + the allegedly-correct code there anyway, in case it works + for other people in other places. + Also add aliases for option names to make ms-windows + users feel at home. + +Version 0.86 fixes 'load at named destination' for AR9. + + +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 [-r|-reset_focus] \ + [-viewer/--viewer ] \ + [-p/--page ] \ + [-g/--goto ] \ + [--file] + +The "ar9" version uses AR9's "-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). + + +pdfclose has the following call sequence: + pdfclose [--file] +This program closes an existing AR5, AR7, AR8, AR9, xpdf or evince window +displaying the given PDF file. + + +Version 0.85 compiles on Linux (Slackware64 14.1, anyway) with +the following command: + gcc -Wall pdfopen.c sendx.c utils.c -o pdfopen -lX11 -s + gcc -Wall pdfclose.c sendx.c utils.c -o pdfclose -lX11 -s +should you not want to go through the process of creating and running +a configure program. + + +Taco Hoekwater (Version(s) up to 0.61) +Dordrecht, The Netherlands, December 2008. + +Jim Diamond (Version 0.80 through 0.84) +Acadia University, Wolfville, Nova Scotia, Canada; May 2014. + + + + +License terms: +-------------- +The following terms apply to all files associated with the software +unless explicitly disclaimed in individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, +provided that existing copyright notices are retained in all copies +and that this notice is included verbatim in any distributions. No +written agreement, license, or royalty fee is required for any of the +authorized uses. Modifications to this software may be copyrighted by +their authors and need not follow the licensing terms described here, +provided that the new terms are clearly indicated on the first page of +each file where they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND +NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND +THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/configure.ac b/Build/source/utils/xpdfopen/xpdfopen-0.86/configure.ac new file mode 100644 index 00000000000..42f7b9a31bc --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/configure.ac @@ -0,0 +1,25 @@ +dnl Process this file with autoconf to produce a configure script. +dnl this is for autoconf 2.5x + +AC_INIT(pdfopen, 0.86, jim.diamond@acadiau.ca) + +AC_CONFIG_AUX_DIR(config) + +AM_INIT_AUTOMAKE() + +AC_CONFIG_FILES(Makefile) + +AC_PROG_CC + +dnl AC_PROG_INSTALL + +dnl Checks for header files. + +dnl Checks for typedefs, structures, and compiler characteristics. + +dnl Checks for library functions. + +dnl Find Xlibs. +AC_PATH_XTRA + +AC_OUTPUT diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/externs.h b/Build/source/utils/xpdfopen/xpdfopen-0.86/externs.h new file mode 100644 index 00000000000..2aff4f858ef --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/externs.h @@ -0,0 +1,24 @@ +/* + * externs.h: This file defines or declares (depending on whether + * DEFINE_EXTERNS is defined) all of the global variables + * and constants used by pdfopen and pdfclose. + * + * Copyright (C) 2014 Jim Diamond + * You may freely use, modify and/or distribute this file. + * + * This file new in Version 0.84 of pdfopen (2014/05/16). + */ + + +#ifndef EXTERNS_H +#define EXTERNS_H + +#ifdef DEFINE_EXTERNS +#define EXTERN +#else +#define EXTERN extern +#endif + +EXTERN char * progname; + +#endif diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfclose.c b/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfclose.c new file mode 100644 index 00000000000..95de13e79cc --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfclose.c @@ -0,0 +1,75 @@ +/* + * pdfclose.c: (attempt to) close a PDF viewer displaying argv[1]. + * + * Modified by Peter Breitenlohner (2009) + * and Jim Diamond (jim.diamond@acadiau.ca) 2010--2014 (V 0.80 -- 0.86). + * + * This program does not take a viewer argument, and just tries to close + * any known viewer displaying the given file. + */ + +#include +#include +#include +#include + +#include "sendx.h" +#include "xpdfopen.h" +#include "utils.h" + +#define DEFINE_EXTERNS +#include "externs.h" + +static void +usage(void) +{ + fprintf(stderr, "%s version %s\n", progname, VERSION); + fprintf(stderr, "Usage: %s [--file] \n", progname); +} + + + +static int +try_name(const char * filename, const char * title_format) +{ + char * winname; + int ret ; + + winname = make_window_name(title_format, filename); + if (winname == NULL) + return 99; + + ret = sendx_control_token("W", winname); + free(winname); + + return ret; +} + + + +int +main (int argc, char * argv[]) +{ + + progname = argv[0]; + + if (argc < 2 || argc > 3 || (argc == 3 && strcmp("--file", argv[1]))) + { + usage(); + return EXIT_FAILURE; + } + if (argc == 3) + { + argv++; + argc--; + } + + if (try_name(argv[1], AR9_WIN_NAME_FMT)) /* This gets both AR8 & AR9 */ + if (try_name(argv[1], XPDF_WIN_NAME_FMT)) + if (try_name(argv[1], AR7_WIN_NAME_FMT)) + if (try_name(argv[1], AR5_WIN_NAME_FMT)) + if (try_name(argv[1], EVINCE_WIN_NAME_FMT)) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.1 b/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.1 new file mode 100644 index 00000000000..23b8f84f61b --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.1 @@ -0,0 +1,166 @@ +.\" This manpage is licensed under the GNU Public License +.TH PDFOPEN 1 2014-05-24 "pdfopen 0.86" "" +. +.SH NAME +pdfopen, pdfclose \- open or close a PDF file viewer +. +.SH SYNOPSIS +.B pdfopen +[ \fIoptions\fP ]\ +[ +.B --file +]\ +\fIfile.pdf\fP +.br +.B pdfclose +[ +.B --file +]\ +\fIfile.pdf\fP +. +.SH OPTIONS +.TP 8 +.B -h, --help, -? +output help and exit. +.TP +.B -v, --version, -V +output the version number and exit. +.TP +.B -p , --page +when starting the viewer, display page of the document (notes: not +all viewers support this feature, and even in those cases this option +only has effect when the document is initially loaded). This option +is over-ridden by \fB-g\fP. +.TP +.B -g , --goto +when starting the viewer, display the page of the document containing +the named destination (notes: not all viewers support this feature, +and even in those cases this option only has effect when the document +is initially loaded). +.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, --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 +(in a new tab of a running AR9, if any), +Adobe Reader 8, Adobe Reader 7, Adobe Reader 5, xpdf or evince as the +PDF viewer program. +Adobe Reader 9 (in a new window) is the default. +. +.SH RATIONALE +At certain points of TeX document preparation, many people repeat a +"edit-compile-view" cycle. Since PDF viewers such as Adobe's Acrobat +Reader ("\fBacroread\fP") do not automatically refresh the display when the +PDF file changes, this cycle can be more cumbersome than desired. +The +.B pdfopen +program provides the ability to automate the reloading of the PDF +document when it is changed. + +Note: there seems to be little need for +.B pdfclose +under GNU/Linux, since (unlike the situation for MS windows) +.B acroread +does not lock the PDF file, which would prevent +.B pdftex +(or a DVI to PDF converter) from creating a new version of the PDF +output file. However, +.B pdfclose +is provided in case someone finds it useful. +. +.SH DESCRIPTION +.B pdfopen +searches for an instance of the specified (or default) PDF viewer +displaying the specified PDF file. +If there is already an instance of the given viewer displaying the +given file, the viewer is instructed to reload the file. If no such +instance is found, \fBpdfopen\fP attempts to run the specified viewer +on the specified document. + +The default viewer is "\fBacroread\fP", which could start any one +of a number of versions of Acrobat Reader, depending on what is +installed on your system. However, the commands to reload the current +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. + +This version 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. +.br +The difference between \fIar9\fP and \fIar9-tab\fP is significant +when there is no instance of AR9 already displaying the requested +document. In this situation, while \fIar9\fP will +request \fBacroread\fP to create a new instance of \fBacroread\fP +(and thus open a new window) by using the \fB-openInNewInstance\fP +argument, \fIar9-tab\fP starts \fBacroread\fP without this argument; +if there is already an instance of \fBacroread\fP running, a new +tab will be opened in an existing window. + +.B pdfclose +searches for one of the above PDF viewers displaying the given file +and instructs the viewer to "close" the window. In most cases, the +PDF viewer continues to run, possibly now displaying just a blank +window. (This behaviour varies somewhat from one PDF viewer to another.) +. +.SH PORTABILITY AND AVAILABILITY +These programs have been tested on Slackware64 Version 14.1 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 +if they come with robust fixes.) + +These programs are designed for X11-based systems. If you somehow +find compiled versions of these programs on a system using another +window system, they are very unlikely to be of any use to you. + +Source and binaries of the programs can be downloaded from +\f(CWCTAN://support/xpdfopen/\fR +(e.g., \f(CWhttp://mirror.ctan.org/support/xpdfopen\fR). +. +.SH CAVEATS +If you use +.I ar9-tab +to reload the PDF document and the instance +of +.B acroread +with the given document is currently displaying some other document, +the command causes your document to be displayed, but not reloaded. + +.B pdfopen +works by looking for a window with a name (window title) matching that +expected for the given viewer and document. If for some reason your +viewer's window name is not as expected, +.B pdfopen +may not work for you. + +With at least AR9 and some window managers, using +.B pdfopen +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. The \fB-reset_focus\fP option can be +used to deal with this problem. +. +.SH AUTHOR +This manual page was written by Jim Diamond <\f(CWJim.Diamond@acadiau.ca\fP>. +I am the current maintainer of the X11 versions of +.B pdfopen +and +\fBpdfclose\fP. +Report any bugs you find to me. Feature enhancement requests are +welcome, coded enhancements even more so. + +Past authors: +Fabrice Popineau wrote the MS-windows versions of +.B pdfopen +and +.B pdfclose +upon which these programs were originally based. +Taco Hoekwater created the GNU/Linux versions, up to Version 0.61 +(including some documentation which inspired parts of this man page). +Peter Breitenlohner has contributed both code and suggestions to +versions later than 0.61. diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.c b/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.c new file mode 100644 index 00000000000..664a4061663 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/pdfopen.c @@ -0,0 +1,681 @@ +/* + * pdfopen.c. + * + * Heavily modified by Jim Diamond (jim.diamond@acadiau.ca) 2010/04/11 + * to work with AR 9, xpdf and evince. + * (Also some mods by Peter Breitenlohner from 2009 + * and suggestions from 2010, and some suggestions from Karl Berry + * (2011).) + * + * Note 1: the calling sequence was changed considerably to match what + * the program actually seemed to do as well as what made sense to me. + * + * Note 2: if there are two instances of acroread displaying that file, + * only one is reloaded. + * + * Note 3: Unlike xpdf and AR[5,7,8,9], okular will not accept X events + * from this program unless the okular window has focus. On my system + * (Slackware64 13.0, using fvwm2), the functions I added to sendx.c to try + * to change the focus to the okular window do not work. (See also the + * comments in sendx.c.) If anyone cares to contribute working code, + * please send it to me for inclusion. + + * Further modified 2010/05/03 to work with ar5, and to include some code + * that does *not* work with okular (see note below). + * + * Modified 2014/05/16 (V 0.84) to add capability to open a pdf file + * at a specified page (currently working with AR9, xpdf and evince). + * + * Modified 2014/05/22 (V 0.85) to allow '--file' option, for + * "compatibility" with windows pdfopen/pdfclose calling sequence. + * Drive by: allow '--viewer' for consistency's sake. + * Also allow '-V', '-?' and '--page' for compatibility. + * Added --goto/-g option... this works in (at least) xpdf 3.03, + * evince 3.12.1. + * + * Modified 2014/05/24 (V 0.86) so that -g works in AR 9.5.5 and + * possibly other AR9 versions. + */ + +#include +#include +#include +#include +#include +#include + +#include "sendx.h" +#include "xpdfopen.h" +#include "utils.h" + +#define DEFINE_EXTERNS +#include "externs.h" + +#define MAX_RELOAD_CMDS 10 +#define MAX_PRE_PAGE_OPTIONS 2 /* See struct defn below */ +#define MAX_POST_PAGE_OPTIONS 1 /* See struct defn below */ +#define MAX_PRE_DEST_OPTIONS 2 /* See struct defn below */ +#define MAX_POST_DEST_OPTIONS 1 /* See struct defn below */ + /* Overkill ... */ +#define MAX_OPTIONS (10 + MAX_PRE_PAGE_OPTIONS \ + + MAX_POST_PAGE_OPTIONS + MAX_PRE_DEST_OPTIONS \ + + MAX_POST_DEST_OPTIONS) + +/* A string unlikely to be used as a real command by a PDF viewer */ +#define FORK_EXEC_CMD "*FORK EXEC*" + + +/* Used in the pdf_viewer_t type... see comment below */ +typedef enum +{ + USE_SENDX, USE_FORK_EXEC +} reload_method_t; + + +/* + * This struct contains the information needed for both + * (a) initially starting up a PDF viewer, and + * (b) telling the viewer to reload the document. + * Of course, the viewer has to support that functionality. + * Two possible ways are supported. + * (a) Send the viewer's window (a) simulated keypress(ss) + * (b) fork()/exec() a second instance of the program which somehow signals + * the running instance. Note that this is problematical if the + * arguments for the "reload" case are different than the options + * for the "start up the viewer" case, because the command-line + * (and environment variable) syntax have to be extended. + * Arguably, if both the start-up and reload can be done with shell + * commands, the user should just write a shell script and be done with + * it. + * These could be extended with this as well: + * (c) send a Unix signal to the currently running viewer. + * This would require augmenting reload_method_t and pdf_viewer_t. + */ + +typedef struct +{ + const char * short_name; /* cmd line option name */ + const char * program_name; /* program to exec() */ + reload_method_t method; /* method to induce reload */ + const char * window_name; /* when no file is viewed */ + const char * window_name_fmt; /* fmt string for file viewed */ + const char * exec_pre_options[MAX_OPTIONS]; /* before filename in cmd */ + const char * exec_post_options[MAX_OPTIONS];/* after filename in cmd */ + const char * reload_cmds[MAX_RELOAD_CMDS]; /* cmds to reload a file */ + /* + * If the page number goes before the filename, use these options. + * The last one must be a printf format string with a %d and + * no other conversions specs. + * End list with a NULL. + */ + const char * initial_page_pre_options[MAX_PRE_PAGE_OPTIONS + 1]; /* */ + /* + * If the page number goes after the filename, use these options. + * The last one must be a printf format string with a %d and + * no other conversions specs. + * End list with a NULL. + */ + const char * initial_page_post_options[MAX_POST_PAGE_OPTIONS + 1]; /* */ + /* Ditto for named destinations */ + const char * initial_dest_pre_options[MAX_PRE_DEST_OPTIONS + 1]; /* */ + const char * initial_dest_post_options[MAX_POST_DEST_OPTIONS + 1]; /* */ +} pdf_viewer_t; + + +/* Reload commands (or prefixes thereof) */ +#define CTRL "Ctrl-" +#define ALT "Alt-" +#define CTRL_ALT "Ctrl-Alt-" +#define FN "Fn-" +#define FOCUS_IN "FOCUS-IN" +#define FOCUS_OUT "FOCUS-OUT" + + + +/* + * The first struct represents the default viewer with the default options. + */ +static +pdf_viewer_t pdf_viewers[] = +{ + {"ar9", "acroread", USE_SENDX, + AR9_WIN_NAME, AR9_WIN_NAME_FMT, + {"-openInNewInstance", NULL}, + {NULL}, + {"Ctrl-R", NULL}, + {"/a", "page=%d", NULL}, + {NULL}, + {"/a", "nameddest=%s", NULL}, + {NULL} + }, + {"ar9-tab", "acroread", USE_SENDX, + AR9_WIN_NAME, AR9_WIN_NAME_FMT, + {NULL}, + {NULL}, + {"Ctrl-R", NULL}, + {"/a", "page=%d", NULL}, + {NULL}, + {"/a", "nameddest='%s'", NULL}, + {NULL} + }, + {"ar8", "acroread", USE_SENDX, + AR8_WIN_NAME, AR8_WIN_NAME_FMT, + {NULL}, + {NULL}, + {"Ctrl-W", FORK_EXEC_CMD, NULL}, + {NULL}, + {NULL}, + {NULL}, + {NULL} + }, + {"ar7", "acroread", USE_SENDX, + AR7_WIN_NAME, AR7_WIN_NAME_FMT, + {NULL}, + {NULL}, + {"Ctrl-W", "Alt-Left", NULL}, + {NULL}, + {NULL}, + {NULL}, + {NULL} + }, + {"ar5", "acroread", USE_SENDX, + AR5_WIN_NAME, AR5_WIN_NAME_FMT, + {NULL}, + {NULL}, + {"Ctrl-W", "Alt-Left", NULL}, + {NULL}, + {NULL}, + {NULL}, + {NULL} + }, + /* + * xpdf also allows 'xpdf -remote tex -reload', but if that xpdf server + * is not running, rather than a failure return, a blank window is + * opened. This is not much good to us. + * Using "tex-server" as the server name is an arbitrary choice. + */ + {"xpdf", "xpdf", USE_SENDX, + XPDF_WIN_NAME, XPDF_WIN_NAME_FMT, + {"-remote", "tex-server", NULL}, + {NULL}, + {"r", NULL}, + {NULL}, + {"%d", NULL}, + {NULL}, + {"+%s", NULL} + }, + {"evince", "evince", USE_SENDX, + EVINCE_WIN_NAME, EVINCE_WIN_NAME_FMT, + {NULL}, + {NULL}, + {"Ctrl-R", NULL}, + {"-i", "%d", NULL}, + {NULL}, + {"-n", "%s", NULL}, + {NULL} + }, +#ifdef TRY_OCULAR + {"okular", "okular", USE_SENDX, + OKULAR_WIN_NAME, OKULAR_WIN_NAME_FMT, + {NULL}, + {NULL}, + {FOCUS_IN, "Fn-F5", FOCUS_OUT, NULL}, + {NULL}, + {NULL}, + {NULL}, + {NULL} + }, +#endif +}; + +#define DEFAULT_VIEWER (pdf_viewers[0].short_name) + + + +static void +usage(void) +{ + int i; + int viewers = sizeof(pdf_viewers) / sizeof(pdf_viewers[0]); + + fprintf(stderr, "This is version %s of %s.\n", VERSION, progname); + fprintf(stderr, "Usage:\n %s [-h|--help|-?]\n" + " Show this help and exit.\n\n", progname); + fprintf(stderr, " %s [-v|--version]\n" + " Show the version number and exit.\n\n", progname); + fprintf(stderr, " %s [-r|--reset_focus] [[-]-viewer ]\n" + "\t\t[-p|--page ] [-g|--goto ] " + "[--file] \n", progname); + fprintf(stderr, " If the PDF viewer is displaying , " + "reload that file;\n" + " Otherwise call to display .\n" + " If '-r' or '--reset_focus' is used, attempt to " + "reset the input focus\n" + " after calling the viewer program.\n" + " If the viewer allows it and is not already " + "running, the argument\n of -p/--page specifies the " + "first page to display.\n" + " If the viewer allows it and is not already " + "running, the argument\n of -g/--goto specifies the " + "named destination to view.\n NOTE: -g overrides -p\n\n"); + fprintf(stderr, "The default viewer program is %s.\n", DEFAULT_VIEWER); + fprintf(stderr, "Implemented viewers:"); + for (i = 0; i < viewers - 1; i++) + fprintf(stderr, " '%s'", pdf_viewers[i].short_name); + fprintf(stderr, " and '%s'.\n", pdf_viewers[viewers - 1].short_name); + fprintf(stderr, "Note: ar9 uses acroread's -openInNewInstance argument," + " ar9-tab does not.\n"); +} + + + +/* + * Send one "command" to the given window. + * The command can be of these forms (for X an upper case letter or arrow + * key, such as "Left", and D one or more digits; see sendx.c): + * - Ctrl-X + * - Alt-X + * - Ctrl-Atl-X + * - Fn-FD + * - FOCUS-[IN|OUT] + * - (not starting with any of the above prefixes) + * Allow other variations on the cases of "Ctrl" and "Alt". + * + * Return 0 on success, non-0 otherwise. + */ + +static int +send_command(const char * window_name, const char * reload_cmd) +{ + int alt_len, ctrl_len, ctrl_alt_len, fn_len, focus_len; + + if (!strcmp(reload_cmd, FORK_EXEC_CMD)) + return 999; + + ctrl_alt_len = strlen(CTRL_ALT); + if (!strncasecmp(CTRL_ALT, reload_cmd, ctrl_alt_len)) + return sendx_controlalt_token(reload_cmd + ctrl_alt_len, window_name); + + ctrl_len = strlen(CTRL); + if (!strncasecmp(CTRL, reload_cmd, ctrl_len)) + return sendx_control_token(reload_cmd + ctrl_len, window_name); + + alt_len = strlen(ALT); + if (!strncasecmp(ALT, reload_cmd, alt_len)) + return sendx_alt_token(reload_cmd + alt_len, window_name); + + fn_len = strlen(FN); + if (!strncasecmp(FN, reload_cmd, fn_len)) + return sendx_token(reload_cmd + fn_len, window_name); + + focus_len = strlen(FOCUS_IN); + if (!strncasecmp(FOCUS_IN, reload_cmd, focus_len)) + return set_focus(window_name); + + focus_len = strlen(FOCUS_OUT); + if (!strncasecmp(FOCUS_OUT, reload_cmd, focus_len)) + return reset_focus(); + + return sendx_string(reload_cmd, window_name); +} + + + +/* + * reload_file(): Try to reload the given file. + * 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 +reload_file(const char * filename, int viewer_index, int focus_reset) +{ + int success = 0; + pdf_viewer_t pdf_viewer = pdf_viewers[viewer_index]; + const char ** reload_cmds = pdf_viewer.reload_cmds; + char * window_name; + + switch (pdf_viewers[viewer_index].method) + { + case USE_SENDX: + 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) + { + /* + * Note: there is a race condition in the sendx.c code which + * can cause the program to crash and burn with a 'BadWindow' + * fault. This has been observed for AR8 (but not AR7, oddly) + * after the ^W causes AR8 to change the window name. It seems + * that Window_With_Name() tries to access a BadWindow within + * its recursive call. + * If this continues to be a problem, a usleep() may make the + * problem go away. + */ + success = ! send_command(window_name, *reload_cmds); + if (! success && reload_cmds != pdf_viewer.reload_cmds) + { + /* + * In some cases the window name might be changed because + * of the first command. + * For example, in AR7 the first command (^W) "closes" + * the document, and the window title changes to reflect + * the fact there is no document. So try that command with + * the "plain" window name. + */ + success = ! send_command(pdf_viewer.window_name, *reload_cmds); + } + if (! success) + break; + reload_cmds++; + } + if (focus_reset) + (void)reset_focus(); + break; + + case USE_FORK_EXEC: + return 2; /* TODO: someone who cares can put some code here */ + break; + + default: + fprintf(stderr, "%s: internal error: invalid reload_method. Sorry.\n", + progname); + return 99; + break; + } + + if (success) + return 0; + + return 1; +} + +/* + * view_file(): (Attempt to) reload or view the given filename. + * + * First call reload_file() in case the given viewer is already + * displaying the given file. + * + * If that is unsuccessful, try to start up a new instance of the + * given viewer with the given file. + * + * If dest != NULL, and the viewer allows it, on initial opening of + * the file go to that named destination. + * As of V 0.85, this is implemented for xpdf, evince, and, according + * to the man page for acroread 9.5.5, for ar9. + * Otherwise, if the viewer allows it, open the document at the given + * page. + */ + +static int +view_file(const char * filename, int viewer_index, int focus_reset, + int initial_page, char * dest) +{ + pid_t pid; + pdf_viewer_t pdf_viewer = pdf_viewers[viewer_index]; + const char * argv_list[2 * MAX_OPTIONS + 3]; + const char ** p; + int i = 0; + + /* First try to reload the file */ + if (reload_file(filename, viewer_index, focus_reset) == 0) + { + /* Success! */ + return 0; + } + + /* + * No luck re-loading the file. + * (Try to) start a new instance of the viewer program. + * Start by forking into the background. + */ + pid = fork(); + if (pid < 0) + { + fprintf(stderr, "%s: fork() failed!?\n", progname); + return 10; + } + if (pid > 0) + return 0; + + /* Child code: */ + argv_list[i++] = pdf_viewer.program_name; + for (p = pdf_viewer.exec_pre_options; *p;) + argv_list[i++] = *p++; + + if (pdf_viewer.initial_page_pre_options[0] != NULL && dest == NULL) + { + int j = 0; + char * buf; + + while (pdf_viewer.initial_page_pre_options[j + 1] != NULL) + argv_list[i++] = pdf_viewer.initial_page_pre_options[j++]; + + /* 10 is more than enough for the page number */ + buf = malloc(strlen(pdf_viewer.initial_page_pre_options[j]) + 10); + if (buf != NULL) + { + /* 1e8 or more pages? I doubt it. */ + sprintf(buf, pdf_viewer.initial_page_pre_options[j], + initial_page > 99999999 ? 1 : initial_page); + argv_list[i++] = buf; + } + else + fprintf(stderr, "%s: unable to allocate memory for page " + "specification!!\n" + "Crossing fingers and continuing.", progname); + } + + if (pdf_viewer.initial_dest_pre_options[0] != NULL && dest != NULL) + { + int j = 0; + char * buf; + + while (pdf_viewer.initial_dest_pre_options[j + 1] != NULL) + argv_list[i++] = pdf_viewer.initial_dest_pre_options[j++]; + + buf = malloc(strlen(pdf_viewer.initial_dest_pre_options[j]) + + strlen(dest) + 1); + if (buf != NULL) + { + sprintf(buf, pdf_viewer.initial_dest_pre_options[j], dest); + argv_list[i++] = buf; + } + else + fprintf(stderr, "%s: unable to allocate memory for named-dest " + "specification!!\n" + "Crossing fingers and continuing.", progname); + } + + argv_list[i++] = filename; + + if (pdf_viewer.initial_page_post_options[0] != NULL && dest == NULL) + { + int j = 0; + char * buf; + + while (pdf_viewer.initial_page_post_options[j + 1] != NULL) + argv_list[i++] = pdf_viewer.initial_page_post_options[j++]; + + buf = malloc(strlen(pdf_viewer.initial_page_post_options[j]) + 10); + if (buf != NULL) + { + sprintf(buf, pdf_viewer.initial_page_post_options[j], + initial_page > 99999999 ? 1 : initial_page); + argv_list[i++] = buf; + } + else + fprintf(stderr, "%s: unable to allocate memory for page " + "specification!!\n" + "Crossing fingers and continuing.", progname); + } + + if (pdf_viewer.initial_dest_post_options[0] != NULL && dest != NULL) + { + int j = 0; + char * buf; + + while (pdf_viewer.initial_dest_post_options[j + 1] != NULL) + argv_list[i++] = pdf_viewer.initial_dest_post_options[j++]; + + buf = malloc(strlen(pdf_viewer.initial_dest_post_options[j]) + + strlen(dest) + 1); + if (buf != NULL) + { + sprintf(buf, pdf_viewer.initial_dest_post_options[j], dest); + argv_list[i++] = buf; + } + else + fprintf(stderr, "%s: unable to allocate memory for named-dest " + "specification!!\n" + "Crossing fingers and continuing.", progname); + } + + argv_list[i++] = NULL; +#ifdef DEBUG + { + int k = 0; + if (dest == NULL) + fprintf(stderr, "dest == NULL\n"); + else + fprintf(stderr, "dest == '%s'\n", dest); + for (; k < i-1; k++) + fprintf(stderr, "%s\n", argv_list[k]); + } +#endif + execvp(pdf_viewer.program_name, (char **)argv_list); + + /* If we are here, Something Bad happened. */ + fprintf(stderr, "%s: %s startup failed\n", progname, + pdf_viewer.program_name); + return 5; +} + + + +int +main(int argc, char * argv[]) +{ + const char * viewer = pdf_viewers[0].short_name; + char * env_viewer; + char * file = NULL; + char * dest = NULL; + int i; + int initial_page = 1; + int viewer_index = -1; + int focus_reset = 0; + + progname = argv[0]; + argc--; + argv++; + + env_viewer = getenv("PDF_VIEWER"); + if (env_viewer != NULL) + viewer = env_viewer; + + if (argc < 1 || !strcmp(argv[0], "-h") || !strcmp(argv[0], "--help") + || !strcmp(argv[0], "-?")) + { + usage(); + return argc < 1 ? EXIT_FAILURE : EXIT_SUCCESS; + } + + if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "-V") + || !strcmp(argv[0], "--version")) + { + printf("This is pdfopen version %s\n", VERSION); + return EXIT_SUCCESS; + } + + while (argc > 0) + { + if (!strcmp(argv[0], "--reset_focus") || !strcmp(argv[0], "-r")) + { + argc--; + argv++; + focus_reset = 1; + continue; + } + + if (argc >= 2 + && (!strcmp(argv[0], "-viewer") || !strcmp(argv[0], "--viewer"))) + { + viewer = argv[1]; + argc -= 2; + argv += 2; + continue; + } + + if (argc >= 2 + && (!strcmp(argv[0], "-g") || !strcmp(argv[0], "--goto"))) + { + dest = argv[1]; + argc -= 2; + argv += 2; + continue; + } + + if (argc >= 2 && !strcmp(argv[0], "--file")) + { + file = argv[1]; + argc -= 2; + argv += 2; + continue; + } + + if (argc >= 2 + && (!strcmp(argv[0], "-p") || !strcmp(argv[0], "--page"))) + { + initial_page = atoi(argv[1]); + argc -= 2; + argv += 2; + continue; + } + + break; + } + + /* + * Should either have no args left (--file seen above) or + * --file was not seen and there is one arg left. + */ + if ( ! ((argc == 0 && file != NULL) || (argc == 1 && file == NULL)) ) + { + fprintf(stderr, "%s: invalid argument(s)\n", progname); + usage(); + return EXIT_FAILURE; + } + + if (argc == 1) + file = argv[0]; + + for (i = 0; i < sizeof(pdf_viewers) / sizeof(pdf_viewers[0]); i++) + { + if (!strcmp(pdf_viewers[i].short_name, viewer)) + { + viewer_index = i; + break; + } + } + + if (viewer_index < 0) + { + fprintf(stderr, "%s: Unknown PDF viewer '%s'\n", progname, viewer); + usage(); + + return EXIT_FAILURE; + } + + if (view_file(file, viewer_index, focus_reset, initial_page, dest)) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.c b/Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.c new file mode 100644 index 00000000000..1fd4f0dbdc6 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.c @@ -0,0 +1,424 @@ +/* + * Modified by Jim Diamond (jim.diamond@acadiau.ca) April 24, 2010 + * to reset error_status to 0 at the beginning of open_channel(). + * + * Also replaced 0xfff with KeyPressMask and KeyReleaseMask (as + * appropriate) in sendx_channel(); otherwise (at least in Slackware64 13.0) + * the events also get sent to the terminal running pdfopen; this is a Bad + * Thing. + * + * Also added set_focus() and reset_focus() functions. + * + * 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_() can + * explain why that makes sense, or why I need the sleep() and the + * XFlush(), I'd be happy to be enlightened. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "sendx.h" + +static char * display_name = NULL; +static Display * display; +static Window root; +static Window window = None; +static XKeyEvent event; + +static char error_message[256]; +static int error_status = 0; + + +static void +throw_exception3(const char * msg, const char * s, int i) +{ + sprintf(error_message, msg, s, i); + error_status = 1; +} + + +static void +throw_exception3s(const char * msg1, const char * msg2, const char * msg3) +{ + sprintf(error_message, msg1, msg2, msg3); + error_status = 1; +} + + +static void +throw_exception(const char * msg) +{ + strncpy(error_message, msg, 256); + error_status = 1; +} + + + +/* + * Added for window managers like swm and tvtwm that follow solbourne's + * virtual root window concept + */ +static Window +GetRootWindow(Display * disp, int scrn) +{ + Atom __SWM_VROOT = None; + Window root, rootReturn, parentReturn, * children; + unsigned int numChildren; + unsigned i; + + root = RootWindow(disp, scrn); + + /* + * see if there is a virtual root + */ + __SWM_VROOT = XInternAtom(disp, "__SWM_VROOT", False); + XQueryTree(disp, root, &rootReturn, &parentReturn, &children, &numChildren); + + for (i = 0; i < numChildren; i++) + { + Atom actual_type; + int actual_format; + unsigned long nitems, bytesafter; + unsigned char * prop_return = NULL; + + if (XGetWindowProperty(disp, children[i], __SWM_VROOT, 0, 1, + False, XA_WINDOW, &actual_type, &actual_format, + &nitems, &bytesafter, &prop_return) + == Success && prop_return) + { + root = *(Window *)prop_return; + break; + } + } + + if (children) + XFree((char *)children); + + return (root); +} + + + +/* + * [These functions are from the file "dsimple.c" used with xwininfo.] + * + * Written by Mark Lillibridge. Last updated 7/1/87 + * + * Window_With_Name: routine to locate a window with a given name on a + * display. If no window with the given name is found, 0 is returned. + * If more than one window has the given name, the first one found + * will be returned. Only top and its subwindows are looked at. + * Normally, top should be the Root Window. + */ + +static Window +Window_With_Name(Display * dpy, Window top, const char * name) +{ + Window * children, dummy; + unsigned int nchildren; + unsigned i; + Window w = 0; + char * window_name; + + if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name)) + return (top); + + if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren)) + return (0); + + for (i = 0; i < nchildren; i++) + { + w = Window_With_Name(dpy, children[i], name); + if (w) + break; + } + + if (children) + XFree((char *)children); + + return (w); +} + + + +static int +open_channel(const char * wname) +{ + /* + * display_name = ":0.0"; + */ + + error_status = 0; + + if ((display = XOpenDisplay(display_name)) == NULL) + { + throw_exception("can't open display"); + return 1; + } + + if ((root = GetRootWindow(display, DefaultScreen(display))) == 0) + { + throw_exception("Cannot get DefaultScreen"); + return 1; + } + + if ((wname[0] == '\0') && (window != None)) + { + } /* take selected window */ + else if (wname[0] != '\0') + { + if ((window = Window_With_Name(display, root, wname)) == None) + { + throw_exception3s("Display %s: can't open window named \"%s\"", + XDisplayName(display_name), wname); + return 1; + } + } + else + { + throw_exception3("bad condition in %s at line %d", __FILE__, __LINE__); + return 1; + } + + event.type = KeyPress; + event.serial = 0; + event.send_event = False; + event.display = display; + event.x = event.y = event.x_root = event.y_root = 0; + event.time = CurrentTime; + event.same_screen = True; + event.subwindow = None; + event.window = window; + event.root = root; + + return 0; +} + + + +static void +close_channel(void) +{ + /* + * XFlush(display); + */ + XCloseDisplay(display); +} + + + +static void +sendx_channel(KeySym ks, int km) +{ + /* + * km: 0=regular, 1=shift, 2=lock, 4=control + */ + if (ks < 256) + { + event.state = isupper((unsigned char)ks); + switch (ks) + { + case 0x08: + ks = XK_BackSpace; + break; + case 0x09: + ks = XK_Tab; + break; + case 0x0A: + ks = XK_Linefeed; + break; + case 0x0B: + ks = XK_Clear; + break; + case 0x0D: + ks = XK_Return; + break; + case 0x13: + ks = XK_Pause; + break; + case 0x14: + ks = XK_Scroll_Lock; + break; + case 0x1B: + ks = XK_Escape; + break; + } + } + else + event.state = 0; + + event.type = KeyPress; + event.state = km; // Mod1Mask + event.keycode = XKeysymToKeycode(display, ks); + + if (XSendEvent(display, window, True, KeyPressMask, (XEvent *)&event) == 0) + throw_exception("Error in XSendEvent"); + + event.type = KeyRelease; + if (XSendEvent(display, window, True, KeyReleaseMask, (XEvent *)&event) + == 0) + throw_exception("Error in XSendEvent"); + + return; +} + + + +int +sendx_string(const char * string, const char * window) +{ + const char * p; + + if (open_channel(window)) + return error_status; + + p = string; + while (*p) + sendx_channel(*p++, 0); + close_channel(); + + return error_status; +} + + + +int +sendx_token(const char * string, const char * window) +{ + if (open_channel(window)) + return error_status; + + sendx_channel(XStringToKeysym(string), 0); + close_channel(); + + return error_status; +} + + + +int +sendx_alt_token(const char * string, const char * window) +{ + if (open_channel(window)) + return error_status; + + sendx_channel(XStringToKeysym(string), Mod1Mask); + close_channel(); + + return error_status; +} + + + +int +sendx_controlalt_token(const char * string, const char * window) +{ + if (open_channel(window)) + return error_status; + + sendx_channel(XStringToKeysym(string), Mod1Mask | ControlMask); + close_channel(); + + return error_status; +} + + + +int +sendx_control_token(const char * string, const char * window) +{ + if (open_channel(window)) + return error_status; + + sendx_channel(XStringToKeysym(string), ControlMask); + close_channel(); + + return error_status; +} + + + + +static Window previous_window; +static int previous_window_set = 0; +static int revert_to; + +/* + * Attempt to give focus to the given window. + * Return 0 on success, non-0 on failure. + * Record the previous window for reset_focus() on success. + */ + +int +set_focus(const char * wname) +{ + if ((display = XOpenDisplay(display_name)) == NULL) + { + throw_exception("can't open display"); + return 1; + } + + if ((root = GetRootWindow(display, DefaultScreen(display))) == 0) + { + throw_exception("Cannot get DefaultScreen"); + return 1; + } + + (void)XGetInputFocus(display, &previous_window, &revert_to); + if (XSetInputFocus(display, Window_With_Name(display, root, wname), + previous_window, CurrentTime)) + { + previous_window_set = 1; + return 0; + } + + throw_exception3s("Display %s: can't focus window named \"%s\"", + XDisplayName(display_name), wname); + return 1; +} + + + +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; + } + + throw_exception("reset_focus() called when previous window not saved"); + return 1; +} + + + +/* + * void PrintKeySyms () { int i; for (i = 32; i < 127; i++) { printf ("%s[%c] + * ", XKeysymToString (i), i); } for (i = 128 + 32; i < 128 + 127; i++) { + * printf ("%s[%c] ", XKeysymToString (i), i); } printf ("\n"); } + */ diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.h b/Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.h new file mode 100644 index 00000000000..569a33f9494 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/sendx.h @@ -0,0 +1,19 @@ +/* + * sendx.h: declare prototypes for functions defined in sendx.c + * + * Copyright (C) 2009 Peter Breitenlohner + * You may freely use, modify and/or distribute this file. + */ + +#ifndef SENDX_H +#define SENDX_H + +extern int sendx_string(const char * string, const char * wname); +extern int sendx_token(const char * string, const char * wname); +extern int sendx_alt_token(const char * string, const char * wname); +extern int sendx_controlalt_token(const char * string, const char * wname); +extern int sendx_control_token(const char * string, const char * wname); +extern int set_focus(const char * wname); +extern int reset_focus(void); + +#endif diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/utils.c b/Build/source/utils/xpdfopen/xpdfopen-0.86/utils.c new file mode 100644 index 00000000000..5201b2dba58 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/utils.c @@ -0,0 +1,45 @@ +/* + * utils.c: Functions common to pdfopen and pdfclose. + * + * Copyright (C) 2010--2014 Jim Diamond + * You may freely use, modify and/or distribute this file. + */ + +#include +#include +#include +#include "utils.h" +#include "xpdfopen.h" +#include "externs.h" + +/* + * Allocate memory and create a window name. + * Return a pointer to the new string or NULL on failure. + * + * The caller is responsible for free()ing the memory allocated here. + * + * Note: acroread (at least AR 7, 8, 9) uses only the basename in the + * window title. + * xpdf uses the whole file name. + * Other PDF viewers may need other treatment. + */ + +char * +make_window_name(const char * fmt, const char * filename) +{ + char * window_name; + const char * title_name; + + title_name = filename; + if (strrchr(title_name, '/') != NULL + && strncasecmp(fmt, XPDF_WIN_NAME, strlen(XPDF_WIN_NAME))) + title_name = strrchr(title_name, '/') + 1; + + window_name = malloc(strlen(fmt) + strlen(title_name) + 1); + if (window_name != NULL) + sprintf(window_name, fmt, title_name); + else + fprintf(stderr, "%s: out of memory\n", progname); + + return window_name; +} diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/utils.h b/Build/source/utils/xpdfopen/xpdfopen-0.86/utils.h new file mode 100644 index 00000000000..b9fe88574cb --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/utils.h @@ -0,0 +1,13 @@ +/* + * utils.h: declare prototypes for functions defined in utils.c + * + * Copyright (C) 2010--2014 Jim Diamond + * You may freely use, modify and/or distribute this file. + */ + +#ifndef UTILS_H +#define UTILS_H + +char * make_window_name(const char * fmt, const char * basename); + +#endif diff --git a/Build/source/utils/xpdfopen/xpdfopen-0.86/xpdfopen.h b/Build/source/utils/xpdfopen/xpdfopen-0.86/xpdfopen.h new file mode 100644 index 00000000000..bd40be932c8 --- /dev/null +++ b/Build/source/utils/xpdfopen/xpdfopen-0.86/xpdfopen.h @@ -0,0 +1,41 @@ +/* + * xpdfopen.h: declare constants of possible use for xpdfopen programs. + * + * Copyright (C) 2010--2014 Jim Diamond + * + * You may freely use, modify and/or distribute this file. + */ + +#ifndef XPDFOPEN_H +#define XPDFOPEN_H + +#define VERSION "0.86" + +/* + * _WIN_NAME is the name of the window when no file is open. + * _WIN_NAME_FMT is the (sprintf) format to generate the name + * when a file is being displayed. + */ + +#define AR5_WIN_NAME "Acrobat Reader" /* Is this correct? */ +#define AR5_WIN_NAME_FMT "%s" /* Is this correct? */ + +#define AR7_WIN_NAME "Adobe Reader" +#define AR7_WIN_NAME_FMT AR7_WIN_NAME " - %s" + +#define AR8_WIN_NAME "Adobe Reader" +#define AR8_WIN_NAME_FMT "%s - " AR8_WIN_NAME + +#define AR9_WIN_NAME "Adobe Reader" +#define AR9_WIN_NAME_FMT "%s - " AR9_WIN_NAME + +#define XPDF_WIN_NAME "Xpdf" +#define XPDF_WIN_NAME_FMT XPDF_WIN_NAME ": %s" + +#define EVINCE_WIN_NAME "evince" +#define EVINCE_WIN_NAME_FMT "%s" + +#define OKULAR_WIN_NAME "Okular" +#define OKULAR_WIN_NAME_FMT "%s - " OKULAR_WIN_NAME + +#endif diff --git a/Build/source/utils/xpdfopen/xpdfopen.h b/Build/source/utils/xpdfopen/xpdfopen.h deleted file mode 100644 index cf7e4f8c3f6..00000000000 --- a/Build/source/utils/xpdfopen/xpdfopen.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * xpdfopen.h: declare constants of possible use for xpdfopen programs. - * - * Copyright (C) 2010--2014 Jim Diamond - * - * You may freely use, modify and/or distribute this file. - */ - -#ifndef XPDFOPEN_H -#define XPDFOPEN_H - -#define VERSION "0.84" - -/* - * _WIN_NAME is the name of the window when no file is open. - * _WIN_NAME_FMT is the (sprintf) format to generate the name - * when a file is being displayed. - */ - -#define AR5_WIN_NAME "Acrobat Reader" /* Is this correct? */ -#define AR5_WIN_NAME_FMT "%s" /* Is this correct? */ - -#define AR7_WIN_NAME "Adobe Reader" -#define AR7_WIN_NAME_FMT AR7_WIN_NAME " - %s" - -#define AR8_WIN_NAME "Adobe Reader" -#define AR8_WIN_NAME_FMT "%s - " AR8_WIN_NAME - -#define AR9_WIN_NAME "Adobe Reader" -#define AR9_WIN_NAME_FMT "%s - " AR9_WIN_NAME - -#define XPDF_WIN_NAME "Xpdf" -#define XPDF_WIN_NAME_FMT XPDF_WIN_NAME ": %s" - -#define EVINCE_WIN_NAME "evince" -#define EVINCE_WIN_NAME_FMT "%s" - -#define OKULAR_WIN_NAME "Okular" -#define OKULAR_WIN_NAME_FMT "%s - " OKULAR_WIN_NAME - -#endif -- cgit v1.2.3