From 7eeee2c94e882a5df1914234df0571b221f9aa35 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 11 May 2024 17:13:20 +0100 Subject: wl-data-device: move to hyprland impl --- src/managers/SeatManager.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/managers/SeatManager.cpp') 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 @@ -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 CSeatManager::seatResourceForClient(wl_client* client) { return PROTO::seat->seatResourceForClient(client); } +void CSeatManager::setCurrentSelection(SP 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 grab) { if (seatGrab) { auto oldGrab = seatGrab; @@ -441,6 +466,19 @@ void CSeatManager::setGrab(SP 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(); } -- cgit v1.2.3