summaryrefslogtreecommitdiff
path: root/libstroke
diff options
context:
space:
mode:
Diffstat (limited to 'libstroke')
-rw-r--r--libstroke/Makefile.am48
-rw-r--r--libstroke/Makefile.in412
-rw-r--r--libstroke/stroke.c395
-rw-r--r--libstroke/stroke.h40
4 files changed, 895 insertions, 0 deletions
diff --git a/libstroke/Makefile.am b/libstroke/Makefile.am
new file mode 100644
index 0000000..30798a8
--- /dev/null
+++ b/libstroke/Makefile.am
@@ -0,0 +1,48 @@
+# A brief demonstration of using Automake with Libtool. -*-Makefile-*-
+#
+# NOTE: Don't forget that in the libtool distribution, files in this
+# directory are distributed by the demo_distfiles variable in the top
+# level Makefile.
+AUTOMAKE_OPTIONS = foreign
+
+EXTRA_DIST =
+
+#tclpath::
+ #echo ${ENABLE_TCL}
+
+#if ENABLE_TCL
+#SEL_BIB = libstroke.la libstroke_tcl.la
+#else
+#SEL_BIB = libstroke.la
+#endif
+#
+#SEL_FIB =
+#if ENABLE_TCL
+#libstroke_tcl_la_SOURCES = tcl.c stroke.c
+#SEL_FIB = libstroke_tcl.la
+#endif
+#SEL_FIB = $(SEL_FIB) libstroke.la
+#
+#lib_LTLIBRARIES = $(SEL_FIB)
+
+lib_LTLIBRARIES = libstroke.la
+#libstroke_tcl_la_LDFLAGS = -ltcl -version-info 0:5:0
+libstroke_la_SOURCES = stroke.c stroke.h
+
+libstroke_la_LDFLAGS = -version-info 0:5:0
+
+include_HEADERS = stroke.h
+
+INCLUDES = -I$(top_srcdir)/libstroke @X_CFLAGS@
+
+EXTRA_DIST =
+
+MOSTLYCLEANFILES = core *~
+CLEANFILES = core *~
+DISTCLEANFILES = core *~
+MAINTAINERCLEANFILES = core *~
+
+# Unfortunately, in order to test libtool thoroughly, we need access
+# to its private directory.
+objdir = `sed -n -e 's/^objdir=\"\(.*\)\"$$/\1/p' ./libtool`
+
diff --git a/libstroke/Makefile.in b/libstroke/Makefile.in
new file mode 100644
index 0000000..1850b84
--- /dev/null
+++ b/libstroke/Makefile.in
@@ -0,0 +1,412 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# A brief demonstration of using Automake with Libtool. -*-Makefile-*-
+#
+# NOTE: Don't forget that in the libtool distribution, files in this
+# directory are distributed by the demo_distfiles variable in the top
+# level Makefile.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+AS = @AS@
+CC = @CC@
+DLLTOOL = @DLLTOOL@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_CONFIG = @GTK_CONFIG@
+GTK_LIBS = @GTK_LIBS@
+LD = @LD@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+NM = @NM@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
+VERSION = @VERSION@
+X_CFLAGS = @X_CFLAGS@
+X_LDFLAGS = @X_LDFLAGS@
+
+AUTOMAKE_OPTIONS = foreign
+
+EXTRA_DIST =
+
+#if ENABLE_TCL
+#SEL_BIB = libstroke.la libstroke_tcl.la
+#else
+#SEL_BIB = libstroke.la
+#endif
+#
+#SEL_FIB =
+#if ENABLE_TCL
+#libstroke_tcl_la_SOURCES = tcl.c stroke.c
+#SEL_FIB = libstroke_tcl.la
+#endif
+#SEL_FIB = $(SEL_FIB) libstroke.la
+#
+#lib_LTLIBRARIES = $(SEL_FIB)
+
+lib_LTLIBRARIES = libstroke.la
+#libstroke_tcl_la_LDFLAGS = -ltcl -version-info 0:5:0
+libstroke_la_SOURCES = stroke.c stroke.h
+
+libstroke_la_LDFLAGS = -version-info 0:5:0
+
+include_HEADERS = stroke.h
+
+INCLUDES = -I$(top_srcdir)/libstroke @X_CFLAGS@
+
+MOSTLYCLEANFILES = core *~
+CLEANFILES = core *~
+DISTCLEANFILES = core *~
+MAINTAINERCLEANFILES = core *~
+
+# Unfortunately, in order to test libtool thoroughly, we need access
+# to its private directory.
+objdir = `sed -n -e 's/^objdir=\"\(.*\)\"$$/\1/p' ./libtool`
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(lib_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+libstroke_la_LIBADD =
+libstroke_la_OBJECTS = stroke.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+HEADERS = $(include_HEADERS)
+
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+DEP_FILES = .deps/stroke.P
+SOURCES = $(libstroke_la_SOURCES)
+OBJECTS = $(libstroke_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --foreign libstroke/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-libLTLIBRARIES:
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+
+distclean-libLTLIBRARIES:
+
+maintainer-clean-libLTLIBRARIES:
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+libstroke.la: $(libstroke_la_OBJECTS) $(libstroke_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libstroke_la_LDFLAGS) $(libstroke_la_OBJECTS) $(libstroke_la_LIBADD) $(LIBS)
+
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(includedir)
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
+ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
+ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
+ done
+
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ list='$(include_HEADERS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(includedir)/$$p; \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = libstroke
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign libstroke/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-libLTLIBRARIES
+install-exec: install-exec-am
+
+install-data-am: install-includeHEADERS
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS
+uninstall: uninstall-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
+
+
+mostlyclean-generic:
+ -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
+ clean-depend clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-libLTLIBRARIES distclean-compile \
+ distclean-libtool distclean-tags distclean-depend \
+ distclean-generic clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-depend \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
+clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
+uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
+distclean-compile clean-compile maintainer-clean-compile \
+mostlyclean-libtool distclean-libtool clean-libtool \
+maintainer-clean-libtool uninstall-includeHEADERS \
+install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
+maintainer-clean-tags distdir mostlyclean-depend distclean-depend \
+clean-depend maintainer-clean-depend info-am info dvi-am dvi check \
+check-am installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+#tclpath::
+ #echo ${ENABLE_TCL}
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libstroke/stroke.c b/libstroke/stroke.c
new file mode 100644
index 0000000..4fccd01
--- /dev/null
+++ b/libstroke/stroke.c
@@ -0,0 +1,395 @@
+/*
+ libstroke - an X11 stroke interface library
+ Copyright (c) 1996,1997,1998,1999 Mark F. Willey, ETLA Technical
+
+ See the files COPYRIGHT and LICENSE for distribution information.
+*/
+
+#include "config.h"
+#include "stroke.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#ifdef STROKE_MOUSE_FOOTPRINTS
+#include <X11/Xutil.h>
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+
+/* structure for holding point data */
+typedef struct s_point *p_point;
+
+static struct s_point {
+ int x;
+ int y;
+ p_point next;
+} point;
+
+/* point list head and tail */
+static p_point point_list_head;
+static p_point point_list_tail;
+
+
+
+/* determine which bin a point falls in */
+static int stroke_bin (p_point point_p, int bound_x_1, int bound_x_2,
+ int bound_y_1, int bound_y_2);
+
+
+
+/* point list head and tail */
+static p_point point_list_head=NULL;
+static p_point point_list_tail=NULL;
+
+/* metrics fo input stroke */
+static int min_x = 10000;
+static int min_y = 10000;
+static int max_x = -1;
+static int max_y = -1;
+static int point_count = 0;
+
+#ifdef STROKE_MOUSE_FOOTPRINTS
+/*FIXME: Maybe these should be put in a structure, and not static...*/
+static Display * stroke_disp;
+static Window stroke_window;
+static GC stroke_gc;
+
+static int use_mouse_footprints; /* True if using mouse footprints */
+#endif
+
+static void init_stroke_data (void)
+{
+ while (point_list_head != NULL) {
+ point_list_tail = point_list_head;
+ point_list_head = point_list_head->next;
+ free (point_list_tail);
+ }
+ point_list_tail = NULL;
+}
+
+#ifdef STROKE_MOUSE_FOOTPRINTS
+void stroke_init_with_mouse_footprints (Display *disp, Window wind)
+{
+ XSetWindowAttributes w_attr;
+ XWindowAttributes orig_w_attr;
+ unsigned long mask, col_border, col_background;
+ unsigned int border_width;
+ int screen = DefaultScreen (disp);
+ XSizeHints hints;
+
+ stroke_disp = disp;
+
+ XGetWindowAttributes (stroke_disp, wind, &orig_w_attr);
+ hints.x = orig_w_attr.x;
+ hints.y = orig_w_attr.y;
+ hints.width = orig_w_attr.width;
+ hints.height = orig_w_attr.height;
+
+ /* Let the X server take care of whats underneath this window,
+ rather than the client applications, it'll also prevent needless
+ Expose events. NOTE: Not all X servers support this */
+ mask = CWSaveUnder;
+ w_attr.save_under = True;
+
+ /* inhibit all the decorations */
+ mask |= CWOverrideRedirect;
+ w_attr.override_redirect = True;
+
+ /* Don't set a background, transparent window */
+ mask |= CWBackPixmap;
+ w_attr.background_pixmap = None;
+
+ /* Default input window look */
+ col_background = WhitePixel (stroke_disp, screen);
+
+ /* no border for the window */
+ border_width = 0;
+ col_border = BlackPixel (stroke_disp, screen);
+
+ stroke_window = XCreateSimpleWindow (stroke_disp, wind,
+ hints.x, hints.y,
+ hints.width, hints.height,
+ border_width,
+ col_border, col_background);
+
+ stroke_gc = XCreateGC (stroke_disp, stroke_window, 0, NULL);
+
+ XSetFunction (stroke_disp, stroke_gc, GXinvert);
+
+ XChangeWindowAttributes (stroke_disp, stroke_window, mask, &w_attr);
+
+ XSetLineAttributes (stroke_disp, stroke_gc, 2, LineSolid,
+ CapButt, JoinMiter);
+
+ /*FIXME: is this call really needed? If yes, does it need the real
+ argc and argv? */
+ hints.flags = PPosition | PSize;
+ XSetStandardProperties (stroke_disp, stroke_window, "stroke_test", NULL,
+ (Pixmap)NULL, NULL, 0, &hints);
+
+
+ /* Receive the close window client message */
+ {
+ /* FIXME: is this really needed? If yes, something should be done
+ with wmdelete...*/
+ Atom wmdelete = XInternAtom (stroke_disp, "WM_DELETE_WINDOW",
+ False);
+ XSetWMProtocols (stroke_disp, stroke_window, &wmdelete, True);
+ }
+ use_mouse_footprints = 1;
+ init_stroke_data ();
+}
+#endif
+
+void stroke_init (void)
+{
+#ifdef STROKE_MOUSE_FOOTPRINTS
+ use_mouse_footprints = 0;
+#endif
+ init_stroke_data ();
+}
+
+
+
+int stroke_trans (char *sequence)
+{
+ /* number of bins recorded in the stroke */
+ int sequence_count = 0;
+
+ /* points-->sequence translation scratch variables */
+ int prev_bin = 0;
+ int current_bin = 0;
+ int bin_count = 0;
+
+ /* flag indicating the start of a stroke - always count it in the sequence */
+ int first_bin = TRUE;
+
+ /* bin boundary and size variables */
+ int delta_x, delta_y;
+ int bound_x_1, bound_x_2;
+ int bound_y_1, bound_y_2;
+
+#ifdef STROKE_MOUSE_FOOTPRINTS
+ if (use_mouse_footprints)
+ {
+ XUnmapWindow (stroke_disp, stroke_window);
+ XFlush (stroke_disp);
+ }
+#endif
+
+ /* determine size of grid */
+ delta_x = max_x - min_x;
+ delta_y = max_y - min_y;
+
+ /* calculate bin boundary positions */
+ bound_x_1 = min_x + (delta_x / 3);
+ bound_x_2 = min_x + 2 * (delta_x / 3);
+
+ bound_y_1 = min_y + (delta_y / 3);
+ bound_y_2 = min_y + 2 * (delta_y / 3);
+
+ if (delta_x > STROKE_SCALE_RATIO * delta_y) {
+ bound_y_1 = (max_y + min_y - delta_x) / 2 + (delta_x / 3);
+ bound_y_2 = (max_y + min_y - delta_x) / 2 + 2 * (delta_x / 3);
+ } else if (delta_y > STROKE_SCALE_RATIO * delta_x) {
+ bound_x_1 = (max_x + min_x - delta_y) / 2 + (delta_y / 3);
+ bound_x_2 = (max_x + min_x - delta_y) / 2 + 2 * (delta_y / 3);
+ }
+
+ /*
+ printf ("DEBUG:: point count: %d\n",point_count);
+ printf ("DEBUG:: min_x: %d\n",min_x);
+ printf ("DEBUG:: max_x: %d\n",max_x);
+ printf ("DEBUG:: min_y: %d\n",min_y);
+ printf ("DEBUG:: max_y: %d\n",max_y);
+ printf ("DEBUG:: delta_x: %d\n",delta_x);
+ printf ("DEBUG:: delta_y: %d\n",delta_y);
+ printf ("DEBUG:: bound_x_1: %d\n",bound_x_1);
+ printf ("DEBUG:: bound_x_2: %d\n",bound_x_2);
+ printf ("DEBUG:: bound_y_1: %d\n",bound_y_1);
+ printf ("DEBUG:: bound_y_2: %d\n",bound_y_2);
+ */
+
+ /*
+ build string by placing points in bins, collapsing bins and
+ discarding those with too few points...
+ */
+
+ while (point_list_head != NULL) {
+
+ /* figure out which bin the point falls in */
+ current_bin = stroke_bin(point_list_head,bound_x_1, bound_x_2,
+ bound_y_1, bound_y_2);
+ /* if this is the first point, consider it the previous bin,
+ too. */
+ prev_bin = (prev_bin == 0) ? current_bin : prev_bin;
+ /* printf ("DEBUG:: current bin: %d\n",current_bin); */
+
+ if (prev_bin == current_bin)
+ bin_count++;
+ else { /* we are moving to a new bin -- consider adding to the
+ sequence */
+ if ((bin_count > (point_count * STROKE_BIN_COUNT_PERCENT))
+ || (first_bin == TRUE)) {
+ first_bin = FALSE;
+ sequence[sequence_count++] = '0' + prev_bin;
+ /* printf ("DEBUG:: adding sequence: %d\n",prev_bin);
+ */
+ }
+
+ /* restart counting points in the new bin */
+ bin_count=0;
+ prev_bin = current_bin;
+ }
+
+ /* move to next point, freeing current point from list */
+ point_list_tail = point_list_head;
+ point_list_head = point_list_head->next;
+ free (point_list_tail);
+ }
+ point_list_tail = NULL;
+
+ /* add the last run of points to the sequence */
+ sequence[sequence_count++] = '0' + current_bin;
+ /* printf ("DEBUG:: adding final sequence: %d\n",current_bin); */
+
+ /* bail out on error cases */
+ if ((point_count < STROKE_MIN_POINTS)
+ || (sequence_count > STROKE_MAX_SEQUENCE)) {
+ point_count = 0;
+ strcpy (sequence,"0");
+ return FALSE;
+ }
+
+ /* add null termination and leave */
+ point_count = 0;
+ sequence[sequence_count] = '\0';
+ return TRUE;
+}
+
+/* figure out which bin the point falls in */
+static int stroke_bin (p_point point_p, int bound_x_1, int bound_x_2,
+ int bound_y_1, int bound_y_2)
+{
+ int bin_num = 1;
+ if (point_p->x > bound_x_1) bin_num += 1;
+ if (point_p->x > bound_x_2) bin_num += 1;
+ if (point_p->y > bound_y_1) bin_num += 3;
+ if (point_p->y > bound_y_2) bin_num += 3;
+
+ return bin_num;
+}
+
+void stroke_record (int x, int y)
+{
+ p_point new_point_p;
+ int delx, dely;
+ float ix, iy;
+
+ if (point_count < STROKE_MAX_POINTS) {
+ new_point_p = (p_point) malloc (sizeof(point));
+
+ if (point_list_tail == NULL) {
+
+ /* first point in list - initialize list and metrics */
+ point_list_head = point_list_tail = new_point_p;
+ min_x = 10000;
+ min_y = 10000;
+ max_x = -1;
+ max_y = -1;
+ point_count = 0;
+
+ } else {
+#ifdef STROKE_MOUSE_FOOTPRINTS
+ if (use_mouse_footprints)
+ {
+ XMapRaised(stroke_disp, stroke_window);
+ XDrawLine (stroke_disp, stroke_window, stroke_gc,
+ x, y, point_list_tail->x, point_list_tail->y);
+ XFlush (stroke_disp);
+ }
+#endif
+
+ /* interpolate between last and current point */
+ delx = x - point_list_tail->x;
+ dely = y - point_list_tail->y;
+
+ /* step by the greatest delta direction */
+ if (abs(delx) > abs(dely)) {
+ iy = point_list_tail->y;
+
+ /* go from the last point to the current, whatever direction it
+ may be */
+ for (ix = point_list_tail->x;
+ (delx > 0) ? (ix < x) : (ix > x);
+ ix += (delx > 0) ? 1 : -1) {
+
+ /* step the other axis by the correct increment */
+ iy += fabs(((float) dely
+ / (float) delx)) * (float) ((dely < 0) ? -1.0 : 1.0);
+
+ /* add the interpolated point */
+ point_list_tail->next = new_point_p;
+ point_list_tail = new_point_p;
+ new_point_p->x = ix;
+ new_point_p->y = iy;
+ new_point_p->next = NULL;
+
+ /* update metrics */
+ if (((int) ix) < min_x) min_x = (int) ix;
+ if (((int) ix) > max_x) max_x = (int) ix;
+ if (((int) iy) < min_y) min_y = (int) iy;
+ if (((int) iy) > max_y) max_y = (int) iy;
+ point_count++;
+
+ new_point_p = (p_point) malloc (sizeof(point));
+ }
+ } else { /* same thing, but for dely larger than delx case... */
+ ix = point_list_tail->x;
+
+ /* go from the last point to the current, whatever direction
+ it may be */
+ for (iy = point_list_tail->y; (dely > 0) ? (iy < y) : (iy > y);
+ iy += (dely > 0) ? 1 : -1) {
+
+ /* step the other axis by the correct increment */
+ ix += fabs(((float) delx / (float) dely))
+ * (float) ((delx < 0) ? -1.0 : 1.0);
+
+ /* add the interpolated point */
+ point_list_tail->next = new_point_p;
+ point_list_tail = new_point_p;
+ new_point_p->y = iy;
+ new_point_p->x = ix;
+ new_point_p->next = NULL;
+
+ /* update metrics */
+ if (((int) ix) < min_x) min_x = (int) ix;
+ if (((int) ix) > max_x) max_x = (int) ix;
+ if (((int) iy) < min_y) min_y = (int) iy;
+ if (((int) iy) > max_y) max_y = (int) iy;
+ point_count++;
+
+ new_point_p = (p_point) malloc (sizeof(point));
+ }
+ }
+
+ /* add the sampled point */
+ point_list_tail->next = new_point_p;
+ point_list_tail = new_point_p;
+ }
+
+ /* record the sampled point values */
+ new_point_p->x = x;
+ new_point_p->y = y;
+ new_point_p->next = NULL;
+ }
+}
+
diff --git a/libstroke/stroke.h b/libstroke/stroke.h
new file mode 100644
index 0000000..0d3ee69
--- /dev/null
+++ b/libstroke/stroke.h
@@ -0,0 +1,40 @@
+/*
+ libstroke - an X11 stroke interface library
+ Copyright (c) 1996,1997,1998,1999 Mark F. Willey, ETLA Technical
+
+ See the files COPYRIGHT and LICENSE for distribution information.
+*/
+
+/* largest number of points allowed to be sampled */
+#define STROKE_MAX_POINTS 10000
+
+/* number of sample points required to have a valid stroke */
+#define STROKE_MIN_POINTS 50
+
+/* maximum number of numbers in stroke */
+#define STROKE_MAX_SEQUENCE 20
+
+/* threshold of size of smaller axis needed for it to define its own
+ bin size */
+#define STROKE_SCALE_RATIO 4
+
+/* minimum percentage of points in bin needed to add to sequence */
+#define STROKE_BIN_COUNT_PERCENT 0.07
+
+/* translate stroke to sequence */
+int stroke_trans (char *sequence);
+
+/* record point in stroke */
+void stroke_record (int x, int y);
+
+/* initialize stroke functions
+ There are 2 ways to initialize the stroke library:
+ stroke_init_with_mouse_footprints will draw mouse footprints
+ Use stroke_init if that is not desired, or if you have your own
+ implementation of footprints. */
+#ifdef STROKE_MOUSE_FOOTPRINTS
+#include <X11/Xlib.h>
+void stroke_init_with_mouse_footprints (Display *disp, Window wind);
+#else
+void stroke_init (void);
+#endif