Manually merged region changes

This commit is contained in:
matt 2021-03-22 10:36:39 +00:00
parent c3e30dcea1
commit 46e03289be
13 changed files with 83 additions and 18 deletions

View File

@ -36,7 +36,9 @@ namespace rfb {
rdr::U32 __unused_attr keycode,
bool __unused_attr down) { }
virtual void pointerEvent(const Point& __unused_attr pos,
int __unused_attr buttonMask) { }
int __unused_attr buttonMask,
const bool __unused_attr skipClick,
const bool __unused_attr skipRelease) { }
virtual void clientCutText(const char* __unused_attr str,
int __unused_attr len) { }
};

View File

@ -217,7 +217,7 @@ void SMsgReader::readPointerEvent()
int mask = is->readU8();
int x = is->readU16();
int y = is->readU16();
handler->pointerEvent(Point(x, y), mask);
handler->pointerEvent(Point(x, y), mask, false, false);
}

View File

@ -168,6 +168,15 @@ rfb::StringParameter rfb::Server::DLP_Region
"Black out anything outside this region",
"");
rfb::BoolParameter rfb::Server::DLP_RegionAllowClick
("DLP_RegionAllowClick",
"Allow clicks inside the blacked-out region",
false);
rfb::BoolParameter rfb::Server::DLP_RegionAllowRelease
("DLP_RegionAllowRelease",
"Allow click releases inside the blacked-out region",
true);
rfb::StringParameter rfb::Server::maxVideoResolution
("MaxVideoResolution",
"When in video mode, downscale the screen to max this size.",

View File

@ -50,6 +50,8 @@ namespace rfb {
static IntParameter DLP_KeyRateLimit;
static StringParameter DLP_ClipLog;
static StringParameter DLP_Region;
static BoolParameter DLP_RegionAllowClick;
static BoolParameter DLP_RegionAllowRelease;
static IntParameter jpegVideoQuality;
static IntParameter webpVideoQuality;
static StringParameter maxVideoResolution;

View File

@ -637,7 +637,7 @@ void VNCSConnectionST::setPixelFormat(const PixelFormat& pf)
setCursor();
}
void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask)
void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease)
{
pointerEventTime = lastEventTime = time(0);
server->lastUserInputTime = lastEventTime;
@ -649,7 +649,23 @@ void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask)
server->pointerClient = this;
else
server->pointerClient = 0;
server->desktop->pointerEvent(pointerEventPos, buttonMask);
bool skipclick = false, skiprelease = false;
if (server->DLPRegion.enabled) {
rdr::U16 x1, y1, x2, y2;
server->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;
}
}
server->desktop->pointerEvent(pointerEventPos, buttonMask, skipclick, skiprelease);
}
}

View File

