After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 340720 - Apply volume on the device the key came from
Apply volume on the device the key came from
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
: 581039 (view as bug list)
Depends on: 623377
Blocks:
 
 
Reported: 2006-05-05 09:46 UTC by James Henstridge
Modified: 2011-11-02 20:14 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
First pass at using XI2 keygrabs (8.88 KB, patch)
2011-10-26 15:46 UTC, Bastien Nocera
none Details | Review
First pass at using XI2 keygrabs (8.78 KB, patch)
2011-10-26 17:51 UTC, Bastien Nocera
none Details | Review
common: Use XI2 to capture key events (15.34 KB, patch)
2011-10-27 17:29 UTC, Bastien Nocera
none Details | Review
common: Use XI2 to capture key events (29.21 KB, patch)
2011-10-28 19:59 UTC, Bastien Nocera
none Details | Review
common: Use XI2 to capture key events (33.00 KB, patch)
2011-10-31 12:47 UTC, Bastien Nocera
none Details | Review
patch (35.71 KB, patch)
2011-10-31 16:21 UTC, Bastien Nocera
committed Details | Review

Description James Henstridge 2006-05-05 09:46:37 UTC
Please describe the problem:
I have a Logitech USB headset that appears as a second sound card.  As well as
appearing as a USB audio device, it also appears as a USB keyboard.  When I use
the volume up/down buttons on the headset, keyboard events get generated.

I can bind these keyboard events to volume up or down in the keybindings control
panel, but this ends up altering the volume of the first sound card.

Steps to reproduce:
1. Connect a second sound card to the system
2. Open the keybindings control panel
3. try to add a keybinding to control the volume of the second sound card


Actual results:
There is no entry in the list for volume up/down of second sound card.

Expected results:
There should be an entry in the list for controlling the volume of the second
sound card.

Does this happen every time?
yes

Other information:
Comment 1 Ronald Bultje 2006-09-11 10:40:00 UTC
Isn't this basically #173035, just more specific for one case?
Comment 2 Bastien Nocera 2007-05-31 09:30:14 UTC
It's more specific than bug 173035. But right now, we can't do anything about it, as X merges all the keyboard events onto a "core" keyboard.

I have the same problem with a USB remote which uses arrows as its main buttons, when I'd want those to be handled as Volume up/down, Rewind, FFwd.

We need to have X support from the input hotplug work before we can do anything about this.
Comment 3 Bastien Nocera 2010-10-13 14:36:21 UTC
*** Bug 581039 has been marked as a duplicate of this bug. ***
Comment 4 Bastien Nocera 2011-10-26 15:46:47 UTC
Created attachment 200031 [details] [review]
First pass at using XI2 keygrabs
Comment 5 Bastien Nocera 2011-10-26 15:49:08 UTC
Still need to implement the key matching using XI2 events, and actually lookup the output stream that corresponds to the input device, if we can actually do that easily and quickly (could PulseAudio tell us whether it's worth searching for?).

Carlos reckons that we need this patch for the grabs to work:
http://lists.x.org/archives/xorg-devel/2011-August/024772.html
Built into some test packages:
http://koji.fedoraproject.org/koji/taskinfo?taskID=3461590
Comment 6 Bastien Nocera 2011-10-26 17:51:48 UTC
Created attachment 200046 [details] [review]
First pass at using XI2 keygrabs
Comment 7 Bastien Nocera 2011-10-26 18:11:45 UTC
Comment on attachment 200031 [details] [review]
First pass at using XI2 keygrabs

New patch is against master
Comment 8 Peter Hutterer 2011-10-27 01:57:54 UTC
Review of attachment 200046 [details] [review]:

Two issues with this patch:
- the return value of XIGrabKey should be checked, it's the number of modifiers that failed to establish (all the ones that did fail are returned in mods)
- a modifier of "0" is still a modifier and must be submitted normally. A num_modifiers of 0 is essentially a noop in the server.


Also note that https://bugs.freedesktop.org/show_bug.cgi?id=42298 currently prevents passive key grabs.
Comment 9 Bastien Nocera 2011-10-27 13:34:45 UTC
A build with the above bug fix:
http://koji.fedoraproject.org/koji/taskinfo?taskID=3465679
Comment 10 Bastien Nocera 2011-10-27 17:29:14 UTC
Created attachment 200121 [details] [review]
common: Use XI2 to capture key events
Comment 11 Bastien Nocera 2011-10-27 17:45:20 UTC
We don't really do error checking in gnome-settings-daemon (apart from the "a key couldn't be captured, meh").

I'll need to rework the current capture code we have to do a single XIGrabKeycode for all the modifier variants, which should make it quicker.
Comment 12 Bastien Nocera 2011-10-27 17:49:53 UTC
I forgot to mention that the code from the above patch works (at least doesn't regress) with your patch applied.
Comment 13 Bastien Nocera 2011-10-28 19:59:59 UTC
Created attachment 200208 [details] [review]
common: Use XI2 to capture key events
Comment 14 Bastien Nocera 2011-10-28 20:04:25 UTC
And something that mostly works.

There are a couple of FIXMEs for caching (though performance shouldn't be impacted that much), and libcanberra should be forced onto the correct PA sink.
The code is also only tested for USB devices. Making Bluetooth devices work would probably need some more work.

Peter, any chance to get the X.org patch committed? I really don't want to support 2 codepaths for this feature.
Comment 15 Bastien Nocera 2011-10-30 23:58:28 UTC
There's a good example of how to do it in the gvc-speaker-test.c in gnome-control-center, but that requires not using ca_gtk_play_for_widget() and following the theme ourselves, only to replicate ca_context_change_device().
Comment 16 Bastien Nocera 2011-10-31 12:47:07 UTC
Created attachment 200332 [details] [review]
common: Use XI2 to capture key events
Comment 17 Bastien Nocera 2011-10-31 16:21:41 UTC
Created attachment 200347 [details] [review]
patch

Split up patch, will commit as soon as the X.org patch is committed upstream.
Comment 18 Bastien Nocera 2011-10-31 17:15:43 UTC
See https://bugs.freedesktop.org/show_bug.cgi?id=42445 about the necessary infrastructure to do that for Bluetooth devices.
Comment 19 Bastien Nocera 2011-11-02 20:14:35 UTC
Now implemented in master. It will be broken as long as the X.org bug above isn't merged. Feel free to poke your distributions about it.