File indexing completed on 2025-03-09 05:02:42
0001 /* 0002 SPDX-FileCopyrightText: 2023 David Edmundson <davidedmundson@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #pragma once 0007 0008 #include <QMargins> 0009 #include <QObject> 0010 #include <memory> 0011 0012 #include <plasmaquick/plasmaquick_export.h> 0013 0014 class QWindow; 0015 0016 class EdgeEventForwarderPrivate; 0017 0018 namespace PlasmaQuick 0019 { 0020 0021 /** 0022 * @brief The EdgeEventForwarder class 0023 * This class forwards edge events to be replayed within the given margin 0024 * This is useful if children do not touch the edge of a window, but want to get input events 0025 */ 0026 class PLASMAQUICK_EXPORT EdgeEventForwarder : public QObject 0027 { 0028 Q_OBJECT 0029 public: 0030 /** 0031 * @brief EdgeEventForwarder constructor 0032 * @param window The window to intercept and filter 0033 * The event forwarder is parented to the window 0034 */ 0035 EdgeEventForwarder(QWindow *parent); 0036 ~EdgeEventForwarder(); 0037 0038 /** 0039 * @brief setMargins sets the margins to use for the event forwarding 0040 */ 0041 void setMargins(const QMargins &margins); 0042 QMargins margins(); 0043 0044 /** 0045 * @brief setActiveEdges sets which margins should be active for edge forwarding 0046 * typically this should match edges touching a screen edge 0047 */ 0048 void setActiveEdges(Qt::Edges edges); 0049 Qt::Edges activeEdges(); 0050 0051 bool eventFilter(QObject *watched, QEvent *event) override; 0052 0053 private: 0054 std::unique_ptr<EdgeEventForwarderPrivate> d; 0055 }; 0056 0057 }