emscripten: add window properties for canvas ID and keyboard element (#12509)

Move hints used by Emscripten to window properties. This change will be necessary if multiple windows for Emscripten will be supported in the future.

- Added Window Create Property SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID
- Added Window Create Property SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT
- Use hint SDL_HINT_EMSCRIPTEN_CANVAS_SELECTOR as override to SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID
- Use hint SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT as override to SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT
This commit is contained in:
Temdog007
2025-03-14 09:39:46 -07:00
committed by GitHub
parent ffe69fc354
commit 17b84dbcf3
5 changed files with 35 additions and 21 deletions

View File

@@ -711,8 +711,6 @@ extern "C" {
*
* This hint only applies to the emscripten platform.
*
* The default value is "#canvas"
*
* This hint should be set before creating a window.
*
* \since This hint is available since SDL 3.2.0.
@@ -726,7 +724,7 @@ extern "C" {
*
* The variable can be one of:
*
* - "#window": the javascript window object (default)
* - "#window": the javascript window object
* - "#document": the javascript document object
* - "#screen": the javascript window.screen object
* - "#canvas": the WebGL canvas element

View File

@@ -1280,6 +1280,19 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren
*
* The window is implicitly shown if the "hidden" property is not set.
*
* These are additional supported properties with Emscripten:
*
* - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID`: the id given to the canvas element.
* This should start with a '#' sign
* - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT`: override the binding element
* for keyboard inputs for this canvas. The variable can be one of:
* - "#window": the javascript window object (default)
* - "#document": the javascript document object
* - "#screen": the javascript window.screen object
* - "#canvas": the WebGL canvas element
* - "#none": Don't bind anything at all
* - any other string without a leading # sign applies to the element on the
* page with that ID.
* Windows with the "tooltip" and "menu" properties are popup windows and have
* the behaviors and guidelines outlined in SDL_CreatePopupWindow().
*
@@ -1341,6 +1354,8 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_Prop
#define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd"
#define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd"
#define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window"
#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID "SDL.window.create.emscripten.canvas_id"
#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL.window.create.emscripten.keyboard_element"
/**
* Get the numeric ID of a window.