summaryrefslogtreecommitdiffstats
path: root/client_examples
diff options
context:
space:
mode:
authordscho <dscho>2009-03-07 19:19:18 +0000
committerdscho <dscho>2009-03-07 19:19:18 +0000
commiteb1cc7608b91996199dae88663ee0d14d5d5b3f7 (patch)
tree4750a73002ee4748344cbb1aa8206c88d876a7a0 /client_examples
parente12c4ccf235e1760364c9a9930a5f1f56c4c7098 (diff)
downloadlibtdevnc-eb1cc7608b91996199dae88663ee0d14d5d5b3f7.tar.gz
libtdevnc-eb1cc7608b91996199dae88663ee0d14d5d5b3f7.zip
SDLvncviewer: upon focus loss, force releasing the Alt keys
When switching windows using the Alt+Tab shortcut, SDLvncviewer would get the "down" event, but not the "up" event. This patch provides a workaround. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'client_examples')
-rw-r--r--client_examples/SDLvncviewer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 738e9c6..6fe1a17 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -17,6 +17,8 @@ static int enableResizable, viewOnly, buttonMask;
static int realWidth, realHeight, bytesPerPixel, rowStride;
static char *sdlPixels;
+static int rightAltKeyDown, leftAltKeyDown;
+
static rfbBool resize(rfbClient* client) {
static char first=TRUE;
int width=client->width,height=client->height,
@@ -376,11 +378,25 @@ static void handleSDLEvent(rfbClient *cl, SDL_Event *e)
break;
SendKeyEvent(cl, SDL_key2rfbKeySym(&e->key),
e->type == SDL_KEYDOWN ? TRUE : FALSE);
+ if (e->key.keysym.sym == SDLK_RALT)
+ rightAltKeyDown = e->type == SDL_KEYDOWN;
+ if (e->key.keysym.sym == SDLK_LALT)
+ leftAltKeyDown = e->type == SDL_KEYDOWN;
break;
case SDL_QUIT:
rfbClientCleanup(cl);
exit(0);
case SDL_ACTIVEEVENT:
+ if (!e->active.gain && rightAltKeyDown) {
+ SendKeyEvent(cl, XK_Alt_R, FALSE);
+ rightAltKeyDown = FALSE;
+ rfbClientLog("released right Alt key\n");
+ }
+ if (!e->active.gain && leftAltKeyDown) {
+ SendKeyEvent(cl, XK_Alt_L, FALSE);
+ leftAltKeyDown = FALSE;
+ rfbClientLog("released left Alt key\n");
+ }
break;
case SDL_VIDEORESIZE:
setRealDimension(cl, e->resize.w, e->resize.h);