summaryrefslogtreecommitdiff
path: root/src/protocols/core/DataDevice.cpp
diff options
context:
space:
mode:
authordavc0n <dconti.dev@gmail.com>2025-05-03 16:02:49 +0200
committerGitHub <noreply@github.com>2025-05-03 16:02:49 +0200
commitd9cad5e1b63f2e1e86eb54551c72d17ee4dd070d (patch)
tree8238b613480214eaf91fc85343d25503bafa51c3 /src/protocols/core/DataDevice.cpp
parent0c736217a787928a87224b2bf7e984c446d4fc22 (diff)
protocols: refactor class member vars (core) (#10259)
Diffstat (limited to 'src/protocols/core/DataDevice.cpp')
-rw-r--r--src/protocols/core/DataDevice.cpp416
1 files changed, 208 insertions, 208 deletions
diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp
index fda46980..a54ae7e1 100644
--- a/src/protocols/core/DataDevice.cpp
+++ b/src/protocols/core/DataDevice.cpp
@@ -16,60 +16,60 @@
#include "../../xwayland/Dnd.hpp"
using namespace Hyprutils::OS;
-CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_) : source(source_), resource(resource_) {
+CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_) : m_source(source_), m_resource(resource_) {
if UNLIKELY (!good())
return;
- resource->setDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); });
- resource->setOnDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); });
+ m_resource->setDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); });
+ m_resource->setOnDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); });
- resource->setAccept([this](CWlDataOffer* r, uint32_t serial, const char* mime) {
- if (!source) {
+ m_resource->setAccept([this](CWlDataOffer* r, uint32_t serial, const char* mime) {
+ if (!m_source) {
LOGM(WARN, "Possible bug: Accept on an offer w/o a source");
return;
}
- if (dead) {
+ if (m_dead) {
LOGM(WARN, "Possible bug: Accept on an offer that's dead");
return;
}
- LOGM(LOG, "Offer {:x} accepts data from source {:x} with mime {}", (uintptr_t)this, (uintptr_t)source.get(), mime ? mime : "null");
+ LOGM(LOG, "Offer {:x} accepts data from source {:x} with mime {}", (uintptr_t)this, (uintptr_t)m_source.get(), mime ? mime : "null");
- source->accepted(mime ? mime : "");
- accepted = mime;
+ m_source->accepted(mime ? mime : "");
+ m_accepted = mime;
});
- resource->setReceive([this](CWlDataOffer* r, const char* mime, int fd) {
+ m_resource->setReceive([this](CWlDataOffer* r, const char* mime, int fd) {
CFileDescriptor sendFd{fd};
- if (!source) {
+ if (!m_source) {
LOGM(WARN, "Possible bug: Receive on an offer w/o a source");
return;
}
- if (dead) {
+ if (m_dead) {
LOGM(WARN, "Possible bug: Receive on an offer that's dead");
return;
}
- LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)source.get());
+ LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get());
- if (!accepted) {
+ if (!m_accepted) {
LOGM(WARN, "Offer was never accepted, sending accept first");
- source->accepted(mime ? mime : "");
+ m_source->accepted(mime ? mime : "");
}
- source->send(mime ? mime : "", std::move(sendFd));
+ m_source->send(mime ? mime : "", std::move(sendFd));
- recvd = true;
+ m_recvd = true;
// if (source->hasDnd())
// PROTO::data->completeDrag();
});
- resource->setFinish([this](CWlDataOffer* r) {
- dead = true;
- if (!source || !recvd || !accepted)
+ m_resource->setFinish([this](CWlDataOffer* r) {
+ m_dead = true;
+ if (!m_source || !m_recvd || !m_accepted)
PROTO::data->abortDrag();
else
PROTO::data->completeDrag();
@@ -77,37 +77,37 @@ CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataS
}
CWLDataOfferResource::~CWLDataOfferResource() {
- if (!source || !source->hasDnd() || dead)
+ if (!m_source || !m_source->hasDnd() || m_dead)
return;
- source->sendDndFinished();
+ m_source->sendDndFinished();
}
bool CWLDataOfferResource::good() {
- return resource->resource();
+ return m_resource->resource();
}
void CWLDataOfferResource::sendData() {
- if (!source)
+ if (!m_source)
return;
- const auto SOURCEACTIONS = source->actions();
+ const auto SOURCEACTIONS = m_source->actions();
- if (resource->version() >= 3 && SOURCEACTIONS > 0) {
- resource->sendSourceActions(SOURCEACTIONS);
+ if (m_resource->version() >= 3 && SOURCEACTIONS > 0) {
+ m_resource->sendSourceActions(SOURCEACTIONS);
if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
- resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE);
+ m_resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE);
else if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
- resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY);
+ m_resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY);
else {
LOGM(ERR, "Client bug? dnd source has no action move or copy. Sending move, f this.");
- resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE);
+ m_resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE);
}
}
- for (auto const& m : source->mimes()) {
+ for (auto const& m : m_source->mimes()) {
LOGM(LOG, " | offer {:x} supports mime {}", (uintptr_t)this, m);
- resource->sendOffer(m.c_str());
+ m_resource->sendOffer(m.c_str());
}
}
@@ -116,7 +116,7 @@ eDataSourceType CWLDataOfferResource::type() {
}
SP<CWLDataOfferResource> CWLDataOfferResource::getWayland() {
- return self.lock();
+ return m_self.lock();
}
SP<CX11DataOffer> CWLDataOfferResource::getX11() {
@@ -124,127 +124,127 @@ SP<CX11DataOffer> CWLDataOfferResource::getX11() {
}
SP<IDataSource> CWLDataOfferResource::getSource() {
- return source.lock();
+ return m_source.lock();
}
-CWLDataSourceResource::CWLDataSourceResource(SP<CWlDataSource> resource_, SP<CWLDataDeviceResource> device_) : device(device_), resource(resource_) {
+CWLDataSourceResource::CWLDataSourceResource(SP<CWlDataSource> resource_, SP<CWLDataDeviceResource> device_) : m_device(device_), m_resource(resource_) {
if UNLIKELY (!good())
return;
- resource->setData(this);
+ m_resource->setData(this);
- resource->setDestroy([this](CWlDataSource* r) {
+ m_resource->setDestroy([this](CWlDataSource* r) {
events.destroy.emit();
- PROTO::data->onDestroyDataSource(self);
+ PROTO::data->onDestroyDataSource(m_self);
PROTO::data->destroyResource(this);
});
- resource->setOnDestroy([this](CWlDataSource* r) {
+ m_resource->setOnDestroy([this](CWlDataSource* r) {
events.destroy.emit();
- PROTO::data->onDestroyDataSource(self);
+ PROTO::data->onDestroyDataSource(m_self);
PROTO::data->destroyResource(this);
});
- resource->setOffer([this](CWlDataSource* r, const char* mime) { mimeTypes.emplace_back(mime); });
- resource->setSetActions([this](CWlDataSource* r, uint32_t a) {
+ m_resource->setOffer([this](CWlDataSource* r, const char* mime) { m_mimeTypes.emplace_back(mime); });
+ m_resource->setSetActions([this](CWlDataSource* r, uint32_t a) {
LOGM(LOG, "DataSource {:x} actions {}", (uintptr_t)this, a);
- supportedActions = a;
+ m_supportedActions = a;
});
}
CWLDataSourceResource::~CWLDataSourceResource() {
events.destroy.emit();
- PROTO::data->onDestroyDataSource(self);
+ PROTO::data->onDestroyDataSource(m_self);
}
SP<CWLDataSourceResource> CWLDataSourceResource::fromResource(wl_resource* res) {
auto data = (CWLDataSourceResource*)(((CWlDataSource*)wl_resource_get_user_data(res))->data());
- return data ? data->self.lock() : nullptr;
+ return data ? data->m_self.lock() : nullptr;
}
bool CWLDataSourceResource::good() {
- return resource->resource();
+ return m_resource->resource();
}
void CWLDataSourceResource::accepted(const std::string& mime) {
if (mime.empty()) {
- resource->sendTarget(nullptr);
+ m_resource->sendTarget(nullptr);
return;
}
- if (std::find(mimeTypes.begin(), mimeTypes.end(), mime) == mimeTypes.end()) {
+ if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLDataSourceResource::sendAccepted with non-existent mime");
return;
}
- resource->sendTarget(mime.c_str());
+ m_resource->sendTarget(mime.c_str());
}
std::vector<std::string> CWLDataSourceResource::mimes() {
- return mimeTypes;
+ return m_mimeTypes;
}
void CWLDataSourceResource::send(const std::string& mime, CFileDescriptor fd) {
- if (std::find(mimeTypes.begin(), mimeTypes.end(), mime) == mimeTypes.end()) {
+ if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLDataSourceResource::sendAskSend with non-existent mime");
return;
}
- resource->sendSend(mime.c_str(), fd.get());
+ m_resource->sendSend(mime.c_str(), fd.get());
}
void CWLDataSourceResource::cancelled() {
- resource->sendCancelled();
+ m_resource->sendCancelled();
}
bool CWLDataSourceResource::hasDnd() {
- return dnd;
+ return m_dnd;
}
bool CWLDataSourceResource::dndDone() {
- return dndSuccess;
+ return m_dndSuccess;
}
void CWLDataSourceResource::error(uint32_t code, const std::string& msg) {
- resource->error(code, msg);
+ m_resource->error(code, msg);
}
void CWLDataSourceResource::sendDndDropPerformed() {
- if (resource->version() < 3)
+ if (m_resource->version() < 3)
return;
- resource->sendDndDropPerformed();
- dropped = true;
+ m_resource->sendDndDropPerformed();
+ m_dropped = true;
}
void CWLDataSourceResource::sendDndFinished() {
- if (resource->version() < 3)
+ if (m_resource->version() < 3)
return;
- resource->sendDndFinished();
+ m_resource->sendDndFinished();
}
void CWLDataSourceResource::sendDndAction(wl_data_device_manager_dnd_action a) {
- if (resource->version() < 3)
+ if (m_resource->version() < 3)
return;
- resource->sendAction(a);
+ m_resource->sendAction(a);
}
uint32_t CWLDataSourceResource::actions() {
- return supportedActions;
+ return m_supportedActions;
}
eDataSourceType CWLDataSourceResource::type() {
return DATA_SOURCE_TYPE_WAYLAND;
}
-CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : resource(resource_) {
+CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : m_resource(resource_) {
if UNLIKELY (!good())
return;
- resource->setRelease([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); });
- resource->setOnDestroy([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); });
+ m_resource->setRelease([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); });
+ m_resource->setOnDestroy([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); });
- pClient = resource->client();
+ m_client = m_resource->client();
- resource->setSetSelection([](CWlDataDevice* r, wl_resource* sourceR, uint32_t serial) {
+ m_resource->setSetSelection([](CWlDataDevice* r, wl_resource* sourceR, uint32_t serial) {
auto source = sourceR ? CWLDataSourceResource::fromResource(sourceR) : CSharedPointer<CWLDataSourceResource>{};
if (!source) {
LOGM(LOG, "Reset selection received");
@@ -252,7 +252,7 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : reso
return;
}
- if (source && source->used)
+ if (source && source->m_used)
LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed();
@@ -260,63 +260,63 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : reso
g_pSeatManager->setCurrentSelection(source);
});
- resource->setStartDrag([](CWlDataDevice* r, wl_resource* sourceR, wl_resource* origin, wl_resource* icon, uint32_t serial) {
+ m_resource->setStartDrag([](CWlDataDevice* r, wl_resource* sourceR, wl_resource* origin, wl_resource* icon, uint32_t serial) {
auto source = CWLDataSourceResource::fromResource(sourceR);
if (!source) {
LOGM(ERR, "No source in drag");
return;
}
- if (source && source->used)
+ if (source && source->m_used)
LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed();
- source->dnd = true;
+ source->m_dnd = true;
PROTO::data->initiateDrag(source, icon ? CWLSurfaceResource::fromResource(icon) : nullptr, CWLSurfaceResource::fromResource(origin));
});
}
bool CWLDataDeviceResource::good() {
- return resource->resource();
+ return m_resource->resource();
}
wl_client* CWLDataDeviceResource::client() {
- return pClient;
+ return m_client;
}
void CWLDataDeviceResource::sendDataOffer(SP<IDataOffer> offer) {
if (!offer)
- resource->sendDataOfferRaw(nullptr);
+ m_resource->sendDataOfferRaw(nullptr);
else if (const auto WL = offer->getWayland(); WL)
- resource->sendDataOffer(WL->resource.get());
+ m_resource->sendDataOffer(WL->m_resource.get());
//FIXME: X11
}
void CWLDataDeviceResource::sendEnter(uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& local, SP<IDataOffer> offer) {
if (const auto WL = offer->getWayland(); WL)
- resource->sendEnterRaw(serial, surf->getResource()->resource(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y), WL->resource->resource());
+ m_resource->sendEnterRaw(serial, surf->getResource()->resource(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y), WL->m_resource->resource());
// FIXME: X11
}
void CWLDataDeviceResource::sendLeave() {
- resource->sendLeave();
+ m_resource->sendLeave();
}
void CWLDataDeviceResource::sendMotion(uint32_t timeMs, const Vector2D& local) {
- resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y));
+ m_resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y));
}
void CWLDataDeviceResource::sendDrop() {
- resource->sendDrop();
+ m_resource->sendDrop();
}
void CWLDataDeviceResource::sendSelection(SP<IDataOffer> offer) {
if (!offer)
- resource->sendSelectionRaw(nullptr);
+ m_resource->sendSelectionRaw(nullptr);
else if (const auto WL = offer->getWayland(); WL)
- resource->sendSelection(WL->resource.get());
+ m_resource->sendSelection(WL->m_resource.get());
}
eDataSourceType CWLDataDeviceResource::type() {
@@ -324,55 +324,55 @@ eDataSourceType CWLDataDeviceResource::type() {
}
SP<CWLDataDeviceResource> CWLDataDeviceResource::getWayland() {
- return self.lock();
+ return m_self.lock();
}
SP<CX11DataDevice> CWLDataDeviceResource::getX11() {
return nullptr;
}
-CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManager> resource_) : resource(resource_) {
+CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManager> resource_) : m_resource(resource_) {
if UNLIKELY (!good())
return;
- resource->setOnDestroy([this](CWlDataDeviceManager* r) { PROTO::data->destroyResource(this); });
+ m_resource->setOnDestroy([this](CWlDataDeviceManager* r) { PROTO::data->destroyResource(this); });
- resource->setCreateDataSource([this](CWlDataDeviceManager* r, uint32_t id) {
- std::erase_if(sources, [](const auto& e) { return e.expired(); });
+ m_resource->setCreateDataSource([this](CWlDataDeviceManager* r, uint32_t id) {
+ std::erase_if(m_sources, [](const auto& e) { return e.expired(); });
- const auto RESOURCE = PROTO::data->m_vSources.emplace_back(makeShared<CWLDataSourceResource>(makeShared<CWlDataSource>(r->client(), r->version(), id), device.lock()));
+ const auto RESOURCE = PROTO::data->m_sources.emplace_back(makeShared<CWLDataSourceResource>(makeShared<CWlDataSource>(r->client(), r->version(), id), m_device.lock()));
if UNLIKELY (!RESOURCE->good()) {
r->noMemory();
- PROTO::data->m_vSources.pop_back();
+ PROTO::data->m_sources.pop_back();
return;
}
- if (!device)
+ if (!m_device)
LOGM(WARN, "New data source before a device was created");
- RESOURCE->self = RESOURCE;
+ RESOURCE->m_self = RESOURCE;
- sources.emplace_back(RESOURCE);
+ m_sources.emplace_back(RESOURCE);
LOGM(LOG, "New data source bound at {:x}", (uintptr_t)RESOURCE.get());
});
- resource->setGetDataDevice([this](CWlDataDeviceManager* r, uint32_t id, wl_resource* seat) {
- const auto RESOURCE = PROTO::data->m_vDevices.emplace_back(makeShared<CWLDataDeviceResource>(makeShared<CWlDataDevice>(r->client(), r->version(), id)));
+ m_resource->setGetDataDevice([this](CWlDataDeviceManager* r, uint32_t id, wl_resource* seat) {
+ const auto RESOURCE = PROTO::data->m_devices.emplace_back(makeShared<CWLDataDeviceResource>(makeShared<CWlDataDevice>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) {
r->noMemory();
- PROTO::data->m_vDevices.pop_back();
+ PROTO::data->m_devices.pop_back();
return;
}
- RESOURCE->self = RESOURCE;
+ RESOURCE->m_self = RESOURCE;
- for (auto const& s : sources) {
+ for (auto const& s : m_sources) {
if (!s)
continue;
- s->device = RESOURCE;
+ s->m_device = RESOURCE;
}
LOGM(LOG, "New data device bound at {:x}", (uintptr_t)RESOURCE.get());
@@ -380,22 +380,22 @@ CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManag
}
bool CWLDataDeviceManagerResource::good() {
- return resource->resource();
+ return m_resource->resource();
}
CWLDataDeviceProtocol::CWLDataDeviceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
g_pEventLoopManager->doLater([this]() {
- listeners.onKeyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { onKeyboardFocus(); });
- listeners.onDndPointerFocusChange = g_pSeatManager->m_events.dndPointerFocusChange.registerListener([this](std::any d) { onDndPointerFocus(); });
+ m_listeners.onKeyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { onKeyboardFocus(); });
+ m_listeners.onDndPointerFocusChange = g_pSeatManager->m_events.dndPointerFocusChange.registerListener([this](std::any d) { onDndPointerFocus(); });
});
}
void CWLDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
- const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLDataDeviceManagerResource>(makeShared<CWlDataDeviceManager>(client, ver, id)));
+ const auto RESOURCE = m_managers.emplace_back(makeShared<CWLDataDeviceManagerResource>(makeShared<CWlDataDeviceManager>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client);
- m_vManagers.pop_back();
+ m_managers.pop_back();
return;
}
@@ -403,19 +403,19 @@ void CWLDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t
}
void CWLDataDeviceProtocol::destroyResource(CWLDataDeviceManagerResource* seat) {
- std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == seat; });
+ std::erase_if(m_managers, [&](const auto& other) { return other.get() == seat; });
}
void CWLDataDeviceProtocol::destroyResource(CWLDataDeviceResource* resource) {
- std::erase_if(m_vDevices, [&](const auto& other) { return other.get() == resource; });
+ std::erase_if(m_devices, [&](const auto& other) { return other.get() == resource; });
}
void CWLDataDeviceProtocol::destroyResource(CWLDataSourceResource* resource) {
- std::erase_if(m_vSources, [&](const auto& other) { return other.get() == resource; });
+ std::erase_if(m_sources, [&](const auto& other) { return other.get() == resource; });
}
void CWLDataDeviceProtocol::destroyResource(CWLDataOfferResource* resource) {
- std::erase_if(m_vOffers, [&](const auto& other) { return other.get() == resource; });
+ std::erase_if(m_offers, [&](const auto& other) { return other.get() == resource; });
}
SP<IDataDevice> CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) {
@@ -424,8 +424,8 @@ SP<IDataDevice> CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) {
return g_pXWayland->pWM->getDataDevice();
#endif
- auto it = std::find_if(m_vDevices.begin(), m_vDevices.end(), [c](const auto& e) { return e->client() == c; });
- if (it == m_vDevices.end())
+ auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; });
+ if (it == m_devices.end())
return nullptr;
return *it;
}
@@ -439,15 +439,15 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP<IDataDevice> dev, SP<IDataS
SP<IDataOffer> offer;
if (const auto WL = dev->getWayland(); WL) {
- const auto OFFER = m_vOffers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->resource->client(), WL->resource->version(), 0), sel));
+ const auto OFFER = m_offers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->m_resource->client(), WL->m_resource->version(), 0), sel));
if UNLIKELY (!OFFER->good()) {
- WL->resource->noMemory();
- m_vOffers.pop_back();
+ WL->m_resource->noMemory();
+ m_offers.pop_back();
return;
}
- OFFER->source = sel;
- OFFER->self = OFFER;
- offer = OFFER;
+ OFFER->m_source = sel;
+ OFFER->m_self = OFFER;
+ offer = OFFER;
}
#ifndef NO_XWAYLAND
else if (const auto X11 = dev->getX11(); X11)
@@ -468,15 +468,15 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP<IDataDevice> dev, SP<IDataS
}
void CWLDataDeviceProtocol::onDestroyDataSource(WP<CWLDataSourceResource> source) {
- if (dnd.currentSource == source)
+ if (m_dnd.currentSource == source)
abortDrag();
}
void CWLDataDeviceProtocol::setSelection(SP<IDataSource> source) {
- for (auto const& o : m_vOffers) {
- if (o->source && o->source->hasDnd())
+ for (auto const& o : m_offers) {
+ if (o->m_source && o->m_source->hasDnd())
continue;
- o->dead = true;
+ o->m_dead = true;
}
if (!source) {
@@ -527,20 +527,20 @@ void CWLDataDeviceProtocol::updateSelection() {
}
void CWLDataDeviceProtocol::onKeyboardFocus() {
- for (auto const& o : m_vOffers) {
- if (o->source && o->source->hasDnd())
+ for (auto const& o : m_offers) {
+ if (o->m_source && o->m_source->hasDnd())
continue;
- o->dead = true;
+ o->m_dead = true;
}
updateSelection();
}
void CWLDataDeviceProtocol::onDndPointerFocus() {
- for (auto const& o : m_vOffers) {
- if (o->source && !o->source->hasDnd())
+ for (auto const& o : m_offers) {
+ if (o->m_source && !o->m_source->hasDnd())
continue;
- o->dead = true;
+ o->m_dead = true;
}
updateDrag();
@@ -548,37 +548,37 @@ void CWLDataDeviceProtocol::onDndPointerFocus() {
void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource, SP<CWLSurfaceResource> dragSurface, SP<CWLSurfaceResource> origin) {
- if (dnd.currentSource) {
+ if (m_dnd.currentSource) {
LOGM(WARN, "New drag started while old drag still active??");
abortDrag();
}
g_pInputManager->setCursorImageUntilUnset("grabbing");
- dnd.overriddenCursor = true;
+ m_dnd.overriddenCursor = true;
LOGM(LOG, "initiateDrag: source {:x}, surface: {:x}, origin: {:x}", (uintptr_t)currentSource.get(), (uintptr_t)dragSurface, (uintptr_t)origin);
- currentSource->used = true;
+ currentSource->m_used = true;
- dnd.currentSource = currentSource;
- dnd.originSurface = origin;
- dnd.dndSurface = dragSurface;
+ m_dnd.currentSource = currentSource;
+ m_dnd.originSurface = origin;
+ m_dnd.dndSurface = dragSurface;
if (dragSurface) {
- dnd.dndSurfaceDestroy = dragSurface->events.destroy.registerListener([this](std::any d) { abortDrag(); });
- dnd.dndSurfaceCommit = dragSurface->events.commit.registerListener([this](std::any d) {
- if (dnd.dndSurface->current.texture && !dnd.dndSurface->mapped) {
- dnd.dndSurface->map();
+ m_dnd.dndSurfaceDestroy = dragSurface->m_events.destroy.registerListener([this](std::any d) { abortDrag(); });
+ m_dnd.dndSurfaceCommit = dragSurface->m_events.commit.registerListener([this](std::any d) {
+ if (m_dnd.dndSurface->m_current.texture && !m_dnd.dndSurface->m_mapped) {
+ m_dnd.dndSurface->map();
return;
}
- if (dnd.dndSurface->current.texture <= 0 && dnd.dndSurface->mapped) {
- dnd.dndSurface->unmap();
+ if (m_dnd.dndSurface->m_current.texture <= 0 && m_dnd.dndSurface->m_mapped) {
+ m_dnd.dndSurface->unmap();
return;
}
});
}
- dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) {
+ m_dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) {
auto E = std::any_cast<IPointer::SButtonEvent>(e);
if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) {
LOGM(LOG, "Dropping drag on mouseUp");
@@ -586,14 +586,14 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
}
});
- dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) {
+ m_dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) {
LOGM(LOG, "Dropping drag on touchUp");
dropDrag();
});
- dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) {
+ m_dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) {
auto V = std::any_cast<const Vector2D>(e);
- if (dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
+ if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
if (!surf)
@@ -604,14 +604,14 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
if (!box.has_value())
return;
- dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos());
+ m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos());
LOGM(LOG, "Drag motion {}", V - box->pos());
}
});
- dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) {
+ m_dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) {
auto E = std::any_cast<ITouch::SMotionEvent>(e);
- if (dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
+ if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
if (!surf)
@@ -622,7 +622,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
if (!box.has_value())
return;
- dnd.focusedDevice->sendMotion(E.timeMs, E.pos);
+ m_dnd.focusedDevice->sendMotion(E.timeMs, E.pos);
LOGM(LOG, "Drag motion {}", E.pos);
}
});
@@ -642,34 +642,34 @@ void CWLDataDeviceProtocol::updateDrag() {
if (!dndActive())
return;
- if (dnd.focusedDevice)
- dnd.focusedDevice->sendLeave();
+ if (m_dnd.focusedDevice)
+ m_dnd.focusedDevice->sendLeave();
if (!g_pSeatManager->m_state.dndPointerFocus)
return;
- dnd.focusedDevice = dataDeviceForClient(g_pSeatManager->m_state.dndPointerFocus->client());
+ m_dnd.focusedDevice = dataDeviceForClient(g_pSeatManager->m_state.dndPointerFocus->client());
- if (!dnd.focusedDevice)
+ if (!m_dnd.focusedDevice)
return;
SP<IDataOffer> offer;
- if (const auto WL = dnd.focusedDevice->getWayland(); WL) {
+ if (const auto WL = m_dnd.focusedDevice->getWayland(); WL) {
const auto OFFER =
- m_vOffers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->resource->client(), WL->resource->version(), 0), dnd.currentSource.lock()));
+ m_offers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->m_resource->client(), WL->m_resource->version(), 0), m_dnd.currentSource.lock()));
if (!OFFER->good()) {
- WL->resource->noMemory();
- m_vOffers.pop_back();
+ WL->m_resource->noMemory();
+ m_offers.pop_back();
return;
}
- OFFER->source = dnd.currentSource;
- OFFER->self = OFFER;
- offer = OFFER;
+ OFFER->m_source = m_dnd.currentSource;
+ OFFER->m_self = OFFER;
+ offer = OFFER;
}
#ifndef NO_XWAYLAND
- else if (const auto X11 = dnd.focusedDevice->getX11(); X11)
- offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), dnd.currentSource.lock());
+ else if (const auto X11 = m_dnd.focusedDevice->getX11(); X11)
+ offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), m_dnd.currentSource.lock());
#endif
if (!offer) {
@@ -678,28 +678,28 @@ void CWLDataDeviceProtocol::updateDrag() {
}
LOGM(LOG, "New {} dnd offer {:x} for data source {:x}", offer->type() == DATA_SOURCE_TYPE_WAYLAND ? "wayland" : "X11", (uintptr_t)offer.get(),
- (uintptr_t)dnd.currentSource.get());
+ (uintptr_t)m_dnd.currentSource.get());
- dnd.focusedDevice->sendDataOffer(offer);
+ m_dnd.focusedDevice->sendDataOffer(offer);
if (const auto WL = offer->getWayland(); WL)
WL->sendData();
- dnd.focusedDevice->sendEnter(wl_display_next_serial(g_pCompositor->m_wlDisplay), g_pSeatManager->m_state.dndPointerFocus.lock(),
- g_pSeatManager->m_state.dndPointerFocus->current.size / 2.F, offer);
+ m_dnd.focusedDevice->sendEnter(wl_display_next_serial(g_pCompositor->m_wlDisplay), g_pSeatManager->m_state.dndPointerFocus.lock(),
+ g_pSeatManager->m_state.dndPointerFocus->m_current.size / 2.F, offer);
}
void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource, bool simulateInput) {
- dnd.dndSurface.reset();
- dnd.dndSurfaceCommit.reset();
- dnd.dndSurfaceDestroy.reset();
- dnd.mouseButton.reset();
- dnd.mouseMove.reset();
- dnd.touchUp.reset();
- dnd.touchMove.reset();
+ m_dnd.dndSurface.reset();
+ m_dnd.dndSurfaceCommit.reset();
+ m_dnd.dndSurfaceDestroy.reset();
+ m_dnd.mouseButton.reset();
+ m_dnd.mouseMove.reset();
+ m_dnd.touchUp.reset();
+ m_dnd.touchMove.reset();
if (resetDevice)
- dnd.focusedDevice.reset();
+ m_dnd.focusedDevice.reset();
if (resetSource)
- dnd.currentSource.reset();
+ m_dnd.currentSource.reset();
if (simulateInput) {
g_pInputManager->simulateMouseMovement();
@@ -708,8 +708,8 @@ void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource,
}
void CWLDataDeviceProtocol::dropDrag() {
- if (!dnd.focusedDevice || !dnd.currentSource) {
- if (dnd.currentSource)
+ if (!m_dnd.focusedDevice || !m_dnd.currentSource) {
+ if (m_dnd.currentSource)
abortDrag();
return;
}
@@ -719,40 +719,40 @@ void CWLDataDeviceProtocol::dropDrag() {
return;
}
- dnd.focusedDevice->sendDrop();
+ m_dnd.focusedDevice->sendDrop();
#ifndef NO_XWAYLAND
- if (dnd.focusedDevice->getX11()) {
- dnd.focusedDevice->sendLeave();
- if (dnd.overriddenCursor)
+ if (m_dnd.focusedDevice->getX11()) {
+ m_dnd.focusedDevice->sendLeave();
+ if (m_dnd.overriddenCursor)
g_pInputManager->unsetCursorImage();
- dnd.overriddenCursor = false;
+ m_dnd.overriddenCursor = false;
cleanupDndState(true, true, true);
return;
}
#endif
- dnd.focusedDevice->sendLeave();
- if (dnd.overriddenCursor)
+ m_dnd.focusedDevice->sendLeave();
+ if (m_dnd.overriddenCursor)
g_pInputManager->unsetCursorImage();
- dnd.overriddenCursor = false;
+ m_dnd.overriddenCursor = false;
cleanupDndState(false, false, false);
}
bool CWLDataDeviceProtocol::wasDragSuccessful() {
- if (!dnd.currentSource)
+ if (!m_dnd.currentSource)
return false;
- for (auto const& o : m_vOffers) {
- if (o->dead || o->source != dnd.currentSource)
+ for (auto const& o : m_offers) {
+ if (o->m_dead || o->m_source != m_dnd.currentSource)
continue;
- if (o->recvd || o->accepted)
+ if (o->m_recvd || o->m_accepted)
return true;
}
#ifndef NO_XWAYLAND
- if (dnd.focusedDevice->getX11())
+ if (m_dnd.focusedDevice->getX11())
return true;
#endif
@@ -760,12 +760,12 @@ bool CWLDataDeviceProtocol::wasDragSuccessful() {
}
void CWLDataDeviceProtocol::completeDrag() {
- if (!dnd.focusedDevice && !dnd.currentSource)
+ if (!m_dnd.focusedDevice && !m_dnd.currentSource)
return;
- if (dnd.currentSource) {
- dnd.currentSource->sendDndDropPerformed();
- dnd.currentSource->sendDndFinished();
+ if (m_dnd.currentSource) {
+ m_dnd.currentSource->sendDndDropPerformed();
+ m_dnd.currentSource->sendDndFinished();
}
cleanupDndState(true, true, true);
@@ -774,56 +774,56 @@ void CWLDataDeviceProtocol::completeDrag() {
void CWLDataDeviceProtocol::abortDrag() {
cleanupDndState(false, false, false);
- if (dnd.overriddenCursor)
+ if (m_dnd.overriddenCursor)
g_pInputManager->unsetCursorImage();
- dnd.overriddenCursor = false;
+ m_dnd.overriddenCursor = false;
- if (!dnd.focusedDevice && !dnd.currentSource)
+ if (!m_dnd.focusedDevice && !m_dnd.currentSource)
return;
- if (dnd.focusedDevice) {
+ if (m_dnd.focusedDevice) {
#ifndef NO_XWAYLAND
- if (auto x11Device = dnd.focusedDevice->getX11(); x11Device)
+ if (auto x11Device = m_dnd.focusedDevice->getX11(); x11Device)
x11Device->forceCleanupDnd();
#endif
- dnd.focusedDevice->sendLeave();
+ m_dnd.focusedDevice->sendLeave();
}
- if (dnd.currentSource)
- dnd.currentSource->cancelled();
+ if (m_dnd.currentSource)
+ m_dnd.currentSource->cancelled();
- dnd.focusedDevice.reset();
- dnd.currentSource.reset();
+ m_dnd.focusedDevice.reset();
+ m_dnd.currentSource.reset();
g_pInputManager->simulateMouseMovement();
g_pSeatManager->resendEnterEvents();
}
void CWLDataDeviceProtocol::renderDND(PHLMONITOR pMonitor, const Time::steady_tp& when) {
- if (!dnd.dndSurface || !dnd.dndSurface->current.texture)
+ if (!m_dnd.dndSurface || !m_dnd.dndSurface->m_current.texture)
return;
const auto POS = g_pInputManager->getMouseCoordsInternal();
Vector2D surfacePos = POS;
- surfacePos += dnd.dndSurface->current.offset;
+ surfacePos += m_dnd.dndSurface->m_current.offset;
- CBox box = CBox{surfacePos, dnd.dndSurface->current.size}.translate(-pMonitor->m_position).scale(pMonitor->m_scale);
+ CBox box = CBox{surfacePos, m_dnd.dndSurface->m_current.size}.translate(-pMonitor->m_position).scale(pMonitor->m_scale);
CTexPassElement::SRenderData data;
- data.tex = dnd.dndSurface->current.texture;
+ data.tex = m_dnd.dndSurface->m_current.texture;
data.box = box;
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
- CBox damageBox = CBox{surfacePos, dnd.dndSurface->current.size}.expand(5);
+ CBox damageBox = CBox{surfacePos, m_dnd.dndSurface->m_current.size}.expand(5);
g_pHyprRenderer->damageBox(damageBox);
- dnd.dndSurface->frame(when);
+ m_dnd.dndSurface->frame(when);
}
bool CWLDataDeviceProtocol::dndActive() {
- return dnd.currentSource;
+ return m_dnd.currentSource;
}
void CWLDataDeviceProtocol::abortDndIfPresent() {