summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-11 17:13:20 +0100
committerVaxry <vaxry@vaxry.net>2024-05-14 23:13:35 +0100
commit7eeee2c94e882a5df1914234df0571b221f9aa35 (patch)
tree51099a811781579c68724b4a0d6fe5bb4ab87a02 /src/managers
parentfc72df8e58bc127442a245f2f29a3246acf77cce (diff)
wl-data-device: move to hyprland impl
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/PointerManager.cpp4
-rw-r--r--src/managers/PointerManager.hpp1
-rw-r--r--src/managers/ProtocolManager.cpp5
-rw-r--r--src/managers/SeatManager.cpp38
-rw-r--r--src/managers/SeatManager.hpp12
-rw-r--r--src/managers/input/InputManager.cpp28
-rw-r--r--src/managers/input/InputManager.hpp3
7 files changed, 65 insertions, 26 deletions
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index 60d11e7f..6a0fb984 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -941,3 +941,7 @@ void CPointerManager::damageCursor(SP<CMonitor> pMonitor) {
return;
}
}
+
+Vector2D CPointerManager::cursorSizeLogical() {
+ return currentCursorImage.size / currentCursorImage.scale;
+}
diff --git a/src/managers/PointerManager.hpp b/src/managers/PointerManager.hpp
index 71ab0fc2..b6cb0c7a 100644
--- a/src/managers/PointerManager.hpp
+++ b/src/managers/PointerManager.hpp
@@ -52,6 +52,7 @@ class CPointerManager {
//
Vector2D position();
+ Vector2D cursorSizeLogical();
private:
void recheckPointerPosition();
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp
index e53eb111..8167103f 100644
--- a/src/managers/ProtocolManager.cpp
+++ b/src/managers/ProtocolManager.cpp
@@ -28,13 +28,16 @@
#include "../protocols/Tablet.hpp"
#include "../protocols/LayerShell.hpp"
#include "../protocols/PresentationTime.hpp"
-#include "../protocols/core/Seat.hpp"
#include "../protocols/XDGShell.hpp"
+#include "../protocols/core/Seat.hpp"
+#include "../protocols/core/DataDevice.hpp"
+
CProtocolManager::CProtocolManager() {
// Core
PROTO::seat = std::make_unique<CWLSeatProtocol>(&wl_seat_interface, 9, "WLSeat");
+ PROTO::data = std::make_unique<CWLDataDeviceProtocol>(&wl_data_device_manager_interface, 3, "WLDataDevice");
// Extensions
PROTO::tearing = std::make_unique<CTearingControlProtocol>(&wp_tearing_control_manager_v1_interface, 1, "TearingControl");
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();
}
diff --git a/src/managers/SeatManager.hpp b/src/managers/SeatManager.hpp
index 16f11ffd..81ca663d 100644
--- a/src/managers/SeatManager.hpp
+++ b/src/managers/SeatManager.hpp
@@ -5,6 +5,7 @@
#include "../macros.hpp"
#include "../helpers/signal/Signal.hpp"
#include "../helpers/Vector2D.hpp"
+#include "../protocols/types/DataDevice.hpp"
#include <vector>
constexpr size_t MAX_SERIAL_STORE_LEN = 100;
@@ -72,6 +73,8 @@ class CSeatManager {
void sendTouchShape(int32_t id, const Vector2D& shape);
void sendTouchOrientation(int32_t id, double angle);
+ void resendEnterEvents();
+
uint32_t nextSerial(SP<CWLSeatResource> seatResource);
// pops the serial if it was valid, meaning it is consumed.
bool serialValid(SP<CWLSeatResource> seatResource, uint32_t serial);
@@ -103,6 +106,13 @@ class CSeatManager {
CSignal setCursor; // SSetCursorEvent
} events;
+ struct {
+ WP<IDataSource> currentSelection;
+ CHyprSignalListener destroySelection;
+ } selection;
+
+ void setCurrentSelection(SP<IDataSource> source);
+
// do not write to directly, use set...
WP<IPointer> mouse;
WP<IKeyboard> keyboard;
@@ -132,6 +142,8 @@ class CSeatManager {
CHyprSignalListener newSeatResource;
} listeners;
+ Vector2D lastLocalCoords;
+
DYNLISTENER(keyboardSurfaceDestroy);
DYNLISTENER(pointerSurfaceDestroy);
DYNLISTENER(touchSurfaceDestroy);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index fe19c98f..d74657d9 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -15,6 +15,7 @@
#include "../../protocols/VirtualPointer.hpp"
#include "../../protocols/LayerShell.hpp"
#include "../../protocols/core/Seat.hpp"
+#include "../../protocols/core/DataDevice.hpp"
#include "../../protocols/XDGShell.hpp"
#include "../../devices/Mouse.hpp"
@@ -137,7 +138,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
static auto PRESIZECURSORICON = CConfigValue<Hyprlang::INT>("general:hover_icon_on_border");
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
- const auto FOLLOWMOUSE = *PFOLLOWONDND && m_sDrag.drag ? 1 : *PFOLLOWMOUSE;
+ const auto FOLLOWMOUSE = *PFOLLOWONDND && PROTO::data->dndActive() ? 1 : *PFOLLOWMOUSE;
m_pFoundSurfaceToFocus = nullptr;
m_pFoundLSToFocus.reset();
@@ -218,10 +219,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF, (uintptr_t)CONSTRAINT.get());
}
- // update stuff
- updateDragIcon();
-
- if (!m_sDrag.drag && !m_lCurrentlyHeldButtons.empty() && g_pCompositor->m_pLastFocus && g_pSeatManager->state.pointerFocus) {
+ // if we are holding a pointer button,
+ // and we're not dnd-ing, don't refocus. Keep focus on last surface.
+ if (!PROTO::data->dndActive() && !m_lCurrentlyHeldButtons.empty() && g_pCompositor->m_pLastFocus && g_pSeatManager->state.pointerFocus && !m_bHardInput) {
foundSurface = g_pSeatManager->state.pointerFocus;
pFoundLayerSurface = g_pCompositor->getLayerSurfaceFromSurface(foundSurface);
if (pFoundLayerSurface) {
@@ -1356,22 +1356,6 @@ void CInputManager::refocus() {
mouseMoveUnified(0, true);
}
-void CInputManager::updateDragIcon() {
- if (!m_sDrag.dragIcon)
- return;
-
- switch (m_sDrag.dragIcon->drag->grab_type) {
- case WLR_DRAG_GRAB_KEYBOARD: break;
- case WLR_DRAG_GRAB_KEYBOARD_POINTER: {
- CBox box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
- g_pHyprRenderer->damageBox(&box);
- m_sDrag.pos = getMouseCoordsInternal();
- break;
- }
- default: break;
- }
-}
-
void CInputManager::unconstrainMouse() {
if (g_pSeatManager->mouse.expired())
return;
@@ -1665,7 +1649,7 @@ std::string CInputManager::getNameForNewDevice(std::string internalName) {
void CInputManager::releaseAllMouseButtons() {
const auto buttonsCopy = m_lCurrentlyHeldButtons;
- if (g_pInputManager->m_sDrag.drag)
+ if (PROTO::data->dndActive())
return;
for (auto& mb : buttonsCopy) {
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 85efecb8..f7d9ae57 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -112,7 +112,6 @@ class CInputManager {
void setTouchDeviceConfigs(SP<ITouch> dev = nullptr);
void setTabletConfigs();
- void updateDragIcon();
void updateCapabilities();
void updateKeyboardsLeds(SP<IKeyboard>);
@@ -143,8 +142,6 @@ class CInputManager {
// for refocus to be forced
PHLWINDOWREF m_pForcedFocus;
- SDrag m_sDrag;
-
std::vector<SP<IKeyboard>> m_vKeyboards;
std::vector<SP<IPointer>> m_vPointers;
std::vector<SP<ITouch>> m_vTouches;