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 547164 - Support for media player keys interferes with the music player
Support for media player keys interferes with the music player
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
2.23.x
Other All
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 551005 570539 574063 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-08-10 12:54 UTC by Eric Piel
Modified: 2018-02-01 08:52 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Grab the mediakeys with a low priority (1.47 KB, patch)
2008-08-10 22:16 UTC, Eric Piel
committed Details | Review

Description Eric Piel 2008-08-10 12:54:24 UTC
Please describe the problem:
The main goal of media player keys on a keyboard is to allow play/pause/next/previous song without having to go to the music player and coming back. This is especially useful when you read a long document in evince.

Now, with the "feature" provided in bug 539971, the multimedia keys are short-circuited, and when I want to pause the music or change tracks, evince goes to presentation mode or change pages!

Steps to reproduce:
1. open rhythmbox
2. press the play/pause key
3. open a document in evince
4. press the play/pause key


Actual results:
Evince goes to presentation mode

Expected results:
Rhythmbox pauses

Does this happen every time?
Yes

Other information:
I guess this feature was done in order to support remote controls when doing presentation. Fine with that, but it should not do anything if a music player is present.

I can see two ways to fix this:
 * Detect that a music/video player is also listening the multimedia keys (on DBus), and disable this feature in this case.
 * (If the detection is not possible) Have a gconf key that permit to activate/deactivate this feature. By default, it should be deactivated (because the normal meaning of a play key on a keyboard is _not_ to go to presentation mode).
Comment 1 Carlos Garcia Campos 2008-08-10 13:23:03 UTC
Yeah, I agree. Adding Bastien to CC. 
Comment 2 Bastien Nocera 2008-08-10 16:25:42 UTC
This is only a problem when Evince was the last focused application (when we're focused, we tell the gnome-settings-daemon that we are the application that's supposed to receive the keys).

Until evince gets plugins, I don't really see how I could fix that problem without adding a configuration option, which would be a pretty bad way to go.
Comment 3 Eric Piel 2008-08-10 17:53:10 UTC
Having to focus the media player to be able to use the multimedia keys defeats the whole idea of multimedia keys: avoiding to have to change of application. Evince is _not_ a multimedia player, and therefore, should it listen for the multimedia keys, it should do it at a very low priority. What I propose is that when evince get the focus, it first asks g-s-t if there is already some application bound to the key, and only if not, it binds itself.

You could in addition add an option to force the binding (in case someone wants to do a presentation with a remote control and a media player in the background and use the remote control for changing the slides), but, I entirely agree with you, adding configuration option should be avoided as much as possible.
Comment 4 Bastien Nocera 2008-08-10 18:00:19 UTC
There's currently no API for that. You can propose that as an API addition for gnome-settings-daemon if you're willing to do the work. I don't see this bug as a problem myself...
Comment 5 Eric Piel 2008-08-10 18:15:37 UTC
Hummm... I'll have a look at g-s-t. Also you could you give some example scenario of when this "feature" is useful? Is the "remote control scenario" the only scenario? What scenario did you have in mind when implementing this feature?
Comment 6 Eric Piel 2008-08-10 22:16:11 UTC
Created attachment 116304 [details] [review]
Grab the mediakeys with a low priority

Indeed, g-s-t permits to modify the list of interested applications, but not to read it. Nevertheless, it allows to pass as a second argument: the "time". It gives the grab to the application with the highest time value (and 0 has a special meaning of "even higher"). So by passing a low value, it permits to grab the key only when no other application has requested it. That's what does this patch (with a arbitrary value of 10). 

This patch also fixes the release message to pass the correct name of the application. However, it seems there is a problem with this part, because the ReleaseMediaPlayerKeys method is never called. You can verify this by running "dbus-monitor". It seems the finalize method is not called. Bastien, care to have a look on this?
Comment 7 Bastien Nocera 2008-08-12 14:00:43 UTC
I'd use "1" instead of "10" though.

