Commit 6cfd9afe authored by dscho's avatar dscho

make cut text handling using a hook

parent e4c85d48
...@@ -1019,10 +1019,6 @@ SendClientCutText(rfbClient* client, char *str, int len) ...@@ -1019,10 +1019,6 @@ SendClientCutText(rfbClient* client, char *str, int len)
{ {
rfbClientCutTextMsg cct; rfbClientCutTextMsg cct;
if (client->serverCutText)
free(client->serverCutText);
client->serverCutText = NULL;
if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE; if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE;
cct.type = rfbClientCutText; cct.type = rfbClientCutText;
...@@ -1481,23 +1477,25 @@ HandleRFBServerMessage(rfbClient* client) ...@@ -1481,23 +1477,25 @@ HandleRFBServerMessage(rfbClient* client)
case rfbServerCutText: case rfbServerCutText:
{ {
char *buffer;
if (!ReadFromRFBServer(client, ((char *)&msg) + 1, if (!ReadFromRFBServer(client, ((char *)&msg) + 1,
sz_rfbServerCutTextMsg - 1)) sz_rfbServerCutTextMsg - 1))
return FALSE; return FALSE;
msg.sct.length = rfbClientSwap32IfLE(msg.sct.length); msg.sct.length = rfbClientSwap32IfLE(msg.sct.length);
if (client->serverCutText) buffer = malloc(msg.sct.length+1);
free(client->serverCutText);
client->serverCutText = malloc(msg.sct.length+1); if (!ReadFromRFBServer(client, buffer, msg.sct.length))
if (!ReadFromRFBServer(client, client->serverCutText, msg.sct.length))
return FALSE; return FALSE;
client->serverCutText[msg.sct.length] = 0; buffer[msg.sct.length] = 0;
if (client->GotXCutText)
client->GotXCutText(client, buffer, msg.sct.length);
client->newServerCutText = TRUE; free(buffer);
break; break;
} }
......
...@@ -104,6 +104,7 @@ typedef void (*SoftCursorUnlockScreenProc)(struct _rfbClient* client); ...@@ -104,6 +104,7 @@ typedef void (*SoftCursorUnlockScreenProc)(struct _rfbClient* client);
typedef void (*GotFrameBufferUpdateProc)(struct _rfbClient* client, int x, int y, int w, int h); typedef void (*GotFrameBufferUpdateProc)(struct _rfbClient* client, int x, int y, int w, int h);
typedef char* (*GetPasswordProc)(struct _rfbClient* client); typedef char* (*GetPasswordProc)(struct _rfbClient* client);
typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client); typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client);
typedef void (*GotXCutTextProc)(struct _rfbClient* client, const char *text, int textlen);
typedef void (*BellProc)(struct _rfbClient* client); typedef void (*BellProc)(struct _rfbClient* client);
typedef struct _rfbClient { typedef struct _rfbClient {
...@@ -136,8 +137,6 @@ typedef struct _rfbClient { ...@@ -136,8 +137,6 @@ typedef struct _rfbClient {
char *desktopName; char *desktopName;
rfbPixelFormat format; rfbPixelFormat format;
rfbServerInitMsg si; rfbServerInitMsg si;
char *serverCutText;
rfbBool newServerCutText;
/* sockets.c */ /* sockets.c */
#define RFB_BUF_SIZE 8192 #define RFB_BUF_SIZE 8192
...@@ -220,6 +219,7 @@ typedef struct _rfbClient { ...@@ -220,6 +219,7 @@ typedef struct _rfbClient {
/* the pointer returned by GetPassword will be freed after use! */ /* the pointer returned by GetPassword will be freed after use! */
GetPasswordProc GetPassword; GetPasswordProc GetPassword;
MallocFrameBufferProc MallocFrameBuffer; MallocFrameBufferProc MallocFrameBuffer;
GotXCutTextProc GotXCutText;
BellProc Bell; BellProc Bell;
/* Which messages are supported by the server /* Which messages are supported by the server
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment