@@ -729,8 +729,8 @@ puglRealize(PuglView* const view)
729729 const char * const className = view -> world -> strings [PUGL_CLASS_NAME ];
730730 d_stdout ("className is %s" , className );
731731
732- PuglPoint defaultPos = view -> positionHints [PUGL_DEFAULT_POSITION ];
733- PuglArea defaultSize = view -> sizeHints [PUGL_DEFAULT_SIZE ];
732+ const PuglPoint defaultPos = view -> positionHints [PUGL_DEFAULT_POSITION ];
733+ const PuglArea defaultSize = view -> sizeHints [PUGL_DEFAULT_SIZE ];
734734 if (!defaultSize .width || !defaultSize .height ) {
735735 return PUGL_BAD_CONFIGURATION ;
736736 }
@@ -761,6 +761,15 @@ puglRealize(PuglView* const view)
761761 canvasWrapper .style .setProperty ("--device-pixel-ratio" , window .devicePixelRatio );
762762 }, className );
763763
764+ const PuglArea minSize = view -> sizeHints [PUGL_MIN_SIZE ];
765+ if (minSize .width && minSize .height ) {
766+ EM_ASM ({
767+ var canvasWrapper = document .getElementById (UTF8ToString ($0 )).parentElement ;
768+ canvasWrapper .style .setProperty ("min-width" , parseInt ($1 / window .devicePixelRatio ) + 'px' );
769+ canvasWrapper .style .setProperty ("min-height" , parseInt ($2 / window .devicePixelRatio ) + 'px' );
770+ }, className , minSize .width , minSize .height );
771+ }
772+
764773 emscripten_set_canvas_element_size (className , defaultSize .width , defaultSize .height );
765774#ifndef PUGL_WASM_NO_KEYBOARD_INPUT
766775// emscripten_set_keypress_callback(className, view, false, puglKeyCallback);
@@ -932,7 +941,30 @@ puglSetSizeHint(PuglView* const view,
932941 const unsigned width ,
933942 const unsigned height )
934943{
935- return puglStoreSizeHint (view , hint , width , height );
944+ const PuglStatus st = puglStoreSizeHint (view , hint , width , height );
945+ if (st != PUGL_SUCCESS )
946+ return st ;
947+ if (!view -> impl -> created )
948+ return PUGL_SUCCESS ;
949+
950+ const char * const className = view -> world -> strings [PUGL_CLASS_NAME ];
951+
952+ switch (hint ) {
953+ case PUGL_MIN_SIZE :
954+ EM_ASM ({
955+ var canvasWrapper = document .getElementById (UTF8ToString ($0 )).parentElement ;
956+ canvasWrapper .style .setProperty ("min-width" , parseInt ($1 / window .devicePixelRatio ) + 'px' );
957+ canvasWrapper .style .setProperty ("min-height" , parseInt ($2 / window .devicePixelRatio ) + 'px' );
958+ }, className , width , height );
959+ break ;
960+ case PUGL_CURRENT_SIZE :
961+ emscripten_set_canvas_element_size (className , width , height );
962+ break ;
963+ default :
964+ break ;
965+ }
966+
967+ return PUGL_SUCCESS ;
936968}
937969
938970static EM_BOOL
0 commit comments