Bug 499362

Summary: virt-viewer prevents key combinations like alt-f from being sent to the guest
Product: [Fedora] Fedora Reporter: Daniel Berrangé <berrange>
Component: virt-viewerAssignee: Daniel Berrangé <berrange>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 11CC: berrange, crobinso, hbrock, markmc, mclasen, quintela, virt-maint, yxie
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 0.0.3-6.fc11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 478418 Environment:
Last Closed: 2009-07-23 18:59:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 480594    
Attachments:
Description Flags
Fix keyboard grabbing
none
backtrace of warning none

Description Daniel Berrangé 2009-05-06 11:19:06 UTC
+++ This bug was initially created as a clone of Bug #478418 +++

Description of problem:
I'm trying to send, for example, alt-f to the guest, but this always opens the top file menu of virt-manager/virt-viewer, regardless of whether the pointer is grabbed or not.

I can clearly see on the frame window: "Press Ctrl+Alt to release pointer.  XXXXX Virtual Machine", but alt-f immediately opens the file menu. This is true of any of the top menu bar accelerators like alt-m/alt-v/alt-h.  The alt-keys should be passed to the guest in this situation, right?

Version-Release number of selected component (if applicable):
vnc-libs-4.1.2-35.fc10.x86_64              
vnc-4.1.2-35.fc10.x86_64             
gtk-vnc-python-0.3.8-1.fc10.x86_64     
gtk-vnc-0.3.8-1.fc10.x86_64                
libvirt-python-0.5.1-2.fc10.x86_64          
libvirt-0.5.1-2.fc10.x86_64              
virt-viewer-0.0.3-3.fc10.x86_64          
virt-manager-0.6.0-5.fc10.x86_64       
python-virtinst-0.400.0-5.fc10.noarch    
kernel-2.6.27.9-159.fc10.x86_64

How reproducible:
always

Steps to Reproduce:
1. install a guest (i'm using f10 guest in kvm on an intel x86_64 cpu)
2. start/open the guest
3. click the view of the guest to focus it
4. press alt-f
  
Actual results:
5. the file menu opens

Expected results:
5. alt-f sent to guest

Additional Info:
In web searches I saw some posts on trying something like "alt alt alt" then "f" to send the combo onward, but this didn't seem to do anything in my testing.  I just got the letter "f" on my command line in the guest.

--- Additional comment from zing on 2008-12-29 16:10:21 EDT ---

Additional Note:

I just noticed the guest actually sees the alt keypress, but it gets "stuck".  So if I press alt-f then press esc to make the file menu go away and then go back to the guest, all the following keypresses are as if the alt key is also pressed down.  Very confusing.  Pressing alt again "releases" the "stuck" alt key.

I also checked my preferences for "Grab keyboard output" which is set to "On mouse over", but it doesn't matter what I set it to, I still see the same symptoms.

--- Additional comment from crobinso on 2009-01-24 14:28:18 EDT ---

I can reproduce, reassigning to gtk-vnc.

--- Additional comment from berrange on 2009-05-06 07:17:45 EDT ---

This isn't something that can be solved at the GTK-VNC level.

While GTK-VNC will grab the keyboard, this merely ensures keyboard input always gets directed to the app using GTK-VNC. We can't stop other widgets in the app seeing some key sequences, because these magic sequences are handled by GTK before the key event even gets given to GTK-VNC widget.

There are 3 types of key sequence an application needs to block:


 - The GTK menu bar accelerator key (ie F10 which activates menu bar)
 - Accelerators for the application window (eg, Ctrl+Q -> Quit menu option)
 - Menu bar shortcuts  (eg,  Alt-F activates file menu)


virt-manager currently only blocks the first two. It needs to also block the last.

It can do this by connecting a callback to the 'mnemonic-activate' signal on each top level menu. The callback should simply ignore the signal, thus blocking normal GTK processing.  virt-manager should add this callback when seeing the 'vnc-keyboard-grab' signal from GTK-VNC, and remove this callback when seeing 'vnc-keyboard-ungrab'.

Comment 1 Daniel Berrangé 2009-05-06 11:20:55 UTC
This isn't something that can be solved at the GTK-VNC level.

While GTK-VNC will grab the keyboard, this merely ensures keyboard input always
gets directed to the app using GTK-VNC. We can't stop other widgets in the app
seeing some key sequences, because these magic sequences are handled by GTK
before the key event even gets given to GTK-VNC widget.

There are 3 types of key sequence an application needs to block:


 - The GTK menu bar accelerator key (ie F10 which activates menu bar)
 - Accelerators for the application window (eg, Ctrl+Q -> Quit menu option)
 - Menu bar shortcuts  (eg,  Alt-F activates file menu)



virt-viewer currently only blocks the latter, and it does so under the wrong scenario - it blocks upon pointer grab, instead of upon keyboard grab.

Upstream code for virt-viewer blocks the full set of items, but still does so upon the wrong event.

Comment 2 Daniel Berrangé 2009-05-07 12:07:06 UTC
Created attachment 342828 [details]
Fix keyboard grabbing

Comment 3 Daniel Berrangé 2009-05-07 12:13:17 UTC
Built in virt-viewer-0.0.3-5.fc11

Comment 4 Mark McLoughlin 2009-05-21 17:03:34 UTC
Moving to f11, I'm guessing we'll only be fixing it there

Dan: any reason you haven't pushed an update with this yet?

Comment 5 Fedora Update System 2009-05-26 15:13:26 UTC
virt-viewer-0.0.3-5.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/virt-viewer-0.0.3-5.fc11

Comment 6 Fedora Update System 2009-05-27 19:06:58 UTC
virt-viewer-0.0.3-5.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update virt-viewer'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-5519

Comment 7 Mark McLoughlin 2009-06-04 14:10:29 UTC
I'm seeing lots of:

  GLib-GObject-CRITICAL **: g_object_get_property: assertion `G_IS_VALUE (value)' failed

Will attach a stack trace of where the warnings are coming from.

It seems to do what you want, though - e.g. F10 is passed through to the guest now.

Comment 8 Mark McLoughlin 2009-06-04 14:11:53 UTC
Created attachment 346536 [details]
backtrace of warning

Comment 9 Daniel Berrangé 2009-06-04 14:25:59 UTC
Ah, looks like there is a missing call to  g_value_init()  on the accelSetting variable

Comment 10 Fedora Update System 2009-07-19 10:19:58 UTC
virt-viewer-0.0.3-6.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update virt-viewer'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-5519

Comment 11 Fedora Update System 2009-07-23 18:58:55 UTC
virt-viewer-0.0.3-6.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.