Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8067: [OSX] Calculate title bar height instead of assuming a fixed value #8491

Merged
merged 2 commits into from Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion src/video/cocoa/cocoa_v.h
Expand Up @@ -18,7 +18,6 @@ extern bool _cocoa_video_started;

class VideoDriver_Cocoa : public VideoDriver {
private:
bool fullscreen_on_mainloop; ///< Switch to fullscreen once the main loop is running?
Dimension orig_res; ///< Saved window size for non-fullscreen mode.

public:
Expand Down
7 changes: 3 additions & 4 deletions src/video/cocoa/cocoa_v.mm
Expand Up @@ -156,6 +156,7 @@ static void QZ_UpdateVideoModes()
static CocoaSubdriver *QZ_CreateSubdriver(int width, int height, int bpp, bool fullscreen, bool fallback)
{
CocoaSubdriver *ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
if (ret != nullptr && fullscreen) ret->ToggleFullscreen(fullscreen);

if (ret != nullptr) return ret;
if (!fallback) return nullptr;
Expand Down Expand Up @@ -209,9 +210,6 @@ static void QZ_UpdateVideoModes()
return "The cocoa quartz subdriver only supports 8 and 32 bpp.";
}

/* Defer fullscreen toggle until the main loop is running,
* as otherwise a grey bar will be stuck on top of the window. */
this->fullscreen_on_mainloop = _fullscreen;
_cocoa_subdriver = QZ_CreateSubdriver(width, height, bpp, _fullscreen, true);
if (_cocoa_subdriver == NULL) {
Stop();
Expand Down Expand Up @@ -569,7 +567,8 @@ - (void)drawRect:(NSRect)invalidRect
[ this->window setContentSize:contentRect.size ];

/* Ensure frame height - title bar height >= view height */
contentRect.size.height = Clamp(height, 0, (int)[ this->window frame ].size.height - 22 /* 22 is the height of title bar of window*/);
float content_height = [ this->window contentRectForFrameRect:[ this->window frame ] ].size.height;
contentRect.size.height = Clamp(height, 0, (int)content_height);

if (this->cocoaview != nil) {
height = (int)contentRect.size.height;
Expand Down
6 changes: 0 additions & 6 deletions src/video/cocoa/event.mm
Expand Up @@ -652,12 +652,6 @@ static bool QZ_PollEvent()

while (QZ_PollEvent()) {}

/* If we do that right after window creation, a grey bar will be left at the top. */
if (this->fullscreen_on_mainloop) {
this->fullscreen_on_mainloop = false;
_cocoa_subdriver->ToggleFullscreen(true);
}

if (_exit_game) {
/* Restore saved resolution if in fullscreen mode. */
if (_cocoa_subdriver->IsFullscreen()) _cur_resolution = this->orig_res;
Expand Down