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 
18 class Q_DECL_HIDDEN IdleInhibitManager::Private
19 {
20 public:
21  Private() = default;
22 
23  void setup(zwp_idle_inhibit_manager_v1 *arg);
24 
25  WaylandPointer<zwp_idle_inhibit_manager_v1, zwp_idle_inhibit_manager_v1_destroy> idleinhibitmanager;
26  EventQueue *queue = nullptr;
27 };
28 
30  : QObject(parent)
31  , d(new Private)
32 {
33 }
34 
35 void IdleInhibitManager::Private::setup(zwp_idle_inhibit_manager_v1 *arg)
36 {
37  Q_ASSERT(arg);
38  Q_ASSERT(!idleinhibitmanager);
39  idleinhibitmanager.setup(arg);
40 }
41 
42 IdleInhibitManager::~IdleInhibitManager()
43 {
44  release();
45 }
46 
47 void IdleInhibitManager::setup(zwp_idle_inhibit_manager_v1 *idleinhibitmanager)
48 {
49  d->setup(idleinhibitmanager);
50 }
51 
53 {
54  d->idleinhibitmanager.release();
55 }
56 
58 {
59  d->idleinhibitmanager.destroy();
60 }
61 
62 IdleInhibitManager::operator zwp_idle_inhibit_manager_v1*() {
63  return d->idleinhibitmanager;
64 }
65 
66 IdleInhibitManager::operator zwp_idle_inhibit_manager_v1*() const {
67  return d->idleinhibitmanager;
68 }
69 
71 {
72  return d->idleinhibitmanager.isValid();
73 }
74 
76 {
77  d->queue = queue;
78 }
79 
81 {
82  return d->queue;
83 }
84 
86 {
87  Q_ASSERT(isValid());
88  auto p = new IdleInhibitor(parent);
89  auto w = zwp_idle_inhibit_manager_v1_create_inhibitor(d->idleinhibitmanager, *surface);
90  if (d->queue) {
91  d->queue->addProxy(w);
92  }
93  p->setup(w);
94  return p;
95 }
96 
97 class Q_DECL_HIDDEN IdleInhibitor::Private
98 {
99 public:
100  void setup(zwp_idle_inhibitor_v1 *arg);
101 
102  WaylandPointer<zwp_idle_inhibitor_v1, zwp_idle_inhibitor_v1_destroy> idleinhibitor;
103 };
104 
105 IdleInhibitor::IdleInhibitor(QObject *parent)
106  : QObject(parent)
107  , d(new Private)
108 {
109 }
110 
111 void IdleInhibitor::Private::setup(zwp_idle_inhibitor_v1 *arg)
112 {
113  Q_ASSERT(arg);
114  Q_ASSERT(!idleinhibitor);
115  idleinhibitor.setup(arg);
116 }
117 
118 IdleInhibitor::~IdleInhibitor()
119 {
120  release();
121 }
122 
123 void IdleInhibitor::setup(zwp_idle_inhibitor_v1 *idleinhibitor)
124 {
125  d->setup(idleinhibitor);
126 }
127 
129 {
130  d->idleinhibitor.release();
131 }
132 
134 {
135  d->idleinhibitor.destroy();
136 }
137 
138 IdleInhibitor::operator zwp_idle_inhibitor_v1*() {
139  return d->idleinhibitor;
140 }
141 
142 IdleInhibitor::operator zwp_idle_inhibitor_v1*() const {
143  return d->idleinhibitor;
144 }
145 
147 {
148  return d->idleinhibitor.isValid();
149 }
150 
151 }
152 }
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
void setup(zwp_idle_inhibitor_v1 *idleinhibitor)
Setup this IdleInhibitor to manage the idleinhibitor.
void release()
Releases the zwp_idle_inhibitor_v1 interface.
Wrapper for the wl_surface interface.
Definition: surface.h:44
IdleInhibitor * createInhibitor(Surface *surface, QObject *parent=nullptr)
Creates an IdleInhibitor for the given surface.
Definition: idleinhibit.cpp:85
void destroy()
Destroys the data held by this IdleInhibitManager.
Definition: idleinhibit.cpp:57
void destroy()
Destroys the data held by this IdleInhibitor.
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating objects with this IdleInhibitManager.
Definition: idleinhibit.cpp:75
void release()
Releases the zwp_idle_inhibit_manager_v1 interface.
Definition: idleinhibit.cpp:52
QObject(QObject *parent)
An IdleInhibitor prevents the Output that the associated Surface is visible on from being set to a st...
Definition: idleinhibit.h:149
IdleInhibitManager(QObject *parent=nullptr)
Creates a new IdleInhibitManager.
Definition: idleinhibit.cpp:29
QObject * parent() const const
void setup(zwp_idle_inhibit_manager_v1 *idleinhibitmanager)
Setup this IdleInhibitManager to manage the idleinhibitmanager.
Definition: idleinhibit.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 22:51:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.