Initialize the first wl_surface in the constructor of QWaylandWindow

This makes it possible to get a pointer to a wl_surface immediately after
platform window creation.

Task-number: QTBUG-58423
Change-Id: I2e62380af8b34d05ae31baacc071766493633022
Reviewed-by: Marco Martin <notmart@gmail.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
This commit is contained in:
Johan Klokkhammer Helsing 2017-02-01 15:25:13 +01:00 committed by Johan Helsing
parent efce1fa6e4
commit b109d2e848
2 changed files with 8 additions and 1 deletions

View File

@ -95,6 +95,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
{ {
static WId id = 1; static WId id = 1;
mWindowId = id++; mWindowId = id++;
initializeWlSurface();
} }
QWaylandWindow::~QWaylandWindow() QWaylandWindow::~QWaylandWindow()
@ -127,7 +128,7 @@ void QWaylandWindow::initWindow()
return; return;
if (!isInitialized()) if (!isInitialized())
init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this))); initializeWlSurface();
if (shouldCreateSubSurface()) { if (shouldCreateSubSurface()) {
Q_ASSERT(!mSubSurfaceWindow); Q_ASSERT(!mSubSurfaceWindow);
@ -200,6 +201,11 @@ void QWaylandWindow::initWindow()
mFlags = window()->flags(); mFlags = window()->flags();
} }
void QWaylandWindow::initializeWlSurface()
{
init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this)));
}
bool QWaylandWindow::shouldCreateShellSurface() const bool QWaylandWindow::shouldCreateShellSurface() const
{ {
if (shouldCreateSubSurface()) if (shouldCreateSubSurface())

View File

@ -248,6 +248,7 @@ private:
bool setWindowStateInternal(Qt::WindowState flags); bool setWindowStateInternal(Qt::WindowState flags);
void setGeometry_helper(const QRect &rect); void setGeometry_helper(const QRect &rect);
void initWindow(); void initWindow();
void initializeWlSurface();
bool shouldCreateShellSurface() const; bool shouldCreateShellSurface() const;
bool shouldCreateSubSurface() const; bool shouldCreateSubSurface() const;
void reset(); void reset();