Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions glfw/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#include <float.h>
#include <string.h>
#import <objc/runtime.h>

@interface FakeView : NSView
@end
@implementation FakeView
- (BOOL)fakeMouseDownCanMoveWindow { return YES; }
@end

static const char*
polymorphic_string_as_utf8(id string) {
Expand Down Expand Up @@ -2920,6 +2926,13 @@ GLFWAPI void glfwHideCocoaTitlebar(GLFWwindow* handle, bool yes) {
button = [window standardWindowButton: NSWindowZoomButton];
[window setTitlebarAppearsTransparent:yes];
if (button) button.hidden = yes;

// http://svenandersson.se/2016/rendering-to-full-size-of-an-nswindow-using-glfw3.html
NSView* glView = [window contentView];
Method originalMethod = class_getInstanceMethod([glView class], @selector(mouseDownCanMoveWindow));
Method categoryMethod = class_getInstanceMethod(FakeView.class, @selector(fakeMouseDownCanMoveWindow));
method_exchangeImplementations(originalMethod, categoryMethod);

if (yes) {
[window setTitleVisibility:NSWindowTitleHidden];
[window setStyleMask: [window styleMask] | NSWindowStyleMaskFullSizeContentView];
Expand Down