Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show All 14 Lines | |||||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | 17 | GNU General Public License for more details. | ||
18 | 18 | | |||
19 | You should have received a copy of the GNU General Public License | 19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | *********************************************************************/ | 21 | *********************************************************************/ | ||
22 | #include "input.h" | 22 | #include "input.h" | ||
23 | #include "effects.h" | ||||
24 | #include "gestures.h" | ||||
25 | #include "globalshortcuts.h" | ||||
23 | #include "input_event.h" | 26 | #include "input_event.h" | ||
24 | #include "input_event_spy.h" | 27 | #include "input_event_spy.h" | ||
25 | #include "keyboard_input.h" | 28 | #include "keyboard_input.h" | ||
29 | #include "logind.h" | ||||
30 | #include "main.h" | ||||
26 | #include "pointer_input.h" | 31 | #include "pointer_input.h" | ||
27 | #include "touch_input.h" | 32 | #include "tablet_input.h" | ||
28 | #include "touch_hide_cursor_spy.h" | 33 | #include "touch_hide_cursor_spy.h" | ||
34 | #include "touch_input.h" | ||||
29 | #include "x11client.h" | 35 | #include "x11client.h" | ||
30 | #include "effects.h" | | |||
31 | #include "gestures.h" | | |||
32 | #include "globalshortcuts.h" | | |||
33 | #include "logind.h" | | |||
34 | #include "main.h" | | |||
35 | #ifdef KWIN_BUILD_TABBOX | 36 | #ifdef KWIN_BUILD_TABBOX | ||
36 | #include "tabbox/tabbox.h" | 37 | #include "tabbox/tabbox.h" | ||
37 | #endif | 38 | #endif | ||
38 | #include "unmanaged.h" | 39 | #include "unmanaged.h" | ||
39 | #include "screenedge.h" | 40 | #include "screenedge.h" | ||
40 | #include "screens.h" | 41 | #include "screens.h" | ||
41 | #include "workspace.h" | 42 | #include "workspace.h" | ||
42 | #include "libinput/connection.h" | 43 | #include "libinput/connection.h" | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | |||||
171 | } | 172 | } | ||
172 | 173 | | |||
173 | bool InputEventFilter::switchEvent(SwitchEvent *event) | 174 | bool InputEventFilter::switchEvent(SwitchEvent *event) | ||
174 | { | 175 | { | ||
175 | Q_UNUSED(event) | 176 | Q_UNUSED(event) | ||
176 | return false; | 177 | return false; | ||
177 | } | 178 | } | ||
178 | 179 | | |||
180 | bool InputEventFilter::tabletToolEvent(QTabletEvent *event) | ||||
181 | { | ||||
182 | Q_UNUSED(event) | ||||
183 | return false; | ||||
184 | } | ||||
185 | | ||||
186 | bool InputEventFilter::tabletToolButtonEvent(const QSet<uint> &pressedButtons) | ||||
187 | { | ||||
188 | Q_UNUSED(pressedButtons) | ||||
189 | return false; | ||||
190 | } | ||||
191 | | ||||
192 | bool InputEventFilter::tabletPadButtonEvent(const QSet<uint> &pressedButtons) | ||||
193 | { | ||||
194 | Q_UNUSED(pressedButtons) | ||||
195 | return false; | ||||
196 | } | ||||
197 | | ||||
198 | bool InputEventFilter::tabletPadStripEvent(int number, int position, bool isFinger) | ||||
199 | { | ||||
200 | Q_UNUSED(number) | ||||
201 | Q_UNUSED(position) | ||||
202 | Q_UNUSED(isFinger) | ||||
203 | return false; | ||||
204 | } | ||||
205 | | ||||
206 | bool InputEventFilter::tabletPadRingEvent(int number, int position, bool isFinger) | ||||
207 | { | ||||
208 | Q_UNUSED(number) | ||||
209 | Q_UNUSED(position) | ||||
210 | Q_UNUSED(isFinger) | ||||
211 | return false; | ||||
212 | } | ||||
213 | | ||||
179 | void InputEventFilter::passToWaylandServer(QKeyEvent *event) | 214 | void InputEventFilter::passToWaylandServer(QKeyEvent *event) | ||
180 | { | 215 | { | ||
181 | Q_ASSERT(waylandServer()); | 216 | Q_ASSERT(waylandServer()); | ||
182 | if (event->isAutoRepeat()) { | 217 | if (event->isAutoRepeat()) { | ||
183 | return; | 218 | return; | ||
184 | } | 219 | } | ||
185 | switch (event->type()) { | 220 | switch (event->type()) { | ||
186 | case QEvent::KeyPress: | 221 | case QEvent::KeyPress: | ||
▲ Show 20 Lines • Show All 1310 Lines • ▼ Show 20 Line(s) | 1531 | if (seat->isDragTouch()) { | |||
1497 | return true; | 1532 | return true; | ||
1498 | } | 1533 | } | ||
1499 | seat->setTimestamp(event->timestamp()); | 1534 | seat->setTimestamp(event->timestamp()); | ||
1500 | switch (event->type()) { | 1535 | switch (event->type()) { | ||
1501 | case QEvent::MouseMove: { | 1536 | case QEvent::MouseMove: { | ||
1502 | const auto pos = input()->globalPointer(); | 1537 | const auto pos = input()->globalPointer(); | ||
1503 | seat->setPointerPos(pos); | 1538 | seat->setPointerPos(pos); | ||
1504 | 1539 | | |||
1505 | const auto eventPos = event->globalPos(); | 1540 | const auto eventPos = event->globalPos(); | ||
romangg: unused | |||||
1506 | // TODO: use InputDeviceHandler::at() here and check isClient()? | 1541 | // TODO: use InputDeviceHandler::at() here and check isClient()? | ||
1507 | Toplevel *t = input()->findManagedToplevel(eventPos); | 1542 | Toplevel *t = input()->findManagedToplevel(eventPos); | ||
1508 | if (auto *xwl = xwayland()) { | 1543 | if (auto *xwl = xwayland()) { | ||
1509 | const auto ret = xwl->dragMoveFilter(t, eventPos); | 1544 | const auto ret = xwl->dragMoveFilter(t, eventPos); | ||
1510 | if (ret == Xwl::DragEventReply::Ignore) { | 1545 | if (ret == Xwl::DragEventReply::Ignore) { | ||
1511 | return false; | 1546 | return false; | ||
1512 | } else if (ret == Xwl::DragEventReply::Take) { | 1547 | } else if (ret == Xwl::DragEventReply::Take) { | ||
1513 | break; | 1548 | break; | ||
1514 | } | 1549 | } | ||
1515 | } | 1550 | } | ||
1516 | 1551 | | |||
1517 | if (t) { | 1552 | if (t) { | ||
1518 | // TODO: consider decorations | 1553 | // TODO: consider decorations | ||
1519 | if (t->surface() != seat->dragSurface()) { | 1554 | if (t->surface() != seat->dragSurface()) { | ||
1520 | if (AbstractClient *c = qobject_cast<AbstractClient*>(t)) { | 1555 | if (AbstractClient *c = qobject_cast<AbstractClient*>(t)) { | ||
1521 | workspace()->activateClient(c); | 1556 | workspace()->activateClient(c); | ||
1522 | } | 1557 | } | ||
1523 | seat->setDragTarget(t->surface(), t->inputTransformation()); | 1558 | seat->setDragTarget(t->surface(), t->inputTransformation()); | ||
1524 | } | 1559 | } | ||
1525 | } else { | 1560 | } else { | ||
1526 | // no window at that place, if we have a surface we need to reset | 1561 | // no window at that place, if we have a surface we need to reset | ||
1527 | seat->setDragTarget(nullptr); | 1562 | seat->setDragTarget(nullptr); | ||
1528 | } | 1563 | } | ||
romangg: There is a `input()->pointer()` getter. Remove member variable. | |||||
1529 | break; | 1564 | break; | ||
1530 | } | 1565 | } | ||
1531 | case QEvent::MouseButtonPress: | 1566 | case QEvent::MouseButtonPress: | ||
1532 | seat->pointerButtonPressed(nativeButton); | 1567 | seat->pointerButtonPressed(nativeButton); | ||
1533 | break; | 1568 | break; | ||
1534 | case QEvent::MouseButtonRelease: | 1569 | case QEvent::MouseButtonRelease: | ||
1535 | seat->pointerButtonReleased(nativeButton); | 1570 | seat->pointerButtonReleased(nativeButton); | ||
1536 | break; | 1571 | break; | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | |||||
1618 | KWIN_SINGLETON_FACTORY(InputRedirection) | 1653 | KWIN_SINGLETON_FACTORY(InputRedirection) | ||
1619 | 1654 | | |||
1620 | static const QString s_touchpadComponent = QStringLiteral("kcm_touchpad"); | 1655 | static const QString s_touchpadComponent = QStringLiteral("kcm_touchpad"); | ||
1621 | 1656 | | |||
1622 | InputRedirection::InputRedirection(QObject *parent) | 1657 | InputRedirection::InputRedirection(QObject *parent) | ||
1623 | : QObject(parent) | 1658 | : QObject(parent) | ||
1624 | , m_keyboard(new KeyboardInputRedirection(this)) | 1659 | , m_keyboard(new KeyboardInputRedirection(this)) | ||
1625 | , m_pointer(new PointerInputRedirection(this)) | 1660 | , m_pointer(new PointerInputRedirection(this)) | ||
1661 | , m_tablet(new TabletInputRedirection(this)) | ||||
1626 | , m_touch(new TouchInputRedirection(this)) | 1662 | , m_touch(new TouchInputRedirection(this)) | ||
1627 | , m_shortcuts(new GlobalShortcutsManager(this)) | 1663 | , m_shortcuts(new GlobalShortcutsManager(this)) | ||
1628 | { | 1664 | { | ||
1629 | qRegisterMetaType<KWin::InputRedirection::KeyboardKeyState>(); | 1665 | qRegisterMetaType<KWin::InputRedirection::KeyboardKeyState>(); | ||
1630 | qRegisterMetaType<KWin::InputRedirection::PointerButtonState>(); | 1666 | qRegisterMetaType<KWin::InputRedirection::PointerButtonState>(); | ||
1631 | qRegisterMetaType<KWin::InputRedirection::PointerAxis>(); | 1667 | qRegisterMetaType<KWin::InputRedirection::PointerAxis>(); | ||
1632 | if (Application::usesLibinput()) { | 1668 | if (Application::usesLibinput()) { | ||
1633 | if (LogindIntegration::self()->hasSessionControl()) { | 1669 | if (LogindIntegration::self()->hasSessionControl()) { | ||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Line(s) | 1753 | connect(device, &FakeInputDevice::pointerMotionAbsoluteRequested, this, | |||
1802 | ); | 1838 | ); | ||
1803 | } | 1839 | } | ||
1804 | ); | 1840 | ); | ||
1805 | connect(workspace(), &Workspace::configChanged, this, &InputRedirection::reconfigure); | 1841 | connect(workspace(), &Workspace::configChanged, this, &InputRedirection::reconfigure); | ||
1806 | 1842 | | |||
1807 | m_keyboard->init(); | 1843 | m_keyboard->init(); | ||
1808 | m_pointer->init(); | 1844 | m_pointer->init(); | ||
1809 | m_touch->init(); | 1845 | m_touch->init(); | ||
1846 | m_tablet->init(); | ||||
1810 | } | 1847 | } | ||
1811 | setupInputFilters(); | 1848 | setupInputFilters(); | ||
1812 | } | 1849 | } | ||
1813 | 1850 | | |||
1814 | void InputRedirection::setupInputFilters() | 1851 | void InputRedirection::setupInputFilters() | ||
1815 | { | 1852 | { | ||
1816 | const bool hasGlobalShortcutSupport = !waylandServer() || waylandServer()->hasGlobalShortcutSupport(); | 1853 | const bool hasGlobalShortcutSupport = !waylandServer() || waylandServer()->hasGlobalShortcutSupport(); | ||
1817 | if (LogindIntegration::self()->hasSessionControl() && hasGlobalShortcutSupport) { | 1854 | if (LogindIntegration::self()->hasSessionControl() && hasGlobalShortcutSupport) { | ||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 1965 | auto handleSwitchEvent = [this] (SwitchEvent::State state, quint32 time, quint64 timeMicroseconds, LibInput::Device *device) { | |||
1929 | SwitchEvent event(state, time, timeMicroseconds, device); | 1966 | SwitchEvent event(state, time, timeMicroseconds, device); | ||
1930 | processSpies(std::bind(&InputEventSpy::switchEvent, std::placeholders::_1, &event)); | 1967 | processSpies(std::bind(&InputEventSpy::switchEvent, std::placeholders::_1, &event)); | ||
1931 | processFilters(std::bind(&InputEventFilter::switchEvent, std::placeholders::_1, &event)); | 1968 | processFilters(std::bind(&InputEventFilter::switchEvent, std::placeholders::_1, &event)); | ||
1932 | }; | 1969 | }; | ||
1933 | connect(conn, &LibInput::Connection::switchToggledOn, this, | 1970 | connect(conn, &LibInput::Connection::switchToggledOn, this, | ||
1934 | std::bind(handleSwitchEvent, SwitchEvent::State::On, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); | 1971 | std::bind(handleSwitchEvent, SwitchEvent::State::On, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); | ||
1935 | connect(conn, &LibInput::Connection::switchToggledOff, this, | 1972 | connect(conn, &LibInput::Connection::switchToggledOff, this, | ||
1936 | std::bind(handleSwitchEvent, SwitchEvent::State::Off, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); | 1973 | std::bind(handleSwitchEvent, SwitchEvent::State::Off, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); | ||
1974 | | ||||
1975 | connect(conn, &LibInput::Connection::tabletToolEvent, | ||||
romangg: These lines are still longer than 100 chars. | |||||
romangg: clang-format stupid | |||||
1976 | m_tablet, &TabletInputRedirection::tabletToolEvent); | ||||
1977 | connect(conn, &LibInput::Connection::tabletToolButtonEvent, | ||||
1978 | m_tablet, &TabletInputRedirection::tabletToolButtonEvent); | ||||
1979 | connect(conn, &LibInput::Connection::tabletPadButtonEvent, | ||||
1980 | m_tablet, &TabletInputRedirection::tabletPadButtonEvent); | ||||
1981 | connect(conn, &LibInput::Connection::tabletPadRingEvent, | ||||
1982 | m_tablet, &TabletInputRedirection::tabletPadRingEvent); | ||||
1983 | connect(conn, &LibInput::Connection::tabletPadStripEvent, | ||||
1984 | m_tablet, &TabletInputRedirection::tabletPadStripEvent); | ||||
1985 | | ||||
1937 | if (screens()) { | 1986 | if (screens()) { | ||
1938 | setupLibInputWithScreens(); | 1987 | setupLibInputWithScreens(); | ||
1939 | } else { | 1988 | } else { | ||
1940 | connect(kwinApp(), &Application::screensCreated, this, &InputRedirection::setupLibInputWithScreens); | 1989 | connect(kwinApp(), &Application::screensCreated, this, &InputRedirection::setupLibInputWithScreens); | ||
1941 | } | 1990 | } | ||
1942 | if (auto s = findSeat()) { | 1991 | if (auto s = findSeat()) { | ||
1943 | // Workaround for QTBUG-54371: if there is no real keyboard Qt doesn't request virtual keyboard | 1992 | // Workaround for QTBUG-54371: if there is no real keyboard Qt doesn't request virtual keyboard | ||
1944 | s->setHasKeyboard(true); | 1993 | s->setHasKeyboard(true); | ||
▲ Show 20 Lines • Show All 503 Lines • Show Last 20 Lines |
unused