File indexing completed on 2024-06-02 05:44:41
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2020 The Qt Company Ltd. 0004 ** Contact: https://www.qt.io/licensing/ 0005 ** 0006 ** This file is part of the test suite of the Qt Toolkit. 0007 ** 0008 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 0009 ** Commercial License Usage 0010 ** Licensees holding valid commercial Qt licenses may use this file in 0011 ** accordance with the commercial license agreement provided with the 0012 ** Software or, alternatively, in accordance with the terms contained in 0013 ** a written agreement between you and The Qt Company. For licensing terms 0014 ** and conditions see https://www.qt.io/terms-conditions. For further 0015 ** information use the contact form at https://www.qt.io/contact-us. 0016 ** 0017 ** GNU General Public License Usage 0018 ** Alternatively, this file may be used under the terms of the GNU 0019 ** General Public License version 3 as published by the Free Software 0020 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 0021 ** included in the packaging of this file. Please review the following 0022 ** information to ensure the GNU General Public License requirements will 0023 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 0024 ** 0025 ** $QT_END_LICENSE$ 0026 ** 0027 ****************************************************************************/ 0028 0029 #include "layershell.h" 0030 0031 namespace MockCompositor 0032 { 0033 LayerShell::LayerShell(CoreCompositor *compositor) 0034 : QtWaylandServer::zwlr_layer_shell_v1(compositor->m_display, 1) 0035 { 0036 } 0037 0038 void LayerShell::zwlr_layer_shell_v1_get_layer_surface(Resource *resource, 0039 uint32_t id, 0040 struct ::wl_resource *surface_resource, 0041 struct ::wl_resource *output_resource, 0042 uint32_t layer, 0043 const QString &scope) 0044 { 0045 Surface *surface = resource_cast<Surface *>(surface_resource); 0046 Output *output = resource_cast<Output *>(output_resource); 0047 0048 if (layer > layer_overlay) { 0049 wl_resource_post_error(resource->handle, error_invalid_layer, "invalid layer %d", layer); 0050 return; 0051 } 0052 0053 wl_resource *layerSurfaceResource = wl_resource_create(resource->client(), &zwlr_layer_surface_v1_interface, resource->version(), id); 0054 if (!layerSurfaceResource) { 0055 wl_resource_post_no_memory(resource->handle); 0056 return; 0057 } 0058 0059 auto layerSurface = new LayerSurface(this, surface, output, layer, scope, layerSurfaceResource); 0060 Q_UNUSED(layerSurface) 0061 } 0062 0063 void LayerShell::zwlr_layer_shell_v1_destroy(Resource *resource) 0064 { 0065 wl_resource_destroy(resource->handle); 0066 } 0067 0068 LayerSurface::LayerSurface(LayerShell *shell, Surface *surface, Output *output, uint32_t layer, const QString &scope, wl_resource *resource) 0069 : QtWaylandServer::zwlr_layer_surface_v1(resource) 0070 , m_output(output) 0071 , m_layer(layer) 0072 , m_scope(scope) 0073 { 0074 Q_UNUSED(shell) 0075 surface->m_role = this; 0076 } 0077 0078 } // namespace MockCompositor