summaryrefslogtreecommitdiff
path: root/src/video/cocoa
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-01-14 21:53:06 +0100
committerGitHub <noreply@github.com>2021-01-14 21:53:06 +0100
commitfa60c1f8b94dd5584a5d5331de277ca23a203422 (patch)
tree7849166d1c2ee40f4d48f4fc4442af1ee24b3b2f /src/video/cocoa
parent711723d7387df67b1abe98ca9ed4d7f2bd7de57d (diff)
downloadopenttd-fa60c1f8b94dd5584a5d5331de277ca23a203422.tar.xz
Feature: Choose a sensible window size on a fresh OTTD config file. (#8536)
Diffstat (limited to 'src/video/cocoa')
-rw-r--r--src/video/cocoa/cocoa_v.h3
-rw-r--r--src/video/cocoa/cocoa_v.mm11
2 files changed, 14 insertions, 0 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index f5d175640..54ff53d15 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -70,6 +70,9 @@ public:
/** Main game loop. */
void GameLoop(); // In event.mm.
+protected:
+ Dimension GetScreenSize() const override;
+
private:
friend class WindowQuartzSubdriver;
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index eae1acbc9..f09920fe2 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -200,6 +200,8 @@ const char *VideoDriver_Cocoa::Start(const StringList &parm)
/* Don't create a window or enter fullscreen if we're just going to show a dialog. */
if (!CocoaSetupApplication()) return NULL;
+ this->UpdateAutoResolution();
+
this->orig_res = _cur_resolution;
int width = _cur_resolution.width;
int height = _cur_resolution.height;
@@ -303,6 +305,15 @@ void VideoDriver_Cocoa::EditBoxLostFocus()
}
/**
+ * Get the resolution of the main screen.
+ */
+Dimension VideoDriver_Cocoa::GetScreenSize() const
+{
+ NSRect frame = [ [ NSScreen mainScreen ] frame ];
+ return { static_cast<uint>(NSWidth(frame)), static_cast<uint>(NSHeight(frame)) };
+}
+
+/**
* Handle a change of the display area.
*/
void VideoDriver_Cocoa::GameSizeChanged()