core: use new typed signals from hu (#10853)
This commit is contained in:
parent
2f34ef141b
commit
78e9eddfb6
85 changed files with 667 additions and 865 deletions
|
|
@ -29,14 +29,12 @@ CPointerManager::CPointerManager() {
|
|||
|
||||
onMonitorLayoutChange();
|
||||
|
||||
PMONITOR->m_events.modeChanged.registerStaticListener([this](void* owner, std::any data) { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); }, nullptr);
|
||||
PMONITOR->m_events.disconnect.registerStaticListener([this](void* owner, std::any data) { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); }, nullptr);
|
||||
PMONITOR->m_events.destroy.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
if (g_pCompositor && !g_pCompositor->m_isShuttingDown)
|
||||
std::erase_if(m_monitorStates, [](const auto& other) { return other->monitor.expired(); });
|
||||
},
|
||||
nullptr);
|
||||
PMONITOR->m_events.modeChanged.listenStatic([this] { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); });
|
||||
PMONITOR->m_events.disconnect.listenStatic([this] { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); });
|
||||
PMONITOR->m_events.destroy.listenStatic([this] {
|
||||
if (g_pCompositor && !g_pCompositor->m_isShuttingDown)
|
||||
std::erase_if(m_monitorStates, [](const auto& other) { return other->monitor.expired(); });
|
||||
});
|
||||
});
|
||||
|
||||
m_hooks.monitorPreRender = g_pHookSystem->hookDynamic("preMonitorCommit", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
|
|
@ -149,8 +147,8 @@ void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hots
|
|||
|
||||
surf->resource()->map();
|
||||
|
||||
m_currentCursorImage.destroySurface = surf->m_events.destroy.registerListener([this](std::any data) { resetCursorImage(); });
|
||||
m_currentCursorImage.commitSurface = surf->resource()->m_events.commit.registerListener([this](std::any data) {
|
||||
m_currentCursorImage.destroySurface = surf->m_events.destroy.listen([this] { resetCursorImage(); });
|
||||
m_currentCursorImage.commitSurface = surf->resource()->m_events.commit.listen([this] {
|
||||
damageIfSoftware();
|
||||
m_currentCursorImage.size = m_currentCursorImage.surface->resource()->m_current.texture ? m_currentCursorImage.surface->resource()->m_current.bufferSize : Vector2D{};
|
||||
m_currentCursorImage.scale = m_currentCursorImage.surface ? m_currentCursorImage.surface->resource()->m_current.scale : 1.F;
|
||||
|
|
@ -898,15 +896,9 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
|
|||
|
||||
listener->pointer = pointer;
|
||||
|
||||
// clang-format off
|
||||
listener->destroy = pointer->m_events.destroy.registerListener([this] (std::any d) {
|
||||
detachPointer(nullptr);
|
||||
});
|
||||
|
||||
listener->motion = pointer->m_pointerEvents.motion.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SMotionEvent>(e);
|
||||
|
||||
g_pInputManager->onMouseMoved(E);
|
||||
listener->destroy = pointer->m_events.destroy.listen([this] { detachPointer(nullptr); });
|
||||
listener->motion = pointer->m_pointerEvents.motion.listen([](const IPointer::SMotionEvent& event) {
|
||||
g_pInputManager->onMouseMoved(event);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -914,10 +906,8 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->motionAbsolute = pointer->m_pointerEvents.motionAbsolute.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SMotionAbsoluteEvent>(e);
|
||||
|
||||
g_pInputManager->onMouseWarp(E);
|
||||
listener->motionAbsolute = pointer->m_pointerEvents.motionAbsolute.listen([](const IPointer::SMotionAbsoluteEvent& event) {
|
||||
g_pInputManager->onMouseWarp(event);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -925,37 +915,29 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->button = pointer->m_pointerEvents.button.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SButtonEvent>(e);
|
||||
|
||||
g_pInputManager->onMouseButton(E);
|
||||
|
||||
listener->button = pointer->m_pointerEvents.button.listen([](const IPointer::SButtonEvent& event) {
|
||||
g_pInputManager->onMouseButton(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->axis = pointer->m_pointerEvents.axis.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SAxisEvent>(e);
|
||||
|
||||
g_pInputManager->onMouseWheel(E);
|
||||
|
||||
listener->axis = pointer->m_pointerEvents.axis.listen([](const IPointer::SAxisEvent& event) {
|
||||
g_pInputManager->onMouseWheel(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->frame = pointer->m_pointerEvents.frame.registerListener([] (std::any e) {
|
||||
listener->frame = pointer->m_pointerEvents.frame.listen([] {
|
||||
bool shouldSkip = false;
|
||||
if (!g_pSeatManager->m_mouse.expired() && g_pInputManager->isLocked()) {
|
||||
auto PMONITOR = g_pCompositor->m_lastMonitor.get();
|
||||
shouldSkip = PMONITOR && PMONITOR->shouldSkipScheduleFrameOnMouseEvent();
|
||||
shouldSkip = PMONITOR && PMONITOR->shouldSkipScheduleFrameOnMouseEvent();
|
||||
}
|
||||
g_pSeatManager->m_isPointerFrameSkipped = shouldSkip;
|
||||
if (!g_pSeatManager->m_isPointerFrameSkipped)
|
||||
g_pSeatManager->sendPointerFrame();
|
||||
});
|
||||
|
||||
listener->swipeBegin = pointer->m_pointerEvents.swipeBegin.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SSwipeBeginEvent>(e);
|
||||
|
||||
g_pInputManager->onSwipeBegin(E);
|
||||
listener->swipeBegin = pointer->m_pointerEvents.swipeBegin.listen([](const IPointer::SSwipeBeginEvent& event) {
|
||||
g_pInputManager->onSwipeBegin(event);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -963,26 +945,18 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->swipeEnd = pointer->m_pointerEvents.swipeEnd.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SSwipeEndEvent>(e);
|
||||
|
||||
g_pInputManager->onSwipeEnd(E);
|
||||
|
||||
listener->swipeEnd = pointer->m_pointerEvents.swipeEnd.listen([](const IPointer::SSwipeEndEvent& event) {
|
||||
g_pInputManager->onSwipeEnd(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->swipeUpdate = pointer->m_pointerEvents.swipeUpdate.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SSwipeUpdateEvent>(e);
|
||||
|
||||
g_pInputManager->onSwipeUpdate(E);
|
||||
|
||||
listener->swipeUpdate = pointer->m_pointerEvents.swipeUpdate.listen([](const IPointer::SSwipeUpdateEvent& event) {
|
||||
g_pInputManager->onSwipeUpdate(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->pinchBegin = pointer->m_pointerEvents.pinchBegin.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SPinchBeginEvent>(e);
|
||||
|
||||
PROTO::pointerGestures->pinchBegin(E.timeMs, E.fingers);
|
||||
listener->pinchBegin = pointer->m_pointerEvents.pinchBegin.listen([](const IPointer::SPinchBeginEvent& event) {
|
||||
PROTO::pointerGestures->pinchBegin(event.timeMs, event.fingers);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -990,38 +964,25 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->pinchEnd = pointer->m_pointerEvents.pinchEnd.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SPinchEndEvent>(e);
|
||||
|
||||
PROTO::pointerGestures->pinchEnd(E.timeMs, E.cancelled);
|
||||
|
||||
listener->pinchEnd = pointer->m_pointerEvents.pinchEnd.listen([](const IPointer::SPinchEndEvent& event) {
|
||||
PROTO::pointerGestures->pinchEnd(event.timeMs, event.cancelled);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->pinchUpdate = pointer->m_pointerEvents.pinchUpdate.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SPinchUpdateEvent>(e);
|
||||
|
||||
PROTO::pointerGestures->pinchUpdate(E.timeMs, E.delta, E.scale, E.rotation);
|
||||
|
||||
listener->pinchUpdate = pointer->m_pointerEvents.pinchUpdate.listen([](const IPointer::SPinchUpdateEvent& event) {
|
||||
PROTO::pointerGestures->pinchUpdate(event.timeMs, event.delta, event.scale, event.rotation);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->holdBegin = pointer->m_pointerEvents.holdBegin.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SHoldBeginEvent>(e);
|
||||
|
||||
PROTO::pointerGestures->holdBegin(E.timeMs, E.fingers);
|
||||
|
||||
listener->holdBegin = pointer->m_pointerEvents.holdBegin.listen([](const IPointer::SHoldBeginEvent& event) {
|
||||
PROTO::pointerGestures->holdBegin(event.timeMs, event.fingers);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->holdEnd = pointer->m_pointerEvents.holdEnd.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<IPointer::SHoldEndEvent>(e);
|
||||
|
||||
PROTO::pointerGestures->holdEnd(E.timeMs, E.cancelled);
|
||||
|
||||
listener->holdEnd = pointer->m_pointerEvents.holdEnd.listen([](const IPointer::SHoldEndEvent& event) {
|
||||
PROTO::pointerGestures->holdEnd(event.timeMs, event.cancelled);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
Debug::log(LOG, "Attached pointer {} to global", pointer->m_hlName);
|
||||
}
|
||||
|
|
@ -1037,15 +998,10 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
|
|||
|
||||
listener->touch = touch;
|
||||
|
||||
// clang-format off
|
||||
listener->destroy = touch->m_events.destroy.registerListener([this] (std::any d) {
|
||||
detachTouch(nullptr);
|
||||
});
|
||||
listener->destroy = touch->m_events.destroy.listen([this] { detachTouch(nullptr); });
|
||||
|
||||
listener->down = touch->m_touchEvents.down.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<ITouch::SDownEvent>(e);
|
||||
|
||||
g_pInputManager->onTouchDown(E);
|
||||
listener->down = touch->m_touchEvents.down.listen([](const ITouch::SDownEvent& event) {
|
||||
g_pInputManager->onTouchDown(event);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -1053,30 +1009,21 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->up = touch->m_touchEvents.up.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<ITouch::SUpEvent>(e);
|
||||
|
||||
g_pInputManager->onTouchUp(E);
|
||||
|
||||
listener->up = touch->m_touchEvents.up.listen([](const ITouch::SUpEvent& event) {
|
||||
g_pInputManager->onTouchUp(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->motion = touch->m_touchEvents.motion.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<ITouch::SMotionEvent>(e);
|
||||
|
||||
g_pInputManager->onTouchMove(E);
|
||||
|
||||
listener->motion = touch->m_touchEvents.motion.listen([](const ITouch::SMotionEvent& event) {
|
||||
g_pInputManager->onTouchMove(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->cancel = touch->m_touchEvents.cancel.registerListener([] (std::any e) {
|
||||
listener->cancel = touch->m_touchEvents.cancel.listen([] {
|
||||
//
|
||||
});
|
||||
|
||||
listener->frame = touch->m_touchEvents.frame.registerListener([] (std::any e) {
|
||||
g_pSeatManager->sendTouchFrame();
|
||||
});
|
||||
// clang-format on
|
||||
listener->frame = touch->m_touchEvents.frame.listen([] { g_pSeatManager->sendTouchFrame(); });
|
||||
|
||||
Debug::log(LOG, "Attached touch {} to global", touch->m_hlName);
|
||||
}
|
||||
|
|
@ -1092,15 +1039,10 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
|
|||
|
||||
listener->tablet = tablet;
|
||||
|
||||
// clang-format off
|
||||
listener->destroy = tablet->m_events.destroy.registerListener([this] (std::any d) {
|
||||
detachTablet(nullptr);
|
||||
});
|
||||
listener->destroy = tablet->m_events.destroy.listen([this] { detachTablet(nullptr); });
|
||||
|
||||
listener->axis = tablet->m_tabletEvents.axis.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<CTablet::SAxisEvent>(e);
|
||||
|
||||
g_pInputManager->onTabletAxis(E);
|
||||
listener->axis = tablet->m_tabletEvents.axis.listen([](const CTablet::SAxisEvent& event) {
|
||||
g_pInputManager->onTabletAxis(event);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -1108,18 +1050,13 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->proximity = tablet->m_tabletEvents.proximity.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<CTablet::SProximityEvent>(e);
|
||||
|
||||
g_pInputManager->onTabletProximity(E);
|
||||
|
||||
listener->proximity = tablet->m_tabletEvents.proximity.listen([](const CTablet::SProximityEvent& event) {
|
||||
g_pInputManager->onTabletProximity(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
|
||||
listener->tip = tablet->m_tabletEvents.tip.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<CTablet::STipEvent>(e);
|
||||
|
||||
g_pInputManager->onTabletTip(E);
|
||||
listener->tip = tablet->m_tabletEvents.tip.listen([](const CTablet::STipEvent& event) {
|
||||
g_pInputManager->onTabletTip(event);
|
||||
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
|
|
@ -1127,11 +1064,8 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
|
|||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
listener->button = tablet->m_tabletEvents.button.registerListener([] (std::any e) {
|
||||
auto E = std::any_cast<CTablet::SButtonEvent>(e);
|
||||
|
||||
g_pInputManager->onTabletButton(E);
|
||||
|
||||
listener->button = tablet->m_tabletEvents.button.listen([](const CTablet::SButtonEvent& event) {
|
||||
g_pInputManager->onTabletButton(event);
|
||||
PROTO::idle->onActivity();
|
||||
});
|
||||
// clang-format on
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ CProtocolManager::CProtocolManager() {
|
|||
PROTO::outputs.emplace(M->m_name, ref);
|
||||
ref->m_self = ref;
|
||||
|
||||
m_modeChangeListeners[M->m_name] = M->m_events.modeChanged.registerListener([M, this](std::any d) { onMonitorModeChange(M); });
|
||||
m_modeChangeListeners[M->m_name] = M->m_events.modeChanged.listen([this, M] { onMonitorModeChange(M); });
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
#include <ranges>
|
||||
|
||||
CSeatManager::CSeatManager() {
|
||||
m_listeners.newSeatResource = PROTO::seat->m_events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast<SP<CWLSeatResource>>(res)); });
|
||||
m_listeners.newSeatResource = PROTO::seat->m_events.newSeatResource.listen([this](const auto& resource) { onNewSeatResource(resource); });
|
||||
}
|
||||
|
||||
CSeatManager::SSeatResourceContainer::SSeatResourceContainer(SP<CWLSeatResource> res) : resource(res) {
|
||||
listeners.destroy = res->m_events.destroy.registerListener(
|
||||
[this](std::any data) { std::erase_if(g_pSeatManager->m_seatResources, [this](const auto& e) { return e->resource.expired() || e->resource == resource; }); });
|
||||
listeners.destroy = res->m_events.destroy.listen(
|
||||
[this] { std::erase_if(g_pSeatManager->m_seatResources, [this](const auto& e) { return e->resource.expired() || e->resource == resource; }); });
|
||||
}
|
||||
|
||||
void CSeatManager::onNewSeatResource(SP<CWLSeatResource> resource) {
|
||||
|
|
@ -151,7 +151,7 @@ void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
|
|||
}
|
||||
}
|
||||
|
||||
m_listeners.keyboardSurfaceDestroy = surf->m_events.destroy.registerListener([this](std::any d) { setKeyboardFocus(nullptr); });
|
||||
m_listeners.keyboardSurfaceDestroy = surf->m_events.destroy.listen([this] { setKeyboardFocus(nullptr); });
|
||||
|
||||
m_events.keyboardFocusChange.emit();
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
|
|||
|
||||
sendPointerFrame();
|
||||
|
||||
m_listeners.pointerSurfaceDestroy = surf->m_events.destroy.registerListener([this](std::any d) { setPointerFocus(nullptr, {}); });
|
||||
m_listeners.pointerSurfaceDestroy = surf->m_events.destroy.listen([this] { setPointerFocus(nullptr, {}); });
|
||||
|
||||
m_events.pointerFocusChange.emit();
|
||||
m_events.dndPointerFocusChange.emit();
|
||||
|
|
@ -372,7 +372,7 @@ void CSeatManager::sendTouchDown(SP<CWLSurfaceResource> surf, uint32_t timeMs, i
|
|||
}
|
||||
}
|
||||
|
||||
m_listeners.touchSurfaceDestroy = surf->m_events.destroy.registerListener([this, timeMs, id](std::any d) { sendTouchUp(timeMs + 10, id); });
|
||||
m_listeners.touchSurfaceDestroy = surf->m_events.destroy.listen([this, timeMs, id] { sendTouchUp(timeMs + 10, id); });
|
||||
|
||||
m_touchLocks++;
|
||||
|
||||
|
|
@ -559,7 +559,7 @@ void CSeatManager::setCurrentSelection(SP<IDataSource> source) {
|
|||
m_selection.currentSelection = source;
|
||||
|
||||
if (source) {
|
||||
m_selection.destroySelection = source->m_events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); });
|
||||
m_selection.destroySelection = source->m_events.destroy.listen([this] { setCurrentSelection(nullptr); });
|
||||
PROTO::data->setSelection(source);
|
||||
PROTO::dataWlr->setSelection(source, false);
|
||||
}
|
||||
|
|
@ -584,7 +584,7 @@ void CSeatManager::setCurrentPrimarySelection(SP<IDataSource> source) {
|
|||
m_selection.currentPrimarySelection = source;
|
||||
|
||||
if (source) {
|
||||
m_selection.destroyPrimarySelection = source->m_events.destroy.registerListener([this](std::any d) { setCurrentPrimarySelection(nullptr); });
|
||||
m_selection.destroyPrimarySelection = source->m_events.destroy.listen([this] { setCurrentPrimarySelection(nullptr); });
|
||||
PROTO::primarySelection->setSelection(source);
|
||||
PROTO::dataWlr->setSelection(source, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ class CSeatManager {
|
|||
};
|
||||
|
||||
struct {
|
||||
CSignal keyboardFocusChange;
|
||||
CSignal pointerFocusChange;
|
||||
CSignal dndPointerFocusChange;
|
||||
CSignal touchFocusChange;
|
||||
CSignal setCursor; // SSetCursorEvent
|
||||
CSignal setSelection;
|
||||
CSignal setPrimarySelection;
|
||||
CSignalT<> keyboardFocusChange;
|
||||
CSignalT<> pointerFocusChange;
|
||||
CSignalT<> dndPointerFocusChange;
|
||||
CSignalT<> touchFocusChange;
|
||||
CSignalT<SSetCursorEvent> setCursor;
|
||||
CSignalT<> setSelection;
|
||||
CSignalT<> setPrimarySelection;
|
||||
} m_events;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : surface(surface_) {
|
||||
pWlrSurface = surface->surface();
|
||||
|
||||
listeners.map = surface_->m_events.map.registerListener([this](std::any data) {
|
||||
listeners.map = surface_->m_events.map.listen([this] {
|
||||
mapped = true;
|
||||
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
|
|
@ -23,14 +23,14 @@ SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : sur
|
|||
g_pHyprRenderer->damageMonitor(PMONITOR);
|
||||
});
|
||||
|
||||
listeners.destroy = surface_->m_events.destroy.registerListener([this](std::any data) {
|
||||
listeners.destroy = surface_->m_events.destroy.listen([this] {
|
||||
if (pWlrSurface == g_pCompositor->m_lastFocus)
|
||||
g_pCompositor->m_lastFocus.reset();
|
||||
|
||||
g_pSessionLockManager->removeSessionLockSurface(this);
|
||||
});
|
||||
|
||||
listeners.commit = surface_->m_events.commit.registerListener([this](std::any data) {
|
||||
listeners.commit = surface_->m_events.commit.listen([this] {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(iMonitorID);
|
||||
|
||||
if (mapped && !g_pCompositor->m_lastFocus)
|
||||
|
|
@ -42,11 +42,10 @@ SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : sur
|
|||
}
|
||||
|
||||
CSessionLockManager::CSessionLockManager() {
|
||||
m_listeners.newLock = PROTO::sessionLock->m_events.newLock.registerListener([this](std::any data) { this->onNewSessionLock(std::any_cast<SP<CSessionLock>>(data)); });
|
||||
m_listeners.newLock = PROTO::sessionLock->m_events.newLock.listen([this](const auto& lock) { this->onNewSessionLock(lock); });
|
||||
}
|
||||
|
||||
void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
|
||||
|
||||
static auto PALLOWRELOCK = CConfigValue<Hyprlang::INT>("misc:allow_session_lock_restore");
|
||||
|
||||
if (PROTO::sessionLock->isLocked() && !*PALLOWRELOCK) {
|
||||
|
|
@ -61,17 +60,15 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
|
|||
m_sessionLock->lock = pLock;
|
||||
m_sessionLock->mLockTimer.reset();
|
||||
|
||||
m_sessionLock->listeners.newSurface = pLock->m_events.newLockSurface.registerListener([this](std::any data) {
|
||||
auto SURFACE = std::any_cast<SP<CSessionLockSurface>>(data);
|
||||
m_sessionLock->listeners.newSurface = pLock->m_events.newLockSurface.listen([this](const SP<CSessionLockSurface>& surface) {
|
||||
const auto PMONITOR = surface->monitor();
|
||||
|
||||
const auto PMONITOR = SURFACE->monitor();
|
||||
|
||||
const auto NEWSURFACE = m_sessionLock->vSessionLockSurfaces.emplace_back(makeUnique<SSessionLockSurface>(SURFACE)).get();
|
||||
const auto NEWSURFACE = m_sessionLock->vSessionLockSurfaces.emplace_back(makeUnique<SSessionLockSurface>(surface)).get();
|
||||
NEWSURFACE->iMonitorID = PMONITOR->m_id;
|
||||
PROTO::fractional->sendScale(SURFACE->surface(), PMONITOR->m_scale);
|
||||
PROTO::fractional->sendScale(surface->surface(), PMONITOR->m_scale);
|
||||
});
|
||||
|
||||
m_sessionLock->listeners.unlock = pLock->m_events.unlockAndDestroy.registerListener([this](std::any data) {
|
||||
m_sessionLock->listeners.unlock = pLock->m_events.unlockAndDestroy.listen([this] {
|
||||
m_sessionLock.reset();
|
||||
g_pInputManager->refocus();
|
||||
|
||||
|
|
@ -79,7 +76,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
|
|||
g_pHyprRenderer->damageMonitor(m);
|
||||
});
|
||||
|
||||
m_sessionLock->listeners.destroy = pLock->m_events.destroyed.registerListener([this](std::any data) {
|
||||
m_sessionLock->listeners.destroy = pLock->m_events.destroyed.listen([this] {
|
||||
m_sessionLock.reset();
|
||||
g_pCompositor->focusSurface(nullptr);
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ void CEventLoopManager::enterLoop() {
|
|||
m_configWatcherInotifySource = wl_event_loop_add_fd(m_wayland.loop, FD.get(), WL_EVENT_READABLE, configWatcherWrite, nullptr);
|
||||
|
||||
syncPollFDs();
|
||||
m_listeners.pollFDsChanged = g_pCompositor->m_aqBackend->events.pollFDsChanged.registerListener([this](std::any d) { syncPollFDs(); });
|
||||
m_listeners.pollFDsChanged = g_pCompositor->m_aqBackend->events.pollFDsChanged.listen([this] { syncPollFDs(); });
|
||||
|
||||
// if we have a session, dispatch it to get the pending input devices
|
||||
if (g_pCompositor->m_aqBackend->hasSession())
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
|
|||
|
||||
Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->m_surface.get());
|
||||
|
||||
PINHIBIT->inhibitor->m_listeners.destroy = PINHIBIT->inhibitor->m_resource->m_events.destroy.registerListener([this, PINHIBIT](std::any data) {
|
||||
PINHIBIT->inhibitor->m_listeners.destroy = PINHIBIT->inhibitor->m_resource->m_events.destroy.listen([this, PINHIBIT] {
|
||||
std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; });
|
||||
recheckIdleInhibitorStatus();
|
||||
});
|
||||
|
|
@ -24,8 +24,8 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
|
|||
return;
|
||||
}
|
||||
|
||||
PINHIBIT->surfaceDestroyListener = WLSurface->m_events.destroy.registerListener(
|
||||
[this, PINHIBIT](std::any data) { std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); });
|
||||
PINHIBIT->surfaceDestroyListener =
|
||||
WLSurface->m_events.destroy.listen([this, PINHIBIT] { std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); });
|
||||
|
||||
recheckIdleInhibitorStatus();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,10 @@
|
|||
#include <aquamarine/input/Input.hpp>
|
||||
|
||||
CInputManager::CInputManager() {
|
||||
m_listeners.setCursorShape = PROTO::cursorShape->m_events.setShape.registerListener([this](std::any data) {
|
||||
m_listeners.setCursorShape = PROTO::cursorShape->m_events.setShape.listen([this](const CCursorShapeProtocol::SSetShapeEvent& event) {
|
||||
if (!cursorImageUnlocked())
|
||||
return;
|
||||
|
||||
auto event = std::any_cast<CCursorShapeProtocol::SSetShapeEvent>(data);
|
||||
|
||||
if (!g_pSeatManager->m_state.pointerFocusResource)
|
||||
return;
|
||||
|
||||
|
|
@ -66,16 +64,16 @@ CInputManager::CInputManager() {
|
|||
g_pHyprRenderer->setCursorFromName(m_cursorSurfaceInfo.name);
|
||||
});
|
||||
|
||||
m_listeners.newIdleInhibitor = PROTO::idleInhibit->m_events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); });
|
||||
m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->m_events.newKeyboard.registerListener([this](std::any data) {
|
||||
this->newVirtualKeyboard(std::any_cast<SP<CVirtualKeyboardV1Resource>>(data));
|
||||
m_listeners.newIdleInhibitor = PROTO::idleInhibit->m_events.newIdleInhibitor.listen([this](const auto& data) { this->newIdleInhibitor(data); });
|
||||
m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->m_events.newKeyboard.listen([this](const auto& keyboard) {
|
||||
this->newVirtualKeyboard(keyboard);
|
||||
updateCapabilities();
|
||||
});
|
||||
m_listeners.newVirtualMouse = PROTO::virtualPointer->m_events.newPointer.registerListener([this](std::any data) {
|
||||
this->newVirtualMouse(std::any_cast<SP<CVirtualPointerV1Resource>>(data));
|
||||
m_listeners.newVirtualMouse = PROTO::virtualPointer->m_events.newPointer.listen([this](const auto& mouse) {
|
||||
this->newVirtualMouse(mouse);
|
||||
updateCapabilities();
|
||||
});
|
||||
m_listeners.setCursor = g_pSeatManager->m_events.setCursor.registerListener([this](std::any d) { this->processMouseRequest(d); });
|
||||
m_listeners.setCursor = g_pSeatManager->m_events.setCursor.listen([this](const auto& event) { this->processMouseRequest(event); });
|
||||
|
||||
m_cursorSurfaceInfo.wlSurface = CWLSurface::create();
|
||||
}
|
||||
|
|
@ -641,23 +639,21 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
|||
}
|
||||
}
|
||||
|
||||
void CInputManager::processMouseRequest(std::any E) {
|
||||
void CInputManager::processMouseRequest(const CSeatManager::SSetCursorEvent& event) {
|
||||
if (!cursorImageUnlocked())
|
||||
return;
|
||||
|
||||
auto e = std::any_cast<CSeatManager::SSetCursorEvent>(E);
|
||||
Debug::log(LOG, "cursorImage request: surface {:x}", (uintptr_t)event.surf.get());
|
||||
|
||||
Debug::log(LOG, "cursorImage request: surface {:x}", (uintptr_t)e.surf.get());
|
||||
|
||||
if (e.surf != m_cursorSurfaceInfo.wlSurface->resource()) {
|
||||
if (event.surf != m_cursorSurfaceInfo.wlSurface->resource()) {
|
||||
m_cursorSurfaceInfo.wlSurface->unassign();
|
||||
|
||||
if (e.surf)
|
||||
m_cursorSurfaceInfo.wlSurface->assign(e.surf);
|
||||
if (event.surf)
|
||||
m_cursorSurfaceInfo.wlSurface->assign(event.surf);
|
||||
}
|
||||
|
||||
if (e.surf) {
|
||||
m_cursorSurfaceInfo.vHotspot = e.hotspot;
|
||||
if (event.surf) {
|
||||
m_cursorSurfaceInfo.vHotspot = event.hotspot;
|
||||
m_cursorSurfaceInfo.hidden = false;
|
||||
} else {
|
||||
m_cursorSurfaceInfo.vHotspot = {};
|
||||
|
|
@ -667,7 +663,7 @@ void CInputManager::processMouseRequest(std::any E) {
|
|||
m_cursorSurfaceInfo.name = "";
|
||||
|
||||
m_cursorSurfaceInfo.inUse = true;
|
||||
g_pHyprRenderer->setCursorSurface(m_cursorSurfaceInfo.wlSurface, e.hotspot.x, e.hotspot.y);
|
||||
g_pHyprRenderer->setCursorSurface(m_cursorSurfaceInfo.wlSurface, event.hotspot.x, event.hotspot.y);
|
||||
}
|
||||
|
||||
void CInputManager::restoreCursorIconToApp() {
|
||||
|
|
@ -962,60 +958,52 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
|
|||
Debug::log(ERR, "Keyboard had no name???"); // logic error
|
||||
}
|
||||
|
||||
keeb->m_events.destroy.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
|
||||
keeb->m_events.destroy.listenStatic([this, keeb = keeb.get()] {
|
||||
auto PKEEB = keeb->m_self.lock();
|
||||
|
||||
if (!PKEEB)
|
||||
return;
|
||||
if (!PKEEB)
|
||||
return;
|
||||
|
||||
destroyKeyboard(PKEEB);
|
||||
Debug::log(LOG, "Destroyed keyboard {:x}", (uintptr_t)owner);
|
||||
},
|
||||
keeb.get());
|
||||
destroyKeyboard(PKEEB);
|
||||
Debug::log(LOG, "Destroyed keyboard {:x}", (uintptr_t)keeb);
|
||||
});
|
||||
|
||||
keeb->m_keyboardEvents.key.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
|
||||
keeb->m_keyboardEvents.key.listenStatic([this, keeb = keeb.get()](const IKeyboard::SKeyEvent& event) {
|
||||
auto PKEEB = keeb->m_self.lock();
|
||||
|
||||
onKeyboardKey(data, PKEEB);
|
||||
onKeyboardKey(event, PKEEB);
|
||||
|
||||
if (PKEEB->m_enabled)
|
||||
PROTO::idle->onActivity();
|
||||
if (PKEEB->m_enabled)
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
|
||||
g_pKeybindManager->dpms("on");
|
||||
},
|
||||
keeb.get());
|
||||
if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
|
||||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
keeb->m_keyboardEvents.modifiers.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
|
||||
keeb->m_keyboardEvents.modifiers.listenStatic([this, keeb = keeb.get()] {
|
||||
auto PKEEB = keeb->m_self.lock();
|
||||
|
||||
onKeyboardMod(PKEEB);
|
||||
onKeyboardMod(PKEEB);
|
||||
|
||||
if (PKEEB->m_enabled)
|
||||
PROTO::idle->onActivity();
|
||||
if (PKEEB->m_enabled)
|
||||
PROTO::idle->onActivity();
|
||||
|
||||
if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
|
||||
g_pKeybindManager->dpms("on");
|
||||
},
|
||||
keeb.get());
|
||||
if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
|
||||
g_pKeybindManager->dpms("on");
|
||||
});
|
||||
|
||||
keeb->m_keyboardEvents.keymap.registerStaticListener(
|
||||
[](void* owner, std::any data) {
|
||||
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
|
||||
const auto LAYOUT = PKEEB->getActiveLayout();
|
||||
keeb->m_keyboardEvents.keymap.listenStatic([keeb = keeb.get()] {
|
||||
auto PKEEB = keeb->m_self.lock();
|
||||
const auto LAYOUT = PKEEB->getActiveLayout();
|
||||
|
||||
if (PKEEB == g_pSeatManager->m_keyboard) {
|
||||
g_pSeatManager->updateActiveKeyboardData();
|
||||
g_pKeybindManager->m_keyToCodeCache.clear();
|
||||
}
|
||||
if (PKEEB == g_pSeatManager->m_keyboard) {
|
||||
g_pSeatManager->updateActiveKeyboardData();
|
||||
g_pKeybindManager->m_keyToCodeCache.clear();
|
||||
}
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEEB->m_hlName + "," + LAYOUT});
|
||||
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{PKEEB, LAYOUT}));
|
||||
},
|
||||
keeb.get());
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEEB->m_hlName + "," + LAYOUT});
|
||||
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{PKEEB, LAYOUT}));
|
||||
});
|
||||
|
||||
disableAllKeyboards(false);
|
||||
|
||||
|
|
@ -1148,16 +1136,7 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
|
|||
|
||||
setPointerConfigs();
|
||||
|
||||
mauz->m_events.destroy.registerStaticListener(
|
||||
[this](void* mouse, std::any data) {
|
||||
const auto PMOUSE = (IPointer*)mouse;
|
||||
|
||||
if (!PMOUSE)
|
||||
return;
|
||||
|
||||
destroyPointer(PMOUSE->m_self.lock());
|
||||
},
|
||||
mauz.get());
|
||||
mauz->m_events.destroy.listenStatic([this, PMOUSE = mauz.get()] { destroyPointer(PMOUSE->m_self.lock()); });
|
||||
|
||||
g_pSeatManager->setMouse(mauz);
|
||||
|
||||
|
|
@ -1413,7 +1392,7 @@ void CInputManager::updateKeyboardsLeds(SP<IKeyboard> pKeyboard) {
|
|||
}
|
||||
}
|
||||
|
||||
void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
||||
void CInputManager::onKeyboardKey(const IKeyboard::SKeyEvent& event, SP<IKeyboard> pKeyboard) {
|
||||
if (!pKeyboard->m_enabled || !pKeyboard->m_allowed)
|
||||
return;
|
||||
|
||||
|
|
@ -1424,17 +1403,15 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
|||
|
||||
bool passEvent = DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard);
|
||||
|
||||
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
||||
|
||||
if (passEvent) {
|
||||
const auto IME = m_relay.m_inputMethod.lock();
|
||||
|
||||
if (IME && IME->hasGrab() && !DISALLOWACTION) {
|
||||
IME->setKeyboard(pKeyboard);
|
||||
IME->sendKey(e.timeMs, e.keycode, e.state);
|
||||
IME->sendKey(event.timeMs, event.keycode, event.state);
|
||||
} else {
|
||||
g_pSeatManager->setKeyboard(pKeyboard);
|
||||
g_pSeatManager->sendKeyboardKey(e.timeMs, e.keycode, e.state);
|
||||
g_pSeatManager->sendKeyboardKey(event.timeMs, event.keycode, event.state);
|
||||
}
|
||||
|
||||
updateKeyboardsLeds(pKeyboard);
|
||||
|
|
@ -1627,16 +1604,14 @@ void CInputManager::newTouchDevice(SP<Aquamarine::ITouch> pDevice) {
|
|||
setTouchDeviceConfigs(PNEWDEV);
|
||||
g_pPointerManager->attachTouch(PNEWDEV);
|
||||
|
||||
PNEWDEV->m_events.destroy.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
auto PDEV = ((ITouch*)owner)->m_self.lock();
|
||||
PNEWDEV->m_events.destroy.listenStatic([this, dev = PNEWDEV.get()] {
|
||||
auto PDEV = dev->m_self.lock();
|
||||
|
||||
if (!PDEV)
|
||||
return;
|
||||
if (!PDEV)
|
||||
return;
|
||||
|
||||
destroyTouchDevice(PDEV);
|
||||
},
|
||||
PNEWDEV.get());
|
||||
destroyTouchDevice(PDEV);
|
||||
});
|
||||
|
||||
Debug::log(LOG, "New touch device added at {:x}", (uintptr_t)PNEWDEV.get());
|
||||
}
|
||||
|
|
@ -1739,17 +1714,16 @@ void CInputManager::newSwitch(SP<Aquamarine::ISwitch> pDevice) {
|
|||
|
||||
Debug::log(LOG, "New switch with name \"{}\" added", pDevice->getName());
|
||||
|
||||
PNEWDEV->listeners.destroy = pDevice->events.destroy.registerListener([this, PNEWDEV](std::any d) { destroySwitch(PNEWDEV); });
|
||||
PNEWDEV->listeners.destroy = pDevice->events.destroy.listen([this, PNEWDEV] { destroySwitch(PNEWDEV); });
|
||||
|
||||
PNEWDEV->listeners.fire = pDevice->events.fire.registerListener([PNEWDEV](std::any d) {
|
||||
PNEWDEV->listeners.fire = pDevice->events.fire.listen([PNEWDEV](const Aquamarine::ISwitch::SFireEvent& event) {
|
||||
const auto NAME = PNEWDEV->pDevice->getName();
|
||||
const auto E = std::any_cast<Aquamarine::ISwitch::SFireEvent>(d);
|
||||
|
||||
Debug::log(LOG, "Switch {} fired, triggering binds.", NAME);
|
||||
|
||||
g_pKeybindManager->onSwitchEvent(NAME);
|
||||
|
||||
if (E.enable) {
|
||||
if (event.enable) {
|
||||
Debug::log(LOG, "Switch {} turn on, triggering binds.", NAME);
|
||||
g_pKeybindManager->onSwitchOnEvent(NAME);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@
|
|||
#include "../../helpers/signal/Signal.hpp"
|
||||
#include "../../devices/IPointer.hpp"
|
||||
#include "../../devices/ITouch.hpp"
|
||||
#include "../../devices/IKeyboard.hpp"
|
||||
#include "../../devices/Tablet.hpp"
|
||||
#include "../SessionLockManager.hpp"
|
||||
#include "../SeatManager.hpp"
|
||||
|
||||
class CPointerConstraint;
|
||||
class CWindow;
|
||||
|
|
@ -89,7 +91,7 @@ class CInputManager {
|
|||
void onMouseWarp(IPointer::SMotionAbsoluteEvent);
|
||||
void onMouseButton(IPointer::SButtonEvent);
|
||||
void onMouseWheel(IPointer::SAxisEvent);
|
||||
void onKeyboardKey(std::any, SP<IKeyboard>);
|
||||
void onKeyboardKey(const IKeyboard::SKeyEvent&, SP<IKeyboard>);
|
||||
void onKeyboardMod(SP<IKeyboard>);
|
||||
|
||||
void newKeyboard(SP<Aquamarine::IKeyboard>);
|
||||
|
|
@ -128,7 +130,7 @@ class CInputManager {
|
|||
|
||||
void setClickMode(eClickBehaviorMode);
|
||||
eClickBehaviorMode getClickMode();
|
||||
void processMouseRequest(std::any e);
|
||||
void processMouseRequest(const CSeatManager::SSetCursorEvent& event);
|
||||
|
||||
void onTouchDown(ITouch::SDownEvent);
|
||||
void onTouchUp(ITouch::SUpEvent);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
#include "../../render/Renderer.hpp"
|
||||
|
||||
CInputPopup::CInputPopup(SP<CInputMethodPopupV2> popup_) : m_popup(popup_) {
|
||||
m_listeners.commit = popup_->m_events.commit.registerListener([this](std::any d) { onCommit(); });
|
||||
m_listeners.map = popup_->m_events.map.registerListener([this](std::any d) { onMap(); });
|
||||
m_listeners.unmap = popup_->m_events.unmap.registerListener([this](std::any d) { onUnmap(); });
|
||||
m_listeners.destroy = popup_->m_events.destroy.registerListener([this](std::any d) { onDestroy(); });
|
||||
m_listeners.commit = popup_->m_events.commit.listen([this] { onCommit(); });
|
||||
m_listeners.map = popup_->m_events.map.listen([this] { onMap(); });
|
||||
m_listeners.unmap = popup_->m_events.unmap.listen([this] { onUnmap(); });
|
||||
m_listeners.destroy = popup_->m_events.destroy.listen([this] { onDestroy(); });
|
||||
m_surface = CWLSurface::create();
|
||||
m_surface->assign(popup_->surface());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ CInputMethodRelay::CInputMethodRelay() {
|
|||
static auto P =
|
||||
g_pHookSystem->hookDynamic("keyboardFocus", [&](void* self, SCallbackInfo& info, std::any param) { onKeyboardFocus(std::any_cast<SP<CWLSurfaceResource>>(param)); });
|
||||
|
||||
m_listeners.newTIV3 = PROTO::textInputV3->m_events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast<WP<CTextInputV3>>(ti)); });
|
||||
m_listeners.newTIV1 = PROTO::textInputV1->m_events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast<WP<CTextInputV1>>(ti)); });
|
||||
m_listeners.newIME = PROTO::ime->m_events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast<SP<CInputMethodV2>>(ime)); });
|
||||
m_listeners.newTIV3 = PROTO::textInputV3->m_events.newTextInput.listen([this](const auto& input) { onNewTextInput(input); });
|
||||
m_listeners.newTIV1 = PROTO::textInputV1->m_events.newTextInput.listen([this](const auto& input) { onNewTextInput(input); });
|
||||
m_listeners.newIME = PROTO::ime->m_events.newIME.listen([this](const auto& ime) { onNewIME(ime); });
|
||||
}
|
||||
|
||||
void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
|
||||
|
|
@ -27,7 +27,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
|
|||
|
||||
m_inputMethod = pIME;
|
||||
|
||||
m_listeners.commitIME = pIME->m_events.onCommit.registerListener([this](std::any d) {
|
||||
m_listeners.commitIME = pIME->m_events.onCommit.listen([this] {
|
||||
const auto PTI = getFocusedTextInput();
|
||||
|
||||
if (!PTI) {
|
||||
|
|
@ -38,7 +38,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
|
|||
PTI->updateIMEState(m_inputMethod.lock());
|
||||
});
|
||||
|
||||
m_listeners.destroyIME = pIME->m_events.destroy.registerListener([this](std::any d) {
|
||||
m_listeners.destroyIME = pIME->m_events.destroy.listen([this] {
|
||||
const auto PTI = getFocusedTextInput();
|
||||
|
||||
Debug::log(LOG, "IME Destroy");
|
||||
|
|
@ -49,9 +49,8 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
|
|||
m_inputMethod.reset();
|
||||
});
|
||||
|
||||
m_listeners.newPopup = pIME->m_events.newPopup.registerListener([this](std::any d) {
|
||||
m_inputMethodPopups.emplace_back(makeUnique<CInputPopup>(std::any_cast<SP<CInputMethodPopupV2>>(d)));
|
||||
|
||||
m_listeners.newPopup = pIME->m_events.newPopup.listen([this](const SP<CInputMethodPopupV2>& popup) {
|
||||
m_inputMethodPopups.emplace_back(makeUnique<CInputPopup>(popup));
|
||||
Debug::log(LOG, "New input popup");
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -229,12 +229,10 @@ void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) {
|
|||
|
||||
g_pPointerManager->attachTablet(PNEWTABLET);
|
||||
|
||||
PNEWTABLET->m_events.destroy.registerStaticListener(
|
||||
[this](void* owner, std::any d) {
|
||||
auto TABLET = ((CTablet*)owner)->m_self;
|
||||
destroyTablet(TABLET.lock());
|
||||
},
|
||||
PNEWTABLET.get());
|
||||
PNEWTABLET->m_events.destroy.listenStatic([this, tablet = PNEWTABLET.get()] {
|
||||
auto TABLET = tablet->m_self;
|
||||
destroyTablet(TABLET.lock());
|
||||
});
|
||||
|
||||
setTabletConfigs();
|
||||
}
|
||||
|
|
@ -255,12 +253,10 @@ SP<CTabletTool> CInputManager::ensureTabletToolPresent(SP<Aquamarine::ITabletToo
|
|||
Debug::log(ERR, "Tablet had no name???"); // logic error
|
||||
}
|
||||
|
||||
PTOOL->m_events.destroy.registerStaticListener(
|
||||
[this](void* owner, std::any d) {
|
||||
auto TOOL = ((CTabletTool*)owner)->m_self;
|
||||
destroyTabletTool(TOOL.lock());
|
||||
},
|
||||
PTOOL.get());
|
||||
PTOOL->m_events.destroy.listenStatic([this, tool = PTOOL.get()] {
|
||||
auto TOOL = tool->m_self;
|
||||
destroyTabletTool(TOOL.lock());
|
||||
});
|
||||
|
||||
return PTOOL;
|
||||
}
|
||||
|
|
@ -275,39 +271,27 @@ void CInputManager::newTabletPad(SP<Aquamarine::ITabletPad> pDevice) {
|
|||
Debug::log(ERR, "Pad had no name???"); // logic error
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
PNEWPAD->m_events.destroy.registerStaticListener([this](void* owner, std::any d) {
|
||||
auto PAD = ((CTabletPad*)owner)->m_self;
|
||||
PNEWPAD->m_events.destroy.listenStatic([this, pad = PNEWPAD.get()] {
|
||||
auto PAD = pad->m_self;
|
||||
destroyTabletPad(PAD.lock());
|
||||
}, PNEWPAD.get());
|
||||
});
|
||||
|
||||
PNEWPAD->m_padEvents.button.registerStaticListener([](void* owner, std::any e) {
|
||||
const auto E = std::any_cast<CTabletPad::SButtonEvent>(e);
|
||||
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
|
||||
PNEWPAD->m_padEvents.button.listenStatic([pad = PNEWPAD.get()](const CTabletPad::SButtonEvent& event) {
|
||||
const auto PPAD = pad->m_self.lock();
|
||||
|
||||
PROTO::tablet->mode(PPAD, 0, E.mode, E.timeMs);
|
||||
PROTO::tablet->buttonPad(PPAD, E.button, E.timeMs, E.down);
|
||||
}, PNEWPAD.get());
|
||||
PROTO::tablet->mode(PPAD, 0, event.mode, event.timeMs);
|
||||
PROTO::tablet->buttonPad(PPAD, event.button, event.timeMs, event.down);
|
||||
});
|
||||
|
||||
PNEWPAD->m_padEvents.strip.registerStaticListener([](void* owner, std::any e) {
|
||||
const auto E = std::any_cast<CTabletPad::SStripEvent>(e);
|
||||
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
|
||||
PNEWPAD->m_padEvents.strip.listenStatic([pad = PNEWPAD.get()](const CTabletPad::SStripEvent& event) {
|
||||
const auto PPAD = pad->m_self.lock();
|
||||
PROTO::tablet->strip(PPAD, event.strip, event.position, event.finger, event.timeMs);
|
||||
});
|
||||
|
||||
PROTO::tablet->strip(PPAD, E.strip, E.position, E.finger, E.timeMs);
|
||||
}, PNEWPAD.get());
|
||||
PNEWPAD->m_padEvents.ring.listenStatic([pad = PNEWPAD.get()](const CTabletPad::SRingEvent& event) {
|
||||
const auto PPAD = pad->m_self.lock();
|
||||
PROTO::tablet->ring(PPAD, event.ring, event.position, event.finger, event.timeMs);
|
||||
});
|
||||
|
||||
PNEWPAD->m_padEvents.ring.registerStaticListener([](void* owner, std::any e) {
|
||||
const auto E = std::any_cast<CTabletPad::SRingEvent>(e);
|
||||
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
|
||||
|
||||
PROTO::tablet->ring(PPAD, E.ring, E.position, E.finger, E.timeMs);
|
||||
}, PNEWPAD.get());
|
||||
|
||||
PNEWPAD->m_padEvents.attach.registerStaticListener([](void* owner, std::any e) {
|
||||
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
|
||||
const auto TOOL = std::any_cast<SP<CTabletTool>>(e);
|
||||
|
||||
PPAD->m_parent = TOOL;
|
||||
}, PNEWPAD.get());
|
||||
// clang-format on
|
||||
PNEWPAD->m_padEvents.attach.listenStatic([pad = PNEWPAD.get()](const SP<CTabletTool>& tool) { pad->m_parent = tool; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ void CTextInput::initCallbacks() {
|
|||
if (isV3()) {
|
||||
const auto INPUT = m_v3Input.lock();
|
||||
|
||||
m_listeners.enable = INPUT->m_events.enable.registerListener([this](std::any p) { onEnabled(); });
|
||||
m_listeners.disable = INPUT->m_events.disable.registerListener([this](std::any p) { onDisabled(); });
|
||||
m_listeners.commit = INPUT->m_events.onCommit.registerListener([this](std::any p) { onCommit(); });
|
||||
m_listeners.reset = INPUT->m_events.reset.registerListener([this](std::any p) { onReset(); });
|
||||
m_listeners.destroy = INPUT->m_events.destroy.registerListener([this](std::any p) {
|
||||
m_listeners.enable = INPUT->m_events.enable.listen([this] { onEnabled(); });
|
||||
m_listeners.disable = INPUT->m_events.disable.listen([this] { onDisabled(); });
|
||||
m_listeners.commit = INPUT->m_events.onCommit.listen([this] { onCommit(); });
|
||||
m_listeners.reset = INPUT->m_events.reset.listen([this] { onReset(); });
|
||||
m_listeners.destroy = INPUT->m_events.destroy.listen([this] {
|
||||
m_listeners.surfaceUnmap.reset();
|
||||
m_listeners.surfaceDestroy.reset();
|
||||
g_pInputManager->m_relay.removeTextInput(this);
|
||||
|
|
@ -36,14 +36,11 @@ void CTextInput::initCallbacks() {
|
|||
} else {
|
||||
const auto INPUT = m_v1Input.lock();
|
||||
|
||||
m_listeners.enable = INPUT->m_events.enable.registerListener([this](std::any p) {
|
||||
const auto SURFACE = std::any_cast<SP<CWLSurfaceResource>>(p);
|
||||
onEnabled(SURFACE);
|
||||
});
|
||||
m_listeners.disable = INPUT->m_events.disable.registerListener([this](std::any p) { onDisabled(); });
|
||||
m_listeners.commit = INPUT->m_events.onCommit.registerListener([this](std::any p) { onCommit(); });
|
||||
m_listeners.reset = INPUT->m_events.reset.registerListener([this](std::any p) { onReset(); });
|
||||
m_listeners.destroy = INPUT->m_events.destroy.registerListener([this](std::any p) {
|
||||
m_listeners.enable = INPUT->m_events.enable.listen([this](const auto& surface) { onEnabled(surface); });
|
||||
m_listeners.disable = INPUT->m_events.disable.listen([this] { onDisabled(); });
|
||||
m_listeners.commit = INPUT->m_events.onCommit.listen([this] { onCommit(); });
|
||||
m_listeners.reset = INPUT->m_events.reset.listen([this] { onReset(); });
|
||||
m_listeners.destroy = INPUT->m_events.destroy.listen([this] {
|
||||
m_listeners.surfaceUnmap.reset();
|
||||
m_listeners.surfaceDestroy.reset();
|
||||
g_pInputManager->m_relay.removeTextInput(this);
|
||||
|
|
@ -135,7 +132,7 @@ void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
|
|||
m_listeners.surfaceUnmap.reset();
|
||||
m_listeners.surfaceDestroy.reset();
|
||||
|
||||
m_listeners.surfaceUnmap = pSurface->m_events.unmap.registerListener([this](std::any d) {
|
||||
m_listeners.surfaceUnmap = pSurface->m_events.unmap.listen([this] {
|
||||
Debug::log(LOG, "Unmap TI owner1");
|
||||
|
||||
if (m_enterLocks)
|
||||
|
|
@ -155,7 +152,7 @@ void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
|
|||
g_pInputManager->m_relay.deactivateIME(this);
|
||||
});
|
||||
|
||||
m_listeners.surfaceDestroy = pSurface->m_events.destroy.registerListener([this](std::any d) {
|
||||
m_listeners.surfaceDestroy = pSurface->m_events.destroy.listen([this] {
|
||||
Debug::log(LOG, "Destroy TI owner1");
|
||||
|
||||
if (m_enterLocks)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue