summaryrefslogtreecommitdiff
path: root/src/managers
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
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')
-rw-r--r--src/managers/CursorManager.cpp4
-rw-r--r--src/managers/CursorManager.hpp2
-rw-r--r--src/managers/KeybindManager.cpp24
-rw-r--r--src/managers/PointerManager.cpp66
-rw-r--r--src/managers/PointerManager.hpp14
-rw-r--r--src/managers/ProtocolManager.cpp34
-rw-r--r--src/managers/SeatManager.cpp50
-rw-r--r--src/managers/SeatManager.hpp43
-rw-r--r--src/managers/SessionLockManager.cpp6
-rw-r--r--src/managers/SessionLockManager.hpp7
-rw-r--r--src/managers/XWaylandManager.cpp13
-rw-r--r--src/managers/XWaylandManager.hpp26
-rw-r--r--src/managers/input/IdleInhibitor.cpp4
-rw-r--r--src/managers/input/InputManager.cpp60
-rw-r--r--src/managers/input/InputManager.hpp24
-rw-r--r--src/managers/input/InputMethodPopup.cpp22
-rw-r--r--src/managers/input/InputMethodPopup.hpp16
-rw-r--r--src/managers/input/InputMethodRelay.cpp20
-rw-r--r--src/managers/input/InputMethodRelay.hpp10
-rw-r--r--src/managers/input/Tablets.cpp6
-rw-r--r--src/managers/input/TextInput.cpp71
-rw-r--r--src/managers/input/TextInput.hpp44
-rw-r--r--src/managers/input/Touch.cpp2
23 files changed, 298 insertions, 270 deletions
diff --git a/src/managers/CursorManager.cpp b/src/managers/CursorManager.cpp
index e3ebce80..4430d0f4 100644
--- a/src/managers/CursorManager.cpp
+++ b/src/managers/CursorManager.cpp
@@ -117,8 +117,8 @@ wlr_buffer* CCursorManager::getCursorBuffer() {
return !m_vCursorBuffers.empty() ? &m_vCursorBuffers.back()->wlrBuffer.base : nullptr;
}
-void CCursorManager::setCursorSurface(CWLSurface* surf, const Vector2D& hotspot) {
- if (!surf || !surf->wlr())
+void CCursorManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot) {
+ if (!surf || !surf->resource())
g_pPointerManager->resetCursorImage();
else
g_pPointerManager->setCursorSurface(surf, hotspot);
diff --git a/src/managers/CursorManager.hpp b/src/managers/CursorManager.hpp
index e76b6829..6fbff636 100644
--- a/src/managers/CursorManager.hpp
+++ b/src/managers/CursorManager.hpp
@@ -18,7 +18,7 @@ class CCursorManager {
wlr_buffer* getCursorBuffer();
void setCursorFromName(const std::string& name);
- void setCursorSurface(CWLSurface* surf, const Vector2D& hotspot);
+ void setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot);
void setXCursor(const std::string& name);
bool changeTheme(const std::string& name, const int size);
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index f7009afb..5811f4a1 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -2003,14 +2003,14 @@ void CKeybindManager::pass(std::string regexp) {
}
const auto XWTOXW = PWINDOW->m_bIsX11 && g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow->m_bIsX11;
- const auto LASTSRF = g_pCompositor->m_pLastFocus;
+ const auto LASTSRF = g_pCompositor->m_pLastFocus.lock();
// pass all mf shit
if (!XWTOXW) {
if (g_pKeybindManager->m_uLastCode != 0)
- g_pSeatManager->setKeyboardFocus(PWINDOW->m_pWLSurface.wlr());
+ g_pSeatManager->setKeyboardFocus(PWINDOW->m_pWLSurface->resource());
else
- g_pSeatManager->setPointerFocus(PWINDOW->m_pWLSurface.wlr(), {1, 1});
+ g_pSeatManager->setPointerFocus(PWINDOW->m_pWLSurface->resource(), {1, 1});
}
g_pSeatManager->sendKeyboardMods(g_pInputManager->accumulateModsFromAllKBs(), 0, 0, 0);
@@ -2044,10 +2044,10 @@ void CKeybindManager::pass(std::string regexp) {
// please kill me
if (PWINDOW->m_bIsX11) {
if (g_pKeybindManager->m_uLastCode != 0) {
- g_pSeatManager->state.keyboardFocus = nullptr;
+ g_pSeatManager->state.keyboardFocus.reset();
g_pSeatManager->state.keyboardFocusResource.reset();
} else {
- g_pSeatManager->state.pointerFocus = nullptr;
+ g_pSeatManager->state.pointerFocus.reset();
g_pSeatManager->state.pointerFocusResource.reset();
}
}
@@ -2057,7 +2057,7 @@ void CKeybindManager::pass(std::string regexp) {
if (g_pKeybindManager->m_uLastCode != 0)
g_pSeatManager->setKeyboardFocus(LASTSRF);
else
- g_pSeatManager->setPointerFocus(PWINDOW->m_pWLSurface.wlr(), SL);
+ g_pSeatManager->setPointerFocus(PWINDOW->m_pWLSurface->resource(), SL);
}
void CKeybindManager::sendshortcut(std::string args) {
@@ -2136,7 +2136,7 @@ void CKeybindManager::sendshortcut(std::string args) {
const std::string regexp = ARGS[2];
PHLWINDOW PWINDOW = nullptr;
- const auto LASTSURFACE = g_pCompositor->m_pLastFocus;
+ const auto LASTSURFACE = g_pCompositor->m_pLastFocus.lock();
//if regexp is not empty, send shortcut to current window
//else, dont change focus
@@ -2154,15 +2154,15 @@ void CKeybindManager::sendshortcut(std::string args) {
}
if (!isMouse)
- g_pSeatManager->setKeyboardFocus(PWINDOW->m_pWLSurface.wlr());
+ g_pSeatManager->setKeyboardFocus(PWINDOW->m_pWLSurface->resource());
else
- g_pSeatManager->setPointerFocus(PWINDOW->m_pWLSurface.wlr(), {1, 1});
+ g_pSeatManager->setPointerFocus(PWINDOW->m_pWLSurface->resource(), {1, 1});
}
//copied the rest from pass and modified it
// if wl -> xwl, activate destination
if (PWINDOW && PWINDOW->m_bIsX11 && g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsX11)
- g_pXWaylandManager->activateSurface(PWINDOW->m_pWLSurface.wlr(), true);
+ g_pXWaylandManager->activateSurface(PWINDOW->m_pWLSurface->resource(), true);
// if xwl -> xwl, send to current. Timing issues make this not work.
if (PWINDOW && PWINDOW->m_bIsX11 && g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsX11)
PWINDOW = nullptr;
@@ -2195,10 +2195,10 @@ void CKeybindManager::sendshortcut(std::string args) {
if (PWINDOW->m_bIsX11) { //xwayland hack, see pass
if (!isMouse) {
- g_pSeatManager->state.keyboardFocus = nullptr;
+ g_pSeatManager->state.keyboardFocus.reset();
g_pSeatManager->state.keyboardFocusResource.reset();
} else {
- g_pSeatManager->state.pointerFocus = nullptr;
+ g_pSeatManager->state.pointerFocus.reset();
g_pSeatManager->state.pointerFocusResource.reset();
}
}
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index 66d12076..80a7ee76 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -3,6 +3,7 @@
#include "../config/ConfigValue.hpp"
#include "../protocols/PointerGestures.hpp"
#include "../protocols/FractionalScale.hpp"
+#include "../protocols/core/Compositor.hpp"
#include "SeatManager.hpp"
#include <wlr/interfaces/wlr_output.h>
#include <wlr/render/interface.h>
@@ -212,13 +213,13 @@ void CPointerManager::setCursorBuffer(wlr_buffer* buf, const Vector2D& hotspot,
damageIfSoftware();
}
-void CPointerManager::setCursorSurface(CWLSurface* surf, const Vector2D& hotspot) {
+void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot) {
damageIfSoftware();
if (surf == currentCursorImage.surface) {
- if (hotspot != currentCursorImage.hotspot || (surf && surf->wlr() ? surf->wlr()->current.scale : 1.F) != currentCursorImage.scale) {
+ if (hotspot != currentCursorImage.hotspot || (surf && surf->resource() ? surf->resource()->current.scale : 1.F) != currentCursorImage.scale) {
currentCursorImage.hotspot = hotspot;
- currentCursorImage.scale = surf && surf->wlr() ? surf->wlr()->current.scale : 1.F;
+ currentCursorImage.scale = surf && surf->resource() ? surf->resource()->current.scale : 1.F;
updateCursorBackend();
damageIfSoftware();
}
@@ -229,27 +230,24 @@ void CPointerManager::setCursorSurface(CWLSurface* surf, const Vector2D& hotspot
resetCursorImage(false);
if (surf) {
- currentCursorImage.size = {surf->wlr()->current.buffer_width, surf->wlr()->current.buffer_height};
currentCursorImage.surface = surf;
- currentCursorImage.scale = surf->wlr()->current.scale;
+ currentCursorImage.scale = surf->resource()->current.scale;
currentCursorImage.destroySurface = surf->events.destroy.registerListener([this](std::any data) { resetCursorImage(); });
- currentCursorImage.hyprListener_commitSurface.initCallback(
- &surf->wlr()->events.commit,
- [this](void* owner, void* data) {
- damageIfSoftware();
- currentCursorImage.size = {currentCursorImage.surface->wlr()->current.buffer_width, currentCursorImage.surface->wlr()->current.buffer_height};
- currentCursorImage.scale = currentCursorImage.surface && currentCursorImage.surface->wlr() ? currentCursorImage.surface->wlr()->current.scale : 1.F;
- recheckEnteredOutputs();
- updateCursorBackend();
- damageIfSoftware();
- },
- nullptr, "CPointerManager");
+ currentCursorImage.commitSurface = surf->resource()->events.commit.registerListener([this](std::any data) {
+ damageIfSoftware();
+ currentCursorImage.size = currentCursorImage.surface->resource()->current.buffer ? currentCursorImage.surface->resource()->current.buffer->size : Vector2D{};
+ currentCursorImage.scale = currentCursorImage.surface ? currentCursorImage.surface->resource()->current.scale : 1.F;
+ recheckEnteredOutputs();
+ updateCursorBackend();
+ damageIfSoftware();
+ });
- if (wlr_surface_has_buffer(surf->wlr())) {
+ if (surf->resource()->current.buffer) {
+ currentCursorImage.size = surf->resource()->current.buffer->size;
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
- wlr_surface_send_frame_done(surf->wlr(), &now);
+ surf->resource()->frame(&now);
}
}
@@ -278,9 +276,9 @@ void CPointerManager::recheckEnteredOutputs() {
if (!currentCursorImage.surface)
continue;
- wlr_surface_send_enter(currentCursorImage.surface->wlr(), s->monitor->output);
- PROTO::fractional->sendScale(currentCursorImage.surface->wlr(), s->monitor->scale);
- g_pCompositor->setPreferredScaleForSurface(currentCursorImage.surface->wlr(), s->monitor->scale);
+ currentCursorImage.surface->resource()->enter(s->monitor.lock());
+ PROTO::fractional->sendScale(currentCursorImage.surface->resource(), s->monitor->scale);
+ g_pCompositor->setPreferredScaleForSurface(currentCursorImage.surface->resource(), s->monitor->scale);
} else if (s->entered && !overlaps) {
s->entered = false;
@@ -293,7 +291,7 @@ void CPointerManager::recheckEnteredOutputs() {
if (!currentCursorImage.surface)
continue;
- wlr_surface_send_leave(currentCursorImage.surface->wlr(), s->monitor->output);
+ currentCursorImage.surface->resource()->leave(s->monitor.lock());
}
}
}
@@ -303,12 +301,12 @@ void CPointerManager::resetCursorImage(bool apply) {
if (currentCursorImage.surface) {
for (auto& m : g_pCompositor->m_vMonitors) {
- wlr_surface_send_leave(currentCursorImage.surface->wlr(), m->output);
+ currentCursorImage.surface->resource()->leave(m);
}
currentCursorImage.destroySurface.reset();
- currentCursorImage.hyprListener_commitSurface.removeCallback();
- currentCursorImage.surface = nullptr;
+ currentCursorImage.commitSurface.reset();
+ currentCursorImage.surface.reset();
} else if (currentCursorImage.pBuffer) {
wlr_buffer_unlock(currentCursorImage.pBuffer);
currentCursorImage.hyprListener_destroyBuffer.removeCallback();
@@ -451,7 +449,7 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, wlr_buff
return true;
}
-wlr_buffer* CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, wlr_texture* texture) {
+wlr_buffer* CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture) {
auto output = state->monitor->output;
int w = currentCursorImage.size.x, h = currentCursorImage.size.y;
@@ -528,7 +526,7 @@ void CPointerManager::renderSoftwareCursorsFor(SP<CMonitor> pMonitor, timespec*
if ((!state->hardwareFailed && state->softwareLocks == 0)) {
if (currentCursorImage.surface)
- wlr_surface_send_frame_done(currentCursorImage.surface->wlr(), now);
+ currentCursorImage.surface->resource()->frame(now);
return;
}
@@ -550,7 +548,7 @@ void CPointerManager::renderSoftwareCursorsFor(SP<CMonitor> pMonitor, timespec*
g_pHyprOpenGL->renderTextureWithDamage(texture, &box, &damage, 1.F);
if (currentCursorImage.surface)
- wlr_surface_send_frame_done(currentCursorImage.surface->wlr(), now);
+ currentCursorImage.surface->resource()->frame(now);
}
Vector2D CPointerManager::getCursorPosForMonitor(SP<CMonitor> pMonitor) {
@@ -762,17 +760,19 @@ void CPointerManager::onMonitorLayoutChange() {
damageIfSoftware();
}
-wlr_texture* CPointerManager::getCurrentCursorTexture() {
- if (!currentCursorImage.pBuffer && (!currentCursorImage.surface || !wlr_surface_get_texture(currentCursorImage.surface->wlr())))
+SP<CTexture> CPointerManager::getCurrentCursorTexture() {
+ if (!currentCursorImage.pBuffer && (!currentCursorImage.surface || !currentCursorImage.surface->resource()->current.buffer))
return nullptr;
if (currentCursorImage.pBuffer) {
- if (!currentCursorImage.pBufferTexture)
+ if (!currentCursorImage.pBufferTexture) {
currentCursorImage.pBufferTexture = wlr_texture_from_buffer(g_pCompositor->m_sWLRRenderer, currentCursorImage.pBuffer);
- return currentCursorImage.pBufferTexture;
+ currentCursorImage.bufferTex = makeShared<CTexture>(currentCursorImage.pBufferTexture);
+ }
+ return currentCursorImage.bufferTex;
}
- return wlr_surface_get_texture(currentCursorImage.surface->wlr());
+ return currentCursorImage.surface->resource()->current.buffer->texture;
}
void CPointerManager::attachPointer(SP<IPointer> pointer) {
diff --git a/src/managers/PointerManager.hpp b/src/managers/PointerManager.hpp
index db9f27e7..b71a79c3 100644
--- a/src/managers/PointerManager.hpp
+++ b/src/managers/PointerManager.hpp
@@ -11,6 +11,7 @@
class CMonitor;
struct wlr_input_device;
class IHID;
+class CTexture;
/*
The naming here is a bit confusing.
@@ -37,7 +38,7 @@ class CPointerManager {
void warpAbsolute(Vector2D abs, SP<IHID> dev);
void setCursorBuffer(wlr_buffer* buf, const Vector2D& hotspot, const float& scale);
- void setCursorSurface(CWLSurface* buf, const Vector2D& hotspot);
+ void setCursorSurface(SP<CWLSurface> buf, const Vector2D& hotspot);
void resetCursorImage(bool apply = true);
void lockSoftwareForMonitor(SP<CMonitor> pMonitor);
@@ -76,7 +77,7 @@ class CPointerManager {
Vector2D transformedHotspot(SP<CMonitor> pMonitor);
- wlr_texture* getCurrentCursorTexture();
+ SP<CTexture> getCurrentCursorTexture();
struct SPointerListener {
CHyprSignalListener destroy;
@@ -129,8 +130,9 @@ class CPointerManager {
} currentMonitorLayout;
struct {
- wlr_buffer* pBuffer = nullptr;
- CWLSurface* surface = nullptr;
+ wlr_buffer* pBuffer = nullptr;
+ SP<CTexture> bufferTex;
+ WP<CWLSurface> surface;
wlr_texture* pBufferTexture = nullptr;
Vector2D hotspot;
@@ -138,7 +140,7 @@ class CPointerManager {
float scale = 1.F;
CHyprSignalListener destroySurface;
- DYNLISTENER(commitSurface);
+ CHyprSignalListener commitSurface;
DYNLISTENER(destroyBuffer);
} currentCursorImage; // TODO: support various sizes per-output so we can have pixel-perfect cursors
@@ -165,7 +167,7 @@ class CPointerManager {
std::vector<SP<SMonitorPointerState>> monitorStates;
SP<SMonitorPointerState> stateFor(SP<CMonitor> mon);
bool attemptHardwareCursor(SP<SMonitorPointerState> state);
- wlr_buffer* renderHWCursorBuffer(SP<SMonitorPointerState> state, wlr_texture* texture);
+ wlr_buffer* renderHWCursorBuffer(SP<SMonitorPointerState> state, SP<CTexture> texture);
bool setHWCursorBuffer(SP<SMonitorPointerState> state, wlr_buffer* buf);
struct {
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp
index feff69e0..bd435b27 100644
--- a/src/managers/ProtocolManager.cpp
+++ b/src/managers/ProtocolManager.cpp
@@ -32,17 +32,45 @@
#include "../protocols/DataDeviceWlr.hpp"
#include "../protocols/PrimarySelection.hpp"
#include "../protocols/XWaylandShell.hpp"
+#include "../protocols/Viewporter.hpp"
+#include "../protocols/MesaDRM.hpp"
+#include "../protocols/LinuxDMABUF.hpp"
#include "../protocols/core/Seat.hpp"
#include "../protocols/core/DataDevice.hpp"
+#include "../protocols/core/Compositor.hpp"
+#include "../protocols/core/Subcompositor.hpp"
+#include "../protocols/core/Output.hpp"
+#include "../protocols/core/Shm.hpp"
+
+#include "../helpers/Monitor.hpp"
CProtocolManager::CProtocolManager() {
+ // Outputs are a bit dumb, we have to agree.
+ static auto P = g_pHookSystem->hookDynamic("monitorAdded", [](void* self, SCallbackInfo& info, std::any param) {
+ auto M = std::any_cast<CMonitor*>(param);
+ if (PROTO::outputs.contains(M->szName))
+ PROTO::outputs.erase(M->szName);
+ PROTO::outputs.emplace(M->szName, std::make_unique<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", M->szName), M->self.lock()));
+ });
+
+ static auto P2 = g_pHookSystem->hookDynamic("monitorRemoved", [](void* self, SCallbackInfo& info, std::any param) {
+ auto M = std::any_cast<CMonitor*>(param);
+ if (!PROTO::outputs.contains(M->szName))
+ return;
+ PROTO::outputs.at(M->szName)->remove();
+ });
+
// Core
- PROTO::seat = std::make_unique<CWLSeatProtocol>(&wl_seat_interface, 9, "WLSeat");
- PROTO::data = std::make_unique<CWLDataDeviceProtocol>(&wl_data_device_manager_interface, 3, "WLDataDevice");
+ PROTO::seat = std::make_unique<CWLSeatProtocol>(&wl_seat_interface, 9, "WLSeat");
+ PROTO::data = std::make_unique<CWLDataDeviceProtocol>(&wl_data_device_manager_interface, 3, "WLDataDevice");
+ PROTO::compositor = std::make_unique<CWLCompositorProtocol>(&wl_compositor_interface, 6, "WLCompositor");
+ PROTO::subcompositor = std::make_unique<CWLSubcompositorProtocol>(&wl_subcompositor_interface, 1, "WLSubcompositor");
+ PROTO::shm = std::make_unique<CWLSHMProtocol>(&wl_shm_interface, 1, "WLSHM");
// Extensions
+ PROTO::viewport = std::make_unique<CViewporterProtocol>(&wp_viewporter_interface, 1, "Viewporter");
PROTO::tearing = std::make_unique<CTearingControlProtocol>(&wp_tearing_control_manager_v1_interface, 1, "TearingControl");
PROTO::fractional = std::make_unique<CFractionalScaleProtocol>(&wp_fractional_scale_manager_v1_interface, 1, "FractionalScale");
PROTO::xdgOutput = std::make_unique<CXDGOutputProtocol>(&zxdg_output_manager_v1_interface, 3, "XDGOutput");
@@ -75,6 +103,8 @@ CProtocolManager::CProtocolManager() {
PROTO::dataWlr = std::make_unique<CDataDeviceWLRProtocol>(&zwlr_data_control_manager_v1_interface, 2, "DataDeviceWlr");
PROTO::primarySelection = std::make_unique<CPrimarySelectionProtocol>(&zwp_primary_selection_device_manager_v1_interface, 1, "PrimarySelection");
PROTO::xwaylandShell = std::make_unique<CXWaylandShellProtocol>(&xwayland_shell_v1_interface, 1, "XWaylandShell");
+ PROTO::mesaDRM = std::make_unique<CMesaDRMProtocol>(&wl_drm_interface, 2, "MesaDRM");
+ PROTO::linuxDma = std::make_unique<CLinuxDMABufV1Protocol>(&zwp_linux_dmabuf_v1_interface, 5, "LinuxDMABUF");
// Old protocol implementations.
// TODO: rewrite them to use hyprwayland-scanner.
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();
diff --git a/src/managers/SeatManager.hpp b/src/managers/SeatManager.hpp
index 35456cb3..e74d9ace 100644
--- a/src/managers/SeatManager.hpp
+++ b/src/managers/SeatManager.hpp
@@ -11,7 +11,7 @@
constexpr size_t MAX_SERIAL_STORE_LEN = 100;
-struct wlr_surface;
+class CWLSurfaceResource;
class CWLSeatResource;
class IPointer;
class IKeyboard;
@@ -29,9 +29,9 @@ class IKeyboard;
*/
class CSeatGrab {
public:
- bool accepts(wlr_surface* surf);
- void add(wlr_surface* surf);
- void remove(wlr_surface* surf);
+ bool accepts(SP<CWLSurfaceResource> surf);
+ void add(SP<CWLSurfaceResource> surf);
+ void remove(SP<CWLSurfaceResource> surf);
void setCallback(std::function<void()> onEnd_);
void clear();
@@ -42,8 +42,8 @@ class CSeatGrab {
bool removeOnInput = true; // on hard input e.g. click outside, remove
private:
- std::vector<wlr_surface*> surfs; // read-only
- std::function<void()> onEnd;
+ std::vector<WP<CWLSurfaceResource>> surfs;
+ std::function<void()> onEnd;
friend class CSeatManager;
};
@@ -57,11 +57,11 @@ class CSeatManager {
void setKeyboard(SP<IKeyboard> keeb);
void updateActiveKeyboardData(); // updates the clients with the keymap and repeat info
- void setKeyboardFocus(wlr_surface* surf);
+ void setKeyboardFocus(SP<CWLSurfaceResource> surf);
void sendKeyboardKey(uint32_t timeMs, uint32_t key, wl_keyboard_key_state state);
void sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
- void setPointerFocus(wlr_surface* surf, const Vector2D& local);
+ void setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D& local);
void sendPointerMotion(uint32_t timeMs, const Vector2D& local);
void sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_button_state state);
void sendPointerFrame();
@@ -69,7 +69,7 @@ class CSeatManager {
void sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double value, int32_t discrete, int32_t value120, wl_pointer_axis_source source,
wl_pointer_axis_relative_direction relative);
- void sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id, const Vector2D& local);
+ void sendTouchDown(SP<CWLSurfaceResource> surf, uint32_t timeMs, int32_t id, const Vector2D& local);
void sendTouchUp(uint32_t timeMs, int32_t id);
void sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D& local);
void sendTouchFrame();
@@ -83,24 +83,24 @@ class CSeatManager {
// pops the serial if it was valid, meaning it is consumed.
bool serialValid(SP<CWLSeatResource> seatResource, uint32_t serial);
- void onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, wlr_surface* surf, const Vector2D& hotspot);
+ void onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& hotspot);
SP<CWLSeatResource> seatResourceForClient(wl_client* client);
struct {
- wlr_surface* keyboardFocus = nullptr;
- WP<CWLSeatResource> keyboardFocusResource;
+ WP<CWLSurfaceResource> keyboardFocus;
+ WP<CWLSeatResource> keyboardFocusResource;
- wlr_surface* pointerFocus = nullptr;
- WP<CWLSeatResource> pointerFocusResource;
+ WP<CWLSurfaceResource> pointerFocus;
+ WP<CWLSeatResource> pointerFocusResource;
- wlr_surface* touchFocus = nullptr;
- WP<CWLSeatResource> touchFocusResource;
+ WP<CWLSurfaceResource> touchFocus;
+ WP<CWLSeatResource> touchFocusResource;
} state;
struct SSetCursorEvent {
- wlr_surface* surf = nullptr;
- Vector2D hotspot;
+ SP<CWLSurfaceResource> surf = nullptr;
+ Vector2D hotspot;
};
struct {
@@ -149,14 +149,13 @@ class CSeatManager {
struct {
CHyprSignalListener newSeatResource;
+ CHyprSignalListener keyboardSurfaceDestroy;
+ CHyprSignalListener pointerSurfaceDestroy;
+ CHyprSignalListener touchSurfaceDestroy;
} listeners;
Vector2D lastLocalCoords;
- DYNLISTENER(keyboardSurfaceDestroy);
- DYNLISTENER(pointerSurfaceDestroy);
- DYNLISTENER(touchSurfaceDestroy);
-
friend struct SSeatResourceContainer;
friend class CSeatGrab;
};
diff --git a/src/managers/SessionLockManager.cpp b/src/managers/SessionLockManager.cpp
index fd4841f4..3bec1c4b 100644
--- a/src/managers/SessionLockManager.cpp
+++ b/src/managers/SessionLockManager.cpp
@@ -20,7 +20,7 @@ SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : sur
listeners.destroy = surface_->events.destroy.registerListener([this](std::any data) {
if (pWlrSurface == g_pCompositor->m_pLastFocus)
- g_pCompositor->m_pLastFocus = nullptr;
+ g_pCompositor->m_pLastFocus.reset();
g_pSessionLockManager->removeSessionLockSurface(this);
});
@@ -70,7 +70,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
g_pHyprRenderer->damageMonitor(m.get());
});
- m_pSessionLock->listeners.destroy = pLock->events.destroyed.registerListener([this](std::any data) {
+ m_pSessionLock->listeners.destroy = pLock->events.destroyed.registerListener([](std::any data) {
g_pCompositor->focusSurface(nullptr);
for (auto& m : g_pCompositor->m_vMonitors)
@@ -117,7 +117,7 @@ float CSessionLockManager::getRedScreenAlphaForMonitor(uint64_t id) {
return std::clamp(NOMAPPEDSURFACETIMER->second.getSeconds() - /* delay for screencopy */ 0.5f, 0.f, 1.f);
}
-bool CSessionLockManager::isSurfaceSessionLock(wlr_surface* pSurface) {
+bool CSessionLockManager::isSurfaceSessionLock(SP<CWLSurfaceResource> pSurface) {
// TODO: this has some edge cases when it's wrong (e.g. destroyed lock but not yet surfaces)
// but can be easily fixed when I rewrite wlr_surface
diff --git a/src/managers/SessionLockManager.hpp b/src/managers/SessionLockManager.hpp
index d655a2bc..ea1b2029 100644
--- a/src/managers/SessionLockManager.hpp
+++ b/src/managers/SessionLockManager.hpp
@@ -8,13 +8,14 @@
class CSessionLockSurface;
class CSessionLock;
+class CWLSurfaceResource;
struct SSessionLockSurface {
SSessionLockSurface(SP<CSessionLockSurface> surface_);
WP<CSessionLockSurface> surface;
- wlr_surface* pWlrSurface = nullptr;
- uint64_t iMonitorID = -1;
+ WP<CWLSurfaceResource> pWlrSurface;
+ uint64_t iMonitorID = -1;
bool mapped = false;
@@ -49,7 +50,7 @@ class CSessionLockManager {
bool isSessionLocked();
bool isSessionLockPresent();
- bool isSurfaceSessionLock(wlr_surface*);
+ bool isSurfaceSessionLock(SP<CWLSurfaceResource>);
void removeSessionLockSurface(SSessionLockSurface*);
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index 4aebefcb..12387900 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -3,6 +3,7 @@
#include "../events/Events.hpp"
#include "../config/ConfigValue.hpp"
#include "../protocols/XDGShell.hpp"
+#include "../protocols/core/Compositor.hpp"
#include "../xwayland/XWayland.hpp"
#define OUTPUT_MANAGER_VERSION 3
@@ -19,11 +20,11 @@ CHyprXWaylandManager::~CHyprXWaylandManager() {
#endif
}
-wlr_surface* CHyprXWaylandManager::getWindowSurface(PHLWINDOW pWindow) {
- return pWindow->m_pWLSurface.wlr();
+SP<CWLSurfaceResource> CHyprXWaylandManager::getWindowSurface(PHLWINDOW pWindow) {
+ return pWindow->m_pWLSurface->resource();
}
-void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) {
+void CHyprXWaylandManager::activateSurface(SP<CWLSurfaceResource> pSurface, bool activate) {
if (!pSurface)
return;
@@ -33,7 +34,7 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate)
if (!w->m_bIsMapped)
continue;
- if (w->m_pWLSurface.wlr() != pSurface)
+ if (w->m_pWLSurface->resource() != pSurface)
continue;
if (w->m_bIsX11) {
@@ -131,10 +132,6 @@ void CHyprXWaylandManager::setWindowSize(PHLWINDOW pWindow, Vector2D size, bool
pWindow->m_vPendingSizeAcks.push_back(std::make_pair<>(pWindow->m_pXDGSurface->toplevel->setSize(size), size.floor()));
}
-wlr_surface* CHyprXWaylandManager::surfaceAt(PHLWINDOW pWindow, const Vector2D& client, Vector2D& surface) {
- return wlr_surface_surface_at(pWindow->m_pWLSurface.wlr(), client.x, client.y, &surface.x, &surface.y);
-}
-
bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) {
if (pWindow->m_bIsX11) {
for (auto& a : pWindow->m_pXWaylandSurface->atoms)
diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp
index 5bbab802..a9f95974 100644
--- a/src/managers/XWaylandManager.hpp
+++ b/src/managers/XWaylandManager.hpp
@@ -5,25 +5,25 @@
class CWindow; // because clangd
typedef SP<CWindow> PHLWINDOW;
+class CWLSurfaceResource;
class CHyprXWaylandManager {
public:
CHyprXWaylandManager();
~CHyprXWaylandManager();
- wlr_surface* getWindowSurface(PHLWINDOW);
- void activateSurface(wlr_surface*, bool);
- void activateWindow(PHLWINDOW, bool);
- void getGeometryForWindow(PHLWINDOW, CBox*);
- void sendCloseWindow(PHLWINDOW);
- void setWindowSize(PHLWINDOW, Vector2D, bool force = false);
- void setWindowFullscreen(PHLWINDOW, bool);
- wlr_surface* surfaceAt(PHLWINDOW, const Vector2D&, Vector2D&);
- bool shouldBeFloated(PHLWINDOW, bool pending = false);
- void checkBorders(PHLWINDOW);
- Vector2D getMaxSizeForWindow(PHLWINDOW);
- Vector2D getMinSizeForWindow(PHLWINDOW);
- Vector2D xwaylandToWaylandCoords(const Vector2D&);
+ SP<CWLSurfaceResource> getWindowSurface(PHLWINDOW);
+ void activateSurface(SP<CWLSurfaceResource>, bool);
+ void activateWindow(PHLWINDOW, bool);
+ void getGeometryForWindow(PHLWINDOW, CBox*);
+ void sendCloseWindow(PHLWINDOW);
+ void setWindowSize(PHLWINDOW, Vector2D, bool force = false);
+ void setWindowFullscreen(PHLWINDOW, bool);
+ bool shouldBeFloated(PHLWINDOW, bool pending = false);
+ void checkBorders(PHLWINDOW);
+ Vector2D getMaxSizeForWindow(PHLWINDOW);
+ Vector2D getMinSizeForWindow(PHLWINDOW);
+ Vector2D xwaylandToWaylandCoords(const Vector2D&);
};
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager; \ No newline at end of file
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index a71059e4..a38acdbf 100644
--- a/src/managers/input/IdleInhibitor.cpp
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -14,7 +14,7 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
recheckIdleInhibitorStatus();
});
- auto WLSurface = CWLSurface::surfaceFromWlr(PINHIBIT->inhibitor->surface);
+ auto WLSurface = CWLSurface::fromResource(PINHIBIT->inhibitor->surface.lock());
if (!WLSurface) {
Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Assuming it's visible.");
@@ -37,7 +37,7 @@ void CInputManager::recheckIdleInhibitorStatus() {
return;
}
- auto WLSurface = CWLSurface::surfaceFromWlr(ii->inhibitor->surface);
+ auto WLSurface = CWLSurface::fromResource(ii->inhibitor->surface.lock());
if (!WLSurface)
continue;
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 27d04699..c12ac389 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -43,7 +43,7 @@ CInputManager::CInputManager() {
Debug::log(LOG, "cursorImage request: shape {} -> {}", (uint32_t)event.shape, event.shapeName);
- m_sCursorSurfaceInfo.wlSurface.unassign();
+ m_sCursorSurfaceInfo.wlSurface->unassign();
m_sCursorSurfaceInfo.vHotspot = {};
m_sCursorSurfaceInfo.name = event.shapeName;
m_sCursorSurfaceInfo.hidden = false;
@@ -58,6 +58,8 @@ CInputManager::CInputManager() {
m_sListeners.newVirtualMouse =
PROTO::virtualPointer->events.newPointer.registerListener([this](std::any data) { this->newVirtualMouse(std::any_cast<SP<CVirtualPointerV1Resource>>(data)); });
m_sListeners.setCursor = g_pSeatManager->events.setCursor.registerListener([this](std::any d) { this->processMouseRequest(d); });
+
+ m_sCursorSurfaceInfo.wlSurface = CWLSurface::create();
}
CInputManager::~CInputManager() {
@@ -115,8 +117,8 @@ void CInputManager::sendMotionEventsToFocused() {
return;
// todo: this sucks ass
- const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_pLastFocus);
- const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
+ const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_pLastFocus.lock());
+ const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus.lock());
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
@@ -125,7 +127,7 @@ void CInputManager::sendMotionEventsToFocused() {
m_bEmptyFocusCursorSet = false;
- g_pSeatManager->setPointerFocus(g_pCompositor->m_pLastFocus, LOCAL);
+ g_pSeatManager->setPointerFocus(g_pCompositor->m_pLastFocus.lock(), LOCAL);
}
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
@@ -141,14 +143,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
const auto FOLLOWMOUSE = *PFOLLOWONDND && PROTO::data->dndActive() ? 1 : *PFOLLOWMOUSE;
- m_pFoundSurfaceToFocus = nullptr;
+ m_pFoundSurfaceToFocus.reset();
m_pFoundLSToFocus.reset();
m_pFoundWindowToFocus.reset();
- wlr_surface* foundSurface = nullptr;
- Vector2D surfaceCoords;
- Vector2D surfacePos = Vector2D(-1337, -1337);
- PHLWINDOW pFoundWindow;
- PHLLS pFoundLayerSurface;
+ SP<CWLSurfaceResource> foundSurface;
+ Vector2D surfaceCoords;
+ Vector2D surfacePos = Vector2D(-1337, -1337);
+ PHLWINDOW pFoundWindow;
+ PHLLS pFoundLayerSurface;
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState)
return;
@@ -191,12 +193,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (forcedFocus) {
pFoundWindow = forcedFocus;
surfacePos = pFoundWindow->m_vRealPosition.value();
- foundSurface = pFoundWindow->m_pWLSurface.wlr();
+ foundSurface = pFoundWindow->m_pWLSurface->resource();
}
// constraints
if (!g_pSeatManager->mouse.expired() && isConstrained()) {
- const auto SURF = CWLSurface::surfaceFromWlr(g_pCompositor->m_pLastFocus);
+ const auto SURF = CWLSurface::fromResource(g_pCompositor->m_pLastFocus.lock());
const auto CONSTRAINT = SURF->constraint();
if (SURF && CONSTRAINT) {
@@ -223,7 +225,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// if we are holding a pointer button,
// and we're not dnd-ing, don't refocus. Keep focus on last surface.
if (!PROTO::data->dndActive() && !m_lCurrentlyHeldButtons.empty() && g_pCompositor->m_pLastFocus && g_pSeatManager->state.pointerFocus && !m_bHardInput) {
- foundSurface = g_pSeatManager->state.pointerFocus;
+ foundSurface = g_pSeatManager->state.pointerFocus.lock();
// IME popups aren't desktop-like elements
// TODO: make them.
@@ -233,7 +235,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
m_bFocusHeldByButtons = true;
m_bRefocusHeldByButtons = refocus;
} else {
- auto HLSurface = CWLSurface::surfaceFromWlr(foundSurface);
+ auto HLSurface = CWLSurface::fromResource(foundSurface);
if (HLSurface) {
const auto BOX = HLSurface->getSurfaceBoxGlobal();
@@ -275,7 +277,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!foundSurface) {
auto popup = g_pInputManager->m_sIMERelay.popupFromCoords(mouseCoords);
if (popup) {
- foundSurface = popup->getWlrSurface();
+ foundSurface = popup->getSurface();
surfacePos = popup->globalBox().pos();
}
}
@@ -306,7 +308,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
surfacePos = Vector2D(-1337, -1337);
} else {
- foundSurface = pFoundWindow->m_pWLSurface.wlr();
+ foundSurface = pFoundWindow->m_pWLSurface->resource();
surfacePos = pFoundWindow->m_vRealPosition.value();
}
}
@@ -345,7 +347,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!pFoundWindow->m_bIsX11) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
} else {
- foundSurface = pFoundWindow->m_pWLSurface.wlr();
+ foundSurface = pFoundWindow->m_pWLSurface->resource();
surfacePos = pFoundWindow->m_vRealPosition.value();
}
}
@@ -369,9 +371,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
return; // setGrab will refocus
} else {
// we need to grab the last surface.
- foundSurface = g_pSeatManager->state.pointerFocus;
+ foundSurface = g_pSeatManager->state.pointerFocus.lock();
- auto HLSurface = CWLSurface::surfaceFromWlr(foundSurface);
+ auto HLSurface = CWLSurface::fromResource(foundSurface);
if (HLSurface) {
const auto BOX = HLSurface->getSurfaceBoxGlobal();
@@ -423,7 +425,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
bool allowKeyboardRefocus = true;
if (!refocus && g_pCompositor->m_pLastFocus) {
- const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
+ const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus.lock());
if (PLS && PLS->layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
allowKeyboardRefocus = false;
@@ -441,7 +443,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
return;
}
- if (pFoundWindow && foundSurface == pFoundWindow->m_pWLSurface.wlr() && !m_bCursorImageOverridden) {
+ if (pFoundWindow && foundSurface == pFoundWindow->m_pWLSurface->resource() && !m_bCursorImageOverridden) {
const auto BOX = pFoundWindow->getWindowMainSurfaceBox();
if (!VECINRECT(mouseCoords, BOX.x, BOX.y, BOX.x + BOX.width, BOX.y + BOX.height))
setCursorImageOverride("left_ptr");
@@ -555,11 +557,11 @@ void CInputManager::processMouseRequest(std::any E) {
Debug::log(LOG, "cursorImage request: surface {:x}", (uintptr_t)e.surf);
- if (e.surf != m_sCursorSurfaceInfo.wlSurface.wlr()) {
- m_sCursorSurfaceInfo.wlSurface.unassign();
+ if (e.surf != m_sCursorSurfaceInfo.wlSurface->resource()) {
+ m_sCursorSurfaceInfo.wlSurface->unassign();
if (e.surf)
- m_sCursorSurfaceInfo.wlSurface.assign(e.surf);
+ m_sCursorSurfaceInfo.wlSurface->assign(e.surf);
}
if (e.surf) {
@@ -573,7 +575,7 @@ void CInputManager::processMouseRequest(std::any E) {
m_sCursorSurfaceInfo.name = "";
m_sCursorSurfaceInfo.inUse = true;
- g_pHyprRenderer->setCursorSurface(&m_sCursorSurfaceInfo.wlSurface, e.hotspot.x, e.hotspot.y);
+ g_pHyprRenderer->setCursorSurface(m_sCursorSurfaceInfo.wlSurface, e.hotspot.x, e.hotspot.y);
}
void CInputManager::restoreCursorIconToApp() {
@@ -586,8 +588,8 @@ void CInputManager::restoreCursorIconToApp() {
}
if (m_sCursorSurfaceInfo.name.empty()) {
- if (m_sCursorSurfaceInfo.wlSurface.exists())
- g_pHyprRenderer->setCursorSurface(&m_sCursorSurfaceInfo.wlSurface, m_sCursorSurfaceInfo.vHotspot.x, m_sCursorSurfaceInfo.vHotspot.y);
+ if (m_sCursorSurfaceInfo.wlSurface->exists())
+ g_pHyprRenderer->setCursorSurface(m_sCursorSurfaceInfo.wlSurface, m_sCursorSurfaceInfo.vHotspot.x, m_sCursorSurfaceInfo.vHotspot.y);
} else {
g_pHyprRenderer->setCursorFromName(m_sCursorSurfaceInfo.name);
}
@@ -696,7 +698,7 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) {
if (!g_pSeatManager->state.pointerFocus)
break;
- auto HLSurf = CWLSurface::surfaceFromWlr(g_pSeatManager->state.pointerFocus);
+ auto HLSurf = CWLSurface::fromResource(g_pSeatManager->state.pointerFocus.lock());
if (HLSurf && HLSurf->getWindow())
g_pCompositor->changeWindowZOrder(HLSurf->getWindow(), true);
@@ -1399,7 +1401,7 @@ bool CInputManager::isConstrained() {
if (!C)
continue;
- if (!C->isActive() || C->owner()->wlr() != g_pCompositor->m_pLastFocus)
+ if (!C->isActive() || C->owner()->resource() != g_pCompositor->m_pLastFocus)
continue;
return true;
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index f7d9ae57..9fdf061c 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -44,10 +44,10 @@ enum eBorderIconDirection {
};
struct STouchData {
- PHLWINDOWREF touchFocusWindow;
- PHLLSREF touchFocusLS;
- wlr_surface* touchFocusSurface = nullptr;
- Vector2D touchSurfaceOrigin;
+ PHLWINDOWREF touchFocusWindow;
+ PHLLSREF touchFocusLS;
+ WP<CWLSurfaceResource> touchFocusSurface;
+ Vector2D touchSurfaceOrigin;
};
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
@@ -236,9 +236,9 @@ class CInputManager {
void applyConfigToKeyboard(SP<IKeyboard>);
// this will be set after a refocus()
- wlr_surface* m_pFoundSurfaceToFocus = nullptr;
- PHLLSREF m_pFoundLSToFocus;
- PHLWINDOWREF m_pFoundWindowToFocus;
+ WP<CWLSurfaceResource> m_pFoundSurfaceToFocus;
+ PHLLSREF m_pFoundLSToFocus;
+ PHLWINDOWREF m_pFoundWindowToFocus;
// for holding focus on buttons held
bool m_bFocusHeldByButtons = false;
@@ -268,11 +268,11 @@ class CInputManager {
// cursor surface
struct cursorSI {
- bool hidden = false; // null surface = hidden
- CWLSurface wlSurface;
- Vector2D vHotspot;
- std::string name; // if not empty, means set by name.
- bool inUse = false;
+ bool hidden = false; // null surface = hidden
+ SP<CWLSurface> wlSurface;
+ Vector2D vHotspot;
+ std::string name; // if not empty, means set by name.
+ bool inUse = false;
} m_sCursorSurfaceInfo;
void restoreCursorIconToApp(); // no-op if restored
diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp
index 9ff584e6..a8757030 100644
--- a/src/managers/input/InputMethodPopup.cpp
+++ b/src/managers/input/InputMethodPopup.cpp
@@ -3,22 +3,24 @@
#include "../../Compositor.hpp"
#include "../../protocols/FractionalScale.hpp"
#include "../../protocols/InputMethodV2.hpp"
+#include "../../protocols/core/Compositor.hpp"
CInputPopup::CInputPopup(SP<CInputMethodPopupV2> popup_) : popup(popup_) {
listeners.commit = popup_->events.commit.registerListener([this](std::any d) { onCommit(); });
listeners.map = popup_->events.map.registerListener([this](std::any d) { onMap(); });
listeners.unmap = popup_->events.unmap.registerListener([this](std::any d) { onUnmap(); });
listeners.destroy = popup_->events.destroy.registerListener([this](std::any d) { onDestroy(); });
- surface.assign(popup_->surface());
+ surface = CWLSurface::create();
+ surface->assign(popup_->surface());
}
-CWLSurface* CInputPopup::queryOwner() {
+SP<CWLSurface> CInputPopup::queryOwner() {
const auto FOCUSED = g_pInputManager->m_sIMERelay.getFocusedTextInput();
if (!FOCUSED)
return nullptr;
- return CWLSurface::surfaceFromWlr(FOCUSED->focusedSurface());
+ return CWLSurface::fromResource(FOCUSED->focusedSurface());
}
void CInputPopup::onDestroy() {
@@ -36,7 +38,7 @@ void CInputPopup::onMap() {
if (!PMONITOR)
return;
- PROTO::fractional->sendScale(surface.wlr(), PMONITOR->scale);
+ PROTO::fractional->sendScale(surface->resource(), PMONITOR->scale);
}
void CInputPopup::onUnmap() {
@@ -69,7 +71,7 @@ void CInputPopup::damageSurface() {
}
Vector2D pos = globalBox().pos();
- g_pHyprRenderer->damageSurface(surface.wlr(), pos.x, pos.y);
+ g_pHyprRenderer->damageSurface(surface->resource(), pos.x, pos.y);
}
void CInputPopup::updateBox() {
@@ -98,7 +100,7 @@ void CInputPopup::updateBox() {
cursorBoxParent = {0, 0, (int)parentBox.w, (int)parentBox.h};
}
- Vector2D currentPopupSize = surface.getViewporterCorrectedSize();
+ Vector2D currentPopupSize = surface->getViewporterCorrectedSize();
CMonitor* pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle());
@@ -127,9 +129,9 @@ void CInputPopup::updateBox() {
const auto PML = g_pCompositor->getMonitorFromID(lastMonitor);
if (PML)
- wlr_surface_send_leave(surface.wlr(), PML->output);
+ surface->resource()->leave(PML->self.lock());
- wlr_surface_send_enter(surface.wlr(), PM->output);
+ surface->resource()->enter(PM->self.lock());
lastMonitor = PM->ID;
}
@@ -151,6 +153,6 @@ bool CInputPopup::isVecInPopup(const Vector2D& point) {
return globalBox().containsPoint(point);
}
-wlr_surface* CInputPopup::getWlrSurface() {
- return surface.wlr();
+SP<CWLSurfaceResource> CInputPopup::getSurface() {
+ return surface->resource();
}
diff --git a/src/managers/input/InputMethodPopup.hpp b/src/managers/input/InputMethodPopup.hpp
index 61b45d74..9c5491bf 100644
--- a/src/managers/input/InputMethodPopup.hpp
+++ b/src/managers/input/InputMethodPopup.hpp
@@ -12,18 +12,18 @@ class CInputPopup {
public:
CInputPopup(SP<CInputMethodPopupV2> popup);
- void damageEntire();
- void damageSurface();
+ void damageEntire();
+ void damageSurface();
- bool isVecInPopup(const Vector2D& point);
+ bool isVecInPopup(const Vector2D& point);
- CBox globalBox();
- wlr_surface* getWlrSurface();
+ CBox globalBox();
+ SP<CWLSurfaceResource> getSurface();
- void onCommit();
+ void onCommit();
private:
- CWLSurface* queryOwner();
+ SP<CWLSurface> queryOwner();
void updateBox();
void onDestroy();
@@ -31,7 +31,7 @@ class CInputPopup {
void onUnmap();
WP<CInputMethodPopupV2> popup;
- CWLSurface surface;
+ SP<CWLSurface> surface;
CBox lastBoxLocal;
uint64_t lastMonitor = -1;
diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp
index abf18fba..92ab14d8 100644
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -3,9 +3,11 @@
#include "../../Compositor.hpp"
#include "../../protocols/TextInputV3.hpp"
#include "../../protocols/InputMethodV2.hpp"
+#include "../../protocols/core/Compositor.hpp"
CInputMethodRelay::CInputMethodRelay() {
- static auto P = g_pHookSystem->hookDynamic("keyboardFocus", [&](void* self, SCallbackInfo& info, std::any param) { onKeyboardFocus(std::any_cast<wlr_surface*>(param)); });
+ static auto P =
+ g_pHookSystem->hookDynamic("keyboardFocus", [&](void* self, SCallbackInfo& info, std::any param) { onKeyboardFocus(std::any_cast<SP<CWLSurfaceResource>>(param)); });
listeners.newTIV3 = PROTO::textInputV3->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(ti); });
listeners.newIME = PROTO::ime->events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast<SP<CInputMethodV2>>(ime)); });
@@ -54,17 +56,17 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
return;
for (auto& ti : m_vTextInputs) {
- if (ti->client() != wl_resource_get_client(g_pCompositor->m_pLastFocus->resource))
+ if (ti->client() != g_pCompositor->m_pLastFocus->client())
continue;
if (ti->isV3())
- ti->enter(g_pCompositor->m_pLastFocus);
+ ti->enter(g_pCompositor->m_pLastFocus.lock());
else
- ti->onEnabled(g_pCompositor->m_pLastFocus);
+ ti->onEnabled(g_pCompositor->m_pLastFocus.lock());
}
}
-void CInputMethodRelay::setIMEPopupFocus(CInputPopup* pPopup, wlr_surface* pSurface) {
+void CInputMethodRelay::setIMEPopupFocus(CInputPopup* pPopup, SP<CWLSurfaceResource> pSurface) {
pPopup->onCommit();
}
@@ -125,7 +127,7 @@ void CInputMethodRelay::commitIMEState(CTextInput* pInput) {
pInput->commitStateToIME(m_pIME.lock());
}
-void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
+void CInputMethodRelay::onKeyboardFocus(SP<CWLSurfaceResource> pSurface) {
if (m_pIME.expired())
return;
@@ -145,7 +147,7 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
if (!ti->isV3())
continue;
- if (ti->client() != wl_resource_get_client(pSurface->resource))
+ if (ti->client() != pSurface->client())
continue;
ti->enter(pSurface);
@@ -161,9 +163,9 @@ CInputPopup* CInputMethodRelay::popupFromCoords(const Vector2D& point) {
return nullptr;
}
-CInputPopup* CInputMethodRelay::popupFromSurface(const wlr_surface* surface) {
+CInputPopup* CInputMethodRelay::popupFromSurface(const SP<CWLSurfaceResource> surface) {
for (auto& p : m_vIMEPopups) {
- if (p->getWlrSurface() == surface)
+ if (p->getSurface() == surface)
return p.get();
}
diff --git a/src/managers/input/InputMethodRelay.hpp b/src/managers/input/InputMethodRelay.hpp
index 2896e8e8..e942add8 100644
--- a/src/managers/input/InputMethodRelay.hpp
+++ b/src/managers/input/InputMethodRelay.hpp
@@ -26,15 +26,15 @@ class CInputMethodRelay {
void commitIMEState(CTextInput* pInput);
void removeTextInput(CTextInput* pInput);
- void onKeyboardFocus(wlr_surface*);
+ void onKeyboardFocus(SP<CWLSurfaceResource>);
CTextInput* getFocusedTextInput();
- void setIMEPopupFocus(CInputPopup*, wlr_surface*);
+ void setIMEPopupFocus(CInputPopup*, SP<CWLSurfaceResource>);
void removePopup(CInputPopup*);
CInputPopup* popupFromCoords(const Vector2D& point);
- CInputPopup* popupFromSurface(const wlr_surface* surface);
+ CInputPopup* popupFromSurface(const SP<CWLSurfaceResource> surface);
void updateAllPopups();
@@ -44,7 +44,7 @@ class CInputMethodRelay {
std::vector<std::unique_ptr<CTextInput>> m_vTextInputs;
std::vector<std::unique_ptr<CInputPopup>> m_vIMEPopups;
- wlr_surface* m_pLastKbFocus = nullptr;
+ WP<CWLSurfaceResource> m_pLastKbFocus;
struct {
CHyprSignalListener newTIV3;
@@ -57,6 +57,6 @@ class CInputMethodRelay {
friend class CHyprRenderer;
friend class CInputManager;
friend class CTextInputV1ProtocolManager;
- friend struct CTextInput;
+ friend class CTextInput;
friend class CHyprRenderer;
};
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index 56e817ec..f1157e4b 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -20,7 +20,7 @@ static void unfocusTool(SP<CTabletTool> tool) {
PROTO::tablet->proximityOut(tool);
}
-static void focusTool(SP<CTabletTool> tool, SP<CTablet> tablet, wlr_surface* surf) {
+static void focusTool(SP<CTabletTool> tool, SP<CTablet> tablet, SP<CWLSurfaceResource> surf) {
if (tool->getSurface() == surf || !surf)
return;
@@ -37,7 +37,7 @@ static void focusTool(SP<CTabletTool> tool, SP<CTablet> tablet, wlr_surface* sur
}
static void refocusTablet(SP<CTablet> tab, SP<CTabletTool> tool, bool motion = false) {
- const auto LASTHLSURFACE = CWLSurface::surfaceFromWlr(g_pSeatManager->state.pointerFocus);
+ const auto LASTHLSURFACE = CWLSurface::fromResource(g_pSeatManager->state.pointerFocus.lock());
if (!LASTHLSURFACE || !tool->active) {
if (tool->getSurface())
@@ -57,7 +57,7 @@ static void refocusTablet(SP<CTablet> tab, SP<CTabletTool> tool, bool motion = f
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
- focusTool(tool, tab, g_pSeatManager->state.pointerFocus);
+ focusTool(tool, tab, g_pSeatManager->state.pointerFocus.lock());
if (!motion)
return;
diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp
index b3f0b0cb..4c7ffe6e 100644
--- a/src/managers/input/TextInput.cpp
+++ b/src/managers/input/TextInput.cpp
@@ -5,6 +5,7 @@
#include "../../Compositor.hpp"
#include "../../protocols/TextInputV3.hpp"
#include "../../protocols/InputMethodV2.hpp"
+#include "../../protocols/core/Compositor.hpp"
CTextInput::CTextInput(STextInputV1* ti) : pV1Input(ti) {
ti->pTextInput = this;
@@ -56,8 +57,8 @@ void CTextInput::initCallbacks() {
hyprListener_textInputDestroy.removeCallback();
hyprListener_textInputDisable.removeCallback();
hyprListener_textInputEnable.removeCallback();
- hyprListener_surfaceDestroyed.removeCallback();
- hyprListener_surfaceUnmapped.removeCallback();
+ listeners.surfaceUnmap.reset();
+ listeners.surfaceDestroy.reset();
g_pInputManager->m_sIMERelay.removeTextInput(this);
},
@@ -65,7 +66,7 @@ void CTextInput::initCallbacks() {
}
}
-void CTextInput::onEnabled(wlr_surface* surfV1) {
+void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) {
Debug::log(LOG, "TI ENABLE");
if (g_pInputManager->m_sIMERelay.m_pIME.expired()) {
@@ -75,7 +76,7 @@ void CTextInput::onEnabled(wlr_surface* surfV1) {
// v1 only, map surface to PTI
if (!isV3()) {
- wlr_surface* pSurface = surfV1;
+ SP<CWLSurfaceResource> pSurface = surfV1;
if (g_pCompositor->m_pLastFocus != pSurface || !pV1Input->active)
return;
@@ -97,8 +98,8 @@ void CTextInput::onDisabled() {
if (!isV3())
leave();
- hyprListener_surfaceDestroyed.removeCallback();
- hyprListener_surfaceUnmapped.removeCallback();
+ listeners.surfaceUnmap.reset();
+ listeners.surfaceDestroy.reset();
g_pInputManager->m_sIMERelay.deactivateIME(this);
}
@@ -117,50 +118,44 @@ void CTextInput::onCommit() {
g_pInputManager->m_sIMERelay.commitIMEState(this);
}
-void CTextInput::setFocusedSurface(wlr_surface* pSurface) {
+void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
if (pSurface == pFocusedSurface)
return;
pFocusedSurface = pSurface;
- hyprListener_surfaceUnmapped.removeCallback();
- hyprListener_surfaceDestroyed.removeCallback();
+ listeners.surfaceUnmap.reset();
+ listeners.surfaceDestroy.reset();
if (!pSurface)
return;
- hyprListener_surfaceUnmapped.initCallback(
- &pSurface->events.unmap,
- [this](void* owner, void* data) {
- Debug::log(LOG, "Unmap TI owner1");
-
- if (enterLocks)
- enterLocks--;
- pFocusedSurface = nullptr;
- hyprListener_surfaceUnmapped.removeCallback();
- hyprListener_surfaceDestroyed.removeCallback();
- },
- this, "CTextInput");
-
- hyprListener_surfaceDestroyed.initCallback(
- &pSurface->events.destroy,
- [this](void* owner, void* data) {
- Debug::log(LOG, "destroy TI owner1");
-
- if (enterLocks)
- enterLocks--;
- pFocusedSurface = nullptr;
- hyprListener_surfaceUnmapped.removeCallback();
- hyprListener_surfaceDestroyed.removeCallback();
- },
- this, "CTextInput");
+ listeners.surfaceUnmap = pSurface->events.unmap.registerListener([this](std::any d) {
+ Debug::log(LOG, "Unmap TI owner1");
+
+ if (enterLocks)
+ enterLocks--;
+ pFocusedSurface.reset();
+ listeners.surfaceUnmap.reset();
+ listeners.surfaceDestroy.reset();
+ });
+
+ listeners.surfaceDestroy = pSurface->events.destroy.registerListener([this](std::any d) {
+ Debug::log(LOG, "Destroy TI owner1");
+
+ if (enterLocks)
+ enterLocks--;
+ pFocusedSurface.reset();
+ listeners.surfaceUnmap.reset();
+ listeners.surfaceDestroy.reset();
+ });
}
bool CTextInput::isV3() {
return !pV1Input;
}
-void CTextInput::enter(wlr_surface* pSurface) {
+void CTextInput::enter(SP<CWLSurfaceResource> pSurface) {
if (!pSurface || !pSurface->mapped)
return;
@@ -182,7 +177,7 @@ void CTextInput::enter(wlr_surface* pSurface) {
if (isV3())
pV3Input->enter(pSurface);
else {
- zwp_text_input_v1_send_enter(pV1Input->resourceImpl, pSurface->resource);
+ zwp_text_input_v1_send_enter(pV1Input->resourceImpl, pSurface->getResource()->resource());
pV1Input->active = true;
}
@@ -211,8 +206,8 @@ void CTextInput::leave() {
g_pInputManager->m_sIMERelay.deactivateIME(this);
}
-wlr_surface* CTextInput::focusedSurface() {
- return pFocusedSurface;
+SP<CWLSurfaceResource> CTextInput::focusedSurface() {
+ return pFocusedSurface.lock();
}
wl_client* CTextInput::client() {
diff --git a/src/managers/input/TextInput.hpp b/src/managers/input/TextInput.hpp
index ff21da95..30fbb4cc 100644
--- a/src/managers/input/TextInput.hpp
+++ b/src/managers/input/TextInput.hpp
@@ -6,12 +6,12 @@
#include "../../helpers/signal/Listener.hpp"
#include <memory>
-struct wlr_surface;
struct wl_client;
struct STextInputV1;
class CTextInputV3;
class CInputMethodV2;
+class CWLSurfaceResource;
class CTextInput {
public:
@@ -19,43 +19,43 @@ class CTextInput {
CTextInput(STextInputV1* ti);
~CTextInput();
- bool isV3();
- void enter(wlr_surface* pSurface);
- void leave();
- void tiV1Destroyed();
- wl_client* client();
- void commitStateToIME(SP<CInputMethodV2> ime);
- void updateIMEState(SP<CInputMethodV2> ime);
+ bool isV3();
+ void enter(SP<CWLSurfaceResource> pSurface);
+ void leave();
+ void tiV1Destroyed();
+ wl_client* client();
+ void commitStateToIME(SP<CInputMethodV2> ime);
+ void updateIMEState(SP<CInputMethodV2> ime);
- void onEnabled(wlr_surface* surfV1 = nullptr);
- void onDisabled();
- void onCommit();
+ void onEnabled(SP<CWLSurfaceResource> surfV1 = nullptr);
+ void onDisabled();
+ void onCommit();
- bool hasCursorRectangle();
- CBox cursorBox();
+ bool hasCursorRectangle();
+ CBox cursorBox();
- wlr_surface* focusedSurface();
+ SP<CWLSurfaceResource> focusedSurface();
private:
- void setFocusedSurface(wlr_surface* pSurface);
- void initCallbacks();
+ void setFocusedSurface(SP<CWLSurfaceResource> pSurface);
+ void initCallbacks();
- wlr_surface* pFocusedSurface = nullptr;
- int enterLocks = 0;
- WP<CTextInputV3> pV3Input;
- STextInputV1* pV1Input = nullptr;
+ WP<CWLSurfaceResource> pFocusedSurface;
+ int enterLocks = 0;
+ WP<CTextInputV3> pV3Input;
+ STextInputV1* pV1Input = nullptr;
DYNLISTENER(textInputEnable);
DYNLISTENER(textInputDisable);
DYNLISTENER(textInputCommit);
DYNLISTENER(textInputDestroy);
- DYNLISTENER(surfaceUnmapped);
- DYNLISTENER(surfaceDestroyed);
struct {
CHyprSignalListener enable;
CHyprSignalListener disable;
CHyprSignalListener commit;
CHyprSignalListener destroy;
+ CHyprSignalListener surfaceUnmap;
+ CHyprSignalListener surfaceDestroy;
} listeners;
}; \ No newline at end of file
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index 7748813b..a1f949c2 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -77,7 +77,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
} else
return; // oops, nothing found.
- g_pSeatManager->sendTouchDown(m_sTouchData.touchFocusSurface, e.timeMs, e.touchID, local);
+ g_pSeatManager->sendTouchDown(m_sTouchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local);
PROTO::idle->onActivity();
}