[libkwineffects] Replace property name lookup with calling the virtual methods

Summary:
EffectWindow proxies its properties from the client/deleted's
properties.

QObject::property(char*) is a slow string search. It's a loop
of string comparisons not a hash lookup!

QML's use of properties is different, there's a property cache.

It's fetched multiple times for every window in every paint of some
effects (such as blur). Hotspot shows this as a significant amount of
the render pass (X11) with nothing in kwin animating.

This patch replaces the macro that does
parent()->property("propertyName")
with a macro calling the relevant function directly without metaobjects.

This also improves type safety for future changes.

Test Plan:
Existing unit tests
Ran it for a bit

Reviewers: #kwin, graesslin

Subscribers: graesslin, zzag, broulik, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16602
This commit is contained in:
David Edmundson 2018-11-30 09:58:45 +00:00
parent 4985cf2da9
commit 7834bec52a
7 changed files with 517 additions and 245 deletions

View file

@ -29,51 +29,217 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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
public:
MockEffectWindow(QObject *parent = nullptr);
virtual WindowQuadList buildQuads(bool force = false) const;
virtual QVariant data(int role) const;
virtual QRect decorationInnerRect() const;
virtual void deleteProperty(long int atom) const;
virtual void disablePainting(int reason);
virtual void enablePainting(int reason);
virtual EffectWindow *findModal();
virtual const EffectWindowGroup *group() const;
virtual bool isPaintingEnabled();
virtual EffectWindowList mainWindows() const;
virtual QByteArray readProperty(long int atom, long int type, int format) const;
virtual void refWindow();
virtual void unrefWindow();
virtual QRegion shape() const;
virtual void setData(int role, const QVariant &data);
virtual void referencePreviousWindowPixmap() {}
virtual void unreferencePreviousWindowPixmap() {}
QList<int> desktops() const { return {};}
WindowQuadList buildQuads(bool force = false) const override;
QVariant data(int role) const override;
QRect decorationInnerRect() const override;
void deleteProperty(long int atom) const override;
void disablePainting(int reason) override;
void enablePainting(int reason) override;
EffectWindow *findModal() override;
const EffectWindowGroup *group() const override;
bool isPaintingEnabled() override;
EffectWindowList mainWindows() const override;
QByteArray readProperty(long int atom, long int type, int format) const override;
void refWindow() override;
void unrefWindow() override;
QRegion shape() const override;
void setData(int role, const QVariant &data) override;
void referencePreviousWindowPixmap() override {}
void unreferencePreviousWindowPixmap() override {}
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;
}
QVector<uint> desktops() const override {
return {};
}
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 override {
return QRect();
}
bool decorationHasAlpha() const override {
return false;
}
QString caption() const override {
return QString();
}
QIcon icon() const override {
return QIcon();
}
QString windowClass() const override {
return QString();
}
QString windowRole() const override {
return QString();
}
NET::WindowType windowType() const override {
return NET::Normal;
}
bool acceptsFocus() const override {
return true;
}
bool keepAbove() const override {
return false;
}
bool keepBelow() const override {
return false;
}
bool isModal() const override {
return false;
}
bool isSkipSwitcher() const override {
return false;
}
bool isCurrentTab() const override {
return true;
}
bool skipsCloseAnimation() const override {
return false;
}
KWayland::Server::SurfaceInterface *surface() const override {
return nullptr;
}
bool isFullScreen() const override {
return false;
}
bool isUnresponsive() const override {
return false;
}
bool isPopupWindow() const override {
return false;
}
bool isManaged() const override {
return true;
}
bool isWaylandClient() const override {
return true;
}
bool isX11Client() const override {
return false;
}
private:
qreal m_opacity = 1.0;
};
MockEffectWindow::MockEffectWindow(QObject *parent)
@ -175,9 +341,8 @@ private Q_SLOTS:
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);
@ -196,8 +361,7 @@ void TestWindowPaintData::testCtor()
void TestWindowPaintData::testCopyCtor()
{
MockEffectWindowHelper helper;
MockEffectWindow w(&helper);
MockEffectWindow w;
WindowPaintData data(&w);
WindowPaintData data2(data);
// no value had been changed
@ -242,8 +406,7 @@ void TestWindowPaintData::testCopyCtor()
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);
@ -268,8 +431,7 @@ void TestWindowPaintData::testOperatorMultiplyAssign()
void TestWindowPaintData::testOperatorPlus()
{
MockEffectWindowHelper helper;
MockEffectWindow w(&helper);
MockEffectWindow w;
WindowPaintData data(&w);
QCOMPARE(data.xTranslation(), 0.0);
QCOMPARE(data.yTranslation(), 0.0);
@ -291,8 +453,7 @@ void TestWindowPaintData::testOperatorPlus()
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());
@ -305,8 +466,7 @@ void TestWindowPaintData::testMultiplyBrightness()
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());
@ -319,8 +479,7 @@ void TestWindowPaintData::testMultiplyOpacity()
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());

