From 7a2af97447ffbfeccf67de9a7f9eb1acd447ac9a Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 8 Mar 2023 18:15:33 +0100 Subject: [PATCH] Detect leaving window on zaphod systems The coordinates we get are relative the root window of each screen, so we can only trust them if we are on the same screen. So let's explicitly check that we are still getting events from the expected screen by checking the root window field of the event. --- vncviewer/DesktopWindow.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index c5952094..b85485b2 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -844,12 +844,20 @@ int DesktopWindow::handle(int event) case FL_LEAVE: case FL_DRAG: case FL_MOVE: - // We don't get FL_LEAVE with a grabbed pointer, so check manually if (mouseGrabbed) { + // We don't get FL_LEAVE with a grabbed pointer, so check manually if ((Fl::event_x() < 0) || (Fl::event_x() >= w()) || (Fl::event_y() < 0) || (Fl::event_y() >= h())) { ungrabPointer(); } + // We also don't get sensible coordinates on zaphod setups +#if !defined(WIN32) && !defined(__APPLE__) + if ((fl_xevent != NULL) && (fl_xevent->type == MotionNotify) && + (((XMotionEvent*)fl_xevent)->root != + XRootWindow(fl_display, fl_screen))) { + ungrabPointer(); + } +#endif } if (fullscreen_active()) { // calculate width of "edge" regions -- 2.39.5