Changeset 54024 in vbox
- Timestamp:
- Jan 29, 2015 6:38:21 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 97937
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r53948 r54024 890 890 - (NSSize)size; 891 891 - (void)updateViewportCS; 892 - (NSRect)safeConvertToScreen:(NSRect *)pRect; 892 893 - (void)vboxReshapePerform; 893 894 - (void)vboxReshapeOnResizePerform; … … 1539 1540 (int)m_Pos.x, (int)m_Pos.y)); 1540 1541 1542 DEBUG_MSG(("vboxSetPosUI: [%d, %d].\n", (int)pos.x, (int)pos.y)); 1543 1541 1544 m_Pos = pos; 1542 1545 … … 1715 1718 { 1716 1719 COCOA_LOG_FLOW(("%s: self=%p\n", __PRETTY_FUNCTION__, (void *)self)); 1720 [self vboxReshapePerform]; 1717 1721 [self createDockTile]; 1718 1722 COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__)); 1719 1723 } 1720 1724 1725 - (NSRect)safeConvertToScreen:(NSRect *)pRect 1726 { 1727 NSRect resultingRect = NSZeroRect; 1728 1729 NSWindow *pWindow = [m_pParentView window]; 1730 if (pWindow) 1731 { 1732 if ([pWindow respondsToSelector:@selector(convertRectToScreen:)]) 1733 { 1734 NSMethodSignature *pSignature = [pWindow methodSignatureForSelector:@selector(convertRectToScreen:)]; 1735 if (pSignature) 1736 { 1737 NSInvocation *pInvocation = [NSInvocation invocationWithMethodSignature:pSignature]; 1738 if (pInvocation) 1739 { 1740 [pInvocation setSelector:@selector(convertRectToScreen:)]; 1741 [pInvocation setTarget:pWindow]; 1742 [pInvocation setArgument:pRect atIndex:2]; 1743 [pInvocation invoke]; 1744 [pInvocation getReturnValue:&resultingRect]; 1745 1746 DEBUG_MSG(("safeConvertToScreen: convert [X, Y, WxH]: [%d, %d, %dx%d] -> [%d, %d, %dx%d]\n", 1747 (int)pRect ->origin.x, (int)pRect ->origin.y, (int)pRect ->size.width, (int)pRect ->size.width, 1748 (int)resultingRect.origin.x, (int)resultingRect.origin.y, (int)resultingRect.size.width, (int)resultingRect.size.width)); 1749 1750 return resultingRect; 1751 } 1752 } 1753 } 1754 1755 /* If we failed, let's use deprecated @selector(convertBaseToScreen:). It is a bit hacky, 1756 * but what to do if we stick to SDK 10.6. */ 1757 resultingRect.origin = [[m_pParentView window] convertBaseToScreen:pRect->origin]; 1758 resultingRect.size = pRect->size; 1759 } 1760 else 1761 /* Should never happen. */ 1762 DEBUG_WARN(("safeConvertToScreen: parent widget has no window.\n")); 1763 1764 DEBUG_MSG(("safeConvertToScreen (deprecated method): convert [X, Y, WxH]: [%d, %d, %dx%d] -> [%d, %d, %dx%d]\n", 1765 (int)pRect ->origin.x, (int)pRect ->origin.y, (int)pRect ->size.width, (int)pRect ->size.width, 1766 (int)resultingRect.origin.x, (int)resultingRect.origin.y, (int)resultingRect.size.width, (int)resultingRect.size.width)); 1767 1768 return resultingRect; 1769 } 1770 1721 1771 - (void)vboxReshapePerform 1722 1772 { 1723 1773 COCOA_LOG_FLOW(("%s: self=%p - m_DockTileView=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)m_DockTileView)); 1724 NSRect parentFrame = NSZeroRect; 1725 NSPoint parentPos = NSZeroPoint; 1726 NSPoint childPos = NSZeroPoint; 1727 NSRect childFrame = NSZeroRect; 1728 NSRect newFrame = NSZeroRect; 1729 1730 DEBUG_MSG(("vboxReshapePerform: m_Pos=[%d, %d], m_Size=[%dx%d]\n", (int)m_Pos.x, (int)m_Pos.y, (int)m_Size.width, (int)m_Size.height)); 1731 1732 parentFrame = [m_pParentView frame]; 1733 DEBUG_MSG(("vboxReshapePerform: FIXED parentFrame [%d:%d], [%d:%d]\n", (int)parentFrame.origin.x, (int)parentFrame.origin.y, (int)parentFrame.size.width, (int)parentFrame.size.height)); 1734 parentPos = parentFrame.origin; 1735 parentPos.y += parentFrame.size.height; 1736 DEBUG_MSG(("vboxReshapePerform: FIXED(view) parentPos [%d:%d]\n", (int)parentPos.x, (int)parentPos.y)); 1737 parentPos = [m_pParentView convertPoint:parentPos toView:nil]; 1738 DEBUG_MSG(("vboxReshapePerform: FIXED parentPos(win) [%d:%d]\n", (int)parentPos.x, (int)parentPos.y)); 1739 parentPos = [[m_pParentView window] convertBaseToScreen:parentPos]; 1740 DEBUG_MSG(("vboxReshapePerform: FIXED parentPos(screen) [%d:%d]\n", (int)parentPos.x, (int)parentPos.y)); 1741 parentFrame.origin = parentPos; 1742 1743 childPos = NSMakePoint(m_Pos.x, m_Pos.y + m_Size.height); 1744 DEBUG_MSG(("vboxReshapePerform: FIXED(view) childPos [%d:%d]\n", (int)childPos.x, (int)childPos.y)); 1745 childPos = [m_pParentView convertPoint:childPos toView:nil]; 1746 DEBUG_MSG(("vboxReshapePerform: FIXED(win) childPos [%d:%d]\n", (int)childPos.x, (int)childPos.y)); 1747 childPos = [[m_pParentView window] convertBaseToScreen:childPos]; 1748 DEBUG_MSG(("vboxReshapePerform: FIXED childPos(screen) [%d:%d]\n", (int)childPos.x, (int)childPos.y)); 1749 childFrame = NSMakeRect(childPos.x, childPos.y, m_Size.width, m_Size.height); 1750 DEBUG_MSG(("vboxReshapePerform: FIXED childFrame [%d:%d], [%d:%d]\n", (int)childFrame.origin.x, (int)childFrame.origin.y, (int)childFrame.size.width, (int)childFrame.size.height)); 1751 1752 /* We have to make sure that the overlay window will not be displayed out 1753 * of the parent window. So intersect both frames & use the result as the new 1754 * frame for the window. */ 1755 newFrame = NSIntersectionRect(parentFrame, childFrame); 1756 1757 DEBUG_MSG(("vboxReshapePerform: [%#p]: parentFrame pos[%d : %d] size[%d : %d]\n", 1758 (void *)self, (int)parentFrame.origin.x, (int)parentFrame.origin.y, (int)parentFrame.size.width, (int)parentFrame.size.height)); 1759 DEBUG_MSG(("vboxReshapePerform: [%#p]: childFrame pos[%d : %d] size[%d : %d]\n", 1760 (void *)self, (int)childFrame.origin.x, (int)childFrame.origin.y, (int)childFrame.size.width, (int)childFrame.size.height)); 1761 1762 DEBUG_MSG(("vboxReshapePerform: [%#p]: newFrame pos[%d : %d] size[%d : %d]\n", 1763 (void *)self, (int)newFrame.origin.x, (int)newFrame.origin.y, (int)newFrame.size.width, (int)newFrame.size.height)); 1764 1765 /* Later we have to correct the texture position in the case the window is 1774 1775 /* NOTE: Please consider the next naming convention for variables. 1776 * 1777 * Rectangle variables: 1778 * 1779 * <object to represent><coordinate system>: 1780 * <object to represent>: 1781 * parentFrame - a frame of the parent container (NSView) object 1782 * childFrame - a frame required to display guest content 1783 * windowFrame - resulting window frame constructed as an intersection of parentFrame and childFrame 1784 * <coordinate system>: 1785 * VCS - View Coordinate System 1786 * WCS - Window Coordinate System 1787 * SCS - Screen Coordinate System 1788 * 1789 * The same convention applied to offset variables naming as well which are of format: 1790 * 1791 * <object to represent><coordinate><coordinate system>. 1792 * 1793 * https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html 1794 */ 1795 1796 NSRect parentFrameVCS, parentFrameWCS, parentFrameSCS; 1797 NSRect childFrameWCS, childFrameSCS; 1798 NSRect windowFrameSCS; 1799 1800 CGFloat childFrameXWCS, childFrameYWCS; 1801 1802 /* We need to construct a new window frame (windowFrameSCS) for entire NSWindow object in 1803 * screen coordinates. In order to make 3D overlay window to do not overlap Cocoa and Qt GUI elements (titlebar, 1804 * Qt statusbar, scroll bars etc) let's do the next. Get parent view visible area (parentFrameSCS) in (NS)Screen 1805 * coordinates. Then get the area required to diaplay guest content (childFrameSCS) in (NS)Screen coordinates as well. 1806 * The intersection of these two areas in screen coordinates will be a new frame for entire NSWindow object. */ 1807 1808 parentFrameVCS = [m_pParentView frame]; 1809 parentFrameWCS = [m_pParentView convertRect:parentFrameVCS toView:nil]; 1810 parentFrameSCS = [self safeConvertToScreen:&parentFrameWCS]; 1811 1812 /* Choose childFrame origin in a bit special way. Its pop-left corner should stick to its parent top-left corner. */ 1813 childFrameXWCS = parentFrameWCS.origin.x + m_Pos.x; 1814 childFrameYWCS = parentFrameWCS.origin.y - m_Pos.y - (m_Size.height - parentFrameWCS.size.height); 1815 childFrameWCS = NSMakeRect(childFrameXWCS, childFrameYWCS, m_Size.width, m_Size.height); 1816 childFrameSCS = [self safeConvertToScreen:&childFrameWCS]; 1817 1818 windowFrameSCS = NSIntersectionRect(parentFrameSCS, childFrameSCS); 1819 1820 DEBUG_MSG(("vboxReshapePerform: a new overlay frame [%d, %d, %dx%d] has been constructed from intersection of window frame " 1821 "[%d, %d, %dx%d] and guest content rectangle [%d, %d, %dx%d]; m_Pos=[%d, %d], m_Size=%dx%d.\n", 1822 (int)windowFrameSCS .origin.x, (int)windowFrameSCS .origin.y, (int)windowFrameSCS .size.width, (int)windowFrameSCS .size.width, 1823 (int)parentFrameSCS.origin.x, (int)parentFrameSCS.origin.y, (int)parentFrameSCS.size.width, (int)parentFrameSCS.size.width, 1824 (int)childFrameSCS .origin.x, (int)childFrameSCS .origin.y, (int)childFrameSCS .size.width, (int)childFrameSCS .size.width, 1825 (int)m_Pos.x, (int)m_Pos.y, (int)m_Size.width, (int)m_Size.height)); 1826 1827 /* @todo galitsyn: drop this! 1828 * Later we have to correct the texture position in the case the window is 1766 1829 * out of the parents window frame. So save the shift values for later use. */ 1767 m_RootRect.origin.x = newFrame.origin.x - childFrame.origin.x;1768 m_RootRect.origin.y = childFrame .size.height + childFrame.origin.y - (newFrame.size.height + newFrame.origin.y);1769 m_RootRect.size = newFrame.size;1770 m_yInvRootOffset = newFrame.origin.y - childFrame.origin.y;1830 m_RootRect.origin.x = windowFrameSCS.origin.x - childFrameSCS.origin.x; 1831 m_RootRect.origin.y = childFrameSCS.size.height + childFrameSCS.origin.y - (windowFrameSCS.size.height + windowFrameSCS.origin.y); 1832 m_RootRect.size = windowFrameSCS.size; 1833 m_yInvRootOffset = windowFrameSCS.origin.y - childFrameSCS.origin.y; 1771 1834 1772 1835 DEBUG_MSG(("vboxReshapePerform: [%#p]: m_RootRect pos[%d : %d] size[%d : %d]\n", … … 1774 1837 1775 1838 /* Set the new frame. */ 1776 [[self window] setFrame: newFramedisplay:YES];1839 [[self window] setFrame:windowFrameSCS display:YES]; 1777 1840 1778 1841 /* Inform the dock tile view as well. */
Note:
See TracChangeset
for help on using the changeset viewer.