-----------
The History
-----------

For simpler installation and more consistent behaviour, official Windows build of mtPaint is packaged with its own copy of GTK+ runtime environment. Prior to version 3.40, it was GTK+ 2.6.4 - or more accurately, a mix of DLLs from official Windows distributions of GTK+ 2.6.4 and 2.6.9, with libgdk and libgtk being from 2.6.4. This allowed mtPaint to continue to support Windows 98, which became unsupported with GTK+ 2.8.

But since version 2.6.4 had been released in 2005, some improvements in Windows support in GTK+ had been made which were really desirable. Moreover, libraries such as libpng, libjpeg, LibTIFF, FreeType, and even zlib had undergone multiple version changes in the meantime, with bugfixes and other improvements. Still, upgrading the package to a newer official distribution of GTK+ would have meant exposing the program to a new set of GTK+ bugs and quirks - which would have been hard to detect and counter in time, because I myself do not run Windows. For this reason, mtPaint 3.40 came with a custom build of GTK+ based on version 2.6.7 with a set of patches backported from the later versions, compiled from source along with all its dependencies.

With mtPaint 3.50, an updated version of that build, with updated libraries, comes with 32-bit build of mtPaint intended for old 32-bit Windows systems such as Windows XP, or even now-ancient Windows 98 in case someone somewhere has a reason to run one. On newer 64-bit Windows systems, specifically Windows 7 and later, the 64-bit build of mtPaint is expected to work better; however, the newer GTK+2 build coming with it is near untested (for I still do not run Windows) so if it misbehaves in any major way, this 32-bit build could serve as a fallback.

For mtPaint 3.51, the only notable change is that giflib library which was a dependency before, now isn't and was removed.

-------------
The Specifics
-------------

