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

Escape can close multiple windows. #70

Closed
Gleefre opened this issue Mar 11, 2023 · 0 comments · Fixed by #81
Closed

Escape can close multiple windows. #70

Gleefre opened this issue Mar 11, 2023 · 0 comments · Fixed by #81

Comments

@Gleefre
Copy link
Contributor

Gleefre commented Mar 11, 2023

Default behaviour

By default sketch will close a window on a :keydown escape event:

;;; Default events

(defmethod kit.sdl2:keyboard-event :before ((instance sketch) state timestamp repeatp keysym)
  (declare (ignorable timestamp repeatp))
  (when (and (eql state :keydown)
             (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape))
    (kit.sdl2:close-window instance)))

Problem

OS: Linux (ubuntu)
SDL version: 2.0.10

Create two windows, move one behind another. Put the mouse to the intersection of two windows.
On escape both are closed!

It seems that SDL is sending an extra :keydown event for all pressed keys when window regains focus.
When the first window closes, the second one is gaining focus, gets an additional :keydown event and closes.

Relevant discussions

Probably this issue on github is relevant: libsdl-org/SDL#4432

Solution?

An easy solution could be to move closing to a :keyup event, so that there is no additional :keydown event for the second window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant