coronalabs / corona

Solar2D Game Engine main repository (ex Corona SDK)
https://solar2d.com/
MIT License
2.5k stars 267 forks source link

macOS - windowSize not working #552

Closed thoorin closed 1 year ago

thoorin commented 1 year ago

I noticed that native.setProperty setting key of windowSize does not work for macOS. Same code works fine on windows. Tested on M2 chip and Intel chip, neither worked.

Example of code: native.setProperty( “windowSize”, { width =100, height = 100 } )

scottrules44 commented 1 year ago

It works fine on my Mac with the newest version.

https://user-images.githubusercontent.com/7820808/233822060-6f9c8943-fb7a-48b8-b5d5-107e81b4d3ac.mov

timer.performWithDelay( 5000, function() native.setProperty( "windowSize", { width =100, height = 100 } ) end )

thoorin commented 1 year ago

Thanks for the testing, because of your post I looked if issue could be somwhere else and found the problem. Just before setting windowSize I set windowMode to normal (from fullscreen). On windows that worked fine but on mac, when you go from fullscreen to windowed mode it is smooth transition that takes split of a second. If you try to set size during that time it will be ignored, whereas on win the transition is immediate, so calling it right after that is ok.

So if anyone encounters the same issue, switching to normal mode from fullscreen and giving it size, from previous code: native.setProperty( “windowMode”, “normal”) native.setProperty( “windowSize”, { width = 100, height = 100 } )

you have to add timer before setting size so app has time to fully transition to windowedMode. So I had to change previous code to: native.setProperty( “windowMode”, “normal”) timer.performWithDelay( 1000, function() native.setProperty( “windowSize”, { width = 100, height = 100 } ) end )

I tried also interval of 500 but that was not enough, but 1000 should be long enoug.