View file

@ -254,6 +254,20 @@ QByteArray Deleted::windowRole() const
return m_windowRole;
}
QVector<uint> Deleted::x11DesktopIds() const
{
const auto desks = desktops();
QVector<uint> x11Ids;
x11Ids.reserve(desks.count());
std::transform(desks.constBegin(), desks.constEnd(),
std::back_inserter(x11Ids),
[] (const VirtualDesktop *vd) {
return vd->x11DesktopNumber();
}
);
return x11Ids;
}
void Deleted::addTransient(Deleted *transient)
{
m_transients.append(transient);

View file

@ -181,6 +181,8 @@ public:
return m_wasPopupWindow;
}
QVector<uint> x11DesktopIds() const;
protected:
virtual void debug(QDebug& stream) const;
private Q_SLOTS:

View file

@ -1658,8 +1658,19 @@ KSharedConfigPtr EffectsHandlerImpl::inputConfig() const
EffectWindowImpl::EffectWindowImpl(Toplevel *toplevel)
: EffectWindow(toplevel)
, toplevel(toplevel)
, sw(NULL)
, sw(nullptr)
{
// Deleted windows are not managed. So, when windowClosed signal is
// emitted, effects can't distinguish managed windows from unmanaged
// windows(e.g. combo box popups, popup menus, etc). Save value of the
// managed property during construction of EffectWindow. At that time,
// parent can be Client, ShellClient, or Unmanaged. So, later on, when
// an instance of Deleted becomes parent of the EffectWindow, effects
// can still figure out whether it is/was a managed window.
managed = toplevel->isClient();
waylandClient = qobject_cast<KWin::ShellClient *>(toplevel) != nullptr;
x11Client = !waylandClient;
}
EffectWindowImpl::~EffectWindowImpl()
@ -1690,7 +1701,7 @@ const EffectWindowGroup* EffectWindowImpl::group() const
{
if (Client* c = dynamic_cast< Client* >(toplevel))
return c->group()->effectGroup();
return NULL; // TODO
return nullptr; // TODO
}
void EffectWindowImpl::refWindow()
@ -1707,6 +1718,122 @@ void EffectWindowImpl::unrefWindow()
abort(); // TODO
}
#define TOPLEVEL_HELPER( rettype, prototype, toplevelPrototype) \
rettype EffectWindowImpl::prototype ( ) const \
{ \
return toplevel->toplevelPrototype(); \
}
TOPLEVEL_HELPER(double, opacity, opacity)
TOPLEVEL_HELPER(bool, hasAlpha, hasAlpha)
TOPLEVEL_HELPER(int, x, x)
TOPLEVEL_HELPER(int, y, y)
TOPLEVEL_HELPER(int, width, width)
TOPLEVEL_HELPER(int, height, height)
TOPLEVEL_HELPER(QPoint, pos, pos)
TOPLEVEL_HELPER(QSize, size, size)
TOPLEVEL_HELPER(int, screen, screen)
TOPLEVEL_HELPER(QRect, geometry, geometry)
TOPLEVEL_HELPER(QRect, expandedGeometry, visibleRect)
TOPLEVEL_HELPER(QRect, rect, rect)
TOPLEVEL_HELPER(int, desktop, desktop)
TOPLEVEL_HELPER(bool, isDesktop, isDesktop)
TOPLEVEL_HELPER(bool, isDock, isDock)
TOPLEVEL_HELPER(bool, isToolbar, isToolbar)
TOPLEVEL_HELPER(bool, isMenu, isMenu)
TOPLEVEL_HELPER(bool, isNormalWindow, isNormalWindow)
TOPLEVEL_HELPER(bool, isDialog, isDialog)
TOPLEVEL_HELPER(bool, isSplash, isSplash)
TOPLEVEL_HELPER(bool, isUtility, isUtility)
TOPLEVEL_HELPER(bool, isDropdownMenu, isDropdownMenu)
TOPLEVEL_HELPER(bool, isPopupMenu, isPopupMenu)
TOPLEVEL_HELPER(bool, isTooltip, isTooltip)
TOPLEVEL_HELPER(bool, isNotification, isNotification)
TOPLEVEL_HELPER(bool, isOnScreenDisplay, isOnScreenDisplay)
TOPLEVEL_HELPER(bool, isComboBox, isComboBox)
TOPLEVEL_HELPER(bool, isDNDIcon, isDNDIcon)
TOPLEVEL_HELPER(bool, isDeleted, isDeleted)
TOPLEVEL_HELPER(bool, hasOwnShape, shape)
TOPLEVEL_HELPER(QString, windowRole, windowRole)
TOPLEVEL_HELPER(QStringList, activities, activities)
TOPLEVEL_HELPER(bool, skipsCloseAnimation, skipsCloseAnimation)
TOPLEVEL_HELPER(KWayland::Server::SurfaceInterface *, surface, surface)
TOPLEVEL_HELPER(bool, isPopupWindow, isPopupWindow)
#undef TOPLEVEL_HELPER
#define CLIENT_HELPER_WITH_DELETED( rettype, prototype, propertyname, defaultValue ) \
rettype EffectWindowImpl::prototype ( ) const \
{ \
auto client = qobject_cast<AbstractClient *>(toplevel); \
if (client) { \
return client->propertyname(); \
} \
auto deleted = qobject_cast<Deleted *>(toplevel); \
if (deleted) { \
return deleted->propertyname(); \
} \
return defaultValue; \
}
CLIENT_HELPER_WITH_DELETED(bool, isMinimized, isMinimized, false)
CLIENT_HELPER_WITH_DELETED(bool, isModal, isModal, false)
CLIENT_HELPER_WITH_DELETED(bool, isFullScreen, isFullScreen, false)
CLIENT_HELPER_WITH_DELETED(bool, isCurrentTab, isCurrentTab, false)
CLIENT_HELPER_WITH_DELETED(bool, keepAbove, keepAbove, false)
CLIENT_HELPER_WITH_DELETED(bool, keepBelow, keepBelow, false)
CLIENT_HELPER_WITH_DELETED(QString, caption, caption, QString());
CLIENT_HELPER_WITH_DELETED(QVector<uint>, desktops, x11DesktopIds, QVector<uint>());
#undef CLIENT_HELPER_WITH_DELETED
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 CLIENT_HELPER( rettype, prototype, propertyname, defaultValue ) \
rettype EffectWindowImpl::prototype ( ) const \
{ \
auto client = qobject_cast<AbstractClient *>(toplevel); \
if (client) { \
return client->propertyname(); \
} \
return defaultValue; \
}
CLIENT_HELPER(bool, isMovable, isMovable, false)
CLIENT_HELPER(bool, isMovableAcrossScreens, isMovableAcrossScreens, false)
CLIENT_HELPER(bool, isUserMove, isMove, false)
CLIENT_HELPER(bool, isUserResize, isResize, false)
CLIENT_HELPER(QRect, iconGeometry, iconGeometry, QRect())
CLIENT_HELPER(bool, isSpecialWindow, isSpecialWindow, true)
CLIENT_HELPER(bool, acceptsFocus, wantsInput, true) // We don't actually know...
CLIENT_HELPER(QIcon, icon, icon, QIcon())
CLIENT_HELPER(bool, isSkipSwitcher, skipSwitcher, false)
CLIENT_HELPER(bool, decorationHasAlpha, decorationHasAlpha, false)
CLIENT_HELPER(bool, isUnresponsive, unresponsive, false)
#undef CLIENT_HELPER
QSize EffectWindowImpl::basicUnit() const
{
if (auto client = qobject_cast<Client*>(toplevel)){
return client->basicUnit();
}
return QSize(1,1);
}
void EffectWindowImpl::setWindow(Toplevel* w)
{
toplevel = w;
@ -1868,6 +1995,22 @@ void EffectWindowImpl::unreferencePreviousWindowPixmap()
}
}
bool EffectWindowImpl::isManaged() const
{
return managed;
}
bool EffectWindowImpl::isWaylandClient() const
{
return waylandClient;
}
bool EffectWindowImpl::isX11Client() const
{
return x11Client;
}
//****************************************
// EffectWindowGroupImpl
//****************************************

