-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[GLFW] Restore css scaling behavior (removed in 3.1.51) #22900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
1067b21
6b5b856
ae7511b
8a1b7ce
98c8256
0b2717d
b7210dc
1dbf09c
dd871a9
861fc4b
c0c147f
a05693c
06c5e82
906f073
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1112,7 +1112,15 @@ var LibraryGLFW = { | |
|
|
||
| // Get non alive id | ||
| const canvas = Module['canvas']; | ||
| var win = new GLFW_Window(id, canvas.clientWidth, canvas.clientHeight, canvas.width, canvas.height, title, monitor, share); | ||
|
|
||
| var clientWidth = canvas.clientWidth; | ||
| var clientHeight = canvas.clientHeight; | ||
| if (GLFW.isCSSScalingEnabled()) { | ||
| clientWidth = width; | ||
| clientHeight = height; | ||
| } | ||
|
|
||
| var win = new GLFW_Window(id, clientWidth, clientHeight, canvas.width, canvas.height, title, monitor, share); | ||
|
|
||
| // Set window to array | ||
| if (id - 1 == GLFW.windows.length) { | ||
|
|
@@ -1266,6 +1274,11 @@ var LibraryGLFW = { | |
| var cw = Module["canvas"].clientWidth; | ||
| var ch = Module["canvas"].clientHeight; | ||
|
|
||
| if (GLFW.isCSSScalingEnabled()) { | ||
| cw = GLFW.active.width; | ||
| ch = GLFW.active.height; | ||
| } | ||
|
|
||
| // Neither .scrollX or .pageXOffset are defined in a spec, but | ||
| // we prefer .scrollX because it is currently in a spec draft. | ||
| // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/) | ||
|
|
@@ -1308,10 +1321,27 @@ var LibraryGLFW = { | |
| return false; | ||
| }, | ||
|
|
||
| /** | ||
| * CSS Scaling is a feature that is NOT part of the GLFW API, but for historical reasons, it is available | ||
| * in Emscripten. | ||
| * It is enabled by default but can be disabled by setting Module['EMSCRIPTEN_GLFW_DISABLE_CSS_SCALING'] to true. | ||
| * It is automatically disabled when using Hi DPI (the library overrides CSS sizes). */ | ||
| isCSSScalingEnabled() { | ||
| return Module['EMSCRIPTEN_GLFW_DISABLE_CSS_SCALING'] !== true && !GLFW.isHiDPIAware(); | ||
|
||
| }, | ||
|
|
||
| adjustCanvasDimensions() { | ||
| const canvas = Module['canvas']; | ||
| Browser.updateCanvasDimensions(canvas, canvas.clientWidth, canvas.clientHeight); | ||
| Browser.updateResizeListeners(); | ||
| if (GLFW.active) { | ||
| const canvas = Module['canvas']; | ||
| var clientWidth = canvas.clientWidth; | ||
| var clientHeight = canvas.clientHeight; | ||
| if (GLFW.isCSSScalingEnabled()) { | ||
| clientWidth = GLFW.active.width; | ||
| clientHeight = GLFW.active.height; | ||
| } | ||
| Browser.updateCanvasDimensions(canvas, clientWidth, clientHeight); | ||
| Browser.updateResizeListeners(); | ||
| } | ||
| }, | ||
|
|
||
| getHiDPIScale() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.