diff --git a/CMakeLists.txt b/CMakeLists.txt index fc7dfd0241..c6d22d3a4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,6 +349,7 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1212) set(kwin_KDEINIT_SRCS workspace.cpp dbusinterface.cpp + abstract_client.cpp client.cpp client_machine.cpp cursor.cpp diff --git a/abstract_client.cpp b/abstract_client.cpp new file mode 100644 index 0000000000..c78223f716 --- /dev/null +++ b/abstract_client.cpp @@ -0,0 +1,41 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2015 Martin Gräßlin + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#include "abstract_client.h" + +namespace KWin +{ + +AbstractClient::AbstractClient() + : Toplevel() +{ +} + +AbstractClient::~AbstractClient() = default; + +void AbstractClient::updateMouseGrab() +{ +} + +bool AbstractClient::belongToSameApplication(const AbstractClient *c1, const AbstractClient *c2, bool active_hack) +{ + return c1->belongsToSameApplication(c2, active_hack); +} + +} diff --git a/abstract_client.h b/abstract_client.h new file mode 100644 index 0000000000..9369e08cee --- /dev/null +++ b/abstract_client.h @@ -0,0 +1,68 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2015 Martin Gräßlin + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#ifndef KWIN_ABSTRACT_CLIENT_H +#define KWIN_ABSTRACT_CLIENT_H + +#include "toplevel.h" + +namespace KWin +{ + +namespace TabBox +{ +class TabBoxClientImpl; +} + +class AbstractClient : public Toplevel +{ + Q_OBJECT +public: + virtual ~AbstractClient(); + + virtual QWeakPointer tabBoxClient() const = 0; + virtual void updateMouseGrab(); + virtual QString caption(bool full = true, bool stripped = false) const = 0; + virtual bool isMinimized() const = 0; + virtual bool isCloseable() const = 0; + virtual bool isFirstInTabBox() const = 0; + // TODO: remove boolean trap + virtual bool isShown(bool shaded_is_shown) const = 0; + virtual bool wantsTabFocus() const = 0; + virtual bool isFullScreen() const = 0; + virtual const QIcon &icon() const = 0; + + // TODO: remove boolean trap + static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, bool active_hack = false); + +public Q_SLOTS: + virtual void closeWindow() = 0; + +protected: + AbstractClient(); + // TODO: remove boolean trap + virtual bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const = 0; +}; + +} + +Q_DECLARE_METATYPE(KWin::AbstractClient*) +Q_DECLARE_METATYPE(QList) + +#endif diff --git a/client.cpp b/client.cpp index a6fbf3ea92..149ea12e1a 100644 --- a/client.cpp +++ b/client.cpp @@ -100,7 +100,7 @@ std::shared_ptr Client::s_defaultPalette; * is done in manage(). */ Client::Client() - : Toplevel() + : AbstractClient() , m_client() , m_wrapper() , m_frame() @@ -2441,6 +2441,15 @@ void Client::addDamage(const QRegion &damage) Toplevel::addDamage(damage); } +bool Client::belongsToSameApplication(const AbstractClient *other, bool active_hack) const +{ + const Client *c2 = dynamic_cast(other); + if (!c2) { + return false; + } + return Client::belongToSameApplication(this, c2, active_hack); +} + } // namespace #include "client.moc" diff --git a/client.h b/client.h index 40d503cfa9..323722192c 100644 --- a/client.h +++ b/client.h @@ -26,7 +26,7 @@ along with this program. If not, see . #include "options.h" #include "rules.h" #include "tabgroup.h" -#include "toplevel.h" +#include "abstract_client.h" #include "xcbutils.h" #include "decorations/decorationpalette.h" // Qt @@ -53,11 +53,6 @@ class Decoration; namespace KWin { -namespace TabBox -{ - -class TabBoxClientImpl; -} namespace Decoration { @@ -78,7 +73,7 @@ enum class Predicate { }; class Client - : public Toplevel + : public AbstractClient { Q_OBJECT /** @@ -354,7 +349,7 @@ public: QSize adjustedSize(const QSize&, Sizemode mode = SizemodeAny) const; QSize adjustedSize() const; - const QIcon &icon() const; + const QIcon &icon() const override; bool isActive() const; void setActive(bool); @@ -373,7 +368,7 @@ public: void blockActivityUpdates(bool b = true); /// Is not minimized and not hidden. I.e. normally visible on some virtual desktop. - bool isShown(bool shaded_is_shown) const; + bool isShown(bool shaded_is_shown) const override; bool isHiddenInternal() const; // For compositing bool isShade() const; // True only for ShadeNormal @@ -382,7 +377,7 @@ public: void setShade(ShadeMode mode); bool isShadeable() const; - bool isMinimized() const; + bool isMinimized() const override; bool isMaximizable() const; QRect geometryRestore() const; MaximizeMode maximizeMode() const; @@ -405,7 +400,7 @@ public: QRect iconGeometry() const; void setFullScreen(bool set, bool user = true); - bool isFullScreen() const; + bool isFullScreen() const override; bool isFullScreenable(bool fullscreen_hack = false) const; bool isActiveFullScreen() const; bool userCanSetFullScreen() const; @@ -444,13 +439,13 @@ public: bool isModal() const; // Auxiliary functions, depend on the windowType - bool wantsTabFocus() const; + bool wantsTabFocus() const override; bool wantsInput() const; bool isResizable() const; bool isMovable() const; bool isMovableAcrossScreens() const; - bool isCloseable() const; ///< May be closed by the user (May have a close button) + bool isCloseable() const override; ///< May be closed by the user (May have a close button) void takeFocus(); bool isDemandingAttention() const { @@ -515,10 +510,10 @@ public: void setBlockingCompositing(bool block); inline bool isBlockingCompositing() { return blocks_compositing; } - QString caption(bool full = true, bool stripped = false) const; + QString caption(bool full = true, bool stripped = false) const override; void keyPressEvent(uint key_code, xcb_timestamp_t time = XCB_TIME_CURRENT_TIME); // FRAME ?? - void updateMouseGrab(); + void updateMouseGrab() override; xcb_window_t moveResizeGrabWindow() const; const QPoint calculateGravitation(bool invert, int gravity = 0) const; // FRAME public? @@ -644,10 +639,10 @@ public: void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; - QWeakPointer tabBoxClient() const { + QWeakPointer tabBoxClient() const override { return m_tabBoxClient.toWeakRef(); } - bool isFirstInTabBox() const { + bool isFirstInTabBox() const override { return m_firstInTabBox; } void setFirstInTabBox(bool enable) { @@ -681,7 +676,7 @@ public: void showOnScreenEdge(); public Q_SLOTS: - void closeWindow(); + void closeWindow() override; void updateCaption(); private Q_SLOTS: @@ -723,6 +718,7 @@ protected: virtual void debug(QDebug& stream) const; virtual bool shouldUnredirect() const; void addDamage(const QRegion &damage) override; + bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const override; private Q_SLOTS: void delayedSetShortcut();