From 20add1c656c9e92bdfffe263cf3c2c847eab5c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 15 Jan 2012 11:03:15 +0100 Subject: [PATCH] Add property shaped for hasOwnShape method Inclusive notify signal. --- effects.cpp | 5 ----- effects.h | 1 - libkwineffects/kwineffects.cpp | 1 + libkwineffects/kwineffects.h | 2 +- toplevel.cpp | 4 ++++ toplevel.h | 10 ++++++++++ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/effects.cpp b/effects.cpp index 5ff27763a5..fa2652fab7 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1408,11 +1408,6 @@ QRegion EffectWindowImpl::shape() const return sw ? sw->shape() : geometry(); } -bool EffectWindowImpl::hasOwnShape() const -{ - return toplevel->shape(); -} - QRect EffectWindowImpl::decorationInnerRect() const { Client *client = dynamic_cast(toplevel); diff --git a/effects.h b/effects.h index bac6e408e8..f15cd16f26 100644 --- a/effects.h +++ b/effects.h @@ -244,7 +244,6 @@ public: virtual const EffectWindowGroup* group() const; virtual QRegion shape() const; - virtual bool hasOwnShape() const; virtual QRect decorationInnerRect() const; virtual QByteArray readProperty(long atom, long type, int format) const; virtual void deleteProperty(long atom) const; diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 412202a9bd..d21d74c612 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -325,6 +325,7 @@ WINDOW_HELPER(bool, isComboBox, "comboBox") WINDOW_HELPER(bool, isDNDIcon, "dndIcon") WINDOW_HELPER(bool, isManaged, "managed") WINDOW_HELPER(bool, isDeleted, "deleted") +WINDOW_HELPER(bool, hasOwnShape, "shaped") WINDOW_HELPER(QString, windowRole, "windowRole") QString EffectWindow::windowClass() const diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index b350494996..73af346354 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1127,7 +1127,7 @@ public: virtual QRegion shape() const = 0; int screen() const; /** @internal Do not use */ - virtual bool hasOwnShape() const = 0; // only for shadow effect, for now + bool hasOwnShape() const; // only for shadow effect, for now QPoint pos() const; QSize size() const; QRect rect() const; diff --git a/toplevel.cpp b/toplevel.cpp index 8535f12662..d9010160ca 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -104,7 +104,11 @@ QRect Toplevel::decorationRect() const void Toplevel::detectShape(Window id) { + const bool wasShape = is_shape; is_shape = Extensions::hasShape(id); + if (wasShape != is_shape) { + emit shapedChanged(); + } } // used only by Deleted::copy() diff --git a/toplevel.h b/toplevel.h index 183dee49c5..8edf7990fd 100644 --- a/toplevel.h +++ b/toplevel.h @@ -153,6 +153,10 @@ class Toplevel * Whether this Toplevel represents an already deleted window and only kept for the compositor for animations. **/ Q_PROPERTY(bool deleted READ isDeleted CONSTANT) + /** + * Whether the window has an own shape + **/ + Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged) public: Toplevel(Workspace *ws); Window frameId() const; @@ -278,6 +282,12 @@ signals: void geometryShapeChanged(KWin::Toplevel* toplevel, const QRect& old); void windowClosed(KWin::Toplevel* toplevel, KWin::Deleted* deleted); void windowShown(KWin::Toplevel* toplevel); + /** + * 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 + * decoration. + **/ + void shapedChanged(); protected: virtual ~Toplevel();