| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef MIR_FRONTEND_XWAYLAND_CONNECTOR_H |
| 20 |
#define MIR_FRONTEND_XWAYLAND_CONNECTOR_H |
| 21 |
|
| 22 |
#include <mir/frontend/connector.h> |
| 23 |
|
| 24 |
#include <memory> |
| 25 |
#include <mutex> |
| 26 |
|
| 27 |
namespace mir |
| 28 |
{ |
| 29 |
class Executor; |
| 30 |
namespace dispatch |
| 31 |
{ |
| 32 |
class ReadableFd; |
| 33 |
class ThreadedDispatcher; |
| 34 |
} |
| 35 |
namespace frontend |
| 36 |
{ |
| 37 |
class WaylandConnector; |
| 38 |
class XWaylandServer; |
| 39 |
class XWaylandSpawner; |
| 40 |
class XWaylandWM; |
| 41 |
class XWaylandConnector : public Connector, public std::enable_shared_from_this<XWaylandConnector> |
| 42 |
{ |
| 43 |
public: |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
XWaylandConnector( |
| 50 |
std::shared_ptr<Executor> const& main_loop, |
| 51 |
std::shared_ptr<WaylandConnector> const& wayland_connector, |
| 52 |
std::string const& xwayland_path, |
| 53 |
float scale); |
| 54 |
~XWaylandConnector(); |
| 55 |
|
| 56 |
void start() override; |
| 57 |
void stop() override; |
| 58 |
|
| 59 |
int client_socket_fd() const override; |
| 60 |
int client_socket_fd( |
| 61 |
std::function<void(std::shared_ptr<scene::Session> const& session)> const& connect_handler) const override; |
| 62 |
|
| 63 |
auto socket_name() const -> std::optional<std::string> override; |
| 64 |
|
| 65 |
private: |
| 66 |
std::shared_ptr<Executor> const main_loop; |
| 67 |
std::shared_ptr<WaylandConnector> const wayland_connector; |
| 68 |
std::string const xwayland_path; |
| 69 |
float const scale; |
| 70 |
|
| 71 |
|
| 72 |
void maybe_create_spawner(std::unique_lock<std::mutex> const& lock); |
| 73 |
|
| 74 |
void clean_up(std::unique_lock<std::mutex> lock); |
| 75 |
|
| 76 |
|
| 77 |
void spawn(); |
| 78 |
|
| 79 |
std::mutex mutable mutex; |
| 80 |
|
| 81 |
bool is_started{false}; |
| 82 |
std::unique_ptr<XWaylandSpawner> spawner; |
| 83 |
std::unique_ptr<XWaylandServer> server; |
| 84 |
std::unique_ptr<XWaylandWM> wm; |
| 85 |
std::unique_ptr<dispatch::ThreadedDispatcher> wm_event_thread; |
| 86 |
}; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
#endif |