summaryrefslogtreecommitdiff
path: root/src/video/cocoa/cocoa_wnd.mm
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-01-30 19:13:29 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-13 22:21:17 +0100
commit8aaf4ea0987a361e5d4f7b690544ee9119746660 (patch)
treeb7f29c2f7f630289a251deae9d4521e5be32d0e9 /src/video/cocoa/cocoa_wnd.mm
parent0eff7de6594b0b0cb451a992287239b04eb66fc4 (diff)
downloadopenttd-8aaf4ea0987a361e5d4f7b690544ee9119746660.tar.xz
Codechange: [OSX] Split Window and back buffer creation in Cocoa video driver.
Diffstat (limited to 'src/video/cocoa/cocoa_wnd.mm')
-rw-r--r--src/video/cocoa/cocoa_wnd.mm31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm
index ff222ea42..80c2e2e21 100644
--- a/src/video/cocoa/cocoa_wnd.mm
+++ b/src/video/cocoa/cocoa_wnd.mm
@@ -324,10 +324,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
{
[ super setFrame:frameRect display:flag ];
- /* Don't do anything if the window is currently being created */
- if (driver->setup) return;
-
- if (!driver->WindowResized()) error("Cocoa: Failed to resize window.");
+ driver->AllocateBackingStore();
}
/**
* Handle hiding of the application
@@ -401,12 +398,13 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
}
@implementation OTTD_CocoaView
-/**
- * Initialize the driver
- */
-- (void)setDriver:(VideoDriver_Cocoa *)drv
+
+- (instancetype)initWithFrame:(NSRect)frameRect andDriver:(VideoDriver_Cocoa *)drv
{
- driver = drv;
+ if (self = [ super initWithFrame:frameRect ]) {
+ self->driver = drv;
+ }
+ return self;
}
/**
* Define the opaqueness of the window / screen
@@ -810,9 +808,12 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
@implementation OTTD_CocoaWindowDelegate
/** Initialize the video driver */
-- (void)setDriver:(VideoDriver_Cocoa *)drv
+- (instancetype)initWithDriver:(VideoDriver_Cocoa *)drv
{
- driver = drv;
+ if (self = [ super init ]) {
+ self->driver = drv;
+ }
+ return self;
}
/** Handle closure requests */
- (BOOL)windowShouldClose:(id)sender
@@ -854,10 +855,11 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
[ e release ];
}
}
-/** The colour profile of the screen the window is on changed. */
-- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification
+/** Screen the window is on changed. */
+- (void)windowDidChangeBackingProperties:(NSNotification *)notification
{
- if (!driver->setup) driver->WindowResized();
+ /* Reallocate screen buffer if necessary. */
+ driver->AllocateBackingStore();
}
/** Presentation options to use for fullsreen mode. */
@@ -867,4 +869,5 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
}
@end
+
#endif /* WITH_COCOA */