File indexing completed on 2024-11-10 04:57:28
0001 /* 0002 SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #include "output_order_v1.h" 0007 #include "core/output.h" 0008 #include "display.h" 0009 0010 #include "qwayland-server-kde-output-order-v1.h" 0011 0012 namespace KWin 0013 { 0014 0015 static constexpr uint32_t s_version = 1; 0016 0017 class OutputOrderV1InterfacePrivate : public QtWaylandServer::kde_output_order_v1 0018 { 0019 public: 0020 OutputOrderV1InterfacePrivate(Display *display); 0021 0022 void sendList(wl_resource *resource); 0023 QList<Output *> outputOrder; 0024 0025 protected: 0026 void kde_output_order_v1_bind_resource(Resource *resource) override; 0027 void kde_output_order_v1_destroy(Resource *resource) override; 0028 }; 0029 0030 OutputOrderV1Interface::OutputOrderV1Interface(Display *display, QObject *parent) 0031 : QObject(parent) 0032 , d(std::make_unique<OutputOrderV1InterfacePrivate>(display)) 0033 { 0034 } 0035 0036 OutputOrderV1Interface::~OutputOrderV1Interface() = default; 0037 0038 void OutputOrderV1Interface::setOutputOrder(const QList<Output *> &outputOrder) 0039 { 0040 d->outputOrder = outputOrder; 0041 const auto resources = d->resourceMap(); 0042 for (const auto &resource : resources) { 0043 d->sendList(resource->handle); 0044 } 0045 } 0046 0047 OutputOrderV1InterfacePrivate::OutputOrderV1InterfacePrivate(Display *display) 0048 : QtWaylandServer::kde_output_order_v1(*display, s_version) 0049 { 0050 } 0051 0052 void OutputOrderV1InterfacePrivate::kde_output_order_v1_bind_resource(Resource *resource) 0053 { 0054 sendList(resource->handle); 0055 } 0056 0057 void OutputOrderV1InterfacePrivate::sendList(wl_resource *resource) 0058 { 0059 for (Output *const output : std::as_const(outputOrder)) { 0060 kde_output_order_v1_send_output(resource, output->name().toUtf8().constData()); 0061 } 0062 kde_output_order_v1_send_done(resource); 0063 } 0064 0065 void OutputOrderV1InterfacePrivate::kde_output_order_v1_destroy(Resource *resource) 0066 { 0067 wl_resource_destroy(resource->handle); 0068 } 0069 } 0070 0071 #include "moc_output_order_v1.cpp"