2022-08-27 12:18:37 +00:00
|
|
|
From f783d5c8b567199178b6690f347e060a69d2aa36 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jan Grulich <jgrulich@redhat.com>
|
|
|
|
Date: Thu, 11 Aug 2022 13:15:29 +0200
|
|
|
|
Subject: [PATCH] x0vncserver: update/display cursor only on correct screen in
|
|
|
|
zaphod mode
|
|
|
|
|
|
|
|
We have to check whether we update cursor position/shape only in case
|
|
|
|
the cursor is on our display, otherwise in zaphod mode, ie. when having
|
|
|
|
two instances of x0vncserver on screens :0.0 and :0.1 we would be having
|
|
|
|
the cursor duplicated and actually not funcional (aka ghost cursor) as
|
|
|
|
it would be actually not present. We also additionally watch EnterNotify
|
|
|
|
and LeaveNotify events in order to show/hide cursor accordingly.
|
|
|
|
|
|
|
|
Change made with help from Olivier Fourdan <ofourdan@redhat.com>
|
|
|
|
---
|
|
|
|
unix/x0vncserver/XDesktop.cxx | 60 +++++++++++++++++++++++++++++++----
|
|
|
|
1 file changed, 53 insertions(+), 7 deletions(-)
|
|
|
|
|
2022-08-19 18:19:55 +00:00
|
|
|
diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx
|
2022-08-27 12:18:37 +00:00
|
|
|
index f2046e43e..f07fd78bf 100644
|
2022-08-19 18:19:55 +00:00
|
|
|
--- a/unix/x0vncserver/XDesktop.cxx
|
|
|
|
+++ b/unix/x0vncserver/XDesktop.cxx
|
2022-08-27 12:18:37 +00:00
|
|
|
@@ -192,7 +192,8 @@ XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
|
2022-08-19 18:19:55 +00:00
|
|
|
RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask);
|
|
|
|
/* Override TXWindow::init input mask */
|
|
|
|
XSelectInput(dpy, DefaultRootWindow(dpy),
|
|
|
|
- PropertyChangeMask | StructureNotifyMask | ExposureMask);
|
2022-08-27 12:18:37 +00:00
|
|
|
+ PropertyChangeMask | StructureNotifyMask |
|
|
|
|
+ ExposureMask | EnterWindowMask | LeaveWindowMask);
|
2022-08-19 18:19:55 +00:00
|
|
|
} else {
|
|
|
|
#endif
|
|
|
|
vlog.info("RANDR extension not present");
|
2022-08-27 12:18:37 +00:00
|
|
|
@@ -217,11 +218,13 @@ void XDesktop::poll() {
|
2022-08-19 18:19:55 +00:00
|
|
|
Window root, child;
|
|
|
|
int x, y, wx, wy;
|
|
|
|
unsigned int mask;
|
|
|
|
- XQueryPointer(dpy, DefaultRootWindow(dpy), &root, &child,
|
|
|
|
- &x, &y, &wx, &wy, &mask);
|
|
|
|
- x -= geometry->offsetLeft();
|
|
|
|
- y -= geometry->offsetTop();
|
|
|
|
- server->setCursorPos(rfb::Point(x, y), false);
|
2022-08-27 12:18:37 +00:00
|
|
|
+
|
|
|
|
+ if (XQueryPointer(dpy, DefaultRootWindow(dpy), &root, &child,
|
|
|
|
+ &x, &y, &wx, &wy, &mask)) {
|
2022-08-19 18:19:55 +00:00
|
|
|
+ x -= geometry->offsetLeft();
|
|
|
|
+ y -= geometry->offsetTop();
|
|
|
|
+ server->setCursorPos(rfb::Point(x, y), false);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
2022-08-27 12:18:37 +00:00
|
|
|
|
|
|
|
@@ -253,7 +256,14 @@ void XDesktop::start(VNCServer* vs) {
|
2022-08-19 18:19:55 +00:00
|
|
|
#endif
|
2022-08-27 12:18:37 +00:00
|
|
|
|
2022-08-19 18:19:55 +00:00
|
|
|
#ifdef HAVE_XFIXES
|
|
|
|
- setCursor();
|
|
|
|
+ Window root, child;
|
|
|
|
+ int x, y, wx, wy;
|
|
|
|
+ unsigned int mask;
|
|
|
|
+ // Check whether the cursor is initially on our screen
|
2022-08-27 12:18:37 +00:00
|
|
|
+ if (XQueryPointer(dpy, DefaultRootWindow(dpy), &root, &child,
|
|
|
|
+ &x, &y, &wx, &wy, &mask))
|
2022-08-19 18:19:55 +00:00
|
|
|
+ setCursor();
|
|
|
|
+
|
|
|
|
#endif
|
2022-08-27 12:18:37 +00:00
|
|
|
|
2022-08-19 18:19:55 +00:00
|
|
|
server->setLEDState(ledState);
|
2022-08-27 12:18:37 +00:00
|
|
|
@@ -701,6 +711,15 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
|
2022-08-19 18:19:55 +00:00
|
|
|
if (cev->subtype != XFixesDisplayCursorNotify)
|
|
|
|
return false;
|
2022-08-27 12:18:37 +00:00
|
|
|
|
|
|
|
+ Window root, child;
|
|
|
|
+ int x, y, wx, wy;
|
|
|
|
+ unsigned int mask;
|
|
|
|
+
|
|
|
|
+ // Check whether the cursor is initially on our screen
|
|
|
|
+ if (!XQueryPointer(dpy, DefaultRootWindow(dpy), &root, &child,
|
|
|
|
+ &x, &y, &wx, &wy, &mask))
|
2022-08-19 18:19:55 +00:00
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
return setCursor();
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_XRANDR
|
2022-08-27 12:18:37 +00:00
|
|
|
@@ -753,6 +772,33 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
|
|
|
|
|
2022-08-19 18:19:55 +00:00
|
|
|
return true;
|
|
|
|
#endif
|
2022-08-27 12:18:37 +00:00
|
|
|
+#ifdef HAVE_XFIXES
|
|
|
|
+ } else if (ev->type == EnterNotify) {
|
2022-08-19 18:19:55 +00:00
|
|
|
+ XCrossingEvent* cev;
|
|
|
|
+
|
|
|
|
+ if (!running)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ cev = (XCrossingEvent*)ev;
|
|
|
|
+
|
|
|
|
+ if (cev->window != cev->root)
|
|
|
|
+ return false;
|
|
|
|
+
|
2022-08-27 12:18:37 +00:00
|
|
|
+ return setCursor();
|
|
|
|
+ } else if (ev->type == LeaveNotify) {
|
|
|
|
+ XCrossingEvent* cev;
|
|
|
|
+
|
|
|
|
+ if (!running)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ cev = (XCrossingEvent*)ev;
|
|
|
|
+
|
|
|
|
+ if (cev->window == cev->root)
|
|
|
|
+ return false;
|
2022-08-19 18:19:55 +00:00
|
|
|
+
|
2022-08-27 12:18:37 +00:00
|
|
|
+ server->setCursor(0, 0, Point(), NULL);
|
2022-08-19 18:19:55 +00:00
|
|
|
+ return true;
|
2022-08-27 12:18:37 +00:00
|
|
|
+#endif
|
2022-08-19 18:19:55 +00:00
|
|
|
}
|
2022-08-27 12:18:37 +00:00
|
|
|
|
2022-08-19 18:19:55 +00:00
|
|
|
return false;
|