mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-12 09:09:49 +01:00
Update code to use amended ext-idle-notify protocol
This commit is contained in:
parent
b0bae15499
commit
d3726be82a
3 changed files with 18 additions and 11 deletions
|
@ -138,7 +138,7 @@ CProtocolManager::CProtocolManager() {
|
|||
PROTO::constraints = std::make_unique<CPointerConstraintsProtocol>(&zwp_pointer_constraints_v1_interface, 1, "PointerConstraints");
|
||||
PROTO::outputPower = std::make_unique<COutputPowerProtocol>(&zwlr_output_power_manager_v1_interface, 1, "OutputPower");
|
||||
PROTO::activation = std::make_unique<CXDGActivationProtocol>(&xdg_activation_v1_interface, 1, "XDGActivation");
|
||||
PROTO::idle = std::make_unique<CIdleNotifyProtocol>(&ext_idle_notifier_v1_interface, 1, "IdleNotify");
|
||||
PROTO::idle = std::make_unique<CIdleNotifyProtocol>(&ext_idle_notifier_v1_interface, 2, "IdleNotify");
|
||||
PROTO::sessionLock = std::make_unique<CSessionLockProtocol>(&ext_session_lock_manager_v1_interface, 1, "SessionLock");
|
||||
PROTO::ime = std::make_unique<CInputMethodV2Protocol>(&zwp_input_method_manager_v2_interface, 1, "IMEv2");
|
||||
PROTO::virtualKeyboard = std::make_unique<CVirtualKeyboardProtocol>(&zwp_virtual_keyboard_manager_v1_interface, 1, "VirtualKeyboard");
|
||||
|
|
|
@ -10,7 +10,8 @@ static int onTimer(SP<CEventLoopTimer> self, void* data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_) : resource(resource_), timeoutMs(timeoutMs_) {
|
||||
CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_, bool obeyInhibitors_) :
|
||||
resource(resource_), timeoutMs(timeoutMs_), obeyInhibitors(obeyInhibitors_) {
|
||||
if (!resource_->resource())
|
||||
return;
|
||||
|
||||
|
@ -35,7 +36,7 @@ bool CExtIdleNotification::good() {
|
|||
}
|
||||
|
||||
void CExtIdleNotification::updateTimer() {
|
||||
if (PROTO::idle->isInhibited)
|
||||
if (PROTO::idle->isInhibited && obeyInhibitors)
|
||||
timer->updateTimeout(std::nullopt);
|
||||
else
|
||||
timer->updateTimeout(std::chrono::milliseconds(timeoutMs));
|
||||
|
@ -63,7 +64,10 @@ void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ve
|
|||
RESOURCE->setOnDestroy([this](CExtIdleNotifierV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
|
||||
RESOURCE->setDestroy([this](CExtIdleNotifierV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||
RESOURCE->setGetIdleNotification([this](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this->onGetNotification(pMgr, id, timeout, seat); });
|
||||
RESOURCE->setGetIdleNotification(
|
||||
[this](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this->onGetNotification(pMgr, id, timeout, seat, true); });
|
||||
RESOURCE->setGetInputIdleNotification(
|
||||
[this](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this->onGetNotification(pMgr, id, timeout, seat, false); });
|
||||
}
|
||||
|
||||
void CIdleNotifyProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
|
@ -74,9 +78,10 @@ void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) {
|
|||
std::erase_if(m_vNotifications, [&](const auto& other) { return other.get() == notif; });
|
||||
}
|
||||
|
||||
void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) {
|
||||
void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors) {
|
||||
const auto CLIENT = pMgr->client();
|
||||
const auto RESOURCE = m_vNotifications.emplace_back(makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version(), id), timeout)).get();
|
||||
const auto RESOURCE =
|
||||
m_vNotifications.emplace_back(makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version(), id), timeout, obeyInhibitors)).get();
|
||||
|
||||
if (!RESOURCE->good()) {
|
||||
pMgr->noMemory();
|
||||
|
@ -94,6 +99,7 @@ void CIdleNotifyProtocol::onActivity() {
|
|||
void CIdleNotifyProtocol::setInhibit(bool inhibited) {
|
||||
isInhibited = inhibited;
|
||||
for (auto const& n : m_vNotifications) {
|
||||
if (n->obeyInhibitors)
|
||||
n->onActivity();
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ class CEventLoopTimer;
|
|||
|
||||
class CExtIdleNotification {
|
||||
public:
|
||||
CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs);
|
||||
CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs, bool obeyInhibitors);
|
||||
~CExtIdleNotification();
|
||||
|
||||
bool good();
|
||||
|
@ -23,6 +23,7 @@ class CExtIdleNotification {
|
|||
SP<CEventLoopTimer> timer;
|
||||
|
||||
bool idled = false;
|
||||
bool obeyInhibitors = false;
|
||||
|
||||
void updateTimer();
|
||||
};
|
||||
|
@ -39,7 +40,7 @@ class CIdleNotifyProtocol : public IWaylandProtocol {
|
|||
private:
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
void destroyNotification(CExtIdleNotification* notif);
|
||||
void onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat);
|
||||
void onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors);
|
||||
|
||||
bool isInhibited = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue