-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add support for non-constrained and non-grabbing popups #12840
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
Conversation
|
|
||
| // Transfer keyboard focus back to the parent from a grabbing popup. | ||
| if ((window->flags & SDL_WINDOW_POPUP_MENU) && !(window->flags & SDL_WINDOW_NOT_FOCUSABLE)) { | ||
| SDL_Window *new_focus; |
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.
whitespace
slouken
left a comment
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.
These seem good to me. The changes are a little involved so I'd leave this on main for now.
By default, popups are automatically constrained to be completely within display bounds, so as not to cut off information and result in an unusable menu, or unreadable tooltip. In some cases, however, this is not wanted, so a property to toggle this behavior is added. There are also cases where the client may not want a popup menu to implicitly grab the keyboard focus, as is the default behavior, so popup menus now respect the focusable flag/property, as well as being able to toggle focus grabbing via SDL_SetWindowFocusable().
|
Did another round of testing and this seems good to go.
I agree, and this is more of a feature addition than a bug fix anyways. |
|
Would it be possible to include this fix in next 3.2.X release? I tried briefly cherry-pick this on top of 3.2.X changes and haven't had no issues with it on Wayland so far. |
|
I'm not opposed to it if someone has a use for it. Would you be willing to give things a quick check on the other platforms as well? Your use cases do a good job at shaking out bugs. |
|
The changes seems OK after testing these on X11, Wayland and Windows. I can't verify the changes on macOS for the time being. |
By default, popups are automatically constrained to be completely within display bounds, so as not to cut off information and result in an unusable menu, or unreadable tool tip. In some cases, however, this is not wanted, so a property to toggle this behavior is added.
There are also cases where the client may not want a popup menu to implicitly grab the keyboard focus when shown, as is the default behavior, so popup menus now respect the focusable flag/property, as well as being able to toggle focus grabbing via SDL_SetWindowFocusable().
Much of the general popup focus code was identical between backends, and the changes here would have introduced even more verbatim code, so the popup focus code was factored out. There can probably be further simplification here, but care has to be taken.
Fixes #12533