Merge branch 'x0-xdesktop-initial-cursor' of https://github.com/x11clone/x11clone
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 2f8889d..0e97a78 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -379,9 +379,10 @@
 {
   if (state() != RFBSTATE_NORMAL) return;
   // Are we switching between client-side and server-side cursor?
-  if (damagedCursorRegion.is_empty() != needRenderedCursor())
+  bool hasRenderedCursor = !damagedCursorRegion.is_empty();
+  if (hasRenderedCursor != needRenderedCursor())
     setCursorOrClose();
-  if (!damagedCursorRegion.is_empty())
+  if (hasRenderedCursor)
     removeRenderedCursor = true;
   if (needRenderedCursor()) {
     updateRenderedCursor = true;
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index 46c4be9..f27099f 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -529,6 +529,13 @@
       return false;
 
     writeUpdate();
+
+    // If this is the first iteration then we need to adjust the timeout
+    if (frameTimer.getTimeoutMs() != 1000/rfb::Server::frameRate) {
+      frameTimer.start(1000/rfb::Server::frameRate);
+      return false;
+    }
+
     return true;
   }
 
@@ -573,7 +580,10 @@
   if (blockCounter > 0)
     return;
 
-  frameTimer.start(1000/rfb::Server::frameRate);
+  // The first iteration will be just half a frame as we get a very
+  // unstable update rate if we happen to be perfectly in sync with
+  // the application's update rate
+  frameTimer.start(1000/rfb::Server::frameRate/2);
 }
 
 void VNCServerST::stopFrameClock()
diff --git a/contrib/packages/deb/ubuntu-xenial/debian/control b/contrib/packages/deb/ubuntu-xenial/debian/control
index c063496..c947f45 100644
--- a/contrib/packages/deb/ubuntu-xenial/debian/control
+++ b/contrib/packages/deb/ubuntu-xenial/debian/control
@@ -9,7 +9,7 @@
 Package: tigervncserver
 Architecture: any
 Provides: xserver, vnc-server
-Depends: x11-common | xserver-common, x11-utils, xauth, libbz2-1.0, libc6, libfontenc1, libfreetype6, libgcc1, libgl1-mesa-dri, libgnutls30, libjpeg-turbo8, libp11-kit0, libpam0g, libpixman-1-0, libstdc++6, libtasn1-3-bin, libx11-6, libxau6, libxcb1, libxdmcp6, libxext6, libxfont1, libxtst6, zlib1g, libglu1-mesa, libxcursor1, libxinerama1, libxfixes3, x11-xkb-utils, libgcrypt20
+Depends: x11-common | xserver-common, x11-utils, xauth, libbz2-1.0, libc6, libfontenc1, libfreetype6, libgcc1, libgl1-mesa-dri, libgnutls30, libjpeg-turbo8, libp11-kit0, libpam0g, libpixman-1-0, libstdc++6, libtasn1-3-bin, libx11-6, libxau6, libxcb1, libxdmcp6, libxext6, libxfont1, libxfont1-dev, libxtst6, zlib1g, libglu1-mesa, libxcursor1, libxinerama1, libxfixes3, x11-xkb-utils, libgcrypt20
 Recommends: xfonts-base, x11-xserver-utils
 Suggests: xtigervncviewer, tigervnc-java
 Description: virtual network computing server software
diff --git a/contrib/packages/rpm/el7/SPECS/tigervnc.spec b/contrib/packages/rpm/el7/SPECS/tigervnc.spec
index ac58d5b..2f74fcb 100644
--- a/contrib/packages/rpm/el7/SPECS/tigervnc.spec
+++ b/contrib/packages/rpm/el7/SPECS/tigervnc.spec
@@ -31,7 +31,7 @@
 BuildRequires:  libdrm-devel, libXt-devel, pixman-devel libXfont-devel
 BuildRequires:  libxkbfile-devel, openssl-devel, libpciaccess-devel
 BuildRequires:  mesa-libGL-devel, libXinerama-devel, ImageMagick
-BuildRequires:  freetype-devel, libXdmcp-devel
+BuildRequires:  freetype-devel, libXdmcp-devel, libXfont2-devel
 BuildRequires:  java-devel, jpackage-utils
 BuildRequires:  libjpeg-turbo-devel, gnutls-devel, pam-devel
 BuildRequires:  systemd, cmake
@@ -162,7 +162,7 @@
 for all in `find . -type f -perm -001`; do
         chmod -x "$all"
 done
-patch -p1 -b --suffix .vnc < ../xserver117.patch
+patch -p1 -b --suffix .vnc < ../xserver119.patch
 popd
 
 # Don't use shebang in vncserver script.