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
This commit is contained in:
Roman Gilg 2019-01-11 16:13:33 +01:00
parent d3253257f9
commit 75a1506869

View file

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