Skip to content

Commit

Permalink
fix resize on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
elias authored and SiegeLord committed Feb 27, 2023
1 parent e8ac980 commit e2ff109
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/macosx/osxgl.m
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ -(void) viewDidChangeBackingProperties
event.display.width = NSWidth(content);
event.display.height = NSHeight(content);
_al_event_source_emit_event(es, &event);
ALLEGRO_INFO("Window finished resizing");
ALLEGRO_INFO("Window finished resizing %d x %d\n", event.display.width, event.display.height);
}
_al_event_source_unlock(es);
}
Expand Down Expand Up @@ -532,7 +532,7 @@ -(void) viewDidEndLiveResize
event.display.width = NSWidth(content);
event.display.height = NSHeight(content);
_al_event_source_emit_event(es, &event);
ALLEGRO_INFO("Window finished resizing");
ALLEGRO_INFO("Window finished resizing %d x %d\n", event.display.width, event.display.height);
}
_al_event_source_unlock(es);
}
Expand Down Expand Up @@ -585,7 +585,6 @@ -(void) windowDidResize:(NSNotification*) notification
scale_factor = [window backingScaleFactor];
}
#endif

NSSize max_size;
max_size.width = (dpy_ptr->max_w > 0) ? dpy_ptr->max_w / scale_factor : FLT_MAX;
max_size.height = (dpy_ptr->max_h > 0) ? dpy_ptr->max_h / scale_factor : FLT_MAX;
Expand All @@ -600,7 +599,7 @@ -(void) windowDidResize:(NSNotification*) notification
event.display.width = NSWidth(content);
event.display.height = NSHeight(content);
_al_event_source_emit_event(es, &event);
ALLEGRO_INFO("Window was resized\n");
ALLEGRO_INFO("Window was resized %d x %d\n", event.display.width, event.display.height);
}
_al_event_source_unlock(es);
}
Expand Down Expand Up @@ -720,10 +719,9 @@ static bool set_current_display(ALLEGRO_DISPLAY* d) {
/* Helper to set up GL state as we want it. */
static void setup_gl(ALLEGRO_DISPLAY *d)
{
_al_ogl_setup_gl(d);

ALLEGRO_DISPLAY_OSX_WIN* dpy = (ALLEGRO_DISPLAY_OSX_WIN*) d;
[dpy->ctx performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:YES];
_al_ogl_setup_gl(d);
}


Expand Down Expand Up @@ -2031,19 +2029,17 @@ static bool acknowledge_resize_display_win_main_thread(ALLEGRO_DISPLAY *d)
d->w = NSWidth(content);
d->h = NSHeight(content);

if (d->ogl_extras->backbuffer) {
_al_ogl_resize_backbuffer(d->ogl_extras->backbuffer, d->w, d->h);
}
setup_gl(d);

return true;
}

/* Call from user thread */
static bool acknowledge_resize_display_win(ALLEGRO_DISPLAY *d) {
ASSERT_USER_THREAD();
dispatch_sync(dispatch_get_main_queue(), ^{
acknowledge_resize_display_win_main_thread(d);
});
// must be done on the thread the user calls it from, not the main thread
setup_gl(d);
return true;
}

Expand All @@ -2062,6 +2058,8 @@ static bool resize_display_win(ALLEGRO_DISPLAY *d, int w, int h)
dispatch_sync(dispatch_get_main_queue(), ^{
rc = resize_display_win_main_thread(d, w, h);
});
// must be done on the thread the user calls it from, not the main thread
setup_gl(d);
return rc;
}

Expand Down

0 comments on commit e2ff109

Please sign in to comment.