obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
59.54k stars 7.89k forks source link

Space bar activates previously clicked UI element (widget) due to FocusPolicy #5445

Open dgatwood opened 2 years ago

dgatwood commented 2 years ago

Operating System Info

Ubuntu 20.04

Other OS

No response

OBS Studio Version

27.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

n/a

OBS Studio Crash Log URL

No response

Expected Behavior

I expect that hitting space bar will trigger the hot key for space bar.

Current Behavior

Space bar is being intercepted by some sort of accessibility feature, and is treated as a click on the last button clicked. So that means if you start recording and hit the space bar, recording stops. For other buttons, like the crossfade button, it pops up a contextual window. So maybe it's acting like a right click. Not sure.

This occurs on both gdm3 and lightdm.

This bug also appears to exist on Windows: https://obsproject.com/forum/threads/can-i-stop-spacebar-from-acting-as-a-hotkey.66796/page-2#post-546420

Steps to Reproduce

  1. Set the space bar to be the hotkey for something useful, like a cross-dissolve.
  2. Click the "Start recording" button.
  3. Press the space bar. Observe that the recording stopped.

Anything else we should know?

This definitely does not reproduce on macOS in version 25.x, and I'm 99% sure it doesn't reproduce on macOS in 26.x. So assuming this affects all platforms, this is probably a regression in version 27.x.

dgatwood commented 2 years ago

Just verified that this misbehavior also occurs on 25.x on Linux. So it is OS-specific.

kkartaltepe commented 2 years ago

I cannot replicate this. Binding disable preview to space bar disables the preview, it also does whatever it should do from Qt's perspective (so if you clicked start recording and thats still the hot button it will stop recording). But the spacebar hotkey works as expected.

dgatwood commented 2 years ago

Sorry, to clarify, yes, the binding triggers the expected action (e.g. the crossfade). The problem is that setting up the binding doesn't disable the accessibility behavior that Qt binds to that key, and there doesn't seem to be a way for users to disable it, either.

And because Qt's behavior causes space bar to trigger a click on the last button, this means that when you bind space bar to something (which is a really obvious thing to do, being the largest key and easiest to hit blindly), 99% of the time, it means that you crossfade and stop streaming/recording (the last button you clicked).

Worse, it's really, really easy to hit space bar accidentally, so Qt's accessibility binding is almost guaranteed to be undesirable in OBS even if you haven't bound the space bar to a hotkey, because again, 99% of the time, the easiest-to-hit key causes the worst possible catastrophe (stopping the recording and streaming).

Full keyboard navigation is maybe useful, but it should absolutely not be the default. By default, all buttons should always reject focus.

RytoEX commented 2 years ago

As far as I understand, this also happens on Windows.

I'd like to clarify that the described behavior is not that space bar is acting as a hotkey. The space bar is activating a previously clicked/focused UI element (in Qt terms, a Widget) the same way that clicking that element would do. If you click any other Widget, the first Widget will lose focus and the other Widget will have focus, and pressing space bar after this will activate/click that second Widget.

Qt is also not the only system that acts this way. For example, in the Twitch video player, if you click an element (Mute/Unmute, Play/Pause, Settings, Theatre Mode, Fullscreen), and then press space bar, that element's click/activation action occurs. Firefox's Settings pages work the same way with checkbox elements. Chrome's and Opera's Settings pages work the same way with toggle elements. You can see dropdowns/comboboxes activate in those browsers in the same manner. I'm sure there are many other examples.

Full keyboard navigation is maybe useful, but it should absolutely not be the default. By default, all buttons should always reject focus.

By clicking the button, you are giving it focus. Unless you unfocus the button, for example, by clicking the gray area around the OBS preview.

What could be done is that we could change the FocusPolicy of our buttons (QPushButtons) to not accept focus on click, but still accept focus by tabbing. However, I don't know if that would be considered a breaking change or if it would be acceptable. @VodBox ?

For now, the easiest way to avoid this behavior is to make sure to unfocus any element that you don't want to accidentally activate.

dgatwood commented 2 years ago

For now, I've patched my copy, now that I realize that this is a Qt button focus issue and is fixable in about half a minute. But ideally, there should be a preference that toggles the accessibility behavior, so that people who rely on full keyboard navigation for accessibility reasons aren't harmed, but it doesn't cause such unexpected behavior for everyone else. That said, I have no idea how to do that. :-D

vencabot commented 6 months ago

Found this Issue while searching for a problem I just had. I clicked 'Stop Stream' for the night, then my cat walked on my keyboard while I was out of the room and started the stream. I didn't realize I was streaming, which caused me to show my desktop on stream when I wasn't expecting to, which is a streamer's worst nightmare. Thankfully, I realized within a couple of minutes and deleted the VOD.

For this very reason, I have disabled all OBS hotkeys for years. I was trying to figure out how the hell the cat managed to start the stream, but then I realized that all that you need to do is press the spacebar a couple of times after clicking 'stop stream'. The spacebar even defaults to 'yes, I'd like to start the stream' when the confirmation dialog comes up. Scary! Shouldn't it default to 'no'? For reasons like this? If the dialog auto-confirms, what's the point of a safety feature like this?

I don't know whether or not keyboard navigation of the UI should or shouldn't be the default, but I feel like there definitely needs to be a Setting where it can be completely or selectively disabled, at least for something like starting the stream.

To reproduce, just give the 'Start Streaming' 'Start Recording' 'Studio Mode' 'Settings' dialog area focus by clicking a button in there. Then you can navigate the UI with the arrow keys and click buttons by pressing space. This means that, if you click 'end stream', you're only a couple of space-bar presses from starting the stream again.