Split up fullscreen able check into AbstractClient subclasses

Summary:
Most parts of this function are only relevant for X clients, in particular
the "fullscreen hack". Therefore split up the function into the AbstractClient
subclasses.

Test Plan: Manually and autotests still pass.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: graesslin, zzag, kwin

Tags: #kwin

Maniphest Tasks: T11098

Differential Revision: https://phabricator.kde.org/D18128
icc-effect-5.17.5
Roman Gilg 2019-01-09 15:20:19 +01:00
parent f2bbb60419
commit 787c22ec4c
6 changed files with 37 additions and 22 deletions

View File

@ -425,8 +425,7 @@ public:
virtual bool isHiddenInternal() const = 0;
// TODO: remove boolean trap
virtual void hideClient(bool hide) = 0;
bool isFullScreenable() const;
bool isFullScreenable(bool fullscreen_hack) const;
virtual bool isFullScreenable() const = 0;
virtual bool isFullScreen() const = 0;
// TODO: remove boolean trap
virtual AbstractClient *findModal(bool allow_itself = false) = 0;

View File

@ -595,6 +595,30 @@ bool Client::userNoBorder() const
return noborder;
}
bool Client::isFullScreenable() const
{
return isFullScreenable(false);
}
bool Client::isFullScreenable(bool fullscreenHack) const
{
if (!rules()->checkFullScreen(true)) {
return false;
}
if (fullscreenHack) {
return isNormalWindow();
}
if (rules()->checkStrictGeometry(true)) {
// check geometry constraints (rule to obey is set)
const QRect fsarea = workspace()->clientArea(FullScreenArea, this);
if (sizeForClientSize(fsarea.size(), SizemodeAny, true) != fsarea.size()) {
return false; // the app wouldn't fit exactly fullscreen geometry due to its strict geometry requirements
}
}
// don't check size constrains - some apps request fullscreen despite requesting fixed size
return !isSpecialWindow(); // also better disallow only weird types to go fullscreen
}
bool Client::noBorder() const
{
return userNoBorder() || isFullScreen();

View File

@ -143,6 +143,7 @@ public:
bool isMinimizable() const override;
QRect iconGeometry() const override;
bool isFullScreenable() const override;
void setFullScreen(bool set, bool user = true) override;
bool isFullScreen() const override;
bool userCanSetFullScreen() const override;
@ -347,6 +348,8 @@ private:
Client* findAutogroupCandidate() const;
bool isFullScreenable(bool fullscreenHack) const;
protected:
virtual void debug(QDebug& stream) const;
void addDamage(const QRegion &damage) override;

View File

@ -2449,26 +2449,6 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
emit quickTileModeChanged();
}
bool AbstractClient::isFullScreenable() const
{
return isFullScreenable(false);
}
bool AbstractClient::isFullScreenable(bool fullscreen_hack) const
{
if (!rules()->checkFullScreen(true))
return false;
if (fullscreen_hack)
return isNormalWindow();
if (rules()->checkStrictGeometry(true)) { // allow rule to ignore geometry constraints
QRect fsarea = workspace()->clientArea(FullScreenArea, this);
if (sizeForClientSize(fsarea.size(), SizemodeAny, true) != fsarea.size())
return false; // the app wouldn't fit exactly fullscreen geometry due to its strict geometry requirements
}
// don't check size constrains - some apps request fullscreen despite requesting fixed size
return !isSpecialWindow(); // also better disallow only weird types to go fullscreen
}
bool Client::userCanSetFullScreen() const
{
if (fullscreen_mode == FullScreenHack)

View File

@ -931,6 +931,14 @@ bool ShellClient::noBorder() const
return true;
}
bool ShellClient::isFullScreenable() const
{
if (!rules()->checkFullScreen(true)) {
return false;
}
return !isSpecialWindow();
}
void ShellClient::setFullScreen(bool set, bool user)
{
if (!isFullScreen() && !set)

View File

@ -77,6 +77,7 @@ public:
void closeWindow() override;
AbstractClient *findModal(bool allow_itself = false) override;
bool isCloseable() const override;
bool isFullScreenable() const override;
bool isFullScreen() const override;
bool isMaximizable() const override;
bool isMinimizable() const override;