Merge branch 'qemukbd-merge' of https://github.com/CendioOssman/tigervnc
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index 8a053e3..d60f62b 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -254,6 +254,11 @@
     if (gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cert_cred) != GNUTLS_E_SUCCESS)
       throw AuthFailureException("gnutls_credentials_set failed");
 
+    if (gnutls_server_name_set(session, GNUTLS_NAME_DNS,
+                               client->getServerName(),
+                               strlen(client->getServerName())) != GNUTLS_E_SUCCESS)
+      vlog.error("Failed to configure the server name for TLS handshake");
+
     vlog.debug("X509 session has been set");
   }
 }
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 674c392..cf37fdd 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -66,6 +66,8 @@
   unsigned inFlight;
 };
 
+static Cursor emptyCursor(0, 0, Point(0, 0), NULL);
+
 VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
                                    bool reverse)
   : sock(s), reverseConnection(reverse),
@@ -376,6 +378,9 @@
 void VNCSConnectionST::renderedCursorChange()
 {
   if (state() != RFBSTATE_NORMAL) return;
+  // Are we switching between client-side and server-side cursor?
+  if (damagedCursorRegion.is_empty() != needRenderedCursor())
+    setCursorOrClose();
   if (!damagedCursorRegion.is_empty())
     removeRenderedCursor = true;
   if (needRenderedCursor()) {
@@ -1257,7 +1262,11 @@
   if (state() != RFBSTATE_NORMAL)
     return;
 
-  cp.setCursor(*server->cursor);
+  // We need to blank out the client's cursor or there will be two
+  if (needRenderedCursor())
+    cp.setCursor(emptyCursor);
+  else
+    cp.setCursor(*server->cursor);
 
   if (!writer()->writeSetCursorWithAlpha()) {
     if (!writer()->writeSetCursor()) {
diff --git a/vncviewer/FLTKPixelBuffer.cxx b/vncviewer/FLTKPixelBuffer.cxx
deleted file mode 100644
index ab116d1..0000000
--- a/vncviewer/FLTKPixelBuffer.cxx
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright 2011-2014 Pierre Ossman for Cendio AB
- * 
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-#include <FL/fl_draw.H>
-
-#include <rfb/Exception.h>
-
-#include "i18n.h"
-#include "FLTKPixelBuffer.h"
-
-FLTKPixelBuffer::FLTKPixelBuffer(int width, int height) :
-  PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true,
-                                       255, 255, 255, 0, 8, 16),
-                      width, height, NULL, width)
-{
-  data = new rdr::U8[width * height * format.bpp/8];
-  if (data == NULL)
-    throw rfb::Exception(_("Not enough memory for framebuffer"));
-}
-
-FLTKPixelBuffer::~FLTKPixelBuffer()
-{
-  delete [] data;
-}
-
-void FLTKPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
-{
-  int pixel_bytes, stride_bytes;
-  const uchar *buf_start;
-
-  pixel_bytes = format.bpp/8;
-  stride_bytes = pixel_bytes * stride;
-  buf_start = data +
-              pixel_bytes * src_x +
-              stride_bytes * src_y;
-
-  fl_draw_image(buf_start, x, y, w, h, pixel_bytes, stride_bytes);
-}
diff --git a/vncviewer/FLTKPixelBuffer.h b/vncviewer/FLTKPixelBuffer.h
deleted file mode 100644
index 148c626..0000000
--- a/vncviewer/FLTKPixelBuffer.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2011-2014 Pierre Ossman for Cendio AB
- * 
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-#ifndef __FLTKPIXELBUFFER_H__
-#define __FLTKPIXELBUFFER_H__
-
-#include "PlatformPixelBuffer.h"
-
-class FLTKPixelBuffer: public PlatformPixelBuffer {
-public:
-  FLTKPixelBuffer(int width, int height);
-  ~FLTKPixelBuffer();
-
-  virtual void draw(int src_x, int src_y, int x, int y, int w, int h);
-};
-
-
-#endif