summaryrefslogtreecommitdiffstats
path: root/client_examples/SDLvncviewer.c
diff options
context:
space:
mode:
Diffstat (limited to 'client_examples/SDLvncviewer.c')
-rw-r--r--client_examples/SDLvncviewer.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 6fe1a17..0042284 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -1,5 +1,6 @@
#include <SDL.h>
#include <rfb/rfbclient.h>
+#include "scrap.h"
struct { int sdl; int rfb; } buttonMapping[]={
{1, rfbButton1Mask},
@@ -397,6 +398,17 @@ static void handleSDLEvent(rfbClient *cl, SDL_Event *e)
leftAltKeyDown = FALSE;
rfbClientLog("released left Alt key\n");
}
+
+ if (e->active.gain && lost_scrap()) {
+ static char *data = NULL;
+ static int len = 0;
+ get_scrap(T('T', 'E', 'X', 'T'), &len, &data);
+ if (len)
+ SendClientCutText(cl, data, len);
+ }
+ break;
+ case SDL_SYSWMEVENT:
+ clipboard_filter(&e);
break;
case SDL_VIDEORESIZE:
setRealDimension(cl, e->resize.w, e->resize.h);
@@ -406,6 +418,11 @@ static void handleSDLEvent(rfbClient *cl, SDL_Event *e)
}
}
+static void got_selection(rfbClient *cl, const char *text, int len)
+{
+ put_scrap(T('T', 'E', 'X', 'T'), len, text);
+}
+
#ifdef mac
#define main SDLmain
#endif
@@ -443,9 +460,12 @@ int main(int argc,char** argv) {
cl->GotFrameBufferUpdate=update;
cl->HandleKeyboardLedState=kbd_leds;
cl->HandleTextChat=text_chat;
+ cl->GotXCutText = got_selection;
if(!rfbInitClient(cl,&argc,argv))
return 1;
+ init_scrap();
+
while(1) {
if(SDL_PollEvent(&e))
handleSDLEvent(cl, &e);