@ -168,7 +168,7 @@ namespace rfb {
virtual void queryConnection(const char* userName);
virtual void clientInit(bool shared);
virtual void setPixelFormat(const PixelFormat& pf);
virtual void pointerEvent(const Point& pos, int buttonMask);
virtual void pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
virtual void clientCutText(const char* str, int len);
virtual void framebufferUpdateRequest(const Rect& r, bool incremental);

View File

@ -123,7 +123,7 @@ static void parseRegionPart(const bool percents, rdr::U16 &pcdest, int &dest,
VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
: blHosts(&blacklist), desktop(desktop_), desktopStarted(false),
blockCounter(0), pb(0), ledState(ledUnknown),
blockCounter(0), pb(0), blackedpb(0), ledState(ledUnknown),
name(strDup(name_)), pointerClient(0), comparer(0),
cursor(new Cursor(0, 0, Point(), NULL)),
renderedCursorInvalid(false),
@ -800,11 +800,8 @@ static void checkAPIMessages(network::GetAPIMessager *apimessager)
pthread_mutex_unlock(&apimessager->userMutex);
}
void VNCServerST::blackOut()
void VNCServerST::translateDLPRegion(rdr::U16 &x1, rdr::U16 &y1, rdr::U16 &x2, rdr::U16 &y2) const
{
// Compute the region, since the resolution may have changed
rdr::U16 x1, y1, x2, y2;
if (DLPRegion.percents) {
x1 = DLPRegion.pcx1 ? DLPRegion.pcx1 * pb->getRect().width() / 100 : 0;
y1 = DLPRegion.pcy1 ? DLPRegion.pcy1 * pb->getRect().height() / 100 : 0;
@ -834,11 +831,25 @@ void VNCServerST::blackOut()
//slog.info("DLP_Region vals %u,%u %u,%u", x1, y1, x2, y2);
ManagedPixelBuffer *mpb = (ManagedPixelBuffer *) pb;
void VNCServerST::blackOut()
{
// Compute the region, since the resolution may have changed
rdr::U16 x1, y1, x2, y2;
translateDLPRegion(x1, y1, x2, y2);
if (blackedpb)
delete blackedpb;
blackedpb = new ManagedPixelBuffer(pb->getPF(), pb->getRect().width(), pb->getRect().height());
int stride;
const rdr::U8 *src = pb->getBuffer(pb->getRect(), &stride);
rdr::U8 *data = blackedpb->getBufferRW(pb->getRect(), &stride);
rdr::U8 *data = mpb->getBufferRW(mpb->getRect(), &stride);
stride *= 4;
memcpy(data, src, stride * pb->getRect().height());
rdr::U16 y;
const rdr::U16 w = pb->getRect().width();
const rdr::U16 h = pb->getRect().height();
@ -873,8 +884,10 @@ void VNCServerST::writeUpdate()
assert(blockCounter == 0);
assert(desktopStarted);
if (DLPRegion.enabled)
if (DLPRegion.enabled) {
comparer->enable_copyrect(false);
blackOut();
}
comparer->getUpdateInfo(&ui, pb->getRect());
toCheck = ui.changed.union_(ui.copied);

View File

@ -95,7 +95,7 @@ namespace rfb {
virtual void setPixelBuffer(PixelBuffer* pb, const ScreenSet& layout);
virtual void setPixelBuffer(PixelBuffer* pb);
virtual void setScreenLayout(const ScreenSet& layout);
virtual PixelBuffer* getPixelBuffer() const { return pb; }
virtual PixelBuffer* getPixelBuffer() const { if (DLPRegion.enabled && blackedpb) return blackedpb; else return pb; }
virtual void serverCutText(const char* str, int len);
virtual void add_changed(const Region &region);
virtual void add_copied(const Region &dest, const Point &delta);
@ -209,6 +209,7 @@ namespace rfb {
bool desktopStarted;
int blockCounter;
PixelBuffer* pb;
ManagedPixelBuffer *blackedpb;
ScreenSet screenLayout;
unsigned int ledState;
@ -264,6 +265,8 @@ namespace rfb {
bool percents;
rdr::U16 pcx1, pcy1, pcx2, pcy2;
} DLPRegion;
void translateDLPRegion(rdr::U16 &x1, rdr::U16 &y1, rdr::U16 &x2, rdr::U16 &y2) const;
};
};

View File

@ -155,7 +155,8 @@ static void enqueueEvents(DeviceIntPtr dev, int n)
}
#endif /* XORG < 111 */
void vncPointerButtonAction(int buttonMask)
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
const unsigned char skiprelease)
{
int i;
#if XORG < 111
@ -169,6 +170,14 @@ void vncPointerButtonAction(int buttonMask)
if ((buttonMask ^ oldButtonMask) & (1 << i)) {
int action = (buttonMask & (1<<i)) ?
ButtonPress : ButtonRelease;
if (action == ButtonPress && skipclick) {
buttonMask &= ~(1<<i);
continue;
} else if (action == ButtonRelease && skiprelease) {
buttonMask |= (1<<i);
continue;
}
#if XORG < 110
n = GetPointerEvents(eventq, vncPointerDev,
action, i + 1,

View File

@ -32,7 +32,8 @@ extern "C" {
void vncInitInputDevice(void);
void vncPointerButtonAction(int buttonMask);
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
const unsigned char skiprelease);
void vncPointerMove(int x, int y);
void vncGetPointerPos(int *x, int *y);

View File

@ -418,11 +418,12 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
// SDesktop callbacks
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask,
const bool skipClick, const bool skipRelease)
{
vncPointerMove(pos.x + vncGetScreenX(screenIndex),
pos.y + vncGetScreenY(screenIndex));
vncPointerButtonAction(buttonMask);
vncPointerButtonAction(buttonMask, skipClick, skipRelease);
}
void XserverDesktop::clientCutText(const char* str, int len)

View File

@ -86,7 +86,8 @@ public:
const char* rejectMsg=0);
// rfb::SDesktop callbacks
virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
virtual void pointerEvent(const rfb::Point& pos, int buttonMask,
const bool skipClick, const bool skipRelease);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
virtual void clientCutText(const char* str, int len);
virtual unsigned int setScreenLayout(int fb_width, int fb_height,

View File

@ -286,6 +286,14 @@ and x2,y2 the lower-left. In addition to absolute pixel values, percentages
are allowed, zero means "default", and a negative number means "border".
.
.TP
.B \-DLP_RegionAllowClick \fIbool\fP
Allow clicks inside the blacked-out region.
.
.TP
.B \-DLP_RegionAllowRelease \fIbool\fP
Allow click releases inside the blacked-out region.
.
.TP
.B \-DLP_ClipSendMax \fIbytes\fP
Limit clipboard bytes to send to clients in one transaction. Default 10,000.
0 disables the limit, use \fBSendCutText\fP to disable clipboard sending entirely.