Skip to content

Linux: Double actions when handling app-command handlers: browser-backward and browser-forward #18322

Closed

Description

@jwheare

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • v5.0.1
  • Operating System:
    • Ubuntu 19.04

#15441 added support for app-command handlers: browser-backward and browser-forward on Linux.

The docs describe how to make use of these here:
https://github.com/electron/electron/blob/v5.0.1/docs/api/browser-window.md#event-app-command-windows-linux

Our code is very similar here, and has been in place to support windows for years:
https://github.com/irccloud/irccloud-desktop/blob/master/app/main.js#L293-L311

When testing this on Ubuntu 19.04, this results in back and forward actions being triggered twice when using the appropriate mouse buttons.

I wonder if it's necessary to have these handlers on Linux or if they should only be registered on Windows?

My hunch is that the action is already automatically handled, and the handlers just repeat it. If this is the case, the docs should be updated.

An e.preventDefault() might also fix the issue but that seems like the wrong fix.

Activity

  1. jwheare commented on May 16, 2019

    @jwheare
    ContributorAuthor
  2. jwheare commented on May 17, 2019

    @jwheare
    ContributorAuthor

    Just confirmed that e.preventDefault() does not prevent this after all

  3. electron-triage commented on Feb 19, 2020

    @electron-triage

    Thank you for taking the time to report this issue and helping to make Electron better.

    The version of Electron you reported this on has been superseded by newer releases.

    If you're still experiencing this issue in Electron 6.x.y or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

    I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

    Thanks in advance! Your help is appreciated.

  4. added
    blocked/need-info ❌
    on Feb 19, 2020
  5. electron-triage commented on Feb 26, 2020

    @electron-triage

    Thank you for your issue!

    We haven't gotten a response to our questions in our comment above. With only the information that is currently in the issue, we don't have enough information to take action. I'm going to close this but don't hesitate to reach out if you have or find the answers we need, we'll be happy to reopen the issue.

  6. jwheare commented on Mar 1, 2020

    @jwheare
    ContributorAuthor

    I have now tested this on electron 8.0.2 on Linux, and the back/forward mouse buttons are still functioning without binding app-command. The documentation still suggests that binding this event is needed:

    https://github.com/electron/electron/blob/v8.0.2/docs/api/browser-window.md#event-app-command-windows-linux

    The following app commands are explicitly supported on Linux: browser-backward / browser-forward

    This is by no means a major issue, but just misleading: if the docs are followed, double actions will be registered.

  7. hawkeyetwolf commented on Apr 6, 2021

    @hawkeyetwolf

    I worked around this for now by using Piper to reassign the forward/back buttons on my Logitech mouse to "alt+left" and "alt+right" rather than "backward/forward". This has a side-effect of focusing the menubar in electron apps, which is annoying and clunky, but less so than double actions.

  8. LunNova commented on Dec 26, 2021

    @LunNova
  9. Rayrsn commented on Jan 5, 2022

    @Rayrsn

    This should be reopened as it is still an issue.

    Discord issue caused by this issue: support.discord.com/hc/en-us/community/posts/1500000622702-Thumb-mouse-button-on-Linux-registers-twice

    @LunNova how can i apply your "workaround" with BetterDiscord?

  10. LunNova commented on Jan 6, 2022

    @LunNova

    Apply the same .diff but to this file and change win to this.

  11. Rayrsn commented on Jan 6, 2022

    @Rayrsn

    I've ended up with this browserwindow.js
    but its not working i dont know what im doing wrong
    and im pretty sure im doing the injection correctly (Instructions)

  12. LunNova commented on Jan 6, 2022

    @LunNova

    Maybe that should be

            var win = this;
            var oldOn = win.on;
            win.on = function(event, listener, args) { if (event === 'app-command') return; oldOn.apply(win, [event, listener, args]); };
    

    Otherwise, not sure and I don't use BetterDiscord, sorry.

  13. Inve1951 commented on Jan 7, 2022

    @Inve1951

    @LunNova how can i apply your "workaround" with BetterDiscord?

    Here's a NavigationFix for BD.
    @Rayrsn

  14. Rayrsn commented on Jan 8, 2022

    @Rayrsn

    @Inve1951 Thanks brother.

  15. LunNova commented on Feb 6, 2022

    @LunNova

    Raised #32763 since it seems unlikely this will get reopened.

  16. lmcarreiro commented on Jun 17, 2022

    @lmcarreiro

    @hawkeyetwolf, this workaround with Piper, is it possible to use it with Slack/Discord only, and keep default behavior on other apps? Could you share more details about it or how to do it? Thanks.

  17. hawkeyetwolf commented on Jun 19, 2022

    @hawkeyetwolf

    @lmcarreiro, Piper is a system-wide tool, so I don't think there's a way to limit it to Slack/Discord only, unfortunately. And it only works for the mouse buttons, but in my case, that's all I needed. Here's a post about configuring Piper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    5-0-xblocked/need-info ❌bug 🪲platform/linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions