GCC Code Coverage Report


Directory: ./
File: server/touch_pool.h
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 3 4 75.0%
Branches: 1 2 50.0%

Line Branch Exec Source
1 /*
2 SPDX-FileCopyrightText: 2020 Roman Gilg <subdiff@gmail.com>
3 SPDX-FileCopyrightText: 2021 Francesco Sorrentino <francesco.sorr@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only
6 */
7 #pragma once
8
9 #include <Wrapland/Server/wraplandserver_export.h>
10
11 #include <QObject>
12 #include <QPoint>
13
14 #include <cstdint>
15 #include <map>
16 #include <vector>
17
18 namespace Wrapland::Server
19 {
20 class Client;
21 class Seat;
22 class Surface;
23 class Touch;
24
25
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 struct touch_focus {
26 117 Surface* surface{nullptr};
27 std::vector<Touch*> devices;
28 QPointF offset;
29 QPointF first_touch_position;
30 QMetaObject::Connection surface_lost_notifier;
31 };
32
33 /*
34 * Handle touch devices associated to a seat.
35 */
36 class WRAPLANDSERVER_EXPORT touch_pool
37 {
38 public:
39 explicit touch_pool(Seat* seat);
40 touch_pool(touch_pool const&) = delete;
41 touch_pool& operator=(touch_pool const&) = delete;
42 112 touch_pool(touch_pool&&) noexcept = default;
43 touch_pool& operator=(touch_pool&&) noexcept = default;
44 ~touch_pool();
45
46 touch_focus const& get_focus() const;
47 std::vector<Touch*> const& get_devices() const;
48
49 void set_focused_surface(Surface* surface, QPointF const& surfacePosition = QPointF());
50 void set_focused_surface_position(QPointF const& surfacePosition);
51 int32_t touch_down(QPointF const& globalPosition);
52 void touch_up(int32_t id);
53 void touch_move(int32_t id, QPointF const& globalPosition);
54 void touch_move_any(QPointF const& pos);
55 void touch_frame() const;
56 void cancel_sequence();
57 bool has_implicit_grab(uint32_t serial) const;
58 bool is_in_progress() const;
59
60 private:
61 friend class Seat;
62 void create_device(Client* client, uint32_t version, uint32_t id);
63
64 touch_focus focus;
65
66 // Key: Distinct id per touch point, Value: Wayland display serial.
67 std::map<int32_t, uint32_t> ids;
68
69 std::vector<Touch*> devices;
70 Seat* seat;
71 };
72
73 }
74