summaryrefslogtreecommitdiff
path: root/src/managers/SeatManager.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-06-08 10:07:59 +0200
committerGitHub <noreply@github.com>2024-06-08 10:07:59 +0200
commit6967a31450441fc5605c05db6f65505dace4b263 (patch)
tree255a3cff7f3e2eb8a50c952eab9b270a7937561d /src/managers/SeatManager.cpp
parentc31d9ef4172452f6f219f91d9b87a24d91f0cf3a (diff)
wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl it's the final countdown
Diffstat (limited to 'src/managers/SeatManager.cpp')
-rw-r--r--src/managers/SeatManager.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp
index 7899386b..399ef419 100644
--- a/src/managers/SeatManager.cpp
+++ b/src/managers/SeatManager.cpp
@@ -3,6 +3,7 @@
#include "../protocols/core/DataDevice.hpp"
#include "../protocols/DataDeviceWlr.hpp"
#include "../protocols/PrimarySelection.hpp"
+#include "../protocols/core/Compositor.hpp"
#include "../Compositor.hpp"
#include "../devices/IKeyboard.hpp"
#include <algorithm>
@@ -98,7 +99,7 @@ void CSeatManager::updateActiveKeyboardData() {
PROTO::seat->updateKeymap();
}
-void CSeatManager::setKeyboardFocus(wlr_surface* surf) {
+void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
if (state.keyboardFocus == surf)
return;
@@ -107,7 +108,7 @@ void CSeatManager::setKeyboardFocus(wlr_surface* surf) {
return;
}
- hyprListener_keyboardSurfaceDestroy.removeCallback();
+ listeners.keyboardSurfaceDestroy.reset();
if (state.keyboardFocusResource) {
auto client = state.keyboardFocusResource->client();
@@ -132,7 +133,7 @@ void CSeatManager::setKeyboardFocus(wlr_surface* surf) {
return;
}
- auto client = wl_resource_get_client(surf->resource);
+ auto client = surf->client();
for (auto& r : seatResources | std::views::reverse) {
if (r->resource->client() != client)
continue;
@@ -147,8 +148,7 @@ void CSeatManager::setKeyboardFocus(wlr_surface* surf) {
}
}
- hyprListener_keyboardSurfaceDestroy.initCallback(
- &surf->events.destroy, [this](void* owner, void* data) { setKeyboardFocus(nullptr); }, nullptr, "CSeatManager");
+ listeners.keyboardSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setKeyboardFocus(nullptr); });
events.keyboardFocusChange.emit();
}
@@ -187,7 +187,7 @@ void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32
}
}
-void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) {
+void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D& local) {
if (state.pointerFocus == surf)
return;
@@ -196,7 +196,7 @@ void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) {
return;
}
- hyprListener_pointerSurfaceDestroy.removeCallback();
+ listeners.pointerSurfaceDestroy.reset();
if (state.pointerFocusResource) {
auto client = state.pointerFocusResource->client();
@@ -224,7 +224,7 @@ void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) {
return;
}
- auto client = wl_resource_get_client(surf->resource);
+ auto client = surf->client();
for (auto& r : seatResources | std::views::reverse) {
if (r->resource->client() != client)
continue;
@@ -243,8 +243,7 @@ void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) {
sendPointerFrame();
- hyprListener_pointerSurfaceDestroy.initCallback(
- &surf->events.destroy, [this](void* owner, void* data) { setPointerFocus(nullptr, {}); }, nullptr, "CSeatManager");
+ listeners.pointerSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setPointerFocus(nullptr, {}); });
events.pointerFocusChange.emit();
}
@@ -340,11 +339,11 @@ void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double
}
}
-void CSeatManager::sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id, const Vector2D& local) {
+void CSeatManager::sendTouchDown(SP<CWLSurfaceResource> surf, uint32_t timeMs, int32_t id, const Vector2D& local) {
if (state.touchFocus == surf)
return;
- hyprListener_touchSurfaceDestroy.removeCallback();
+ listeners.touchSurfaceDestroy.reset();
if (state.touchFocusResource) {
auto client = state.touchFocusResource->client();
@@ -369,7 +368,7 @@ void CSeatManager::sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id,
return;
}
- auto client = wl_resource_get_client(surf->resource);
+ auto client = surf->client();
for (auto& r : seatResources | std::views::reverse) {
if (r->resource->client() != client)
continue;
@@ -383,8 +382,7 @@ void CSeatManager::sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id,
}
}
- hyprListener_touchSurfaceDestroy.initCallback(
- &surf->events.destroy, [this, timeMs, id](void* owner, void* data) { sendTouchUp(timeMs + 10, id); }, nullptr, "CSeatManager");
+ listeners.touchSurfaceDestroy = surf->events.destroy.registerListener([this, timeMs, id](std::any d) { sendTouchUp(timeMs + 10, id); });
events.touchFocusChange.emit();
}
@@ -486,7 +484,7 @@ void CSeatManager::refocusGrab() {
// try to find a surf in focus first
const auto MOUSE = g_pInputManager->getMouseCoordsInternal();
for (auto& s : seatGrab->surfs) {
- auto hlSurf = CWLSurface::surfaceFromWlr(s);
+ auto hlSurf = CWLSurface::fromResource(s.lock());
if (!hlSurf)
continue;
@@ -498,13 +496,13 @@ void CSeatManager::refocusGrab() {
continue;
if (seatGrab->keyboard)
- setKeyboardFocus(s);
+ setKeyboardFocus(s.lock());
if (seatGrab->pointer)
- setPointerFocus(s, MOUSE - b->pos());
+ setPointerFocus(s.lock(), MOUSE - b->pos());
return;
}
- wlr_surface* surf = seatGrab->surfs.at(0);
+ SP<CWLSurfaceResource> surf = seatGrab->surfs.at(0).lock();
if (seatGrab->keyboard)
setKeyboardFocus(surf);
if (seatGrab->pointer)
@@ -512,7 +510,7 @@ void CSeatManager::refocusGrab() {
}
}
-void CSeatManager::onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, wlr_surface* surf, const Vector2D& hotspot) {
+void CSeatManager::onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& hotspot) {
if (!state.pointerFocusResource || !seatResource || seatResource->client() != state.pointerFocusResource->client()) {
Debug::log(LOG, "[seatmgr] Rejecting a setCursor because the client ain't in focus");
return;
@@ -599,10 +597,10 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
}
void CSeatManager::resendEnterEvents() {
- wlr_surface* kb = state.keyboardFocus;
- wlr_surface* pt = state.pointerFocus;
+ SP<CWLSurfaceResource> kb = state.keyboardFocus.lock();
+ SP<CWLSurfaceResource> pt = state.pointerFocus.lock();
- auto last = lastLocalCoords;
+ auto last = lastLocalCoords;
setKeyboardFocus(nullptr);
setPointerFocus(nullptr, {});
@@ -611,15 +609,15 @@ void CSeatManager::resendEnterEvents() {
setPointerFocus(pt, last);
}
-bool CSeatGrab::accepts(wlr_surface* surf) {
+bool CSeatGrab::accepts(SP<CWLSurfaceResource> surf) {
return std::find(surfs.begin(), surfs.end(), surf) != surfs.end();
}
-void CSeatGrab::add(wlr_surface* surf) {
+void CSeatGrab::add(SP<CWLSurfaceResource> surf) {
surfs.push_back(surf);
}
-void CSeatGrab::remove(wlr_surface* surf) {
+void CSeatGrab::remove(SP<CWLSurfaceResource> surf) {
std::erase(surfs, surf);
if ((keyboard && g_pSeatManager->state.keyboardFocus == surf) || (pointer && g_pSeatManager->state.pointerFocus == surf))
g_pSeatManager->refocusGrab();