mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-17 13:03:48 -07:00
wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl it's the final countdown
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user