KWayland

idleinhibit.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 Martin Flöser <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "idleinhibit.h"
7 #include "event_queue.h"
8 #include "surface.h"
9 #include "wayland_pointer_p.h"
10 
11 #include <wayland-idle-inhibit-unstable-v1-client-protocol.h>
12 
13 namespace KWayland
14 {
15 namespace Client
16 {
17 class Q_DECL_HIDDEN IdleInhibitManager::Private
18 {
19 public:
20  Private() = default;
21 
22  void setup(zwp_idle_inhibit_manager_v1 *arg);
23 
24  WaylandPointer<zwp_idle_inhibit_manager_v1, zwp_idle_inhibit_manager_v1_destroy> idleinhibitmanager;
25  EventQueue *queue = nullptr;
26 };
27 
29  : QObject(parent)
30  , d(new Private)
31 {
32 }
33 
34 void IdleInhibitManager::Private::setup(zwp_idle_inhibit_manager_v1 *arg)
35 {
36  Q_ASSERT(arg);
37  Q_ASSERT(!idleinhibitmanager);
38  idleinhibitmanager.setup(arg);
39 }
40 
41 IdleInhibitManager::~IdleInhibitManager()
42 {
43  release();
44 }
45 
46 void IdleInhibitManager::setup(zwp_idle_inhibit_manager_v1 *idleinhibitmanager)
47 {
48  d->setup(idleinhibitmanager);
49 }
50 
52 {
53  d->idleinhibitmanager.release();
54 }
55 
57 {
58  d->idleinhibitmanager.destroy();
59 }
60 
61 IdleInhibitManager::operator zwp_idle_inhibit_manager_v1 *()
62 {
63  return d->idleinhibitmanager;
64 }
65 
66 IdleInhibitManager::operator zwp_idle_inhibit_manager_v1 *() const
67 {
68  return d->idleinhibitmanager;
69 }
70 
72 {
73  return d->idleinhibitmanager.isValid();
74 }
75 
77 {
78  d->queue = queue;
79 }
80 
82 {
83  return d->queue;
84 }
85 
87 {
88  Q_ASSERT(isValid());
89  auto p = new IdleInhibitor(parent);
90  auto w = zwp_idle_inhibit_manager_v1_create_inhibitor(d->idleinhibitmanager, *surface);
91  if (d->queue) {
92  d->queue->addProxy(w);
93  }
94  p->setup(w);
95  return p;
96 }
97 
98 class Q_DECL_HIDDEN IdleInhibitor::Private
99 {
100 public:
101  void setup(zwp_idle_inhibitor_v1 *arg);
102 
103  WaylandPointer<zwp_idle_inhibitor_v1, zwp_idle_inhibitor_v1_destroy> idleinhibitor;
104 };
105 
106 IdleInhibitor::IdleInhibitor(QObject *parent)
107  : QObject(parent)
108  , d(new Private)
109 {
110 }
111 
112 void IdleInhibitor::Private::setup(zwp_idle_inhibitor_v1 *arg)
113 {
114  Q_ASSERT(arg);
115  Q_ASSERT(!idleinhibitor);
116  idleinhibitor.setup(arg);
117 }
118 
119 IdleInhibitor::~IdleInhibitor()
120 {
121  release();
122 }
123 
124 void IdleInhibitor::setup(zwp_idle_inhibitor_v1 *idleinhibitor)
125 {
126  d->setup(idleinhibitor);
127 }
128 
130 {
131  d->idleinhibitor.release();
132 }
133 
135 {
136  d->idleinhibitor.destroy();
137 }
138 
139 IdleInhibitor::operator zwp_idle_inhibitor_v1 *()
140 {
141  return d->idleinhibitor;
142 }
143 
144 IdleInhibitor::operator zwp_idle_inhibitor_v1 *() const
145 {
146  return d->idleinhibitor;
147 }
148 
150 {
151  return d->idleinhibitor.isValid();
152 }
153 
154 }
155 }
Wrapper for the wl_surface interface.
Definition: surface.h:43
void destroy()
Destroys the data held by this IdleInhibitManager.
Definition: idleinhibit.cpp:56
An IdleInhibitor prevents the Output that the associated Surface is visible on from being set to a st...
Definition: idleinhibit.h:148
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating objects with this IdleInhibitManager.
Definition: idleinhibit.cpp:76
void release()
Releases the zwp_idle_inhibitor_v1 interface.
IdleInhibitManager(QObject *parent=nullptr)
Creates a new IdleInhibitManager.
Definition: idleinhibit.cpp:28
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
void setup(zwp_idle_inhibit_manager_v1 *idleinhibitmanager)
Setup this IdleInhibitManager to manage the idleinhibitmanager.
Definition: idleinhibit.cpp:46
void setup(zwp_idle_inhibitor_v1 *idleinhibitor)
Setup this IdleInhibitor to manage the idleinhibitor.
void destroy()
Destroys the data held by this IdleInhibitor.
void release()
Releases the zwp_idle_inhibit_manager_v1 interface.
Definition: idleinhibit.cpp:51
IdleInhibitor * createInhibitor(Surface *surface, QObject *parent=nullptr)
Creates an IdleInhibitor for the given surface.
Definition: idleinhibit.cpp:86
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Jan 30 2023 03:56:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.