KWaylandServer

idleinhibit_v1_interface.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 "display.h"
7 #include "idleinhibit_v1_interface_p.h"
8 #include "surface_interface_p.h"
9 
10 namespace KWaylandServer
11 {
12 static const quint32 s_version = 1;
13 
14 IdleInhibitManagerV1InterfacePrivate::IdleInhibitManagerV1InterfacePrivate(IdleInhibitManagerV1Interface *_q, Display *display)
15  : QtWaylandServer::zwp_idle_inhibit_manager_v1(*display, s_version)
16  , q(_q)
17 {
18 }
19 
20 void IdleInhibitManagerV1InterfacePrivate::zwp_idle_inhibit_manager_v1_destroy(Resource *resource)
21 {
22  wl_resource_destroy(resource->handle);
23 }
24 
25 void IdleInhibitManagerV1InterfacePrivate::zwp_idle_inhibit_manager_v1_create_inhibitor(Resource *resource, uint32_t id, wl_resource *surface)
26 {
27  auto s = SurfaceInterface::get(surface);
28  if (!s) {
29  wl_resource_post_error(resource->handle, 0, "Invalid surface");
30  return;
31  }
32 
33  wl_resource *inhibitorResource = wl_resource_create(resource->client(), &zwp_idle_inhibitor_v1_interface, resource->version(), id);
34  if (!inhibitorResource) {
35  wl_client_post_no_memory(resource->client());
36  return;
37  }
38  auto inhibitor = new IdleInhibitorV1Interface(inhibitorResource);
39 
40  SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(s);
41  surfacePrivate->installIdleInhibitor(inhibitor);
42 }
43 
44 IdleInhibitManagerV1Interface::IdleInhibitManagerV1Interface(Display *display, QObject *parent)
45  : QObject(parent)
46  , d(new IdleInhibitManagerV1InterfacePrivate(this, display))
47 {
48 }
49 
50 IdleInhibitManagerV1Interface::~IdleInhibitManagerV1Interface() = default;
51 
52 IdleInhibitorV1Interface::IdleInhibitorV1Interface(wl_resource *resource)
53  : QObject(nullptr)
54  , QtWaylandServer::zwp_idle_inhibitor_v1(resource)
55 {
56 }
57 
58 IdleInhibitorV1Interface::~IdleInhibitorV1Interface() = default;
59 
60 void IdleInhibitorV1Interface::zwp_idle_inhibitor_v1_destroy(Resource *resource)
61 {
62  wl_resource_destroy(resource->handle);
63 }
64 
65 void IdleInhibitorV1Interface::zwp_idle_inhibitor_v1_destroy_resource(Resource *resource)
66 {
67  Q_UNUSED(resource)
68  delete this;
69 }
70 
71 }
static SurfaceInterface * get(wl_resource *native)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.