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

Prevent stealing focus on new windows #1176

Merged
merged 1 commit into from
Sep 19, 2019

Conversation

murarth
Copy link
Contributor

@murarth murarth commented Sep 18, 2019

Previously, XSetInputFocus was 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 the XSetInputFocus call into Window::set_fullscreen, preventing non-fullscreen windows from stealing focus, which may not be desired, e.g. for tooltip or notification type windows.

Fixes #1160

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

Copy link
Contributor

@Osspial Osspial left a comment

Choose a reason for hiding this comment

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

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.

@murarth
Copy link
Contributor Author

murarth commented Sep 18, 2019

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.

@Osspial
Copy link
Contributor

Osspial commented Sep 19, 2019

Ah, thanks for the clarification! This seems good to go, then.

@Osspial Osspial merged commit eb20612 into rust-windowing:master Sep 19, 2019
@murarth murarth deleted the fix-focus-stealing branch September 19, 2019 16:35
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.

No way to avoid focus stealing on X11.
2 participants