diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index d657c2e..21dde7b 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -997,6 +997,27 @@ void VNCServerST::translateDLPRegion(rdr::U16 &x1, rdr::U16 &y1, rdr::U16 &x2, r //slog.info("DLP_Region vals %u,%u %u,%u", x1, y1, x2, y2); } +void VNCServerST::getDLPRegionSkipFlags(const Point& pos, + bool& skipclick, bool& skiprelease) const +{ + skipclick = false; + skiprelease = false; + + if (!DLPRegion.enabled) + return; + + rdr::U16 x1, y1, x2, y2; + translateDLPRegion(x1, y1, x2, y2); + + if (pos.x < x1 || pos.x >= x2 || + pos.y < y1 || pos.y >= y2) { + if (!Server::DLP_RegionAllowClick) + skipclick = true; + if (!Server::DLP_RegionAllowRelease) + skiprelease = true; + } +} + void VNCServerST::blackOut() { // Compute the region, since the resolution may have changed diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h index 64d84f0..df2f0aa 100644 --- a/common/rfb/VNCServerST.h +++ b/common/rfb/VNCServerST.h @@ -208,6 +208,11 @@ namespace rfb { enum UserActionType {Join, Leave}; void notifyUserAction(const VNCSConnectionST* newConnection, std::string& user_name, const UserActionType action_type); + // Compute whether a pointer click/release at the given framebuffer + // position should be suppressed by the DLP region policy. + void getDLPRegionSkipFlags(const Point& pos, + bool& skipclick, bool& skiprelease) const; + protected: friend class VNCSConnectionST; diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index 8ecfec8..3085ec5 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -548,19 +548,9 @@ rfb::Point XserverDesktop::directMouseEventWithPosition(int dx, int dy, vncPointerMoveRelative(dx, dy, cursorX, cursorY); bool skipclick = false, skiprelease = false; - if (server->DLPRegion.enabled) { - rdr::U16 x1, y1, x2, y2; - server->translateDLPRegion(x1, y1, x2, y2); - - rfb::Point cursorPos(cursorX - screenX, cursorY - screenY); - if (cursorPos.x < x1 || cursorPos.x >= x2 || - cursorPos.y < y1 || cursorPos.y >= y2) { - if (!rfb::Server::DLP_RegionAllowClick) - skipclick = true; - if (!rfb::Server::DLP_RegionAllowRelease) - skiprelease = true; - } - } + server->getDLPRegionSkipFlags(rfb::Point(cursorX - screenX, + cursorY - screenY), + skipclick, skiprelease); vncPointerButtonAction(buttonMask, skipclick, skiprelease); } else {