diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-11 17:13:20 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-05-14 23:13:35 +0100 |
| commit | 7eeee2c94e882a5df1914234df0571b221f9aa35 (patch) | |
| tree | 51099a811781579c68724b4a0d6fe5bb4ab87a02 /src/managers/SeatManager.cpp | |
| parent | fc72df8e58bc127442a245f2f29a3246acf77cce (diff) | |
wl-data-device: move to hyprland impl
Diffstat (limited to 'src/managers/SeatManager.cpp')
| -rw-r--r-- | src/managers/SeatManager.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index d962dd84..76840bd3 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -1,5 +1,6 @@ #include "SeatManager.hpp" #include "../protocols/core/Seat.hpp" +#include "../protocols/core/DataDevice.hpp" #include "../Compositor.hpp" #include "../devices/IKeyboard.hpp" #include <algorithm> @@ -222,6 +223,8 @@ void CSeatManager::sendPointerMotion(uint32_t timeMs, const Vector2D& local) { p->sendMotion(timeMs, local); } + + lastLocalCoords = local; } void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_button_state state_) { @@ -424,6 +427,28 @@ SP<CWLSeatResource> CSeatManager::seatResourceForClient(wl_client* client) { return PROTO::seat->seatResourceForClient(client); } +void CSeatManager::setCurrentSelection(SP<IDataSource> source) { + if (source == selection.currentSelection) { + Debug::log(WARN, "[seat] duplicated setCurrentSelection?"); + return; + } + + selection.destroySelection.reset(); + + if (selection.currentSelection) + selection.currentSelection->cancelled(); + + if (!source) + PROTO::data->setSelection(nullptr); + + selection.currentSelection = source; + + if (source) { + selection.destroySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); }); + PROTO::data->setSelection(source); + } +} + void CSeatManager::setGrab(SP<CSeatGrab> grab) { if (seatGrab) { auto oldGrab = seatGrab; @@ -441,6 +466,19 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) { refocusGrab(); } +void CSeatManager::resendEnterEvents() { + wlr_surface* kb = state.keyboardFocus; + wlr_surface* pt = state.pointerFocus; + + auto last = lastLocalCoords; + + setKeyboardFocus(nullptr); + setPointerFocus(nullptr, {}); + + setKeyboardFocus(kb); + setPointerFocus(pt, last); +} + bool CSeatGrab::accepts(wlr_surface* surf) { return std::find(surfs.begin(), surfs.end(), surf) != surfs.end(); } |
