Make focus request handling predictable.#948
Merged
xStrom merged 4 commits intolinebender:masterfrom May 21, 2020
Merged
Conversation
cmyr
approved these changes
May 20, 2020
Member
cmyr
left a comment
There was a problem hiding this comment.
Cool, I think this is a good solution to a hairy little problem.
druid/src/core.rs
Outdated
| self.request_focus = self.request_focus.or(child_state.request_focus); | ||
| self.timers.extend(&child_state.timers); | ||
| self.request_focus = child_state.request_focus.take().or(self.request_focus); | ||
| self.timers.extend(&mut child_state.timers.drain()); |
Member
There was a problem hiding this comment.
Was just looking at this yesterday; there's a small optimization we could make where if child has timers and we don't, we just do a mem::swap, which will save us an allocation?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Focus request handling in
masteris somewhat unpredictable:This PR makes it a lot simpler to understand:
request_focuslast will win.This change makes it easier to build widget groups where both the parent and children are interested in focus. It will allow the parent to request focus before passing down the event if it's ok with not winning. With
masterthe parent would have to track the children's interest in focus by its own means to not override it.