ReleaseMediaPlayerKeys is probably never called because the object it belongs to is not disposed of properly (do we take care of cleaning up, or do we just exit?). That makes no difference, the gnome-settings-daemon (fyi, g-s-d, not g-s-t) will notice the application dropped off the bus, so it's as good as.
Comment 8 Eric Piel 2008-08-12 14:05:24 UTC
I put 10, just in case there would be applications which would like to have even lower priority, but 1 should be fine as well! Please feel free to commit the patch with 1 if you prefer :-)
Comment 9 Carlos Garcia Campos 2008-09-04 11:43:51 UTC
Applied to svn trunk, thanks Eric!
Comment 10 Nickolay V. Shmyrev 2008-09-05 20:03:38 UTC
*** Bug 551005 has been marked as a duplicate of this bug. ***
Comment 11 Iain Lane 2008-09-10 17:38:57 UTC
Well with the latest Evince update, Banshee and Rhythmbox get their keys back when Evince exits but while Evince is running they still cannot use them.
Comment 12 Iain Lane 2008-09-11 19:49:56 UTC
Actually it always seems to be the most recent application to request the media keys that gets it. I tried a variety of priorities but none made any difference. Start media player than evince -> evince gets keys. Start evince then media player -> media player gets them.
Comment 13 nathansamson 2008-10-12 14:29:18 UTC
I'm in favour to make this an option.

It is really bad, whenever I have opened a PDF (in my case this is quite often), and can't use the media keys for banshee (or any other media-player).


Another option (and probably this is better since it doesn't introduce an config option) is only listening to "next/previous song", and only when in presention mode. If in presentation mode (I assume you are giving a presentation then) the chances are really low that you are indeed "having a media player open that you want to control with a remote"
When not in presentation mode (you are just reading a PDF file), evince should't listen to next/previous (probably the keys are used for a media player)

Play/pause should't do anything (this you do at the start of your presentation with mouse/keyboard).

I hope I was clear enough about my point.

On the longer term, when g-s-m has improved (priorities regardless of startup order), we can reintrouduce current behaviour (low priority).


Greetings,
Nathan
Comment 14 Nickolay V. Shmyrev 2008-10-15 07:39:06 UTC
Should we reopen this bug?
Comment 15 Chow Loong Jin 2008-11-07 16:20:28 UTC
I believe it should be reopened. I'm actually pretty annoyed with not being able to control Banshee while reading a PDF (unless I restart Banshee or at least its Media Keys extension).
Comment 16 Renato Caldas 2009-01-29 18:26:55 UTC
Please reopen this bug report.

IMHO it is stupid for a non-multimedia application to grab the multimedia keys. Even in presentation mode, other solutions should be used. A lot of users are really annoyed with this, including myself.

It seems that the only way to prevent evince from "hijacking" the multimedia keys is to compile it without dbus support. This by itself breaks other benign features, which is undesirable.

So the very least would be to provide an option to turn off this feature, or better, just turn it off by default.
Comment 17 Chow Loong Jin 2009-01-29 19:03:15 UTC
Renato, this bug belongs to gnome-settings-daemon, and even then it's fixed in the latest upstream version. 

While Evince grabs the multimedia keys, it does so in a manner that prioritizes media applications first. The actual bug was gnome-settings-daemon not honouring the said priority that was set by Evince.
Comment 18 Renato Caldas 2009-01-29 20:12:14 UTC
I believe I'm using the latest stable versions. Is this fixed in the 2.25.x versions?

I'm having this problem with the exaile media player. The relevant versions are:

gnome-settings-daemon-2.24.1
evince-2.24.2
exaile-0.2.14

Comment 19 Chow Loong Jin 2009-01-29 20:30:48 UTC
Yes, I meant the 2.25.x versions. Exaile and Evince aren't the ones having this bug at your current versions.
Comment 20 Renato Caldas 2009-01-29 20:54:30 UTC
Ok, thanks.

I still don't like the fact that evince grabs the multimedia keys, but if it works then I'm ok with that.

Sorry for the noise.. :)
Comment 21 Nickolay V. Shmyrev 2009-02-04 23:39:21 UTC
*** Bug 570539 has been marked as a duplicate of this bug. ***
Comment 22 Carlos Garcia Campos 2009-03-04 14:54:43 UTC
*** Bug 574063 has been marked as a duplicate of this bug. ***
Comment 23 gmenih 2018-02-01 08:52:03 UTC
This is still an issue in 2.26.0.

Whenever I have Evince open, I can't use multimedia keys for Play, Paus, Next Track and Previous track.