mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-22 23:35:39 +00:00
Add support for modal windows to more platforms
- Adds support for modal windows to Win32, Mac, and Haiku, and enhances functionality on Wayland and X11, which previous set only the parent window, but not the modal state. - Windows can be declared modal at creation time, and the modal state can be toggled at any time via SDL_SetWindowModalFor() (tested with UE5 through sdl2-compat). - Allows dynamic unparenting/reparenting of windows. - Includes a modal window test.
This commit is contained in:
@@ -144,6 +144,7 @@ typedef Uint32 SDL_WindowFlags;
|
||||
#define SDL_WINDOW_INPUT_FOCUS 0x00000200U /**< window has input focus */
|
||||
#define SDL_WINDOW_MOUSE_FOCUS 0x00000400U /**< window has mouse focus */
|
||||
#define SDL_WINDOW_EXTERNAL 0x00000800U /**< window not created by SDL */
|
||||
#define SDL_WINDOW_MODAL 0x00001000U /**< window is modal */
|
||||
#define SDL_WINDOW_HIGH_PIXEL_DENSITY 0x00002000U /**< window uses high pixel density back buffer if possible */
|
||||
#define SDL_WINDOW_MOUSE_CAPTURE 0x00004000U /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
|
||||
#define SDL_WINDOW_ALWAYS_ON_TOP 0x00008000U /**< window should always be above others */
|
||||
@@ -907,13 +908,15 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, in
|
||||
* with Metal rendering
|
||||
* - `SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN`: true if the window should
|
||||
* start minimized
|
||||
* - `SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN`: true if the window is modal to its
|
||||
* parent
|
||||
* - `SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN`: true if the window starts
|
||||
* with grabbed mouse focus
|
||||
* - `SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`: true if the window will be used
|
||||
* with OpenGL rendering
|
||||
* - `SDL_PROP_WINDOW_CREATE_PARENT_POINTER`: an SDL_Window that will be the
|
||||
* parent of this window, required for windows with the "toolip" and "menu"
|
||||
* properties
|
||||
* parent of this window, required for windows with the "toolip", "menu", and
|
||||
* "modal" properties
|
||||
* - `SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN`: true if the window should be
|
||||
* resizable
|
||||
* - `SDL_PROP_WINDOW_CREATE_TITLE_STRING`: the title of the window, in UTF-8
|
||||
@@ -1008,6 +1011,7 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowWithProperties(SDL_Propertie
|
||||
#define SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN "menu"
|
||||
#define SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN "metal"
|
||||
#define SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN "minimized"
|
||||
#define SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN "modal"
|
||||
#define SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN "mouse_grabbed"
|
||||
#define SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN "opengl"
|
||||
#define SDL_PROP_WINDOW_CREATE_PARENT_POINTER "parent"
|
||||
@@ -2000,7 +2004,12 @@ extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opaci
|
||||
extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity);
|
||||
|
||||
/**
|
||||
* Set the window as a modal for another window.
|
||||
* Set the window as a modal to a parent window.
|
||||
*
|
||||
* If the window is already modal to an existing window, it will be reparented to the new owner.
|
||||
* Setting the parent window to null unparents the modal window and removes modal status.
|
||||
*
|
||||
* Setting a window as modal to a parent that is a descendent of the modal window results in undefined behavior.
|
||||
*
|
||||
* \param modal_window the window that should be set modal
|
||||
* \param parent_window the parent window for the modal window
|
||||
@@ -2181,6 +2190,8 @@ extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperati
|
||||
/**
|
||||
* Destroy a window.
|
||||
*
|
||||
* Any popups or modal windows owned by the window will be recursively destroyed as well.
|
||||
*
|
||||
* If `window` is NULL, this function will return immediately after setting
|
||||
* the SDL error message to "Invalid window". See SDL_GetError().
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user