Add a function to display the system menu for a window
Add SDL_ShowWindowSystemMenu() to display the system-level menu for windows. Typically, this is done by right-clicking on the system provided window decorations, however, if an application is rendering its own client-side decorations, there is currently no way to display it. This menu is provided by the system and can provide privileged desktop functionality such as moving or pinning a window to a specific workspace or display, setting the always-on-top property, or taking screenshots. In many cases, there are no APIs which allow applications to perform these actions manually. Implemented for Wayland via functionality provided by the xdg_toplevel protocol, Win32 via the undocumented message 0x313 (typically called WM_POPUPSYSTEMMENU), and X11 via the "_GTK_SHOW_WINDOW_MENU" atom (supported in GNOME and KDE).
This commit is contained in:
@@ -118,6 +118,7 @@ typedef enum
|
||||
* \sa SDL_SetWindowResizable()
|
||||
* \sa SDL_SetWindowTitle()
|
||||
* \sa SDL_ShowWindow()
|
||||
* \sa SDL_ShowWindowSystemMenu()
|
||||
*/
|
||||
typedef struct SDL_Window SDL_Window;
|
||||
|
||||
@@ -1675,6 +1676,28 @@ extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Display the system-level window menu.
|
||||
*
|
||||
* This default window menu is provided by the system and on some platforms
|
||||
* provides functionality for setting or changing privileged state on the
|
||||
* window, such as moving it between workspaces or displays, or toggling the
|
||||
* always-on-top property.
|
||||
*
|
||||
* On platforms or desktops where this is unsupported, this function
|
||||
* does nothing.
|
||||
*
|
||||
* \param window the window for which the menu will be displayed
|
||||
* \param x the x coordinate of the menu, relative to the origin (top-left) of the client area
|
||||
* \param y the y coordinate of the menu, relative to the origin (top-left) of the client area
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
|
||||
|
||||
/**
|
||||
* Possible return values from the SDL_HitTest callback.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user