From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- third_party/wayland-proxy/wayland-proxy.h | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 third_party/wayland-proxy/wayland-proxy.h (limited to 'third_party/wayland-proxy/wayland-proxy.h') diff --git a/third_party/wayland-proxy/wayland-proxy.h b/third_party/wayland-proxy/wayland-proxy.h new file mode 100644 index 0000000000..1ec690a596 --- /dev/null +++ b/third_party/wayland-proxy/wayland-proxy.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _wayland_proxy_h_ +#define _wayland_proxy_h_ + +#include +#include +#include +#include +#include + +class ProxiedConnection; + +class WaylandProxy { + public: + static std::unique_ptr Create(); + + // Launch an application with Wayland proxy set + bool RunChildApplication(char* argv[]); + + // Run proxy as part of already running application + // and set Wayland proxy display for it. + bool RunThread(); + + // Set original Wayland display env variable and clear + // proxy display file. + void RestoreWaylandDisplay(); + + static void SetVerbose(bool aVerbose); + + ~WaylandProxy(); + + private: + bool Init(); + void Run(); + + void SetWaylandProxyDisplay(); + static void* RunProxyThread(WaylandProxy* aProxy); + + bool SetupWaylandDisplays(); + bool StartProxyServer(); + bool IsChildAppTerminated(); + + bool PollConnections(); + bool ProcessConnections(); + + void Info(const char* aFormat, ...); + void Warning(const char* aOperation, bool aPrintErrno = true); + void Error(const char* aOperation, bool aPrintErrno = true); + void ErrorPlain(const char* aFormat, ...); + + private: + // List of all Compositor <-> Application connections + std::vector> mConnections; + int mProxyServerSocket = -1; + pid_t mApplicationPID = 0; + std::atomic mThreadRunning = false; + pthread_t mThread; + + // sockaddr_un has hardcoded max len of sun_path + static constexpr int sMaxDisplayNameLen = 108; + // Name of Wayland display provided by compositor + char mWaylandDisplay[sMaxDisplayNameLen]; + // Name of Wayland display provided by us + char mWaylandProxy[sMaxDisplayNameLen]; +}; + +#endif // _wayland_proxy_h_ -- cgit v1.2.3