Repository navigation
fix and expand the support of the window_minimized_event - #552
Conversation
|
I've also made similar changes here for reference: Miniquad commits: Macroquad commit: |
Thank you! Gives me more confidence, that this fix is on the right track :D |
|
Verified on X11 with Ubuntu 24.04.2 LTS (with a somewhat esoteric window manager to be fair, running awesomewm, a tiling wm), not sure if we want/need someone running Wayland to try it as well or if it's fine with just X11? Seems to be working as expected :) edit: had a friend try it under Hyprland (Wayland) on Arch as well and it seems to be working there too |
Good question. I have no idea what policy macroquad has towards Wayland. Last time I checked the support was "unstable". So technically speaking, bugs for Wayland are to be expected are not required to be fixed by this PR. That said, if Wayland does get fixed too -- good! |
4aab146 to
1ff3c7f
Compare
|
@not-fl3 the PR has been tested on all declared platforms and seems to work! Any chance of it getting merged? :) |
1ff3c7f to
a33b678
Compare
|
@InnocentusLime I think your osx changes are missing the event for when the window gets reactivated. You should use this instead because these are the actual activated/deactivated windows events for macos: VoltaSoftware@3e32633 https://developer.apple.com/documentation/appkit/nswindowdelegate/windowdidbecomekey(_:) |
Interesting. I just did what Godot did in their PR. I suppose I can just alter the commit to use those instead. Thx! :) |
|
@jonatino |
a33b678 to
6a00a94
Compare
|
Hey this is the same as this issue: #517 While your fix should be applied probably, it doesn't fix the overall issue with the key APIs. For that we should copy what Qt does with making available the actual scancodes, as well as merging the char and various key events into a unified API. |
The API might be a bit confusing right now, but |
|
KeyCode is not the scan code. It changes between key presses. For example Colon and Semicolon. With scancodes they have the same value. |
|
@narodnik that's odd, considering there's this issue: not-fl3/macroquad#686 which seems to imply all the key codes are unrelated to the keyboard layout, so we have some awkward middleground right now then? |
This is factually incorrect. There is no https://github.com/not-fl3/miniquad/blob/master/src/event.rs#L21-L145 I have reviewed the windows implementation. I can vouch that it works with scancodes. |
|
Linux wayland does not use scancodes. It converts them to key syms, then converts the key syms to key codes. For tracking key state, you should use the raw key passed in (which it does), but this does not match the key codes used in miniquad. The miniquad KeyCode does not work for key repeat. Check |
|
Just to weigh in on this: as I understand, what this PR does is to fire the There's also a related issue by Fedor himself #28 although I think we can all agree that this is basically |
You are absolutely correct.
|
Apologies. I may not have a good grasp of how wayland works. Regardless, I believe This PR is also in fact unrelated to #517, despite what you said. So I would suggest moving the keyboard processing related discussion there |
|
Oh, thanks for PR, missed it! |
Why?
macroquadhas a bug: not-fl3/macroquad#547.There is a good fix we can implement, that has been suggested by @profan - the same issue, but in godot (godotengine/godot#28061). Essentially, this PR part 1 of the fix.
Context
miniquadalready has some ready-to-use handlers for a potential fix. There iswindow_minimized_event. Despite the name, on X Window system and WASM it gets fired when a window loses focus.I decided not to change that and instead focus on the following:
Bug Reproduction
The following application is sufficient to catch the bug
The steps are simple:
is_key_downis still returningtrue)Testing The Fix
Cargo.tomlTests:
Technical Notes About the fixed
js/gl.jsThere were a few things that did not make the minimized events fire correctly:
(fixed in 8d7cb80)lastFocus == hasFocuscaused the app being notified of focus only when it didn't changevisibilitychangelistener had a mistake. Elements do not lose focus when the browser changes tabs of the browser window becomes inactive. Insteaddocument.visibilityStatebecomes not equal to"visible"