macOS: Remove workaround for default-sized NSViews
The workaround introduced in 38a55c7 to explicitly call viewDidChangeFrame() was not ideal for a multitude of reasons. Instead we can just initialize the NSView with a NSZeroRect frame, which will ensure that whatever geometry we set from the Qt side will result in geometry change and expose events. The only case where we will not receive an expose event is if the QWindow is requested to be 0x0 sized, but that wouldn't warrant an expose event anyways. Also, it's not possible to initialize a QWindow to 0x0 from the Qt side, as that will trigger QPlatformWindow::initialGeometry() to pick the default size (160x160 in the case of macOS). Task-number: QTBUG-58963 Change-Id: Ia84de7edcfdf26b90e4e93186fabe8b5c7382caa Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
dd38574160
commit
22a414ab3d
@ -1645,13 +1645,6 @@ void QCocoaWindow::recreateWindowIfNeeded()
|
||||
[m_nsWindow setContentView:m_view];
|
||||
[m_view release];
|
||||
[m_view setPostsFrameChangedNotifications:YES];
|
||||
// QTBUG-58963
|
||||
// viewDidChangeFrame() should be called for each window automatically at this point because it is
|
||||
// registered with Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification);
|
||||
// The corner case when it's not called and we need to make a manual geometry update is when window's
|
||||
// size is not specified explicitly but minimumSize is set and matches to the size NSView was created with.
|
||||
if (QSizeF::fromCGSize(m_view.frame.size) == [QNSView defaultViewSize])
|
||||
viewDidChangeFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
|
||||
QSet<quint32> m_acceptedKeyDowns;
|
||||
}
|
||||
|
||||
+ (QSizeF)defaultViewSize;
|
||||
- (id)init;
|
||||
- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow;
|
||||
#ifndef QT_NO_OPENGL
|
||||
|
@ -140,8 +140,7 @@ static bool _q_dontOverrideCtrlLMB = false;
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super initWithFrame : NSMakeRect(0, 0, [[self class] defaultViewSize].width(), [[self class] defaultViewSize].height())];
|
||||
if (self) {
|
||||
if (self = [super initWithFrame:NSZeroRect]) {
|
||||
m_backingStore = 0;
|
||||
m_maskImage = 0;
|
||||
m_shouldInvalidateWindowShadow = false;
|
||||
@ -189,11 +188,6 @@ static bool _q_dontOverrideCtrlLMB = false;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (QSizeF)defaultViewSize
|
||||
{
|
||||
return QSizeF(300.0, 300.0);
|
||||
}
|
||||
|
||||
- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow
|
||||
{
|
||||
self = [self init];
|
||||
|
Loading…
x
Reference in New Issue
Block a user