macOS: Remove machinery for attaching NSToolBar to QWindow
It was only used by QMacToolBar in QtMacExtras, which no longer exists in Qt 6. Attaching a toolbar can be done manually via the NSWindow of the NSView retrieved from winId(). There are no public uses of the native interface in GitHub outside of Qt. Improvements we want to make to toolbars in QtWidgets and QtQuick in the future, possibly backed by native toolbars, would be done behind the scenes and would not need this API. This effectively reverts e8fd6b9604bac334404dc52daa63b9e6d9cd71d8. Pick-to: 6.5 Change-Id: I33b090fa19f9f3af029ae8c269efcf739a4b1b22 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
2294e68559
commit
5d13e05651
|
|
@ -85,10 +85,6 @@ public:
|
|||
Qt::KeyboardModifiers queryKeyboardModifiers() const override;
|
||||
QList<int> possibleKeys(const QKeyEvent *event) const override;
|
||||
|
||||
void setToolbar(QWindow *window, NSToolbar *toolbar);
|
||||
NSToolbar *toolbar(QWindow *window) const;
|
||||
void clearToolbars();
|
||||
|
||||
void setApplicationIcon(const QIcon &icon) const override;
|
||||
void setApplicationBadge(qint64 number) override;
|
||||
|
||||
|
|
@ -120,7 +116,6 @@ private:
|
|||
#if QT_CONFIG(vulkan)
|
||||
mutable QCocoaVulkanInstance *mCocoaVulkanInstance = nullptr;
|
||||
#endif
|
||||
QHash<QWindow *, NSToolbar *> mToolbars;
|
||||
|
||||
QCocoaWindowManager m_windowManager;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -199,8 +199,6 @@ QCocoaIntegration::~QCocoaIntegration()
|
|||
#endif
|
||||
|
||||
QCocoaScreen::cleanupScreens();
|
||||
|
||||
clearToolbars();
|
||||
}
|
||||
|
||||
QCocoaIntegration *QCocoaIntegration::instance()
|
||||
|
|
@ -407,30 +405,6 @@ QList<int> QCocoaIntegration::possibleKeys(const QKeyEvent *event) const
|
|||
return mKeyboardMapper->possibleKeys(event);
|
||||
}
|
||||
|
||||
void QCocoaIntegration::setToolbar(QWindow *window, NSToolbar *toolbar)
|
||||
{
|
||||
if (NSToolbar *prevToolbar = mToolbars.value(window))
|
||||
[prevToolbar release];
|
||||
|
||||
[toolbar retain];
|
||||
mToolbars.insert(window, toolbar);
|
||||
}
|
||||
|
||||
NSToolbar *QCocoaIntegration::toolbar(QWindow *window) const
|
||||
{
|
||||
return mToolbars.value(window);
|
||||
}
|
||||
|
||||
void QCocoaIntegration::clearToolbars()
|
||||
{
|
||||
QHash<QWindow *, NSToolbar *>::const_iterator it = mToolbars.constBegin();
|
||||
while (it != mToolbars.constEnd()) {
|
||||
[it.value() release];
|
||||
++it;
|
||||
}
|
||||
mToolbars.clear();
|
||||
}
|
||||
|
||||
void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const
|
||||
{
|
||||
// Fall back to a size that looks good on the highest resolution screen available
|
||||
|
|
|
|||
|
|
@ -67,12 +67,6 @@ private:
|
|||
// Returns true if the given coordinate is inside the current
|
||||
// content border.
|
||||
static bool testContentBorderPosition(QWindow *window, int position);
|
||||
|
||||
// Sets a NSToolbar instance for the given QWindow. The
|
||||
// toolbar will be attached to the native NSWindow when
|
||||
// that is created;
|
||||
static void setNSToolbar(QWindow *window, void *nsToolbar);
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -71,8 +71,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
|
|||
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerContentBorderArea);
|
||||
if (resource.toLower() == "setcontentborderareaenabled")
|
||||
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setContentBorderAreaEnabled);
|
||||
if (resource.toLower() == "setnstoolbar")
|
||||
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setNSToolbar);
|
||||
if (resource.toLower() == "testcontentborderposition")
|
||||
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::testContentBorderPosition);
|
||||
|
||||
|
|
@ -171,15 +169,6 @@ void QCocoaNativeInterface::setContentBorderAreaEnabled(QWindow *window, quintpt
|
|||
cocoaWindow->setContentBorderAreaEnabled(identifier, enable);
|
||||
}
|
||||
|
||||
void QCocoaNativeInterface::setNSToolbar(QWindow *window, void *nsToolbar)
|
||||
{
|
||||
QCocoaIntegration::instance()->setToolbar(window, static_cast<NSToolbar *>(nsToolbar));
|
||||
|
||||
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
|
||||
if (cocoaWindow)
|
||||
cocoaWindow->updateNSToolbar();
|
||||
}
|
||||
|
||||
bool QCocoaNativeInterface::testContentBorderPosition(QWindow *window, int position)
|
||||
{
|
||||
if (!window)
|
||||
|
|
|
|||
|
|
@ -164,7 +164,6 @@ public:
|
|||
void setContentBorderEnabled(bool enable) override;
|
||||
bool testContentBorderAreaPosition(int position) const;
|
||||
void applyContentBorderThickness(NSWindow *window = nullptr);
|
||||
void updateNSToolbar();
|
||||
|
||||
qreal devicePixelRatio() const override;
|
||||
QWindow *childWindowAt(QPoint windowPoint);
|
||||
|
|
|
|||
|
|
@ -1535,11 +1535,6 @@ void QCocoaWindow::recreateWindowIfNeeded()
|
|||
setOpacity(opacity);
|
||||
|
||||
setMask(QHighDpi::toNativeLocalRegion(window()->mask(), window()));
|
||||
|
||||
// top-level QWindows may have an attached NSToolBar, call
|
||||
// update function which will attach to the NSWindow.
|
||||
if (!parentWindow && !isEmbeddedView)
|
||||
updateNSToolbar();
|
||||
}
|
||||
|
||||
void QCocoaWindow::requestUpdate()
|
||||
|
|
@ -1920,21 +1915,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window)
|
|||
[[[window contentView] superview] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
void QCocoaWindow::updateNSToolbar()
|
||||
{
|
||||
if (!isContentView())
|
||||
return;
|
||||
|
||||
NSToolbar *toolbar = QCocoaIntegration::instance()->toolbar(window());
|
||||
const NSWindow *window = m_view.window;
|
||||
|
||||
if (window.toolbar == toolbar)
|
||||
return;
|
||||
|
||||
window.toolbar = toolbar;
|
||||
window.showsToolbarButton = YES;
|
||||
}
|
||||
|
||||
bool QCocoaWindow::testContentBorderAreaPosition(int position) const
|
||||
{
|
||||
if (!m_drawContentBorderGradient || !isContentView())
|
||||
|
|
|
|||
Loading…
Reference in New Issue