Browse Source

WIP: macOS port
- Switching to fullscreen at non-desktop resolution now works properly
- Fixing an issue where mouse up event didn't trigger after a fullscreen toggle

Marko Pintera 7 năm trước cách đây
mục cha
commit
2c6f9503f4

+ 8 - 0
Source/BansheeCore/Private/MacOS/BsMacOSWindow.mm

@@ -87,6 +87,14 @@ static bool keyCodeToInputCommand(uint32_t keyCode, bool shift, bs::InputCommand
 	[self addTrackingArea:mTrackingArea];
 }
 
+-(void)mouseUp:(NSEvent*)event
+{
+	// After a fullscreen switch the view starts eating the mouseUp event, so we instead forward the event to window's
+	// responder for normal handling
+	if([event.window nextResponder])
+		[[event.window nextResponder] mouseUp:event];
+}
+
 -(void)rightMouseDown:(NSEvent*)event
 {
 	// By default the view eats the right mouse event, but we instead forward the event to window's responder for normal

+ 3 - 1
Source/BansheeGLRenderAPI/MacOS/BsMacOSContext.mm

@@ -23,7 +23,6 @@ namespace bs::ct
 
 		attributes[attrIdx++] = NSOpenGLPFAOpenGLProfile;
 		attributes[attrIdx++] = NSOpenGLProfileVersion4_1Core;
-
 		attributes[attrIdx++] = NSOpenGLPFADoubleBuffer;
 		attributes[attrIdx++] = NSOpenGLPFAAccelerated;
 
@@ -71,7 +70,10 @@ namespace bs::ct
 
 		CocoaWindow* window = MacOSPlatform::getWindow(windowId);
 		if(!window)
+		{
+			MacOSPlatform::unlockWindows();
 			return;
+		}
 
 		NSWindow* nsWindow = window->_getPrivateData()->window;
 

+ 3 - 34
Source/BansheeGLRenderAPI/MacOS/BsMacOSRenderWindow.mm

@@ -314,43 +314,12 @@ namespace bs
 
 		auto& destOutput = static_cast<const ct::MacOSVideoOutputInfo&>(output);
 		auto& newMode = static_cast<const ct::MacOSVideoMode&>(mode);
-		auto& desktopMode = static_cast<const ct::MacOSVideoMode&>(output.getDesktopVideoMode());
 
+		// Note: An alternative to changing display resolution would be to only change the back-buffer size. But that doesn't
+		// account for refresh rate, so it's questionable how useful it would be.
 		CGDirectDisplayID displayID = destOutput._getDisplayID();
+		CGDisplaySetDisplayMode(displayID, newMode._getModeRef(), nullptr);
 
-		if (desktopMode._getModeRef() == newMode._getModeRef())
-		{
-			CGDisplaySetDisplayMode(displayID, newMode._getModeRef(), nullptr);
-
-			if (CGDisplayIsMain(displayID))
-				CGReleaseAllDisplays();
-			else
-				CGDisplayRelease(displayID);
-		}
-		else
-		{
-			CGError status;
-			if (CGDisplayIsMain(displayID))
-				status = CGCaptureAllDisplays();
-			else
-				status = CGDisplayCapture(displayID);
-
-			if (status != kCGErrorSuccess)
-				goto UNFADE;
-
-			status = CGDisplaySetDisplayMode(displayID, newMode._getModeRef(), nullptr);
-			if(status != kCGErrorSuccess)
-			{
-				if (CGDisplayIsMain(displayID))
-					CGReleaseAllDisplays();
-				else
-					CGDisplayRelease(displayID);
-
-				goto UNFADE;
-			}
-		}
-
-		UNFADE:
 		if (fadeToken != kCGDisplayFadeReservationInvalidToken)
 		{
 			CGDisplayFade(fadeToken, 0.3f, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, FALSE);