Skip to content

Commit

Permalink
Remove old setWindowTitle global function (#20160)
Browse files Browse the repository at this point in the history
Instead just move the single implementation to
`emscripten_set_window_title` alongside `emscripten_get_window_title`.
  • Loading branch information
sbc100 committed Aug 30, 2023
1 parent 973a38c commit 10d156e
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,7 @@ var LibraryBrowser = {
},

emscripten_set_window_title__proxy: 'sync',
emscripten_set_window_title: (title) => {
setWindowTitle(UTF8ToString(title));
},
emscripten_set_window_title: (title) => document.title = UTF8ToString(title),

emscripten_get_screen_size__proxy: 'sync',
emscripten_get_screen_size: (width, height) => {
Expand Down
5 changes: 3 additions & 2 deletions src/library_glfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var LibraryGLFW = {

$GLFW__deps: ['emscripten_get_now', '$GL', '$Browser', '$GLFW_Window',
'$stringToNewUTF8',
'emscripten_set_window_title',
#if FILESYSTEM
'$FS',
#endif
Expand Down Expand Up @@ -636,9 +637,9 @@ var LibraryGLFW = {
var win = GLFW.WindowFromId(winid);
if (!win) return;

win.title = UTF8ToString(title);
win.title = title;
if (GLFW.active.id == win.id) {
document.title = win.title;
_emscripten_set_window_title(title);
}
},

Expand Down
5 changes: 3 additions & 2 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1723,9 +1723,10 @@ var LibrarySDL = {
#endif

SDL_WM_SetCaption__proxy: 'sync',
SDL_WM_SetCaption__deps: ['emscripten_set_window_title'],
SDL_WM_SetCaption: (title, icon) => {
if (title && typeof setWindowTitle != 'undefined') {
setWindowTitle(UTF8ToString(title));
if (title) {
_emscripten_set_window_title(title);
}
icon = icon && UTF8ToString(icon);
},
Expand Down
7 changes: 2 additions & 5 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ function locateFile(path) {
// Hooks that are implemented differently in different runtime environments.
var read_,
readAsync,
readBinary,
setWindowTitle;
readBinary;

#if ENVIRONMENT_MAY_BE_NODE
if (ENVIRONMENT_IS_NODE) {
Expand Down Expand Up @@ -407,8 +406,6 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
{
#include "web_or_worker_shell_read.js"
}

setWindowTitle = (title) => document.title = title;
} else
#endif // ENVIRONMENT_MAY_BE_WEB || ENVIRONMENT_MAY_BE_WORKER
#if AUDIO_WORKLET && ASSERTIONS
Expand Down Expand Up @@ -475,7 +472,7 @@ assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackage
assert(typeof Module['read'] == 'undefined', 'Module.read option was removed (modify read_ in JS)');
assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify setWindowTitle in JS)');
assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
{{{ makeRemovedModuleAPIAssert('asm', 'wasmExports', false) }}}
{{{ makeRemovedModuleAPIAssert('read', 'read_') }}}
Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23567
23580
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20039
20052
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58331
58269
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_no_asserts.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
31712
31637
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57045
56983

0 comments on commit 10d156e

Please sign in to comment.