Cocoa: Update geometry on window move.

Call [QNSView updateGeometry] directly. We can't
got through the frameDidChange notification since
we are not actually changing the QNSView frame.

Rename frameDidChangeNotification -> updateGeometry
sine it now handles updates from two different sources.

Change-Id: I848e558294093cd51d97778734b5cf872435266a
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Morten Johan Sorvig 2011-12-14 12:05:56 +01:00 committed by Qt by Nokia
parent 140579cb3e
commit 7b874b7fc4
3 changed files with 9 additions and 7 deletions

View File

@ -224,16 +224,13 @@ NSView *QCocoaWindow::contentView() const
void QCocoaWindow::windowDidMove()
{
NSRect rect = [[m_nsWindow contentView]frame];
NSRect windowRect = [m_nsWindow frame];
[[m_nsWindow contentView] setFrameSize:rect.size];
[m_contentView updateGeometry];
}
void QCocoaWindow::windowDidResize()
{
NSRect rect = [[m_nsWindow contentView]frame];
NSRect windowRect = [m_nsWindow frame];
// Call setFrameSize which will trigger a frameDidChangeNotificatio on QNSView.
// Call setFrameSize which will trigger a frameDidChangeNotification on QNSView.
[[m_nsWindow contentView] setFrameSize:rect.size];
}

View File

@ -61,6 +61,7 @@ class QCocoaWindow;
- (void)setImage:(QImage *)image;
- (void)drawRect:(NSRect)dirtyRect;
- (void)updateGeometry;
- (BOOL)isFlipped;
- (BOOL)acceptsFirstResponder;

View File

@ -111,19 +111,23 @@ static QTouchDevice *touchDevice = 0;
[self setPostsFrameChangedNotifications : YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameDidChangeNotification:)
selector:@selector(updateGeometry)
name:NSViewFrameDidChangeNotification
object:self];
return self;
}
- (void) frameDidChangeNotification: (NSNotification *) notification
- (void)updateGeometry
{
NSRect rect = [self frame];
NSRect windowRect = [[self window] frame];
QRect geo(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QNSView::udpateGeometry" << geo;
#endif
// Call setGeometry on QPlatformWindow. (not on QCocoaWindow,
// doing that will initiate a geometry change it and possibly create
// an infinite loop when this notification is triggered again.)