mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 08:05:58 +01:00
parent
e0a7cf5c30
commit
b1a9430289
2 changed files with 19 additions and 7 deletions
|
@ -272,6 +272,7 @@ struct STabletPad {
|
||||||
struct SIdleInhibitor {
|
struct SIdleInhibitor {
|
||||||
wlr_idle_inhibitor_v1* pWlrInhibitor = nullptr;
|
wlr_idle_inhibitor_v1* pWlrInhibitor = nullptr;
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
|
HOOK_CALLBACK_FN* onWindowDestroy = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(Destroy);
|
DYNLISTENER(Destroy);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,16 @@ void Events::listener_newIdleInhibitor(wl_listener* listener, void* data) {
|
||||||
g_pInputManager->newIdleInhibitor(WLRIDLEINHIBITOR);
|
g_pInputManager->newIdleInhibitor(WLRIDLEINHIBITOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroyInhibitor(SIdleInhibitor* inhibitor) {
|
||||||
|
g_pHookSystem->unhook(inhibitor->onWindowDestroy);
|
||||||
|
|
||||||
|
g_pInputManager->m_lIdleInhibitors.remove(*inhibitor);
|
||||||
|
|
||||||
|
Debug::log(LOG, "Destroyed an idleinhibitor");
|
||||||
|
|
||||||
|
g_pInputManager->recheckIdleInhibitorStatus();
|
||||||
|
}
|
||||||
|
|
||||||
void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
|
void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
|
||||||
const auto PINHIBIT = &m_lIdleInhibitors.emplace_back();
|
const auto PINHIBIT = &m_lIdleInhibitors.emplace_back();
|
||||||
|
|
||||||
|
@ -17,16 +27,17 @@ void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
|
||||||
|
|
||||||
PINHIBIT->pWlrInhibitor = pInhibitor;
|
PINHIBIT->pWlrInhibitor = pInhibitor;
|
||||||
|
|
||||||
|
PINHIBIT->onWindowDestroy = g_pHookSystem->hookDynamic("closeWindow", [PINHIBIT](void* self, SCallbackInfo& info, std::any data) {
|
||||||
|
if (PINHIBIT->pWindow == std::any_cast<CWindow*>(data))
|
||||||
|
destroyInhibitor(PINHIBIT);
|
||||||
|
});
|
||||||
|
|
||||||
PINHIBIT->hyprListener_Destroy.initCallback(
|
PINHIBIT->hyprListener_Destroy.initCallback(
|
||||||
&pInhibitor->events.destroy,
|
&pInhibitor->events.destroy,
|
||||||
[](void* owner, void* data) {
|
[](void* owner, void* data) {
|
||||||
const auto PINH = (SIdleInhibitor*)owner;
|
const auto PINH = (SIdleInhibitor*)owner;
|
||||||
|
|
||||||
g_pInputManager->m_lIdleInhibitors.remove(*PINH);
|
destroyInhibitor(PINH);
|
||||||
|
|
||||||
Debug::log(LOG, "Destroyed an idleinhibitor");
|
|
||||||
|
|
||||||
g_pInputManager->recheckIdleInhibitorStatus();
|
|
||||||
},
|
},
|
||||||
PINHIBIT, "IdleInhibitor");
|
PINHIBIT, "IdleInhibitor");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue