@@ -235,6 +235,7 @@ -(void) viewDidMoveToWindow;
235
235
-(void ) viewWillMoveToWindow : (NSWindow *) newWindow ;
236
236
-(void ) mouseEntered : (NSEvent *) evt ;
237
237
-(void ) mouseExited : (NSEvent *) evt ;
238
+ -(void ) viewWillStartLiveResize ;
238
239
-(void ) viewDidEndLiveResize ;
239
240
/* Window delegate methods */
240
241
-(void ) windowDidBecomeMain : (NSNotification *) notification ;
@@ -519,6 +520,33 @@ -(void) viewDidChangeBackingProperties
519
520
}
520
521
#endif
521
522
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
+
522
550
-(void ) viewDidEndLiveResize
523
551
{
524
552
[super viewDidEndLiveResize ];
@@ -541,6 +569,11 @@ -(void) viewDidEndLiveResize
541
569
event.display .height = NSHeight (content);
542
570
_al_event_source_emit_event (es, &event);
543
571
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
+ }
544
577
}
545
578
_al_event_source_unlock (es);
546
579
dpy->old_w = NSWidth (content);
@@ -1104,6 +1137,19 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
1104
1137
CVDisplayLinkStart (dpy->display_link );
1105
1138
}
1106
1139
1140
+ static void init_halt_events (ALLEGRO_DISPLAY_OSX_WIN *dpy)
1141
+ {
1142
+ const char * value = al_get_config_value (al_get_system_config (), " osx" , " allow_live_resize" );
1143
+ if (value && strcmp (value, " false" ) == 0 ) {
1144
+ dpy->send_halt_events = true ;
1145
+ }
1146
+ else {
1147
+ dpy->send_halt_events = false ;
1148
+ }
1149
+ dpy->halt_mutex = al_create_mutex ();
1150
+ dpy->halt_cond = al_create_cond ();
1151
+ }
1152
+
1107
1153
/* create_display_fs:
1108
1154
* Create a fullscreen display - capture the display
1109
1155
*/
@@ -1141,6 +1187,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
1141
1187
_al_event_source_init (&display->es );
1142
1188
dpy->cursor = [[NSCursor arrowCursor ] retain ];
1143
1189
dpy->display_id = CGMainDisplayID ();
1190
+ init_halt_events (dpy);
1144
1191
1145
1192
/* Get display ID for the requested display */
1146
1193
if (al_get_new_display_adapter () > 0 ) {
@@ -1338,6 +1385,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
1338
1385
_al_event_source_init(&dpy->parent.es);
1339
1386
osx_change_cursor(dpy, [NSCursor arrowCursor]);
1340
1387
dpy->show_cursor = YES;
1388
+ init_halt_events(dpy);
1341
1389
1342
1390
// Set up a pixel format to describe the mode we want.
1343
1391
osx_set_opengl_pixelformat_attributes(dpy);
@@ -1519,6 +1567,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
1519
1567
_al_event_source_init (&display->es );
1520
1568
_al_osx_change_cursor (dpy, [NSCursor arrowCursor ]);
1521
1569
dpy->show_cursor = YES ;
1570
+ init_halt_events (dpy);
1522
1571
1523
1572
// Set up a pixel format to describe the mode we want.
1524
1573
osx_set_opengl_pixelformat_attributes (dpy);
@@ -1807,6 +1856,8 @@ static void destroy_display(ALLEGRO_DISPLAY* d)
1807
1856
_al_set_current_display_only (NULL );
1808
1857
}
1809
1858
1859
+ al_destroy_cond (dpy->halt_cond );
1860
+ al_destroy_mutex (dpy->halt_mutex );
1810
1861
if (dpy->flip_mutex ) {
1811
1862
al_destroy_mutex (dpy->flip_mutex );
1812
1863
al_destroy_cond (dpy->flip_cond );
@@ -2497,6 +2548,15 @@ static bool set_display_flag(ALLEGRO_DISPLAY *display, int flag, bool onoff)
2497
2548
#endif
2498
2549
}
2499
2550
2551
+ static void acknowledge_drawing_halt (ALLEGRO_DISPLAY *display)
2552
+ {
2553
+ ALLEGRO_DISPLAY_OSX_WIN *dpy = (ALLEGRO_DISPLAY_OSX_WIN *)display;
2554
+ al_lock_mutex (dpy->halt_mutex );
2555
+ dpy->halt_event_acknowledged = true ;
2556
+ al_signal_cond (dpy->halt_cond );
2557
+ al_unlock_mutex (dpy->halt_mutex );
2558
+ }
2559
+
2500
2560
ALLEGRO_DISPLAY_INTERFACE* _al_osx_get_display_driver_win (void )
2501
2561
{
2502
2562
static ALLEGRO_DISPLAY_INTERFACE* vt = NULL ;
@@ -2527,6 +2587,7 @@ static bool set_display_flag(ALLEGRO_DISPLAY *display, int flag, bool onoff)
2527
2587
vt->set_display_flag = set_display_flag;
2528
2588
vt->set_icons = set_icons;
2529
2589
vt->update_render_state = _al_ogl_update_render_state;
2590
+ vt->acknowledge_drawing_halt = acknowledge_drawing_halt;
2530
2591
_al_ogl_add_drawing_functions (vt);
2531
2592
_al_osx_add_clipboard_functions (vt);
2532
2593
}
0 commit comments