diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-13 21:47:59 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-05-14 23:13:35 +0100 |
| commit | 94c20a186372aace78b188842848b873eb3ebbd7 (patch) | |
| tree | b7bc6aa3de054c2234d0db0836d720717b7354d6 /src/managers | |
| parent | 3eeaea5be9324121678774761c0226fe98bf7e5b (diff) | |
primary-selection: move to hyprland impl
Diffstat (limited to 'src/managers')
| -rw-r--r-- | src/managers/ProtocolManager.cpp | 2 | ||||
| -rw-r--r-- | src/managers/SeatManager.cpp | 26 | ||||
| -rw-r--r-- | src/managers/SeatManager.hpp | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index 4b03263b..c43e4c56 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -30,6 +30,7 @@ #include "../protocols/PresentationTime.hpp" #include "../protocols/XDGShell.hpp" #include "../protocols/DataDeviceWlr.hpp" +#include "../protocols/PrimarySelection.hpp" #include "../protocols/core/Seat.hpp" #include "../protocols/core/DataDevice.hpp" @@ -71,6 +72,7 @@ CProtocolManager::CProtocolManager() { PROTO::presentation = std::make_unique<CPresentationProtocol>(&wp_presentation_interface, 1, "Presentation"); PROTO::xdgShell = std::make_unique<CXDGShellProtocol>(&xdg_wm_base_interface, 6, "XDGShell"); PROTO::dataWlr = std::make_unique<CDataDeviceWLRProtocol>(&zwlr_data_control_manager_v1_interface, 2, "DataDeviceWlr"); + PROTO::primarySelection = std::make_unique<CPrimarySelectionProtocol>(&zwp_primary_selection_device_manager_v1_interface, 1, "PrimarySelection"); // Old protocol implementations. // TODO: rewrite them to use hyprwayland-scanner. diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index a8505610..3e2d595f 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -2,6 +2,7 @@ #include "../protocols/core/Seat.hpp" #include "../protocols/core/DataDevice.hpp" #include "../protocols/DataDeviceWlr.hpp" +#include "../protocols/PrimarySelection.hpp" #include "../Compositor.hpp" #include "../devices/IKeyboard.hpp" #include <algorithm> @@ -447,7 +448,30 @@ void CSeatManager::setCurrentSelection(SP<IDataSource> source) { if (source) { selection.destroySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); }); PROTO::data->setSelection(source); - PROTO::dataWlr->setSelection(source); + PROTO::dataWlr->setSelection(source, false); + } +} + +void CSeatManager::setCurrentPrimarySelection(SP<IDataSource> source) { + if (source == selection.currentPrimarySelection) { + Debug::log(WARN, "[seat] duplicated setCurrentPrimarySelection?"); + return; + } + + selection.destroyPrimarySelection.reset(); + + if (selection.currentPrimarySelection) + selection.currentPrimarySelection->cancelled(); + + if (!source) + PROTO::primarySelection->setSelection(nullptr); + + selection.currentPrimarySelection = source; + + if (source) { + selection.destroyPrimarySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentPrimarySelection(nullptr); }); + PROTO::primarySelection->setSelection(source); + PROTO::dataWlr->setSelection(source, true); } } diff --git a/src/managers/SeatManager.hpp b/src/managers/SeatManager.hpp index 81ca663d..f4efda70 100644 --- a/src/managers/SeatManager.hpp +++ b/src/managers/SeatManager.hpp @@ -109,9 +109,12 @@ class CSeatManager { struct { WP<IDataSource> currentSelection; CHyprSignalListener destroySelection; + WP<IDataSource> currentPrimarySelection; + CHyprSignalListener destroyPrimarySelection; } selection; void setCurrentSelection(SP<IDataSource> source); + void setCurrentPrimarySelection(SP<IDataSource> source); // do not write to directly, use set... WP<IPointer> mouse; |
