Skip to content

Commit

Permalink
Titlebar fix we can now switch between enabling and disabling it duri…
Browse files Browse the repository at this point in the history
…ng runtime
  • Loading branch information
kasperhbo committed Feb 15, 2024
1 parent 9c72937 commit 63642a7
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,8 @@ static GLFWbool createNativeWindow(_GLFWwindow *window,
}

//todo:implement
if(window->monitor || !window->titleBar) {
}
else{
if (window->monitor || !window->titleBar) {
} else {
}

window->ns.object =
Expand Down Expand Up @@ -1288,17 +1287,19 @@ void _glfwSetWindowResizableCocoa(_GLFWwindow *window, GLFWbool enabled) {
void _glfwSetWindowDecoratedCocoa(_GLFWwindow *window, GLFWbool enabled) {
@autoreleasepool {

NSUInteger styleMask = [window->ns.object styleMask];
if (enabled) {
styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
styleMask &= ~NSWindowStyleMaskBorderless;
} else {
styleMask |= NSWindowStyleMaskBorderless;
styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
}
[window->ns.object setStyleMask:styleMask];
[window->ns.object makeFirstResponder:window->ns.view];
}
NSUInteger styleMask = [window->ns.object styleMask];
if (enabled) {
styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
styleMask &= ~NSWindowStyleMaskBorderless;
} else {
styleMask |= NSWindowStyleMaskBorderless;
styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
}

[window->ns.object setStyleMask:styleMask];
[window->ns.object makeFirstResponder:window->ns.view];

}// autoreleasepool
}

void _glfwSetWindowTitlebarCocoa(_GLFWwindow *window, GLFWbool enabled) {
Expand All @@ -1309,21 +1310,21 @@ void _glfwSetWindowTitlebarCocoa(_GLFWwindow *window, GLFWbool enabled) {
m_nsWindow.hasShadow = false;
m_nsWindow.backgroundColor = [NSColor clearColor];

m_nsWindow.titleVisibility = NSWindowTitleVisible;
m_nsWindow.titleVisibility |= NSWindowTitleVisible;
m_nsWindow.titlebarAppearsTransparent = true;
m_nsWindow.styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView;
m_nsWindow.titleVisibility = NSWindowTitleHidden;
m_nsWindow.styleMask |= NSWindowStyleMaskFullSizeContentView;
m_nsWindow.titleVisibility |= NSWindowTitleHidden;
} else {
NSWindow *m_nsWindow = window->ns.object;

m_nsWindow.opaque = true;
m_nsWindow.hasShadow = true;
m_nsWindow.backgroundColor = [NSColor windowBackgroundColor];

m_nsWindow.titleVisibility = NSWindowTitleVisible;
m_nsWindow.titleVisibility &= ~NSWindowTitleVisible;
m_nsWindow.titlebarAppearsTransparent = false;
m_nsWindow.styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView;
m_nsWindow.titleVisibility = NSWindowTitleVisible;
m_nsWindow.styleMask &= ~NSWindowStyleMaskFullSizeContentView;
m_nsWindow.titleVisibility |= NSWindowTitleVisible;
}
}// autoreleasepool
}
Expand Down

0 comments on commit 63642a7

Please sign in to comment.