summaryrefslogtreecommitdiff
path: root/src/managers/input/TextInput.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/input/TextInput.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/input/TextInput.cpp')
-rw-r--r--src/managers/input/TextInput.cpp71
1 files changed, 33 insertions, 38 deletions
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() {