Changeset View
Changeset View
Standalone View
Standalone View
debug_console.cpp
Show All 22 Lines | |||||
23 | #include "input_event.h" | 23 | #include "input_event.h" | ||
24 | #include "main.h" | 24 | #include "main.h" | ||
25 | #include "scene.h" | 25 | #include "scene.h" | ||
26 | #include "shell_client.h" | 26 | #include "shell_client.h" | ||
27 | #include "unmanaged.h" | 27 | #include "unmanaged.h" | ||
28 | #include "wayland_server.h" | 28 | #include "wayland_server.h" | ||
29 | #include "workspace.h" | 29 | #include "workspace.h" | ||
30 | #include "keyboard_input.h" | 30 | #include "keyboard_input.h" | ||
31 | #if HAVE_INPUT | | |||
32 | #include "libinput/connection.h" | 31 | #include "libinput/connection.h" | ||
33 | #include "libinput/device.h" | 32 | #include "libinput/device.h" | ||
34 | #endif | | |||
35 | #include <kwinglplatform.h> | 33 | #include <kwinglplatform.h> | ||
36 | #include <kwinglutils.h> | 34 | #include <kwinglutils.h> | ||
37 | 35 | | |||
38 | #include "ui_debug_console.h" | 36 | #include "ui_debug_console.h" | ||
39 | 37 | | |||
40 | // KWayland | 38 | // KWayland | ||
41 | #include <KWayland/Server/buffer_interface.h> | 39 | #include <KWayland/Server/buffer_interface.h> | ||
42 | #include <KWayland/Server/clientconnection.h> | 40 | #include <KWayland/Server/clientconnection.h> | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 135 | case Qt::ExtraButton23: | |||
138 | return i18nc("A mouse button", "Extra Button 23"); | 136 | return i18nc("A mouse button", "Extra Button 23"); | ||
139 | case Qt::ExtraButton24: | 137 | case Qt::ExtraButton24: | ||
140 | return i18nc("A mouse button", "Extra Button 24"); | 138 | return i18nc("A mouse button", "Extra Button 24"); | ||
141 | default: | 139 | default: | ||
142 | return QString(); | 140 | return QString(); | ||
143 | } | 141 | } | ||
144 | } | 142 | } | ||
145 | 143 | | |||
146 | #if HAVE_INPUT | | |||
147 | static QString deviceRow(LibInput::Device *device) | 144 | static QString deviceRow(LibInput::Device *device) | ||
148 | { | 145 | { | ||
149 | if (!device) { | 146 | if (!device) { | ||
150 | return tableRow(i18n("Input Device"), i18nc("The input device of the event is not known", "Unknown")); | 147 | return tableRow(i18n("Input Device"), i18nc("The input device of the event is not known", "Unknown")); | ||
151 | } | 148 | } | ||
152 | return tableRow(i18n("Input Device"), QStringLiteral("%1 (%2)").arg(device->name()).arg(device->sysName())); | 149 | return tableRow(i18n("Input Device"), QStringLiteral("%1 (%2)").arg(device->name()).arg(device->sysName())); | ||
153 | } | 150 | } | ||
154 | #endif | | |||
155 | 151 | | |||
156 | static QString buttonsToString(Qt::MouseButtons buttons) | 152 | static QString buttonsToString(Qt::MouseButtons buttons) | ||
157 | { | 153 | { | ||
158 | QString ret; | 154 | QString ret; | ||
159 | for (uint i = 1; i < Qt::ExtraButton24; i = i << 1) { | 155 | for (uint i = 1; i < Qt::ExtraButton24; i = i << 1) { | ||
160 | if (buttons & i) { | 156 | if (buttons & i) { | ||
161 | ret.append(buttonToString(Qt::MouseButton(uint(buttons) & i))); | 157 | ret.append(buttonToString(Qt::MouseButton(uint(buttons) & i))); | ||
162 | ret.append(QStringLiteral(" ")); | 158 | ret.append(QStringLiteral(" ")); | ||
Show All 18 Lines | |||||
181 | { | 177 | { | ||
182 | QString text = s_hr; | 178 | QString text = s_hr; | ||
183 | const QString timestamp = timestampRow(event->timestamp()); | 179 | const QString timestamp = timestampRow(event->timestamp()); | ||
184 | 180 | | |||
185 | text.append(s_tableStart); | 181 | text.append(s_tableStart); | ||
186 | switch (event->type()) { | 182 | switch (event->type()) { | ||
187 | case QEvent::MouseMove: { | 183 | case QEvent::MouseMove: { | ||
188 | text.append(tableHeaderRow(i18nc("A mouse pointer motion event", "Pointer Motion"))); | 184 | text.append(tableHeaderRow(i18nc("A mouse pointer motion event", "Pointer Motion"))); | ||
189 | #if HAVE_INPUT | | |||
190 | text.append(deviceRow(event->device())); | 185 | text.append(deviceRow(event->device())); | ||
191 | #endif | | |||
192 | text.append(timestamp); | 186 | text.append(timestamp); | ||
193 | if (event->timestampMicroseconds() != 0) { | 187 | if (event->timestampMicroseconds() != 0) { | ||
194 | text.append(timestampRowUsec(event->timestampMicroseconds())); | 188 | text.append(timestampRowUsec(event->timestampMicroseconds())); | ||
195 | } | 189 | } | ||
196 | if (event->delta() != QSizeF()) { | 190 | if (event->delta() != QSizeF()) { | ||
197 | text.append(tableRow(i18nc("The relative mouse movement", "Delta"), | 191 | text.append(tableRow(i18nc("The relative mouse movement", "Delta"), | ||
198 | QStringLiteral("%1/%2").arg(event->delta().width()).arg(event->delta().height()))); | 192 | QStringLiteral("%1/%2").arg(event->delta().width()).arg(event->delta().height()))); | ||
199 | } | 193 | } | ||
200 | if (event->deltaUnaccelerated() != QSizeF()) { | 194 | if (event->deltaUnaccelerated() != QSizeF()) { | ||
201 | text.append(tableRow(i18nc("The relative mouse movement", "Delta (not accelerated)"), | 195 | text.append(tableRow(i18nc("The relative mouse movement", "Delta (not accelerated)"), | ||
202 | QStringLiteral("%1/%2").arg(event->deltaUnaccelerated().width()).arg(event->deltaUnaccelerated().height()))); | 196 | QStringLiteral("%1/%2").arg(event->deltaUnaccelerated().width()).arg(event->deltaUnaccelerated().height()))); | ||
203 | } | 197 | } | ||
204 | text.append(tableRow(i18nc("The global mouse pointer position", "Global Position"), QStringLiteral("%1/%2").arg(event->pos().x()).arg(event->pos().y()))); | 198 | text.append(tableRow(i18nc("The global mouse pointer position", "Global Position"), QStringLiteral("%1/%2").arg(event->pos().x()).arg(event->pos().y()))); | ||
205 | break; | 199 | break; | ||
206 | } | 200 | } | ||
207 | case QEvent::MouseButtonPress: | 201 | case QEvent::MouseButtonPress: | ||
208 | text.append(tableHeaderRow(i18nc("A mouse pointer button press event", "Pointer Button Press"))); | 202 | text.append(tableHeaderRow(i18nc("A mouse pointer button press event", "Pointer Button Press"))); | ||
209 | #if HAVE_INPUT | | |||
210 | text.append(deviceRow(event->device())); | 203 | text.append(deviceRow(event->device())); | ||
211 | #endif | | |||
212 | text.append(timestamp); | 204 | text.append(timestamp); | ||
213 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Button"), buttonToString(event->button()))); | 205 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Button"), buttonToString(event->button()))); | ||
214 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Native Button code"), event->nativeButton())); | 206 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Native Button code"), event->nativeButton())); | ||
215 | text.append(tableRow(i18nc("All currently pressed buttons in a mouse press/release event", "Pressed Buttons"), buttonsToString(event->buttons()))); | 207 | text.append(tableRow(i18nc("All currently pressed buttons in a mouse press/release event", "Pressed Buttons"), buttonsToString(event->buttons()))); | ||
216 | break; | 208 | break; | ||
217 | case QEvent::MouseButtonRelease: | 209 | case QEvent::MouseButtonRelease: | ||
218 | text.append(tableHeaderRow(i18nc("A mouse pointer button release event", "Pointer Button Release"))); | 210 | text.append(tableHeaderRow(i18nc("A mouse pointer button release event", "Pointer Button Release"))); | ||
219 | #if HAVE_INPUT | | |||
220 | text.append(deviceRow(event->device())); | 211 | text.append(deviceRow(event->device())); | ||
221 | #endif | | |||
222 | text.append(timestamp); | 212 | text.append(timestamp); | ||
223 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Button"), buttonToString(event->button()))); | 213 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Button"), buttonToString(event->button()))); | ||
224 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Native Button code"), event->nativeButton())); | 214 | text.append(tableRow(i18nc("A button in a mouse press/release event", "Native Button code"), event->nativeButton())); | ||
225 | text.append(tableRow(i18nc("All currently pressed buttons in a mouse press/release event", "Pressed Buttons"), buttonsToString(event->buttons()))); | 215 | text.append(tableRow(i18nc("All currently pressed buttons in a mouse press/release event", "Pressed Buttons"), buttonsToString(event->buttons()))); | ||
226 | break; | 216 | break; | ||
227 | default: | 217 | default: | ||
228 | break; | 218 | break; | ||
229 | } | 219 | } | ||
230 | text.append(s_tableEnd); | 220 | text.append(s_tableEnd); | ||
231 | 221 | | |||
232 | m_textEdit->insertHtml(text); | 222 | m_textEdit->insertHtml(text); | ||
233 | m_textEdit->ensureCursorVisible(); | 223 | m_textEdit->ensureCursorVisible(); | ||
234 | } | 224 | } | ||
235 | 225 | | |||
236 | void DebugConsoleFilter::wheelEvent(WheelEvent *event) | 226 | void DebugConsoleFilter::wheelEvent(WheelEvent *event) | ||
237 | { | 227 | { | ||
238 | QString text = s_hr; | 228 | QString text = s_hr; | ||
239 | text.append(s_tableStart); | 229 | text.append(s_tableStart); | ||
240 | text.append(tableHeaderRow(i18nc("A mouse pointer axis (wheel) event", "Pointer Axis"))); | 230 | text.append(tableHeaderRow(i18nc("A mouse pointer axis (wheel) event", "Pointer Axis"))); | ||
241 | #if HAVE_INPUT | | |||
242 | text.append(deviceRow(event->device())); | 231 | text.append(deviceRow(event->device())); | ||
243 | #endif | | |||
244 | text.append(timestampRow(event->timestamp())); | 232 | text.append(timestampRow(event->timestamp())); | ||
245 | const Qt::Orientation orientation = event->angleDelta().x() == 0 ? Qt::Vertical : Qt::Horizontal; | 233 | const Qt::Orientation orientation = event->angleDelta().x() == 0 ? Qt::Vertical : Qt::Horizontal; | ||
246 | text.append(tableRow(i18nc("The orientation of a pointer axis event", "Orientation"), | 234 | text.append(tableRow(i18nc("The orientation of a pointer axis event", "Orientation"), | ||
247 | orientation == Qt::Horizontal ? i18nc("An orientation of a pointer axis event", "Horizontal") | 235 | orientation == Qt::Horizontal ? i18nc("An orientation of a pointer axis event", "Horizontal") | ||
248 | : i18nc("An orientation of a pointer axis event", "Vertical"))); | 236 | : i18nc("An orientation of a pointer axis event", "Vertical"))); | ||
249 | text.append(tableRow(QStringLiteral("Delta"), orientation == Qt::Horizontal ? event->angleDelta().x() : event->angleDelta().y())); | 237 | text.append(tableRow(QStringLiteral("Delta"), orientation == Qt::Horizontal ? event->angleDelta().x() : event->angleDelta().y())); | ||
250 | text.append(s_tableEnd); | 238 | text.append(s_tableEnd); | ||
251 | 239 | | |||
Show All 11 Lines | 250 | case QEvent::KeyPress: | |||
263 | text.append(tableHeaderRow(i18nc("A key press event", "Key Press"))); | 251 | text.append(tableHeaderRow(i18nc("A key press event", "Key Press"))); | ||
264 | break; | 252 | break; | ||
265 | case QEvent::KeyRelease: | 253 | case QEvent::KeyRelease: | ||
266 | text.append(tableHeaderRow(i18nc("A key release event", "Key Release"))); | 254 | text.append(tableHeaderRow(i18nc("A key release event", "Key Release"))); | ||
267 | break; | 255 | break; | ||
268 | default: | 256 | default: | ||
269 | break; | 257 | break; | ||
270 | } | 258 | } | ||
271 | #if HAVE_INPUT | | |||
272 | text.append(deviceRow(event->device())); | 259 | text.append(deviceRow(event->device())); | ||
273 | #endif | | |||
274 | auto modifiersToString = [event] { | 260 | auto modifiersToString = [event] { | ||
275 | QString ret; | 261 | QString ret; | ||
276 | if (event->modifiers().testFlag(Qt::ShiftModifier)) { | 262 | if (event->modifiers().testFlag(Qt::ShiftModifier)) { | ||
277 | ret.append(i18nc("A keyboard modifier", "Shift")); | 263 | ret.append(i18nc("A keyboard modifier", "Shift")); | ||
278 | ret.append(QStringLiteral(" ")); | 264 | ret.append(QStringLiteral(" ")); | ||
279 | } | 265 | } | ||
280 | if (event->modifiers().testFlag(Qt::ControlModifier)) { | 266 | if (event->modifiers().testFlag(Qt::ControlModifier)) { | ||
281 | ret.append(i18nc("A keyboard modifier", "Control")); | 267 | ret.append(i18nc("A keyboard modifier", "Control")); | ||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | |||||
463 | { | 449 | { | ||
464 | QString text = s_hr; | 450 | QString text = s_hr; | ||
465 | text.append(s_tableStart); | 451 | text.append(s_tableStart); | ||
466 | text.append(tableHeaderRow(i18nc("A hardware switch (e.g. notebook lid) got toggled", "Switch toggled"))); | 452 | text.append(tableHeaderRow(i18nc("A hardware switch (e.g. notebook lid) got toggled", "Switch toggled"))); | ||
467 | text.append(timestampRow(event->timestamp())); | 453 | text.append(timestampRow(event->timestamp())); | ||
468 | if (event->timestampMicroseconds() != 0) { | 454 | if (event->timestampMicroseconds() != 0) { | ||
469 | text.append(timestampRowUsec(event->timestampMicroseconds())); | 455 | text.append(timestampRowUsec(event->timestampMicroseconds())); | ||
470 | } | 456 | } | ||
471 | #if HAVE_INPUT | | |||
472 | text.append(deviceRow(event->device())); | 457 | text.append(deviceRow(event->device())); | ||
473 | QString switchName; | 458 | QString switchName; | ||
474 | if (event->device()->isLidSwitch()) { | 459 | if (event->device()->isLidSwitch()) { | ||
475 | switchName = i18nc("Name of a hardware switch", "Notebook lid"); | 460 | switchName = i18nc("Name of a hardware switch", "Notebook lid"); | ||
476 | } else if (event->device()->isTabletModeSwitch()) { | 461 | } else if (event->device()->isTabletModeSwitch()) { | ||
477 | switchName = i18nc("Name of a hardware switch", "Tablet mode"); | 462 | switchName = i18nc("Name of a hardware switch", "Tablet mode"); | ||
478 | } | 463 | } | ||
479 | text.append(tableRow(i18nc("A hardware switch", "Switch"), switchName)); | 464 | text.append(tableRow(i18nc("A hardware switch", "Switch"), switchName)); | ||
480 | #endif | | |||
481 | QString switchState; | 465 | QString switchState; | ||
482 | switch (event->state()) { | 466 | switch (event->state()) { | ||
483 | case SwitchEvent::State::Off: | 467 | case SwitchEvent::State::Off: | ||
484 | switchState = i18nc("The hardware switch got turned off", "Off"); | 468 | switchState = i18nc("The hardware switch got turned off", "Off"); | ||
485 | break; | 469 | break; | ||
486 | case SwitchEvent::State::On: | 470 | case SwitchEvent::State::On: | ||
487 | switchState = i18nc("The hardware switch got turned on", "On"); | 471 | switchState = i18nc("The hardware switch got turned on", "On"); | ||
488 | break; | 472 | break; | ||
Show All 11 Lines | 483 | DebugConsole::DebugConsole() | |||
500 | : QWidget() | 484 | : QWidget() | ||
501 | , m_ui(new Ui::DebugConsole) | 485 | , m_ui(new Ui::DebugConsole) | ||
502 | { | 486 | { | ||
503 | setAttribute(Qt::WA_ShowWithoutActivating); | 487 | setAttribute(Qt::WA_ShowWithoutActivating); | ||
504 | m_ui->setupUi(this); | 488 | m_ui->setupUi(this); | ||
505 | m_ui->windowsView->setItemDelegate(new DebugConsoleDelegate(this)); | 489 | m_ui->windowsView->setItemDelegate(new DebugConsoleDelegate(this)); | ||
506 | m_ui->windowsView->setModel(new DebugConsoleModel(this)); | 490 | m_ui->windowsView->setModel(new DebugConsoleModel(this)); | ||
507 | m_ui->surfacesView->setModel(new SurfaceTreeModel(this)); | 491 | m_ui->surfacesView->setModel(new SurfaceTreeModel(this)); | ||
508 | #if HAVE_INPUT | | |||
509 | if (kwinApp()->usesLibinput()) { | 492 | if (kwinApp()->usesLibinput()) { | ||
510 | m_ui->inputDevicesView->setModel(new InputDeviceModel(this)); | 493 | m_ui->inputDevicesView->setModel(new InputDeviceModel(this)); | ||
511 | m_ui->inputDevicesView->setItemDelegate(new DebugConsoleDelegate(this)); | 494 | m_ui->inputDevicesView->setItemDelegate(new DebugConsoleDelegate(this)); | ||
512 | } | 495 | } | ||
513 | #endif | | |||
514 | m_ui->quitButton->setIcon(QIcon::fromTheme(QStringLiteral("application-exit"))); | 496 | m_ui->quitButton->setIcon(QIcon::fromTheme(QStringLiteral("application-exit"))); | ||
515 | m_ui->tabWidget->setTabIcon(0, QIcon::fromTheme(QStringLiteral("view-list-tree"))); | 497 | m_ui->tabWidget->setTabIcon(0, QIcon::fromTheme(QStringLiteral("view-list-tree"))); | ||
516 | m_ui->tabWidget->setTabIcon(1, QIcon::fromTheme(QStringLiteral("view-list-tree"))); | 498 | m_ui->tabWidget->setTabIcon(1, QIcon::fromTheme(QStringLiteral("view-list-tree"))); | ||
517 | 499 | | |||
518 | if (kwinApp()->operationMode() == Application::OperationMode::OperationModeX11) { | 500 | if (kwinApp()->operationMode() == Application::OperationMode::OperationModeX11) { | ||
519 | m_ui->tabWidget->setTabEnabled(1, false); | 501 | m_ui->tabWidget->setTabEnabled(1, false); | ||
520 | m_ui->tabWidget->setTabEnabled(2, false); | 502 | m_ui->tabWidget->setTabEnabled(2, false); | ||
521 | } | 503 | } | ||
▲ Show 20 Lines • Show All 881 Lines • ▼ Show 20 Line(s) | 1384 | if (buffer->shmBuffer()) { | |||
1403 | return buffer->data().scaled(QSize(64, 64), Qt::KeepAspectRatio); | 1385 | return buffer->data().scaled(QSize(64, 64), Qt::KeepAspectRatio); | ||
1404 | } | 1386 | } | ||
1405 | } | 1387 | } | ||
1406 | } | 1388 | } | ||
1407 | } | 1389 | } | ||
1408 | return QVariant(); | 1390 | return QVariant(); | ||
1409 | } | 1391 | } | ||
1410 | 1392 | | |||
1411 | #if HAVE_INPUT | | |||
1412 | InputDeviceModel::InputDeviceModel(QObject *parent) | 1393 | InputDeviceModel::InputDeviceModel(QObject *parent) | ||
1413 | : QAbstractItemModel(parent) | 1394 | : QAbstractItemModel(parent) | ||
1414 | , m_devices(LibInput::Connection::self()->devices()) | 1395 | , m_devices(LibInput::Connection::self()->devices()) | ||
1415 | { | 1396 | { | ||
1416 | for (auto it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) { | 1397 | for (auto it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) { | ||
1417 | setupDeviceConnections(*it); | 1398 | setupDeviceConnections(*it); | ||
1418 | } | 1399 | } | ||
1419 | auto c = LibInput::Connection::self(); | 1400 | auto c = LibInput::Connection::self(); | ||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 1516 | connect(device, &LibInput::Device::pointerAccelerationChanged, this, | |||
1536 | [this, device] { | 1517 | [this, device] { | ||
1537 | const QModelIndex parent = index(m_devices.indexOf(device), 0, QModelIndex()); | 1518 | const QModelIndex parent = index(m_devices.indexOf(device), 0, QModelIndex()); | ||
1538 | const QModelIndex child = index(device->metaObject()->indexOfProperty("pointerAcceleration"), 1, parent); | 1519 | const QModelIndex child = index(device->metaObject()->indexOfProperty("pointerAcceleration"), 1, parent); | ||
1539 | emit dataChanged(child, child, QVector<int>{Qt::DisplayRole}); | 1520 | emit dataChanged(child, child, QVector<int>{Qt::DisplayRole}); | ||
1540 | } | 1521 | } | ||
1541 | ); | 1522 | ); | ||
1542 | } | 1523 | } | ||
1543 | 1524 | | |||
1544 | #endif | | |||
1545 | | ||||
1546 | } | 1525 | } |