KWin
Loading...
Searching...
No Matches
debug_console.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include "input.h"
12#include "input_event_spy.h"
13#include <config-kwin.h>
14#include <kwin_export.h>
15
16#include <QAbstractItemModel>
17#include <QList>
18#include <QStyledItemDelegate>
19#include <functional>
20#include <memory>
21
22class QTextEdit;
23
24namespace Ui
25{
26class DebugConsole;
27}
28
29namespace KWin
30{
31
32class AbstractDataSource;
33class Window;
34class X11Window;
35class InternalWindow;
36class DebugConsoleFilter;
37class WaylandWindow;
38
39class KWIN_EXPORT DebugConsoleModel : public QAbstractItemModel
40{
41 Q_OBJECT
42public:
43 explicit DebugConsoleModel(QObject *parent = nullptr);
45
46 int columnCount(const QModelIndex &parent) const override;
47 QVariant data(const QModelIndex &index, int role) const override;
48 QModelIndex index(int row, int column, const QModelIndex &parent) const override;
49 int rowCount(const QModelIndex &parent) const override;
50 QModelIndex parent(const QModelIndex &child) const override;
51
52private Q_SLOTS:
53 void handleWindowAdded(Window *window);
54 void handleWindowRemoved(Window *window);
55
56private:
57 template<class T>
58 QModelIndex indexForWindow(int row, int column, const QList<T *> &windows, int id) const;
59 template<class T>
60 QModelIndex indexForProperty(int row, int column, const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex &) const) const;
61 template<class T>
62 int propertyCount(const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex &) const) const;
63 QVariant propertyData(QObject *object, const QModelIndex &index, int role) const;
64 template<class T>
65 QVariant windowData(const QModelIndex &index, int role, const QList<T *> windows, const std::function<QString(T *)> &toString) const;
66 template<class T>
67 void add(int parentRow, QList<T *> &windows, T *window);
68 template<class T>
69 void remove(int parentRow, QList<T *> &windows, T *window);
70 WaylandWindow *waylandWindow(const QModelIndex &index) const;
71 InternalWindow *internalWindow(const QModelIndex &index) const;
72 X11Window *x11Window(const QModelIndex &index) const;
73 X11Window *unmanaged(const QModelIndex &index) const;
74 int topLevelRowCount() const;
75
76 QList<WaylandWindow *> m_waylandWindows;
77 QList<InternalWindow *> m_internalWindows;
78 QList<X11Window *> m_x11Windows;
79 QList<X11Window *> m_unmanageds;
80};
81
82class DebugConsoleDelegate : public QStyledItemDelegate
83{
84 Q_OBJECT
85public:
86 explicit DebugConsoleDelegate(QObject *parent = nullptr);
88
89 QString displayText(const QVariant &value, const QLocale &locale) const override;
90};
91
92class KWIN_EXPORT DebugConsole : public QWidget
93{
94 Q_OBJECT
95public:
97 ~DebugConsole() override;
98
99protected:
100 void showEvent(QShowEvent *event) override;
101
102private:
103 void initGLTab();
104 void updateKeyboardTab();
105
106 std::unique_ptr<Ui::DebugConsole> m_ui;
107 std::unique_ptr<DebugConsoleFilter> m_inputFilter;
108};
109
110class SurfaceTreeModel : public QAbstractItemModel
111{
112 Q_OBJECT
113public:
114 explicit SurfaceTreeModel(QObject *parent = nullptr);
116
117 int columnCount(const QModelIndex &parent) const override;
118 QVariant data(const QModelIndex &index, int role) const override;
119 QModelIndex index(int row, int column, const QModelIndex &parent) const override;
120 int rowCount(const QModelIndex &parent) const override;
121 QModelIndex parent(const QModelIndex &child) const override;
122};
123
125{
126public:
127 explicit DebugConsoleFilter(QTextEdit *textEdit);
129
130 void pointerEvent(MouseEvent *event) override;
131 void wheelEvent(WheelEvent *event) override;
132 void keyEvent(KeyEvent *event) override;
133 void touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
134 void touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
135 void touchUp(qint32 id, std::chrono::microseconds time) override;
136
137 void pinchGestureBegin(int fingerCount, std::chrono::microseconds time) override;
138 void pinchGestureUpdate(qreal scale, qreal angleDelta, const QPointF &delta, std::chrono::microseconds time) override;
139 void pinchGestureEnd(std::chrono::microseconds time) override;
140 void pinchGestureCancelled(std::chrono::microseconds time) override;
141
142 void swipeGestureBegin(int fingerCount, std::chrono::microseconds time) override;
143 void swipeGestureUpdate(const QPointF &delta, std::chrono::microseconds time) override;
144 void swipeGestureEnd(std::chrono::microseconds time) override;
145 void swipeGestureCancelled(std::chrono::microseconds time) override;
146
147 void switchEvent(SwitchEvent *event) override;
148
149 void tabletToolEvent(TabletEvent *event) override;
150 void tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId, std::chrono::microseconds time) override;
151 void tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId, std::chrono::microseconds time) override;
152 void tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId, std::chrono::microseconds time) override;
153 void tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId, std::chrono::microseconds time) override;
154
155private:
156 QTextEdit *m_textEdit;
157};
158
159class InputDeviceModel : public QAbstractItemModel
160{
161 Q_OBJECT
162public:
163 explicit InputDeviceModel(QObject *parent = nullptr);
165
166 int columnCount(const QModelIndex &parent) const override;
167 QVariant data(const QModelIndex &index, int role) const override;
168 QModelIndex index(int row, int column, const QModelIndex &parent) const override;
169 int rowCount(const QModelIndex &parent) const override;
170 QModelIndex parent(const QModelIndex &child) const override;
171
172private Q_SLOTS:
173 void slotPropertyChanged();
174
175private:
176 void setupDeviceConnections(InputDevice *device);
177 QList<InputDevice *> m_devices;
178};
179
180class DataSourceModel : public QAbstractItemModel
181{
182public:
183 using QAbstractItemModel::QAbstractItemModel;
184
185 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
186 QModelIndex parent(const QModelIndex &child) const override;
187 int rowCount(const QModelIndex &parent) const override;
188 int columnCount(const QModelIndex &parent) const override
189 {
190 return parent.isValid() ? 0 : 2;
191 }
192 QVariant data(const QModelIndex &index, int role) const override;
193 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
194
195 void setSource(AbstractDataSource *source);
196
197private:
198 AbstractDataSource *m_source = nullptr;
199 QList<QByteArray> m_data;
200};
201}
The AbstractDataSource class abstracts the data that can be transferred to another client.
QModelIndex parent(const QModelIndex &child) const override
int rowCount(const QModelIndex &parent) const override
int columnCount(const QModelIndex &parent) const override
QVariant data(const QModelIndex &index, int role) const override
void setSource(AbstractDataSource *source)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QString displayText(const QVariant &value, const QLocale &locale) const override
DebugConsoleDelegate(QObject *parent=nullptr)
void tabletToolEvent(TabletEvent *event) override
void touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time) override
void swipeGestureEnd(std::chrono::microseconds time) override
void switchEvent(SwitchEvent *event) override
void touchUp(qint32 id, std::chrono::microseconds time) override
void pinchGestureCancelled(std::chrono::microseconds time) override
void keyEvent(KeyEvent *event) override
DebugConsoleFilter(QTextEdit *textEdit)
void swipeGestureBegin(int fingerCount, std::chrono::microseconds time) override
void touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override
void tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId, std::chrono::microseconds time) override
void tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId, std::chrono::microseconds time) override
void tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId, std::chrono::microseconds time) override
void tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId, std::chrono::microseconds time) override
void pinchGestureUpdate(qreal scale, qreal angleDelta, const QPointF &delta, std::chrono::microseconds time) override
void swipeGestureCancelled(std::chrono::microseconds time) override
void wheelEvent(WheelEvent *event) override
void pinchGestureBegin(int fingerCount, std::chrono::microseconds time) override
~DebugConsoleFilter() override
void swipeGestureUpdate(const QPointF &delta, std::chrono::microseconds time) override
void pinchGestureEnd(std::chrono::microseconds time) override
void pointerEvent(MouseEvent *event) override
~DebugConsole() override
~DebugConsoleModel() override
InputDeviceModel(QObject *parent=nullptr)
int columnCount(const QModelIndex &parent) const override
QModelIndex parent(const QModelIndex &child) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
int rowCount(const QModelIndex &parent) const override
QVariant data(const QModelIndex &index, int role) const override
~InputDeviceModel() override
SurfaceTreeModel(QObject *parent=nullptr)
~SurfaceTreeModel() override
int rowCount(const QModelIndex &parent) const override
int columnCount(const QModelIndex &parent) const override
QModelIndex parent(const QModelIndex &child) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
QVariant data(const QModelIndex &index, int role) const override