From 7e6e62ac799f806e47f88ba0573fa320c016e8e5 Mon Sep 17 00:00:00 2001 From: auroux Date: Mon, 2 Nov 2009 05:08:21 +0000 Subject: [PATCH] Win32 portability --- ChangeLog | 3 + Makefile.in | 13 ++++- configure | 125 +++++++++++++++++++++++++++++++++++++++++- configure.in | 14 ++++- src/Makefile.am | 13 ++++- src/Makefile.in | 28 ++++++++-- src/TODO | 79 ++++++++------------------ src/win32/Makefile | 7 +++ src/win32/xournal.ico | Bin 0 -> 9662 bytes src/win32/xournal.rc | 1 + src/xo-callbacks.c | 11 +++- src/xo-file.c | 22 +++++--- src/xo-misc.c | 26 +++++++-- src/xo-paint.c | 70 +++++++++++++++++++++++ src/xo-print.c | 2 +- src/xournal.h | 9 +++ 16 files changed, 342 insertions(+), 81 deletions(-) create mode 100644 src/win32/Makefile create mode 100644 src/win32/xournal.ico create mode 100644 src/win32/xournal.rc diff --git a/ChangeLog b/ChangeLog index 6c19ddb..85fce2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +This version: + - win32 portability code (contributed by Dirk Gerrits) + Version 0.4.5 (Oct 2, 2009): - bugfixes for GTK+ 2.16/2.17 issues with xinput events - various minor UI bugfixes diff --git a/Makefile.in b/Makefile.in index 5c95f1e..88e8ec1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,11 +31,14 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - depcomp install-sh missing mkinstalldirs + config.guess config.sub depcomp install-sh missing \ + mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -175,14 +178,22 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ +build = @build@ build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +host = @host@ host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ diff --git a/configure b/configure index 893a46f..92a9db1 100755 --- a/configure +++ b/configure @@ -656,6 +656,16 @@ MSGFMT_OPTS MSGFMT USE_NLS GETTEXT_PACKAGE +WIN32_FALSE +WIN32_TRUE +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build PACKAGE_LIBS PACKAGE_CFLAGS PKG_CONFIG @@ -1373,6 +1383,10 @@ Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi @@ -5865,7 +5879,7 @@ _ACEOF fi -pkg_modules="gtk+-2.0 >= 2.10.0 libgnomecanvas-2.0 >= 2.4.0 poppler-glib >= 0.5.4" +pkg_modules="gtk+-2.0 >= 2.10.0 libgnomecanvas-2.0 >= 2.4.0 poppler-glib >= 0.5.4 pangoft2 >= 1.0" if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then @@ -6094,6 +6108,108 @@ fi +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ $as_echo "$as_me:$LINENO: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +$as_echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:$LINENO: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +$as_echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:$LINENO: checking for Win32 environment" >&5 +$as_echo_n "checking for Win32 environment... " >&6; } +case "$host" in + *-*-mingw*) + os_win32=yes;; + *) + os_win32=no;; +esac +{ $as_echo "$as_me:$LINENO: result: $os_win32" >&5 +$as_echo "$os_win32" >&6; } + if test "$os_win32" = "yes"; then + WIN32_TRUE= + WIN32_FALSE='#' +else + WIN32_TRUE='#' + WIN32_FALSE= +fi + + GETTEXT_PACKAGE=xournal @@ -7904,6 +8020,13 @@ $as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${WIN32_TRUE}" && test -z "${WIN32_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"WIN32\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"WIN32\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi : ${CONFIG_STATUS=./config.status} ac_write_fail=0 diff --git a/configure.in b/configure.in index afb03e3..4d74a8a 100644 --- a/configure.in +++ b/configure.in @@ -11,11 +11,23 @@ AM_PROG_CC_STDC AC_PROG_RANLIB AC_HEADER_STDC -pkg_modules="gtk+-2.0 >= 2.10.0 libgnomecanvas-2.0 >= 2.4.0 poppler-glib >= 0.5.4" +pkg_modules="gtk+-2.0 >= 2.10.0 libgnomecanvas-2.0 >= 2.4.0 poppler-glib >= 0.5.4 pangoft2 >= 1.0" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) +dnl detect Win32 environment... +AC_CANONICAL_HOST +AC_MSG_CHECKING([for Win32 environment]) +case "$host" in + *-*-mingw*) + os_win32=yes;; + *) + os_win32=no;; +esac +AC_MSG_RESULT([$os_win32]) +AM_CONDITIONAL(WIN32, test "$os_win32" = "yes") + GETTEXT_PACKAGE=xournal AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.]) diff --git a/src/Makefile.am b/src/Makefile.am index aef9a77..4a2823f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,10 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = ttsubset +if WIN32 + SUBDIRS = ttsubset win32 +else + SUBDIRS = ttsubset +endif INCLUDES = \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ @@ -20,5 +24,10 @@ xournal_SOURCES = \ xo-callbacks.c xo-callbacks.h \ xo-shapes.c xo-shapes.h -xournal_LDADD = ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS) +if WIN32 + xournal_LDFLAGS = -mwindows + xournal_LDADD = win32/xournal.res ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS) -lz +else + xournal_LDADD = ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS) +endif diff --git a/src/Makefile.in b/src/Makefile.in index b9859f9..8557b93 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,6 +32,8 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ bin_PROGRAMS = xournal$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO @@ -51,7 +53,12 @@ am_xournal_OBJECTS = main.$(OBJEXT) xo-misc.$(OBJEXT) \ xo-callbacks.$(OBJEXT) xo-shapes.$(OBJEXT) xournal_OBJECTS = $(am_xournal_OBJECTS) am__DEPENDENCIES_1 = -xournal_DEPENDENCIES = ttsubset/libttsubset.a $(am__DEPENDENCIES_1) +@WIN32_FALSE@xournal_DEPENDENCIES = ttsubset/libttsubset.a \ +@WIN32_FALSE@ $(am__DEPENDENCIES_1) +@WIN32_TRUE@xournal_DEPENDENCIES = win32/xournal.res \ +@WIN32_TRUE@ ttsubset/libttsubset.a $(am__DEPENDENCIES_1) +xournal_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(xournal_LDFLAGS) \ + $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -76,7 +83,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ distdir ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) +DIST_SUBDIRS = ttsubset win32 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -179,14 +186,22 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ +build = @build@ build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +host = @host@ host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ @@ -210,7 +225,8 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = ttsubset +@WIN32_FALSE@SUBDIRS = ttsubset +@WIN32_TRUE@SUBDIRS = ttsubset win32 INCLUDES = \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ @@ -227,7 +243,9 @@ xournal_SOURCES = \ xo-callbacks.c xo-callbacks.h \ xo-shapes.c xo-shapes.h -xournal_LDADD = ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS) +@WIN32_TRUE@xournal_LDFLAGS = -mwindows +@WIN32_FALSE@xournal_LDADD = ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS) +@WIN32_TRUE@xournal_LDADD = win32/xournal.res ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS) -lz all: all-recursive .SUFFIXES: @@ -301,7 +319,7 @@ clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) xournal$(EXEEXT): $(xournal_OBJECTS) $(xournal_DEPENDENCIES) @rm -f xournal$(EXEEXT) - $(LINK) $(xournal_OBJECTS) $(xournal_LDADD) $(LIBS) + $(xournal_LINK) $(xournal_OBJECTS) $(xournal_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) diff --git a/src/TODO b/src/TODO index 3472890..e58e73b 100644 --- a/src/TODO +++ b/src/TODO @@ -1,56 +1,8 @@ List of features to be implemented (not in any particular order) ---------------------------------------------------------------- -THINGS DONE IN THIS RELEASE: - -DONE: fix GTK+ 2.16/2.17 XInput issues with scrollbars and menus -DONE: fix bug 2826845 (shape recognizer accel doesn't work in fullscreen mode) -DONE: bug affecting resize zone in statusbar -DONE: page spinbutton wide enough for 3 digits; avoid "deprecated" warning -DONE: edit->paste command should refresh toolbar to unselect color/thickness - (so can repaint sel) -DONE: cursor doesn't reset properly after selection operation if primary - tool is select mode (stays with arrow cursor instead of pointer) -DONE: device with "eraser" at the end of its name is of type ERASER - (Edward Yang) -DONE: fix_xinput_coords() replaces buggy xinput events by core pointer - coordinates -DONE: use poppler to render PDF backgrounds (after patches contributed - by Mike Ter Louw and Bob McElrath) -DONE: gettext internationalization (contributed by David Planella) -DONE: Catalan translation (by David Planella); French translation -DONE: fix unresponsiveness to button events in text edition box (GTK+ 2.17) - and segfaults when dragging text or using Layers combobox (GTK+ 2.17) -DONE: Esc leaves text box if editing; and leaves fullscreen mode -DONE: package our own copy of the ttsubset library (to remove a dependency - on libgnomeprint), and create TT subfonts in memory -DONE: use gtk-print instead of libgnomeprint -DONE: remove deprecated "antialias bg" option -DONE: fix fix_xinput_coords so it works ok without ENABLE_XINPUT_BUGFIX ? -DONE: disable ctrl-left/right accelerators during text edition -DONE: custom color chooser button (after a patch contributed by Alex Ray) -DONE: remember last used directory (after a patch contributed by Lu Zhihe) -DONE: discard Alt-click and Control-click events -DONE: option to have buttons *toggle* the tool rather than act as tool - (ie button 2 causes button 1 to map to tool 2) [Dylan Thurston] -DONE: patch to fix focus + allow up/dn in single page mode (Bob McElrath) -DONE: patch to fix underscores in MRU filename display (Bob McElrath) -DONE: patch to avoid tiny file dialogs (Bob McElrath) -DONE: further fixes for focus; can Esc out of page selection box -DONE: further fixes for xinput under GTK+ 2.17 -DONE: option to auto-load *.pdf.xoj instead of *.pdf (Bob McElrath) -DONE: look for PDF backgrounds in path of xoj file before prompting user -DONE: paper color chooser (after a patch by ojb) -DONE: remove "Discard core events" from options menu -DONE: get_pressure_multiplier() accesses correct members of event union -DONE: address recognizer bug on single-segment strokes (division by 0) -DONE: remove binary installer (poppler is binary incompatible across versions) - but provide configure script - -REMAINING THINGS TO DO: - - collaborative editing (see discussion with Erik Demaine) -- porting to Win32 and MacOS; merge Nokia port +- porting to MacOS; merge Nokia port - multiple-scenario undo history - collaborative: allow non-x86 endianness (for ints, for floats?) @@ -65,6 +17,21 @@ REMAINING THINGS TO DO: or see if removing the GTK bugfix would help? -- e.g. by recalling an internal gtk init function? +BUGS: +** lingering issues with synaptics touchpads? (#2872667) + - add patch 0.4.5-fix-synaptics-v1.patch (fix ButtonDown events) + - set device to Absolute mode at startup? (GDK doesn't expose API, + cf XSetDeviceMode() in /usr/include/X11/extensions/XInput.h) +** color picker into canvas doesn't work in GTK+ 2.16 (should disable + xinput first?) + +WIN32: +- test further +- write an installer + +PATCHES TO INCORPORATE: +** Italian translation (add_it_po.patch unless updated on tracker) + (by Marco Poletti) ** patch: ortho/snap (revised Apr 13 2009) xournal_ortho_snap_patch_4 (by Josef Pavlicek) @@ -72,10 +39,12 @@ REMAINING THINGS TO DO: ** patch (Ian-Woo Kim): multicolumn mode + LASSO SELECTION xournal_lasso_multipage_zoom_button_20090620.patch -** autosave patch (Edward Yang) (fix: optional only, w/ menu + cfgfile +** autosave patch (Edward Yang) (should fix: optional only, w/ menu + cfgfile entries; fix: should clean up autosave.xoj.bg* files too; config interval) 0001-Implement-autosave-for-documents-revised.patch (2 seconds after modification, vs original 5 seconds) + *** NEW VERSION: #2881919 (autosave for 0.4.5, w/ some changes) + NB: last modif should be triggered by prepare_new_undo() and undo/redo? - PDF bg memory usage throttling / delete oldest pdf backgrounds - replace ttsubset by something more modern? (eg. from cairo ?) @@ -119,13 +88,11 @@ REMAINING THINGS TO DO: - allow toolbar to go vertical - toolbar buttons should react to button 2/3 click to modify settings - for that tool? + for that tool!! - paste text directly into xournal, from xournal? (instead of starting a text item and pasting into/from it) - insert links (to URLs; within document/to other xoj? hand mode navigates) -- increase width of spinPageNo to fit 3 digits -- should escape '_' to '__' in MRU menu entries (else become mnemonics) - a command + keyboard shortcut to switch mappings (1<->2, 1<->3, 2<->3) (A. Rechnitzer Sept 11, 2007) - modify encoding of TrueType font subsets or provide cmap so pdf text @@ -145,9 +112,9 @@ REMAINING THINGS TO DO: - export as SVG, as bitmap (use Cairo for this) - improved PDF viewer features (search text, hyperlink, page borders...) (using full poppler api ?) +- search text: among PDF background (using poppler); among text annotations - use system paper size as default (/etc/papersize) -- autoload *.pdf.xoj if present when opening *.pdf ??? - sticky notes (anchor visually text box to a bg location) - use relative paths for bg documents (e.g. annotated PDF) - flush display queue when drawing over a slow X server? @@ -164,8 +131,8 @@ REMAINING THINGS TO DO: - lasso selection tool (see shoffsta patch) (http://shoffsta.afraid.org/Projects/Xournal/) - flatten (incl undo/redo...) - enabled only if nlayers>1 -- color chooser (papercolor, pen color); maybe more default colors - cf. ojb patch #2083103 adds paper color chooser +- color chooser (papercolor, pen color); have default colors and a history + appear as palette in there! - printing: print-options, save printer settings (throughout a session, and on disk) (maybe a separate config file .xournal/gnome-print-settings) - help index diff --git a/src/win32/Makefile b/src/win32/Makefile new file mode 100644 index 0000000..97821d3 --- /dev/null +++ b/src/win32/Makefile @@ -0,0 +1,7 @@ +all: xournal.res +all-recursive: all +install-recursive: +install: + +xournal.res: xournal.rc + windres xournal.rc -O coff -o xournal.res diff --git a/src/win32/xournal.ico b/src/win32/xournal.ico new file mode 100644 index 0000000000000000000000000000000000000000..ad184de46a42155495620fcf14fa9f137bfc566c GIT binary patch literal 9662 zcmeHNd323u9=>X?j@FDRT4RhU)#<6z!|6F=w8zv~Bh;LZIclk)iZVtgmS7lykWKbg z64@+?NUe!PHVG98vBg$`P+M$`MC?5CdtQCN^WE#Zy?T0#KgxOX``&MTp5OMq-*>LX zQb+#3`>sX)wzVX;w^&}aSS%d{vdi)h0r#taZ&)n9Z1M+|y!l5s zy&$MBXe@YH&|J_`@EgJJ1QKOS2LV&Sj5lTcdqG=4Ye5UauLQpkG!oPm{N#GSzprGS zdKRDCPC#Do2)YRVD0pA+p`fRrub`ixzrgi-aN9+|W4#1C_X7d1O> zQ1DcGdiClx&ehemqHo{6*9Fx?pFVwROt>N2M6E{e-o0;{a7(tGfpLw#&-Yf}pH@9r z^XT8d|EZomdyalmKKAR^uc@4SbKACU*tv7(bB7%}c3{AO0o2{Zo(AFGcKGn&H6T?i|jXIfK)uPvhHfzs33U=hgnI zsw(i=JfF|E1&@h;Z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WuSn_xE4pUt6s0gcZP7i=rE8s`@lSdDYH=39-kC0ESP+mf4&jLgi3k`Jq%hCh3) zXgI=evgZ5!KgPo2u=JikJPm*Ixpn^SbC3B$%l*%KZ07P~wi~zydcNT1Q%lS1pY{01 zaQ^w4XZo8Qx?6q&^zf0bk{^|DEQ@0Psi2i#nQWz%UsU{%t>Afb{Xournal " VERSION ""); + "Xournal " VERSION_STRING ""); gtk_dialog_run (GTK_DIALOG(aboutDialog)); gtk_widget_destroy(aboutDialog); } @@ -2370,6 +2370,8 @@ on_canvas_button_press_event (GtkWidget *widget, } if ((event->state & (GDK_CONTROL_MASK|GDK_MOD1_MASK)) != 0) return FALSE; // no control-clicking or alt-clicking + if (!is_core) gdk_device_get_state(event->device, event->window, event->axes, NULL); + // synaptics touchpads send bogus axis values with ButtonDown if (!is_core) fix_xinput_coords((GdkEvent *)event); @@ -2443,6 +2445,9 @@ on_canvas_button_press_event (GtkWidget *widget, ui.which_mouse_button = event->button; switch_mapping(mapping); +#ifdef WIN32 + update_cursor(); +#endif // in text tool, clicking in a text area edits it if (ui.toolno[mapping] == TOOL_TEXT) { diff --git a/src/xo-file.c b/src/xo-file.c index 7ff7974..2743a28 100644 --- a/src/xo-file.c +++ b/src/xo-file.c @@ -11,13 +11,16 @@ #include #include #include -#include -#include #include #include #include #include +#ifndef WIN32 + #include + #include +#endif + #include "xournal.h" #include "xo-interface.h" #include "xo-support.h" @@ -83,7 +86,7 @@ gboolean save_journal(const char *filename) GList *pagelist, *layerlist, *itemlist, *list; GtkWidget *dialog; - f = gzopen(filename, "w"); + f = gzopen(filename, "wb"); if (f==NULL) return FALSE; chk_attach_names(); @@ -143,7 +146,7 @@ gboolean save_journal(const char *filename) success = FALSE; if (bgpdf.status != STATUS_NOT_INIT && bgpdf.file_contents != NULL) { - tmpf = fopen(tmpfn, "w"); + tmpf = fopen(tmpfn, "wb"); if (tmpf != NULL && fwrite(bgpdf.file_contents, 1, bgpdf.file_length, tmpf) == bgpdf.file_length) success = TRUE; fclose(tmpf); @@ -715,7 +718,7 @@ gboolean open_journal(char *filename) } g_free(tmpfn); - f = gzopen(filename, "r"); + f = gzopen(filename, "rb"); if (f==NULL) return FALSE; if (filename[0]=='/') { if (ui.default_path != NULL) g_free(ui.default_path); @@ -864,7 +867,7 @@ GList *attempt_load_gv_bg(char *filename) char *pipename; int buflen, remnlen, file_pageno; - f = fopen(filename, "r"); + f = fopen(filename, "rb"); if (f == NULL) return NULL; buf = g_malloc(BUFSIZE); // a reasonable buffer size if (fread(buf, 1, 4, f) !=4 || @@ -876,7 +879,7 @@ GList *attempt_load_gv_bg(char *filename) fclose(f); pipename = g_strdup_printf(GS_CMDLINE, (double)GS_BITMAP_DPI, filename); - gs_pipe = popen(pipename, "r"); + gs_pipe = popen(pipename, "rb"); g_free(pipename); bg_list = NULL; @@ -922,6 +925,7 @@ GList *attempt_load_gv_bg(char *filename) struct Background *attempt_screenshot_bg(void) { +#ifndef WIN32 struct Background *bg; GdkPixbuf *pix; XEvent x_event; @@ -958,6 +962,10 @@ struct Background *attempt_screenshot_bg(void) bg->filename = new_refstring(NULL); bg->file_domain = DOMAIN_ATTACH; return bg; +#else + // not implemented under WIN32 + return FALSE; +#endif } /************** pdf annotation ***************/ diff --git a/src/xo-misc.c b/src/xo-misc.c index cf63de7..cb8fd48 100644 --- a/src/xo-misc.c +++ b/src/xo-misc.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "xournal.h" #include "xo-interface.h" @@ -2040,6 +2039,11 @@ void hide_unimplemented(void) if (gtk_check_version(2, 10, 0)) { gtk_widget_hide(GET_COMPONENT("filePrint")); } + + /* screenshot feature doesn't work yet in Win32 */ +#ifdef WIN32 + gtk_widget_hide(GET_COMPONENT("journalScreenshot")); +#endif } // toggle fullscreen mode @@ -2052,9 +2056,23 @@ void do_fullscreen(gboolean active) gtk_toggle_tool_button_set_active( GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), ui.fullscreen); - if (ui.fullscreen) gtk_window_fullscreen(GTK_WINDOW(winMain)); - else gtk_window_unfullscreen(GTK_WINDOW(winMain)); - + if (ui.fullscreen) { +#ifdef WIN32 + gtk_window_get_size(GTK_WINDOW(winMain), &ui.pre_fullscreen_width, &ui.pre_fullscreen_height); + gtk_widget_set_size_request(GTK_WIDGET(winMain), gdk_screen_width(), + gdk_screen_height()); +#endif + gtk_window_fullscreen(GTK_WINDOW(winMain)); + } + else { +#ifdef WIN32 + gtk_widget_set_size_request(GTK_WIDGET(winMain), -1, -1); + gtk_window_resize(GTK_WINDOW(winMain), ui.pre_fullscreen_width, + ui.pre_fullscreen_height); +#endif + gtk_window_unfullscreen(GTK_WINDOW(winMain)); + } + update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]); } diff --git a/src/xo-paint.c b/src/xo-paint.c index 7ab1846..6361af7 100644 --- a/src/xo-paint.c +++ b/src/xo-paint.c @@ -16,6 +16,76 @@ #include "xo-misc.h" #include "xo-paint.h" +/***** Win32 fix for gdk_cursor_new_from_pixmap() by Dirk Gerrits ****/ + +#ifdef WIN32 +gboolean colors_too_similar(const GdkColor *colora, const GdkColor *colorb) +{ + return (abs(colora->red - colorb->red) < 256 && + abs(colora->green - colorb->green) < 256 && + abs(colora->blue - colorb->blue) < 256); +} + +/* gdk_cursor_new_from_pixmap is broken on Windows. + this is a workaround using gdk_cursor_new_from_pixbuf. */ +GdkCursor* fixed_gdk_cursor_new_from_pixmap(GdkPixmap *source, GdkPixmap *mask, + const GdkColor *fg, const GdkColor *bg, + gint x, gint y) +{ + GdkPixmap *rgb_pixmap; + GdkGC *gc; + GdkPixbuf *rgb_pixbuf, *rgba_pixbuf; + GdkCursor *cursor; + int width, height; + + /* HACK! It seems impossible to work with RGBA pixmaps directly in + GDK-Win32. Instead we pick some third color, different from fg + and bg, and use that as the 'transparent color'. We do this using + colors_too_similar (see above) because two colors could be + unequal in GdkColor's 16-bit/sample, but equal in GdkPixbuf's + 8-bit/sample. */ + GdkColor candidates[3] = {{0,65535,0,0}, {0,0,65535,0}, {0,0,0,65535}}; + GdkColor *trans = &candidates[0]; + if (colors_too_similar(trans, fg) || colors_too_similar(trans, bg)) { + trans = &candidates[1]; + if (colors_too_similar(trans, fg) || colors_too_similar(trans, bg)) { + trans = &candidates[2]; + } + } /* trans is now guaranteed to be unique from fg and bg */ + + /* create an empty pixmap to hold the cursor image */ + gdk_drawable_get_size(source, &width, &height); + rgb_pixmap = gdk_pixmap_new(NULL, width, height, 24); + + /* blit the bitmaps defining the cursor onto a transparent background */ + gc = gdk_gc_new(rgb_pixmap); + gdk_gc_set_fill(gc, GDK_SOLID); + gdk_gc_set_rgb_fg_color(gc, trans); + gdk_draw_rectangle(rgb_pixmap, gc, TRUE, 0, 0, width, height); + gdk_gc_set_fill(gc, GDK_OPAQUE_STIPPLED); + gdk_gc_set_stipple(gc, source); + gdk_gc_set_clip_mask(gc, mask); + gdk_gc_set_rgb_fg_color(gc, fg); + gdk_gc_set_rgb_bg_color(gc, bg); + gdk_draw_rectangle(rgb_pixmap, gc, TRUE, 0, 0, width, height); + gdk_gc_unref(gc); + + /* create a cursor out of the created pixmap */ + rgb_pixbuf = gdk_pixbuf_get_from_drawable( + NULL, rgb_pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, width, height); + gdk_pixmap_unref(rgb_pixmap); + rgba_pixbuf = gdk_pixbuf_add_alpha( + rgb_pixbuf, TRUE, trans->red, trans->green, trans->blue); + gdk_pixbuf_unref(rgb_pixbuf); + cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), rgba_pixbuf, x, y); + gdk_pixbuf_unref(rgba_pixbuf); + + return cursor; +} +#define gdk_cursor_new_from_pixmap fixed_gdk_cursor_new_from_pixmap +#endif + + /************** drawing nice cursors *********/ static char cursor_pen_bits[] = { diff --git a/src/xo-print.c b/src/xo-print.c index bb80653..6340ca3 100644 --- a/src/xo-print.c +++ b/src/xo-print.c @@ -1191,7 +1191,7 @@ gboolean print_to_pdf(char *filename) struct PdfFont *font; char *tmpbuf; - f = fopen(filename, "w"); + f = fopen(filename, "wb"); if (f == NULL) return FALSE; setlocale(LC_NUMERIC, "C"); annot = FALSE; diff --git a/src/xournal.h b/src/xournal.h index 48ae81a..15906cd 100644 --- a/src/xournal.h +++ b/src/xournal.h @@ -24,6 +24,14 @@ #define MRU_SIZE 8 #define CONFIG_FILE "config" +// version string for about box + +#ifdef WIN32 +#define VERSION_STRING VERSION "-win32" +#else +#define VERSION_STRING VERSION +#endif + // DATA STRUCTURES AND CONSTANTS #define PIXEL_MOTION_THRESHOLD 0.3 @@ -282,6 +290,7 @@ typedef struct UIData { gboolean shorten_menus; // shorten menus ? gchar *shorten_menu_items; // which items to hide gboolean is_sel_cursor; // displaying a selection-related cursor + gint pre_fullscreen_width, pre_fullscreen_height; // for win32 fullscreen #if GTK_CHECK_VERSION(2,10,0) GtkPrintSettings *print_settings; #endif -- 2.39.2