diff --git a/abstract_client.h b/abstract_client.h --- a/abstract_client.h +++ b/abstract_client.h @@ -333,11 +333,11 @@ **/ void setActive(bool); - bool keepAbove() const { + bool keepAbove() const override { return m_keepAbove; } void setKeepAbove(bool); - bool keepBelow() const { + bool keepBelow() const override { return m_keepBelow; } void setKeepBelow(bool); @@ -361,7 +361,7 @@ * @see captionNormal * @see captionSuffix **/ - QString caption() const; + QString caption() const override final; /** * @returns The caption as set by the AbstractClient without any suffix. * @see caption @@ -382,7 +382,6 @@ virtual void hideClient(bool hide) = 0; bool isFullScreenable() const; bool isFullScreenable(bool fullscreen_hack) const; - virtual bool isFullScreen() const = 0; // TODO: remove boolean trap virtual AbstractClient *findModal(bool allow_itself = false) = 0; virtual bool isTransient() const; @@ -432,7 +431,7 @@ */ void minimize(bool avoid_animation = false); void unminimize(bool avoid_animation = false); - bool isMinimized() const { + bool isMinimized() const override { return m_minimized; } virtual void setFullScreen(bool set, bool user = true) = 0; @@ -458,12 +457,7 @@ void setTabGroup(TabGroup* group); virtual void setClientShown(bool shown); Q_INVOKABLE bool untab(const QRect &toGeometry = QRect(), bool clientRemoved = false); - /* - * When a click is done in the decoration and it calls the group - * to change the visible client it starts to move-resize the new - * client, this function stops it. - */ - bool isCurrentTab() const; + bool isCurrentTab() const override; virtual QRect geometryRestore() const = 0; /** * The currently applied maximize mode @@ -628,8 +622,7 @@ virtual bool hasStrut() const; void setModal(bool modal); - bool isModal() const; - + bool isModal() const override; /** * Determines the mouse command for the given @p button in the current state. * @@ -763,7 +756,6 @@ void clientUnminimized(KWin::AbstractClient* client, bool animate); void paletteChanged(const QPalette &p); void colorSchemeChanged(); - void captionChanged(); void clientMaximizedStateChanged(KWin::AbstractClient*, MaximizeMode); void clientMaximizedStateChanged(KWin::AbstractClient* c, bool h, bool v); void transientChanged(); diff --git a/autotests/test_window_paint_data.cpp b/autotests/test_window_paint_data.cpp --- a/autotests/test_window_paint_data.cpp +++ b/autotests/test_window_paint_data.cpp @@ -28,28 +28,6 @@ using namespace KWin; -class MockEffectWindowHelper : public QObject -{ - Q_OBJECT - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) -public: - MockEffectWindowHelper(QObject *parent = nullptr); - double opacity() const { - return m_opacity; - } - void setOpacity(qreal opacity) { - m_opacity = opacity; - } -private: - qreal m_opacity; -}; - -MockEffectWindowHelper::MockEffectWindowHelper(QObject *parent) - : QObject(parent) - , m_opacity(1.0) -{ -} - class MockEffectWindow : public EffectWindow { Q_OBJECT @@ -72,6 +50,185 @@ virtual void setData(int role, const QVariant &data); virtual void referencePreviousWindowPixmap() {} virtual void unreferencePreviousWindowPixmap() {} + + bool isDeleted() const override { + return false; + }; + bool isMinimized() const override { + return false; + } + double opacity() const override { + return m_opacity; + } + void setOpacity(qreal opacity) { + m_opacity = opacity; + } + bool hasAlpha() const override { + return true; + } + QStringList activities() const override { + return QStringList(); + } + int desktop() const override { + return 0; + } + int x() const override { + return 0; + } + int y() const override { + return 0; + } + int width() const override { + return 100; + } + int height() const override { + return 100; + } + + QSize basicUnit() const override { + return QSize(); + } + QRect geometry() const override { + return QRect(); + } + + QRect expandedGeometry() const override { + return QRect(); + } + int screen() const override { + return 0; + }; + bool hasOwnShape() const override { + return false; + } + QPoint pos() const override { + return QPoint(); + } + QSize size() const override { + return QSize(100,100); + } + QRect rect() const override { + return QRect(0,0,100,100); + } + + bool isMovable() const override { + return true; + } + bool isMovableAcrossScreens() const override { + return true; + } + bool isUserMove() const override { + return false; + } + bool isUserResize() const override { + return false; + } + QRect iconGeometry() const override { + return QRect(); + } + + bool isDesktop() const override { + return false; + } + bool isDock() const override { + return false; + } + bool isToolbar() const override { + return false; + } + bool isMenu() const override { + return false; + } + bool isNormalWindow() const override { + return true; + } + bool isSpecialWindow() const override { + return false; + } + bool isDialog() const override { + return false; + } + bool isSplash() const override { + return false; + } + bool isUtility() const override { + return false; + } + bool isDropdownMenu() const override { + return false; + } + bool isPopupMenu() const override { + return false; + } + bool isTooltip() const override { + return false; + } + bool isNotification() const override { + return false; + } + bool isOnScreenDisplay() const override { + return false; + } + bool isComboBox() const override { + return false; + } + bool isDNDIcon() const override { + return false; + } + QRect contentsRect() const { + return QRect(); + } + bool decorationHasAlpha() const { + return false; + } + QString caption() const { + return QString(); + } + QIcon icon() const { + return QIcon(); + } + QString windowClass() const { + return QString(); + } + QString windowRole() const { + return QString(); + } + NET::WindowType windowType() const { + return NET::Normal; + } + bool acceptsFocus() const { + return true; + } + bool keepAbove() const { + return false; + } + bool keepBelow() const { + return false; + } + bool isModal() const { + return false; + } + bool isSkipSwitcher() const { + return false; + } + bool isCurrentTab() const { + return true; + } + bool skipsCloseAnimation() const { + return false; + } + KWayland::Server::SurfaceInterface *surface() const { + return nullptr; + } + bool isFullScreen() const { + return false; + } + bool isUnresponsive() const { + return false; + } + +private: + qreal m_opacity = 1.0; }; MockEffectWindow::MockEffectWindow(QObject *parent) @@ -173,9 +330,8 @@ void TestWindowPaintData::testCtor() { - MockEffectWindowHelper helper; - helper.setOpacity(0.5); - MockEffectWindow w(&helper); + MockEffectWindow w; + w.setOpacity(0.5); WindowPaintData data(&w); QCOMPARE(data.xScale(), 1.0); QCOMPARE(data.yScale(), 1.0); @@ -194,8 +350,7 @@ void TestWindowPaintData::testCopyCtor() { - MockEffectWindowHelper helper; - MockEffectWindow w(&helper); + MockEffectWindow w; WindowPaintData data(&w); WindowPaintData data2(data); // no value had been changed @@ -240,8 +395,7 @@ void TestWindowPaintData::testOperatorMultiplyAssign() { - MockEffectWindowHelper helper; - MockEffectWindow w(&helper); + MockEffectWindow w; WindowPaintData data(&w); // without anything set, it's 1.0 on all axis QCOMPARE(data.xScale(), 1.0); @@ -266,8 +420,7 @@ void TestWindowPaintData::testOperatorPlus() { - MockEffectWindowHelper helper; - MockEffectWindow w(&helper); + MockEffectWindow w; WindowPaintData data(&w); QCOMPARE(data.xTranslation(), 0.0); QCOMPARE(data.yTranslation(), 0.0); @@ -289,8 +442,7 @@ void TestWindowPaintData::testMultiplyBrightness() { - MockEffectWindowHelper helper; - MockEffectWindow w(&helper); + MockEffectWindow w; WindowPaintData data(&w); QCOMPARE(0.2, data.multiplyBrightness(0.2)); QCOMPARE(0.2, data.brightness()); @@ -303,8 +455,7 @@ void TestWindowPaintData::testMultiplyOpacity() { - MockEffectWindowHelper helper; - MockEffectWindow w(&helper); + MockEffectWindow w; WindowPaintData data(&w); QCOMPARE(0.2, data.multiplyOpacity(0.2)); QCOMPARE(0.2, data.opacity()); @@ -317,8 +468,7 @@ void TestWindowPaintData::testMultiplySaturation() { - MockEffectWindowHelper helper; - MockEffectWindow w(&helper); + MockEffectWindow w; WindowPaintData data(&w); QCOMPARE(0.2, data.multiplySaturation(0.2)); QCOMPARE(0.2, data.saturation()); diff --git a/deleted.h b/deleted.h --- a/deleted.h +++ b/deleted.h @@ -37,13 +37,6 @@ : public Toplevel { Q_OBJECT - Q_PROPERTY(bool minimized READ isMinimized) - Q_PROPERTY(bool modal READ isModal) - Q_PROPERTY(bool fullScreen READ isFullScreen CONSTANT) - Q_PROPERTY(bool isCurrentTab READ isCurrentTab) - Q_PROPERTY(bool keepAbove READ keepAbove CONSTANT) - Q_PROPERTY(bool keepBelow READ keepBelow CONSTANT) - Q_PROPERTY(QString caption READ caption CONSTANT) public: static Deleted* create(Toplevel* c); // used by effects to keep the window around for e.g. fadeout effects when it's destroyed @@ -68,10 +61,10 @@ virtual Layer layer() const { return m_layer; } - bool isMinimized() const { + bool isMinimized() const override { return m_minimized; } - bool isModal() const { + bool isModal() const override { return m_modal; } QList mainClients() const { @@ -88,20 +81,20 @@ return m_decorationRenderer; } - bool isFullScreen() const { + bool isFullScreen() const override { return m_fullscreen; } - bool isCurrentTab() const { + bool isCurrentTab() const override { return m_wasCurrentTab; } - bool keepAbove() const { + bool keepAbove() const override { return m_keepAbove; } - bool keepBelow() const { + bool keepBelow() const override { return m_keepBelow; } - QString caption() const { + QString caption() const override { return m_caption; } diff --git a/effects.h b/effects.h --- a/effects.h +++ b/effects.h @@ -355,18 +355,84 @@ Q_OBJECT public: explicit EffectWindowImpl(Toplevel *toplevel); - virtual ~EffectWindowImpl(); + virtual ~EffectWindowImpl() override; void enablePainting(int reason) override; void disablePainting(int reason) override; bool isPaintingEnabled() override; void refWindow() override; void unrefWindow() override; - const EffectWindowGroup* group() const override; + bool isDeleted() const override; + bool isMinimized() const override; + double opacity() const override; + bool hasAlpha() const override; + + QStringList activities() const override; + int desktop() const override; + int x() const override; + int y() const override; + int width() const override; + int height() const override; + + QSize basicUnit() const override; + QRect geometry() const override; + + QString caption() const override; + QRect expandedGeometry() const override; QRegion shape() const override; + int screen() const override; + bool hasOwnShape() const override; // only for shadow effect, for now + QPoint pos() const override; + QSize size() const override; + QRect rect() const override; + + bool isMovable() const override; + bool isMovableAcrossScreens() const override; + bool isUserMove() const override; + bool isUserResize() const override; + QRect iconGeometry() const override; + + bool isDesktop() const override; + bool isDock() const override; + bool isToolbar() const override; + bool isMenu() const override; + bool isNormalWindow() const override; + bool isSpecialWindow() const override; + bool isDialog() const override; + bool isSplash() const override; + bool isUtility() const override; + bool isDropdownMenu() const override; + bool isPopupMenu() const override; + bool isTooltip() const override; + bool isNotification() const override; + bool isOnScreenDisplay() const override; + bool isComboBox() const override; + bool isDNDIcon() const override; + bool skipsCloseAnimation() const override; + + bool acceptsFocus() const override; + bool keepAbove() const override; + bool keepBelow() const override; + bool isModal() const override; + + KWayland::Server::SurfaceInterface *surface() const override; + bool isFullScreen() const override; + bool isUnresponsive() const override; + + QRect contentsRect() const override; + bool decorationHasAlpha() const override; + QIcon icon() const override; + QString windowClass() const override; + NET::WindowType windowType() const override; + bool isSkipSwitcher() const override; + bool isCurrentTab() const override; + QString windowRole() const override; + + const EffectWindowGroup* group() const override; + QRect decorationInnerRect() const override; QByteArray readProperty(long atom, long type, int format) const override; void deleteProperty(long atom) const override; @@ -389,8 +455,8 @@ void elevate(bool elevate); - void setData(int role, const QVariant &data); - QVariant data(int role) const; + void setData(int role, const QVariant &data) override; + QVariant data(int role) const override; void registerThumbnail(AbstractThumbnailItem *item); QHash > const &thumbnails() const { @@ -435,16 +501,16 @@ void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override; Qt::Alignment alignment() const override; void setAlignment(Qt::Alignment alignment) override; - const QFont& font() const override; + const QFont font() const override; void setFont(const QFont& font) override; - const QRect& geometry() const override; + const QRect geometry() const override; void setGeometry(const QRect& geometry, bool force = false) override; - const QIcon& icon() const override; + const QIcon icon() const override; void setIcon(const QIcon& icon) override; - const QSize& iconSize() const override; + const QSize iconSize() const override; void setIconSize(const QSize& size) override; void setPosition(const QPoint& point) override; - const QString& text() const override; + const QString text() const override; void setText(const QString& text) override; EffectFrameStyle style() const override { return m_style; diff --git a/effects.cpp b/effects.cpp --- a/effects.cpp +++ b/effects.cpp @@ -1667,7 +1667,7 @@ { if (Client* c = dynamic_cast< Client* >(toplevel)) return c->group()->effectGroup(); - return NULL; // TODO + return nullptr; // TODO } void EffectWindowImpl::refWindow() @@ -1684,6 +1684,100 @@ abort(); // TODO } +#define WINDOW_HELPER( rettype, prototype, toplevelPrototype) \ + rettype EffectWindowImpl::prototype ( ) const \ + { \ + return toplevel->toplevelPrototype(); \ + } + +WINDOW_HELPER(double, opacity, opacity) +WINDOW_HELPER(bool, hasAlpha, hasAlpha) +WINDOW_HELPER(int, x, x) +WINDOW_HELPER(int, y, y) +WINDOW_HELPER(int, width, width) +WINDOW_HELPER(int, height, height) +WINDOW_HELPER(QPoint, pos, pos) +WINDOW_HELPER(QSize, size, size) +WINDOW_HELPER(int, screen, screen) +WINDOW_HELPER(QRect, geometry, geometry) +WINDOW_HELPER(QRect, expandedGeometry, visibleRect) +WINDOW_HELPER(QRect, rect, rect) +WINDOW_HELPER(int, desktop, desktop) +WINDOW_HELPER(bool, isDesktop, isDesktop) +WINDOW_HELPER(bool, isDock, isDock) +WINDOW_HELPER(bool, isToolbar, isToolbar) +WINDOW_HELPER(bool, isMenu, isMenu) +WINDOW_HELPER(bool, isNormalWindow, isNormalWindow) +WINDOW_HELPER(bool, isDialog, isDialog) +WINDOW_HELPER(bool, isSplash, isSplash) +WINDOW_HELPER(bool, isUtility, isUtility) +WINDOW_HELPER(bool, isDropdownMenu, isDropdownMenu) +WINDOW_HELPER(bool, isPopupMenu, isPopupMenu) +WINDOW_HELPER(bool, isTooltip, isTooltip) +WINDOW_HELPER(bool, isNotification, isNotification) +WINDOW_HELPER(bool, isOnScreenDisplay, isOnScreenDisplay) +WINDOW_HELPER(bool, isComboBox, isComboBox) +WINDOW_HELPER(bool, isDNDIcon, isDNDIcon) +WINDOW_HELPER(bool, isDeleted, isDeleted) +WINDOW_HELPER(bool, hasOwnShape, shape) +WINDOW_HELPER(QString, windowRole, windowRole) +WINDOW_HELPER(QStringList, activities, activities) +WINDOW_HELPER(bool, skipsCloseAnimation, skipsCloseAnimation) +WINDOW_HELPER(KWayland::Server::SurfaceInterface *, surface, surface) +WINDOW_HELPER(QString, caption, caption); +WINDOW_HELPER(bool, isMinimized, isMinimized) +WINDOW_HELPER(bool, keepAbove, keepAbove) +WINDOW_HELPER(bool, keepBelow, keepBelow) +WINDOW_HELPER(bool, isModal, isModal) +WINDOW_HELPER(bool, isFullScreen, isFullScreen) +WINDOW_HELPER(bool, isCurrentTab, isCurrentTab) + +//windowClass +QString EffectWindowImpl::windowClass() const +{ + return toplevel->resourceName() + QLatin1Char(' ') + toplevel->resourceClass(); +} + +QRect EffectWindowImpl::contentsRect() const +{ + return QRect(toplevel->clientPos(), toplevel->clientSize()); +} + +NET::WindowType EffectWindowImpl::windowType() const +{ + return toplevel->windowType(); +} + +#define WINDOW_HELPER_DEFAULT( rettype, prototype, propertyname, defaultValue ) \ + rettype EffectWindowImpl::prototype ( ) const \ + { \ + auto client = qobject_cast(toplevel); \ + if (!client) { \ + return defaultValue; \ + } \ + return client->propertyname(); \ + } + +WINDOW_HELPER_DEFAULT(bool, isMovable, isMovable, false) +WINDOW_HELPER_DEFAULT(bool, isMovableAcrossScreens, isMovableAcrossScreens, false) +WINDOW_HELPER_DEFAULT(bool, isUserMove, isMove, false) +WINDOW_HELPER_DEFAULT(bool, isUserResize, isResize, false) +WINDOW_HELPER_DEFAULT(QRect, iconGeometry, iconGeometry, QRect()) +WINDOW_HELPER_DEFAULT(bool, isSpecialWindow, isSpecialWindow, true) +WINDOW_HELPER_DEFAULT(bool, acceptsFocus, wantsInput, true) // We don't actually know... +WINDOW_HELPER_DEFAULT(QIcon, icon, icon, QIcon()) +WINDOW_HELPER_DEFAULT(bool, isSkipSwitcher, skipSwitcher, false) +WINDOW_HELPER_DEFAULT(bool, decorationHasAlpha, decorationHasAlpha, false) +WINDOW_HELPER_DEFAULT(bool, isUnresponsive, unresponsive, false) + +QSize EffectWindowImpl::basicUnit() const +{ + if (auto client = qobject_cast(toplevel)){ + return client->basicUnit(); + } + return QSize(1,1); +} + void EffectWindowImpl::setWindow(Toplevel* w) { toplevel = w; @@ -1893,7 +1987,7 @@ delete m_sceneFrame; } -const QFont& EffectFrameImpl::font() const +const QFont EffectFrameImpl::font() const { return m_font; } @@ -1919,7 +2013,7 @@ m_sceneFrame->free(); } -const QRect& EffectFrameImpl::geometry() const +const QRect EffectFrameImpl::geometry() const { return m_geometry; } @@ -1946,7 +2040,7 @@ free(); } -const QIcon& EffectFrameImpl::icon() const +const QIcon EffectFrameImpl::icon() const { return m_icon; } @@ -1963,7 +2057,7 @@ m_sceneFrame->freeIconFrame(); } -const QSize& EffectFrameImpl::iconSize() const +const QSize EffectFrameImpl::iconSize() const { return m_iconSize; } @@ -2039,7 +2133,7 @@ setGeometry(geometry); } -const QString& EffectFrameImpl::text() const +const QString EffectFrameImpl::text() const { return m_text; } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -2057,188 +2057,189 @@ virtual void refWindow() = 0; virtual void unrefWindow() = 0; - bool isDeleted() const; - bool isMinimized() const; - double opacity() const; - bool hasAlpha() const; + virtual bool isDeleted() const = 0; + + virtual bool isMinimized() const = 0; + virtual double opacity() const = 0; + virtual bool hasAlpha() const = 0; bool isOnCurrentActivity() const; Q_SCRIPTABLE bool isOnActivity(QString id) const; bool isOnAllActivities() const; - QStringList activities() const; + virtual QStringList activities() const = 0; Q_SCRIPTABLE bool isOnDesktop(int d) const; bool isOnCurrentDesktop() const; bool isOnAllDesktops() const; - int desktop() const; // prefer isOnXXX() + virtual int desktop() const = 0; // prefer isOnXXX() - int x() const; - int y() const; - int width() const; - int height() const; + virtual int x() const = 0; + virtual int y() const = 0; + virtual int width() const = 0; + virtual int height() const = 0; /** * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. */ - QSize basicUnit() const; - QRect geometry() const; + virtual QSize basicUnit() const = 0; + virtual QRect geometry() const = 0; /** * Geometry of the window including decoration and potentially shadows. * May be different from geometry() if the window has a shadow. * @since 4.9 */ - QRect expandedGeometry() const; + virtual QRect expandedGeometry() const = 0; virtual QRegion shape() const = 0; - int screen() const; + virtual int screen() const = 0; /** @internal Do not use */ - bool hasOwnShape() const; // only for shadow effect, for now - QPoint pos() const; - QSize size() const; - QRect rect() const; - bool isMovable() const; - bool isMovableAcrossScreens() const; - bool isUserMove() const; - bool isUserResize() const; - QRect iconGeometry() const; + virtual bool hasOwnShape() const = 0; // only for shadow effect, for now + virtual QPoint pos() const = 0; + virtual QSize size() const = 0; + virtual QRect rect() const = 0; + virtual bool isMovable() const = 0; + virtual bool isMovableAcrossScreens() const = 0; + virtual bool isUserMove() const = 0; + virtual bool isUserResize() const = 0; + virtual QRect iconGeometry() const = 0; /** * Geometry of the actual window contents inside the whole (including decorations) window. */ - QRect contentsRect() const; + virtual QRect contentsRect() const = 0; /** * Geometry of the transparent rect in the decoration. * May be different from contentsRect() if the decoration is extended into the client area. * @since 4.5 */ virtual QRect decorationInnerRect() const = 0; bool hasDecoration() const; - bool decorationHasAlpha() const; + virtual bool decorationHasAlpha() const = 0; virtual QByteArray readProperty(long atom, long type, int format) const = 0; virtual void deleteProperty(long atom) const = 0; - QString caption() const; - QIcon icon() const; - QString windowClass() const; - QString windowRole() const; + virtual QString caption() const = 0; + virtual QIcon icon() const = 0; + virtual QString windowClass() const = 0; + virtual QString windowRole() const = 0; virtual const EffectWindowGroup* group() const = 0; /** * Returns whether the window is a desktop background window (the one with wallpaper). * See _NET_WM_WINDOW_TYPE_DESKTOP at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isDesktop() const; + virtual bool isDesktop() const = 0; /** * Returns whether the window is a dock (i.e. a panel). * See _NET_WM_WINDOW_TYPE_DOCK at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isDock() const; + virtual bool isDock() const = 0; /** * Returns whether the window is a standalone (detached) toolbar window. * See _NET_WM_WINDOW_TYPE_TOOLBAR at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isToolbar() const; + virtual bool isToolbar() const = 0; /** * Returns whether the window is a torn-off menu. * See _NET_WM_WINDOW_TYPE_MENU at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isMenu() const; + virtual bool isMenu() const = 0; /** * Returns whether the window is a "normal" window, i.e. an application or any other window * for which none of the specialized window types fit. * See _NET_WM_WINDOW_TYPE_NORMAL at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient' + virtual bool isNormalWindow() const = 0; // normal as in 'NET::Normal or NET::Unknown non-transient' /** * Returns whether the window is any of special windows types (desktop, dock, splash, ...), * i.e. window types that usually don't have a window frame and the user does not use window * management (moving, raising,...) on them. */ - bool isSpecialWindow() const; + virtual bool isSpecialWindow() const = 0; /** * Returns whether the window is a dialog window. * See _NET_WM_WINDOW_TYPE_DIALOG at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isDialog() const; + virtual bool isDialog() const = 0; /** * Returns whether the window is a splashscreen. Note that many (especially older) applications * do not support marking their splash windows with this type. * See _NET_WM_WINDOW_TYPE_SPLASH at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isSplash() const; + virtual bool isSplash() const = 0; /** * Returns whether the window is a utility window, such as a tool window. * See _NET_WM_WINDOW_TYPE_UTILITY at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isUtility() const; + virtual bool isUtility() const = 0; /** * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open * from the applications menubar). * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isDropdownMenu() const; + virtual bool isDropdownMenu() const = 0; /** * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu). * See _NET_WM_WINDOW_TYPE_POPUP_MENU at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isPopupMenu() const; // a context popup, not dropdown, not torn-off + virtual bool isPopupMenu() const = 0; // a context popup, not dropdown, not torn-off /** * Returns whether the window is a tooltip. * See _NET_WM_WINDOW_TYPE_TOOLTIP at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isTooltip() const; + virtual bool isTooltip() const = 0; /** * Returns whether the window is a window with a notification. * See _NET_WM_WINDOW_TYPE_NOTIFICATION at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isNotification() const; + virtual bool isNotification() const = 0; /** * Returns whether the window is an on screen display window * using the non-standard _KDE_NET_WM_WINDOW_TYPE_ON_SCREEN_DISPLAY */ - bool isOnScreenDisplay() const; + virtual bool isOnScreenDisplay() const = 0; /** * Returns whether the window is a combobox popup. * See _NET_WM_WINDOW_TYPE_COMBO at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isComboBox() const; + virtual bool isComboBox() const = 0; /** * Returns whether the window is a Drag&Drop icon. * See _NET_WM_WINDOW_TYPE_DND at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - bool isDNDIcon() const; + virtual bool isDNDIcon() const = 0; /** * Returns the NETWM window type * See http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - NET::WindowType windowType() const; + virtual NET::WindowType windowType() const = 0; /** * Returns whether the window is managed by KWin (it has control over its placement and other * aspects, as opposed to override-redirect windows that are entirely handled by the application). */ bool isManaged() const; // whether it's managed or override-redirect /** * Returns whether or not the window can accept keyboard focus. */ - bool acceptsFocus() const; + virtual bool acceptsFocus() const = 0; /** * Returns whether or not the window is kept above all other windows. */ - bool keepAbove() const; + virtual bool keepAbove() const = 0; /** * Returns whether the window is kept below all other windows. */ - bool keepBelow() const; + virtual bool keepBelow() const = 0; - bool isModal() const; + virtual bool isModal() const = 0; Q_SCRIPTABLE virtual KWin::EffectWindow* findModal() = 0; Q_SCRIPTABLE virtual QList mainWindows() const = 0; /** * Returns whether the window should be excluded from window switching effects. * @since 4.5 */ - bool isSkipSwitcher() const; + virtual bool isSkipSwitcher() const = 0; /** * Returns the unmodified window quad list. Can also be used to force rebuilding. @@ -2250,7 +2251,7 @@ void unminimize(); Q_SCRIPTABLE void closeWindow() const; - bool isCurrentTab() const; + virtual bool isCurrentTab() const = 0; /** * @since 4.11 @@ -2260,22 +2261,22 @@ /** * @since 5.0 **/ - bool skipsCloseAnimation() const; + virtual bool skipsCloseAnimation() const = 0; /** * @since 5.5 */ - KWayland::Server::SurfaceInterface *surface() const; + virtual KWayland::Server::SurfaceInterface *surface() const = 0; /** * @since 5.6 **/ - bool isFullScreen() const; + virtual bool isFullScreen() const = 0; /** * @since 5.10 */ - bool isUnresponsive() const; + virtual bool isUnresponsive() const = 0; /** * @since 5.15 @@ -3277,19 +3278,19 @@ virtual void setAlignment(Qt::Alignment alignment) = 0; virtual Qt::Alignment alignment() const = 0; virtual void setGeometry(const QRect& geometry, bool force = false) = 0; - virtual const QRect& geometry() const = 0; + virtual const QRect geometry() const = 0; virtual void setText(const QString& text) = 0; - virtual const QString& text() const = 0; + virtual const QString text() const = 0; virtual void setFont(const QFont& font) = 0; - virtual const QFont& font() const = 0; + virtual const QFont font() const = 0; /** * Set the icon that will appear on the left-hand size of the frame. */ virtual void setIcon(const QIcon& icon) = 0; - virtual const QIcon& icon() const = 0; + virtual const QIcon icon() const = 0; virtual void setIconSize(const QSize& size) = 0; - virtual const QSize& iconSize() const = 0; + virtual const QSize iconSize() const = 0; /** * Sets the geometry of a selection. diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -808,107 +808,17 @@ { } -#define WINDOW_HELPER( rettype, prototype, propertyname ) \ - rettype EffectWindow::prototype ( ) const \ - { \ - return parent()->property( propertyname ).value< rettype >(); \ - } - -WINDOW_HELPER(double, opacity, "opacity") -WINDOW_HELPER(bool, hasAlpha, "alpha") -WINDOW_HELPER(int, x, "x") -WINDOW_HELPER(int, y, "y") -WINDOW_HELPER(int, width, "width") -WINDOW_HELPER(int, height, "height") -WINDOW_HELPER(QPoint, pos, "pos") -WINDOW_HELPER(QSize, size, "size") -WINDOW_HELPER(int, screen, "screen") -WINDOW_HELPER(QRect, geometry, "geometry") -WINDOW_HELPER(QRect, expandedGeometry, "visibleRect") -WINDOW_HELPER(QRect, rect, "rect") -WINDOW_HELPER(int, desktop, "desktop") -WINDOW_HELPER(bool, isDesktop, "desktopWindow") -WINDOW_HELPER(bool, isDock, "dock") -WINDOW_HELPER(bool, isToolbar, "toolbar") -WINDOW_HELPER(bool, isMenu, "menu") -WINDOW_HELPER(bool, isNormalWindow, "normalWindow") -WINDOW_HELPER(bool, isDialog, "dialog") -WINDOW_HELPER(bool, isSplash, "splash") -WINDOW_HELPER(bool, isUtility, "utility") -WINDOW_HELPER(bool, isDropdownMenu, "dropdownMenu") -WINDOW_HELPER(bool, isPopupMenu, "popupMenu") -WINDOW_HELPER(bool, isTooltip, "tooltip") -WINDOW_HELPER(bool, isNotification, "notification") -WINDOW_HELPER(bool, isOnScreenDisplay, "onScreenDisplay") -WINDOW_HELPER(bool, isComboBox, "comboBox") -WINDOW_HELPER(bool, isDNDIcon, "dndIcon") -WINDOW_HELPER(bool, isDeleted, "deleted") -WINDOW_HELPER(bool, hasOwnShape, "shaped") -WINDOW_HELPER(QString, windowRole, "windowRole") -WINDOW_HELPER(QStringList, activities, "activities") -WINDOW_HELPER(bool, skipsCloseAnimation, "skipsCloseAnimation") -WINDOW_HELPER(KWayland::Server::SurfaceInterface *, surface, "surface") - -QString EffectWindow::windowClass() const -{ - return parent()->property("resourceName").toString() + QLatin1Char(' ') + parent()->property("resourceClass").toString(); -} - -QRect EffectWindow::contentsRect() const -{ - return QRect(parent()->property("clientPos").toPoint(), parent()->property("clientSize").toSize()); -} - -NET::WindowType EffectWindow::windowType() const -{ - return static_cast(parent()->property("windowType").toInt()); -} - bool EffectWindow::isOnActivity(QString activity) const { - const QStringList activities = parent()->property("activities").toStringList(); - return activities.isEmpty() || activities.contains(activity); + const QStringList _activities = activities(); + return _activities.isEmpty() || _activities.contains(activity); } bool EffectWindow::isOnAllActivities() const { - return parent()->property("activities").toStringList().isEmpty(); + return activities().isEmpty(); } -#undef WINDOW_HELPER - -#define WINDOW_HELPER_DEFAULT( rettype, prototype, propertyname, defaultValue ) \ - rettype EffectWindow::prototype ( ) const \ - { \ - const QVariant variant = parent()->property( propertyname ); \ - if (!variant.isValid()) { \ - return defaultValue; \ - } \ - return variant.value< rettype >(); \ - } - -WINDOW_HELPER_DEFAULT(bool, isMinimized, "minimized", false) -WINDOW_HELPER_DEFAULT(bool, isMovable, "moveable", false) -WINDOW_HELPER_DEFAULT(bool, isMovableAcrossScreens, "moveableAcrossScreens", false) -WINDOW_HELPER_DEFAULT(QString, caption, "caption", QString()) -WINDOW_HELPER_DEFAULT(bool, keepAbove, "keepAbove", true) -WINDOW_HELPER_DEFAULT(bool, keepBelow, "keepBelow", false) -WINDOW_HELPER_DEFAULT(bool, isModal, "modal", false) -WINDOW_HELPER_DEFAULT(QSize, basicUnit, "basicUnit", QSize(1, 1)) -WINDOW_HELPER_DEFAULT(bool, isUserMove, "move", false) -WINDOW_HELPER_DEFAULT(bool, isUserResize, "resize", false) -WINDOW_HELPER_DEFAULT(QRect, iconGeometry, "iconGeometry", QRect()) -WINDOW_HELPER_DEFAULT(bool, isSpecialWindow, "specialWindow", true) -WINDOW_HELPER_DEFAULT(bool, acceptsFocus, "wantsInput", true) // We don't actually know... -WINDOW_HELPER_DEFAULT(QIcon, icon, "icon", QIcon()) -WINDOW_HELPER_DEFAULT(bool, isSkipSwitcher, "skipSwitcher", false) -WINDOW_HELPER_DEFAULT(bool, isCurrentTab, "isCurrentTab", true) -WINDOW_HELPER_DEFAULT(bool, decorationHasAlpha, "decorationHasAlpha", false) -WINDOW_HELPER_DEFAULT(bool, isFullScreen, "fullScreen", false) -WINDOW_HELPER_DEFAULT(bool, isUnresponsive, "unresponsive", false) - -#undef WINDOW_HELPER_DEFAULT - #define WINDOW_HELPER_SETTER( prototype, propertyname, args, value ) \ void EffectWindow::prototype ( args ) \ {\ diff --git a/toplevel.h b/toplevel.h --- a/toplevel.h +++ b/toplevel.h @@ -457,6 +457,26 @@ **/ virtual bool isPopupWindow() const; + /** + * @returns The caption consisting of @link{captionNormal} and @link{captionSuffix} + * @see captionNormal + * @see captionSuffix + **/ + virtual QString caption() const; + + virtual bool isMinimized() const; + virtual bool isModal() const; + virtual bool isFullScreen() const; + virtual bool keepAbove() const; + virtual bool keepBelow() const; + /* + * When a click is done in the decoration and it calls the group + * to change the visible client it starts to move-resize the new + * client, this function stops it. + */ + virtual bool isCurrentTab() const; + + Q_SIGNALS: void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); void damaged(KWin::Toplevel* toplevel, const QRect& damage); @@ -466,6 +486,7 @@ void windowClosed(KWin::Toplevel* toplevel, KWin::Deleted* deleted); void windowShown(KWin::Toplevel* toplevel); void windowHidden(KWin::Toplevel* toplevel); + void captionChanged(); /** * Signal emitted when the window's shape state changed. That is if it did not have a shape * and received one or if the shape was withdrawn. Think of Chromium enabling/disabling KWin's diff --git a/toplevel.cpp b/toplevel.cpp --- a/toplevel.cpp +++ b/toplevel.cpp @@ -553,5 +553,41 @@ return geometry(); } +QString Toplevel::caption() const +{ + return QString(); +} + +bool Toplevel::isMinimized() const +{ + return false; +} + +bool Toplevel::isModal() const +{ + return false; +} + +bool Toplevel::isCurrentTab() const +{ + return false; +} + +bool Toplevel::isFullScreen() const +{ + return false; +} + +bool Toplevel::keepAbove() const +{ + return false; +} + +bool Toplevel::keepBelow() const +{ + return false; +} + + } // namespace