2
0
Эх сурвалжийг харах

WIP: macOS port
- Window creation and move methods now properly position the window
- Fixing an issue where floating windows couldn't be re-docked
- Fixing an issue where newly opened floating windows didn't have their focus received event triggered

Marko Pintera 7 жил өмнө
parent
commit
c6fa8c1da1

+ 2 - 1
Source/BansheeCore/Private/MacOS/BsMacOSPlatform.mm

@@ -644,10 +644,11 @@ namespace bs
 			CFNumberGetValue(layerRef, kCFNumberIntType, &layer);
 
 			// Layer 0 appear to be normal windows
+			// Layer 3 appear to be floating windows
 			// Layer 8 appear to be modal windows
 			// Layer 25 appear to be fullscreen windows
 			// Note: This is based on experimentation, as no documentation about it exists
-			if(layer != 0 && layer != 8 && layer != 25)
+			if(layer != 0 && layer != 3 && layer != 8 && layer != 25)
 				continue;
 
 			CFDictionaryRef boundsRef = (CFDictionaryRef)CFDictionaryGetValue(dict, kCGWindowBounds);

+ 12 - 6
Source/BansheeCore/Private/MacOS/BsMacOSWindow.mm

@@ -573,18 +573,23 @@ namespace bs
 		{
 			NSRect screenRect = [entry frame];
 
-			if(((desc.x >= screenRect.origin.x && desc.y < (screenRect.origin.x + screenRect.size.width)) || desc.x == -1) &&
-			   ((desc.y >= screenRect.origin.y && desc.y < (screenRect.origin.y + screenRect.size.height)) || desc.y == -1))
+			INT32 left = (INT32)screenRect.origin.x;
+			INT32 right = left + (INT32)screenRect.size.width;
+			INT32 bottom = (INT32)screenRect.origin.y;
+			INT32 top = bottom + (INT32)screenRect.size.height;
+
+			if(((desc.x >= left && desc.x < right) || desc.x == -1) &&
+			   ((desc.y >= bottom && desc.y < top) || desc.y == -1))
 			{
 				if(desc.x == -1)
-					x = (INT32)screenRect.origin.x + std::max(0, (INT32)screenRect.size.width - (INT32)desc.width) / 2;
+					x = left + std::max(0, (INT32)screenRect.size.width - (INT32)desc.width) / 2;
 				else
-					x = desc.x - (INT32)screenRect.origin.x;
+					x = desc.x - left;
 
 				if(desc.y == -1)
-					y = (INT32)screenRect.origin.y + std::max(0, (INT32)screenRect.size.height - (INT32)desc.height) / 2;
+					y = bottom + std::max(0, (INT32)screenRect.size.height - (INT32)desc.height) / 2;
 				else
-					y = desc.y - (INT32)screenRect.origin.y;
+					y = ((INT32)screenRect.size.height - (desc.y + desc.height)) - bottom;
 
 				screen = entry;
 				break;
@@ -674,6 +679,7 @@ namespace bs
 			point.x = x;
 			point.y = y;
 
+			flipY(m->window.screen, point);
 			[m->window setFrameTopLeftPoint:point];
 		}
 	}

+ 2 - 1
Source/BansheeEditor/GUI/BsGUITabbedTitleBar.cpp

@@ -358,7 +358,8 @@ namespace bs
 			GUITabButton* btn = mTabButtons[i];
 			Vector2I optimalSize = btn->_getOptimalSize();
 
-			draggableAreas.push_back(Rect2I(curX, curY, TAB_SPACING, height));
+			if(TAB_SPACING > 0)
+				draggableAreas.push_back(Rect2I(curX, curY, TAB_SPACING, height));
 
 			curX += TAB_SPACING + optimalSize.x;
 		}

+ 4 - 0
Source/BansheeGLRenderAPI/MacOS/BsMacOSRenderWindow.mm

@@ -49,6 +49,7 @@ namespace bs
 		props.height = area.height;
 		props.top = area.y;
 		props.left = area.x;
+		props.hasFocus = true;
 
 		props.hwGamma = mDesc.gamma;
 		props.multisampleCount = mDesc.multisampleCount;
@@ -69,6 +70,9 @@ namespace bs
 		}
 
 		ct::RenderWindowManager::instance().notifySyncDataDirty(getCore().get());
+
+		// New windows always receive focus, but we don't receive an initial event from the OS, so trigger one manually
+		RenderWindowManager::instance().notifyFocusReceived(getCore().get());
 	}
 
 	void MacOSRenderWindow::destroy()