Skip to content

Commit ce35f4b

Browse files
committed
Move mainWindow from static to SDL_VideoData
1 parent 348479b commit ce35f4b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/video/emscripten/SDL_emscriptenvideo.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,9 @@ static void Emscripten_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
711711
canvas.remove();
712712
} else {
713713
// Since the canvas wasn't created by SDL3, just resize it to zero instead.
714-
// TODO: Is this necessary?
714+
// TODO: Is this necessary or desired. If the goal is to make the window not
715+
// visible, then the better thing to do is:
716+
// canvas.style.display = 'none';
715717
canvas.width = 0;
716718
canvas.height = 0;
717719
}
@@ -778,15 +780,14 @@ static SDL_FullscreenResult Emscripten_SetWindowFullscreen(SDL_VideoDevice *_thi
778780
}
779781
}
780782

781-
// Assume the first window that calls SDL_SetWindowTitle is the main window.
782-
static SDL_Window *mainWindow = NULL;
783-
784783
static void Emscripten_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
785784
{
786-
if (!mainWindow) {
787-
mainWindow = window;
785+
SDL_VideoData *videodata = _this->internal;
786+
if (!videodata->mainWindow) {
787+
// Assume that the first window to have its title set is the main window
788+
videodata->mainWindow = window;
788789
}
789-
if (mainWindow == window) {
790+
if (videodata->mainWindow == window) {
790791
emscripten_set_window_title(window->title);
791792
}
792793
}

src/video/emscripten/SDL_emscriptenvideo.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct SDL_WindowData
5353
struct SDL_VideoData
5454
{
5555
SDL_PropertiesID window_map;
56+
SDL_Window *mainWindow;
5657
};
5758

5859
bool Emscripten_ShouldSetSwapInterval(int interval);

0 commit comments

Comments
 (0)