mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-09 15:26:00 +01:00
added support for wlr_idle_inhibitor_v1
This commit is contained in:
parent
5a22335b8d
commit
9655d0c138
8 changed files with 83 additions and 0 deletions
|
@ -124,6 +124,8 @@ CCompositor::CCompositor() {
|
|||
|
||||
m_sWLRForeignRegistry = wlr_xdg_foreign_registry_create(m_sWLDisplay);
|
||||
|
||||
m_sWLRIdleInhibitMgr = wlr_idle_inhibit_v1_create(m_sWLDisplay);
|
||||
|
||||
wlr_xdg_foreign_v1_create(m_sWLDisplay, m_sWLRForeignRegistry);
|
||||
wlr_xdg_foreign_v2_create(m_sWLDisplay, m_sWLRForeignRegistry);
|
||||
}
|
||||
|
@ -160,6 +162,7 @@ void CCompositor::initAllSignals() {
|
|||
addWLSignal(&m_sWLRXDGDecoMgr->events.new_toplevel_decoration, &Events::listen_NewXDGDeco, m_sWLRXDGDecoMgr, "XDGDecoMgr");
|
||||
addWLSignal(&m_sWLRVirtPtrMgr->events.new_virtual_pointer, &Events::listen_newVirtPtr, m_sWLRVirtPtrMgr, "VirtPtrMgr");
|
||||
addWLSignal(&m_sWLRRenderer->events.destroy, &Events::listen_RendererDestroy, m_sWLRRenderer, "WLRRenderer");
|
||||
addWLSignal(&m_sWLRIdleInhibitMgr->events.new_inhibitor, &Events::listen_newIdleInhibitor, m_sWLRIdleInhibitMgr, "WLRIdleInhibitMgr");
|
||||
|
||||
signal(SIGINT, handleCritSignal);
|
||||
signal(SIGTERM, handleCritSignal);
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
|
||||
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
||||
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
||||
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
|
||||
// ------------------------------------------------- //
|
||||
|
||||
|
||||
|
|
|
@ -112,4 +112,6 @@ namespace Events {
|
|||
|
||||
// Renderer destroy
|
||||
LISTENER(RendererDestroy);
|
||||
|
||||
LISTENER(newIdleInhibitor);
|
||||
};
|
|
@ -284,6 +284,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
g_pCompositor->setWindowFullscreen(PWINDOW, true, FULLSCREEN_FULL);
|
||||
}
|
||||
|
||||
// recheck idle inhibitors
|
||||
g_pInputManager->recheckIdleInhibitorStatus();
|
||||
|
||||
PWINDOW->m_pSurfaceTree = SubsurfaceTree::createTreeRoot(g_pXWaylandManager->getWindowSurface(PWINDOW), addViewCoords, PWINDOW, PWINDOW);
|
||||
|
||||
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
|
||||
|
@ -363,6 +366,9 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
|||
// Destroy Foreign Toplevel
|
||||
wlr_foreign_toplevel_handle_v1_destroy(PWINDOW->m_phForeignToplevel);
|
||||
PWINDOW->m_phForeignToplevel = nullptr;
|
||||
|
||||
// recheck idle inhibitors
|
||||
g_pInputManager->recheckIdleInhibitorStatus();
|
||||
}
|
||||
|
||||
void Events::listener_commitWindow(void* owner, void* data) {
|
||||
|
|
|
@ -221,3 +221,14 @@ struct STabletPad {
|
|||
return wlrTabletPadV2 == b.wlrTabletPadV2;
|
||||
}
|
||||
};
|
||||
|
||||
struct SIdleInhibitor {
|
||||
wlr_idle_inhibitor_v1* pWlrInhibitor = nullptr;
|
||||
CWindow* pWindow = nullptr;
|
||||
|
||||
DYNLISTENER(Destroy);
|
||||
|
||||
bool operator==(const SIdleInhibitor& b) {
|
||||
return pWlrInhibitor == b.pWlrInhibitor;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -74,6 +74,7 @@ extern "C" {
|
|||
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
|
||||
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
||||
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
||||
#include <wlr/types/wlr_idle_inhibit_v1.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/xwayland.h>
|
||||
#include <wlr/util/region.h>
|
||||
|
|
54
src/managers/input/IdleInhibitor.cpp
Normal file
54
src/managers/input/IdleInhibitor.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "InputManager.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
|
||||
void Events::listener_newIdleInhibitor(wl_listener* listener, void* data) {
|
||||
const auto WLRIDLEINHIBITOR = (wlr_idle_inhibitor_v1*)data;
|
||||
|
||||
if (!WLRIDLEINHIBITOR)
|
||||
return;
|
||||
|
||||
g_pInputManager->newIdleInhibitor(WLRIDLEINHIBITOR);
|
||||
}
|
||||
|
||||
void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
|
||||
const auto PINHIBIT = &m_lIdleInhibitors.emplace_back();
|
||||
|
||||
Debug::log(LOG, "New idle inhibitor registered");
|
||||
|
||||
PINHIBIT->pWlrInhibitor = pInhibitor;
|
||||
|
||||
PINHIBIT->hyprListener_Destroy.initCallback(&pInhibitor->events.destroy, [](void* owner, void* data){
|
||||
|
||||
const auto PINH = (SIdleInhibitor*)owner;
|
||||
|
||||
g_pInputManager->m_lIdleInhibitors.remove(*PINH);
|
||||
|
||||
Debug::log(LOG, "Destroyed an idleinhibitor");
|
||||
|
||||
g_pInputManager->recheckIdleInhibitorStatus();
|
||||
|
||||
}, PINHIBIT, "IdleInhibitor");
|
||||
|
||||
PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface);
|
||||
|
||||
if (PINHIBIT->pWindow)
|
||||
Debug::log(LOG, "IdleInhibitor got window %x (%s)", PINHIBIT->pWindow, PINHIBIT->pWindow->m_szTitle.c_str());
|
||||
|
||||
recheckIdleInhibitorStatus();
|
||||
}
|
||||
|
||||
void CInputManager::recheckIdleInhibitorStatus() {
|
||||
|
||||
for (auto& ii : m_lIdleInhibitors) {
|
||||
if (!ii.pWindow) {
|
||||
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
|
||||
return;
|
||||
} else if (g_pHyprRenderer->shouldRenderWindow(ii.pWindow)) {
|
||||
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true);
|
||||
return;
|
||||
}
|
|
@ -56,9 +56,14 @@ public:
|
|||
std::list<STabletTool> m_lTabletTools;
|
||||
std::list<STabletPad> m_lTabletPads;
|
||||
|
||||
// idle inhibitors
|
||||
std::list<SIdleInhibitor> m_lIdleInhibitors;
|
||||
|
||||
void newTabletTool(wlr_input_device*);
|
||||
void newTabletPad(wlr_input_device*);
|
||||
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
||||
void newIdleInhibitor(wlr_idle_inhibitor_v1*);
|
||||
void recheckIdleInhibitorStatus();
|
||||
|
||||
SKeyboard* m_pActiveKeyboard = nullptr;
|
||||
|
||||
|
|
Loading…
Reference in a new issue