From 75a1506869f2c731e943c57a1210520001ded8c7 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Fri, 11 Jan 2019 16:13:33 +0100 Subject: [PATCH] Rework Client fullscreen control Summary: After fixing superficial issues go and work over Client's fullscreen control. This way we: * check first for what the rule wants uis to do, * do only proceed if there is a change from/to fullscreen * remove code, that becomes unneeded by this. This goes with the assumption, that the current fullscreen state is always correctly stored in the m_fullscreenMode variable, but the previous code implicitly did the same at numerous occasions, just not in a consistent manner. Test Plan: Manually and auto tests still pass. Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: graesslin, zzag, kwin Tags: #kwin Maniphest Tasks: T11098 Differential Revision: https://phabricator.kde.org/D18185 --- geometry.cpp | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index 436db77573..3860274e4f 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2454,15 +2454,16 @@ bool Client::userCanSetFullScreen() const void Client::setFullScreen(bool set, bool user) { + set = rules()->checkFullScreen(set); + const bool wasFullscreen = isFullScreen(); - if (!wasFullscreen && !set) { + if (wasFullscreen == set) { return; } if (user && !userCanSetFullScreen()) { return; } - set = rules()->checkFullScreen(set && !isSpecialWindow()); setShade(ShadeNone); if (wasFullscreen) { @@ -2471,48 +2472,41 @@ void Client::setFullScreen(bool set, bool user) geom_fs_restore = geometry(); } - m_fullscreenMode = set ? FullScreenNormal : FullScreenNone; - if (wasFullscreen == isFullScreen()) { - return; - } if (set) { + m_fullscreenMode = FullScreenNormal; untab(); workspace()->raiseClient(this); + } else { + m_fullscreenMode = FullScreenNone; } StackingUpdatesBlocker blocker1(workspace()); GeometryUpdatesBlocker blocker2(this); - workspace()->updateClientLayer(this); // active fullscreens get different layer + + // active fullscreens get different layer + workspace()->updateClientLayer(this); info->setState(isFullScreen() ? NET::FullScreen : NET::States(0), NET::FullScreen); updateDecoration(false, false); - if (isFullScreen()) { + if (set) { if (info->fullscreenMonitors().isSet()) { setGeometry(fullscreenMonitorsArea(info->fullscreenMonitors())); } else { setGeometry(workspace()->clientArea(FullScreenArea, this)); } } else { - if (!geom_fs_restore.isNull()) { - const int currentScreen = screen(); - setGeometry(QRect(geom_fs_restore.topLeft(), adjustedSize(geom_fs_restore.size()))); - if(currentScreen != screen()) { - workspace()->sendClientToScreen( this, currentScreen ); - } - // TODO isShaded() ? - } else { - // does this ever happen? - setGeometry(workspace()->clientArea(MaximizeArea, this)); + Q_ASSERT(!geom_fs_restore.isNull()); + const int currentScreen = screen(); + setGeometry(QRect(geom_fs_restore.topLeft(), adjustedSize(geom_fs_restore.size()))); + if(currentScreen != screen()) { + workspace()->sendClientToScreen(this, currentScreen); } } updateWindowRules(Rules::Fullscreen | Rules::Position | Rules::Size); - - if (wasFullscreen != isFullScreen()) { - emit clientFullScreenSet(this, set, user); - emit fullScreenChanged(); - } + emit clientFullScreenSet(this, set, user); + emit fullScreenChanged(); }