Prevent stealing focus on new windows#1176
Conversation
Osspial
left a comment
There was a problem hiding this comment.
I think this should be a configurable behavior, instead of having us enforce focus stealing should never happen or focus stealing should always happen. There are valid cases for both, and we shouldn't decide to make one or the other impossible.
I'll also note that it doesn't make sense to make this decision separately for each platform. Windows, for example, automatically focuses new windows upon creation, and merging this as-is will lead to a behavioral mismatch; we have a responsibility to try and ensure that behavior is roughly identical across platforms, since our job is to abstract away the differences between platforms.
|
Focus stealing in X11 is determined by the window manager, influenced by window type hint. Some window types should never steal focus, such as tooltips and notifications, while others usually do take focus. This PR corrects a bug introduced by a ~4 year old bugfix which gives all new windows focus. The new behavior gives control back to the WM, while preventing a regression on the original bug -- a window will always gain focus when entering fullscreen mode so that it doesn't lock up the user's display. I suppose the title is misleading -- this PR does not prevent any new window from stealing focus; it only no longer gives focus to windows that are not intended to ever have input focus. |
|
Ah, thanks for the clarification! This seems good to go, then. |
Previously,
XSetInputFocuswas called unconditionally on new windows (so long as they were visible upon creation). This was a bugfix for fullscreen windows not receiving input and locking up the user's display (rust-windowing/glutin#509). This PR moves theXSetInputFocuscall intoWindow::set_fullscreen, preventing non-fullscreen windows from stealing focus, which may not be desired, e.g. for tooltip or notification type windows.Fixes #1160
cargo fmthas been run on this branchCHANGELOG.mdif knowledge of this change could be valuable to users