diff --git a/src/surface/surfacewrapper.cpp b/src/surface/surfacewrapper.cpp index 5b77b72d6..a316085f0 100644 --- a/src/surface/surfacewrapper.cpp +++ b/src/surface/surfacewrapper.cpp @@ -22,9 +22,11 @@ #include #include #include +#include #include #include +#include #include #include @@ -297,6 +299,32 @@ void SurfaceWrapper::setup() m_surfaceItem->setShellSurface(m_shellSurface); if (!m_isProxy) { + if (auto toplevelItem = qobject_cast(m_surfaceItem)) { + connect(toplevelItem, &WXdgToplevelSurfaceItem::initialCommitReceived, this, [this] { + auto toplevel = qobject_cast(m_shellSurface); + auto handle = toplevel->handle()->handle(); + if (handle->requested.maximized) { + toplevel->handle()->set_maximized(true); + resize(maximizedGeometry().size()); + m_previousSurfaceState.setValueBypassingBindings(State::Maximized); + m_surfaceState.setValueBypassingBindings(State::Maximized); + setVisibleDecoration(false); + setNoCornerRadius(true); + + return; + } + if (handle->requested.fullscreen) { + toplevel->handle()->set_fullscreen(true); + resize(fullscreenGeometry().size()); + m_previousSurfaceState.setValueBypassingBindings(State::Fullscreen); + m_surfaceState.setValueBypassingBindings(State::Fullscreen); + setVisibleDecoration(false); + setNoCornerRadius(true); + return; + } + + }, Qt::SingleShotConnection); + } m_shellSurface->safeConnect(&WToplevelSurface::requestMinimize, this, [this]() { minimize(); }); @@ -1006,7 +1034,7 @@ void SurfaceWrapper::setSurfaceState(State newSurfaceState) targetGeometry = m_tilingGeometry; } - if (targetGeometry.isValid()) { + if (targetGeometry.isValid() && m_previousSurfaceState.value() != newSurfaceState) { startStateChangeAnimation(newSurfaceState, targetGeometry); } else { if (m_geometryAnimation) { @@ -1414,7 +1442,7 @@ void SurfaceWrapper::doSetSurfaceState(State newSurfaceState) void SurfaceWrapper::onAnimationReady() { - Q_ASSERT(m_pendingState != m_surfaceState); + // Q_ASSERT(m_pendingState != m_surfaceState); Q_ASSERT(m_pendingGeometry.isValid()); if (!resize(m_pendingGeometry.size(), true)) { @@ -1649,6 +1677,7 @@ void SurfaceWrapper::minimize(bool onAnimation) void SurfaceWrapper::restoreFromMinimized(bool onAnimation) { + qWarning() << "xyb---state" << m_surfaceState.value(); if (m_surfaceState != State::Minimized && m_hideByshowDesk) return; if (!m_hideByshowDesk) @@ -1670,6 +1699,8 @@ void SurfaceWrapper::maximize() void SurfaceWrapper::unmaximize() { + + qWarning() << "xyb---unmaximize state:" << m_surfaceState.value(); if (m_surfaceState != State::Maximized) return; diff --git a/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.cpp b/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.cpp index 65b6a448b..b055846a4 100644 --- a/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.cpp +++ b/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.cpp @@ -78,11 +78,10 @@ void WXdgToplevelSurfaceItem::onSurfaceCommit() auto xdg_surface = toplevelSurface()->handle()->handle()->base; if (xdg_surface->initial_commit) { - /* When an xdg_surface performs an initial commit, the compositor must - * reply with a configure so the client can map the surface. - * configures the xdg_toplevel with 0,0 size to let the client pick the - * dimensions itself. */ - toplevelSurface()->handle()->set_size(0, 0); + toplevelSurface()->handle()->set_size(0, 0); + if (!xdg_surface->surface->mapped) { + Q_EMIT initialCommitReceived(); + } } } diff --git a/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.h b/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.h index 3864802b5..053cb22c8 100644 --- a/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.h +++ b/waylib/src/server/qtquick/wxdgtoplevelsurfaceitem.h @@ -36,6 +36,7 @@ class WAYLIB_SERVER_EXPORT WXdgToplevelSurfaceItem : public WSurfaceItem Q_SIGNALS: void minimumSizeChanged(); void maximumSizeChanged(); + void initialCommitReceived(); private: Q_SLOT void onSurfaceCommit() override;