Commit ac804ff1 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

ShowDesktop: Use the new DBus API for showing the desktop

This unifies the code paths (underneath KWindowSystem goes through two
separate code paths) and generally makes the code a lot more direct
instead of going through a bunch of layers. Additionally, it allows the
KWin-side of things to check if the caller disappears and quit the "show
desktop" mode if that happens.

BUG: 449445
parent 098a965b
Pipeline #210285 passed with stage
in 3 minutes and 16 seconds
......@@ -7,6 +7,8 @@ set(showdesktop_SRCS
plugin/showdesktopplugin.cpp
)
qt_add_dbus_interface(showdesktop_SRCS plugin/org.kde.KWin.xml kwin_interface)
add_library(showdesktopplugin SHARED ${showdesktop_SRCS})
target_link_libraries(showdesktopplugin
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.KWin">
<property name="showingDesktop" type="b" access="read"/>
<method name="showDesktop">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
<arg name="showing" type="b" direction="in"/>
</method>
<signal name="showingDesktopChanged">
<arg name="showing" type="b" direction="out"/>
</signal>
</interface>
</node>
......@@ -15,6 +15,9 @@
ShowDesktop::ShowDesktop(QObject *parent)
: QObject(parent)
{
m_interface = new OrgKdeKWinInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/KWin"), QDBusConnection::sessionBus(), this);
connect(m_interface, &OrgKdeKWinInterface::showingDesktopChanged, this, &ShowDesktop::showingDesktopChanged);
connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, this, &ShowDesktop::showingDesktopChanged);
}
......@@ -22,12 +25,21 @@ ShowDesktop::~ShowDesktop() = default;
bool ShowDesktop::showingDesktop() const
{
if (m_interface->isValid()) {
return m_interface->showingDesktop();
}
return KWindowSystem::showingDesktop();
}
void ShowDesktop::setShowingDesktop(bool showingDesktop)
{
KWindowSystem::setShowingDesktop(showingDesktop);
if (m_interface->isValid()) {
m_interface->showDesktop(showingDesktop);
} else {
KWindowSystem::setShowingDesktop(showingDesktop);
}
Q_EMIT showingDesktopChanged(showingDesktop);
}
......@@ -50,7 +62,5 @@ void ShowDesktop::minimizeAll()
void ShowDesktop::toggleDesktop()
{
const bool showingNow = KWindowSystem::showingDesktop();
KWindowSystem::setShowingDesktop(!showingNow);
Q_EMIT showingDesktopChanged(!showingNow);
setShowingDesktop(!showingDesktop());
}
......@@ -9,6 +9,8 @@
#include <QObject>
#include "kwin_interface.h"
class ShowDesktop : public QObject
{
Q_OBJECT
......@@ -27,6 +29,9 @@ public:
Q_SIGNALS:
void showingDesktopChanged(bool showingDesktop);
private:
OrgKdeKWinInterface *m_interface;
};
#endif // SHOWDESKTOP_HEADER
Supports Markdown
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