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.mm25
1 files changed, 17 insertions, 8 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index d30cb1c092..ba3ac9862e 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -339,6 +339,8 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
CGFloat oldBackingScaleFactor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue];
if (OS_OSX::singleton->is_hidpi_allowed()) {
[OS_OSX::singleton->window_view setWantsBestResolutionOpenGLSurface:YES];
+ } else {
+ [OS_OSX::singleton->window_view setWantsBestResolutionOpenGLSurface:NO];
}
if (newBackingScaleFactor != oldBackingScaleFactor) {
@@ -618,7 +620,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
Vector<String> files;
- for (int i = 0; i < filenames.count; i++) {
+ for (NSUInteger i = 0; i < filenames.count; i++) {
NSString *ns = [filenames objectAtIndex:i];
char *utfs = strdup([ns UTF8String]);
String ret;
@@ -707,6 +709,11 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
mm->set_position(pos);
+ mm->set_pressure([event pressure]);
+ if ([event subtype] == NSTabletPointEventSubtype) {
+ const NSPoint p = [event tilt];
+ mm->set_tilt(Vector2(p.x, p.y));
+ }
mm->set_global_position(pos);
mm->set_speed(OS_OSX::singleton->input->get_last_mouse_speed());
Vector2 relativeMotion = Vector2();
@@ -1492,13 +1499,15 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
[window_view setWantsBestResolutionOpenGLSurface:YES];
//if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ } else {
+ [window_view setWantsBestResolutionOpenGLSurface:NO];
}
//[window_object setTitle:[NSString stringWithUTF8String:"GodotEnginies"]];
[window_object setContentView:window_view];
[window_object setDelegate:window_delegate];
[window_object setAcceptsMouseMovedEvents:YES];
- [window_object center];
+ [(NSWindow *)window_object center];
[window_object setRestorable:NO];
@@ -2334,12 +2343,12 @@ void OS_OSX::set_current_screen(int p_screen) {
};
Point2 OS_OSX::get_native_screen_position(int p_screen) const {
- if (p_screen == -1) {
+ if (p_screen < 0) {
p_screen = get_current_screen();
}
NSArray *screenArray = [NSScreen screens];
- if (p_screen < [screenArray count]) {
+ if ((NSUInteger)p_screen < [screenArray count]) {
float display_scale = _display_scale([screenArray objectAtIndex:p_screen]);
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
// Return the top-left corner of the screen, for OS X the y starts at the bottom
@@ -2358,12 +2367,12 @@ Point2 OS_OSX::get_screen_position(int p_screen) const {
}
int OS_OSX::get_screen_dpi(int p_screen) const {
- if (p_screen == -1) {
+ if (p_screen < 0) {
p_screen = get_current_screen();
}
NSArray *screenArray = [NSScreen screens];
- if (p_screen < [screenArray count]) {
+ if ((NSUInteger)p_screen < [screenArray count]) {
float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
@@ -2377,12 +2386,12 @@ int OS_OSX::get_screen_dpi(int p_screen) const {
}
Size2 OS_OSX::get_screen_size(int p_screen) const {
- if (p_screen == -1) {
+ if (p_screen < 0) {
p_screen = get_current_screen();
}
NSArray *screenArray = [NSScreen screens];
- if (p_screen < [screenArray count]) {
+ if ((NSUInteger)p_screen < [screenArray count]) {
float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
// Note: Use frame to get the whole screen size
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];