File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,26 @@ fn gg_init_sokol_window(user_data voidptr) {
222222 ctx.timage_pip = sgl.make_pipeline (& pipdesc)
223223 //
224224 if ctx.config.init_fn != voidptr (0 ) {
225+ $if android {
226+ // NOTE on Android sokol can emit resize events *before* the init function is
227+ // called (Android has to initialize a lot more through the Activity system to
228+ // reach a valid coontext) and thus the user's code will miss the resize event.
229+ // To prevent this we emit a custom window resize event, if the screen size has
230+ // changed meanwhile.
231+ win_size := ctx.window_size ()
232+ if ctx.width != win_size.width || ctx.height != win_size.height {
233+ ctx.width = win_size.width
234+ ctx.height = win_size.height
235+ if ctx.config.resized_fn != voidptr (0 ) {
236+ e := Event{
237+ typ: .resized
238+ window_width: ctx.width
239+ window_height: ctx.height
240+ }
241+ ctx.config.resized_fn (& e, ctx.user_data)
242+ }
243+ }
244+ }
225245 ctx.config.init_fn (ctx.user_data)
226246 }
227247 // Create images now that we can do that after sg is inited
You can’t perform that action at this time.
0 commit comments