View file

@ -357,7 +357,7 @@ class EffectWindowImpl : public EffectWindow
Q_OBJECT
public:
explicit EffectWindowImpl(Toplevel *toplevel);
virtual ~EffectWindowImpl();
~EffectWindowImpl() override;
void enablePainting(int reason) override;
void disablePainting(int reason) override;
@ -368,7 +368,79 @@ public:
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;
QVector<uint> desktops() 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;
bool isPopupWindow() 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;
bool isManaged() const override;
bool isWaylandClient() const override;
bool isX11Client() const override;
QRect decorationInnerRect() const override;
QByteArray readProperty(long atom, long type, int format) const override;
void deleteProperty(long atom) const override;
@ -401,6 +473,7 @@ public:
QList<DesktopThumbnailItem*> const &desktopThumbnails() const {
return m_desktopThumbnails;
}
private Q_SLOTS:
void thumbnailDestroyed(QObject *object);
void thumbnailTargetChanged();
@ -412,6 +485,9 @@ private:
QHash<int, QVariant> dataMap;
QHash<WindowThumbnailItem*, QWeakPointer<EffectWindowImpl> > m_thumbnails;
QList<DesktopThumbnailItem*> m_desktopThumbnails;
bool managed = false;
bool waylandClient;
bool x11Client;
};
class EffectWindowGroupImpl

