summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsview.mm
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-01-28 15:19:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-05 23:12:50 +0100
commitb1714aec5103ddd24e4f1cf14138746a3526ae95 (patch)
tree63307d9f9d54ee77d5b78fe98553f5155d5fe785 /src/plugins/platforms/cocoa/qnsview.mm
parent23401a1462ffd601172d17365ff07118f198c438 (diff)
Cocoa: Allow frameless NSWindow child QWindows
Showing, moving and resizing Contrarily to what an NSWindow does to its NSViews, child NSWindows need to be explicitly shown and hidden, and clipped if the parent NSWindow changes geometry. Also, hiding an NSWindow will not hide its child windows. This needed to be managed manually, adding 2 additional states to QCocoaWindow to reflect whether a child window has been clipped out by any ancestor geometry change, or hidden by any ancestor being hid. Also, ordering out an NSWindow will remove it fromm its parent's child windows array, making necessary to maintain a parallel list of child windows in QCocoaWindow. Stack order Although child NSWindows can be ordered relatively to each other, they need to be added again to be moved lower in the window stack. This also means the windows above it need to be added on top. Key (focus) status One of the remaining issues, is to make sure the top level window keeps the "key status" while still forwarding key events to the child window. Keeping same event propagation This use case is best illustrated with undocking QDockWidgets (if these are child NSWindows). The main issue is to make sure the QDockArea will get the mouse events right after undocking a dock widget. We used a similar workaround as the "key status" problem, and manually forward the mouse events to the dock area's QWindow. Manual test, by Morten Johan Sørvig, included. Task-number: QTBUG-33082 Task-number: QTBUG-22815 Change-Id: I50e34936fb82bff013e99f4bcb3bd0db0704c6ae Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 849a75f03c..7cd74c6725 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -227,7 +227,21 @@ static QTouchDevice *touchDevice = 0;
- (void)updateGeometry
{
QRect geometry;
- if (m_platformWindow->m_nsWindow) {
+
+ if (m_platformWindow->m_isNSWindowChild) {
+ return;
+#if 0
+ //geometry = qt_mac_toQRect([self frame]);
+ qDebug() << "nsview updateGeometry" << m_platformWindow->window();
+ QRect screenRect = qt_mac_toQRect([m_platformWindow->m_nsWindow convertRectToScreen:[self frame]]);
+ qDebug() << "screenRect" << screenRect;
+
+ screenRect.moveTop(qt_mac_flipYCoordinate(screenRect.y() + screenRect.height()));
+ geometry = QRect(m_platformWindow->window()->parent()->mapFromGlobal(screenRect.topLeft()), screenRect.size());
+ qDebug() << "geometry" << geometry;
+#endif
+ //geometry = QRect(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y + screenRect.size.height), screenRect.size.width, screenRect.size.height);
+ } else if (m_platformWindow->m_nsWindow) {
// top level window, get window rect and flip y.
NSRect rect = [self frame];
NSRect windowRect = [[self window] frame];
@@ -548,14 +562,20 @@ static QTouchDevice *touchDevice = 0;
QPointF qtWindowPoint;
QPointF qtScreenPoint;
- [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
+ QNSView *targetView = self;
+ if (m_platformWindow && m_platformWindow->m_forwardWindow
+ && (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp)) {
+ targetView = m_platformWindow->m_forwardWindow->m_qtView;
+ }
+
+ [targetView convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000;
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
nativeDrag->setLastMouseEvent(theEvent, self);
Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
- QWindowSystemInterface::handleMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers);
+ QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers);
}
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent