Client: Lazy load QWaylandCursor
If nothing is trying to access QWaylandScreen::cursor() leave the platform cursor uninitialized. This in turn avoids initializing cursor themes, which may use a significant amount of shared memory depending on the cursor size, number of screens and screen DPI. Task-number: QTBUG-67796 Change-Id: Ifd062cb52c4889adcaadeb00bea928b8e84a2182 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
c683571411
commit
ae58414530
@ -238,7 +238,6 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
||||
mScreens.append(screen);
|
||||
// We need to get the output events before creating surfaces
|
||||
forceRoundTrip();
|
||||
screen->init();
|
||||
mWaylandIntegration->screenAdded(screen);
|
||||
} else if (interface == QStringLiteral("wl_compositor")) {
|
||||
mCompositorVersion = qMin((int)version, 3);
|
||||
|
@ -60,20 +60,6 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
|
||||
{
|
||||
}
|
||||
|
||||
QWaylandScreen::~QWaylandScreen()
|
||||
{
|
||||
#if QT_CONFIG(cursor)
|
||||
delete mWaylandCursor;
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWaylandScreen::init()
|
||||
{
|
||||
#if QT_CONFIG(cursor)
|
||||
mWaylandCursor = new QWaylandCursor(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
QWaylandDisplay * QWaylandScreen::display() const
|
||||
{
|
||||
return mWaylandDisplay;
|
||||
@ -165,11 +151,20 @@ qreal QWaylandScreen::refreshRate() const
|
||||
}
|
||||
|
||||
#if QT_CONFIG(cursor)
|
||||
|
||||
QPlatformCursor *QWaylandScreen::cursor() const
|
||||
{
|
||||
return mWaylandCursor;
|
||||
return const_cast<QWaylandScreen *>(this)->waylandCursor();
|
||||
}
|
||||
#endif
|
||||
|
||||
QWaylandCursor *QWaylandScreen::waylandCursor()
|
||||
{
|
||||
if (!mWaylandCursor)
|
||||
mWaylandCursor.reset(new QWaylandCursor(this));
|
||||
return mWaylandCursor.data();
|
||||
}
|
||||
|
||||
#endif // QT_CONFIG(cursor)
|
||||
|
||||
QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
|
||||
{
|
||||
|
@ -67,9 +67,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland
|
||||
{
|
||||
public:
|
||||
QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id);
|
||||
~QWaylandScreen() override;
|
||||
|
||||
void init();
|
||||
QWaylandDisplay *display() const;
|
||||
|
||||
QString manufacturer() const override;
|
||||
@ -95,7 +93,7 @@ public:
|
||||
|
||||
#if QT_CONFIG(cursor)
|
||||
QPlatformCursor *cursor() const override;
|
||||
QWaylandCursor *waylandCursor() const { return mWaylandCursor; }
|
||||
QWaylandCursor *waylandCursor();
|
||||
#endif
|
||||
|
||||
uint32_t outputId() const { return m_outputId; }
|
||||
@ -130,7 +128,7 @@ private:
|
||||
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
|
||||
|
||||
#if QT_CONFIG(cursor)
|
||||
QWaylandCursor *mWaylandCursor = nullptr;
|
||||
QScopedPointer<QWaylandCursor> mWaylandCursor;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user