View file

@ -775,9 +775,6 @@ public:
Private(EffectWindow *q);
EffectWindow *q;
bool managed = false;
bool waylandClient;
bool x11Client;
};
EffectWindow::Private::Private(EffectWindow *q)
@ -789,128 +786,23 @@ EffectWindow::EffectWindow(QObject *parent)
: QObject(parent)
, d(new Private(this))
{
// Deleted windows are not managed. So, when windowClosed signal is
// emitted, effects can't distinguish managed windows from unmanaged
// windows(e.g. combo box popups, popup menus, etc). Save value of the
// managed property during construction of EffectWindow. At that time,
// parent can be Client, ShellClient, or Unmanaged. So, later on, when
// an instance of Deleted becomes parent of the EffectWindow, effects
// can still figure out whether it is/was a managed window.
d->managed = parent->property("managed").value<bool>();
d->waylandClient = parent->inherits("KWin::ShellClient");
d->x11Client = !d->waylandClient;
}
EffectWindow::~EffectWindow()
{
}
#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")
#ifndef KWIN_NO_DEPRECATED
WINDOW_HELPER(int, desktop, "desktop")
#endif
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")
WINDOW_HELPER(QVector<uint>, desktops, "x11DesktopIds")
WINDOW_HELPER(bool, isPopupWindow, "popupWindow")
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<NET::WindowType>(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 ) \
{\
@ -997,21 +889,6 @@ bool EffectWindow::isVisible() const
&& isOnCurrentActivity();
}
bool EffectWindow::isManaged() const
{
return d->managed;
}
bool EffectWindow::isWaylandClient() const
{
return d->waylandClient;
}
bool EffectWindow::isX11Client() const
{
return d->x11Client;
}
//****************************************
// EffectWindowGroup
//****************************************

View file

@ -2071,16 +2071,17 @@ public:
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;
@ -2094,48 +2095,48 @@ public:
* @deprecated
*/
#ifndef KWIN_NO_DEPRECATED
int KWIN_DEPRECATED desktop() const; // prefer isOnXXX()
virtual int KWIN_DEPRECATED desktop() const = 0; // prefer isOnXXX()
#endif
/**
* All the desktops by number that the window is in. On X11 this list will always have
* a length of 1, on Wayland can be any subset.
* If the list is empty it means the window is on all desktops
*/
QVector<uint> desktops() const;
virtual QVector<uint> desktops() const = 0;
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.
@ -2143,124 +2144,124 @@ public:
*/
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
virtual bool isManaged() const = 0; // 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<KWin::EffectWindow*> mainWindows() const = 0;
@ -2268,7 +2269,7 @@ public:
* 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.
@ -2280,7 +2281,7 @@ public:
void unminimize();
Q_SCRIPTABLE void closeWindow() const;
bool isCurrentTab() const;
virtual bool isCurrentTab() const = 0;
/**
* @since 4.11
@ -2290,37 +2291,37 @@ public:
/**
* @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
**/
bool isWaylandClient() const;
virtual bool isWaylandClient() const = 0;
/**
* @since 5.15
**/
bool isX11Client() const;
virtual bool isX11Client() const = 0;
/**
* @since 5.15
**/
bool isPopupWindow() const;
virtual bool isPopupWindow() const = 0;
/**
* Can be used to by effects to store arbitrary data in the EffectWindow.