1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef _wayland_proxy_h_
7 #define _wayland_proxy_h_
15 class ProxiedConnection
;
19 static std::unique_ptr
<WaylandProxy
> Create();
21 // Launch an application with Wayland proxy set
22 bool RunChildApplication(char* argv
[]);
24 // Run proxy as part of already running application
25 // and set Wayland proxy display for it.
28 // Set original Wayland display env variable and clear
29 // proxy display file.
30 void RestoreWaylandDisplay();
32 static void SetVerbose(bool aVerbose
);
40 void SetWaylandProxyDisplay();
41 static void* RunProxyThread(WaylandProxy
* aProxy
);
42 bool CheckWaylandDisplay(const char* aWaylandDisplay
);
44 bool SetupWaylandDisplays();
45 bool StartProxyServer();
46 bool IsChildAppTerminated();
48 bool PollConnections();
49 bool ProcessConnections();
51 void Info(const char* aFormat
, ...);
52 void Warning(const char* aOperation
);
53 void Error(const char* aOperation
);
54 void ErrorPlain(const char* aFormat
, ...);
57 // List of all Compositor <-> Application connections
58 std::vector
<std::unique_ptr
<ProxiedConnection
>> mConnections
;
59 int mProxyServerSocket
= -1;
60 pid_t mApplicationPID
= 0;
61 std::atomic
<bool> mThreadRunning
= false;
64 // sockaddr_un has hardcoded max len of sun_path
65 static constexpr int sMaxDisplayNameLen
= 108;
66 // Name of Wayland display provided by compositor
67 char mWaylandDisplay
[sMaxDisplayNameLen
];
68 // Name of Wayland display provided by us
69 char mWaylandProxy
[sMaxDisplayNameLen
];
72 #endif // _wayland_proxy_h_