Skip to content

Commit

Permalink
Use XQueryPointer() instead to detect zaphod
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CendioOssman committed Apr 10, 2024
1 parent c987d61 commit 34d9692
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions vncviewer/DesktopWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34d9692

Please sign in to comment.