Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show First 20 Lines • Show All 392 Lines • ▼ Show 20 Line(s) | 380 | private: | |||
---|---|---|---|---|---|
393 | bool keyboardSurfaceAllowed() const { | 393 | bool keyboardSurfaceAllowed() const { | ||
394 | return surfaceAllowed(&KWayland::Server::SeatInterface::focusedKeyboardSurface); | 394 | return surfaceAllowed(&KWayland::Server::SeatInterface::focusedKeyboardSurface); | ||
395 | } | 395 | } | ||
396 | bool touchSurfaceAllowed() const { | 396 | bool touchSurfaceAllowed() const { | ||
397 | return surfaceAllowed(&KWayland::Server::SeatInterface::focusedTouchSurface); | 397 | return surfaceAllowed(&KWayland::Server::SeatInterface::focusedTouchSurface); | ||
398 | } | 398 | } | ||
399 | }; | 399 | }; | ||
400 | 400 | | |||
401 | class PointerConstraintsFilter : public InputEventFilter { | | |||
402 | public: | | |||
403 | explicit PointerConstraintsFilter() | | |||
404 | : InputEventFilter() | | |||
405 | , m_timer(new QTimer) | | |||
406 | { | | |||
407 | QObject::connect(m_timer.data(), &QTimer::timeout, | | |||
408 | [this] { | | |||
409 | if (waylandServer()) { | | |||
410 | // break keyboard focus, this cancels the pressed ESC | | |||
411 | waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); | | |||
412 | } | | |||
413 | input()->pointer()->breakPointerConstraints(); | | |||
414 | input()->pointer()->blockPointerConstraints(); | | |||
415 | // TODO: show notification | | |||
416 | waylandServer()->seat()->keyReleased(m_keyCode); | | |||
417 | cancel(); | | |||
418 | } | | |||
419 | ); | | |||
420 | } | | |||
421 | | ||||
422 | bool keyEvent(QKeyEvent *event) override { | | |||
423 | if (isActive()) { | | |||
424 | if (event->type() == QEvent::KeyPress) { | | |||
425 | // is that another key that gets pressed? | | |||
426 | if (!event->isAutoRepeat() && event->key() != Qt::Key_Escape) { | | |||
427 | cancel(); | | |||
428 | return false; | | |||
429 | } | | |||
430 | if (event->isAutoRepeat() && event->key() == Qt::Key_Escape) { | | |||
431 | // filter out | | |||
432 | return true; | | |||
433 | } | | |||
434 | } else { | | |||
435 | cancel(); | | |||
436 | return false; | | |||
437 | } | | |||
438 | } else if (input()->pointer()->isConstrained()) { | | |||
439 | if (event->type() == QEvent::KeyPress && | | |||
440 | event->key() == Qt::Key_Escape && | | |||
441 | static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts() == Qt::KeyboardModifiers()) { | | |||
442 | // TODO: don't hard code | | |||
443 | m_timer->start(3000); | | |||
444 | m_keyCode = event->nativeScanCode(); | | |||
445 | return false; | | |||
446 | } | | |||
447 | } | | |||
448 | return false; | | |||
449 | } | | |||
450 | | ||||
451 | void cancel() { | | |||
452 | if (!isActive()) { | | |||
453 | return; | | |||
454 | } | | |||
455 | m_timer->stop(); | | |||
456 | input()->keyboard()->update(); | | |||
457 | } | | |||
458 | | ||||
459 | bool isActive() const { | | |||
460 | return m_timer->isActive(); | | |||
461 | } | | |||
462 | | ||||
463 | private: | | |||
464 | QScopedPointer<QTimer> m_timer; | | |||
465 | int m_keyCode = 0; | | |||
466 | }; | | |||
467 | | ||||
468 | class EffectsFilter : public InputEventFilter { | 401 | class EffectsFilter : public InputEventFilter { | ||
469 | public: | 402 | public: | ||
470 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | 403 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | ||
471 | Q_UNUSED(nativeButton) | 404 | Q_UNUSED(nativeButton) | ||
472 | if (!effects) { | 405 | if (!effects) { | ||
473 | return false; | 406 | return false; | ||
474 | } | 407 | } | ||
475 | return static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(event); | 408 | return static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(event); | ||
▲ Show 20 Lines • Show All 1242 Lines • ▼ Show 20 Line(s) | 1650 | { | |||
1718 | if (LogindIntegration::self()->hasSessionControl()) { | 1651 | if (LogindIntegration::self()->hasSessionControl()) { | ||
1719 | installInputEventFilter(new VirtualTerminalFilter); | 1652 | installInputEventFilter(new VirtualTerminalFilter); | ||
1720 | } | 1653 | } | ||
1721 | if (waylandServer()) { | 1654 | if (waylandServer()) { | ||
1722 | installInputEventFilter(new TerminateServerFilter); | 1655 | installInputEventFilter(new TerminateServerFilter); | ||
1723 | installInputEventFilter(new DragAndDropInputFilter); | 1656 | installInputEventFilter(new DragAndDropInputFilter); | ||
1724 | installInputEventFilter(new LockScreenFilter); | 1657 | installInputEventFilter(new LockScreenFilter); | ||
1725 | installInputEventFilter(new PopupInputFilter); | 1658 | installInputEventFilter(new PopupInputFilter); | ||
1726 | m_pointerConstraintsFilter = new PointerConstraintsFilter; | | |||
1727 | installInputEventFilter(m_pointerConstraintsFilter); | | |||
1728 | m_windowSelector = new WindowSelectorFilter; | 1659 | m_windowSelector = new WindowSelectorFilter; | ||
1729 | installInputEventFilter(m_windowSelector); | 1660 | installInputEventFilter(m_windowSelector); | ||
1730 | } | 1661 | } | ||
1731 | installInputEventFilter(new ScreenEdgeInputFilter); | 1662 | installInputEventFilter(new ScreenEdgeInputFilter); | ||
1732 | installInputEventFilter(new EffectsFilter); | 1663 | installInputEventFilter(new EffectsFilter); | ||
1733 | installInputEventFilter(new MoveResizeFilter); | 1664 | installInputEventFilter(new MoveResizeFilter); | ||
1734 | #ifdef KWIN_BUILD_TABBOX | 1665 | #ifdef KWIN_BUILD_TABBOX | ||
1735 | installInputEventFilter(new TabBoxInputFilter); | 1666 | installInputEventFilter(new TabBoxInputFilter); | ||
▲ Show 20 Lines • Show All 400 Lines • ▼ Show 20 Line(s) | 2061 | { | |||
2136 | m_pointer->setWindowSelectionCursor(QByteArray()); | 2067 | m_pointer->setWindowSelectionCursor(QByteArray()); | ||
2137 | } | 2068 | } | ||
2138 | 2069 | | |||
2139 | bool InputRedirection::isSelectingWindow() const | 2070 | bool InputRedirection::isSelectingWindow() const | ||
2140 | { | 2071 | { | ||
2141 | return m_windowSelector ? m_windowSelector->isActive() : false; | 2072 | return m_windowSelector ? m_windowSelector->isActive() : false; | ||
2142 | } | 2073 | } | ||
2143 | 2074 | | |||
2144 | bool InputRedirection::isBreakingPointerConstraints() const | | |||
2145 | { | | |||
2146 | return m_pointerConstraintsFilter ? m_pointerConstraintsFilter->isActive() : false; | | |||
2147 | } | | |||
2148 | | ||||
2149 | InputDeviceHandler::InputDeviceHandler(InputRedirection *input) | 2075 | InputDeviceHandler::InputDeviceHandler(InputRedirection *input) | ||
2150 | : QObject(input) | 2076 | : QObject(input) | ||
2151 | , m_input(input) | 2077 | , m_input(input) | ||
2152 | { | 2078 | { | ||
2153 | } | 2079 | } | ||
2154 | 2080 | | |||
2155 | InputDeviceHandler::~InputDeviceHandler() = default; | 2081 | InputDeviceHandler::~InputDeviceHandler() = default; | ||
2156 | 2082 | | |||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |