From f58d03fba4a93488be608d3ec0e25014d089d7aa Mon Sep 17 00:00:00 2001 From: Colin Cornaby Date: Sun, 8 Dec 2024 14:07:13 -0800 Subject: [PATCH] Properly subscribing to display change updates --- Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm b/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm index abba2a0bf4..dbac5a1e51 100644 --- a/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm +++ b/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm @@ -118,6 +118,7 @@ @interface AppDelegate : NSWindowController (); _displayHelper->SetCurrentScreen([window screen]); _displayHelper->MakeCurrentDisplayHelper(); gClient.SetClientWindow((__bridge void *)view.layer); - gClient.SetClientDisplay((hsWindowHndl)NULL); + gClient.SetClientDisplay((__bridge hsWindowHndl)window.screen); self = [super initWithWindow:window]; self.window.acceptsMouseMovedEvents = YES; @@ -237,7 +238,6 @@ - (void)startRunLoop object:self.window queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* _Nonnull note) { - _displayHelper->SetCurrentScreen(self.window.screen); // if we change displays, setup a new draw loop. The new display might // have a different or variable refresh rate. [self setupRunLoop]; @@ -398,7 +398,6 @@ - (void)initializeClient while (!gClient.IsInited()) { [NSRunLoop.mainRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } - if (!gClient || gClient->GetDone()) { [NSApp terminate:self]; @@ -489,6 +488,8 @@ - (void)loginWindowControllerDidLogin:(PLSLoginWindowController*)sender - (void)startClient { PF_CONSOLE_INITIALIZE(Audio) + + [self.gameWindow setDelegate:self]; self.plsView.delegate = self; // Create a window: @@ -582,6 +583,11 @@ - (NSApplicationPresentationOptions)window:(NSWindow*)window NSApplicationPresentationAutoHideMenuBar; } +- (void)windowDidChangeScreen:(NSNotification *)notification +{ + _displayHelper->SetCurrentScreen(self.window.screen); +} + - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (context == DeviceDidChangeContext) {