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

MacOS: GlfwApplication.cpp::currentGlfwModifiers wrongly detects modifiers in mouseMoveEvent #593

Open
DavidPeicho opened this issue Sep 20, 2022 · 7 comments

Comments

@DavidPeicho
Copy link

Hi,

It looks like GlfwApplication.cpp::currentGlfwModifiers returns the wrong modifiers after opening the MacOS screenshot panel and cancelling it.

The problem comes from glfwGetKey that will return true at:

    if(glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) ||
       glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT))

Reproduction

  • Open a GLFW application
  • Press cmd+shift+5 to open the MacOS screenshot dialog
  • Close it using escape
  • Check the value of GlfwApplication.cpp::currentGlfwModifiers while not holding any key

Fix

I guess one way to fix it would be to only use the glfwSetKeyCallback method instead of using glfwGetKey

@DavidPeicho
Copy link
Author

Definitely a bug with glfw and I don't think there is a way around it: glfw/glfw#2189

@mosra
Copy link
Owner

mosra commented Sep 20, 2022

Hi!

Hmm, I have a vague feeling that this wasn't limited to just GLFW and macOS, but happened to me with SDL on Linux and other apps as well. So maybe not a GLFW-specific bug but rather a general event handling "wart"?

Is it possible for you to try the same with the SDL application? I wonder how it handles that.

@mosra mosra reopened this Sep 20, 2022
@DavidPeicho
Copy link
Author

I can give it a try yes. I will do that tomorrow.

The exact bug though comes from this process:

  • I press cmd + shift + 5 so glfw registers this as pressed
  • It opens the screenshot manager and glfw do not produce a release even for shift

So I would assume it should be specific to GLFW.

@mosra
Copy link
Owner

mosra commented Sep 20, 2022

Does the same happen e.g. for Cmd+Space that opens the application launcher?

I tried on Linux (with Alt+F2, which opens the Plasm application launcher) and got a release event for Alt right before the window went out of focus. So that's how it should behave, I guess :)

@DavidPeicho
Copy link
Author

Spotlight works fine. I will have to find a SDL example to try with

@mosra
Copy link
Owner

mosra commented Sep 23, 2022

Easiest could be if you build Magnum with MAGNUM_BUILD_TESTS enabled, then there's a PlatformSdl2ApplicationTest executable that prints a message to the console on each input event (and same with GLFW).

But I kinda suspect SDL will work, so maybe let's just wait for a response from GLFW devs :)

@bear24rw
Copy link

bear24rw commented Nov 7, 2023

Possibly related to: glfw/glfw#1011

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

No branches or pull requests

3 participants