This repository was archived by the owner on Aug 31, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ mergeInto(LibraryManager.library, {
130130 tInput . addEventListener ( type , handler ) ;
131131 } ) ;
132132
133+ // Add listener for changes to device pixel ratio
134+ var matchQuery = `(resolution: ${ window . devicePixelRatio } dppx)` ;
135+ window . matchMedia ( matchQuery ) . addListener ( LiveCodeEvents . _handleDevicePixelRatioChanged ) ;
136+
133137 LiveCodeEvents . _initialised = true ;
134138 } ,
135139
@@ -892,6 +896,16 @@ mergeInto(LibraryManager.library, {
892896 // UI events
893897 // ----------------------------------------------------------------
894898
899+ _handleDevicePixelRatioChanged : function ( ) {
900+ LiveCodeAsync . delay ( function ( ) {
901+ Module . ccall ( 'MCEmscriptenHandleDevicePixelRatioChanged' ,
902+ 'number' , /* bool */
903+ [ ] ,
904+ [ ] )
905+ } ) ;
906+ LiveCodeAsync . resume ( ) ;
907+ } ,
908+
895909 // prevent context menu popup on right-click
896910 _handleContextMenu : function ( e ) {
897911 e . preventDefault ( )
Original file line number Diff line number Diff line change @@ -16,12 +16,22 @@ for more details.
1616You should have received a copy of the GNU General Public License
1717along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818
19+ #include " globdefs.h"
20+ #include " filedefs.h"
21+ #include " osspec.h"
22+ #include " typedefs.h"
23+ #include " parsedef.h"
24+ #include " objdefs.h"
25+
26+ #include " globals.h"
27+
1928#include " em-util.h"
2029
2130#include " sysdefs.h"
2231
2332#include " graphics.h"
2433#include " resolution.h"
34+ #include " stacklst.h"
2535
2636#include < emscripten.h>
2737
@@ -70,5 +80,19 @@ MCResPlatformGetUIDeviceScale()
7080void
7181MCResPlatformHandleScaleChange ()
7282{
73- MCEmscriptenNotImplemented ();
83+ // Global use-pixel-scaling value has been updated, so now we just need to reopen any open stack windows
84+ MCstacks->reopenallstackwindows ();
85+ }
86+
87+ extern " C" MC_DLLEXPORT_DEF bool
88+ MCEmscriptenHandleDevicePixelRatioChanged ()
89+ {
90+ MCGFloat t_scale = emscripten_get_device_pixel_ratio ();
91+ if (t_scale != s_emscripten_device_scale)
92+ {
93+ s_emscripten_device_scale = t_scale;
94+ MCResPlatformHandleScaleChange ();
95+ }
96+
97+ return true ;
7498}
You can’t perform that action at this time.
0 commit comments