From 4ec24bc43faa853a5523d09952e3050df260fcb8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 4 Feb 2020 20:12:07 +0200 Subject: [PATCH] Make support for full screen mode optional Summary: In long term, we want to split XdgShellClient into several classes. One class for xdg-toplevel clients, and the other one for xdg-popup clients. xdg-popup clients are much simpler than xdg-toplevel clients, they can't be maximized or shown in full screen mode, they can't be interactively moved on the screen, and so on. In the end, we will have to plumb many pure virtual methods, which looks a bit ugly. This change makes support for full screen mode in AbstractClient optional so we don't have to add those no-op methods and keep code more or less "clean." Test Plan: Compiles. Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D27162 --- abstract_client.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++ abstract_client.h | 8 ++++---- internal_client.cpp | 21 --------------------- internal_client.h | 4 ---- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/abstract_client.cpp b/abstract_client.cpp index f125ec7262..c44f0b0deb 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -3116,4 +3116,50 @@ QSize AbstractClient::adjustedSize() const return sizeForClientSize(clientSize()); } +/** + * Returns @c true if the AbstractClient can be shown in full screen mode; otherwise @c false. + * + * Default implementation returns @c false. + */ +bool AbstractClient::isFullScreenable() const +{ + return false; +} + +/** + * Returns @c true if the AbstractClient is currently being shown in full screen mode; otherwise @c false. + * + * A client in full screen mode occupies the entire screen with no window frame around it. + * + * Default implementation returns @c false. + */ +bool AbstractClient::isFullScreen() const +{ + return false; +} + +/** + * Returns whether requests initiated by the user to enter or leave full screen mode are honored. + * + * Default implementation returns @c false. + */ +bool AbstractClient::userCanSetFullScreen() const +{ + return false; +} + +/** + * Asks the AbstractClient to enter or leave full screen mode. + * + * Default implementation does nothing. + * + * @param set @c true if the AbstractClient has to be shown in full screen mode, otherwise @c false + * @param user @c true if the request is initiated by the user, otherwise @c false + */ +void AbstractClient::setFullScreen(bool set, bool user) +{ + Q_UNUSED(set) + Q_UNUSED(user) +} + } diff --git a/abstract_client.h b/abstract_client.h index 8bdfe35e03..ee32246f65 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -416,8 +416,8 @@ public: virtual bool isHiddenInternal() const = 0; // TODO: remove boolean trap virtual void hideClient(bool hide) = 0; - virtual bool isFullScreenable() const = 0; - virtual bool isFullScreen() const = 0; + virtual bool isFullScreenable() const; + virtual bool isFullScreen() const; // TODO: remove boolean trap virtual AbstractClient *findModal(bool allow_itself = false) = 0; virtual bool isTransient() const; @@ -484,7 +484,7 @@ public: bool isMinimized() const { return m_minimized; } - virtual void setFullScreen(bool set, bool user = true) = 0; + virtual void setFullScreen(bool set, bool user = true); virtual void setClientShown(bool shown); @@ -546,7 +546,7 @@ public: virtual bool isMaximizable() const = 0; virtual bool isMinimizable() const = 0; virtual QRect iconGeometry() const; - virtual bool userCanSetFullScreen() const = 0; + virtual bool userCanSetFullScreen() const; virtual bool userCanSetNoBorder() const = 0; virtual void checkNoBorder(); virtual void setOnActivities(QStringList newActivitiesList); diff --git a/internal_client.cpp b/internal_client.cpp index 76b45f5730..06015c5f34 100644 --- a/internal_client.cpp +++ b/internal_client.cpp @@ -208,16 +208,6 @@ bool InternalClient::isCloseable() const return true; } -bool InternalClient::isFullScreenable() const -{ - return false; -} - -bool InternalClient::isFullScreen() const -{ - return false; -} - bool InternalClient::isMaximizable() const { return false; @@ -397,17 +387,6 @@ void InternalClient::takeFocus() { } -bool InternalClient::userCanSetFullScreen() const -{ - return false; -} - -void InternalClient::setFullScreen(bool set, bool user) -{ - Q_UNUSED(set) - Q_UNUSED(user) -} - void InternalClient::setNoBorder(bool set) { if (!userCanSetNoBorder()) { diff --git a/internal_client.h b/internal_client.h index 140e87d69f..57204a846b 100644 --- a/internal_client.h +++ b/internal_client.h @@ -53,8 +53,6 @@ public: QByteArray windowRole() const override; void closeWindow() override; bool isCloseable() const override; - bool isFullScreenable() const override; - bool isFullScreen() const override; bool isMaximizable() const override; bool isMinimizable() const override; bool isMovable() const override; @@ -82,8 +80,6 @@ public: AbstractClient *findModal(bool allow_itself = false) override; void setOnAllActivities(bool set) override; void takeFocus() override; - bool userCanSetFullScreen() const override; - void setFullScreen(bool set, bool user = true) override; void setNoBorder(bool set) override; void updateDecoration(bool check_workspace_pos, bool force = false) override; void updateColorScheme() override;