Skip to content

Commit cbc26fe

Browse files
Temdog007slouken
authored andcommitted
Add Emscripten window data to window properties
1 parent 4aefde0 commit cbc26fe

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/SDL3/SDL_video.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,11 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window)
15421542
* - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the
15431543
* window
15441544
*
1545+
* On Emscripten:
1546+
* - `SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID`: the id the canvas element will have
1547+
* - `SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT`: the keyboard element that associates
1548+
* keyboard events to this window
1549+
*
15451550
* \param window the window to query.
15461551
* \returns a valid property ID on success or 0 on failure; call
15471552
* SDL_GetError() for more information.
@@ -1587,6 +1592,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window
15871592
#define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display"
15881593
#define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen"
15891594
#define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window"
1595+
#define SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID "SDL.window.emscripten.canvas_id"
1596+
#define SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL.window.emscripten.keyboard_element"
15901597

15911598
/**
15921599
* Get the window flags.

src/video/emscripten/SDL_emscriptenvideo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,10 @@ static bool Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window,
525525
};
526526
}, window);
527527

528+
// Ensure canvas_id and keyboard_element are added to the window's properties
529+
SDL_SetStringProperty(window->props, SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID, wdata->canvas_id);
530+
SDL_SetStringProperty(window->props, SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT, wdata->keyboard_element);
531+
528532
// Window has been successfully created
529533
return true;
530534
}

0 commit comments

Comments
 (0)