File indexing completed on 2024-11-10 04:57:28

0001 /*
0002     SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "lockscreen_overlay_v1.h"
0008 #include "display.h"
0009 #include "seat.h"
0010 #include "surface.h"
0011 
0012 #include "qwayland-server-kde-lockscreen-overlay-v1.h"
0013 
0014 namespace KWin
0015 {
0016 static constexpr int s_version = 1;
0017 
0018 class LockscreenOverlayV1InterfacePrivate : public QtWaylandServer::kde_lockscreen_overlay_v1
0019 {
0020 public:
0021     LockscreenOverlayV1InterfacePrivate(Display *display, LockscreenOverlayV1Interface *q)
0022         : QtWaylandServer::kde_lockscreen_overlay_v1(*display, s_version)
0023         , q(q)
0024     {
0025     }
0026 
0027 protected:
0028     void kde_lockscreen_overlay_v1_allow(Resource *resource, struct ::wl_resource *surface) override
0029     {
0030         auto surfaceIface = SurfaceInterface::get(surface);
0031         if (surfaceIface->isMapped()) {
0032             wl_resource_post_error(resource->handle, error_invalid_surface_state, "surface is already mapped");
0033             return;
0034         }
0035         Q_EMIT q->allowRequested(surfaceIface);
0036     }
0037     void kde_lockscreen_overlay_v1_destroy(Resource *resource) override
0038     {
0039         wl_resource_destroy(resource->handle);
0040     }
0041 
0042 private:
0043     LockscreenOverlayV1Interface *const q;
0044 };
0045 
0046 LockscreenOverlayV1Interface::~LockscreenOverlayV1Interface() = default;
0047 
0048 LockscreenOverlayV1Interface::LockscreenOverlayV1Interface(Display *display, QObject *parent)
0049     : QObject(parent)
0050     , d(std::make_unique<LockscreenOverlayV1InterfacePrivate>(display, this))
0051 {
0052 }
0053 
0054 }
0055 
0056 #include "moc_lockscreen_overlay_v1.cpp"