Skip to content

Conversation

@chipschipschips
Copy link
Contributor

@chipschipschips chipschipschips commented Nov 2, 2024

On macOS, explicitly focus the new window in case Alacritty isn't the active app, otherwise it won't get focus automatically.

This is continuing from PR !8283 for issue #8283

On macOS, when window.set_visible(true) is called, winit's AppKit delegate calls NSWindow.makeKeyAndOrderFront which moves the window to the front of the application's screen list and makes it the key window for that application. If the application itself is already active, then great, the window has focus. If the application isn't active, then the window doesn't get focus.

This change explicitly focuses the window.

I kept focus_window in alacritty::display::window::Window and called it from alacritty::display::Display::new; cramming the call to self.window.focus_window() in set_visible didn't seem appropriate. Setting .with_active(true) on window_attributes has no effect.

make app and cargo test succeed on macOS 15.1. Manual tested and the change seems to work as expected.
make binary and cargo test succeed on Ubuntu 24.04. Manual tested and the app still works.

Copy link
Member

@chrisduerr chrisduerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires a changelog entry in the changed section.

Copy link
Member

@chrisduerr chrisduerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit bikesheddy, but after this it should be good to go.

chipschipschips and others added 2 commits November 2, 2024 07:26
Co-authored-by: Christian Duerr <[email protected]>
@chrisduerr chrisduerr merged commit 39ea727 into alacritty:master Nov 2, 2024
@glensc
Copy link

glensc commented Dec 30, 2024

oh damn, how I hate when apps steal focus. I might be typing something!

@kchibisov
Copy link
Member

You probably don't understand what it does then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants