@@ -235,6 +235,7 @@ -(void) viewDidMoveToWindow;
235235-(void ) viewWillMoveToWindow : (NSWindow *) newWindow ;
236236-(void ) mouseEntered : (NSEvent *) evt ;
237237-(void ) mouseExited : (NSEvent *) evt ;
238+ -(void ) viewWillStartLiveResize ;
238239-(void ) viewDidEndLiveResize ;
239240/* Window delegate methods */
240241-(void ) windowDidBecomeMain : (NSNotification *) notification ;
@@ -519,6 +520,33 @@ -(void) viewDidChangeBackingProperties
519520}
520521#endif
521522
523+ -(void ) viewWillStartLiveResize
524+ {
525+ ALLEGRO_DISPLAY_OSX_WIN* dpy = (ALLEGRO_DISPLAY_OSX_WIN*) dpy_ptr;
526+ ALLEGRO_EVENT_SOURCE *es = &dpy->parent .es ;
527+
528+ if (dpy->send_halt_events ) {
529+ al_lock_mutex (dpy->halt_mutex );
530+ dpy->halt_event_acknowledged = false ;
531+ al_unlock_mutex (dpy->halt_mutex );
532+
533+ _al_event_source_lock (es);
534+ if (_al_event_source_needs_to_generate_event (es)) {
535+ ALLEGRO_EVENT event;
536+ event.display .type = ALLEGRO_EVENT_DISPLAY_HALT_DRAWING;
537+ event.display .timestamp = al_get_time ();
538+ _al_event_source_emit_event (es, &event);
539+ }
540+ _al_event_source_unlock (es);
541+
542+ al_lock_mutex (dpy->halt_mutex );
543+ while (!dpy->halt_event_acknowledged ) {
544+ al_wait_cond (dpy->halt_cond , dpy->halt_mutex );
545+ }
546+ al_unlock_mutex (dpy->halt_mutex );
547+ }
548+ }
549+
522550-(void ) viewDidEndLiveResize
523551{
524552 [super viewDidEndLiveResize ];
@@ -541,6 +569,11 @@ -(void) viewDidEndLiveResize
541569 event.display .height = NSHeight (content);
542570 _al_event_source_emit_event (es, &event);
543571 ALLEGRO_INFO (" Window finished resizing %d x %d \n " , event.display .width , event.display .height );
572+
573+ if (dpy->send_halt_events ) {
574+ event.display .type = ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING;
575+ _al_event_source_emit_event (es, &event);
576+ }
544577 }
545578 _al_event_source_unlock (es);
546579}
@@ -1102,6 +1135,19 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
11021135 CVDisplayLinkStart (dpy->display_link );
11031136}
11041137
1138+ static void init_halt_events (ALLEGRO_DISPLAY_OSX_WIN *dpy)
1139+ {
1140+ const char * value = al_get_config_value (al_get_system_config (), " osx" , " allow_live_resize" );
1141+ if (value && strcmp (value, " false" ) == 0 ) {
1142+ dpy->send_halt_events = true ;
1143+ }
1144+ else {
1145+ dpy->send_halt_events = false ;
1146+ }
1147+ dpy->halt_mutex = al_create_mutex ();
1148+ dpy->halt_cond = al_create_cond ();
1149+ }
1150+
11051151/* create_display_fs:
11061152 * Create a fullscreen display - capture the display
11071153 */
@@ -1139,6 +1185,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
11391185 _al_event_source_init (&display->es );
11401186 dpy->cursor = [[NSCursor arrowCursor ] retain ];
11411187 dpy->display_id = CGMainDisplayID ();
1188+ init_halt_events (dpy);
11421189
11431190 /* Get display ID for the requested display */
11441191 if (al_get_new_display_adapter () > 0 ) {
@@ -1334,6 +1381,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
13341381 _al_event_source_init(&dpy->parent.es);
13351382 osx_change_cursor(dpy, [NSCursor arrowCursor]);
13361383 dpy->show_cursor = YES;
1384+ init_halt_events(dpy);
13371385
13381386 // Set up a pixel format to describe the mode we want.
13391387 osx_set_opengl_pixelformat_attributes(dpy);
@@ -1513,6 +1561,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
15131561 _al_event_source_init (&display->es );
15141562 _al_osx_change_cursor (dpy, [NSCursor arrowCursor ]);
15151563 dpy->show_cursor = YES ;
1564+ init_halt_events (dpy);
15161565
15171566 // Set up a pixel format to describe the mode we want.
15181567 osx_set_opengl_pixelformat_attributes (dpy);
@@ -1799,6 +1848,8 @@ static void destroy_display(ALLEGRO_DISPLAY* d)
17991848 _al_set_current_display_only (NULL );
18001849 }
18011850
1851+ al_destroy_cond (dpy->halt_cond );
1852+ al_destroy_mutex (dpy->halt_mutex );
18021853 if (dpy->flip_mutex ) {
18031854 al_destroy_mutex (dpy->flip_mutex );
18041855 al_destroy_cond (dpy->flip_cond );
@@ -2489,6 +2540,15 @@ static bool set_display_flag(ALLEGRO_DISPLAY *display, int flag, bool onoff)
24892540#endif
24902541}
24912542
2543+ static void acknowledge_drawing_halt (ALLEGRO_DISPLAY *display)
2544+ {
2545+ ALLEGRO_DISPLAY_OSX_WIN *dpy = (ALLEGRO_DISPLAY_OSX_WIN *)display;
2546+ al_lock_mutex (dpy->halt_mutex );
2547+ dpy->halt_event_acknowledged = true ;
2548+ al_signal_cond (dpy->halt_cond );
2549+ al_unlock_mutex (dpy->halt_mutex );
2550+ }
2551+
24922552ALLEGRO_DISPLAY_INTERFACE* _al_osx_get_display_driver_win (void )
24932553{
24942554 static ALLEGRO_DISPLAY_INTERFACE* vt = NULL ;
@@ -2519,6 +2579,7 @@ static bool set_display_flag(ALLEGRO_DISPLAY *display, int flag, bool onoff)
25192579 vt->set_display_flag = set_display_flag;
25202580 vt->set_icons = set_icons;
25212581 vt->update_render_state = _al_ogl_update_render_state;
2582+ vt->acknowledge_drawing_halt = acknowledge_drawing_halt;
25222583 _al_ogl_add_drawing_functions (vt);
25232584 _al_osx_add_clipboard_functions (vt);
25242585 }
0 commit comments