Commit 1013ee1b authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Vlad Zahorodnii
Browse files

[wayland] Queue maximize and fullscreen requests if initial state isn't committed yet

In order to ensure that no configure events will be sent before the full
initial state is committed, we need to queue maximize and full screen
requests or else the client may receive an "unexpected" configure event
and we miss to call initialize().
parent 1b4c725d
......@@ -1188,27 +1188,43 @@ void XdgToplevelClient::handleStatesAcknowledged(const XdgToplevelInterface::Sta
void XdgToplevelClient::handleMaximizeRequested()
{
maximize(MaximizeFull);
scheduleConfigure();
if (m_isInitialized) {
maximize(MaximizeFull);
scheduleConfigure();
} else {
m_initialStates |= XdgToplevelInterface::State::Maximized;
}
}
void XdgToplevelClient::handleUnmaximizeRequested()
{
maximize(MaximizeRestore);
scheduleConfigure();
if (m_isInitialized) {
maximize(MaximizeRestore);
scheduleConfigure();
} else {
m_initialStates &= ~XdgToplevelInterface::State::Maximized;
}
}
void XdgToplevelClient::handleFullscreenRequested(OutputInterface *output)
{
Q_UNUSED(output)
setFullScreen(/* set */ true, /* user */ false);
scheduleConfigure();
if (m_isInitialized) {
setFullScreen(/* set */ true, /* user */ false);
scheduleConfigure();
} else {
m_initialStates |= XdgToplevelInterface::State::FullScreen;
}
}
void XdgToplevelClient::handleUnfullscreenRequested()
{
setFullScreen(/* set */ false, /* user */ false);
scheduleConfigure();
if (m_isInitialized) {
setFullScreen(/* set */ false, /* user */ false);
scheduleConfigure();
} else {
m_initialStates &= ~XdgToplevelInterface::State::FullScreen;
}
}
void XdgToplevelClient::handleMinimizeRequested()
......@@ -1291,6 +1307,23 @@ void XdgToplevelClient::sendPing(PingReason reason)
m_pings.insert(serial, reason);
}
MaximizeMode XdgToplevelClient::initialMaximizeMode() const
{
MaximizeMode maximizeMode = MaximizeRestore;
if (m_initialStates & XdgToplevelInterface::State::MaximizedHorizontal) {
maximizeMode = MaximizeMode(maximizeMode | MaximizeHorizontal);
}
if (m_initialStates & XdgToplevelInterface::State::MaximizedVertical) {
maximizeMode = MaximizeMode(maximizeMode | MaximizeVertical);
}
return maximizeMode;
}
bool XdgToplevelClient::initialFullScreenMode() const
{
return m_initialStates & XdgToplevelInterface::State::FullScreen;
}
void XdgToplevelClient::initialize()
{
blockGeometryUpdates(true);
......@@ -1305,7 +1338,8 @@ void XdgToplevelClient::initialize()
if (originalGeometry != ruledGeometry) {
setFrameGeometry(ruledGeometry);
}
maximize(rules()->checkMaximize(maximizeMode(), true));
maximize(rules()->checkMaximize(initialMaximizeMode(), true));
setFullScreen(rules()->checkFullScreen(initialFullScreenMode(), true), false);
setDesktop(rules()->checkDesktop(desktop(), true));
setDesktopFileName(rules()->checkDesktopFile(desktopFileName(), true).toUtf8());
if (rules()->checkMinimize(isMinimized(), true)) {
......@@ -1343,6 +1377,7 @@ void XdgToplevelClient::initialize()
blockGeometryUpdates(false);
scheduleConfigure();
updateColorScheme();
m_isInitialized = true;
}
void XdgToplevelClient::updateMaximizeMode(MaximizeMode maximizeMode)
......
......@@ -221,6 +221,8 @@ private:
void setupWindowManagementIntegration();
void setupPlasmaShellIntegration();
void sendPing(PingReason reason);
MaximizeMode initialMaximizeMode() const;
bool initialFullScreenMode() const;
QPointer<KWaylandServer::PlasmaShellSurfaceInterface> m_plasmaShellSurface;
QPointer<KWaylandServer::AppMenuInterface> m_appMenuInterface;
......@@ -230,12 +232,14 @@ private:
KWaylandServer::XdgToplevelInterface *m_shellSurface;
KWaylandServer::XdgToplevelInterface::States m_requestedStates;
KWaylandServer::XdgToplevelInterface::States m_acknowledgedStates;
KWaylandServer::XdgToplevelInterface::States m_initialStates;
QMap<quint32, PingReason> m_pings;
QRect m_fullScreenGeometryRestore;
NET::WindowType m_windowType = NET::Normal;
MaximizeMode m_maximizeMode = MaximizeRestore;
MaximizeMode m_requestedMaximizeMode = MaximizeRestore;
bool m_isFullScreen = false;
bool m_isInitialized = false;
bool m_userNoBorder = false;
bool m_isTransient = false;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment