GCC Code Coverage Report


Directory: ./
File: server/xdg_foreign.cpp
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 18 20 90.0%
Branches: 9 22 40.9%

Line Branch Exec Source
1 /****************************************************************************
2 Copyright 2017 Marco Martin <notmart@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 ****************************************************************************/
20 #include "xdg_foreign.h"
21
22 #include "xdg_foreign_v2_p.h"
23
24 #include "display.h"
25 #include "surface_p.h"
26
27 #include "wayland-xdg-foreign-unstable-v2-server-protocol.h"
28
29 namespace Wrapland::Server
30 {
31
32 14 XdgForeign::Private::Private(Display* display, XdgForeign* q_ptr)
33 7 : q_ptr{q_ptr}
34 {
35 7 display->globals.xdg_foreign = q_ptr;
36
37
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 exporter = std::make_unique<XdgExporterV2>(display);
38
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 importer = std::make_unique<XdgImporterV2>(display);
39
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 importer->setExporter(exporter.get());
40
41
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 connect(importer.get(), &XdgImporterV2::parentChanged, q_ptr, &XdgForeign::parentChanged);
42 7 }
43
44 7 XdgForeign::Private::~Private()
45 {
46
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7 if (exporter && exporter->d_ptr->display()) {
47 if (auto& ptr = exporter->d_ptr->display()->handle->globals.xdg_foreign; ptr == q_ptr) {
48 ptr = nullptr;
49 }
50 }
51 7 }
52
53 7 XdgForeign::XdgForeign(Display* display)
54
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 : d_ptr(new Private(display, this))
55 7 {
56 7 }
57
58 14 XdgForeign::~XdgForeign() = default;
59
60 14 Surface* XdgForeign::parentOf(Surface* surface)
61 {
62 14 return d_ptr->importer->parentOf(surface);
63 }
64
65 }
66