Commit 9993c6d6 authored by Martin Flöser's avatar Martin Flöser

Add a dbus method getWindowInfo returning same data as queryWindowInfo

Summary:
This dbus method is intended to be used by the kwin rules dialog. KWin
can pass the internal id to the rules dialog through a command line
argument (or similar way) and the dialog can query the information
through the dbus call for the provided id. Thus it's possible to
implement one way to query the information which works on both X11 and
Wayland without any windowing system specific functionality.

Test Plan: See new added integration test

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17433
parent c20be6e0
......@@ -76,6 +76,7 @@ if (XCB_ICCCM_FOUND)
integrationTest(NAME testSceneQPainter SRCS scene_qpainter_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testSceneQPainterShadow SRCS scene_qpainter_shadow_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testStackingOrder SRCS stacking_order_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testDbusInterface SRCS dbus_interface_test.cpp LIBS XCB::ICCCM)
if (KWIN_BUILD_ACTIVITIES)
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM)
......
This diff is collapsed.
......@@ -189,6 +189,37 @@ void DBusInterface::showDebugConsole()
console->show();
}
namespace {
QVariantMap clientToVariantMap(const AbstractClient *c)
{
return {
{QStringLiteral("resourceClass"), c->resourceClass()},
{QStringLiteral("resourceName"), c->resourceName()},
{QStringLiteral("desktopFile"), c->desktopFileName()},
{QStringLiteral("role"), c->windowRole()},
{QStringLiteral("caption"), c->captionNormal()},
{QStringLiteral("clientMachine"), c->wmClientMachine(true)},
{QStringLiteral("type"), c->windowType()},
{QStringLiteral("x"), c->x()},
{QStringLiteral("y"), c->y()},
{QStringLiteral("width"), c->width()},
{QStringLiteral("height"), c->height()},
{QStringLiteral("x11DesktopNumber"), c->desktop()},
{QStringLiteral("minimized"), c->isMinimized()},
{QStringLiteral("shaded"), c->isShade()},
{QStringLiteral("fullscreen"), c->isFullScreen()},
{QStringLiteral("keepAbove"), c->keepAbove()},
{QStringLiteral("keepBelow"), c->keepBelow()},
{QStringLiteral("noBorder"), c->noBorder()},
{QStringLiteral("skipTaskbar"), c->skipTaskbar()},
{QStringLiteral("skipPager"), c->skipPager()},
{QStringLiteral("skipSwitcher"), c->skipSwitcher()},
{QStringLiteral("maximizeHorizontal"), c->maximizeMode() & MaximizeHorizontal},
{QStringLiteral("maximizeVertical"), c->maximizeMode() & MaximizeVertical}
};
}
}
QVariantMap DBusInterface::queryWindowInfo()
{
m_replyQueryWindowInfo = message();
......@@ -196,32 +227,7 @@ QVariantMap DBusInterface::queryWindowInfo()
kwinApp()->platform()->startInteractiveWindowSelection(
[this] (Toplevel *t) {
if (auto c = qobject_cast<AbstractClient*>(t)) {
const QVariantMap ret{
{QStringLiteral("resourceClass"), c->resourceClass()},
{QStringLiteral("resourceName"), c->resourceName()},
{QStringLiteral("desktopFile"), c->desktopFileName()},
{QStringLiteral("role"), c->windowRole()},
{QStringLiteral("caption"), c->captionNormal()},
{QStringLiteral("clientMachine"), c->wmClientMachine(true)},
{QStringLiteral("type"), c->windowType()},
{QStringLiteral("x"), c->x()},
{QStringLiteral("y"), c->y()},
{QStringLiteral("width"), c->width()},
{QStringLiteral("height"), c->height()},
{QStringLiteral("x11DesktopNumber"), c->desktop()},
{QStringLiteral("minimized"), c->isMinimized()},
{QStringLiteral("shaded"), c->isShade()},
{QStringLiteral("fullscreen"), c->isFullScreen()},
{QStringLiteral("keepAbove"), c->keepAbove()},
{QStringLiteral("keepBelow"), c->keepBelow()},
{QStringLiteral("noBorder"), c->noBorder()},
{QStringLiteral("skipTaskbar"), c->skipTaskbar()},
{QStringLiteral("skipPager"), c->skipPager()},
{QStringLiteral("skipSwitcher"), c->skipSwitcher()},
{QStringLiteral("maximizeHorizontal"), c->maximizeMode() & MaximizeHorizontal},
{QStringLiteral("maximizeVertical"), c->maximizeMode() & MaximizeVertical}
};
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(ret));
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(c)));
} else {
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply(QString(), QString()));
}
......@@ -230,6 +236,17 @@ QVariantMap DBusInterface::queryWindowInfo()
return QVariantMap{};
}
QVariantMap DBusInterface::getWindowInfo(const QString &uuid)
{
const auto id = QUuid::fromString(uuid);
const auto client = workspace()->findAbstractClient([&id] (const AbstractClient *c) { return c->internalId() == id; });
if (client) {
return clientToVariantMap(client);
} else {
return {};
}
}
CompositorDBusInterface::CompositorDBusInterface(Compositor *parent)
: QObject(parent)
, m_compositor(parent)
......
......@@ -70,6 +70,7 @@ public Q_SLOTS: // METHODS
Q_NOREPLY void showDebugConsole();
QVariantMap queryWindowInfo();
QVariantMap getWindowInfo(const QString &uuid);
private Q_SLOTS:
void becomeKWinService(const QString &service);
......
......@@ -40,5 +40,10 @@
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg type="a{sv}" direction="out"/>
</method>
<method name="getWindowInfo">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
</method>
</interface>
</node>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment