Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
jwheare opened this issue May 16, 2019 · 16 comments
Closed
3 tasks done
Labels
Projects

Comments

@jwheare
Copy link
Contributor

jwheare commented May 16, 2019

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.

@jwheare
Copy link
Contributor Author

jwheare commented May 16, 2019

cc @SaswatB @MarshallOfSound

@jwheare
Copy link
Contributor Author

jwheare commented May 17, 2019

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

@electron-triage
Copy link

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.

@electron-triage electron-triage added the blocked/need-info ❌ Cannot proceed without more information label Feb 19, 2020
@electron-triage
Copy link

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.

@jwheare
Copy link
Contributor Author

jwheare commented Mar 1, 2020

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.

@hawkeyetwolf
Copy link

hawkeyetwolf commented Apr 6, 2021

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.

@LunNova
Copy link

LunNova commented Dec 26, 2021

This should be reopened as it is still an issue.

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

LunNova added a commit to LunNova/nixos-configs that referenced this issue Dec 26, 2021
@Rayrsn
Copy link

Rayrsn commented Jan 5, 2022

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?

@LunNova
Copy link

LunNova commented Jan 6, 2022

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

@Rayrsn
Copy link

Rayrsn commented Jan 6, 2022

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)

@LunNova
Copy link

LunNova commented Jan 6, 2022

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.

@Inve1951
Copy link

Inve1951 commented Jan 7, 2022

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

Here's a NavigationFix for BD.
@Rayrsn

@Rayrsn
Copy link

Rayrsn commented Jan 8, 2022

@Inve1951 Thanks brother.

@LunNova
Copy link

LunNova commented Feb 6, 2022

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

@lmcarreiro
Copy link

@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.

@hawkeyetwolf
Copy link

@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
Labels
Projects
No open projects
5.0.x
Unsorted Issues
Development

No branches or pull requests

8 participants