-
Notifications
You must be signed in to change notification settings - Fork 910
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
Missing X11 FocusIn event #3892
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need a changelog entry.
let focused = self.with_window(window, |window| { | ||
let mut shared_state_lock = window.shared_state_lock(); | ||
if !shared_state_lock.has_focus { | ||
shared_state_lock.has_focus = true; | ||
true | ||
} else { | ||
false | ||
} | ||
}); | ||
if focused == Some(true) { | ||
let event = Event::WindowEvent { window_id, event: WindowEvent::Focused(true) }; | ||
callback(&self.target, event); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only send focus event when we actually will be sending anything related to the keyboard input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if this particular keyboard event does not end in notifying the user of anything, my argument was that if I'm getting this X11 event here it is because this window has the focus. And if shared_state_lock.has_focus
is false, then I should already have received it, so I'm sending it now to compensate for the missing one.
9ae0200
to
d4eff84
Compare
It should be done before mapping the window, or we could lose the firsst XInput2 events, such as the first FocusIn. Fixes rust-windowing#2841.
b9f7ed6
to
8257144
Compare
Hi! This seems to have stalled a bit. I think adding two unrelated "fixes" to the focus was a mistake. I'm rewriting the PR to just include the fix for #2841, that should be easier to merge. |
This PR fixes #2841.
Also it adds and extra commit that synthesizes a FocusIn event if ever the window receives a keyboard event while unfocused, that should not happen, but it does happen sometimes.
Feel free to comment on those two commits separately, if you prefer that.