wl-data-device: move to hyprland impl
This commit is contained in:
parent
fc72df8e58
commit
7eeee2c94e
16 changed files with 963 additions and 171 deletions
|
|
@ -941,3 +941,7 @@ void CPointerManager::damageCursor(SP<CMonitor> pMonitor) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2D CPointerManager::cursorSizeLogical() {
|
||||
return currentCursorImage.size / currentCursorImage.scale;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class CPointerManager {
|
|||
|
||||
//
|
||||
Vector2D position();
|
||||
Vector2D cursorSizeLogical();
|
||||
|
||||
private:
|
||||
void recheckPointerPosition();
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue