File indexing completed on 2024-11-10 04:57:25
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #include "compositor.h" 0008 #include "display.h" 0009 #include "region_p.h" 0010 #include "surface.h" 0011 0012 #include "qwayland-server-wayland.h" 0013 0014 namespace KWin 0015 { 0016 static const int s_version = 6; 0017 0018 class CompositorInterfacePrivate : public QtWaylandServer::wl_compositor 0019 { 0020 public: 0021 CompositorInterfacePrivate(CompositorInterface *q, Display *display); 0022 0023 CompositorInterface *q; 0024 Display *display; 0025 0026 protected: 0027 void compositor_create_surface(Resource *resource, uint32_t id) override; 0028 void compositor_create_region(Resource *resource, uint32_t id) override; 0029 }; 0030 0031 CompositorInterfacePrivate::CompositorInterfacePrivate(CompositorInterface *q, Display *display) 0032 : QtWaylandServer::wl_compositor(*display, s_version) 0033 , q(q) 0034 , display(display) 0035 { 0036 } 0037 0038 void CompositorInterfacePrivate::compositor_create_surface(Resource *resource, uint32_t id) 0039 { 0040 wl_resource *surfaceResource = wl_resource_create(resource->client(), &wl_surface_interface, resource->version(), id); 0041 if (!surfaceResource) { 0042 wl_resource_post_no_memory(resource->handle); 0043 return; 0044 } 0045 Q_EMIT q->surfaceCreated(new SurfaceInterface(q, surfaceResource)); 0046 } 0047 0048 void CompositorInterfacePrivate::compositor_create_region(Resource *resource, uint32_t id) 0049 { 0050 wl_resource *regionResource = wl_resource_create(resource->client(), &wl_region_interface, resource->version(), id); 0051 if (!regionResource) { 0052 wl_resource_post_no_memory(resource->handle); 0053 return; 0054 } 0055 new RegionInterface(regionResource); 0056 } 0057 0058 CompositorInterface::CompositorInterface(Display *display, QObject *parent) 0059 : QObject(parent) 0060 , d(new CompositorInterfacePrivate(this, display)) 0061 { 0062 } 0063 0064 CompositorInterface::~CompositorInterface() 0065 { 0066 } 0067 0068 Display *CompositorInterface::display() const 0069 { 0070 return d->display; 0071 } 0072 0073 } // namespace KWin 0074 0075 #include "wayland/moc_compositor.cpp"