From 1347610bb9357ced99cd871387cdafd1dcb387d4 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 9 Jan 2019 20:49:10 +0100 Subject: [PATCH] Rework ShellClient fullscreen control Summary: The ShellClient::setFullScreen method was a direct copy of the Client version. Straighten out the function logic now and align with modern coding style. In short we check: 1. what the manual override window rule wants, 2. if there is a change at all with this, 3. if such a change is possible. And do: 4. (un-)set the fullscreen, 5. emit the changed signal. Test Plan: Manually, autotests pass. Reviewers: #kwin Subscribers: zzag, kwin Tags: #kwin Maniphest Tasks: T11098 Differential Revision: https://phabricator.kde.org/D18132 --- shell_client.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/shell_client.cpp b/shell_client.cpp index e314f16160..68da207649 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -945,14 +945,20 @@ bool ShellClient::isFullScreenable() const void ShellClient::setFullScreen(bool set, bool user) { - if (!isFullScreen() && !set) + set = rules()->checkFullScreen(set); + + const bool wasFullscreen = isFullScreen(); + if (wasFullscreen == set) { return; - if (user && !userCanSetFullScreen()) + } + if (isSpecialWindow()) { return; - set = rules()->checkFullScreen(set && !isSpecialWindow()); - setShade(ShadeNone); - bool was_fs = isFullScreen(); - if (was_fs) { + } + if (user && !userCanSetFullScreen()) { + return; + } + + if (wasFullscreen) { workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event } else { // in shell surface, maximise mode and fullscreen are exclusive @@ -964,8 +970,7 @@ void ShellClient::setFullScreen(bool set, bool user) } } m_fullScreen = set; - if (was_fs == isFullScreen()) - return; + if (set) { untab(); workspace()->raiseClient(this); @@ -973,9 +978,11 @@ void ShellClient::setFullScreen(bool set, bool user) RequestGeometryBlocker requestBlocker(this); StackingUpdatesBlocker blocker1(workspace()); GeometryUpdatesBlocker blocker2(this); + workspace()->updateClientLayer(this); // active fullscreens get different layer updateDecoration(false, false); - if (isFullScreen()) { + + if (set) { setGeometry(workspace()->clientArea(FullScreenArea, this)); } else { if (m_geomFsRestore.isValid()) { @@ -989,11 +996,9 @@ void ShellClient::setFullScreen(bool set, bool user) setGeometry(QRect(workspace()->clientArea(PlacementArea, this).topLeft(), QSize(0, 0))); } } - updateWindowRules(Rules::Fullscreen|Rules::Position|Rules::Size); - if (was_fs != isFullScreen()) { - emit fullScreenChanged(); - } + updateWindowRules(Rules::Fullscreen|Rules::Position|Rules::Size); + emit fullScreenChanged(); } void ShellClient::setNoBorder(bool set)