Original patches from GTK+ tree contained in the cumulative patch:
- svn  7886 / git d73fa807875951d0240dce572398992d395bbe77
  Use GetDriveType() to recognize removable drives (in order to avoid
  (REVERTED: was making flash drives inaccessible from file selector)
- svn 12881 / git 0604a90098416694c1d26bfa920e34c3f5d61493
  Remove debugging output. (#302404, Frederic Crozat)
  (APPLIED: cleans up BMP loader)
- svn 12899 / git cf5324d980fcddad8318bf52f5315d39fc4221f6
  Don't grab focus to unrealized widgets. (#302240, Philip Langdale)
  (APPLIED: fixes possible glitch in radiobutton groups)
- svn 12903 / git 0ae5528968af2b0e28eebdb9c4b38f76af129707
  Take multi-monitor offset into account. (#302525)
  (APPLIED)
- svn 12946 / git 35f75bd3401d498201327fe00fa454deb351cee1
  Always initialize child-visible to FALSE, otherwise we may end up with the
  (PARTIALLY APPLIED: fixes possible glitch in GtkNotebook)
- svn 12968 / git ff576e3fe7dce780f2b892967fb16c073656d29d
  Check that GDK_IS_SCREEN(screen) (like the X11 backend does), not screen
  (APPLIED)
- svn 12991 / git 7c337b69f23d4200d4975cc35da13d1d3c00cc1f
  Don't blink the cursor if the entry is not editable. (#304171,Nikos
  (APPLIED)
- svn 12992 / git ef25506011d6bfa67294cdcc8bbdd40185f0bfaa
  Don't bind GDK_Page_Up and GDK_Page_Down twice. (#168333, Hazael Maldonado
  (APPLIED: fixes reaction to PageUp & PageDown keys in sliders)
- svn 12994 / git f4fc3fee869d901eba7b6eaf22a4794b15659a2e
  Keep the popup posted if the button is released over the cellview. This
  (APPLIED: fixes GtkComboBox)
- svn 13027 / git a9c0d119133ea9c22017cf7bb567b5de54b538c0
  If the keysym isn't one of the special cases this function takes care of,
  (APPLIED)
- svn 13057 / git 67f3c556626c6e9fa06b2143c87633e635ed733c
  If blitting from the root window, take the multi-monitor offset into
  (APPLIED)
- svn 13062 / git b27c1cc6ee8e5d86a628a3a96a8c3d56bdc00b7e
  Make autoscrolling work at the bottom of the screen.
  (APPLIED: fixes GtkComboBox)
- svn 13095 / git 36c4c40f8822aa519aa33fa3222f42fc6563dfa8
  Check for overflow. (#306394, Morten Welinder)
  (APPLIED: fixes PNM loader)
- svn 13200 / git 5e575c6df3a3e407042a666a9ba9cbb1e01c0b6c
  [Win32] Borrow this function from GLib HEAD. (_gtk_get_localedir): [Win32]
  (APPLIED: fixes possible problem with non-ASCII installation path)
- svn 13219 / git 4a37701aa1615c30d80a6840fbc836fc2896adaa
  Queue a draw on the old and new focus widgets, if their defaultness
  (APPLIED)
- svn 13224 / git c943c3552a7a8f2aee2bad0d3d694b67c6c8e41c
  Set the actions and suggested_action fields in the GdkDragContext to
  (APPLIED)
- svn 13267 / git 406be320feec1adec2e5794150cb3eea351cb1fb
  Connect to button-release-event as well, to handle touchscreen scenarios
  (APPLIED)
- svn 13438 / git 5454441a8336a0f96a3999143903e394ce1498cd
  Fix handling of Aiptek and Aiptek-like graphical tablets such as Trust on
  (APPLIED)
- svn 13493 / git 91f2fb2d4d3b8f5474121a396c1b191938ad3887
  don't iterate past the end of the string, so pango_layout_get_cursor_pos()
  (APPLIED: fixes a glitch in GtkEntry)
- svn 13498 / git 24d63ffe74df3b5f5780c8c9a8058c341f26da93
  Don't fail if we can't get a keyboard grab. (#168351)
  (APPLIED)
- svn 13588 / git 1cabe720eb48eb0fd29421b4dcdf8c3f58eaf71e
  Avoid spurious core pointer events when the tablet pen is lifted.
  (APPLIED)
- svn 13738 / git bd80abab9f749698ad034aa2a3b313ac62344b9c
  Backport from 2.8.
  (APPLIED: fixes possible crash in GtkComboBox)
- svn 14261 / git 21b6ed0024a44054d99c4930914f4eb81dfdd05b
  2.8.7
  (PARTIALLY APPLIED: fixes two vulnerabilities in XPM loader)
- svn 14527 / git 3750d5da6b2dc7e104b9cc19f60b5724032e67c2
  Get the invalidated region from ScrollWindowEx() instead of an incorrect
  (APPLIED: fixes scrolling of partially covered windows)
- svn 15720 / git f93e5455e983144e133e18b5041aab29afc97360
  [WM_WINDOWPOSCHANGED] Replace identical code as in
  (APPLIED: prerequisite for svn 17834)
- svn 17096 / git 8d601fbde30fd28f9d9fc5e5ebc47cba5e56f351
  New file. Downloaded from freedesktop.org's webcvs. Slighly edited cursors
  (APPLIED: changes to several builtin cursors)
- svn 17299 / git ea7cc8d95eade637c67c5331a9f98863210ad8f1
  Fix Win32 resize events and flickering
  (APPLIED)
- svn 17615 / git f251591cf8d1d6c399485a4b0f95811e628e6b6f
  Fix menuitem rendering in Vista
  (BACKPORTED)
- svn 17645 / git 2cf71073edccd5a445a3baef5a158d85caf16520
  Use native Win32 cursors where it makes sense
  (APPLIED)
- svn 17834 / git 50af49319ad07682cd15913d264cb4a9570e1f8c
  Fix context iterations for handle_configure_event()
  (APPLIED)
- svn 20250 / git 710c9619b944e993f5402e04dc08846851b11f38
  leak of GDI region in function 'handle_wm_paint'
  (APPLIED)
- svn 20726 / git 0d0f9a7fc184db3ff8ce76e49256fee397de3d35
  Windows' System Menu blocks main loop
  (APPLIED)
- svn 20881 / git c8fef535b20ad75f82739f68fce2216c1d62f6ab
  Repaint glitches in widgets
  (APPLIED)
- svn 22511 / git 703a18c25fc4b1e8f06c4b9c8ea7cb74c06b3871
  Can not resize shaped windows on Windows
  (APPLIED)
- git 106ddae86d5ffd3409901c5f9772b1a01f84ad04
  Emit changed and notify:text only once. The same fix was applied for
  (BACKPORTED)

In addition, there are couple of my own patches, solving the build problems arising from use of then-recent MinGW on a Linux box (in GTK+ 2.6.x time, official Windows packages were built with MSVC on Windows).

And one my patch that fixes a critical bug afflicting the entire GTK+2 line for whole 20 years, causing random crashes on Windows; namely, mixing up GDI handles from CreateDIBSection() in gdk/win32/gdkpixmap-win32.c with HWND user handles from everywhere else, in one single hash. The two types of handles can clash, and when they do, GDK event dispatch is done for, with "invalid cast from `GdkPixmap' to `GdkWindow'" as its dying gasps. It managed to avoid my notice till now, accruing full benefit from my not using Windows; still, better late than never.

Patch from Pango tree:
- svn 2489 / git d686e1d4ae80b64390149e7336329c0254479161
  On Windows store the default aliases file in a string array. (#492517)
  (BACKPORTED: needed to handle 'pango.aliases' for Windows Vista & Windows 7)

---------
The Build
---------

The build was done on a Slackware Linux system using MinGW cross-compiler installation combined of the following parts:
- GCC 4.2.4		( https://gcc.gnu.org/pub/gcc/releases/gcc-4.2.4/ )
- TDM patches to it     ( https://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Old%20Releases/TDM-GCC%204.2%20series/4.2.4-tdm-1/ )
- binutils 2.28		( https://ftp.gnu.org/gnu/binutils/ )
- MinGW runtime 3.15.2	( https://sourceforge.net/projects/mingw/files/OldFiles/mingwrt-3.15.2/ )
- Win32 API 3.13	( https://sourceforge.net/projects/mingw/files/OldFiles/w32api-3.13/ )
And CMake 3.5.2 (for building OpenJPEG and zstd).

The reason for using those old MinGW packages specifically, besides maximal similarity with the build packaged with mtPaint 3.40, is retaining support for old Windows versions, in case it was removed from MinGW (or bitrotten there) sometime later.

To replicate it, you need the following source packages:
- GTK+ 2.6.7 (this specific version and no other):
    gtk+-2.6.7.tar.bz2
    https://download.gnome.org/sources/gtk+/2.6/gtk+-2.6.7.tar.bz2
- Wintab development package:
    wtkit126.zip
    https://web.archive.org/web/20070728143618/http://www.wacomeng.com/devsupport/downloads/pc/wtkit126.zip
- Pango 1.8.2 (this specific version and no other):
    pango-1.8.2.tar.bz2
    https://download.gnome.org/sources/pango/1.8/pango-1.8.2.tar.bz2
- ATK 1.9.0:
    atk-1.9.0.tar.bz2
    https://download.gnome.org/sources/atk/1.9/atk-1.9.0.tar.bz2
- GLib 2.6.6:
    glib-2.6.6.tar.bz2
    https://download.gnome.org/sources/glib/2.6/glib-2.6.6.tar.bz2
- GNU gettext 0.14.5:
    gettext-0.14.5.tar.gz
    https://ftp.gnu.org/pub/gnu/gettext/gettext-0.14.5.tar.gz
- GNU libiconv 1.9.2:
    libiconv-1.9.2.tar.gz
    https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz
- zlib 1.2.11:
    zlib-1.2.11.tar.gz
    https://zlib.net/zlib-1.2.11.tar.gz
- XZ Utils 5.2.5:
    xz-5.2.5.tar.gz
    https://tukaani.org/xz/xz-5.2.5.tar.gz
- zstd 1.4.5:
    zstd-1.4.5.tar.gz
    https://github.com/facebook/zstd/releases/download/v1.4.5/zstd-1.4.5.tar.gz
- libpng 1.2.59 (not version 1.4+):
    libpng-1.2.59.tar.gz
    https://sourceforge.net/projects/libpng/files/libpng12/1.2.59/libpng-1.2.59.tar.gz/download
- libjpeg 9d:
    jpegsrc.v9d.tar.gz
    https://www.ijg.org/files/jpegsrc.v9d.tar.gz
- libwebp 1.1.0:
    libwebp-1.1.0.tar.gz
    https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz
- LibTIFF 4.1.0:
    tiff-4.1.0.tar.gz
    https://download.osgeo.org/libtiff/tiff-4.1.0.tar.gz
- FreeType 2.10.4:
    freetype-2.10.4.tar.xz
    https://sourceforge.net/projects/freetype/files/freetype2/2.10.4/freetype-2.10.4.tar.xz/download
- OpenJPEG 2.4.0:
    openjpeg-2.4.0.tar.gz
    https://github.com/uclouvain/openjpeg/archive/v2.4.0.tar.gz
- Little CMS 2.11:
    lcms2-2.11.tar.gz
    https://sourceforge.net/projects/lcms/files/lcms/2.11/lcms2-2.11.tar.gz/download
- Gifsicle 1.92:
    gifsicle-1.92.tar.gz
    https://www.lcdf.org/gifsicle/gifsicle-1.92.tar.gz
- mtPaint 3.50 (or later):
    mtpaint-3.50.tar.bz2
- mtPaint handbook 3.50 (same version as mtPaint):
    mtpaint_handbook-3.50.zip

Also you need the following files from 'gtk' subdirectory of mtPaint source package:
  winbuild.sh
  gtk267_7wj.patch
  gtkrc
  pango182_1wj.patch
  pango.aliases

To recreate the "etc/pango/pango.modules" and "etc/gtk-2.0/gdk-pixbuf.loaders" files, you additionally need a working install of Wine.

To do the build, put all requisite files into same directory, adjust the variables in "CONFIGURATION SETTINGS" section of 'winbuild.sh' if necessary, and run 'winbuild.sh'. Subdirectory 'zad' will be created for use in the build process; if the build succeeds, executables and runtime files will be placed under 'zad/pkg', and development libraries and headers, under 'zad/dev'.

An alternative cross-compiler installation using MXE http://mxe.cc :
git clone https://github.com/mxe/mxe.git
cd mxe && make gcc MXE_TARGETS=i686-w64-mingw32.shared

---------------------------------
Copyright (C) 2010,2011,2017,2019,2020,2021 Dmitry Groshev
