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

Glitchy behaviour after window loses focus. #89

Closed
micheldebree opened this issue Oct 27, 2020 · 7 comments
Closed

Glitchy behaviour after window loses focus. #89

micheldebree opened this issue Oct 27, 2020 · 7 comments
Labels
bug Something isn't working known issue macos Applies only to the macos version

Comments

@micheldebree
Copy link
Collaborator

This reproduces it every time for me:

  • CTRL-F2. This sets focus to the system menu on my macOS, causing the SF2 window to lose focus
  • ESC. This sets focus back to SF2

By now the cursor keys have stopped working. I can only move the cursor by clicking with the mouse.

  • CTRL

Now things start flashing erraticly like broken fluorescent lights. The same behaviour as when I keep F2 pressed all the time. Pressing F2 stops this behaviour.

@micheldebree micheldebree added bug Something isn't working macos Applies only to the macos version labels Oct 27, 2020
@micheldebree
Copy link
Collaborator Author

micheldebree commented Oct 28, 2020

This typically happens if you press CTRL-F2 instread of CTRL-2. The quickest way to recover is to press CTRL followed by F2 (not at the same time)
.

@micheldebree
Copy link
Collaborator Author

micheldebree commented Oct 28, 2020

Logged all the SDL events. There are no window events being received whatsoever when losing focus nor when regaining focus :(

The logging shows our assumption was right:

CTRL+F2 -> logged event 768 with keycode 400000E0 = CTRL down

Focus shifted to system menu.

ESC (while focus is on system menu) -> logged event 768 with keycode 4000003B = F2 down

So both the CTRL up and F2 up are lost. Weird thing is that the F2 down event is received after regaining focus, but the F2 up that should come after that is lost...
It looks like the F2 down is "remembered" right before focus is lost, the F2 up happens outside the SF2 focus, and then the "remembered" F2 down is received when the focus is regained.
Could it be that F2 down event is received by the SF2 window, but not processed until it regains focus? The key down events all happen outside SF2 focus and seem to be lost.

So a theory:

  • CTRL down is received by the SDL window and processed by SF2
  • F2 down is received by the SDL window
  • SDL window loses focus, SF2 stops processing received events
  • CTRL up and F2 up events happen outside SDL window focus and are not received by the window
  • SDL window regains focus and SF2 processes the F2 down event that the SDL window had received before it lost focus, but had not started processing yet.

@micheldebree
Copy link
Collaborator Author

Probably won't be able to fix. Labeled it 'known issue'.

@Grrrolf
Copy link

Grrrolf commented May 8, 2021

FYI:
ctrl-F2 is a keyboard shortcut on OS level:
image
I don't think it's a good idea asking people to turn this off. This makes using other applications less accessible for keyboard navigation.

A solution is using cmd+key instead of ctrl+key on the Mac. This is also much more in line with macOS workflow in general.

@micheldebree
Copy link
Collaborator Author

Hi @Grrrolf. On macOS there shouldn't be a ctrl-f2 shortcut, it's mapped to Cmd+F2 like you suggest. The issue above occurs when you hit ctrl-f2 by accident.

P.S. if you do a 'linux-style' build on macOS the mapping is ctrl-f2, so you do have this problem then.

@Grrrolf
Copy link

Grrrolf commented May 11, 2021

P.S. if you do a 'linux-style' build on macOS the mapping is ctrl-f2, so you do have this problem then.

Are you saying that when I type make, it doesn't take the proper key combos for macOS? I'm more of a command line person than xcode. It's soo much easier to just type make app than even start xcode :-)

@micheldebree
Copy link
Collaborator Author

The official release builds are built with make, I don't touch xcode at all :) If you build an App bundle, the mapping for "Play from cursor" should be Cmd+F2.

Is your master up-to-date? Until recently there was a wrong mapping in master.

By 'linux style' I mean building with the Makefile in the project root. An app built with the Makefile in /macos should have the Cmd+F2 mapping (Ctrl-F2 is not mapped to anything).

Have you built an App bundle where 'Play from cursor' is not mapped to Cmd+F2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working known issue macos Applies only to the macos version
Projects
None yet
Development

No branches or pull requests

2 participants