ZaStoGram_desktop/Telegram/SourceFiles/platform/posix/widget_channel_posix.h
John Preston 145405a6cf Run macOS widget engines in a separate helper executable
Task: 2026/11/14/run-macos-widget-engines-in-a-qt-free-helper-executable
2026-11-19 23:17:08 +04:00

46 lines
1.1 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "twidget/remote_stream.h"
#include <atomic>
#include <memory>
#include <string>
namespace Platform::WidgetHelper {
constexpr auto kChannelDescriptor = 3;
class PosixStream final : public twidget::SandboxRemoteStream {
public:
explicit PosixStream(int descriptor);
~PosixStream();
[[nodiscard]] int descriptor() const;
size_t read(char *out, size_t size) override;
bool write(std::string_view bytes) override;
void shutdown() override;
private:
const int _descriptor = -1;
std::atomic<bool> _stopped = false;
};
struct PosixChannel {
std::unique_ptr<PosixStream> parent;
std::unique_ptr<PosixStream> child;
std::string error;
};
[[nodiscard]] PosixChannel CreatePosixChannel();
[[nodiscard]] std::unique_ptr<PosixStream> AdoptPosixChannel(int descriptor);
} // namespace Platform::WidgetHelper