From 34d96928632b79196cc3d46aa2abd7c1f1122593 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 10 Apr 2024 12:37:45 +0200 Subject: Use XQueryPointer() instead to detect zaphod FLTK can send events with fl_xevent pointing to random memory, which means that we cannot trust that structure. XQueryPointer() can give us what we need, at the cost of an extra round trip. --- vncviewer/DesktopWindow.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'vncviewer') diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index b85485b2..7d7ae7c3 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -850,11 +850,15 @@ int DesktopWindow::handle(int event) (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))) { + Window root, child; + int x, y, wx, wy; + unsigned int mask; + + // We also don't get sensible coordinates on zaphod setups + if (XQueryPointer(fl_display, fl_xid(this), &root, &child, + &x, &y, &wx, &wy, &mask) && + (root != XRootWindow(fl_display, fl_screen))) { ungrabPointer(); } #endif -- cgit v1.2.3