File indexing completed on 2024-11-10 04:57:27
0001 /* 0002 SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #include "display.h" 0007 #include "idleinhibit_v1_p.h" 0008 #include "surface_p.h" 0009 0010 namespace KWin 0011 { 0012 static const quint32 s_version = 1; 0013 0014 IdleInhibitManagerV1InterfacePrivate::IdleInhibitManagerV1InterfacePrivate(IdleInhibitManagerV1Interface *_q, Display *display) 0015 : QtWaylandServer::zwp_idle_inhibit_manager_v1(*display, s_version) 0016 , q(_q) 0017 { 0018 } 0019 0020 void IdleInhibitManagerV1InterfacePrivate::zwp_idle_inhibit_manager_v1_destroy(Resource *resource) 0021 { 0022 wl_resource_destroy(resource->handle); 0023 } 0024 0025 void IdleInhibitManagerV1InterfacePrivate::zwp_idle_inhibit_manager_v1_create_inhibitor(Resource *resource, uint32_t id, wl_resource *surface) 0026 { 0027 auto s = SurfaceInterface::get(surface); 0028 if (!s) { 0029 wl_resource_post_error(resource->handle, 0, "Invalid surface"); 0030 return; 0031 } 0032 0033 wl_resource *inhibitorResource = wl_resource_create(resource->client(), &zwp_idle_inhibitor_v1_interface, resource->version(), id); 0034 if (!inhibitorResource) { 0035 wl_client_post_no_memory(resource->client()); 0036 return; 0037 } 0038 auto inhibitor = new IdleInhibitorV1Interface(inhibitorResource); 0039 0040 SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(s); 0041 surfacePrivate->installIdleInhibitor(inhibitor); 0042 } 0043 0044 IdleInhibitManagerV1Interface::IdleInhibitManagerV1Interface(Display *display, QObject *parent) 0045 : QObject(parent) 0046 , d(new IdleInhibitManagerV1InterfacePrivate(this, display)) 0047 { 0048 } 0049 0050 IdleInhibitManagerV1Interface::~IdleInhibitManagerV1Interface() = default; 0051 0052 IdleInhibitorV1Interface::IdleInhibitorV1Interface(wl_resource *resource) 0053 : QObject(nullptr) 0054 , QtWaylandServer::zwp_idle_inhibitor_v1(resource) 0055 { 0056 } 0057 0058 IdleInhibitorV1Interface::~IdleInhibitorV1Interface() = default; 0059 0060 void IdleInhibitorV1Interface::zwp_idle_inhibitor_v1_destroy(Resource *resource) 0061 { 0062 wl_resource_destroy(resource->handle); 0063 } 0064 0065 void IdleInhibitorV1Interface::zwp_idle_inhibitor_v1_destroy_resource(Resource *resource) 0066 { 0067 delete this; 0068 } 0069 0070 } 0071 0072 #include "moc_idleinhibit_v1.cpp" 0073 #include "moc_idleinhibit_v1_p.cpp"