Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show All 40 Lines | |||||
41 | #include "workspace.h" | 41 | #include "workspace.h" | ||
42 | #include "libinput/connection.h" | 42 | #include "libinput/connection.h" | ||
43 | #include "libinput/device.h" | 43 | #include "libinput/device.h" | ||
44 | #include "platform.h" | 44 | #include "platform.h" | ||
45 | #include "popup_input_filter.h" | 45 | #include "popup_input_filter.h" | ||
46 | #include "shell_client.h" | 46 | #include "shell_client.h" | ||
47 | #include "wayland_server.h" | 47 | #include "wayland_server.h" | ||
48 | #include "xwl/xwayland_interface.h" | 48 | #include "xwl/xwayland_interface.h" | ||
49 | #include "internal_client.h" | ||||
49 | #include <KWayland/Server/display.h> | 50 | #include <KWayland/Server/display.h> | ||
50 | #include <KWayland/Server/fakeinput_interface.h> | 51 | #include <KWayland/Server/fakeinput_interface.h> | ||
51 | #include <KWayland/Server/seat_interface.h> | 52 | #include <KWayland/Server/seat_interface.h> | ||
52 | #include <KWayland/Server/relativepointer_interface.h> | 53 | #include <KWayland/Server/relativepointer_interface.h> | ||
53 | #include <decorations/decoratedclient.h> | 54 | #include <decorations/decoratedclient.h> | ||
54 | #include <KDecoration2/Decoration> | 55 | #include <KDecoration2/Decoration> | ||
55 | #include <KGlobalAccel> | 56 | #include <KGlobalAccel> | ||
56 | 57 | | |||
▲ Show 20 Lines • Show All 756 Lines • ▼ Show 20 Line(s) | 811 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | |||
813 | if (!internal) { | 814 | if (!internal) { | ||
814 | return false; | 815 | return false; | ||
815 | } | 816 | } | ||
816 | // find client | 817 | // find client | ||
817 | switch (event->type()) | 818 | switch (event->type()) | ||
818 | { | 819 | { | ||
819 | case QEvent::MouseButtonPress: | 820 | case QEvent::MouseButtonPress: | ||
820 | case QEvent::MouseButtonRelease: { | 821 | case QEvent::MouseButtonRelease: { | ||
821 | auto s = waylandServer()->findClient(internal); | 822 | auto s = qobject_cast<InternalClient *>(workspace()->findInternal(internal)); | ||
822 | if (s && s->isDecorated()) { | 823 | if (s && s->isDecorated()) { | ||
823 | // only perform mouse commands on decorated internal windows | 824 | // only perform mouse commands on decorated internal windows | ||
824 | const auto actionResult = performClientMouseAction(event, s); | 825 | const auto actionResult = performClientMouseAction(event, s); | ||
825 | if (actionResult.first) { | 826 | if (actionResult.first) { | ||
826 | return actionResult.second; | 827 | return actionResult.second; | ||
827 | } | 828 | } | ||
828 | } | 829 | } | ||
829 | break; | 830 | break; | ||
Show All 10 Lines | |||||
840 | return e.isAccepted(); | 841 | return e.isAccepted(); | ||
841 | } | 842 | } | ||
842 | bool wheelEvent(QWheelEvent *event) override { | 843 | bool wheelEvent(QWheelEvent *event) override { | ||
843 | auto internal = input()->pointer()->internalWindow(); | 844 | auto internal = input()->pointer()->internalWindow(); | ||
844 | if (!internal) { | 845 | if (!internal) { | ||
845 | return false; | 846 | return false; | ||
846 | } | 847 | } | ||
847 | if (event->angleDelta().y() != 0) { | 848 | if (event->angleDelta().y() != 0) { | ||
848 | auto s = waylandServer()->findClient(internal); | 849 | auto s = qobject_cast<InternalClient *>(workspace()->findInternal(internal)); | ||
849 | if (s && s->isDecorated()) { | 850 | if (s && s->isDecorated()) { | ||
850 | // client window action only on vertical scrolling | 851 | // client window action only on vertical scrolling | ||
851 | const auto actionResult = performClientWheelAction(event, s); | 852 | const auto actionResult = performClientWheelAction(event, s); | ||
852 | if (actionResult.first) { | 853 | if (actionResult.first) { | ||
853 | return actionResult.second; | 854 | return actionResult.second; | ||
854 | } | 855 | } | ||
855 | } | 856 | } | ||
856 | } | 857 | } | ||
857 | const QPointF localPos = event->globalPosF() - QPointF(internal->x(), internal->y()); | 858 | const QPointF localPos = event->globalPosF() - QPointF(internal->x(), internal->y()); | ||
858 | const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical; | 859 | const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical; | ||
859 | const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y(); | 860 | const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y(); | ||
860 | QWheelEvent e(localPos, event->globalPosF(), QPoint(), | 861 | QWheelEvent e(localPos, event->globalPosF(), QPoint(), | ||
861 | event->angleDelta() * -1, | 862 | event->angleDelta() * -1, | ||
862 | delta * -1, | 863 | delta * -1, | ||
863 | orientation, | 864 | orientation, | ||
864 | event->buttons(), | 865 | event->buttons(), | ||
865 | event->modifiers()); | 866 | event->modifiers()); | ||
866 | e.setAccepted(false); | 867 | e.setAccepted(false); | ||
867 | QCoreApplication::sendEvent(internal.data(), &e); | 868 | QCoreApplication::sendEvent(internal.data(), &e); | ||
868 | return e.isAccepted(); | 869 | return e.isAccepted(); | ||
869 | } | 870 | } | ||
870 | bool keyEvent(QKeyEvent *event) override { | 871 | bool keyEvent(QKeyEvent *event) override { | ||
871 | const auto &internalClients = waylandServer()->internalClients(); | 872 | const QList<InternalClient *> &internalClients = workspace()->internalClients(); | ||
872 | if (internalClients.isEmpty()) { | 873 | if (internalClients.isEmpty()) { | ||
873 | return false; | 874 | return false; | ||
874 | } | 875 | } | ||
875 | QWindow *found = nullptr; | 876 | QWindow *found = nullptr; | ||
876 | auto it = internalClients.end(); | 877 | auto it = internalClients.end(); | ||
877 | do { | 878 | do { | ||
878 | it--; | 879 | it--; | ||
879 | if (QWindow *w = (*it)->internalWindow()) { | 880 | if (QWindow *w = (*it)->internalWindow()) { | ||
▲ Show 20 Lines • Show All 1442 Lines • ▼ Show 20 Line(s) | 2307 | { | |||
2322 | } | 2323 | } | ||
2323 | cleanupDecoration(oldDeco.data(), m_focus.decoration.data()); | 2324 | cleanupDecoration(oldDeco.data(), m_focus.decoration.data()); | ||
2324 | emit decorationChanged(); | 2325 | emit decorationChanged(); | ||
2325 | return true; | 2326 | return true; | ||
2326 | } | 2327 | } | ||
2327 | 2328 | | |||
2328 | void InputDeviceHandler::updateInternalWindow(QWindow *window) | 2329 | void InputDeviceHandler::updateInternalWindow(QWindow *window) | ||
2329 | { | 2330 | { | ||
2330 | if (m_focus.internalWindow == window) { | 2331 | if (internalWindow() == window) { | ||
2331 | // no change | 2332 | // no change | ||
2332 | return; | 2333 | return; | ||
2333 | } | 2334 | } | ||
2334 | const auto oldInternal = m_focus.internalWindow; | 2335 | QWindow *oldInternal = internalWindow(); | ||
2335 | m_focus.internalWindow = window; | 2336 | setInternalWindow(window); | ||
2336 | cleanupInternalWindow(oldInternal, window); | 2337 | cleanupInternalWindow(oldInternal, window); | ||
2337 | } | 2338 | } | ||
2338 | 2339 | | |||
2339 | void InputDeviceHandler::update() | 2340 | void InputDeviceHandler::update() | ||
2340 | { | 2341 | { | ||
2341 | if (!m_inited) { | 2342 | if (!m_inited) { | ||
2342 | return; | 2343 | return; | ||
2343 | } | 2344 | } | ||
2344 | 2345 | | |||
2345 | Toplevel *toplevel = nullptr; | 2346 | Toplevel *toplevel = nullptr; | ||
2346 | QWindow *internalWindow = nullptr; | 2347 | QWindow *internalWindow = nullptr; | ||
2347 | 2348 | | |||
2348 | if (!positionValid()) { | 2349 | if (!positionValid()) { | ||
2349 | const auto pos = position().toPoint(); | 2350 | const auto pos = position().toPoint(); | ||
2350 | internalWindow = findInternalWindow(pos); | 2351 | internalWindow = findInternalWindow(pos); | ||
2351 | if (internalWindow) { | 2352 | if (internalWindow) { | ||
2352 | toplevel = waylandServer()->findClient(internalWindow); | 2353 | toplevel = workspace()->findInternal(internalWindow); | ||
2353 | } else { | 2354 | } else { | ||
2354 | toplevel = input()->findToplevel(pos); | 2355 | toplevel = input()->findToplevel(pos); | ||
2355 | } | 2356 | } | ||
2356 | } | 2357 | } | ||
2357 | // Always set the toplevel at the position of the input device. | 2358 | // Always set the toplevel at the position of the input device. | ||
2358 | setAt(toplevel); | 2359 | setAt(toplevel); | ||
2359 | 2360 | | |||
2360 | if (focusUpdatesBlocked()) { | 2361 | if (focusUpdatesBlocked()) { | ||
Show All 28 Lines | |||||
2389 | } | 2390 | } | ||
2390 | 2391 | | |||
2391 | QWindow* InputDeviceHandler::findInternalWindow(const QPoint &pos) const | 2392 | QWindow* InputDeviceHandler::findInternalWindow(const QPoint &pos) const | ||
2392 | { | 2393 | { | ||
2393 | if (waylandServer()->isScreenLocked()) { | 2394 | if (waylandServer()->isScreenLocked()) { | ||
2394 | return nullptr; | 2395 | return nullptr; | ||
2395 | } | 2396 | } | ||
2396 | 2397 | | |||
2397 | const auto &internalClients = waylandServer()->internalClients(); | 2398 | const QList<InternalClient *> &internalClients = workspace()->internalClients(); | ||
2398 | if (internalClients.isEmpty()) { | 2399 | if (internalClients.isEmpty()) { | ||
2399 | return nullptr; | 2400 | return nullptr; | ||
2400 | } | 2401 | } | ||
2401 | 2402 | | |||
2402 | auto it = internalClients.end(); | 2403 | auto it = internalClients.end(); | ||
2403 | do { | 2404 | do { | ||
2404 | --it; | 2405 | --it; | ||
2405 | QWindow *w = (*it)->internalWindow(); | 2406 | QWindow *w = (*it)->internalWindow(); | ||
Show All 21 Lines |