Turn isManaged and isDeleted into properties on Toplevel

Property invokes virtual methods returning false by default. Deleted
reimplements the isDeleted and returns true. Client returns true for
isClient. Method is not called isManaged as this is already used
inside Client.
This commit is contained in:
Martin Gräßlin 2012-01-15 10:51:09 +01:00
parent 18f64bd36d
commit bfdcbe60f5
10 changed files with 37 additions and 14 deletions

View file

@ -2405,6 +2405,11 @@ void Client::updateFirstInTabBox()
XFree(data);
}
bool Client::isClient() const
{
return true;
}
} // namespace
#include "client.moc"

View file

@ -579,6 +579,7 @@ public:
//sets whether the client should be treated as a SessionInteract window
void setSessionInteract(bool needed);
virtual bool isClient() const;
public slots:
void closeWindow();

View file

@ -161,6 +161,11 @@ QRect Deleted::transparentRect() const
return transparent_rect;
}
bool Deleted::isDeleted() const
{
return true;
}
} // namespace
#include "deleted.moc"

View file

@ -40,6 +40,7 @@ public:
virtual QPoint clientPos() const;
virtual QSize clientSize() const;
virtual QRect transparentRect() const;
virtual bool isDeleted() const;
const QPixmap *topDecoPixmap() const {
return &decorationPixmapTop;
}

View file

@ -1378,11 +1378,6 @@ const EffectWindowGroup* EffectWindowImpl::group() const
return NULL; // TODO
}
bool EffectWindowImpl::isDeleted() const
{
return (dynamic_cast<Deleted*>(toplevel) != 0);
}
void EffectWindowImpl::refWindow()
{
if (Deleted* d = dynamic_cast< Deleted* >(toplevel))
@ -1434,11 +1429,6 @@ void EffectWindowImpl::deleteProperty(long int atom) const
deleteWindowProperty(window()->window(), atom);
}
bool EffectWindowImpl::isManaged() const
{
return dynamic_cast< const Client* >(toplevel) != NULL;
}
EffectWindow* EffectWindowImpl::findModal()
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {

View file

@ -240,7 +240,6 @@ public:
virtual void refWindow();
virtual void unrefWindow();
virtual bool isDeleted() const;
virtual const EffectWindowGroup* group() const;
@ -250,7 +249,6 @@ public:
virtual QByteArray readProperty(long atom, long type, int format) const;
virtual void deleteProperty(long atom) const;
virtual bool isManaged() const; // managed or override-redirect
virtual EffectWindow* findModal();
virtual EffectWindowList mainWindows() const;

View file

@ -323,6 +323,8 @@ WINDOW_HELPER(bool, isTooltip, "tooltip")
WINDOW_HELPER(bool, isNotification, "notification")
WINDOW_HELPER(bool, isComboBox, "comboBox")
WINDOW_HELPER(bool, isDNDIcon, "dndIcon")
WINDOW_HELPER(bool, isManaged, "managed")
WINDOW_HELPER(bool, isDeleted, "deleted")
WINDOW_HELPER(QString, windowRole, "windowRole")
QString EffectWindow::windowClass() const

View file

@ -1099,7 +1099,7 @@ public:
virtual void refWindow() = 0;
virtual void unrefWindow() = 0;
virtual bool isDeleted() const = 0;
bool isDeleted() const;
bool isMinimized() const;
double opacity() const;
@ -1244,7 +1244,7 @@ public:
* 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).
*/
virtual bool isManaged() const = 0; // whether it's managed or override-redirect
bool isManaged() const; // whether it's managed or override-redirect
/**
* Returns whether or not the window can accept keyboard focus.
*/

View file

@ -446,6 +446,16 @@ void Toplevel::getWmOpaqueRegion()
opaque_region = new_opaque_region;
}
bool Toplevel::isClient() const
{
return false;
}
bool Toplevel::isDeleted() const
{
return false;
}
} // namespace
#include "toplevel.moc"

View file

@ -144,6 +144,15 @@ class Toplevel
*/
Q_PROPERTY(int windowType READ windowType)
Q_PROPERTY(QStringList activities READ activities)
/**
* Whether this Toplevel 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).
**/
Q_PROPERTY(bool managed READ isClient CONSTANT)
/**
* Whether this Toplevel represents an already deleted window and only kept for the compositor for animations.
**/
Q_PROPERTY(bool deleted READ isDeleted CONSTANT)
public:
Toplevel(Workspace *ws);
Window frameId() const;
@ -165,6 +174,8 @@ public:
virtual QRect decorationRect() const; // rect including the decoration shadows
virtual QRect transparentRect() const = 0;
virtual QRegion decorationPendingRegion() const; // decoration region that needs to be repainted
virtual bool isClient() const;
virtual bool isDeleted() const;
// prefer isXXX() instead
// 0 for supported types means default for managed/unmanaged types