diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-01 16:41:17 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-05-01 16:41:17 +0100 |
| commit | 8bcccf9f0f0f69986e315d4288dfdbf119dd19db (patch) | |
| tree | eebb6714fc1e41a0df2784ed22752f0efe2bbdc1 /src/managers/input/InputMethodPopup.cpp | |
| parent | 4ed6b69b68a544a81cec583a1ad8aff218f7db5d (diff) | |
ime-v2: move to new impl
Diffstat (limited to 'src/managers/input/InputMethodPopup.cpp')
| -rw-r--r-- | src/managers/input/InputMethodPopup.cpp | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp index 3a56d30c..f2d49ae8 100644 --- a/src/managers/input/InputMethodPopup.cpp +++ b/src/managers/input/InputMethodPopup.cpp @@ -2,37 +2,14 @@ #include "InputManager.hpp" #include "../../Compositor.hpp" #include "../../protocols/FractionalScale.hpp" +#include "../../protocols/InputMethodV2.hpp" -CInputPopup::CInputPopup(wlr_input_popup_surface_v2* surf) : pWlr(surf) { - surface.assign(surf->surface); - initCallbacks(); -} - -static void onCommit(void* owner, void* data) { - const auto PPOPUP = (CInputPopup*)owner; - PPOPUP->onCommit(); -} - -static void onMap(void* owner, void* data) { - const auto PPOPUP = (CInputPopup*)owner; - PPOPUP->onMap(); -} - -static void onUnmap(void* owner, void* data) { - const auto PPOPUP = (CInputPopup*)owner; - PPOPUP->onUnmap(); -} - -static void onDestroy(void* owner, void* data) { - const auto PPOPUP = (CInputPopup*)owner; - PPOPUP->onDestroy(); -} - -void CInputPopup::initCallbacks() { - hyprListener_commitPopup.initCallback(&pWlr->surface->events.commit, &::onCommit, this, "IME Popup"); - hyprListener_mapPopup.initCallback(&pWlr->surface->events.map, &::onMap, this, "IME Popup"); - hyprListener_unmapPopup.initCallback(&pWlr->surface->events.unmap, &::onUnmap, this, "IME Popup"); - hyprListener_destroyPopup.initCallback(&pWlr->events.destroy, &::onDestroy, this, "IME Popup"); +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()); } CWLSurface* CInputPopup::queryOwner() { @@ -45,11 +22,6 @@ CWLSurface* CInputPopup::queryOwner() { } void CInputPopup::onDestroy() { - hyprListener_commitPopup.removeCallback(); - hyprListener_destroyPopup.removeCallback(); - hyprListener_mapPopup.removeCallback(); - hyprListener_unmapPopup.removeCallback(); - g_pInputManager->m_sIMERelay.removePopup(this); } @@ -101,7 +73,7 @@ void CInputPopup::damageSurface() { } void CInputPopup::updateBox() { - if (!surface.wlr()->mapped) + if (!popup.lock()->mapped) return; const auto OWNER = queryOwner(); @@ -142,7 +114,7 @@ void CInputPopup::updateBox() { popupOffset.x -= popupOverflow; CBox cursorBoxLocal({-popupOffset.x, -popupOffset.y}, cursorBoxParent.size()); - wlr_input_popup_surface_v2_send_text_input_rectangle(pWlr, cursorBoxLocal.pWlr()); + popup.lock()->sendInputRectangle(cursorBoxLocal); CBox popupBoxParent(cursorBoxParent.pos() + popupOffset, currentPopupSize); if (popupBoxParent != lastBoxLocal) { |
