diff options
author | dscho <dscho> | 2009-03-08 18:33:08 +0000 |
---|---|---|
committer | dscho <dscho> | 2009-03-08 18:33:08 +0000 |
commit | ebe79c28c30ad328dcff88b95e7863e885af36f9 (patch) | |
tree | 2766085f80235a27b070a8e5eba9cc4dcdbed393 /client_examples/SDLvncviewer.c | |
parent | e7152a7f68063a86887a9059728ca26b5404ce51 (diff) | |
download | libtdevnc-ebe79c28c30ad328dcff88b95e7863e885af36f9.tar.gz libtdevnc-ebe79c28c30ad328dcff88b95e7863e885af36f9.zip |
Clipboard support for SDLvncviewer
The clipboard support has only been tested on Linux so far.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'client_examples/SDLvncviewer.c')
-rw-r--r-- | client_examples/SDLvncviewer.c | 20 |
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); |