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.
This commit is contained in:
Vlad Zahorodnii 2021-12-09 14:52:37 +02:00
parent da53d26543
commit ab9bfb2993
2 changed files with 5 additions and 11 deletions

View file

@ -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);
}
);
}
);

View file

@ -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);
}