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
|
|
@ -62,7 +62,6 @@
|
|||
#include "managers/animation/AnimationManager.hpp"
|
||||
#include "managers/animation/DesktopAnimationManager.hpp"
|
||||
#include "managers/EventManager.hpp"
|
||||
#include "managers/HookSystemManager.hpp"
|
||||
#include "managers/ProtocolManager.hpp"
|
||||
#include "managers/WelcomeManager.hpp"
|
||||
#include "render/AsyncResourceGatherer.hpp"
|
||||
|
|
@ -74,6 +73,7 @@
|
|||
#include "i18n/Engine.hpp"
|
||||
#include "layout/LayoutManager.hpp"
|
||||
#include "layout/target/WindowTarget.hpp"
|
||||
#include "event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/string/String.hpp>
|
||||
#include <aquamarine/input/Input.hpp>
|
||||
|
|
@ -106,11 +106,6 @@ static void handleUnrecoverableSignal(int sig) {
|
|||
signal(SIGABRT, SIG_DFL);
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
|
||||
if (g_pHookSystem && g_pHookSystem->m_currentEventPlugin) {
|
||||
longjmp(g_pHookSystem->m_hookFaultJumpBuf, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Kill the program if the crash-reporter is caught in a deadlock.
|
||||
signal(SIGALRM, [](int _) {
|
||||
char const* msg = "\nCrashReporter exceeded timeout, forcefully exiting\n";
|
||||
|
|
@ -286,7 +281,6 @@ static bool filterGlobals(const wl_client* client, const wl_global* global, void
|
|||
//
|
||||
void CCompositor::initServer(std::string socketName, int socketFd) {
|
||||
if (m_onlyConfigVerification) {
|
||||
g_pHookSystem = makeUnique<CHookSystemManager>();
|
||||
g_pKeybindManager = makeUnique<CKeybindManager>();
|
||||
g_pAnimationManager = makeUnique<CHyprAnimationManager>();
|
||||
g_pConfigManager = makeUnique<CConfigManager>();
|
||||
|
|
@ -597,7 +591,6 @@ void CCompositor::cleanup() {
|
|||
g_pHyprError.reset();
|
||||
g_pConfigManager.reset();
|
||||
g_pKeybindManager.reset();
|
||||
g_pHookSystem.reset();
|
||||
g_pXWaylandManager.reset();
|
||||
g_pPointerManager.reset();
|
||||
g_pSeatManager.reset();
|
||||
|
|
@ -626,9 +619,6 @@ void CCompositor::initManagers(eManagersInitStage stage) {
|
|||
Log::logger->log(Log::DEBUG, "Creating the EventLoopManager!");
|
||||
g_pEventLoopManager = makeUnique<CEventLoopManager>(m_wlDisplay, m_wlEventLoop);
|
||||
|
||||
Log::logger->log(Log::DEBUG, "Creating the HookSystem!");
|
||||
g_pHookSystem = makeUnique<CHookSystemManager>();
|
||||
|
||||
Log::logger->log(Log::DEBUG, "Creating the KeybindManager!");
|
||||
g_pKeybindManager = makeUnique<CKeybindManager>();
|
||||
|
||||
|
|
@ -799,7 +789,8 @@ void CCompositor::startCompositor() {
|
|||
|
||||
createLockFile();
|
||||
|
||||
EMIT_HOOK_EVENT("ready", nullptr);
|
||||
Event::bus()->m_events.ready.emit();
|
||||
|
||||
if (m_watchdogWriteFd.isValid())
|
||||
write(m_watchdogWriteFd.get(), "vax", 3);
|
||||
|
||||
|
|
@ -879,7 +870,7 @@ PHLMONITOR CCompositor::getMonitorFromVector(const Vector2D& point) {
|
|||
|
||||
void CCompositor::removeWindowFromVectorSafe(PHLWINDOW pWindow) {
|
||||
if (!pWindow->m_fadingOut) {
|
||||
EMIT_HOOK_EVENT("destroyWindow", pWindow);
|
||||
Event::bus()->m_events.window.destroy.emit(pWindow);
|
||||
|
||||
std::erase_if(m_windows, [&](SP<Desktop::View::CWindow>& el) { return el == pWindow; });
|
||||
std::erase_if(m_windowsFadingOut, [&](PHLWINDOWREF el) { return el.lock() == pWindow; });
|
||||
|
|
@ -1834,17 +1825,17 @@ void CCompositor::swapActiveWorkspaces(PHLMONITOR pMonitorA, PHLMONITOR pMonitor
|
|||
const auto PNEWWORKSPACE = pMonitorA->m_id == Desktop::focusState()->monitor()->m_id ? PWORKSPACEB : PWORKSPACEA;
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "workspace", .data = PNEWWORKSPACE->m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "workspacev2", .data = std::format("{},{}", PNEWWORKSPACE->m_id, PNEWWORKSPACE->m_name)});
|
||||
EMIT_HOOK_EVENT("workspace", PNEWWORKSPACE);
|
||||
Event::bus()->m_events.workspace.active.emit(PNEWWORKSPACE);
|
||||
}
|
||||
|
||||
// event
|
||||
// events
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "moveworkspace", .data = PWORKSPACEA->m_name + "," + pMonitorB->m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "moveworkspacev2", .data = std::format("{},{},{}", PWORKSPACEA->m_id, PWORKSPACEA->m_name, pMonitorB->m_name)});
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{PWORKSPACEA, pMonitorB}));
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "moveworkspace", .data = PWORKSPACEB->m_name + "," + pMonitorA->m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "moveworkspacev2", .data = std::format("{},{},{}", PWORKSPACEB->m_id, PWORKSPACEB->m_name, pMonitorA->m_name)});
|
||||
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{PWORKSPACEB, pMonitorA}));
|
||||
Event::bus()->m_events.workspace.moveToMonitor.emit(PWORKSPACEA, pMonitorB);
|
||||
Event::bus()->m_events.workspace.moveToMonitor.emit(PWORKSPACEB, pMonitorA);
|
||||
}
|
||||
|
||||
PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
|
||||
|
|
@ -2054,7 +2045,8 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo
|
|||
// event
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "moveworkspace", .data = pWorkspace->m_name + "," + pMonitor->m_name});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "moveworkspacev2", .data = std::format("{},{},{}", pWorkspace->m_id, pWorkspace->m_name, pMonitor->m_name)});
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{pWorkspace, pMonitor}));
|
||||
|
||||
Event::bus()->m_events.workspace.moveToMonitor.emit(pWorkspace, pMonitor);
|
||||
}
|
||||
|
||||
bool CCompositor::workspaceIDOutOfBounds(const WORKSPACEID& id) {
|
||||
|
|
@ -2149,7 +2141,7 @@ void CCompositor::setWindowFullscreenState(const PHLWINDOW PWINDOW, Desktop::Vie
|
|||
PWINDOW->m_fullscreenState.internal = state.internal;
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "fullscreen", .data = std::to_string(sc<int>(EFFECTIVE_MODE) != FSMODE_NONE)});
|
||||
EMIT_HOOK_EVENT("fullscreen", PWINDOW);
|
||||
Event::bus()->m_events.window.fullscreen.emit(PWINDOW);
|
||||
|
||||
PWINDOW->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_FULLSCREEN | Desktop::Rule::RULE_PROP_FULLSCREENSTATE_CLIENT |
|
||||
Desktop::Rule::RULE_PROP_FULLSCREENSTATE_INTERNAL | Desktop::Rule::RULE_PROP_ON_WORKSPACE);
|
||||
|
|
@ -2897,7 +2889,7 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
|
|||
PNEWMONITOR->m_id = FALLBACK ? MONITOR_INVALID : g_pCompositor->getNextAvailableMonitorID(output->name);
|
||||
PNEWMONITOR->m_isUnsafeFallback = FALLBACK;
|
||||
|
||||
EMIT_HOOK_EVENT("newMonitor", PNEWMONITOR);
|
||||
Event::bus()->m_events.monitor.newMon.emit(PNEWMONITOR);
|
||||
|
||||
if (!FALLBACK)
|
||||
PNEWMONITOR->onConnect(false);
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@ enum eInputType : uint8_t {
|
|||
INPUT_TYPE_MOTION
|
||||
};
|
||||
|
||||
struct SCallbackInfo {
|
||||
bool cancelled = false; /* on cancellable events, will cancel the event. */
|
||||
};
|
||||
|
||||
enum eHyprCtlOutputFormat : uint8_t {
|
||||
FORMAT_NORMAL = 0,
|
||||
FORMAT_JSON
|
||||
|
|
@ -62,5 +58,3 @@ struct SDispatchResult {
|
|||
using WINDOWID = int64_t;
|
||||
using MONITORID = int64_t;
|
||||
using WORKSPACEID = int64_t;
|
||||
|
||||
using HOOK_CALLBACK_FN = std::function<void(void*, SCallbackInfo&, std::any)>;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@
|
|||
#include "../managers/input/trackpad/gestures/FullscreenGesture.hpp"
|
||||
#include "../managers/input/trackpad/gestures/CursorZoomGesture.hpp"
|
||||
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
#include "../protocols/types/ContentType.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
|
@ -1066,7 +1067,7 @@ static void clearHlVersionVars() {
|
|||
}
|
||||
|
||||
void CConfigManager::reload() {
|
||||
EMIT_HOOK_EVENT("preConfigReload", nullptr);
|
||||
Event::bus()->m_events.config.preReload.emit();
|
||||
setDefaultAnimationVars();
|
||||
resetHLConfig();
|
||||
m_configCurrentPath = getMainConfigPath();
|
||||
|
|
@ -1458,7 +1459,7 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
|
|||
// update layouts
|
||||
Layout::Supplementary::algoMatcher()->updateWorkspaceLayouts();
|
||||
|
||||
EMIT_HOOK_EVENT("configReloaded", nullptr);
|
||||
Event::bus()->m_events.config.reloaded.emit();
|
||||
if (g_pEventManager)
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"configreloaded", ""});
|
||||
}
|
||||
|
|
@ -1747,7 +1748,7 @@ void CConfigManager::performMonitorReload() {
|
|||
|
||||
m_wantsMonitorReload = false;
|
||||
|
||||
EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr);
|
||||
Event::bus()->m_events.monitor.layoutChanged.emit();
|
||||
}
|
||||
|
||||
void* const* CConfigManager::getConfigValuePtr(const std::string& val) {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
#include "../Compositor.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include "../render/pass/TexPassElement.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
#include "../managers/animation/AnimationManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
|
||||
static inline auto iconBackendFromLayout(PangoLayout* layout) {
|
||||
|
|
@ -22,7 +22,7 @@ static inline auto iconBackendFromLayout(PangoLayout* layout) {
|
|||
}
|
||||
|
||||
CHyprNotificationOverlay::CHyprNotificationOverlay() {
|
||||
static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P = Event::bus()->m_events.monitor.focused.listen([&](PHLMONITOR mon) {
|
||||
if (m_notifications.empty())
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
#include "Logger.hpp"
|
||||
#include "RollingLogFollow.hpp"
|
||||
|
||||
#include "../../defines.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../config/ConfigValue.hpp"
|
||||
|
||||
using namespace Log;
|
||||
|
|
@ -39,7 +38,7 @@ void CLogger::initIS(const std::string_view& IS) {
|
|||
}
|
||||
|
||||
void CLogger::initCallbacks() {
|
||||
static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) { recheckCfg(); });
|
||||
static auto P = Event::bus()->m_events.config.reloaded.listen([this]() { recheckCfg(); });
|
||||
recheckCfg();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
#include "config/ConfigManager.hpp"
|
||||
#include "managers/animation/AnimationManager.hpp"
|
||||
#include "../managers/EventManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../layout/space/Space.hpp"
|
||||
#include "../layout/supplementary/WorkspaceAlgoMatcher.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/animation/AnimatedVariable.hpp>
|
||||
#include <hyprutils/string/String.hpp>
|
||||
|
|
@ -37,10 +37,8 @@ void CWorkspace::init(PHLWORKSPACE self) {
|
|||
if (RULEFORTHIS.defaultName.has_value())
|
||||
m_name = RULEFORTHIS.defaultName.value();
|
||||
|
||||
m_focusedWindowHook = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(param);
|
||||
|
||||
if (PWINDOW == m_lastFocusedWindow.lock())
|
||||
m_focusedWindowHook = Event::bus()->m_events.window.close.listen([this](PHLWINDOW pWindow) {
|
||||
if (pWindow == m_lastFocusedWindow.lock())
|
||||
m_lastFocusedWindow.reset();
|
||||
});
|
||||
|
||||
|
|
@ -58,22 +56,19 @@ void CWorkspace::init(PHLWORKSPACE self) {
|
|||
|
||||
g_pEventManager->postEvent({.event = "createworkspace", .data = m_name});
|
||||
g_pEventManager->postEvent({.event = "createworkspacev2", .data = std::format("{},{}", m_id, m_name)});
|
||||
EMIT_HOOK_EVENT("createWorkspace", this);
|
||||
Event::bus()->m_events.workspace.created.emit(self);
|
||||
}
|
||||
|
||||
CWorkspace::~CWorkspace() {
|
||||
Log::logger->log(Log::DEBUG, "Destroying workspace ID {}", m_id);
|
||||
|
||||
// check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing.
|
||||
if (g_pHookSystem)
|
||||
g_pHookSystem->unhook(m_focusedWindowHook);
|
||||
|
||||
if (g_pEventManager) {
|
||||
g_pEventManager->postEvent({.event = "destroyworkspace", .data = m_name});
|
||||
g_pEventManager->postEvent({.event = "destroyworkspacev2", .data = std::format("{},{}", m_id, m_name)});
|
||||
EMIT_HOOK_EVENT("destroyWorkspace", this);
|
||||
}
|
||||
|
||||
Event::bus()->m_events.workspace.removed.emit(m_self);
|
||||
|
||||
m_events.destroy.emit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,13 +93,13 @@ class CWorkspace {
|
|||
} m_events;
|
||||
|
||||
private:
|
||||
void init(PHLWORKSPACE self);
|
||||
void init(PHLWORKSPACE self);
|
||||
|
||||
SP<HOOK_CALLBACK_FN> m_focusedWindowHook;
|
||||
bool m_inert = true;
|
||||
CHyprSignalListener m_focusedWindowHook;
|
||||
bool m_inert = true;
|
||||
|
||||
SP<CWorkspace> m_selfPersistent; // for persistent workspaces.
|
||||
bool m_persistent = false;
|
||||
SP<CWorkspace> m_selfPersistent; // for persistent workspaces.
|
||||
bool m_persistent = false;
|
||||
};
|
||||
|
||||
inline bool valid(const PHLWORKSPACE& ref) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "WindowHistoryTracker.hpp"
|
||||
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../view/Window.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
using namespace Desktop;
|
||||
using namespace Desktop::History;
|
||||
|
|
@ -12,18 +12,12 @@ SP<CWindowHistoryTracker> History::windowTracker() {
|
|||
}
|
||||
|
||||
CWindowHistoryTracker::CWindowHistoryTracker() {
|
||||
static auto P = g_pHookSystem->hookDynamic("openWindowEarly", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
static auto P = Event::bus()->m_events.window.openEarly.listen([this](PHLWINDOW pWindow) {
|
||||
// add a last track
|
||||
m_history.insert(m_history.begin(), window);
|
||||
m_history.insert(m_history.begin(), pWindow);
|
||||
});
|
||||
|
||||
static auto P1 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<Desktop::View::SWindowActiveEvent>(data).window;
|
||||
|
||||
track(window);
|
||||
});
|
||||
static auto P1 = Event::bus()->m_events.window.active.listen([this](PHLWINDOW window, uint8_t reason) { track(window); });
|
||||
}
|
||||
|
||||
void CWindowHistoryTracker::track(PHLWINDOW w) {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
#include "../../helpers/Monitor.hpp"
|
||||
#include "../Workspace.hpp"
|
||||
#include "../state/FocusState.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
#include "../../config/ConfigValue.hpp"
|
||||
|
||||
#include <hyprutils/utils/ScopeGuard.hpp>
|
||||
|
|
@ -18,14 +18,9 @@ SP<CWorkspaceHistoryTracker> History::workspaceTracker() {
|
|||
}
|
||||
|
||||
CWorkspaceHistoryTracker::CWorkspaceHistoryTracker() {
|
||||
static auto P = g_pHookSystem->hookDynamic("workspace", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto workspace = std::any_cast<PHLWORKSPACE>(data);
|
||||
track(workspace);
|
||||
});
|
||||
|
||||
static auto P1 = g_pHookSystem->hookDynamic("focusedMon", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto mon = std::any_cast<PHLMONITOR>(data);
|
||||
static auto P = Event::bus()->m_events.workspace.active.listen([this](PHLWORKSPACE workspace) { track(workspace); });
|
||||
|
||||
static auto P1 = Event::bus()->m_events.monitor.focused.listen([this](PHLMONITOR mon) {
|
||||
// This sucks ASS, but we have to do this because switching to a workspace on another mon will trigger a workspace event right afterwards and we don't
|
||||
// want to remember the workspace that was not visible there
|
||||
// TODO: do something about this
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "../utils/SetUtils.hpp"
|
||||
#include "../../view/Window.hpp"
|
||||
#include "../../types/OverridableVar.hpp"
|
||||
#include "../../../managers/HookSystemManager.hpp"
|
||||
#include "../../../event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/string/String.hpp>
|
||||
|
||||
|
|
@ -634,5 +634,5 @@ void CWindowRuleApplicator::propertiesChanged(std::underlying_type_t<eRuleProper
|
|||
g_pDecorationPositioner->forceRecalcFor(m_window.lock());
|
||||
|
||||
// for plugins
|
||||
EMIT_HOOK_EVENT("windowUpdateRules", m_window.lock());
|
||||
Event::bus()->m_events.window.updateRules.emit(m_window.lock());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
#include "../../protocols/XDGShell.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "../../managers/EventManager.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/input/InputManager.hpp"
|
||||
#include "../../managers/SeatManager.hpp"
|
||||
#include "../../xwayland/XSurface.hpp"
|
||||
#include "../../protocols/PointerConstraints.hpp"
|
||||
#include "managers/animation/DesktopAnimationManager.hpp"
|
||||
#include "../../layout/LayoutManager.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
using namespace Desktop;
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, eFocusReason reason, SP<CWLS
|
|||
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""});
|
||||
|
||||
EMIT_HOOK_EVENT("activeWindow", Desktop::View::SWindowActiveEvent{nullptr COMMA reason});
|
||||
Event::bus()->m_events.window.active.emit(nullptr, reason);
|
||||
|
||||
m_focusSurface.reset();
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, eFocusReason reason, SP<CWLS
|
|||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = pWindow->m_class + "," + pWindow->m_title});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", rc<uintptr_t>(pWindow.get()))});
|
||||
|
||||
EMIT_HOOK_EVENT("activeWindow", Desktop::View::SWindowActiveEvent{pWindow COMMA reason});
|
||||
Event::bus()->m_events.window.active.emit(pWindow, reason);
|
||||
|
||||
g_pInputManager->recheckIdleInhibitorStatus();
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ void CFocusState::rawSurfaceFocus(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWi
|
|||
g_pSeatManager->setKeyboardFocus(nullptr);
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = ","});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = ""});
|
||||
EMIT_HOOK_EVENT("keyboardFocus", SP<CWLSurfaceResource>{nullptr});
|
||||
Event::bus()->m_events.input.keyboard.focus.emit(nullptr);
|
||||
m_focusSurface.reset();
|
||||
return;
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ void CFocusState::rawSurfaceFocus(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWi
|
|||
g_pXWaylandManager->activateSurface(pSurface, true);
|
||||
m_focusSurface = pSurface;
|
||||
|
||||
EMIT_HOOK_EVENT("keyboardFocus", pSurface);
|
||||
Event::bus()->m_events.input.keyboard.focus.emit(pSurface);
|
||||
|
||||
const auto SURF = Desktop::View::CWLSurface::fromResource(pSurface);
|
||||
const auto OLDSURF = Desktop::View::CWLSurface::fromResource(PLASTSURF);
|
||||
|
|
@ -278,7 +278,7 @@ void CFocusState::rawMonitorFocus(PHLMONITOR pMonitor) {
|
|||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "focusedmon", .data = pMonitor->m_name + "," + WORKSPACE_NAME});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "focusedmonv2", .data = pMonitor->m_name + "," + WORKSPACE_ID});
|
||||
|
||||
EMIT_HOOK_EVENT("focusedMon", pMonitor);
|
||||
Event::bus()->m_events.monitor.focused.emit(pMonitor);
|
||||
m_focusMonitor = pMonitor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../DesktopTypes.hpp"
|
||||
#include "../../SharedDefs.hpp"
|
||||
#include "../../helpers/signal/Signal.hpp"
|
||||
|
||||
class CWLSurfaceResource;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ namespace Desktop {
|
|||
PHLWINDOWREF m_focusWindow;
|
||||
PHLMONITORREF m_focusMonitor;
|
||||
|
||||
SP<HOOK_CALLBACK_FN> m_windowOpen, m_windowClose;
|
||||
CHyprSignalListener m_windowOpen, m_windowClose;
|
||||
};
|
||||
|
||||
SP<CFocusState> focusState();
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
#include "../../config/ConfigManager.hpp"
|
||||
#include "../../helpers/Monitor.hpp"
|
||||
#include "../../managers/input/InputManager.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/EventManager.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
using namespace Desktop;
|
||||
using namespace Desktop::View;
|
||||
|
|
@ -222,7 +222,7 @@ void CLayerSurface::onMap() {
|
|||
m_fadingOut = false;
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "openlayer", .data = m_namespace});
|
||||
EMIT_HOOK_EVENT("openLayer", m_self.lock());
|
||||
Event::bus()->m_events.layer.opened.emit(m_self.lock());
|
||||
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), PMONITOR->m_scale);
|
||||
g_pCompositor->setPreferredTransformForSurface(m_wlSurface->resource(), PMONITOR->m_transform);
|
||||
|
|
@ -232,7 +232,7 @@ void CLayerSurface::onUnmap() {
|
|||
Log::logger->log(Log::DEBUG, "LayerSurface {:x} unmapped", rc<uintptr_t>(m_layerSurface.get()));
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "closelayer", .data = m_layerSurface->m_layerNamespace});
|
||||
EMIT_HOOK_EVENT("closeLayer", m_self.lock());
|
||||
Event::bus()->m_events.layer.closed.emit(m_self.lock());
|
||||
|
||||
std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; });
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
#include "../../helpers/math/Expression.hpp"
|
||||
#include "../../managers/XWaylandManager.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/EventManager.hpp"
|
||||
#include "../../managers/input/InputManager.hpp"
|
||||
#include "../../managers/PointerManager.hpp"
|
||||
|
|
@ -48,6 +47,7 @@
|
|||
#include "../../layout/LayoutManager.hpp"
|
||||
#include "../../layout/target/WindowTarget.hpp"
|
||||
#include "../../layout/target/WindowGroupTarget.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/string/String.hpp>
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
|
|||
if (valid(pWorkspace)) {
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindow", .data = std::format("{:x},{}", rc<uintptr_t>(this), pWorkspace->m_name)});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindowv2", .data = std::format("{:x},{},{}", rc<uintptr_t>(this), pWorkspace->m_id, pWorkspace->m_name)});
|
||||
EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{m_self.lock(), pWorkspace}));
|
||||
Event::bus()->m_events.window.moveToWorkspace.emit(m_self.lock(), pWorkspace);
|
||||
}
|
||||
|
||||
if (const auto SWALLOWED = m_swallowed.lock()) {
|
||||
|
|
@ -1037,7 +1037,7 @@ void CWindow::activate(bool force) {
|
|||
m_isUrgent = true;
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "urgent", .data = std::format("{:x}", rc<uintptr_t>(this))});
|
||||
EMIT_HOOK_EVENT("urgent", m_self.lock());
|
||||
Event::bus()->m_events.window.urgent.emit(m_self.lock());
|
||||
|
||||
if (!force &&
|
||||
(!m_ruleApplicator->focusOnActivate().valueOr(*PFOCUSONACTIVATE) || (m_suppressedEvents & SUPPRESS_ACTIVATE_FOCUSONLY) || (m_suppressedEvents & SUPPRESS_ACTIVATE)))
|
||||
|
|
@ -1098,7 +1098,7 @@ void CWindow::onUpdateMeta() {
|
|||
m_title = NEWTITLE;
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitle", .data = std::format("{:x}", rc<uintptr_t>(this))});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitlev2", .data = std::format("{:x},{}", rc<uintptr_t>(this), m_title)});
|
||||
EMIT_HOOK_EVENT("windowTitle", m_self.lock());
|
||||
Event::bus()->m_events.window.title.emit(m_self.lock());
|
||||
|
||||
if (m_self == Desktop::focusState()->window()) { // if it's the active, let's post an event to update others
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title});
|
||||
|
|
@ -1115,6 +1115,8 @@ void CWindow::onUpdateMeta() {
|
|||
if (m_class != NEWCLASS) {
|
||||
m_class = NEWCLASS;
|
||||
|
||||
Event::bus()->m_events.window.class_.emit(m_self.lock());
|
||||
|
||||
if (m_self == Desktop::focusState()->window()) { // if it's the active, let's post an event to update others
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", rc<uintptr_t>(this))});
|
||||
|
|
@ -1945,7 +1947,7 @@ void CWindow::mapWindow() {
|
|||
|
||||
// emit the IPC event before the layout might focus the window to avoid a focus event first
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"openwindow", std::format("{:x},{},{},{}", m_self.lock(), PWORKSPACE->m_name, m_class, m_title)});
|
||||
EMIT_HOOK_EVENT("openWindowEarly", m_self.lock());
|
||||
Event::bus()->m_events.window.openEarly.emit(m_self.lock());
|
||||
|
||||
if (*PAUTOGROUP // auto_group enabled
|
||||
&& Desktop::focusState()->window() // focused window exists
|
||||
|
|
@ -2078,7 +2080,7 @@ void CWindow::mapWindow() {
|
|||
Log::logger->log(Log::DEBUG, "Map request dispatched, monitor {}, window pos: {:5j}, window size: {:5j}", PMONITOR->m_name, m_realPosition->goal(), m_realSize->goal());
|
||||
|
||||
// emit the hook event here after basic stuff has been initialized
|
||||
EMIT_HOOK_EVENT("openWindow", m_self.lock());
|
||||
Event::bus()->m_events.window.open.emit(m_self.lock());
|
||||
|
||||
// apply data from default decos. Borders, shadows.
|
||||
g_pDecorationPositioner->forceRecalcFor(m_self.lock());
|
||||
|
|
@ -2136,7 +2138,7 @@ void CWindow::unmapWindow() {
|
|||
|
||||
m_events.unmap.emit();
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"closewindow", std::format("{:x}", m_self.lock())});
|
||||
EMIT_HOOK_EVENT("closeWindow", m_self.lock());
|
||||
Event::bus()->m_events.window.close.emit(m_self.lock());
|
||||
|
||||
if (m_isFloating && !m_isX11 && m_ruleApplicator->persistentSize().valueOrDefault()) {
|
||||
Log::logger->log(Log::DEBUG, "storing floating size {}x{} for window {}::{} on close", m_realSize->value().x, m_realSize->value().y, m_class, m_title);
|
||||
|
|
@ -2250,7 +2252,7 @@ void CWindow::unmapWindow() {
|
|||
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""});
|
||||
|
||||
EMIT_HOOK_EVENT("activeWindow", Desktop::View::SWindowActiveEvent{nullptr COMMA FOCUS_REASON_OTHER});
|
||||
Event::bus()->m_events.window.active.emit(m_self.lock(), FOCUS_REASON_OTHER);
|
||||
}
|
||||
} else {
|
||||
Log::logger->log(Log::DEBUG, "Unmapped was not focused, ignoring a refocus.");
|
||||
|
|
|
|||
8
src/event/EventBus.cpp
Normal file
8
src/event/EventBus.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include "EventBus.hpp"
|
||||
|
||||
using namespace Event;
|
||||
|
||||
UP<CEventBus>& Event::bus() {
|
||||
static UP<CEventBus> p = makeUnique<CEventBus>();
|
||||
return p;
|
||||
}
|
||||
142
src/event/EventBus.hpp
Normal file
142
src/event/EventBus.hpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
#pragma once
|
||||
|
||||
#include "../helpers/memory/Memory.hpp"
|
||||
#include "../helpers/signal/Signal.hpp"
|
||||
#include "../helpers/math/Math.hpp"
|
||||
|
||||
#include "../devices/IPointer.hpp"
|
||||
#include "../devices/IKeyboard.hpp"
|
||||
#include "../devices/Tablet.hpp"
|
||||
#include "../devices/ITouch.hpp"
|
||||
|
||||
#include "../desktop/DesktopTypes.hpp"
|
||||
|
||||
#include "../SharedDefs.hpp"
|
||||
|
||||
namespace Desktop {
|
||||
enum eFocusReason : uint8_t;
|
||||
}
|
||||
namespace Event {
|
||||
struct SCallbackInfo {
|
||||
bool cancelled = false; /* on cancellable events, will cancel the event. */
|
||||
};
|
||||
|
||||
class CEventBus {
|
||||
public:
|
||||
CEventBus() = default;
|
||||
~CEventBus() = default;
|
||||
|
||||
template <typename... Args>
|
||||
using Event = CSignalT<Args...>;
|
||||
|
||||
template <typename... Args>
|
||||
using Cancellable = CSignalT<Args..., SCallbackInfo&>;
|
||||
|
||||
struct {
|
||||
Event<> ready;
|
||||
Event<> tick;
|
||||
|
||||
struct {
|
||||
Event<PHLWINDOW> open;
|
||||
Event<PHLWINDOW> openEarly;
|
||||
Event<PHLWINDOW> destroy;
|
||||
Event<PHLWINDOW> close;
|
||||
Event<PHLWINDOW, Desktop::eFocusReason> active;
|
||||
Event<PHLWINDOW> urgent;
|
||||
Event<PHLWINDOW> title;
|
||||
Event<PHLWINDOW> class_;
|
||||
Event<PHLWINDOW> pin;
|
||||
Event<PHLWINDOW> fullscreen;
|
||||
Event<PHLWINDOW> updateRules;
|
||||
Event<PHLWINDOW, PHLWORKSPACE> moveToWorkspace;
|
||||
} window;
|
||||
|
||||
struct {
|
||||
Event<PHLLS> opened;
|
||||
Event<PHLLS> closed;
|
||||
} layer;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
Cancellable<Vector2D> move;
|
||||
Cancellable<IPointer::SButtonEvent> button;
|
||||
Cancellable<IPointer::SAxisEvent> axis;
|
||||
} mouse;
|
||||
|
||||
struct {
|
||||
Cancellable<IKeyboard::SKeyEvent> key;
|
||||
Event<SP<IKeyboard>, const std::string&> layout;
|
||||
Event<SP<CWLSurfaceResource>> focus;
|
||||
} keyboard;
|
||||
|
||||
struct {
|
||||
Cancellable<CTablet::SAxisEvent> axis;
|
||||
Cancellable<CTablet::SButtonEvent> button;
|
||||
Cancellable<CTablet::SProximityEvent> proximity;
|
||||
Cancellable<CTablet::STipEvent> tip;
|
||||
} tablet;
|
||||
|
||||
struct {
|
||||
Cancellable<ITouch::SCancelEvent> cancel;
|
||||
Cancellable<ITouch::SDownEvent> down;
|
||||
Cancellable<ITouch::SUpEvent> up;
|
||||
Cancellable<ITouch::SMotionEvent> motion;
|
||||
} touch;
|
||||
} input;
|
||||
|
||||
struct {
|
||||
Event<PHLMONITOR> pre;
|
||||
Event<eRenderStage> stage;
|
||||
} render;
|
||||
|
||||
struct {
|
||||
Event<bool /* state start/stop */, uint8_t /* eScreenshareType */, const std::string& /* name */> state;
|
||||
} screenshare;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
Cancellable<IPointer::SSwipeBeginEvent> begin;
|
||||
Cancellable<IPointer::SSwipeEndEvent> end;
|
||||
Cancellable<IPointer::SSwipeUpdateEvent> update;
|
||||
} swipe;
|
||||
|
||||
struct {
|
||||
Cancellable<IPointer::SPinchBeginEvent> begin;
|
||||
Cancellable<IPointer::SPinchEndEvent> end;
|
||||
Cancellable<IPointer::SPinchUpdateEvent> update;
|
||||
} pinch;
|
||||
} gesture;
|
||||
|
||||
struct {
|
||||
Event<PHLMONITOR> newMon;
|
||||
Event<PHLMONITOR> preAdded;
|
||||
Event<PHLMONITOR> added;
|
||||
Event<PHLMONITOR> preRemoved;
|
||||
Event<PHLMONITOR> removed;
|
||||
Event<PHLMONITOR> preCommit;
|
||||
Event<PHLMONITOR> focused;
|
||||
|
||||
Event<> layoutChanged;
|
||||
} monitor;
|
||||
|
||||
struct {
|
||||
Event<PHLWORKSPACE, PHLMONITOR> moveToMonitor;
|
||||
Event<PHLWORKSPACE> active;
|
||||
Event<PHLWORKSPACEREF> created;
|
||||
Event<PHLWORKSPACEREF> removed;
|
||||
} workspace;
|
||||
|
||||
struct {
|
||||
Event<> preReload;
|
||||
Event<> reloaded;
|
||||
} config;
|
||||
|
||||
struct {
|
||||
Event<const std::string&> submap;
|
||||
} keybinds;
|
||||
|
||||
} m_events;
|
||||
};
|
||||
|
||||
UP<CEventBus>& bus();
|
||||
};
|
||||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include "../render/pass/TexPassElement.hpp"
|
||||
#include "../managers/animation/AnimationManager.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/utils/ScopeGuard.hpp>
|
||||
using namespace Hyprutils::Animation;
|
||||
|
|
@ -15,7 +15,7 @@ using namespace Hyprutils::Animation;
|
|||
CHyprError::CHyprError() {
|
||||
g_pAnimationManager->createAnimation(0.f, m_fadeOpacity, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), AVARDAMAGE_NONE);
|
||||
|
||||
static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P = Event::bus()->m_events.monitor.focused.listen([&](PHLMONITOR mon) {
|
||||
if (!m_isCreated)
|
||||
return;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ CHyprError::CHyprError() {
|
|||
m_monitorChanged = true;
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("preRender", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P2 = Event::bus()->m_events.render.pre.listen([&](PHLMONITOR mon) {
|
||||
if (!m_isCreated)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
#include "../config/ConfigManager.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../desktop/view/Group.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
using namespace Layout;
|
||||
|
||||
CLayoutManager::CLayoutManager() {
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [](void* hk, SCallbackInfo& info, std::any param) {
|
||||
static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([] {
|
||||
for (const auto& ws : g_pCompositor->getWorkspaces()) {
|
||||
ws->m_space->recheckWorkArea();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "../../../../desktop/history/WindowHistoryTracker.hpp"
|
||||
#include "../../../../helpers/Monitor.hpp"
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/string/VarList2.hpp>
|
||||
#include <hyprutils/string/ConstVarList.hpp>
|
||||
|
|
@ -22,16 +23,14 @@ using namespace Layout::Tiled;
|
|||
|
||||
CMonocleAlgorithm::CMonocleAlgorithm() {
|
||||
// hook into focus changes to bring focused window to front
|
||||
m_focusCallback = g_pHookSystem->hookDynamic("activeWindow", [this](void* hk, SCallbackInfo& info, std::any param) {
|
||||
const auto PWINDOW = std::any_cast<Desktop::View::SWindowActiveEvent>(param).window;
|
||||
|
||||
if (!PWINDOW)
|
||||
m_focusCallback = Event::bus()->m_events.window.active.listen([this](PHLWINDOW pWindow, Desktop::eFocusReason reason) {
|
||||
if (!pWindow)
|
||||
return;
|
||||
|
||||
if (!PWINDOW->m_workspace->isVisible())
|
||||
if (!pWindow->m_workspace->isVisible())
|
||||
return;
|
||||
|
||||
const auto TARGET = PWINDOW->layoutTarget();
|
||||
const auto TARGET = pWindow->layoutTarget();
|
||||
if (!TARGET)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../TiledAlgorithm.hpp"
|
||||
#include "../../../../managers/HookSystemManager.hpp"
|
||||
#include "../../../../helpers/signal/Signal.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ namespace Layout::Tiled {
|
|||
|
||||
private:
|
||||
std::vector<SP<SMonocleTargetData>> m_targetDatas;
|
||||
SP<HOOK_CALLBACK_FN> m_focusCallback;
|
||||
CHyprSignalListener m_focusCallback;
|
||||
|
||||
int m_currentVisibleIndex = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "../../../../config/ConfigManager.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
#include "../../../../managers/input/InputManager.hpp"
|
||||
#include "../../../../event/EventBus.hpp"
|
||||
|
||||
#include <hyprutils/string/VarList2.hpp>
|
||||
#include <hyprutils/string/ConstVarList.hpp>
|
||||
|
|
@ -477,7 +478,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() {
|
|||
return SCROLL_DIR_RIGHT; // default
|
||||
};
|
||||
|
||||
m_configCallback = g_pHookSystem->hookDynamic("configReloaded", [this, parseDirection](void* hk, SCallbackInfo& info, std::any param) {
|
||||
m_configCallback = Event::bus()->m_events.config.reloaded.listen([this, parseDirection] {
|
||||
static const auto PCONFDIRECTION = CConfigValue<Hyprlang::STRING>("scrolling:direction");
|
||||
|
||||
m_config.configuredWidths.clear();
|
||||
|
|
@ -495,32 +496,28 @@ CScrollingAlgorithm::CScrollingAlgorithm() {
|
|||
m_scrollingData->controller->setDirection(parseDirection(*PCONFDIRECTION));
|
||||
});
|
||||
|
||||
m_mouseButtonCallback = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto E = std::any_cast<IPointer::SButtonEvent>(e);
|
||||
if (E.state == WL_POINTER_BUTTON_STATE_RELEASED && Desktop::focusState()->window())
|
||||
m_mouseButtonCallback = Event::bus()->m_events.input.mouse.button.listen([this](IPointer::SButtonEvent e, Event::SCallbackInfo&) {
|
||||
if (e.state == WL_POINTER_BUTTON_STATE_RELEASED && Desktop::focusState()->window())
|
||||
focusOnInput(Desktop::focusState()->window()->layoutTarget(), true);
|
||||
});
|
||||
|
||||
m_focusCallback = g_pHookSystem->hookDynamic("activeWindow", [this](void* hk, SCallbackInfo& info, std::any param) {
|
||||
const auto E = std::any_cast<Desktop::View::SWindowActiveEvent>(param);
|
||||
const auto PWINDOW = E.window;
|
||||
|
||||
if (!PWINDOW)
|
||||
m_focusCallback = Event::bus()->m_events.window.active.listen([this](PHLWINDOW pWindow, Desktop::eFocusReason reason) {
|
||||
if (!pWindow)
|
||||
return;
|
||||
|
||||
static const auto PFOLLOW_FOCUS = CConfigValue<Hyprlang::INT>("scrolling:follow_focus");
|
||||
|
||||
if (!*PFOLLOW_FOCUS && !Desktop::isHardInputFocusReason(E.reason))
|
||||
if (!*PFOLLOW_FOCUS && !Desktop::isHardInputFocusReason(reason))
|
||||
return;
|
||||
|
||||
if (PWINDOW->m_workspace != m_parent->space()->workspace())
|
||||
if (pWindow->m_workspace != m_parent->space()->workspace())
|
||||
return;
|
||||
|
||||
const auto TARGET = PWINDOW->layoutTarget();
|
||||
const auto TARGET = pWindow->layoutTarget();
|
||||
if (!TARGET || TARGET->floating())
|
||||
return;
|
||||
|
||||
focusOnInput(TARGET, Desktop::isHardInputFocusReason(E.reason));
|
||||
focusOnInput(TARGET, Desktop::isHardInputFocusReason(reason));
|
||||
});
|
||||
|
||||
// Initialize default widths and direction
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../TiledAlgorithm.hpp"
|
||||
#include "../../../../managers/HookSystemManager.hpp"
|
||||
#include "../../../../helpers/math/Direction.hpp"
|
||||
#include "ScrollTapeController.hpp"
|
||||
#include "../../../../helpers/signal/Signal.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -112,11 +112,11 @@ namespace Layout::Tiled {
|
|||
CBox usableArea();
|
||||
|
||||
private:
|
||||
SP<SScrollingData> m_scrollingData;
|
||||
SP<SScrollingData> m_scrollingData;
|
||||
|
||||
SP<HOOK_CALLBACK_FN> m_configCallback;
|
||||
SP<HOOK_CALLBACK_FN> m_focusCallback;
|
||||
SP<HOOK_CALLBACK_FN> m_mouseButtonCallback;
|
||||
CHyprSignalListener m_configCallback;
|
||||
CHyprSignalListener m_focusCallback;
|
||||
CHyprSignalListener m_mouseButtonCallback;
|
||||
|
||||
struct {
|
||||
std::vector<float> configuredWidths;
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
#include "../helpers/fs/FsUtils.hpp"
|
||||
#include "../debug/log/Logger.hpp"
|
||||
#include "../macros.hpp"
|
||||
#include "HookSystemManager.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../protocols/XDGShell.hpp"
|
||||
#include "./eventLoop/EventLoopManager.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include "../xwayland/XSurface.hpp"
|
||||
#include "../i18n/Engine.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
using namespace Hyprutils::OS;
|
||||
|
||||
|
|
@ -26,9 +26,7 @@ CANRManager::CANRManager() {
|
|||
|
||||
m_active = true;
|
||||
|
||||
static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
static auto P = Event::bus()->m_events.window.open.listen([this](PHLWINDOW window) {
|
||||
for (const auto& d : m_data) {
|
||||
// Window is ANR dialog
|
||||
if (d->isRunning() && d->dialogBox->getPID() == window->getPID())
|
||||
|
|
@ -41,9 +39,7 @@ CANRManager::CANRManager() {
|
|||
m_data.emplace_back(makeShared<SANRData>(window));
|
||||
});
|
||||
|
||||
static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
static auto P1 = Event::bus()->m_events.window.close.listen([this](PHLWINDOW window) {
|
||||
for (const auto& d : m_data) {
|
||||
if (!d->fitsWindow(window))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
#include "../config/ConfigValue.hpp"
|
||||
#include "PointerManager.hpp"
|
||||
#include "../xwayland/XWayland.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../helpers/Monitor.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
static int cursorAnimTimer(SP<CEventLoopTimer> self, void* data) {
|
||||
const auto cursorMgr = sc<CCursorManager*>(data);
|
||||
|
|
@ -111,7 +111,7 @@ CCursorManager::CCursorManager() {
|
|||
|
||||
updateTheme();
|
||||
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [this](void* self, SCallbackInfo& info, std::any param) { this->updateTheme(); });
|
||||
static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([this] { this->updateTheme(); });
|
||||
}
|
||||
|
||||
CCursorManager::~CCursorManager() {
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
#include "HookSystemManager.hpp"
|
||||
|
||||
#include "../plugins/PluginSystem.hpp"
|
||||
|
||||
CHookSystemManager::CHookSystemManager() {
|
||||
; //
|
||||
}
|
||||
|
||||
// returns the pointer to the function
|
||||
SP<HOOK_CALLBACK_FN> CHookSystemManager::hookDynamic(const std::string& event, HOOK_CALLBACK_FN fn, HANDLE handle) {
|
||||
SP<HOOK_CALLBACK_FN> hookFN = makeShared<HOOK_CALLBACK_FN>(fn);
|
||||
m_registeredHooks[event].emplace_back(SCallbackFNPtr{.fn = hookFN, .handle = handle});
|
||||
return hookFN;
|
||||
}
|
||||
|
||||
void CHookSystemManager::unhook(SP<HOOK_CALLBACK_FN> fn) {
|
||||
for (auto& [k, v] : m_registeredHooks) {
|
||||
std::erase_if(v, [&](const auto& other) {
|
||||
SP<HOOK_CALLBACK_FN> fn_ = other.fn.lock();
|
||||
|
||||
return fn_.get() == fn.get();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCallbackInfo& info, std::any data) {
|
||||
if (callbacks->empty())
|
||||
return;
|
||||
|
||||
std::vector<HANDLE> faultyHandles;
|
||||
volatile bool needsDeadCleanup = false;
|
||||
|
||||
for (auto const& cb : *callbacks) {
|
||||
|
||||
m_currentEventPlugin = false;
|
||||
|
||||
if (!cb.handle) {
|
||||
// we don't guard hl hooks
|
||||
|
||||
if (SP<HOOK_CALLBACK_FN> fn = cb.fn.lock())
|
||||
(*fn)(fn.get(), info, data);
|
||||
else
|
||||
needsDeadCleanup = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
m_currentEventPlugin = true;
|
||||
|
||||
if (std::ranges::find(faultyHandles, cb.handle) != faultyHandles.end())
|
||||
continue;
|
||||
|
||||
try {
|
||||
if (!setjmp(m_hookFaultJumpBuf)) {
|
||||
if (SP<HOOK_CALLBACK_FN> fn = cb.fn.lock())
|
||||
(*fn)(fn.get(), info, data);
|
||||
else
|
||||
needsDeadCleanup = true;
|
||||
} else {
|
||||
// this module crashed.
|
||||
throw std::exception();
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
// TODO: this works only once...?
|
||||
faultyHandles.push_back(cb.handle);
|
||||
Log::logger->log(Log::ERR, "[hookSystem] Hook from plugin {:x} caused a SIGSEGV, queueing for unloading.", rc<uintptr_t>(cb.handle));
|
||||
}
|
||||
}
|
||||
|
||||
if (needsDeadCleanup)
|
||||
std::erase_if(*callbacks, [](const auto& fn) { return !fn.fn.lock(); });
|
||||
|
||||
if (!faultyHandles.empty()) {
|
||||
for (auto const& h : faultyHandles)
|
||||
g_pPluginSystem->unloadPlugin(g_pPluginSystem->getPluginByHandle(h), true);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SCallbackFNPtr>* CHookSystemManager::getVecForEvent(const std::string& event) {
|
||||
if (!m_registeredHooks.contains(event))
|
||||
Log::logger->log(Log::DEBUG, "[hookSystem] New hook event registered: {}", event);
|
||||
|
||||
return &m_registeredHooks[event];
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../defines.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <any>
|
||||
#include <array>
|
||||
#include <list>
|
||||
|
||||
#include <csetjmp>
|
||||
|
||||
#define HANDLE void*
|
||||
|
||||
// global type alias for hooked functions. Passes itself as a ptr when called, and `data` additionally.
|
||||
|
||||
using HOOK_CALLBACK_FN = std::function<void(void*, SCallbackInfo& info, std::any data)>;
|
||||
|
||||
struct SCallbackFNPtr {
|
||||
WP<HOOK_CALLBACK_FN> fn;
|
||||
HANDLE handle = nullptr;
|
||||
};
|
||||
|
||||
#define EMIT_HOOK_EVENT(name, param) \
|
||||
{ \
|
||||
static auto* const PEVENTVEC = g_pHookSystem->getVecForEvent(name); \
|
||||
SCallbackInfo info; \
|
||||
g_pHookSystem->emit(PEVENTVEC, info, param); \
|
||||
}
|
||||
|
||||
#define EMIT_HOOK_EVENT_CANCELLABLE(name, param) \
|
||||
{ \
|
||||
static auto* const PEVENTVEC = g_pHookSystem->getVecForEvent(name); \
|
||||
SCallbackInfo info; \
|
||||
g_pHookSystem->emit(PEVENTVEC, info, param); \
|
||||
if (info.cancelled) \
|
||||
return; \
|
||||
}
|
||||
|
||||
class CHookSystemManager {
|
||||
public:
|
||||
CHookSystemManager();
|
||||
|
||||
// returns the pointer to the function.
|
||||
// losing this pointer (letting it get destroyed)
|
||||
// will equal to unregistering the callback.
|
||||
[[nodiscard("Losing this pointer instantly unregisters the callback")]] SP<HOOK_CALLBACK_FN> hookDynamic(const std::string& event, HOOK_CALLBACK_FN fn,
|
||||
HANDLE handle = nullptr);
|
||||
void unhook(SP<HOOK_CALLBACK_FN> fn);
|
||||
|
||||
void emit(std::vector<SCallbackFNPtr>* const callbacks, SCallbackInfo& info, std::any data = 0);
|
||||
std::vector<SCallbackFNPtr>* getVecForEvent(const std::string& event);
|
||||
|
||||
bool m_currentEventPlugin = false;
|
||||
jmp_buf m_hookFaultJumpBuf;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::vector<SCallbackFNPtr>> m_registeredHooks;
|
||||
};
|
||||
|
||||
inline UP<CHookSystemManager> g_pHookSystem;
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
#include "TokenManager.hpp"
|
||||
#include "eventLoop/EventLoopManager.hpp"
|
||||
#include "debug/log/Logger.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/animation/DesktopAnimationManager.hpp"
|
||||
#include "../managers/EventManager.hpp"
|
||||
|
|
@ -32,6 +31,7 @@
|
|||
#include "../layout/algorithm/Algorithm.hpp"
|
||||
#include "../layout/algorithm/tiled/master/MasterAlgorithm.hpp"
|
||||
#include "../layout/algorithm/tiled/monocle/MonocleAlgorithm.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <iterator>
|
||||
|
|
@ -203,8 +203,7 @@ CKeybindManager::CKeybindManager() {
|
|||
g_pEventLoopManager->addTimer(m_repeatKeyTimer);
|
||||
}
|
||||
|
||||
static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) {
|
||||
// clear cuz realloc'd
|
||||
static auto P = Event::bus()->m_events.config.reloaded.listen([this] {
|
||||
m_activeKeybinds.clear();
|
||||
m_lastLongPressKeybind.reset();
|
||||
m_pressedSpecialBinds.clear();
|
||||
|
|
@ -2215,7 +2214,7 @@ SDispatchResult CKeybindManager::setSubmap(std::string submap) {
|
|||
m_currentSelectedSubmap.name = "";
|
||||
Log::logger->log(Log::DEBUG, "Reset active submap to the default one.");
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"submap", ""});
|
||||
EMIT_HOOK_EVENT("submap", m_currentSelectedSubmap.name);
|
||||
Event::bus()->m_events.keybinds.submap.emit(m_currentSelectedSubmap.name);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -2224,7 +2223,7 @@ SDispatchResult CKeybindManager::setSubmap(std::string submap) {
|
|||
m_currentSelectedSubmap.name = submap;
|
||||
Log::logger->log(Log::DEBUG, "Changed keybind submap to {}", submap);
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"submap", submap});
|
||||
EMIT_HOOK_EVENT("submap", m_currentSelectedSubmap.name);
|
||||
Event::bus()->m_events.keybinds.submap.emit(m_currentSelectedSubmap.name);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
|
@ -2584,7 +2583,7 @@ SDispatchResult CKeybindManager::pinActive(std::string args) {
|
|||
g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS);
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"pin", std::format("{:x},{}", rc<uintptr_t>(PWINDOW.get()), sc<int>(PWINDOW->m_pinned))});
|
||||
EMIT_HOOK_EVENT("pin", PWINDOW);
|
||||
Event::bus()->m_events.window.pin.emit(PWINDOW);
|
||||
|
||||
g_pHyprRenderer->damageWindow(PWINDOW, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
#include "eventLoop/EventLoopManager.hpp"
|
||||
#include "../render/pass/TexPassElement.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../render/OpenGL.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "SeatManager.hpp"
|
||||
#include "../helpers/time/Time.hpp"
|
||||
#include "../helpers/Drm.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include <cstring>
|
||||
#include <gbm.h>
|
||||
#include <cairo/cairo.h>
|
||||
|
|
@ -26,21 +26,19 @@
|
|||
using namespace Hyprutils::Utils;
|
||||
|
||||
CPointerManager::CPointerManager() {
|
||||
m_hooks.monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto PMONITOR = std::any_cast<PHLMONITOR>(data);
|
||||
|
||||
m_hooks.monitorAdded = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR monitor) {
|
||||
onMonitorLayoutChange();
|
||||
|
||||
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] {
|
||||
monitor->m_events.modeChanged.listenStatic([this] { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); });
|
||||
monitor->m_events.disconnect.listenStatic([this] { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); });
|
||||
monitor->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) {
|
||||
auto state = stateFor(std::any_cast<PHLMONITOR>(data));
|
||||
m_hooks.monitorPreRender = Event::bus()->m_events.monitor.preCommit.listen([this](PHLMONITOR monitor) {
|
||||
auto state = stateFor(monitor);
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "../desktop/view/WLSurface.hpp"
|
||||
#include "../helpers/sync/SyncTimeline.hpp"
|
||||
#include "../helpers/time/Time.hpp"
|
||||
#include "../helpers/signal/Signal.hpp"
|
||||
#include <tuple>
|
||||
|
||||
class CMonitor;
|
||||
|
|
@ -184,8 +185,8 @@ class CPointerManager {
|
|||
bool setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquamarine::IBuffer> buf);
|
||||
|
||||
struct {
|
||||
SP<HOOK_CALLBACK_FN> monitorAdded;
|
||||
SP<HOOK_CALLBACK_FN> monitorPreRender;
|
||||
CHyprSignalListener monitorAdded;
|
||||
CHyprSignalListener monitorPreRender;
|
||||
} m_hooks;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@
|
|||
#include "../protocols/PointerWarp.hpp"
|
||||
#include "../protocols/Fifo.hpp"
|
||||
#include "../protocols/CommitTiming.hpp"
|
||||
#include "HookSystemManager.hpp"
|
||||
|
||||
#include "../helpers/Monitor.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "content-type-v1.hpp"
|
||||
|
|
@ -113,9 +113,7 @@ CProtocolManager::CProtocolManager() {
|
|||
static const auto PENABLECT = CConfigValue<Hyprlang::INT>("render:commit_timing_enabled");
|
||||
|
||||
// Outputs are a bit dumb, we have to agree.
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
auto M = std::any_cast<PHLMONITOR>(param);
|
||||
|
||||
static auto P = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR M) {
|
||||
// ignore mirrored outputs. I don't think this will ever be hit as mirrors are applied after
|
||||
// this event is emitted iirc.
|
||||
// also ignore the fallback
|
||||
|
|
@ -132,8 +130,7 @@ CProtocolManager::CProtocolManager() {
|
|||
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) {
|
||||
auto M = std::any_cast<PHLMONITOR>(param);
|
||||
static auto P2 = Event::bus()->m_events.monitor.removed.listen([this](PHLMONITOR M) {
|
||||
if (!PROTO::outputs.contains(M->m_name))
|
||||
return;
|
||||
PROTO::outputs.at(M->m_name)->remove();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include "../devices/IKeyboard.hpp"
|
||||
#include "../desktop/view/LayerSurface.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "wlr-layer-shell-unstable-v1.hpp"
|
||||
#include <algorithm>
|
||||
#include <hyprutils/utils/ScopeGuard.hpp>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "AnimationManager.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../HookSystemManager.hpp"
|
||||
#include "../../config/ConfigManager.hpp"
|
||||
#include "../../desktop/DesktopTypes.hpp"
|
||||
#include "../../helpers/AnimatedVariable.hpp"
|
||||
|
|
@ -11,6 +10,7 @@
|
|||
#include "../eventLoop/EventLoopManager.hpp"
|
||||
#include "../../helpers/varlist/VarList.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
#include <hyprgraphics/color/Color.hpp>
|
||||
#include <hyprutils/animation/AnimatedVariable.hpp>
|
||||
|
|
@ -252,7 +252,7 @@ void CHyprAnimationManager::frameTick() {
|
|||
if (!shouldTickForNext())
|
||||
return;
|
||||
|
||||
if UNLIKELY (!g_pCompositor->m_sessionActive || !g_pHookSystem || g_pCompositor->m_unsafeState ||
|
||||
if UNLIKELY (!g_pCompositor->m_sessionActive || g_pCompositor->m_unsafeState ||
|
||||
!std::ranges::any_of(g_pCompositor->m_monitors, [](const auto& mon) { return mon->m_enabled && mon->m_output; }))
|
||||
return;
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ void CHyprAnimationManager::frameTick() {
|
|||
m_lastTickValid = true;
|
||||
|
||||
tick();
|
||||
EMIT_HOOK_EVENT("tick", nullptr);
|
||||
Event::bus()->m_events.tick.emit();
|
||||
}
|
||||
|
||||
if (shouldTickForNext())
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include "../../managers/SeatManager.hpp"
|
||||
#include "../../managers/KeybindManager.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/EventManager.hpp"
|
||||
#include "../../managers/permissions/DynamicPermissionManager.hpp"
|
||||
|
||||
|
|
@ -44,6 +43,8 @@
|
|||
|
||||
#include "../../layout/LayoutManager.hpp"
|
||||
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
#include "trackpad/TrackpadGestures.hpp"
|
||||
#include "../cursor/CursorShapeOverrideController.hpp"
|
||||
|
||||
|
|
@ -233,7 +234,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
PHLLS pFoundLayerSurface;
|
||||
const auto FOCUS_REASON = refocus ? Desktop::FOCUS_REASON_CLICK : Desktop::FOCUS_REASON_FFM;
|
||||
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.mouse.move.emit(MOUSECOORDSFLOORED, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
m_lastCursorPosFloored = MOUSECOORDSFLOORED;
|
||||
|
||||
|
|
@ -644,7 +648,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
}
|
||||
|
||||
void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.mouse.button.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
if (e.mouse)
|
||||
recheckMouseWarpOnMouseInput();
|
||||
|
|
@ -866,8 +873,10 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e, SP<IPointer> pointer) {
|
|||
if (pointer && pointer->m_scrollFactor.has_value())
|
||||
factor = *pointer->m_scrollFactor;
|
||||
|
||||
const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}};
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.mouse.axis.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
if (e.mouse)
|
||||
recheckMouseWarpOnMouseInput();
|
||||
|
|
@ -1056,7 +1065,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
|
|||
}
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEEB->m_hlName + "," + LAYOUT});
|
||||
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{PKEEB, LAYOUT}));
|
||||
Event::bus()->m_events.input.keyboard.layout.emit(PKEEB, LAYOUT);
|
||||
});
|
||||
|
||||
disableAllKeyboards(false);
|
||||
|
|
@ -1153,7 +1162,7 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
|
|||
const auto LAYOUTSTR = pKeyboard->getActiveLayout();
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUTSTR});
|
||||
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUTSTR}));
|
||||
Event::bus()->m_events.input.keyboard.layout.emit(pKeyboard, LAYOUTSTR);
|
||||
|
||||
Log::logger->log(Log::DEBUG, "Set the keyboard layout to {} and variant to {} for keyboard \"{}\"", pKeyboard->m_currentRules.layout, pKeyboard->m_currentRules.variant,
|
||||
pKeyboard->m_hlName);
|
||||
|
|
@ -1475,14 +1484,16 @@ void CInputManager::onKeyboardKey(const IKeyboard::SKeyEvent& event, SP<IKeyboar
|
|||
if (!pKeyboard->m_enabled || !pKeyboard->m_allowed)
|
||||
return;
|
||||
|
||||
const bool DISALLOWACTION = pKeyboard->isVirtual() && shouldIgnoreVirtualKeyboard(pKeyboard);
|
||||
const bool DISALLOWACTION = pKeyboard->isVirtual() && shouldIgnoreVirtualKeyboard(pKeyboard);
|
||||
|
||||
const auto IME = m_relay.m_inputMethod.lock();
|
||||
const bool HASIME = IME && IME->hasGrab();
|
||||
const bool USEIME = HASIME && !DISALLOWACTION;
|
||||
const auto IME = m_relay.m_inputMethod.lock();
|
||||
const bool HASIME = IME && IME->hasGrab();
|
||||
const bool USEIME = HASIME && !DISALLOWACTION;
|
||||
|
||||
const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", event}};
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.keyboard.key.emit(event, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
bool passEvent = DISALLOWACTION;
|
||||
|
||||
|
|
@ -1571,7 +1582,7 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) {
|
|||
Log::logger->log(Log::DEBUG, "LAYOUT CHANGED TO {} GROUP {}", LAYOUT, MODS.group);
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUT});
|
||||
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUT}));
|
||||
Event::bus()->m_events.input.keyboard.layout.emit(pKeyboard, LAYOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2039,7 +2050,10 @@ void CInputManager::recheckMouseWarpOnMouseInput() {
|
|||
}
|
||||
|
||||
void CInputManager::onSwipeBegin(IPointer::SSwipeBeginEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("swipeBegin", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.gesture.swipe.begin.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
g_pTrackpadGestures->gestureBegin(e);
|
||||
|
||||
|
|
@ -2047,7 +2061,10 @@ void CInputManager::onSwipeBegin(IPointer::SSwipeBeginEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onSwipeUpdate(IPointer::SSwipeUpdateEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("swipeUpdate", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.gesture.swipe.update.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
g_pTrackpadGestures->gestureUpdate(e);
|
||||
|
||||
|
|
@ -2055,7 +2072,10 @@ void CInputManager::onSwipeUpdate(IPointer::SSwipeUpdateEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onSwipeEnd(IPointer::SSwipeEndEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("swipeEnd", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.gesture.swipe.end.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
g_pTrackpadGestures->gestureEnd(e);
|
||||
|
||||
|
|
@ -2063,7 +2083,10 @@ void CInputManager::onSwipeEnd(IPointer::SSwipeEndEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onPinchBegin(IPointer::SPinchBeginEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("pinchBegin", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.gesture.pinch.begin.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
g_pTrackpadGestures->gestureBegin(e);
|
||||
|
||||
|
|
@ -2071,7 +2094,10 @@ void CInputManager::onPinchBegin(IPointer::SPinchBeginEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onPinchUpdate(IPointer::SPinchUpdateEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("pinchUpdate", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.gesture.pinch.update.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
g_pTrackpadGestures->gestureUpdate(e);
|
||||
|
||||
|
|
@ -2079,7 +2105,10 @@ void CInputManager::onPinchUpdate(IPointer::SPinchUpdateEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onPinchEnd(IPointer::SPinchEndEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("pinchEnd", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.gesture.pinch.end.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
g_pTrackpadGestures->gestureEnd(e);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
#include "InputMethodRelay.hpp"
|
||||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
#include "../../protocols/TextInputV3.hpp"
|
||||
#include "../../protocols/TextInputV1.hpp"
|
||||
#include "../../protocols/InputMethodV2.hpp"
|
||||
#include "../../protocols/core/Compositor.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
|
||||
CInputMethodRelay::CInputMethodRelay() {
|
||||
static auto P =
|
||||
g_pHookSystem->hookDynamic("keyboardFocus", [&](void* self, SCallbackInfo& info, std::any param) { onKeyboardFocus(std::any_cast<SP<CWLSurfaceResource>>(param)); });
|
||||
static auto P = Event::bus()->m_events.input.keyboard.focus.listen([&](SP<CWLSurfaceResource> surf) { onKeyboardFocus(surf); });
|
||||
|
||||
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); });
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
#include "../../desktop/view/Window.hpp"
|
||||
#include "../../protocols/Tablet.hpp"
|
||||
#include "../../devices/Tablet.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/PointerManager.hpp"
|
||||
#include "../../managers/SeatManager.hpp"
|
||||
#include "../../protocols/PointerConstraints.hpp"
|
||||
#include "../../protocols/core/DataDevice.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
static void unfocusTool(SP<CTabletTool> tool) {
|
||||
if (!tool->getSurface())
|
||||
|
|
@ -107,6 +107,11 @@ static Vector2D transformToActiveRegion(const Vector2D pos, const CBox activeAre
|
|||
}
|
||||
|
||||
void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.tablet.axis.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
const auto PTAB = e.tablet;
|
||||
const auto PTOOL = ensureTabletToolPresent(e.tool);
|
||||
|
||||
|
|
@ -171,7 +176,10 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onTabletTip(CTablet::STipEvent e) {
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("tabletTip", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.tablet.tip.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
const auto PTAB = e.tablet;
|
||||
const auto PTOOL = ensureTabletToolPresent(e.tool);
|
||||
|
|
@ -196,6 +204,11 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.tablet.button.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
const auto PTOOL = ensureTabletToolPresent(e.tool);
|
||||
|
||||
if (e.down)
|
||||
|
|
@ -210,6 +223,11 @@ void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
|
|||
}
|
||||
|
||||
void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.tablet.proximity.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
const auto PTAB = e.tablet;
|
||||
const auto PTOOL = ensureTabletToolPresent(e.tool);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
#include "../../config/ConfigValue.hpp"
|
||||
#include "../../helpers/Monitor.hpp"
|
||||
#include "../../devices/ITouch.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
#include "../SeatManager.hpp"
|
||||
#include "../HookSystemManager.hpp"
|
||||
#include "debug/log/Logger.hpp"
|
||||
#include "UnifiedWorkspaceSwipeGesture.hpp"
|
||||
|
||||
|
|
@ -19,10 +19,14 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
|||
static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
|
||||
auto* const PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr())->getData());
|
||||
// TODO: WORKSPACERULE.gapsOut.value_or()
|
||||
auto gapsOut = *PGAPSOUT;
|
||||
static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size");
|
||||
static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert");
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("touchDown", e);
|
||||
auto gapsOut = *PGAPSOUT;
|
||||
static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size");
|
||||
static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert");
|
||||
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.touch.down.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->m_boundOutput.empty() ? e.device->m_boundOutput : "");
|
||||
|
||||
|
|
@ -109,7 +113,11 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
|||
void CInputManager::onTouchUp(ITouch::SUpEvent e) {
|
||||
m_lastInputTouch = true;
|
||||
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("touchUp", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.touch.up.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
if (g_pUnifiedWorkspaceSwipe->isGestureInProgress()) {
|
||||
// If there was a swipe from this finger, end it.
|
||||
if (e.touchID == g_pUnifiedWorkspaceSwipe->m_touchID)
|
||||
|
|
@ -126,7 +134,11 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) {
|
|||
|
||||
m_lastCursorMovement.reset();
|
||||
|
||||
EMIT_HOOK_EVENT_CANCELLABLE("touchMove", e);
|
||||
Event::SCallbackInfo info;
|
||||
Event::bus()->m_events.input.touch.motion.emit(e, info);
|
||||
if (info.cancelled)
|
||||
return;
|
||||
|
||||
if (g_pUnifiedWorkspaceSwipe->isGestureInProgress()) {
|
||||
// Do nothing if this is using a different finger.
|
||||
if (e.touchID != g_pUnifiedWorkspaceSwipe->m_touchID)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#include "../../render/OpenGL.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "../HookSystemManager.hpp"
|
||||
#include "../EventManager.hpp"
|
||||
#include "../eventLoop/EventLoopManager.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
using namespace Screenshare;
|
||||
|
||||
|
|
@ -119,18 +119,18 @@ void CScreenshareSession::calculateConstraints() {
|
|||
void CScreenshareSession::screenshareEvents(bool startSharing) {
|
||||
if (startSharing && !m_sharing) {
|
||||
m_sharing = true;
|
||||
EMIT_HOOK_EVENT("screencast", (std::vector<std::any>{1, m_type}));
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "screencast", .data = std::format("1,{}", m_type)});
|
||||
EMIT_HOOK_EVENT("screencastv2", (std::vector<std::any>{1, m_type, m_name}));
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "screencastv2", .data = std::format("1,{},{}", m_type, m_name)});
|
||||
LOGM(Log::INFO, "New screenshare session for ({}): {}", m_type, m_name);
|
||||
|
||||
Event::bus()->m_events.screenshare.state.emit(true, m_type, m_name);
|
||||
} else if (!startSharing && m_sharing) {
|
||||
m_sharing = false;
|
||||
EMIT_HOOK_EVENT("screencast", (std::vector<std::any>{0, m_type}));
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "screencast", .data = std::format("0,{}", m_type)});
|
||||
EMIT_HOOK_EVENT("screencastv2", (std::vector<std::any>{0, m_type, m_name}));
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "screencastv2", .data = std::format("0,{},{}", m_type, m_name)});
|
||||
LOGM(Log::INFO, "Stopped screenshare session for ({}): {}", m_type, m_name);
|
||||
|
||||
Event::bus()->m_events.screenshare.state.emit(false, m_type, m_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "../Compositor.hpp"
|
||||
#include "../debug/HyprCtl.hpp"
|
||||
#include "../plugins/PluginSystem.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../config/ConfigManager.hpp"
|
||||
#include "../debug/HyprNotificationOverlay.hpp"
|
||||
|
|
@ -38,9 +37,9 @@ APICALL SP<HOOK_CALLBACK_FN> HyprlandAPI::registerCallbackDynamic(HANDLE handle,
|
|||
if (!PLUGIN)
|
||||
return nullptr;
|
||||
|
||||
auto PFN = g_pHookSystem->hookDynamic(event, fn, handle);
|
||||
PLUGIN->m_registeredCallbacks.emplace_back(std::make_pair<>(event, WP<HOOK_CALLBACK_FN>(PFN)));
|
||||
return PFN;
|
||||
//auto PFN = g_pHookSystem->hookDynamic(event, fn, handle);
|
||||
//PLUGIN->m_registeredCallbacks.emplace_back(std::make_pair<>(event, WP<HOOK_CALLBACK_FN>(PFN)));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
APICALL bool HyprlandAPI::unregisterCallback(HANDLE handle, SP<HOOK_CALLBACK_FN> fn) {
|
||||
|
|
@ -49,8 +48,8 @@ APICALL bool HyprlandAPI::unregisterCallback(HANDLE handle, SP<HOOK_CALLBACK_FN>
|
|||
if (!PLUGIN)
|
||||
return false;
|
||||
|
||||
g_pHookSystem->unhook(fn);
|
||||
std::erase_if(PLUGIN->m_registeredCallbacks, [&](const auto& other) { return other.second.lock() == fn; });
|
||||
//g_pHookSystem->unhook(fn);
|
||||
// std::erase_if(PLUGIN->m_registeredCallbacks, [&](const auto& other) { return other.second.lock() == fn; });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,12 +70,15 @@ struct SVersionInfo {
|
|||
class IHyprLayout;
|
||||
class IHyprWindowDecoration;
|
||||
struct SConfigValue;
|
||||
class Hypr_dummyClass {};
|
||||
|
||||
namespace Layout {
|
||||
class ITiledAlgorithm;
|
||||
class IFloatingAlgorithm;
|
||||
};
|
||||
|
||||
using HOOK_CALLBACK_FN = Hypr_dummyClass;
|
||||
|
||||
/*
|
||||
These methods are for the plugin to implement
|
||||
Methods marked with REQUIRED are required.
|
||||
|
|
@ -148,6 +151,8 @@ namespace HyprlandAPI {
|
|||
APICALL Hyprlang::CConfigValue* getConfigValue(HANDLE handle, const std::string& name);
|
||||
|
||||
/*
|
||||
Deprecated: doesn't do anything anymore, use Event::bus()
|
||||
|
||||
Register a dynamic (function) callback to a selected event.
|
||||
Pointer will be free'd by Hyprland on unregisterCallback().
|
||||
|
||||
|
|
@ -155,7 +160,7 @@ namespace HyprlandAPI {
|
|||
|
||||
WARNING: Losing this pointer will unregister the callback!
|
||||
*/
|
||||
APICALL [[nodiscard]] SP<HOOK_CALLBACK_FN> registerCallbackDynamic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN fn);
|
||||
APICALL [[deprecated]] [[nodiscard]] SP<HOOK_CALLBACK_FN> registerCallbackDynamic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN fn);
|
||||
|
||||
/*
|
||||
Unregisters a callback. If the callback was dynamic, frees the memory.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include <ranges>
|
||||
#include "../config/ConfigManager.hpp"
|
||||
#include "../debug/HyprCtl.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../managers/permissions/DynamicPermissionManager.hpp"
|
||||
#include "../debug/HyprNotificationOverlay.hpp"
|
||||
|
|
@ -151,10 +150,10 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
|
|||
exitFunc();
|
||||
}
|
||||
|
||||
for (auto const& [k, v] : plugin->m_registeredCallbacks) {
|
||||
if (const auto SHP = v.lock())
|
||||
g_pHookSystem->unhook(SHP);
|
||||
}
|
||||
// for (auto const& [k, v] : plugin->m_registeredCallbacks) {
|
||||
// if (const auto SHP = v.lock())
|
||||
// g_pHookSystem->unhook(SHP);
|
||||
// }
|
||||
|
||||
for (const auto& l : plugin->m_registeredAlgos) {
|
||||
Layout::Supplementary::algoMatcher()->unregisterAlgo(l);
|
||||
|
|
|
|||
|
|
@ -12,22 +12,22 @@ class IHyprWindowDecoration;
|
|||
|
||||
class CPlugin {
|
||||
public:
|
||||
std::string m_name = "";
|
||||
std::string m_description = "";
|
||||
std::string m_author = "";
|
||||
std::string m_version = "";
|
||||
std::string m_name = "";
|
||||
std::string m_description = "";
|
||||
std::string m_author = "";
|
||||
std::string m_version = "";
|
||||
|
||||
std::string m_path = "";
|
||||
std::string m_path = "";
|
||||
|
||||
bool m_loadedWithConfig = false;
|
||||
bool m_loadedWithConfig = false;
|
||||
|
||||
HANDLE m_handle = nullptr;
|
||||
HANDLE m_handle = nullptr;
|
||||
|
||||
std::vector<IHyprWindowDecoration*> m_registeredDecorations;
|
||||
std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> m_registeredCallbacks;
|
||||
std::vector<std::string> m_registeredDispatchers;
|
||||
std::vector<WP<SHyprCtlCommand>> m_registeredHyprctlCommands;
|
||||
std::vector<std::string> m_registeredAlgos;
|
||||
std::vector<IHyprWindowDecoration*> m_registeredDecorations;
|
||||
//std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> m_registeredCallbacks;
|
||||
std::vector<std::string> m_registeredDispatchers;
|
||||
std::vector<WP<SHyprCtlCommand>> m_registeredHyprctlCommands;
|
||||
std::vector<std::string> m_registeredAlgos;
|
||||
};
|
||||
|
||||
class CPluginSystem {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
#include "ExtWorkspace.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include <algorithm>
|
||||
#include <any>
|
||||
#include <utility>
|
||||
#include "core/Output.hpp"
|
||||
|
||||
|
|
@ -297,17 +296,13 @@ void CExtWorkspaceManagerResource::onWorkspaceCreated(const PHLWORKSPACE& worksp
|
|||
}
|
||||
|
||||
CExtWorkspaceProtocol::CExtWorkspaceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P1 = g_pHookSystem->hookDynamic("createWorkspace", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto workspace = std::any_cast<CWorkspace*>(data)->m_self.lock();
|
||||
|
||||
static auto P1 = Event::bus()->m_events.workspace.created.listen([this](PHLWORKSPACEREF workspace) {
|
||||
for (auto const& m : m_managers) {
|
||||
m->onWorkspaceCreated(workspace);
|
||||
m->onWorkspaceCreated(workspace.lock());
|
||||
}
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto monitor = std::any_cast<PHLMONITOR>(data);
|
||||
|
||||
static auto P2 = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR monitor) {
|
||||
for (auto const& m : m_managers) {
|
||||
m->onMonitorCreated(monitor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "Fifo.hpp"
|
||||
#include "Compositor.hpp"
|
||||
#include "core/Compositor.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../helpers/Monitor.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
CFifoResource::CFifoResource(UP<CWpFifoV1>&& resource_, SP<CWLSurfaceResource> surface) : m_resource(std::move(resource_)), m_surface(surface) {
|
||||
if UNLIKELY (!m_resource->resource())
|
||||
|
|
@ -153,9 +153,7 @@ bool CFifoManagerResource::good() {
|
|||
}
|
||||
|
||||
CFifoProtocol::CFifoProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
auto M = std::any_cast<PHLMONITOR>(param);
|
||||
|
||||
static auto P = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR M) {
|
||||
M->m_events.presented.listenStatic([this, m = PHLMONITORREF{M}]() {
|
||||
if (!m || !PROTO::fifo)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "ForeignToplevel.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
CForeignToplevelHandle::CForeignToplevelHandle(SP<CExtForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) {
|
||||
if UNLIKELY (!resource_->resource())
|
||||
|
|
@ -123,9 +123,7 @@ bool CForeignToplevelList::good() {
|
|||
}
|
||||
|
||||
CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
static auto P = Event::bus()->m_events.window.open.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
|
|
@ -134,9 +132,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
|
|||
}
|
||||
});
|
||||
|
||||
static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
static auto P1 = Event::bus()->m_events.window.close.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
|
|
@ -145,9 +141,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
|
|||
}
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
auto window = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
static auto P2 = Event::bus()->m_events.window.title.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/EventManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) {
|
||||
if UNLIKELY (!resource_->resource())
|
||||
|
|
@ -343,70 +343,57 @@ bool CForeignToplevelWlrManager::good() {
|
|||
}
|
||||
|
||||
CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
if (!windowValidForForeign(PWINDOW))
|
||||
static auto P = Event::bus()->m_events.window.open.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
for (auto const& m : m_managers) {
|
||||
m->onMap(PWINDOW);
|
||||
m->onMap(window);
|
||||
}
|
||||
});
|
||||
|
||||
static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
if (!windowValidForForeign(PWINDOW))
|
||||
static auto P1 = Event::bus()->m_events.window.close.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
for (auto const& m : m_managers) {
|
||||
m->onUnmap(PWINDOW);
|
||||
m->onUnmap(window);
|
||||
}
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
if (!windowValidForForeign(PWINDOW))
|
||||
static auto P2 = Event::bus()->m_events.window.title.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
for (auto const& m : m_managers) {
|
||||
m->onTitle(PWINDOW);
|
||||
m->onTitle(window);
|
||||
}
|
||||
});
|
||||
|
||||
static auto P3 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
const auto PWINDOW = std::any_cast<Desktop::View::SWindowActiveEvent>(data).window;
|
||||
|
||||
if (PWINDOW && !windowValidForForeign(PWINDOW))
|
||||
static auto P3 = Event::bus()->m_events.window.active.listen([this](PHLWINDOW window, Desktop::eFocusReason reason) {
|
||||
if (window && !windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
for (auto const& m : m_managers) {
|
||||
m->onNewFocus(PWINDOW);
|
||||
m->onNewFocus(window);
|
||||
}
|
||||
});
|
||||
|
||||
static auto P4 = g_pHookSystem->hookDynamic("moveWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(std::any_cast<std::vector<std::any>>(data).at(0));
|
||||
const auto PWORKSPACE = std::any_cast<PHLWORKSPACE>(std::any_cast<std::vector<std::any>>(data).at(1));
|
||||
|
||||
if (!PWORKSPACE)
|
||||
static auto P4 = Event::bus()->m_events.window.moveToWorkspace.listen([this](PHLWINDOW window, PHLWORKSPACE ws) {
|
||||
if (!ws)
|
||||
return;
|
||||
|
||||
for (auto const& m : m_managers) {
|
||||
m->onMoveMonitor(PWINDOW, PWORKSPACE->m_monitor.lock());
|
||||
m->onMoveMonitor(window, ws->m_monitor.lock());
|
||||
}
|
||||
});
|
||||
|
||||
static auto P5 = g_pHookSystem->hookDynamic("fullscreen", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
if (!windowValidForForeign(PWINDOW))
|
||||
static auto P5 = Event::bus()->m_events.window.fullscreen.listen([this](PHLWINDOW window) {
|
||||
if (!windowValidForForeign(window))
|
||||
return;
|
||||
|
||||
for (auto const& m : m_managers) {
|
||||
m->onFullscreen(PWINDOW);
|
||||
m->onFullscreen(window);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
#include "core/Compositor.hpp"
|
||||
#include "types/DMABuffer.hpp"
|
||||
#include "types/WLBuffer.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../render/OpenGL.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
using namespace Hyprutils::OS;
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ void CLinuxDMABUFResource::sendMods() {
|
|||
}
|
||||
|
||||
CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("ready", [this](void* self, SCallbackInfo& info, std::any d) {
|
||||
static auto P = Event::bus()->m_events.ready.listen([this] {
|
||||
int rendererFD = g_pCompositor->m_drmRenderNode.fd >= 0 ? g_pCompositor->m_drmRenderNode.fd : g_pCompositor->m_drm.fd;
|
||||
auto dev = devIDFromFD(rendererFD);
|
||||
|
||||
|
|
@ -467,24 +467,22 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
|
|||
tches.emplace_back(std::make_pair<>(mon, tranche));
|
||||
}
|
||||
|
||||
static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
auto pMonitor = std::any_cast<PHLMONITOR>(param);
|
||||
auto tranche = SDMABUFTranche{
|
||||
.device = m_mainDevice,
|
||||
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
|
||||
.formats = pMonitor->m_output->getRenderFormats(),
|
||||
static auto monitorAdded = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR mon) {
|
||||
auto tranche = SDMABUFTranche{
|
||||
.device = m_mainDevice,
|
||||
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
|
||||
.formats = mon->m_output->getRenderFormats(),
|
||||
};
|
||||
m_formatTable->m_monitorTranches.emplace_back(std::make_pair<>(pMonitor, tranche));
|
||||
m_formatTable->m_monitorTranches.emplace_back(std::make_pair<>(mon, tranche));
|
||||
resetFormatTable();
|
||||
});
|
||||
|
||||
static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
auto pMonitor = std::any_cast<PHLMONITOR>(param);
|
||||
std::erase_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
|
||||
static auto monitorRemoved = Event::bus()->m_events.monitor.removed.listen([this](PHLMONITOR mon) {
|
||||
std::erase_if(m_formatTable->m_monitorTranches, [mon](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == mon; });
|
||||
resetFormatTable();
|
||||
});
|
||||
|
||||
static auto configReloaded = g_pHookSystem->hookDynamic("configReloaded", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto configReloaded = Event::bus()->m_events.config.reloaded.listen([this] {
|
||||
static const auto PSKIP_NON_KMS = CConfigValue<Hyprlang::INT>("quirks:skip_non_kms_dmabuf_formats");
|
||||
static auto prev = *PSKIP_NON_KMS;
|
||||
if (prev != *PSKIP_NON_KMS) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#include <algorithm>
|
||||
#include "../Compositor.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../config/ConfigManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
|
||||
using namespace Aquamarine;
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ bool COutputConfigurationHead::good() {
|
|||
}
|
||||
|
||||
COutputManagementProtocol::COutputManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([this] {
|
||||
updateAllOutputs();
|
||||
sendPendingSuccessEvents();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "PresentationTime.hpp"
|
||||
#include <algorithm>
|
||||
#include "../helpers/Monitor.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "core/Compositor.hpp"
|
||||
#include "core/Output.hpp"
|
||||
#include <aquamarine/output/Output.hpp>
|
||||
|
|
@ -77,10 +77,8 @@ void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const t
|
|||
}
|
||||
|
||||
CPresentationProtocol::CPresentationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
const auto PMONITOR = PHLMONITORREF{std::any_cast<PHLMONITOR>(param)};
|
||||
std::erase_if(m_queue, [PMONITOR](const auto& other) { return !other->m_surface || other->m_monitor == PMONITOR; });
|
||||
});
|
||||
static auto P = Event::bus()->m_events.monitor.removed.listen(
|
||||
[this](PHLMONITOR mon) { std::erase_if(m_queue, [mon](const auto& other) { return !other->m_surface || other->m_monitor == mon; }); });
|
||||
}
|
||||
|
||||
void CPresentationProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
#include "TearingControl.hpp"
|
||||
#include "../managers/ProtocolManager.hpp"
|
||||
#include "../desktop/view/Window.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "core/Compositor.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
|
||||
CTearingControlProtocol::CTearingControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P =
|
||||
g_pHookSystem->hookDynamic("destroyWindow", [this](void* self, SCallbackInfo& info, std::any param) { this->onWindowDestroy(std::any_cast<PHLWINDOW>(param)); });
|
||||
static auto P = Event::bus()->m_events.window.destroy.listen([this](PHLWINDOW window) { onWindowDestroy(window); });
|
||||
}
|
||||
|
||||
void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "../Compositor.hpp"
|
||||
#include "ForeignToplevelWlr.hpp"
|
||||
#include "../managers/screenshare/ScreenshareManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../helpers/Format.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "../config/ConfigValue.hpp"
|
||||
#include "../helpers/Monitor.hpp"
|
||||
#include "../xwayland/XWayland.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "core/Output.hpp"
|
||||
|
||||
#define OUTPUT_MANAGER_VERSION 3
|
||||
|
|
@ -36,8 +36,8 @@ void CXDGOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver
|
|||
}
|
||||
|
||||
CXDGOutputProtocol::CXDGOutputProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [this](void* self, SCallbackInfo& info, std::any param) { this->updateAllOutputs(); });
|
||||
static auto P2 = g_pHookSystem->hookDynamic("configReloaded", [this](void* self, SCallbackInfo& info, std::any param) { this->updateAllOutputs(); });
|
||||
static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([this] { updateAllOutputs(); });
|
||||
static auto P2 = Event::bus()->m_events.config.reloaded.listen([this] { updateAllOutputs(); });
|
||||
}
|
||||
|
||||
void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource) {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
#include "../../xwayland/XWayland.hpp"
|
||||
#include "../../xwayland/Server.hpp"
|
||||
#include "../../managers/input/InputManager.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../managers/cursor/CursorShapeOverrideController.hpp"
|
||||
#include "../../helpers/Monitor.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "../../xwayland/Dnd.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
using namespace Hyprutils::OS;
|
||||
|
||||
CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_) : m_source(source_), m_resource(resource_) {
|
||||
|
|
@ -586,29 +586,26 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
|
|||
});
|
||||
}
|
||||
|
||||
m_dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto E = std::any_cast<IPointer::SButtonEvent>(e);
|
||||
if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
m_dnd.mouseButton = Event::bus()->m_events.input.mouse.button.listen([this](IPointer::SButtonEvent e, Event::SCallbackInfo&) {
|
||||
if (e.state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
LOGM(Log::DEBUG, "Dropping drag on mouseUp");
|
||||
dropDrag();
|
||||
}
|
||||
});
|
||||
|
||||
m_dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) {
|
||||
m_dnd.touchUp = Event::bus()->m_events.input.touch.up.listen([this](ITouch::SUpEvent e, Event::SCallbackInfo&) {
|
||||
LOGM(Log::DEBUG, "Dropping drag on touchUp");
|
||||
dropDrag();
|
||||
});
|
||||
|
||||
m_dnd.tabletTip = g_pHookSystem->hookDynamic("tabletTip", [this](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto E = std::any_cast<CTablet::STipEvent>(e);
|
||||
if (!E.in) {
|
||||
m_dnd.tabletTip = Event::bus()->m_events.input.tablet.tip.listen([this](CTablet::STipEvent e, Event::SCallbackInfo&) {
|
||||
if (!e.in) {
|
||||
LOGM(Log::DEBUG, "Dropping drag on tablet tipUp");
|
||||
dropDrag();
|
||||
}
|
||||
});
|
||||
|
||||
m_dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto V = std::any_cast<const Vector2D>(e);
|
||||
m_dnd.mouseMove = Event::bus()->m_events.input.mouse.move.listen([this](Vector2D pos, Event::SCallbackInfo&) {
|
||||
if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
|
||||
auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
|
||||
|
||||
|
|
@ -620,13 +617,12 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
|
|||
if (!box.has_value())
|
||||
return;
|
||||
|
||||
m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos());
|
||||
LOGM(Log::DEBUG, "Drag motion {}", V - box->pos());
|
||||
m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), pos - box->pos());
|
||||
LOGM(Log::DEBUG, "Drag motion {}", pos - box->pos());
|
||||
}
|
||||
});
|
||||
|
||||
m_dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto E = std::any_cast<ITouch::SMotionEvent>(e);
|
||||
m_dnd.touchMove = Event::bus()->m_events.input.touch.motion.listen([this](ITouch::SMotionEvent e, Event::SCallbackInfo&) {
|
||||
if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
|
||||
auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
|
||||
|
||||
|
|
@ -638,8 +634,8 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
|
|||
if (!box.has_value())
|
||||
return;
|
||||
|
||||
m_dnd.focusedDevice->sendMotion(E.timeMs, E.pos);
|
||||
LOGM(Log::DEBUG, "Drag motion {}", E.pos);
|
||||
m_dnd.focusedDevice->sendMotion(e.timeMs, e.pos);
|
||||
LOGM(Log::DEBUG, "Drag motion {}", e.pos);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -178,11 +178,11 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
|
|||
CHyprSignalListener dndSurfaceCommit;
|
||||
|
||||
// for ending a dnd
|
||||
SP<HOOK_CALLBACK_FN> mouseMove;
|
||||
SP<HOOK_CALLBACK_FN> mouseButton;
|
||||
SP<HOOK_CALLBACK_FN> touchUp;
|
||||
SP<HOOK_CALLBACK_FN> touchMove;
|
||||
SP<HOOK_CALLBACK_FN> tabletTip;
|
||||
CHyprSignalListener mouseMove;
|
||||
CHyprSignalListener mouseButton;
|
||||
CHyprSignalListener touchUp;
|
||||
CHyprSignalListener touchMove;
|
||||
CHyprSignalListener tabletTip;
|
||||
} m_dnd;
|
||||
|
||||
void abortDrag();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "../protocols/core/Compositor.hpp"
|
||||
#include "../protocols/ColorManagement.hpp"
|
||||
#include "../protocols/types/ColorManagement.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../managers/CursorManager.hpp"
|
||||
|
|
@ -27,6 +26,7 @@
|
|||
#include "../helpers/env/Env.hpp"
|
||||
#include "../helpers/MainLoopExecutor.hpp"
|
||||
#include "../i18n/Engine.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "debug/HyprNotificationOverlay.hpp"
|
||||
#include "hyprerror/HyprError.hpp"
|
||||
#include "pass/TexPassElement.hpp"
|
||||
|
|
@ -391,7 +391,7 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() : m_drmFD(g_pCompositor->m_drmRenderNode.fd >
|
|||
|
||||
initAssets();
|
||||
|
||||
static auto P = g_pHookSystem->hookDynamic("preRender", [&](void* self, SCallbackInfo& info, std::any data) { preRender(std::any_cast<PHLMONITOR>(data)); });
|
||||
static auto P = Event::bus()->m_events.render.pre.listen([&](PHLMONITOR mon) { preRender(mon); });
|
||||
|
||||
RASSERT(eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), "Couldn't unset current EGL!");
|
||||
|
||||
|
|
@ -422,23 +422,19 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() : m_drmFD(g_pCompositor->m_drmRenderNode.fd >
|
|||
#endif
|
||||
};
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("mouseButton", [](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto E = std::any_cast<IPointer::SButtonEvent>(e);
|
||||
|
||||
if (E.state != WL_POINTER_BUTTON_STATE_PRESSED)
|
||||
static auto P2 = Event::bus()->m_events.input.mouse.button.listen([](IPointer::SButtonEvent e, Event::SCallbackInfo&) {
|
||||
if (e.state != WL_POINTER_BUTTON_STATE_PRESSED)
|
||||
return;
|
||||
|
||||
addLastPressToHistory(g_pInputManager->getMouseCoordsInternal(), g_pInputManager->getClickMode() == CLICKMODE_KILL, false);
|
||||
});
|
||||
|
||||
static auto P3 = g_pHookSystem->hookDynamic("touchDown", [](void* self, SCallbackInfo& info, std::any e) {
|
||||
auto E = std::any_cast<ITouch::SDownEvent>(e);
|
||||
|
||||
auto PMONITOR = g_pCompositor->getMonitorFromName(!E.device->m_boundOutput.empty() ? E.device->m_boundOutput : "");
|
||||
static auto P3 = Event::bus()->m_events.input.touch.down.listen([](ITouch::SDownEvent e, Event::SCallbackInfo&) {
|
||||
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->m_boundOutput.empty() ? e.device->m_boundOutput : "");
|
||||
|
||||
PMONITOR = PMONITOR ? PMONITOR : Desktop::focusState()->monitor();
|
||||
|
||||
const auto TOUCH_COORDS = PMONITOR->m_position + (E.pos * PMONITOR->m_size);
|
||||
const auto TOUCH_COORDS = PMONITOR->m_position + (e.pos * PMONITOR->m_size);
|
||||
|
||||
addLastPressToHistory(TOUCH_COORDS, g_pInputManager->getClickMode() == CLICKMODE_KILL, true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include "../managers/CursorManager.hpp"
|
||||
#include "../managers/PointerManager.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../managers/animation/AnimationManager.hpp"
|
||||
#include "../desktop/view/Window.hpp"
|
||||
#include "../desktop/view/LayerSurface.hpp"
|
||||
|
|
@ -30,6 +29,7 @@
|
|||
#include "../layout/LayoutManager.hpp"
|
||||
#include "../layout/space/Space.hpp"
|
||||
#include "../i18n/Engine.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "helpers/CursorShapes.hpp"
|
||||
#include "helpers/Monitor.hpp"
|
||||
#include "pass/TexPassElement.hpp"
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
#include "../protocols/ColorManagement.hpp"
|
||||
#include "../protocols/types/ContentType.hpp"
|
||||
#include "../helpers/MiscFunctions.hpp"
|
||||
#include "../event/EventBus.hpp"
|
||||
#include "render/OpenGL.hpp"
|
||||
|
||||
#include <hyprutils/utils/ScopeGuard.hpp>
|
||||
|
|
@ -113,7 +114,7 @@ CHyprRenderer::CHyprRenderer() {
|
|||
|
||||
// cursor hiding stuff
|
||||
|
||||
static auto P = g_pHookSystem->hookDynamic("keyPress", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P = Event::bus()->m_events.input.keyboard.key.listen([&](IKeyboard::SKeyEvent e, Event::SCallbackInfo&) {
|
||||
if (m_cursorHiddenConditions.hiddenOnKeyboard)
|
||||
return;
|
||||
|
||||
|
|
@ -121,7 +122,7 @@ CHyprRenderer::CHyprRenderer() {
|
|||
ensureCursorRenderingMode();
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("mouseMove", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P2 = Event::bus()->m_events.input.mouse.move.listen([&](Vector2D pos, Event::SCallbackInfo&) {
|
||||
if (!m_cursorHiddenConditions.hiddenOnKeyboard && m_cursorHiddenConditions.hiddenOnTouch == g_pInputManager->m_lastInputTouch &&
|
||||
m_cursorHiddenConditions.hiddenOnTablet == g_pInputManager->m_lastInputTablet && !m_cursorHiddenConditions.hiddenOnTimeout)
|
||||
return;
|
||||
|
|
@ -133,7 +134,7 @@ CHyprRenderer::CHyprRenderer() {
|
|||
ensureCursorRenderingMode();
|
||||
});
|
||||
|
||||
static auto P3 = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
static auto P3 = Event::bus()->m_events.monitor.focused.listen([&](PHLMONITOR mon) {
|
||||
g_pEventLoopManager->doLater([this]() {
|
||||
if (!g_pHyprError->active())
|
||||
return;
|
||||
|
|
@ -143,11 +144,9 @@ CHyprRenderer::CHyprRenderer() {
|
|||
});
|
||||
});
|
||||
|
||||
static auto P4 = g_pHookSystem->hookDynamic("windowUpdateRules", [&](void* self, SCallbackInfo& info, std::any param) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(param);
|
||||
|
||||
if (PWINDOW->m_ruleApplicator->renderUnfocused().valueOrDefault())
|
||||
addWindowToRenderUnfocused(PWINDOW);
|
||||
static auto P4 = Event::bus()->m_events.window.updateRules.listen([&](PHLWINDOW window) {
|
||||
if (window->m_ruleApplicator->renderUnfocused().valueOrDefault())
|
||||
addWindowToRenderUnfocused(window);
|
||||
});
|
||||
|
||||
m_cursorTicker = wl_event_loop_add_timer(g_pCompositor->m_wlEventLoop, cursorTicker, nullptr);
|
||||
|
|
@ -290,7 +289,7 @@ bool CHyprRenderer::shouldRenderWindow(PHLWINDOW pWindow) {
|
|||
void CHyprRenderer::renderWorkspaceWindowsFullscreen(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, const Time::steady_tp& time) {
|
||||
PHLWINDOW pWorkspaceWindow = nullptr;
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_PRE_WINDOWS);
|
||||
|
||||
// loop over the tiled windows that are fading out
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
|
|
@ -381,7 +380,7 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(PHLMONITOR pMonitor, PHLWOR
|
|||
void CHyprRenderer::renderWorkspaceWindows(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, const Time::steady_tp& time) {
|
||||
PHLWINDOW lastWindow;
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_PRE_WINDOWS);
|
||||
|
||||
std::vector<PHLWINDOWREF> windows, tiledFadingOut;
|
||||
windows.reserve(g_pCompositor->m_windows.size());
|
||||
|
|
@ -545,7 +544,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
|
|||
// for plugins
|
||||
g_pHyprOpenGL->m_renderData.currentWindow = pWindow;
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOW);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_PRE_WINDOW);
|
||||
|
||||
const auto fullAlpha = renderdata.alpha * renderdata.fadeAlpha;
|
||||
|
||||
|
|
@ -729,7 +728,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
|
|||
}
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_POST_WINDOW);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_POST_WINDOW);
|
||||
|
||||
g_pHyprOpenGL->m_renderData.currentWindow.reset();
|
||||
}
|
||||
|
|
@ -941,7 +940,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
renderLayer(ls.lock(), pMonitor, time);
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_POST_WALLPAPER);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_POST_WALLPAPER);
|
||||
|
||||
for (auto const& ls : pMonitor->m_layerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) {
|
||||
renderLayer(ls.lock(), pMonitor, time);
|
||||
|
|
@ -965,7 +964,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
renderLayer(ls.lock(), pMonitor, time);
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_POST_WALLPAPER);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_POST_WALLPAPER);
|
||||
|
||||
for (auto const& ls : pMonitor->m_layerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) {
|
||||
renderLayer(ls.lock(), pMonitor, time);
|
||||
|
|
@ -1030,7 +1029,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
renderWindow(w, pMonitor, time, true, RENDER_PASS_ALL);
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_POST_WINDOWS);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_POST_WINDOWS);
|
||||
|
||||
// Render surfaces above windows for monitor
|
||||
for (auto const& ls : pMonitor->m_layerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
||||
|
|
@ -1330,7 +1329,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
|
|||
pMonitor->m_drmFormat = pMonitor->m_prevDrmFormat;
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("preRender", pMonitor);
|
||||
Event::bus()->m_events.render.pre.emit(pMonitor);
|
||||
|
||||
const auto NOW = Time::steadyNow();
|
||||
|
||||
|
|
@ -1345,7 +1344,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
|
|||
return;
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_PRE);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_PRE);
|
||||
|
||||
pMonitor->m_renderingActive = true;
|
||||
|
||||
|
|
@ -1398,7 +1397,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
|
|||
pMonitor->m_forceFullFrames = 0;
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_BEGIN);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_BEGIN);
|
||||
|
||||
bool renderCursor = true;
|
||||
|
||||
|
|
@ -1409,7 +1408,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
|
|||
g_pHyprOpenGL->blend(false);
|
||||
g_pHyprOpenGL->renderMirrored();
|
||||
g_pHyprOpenGL->blend(true);
|
||||
EMIT_HOOK_EVENT("render", RENDER_POST_MIRROR);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_POST_MIRROR);
|
||||
renderCursor = false;
|
||||
} else {
|
||||
CBox renderBox = {0, 0, sc<int>(pMonitor->m_pixelSize.x), sc<int>(pMonitor->m_pixelSize.y)};
|
||||
|
|
@ -1462,7 +1461,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
|
|||
m_renderPass.add(makeUnique<CRectPassElement>(data));
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_LAST_MOMENT);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_LAST_MOMENT);
|
||||
|
||||
endRender();
|
||||
|
||||
|
|
@ -1484,7 +1483,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
|
|||
|
||||
pMonitor->m_renderingActive = false;
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_POST);
|
||||
Event::bus()->m_events.render.stage.emit(RENDER_POST);
|
||||
|
||||
pMonitor->m_output->state->addDamage(frameDamage);
|
||||
pMonitor->m_output->state->setPresentationMode(shouldTear ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE :
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "../../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../pass/BorderPassElement.hpp"
|
||||
#include "../Renderer.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
|
||||
CHyprBorderDecoration::CHyprBorderDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_window(pWindow) {
|
||||
;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,11 @@
|
|||
#include "DecorationPositioner.hpp"
|
||||
#include "../../desktop/view/Window.hpp"
|
||||
#include "../../managers/HookSystemManager.hpp"
|
||||
#include "../../layout/target/Target.hpp"
|
||||
#include "../../event/EventBus.hpp"
|
||||
|
||||
CDecorationPositioner::CDecorationPositioner() {
|
||||
static auto P = g_pHookSystem->hookDynamic("closeWindow", [this](void* call, SCallbackInfo& info, std::any data) {
|
||||
auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
this->onWindowUnmap(PWINDOW);
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("openWindow", [this](void* call, SCallbackInfo& info, std::any data) {
|
||||
auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
this->onWindowMap(PWINDOW);
|
||||
});
|
||||
static auto P = Event::bus()->m_events.window.close.listen([this](PHLWINDOW window) { onWindowUnmap(window); });
|
||||
static auto P2 = Event::bus()->m_events.window.open.listen([this](PHLWINDOW window) { onWindowMap(window); });
|
||||
}
|
||||
|
||||
Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOWREF pWindow) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue