File indexing completed on 2024-11-03 13:42:41
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2014 Fredrik Höglund <fredrik@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #include "x11eventfilter.h" 0011 #include "main.h" 0012 0013 namespace KWin 0014 { 0015 0016 X11EventFilter::X11EventFilter(const QVector<int> &eventTypes) 0017 : m_eventTypes(eventTypes) 0018 , m_extension(0) 0019 { 0020 kwinApp()->registerEventFilter(this); 0021 } 0022 0023 X11EventFilter::X11EventFilter(int eventType, int opcode, int genericEventType) 0024 : X11EventFilter(eventType, opcode, QVector<int>{genericEventType}) 0025 { 0026 } 0027 0028 X11EventFilter::X11EventFilter(int eventType, int opcode, const QVector<int> &genericEventTypes) 0029 : m_eventTypes(QVector<int>{eventType}) 0030 , m_extension(opcode) 0031 , m_genericEventTypes(genericEventTypes) 0032 { 0033 kwinApp()->registerEventFilter(this); 0034 } 0035 0036 X11EventFilter::~X11EventFilter() 0037 { 0038 if (kwinApp()) { 0039 kwinApp()->unregisterEventFilter(this); 0040 } 0041 } 0042 0043 bool X11EventFilter::isGenericEvent() const 0044 { 0045 if (m_eventTypes.count() != 1) { 0046 return false; 0047 } 0048 return m_eventTypes.first() == XCB_GE_GENERIC; 0049 } 0050 0051 }