File indexing completed on 2024-02-18 16:20:22

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 "effects.h"
0011 #include "unmanaged.h"
0012 #include "workspace.h"
0013 #include "x11window.h"
0014 
0015 namespace KWin
0016 {
0017 
0018 WindowPropertyNotifyX11Filter::WindowPropertyNotifyX11Filter(EffectsHandlerImpl *effects)
0019     : X11EventFilter(QVector<int>{XCB_PROPERTY_NOTIFY})
0020     , m_effects(effects)
0021 {
0022 }
0023 
0024 bool WindowPropertyNotifyX11Filter::event(xcb_generic_event_t *event)
0025 {
0026     const auto *pe = reinterpret_cast<xcb_property_notify_event_t *>(event);
0027     if (!m_effects->isPropertyTypeRegistered(pe->atom)) {
0028         return false;
0029     }
0030     if (pe->window == kwinApp()->x11RootWindow()) {
0031         Q_EMIT m_effects->propertyNotify(nullptr, pe->atom);
0032     } else if (const auto c = workspace()->findClient(Predicate::WindowMatch, pe->window)) {
0033         Q_EMIT m_effects->propertyNotify(c->effectWindow(), pe->atom);
0034     } else if (const auto c = workspace()->findUnmanaged(pe->window)) {
0035         Q_EMIT m_effects->propertyNotify(c->effectWindow(), pe->atom);
0036     }
0037     return false;
0038 }
0039 
0040 }