Added virtual pointer protocol

This commit is contained in:
vaxerski 2022-05-12 12:13:02 +02:00
parent ac7903f521
commit d438bd970a
7 changed files with 45 additions and 8 deletions

View file

@ -100,6 +100,8 @@ CCompositor::CCompositor() {
m_sWLRRelPointerMgr = wlr_relative_pointer_manager_v1_create(m_sWLDisplay); m_sWLRRelPointerMgr = wlr_relative_pointer_manager_v1_create(m_sWLDisplay);
m_sWLRVKeyboardMgr = wlr_virtual_keyboard_manager_v1_create(m_sWLDisplay); m_sWLRVKeyboardMgr = wlr_virtual_keyboard_manager_v1_create(m_sWLDisplay);
m_sWLRVirtPtrMgr = wlr_virtual_pointer_manager_v1_create(m_sWLDisplay);
} }
CCompositor::~CCompositor() { CCompositor::~CCompositor() {
@ -132,6 +134,7 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sWLRInhibitMgr->events.deactivate, &Events::listen_InhibitDeactivate, m_sWLRInhibitMgr, "InhibitMgr"); addWLSignal(&m_sWLRInhibitMgr->events.deactivate, &Events::listen_InhibitDeactivate, m_sWLRInhibitMgr, "InhibitMgr");
addWLSignal(&m_sWLRPointerConstraints->events.new_constraint, &Events::listen_newConstraint, m_sWLRPointerConstraints, "PointerConstraints"); addWLSignal(&m_sWLRPointerConstraints->events.new_constraint, &Events::listen_newConstraint, m_sWLRPointerConstraints, "PointerConstraints");
addWLSignal(&m_sWLRXDGDecoMgr->events.new_toplevel_decoration, &Events::listen_NewXDGDeco, m_sWLRXDGDecoMgr, "XDGDecoMgr"); addWLSignal(&m_sWLRXDGDecoMgr->events.new_toplevel_decoration, &Events::listen_NewXDGDeco, m_sWLRXDGDecoMgr, "XDGDecoMgr");
addWLSignal(&m_sWLRVirtPtrMgr->events.new_virtual_pointer, &Events::listen_newVirtPtr, m_sWLRVirtPtrMgr, "VirtPtrMgr");
signal(SIGINT, handleCritSignal); signal(SIGINT, handleCritSignal);
signal(SIGTERM, handleCritSignal); signal(SIGTERM, handleCritSignal);

View file

@ -55,6 +55,7 @@ public:
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr; wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
wlr_server_decoration_manager* m_sWLRServerDecoMgr; wlr_server_decoration_manager* m_sWLRServerDecoMgr;
wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr; wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr;
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
// ------------------------------------------------- // // ------------------------------------------------- //

View file

@ -117,3 +117,17 @@ void Events::listener_destroyConstraint(void* owner, void* data) {
void Events::listener_setConstraintRegion(void* owner, void* data) { void Events::listener_setConstraintRegion(void* owner, void* data) {
// no // no
} }
void Events::listener_newVirtPtr(wl_listener* listener, void* data) {
const auto EV = (wlr_virtual_pointer_v1_new_pointer_event*)data;
const auto POINTER = EV->new_pointer;
const auto DEVICE = &POINTER->pointer.base;
g_pInputManager->newMouse(DEVICE);
}
void Events::listener_destroyMouse(void* owner, void* data) {
const auto PMOUSE = (SMouse*)owner;
g_pInputManager->destroyMouse(PMOUSE->mouse);
}

View file

@ -62,6 +62,10 @@ namespace Events {
LISTENER(newInput); LISTENER(newInput);
// Virt Ptr
LISTENER(newVirtPtr);
DYNLISTENFUNC(destroyMouse);
DYNLISTENFUNC(keyboardKey); DYNLISTENFUNC(keyboardKey);
DYNLISTENFUNC(keyboardMod); DYNLISTENFUNC(keyboardMod);
DYNLISTENFUNC(keyboardDestroy); DYNLISTENFUNC(keyboardDestroy);

View file

@ -71,6 +71,7 @@ struct SMouse {
pixman_region32_t confinedTo; pixman_region32_t confinedTo;
DYNLISTENER(commitConstraint); DYNLISTENER(commitConstraint);
DYNLISTENER(destroyMouse);
bool operator==(const SMouse& b) { bool operator==(const SMouse& b) {
return mouse == b.mouse; return mouse == b.mouse;

View file

@ -72,6 +72,7 @@ extern "C" {
#include <wlr/types/wlr_output_damage.h> #include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_input_inhibitor.h> #include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/xwayland.h> #include <wlr/xwayland.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>

View file

@ -26,6 +26,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!g_pCompositor->m_bReadyToProcess) if (!g_pCompositor->m_bReadyToProcess)
return; return;
if (!g_pCompositor->m_sSeat.mouse) {
Debug::log(ERR, "BUG THIS: Mouse move on mouse nullptr!");
return;
}
// update stuff // update stuff
updateDragIcon(); updateDragIcon();
@ -139,6 +144,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (g_pCompositor->m_sSeat.mouse->currentConstraint) { if (g_pCompositor->m_sSeat.mouse->currentConstraint) {
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (!CONSTRAINTWINDOW) {
g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
} else {
const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec(); const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
@ -149,6 +157,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToMiddle.x, deltaToMiddle.y); wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToMiddle.x, deltaToMiddle.y);
} }
} }
}
} }
void CInputManager::onMouseButton(wlr_pointer_button_event* e) { void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
@ -283,6 +292,8 @@ void CInputManager::newMouse(wlr_input_device* mouse) {
} }
} }
PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse");
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse); wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
g_pCompositor->m_sSeat.mouse = PMOUSE; g_pCompositor->m_sSeat.mouse = PMOUSE;
@ -302,11 +313,13 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
for (auto& m : m_lMice) { for (auto& m : m_lMice) {
if (m.mouse == mouse) { if (m.mouse == mouse) {
m_lMice.remove(m); m_lMice.remove(m);
return; break;
} }
} }
g_pCompositor->m_sSeat.mouse = m_lMice.size() > 0 ? &m_lMice.front() : nullptr; g_pCompositor->m_sSeat.mouse = m_lMice.size() > 0 ? &m_lMice.front() : nullptr;
g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
} }
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) { void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {