Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 djview4 (4.11-3) unstable; urgency=medium
 .
   * track upstream fixes
     - include keywords in .desktop file which placates lintian
   * debhelper 13
   * bump standards version
   * lengthen long description to placate lintian
   * stop generating browser plugin package that doesn't work with modern
     browsers (closes: #377468, #948450, #962181)
   * remove quotes in mime entry to placate lintian
   * verbose build: don't suppress compiler commands
   * enable executable debugging info
   * pkg-config info quilt patch for FTCBFS issue (closes: #886304)
Author: Barak A. Pearlmutter <bap@debian.org>
Bug-Debian: https://bugs.debian.org/377468
Bug-Debian: https://bugs.debian.org/886304
Bug-Debian: https://bugs.debian.org/948450
Bug-Debian: https://bugs.debian.org/962181

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2020-06-12

--- djview4-4.11.orig/README
+++ djview4-4.11/README
@@ -32,6 +32,14 @@ Prerequisites:
 1.2 - USING DJVIEW4 AS A PLUGIN
 -------------------------------
 
+
+WARNING: USING DJVIEW AS A PLUGIN IN 2020 IS VERY DIFFICULT BECAUSE
+POPULAR BROWSERS EITHER DO NOT SUPPORT NETSCAPE PLUGINS (CHROME), OR
+REMOVED SUPPORT FOR NETSCAPE PLUGINS OTHER THAN FLASH (FIREFOX).
+We regret this decision because djview/nsdejavu is a perfect
+example of very well behaved plugin that would have been
+easy to support.
+
 Under Unix/X11, djview4 can be used as a browser plugin
 by means of the small shared library named nsdejavu.so.
 The djview3 distributed with djvulibre uses the same approach.
@@ -183,13 +191,9 @@ There are also two ways to compile djvie
 
 * Using Visual C++ 
 
-  - First you need to compile Qt4 using Visual C++.
-    This used to be require patching the Qt source
-    <http://qtnode.net/wiki?title=Qt4_with_Visual_Studio>
-    Starting with Qt-4.3.2, the opensource Qt version
-    supports Visual C++ right out of the box.
-  - Compile djvulibre using the visual C++ method.
-  - Go to directory src
+  - First you need to install Qt5 binaries compatible
+    with your compiler. Sometimes this means
+    compiling Qt yourself.
   - Type command 
        $ qmake -win32 -tp vc
     to generate a MS Visual C++ project file.
--- djview4-4.11.orig/desktopfiles/djvulibre-djview4.desktop
+++ djview4-4.11/desktopfiles/djvulibre-djview4.desktop
@@ -75,3 +75,4 @@ Comment[ru]=Программа прос
 Comment[uk]=Переглядач документів DjVu
 Comment[zh_CN]=DjVu文档查看工具
 Comment[zh_TW]=DjVu文件檢視工具
+Keywords=DjVu;document;presentation;viewer;graphics;
--- djview4-4.11.orig/mac/make_djview_bundle.sh
+++ djview4-4.11/mac/make_djview_bundle.sh
@@ -69,6 +69,10 @@ done
     run ln -s "$target"  "$bundle/$d" || exit
 done
 
+# misc copies
+run cp ../src/djview.1 $bundle/share/man/man1
+run cp $bundle/Resources/qt.conf $bundle/MacOS
+
 # merge MacOS, bin, and plugins directories
 run mv $bundle/bin/* $bundle/MacOS || exit
 run rmdir $bundle/bin || exit
@@ -87,33 +91,42 @@ done
 
 # copy needed qt plugins
 ( cd "$QTDIR" ; \
-  ls -1 plugins/{platforms,imageformats,printsupport}/*.dylib | \
+  ls -1 plugins/{platforms,imageformats,styles,printsupport}/*.dylib | \
+  grep -v libqwebgl.dylib | \
   grep -v _debug.dylib ) | \
 while read plugin ; do
   run mkdir -p $bundle/$(dirname "$plugin") || exit
   run cp "$QTDIR/$plugin" $bundle/"$plugin" || exit
 done
 
+
+
 # copy needed libraries  
-for lib in \
-    $(otool -L $bundle/MacOS/djview | awk '/^\t/{print $1}') \
-    $(otool -L $bundle/MacOS/platforms/libqcocoa.dylib | awk '/^\t/{print $1}') 
-do
-  case "$lib" in 
-    $BREWDIR/*) 
+for loader in \
+    $bundle/MacOS/djview \
+    $bundle/MacOS/*/*.dylib 
+do 
+  for lib in $(otool -L $loader | awk '/^\t/{print $1}') 
+  do
+    if [ $(basename "$lib") != $(basename "$loader") ]
+    then
+      case "$lib" in 
+      $BREWDIR/*) 
         libname=$(basename "$lib")
 	test -r "./$bundle/lib/$libname" || \
 	    run cp "$lib" "./$bundle/lib/$libname" || exit ;;
-    @rpath/*)
+      @rpath/*)
         libname=$(basename "$lib")
         lib="$QTDIR/lib${lib/#@rpath//}"
 	test -r "./$bundle/lib/$libname" || \
 	    run cp "$lib" "./$bundle/lib/$libname" || exit ;;
-    $QTDIR/*)
+      $QTDIR/*)
         libname=$(basename "$lib")
 	test -r "./$bundle/lib/$libname" || \
 	    run cp "$lib" "./$bundle/lib/$libname" || exit ;;
-  esac
+      esac
+    fi
+  done
 done
 
 # copy translations
--- djview4-4.11.orig/nsdejavu/npsdk/prcpucfg.h
+++ djview4-4.11/nsdejavu/npsdk/prcpucfg.h
@@ -236,7 +236,7 @@
 #define PR_BYTES_PER_WORD_LOG2  3
 #define PR_BYTES_PER_DWORD_LOG2 3
 
-#elif defined(__x86_64__)
+#elif defined(__x86_64__) && !defined(__ILP32__)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
@@ -282,6 +282,51 @@
 #define PR_BYTES_PER_WORD_LOG2  3
 #define PR_BYTES_PER_DWORD_LOG2 3
 
+#elif defined(__x86_64__) && defined(__ILP32__)
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#define PR_BYTES_PER_WORD_LOG2  2
+#define PR_BYTES_PER_DWORD_LOG2 3
+
 #elif defined(__mc68000__)
 
 #undef  IS_LITTLE_ENDIAN
--- djview4-4.11.orig/nsdejavu/nsdejavu.1.in
+++ djview4-4.11/nsdejavu/nsdejavu.1.in
@@ -32,6 +32,16 @@ nsdejavu \- DjVu browser plugin
 .SH SYNOPSIS
 .B PLUGINSDIR/NSDEJAVUSO
 
+.SH WARNING
+Using
+.B nsdejavu
+as a plugin in 2020 is very difficult because
+popular browsers either do not support netscape plugins (chrome), or
+removed support for netscape plugins other than flash (firefox).
+We regret this decision because djview/nsdejavu is a perfect
+example of very well behaved plugin that would have been
+easy to support.
+
 .SH DESCRIPTION
 The shared library
 .B NSDEJAVUSO
@@ -39,14 +49,9 @@ uses the Netscape browser plugin
 .SM API
 to display DjVu images in
 in a number of popular web browsers.
-Different web browsers provide various level
-of support for Netscape plugins.
-Please check section "Browser Compatibility"
-for instructions on how to enable the
-DjVu browser plugin.
-
-The DjVuLibre browser plugin works by invoking
-a standalone viewer with the special command line option
+It works by invoking
+a standalone viewer out-of-process
+with the special command line option
 .BR -netscape .
 The plugin first searches a program named
 .BR djview .
--- djview4-4.11.orig/src/djview.pro
+++ djview4-4.11/src/djview.pro
@@ -37,8 +37,8 @@ CONFIG(autoconf) {
     #   QMAKE_LFLAGS += ...
 } else {
     # customize below
-    INCLUDEPATH += /usr/include
-    LIBS += -L/usr/local/lib -ldjvulibre -ljpeg
+    #INCLUDEPATH += /usr/include
+    #LIBS += -L/usr/local/lib -ldjvulibre -ljpeg
     #QMAKE_CXXFLAGS += 
     #QMAKE_CFLAGS += 
     #QMAKE_LFLAGS += 
--- djview4-4.11.orig/src/djview_es.ts
+++ djview4-4.11/src/djview_es.ts
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS version="2.0" language="es">
+<TS version="2.1" language="es">
 <context>
     <name>Generic</name>
     <message>
@@ -535,7 +535,7 @@
         <source>Rotate page image clockwise.</source>
         <translation>Girar página en sentido horario.</translation>
     </message>
-    <message utf8="true">
+    <message>
         <location filename="qdjview.cpp" line="643"/>
         <source>Rotate &amp;0°</source>
         <comment>Rotate|</comment>
@@ -546,7 +546,7 @@
         <source>Set natural page orientation.</source>
         <translation>Ajustar orientación natural.</translation>
     </message>
-    <message utf8="true">
+    <message>
         <location filename="qdjview.cpp" line="649"/>
         <source>Rotate &amp;90°</source>
         <comment>Rotate|</comment>
@@ -557,7 +557,7 @@
         <source>Turn page on its left side.</source>
         <translation>Girar páagina sobre su lado izquuierdo.</translation>
     </message>
-    <message utf8="true">
+    <message>
         <location filename="qdjview.cpp" line="655"/>
         <source>Rotate &amp;180°</source>
         <comment>Rotate|</comment>
@@ -568,7 +568,7 @@
         <source>Turn page upside-down.</source>
         <translation>Girar página al revés.</translation>
     </message>
-    <message utf8="true">
+    <message>
         <location filename="qdjview.cpp" line="661"/>
         <source>Rotate &amp;270°</source>
         <comment>Rotate|</comment>
@@ -1335,7 +1335,7 @@ Nombre de archgivo &apos;%1&apos; no tie
     <message>
         <location filename="qdjview.cpp" line="4042"/>
         <source> (in other window.)</source>
-        <translation>(en otra ventana)</translation>
+        <translation> (en otra ventana.)</translation>
     </message>
     <message>
         <location filename="qdjview.cpp" line="4131"/>
@@ -1425,7 +1425,7 @@ Nombre de archgivo &apos;%1&apos; no tie
         <source>Save into the clipboard a maparea annotation expression for program djvused.</source>
         <translation>Guarddar en el portapapeles una expresión de la anotación de Mapa de Imágenes para el programa djvused.</translation>
     </message>
-    <message utf8="true">
+    <message>
         <location filename="qdjview.cpp" line="4359"/>
         <source>&lt;html&gt;&lt;h2&gt;DjVuLibre DjView %1&lt;/h2&gt;%2&lt;p&gt;Viewer for DjVu documents&lt;br&gt;&lt;a href=%3&gt;%3&lt;/a&gt;&lt;br&gt;Copyright © 2006-- Léon Bottou.&lt;/p&gt;&lt;p align=justify&gt;&lt;small&gt;This program is free software. You can redistribute or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This program is distributed &lt;i&gt;without any warranty&lt;/i&gt;. See the GNU General Public License for more details.&lt;/small&gt;&lt;/p&gt;&lt;/html&gt;</source>
         <translation>&lt;html&gt;&lt;h2&gt;DjVuLibre DjView %1&lt;/h2&gt;%2&lt;p&gt;Visor para documentos DjVu&lt;br&gt;&lt;a href=%3&gt;%3&lt;/a&gt;&lt;br&gt;Copyright © 2006-- Léon Bottou.&lt;/p&gt;&lt;p align=justify&gt;&lt;small&gt;Este programa es software libre. Usted puede redistribuirlo o modificarlo bajo los términos de la GNU General Public License publicada por la Free Software Foundation. Este programa es distribuido &lt;i&gt;sin garantía alguna&lt;/i&gt;. Ver la GNU General Public License para mayor información.&lt;/small&gt;&lt;/p&gt;&lt;/html&gt;</translation>
@@ -1515,7 +1515,8 @@ Opciones comunes incluyen:
 -page=&lt;page&gt;~~~Ir a página &lt;page&gt;.
 -zoom=&lt;zoom&gt;~~~Ajustar ampliación en un factor &lt;zoom&gt;.
 -continuous=&lt;yn&gt;~~~Ajustar desplazamiento continuo.
--sidebyside=&lt;yn&gt;~~~Ajustar vista de dos páginas.</translation>
+-sidebyside=&lt;yn&gt;~~~Ajustar vista de dos páginas.
+</translation>
     </message>
 </context>
 <context>
@@ -1804,7 +1805,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexportps2.ui" line="76"/>
         <source> %</source>
-        <translation>%</translation>
+        <translation> %</translation>
     </message>
     <message>
         <location filename="qdjviewexportps2.ui" line="100"/>
@@ -1847,7 +1848,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexportps3.ui" line="55"/>
         <source>Sheets per booklet: </source>
-        <translation>Hojas por folleto:</translation>
+        <translation>Hojas por folleto: </translation>
     </message>
     <message>
         <location filename="qdjviewexportps3.ui" line="62"/>
@@ -1857,12 +1858,12 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexportps3.ui" line="65"/>
         <source>at most </source>
-        <translation>a lo sumo</translation>
+        <translation>a lo sumo </translation>
     </message>
     <message>
         <location filename="qdjviewexportps3.ui" line="98"/>
         <source>Print </source>
-        <translation>Imprimir</translation>
+        <translation>Imprimir </translation>
     </message>
     <message>
         <location filename="qdjviewexportps3.ui" line="112"/>
@@ -1882,12 +1883,12 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexportps3.ui" line="153"/>
         <source>Shift rectos and versos by </source>
-        <translation>Cambiar delantera y trasera por</translation>
+        <translation>Cambiar delantera y trasera por </translation>
     </message>
     <message>
         <location filename="qdjviewexportps3.ui" line="160"/>
         <source> points.</source>
-        <translation>puntos.</translation>
+        <translation> puntos.</translation>
     </message>
     <message>
         <location filename="qdjviewexportps3.ui" line="196"/>
@@ -1897,7 +1898,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexportps3.ui" line="203"/>
         <source> points</source>
-        <translation>puntos</translation>
+        <translation> puntos</translation>
     </message>
     <message>
         <location filename="qdjviewexportps3.ui" line="216"/>
@@ -1970,7 +1971,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexportprn.ui" line="117"/>
         <source> %</source>
-        <translation>%</translation>
+        <translation> %</translation>
     </message>
     <message>
         <location filename="qdjviewexportprn.ui" line="141"/>
@@ -2008,12 +2009,12 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewexporttiff.ui" line="37"/>
         <source>Maximum image resolution </source>
-        <translation>Resolución máxima de imagen</translation>
+        <translation>Resolución máxima de imagen </translation>
     </message>
     <message>
         <location filename="qdjviewexporttiff.ui" line="44"/>
         <source> dpi</source>
-        <translation>dpi</translation>
+        <translation> dpi</translation>
     </message>
     <message>
         <location filename="qdjviewexporttiff.ui" line="76"/>
@@ -2061,12 +2062,12 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewsidebar.cpp" line="1625"/>
         <source>Find Previous (Shift+F3) </source>
-        <translation>Buscar anterior (Shift+F3)</translation>
+        <translation>Buscar anterior (Shift+F3) </translation>
     </message>
     <message>
         <location filename="qdjviewsidebar.cpp" line="1630"/>
         <source>Find Next (F3) </source>
-        <translation>Buscar siguiente (F3)</translation>
+        <translation>Buscar siguiente (F3) </translation>
     </message>
     <message>
         <location filename="qdjviewsidebar.cpp" line="1636"/>
@@ -2203,7 +2204,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewinfodialog.ui" line="108"/>
         <source>File: </source>
-        <translation>Archivo:</translation>
+        <translation>Archivo: </translation>
     </message>
     <message>
         <location filename="qdjviewinfodialog.ui" line="154"/>
@@ -2260,7 +2261,7 @@ Do you want to replace it?</source>
         <source>Waiting for data...</source>
         <translation>Esperando datos...</translation>
     </message>
-    <message utf8="true">
+    <message>
         <location filename="qdjviewdialogs.cpp" line="502"/>
         <source>Page #%1 - « %2 »</source>
         <translation>Página #%1 - « %2 »</translation>
@@ -2350,17 +2351,17 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewdialogs.cpp" line="588"/>
         <source> Page </source>
-        <translation>Página </translation>
+        <translation> Página </translation>
     </message>
     <message>
         <location filename="qdjviewdialogs.cpp" line="590"/>
         <source> Thumbnails </source>
-        <translation>Miniatura </translation>
+        <translation> Miniatura </translation>
     </message>
     <message>
         <location filename="qdjviewdialogs.cpp" line="592"/>
         <source> Shared </source>
-        <translation>Compartido </translation>
+        <translation> Compartido </translation>
     </message>
 </context>
 <context>
@@ -2404,12 +2405,12 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewdialogs.cpp" line="662"/>
         <source> Key </source>
-        <translation>Clave</translation>
+        <translation> Clave </translation>
     </message>
     <message>
         <location filename="qdjviewdialogs.cpp" line="662"/>
         <source> Value </source>
-        <translation>Valor</translation>
+        <translation> Valor </translation>
     </message>
     <message>
         <location filename="qdjviewdialogs.cpp" line="706"/>
@@ -2623,7 +2624,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="234"/>
         <source> dpi</source>
-        <translation>dpi</translation>
+        <translation> dpi</translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="268"/>
@@ -2698,7 +2699,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="415"/>
         <source>Timer:  </source>
-        <translation>Avanzar cada: </translation>
+        <translation>Avanzar cada:  </translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="428"/>
@@ -2814,7 +2815,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="780"/>
         <source> pixels</source>
-        <translation>pixeles</translation>
+        <translation> pixeles</translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="816"/>
@@ -2865,17 +2866,17 @@ Do you want to replace it?</source>
         <location filename="qdjviewprefsdialog.ui" line="949"/>
         <location filename="qdjviewprefsdialog.ui" line="962"/>
         <source> MB</source>
-        <translation>MB</translation>
+        <translation> MB</translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="978"/>
         <source>&amp;Decoded page cache: </source>
-        <translation>Cache de páginas &amp;decodificadas:</translation>
+        <translation>Cache de páginas &amp;decodificadas: </translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="988"/>
         <source>&amp;Pixel cache: </source>
-        <translation>Cache de &amp;pixeles:</translation>
+        <translation>Cache de &amp;pixeles: </translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="1015"/>
@@ -3044,7 +3045,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewprintdialog.ui" line="182"/>
         <source>Printer name: </source>
-        <translation>Nombre impresora:</translation>
+        <translation>Nombre impresora: </translation>
     </message>
     <message>
         <location filename="qdjviewprintdialog.ui" line="207"/>
--- djview4-4.11.orig/src/djview_ru.ts
+++ djview4-4.11/src/djview_ru.ts
@@ -2640,7 +2640,7 @@ Do you want to replace it?</source>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="1091"/>
         <source>Render with openGL when available</source>
-        <translation>Нарисуйте с OpenGL при наличии</translation>
+        <translation>Использовать ускорение OpenGL, если это возможно</translation>
     </message>
     <message>
         <location filename="qdjviewprefsdialog.ui" line="1101"/>
--- djview4-4.11.orig/src/qdjviewdialogs.cpp
+++ djview4-4.11/src/qdjviewdialogs.cpp
@@ -156,6 +156,9 @@ QDjViewErrorDialog::error(QString msg, Q
   while (d->messages.size() >= 16)
     d->messages.removeLast();
   compose();
+  // For verbose mode
+  QByteArray msga = msg.toLocal8Bit();
+  qWarning("%s", msga.constData());
 }
 
 void 
@@ -772,6 +775,7 @@ metadataFill(QTableWidget *table, QMap<Q
   int nkeys = keys.size();
   table->setRowCount(nkeys);
   table->setSortingEnabled(false);
+  table->setWordWrap(false);
   for(int j = 0; j < nkeys; j++)
     {
       QTableWidgetItem *kitem = new QTableWidgetItem(keys[j]);
--- djview4-4.11.orig/src/qdjviewplugin.cpp
+++ djview4-4.11/src/qdjviewplugin.cpp
@@ -52,8 +52,14 @@
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
+#ifdef Q_OS_UNIX
+# include <unistd.h>
+# include <fcntl.h>
+#endif
+#ifdef Q_OS_WIN32
+# include <io.h>
+# include <fcntl.h>
+#endif
 
 #if QT_VERSION < 0x50000
 # if defined(Q_WS_X11)
@@ -196,52 +202,46 @@ struct my_xcb_configure_notify_event_t
 class my_timer_object_t : public QObject 
 {
   Q_OBJECT
-  quint32 wid;
-  quint16 w,h;
+  quint32 wid; quint16 w,h; int tid; bool tidp;
 public:
-  my_timer_object_t(quint32, quint16, quint16);
+  my_timer_object_t(quint32 wid)
+    : wid(wid), tid(0), tidp(false) {}
+  void start(quint16 ww, quint16 hh) {
+    if (tidp) killTimer(tid);
+    tidp = true; w = ww; h = hh; startTimer(100); } 
   void timerEvent(QTimerEvent*);
 };
 
 struct my_event_filter_t : public QAbstractNativeEventFilter
 {
-  QMap<quint32,QDjViewPlugin::Instance*> instances;
   virtual bool nativeEventFilter(const QByteArray &type, void *msg, long*);
+  QMap<quint32,QDjViewPlugin::Instance*> instances;
+  QMap<quint32,my_timer_object_t*> timers;
+  static my_event_filter_t *instance() {
+    static my_event_filter_t *filter = 0;
+    return filter ? filter : filter = new my_event_filter_t; }
 };
 
-static my_event_filter_t *my_event_filter()
-{
-  static my_event_filter_t *filter = 0;
-  if (! filter) filter = new my_event_filter_t;
-  return filter;
-}
-
-my_timer_object_t::my_timer_object_t(quint32 wid, quint16 w, quint16 h)
-  : wid(wid), w(w), h(h) 
+bool my_event_filter_t::nativeEventFilter(const QByteArray &type, void *msg, long*)
 {
-  startTimer(1);
+  if (type != "xcb_generic_event_t") return false;
+  my_xcb_configure_notify_event_t *ev = (my_xcb_configure_notify_event_t*)msg;
+  if (! (ev->response_type == 22 && instances.contains(ev->window))) return false;
+  if (! timers.contains(ev->window)) timers.insert(ev->window, new my_timer_object_t(ev->window));
+  timers.value(ev->window)->start(ev->width, ev->height);
+  return false;
 }
 
-void my_timer_object_t::timerEvent(QTimerEvent *ev)
+void my_timer_object_t::timerEvent(QTimerEvent*)
 {
-  QDjViewPlugin::Instance *instance = my_event_filter()->instances.value(wid,0);
+  my_event_filter_t *f = my_event_filter_t::instance();
+  QDjViewPlugin::Instance *instance = f->instances.value(wid,0);
   if (instance && instance->shell) // test for resizing bug
     if (instance->shell->width() != w || instance->shell->height() != h )
       instance->shell->resize((int)w, (int)h);
-  killTimer(ev->timerId());
+  f->timers.remove(wid);
+  killTimer(tid);
   deleteLater();
-  wid = 0;
-}
-
-bool my_event_filter_t::nativeEventFilter(const QByteArray &type, void *msg, long*)
-{
-  if (type == "xcb_generic_event_t")
-    {
-      my_xcb_configure_notify_event_t *ev = (my_xcb_configure_notify_event_t*)msg;
-      if (ev->response_type == 22 && instances.contains(ev->window) )
-        new my_timer_object_t(ev->window, ev->width, ev->height);
-    }
-  return false;
 }
 
 #endif
@@ -593,7 +593,7 @@ QDjViewPlugin::Instance::destroy()
         window->setVisible(false);
         window->setParent(0);
 # if WORKAROUND_QT55_XEMBED_BUG
-        my_event_filter()->instances.remove((quint32)shell->winId());
+        my_event_filter_t::instance()->instances.remove((quint32)shell->winId());
 # endif
       }
 #elif HAVE_X11
@@ -991,7 +991,7 @@ QDjViewPlugin::cmdAttachWindow()
       application->installEventFilter(forwarder);
 #endif
 #if WORKAROUND_QT55_XEMBED_BUG
-      application->installNativeEventFilter(my_event_filter());
+      application->installNativeEventFilter(my_event_filter_t::instance());
 #endif
       QObject::connect(application, SIGNAL(lastWindowClosed()), 
                        forwarder, SLOT(lastViewerClosed()));
@@ -1028,7 +1028,7 @@ QDjViewPlugin::cmdAttachWindow()
           instance->containerwin = cwindow;
           dwindow->setParent(cwindow);
 # if WORKAROUND_QT55_XEMBED_BUG
-          my_event_filter()->instances.insert((quint32)shell->winId(), instance);
+          my_event_filter_t::instance()->instances.insert((quint32)shell->winId(), instance);
 # endif
         }
       else
@@ -1446,7 +1446,8 @@ QDjViewPlugin::instance()
 int 
 QDjViewPlugin::exec()
 {
-#ifndef QT_NO_DEBUG
+#ifdef Q_OS_UNIX
+ #ifndef QT_NO_DEBUG
   const char *s = ::getenv("DJVIEW_DEBUG");
   if (s && strcmp(s,"0"))
     {
@@ -1455,6 +1456,7 @@ QDjViewPlugin::exec()
       while (loop)
         sleep(1);
     }
+# endif
 #endif
   returnCode = 0;
   quitFlag = false;
--- djview4-4.11.orig/src/qdjviewprefs.cpp
+++ djview4-4.11/src/qdjviewprefs.cpp
@@ -1156,8 +1156,10 @@ QDjViewPrefsDialog::reset()
         case QDjView::STANDALONE_SLIDESHOW:
           d->saved[i].remember = false;
           d->saved[i].zoom = QDjVuWidget::ZOOM_FITPAGE;
+          /* FALLTHRU */
         case QDjView::STANDALONE_FULLSCREEN:
           d->saved[i].options &= ~(optMSS|optS|optT);
+          /* FALLTHRU */
         case QDjView::STANDALONE:
           break;
         case QDjView::EMBEDDED_PLUGIN:
--- djview4-4.11.orig/src/qdjvuwidget.cpp
+++ djview4-4.11/src/qdjvuwidget.cpp
@@ -1932,7 +1932,7 @@ QDjVuPrivate::pageinfoPage(QDjVuPage *pa
         case DDJVU_JOB_OK:
           if (p)
             getAnnotationsAndText(p);
-          // no break!
+          /* FALLTHRU */
         case DDJVU_JOB_STARTED:
           if (p && p->dpi <= 0)
             {
@@ -4374,12 +4374,14 @@ QDjVuPrivate::paintHiddenText(QImage &im
                     case 2:
                       paint.translate(dw, dh);
                       paint.rotate(180);
+                      /* FALLTHRU */
                     default:
                       paint.scale(dw/bw, dh/bh);
                       break;
                     case 3:
                       paint.translate(dw, dh);
                       paint.rotate(180);
+                      /* FALLTHRU */
                     case 1:
                       paint.translate(dw, 0);
                       paint.rotate(90);
--- djview4-4.11.orig/src/tiff2pdf.c
+++ djview4-4.11/src/tiff2pdf.c
@@ -85,11 +85,29 @@
 #ifndef TIFFmin
 # define TIFFmin(A,B) ((A)<(B)?(A):(B))
 #endif
+#ifndef TIFFclip
+# define TIFFclip(A,B) ((A)<(0)?(0):((A)>(B)?(B):(A)))
+#endif
 
 #ifdef HAVE_GETOPT_H
 # include <getopt.h>
 #endif
 
+#if defined(_WIN32) && defined(_MSC_VER)
+# ifndef HAVE_SNPRINTF
+# define snprintf mysnprintf
+static int
+snprintf(char* str, size_t size, const char* format, ...)
+{
+  int count;
+  va_list ap;
+  va_start(ap, format);
+  count = vsnprintf(str, size, format, ap);
+  va_end(ap);
+  return count;
+}
+# endif
+#endif
 
 
 #ifndef HAVE_GETOPT_H
@@ -3848,8 +3866,8 @@ t2p_sample_rgbaa_to_rgb(tdata_t data, ui
     /* For the 3 first samples, there is overlapping between souce and
        destination, so use memmove().
        See http://bugzilla.maptools.org/show_bug.cgi?id=2577 */
-    for(i = 0; i < 3 && i < samplecount; i++)
-        memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
+	for(i = 0; i < 3 && i < samplecount; i++)
+		memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
 	for(; i < samplecount; i++)
 		memcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
 
@@ -4266,13 +4284,13 @@ void t2p_pdf_currenttime(T2P* t2p)
 
 	currenttime = localtime(&timenow);
 	snprintf(t2p->pdf_datetime, sizeof(t2p->pdf_datetime),
-		 "D:%.4d%.2d%.2d%.2d%.2d%.2d",
-		 (currenttime->tm_year + 1900) % 65536,
-		 (currenttime->tm_mon + 1) % 256,
-		 (currenttime->tm_mday) % 256,
-		 (currenttime->tm_hour) % 256,
-		 (currenttime->tm_min) % 256,
-		 (currenttime->tm_sec) % 256);
+             "D:%.4d%.2d%.2d%.2d%.2d%.2d",
+             TIFFclip( (currenttime->tm_year + 1900) % 65536 , 9999),
+             TIFFclip( (currenttime->tm_mon + 1) % 256 , 99),
+             TIFFclip( (currenttime->tm_mday) % 256 , 99),
+             TIFFclip( (currenttime->tm_hour) % 256 , 99),
+             TIFFclip( (currenttime->tm_min) % 256 , 99),
+             TIFFclip( (currenttime->tm_sec) % 256 , 99));
 
 	return;
 }
