Commit ebe79c28 authored by dscho's avatar dscho

Clipboard support for SDLvncviewer

The clipboard support has only been tested on Linux so far.
Signed-off-by: 's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
parent e7152a7f
2009-03-08 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* client_examples/SDLvncviewer.c: support clipboard operations
2009-03-07 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* client_examples/SDLvncviewer.c: force releasing Alt keys whenr
losing focus. This helps when you switch windows by pressing
......
......@@ -19,8 +19,14 @@ SDLVIEWER=SDLvncviewer
SDLvncviewer_CFLAGS=$(SDL_CFLAGS)
SDLvncviewer_SOURCES=SDLvncviewer.c scrap.c
if HAVE_X
X11_LIB=-lX11
endif
# thanks to autoconf, this looks ugly
SDLvncviewer_LDADD=$(LDADD) $(SDL_LIBS)
SDLvncviewer_LDADD=$(LDADD) $(SDL_LIBS) $(X11_LIB)
endif
noinst_PROGRAMS=ppmtest $(SDLVIEWER) $(FFMPEG_CLIENT) backchannel
......
#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);
......
This diff is collapsed.
/* Handle clipboard text and data in arbitrary formats */
/* Miscellaneous defines */
#define T(A, B, C, D) (int)((A<<24)|(B<<16)|(C<<8)|(D<<0))
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern int init_scrap(void);
extern int lost_scrap(void);
extern void put_scrap(int type, int srclen, const char *src);
extern void get_scrap(int type, int *dstlen, char **dst);
extern int clipboard_filter(const SDL_Event *event);
#ifdef __cplusplus
}
#endif /* __cplusplus */
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