summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-06-28 07:51:52 +0200
committerGitHub <noreply@github.com>2017-06-28 07:51:52 +0200
commit82298e989abfc6732e535704d2a303f0676d51bc (patch)
treea98e0b0538f99cc085f134850bf452013b7aec0f
parentf59430beef2fa0d34670b4533167f03018454b00 (diff)
parentfd7976ddd7e54814a865015380bd9f3ea3cbf92f (diff)
Merge pull request #9416 from marcelofg55/master
Implemented borderless window code for OSX.
-rw-r--r--platform/osx/os_osx.h4
-rw-r--r--platform/osx/os_osx.mm35
2 files changed, 38 insertions, 1 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 123816b22d..dc3e88df2c 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -96,6 +96,7 @@ public:
CursorShape cursor_shape;
MouseMode mouse_mode;
+ String title;
bool minimized;
bool maximized;
bool zoomed;
@@ -200,6 +201,9 @@ public:
virtual void request_attention();
virtual String get_joy_guid(int p_device) const;
+ virtual void set_borderless_window(int p_borderless);
+ virtual bool get_borderless_window();
+
virtual PowerState get_power_state();
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 1070de724b..ad1e308ae0 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -53,6 +53,10 @@
#include <sys/types.h>
#include <unistd.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
+#endif
+
static NSRect convertRectToBacking(NSRect contentRect) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
@@ -813,7 +817,13 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
// Don't use accumulation buffer support; it's not accelerated
// Aux buffers probably aren't accelerated either
- unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable ? NSResizableWindowMask : 0);
+ unsigned int styleMask;
+
+ if (p_desired.borderless_window) {
+ styleMask = NSWindowStyleMaskBorderless;
+ } else {
+ styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable ? NSResizableWindowMask : 0);
+ }
window_object = [[GodotWindow alloc]
initWithContentRect:NSMakeRect(0, 0, p_desired.width, p_desired.height)
@@ -1125,6 +1135,7 @@ int OS_OSX::get_mouse_button_state() const {
}
void OS_OSX::set_window_title(const String &p_title) {
+ title = p_title;
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
}
@@ -1403,6 +1414,28 @@ void OS_OSX::request_attention() {
[NSApp requestUserAttention:NSCriticalRequest];
}
+void OS_OSX::set_borderless_window(int p_borderless) {
+
+ if (p_borderless)
+ [window_object setStyleMask:NSWindowStyleMaskBorderless];
+ else {
+ [window_object setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask];
+
+ // Force update of the window styles
+ NSRect frameRect = [window_object frame];
+ [window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
+ [window_object setFrame:frameRect display:NO];
+
+ // Restore the window title
+ [window_object setTitle:[NSString stringWithUTF8String:title.utf8().get_data()]];
+ }
+}
+
+bool OS_OSX::get_borderless_window() {
+
+ return [window_object styleMask] == NSWindowStyleMaskBorderless;
+}
+
String OS_OSX::get_executable_path() const {
int ret;