Support custom color scheme for Wayland windows

Summary:
On Wayland the QtExtendedSurface is used to pass the path to the color
scheme using the generic window property. To support this ShellClient
installs an event filter on the extended surface and listens for dynamic
property change events.

As the color scheme is KDE specific anyway it is not a problem that a Qt
specific interface is being used. For other toolkits just passing the
name to KDE's color scheme isn't sufficient anyway. If at some point we
find a way to support this for e.g. GTK+ we would need to come up with a
dedicated interface.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3047
master
Martin Gräßlin 8 years ago
parent 8201def97f
commit f41b610608

@ -50,6 +50,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using namespace KWayland::Server;
static const QByteArray s_schemePropertyName = QByteArrayLiteral("KDE_COLOR_SCHEME_PATH");
namespace KWin
{
@ -1137,6 +1139,18 @@ void ShellClient::installQtExtendedSurface(QtExtendedSurfaceInterface *surface)
connect(m_qtExtendedSurface.data(), &QtExtendedSurfaceInterface::lowerRequested, this, [this]() {
workspace()->lowerClientRequest(this);
});
m_qtExtendedSurface->installEventFilter(this);
}
bool ShellClient::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_qtExtendedSurface.data() && event->type() == QEvent::DynamicPropertyChange) {
QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event);
if (pe->propertyName() == s_schemePropertyName) {
updateColorScheme(rules()->checkDecoColor(m_qtExtendedSurface->property(pe->propertyName().constData()).toString()));
}
}
return false;
}
bool ShellClient::hasStrut() const

@ -46,6 +46,8 @@ public:
ShellClient(KWayland::Server::XdgShellPopupInterface *surface);
virtual ~ShellClient();
bool eventFilter(QObject *watched, QEvent *event) override;
QStringList activities() const override;
QPoint clientContentPos() const override;
QSize clientSize() const override;

Loading…
Cancel
Save