diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-06-08 10:07:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-08 10:07:59 +0200 |
| commit | 6967a31450441fc5605c05db6f65505dace4b263 (patch) | |
| tree | 255a3cff7f3e2eb8a50c952eab9b270a7937561d /src/protocols/core/Seat.cpp | |
| parent | c31d9ef4172452f6f219f91d9b87a24d91f0cf3a (diff) | |
wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl
it's the final countdown
Diffstat (limited to 'src/protocols/core/Seat.cpp')
| -rw-r--r-- | src/protocols/core/Seat.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/protocols/core/Seat.cpp b/src/protocols/core/Seat.cpp index 9d5cf496..8bf03909 100644 --- a/src/protocols/core/Seat.cpp +++ b/src/protocols/core/Seat.cpp @@ -1,4 +1,5 @@ #include "Seat.hpp" +#include "Compositor.hpp" #include "../../devices/IKeyboard.hpp" #include "../../managers/SeatManager.hpp" #include "../../config/ConfigValue.hpp" @@ -20,7 +21,7 @@ bool CWLTouchResource::good() { return resource->resource(); } -void CWLTouchResource::sendDown(wlr_surface* surface, uint32_t timeMs, int32_t id, const Vector2D& local) { +void CWLTouchResource::sendDown(SP<CWLSurfaceResource> surface, uint32_t timeMs, int32_t id, const Vector2D& local) { if (!owner) return; @@ -29,15 +30,12 @@ void CWLTouchResource::sendDown(wlr_surface* surface, uint32_t timeMs, int32_t i sendUp(timeMs, id); } - ASSERT(wl_resource_get_client(surface->resource) == owner->client()); + ASSERT(surface->client() == owner->client()); - currentSurface = surface; - hyprListener_surfaceDestroy.initCallback( - &surface->events.destroy, [this, id, timeMs](void* owner, void* data) { sendUp(timeMs + 10 /* hack */, id); }, this, "CWLTouchResource"); + currentSurface = surface; + listeners.destroySurface = surface->events.destroy.registerListener([this, timeMs, id](std::any d) { sendUp(timeMs + 10 /* hack */, id); }); - // FIXME: - // fix this once we get our own wlr_surface, this is horrible - resource->sendDownRaw(g_pSeatManager->nextSerial(owner.lock()), timeMs, surface->resource, id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + resource->sendDown(g_pSeatManager->nextSerial(owner.lock()), timeMs, surface->getResource().get(), id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } void CWLTouchResource::sendUp(uint32_t timeMs, int32_t id) { @@ -45,8 +43,8 @@ void CWLTouchResource::sendUp(uint32_t timeMs, int32_t id) { return; resource->sendUp(g_pSeatManager->nextSerial(owner.lock()), timeMs, id); - currentSurface = nullptr; - hyprListener_surfaceDestroy.removeCallback(); + currentSurface.reset(); + listeners.destroySurface.reset(); } void CWLTouchResource::sendMotion(uint32_t timeMs, int32_t id, const Vector2D& local) { @@ -97,7 +95,7 @@ CWLPointerResource::CWLPointerResource(SP<CWlPointer> resource_, SP<CWLSeatResou return; } - g_pSeatManager->onSetCursor(owner.lock(), serial, surf ? wlr_surface_from_resource(surf) : nullptr, {hotX, hotY}); + g_pSeatManager->onSetCursor(owner.lock(), serial, surf ? CWLSurfaceResource::fromResource(surf) : nullptr, {hotX, hotY}); }); } @@ -105,7 +103,7 @@ bool CWLPointerResource::good() { return resource->resource(); } -void CWLPointerResource::sendEnter(wlr_surface* surface, const Vector2D& local) { +void CWLPointerResource::sendEnter(SP<CWLSurfaceResource> surface, const Vector2D& local) { if (!owner || currentSurface == surface) return; @@ -114,22 +112,21 @@ void CWLPointerResource::sendEnter(wlr_surface* surface, const Vector2D& local) sendLeave(); } - ASSERT(wl_resource_get_client(surface->resource) == owner->client()); + ASSERT(surface->client() == owner->client()); - currentSurface = surface; - hyprListener_surfaceDestroy.initCallback( - &surface->events.destroy, [this](void* owner, void* data) { sendLeave(); }, this, "CWLPointerResource"); + currentSurface = surface; + listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { sendLeave(); }); - resource->sendEnterRaw(g_pSeatManager->nextSerial(owner.lock()), surface->resource, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + resource->sendEnter(g_pSeatManager->nextSerial(owner.lock()), surface->getResource().get(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } void CWLPointerResource::sendLeave() { if (!owner || !currentSurface) return; - resource->sendLeaveRaw(g_pSeatManager->nextSerial(owner.lock()), currentSurface->resource); - currentSurface = nullptr; - hyprListener_surfaceDestroy.removeCallback(); + resource->sendLeave(g_pSeatManager->nextSerial(owner.lock()), currentSurface->getResource().get()); + currentSurface.reset(); + listeners.destroySurface.reset(); } void CWLPointerResource::sendMotion(uint32_t timeMs, const Vector2D& local) { @@ -237,7 +234,7 @@ void CWLKeyboardResource::sendKeymap(SP<IKeyboard> keyboard) { close(fd); } -void CWLKeyboardResource::sendEnter(wlr_surface* surface) { +void CWLKeyboardResource::sendEnter(SP<CWLSurfaceResource> surface) { if (!owner || currentSurface == surface) return; @@ -246,16 +243,15 @@ void CWLKeyboardResource::sendEnter(wlr_surface* surface) { sendLeave(); } - ASSERT(wl_resource_get_client(surface->resource) == owner->client()); + ASSERT(surface->client() == owner->client()); - currentSurface = surface; - hyprListener_surfaceDestroy.initCallback( - &surface->events.destroy, [this](void* owner, void* data) { sendLeave(); }, this, "CWLKeyboardResource"); + currentSurface = surface; + listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { sendLeave(); }); wl_array arr; wl_array_init(&arr); - resource->sendEnterRaw(g_pSeatManager->nextSerial(owner.lock()), surface->resource, &arr); + resource->sendEnter(g_pSeatManager->nextSerial(owner.lock()), surface->getResource().get(), &arr); wl_array_release(&arr); } @@ -264,9 +260,9 @@ void CWLKeyboardResource::sendLeave() { if (!owner || !currentSurface) return; - resource->sendLeaveRaw(g_pSeatManager->nextSerial(owner.lock()), currentSurface->resource); - currentSurface = nullptr; - hyprListener_surfaceDestroy.removeCallback(); + resource->sendLeave(g_pSeatManager->nextSerial(owner.lock()), currentSurface->getResource().get()); + currentSurface.reset(); + listeners.destroySurface.reset(); } void CWLKeyboardResource::sendKey(uint32_t timeMs, uint32_t key, wl_keyboard_key_state state) { |
