summaryrefslogtreecommitdiff
path: root/platform/osx/os_osx.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/osx/os_osx.mm')
-rw-r--r--platform/osx/os_osx.mm31
1 files changed, 14 insertions, 17 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 886ff4b332..6ab433203f 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -76,11 +76,6 @@
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#endif
-static NSRect convertRectToBacking(NSRect contentRect) {
-
- return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
-}
-
static void get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> state) {
state->set_shift((p_osx_state & NSEventModifierFlagShift));
@@ -271,7 +266,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
float newDisplayScale = OS_OSX::singleton->is_hidpi_allowed() ? newBackingScaleFactor : 1.0;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
+ const NSRect fbRect = contentRect;
OS_OSX::singleton->window_size.width = fbRect.size.width * newDisplayScale;
OS_OSX::singleton->window_size.height = fbRect.size.height * newDisplayScale;
@@ -292,7 +287,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
[OS_OSX::singleton->context update];
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
+ const NSRect fbRect = contentRect;
float displayScale = OS_OSX::singleton->_display_scale();
OS_OSX::singleton->window_size.width = fbRect.size.width * displayScale;
@@ -1864,28 +1859,30 @@ bool OS_OSX::can_draw() const {
void OS_OSX::set_clipboard(const String &p_text) {
- NSArray *types = [NSArray arrayWithObjects:NSStringPboardType, nil];
+ NSString *copiedString = [NSString stringWithUTF8String:p_text.utf8().get_data()];
+ NSArray *copiedStringArray = [NSArray arrayWithObject:copiedString];
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
- [pasteboard declareTypes:types owner:nil];
- [pasteboard setString:[NSString stringWithUTF8String:p_text.utf8().get_data()]
- forType:NSStringPboardType];
+ [pasteboard clearContents];
+ [pasteboard writeObjects:copiedStringArray];
}
String OS_OSX::get_clipboard() const {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
+ NSDictionary *options = [NSDictionary dictionary];
- if (![[pasteboard types] containsObject:NSStringPboardType]) {
- return "";
- }
+ BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
- NSString *object = [pasteboard stringForType:NSStringPboardType];
- if (!object) {
+ if (!ok) {
return "";
}
- char *utfs = strdup([object UTF8String]);
+ NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
+ NSString *string = [objectsToPaste objectAtIndex:0];
+
+ char *utfs = strdup([string UTF8String]);
String ret;
ret.parse_utf8(utfs);
free(utfs);