-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[GLFW] Restore css scaling behavior (removed in 3.1.51) #22900
Conversation
- the changes in 3.1.51 to add HiDPI support removed a feature that is not documented nor a feature of GLFW - raylib wants it back so this patch restores it
After the changes are approved I will modify Changelog to add an entry about this. |
@ypujante Thanks for the review. I tested this change on latest raylib master branch, with Please, excuse me if some of my previous messages could be rude. Thanks again for reviewing it. |
- in any case when adjustCanvasDimensions is called and there is no window active, there is no reason to resize the canvas
The only test failure I am seeing is
which seems to be very unlikely related to these unrelated changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this fix! Much appreciated.
src/library_glfw.js
Outdated
* 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat loath to add more incoming module API elements like this. Can we perhaps wait until somebody asks for this setting?
If we do end up adding it it would need to be added to INCOMING_MODULE_JS_API and then this line should be wrapped in #if expectToReceiveOnModule('INCOMING_MODULE_JS_API')
.
I simpler more pay-as-you-go option could be to add some kind of new API for this either via glfwSetWindowParam
or some new C API.
I wonder if we can add a test for this behaviour? Can we perhaps make a simple reftest that shows that the GLFW windows is scaled to the size of the canvas? I'm not sure how hard that would be.
- as requested by @sbc100 - if somebody asks for a way to disable the feature we can add a C API at a later time
- although the result is the same we should be testing with the correct constant
FYI, I am aware of the test failure (which does not fail on my local machine). I am trying to figure out why... will report when I do. |
- describe why CSS scaling cannot work in this mode
20cd1ca
to
861fc4b
Compare
@sbc100 I have made the changes that you requested:
|
Just tested with latest raylib and this PRs |
This is the patch I am proposing for addressing #22847
Some points:
isCSSScalingEnabled()
with documentation to make it clear what is happeningI have tested the changes as best as I could with ImGui and raylib. I tested a few examples with raylib and it seems to be doing what they want (the canvas occupies the fullscreen and the mouse coordinates are correct and resizing the window follows appriopriately)
It would certainly be better if @michaelfiber and/or @raysan5 could test the changes before they go live. It should be a matter of checking out this PR but I don't know if they have any bandwidth to do this.