File: lidswitchtracker.cpp

package info (click to toggle)
kwin 4%3A6.5.4-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 53,420 kB
  • sloc: cpp: 240,899; javascript: 2,225; xml: 2,096; ansic: 775; sh: 37; python: 15; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
    KWin - the KDE window manager
    This file is part of the KDE project.

    SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com>

    SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "lidswitchtracker.h"
#include "core/inputdevice.h"
#include "input_event.h"

namespace KWin
{

LidSwitchTracker::LidSwitchTracker()
{
    input()->installInputEventSpy(this);
}

bool LidSwitchTracker::isLidClosed() const
{
    return m_isLidClosed;
}

void LidSwitchTracker::switchEvent(KWin::SwitchEvent *event)
{
    if (event->device->isLidSwitch()) {
        const bool state = event->state == SwitchState::On;
        if (state != m_isLidClosed) {
            m_isLidClosed = state;
            Q_EMIT lidStateChanged();
        }
    }
}

}

#include "moc_lidswitchtracker.cpp"