From be88293952175258992c1ed2f5a1b7d8f78fe7cc Mon Sep 17 00:00:00 2001
From: Pierre Ossman <ossman@cendio.se>
Date: Tue, 31 Jul 2018 16:06:59 +0200
Subject: Ignore buttons in mouse leave events

For KDE we can sometimes get a bunch of stray FL_LEAVE events before
gaining focus. Sending their included button information gets things
in the incorrect order with regard to other synchronisation we do on
focus. So just ignore buttons as the only information we want out of
the leave information is a position update.

diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index ff27f7bf..7b5df572 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -587,7 +587,10 @@ int Viewport::handle(int event)
 
   case FL_LEAVE:
     window()->cursor(FL_CURSOR_DEFAULT);
-    // Fall through as we want a last move event to help trigger edge stuff
+    // We want a last move event to help trigger edge stuff
+    handlePointerEvent(Point(Fl::event_x() - x(), Fl::event_y() - y()), 0);
+    return 1;
+
   case FL_PUSH:
   case FL_RELEASE:
   case FL_DRAG:
