event: refactor HookSystem into a typed event bus (#13333)
Refactors the old HookSystem into a typed event bus with clear separation, discovery and types.
This commit is contained in:
parent
b4ee4674f9
commit
b88813c7ef
58 changed files with 493 additions and 516 deletions
|
|
@ -26,7 +26,6 @@
|
|||
#include "../managers/animation/AnimationManager.hpp"
|
||||
#include "../managers/animation/DesktopAnimationManager.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../hyprerror/HyprError.hpp"
|
||||
#include "../layout/LayoutManager.hpp"
|
||||
#include "../i18n/Engine.hpp"
|
||||
|
|
@ -34,6 +33,7 @@
|
|||
#include "time/Time.hpp"
|
||||
#include "../desktop/view/LayerSurface.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "Drm.hpp"
|
||||
#include <aquamarine/output/Output.hpp>
|
||||
#include "debug/log/Logger.hpp"
|
||||
|
|
@ -74,7 +74,7 @@ CMonitor::~CMonitor() {
|
|||
}
|
||||
|
||||
void CMonitor::onConnect(bool noRule) {
|
||||
EMIT_HOOK_EVENT("preMonitorAdded", m_self.lock());
|
||||
Event::bus()->m_events.monitor.preAdded.emit(m_self.lock());
|
||||
CScopeGuard x = {[]() { g_pCompositor->arrangeMonitors(); }};
|
||||
|
||||
m_zoomAnimProgress->setValueAndWarp(0.F);
|
||||
|
|
@ -347,17 +347,17 @@ void CMonitor::onConnect(bool noRule) {
|
|||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", m_id, m_name, m_shortDescription)});
|
||||
EMIT_HOOK_EVENT("monitorAdded", m_self.lock());
|
||||
Event::bus()->m_events.monitor.added.emit(m_self.lock());
|
||||
}
|
||||
|
||||
void CMonitor::onDisconnect(bool destroy) {
|
||||
EMIT_HOOK_EVENT("preMonitorRemoved", m_self.lock());
|
||||
Event::bus()->m_events.monitor.preRemoved.emit(m_self.lock());
|
||||
CScopeGuard x = {[this]() {
|
||||
if (g_pCompositor->m_isShuttingDown)
|
||||
return;
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitorremovedv2", std::format("{},{},{}", m_id, m_name, m_shortDescription)});
|
||||
EMIT_HOOK_EVENT("monitorRemoved", m_self.lock());
|
||||
Event::bus()->m_events.monitor.removed.emit(m_self.lock());
|
||||
g_pCompositor->scheduleMonitorStateRecheck();
|
||||
}};
|
||||
|
||||
|
|
@ -1016,7 +1016,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
|
|||
Log::logger->log(Log::DEBUG, "Monitor {} data dump: res {:X}@{:.2f}Hz, scale {:.2f}, transform {}, pos {:X}, 10b {}", m_name, m_pixelSize, m_refreshRate, m_scale,
|
||||
sc<int>(m_transform), m_position, sc<int>(m_enabled10bit));
|
||||
|
||||
EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr);
|
||||
Event::bus()->m_events.monitor.layoutChanged.emit();
|
||||
|
||||
m_events.modeChanged.emit();
|
||||
|
||||
|
|
@ -1336,7 +1336,7 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo
|
|||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"workspacev2", std::format("{},{}", pWorkspace->m_id, pWorkspace->m_name)});
|
||||
EMIT_HOOK_EVENT("workspace", pWorkspace);
|
||||
Event::bus()->m_events.workspace.active.emit(pWorkspace);
|
||||
}
|
||||
|
||||
// set all LSes as not above fullscreen on workspace changes
|
||||
|
|
@ -2196,7 +2196,7 @@ bool CMonitorState::commit() {
|
|||
if (!updateSwapchain())
|
||||
return false;
|
||||
|
||||
EMIT_HOOK_EVENT("preMonitorCommit", m_owner->m_self.lock());
|
||||
Event::bus()->m_events.monitor.preCommit.emit(m_owner->m_self.lock());
|
||||
|
||||
ensureBufferPresent();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue