Fix some local->remote clipboard merge misses

This commit is contained in:
Lauri Kasanen 2021-04-13 13:49:43 +03:00
parent a1cf454f06
commit 95d34f7e58
9 changed files with 22 additions and 19 deletions

View File

@ -296,8 +296,10 @@ void SConnection::setEncodings(int nEncodings, const rdr::S32* encodings)
}
}
void SConnection::clientCutText(const char* str)
void SConnection::clientCutText(const char* str, int len)
{
hasLocalClipboard = false;
strFree(clientClipboard);
clientClipboard = NULL;
@ -328,10 +330,12 @@ void SConnection::handleClipboardNotify(rdr::U32 flags)
strFree(clientClipboard);
clientClipboard = NULL;
if (flags & rfb::clipboardUTF8)
if (flags & rfb::clipboardUTF8) {
handleClipboardAnnounce(true);
else
hasLocalClipboard = false;
} else {
handleClipboardAnnounce(false);
}
}
void SConnection::handleClipboardProvide(rdr::U32 flags,

View File

@ -73,7 +73,7 @@ namespace rfb {
virtual void setEncodings(int nEncodings, const rdr::S32* encodings);
virtual void clientCutText(const char* str);
virtual void clientCutText(const char* str, int len);
virtual void handleClipboardRequest(rdr::U32 flags);
virtual void handleClipboardPeek(rdr::U32 flags);

View File

@ -1016,7 +1016,7 @@ void VNCSConnectionST::handleClipboardAnnounce(bool available)
server->handleClipboardAnnounce(this, available);
}
void VNCSConnectionST::handleClipboardData(const char* data)
void VNCSConnectionST::handleClipboardData(const char* data, int len)
{
if (!(accessRights & AccessCutText)) return;
if (!rfb::Server::acceptCutText) return;
@ -1025,7 +1025,6 @@ void VNCSConnectionST::handleClipboardData(const char* data)
sock->getPeerAddress());
return;
}
int len = strlen(data);
const int origlen = len;
if (rfb::Server::DLP_ClipAcceptMax && len > rfb::Server::DLP_ClipAcceptMax)
len = rfb::Server::DLP_ClipAcceptMax;

View File

@ -185,7 +185,7 @@ namespace rfb {
int x, int y, int w, int h);
virtual void handleClipboardRequest();
virtual void handleClipboardAnnounce(bool available);
virtual void handleClipboardData(const char* data);
virtual void handleClipboardData(const char* data, int len);
virtual void supportsLocalCursor();
virtual void supportsFence();
virtual void supportsContinuousUpdates();

View File

@ -535,7 +535,7 @@ void VNCServerST::sendClipboardData(const char* data)
for (ci = clipboardRequestors.begin();
ci != clipboardRequestors.end(); ci = ci_next) {
ci_next = ci; ci_next++;
(*ci)->sendClipboardData(data, strlen(data));
(*ci)->sendClipboardDataOrClose(data);
}
clipboardRequestors.clear();

View File

@ -476,9 +476,9 @@ void XserverDesktop::handleClipboardAnnounce(bool available)
vncHandleClipboardAnnounce(available);
}
void XserverDesktop::handleClipboardData(const char* data_)
void XserverDesktop::handleClipboardData(const char* data_, int len)
{
vncHandleClipboardData(data_);
vncHandleClipboardData(data_, len);
}
void XserverDesktop::grabRegion(const rfb::Region& region)

View File

@ -96,7 +96,7 @@ public:
const rfb::ScreenSet& layout);
virtual void handleClipboardRequest();
virtual void handleClipboardAnnounce(bool available);
virtual void handleClipboardData(const char* data);
virtual void handleClipboardData(const char* data, int len);
// rfb::PixelBuffer callbacks
virtual void grabRegion(const rfb::Region& r);

View File

@ -67,7 +67,7 @@ static int vncOwnSelection(Atom selection);
static int vncConvertSelection(ClientPtr client, Atom selection,
Atom target, Atom property,
Window requestor, CARD32 time,
const char* data);
const char* data, int len);
static int vncProcConvertSelection(ClientPtr client);
static void vncSelectionRequest(Atom selection, Atom target);
static int vncProcSendEvent(ClientPtr client);
@ -161,7 +161,7 @@ void vncHandleClipboardAnnounce(int available)
}
}
void vncHandleClipboardData(const char* data)
void vncHandleClipboardData(const char* data, int len)
{
struct VncDataTarget* next;
@ -177,7 +177,7 @@ void vncHandleClipboardData(const char* data)
vncDataTargetHead->property,
vncDataTargetHead->requestor,
vncDataTargetHead->time,
data);
data, len);
if (rc != Success) {
event.u.u.type = SelectionNotify;
event.u.selectionNotify.time = vncDataTargetHead->time;
@ -280,7 +280,7 @@ static int vncOwnSelection(Atom selection)
static int vncConvertSelection(ClientPtr client, Atom selection,
Atom target, Atom property,
Window requestor, CARD32 time,
const char* data)
const char* data, int len)
{
Selection *pSel;
WindowPtr pWin;
@ -370,7 +370,7 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
XA_STRING, 8, PropModeReplace,
strlen(latin1), latin1, TRUE);
len, latin1, TRUE);
vncStrFree(latin1);
@ -379,7 +379,7 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
} else if (target == xaUTF8_STRING) {
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
xaUTF8_STRING, 8, PropModeReplace,
strlen(data), data, TRUE);
len, data, TRUE);
if (rc != Success)
return rc;
} else {
@ -424,7 +424,7 @@ static int vncProcConvertSelection(ClientPtr client)
pSel->window == wid) {
rc = vncConvertSelection(client, stuff->selection,
stuff->target, stuff->property,
stuff->requestor, stuff->time, NULL);
stuff->requestor, stuff->time, NULL, 0);
if (rc != Success) {
xEvent event;

View File

@ -26,7 +26,7 @@ void vncSelectionInit(void);
void vncHandleClipboardRequest(void);
void vncHandleClipboardAnnounce(int available);
void vncHandleClipboardData(const char* data);
void vncHandleClipboardData(const char* data, int len);
#ifdef __cplusplus
}