Skip to content

native/macos: moving the window doesn't send window_minimized_event - #708

Open
nivaldomcj wants to merge 1 commit into
not-fl3:masterfrom
nivaldomcj:macos-move-not-minimized
Open

nivaldomcj wants to merge 1 commit into
not-fl3:masterfrom
nivaldomcj:macos-move-not-minimized

Conversation

@nivaldomcj

@nivaldomcj nivaldomcj commented Nov 23, 2026 •

Copy link
Copy Markdown

window_did_move sends window_minimized_event, but nothing on that path sends window_restored_event: only window_did_become_key does, and a window that was just dragged is still the key window. So after a plain drag, or a move to another display, an app that pauses on window_minimized_event stays paused until the window loses focus and gets it back. I hit this in a game that stops its timer on minimize.

This PR removes the event from window_did_move and keeps the gl_context update. Focus loss is still reported by window_did_resign_key, and minimizing the window also resigns key, so that's still reported too.

I tested it on macOS with a small program that logs both events while it runs these steps:

Step Before After
Move the window with setFrameOrigin: (still the key window) minimized, with no restored after it no event
Hide the app, then unhide and activate it minimized, then restored minimized, then restored
miniaturize:, then deminiaturize: minimized, then restored minimized, then restored

Tested on macOS 27.2.1 (26B131), Apple M3 Max (arm64), Rust 1.100.0.

cargo build --all-targets passes for aarch64-apple-darwin and x86_64-apple-darwin, and cargo check --all-targets for aarch64-apple-ios and x86_64-apple-ios.

The move case came in with #552, which made these events mean focus lost and gained on macOS. @InnocentusLime, was there a reason to send it on move as well? If there's a case I'm missing, I'm happy to rework this.

window_did_move sent window_minimized_event, but nothing on that path
sends window_restored_event: only window_did_become_key does, and a moved
window never stops being the key window. Dragging the window therefore
left apps that pause on window_minimized_event paused until the window
lost and regained focus. Real focus loss is still reported by
window_did_resign_key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@InnocentusLime

InnocentusLime commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Hi! If you are asking about the PR it was a building block to fix a sticky key bug in macroquad. If the window lost focus while a key was held, the app would consider the key held down until you gave the window the focus back and pressed it again.

I don't remember working with any "on move" events or anything like that

@nivaldomcj

Copy link
Copy Markdown
Author

Thanks for the quick answer! It did come in with #552, though: the macos.rs diff there adds the window_minimized_event() call to window_did_move, and you mentioned it in the thread, saying DidMove should trigger it "just in case" (#552 (comment)). That was a year and a half ago, so no surprise it slipped your mind.

The sticky-key fix doesn't depend on it. Focus loss and regain still come from window_did_resign_key and window_did_become_key, which this PR leaves alone. A move doesn't take focus away, and with the call in place a plain drag sends "minimized" with no "restored" after it, so apps that pause on it stay paused.

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

Successfully merging this pull request may close these issues.

2 participants