From ab9bfb299330ee4a1220a2b82c6df0d769030de3 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 9 Dec 2021 14:52:37 +0200 Subject: [PATCH] wayland: Port to ServerSideDecorationInterface::preferredMode() Currently, the wayland server updates the server side decoration mode, which is counter-intuitive, because it doesn't cache the last preferred mode. With ServerSideDecorationInterface::preferredMode(), it can be simpler. --- src/wayland_server.cpp | 6 ------ src/xdgshellclient.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index 6d9b40dc79..e3ed4601eb 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -487,12 +487,6 @@ bool WaylandServer::init(InitializationFlags flags) if (XdgToplevelClient *client = findXdgToplevelClient(decoration->surface())) { client->installServerDecoration(decoration); } - connect(decoration, &ServerSideDecorationInterface::modeRequested, this, - [decoration] (ServerSideDecorationManagerInterface::Mode mode) { - // always acknowledge the requested mode - decoration->setMode(mode); - } - ); } ); diff --git a/src/xdgshellclient.cpp b/src/xdgshellclient.cpp index 0dbc843a8a..31c980ad74 100644 --- a/src/xdgshellclient.cpp +++ b/src/xdgshellclient.cpp @@ -725,7 +725,7 @@ bool XdgToplevelClient::userCanSetFullScreen() const bool XdgToplevelClient::userCanSetNoBorder() const { if (m_serverDecoration) { - switch (m_serverDecoration->mode()) { + switch (m_serverDecoration->preferredMode()) { case ServerSideDecorationManagerInterface::Mode::Server: return !isFullScreen() && !isShade(); case ServerSideDecorationManagerInterface::Mode::Client: @@ -748,7 +748,7 @@ bool XdgToplevelClient::userCanSetNoBorder() const bool XdgToplevelClient::noBorder() const { if (m_serverDecoration) { - switch (m_serverDecoration->mode()) { + switch (m_serverDecoration->preferredMode()) { case ServerSideDecorationManagerInterface::Mode::Server: return m_userNoBorder || isRequestedFullScreen(); case ServerSideDecorationManagerInterface::Mode::Client: @@ -1465,9 +1465,9 @@ void XdgToplevelClient::installServerDecoration(ServerSideDecorationInterface *d updateDecoration(/* check_workspace_pos */ true); } }); - connect(m_serverDecoration, &ServerSideDecorationInterface::modeRequested, this, - [this] (ServerSideDecorationManagerInterface::Mode mode) { - const bool changed = mode != m_serverDecoration->mode(); + connect(m_serverDecoration, &ServerSideDecorationInterface::preferredModeChanged, this, + [this] () { + const bool changed = m_serverDecoration->preferredMode() != m_serverDecoration->mode(); if (changed && readyForPainting()) { updateDecoration(/* check_workspace_pos */ true); }