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

feat: support moving macos windows with hidden decorations #6129

Closed
wants to merge 1 commit into from
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