Skip to content

Commit fab95f1

Browse files
committed
Fix Cocoa window resize regressions after scaler restore
Prevent Cocoa display startup from resizing the restored window before the first rendered frame, so saved zoom/window size is preserved on launch. Also avoid reselecting the current scaler when Preferences closes, preventing unnecessary graphics hotswap and window resize when no scaler actually changed.
1 parent 906517b commit fab95f1

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

fusepb/controllers/PreferencesController.m

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,9 @@ - (void)handleWillClose:(NSNotification *)note
245245
with a now-removed scaler) rather than show ui_error from
246246
scaler_select_id every time Preferences closes. */
247247
int new_scaler = scaler_get_type( settings_current.start_scaler_mode );
248-
if( new_scaler >= 0 ) {
249-
/* scaler_select_scaler is a no-op when the requested scaler is already
250-
current; if it isn't supported on the current machine it returns
251-
non-zero and current_scaler is left unchanged. When the scaler does
252-
change, the hotswap inside picks up the new bilinear setting via
253-
createTexture, so no separate hotswap call is needed for that path. */
248+
if( new_scaler >= 0 && new_scaler != current_scaler ) {
249+
/* Changing the scaler hotswaps graphics; selecting the current scaler
250+
would also hotswap and resize the emulator window when Preferences closes. */
254251
scaler_select_scaler( new_scaler );
255252
}
256253

ui/cocoa/cocoadisplay.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
static uint16_t bw_values[16];
9292

9393
static int display_updated = 0;
94+
static int window_resize_enabled = 0;
9495

9596
/* This is a rule of thumb for the maximum number of rects that can be updated
9697
each frame. */
@@ -241,10 +242,10 @@ Callers may be on a worker thread (fuse_init runs on the emulator thread
241242
static void
242243
cocoadisplay_resize_window( void )
243244
{
244-
/* Skip during the very first uidisplay_init so the xib's window size is
245-
preserved at launch. Subsequent inits (machine change) and every
246-
hotswap will resize. */
247-
if( !display_ui_initialised || settings_current.full_screen ) return;
245+
/* Startup applies the saved scaler before the first rendered frame; let
246+
AppKit keep the restored window frame until emulation is visibly running. */
247+
if( !display_ui_initialised || !window_resize_enabled ||
248+
settings_current.full_screen ) return;
248249

249250
float factor = scaler_get_scaling_factor( current_scaler );
250251
NSSize size = NSMakeSize( image_width * factor, image_height * factor );
@@ -532,6 +533,8 @@ pixels is NULL on the very first hotswap (before uidisplay_init has run
532533
{
533534
int i;
534535

536+
window_resize_enabled = 1;
537+
535538
if( display_updated ) {
536539
/* obtain lock for buffered screen */
537540
[buffered_screen_lock lock];

0 commit comments

Comments
 (0)