Skip to content

Conversation

CommandMC
Copy link
Collaborator

focus and blur events don't get triggered when the actual browser window gets focus (they instead fire when an element gains/loses focus). Not sure how this worked before, Electron bug?
Instead now detect those changes in the Backend and pass them along

To make this modular, two new Backend events were added, mainWindowFocussed and mainWindowUnfocussed. A small handler then sends a gamepad.setInputsEnabled Frontend message when either event happens (either enabling or disabling gamepad inputs), which the Frontend then listens for

To test:

  1. Connect gamepad
  2. Unfocus Heroic
  3. On main: Notice gamepad still controls Heroic. On this branch: Notice gamepad no longer controls Heroic.

Since I was already creating the src/backend/gamepad/ folder for gamepad-related code, I also went ahead and moved the gamepadAction handler to its own file


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@CommandMC CommandMC requested a review from a team August 8, 2025 00:28
@CommandMC CommandMC self-assigned this Aug 8, 2025
@CommandMC CommandMC requested review from Etaash-mathamsetty, Nocccer, arielj, biliesilva, flavioislima and imLinguin and removed request for a team August 8, 2025 00:28
@CommandMC CommandMC added the pr:ready-for-review Feature-complete, ready for the grind! :P label Aug 8, 2025
@arielj
Copy link
Collaborator

arielj commented Aug 8, 2025

I can't reproduce this, I open heroic on main, move the controller around, then I click on a different window and the controller stops working, and I get the focus/blur events in the window object

what's your windows manager? I think one time someone reported a similar issue way back then when I first implemented this, and it was a window manager not properly unfocusing heroic or something like that

@CommandMC
Copy link
Collaborator Author

I'm on KDE Plasma

Operating System: Arch Linux 
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1
Kernel Version: 6.15.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 3700X 8-Core Processor
Memory: 32 GiB of RAM (31,3 GiB usable)
Graphics Processor: NVIDIA GeForce RTX 4070

According to MDN docs, the focus event should fire "when an element has received focus", so it's not (just) related to the window focus itself. We're also using it for the controller hints after all, the usage there looks more like what I'd imagine it to work
Electron is correctly receiving focus/blur events on my end, otherwise this approach wouldn't work either

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

Labels

pr:ready-for-review Feature-complete, ready for the grind! :P

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants