Re: [gtk-vnc-devel] PATCH: Track key presses & fake up events when loosing focus



On Mon, Jul 09, 2007 at 10:51:40AM +0200, Gerd Hoffmann wrote:
> Daniel P. Berrange wrote:
> > The VNC protocol has no concept of focus in/out, nor modifier key states.
> > So if the VNC widget looses key board focus while certain keys are held
> > down, and then re-gains it when a different set of keys are held down it
> > can get very confusing state - missing key up events for the original set
> > of keys, and unexpected key up events for the new set of keys. This is
> > particularly bad if the keys are modifier keys. This is really really 
> > painful if one uses 'Alt+Tab' for cycling keyboard focus through local
> > windows because Alt+Tab get stuck on in the remote server.
> 
> X11 has a KeymapNotify event for that.  It usually comes in when the
> window re-gains the kbd focus and it tells you the current key state, so
> you can fixup things for changes you havn't seen.

I don't think KeymapNotify particularly helps. It only tells me the state
of the keys upon gaining focus. To know what fake key up/down events I need
to generate, I also need to know the state when we lost focus to calculate
the key state 'diff'.  There's no KeymapNotify upon loosing focus so the
widget would still need to manually track state like I'm doing now.

> That way you even get the case right where the Alt Key is still (or
> again) in down state when the vnc window gets the focus (due to
> switching back to the vnc window is done via kbd hotkey too).

With the current patch, if Alt was down when we lost focus, it sends a
fake up event. If we used KeymapNotify, we could avoid that fake up event
if Alt was still held, or generate a fake down if it was not held upon
loosing focus. Either way we avoid the 'stuck' Alt key scenario, so its
a minor improvemen compared to the core goal of the patch

> It is a bit tricky to get these events though.  There is no gtk event
> for them and also no signal, so you have to install an event filter
> using gdk_window_add_filter().

Yeah, that makes it rather a PITA, but I'll have a look at how much more
code would be needed to make use of KeymapNotify

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]