File indexing completed on 2024-04-28 05:30:37

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "window_property_notify_x11_filter.h"
0010 #include "effect/effecthandler.h"
0011 #include "workspace.h"
0012 #include "x11window.h"
0013 
0014 namespace KWin
0015 {
0016 
0017 WindowPropertyNotifyX11Filter::WindowPropertyNotifyX11Filter(EffectsHandler *effects)
0018     : X11EventFilter(QList<int>{XCB_PROPERTY_NOTIFY})
0019     , m_effects(effects)
0020 {
0021 }
0022 
0023 bool WindowPropertyNotifyX11Filter::event(xcb_generic_event_t *event)
0024 {
0025     const auto *pe = reinterpret_cast<xcb_property_notify_event_t *>(event);
0026     if (!m_effects->isPropertyTypeRegistered(pe->atom)) {
0027         return false;
0028     }
0029     if (pe->window == kwinApp()->x11RootWindow()) {
0030         Q_EMIT m_effects->propertyNotify(nullptr, pe->atom);
0031     } else if (const auto c = workspace()->findClient(Predicate::WindowMatch, pe->window)) {
0032         Q_EMIT m_effects->propertyNotify(c->effectWindow(), pe->atom);
0033     } else if (const auto c = workspace()->findUnmanaged(pe->window)) {
0034         Q_EMIT m_effects->propertyNotify(c->effectWindow(), pe->atom);
0035     }
0036     return false;
0037 }
0038 
0039 }