File indexing completed on 2024-04-28 16:48:59

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 "rootinfo_filter.h"
0010 #include "netinfo.h"
0011 #include "virtualdesktops.h"
0012 
0013 namespace KWin
0014 {
0015 
0016 RootInfoFilter::RootInfoFilter(RootInfo *parent)
0017     : X11EventFilter(QVector<int>{XCB_PROPERTY_NOTIFY, XCB_CLIENT_MESSAGE})
0018     , m_rootInfo(parent)
0019 {
0020 }
0021 
0022 bool RootInfoFilter::event(xcb_generic_event_t *event)
0023 {
0024     NET::Properties dirtyProtocols;
0025     NET::Properties2 dirtyProtocols2;
0026     m_rootInfo->event(event, &dirtyProtocols, &dirtyProtocols2);
0027     if (dirtyProtocols & NET::DesktopNames) {
0028         VirtualDesktopManager::self()->save();
0029     }
0030     if (dirtyProtocols2 & NET::WM2DesktopLayout) {
0031         VirtualDesktopManager::self()->updateLayout();
0032     }
0033     return false;
0034 }
0035 
0036 }