layer-shell: do not grab focus if keyboard interactivity is set to ON_DEMAND #2530
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.
Fixes #2450
This change avoids automatically focusing layer-shell surfaces when their keyboard interactivity is changed to ON_DEMAND. As discussed in #2422 (comment), this is not intended. However, this change can lead to unexpected changes if an app expects that this will grab focus. So it might not be the best solution after all.
Main change: Layer-shell views can now intentionally lose focus by setting keyboard interactivity to NONE and then back to ON_DEMAND (thus allowing them to be later refocused by normal user interactions; this was not possible before).
Possible drawback: if an app sets keyboard interactivity to ON_DEMAND as a response to user action (e.g. mouse click), it will not get keyboard focus until further user action. This is demonstrated e.g. by the test code in issue #2450 where after applying this patch, clicking on the "On demand" button will not grab focus. However, grabbing focus is still possible by first setting it to EXCLUSIVE and then back to ON_DEMAND (this is e.g. used by wf-shell which continues to work fine with this patch applied).