Skip to content

Conversation

@remco-k
Copy link

@remco-k remco-k commented May 27, 2025

I've had more than once that Chromium can lose keyboard input focus due to:

  • Disconnecting or turning off the HDMI monitor/tv
  • Connecting/disconnecting with VNC
  • Popup of a notification from the taskbar
  • At random after startup no keyboard input focus

This causes the kiosk mode to just get stuck on whatever page is showing until you Alt+Tab to it or click it to give it focus.

I've tried to implement various ways of making sure keyboard input focus stays at Chromium, so that Ctrl+Tab and Ctrl+R keep on working, regardless of what happens with the Raspberry GUI. Only to find out its all just not good enough or a nice solid, maintainable, understandable solution.

The only nice, proper and rocksolid solution I could think of was to completely abandon the keyboard shortcut usage. For that I implemented the use of the Chromium debugging port, via that port Chromium can be controlled in many different ways and more importantly: It doesn't matter if it has or hasn't keyboard input focus, because we're not using keyboard shortcuts anymore.

This results in a always working tab-switch. Even when Chromium is not having keyboard input focus. I think this will be a great change for this project as I can imagine that many people have this problem with their "PiOSK" that suddenly stops changing tabs.

A couple of remarks about this change:

  • You'll see that one of my new files (chromium-reload-tab.py) is a Python file, this is due to this reload function needed a websocket connection and doing that in bash, wasn't my thing. It posed too many things that needed a change, so I figured using Python was the better way.
  • In a seperate commit I've removed the --enable-low-end-device-mode option from Chromium, as with that option the color depth was decreased significantly, making any picture look horrible. Tested on a Raspberry Pi 4b, looked good after that. Feel free to ignore this change.

@debloper
Copy link
Owner

I would also prefer to get off-board from keyboard emulation as well, and send direct tab-switch commands to chromium... but given the complexity involved (extra moving parts, more edge cases, wider blast radius... not to mention, introducing python to the mix), the current solution seems like the simpler solution among all the imperfect alternatives.

Thanks for the PR; I need some time to think this through. Keeping it open as a reminder.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants