diff options
3 files changed, 53 insertions, 5 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp index c103dc03..342edfd1 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp @@ -1054,6 +1054,8 @@ uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size) * Convenience for sending a configure event with the fullscreen state set, and * maximized and resizing removed. The activated state is left in its current state. * + * \sa sendUnmaximized + * * \a size is the new size of the window. */ @@ -1061,6 +1063,8 @@ uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size) * Convenience for sending a configure event with the fullscreen state set, and * maximized and resizing removed. The activated state is left in its current state. * + * \sa sendUnmaximized + * * \a size is the new size of the window. */ uint QWaylandXdgToplevelV6::sendFullscreen(const QSize &size) diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp index 68230937..769b426c 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp @@ -66,6 +66,9 @@ XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem connect(m_toplevel, &QWaylandXdgToplevelV6::setMaximized, this, &XdgToplevelV6Integration::handleSetMaximized); connect(m_toplevel, &QWaylandXdgToplevelV6::unsetMaximized, this, &XdgToplevelV6Integration::handleUnsetMaximized); connect(m_toplevel, &QWaylandXdgToplevelV6::maximizedChanged, this, &XdgToplevelV6Integration::handleMaximizedChanged); + connect(m_toplevel, &QWaylandXdgToplevelV6::setFullscreen, this, &XdgToplevelV6Integration::handleSetFullscreen); + connect(m_toplevel, &QWaylandXdgToplevelV6::unsetFullscreen, this, &XdgToplevelV6Integration::handleUnsetFullscreen); + connect(m_toplevel, &QWaylandXdgToplevelV6::fullscreenChanged, this, &XdgToplevelV6Integration::handleFullscreenChanged); connect(m_toplevel, &QWaylandXdgToplevelV6::activatedChanged, this, &XdgToplevelV6Integration::handleActivatedChanged); connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){ handlePopupCreated(item, popup); @@ -135,8 +138,12 @@ void XdgToplevelV6Integration::handleSetMaximized() if (!m_item->view()->isPrimary()) return; - maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - maximizeState.initialPosition = m_item->moveItem()->position(); + QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states(); + + if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) { + windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); + windowedGeometry.initialPosition = m_item->moveItem()->position(); + } QWaylandOutput *output = m_item->view()->output(); m_toplevel->sendMaximized(output->availableGeometry().size() / output->scaleFactor()); @@ -147,7 +154,7 @@ void XdgToplevelV6Integration::handleUnsetMaximized() if (!m_item->view()->isPrimary()) return; - m_toplevel->sendUnmaximized(maximizeState.initialWindowSize); + m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize); } void XdgToplevelV6Integration::handleMaximizedChanged() @@ -156,7 +163,41 @@ void XdgToplevelV6Integration::handleMaximizedChanged() QWaylandOutput *output = m_item->view()->output(); m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); } else { - m_item->moveItem()->setPosition(maximizeState.initialPosition); + m_item->moveItem()->setPosition(windowedGeometry.initialPosition); + } +} + +void XdgToplevelV6Integration::handleSetFullscreen() +{ + if (!m_item->view()->isPrimary()) + return; + + QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states(); + + if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) { + windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); + windowedGeometry.initialPosition = m_item->moveItem()->position(); + } + + QWaylandOutput *output = m_item->view()->output(); + m_toplevel->sendFullscreen(output->geometry().size() / output->scaleFactor()); +} + +void XdgToplevelV6Integration::handleUnsetFullscreen() +{ + if (!m_item->view()->isPrimary()) + return; + + m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize); +} + +void XdgToplevelV6Integration::handleFullscreenChanged() +{ + if (m_toplevel->fullscreen()) { + QWaylandOutput *output = m_item->view()->output(); + m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft()); + } else { + m_item->moveItem()->setPosition(windowedGeometry.initialPosition); } } diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h index 4ccabfa9..afb4964b 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h @@ -72,6 +72,9 @@ private Q_SLOTS: void handleSetMaximized(); void handleUnsetMaximized(); void handleMaximizedChanged(); + void handleSetFullscreen(); + void handleUnsetFullscreen(); + void handleFullscreenChanged(); void handleActivatedChanged(); void handleSurfaceSizeChanged(); @@ -106,7 +109,7 @@ private: struct { QSize initialWindowSize; QPointF initialPosition; - } maximizeState; + } windowedGeometry; }; class XdgPopupV6Integration : public QWaylandQuickShellIntegration |