Bug 85331 - RFE: Add a way to release keyboard grabs without reaching for the mouse
Summary: RFE: Add a way to release keyboard grabs without reaching for the mouse
Status: RESOLVED FIXED
Alias: None
Product: Spice
Classification: Unclassified
Component: spice-gtk (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Pavel Grunt
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-22 15:16 UTC by Christophe Fergeau
Modified: 2015-02-09 07:54 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Christophe Fergeau 2014-10-22 15:16:12 UTC
It would be nice to able to send some shortcuts to the client OS, even while the VM (with vdagent running) has focus.
This would allow to use alt-tab, alt-f4, ... even when the VM is focused (which can even happen by mistake when using alt-tab or workspace switching if the cursor happens to end up on a spice-gtk window).

One way of handling that would be to always honour the 'ungrab keyboard' shortcut even when the agent is running. It would be regrabbed when the shortcut is pressed again or when the mouse is moved and stays over the VM (?)

See https://bugzilla.gnome.org/show_bug.cgi?id=730826 or https://bugzilla.gnome.org/show_bug.cgi?id=733988 for cases where this could be useful.
Comment 1 Marc-Andre Lureau 2014-10-22 22:02:00 UTC
You suggested to release the grab when the key combination is released, and after other key/event happened.

Since by default ctrl+alt is the release binding, when pressing and releasing only ctrl and alt, the guess would receive those events, and the keyboard grab would be released: the next ctrl-alt or mouse move would regrab. 

I guess this would not prevent using as much as key input as possible, as key events would still be received by guest and more complex guest bindings, such as ctrl+alt+key would still work in guest only.
Comment 2 Marc-Andre Lureau 2014-11-07 16:17:58 UTC
To illustrate #1, hopefully making myself more clear. In order to release the grab temporarily, user would have to:

- no pointer move during following steps, and no other key press!
- press ctrl+alt
  -> ctrl+alt press are sent to guest
- user release ctrl+alt
  -> ctrl+alt release sent to guest
  -> spice-gtk ungrab pointer/keyboard
- user may now press alt-tab or other actions that were prevented by the grab
- press and release ctrl+alt or move pointer
  -> spice-gtk grab the pointer, no ctrl+alt sent to guest

Would this work?
Comment 3 Pavel Grunt 2014-11-07 16:35:39 UTC
(In reply to Marc-Andre Lureau from comment #2)

> Would this work?

Yes, the "press and release" combination is necessary as you mentioned.
Comment 4 Pavel Grunt 2015-01-09 09:03:25 UTC
Fixed in spice-gtk v0.27
commit 767e5522f64c115f66f6419abd378ad568e5564e
Comment 5 Zeeshan Ali 2015-01-21 22:23:50 UTC
Probably better to open another bug for this but I'll leave that decision to others:

<zeenix> pgrunt: any indication from spice-gtk that user has pressed+released ctrl+alt?
<zeenix> i would like to change the hint when that is the case
<pgrunt> zeenix, only "grab-keys-pressed" signal when pressed 
<zeenix> and not the opposite? :(
<zeenix> how do i know when user has pressed+released ctrl+alt again to send keys back to guest?
<pgrunt> zeenix: nothing for pressed & released
<pgrunt> there is private boolean in spice-widget
<zeenix> sorry for confusion but I meant that i need to know when events are being sent to host and when they are being sent to guest
<pgrunt> well, the grab is released when the the ctrl+alt is pressed
<pgrunt> and regain when mouse moves or the sequence is pressed again
<zeenix> yes
<zeenix> but how do i find that programmatically?
<zeenix> i-e which mode we are in currently
<zeenix> so i can swap between "press & release left ctrl+alt to send key events to host" and "press & release left ctrl+alt to send key events to guest"
<pgrunt> I understand what u mean, there is gboolean keyboard_grab_released in spice-widget-priv.c 
<pgrunt> this behaviour is "private" at the moment, but it is not difficult to change it
<pgrunt> it would be ideal if u mention this use case in that bug
<pgrunt> we can emit signal on press&release or found another solution
<fidencio> zeenix: what do you need? a new signal for ctrl+alt press+release is what you are looking for, right?
<teuf> a keyboard-grabbed/keyboard-ungrabbed signal I'd say
<teuf> (grabbed by spice-gtk widget/ungrabbed by spice-gtk widget)
Comment 6 Zeeshan Ali 2015-01-21 23:41:17 UTC
Re-opening this as per https://bugzilla.gnome.org/show_bug.cgi?id=730826#c14
Comment 7 Pavel Grunt 2015-01-22 09:23:33 UTC
Zeeshan, the signal you are (probably) looking for is "keyboard-grab". It is emitted when the grab changes.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.