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:
parent
140579cb3e
commit
7b874b7fc4
@ -224,16 +224,13 @@ NSView *QCocoaWindow::contentView() const
|
|||||||
|
|
||||||
void QCocoaWindow::windowDidMove()
|
void QCocoaWindow::windowDidMove()
|
||||||
{
|
{
|
||||||
NSRect rect = [[m_nsWindow contentView]frame];
|
[m_contentView updateGeometry];
|
||||||
NSRect windowRect = [m_nsWindow frame];
|
|
||||||
[[m_nsWindow contentView] setFrameSize:rect.size];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCocoaWindow::windowDidResize()
|
void QCocoaWindow::windowDidResize()
|
||||||
{
|
{
|
||||||
NSRect rect = [[m_nsWindow contentView]frame];
|
NSRect rect = [[m_nsWindow contentView]frame];
|
||||||
NSRect windowRect = [m_nsWindow frame];
|
// Call setFrameSize which will trigger a frameDidChangeNotification on QNSView.
|
||||||
// Call setFrameSize which will trigger a frameDidChangeNotificatio on QNSView.
|
|
||||||
[[m_nsWindow contentView] setFrameSize:rect.size];
|
[[m_nsWindow contentView] setFrameSize:rect.size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ class QCocoaWindow;
|
|||||||
|
|
||||||
- (void)setImage:(QImage *)image;
|
- (void)setImage:(QImage *)image;
|
||||||
- (void)drawRect:(NSRect)dirtyRect;
|
- (void)drawRect:(NSRect)dirtyRect;
|
||||||
|
- (void)updateGeometry;
|
||||||
|
|
||||||
- (BOOL)isFlipped;
|
- (BOOL)isFlipped;
|
||||||
- (BOOL)acceptsFirstResponder;
|
- (BOOL)acceptsFirstResponder;
|
||||||
|
@ -111,19 +111,23 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
[self setPostsFrameChangedNotifications : YES];
|
[self setPostsFrameChangedNotifications : YES];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(frameDidChangeNotification:)
|
selector:@selector(updateGeometry)
|
||||||
name:NSViewFrameDidChangeNotification
|
name:NSViewFrameDidChangeNotification
|
||||||
object:self];
|
object:self];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) frameDidChangeNotification: (NSNotification *) notification
|
- (void)updateGeometry
|
||||||
{
|
{
|
||||||
NSRect rect = [self frame];
|
NSRect rect = [self frame];
|
||||||
NSRect windowRect = [[self window] 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);
|
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,
|
// Call setGeometry on QPlatformWindow. (not on QCocoaWindow,
|
||||||
// doing that will initiate a geometry change it and possibly create
|
// doing that will initiate a geometry change it and possibly create
|
||||||
// an infinite loop when this notification is triggered again.)
|
// an infinite loop when this notification is triggered again.)
|
||||||
|
Loading…
Reference in New Issue
Block a user