mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 09:25:59 +01:00
virtualptr: allow binding to output
This commit is contained in:
parent
70468857da
commit
23a8f06594
5 changed files with 36 additions and 12 deletions
|
@ -107,6 +107,7 @@ class IPointer : public IHID {
|
||||||
|
|
||||||
std::string hlName;
|
std::string hlName;
|
||||||
bool connected = false; // means connected to the cursor
|
bool connected = false; // means connected to the cursor
|
||||||
|
std::string boundOutput = "";
|
||||||
|
|
||||||
WP<IPointer> self;
|
WP<IPointer> self;
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,8 @@ CVirtualPointer::CVirtualPointer(SP<CVirtualPointerV1Resource> resource) : point
|
||||||
listeners.holdBegin = pointer->events.holdBegin.registerListener([this](std::any d) { pointerEvents.holdBegin.emit(d); });
|
listeners.holdBegin = pointer->events.holdBegin.registerListener([this](std::any d) { pointerEvents.holdBegin.emit(d); });
|
||||||
listeners.holdEnd = pointer->events.holdEnd.registerListener([this](std::any d) { pointerEvents.holdEnd.emit(d); });
|
listeners.holdEnd = pointer->events.holdEnd.registerListener([this](std::any d) { pointerEvents.holdEnd.emit(d); });
|
||||||
|
|
||||||
|
boundOutput = resource->boundOutput ? resource->boundOutput->szName : "auto";
|
||||||
|
|
||||||
deviceName = pointer->name;
|
deviceName = pointer->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -674,6 +674,16 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case HID_TYPE_POINTER: {
|
||||||
|
IPointer* POINTER = reinterpret_cast<IPointer*>(dev.get());
|
||||||
|
if (!POINTER->boundOutput.empty() && POINTER->boundOutput != "auto") {
|
||||||
|
if (const auto PMONITOR = g_pCompositor->getMonitorFromString(POINTER->boundOutput); PMONITOR) {
|
||||||
|
currentMonitor = PMONITOR->self.lock();
|
||||||
|
mappedArea = currentMonitor->logicalBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#include "VirtualPointer.hpp"
|
#include "VirtualPointer.hpp"
|
||||||
|
#include "core/Output.hpp"
|
||||||
|
|
||||||
#define LOGM PROTO::virtualPointer->protoLog
|
#define LOGM PROTO::virtualPointer->protoLog
|
||||||
|
|
||||||
CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_) : resource(resource_) {
|
CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, WP<CMonitor> boundOutput_) : boundOutput(boundOutput_), resource(resource_) {
|
||||||
if (!good())
|
if (!good())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -112,10 +113,18 @@ void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_
|
||||||
RESOURCE->setOnDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
RESOURCE->setOnDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||||
RESOURCE->setDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
RESOURCE->setDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||||
|
|
||||||
RESOURCE->setCreateVirtualPointer([this](CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id) { this->onCreatePointer(pMgr, seat, id); });
|
RESOURCE->setCreateVirtualPointer([this](CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id) { this->onCreatePointer(pMgr, seat, id, {}); });
|
||||||
RESOURCE->setCreateVirtualPointerWithOutput([this](CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, wl_resource* output, uint32_t id) {
|
RESOURCE->setCreateVirtualPointerWithOutput([this](CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, wl_resource* output, uint32_t id) {
|
||||||
LOGM(WARN, "TODO: CreateWithOutput is not supported yet. Ignoring for now.");
|
if (output) {
|
||||||
this->onCreatePointer(pMgr, seat, id);
|
auto RES = CWLOutputResource::fromResource(output);
|
||||||
|
if (!RES) {
|
||||||
|
this->onCreatePointer(pMgr, seat, id, {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->onCreatePointer(pMgr, seat, id, RES->monitor);
|
||||||
|
} else
|
||||||
|
this->onCreatePointer(pMgr, seat, id, {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,9 +136,9 @@ void CVirtualPointerProtocol::destroyResource(CVirtualPointerV1Resource* pointer
|
||||||
std::erase_if(m_vPointers, [&](const auto& other) { return other.get() == pointer; });
|
std::erase_if(m_vPointers, [&](const auto& other) { return other.get() == pointer; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVirtualPointerProtocol::onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id) {
|
void CVirtualPointerProtocol::onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, WP<CMonitor> output) {
|
||||||
|
|
||||||
const auto RESOURCE = m_vPointers.emplace_back(makeShared<CVirtualPointerV1Resource>(makeShared<CZwlrVirtualPointerV1>(pMgr->client(), pMgr->version(), id)));
|
const auto RESOURCE = m_vPointers.emplace_back(makeShared<CVirtualPointerV1Resource>(makeShared<CZwlrVirtualPointerV1>(pMgr->client(), pMgr->version(), id), output));
|
||||||
|
|
||||||
if (!RESOURCE->good()) {
|
if (!RESOURCE->good()) {
|
||||||
pMgr->noMemory();
|
pMgr->noMemory();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
class CVirtualPointerV1Resource {
|
class CVirtualPointerV1Resource {
|
||||||
public:
|
public:
|
||||||
CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_);
|
CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, WP<CMonitor> boundOutput_);
|
||||||
~CVirtualPointerV1Resource();
|
~CVirtualPointerV1Resource();
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -39,6 +39,8 @@ class CVirtualPointerV1Resource {
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
|
WP<CMonitor> boundOutput;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SP<CZwlrVirtualPointerV1> resource;
|
SP<CZwlrVirtualPointerV1> resource;
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ class CVirtualPointerProtocol : public IWaylandProtocol {
|
||||||
private:
|
private:
|
||||||
void onManagerResourceDestroy(wl_resource* res);
|
void onManagerResourceDestroy(wl_resource* res);
|
||||||
void destroyResource(CVirtualPointerV1Resource* pointer);
|
void destroyResource(CVirtualPointerV1Resource* pointer);
|
||||||
void onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id);
|
void onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, WP<CMonitor> output);
|
||||||
|
|
||||||
//
|
//
|
||||||
std::vector<UP<CZwlrVirtualPointerManagerV1>> m_vManagers;
|
std::vector<UP<CZwlrVirtualPointerManagerV1>> m_vManagers;
|
||||||
|
|
Loading…
Reference in a new issue