video: Disallow additional operations on popups where appropriate

Disallow additional window operations on popups where they have no functionality or otherwise don't make sense:

- Popups cannot be set as modal to other windows (they're already child windows of a parent)
- Other windows cannot be set as modal of popups
- Popups cannot explicitly grab the mouse/keyboard (the topmost popup menu takes the keyboard focus implicitly)
- Popups cannot flash or be raised
This commit is contained in:
Frank Praznik 2023-03-13 12:02:26 -04:00
parent d5b5e524af
commit f97b469184
1 changed files with 7 additions and 0 deletions

View File

@ -2739,6 +2739,7 @@ int SDL_HideWindow(SDL_Window *window)
int SDL_RaiseWindow(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, -1);
CHECK_WINDOW_NOT_POPUP(window, -1);
if (window->flags & SDL_WINDOW_HIDDEN) {
return 0;
@ -3012,6 +3013,8 @@ int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window)
{
CHECK_WINDOW_MAGIC(modal_window, -1);
CHECK_WINDOW_MAGIC(parent_window, -1);
CHECK_WINDOW_NOT_POPUP(modal_window, -1);
CHECK_WINDOW_NOT_POPUP(parent_window, -1);
if (!_this->SetWindowModalFor) {
return SDL_Unsupported();
@ -3023,6 +3026,7 @@ int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window)
int SDL_SetWindowInputFocus(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, -1);
CHECK_WINDOW_NOT_POPUP(window, -1);
if (!_this->SetWindowInputFocus) {
return SDL_Unsupported();
@ -3092,6 +3096,7 @@ int SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed)
int SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed)
{
CHECK_WINDOW_MAGIC(window, -1);
CHECK_WINDOW_NOT_POPUP(window, -1);
if (!!grabbed == !!(window->flags & SDL_WINDOW_KEYBOARD_GRABBED)) {
return 0;
@ -3108,6 +3113,7 @@ int SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed)
int SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed)
{
CHECK_WINDOW_MAGIC(window, -1);
CHECK_WINDOW_NOT_POPUP(window, -1);
if (!!grabbed == !!(window->flags & SDL_WINDOW_MOUSE_GRABBED)) {
return 0;
@ -3178,6 +3184,7 @@ const SDL_Rect *SDL_GetWindowMouseRect(SDL_Window *window)
int SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation)
{
CHECK_WINDOW_MAGIC(window, -1);
CHECK_WINDOW_NOT_POPUP(window, -1);
if (_this->FlashWindow) {
return _this->FlashWindow(_this, window, operation);