KWin
Loading...
Searching...
No Matches
idlenotify_v1.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "idlenotify_v1.h"
8#include "display.h"
9
10#include "idledetector.h"
11
12#include "qwayland-server-ext-idle-notify-v1.h"
13
14namespace KWin
15{
16
17static const quint32 s_version = 1;
18
19class IdleNotifyV1InterfacePrivate : public QtWaylandServer::ext_idle_notifier_v1
20{
21public:
23
24protected:
25 void ext_idle_notifier_v1_destroy(Resource *resource) override;
26 void ext_idle_notifier_v1_get_idle_notification(Resource *resource, uint32_t id, uint32_t timeout, struct ::wl_resource *seat) override;
27};
28
29class IdleNotificationV1Interface : public QObject, public QtWaylandServer::ext_idle_notification_v1
30{
31 Q_OBJECT
32
33public:
34 IdleNotificationV1Interface(wl_client *client, int version, uint32_t id, std::chrono::milliseconds timeout);
35
36protected:
37 void ext_idle_notification_v1_destroy_resource(Resource *resource) override;
38 void ext_idle_notification_v1_destroy(Resource *resource) override;
39};
40
42 : QtWaylandServer::ext_idle_notifier_v1(*display, s_version)
43{
44}
45
47{
48 wl_resource_destroy(resource->handle);
49}
50
51void IdleNotifyV1InterfacePrivate::ext_idle_notifier_v1_get_idle_notification(Resource *resource, uint32_t id, uint32_t timeout, struct ::wl_resource *seat)
52{
53 new IdleNotificationV1Interface(resource->client(), resource->version(), id, std::chrono::milliseconds(timeout));
54}
55
56IdleNotificationV1Interface::IdleNotificationV1Interface(wl_client *client, int version, uint32_t id, std::chrono::milliseconds timeout)
57 : QtWaylandServer::ext_idle_notification_v1(client, id, version)
58{
59 auto detector = new IdleDetector(timeout, this);
60 connect(detector, &IdleDetector::idle, this, [this]() {
61 send_idled();
62 });
63 connect(detector, &IdleDetector::resumed, this, [this]() {
64 send_resumed();
65 });
66}
67
69{
70 delete this;
71}
72
74{
75 wl_resource_destroy(resource->handle);
76}
77
79 : QObject(parent)
80 , d(new IdleNotifyV1InterfacePrivate(display))
81{
82}
83
87
88}
89
90#include "idlenotify_v1.moc"
91
92#include "moc_idlenotify_v1.cpp"
Class holding the Wayland server display loop.
Definition display.h:34
void ext_idle_notification_v1_destroy(Resource *resource) override
void ext_idle_notification_v1_destroy_resource(Resource *resource) override
IdleNotificationV1Interface(wl_client *client, int version, uint32_t id, std::chrono::milliseconds timeout)
IdleNotifyV1Interface(Display *display, QObject *parent=nullptr)
void ext_idle_notifier_v1_destroy(Resource *resource) override
IdleNotifyV1InterfacePrivate(Display *display)
void ext_idle_notifier_v1_get_idle_notification(Resource *resource, uint32_t id, uint32_t timeout, struct ::wl_resource *seat) override
constexpr int version