File indexing completed on 2024-11-10 04:57:50
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "lidswitchtracker.h" 0010 #include "core/inputdevice.h" 0011 #include "input_event.h" 0012 0013 namespace KWin 0014 { 0015 0016 LidSwitchTracker::LidSwitchTracker() 0017 { 0018 input()->installInputEventSpy(this); 0019 } 0020 0021 bool LidSwitchTracker::isLidClosed() const 0022 { 0023 return m_isLidClosed; 0024 } 0025 0026 void LidSwitchTracker::switchEvent(KWin::SwitchEvent *event) 0027 { 0028 if (event->device()->isLidSwitch()) { 0029 const bool state = event->state() == SwitchEvent::State::On; 0030 if (state != m_isLidClosed) { 0031 m_isLidClosed = state; 0032 Q_EMIT lidStateChanged(); 0033 } 0034 } 0035 } 0036 0037 } 0038 0039 #include "moc_lidswitchtracker.cpp"