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>
pull/1/head
dscho 15 years ago
parent e12c4ccf23
commit eb1cc7608b

@ -1,3 +1,9 @@
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
Alt+Tab (SDLvncviewer would get the "Alt down" event, but not
the "Alt up" one).
2009-03-07 Johannes E. Schindelin <Johannes.Schindelin@gmx.de> 2009-03-07 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* client_examples/SDLvncviewer.c: make the viewer resizable * client_examples/SDLvncviewer.c: make the viewer resizable

@ -2,7 +2,6 @@ immediate:
---------- ----------
make SDLvncviewer more versatile make SDLvncviewer more versatile
- Send modifiers key-up on leave focus,
- test for missing keys (especially "[]{}" with ./examples/mac), - test for missing keys (especially "[]{}" with ./examples/mac),
- map Apple/Linux/Windows keys onto each other, - map Apple/Linux/Windows keys onto each other,
- handle selection - handle selection

@ -17,6 +17,8 @@ static int enableResizable, viewOnly, buttonMask;
static int realWidth, realHeight, bytesPerPixel, rowStride; static int realWidth, realHeight, bytesPerPixel, rowStride;
static char *sdlPixels; static char *sdlPixels;
static int rightAltKeyDown, leftAltKeyDown;
static rfbBool resize(rfbClient* client) { static rfbBool resize(rfbClient* client) {
static char first=TRUE; static char first=TRUE;
int width=client->width,height=client->height, int width=client->width,height=client->height,
@ -376,11 +378,25 @@ static void handleSDLEvent(rfbClient *cl, SDL_Event *e)
break; break;
SendKeyEvent(cl, SDL_key2rfbKeySym(&e->key), SendKeyEvent(cl, SDL_key2rfbKeySym(&e->key),
e->type == SDL_KEYDOWN ? TRUE : FALSE); 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; break;
case SDL_QUIT: case SDL_QUIT:
rfbClientCleanup(cl); rfbClientCleanup(cl);
exit(0); exit(0);
case SDL_ACTIVEEVENT: 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; break;
case SDL_VIDEORESIZE: case SDL_VIDEORESIZE:
setRealDimension(cl, e->resize.w, e->resize.h); setRealDimension(cl, e->resize.w, e->resize.h);

Loading…
Cancel
Save