Skip to content

Linux + iPhone Continuity / iMessage / SMS

fmt

Zack Bartel5ef372479815
diff --git a/src/core/include/tether/log.hpp b/src/core/include/tether/log.hpp
index 4a74f1f..c9e99d9 100644
--- a/src/core/include/tether/log.hpp
+++ b/src/core/include/tether/log.hpp
@@ -1,11 +1,10 @@
#pragma once
+#include <filesystem>
#include <format>
#include <iostream>
-#include <filesystem>
-template <>
-struct std::formatter<std::filesystem::path> : std::formatter<std::string> {
+template <> struct std::formatter<std::filesystem::path> : std::formatter<std::string> {
auto format(const std::filesystem::path& p, std::format_context& ctx) const {
return std::formatter<std::string>::format(p.string(), ctx);
}
diff --git a/src/core/src/base64.cpp b/src/core/src/base64.cpp
index b9205aa..9f0a82a 100644
--- a/src/core/src/base64.cpp
+++ b/src/core/src/base64.cpp
@@ -2,98 +2,97 @@
namespace tether {
-static const std::string base64_chars =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
-
-static inline bool is_base64(unsigned char c) {
- return (isalnum(c) || (c == '+') || (c == '/'));
-}
-
-std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len) {
- std::string ret;
- int i = 0;
- int j = 0;
- unsigned char char_array_3[3];
- unsigned char char_array_4[4];
-
- while (in_len--) {
- char_array_3[i++] = *(bytes_to_encode++);
- if (i == 3) {
+ static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
+
+ static inline bool is_base64(unsigned char c) { return (isalnum(c) || (c == '+') || (c == '/')); }
+
+ std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len) {
+ std::string ret;
+ int i = 0;
+ int j = 0;
+ unsigned char char_array_3[3];
+ unsigned char char_array_4[4];
+
+ while (in_len--) {
+ char_array_3[i++] = *(bytes_to_encode++);
+ if (i == 3) {
+ char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+ char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+ char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+ char_array_4[3] = char_array_3[2] & 0x3f;
+
+ for (i = 0; (i < 4); i++)
+ ret += base64_chars[char_array_4[i]];
+ i = 0;
+ }
+ }
+
+ if (i) {
+ for (j = i; j < 3; j++)
+ char_array_3[j] = '\0';
+
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
- for(i = 0; (i <4) ; i++)
- ret += base64_chars[char_array_4[i]];
- i = 0;
- }
- }
-
- if (i) {
- for(j = i; j < 3; j++)
- char_array_3[j] = '\0';
+ for (j = 0; (j < i + 1); j++)
+ ret += base64_chars[char_array_4[j]];
- char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
- char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
- char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
- char_array_4[3] = char_array_3[2] & 0x3f;
-
- for (j = 0; (j < i + 1); j++)
- ret += base64_chars[char_array_4[j]];
+ while ((i++ < 3))
+ ret += '=';
+ }
- while((i++ < 3))
- ret += '=';
+ return ret;
}
- return ret;
-}
+ std::string base64_encode(const std::vector<unsigned char>& data) {
+ return base64_encode(data.data(), data.size());
+ }
-std::string base64_encode(const std::vector<unsigned char>& data) {
- return base64_encode(data.data(), data.size());
-}
+ std::vector<unsigned char> base64_decode(const std::string& encoded_string) {
+ int in_len = encoded_string.size();
+ int i = 0;
+ int j = 0;
+ int in_ = 0;
+ unsigned char char_array_4[4], char_array_3[3];
+ std::vector<unsigned char> ret;
+
+ while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
+ char_array_4[i++] = encoded_string[in_];
+ in_++;
+ if (i == 4) {
+ for (i = 0; i < 4; i++)
+ char_array_4[i] = base64_chars.find(char_array_4[i]);
+
+ char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+ char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+ char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+ for (i = 0; (i < 3); i++)
+ ret.push_back(char_array_3[i]);
+ i = 0;
+ }
+ }
-std::vector<unsigned char> base64_decode(const std::string& encoded_string) {
- int in_len = encoded_string.size();
- int i = 0;
- int j = 0;
- int in_ = 0;
- unsigned char char_array_4[4], char_array_3[3];
- std::vector<unsigned char> ret;
+ if (i) {
+ for (j = i; j < 4; j++)
+ char_array_4[j] = 0;
- while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
- char_array_4[i++] = encoded_string[in_]; in_++;
- if (i ==4) {
- for (i = 0; i <4; i++)
- char_array_4[i] = base64_chars.find(char_array_4[i]);
+ for (j = 0; j < 4; j++)
+ char_array_4[j] = base64_chars.find(char_array_4[j]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
- for (i = 0; (i < 3); i++)
- ret.push_back(char_array_3[i]);
- i = 0;
+ for (j = 0; (j < i - 1); j++)
+ ret.push_back(char_array_3[j]);
}
- }
-
- if (i) {
- for (j = i; j <4; j++)
- char_array_4[j] = 0;
- for (j = 0; j <4; j++)
- char_array_4[j] = base64_chars.find(char_array_4[j]);
-
- char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
- char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
- char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
-
- for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]);
+ return ret;
}
- return ret;
-}
-
} // namespace tether
diff --git a/src/core/src/clipboard.cpp b/src/core/src/clipboard.cpp
index 6389757..4fa3ad8 100644
--- a/src/core/src/clipboard.cpp
+++ b/src/core/src/clipboard.cpp
@@ -1,175 +1,176 @@
#include "tether/clipboard.hpp"
-#include "wayland_protocols/wlr-data-control-unstable-v1.hpp"
#include "wayland_protocols/wayland.hpp"
+#include "wayland_protocols/wlr-data-control-unstable-v1.hpp"
+#include <cstring>
+#include <fcntl.h>
#include <tether/log.hpp>
#include <thread>
#include <unistd.h>
-#include <fcntl.h>
-#include <cstring>
namespace tether {
-ClipboardManager::ClipboardManager(CCZwlrDataControlManagerV1* manager, CCWlSeat* seat, EpollEventLoop& loop, wl_display* display)
- : manager_(manager), seat_(seat), loop_(loop), display_(display) {
-
- auto proxy = manager_->sendGetDataDevice((wl_proxy*)seat_->resource());
- device_ = std::make_unique<CCZwlrDataControlDeviceV1>(proxy);
-
- device_->setDataOffer([this](CCZwlrDataControlDeviceV1*, wl_proxy* offer_proxy) {
- auto offer = std::make_unique<CCZwlrDataControlOfferV1>(offer_proxy);
-
- // Clean up previous offers that were never selected to avoid memory growth,
- // but keep the current one and any very recent ones.
- // Wayland selection events usually follow data_offer events quickly.
- if (offers_.size() > 5) {
- offers_.erase(offers_.begin());
- offer_mimes_.erase(offer_mimes_.begin());
- }
+ ClipboardManager::ClipboardManager(CCZwlrDataControlManagerV1* manager,
+ CCWlSeat* seat,
+ EpollEventLoop& loop,
+ wl_display* display)
+ : manager_(manager), seat_(seat), loop_(loop), display_(display) {
+
+ auto proxy = manager_->sendGetDataDevice((wl_proxy*)seat_->resource());
+ device_ = std::make_unique<CCZwlrDataControlDeviceV1>(proxy);
+
+ device_->setDataOffer([this](CCZwlrDataControlDeviceV1*, wl_proxy* offer_proxy) {
+ auto offer = std::make_unique<CCZwlrDataControlOfferV1>(offer_proxy);
+
+ // Clean up previous offers that were never selected to avoid memory growth,
+ // but keep the current one and any very recent ones.
+ // Wayland selection events usually follow data_offer events quickly.
+ if (offers_.size() > 5) {
+ offers_.erase(offers_.begin());
+ offer_mimes_.erase(offer_mimes_.begin());
+ }
- offer->setOffer([this, offer_proxy](CCZwlrDataControlOfferV1*, const char* mime_type) {
- offer_mimes_[offer_proxy].push_back(mime_type);
+ offer->setOffer([this, offer_proxy](CCZwlrDataControlOfferV1*, const char* mime_type) {
+ offer_mimes_[offer_proxy].push_back(mime_type);
+ });
+
+ offers_[offer_proxy] = std::move(offer);
});
-
- offers_[offer_proxy] = std::move(offer);
- });
- device_->setSelection([this](CCZwlrDataControlDeviceV1*, wl_proxy* offer_proxy) {
- if (!offer_proxy) {
- offers_.clear();
- offer_mimes_.clear();
- if (cb_) cb_("");
- return;
- }
+ device_->setSelection([this](CCZwlrDataControlDeviceV1*, wl_proxy* offer_proxy) {
+ if (!offer_proxy) {
+ offers_.clear();
+ offer_mimes_.clear();
+ if (cb_)
+ cb_("");
+ return;
+ }
- auto it_mimes = offer_mimes_.find(offer_proxy);
- auto it_offer = offers_.find(offer_proxy);
+ auto it_mimes = offer_mimes_.find(offer_proxy);
+ auto it_offer = offers_.find(offer_proxy);
- if (it_mimes == offer_mimes_.end() || it_offer == offers_.end()) {
- return;
- }
+ if (it_mimes == offer_mimes_.end() || it_offer == offers_.end()) {
+ return;
+ }
- const auto& current_mimes = it_mimes->second;
- auto& current_offer = it_offer->second;
-
- // Selection changed, negotiate best mime type
- std::string best_mime = "text/plain"; // fallback
- bool found = false;
-
- static const std::vector<std::string> priorities = {
- "text/plain;charset=utf-8",
- "text/plain;charset=UTF-8",
- "UTF8_STRING",
- "text/plain;charset=utf8",
- "text/plain",
- "TEXT",
- "STRING"
- };
-
- for (const auto& p : priorities) {
- for (const auto& m : current_mimes) {
- if (m == p) {
- best_mime = m;
- found = true;
- break;
+ const auto& current_mimes = it_mimes->second;
+ auto& current_offer = it_offer->second;
+
+ // Selection changed, negotiate best mime type
+ std::string best_mime = "text/plain"; // fallback
+ bool found = false;
+
+ static const std::vector<std::string> priorities = {"text/plain;charset=utf-8",
+ "text/plain;charset=UTF-8",
+ "UTF8_STRING",
+ "text/plain;charset=utf8",
+ "text/plain",
+ "TEXT",
+ "STRING"};
+
+ for (const auto& p : priorities) {
+ for (const auto& m : current_mimes) {
+ if (m == p) {
+ best_mime = m;
+ found = true;
+ break;
+ }
}
+ if (found)
+ break;
}
- if (found) break;
- }
- // Catch-all fallback: if none of our preferred types are found,
- // try the first thing the compositor offered.
- if (!found && !current_mimes.empty()) {
- best_mime = current_mimes[0];
- found = true;
- }
+ // Catch-all fallback: if none of our preferred types are found,
+ // try the first thing the compositor offered.
+ if (!found && !current_mimes.empty()) {
+ best_mime = current_mimes[0];
+ found = true;
+ }
- if (!found) return;
-
- int pipefs[2];
- if (pipe(pipefs) < 0) return;
-
- // Use non-blocking read end for the event loop
- fcntl(pipefs[0], F_SETFL, O_NONBLOCK);
-
- current_offer->sendReceive(best_mime.c_str(), pipefs[1]);
- close(pipefs[1]);
- wl_display_flush(display_);
-
- // Cleanup: remove all other offers as this one is now the active selection
- auto saved_offer = std::move(offers_[offer_proxy]);
- auto saved_mimes = std::move(offer_mimes_[offer_proxy]);
- offers_.clear();
- offer_mimes_.clear();
- offers_[offer_proxy] = std::move(saved_offer);
- offer_mimes_[offer_proxy] = std::move(saved_mimes);
-
- loop_.addFd(pipefs[0], [this](int fd) {
- char buf[4096];
- ssize_t n = read(fd, buf, sizeof(buf));
- if (n > 0) {
- pending_reads_[fd].append(buf, n);
- } else if (n == 0 || (n < 0 && errno != EAGAIN)) {
- // Done reading or error
- std::string result = pending_reads_[fd];
- pending_reads_.erase(fd);
- loop_.removeFd(fd);
- close(fd);
+ if (!found)
+ return;
- // Trim trailing nulls and whitespace
- while (!result.empty() && (result.back() == '\0' || isspace(result.back()))) {
- result.pop_back();
- }
+ int pipefs[2];
+ if (pipe(pipefs) < 0)
+ return;
+
+ // Use non-blocking read end for the event loop
+ fcntl(pipefs[0], F_SETFL, O_NONBLOCK);
+
+ current_offer->sendReceive(best_mime.c_str(), pipefs[1]);
+ close(pipefs[1]);
+ wl_display_flush(display_);
- if (cb_) {
- cb_(result);
+ // Cleanup: remove all other offers as this one is now the active selection
+ auto saved_offer = std::move(offers_[offer_proxy]);
+ auto saved_mimes = std::move(offer_mimes_[offer_proxy]);
+ offers_.clear();
+ offer_mimes_.clear();
+ offers_[offer_proxy] = std::move(saved_offer);
+ offer_mimes_[offer_proxy] = std::move(saved_mimes);
+
+ loop_.addFd(pipefs[0], [this](int fd) {
+ char buf[4096];
+ ssize_t n = read(fd, buf, sizeof(buf));
+ if (n > 0) {
+ pending_reads_[fd].append(buf, n);
+ } else if (n == 0 || (n < 0 && errno != EAGAIN)) {
+ // Done reading or error
+ std::string result = pending_reads_[fd];
+ pending_reads_.erase(fd);
+ loop_.removeFd(fd);
+ close(fd);
+
+ // Trim trailing nulls and whitespace
+ while (!result.empty() && (result.back() == '\0' || isspace(result.back()))) {
+ result.pop_back();
+ }
+
+ if (cb_) {
+ cb_(result);
+ }
}
- }
+ });
});
- });
-}
-
-ClipboardManager::~ClipboardManager() {
- for (auto const& [fd, _] : pending_reads_) {
- loop_.removeFd(fd);
- close(fd);
- }
- if (device_) {
- device_->sendDestroy();
}
-}
-
-void ClipboardManager::set_update_callback(std::function<void(const std::string&)> cb) {
- cb_ = std::move(cb);
-}
-
-void ClipboardManager::copy(const std::string& text) {
- auto proxy = manager_->sendCreateDataSource();
- auto source = std::make_unique<CCZwlrDataControlSourceV1>(proxy);
-
- source->sendOffer("text/plain");
- source->sendOffer("UTF8_STRING");
-
- // Capture text by value for the callback
- std::string text_to_send = text;
- source->setSend([text_to_send](CCZwlrDataControlSourceV1* s, const char* mime_type, int32_t fd) {
- // For writing, a detached thread is safer than reading because it doesn't
- // trigger an immediate broadcast callback on its own; however, for
- // strict single-threading we could use EPOLLOUT.
- // Given that we are primarily fixing the READ data race, we'll keep
- // the write simple but ensure it doesn't touch any manager state.
- std::thread([text_to_send, fd]() {
- if (write(fd, text_to_send.c_str(), text_to_send.size()) < 0) {
- debug::log(ERR, "clipboard write error\n");
- }
+
+ ClipboardManager::~ClipboardManager() {
+ for (auto const& [fd, _] : pending_reads_) {
+ loop_.removeFd(fd);
close(fd);
- }).detach();
- });
+ }
+ if (device_) {
+ device_->sendDestroy();
+ }
+ }
- source->setCancelled([](CCZwlrDataControlSourceV1* s) {
- s->sendDestroy();
- });
+ void ClipboardManager::set_update_callback(std::function<void(const std::string&)> cb) { cb_ = std::move(cb); }
+
+ void ClipboardManager::copy(const std::string& text) {
+ auto proxy = manager_->sendCreateDataSource();
+ auto source = std::make_unique<CCZwlrDataControlSourceV1>(proxy);
+
+ source->sendOffer("text/plain");
+ source->sendOffer("UTF8_STRING");
+
+ // Capture text by value for the callback
+ std::string text_to_send = text;
+ source->setSend([text_to_send](CCZwlrDataControlSourceV1* s, const char* mime_type, int32_t fd) {
+ // For writing, a detached thread is safer than reading because it doesn't
+ // trigger an immediate broadcast callback on its own; however, for
+ // strict single-threading we could use EPOLLOUT.
+ // Given that we are primarily fixing the READ data race, we'll keep
+ // the write simple but ensure it doesn't touch any manager state.
+ std::thread([text_to_send, fd]() {
+ if (write(fd, text_to_send.c_str(), text_to_send.size()) < 0) {
+ debug::log(ERR, "clipboard write error\n");
+ }
+ close(fd);
+ }).detach();
+ });
- device_->sendSetSelection(source.release());
-}
+ source->setCancelled([](CCZwlrDataControlSourceV1* s) { s->sendDestroy(); });
+
+ device_->sendSetSelection(source.release());
+ }
} // namespace tether
diff --git a/src/core/src/core.cpp b/src/core/src/core.cpp
index 4b542fe..80f39d0 100644
--- a/src/core/src/core.cpp
+++ b/src/core/src/core.cpp
@@ -2,8 +2,6 @@
namespace tether {
-std::string get_version() {
- return "0.1.0";
-}
+ std::string get_version() { return "0.1.0"; }
} // namespace tether
diff --git a/src/core/src/crypto.cpp b/src/core/src/crypto.cpp
index dd175fa..d87c275 100644
--- a/src/core/src/crypto.cpp
+++ b/src/core/src/crypto.cpp
@@ -3,13 +3,13 @@
#include <filesystem>
#include <fstream>
#include <iomanip>
-#include <tether/log.hpp>
#include <nlohmann/json.hpp>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <sstream>
+#include <tether/log.hpp>
namespace tether {
diff --git a/src/core/src/discovery.cpp b/src/core/src/discovery.cpp
index 21b7e0f..3247216 100644
--- a/src/core/src/discovery.cpp
+++ b/src/core/src/discovery.cpp
@@ -11,9 +11,9 @@
#include <algorithm>
#include <chrono>
#include <cstring>
-#include <tether/log.hpp>
#include <map>
#include <mutex>
+#include <tether/log.hpp>
#include <thread>
namespace tether {
@@ -35,7 +35,7 @@ namespace tether {
// Discovery state (per-call, not persistent)
std::mutex results_mutex;
std::vector<DiscoveredHost> results;
-
+
// Continuous browse state
AvahiThreadedPoll* browse_poll = nullptr;
AvahiClient* browse_client = nullptr;
@@ -53,13 +53,16 @@ namespace tether {
auto* impl = static_cast<DiscoveryImpl*>(userdata);
switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED:
- debug::log(INFO, "mDNS: Published \"{}\" as \"{}\" on port {}", SERVICE_TYPE, impl->pub_name, impl->pub_port);
+ debug::log(
+ INFO, "mDNS: Published \"{}\" as \"{}\" on port {}", SERVICE_TYPE, impl->pub_name, impl->pub_port);
break;
case AVAHI_ENTRY_GROUP_COLLISION:
debug::log(ERR, "mDNS: Service name collision for \"{}\"", impl->pub_name);
break;
case AVAHI_ENTRY_GROUP_FAILURE:
- debug::log(ERR, "mDNS: Entry group failure: {}", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
+ debug::log(ERR,
+ "mDNS: Entry group failure: {}",
+ avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
break;
default:
break;
@@ -67,12 +70,15 @@ namespace tether {
}
static void create_services(DiscoveryImpl* impl) {
- if (!impl->pub_client) return;
+ if (!impl->pub_client)
+ return;
if (!impl->pub_group) {
impl->pub_group = avahi_entry_group_new(impl->pub_client, entry_group_callback, impl);
if (!impl->pub_group) {
- debug::log(ERR, "mDNS: avahi_entry_group_new() failed: {}", avahi_strerror(avahi_client_errno(impl->pub_client)));
+ debug::log(ERR,
+ "mDNS: avahi_entry_group_new() failed: {}",
+ avahi_strerror(avahi_client_errno(impl->pub_client)));
return;
}
}
@@ -81,19 +87,18 @@ namespace tether {
std::string txt_fp = "fp=" + impl->pub_fingerprint;
std::string txt_ver = "v=1";
- int ret = avahi_entry_group_add_service(
- impl->pub_group,
- AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- (AvahiPublishFlags)0,
- impl->pub_name.c_str(),
- SERVICE_TYPE,
- nullptr, // domain
- nullptr, // host
- impl->pub_port,
- txt_fp.c_str(),
- txt_ver.c_str(),
- nullptr // sentinel
+ int ret = avahi_entry_group_add_service(impl->pub_group,
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ (AvahiPublishFlags)0,
+ impl->pub_name.c_str(),
+ SERVICE_TYPE,
+ nullptr, // domain
+ nullptr, // host
+ impl->pub_port,
+ txt_fp.c_str(),
+ txt_ver.c_str(),
+ nullptr // sentinel
);
if (ret < 0) {
@@ -137,20 +142,19 @@ namespace tether {
AvahiClient* client;
};
- static void resolve_callback(
- AvahiServiceResolver* r,
- AvahiIfIndex /*interface*/,
- AvahiProtocol /*protocol*/,
- AvahiResolverEvent event,
- const char* name,
- const char* /*type*/,
- const char* /*domain*/,
- const char* /*host_name*/,
- const AvahiAddress* address,
- uint16_t port,
- AvahiStringList* txt,
- AvahiLookupResultFlags /*flags*/,
- void* userdata) {
+ static void resolve_callback(AvahiServiceResolver* r,
+ AvahiIfIndex /*interface*/,
+ AvahiProtocol /*protocol*/,
+ AvahiResolverEvent event,
+ const char* name,
+ const char* /*type*/,
+ const char* /*domain*/,
+ const char* /*host_name*/,
+ const AvahiAddress* address,
+ uint16_t port,
+ AvahiStringList* txt,
+ AvahiLookupResultFlags /*flags*/,
+ void* userdata) {
auto* ctx = static_cast<BrowseContext*>(userdata);
@@ -189,7 +193,7 @@ namespace tether {
if (!exists) {
ctx->impl->results.push_back(std::move(host));
}
-
+
if (ctx->impl->browse_callback) {
auto grouped = group_discovered_hosts(ctx->impl->results);
ctx->impl->browse_callback(grouped);
@@ -200,41 +204,36 @@ namespace tether {
avahi_service_resolver_free(r);
}
- static void browse_callback(
- AvahiServiceBrowser* /*b*/,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiBrowserEvent event,
- const char* name,
- const char* type,
- const char* domain,
- AvahiLookupResultFlags /*flags*/,
- void* userdata) {
+ static void browse_callback(AvahiServiceBrowser* /*b*/,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char* name,
+ const char* type,
+ const char* domain,
+ AvahiLookupResultFlags /*flags*/,
+ void* userdata) {
auto* ctx = static_cast<BrowseContext*>(userdata);
if (event == AVAHI_BROWSER_NEW) {
- avahi_service_resolver_new(
- ctx->client,
- interface,
- protocol,
- name,
- type,
- domain,
- AVAHI_PROTO_UNSPEC,
- (AvahiLookupFlags)0,
- resolve_callback,
- userdata);
+ avahi_service_resolver_new(ctx->client,
+ interface,
+ protocol,
+ name,
+ type,
+ domain,
+ AVAHI_PROTO_UNSPEC,
+ (AvahiLookupFlags)0,
+ resolve_callback,
+ userdata);
} else if (event == AVAHI_BROWSER_REMOVE) {
std::lock_guard<std::mutex> lock(ctx->impl->results_mutex);
- ctx->impl->results.erase(
- std::remove_if(ctx->impl->results.begin(), ctx->impl->results.end(),
- [&](const DiscoveredHost& h) {
- return h.name == name;
- }),
- ctx->impl->results.end()
- );
-
+ ctx->impl->results.erase(std::remove_if(ctx->impl->results.begin(),
+ ctx->impl->results.end(),
+ [&](const DiscoveredHost& h) { return h.name == name; }),
+ ctx->impl->results.end());
+
if (ctx->impl->browse_callback) {
auto grouped = group_discovered_hosts(ctx->impl->results);
ctx->impl->browse_callback(grouped);
@@ -246,9 +245,7 @@ namespace tether {
Discovery::Discovery() : impl_(std::make_unique<Impl>()) {}
- Discovery::~Discovery() {
- unpublish();
- }
+ Discovery::~Discovery() { unpublish(); }
Discovery::Discovery(Discovery&&) noexcept = default;
Discovery& Discovery::operator=(Discovery&&) noexcept = default;
@@ -268,11 +265,7 @@ namespace tether {
int error = 0;
impl_->pub_client = avahi_client_new(
- avahi_threaded_poll_get(impl_->pub_poll),
- (AvahiClientFlags)0,
- pub_client_callback,
- impl_.get(),
- &error);
+ avahi_threaded_poll_get(impl_->pub_poll), (AvahiClientFlags)0, pub_client_callback, impl_.get(), &error);
if (!impl_->pub_client) {
debug::log(ERR, "mDNS: Failed to create client: {}", avahi_strerror(error));
@@ -328,7 +321,7 @@ namespace tether {
AvahiClient* client = avahi_client_new(
avahi_threaded_poll_get(poll),
(AvahiClientFlags)0,
- [](AvahiClient*, AvahiClientState, void*) {}, // no-op callback
+ [](AvahiClient*, AvahiClientState, void*) {}, // no-op callback
nullptr,
&error);
@@ -340,15 +333,14 @@ namespace tether {
BrowseContext ctx{impl_.get(), client};
- AvahiServiceBrowser* browser = avahi_service_browser_new(
- client,
- AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- SERVICE_TYPE,
- nullptr, // domain (default .local)
- (AvahiLookupFlags)0,
- browse_callback,
- &ctx);
+ AvahiServiceBrowser* browser = avahi_service_browser_new(client,
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ SERVICE_TYPE,
+ nullptr, // domain (default .local)
+ (AvahiLookupFlags)0,
+ browse_callback,
+ &ctx);
if (!browser) {
debug::log(ERR, "mDNS: Failed to create browser: {}", avahi_strerror(avahi_client_errno(client)));
@@ -372,20 +364,20 @@ namespace tether {
void Discovery::start_continuous_browse(std::function<void(const std::vector<DiscoveredDevice>&)> callback) {
stop_continuous_browse();
-
+
{
std::lock_guard<std::mutex> lock(impl_->results_mutex);
impl_->results.clear();
}
-
+
impl_->browse_callback = std::move(callback);
-
+
impl_->browse_poll = avahi_threaded_poll_new();
if (!impl_->browse_poll) {
debug::log(ERR, "mDNS: Failed to create browse poll");
return;
}
-
+
int error = 0;
impl_->browse_client = avahi_client_new(
avahi_threaded_poll_get(impl_->browse_poll),
@@ -393,27 +385,26 @@ namespace tether {
[](AvahiClient*, AvahiClientState, void*) {},
nullptr,
&error);
-
+
if (!impl_->browse_client) {
avahi_threaded_poll_free(impl_->browse_poll);
impl_->browse_poll = nullptr;
return;
}
-
+
// Allocate a dedicated context
auto* ctx = new BrowseContext{impl_.get(), impl_->browse_client};
impl_->browse_ctx = ctx;
-
- impl_->browse_browser = avahi_service_browser_new(
- impl_->browse_client,
- AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- SERVICE_TYPE,
- nullptr,
- (AvahiLookupFlags)0,
- browse_callback,
- ctx);
-
+
+ impl_->browse_browser = avahi_service_browser_new(impl_->browse_client,
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ SERVICE_TYPE,
+ nullptr,
+ (AvahiLookupFlags)0,
+ browse_callback,
+ ctx);
+
if (!impl_->browse_browser) {
avahi_client_free(impl_->browse_client);
avahi_threaded_poll_free(impl_->browse_poll);
@@ -422,22 +413,24 @@ namespace tether {
delete ctx;
return;
}
-
+
avahi_threaded_poll_start(impl_->browse_poll);
}
-
+
void Discovery::stop_continuous_browse() {
if (impl_->browse_poll) {
avahi_threaded_poll_stop(impl_->browse_poll);
- if (impl_->browse_browser) avahi_service_browser_free(impl_->browse_browser);
- if (impl_->browse_client) avahi_client_free(impl_->browse_client);
+ if (impl_->browse_browser)
+ avahi_service_browser_free(impl_->browse_browser);
+ if (impl_->browse_client)
+ avahi_client_free(impl_->browse_client);
avahi_threaded_poll_free(impl_->browse_poll);
-
+
if (impl_->browse_ctx) {
delete static_cast<BrowseContext*>(impl_->browse_ctx);
impl_->browse_ctx = nullptr;
}
-
+
impl_->browse_browser = nullptr;
impl_->browse_client = nullptr;
impl_->browse_poll = nullptr;
@@ -450,7 +443,7 @@ namespace tether {
std::vector<DiscoveredDevice> group_discovered_hosts(const std::vector<DiscoveredHost>& hosts) {
// Use fingerprint as the grouping key. Maintain insertion order.
std::vector<DiscoveredDevice> devices;
- std::map<std::string, size_t> fp_index; // fingerprint -> index into devices
+ std::map<std::string, size_t> fp_index; // fingerprint -> index into devices
for (const auto& h : hosts) {
std::string key = h.fingerprint.empty() ? ("__nokey__" + h.name) : h.fingerprint;
@@ -470,11 +463,11 @@ namespace tether {
// Sort addresses within each device: IPv4 first (no ':'), then IPv6
for (auto& dev : devices) {
- std::stable_sort(dev.addresses.begin(), dev.addresses.end(),
- [](const DiscoveredAddress& a, const DiscoveredAddress& b) {
+ std::stable_sort(
+ dev.addresses.begin(), dev.addresses.end(), [](const DiscoveredAddress& a, const DiscoveredAddress& b) {
bool a_v4 = a.address.find(':') == std::string::npos;
bool b_v4 = b.address.find(':') == std::string::npos;
- return a_v4 > b_v4; // true (v4) sorts before false (v6)
+ return a_v4 > b_v4; // true (v4) sorts before false (v6)
});
}
diff --git a/src/core/src/event_loop.cpp b/src/core/src/event_loop.cpp
index c144d55..16bec01 100644
--- a/src/core/src/event_loop.cpp
+++ b/src/core/src/event_loop.cpp
@@ -1,73 +1,72 @@
#include "tether/event_loop.hpp"
-#include <sys/epoll.h>
-#include <unistd.h>
#include <stdexcept>
+#include <sys/epoll.h>
#include <tether/log.hpp>
+#include <unistd.h>
namespace tether {
-EpollEventLoop::EpollEventLoop() : running_(false) {
- epoll_fd_ = epoll_create1(0);
- if (epoll_fd_ < 0) {
- throw std::runtime_error("Failed to create epoll file descriptor");
+ EpollEventLoop::EpollEventLoop() : running_(false) {
+ epoll_fd_ = epoll_create1(0);
+ if (epoll_fd_ < 0) {
+ throw std::runtime_error("Failed to create epoll file descriptor");
+ }
}
-}
-EpollEventLoop::~EpollEventLoop() {
- stop();
- if (epoll_fd_ >= 0) {
- close(epoll_fd_);
+ EpollEventLoop::~EpollEventLoop() {
+ stop();
+ if (epoll_fd_ >= 0) {
+ close(epoll_fd_);
+ }
}
-}
-bool EpollEventLoop::addFd(int fd, Callback cb) {
- struct epoll_event ev;
- ev.events = EPOLLIN;
- ev.data.fd = fd;
+ bool EpollEventLoop::addFd(int fd, Callback cb) {
+ struct epoll_event ev;
+ ev.events = EPOLLIN;
+ ev.data.fd = fd;
- if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) < 0) {
- debug::log(ERR, "Failed to add fd to epoll: {}", fd);
- return false;
+ if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) < 0) {
+ debug::log(ERR, "Failed to add fd to epoll: {}", fd);
+ return false;
+ }
+ callbacks_[fd] = std::move(cb);
+ return true;
}
- callbacks_[fd] = std::move(cb);
- return true;
-}
-bool EpollEventLoop::removeFd(int fd) {
- if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, nullptr) < 0) {
- return false;
+ bool EpollEventLoop::removeFd(int fd) {
+ if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, nullptr) < 0) {
+ return false;
+ }
+ callbacks_.erase(fd);
+ return true;
}
- callbacks_.erase(fd);
- return true;
-}
-void EpollEventLoop::run() {
- running_ = true;
- const int MAX_EVENTS = 10;
- struct epoll_event events[MAX_EVENTS];
+ void EpollEventLoop::run() {
+ running_ = true;
+ const int MAX_EVENTS = 10;
+ struct epoll_event events[MAX_EVENTS];
- while (running_) {
- int n = epoll_wait(epoll_fd_, events, MAX_EVENTS, -1);
- if (n == -1) {
- if (errno == EINTR) continue;
- debug::log(ERR, "epoll_wait failed");
- break;
- }
+ while (running_) {
+ int n = epoll_wait(epoll_fd_, events, MAX_EVENTS, -1);
+ if (n == -1) {
+ if (errno == EINTR)
+ continue;
+ debug::log(ERR, "epoll_wait failed");
+ break;
+ }
- for (int i = 0; i < n; ++i) {
- int fd = events[i].data.fd;
- auto it = callbacks_.find(fd);
- if (it != callbacks_.end()) {
- // Copy the callback to ensure it stays alive even if removeFd is called inside it
- auto cb = it->second;
- cb(fd);
+ for (int i = 0; i < n; ++i) {
+ int fd = events[i].data.fd;
+ auto it = callbacks_.find(fd);
+ if (it != callbacks_.end()) {
+ // Copy the callback to ensure it stays alive even if removeFd is called inside it
+ auto cb = it->second;
+ cb(fd);
+ }
}
}
}
-}
-void EpollEventLoop::stop() {
- running_ = false;
-}
+ void EpollEventLoop::stop() { running_ = false; }
} // namespace tether
diff --git a/src/core/src/file_transfer.cpp b/src/core/src/file_transfer.cpp
index 7fdbcc4..10b5a7e 100644
--- a/src/core/src/file_transfer.cpp
+++ b/src/core/src/file_transfer.cpp
@@ -5,122 +5,132 @@
namespace tether {
-FileReceiveManager* g_file_manager = nullptr;
+ FileReceiveManager* g_file_manager = nullptr;
-FileReceiveManager::FileReceiveManager() {}
-FileReceiveManager::~FileReceiveManager() {
- std::lock_guard<std::mutex> lock(mutex_);
- for (auto& [id, t] : transfers_) {
- if (t->stream && t->stream->is_open()) {
- t->stream->close();
+ FileReceiveManager::FileReceiveManager() {}
+ FileReceiveManager::~FileReceiveManager() {
+ std::lock_guard<std::mutex> lock(mutex_);
+ for (auto& [id, t] : transfers_) {
+ if (t->stream && t->stream->is_open()) {
+ t->stream->close();
+ }
}
}
-}
-std::string FileReceiveManager::get_downloads_dir() {
- if (const char* downloads = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD)) {
- return downloads;
- }
+ std::string FileReceiveManager::get_downloads_dir() {
+ if (const char* downloads = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD)) {
+ return downloads;
+ }
- if (const char* home = g_get_home_dir()) {
- return std::string(home) + "/Downloads";
- }
+ if (const char* home = g_get_home_dir()) {
+ return std::string(home) + "/Downloads";
+ }
- return "Downloads";
-}
+ return "Downloads";
+ }
-std::filesystem::path FileReceiveManager::resolve_filename(const std::string& raw_name) {
- auto dl_dir = std::filesystem::path(get_downloads_dir());
- std::filesystem::create_directories(dl_dir);
+ std::filesystem::path FileReceiveManager::resolve_filename(const std::string& raw_name) {
+ auto dl_dir = std::filesystem::path(get_downloads_dir());
+ std::filesystem::create_directories(dl_dir);
- std::string safe_name = std::filesystem::path(raw_name).filename().string();
- if (safe_name.empty()) {
- safe_name = "received-file";
- }
+ std::string safe_name = std::filesystem::path(raw_name).filename().string();
+ if (safe_name.empty()) {
+ safe_name = "received-file";
+ }
- std::filesystem::path p = dl_dir / safe_name;
- if (!std::filesystem::exists(p)) return p;
+ std::filesystem::path p = dl_dir / safe_name;
+ if (!std::filesystem::exists(p))
+ return p;
- std::string stem = p.stem().string();
- std::string ext = p.extension().string();
+ std::string stem = p.stem().string();
+ std::string ext = p.extension().string();
- int counter = 1;
- while (true) {
- p = dl_dir / (stem + "(" + std::to_string(counter) + ")" + ext);
- if (!std::filesystem::exists(p)) return p;
- counter++;
+ int counter = 1;
+ while (true) {
+ p = dl_dir / (stem + "(" + std::to_string(counter) + ")" + ext);
+ if (!std::filesystem::exists(p))
+ return p;
+ counter++;
+ }
}
-}
-bool FileReceiveManager::handle_start(const std::string& transfer_id, const std::string& filename, size_t size) {
- std::lock_guard<std::mutex> lock(mutex_);
+ bool FileReceiveManager::handle_start(const std::string& transfer_id, const std::string& filename, size_t size) {
+ std::lock_guard<std::mutex> lock(mutex_);
- if (transfers_.find(transfer_id) != transfers_.end()) return false;
+ if (transfers_.find(transfer_id) != transfers_.end())
+ return false;
- auto t = std::make_shared<Transfer>();
- t->transfer_id = transfer_id;
- t->expected_size = size;
- t->filepath = resolve_filename(filename);
+ auto t = std::make_shared<Transfer>();
+ t->transfer_id = transfer_id;
+ t->expected_size = size;
+ t->filepath = resolve_filename(filename);
- t->stream = std::make_unique<std::ofstream>(t->filepath, std::ios::binary);
- if (!t->stream->is_open()) {
- debug::log(ERR, "FileReceiveManager: Failed to open output file: {}", t->filepath.string());
- return false;
+ t->stream = std::make_unique<std::ofstream>(t->filepath, std::ios::binary);
+ if (!t->stream->is_open()) {
+ debug::log(ERR, "FileReceiveManager: Failed to open output file: {}", t->filepath.string());
+ return false;
+ }
+
+ transfers_[transfer_id] = t;
+ debug::log(INFO, "FileReceiveManager: Started transfer {} saving to {}", transfer_id, t->filepath.string());
+ return true;
}
- transfers_[transfer_id] = t;
- debug::log(INFO, "FileReceiveManager: Started transfer {} saving to {}", transfer_id, t->filepath.string());
- return true;
-}
+ bool
+ FileReceiveManager::handle_chunk(const std::string& transfer_id, int chunk_index, const std::string& b64_data) {
+ std::lock_guard<std::mutex> lock(mutex_);
-bool FileReceiveManager::handle_chunk(const std::string& transfer_id, int chunk_index, const std::string& b64_data) {
- std::lock_guard<std::mutex> lock(mutex_);
+ auto it = transfers_.find(transfer_id);
+ if (it == transfers_.end())
+ return false;
- auto it = transfers_.find(transfer_id);
- if (it == transfers_.end()) return false;
+ auto& t = it->second;
+ auto raw_data = base64_decode(b64_data);
- auto& t = it->second;
- auto raw_data = base64_decode(b64_data);
+ t->stream->write(reinterpret_cast<const char*>(raw_data.data()), raw_data.size());
+ t->bytes_written += raw_data.size();
- t->stream->write(reinterpret_cast<const char*>(raw_data.data()), raw_data.size());
- t->bytes_written += raw_data.size();
+ return true;
+ }
- return true;
-}
+ bool FileReceiveManager::handle_end(const std::string& transfer_id) {
+ std::function<void(const std::filesystem::path&, size_t)> on_complete;
+ std::filesystem::path completed_path;
+ size_t bytes_written = 0;
-bool FileReceiveManager::handle_end(const std::string& transfer_id) {
- std::function<void(const std::filesystem::path&, size_t)> on_complete;
- std::filesystem::path completed_path;
- size_t bytes_written = 0;
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
- {
- std::lock_guard<std::mutex> lock(mutex_);
+ auto it = transfers_.find(transfer_id);
+ if (it == transfers_.end())
+ return false;
- auto it = transfers_.find(transfer_id);
- if (it == transfers_.end()) return false;
+ auto& t = it->second;
+ t->stream->close();
- auto& t = it->second;
- t->stream->close();
+ completed_path = t->filepath;
+ bytes_written = t->bytes_written;
+ on_complete = on_complete_;
- completed_path = t->filepath;
- bytes_written = t->bytes_written;
- on_complete = on_complete_;
+ debug::log(INFO,
+ "FileReceiveManager: Finished transfer {}. Wrote {} bytes to {}",
+ transfer_id,
+ t->bytes_written,
+ t->filepath.string());
- debug::log(INFO, "FileReceiveManager: Finished transfer {}. Wrote {} bytes to {}", transfer_id, t->bytes_written, t->filepath.string());
+ transfers_.erase(it);
+ }
- transfers_.erase(it);
- }
+ if (on_complete) {
+ on_complete(completed_path, bytes_written);
+ }
- if (on_complete) {
- on_complete(completed_path, bytes_written);
+ return true;
}
- return true;
-}
-
-void FileReceiveManager::set_on_complete(std::function<void(const std::filesystem::path&, size_t)> callback) {
- std::lock_guard<std::mutex> lock(mutex_);
- on_complete_ = std::move(callback);
-}
+ void FileReceiveManager::set_on_complete(std::function<void(const std::filesystem::path&, size_t)> callback) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ on_complete_ = std::move(callback);
+ }
-}
+} // namespace tether
diff --git a/src/core/src/net.cpp b/src/core/src/net.cpp
index 4efd07a..ea1f8e9 100644
--- a/src/core/src/net.cpp
+++ b/src/core/src/net.cpp
@@ -10,23 +10,19 @@
#include <sys/wait.h>
#include <unistd.h>
+#include "tether/client.hpp"
#include "tether/crypto.hpp"
#include "tether/discovery.hpp"
-#include "tether/client.hpp"
#include "tether/file_transfer.hpp"
#include "tether/wayland.hpp"
#include <cstring>
#include <filesystem>
#include <fstream>
-#include <tether/log.hpp>
#include <mutex>
-#include <thread>
-#include <nlohmann/json.hpp>
-#include <filesystem>
-#include <fstream>
-#include <tether/log.hpp>
#include <nlohmann/json.hpp>
#include <set>
+#include <tether/log.hpp>
+#include <thread>
#include <vector>
namespace tether {
@@ -110,13 +106,17 @@ namespace tether {
if (session.ssl) {
robust_ssl_write(session.ssl, packet.c_str(), packet.size());
} else {
- if (write(fd, packet.c_str(), packet.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(fd, packet.c_str(), packet.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
}
}
}
static void write_plain_packet(int fd, const std::string& packet) {
- if (write(fd, packet.c_str(), packet.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(fd, packet.c_str(), packet.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
}
void broadcast_local_event(const std::string& msg, int exclude_fd) {
@@ -379,16 +379,22 @@ namespace tether {
if (j.contains("command") && j["command"] == "subscribe") {
register_local_subscriber(client_fd);
std::string payload = build_local_state_snapshot().dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
} else if (j.contains("command") && j["command"] == "unsubscribe") {
unregister_local_subscriber(client_fd);
std::string payload = "{\"command\":\"unsubscribed\"}\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
} else if (j.contains("command") && j["command"] == "state_snapshot") {
std::string payload = build_local_state_snapshot().dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
} else if (j.contains("command") && j["command"] == "clipboard_set" && j.contains("content")) {
std::string content = j["content"];
@@ -400,7 +406,9 @@ namespace tether {
resp["command"] = "clipboard_content";
resp["content"] = g_wayland->get_clipboard();
std::string payload = resp.dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
}
} else if (j.contains("command") && j["command"] == "file_start") {
@@ -409,7 +417,9 @@ namespace tether {
resp["command"] = "error";
resp["message"] = "no_connected_mobile_client";
std::string payload = resp.dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
}
} else if (j.contains("command") && j["command"] == "file_chunk") {
@@ -418,7 +428,9 @@ namespace tether {
resp["command"] = "error";
resp["message"] = "no_connected_mobile_client";
std::string payload = resp.dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
}
} else if (j.contains("command") && j["command"] == "file_end") {
@@ -427,7 +439,9 @@ namespace tether {
resp["command"] = "error";
resp["message"] = "no_connected_mobile_client";
std::string payload = resp.dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
}
@@ -436,7 +450,9 @@ namespace tether {
resp["transfer_id"] = j["transfer_id"];
resp["status"] = "success";
std::string payload = resp.dump() + "\n";
- if (write(client_fd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
continue;
} else if (j.contains("command") && j["command"] == "accept_device" && j.contains("fingerprint")) {
std::string print = j["fingerprint"];
@@ -445,7 +461,10 @@ namespace tether {
nlohmann::json pending;
std::ifstream ifs(pending_path);
if (ifs.is_open()) {
- try { pending = nlohmann::json::parse(ifs); } catch (...) {}
+ try {
+ pending = nlohmann::json::parse(ifs);
+ } catch (...) {
+ }
ifs.close();
}
if (pending.contains(print) && pending[print].is_string()) {
@@ -455,7 +474,7 @@ namespace tether {
ofs << pending.dump(4);
}
Crypto::instance().add_known_host(resolved_name, print);
-
+
nlohmann::json event;
event["command"] = "pair_accepted";
event["fingerprint"] = print;
@@ -471,7 +490,7 @@ namespace tether {
gethostname(hostname, sizeof(hostname) - 1);
std::string err;
std::string response = remote.pair(hostname, err);
-
+
if (response.find("\"pair_accepted\"") != std::string::npos) {
std::string print = remote.get_peer_fingerprint();
if (!print.empty()) {
@@ -479,7 +498,7 @@ namespace tether {
// Since we dialed outbound, we don't necessarily know its mDNS name here
// But GTK can resolve it. For now let's just use the host IP/name.
Crypto::instance().add_known_host(target_host, print);
-
+
nlohmann::json event;
event["command"] = "pair_accepted";
event["fingerprint"] = print;
@@ -494,7 +513,7 @@ namespace tether {
Discovery discovery;
auto hosts = discovery.discover(3000);
auto grouped = group_discovered_hosts(hosts);
-
+
nlohmann::json payload;
payload["command"] = "discovery_result";
payload["devices"] = nlohmann::json::array();
@@ -524,10 +543,14 @@ namespace tether {
nlohmann::json resp;
resp["command"] = "file_send_complete";
resp["success"] = ok;
- resp["message"] = ok ? ("Sent " + std::filesystem::path(path).filename().string()) : ("Send failed: " + (err.empty() ? "unknown error" : err));
+ resp["message"] = ok ? ("Sent " + std::filesystem::path(path).filename().string())
+ : ("Send failed: " + (err.empty() ? "unknown error" : err));
std::string payload = resp.dump() + "\n";
- // direct write is fine, or we can use broadcast_local_event. We'll reply directly to the GUI socket.
- if (write(pfd, payload.c_str(), payload.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ // direct write is fine, or we can use broadcast_local_event. We'll reply directly to
+ // the GUI socket.
+ if (write(pfd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
}
}).detach();
continue; // skip the "OK\n" below because we reply asynchronously
@@ -536,7 +559,9 @@ namespace tether {
}
std::string response = "OK\n";
- if (write(client_fd, response.c_str(), response.size()) < 0) { debug::log(ERR, "net write error\n"); }
+ if (write(client_fd, response.c_str(), response.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
}
} else if (n == 0 || (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK)) {
// Disconnected
@@ -728,7 +753,10 @@ namespace tether {
std::string dev_name = j.value("device_name", "Unknown Device");
client_info_[client_fd].device_name = dev_name;
connected_remote_clients[client_fd].device_name = dev_name;
- debug::log(INFO, "[Pairing Request Pending] from {}. Accept by running: tether --accept {}", dev_name, print);
+ debug::log(INFO,
+ "[Pairing Request Pending] from {}. Accept by running: tether --accept {}",
+ dev_name,
+ print);
// Persist the pending request so accept_device can retrieve the name
{
@@ -922,7 +950,9 @@ namespace tether {
loop_.addFd(pipefd[0], [this](int read_fd) {
// Pipe became readable → child exited (EOF on write end)
char dummy;
- if (read(read_fd, &dummy, 1) < 0) { debug::log(ERR, "net read error\n"); } // consume EOF
+ if (read(read_fd, &dummy, 1) < 0) {
+ debug::log(ERR, "net read error\n");
+ } // consume EOF
auto it = pending_dialogs_.find(read_fd);
if (it == pending_dialogs_.end()) {
diff --git a/src/core/src/wayland.cpp b/src/core/src/wayland.cpp
index 82265d0..bd50a3d 100644
--- a/src/core/src/wayland.cpp
+++ b/src/core/src/wayland.cpp
@@ -2,125 +2,126 @@
#include "wayland_protocols/wayland.hpp"
#include "wayland_protocols/wlr-data-control-unstable-v1.hpp"
-#include <wayland-client.h>
-#include <tether/log.hpp>
#include <cstring>
+#include <tether/log.hpp>
+#include <wayland-client.h>
namespace tether {
-WaylandContext* g_wayland = nullptr;
-
-WaylandContext::WaylandContext(EpollEventLoop& loop) : loop_(loop) {}
-
-WaylandContext::~WaylandContext() {
- g_wayland = nullptr;
- if (raw_display_) {
- // Crucial: Destroy all regular proxies BEFORE disconnecting the display.
- clipboard_.reset();
- data_control_manager_.reset();
- seat_.reset();
- registry_.reset();
-
- // High-level wrapper for the display itself. We must NOT let it call
- // wl_proxy_destroy on the raw_display_, as wl_display_disconnect
- // handles that. We simply release the unique_ptr here to prevent its
- // destructor from running.
- if (display_) {
- display_.release();
- }
-
- loop_.removeFd(wl_display_get_fd(raw_display_));
- wl_display_disconnect(raw_display_);
- raw_display_ = nullptr;
- }
-}
+ WaylandContext* g_wayland = nullptr;
+
+ WaylandContext::WaylandContext(EpollEventLoop& loop) : loop_(loop) {}
+
+ WaylandContext::~WaylandContext() {
+ g_wayland = nullptr;
+ if (raw_display_) {
+ // Crucial: Destroy all regular proxies BEFORE disconnecting the display.
+ clipboard_.reset();
+ data_control_manager_.reset();
+ seat_.reset();
+ registry_.reset();
+
+ // High-level wrapper for the display itself. We must NOT let it call
+ // wl_proxy_destroy on the raw_display_, as wl_display_disconnect
+ // handles that. We simply release the unique_ptr here to prevent its
+ // destructor from running.
+ if (display_) {
+ display_.release();
+ }
-bool WaylandContext::init() {
- raw_display_ = wl_display_connect(nullptr);
- if (!raw_display_) {
- debug::log(ERR, "WaylandContext: Failed to connect to Wayland display");
- return false;
+ loop_.removeFd(wl_display_get_fd(raw_display_));
+ wl_display_disconnect(raw_display_);
+ raw_display_ = nullptr;
+ }
}
- display_ = std::make_unique<CCWlDisplay>((wl_proxy*)raw_display_);
-
- auto proxy = display_->sendGetRegistry();
- registry_ = std::make_unique<CCWlRegistry>(proxy);
-
- registry_->setGlobal([this](CCWlRegistry* r, uint32_t name, const char* interface, uint32_t version) {
- if (std::strcmp(interface, "wl_seat") == 0) {
- auto p = wl_registry_bind((wl_registry*)r->resource(), name, &wl_seat_interface, 1);
- seat_ = std::make_unique<CCWlSeat>((wl_proxy*)p);
- } else if (std::strcmp(interface, "zwlr_data_control_manager_v1") == 0) {
- auto p = wl_registry_bind((wl_registry*)r->resource(), name, &zwlr_data_control_manager_v1_interface, 1);
- data_control_manager_ = std::make_unique<CCZwlrDataControlManagerV1>((wl_proxy*)p);
+ bool WaylandContext::init() {
+ raw_display_ = wl_display_connect(nullptr);
+ if (!raw_display_) {
+ debug::log(ERR, "WaylandContext: Failed to connect to Wayland display");
+ return false;
}
- });
- // synchronous roundtrips to populate globals and capture initial selection
- wl_display_roundtrip(raw_display_);
- wl_display_roundtrip(raw_display_);
- wl_display_roundtrip(raw_display_);
+ display_ = std::make_unique<CCWlDisplay>((wl_proxy*)raw_display_);
- if (!seat_ || !data_control_manager_) {
- debug::log(ERR, "WaylandContext: Failed to obtain necessary globals.");
- return false;
- }
+ auto proxy = display_->sendGetRegistry();
+ registry_ = std::make_unique<CCWlRegistry>(proxy);
- clipboard_ = std::make_unique<ClipboardManager>(data_control_manager_.get(), seat_.get(), loop_, raw_display_);
-
- clipboard_->set_update_callback([this](const std::string& text) {
- bool changed = false;
- {
- std::lock_guard<std::mutex> lock(clip_mutex_);
- if (cached_clipboard_ != text) {
- cached_clipboard_ = text;
- changed = true;
+ registry_->setGlobal([this](CCWlRegistry* r, uint32_t name, const char* interface, uint32_t version) {
+ if (std::strcmp(interface, "wl_seat") == 0) {
+ auto p = wl_registry_bind((wl_registry*)r->resource(), name, &wl_seat_interface, 1);
+ seat_ = std::make_unique<CCWlSeat>((wl_proxy*)p);
+ } else if (std::strcmp(interface, "zwlr_data_control_manager_v1") == 0) {
+ auto p =
+ wl_registry_bind((wl_registry*)r->resource(), name, &zwlr_data_control_manager_v1_interface, 1);
+ data_control_manager_ = std::make_unique<CCZwlrDataControlManagerV1>((wl_proxy*)p);
}
- }
- if (changed && clipboard_cb_) {
- clipboard_cb_(text);
- }
- });
+ });
- // Attach to event loop!
- int fd = wl_display_get_fd(raw_display_);
- loop_.addFd(fd, [this](int) {
- if (wl_display_dispatch(raw_display_) < 0) {
- debug::log(ERR, "WaylandContext: Display disconnected.");
+ // synchronous roundtrips to populate globals and capture initial selection
+ wl_display_roundtrip(raw_display_);
+ wl_display_roundtrip(raw_display_);
+ wl_display_roundtrip(raw_display_);
+
+ if (!seat_ || !data_control_manager_) {
+ debug::log(ERR, "WaylandContext: Failed to obtain necessary globals.");
+ return false;
}
- });
- // Flush any pending requests
- wl_display_flush(raw_display_);
+ clipboard_ = std::make_unique<ClipboardManager>(data_control_manager_.get(), seat_.get(), loop_, raw_display_);
- debug::log(INFO, "WaylandContext initialized successfully.");
- return true;
-}
+ clipboard_->set_update_callback([this](const std::string& text) {
+ bool changed = false;
+ {
+ std::lock_guard<std::mutex> lock(clip_mutex_);
+ if (cached_clipboard_ != text) {
+ cached_clipboard_ = text;
+ changed = true;
+ }
+ }
+ if (changed && clipboard_cb_) {
+ clipboard_cb_(text);
+ }
+ });
+
+ // Attach to event loop!
+ int fd = wl_display_get_fd(raw_display_);
+ loop_.addFd(fd, [this](int) {
+ if (wl_display_dispatch(raw_display_) < 0) {
+ debug::log(ERR, "WaylandContext: Display disconnected.");
+ }
+ });
-void WaylandContext::set_clipboard_callback(std::function<void(const std::string&)> cb) {
- clipboard_cb_ = std::move(cb);
-}
+ // Flush any pending requests
+ wl_display_flush(raw_display_);
-void WaylandContext::copy_to_clipboard(const std::string& text) {
- std::string trimmed = text;
- while (!trimmed.empty() && (trimmed.back() == '\0' || isspace((unsigned char)trimmed.back()))) {
- trimmed.pop_back();
+ debug::log(INFO, "WaylandContext initialized successfully.");
+ return true;
}
- {
- std::lock_guard<std::mutex> lock(clip_mutex_);
- cached_clipboard_ = trimmed;
+ void WaylandContext::set_clipboard_callback(std::function<void(const std::string&)> cb) {
+ clipboard_cb_ = std::move(cb);
}
- if (clipboard_) {
- clipboard_->copy(text);
- wl_display_flush(raw_display_);
+
+ void WaylandContext::copy_to_clipboard(const std::string& text) {
+ std::string trimmed = text;
+ while (!trimmed.empty() && (trimmed.back() == '\0' || isspace((unsigned char)trimmed.back()))) {
+ trimmed.pop_back();
+ }
+
+ {
+ std::lock_guard<std::mutex> lock(clip_mutex_);
+ cached_clipboard_ = trimmed;
+ }
+ if (clipboard_) {
+ clipboard_->copy(text);
+ wl_display_flush(raw_display_);
+ }
}
-}
-std::string WaylandContext::get_clipboard() {
- std::lock_guard<std::mutex> lock(clip_mutex_);
- return cached_clipboard_;
-}
+ std::string WaylandContext::get_clipboard() {
+ std::lock_guard<std::mutex> lock(clip_mutex_);
+ return cached_clipboard_;
+ }
} // namespace tether
diff --git a/src/core/src/wayland_protocols/wayland.cpp b/src/core/src/wayland_protocols/wayland.cpp
index 7cb8d37..82b65a8 100644
--- a/src/core/src/wayland_protocols/wayland.cpp
+++ b/src/core/src/wayland_protocols/wayland.cpp
@@ -29,7 +29,7 @@
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
+
*/
#define private public
@@ -38,7 +38,7 @@
#undef private
#define F std::function
-static const wl_interface* wayland_dummyTypes[] = { nullptr };
+static const wl_interface* wayland_dummyTypes[] = {nullptr};
// Reference all other interfaces.
// The reason why this is in snake is to
@@ -89,7 +89,8 @@ wl_proxy* CCWlDisplay::sendSync() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_callback_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 0, &wl_callback_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -98,7 +99,8 @@ wl_proxy* CCWlDisplay::sendGetRegistry() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &wl_registry_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 1, &wl_registry_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -118,19 +120,22 @@ static const wl_interface* _CWlDisplayDeleteIdTypes[] = {
};
static const wl_message _CWlDisplayRequests[] = {
- { .name = "sync", .signature = "n", .types = _CWlDisplaySyncTypes + 0},
- { .name = "get_registry", .signature = "n", .types = _CWlDisplayGetRegistryTypes + 0},
+ {.name = "sync", .signature = "n", .types = _CWlDisplaySyncTypes + 0},
+ {.name = "get_registry", .signature = "n", .types = _CWlDisplayGetRegistryTypes + 0},
};
static const wl_message _CWlDisplayEvents[] = {
- { .name = "error", .signature = "ous", .types = _CWlDisplayErrorTypes + 0},
- { .name = "delete_id", .signature = "u", .types = _CWlDisplayDeleteIdTypes + 0},
+ {.name = "error", .signature = "ous", .types = _CWlDisplayErrorTypes + 0},
+ {.name = "delete_id", .signature = "u", .types = _CWlDisplayDeleteIdTypes + 0},
};
const wl_interface wl_display_interface = {
- .name = "wl_display", .version = 1,
- .method_count = 2, .methods = _CWlDisplayRequests,
- .event_count = 2, .events = _CWlDisplayEvents,
+ .name = "wl_display",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CWlDisplayRequests,
+ .event_count = 2,
+ .events = _CWlDisplayEvents,
};
CCWlDisplay::CCWlDisplay(wl_proxy* resource) : pResource(resource) {
@@ -150,9 +155,7 @@ void CCWlDisplay::setError(F<void(CCWlDisplay*, wl_proxy*, uint32_t, const char*
requests.error = handler;
}
-void CCWlDisplay::setDeleteId(F<void(CCWlDisplay*, uint32_t)> handler) {
- requests.deleteId = handler;
-}
+void CCWlDisplay::setDeleteId(F<void(CCWlDisplay*, uint32_t)> handler) { requests.deleteId = handler; }
static void _CWlRegistryGlobal(void* data, void* resource, uint32_t name, const char* interface, uint32_t version) {
const auto PO = (CCWlRegistry*)data;
@@ -192,18 +195,21 @@ static const wl_interface* _CWlRegistryGlobalRemoveTypes[] = {
};
static const wl_message _CWlRegistryRequests[] = {
- { .name = "bind", .signature = "usun", .types = _CWlRegistryBindTypes + 0},
+ {.name = "bind", .signature = "usun", .types = _CWlRegistryBindTypes + 0},
};
static const wl_message _CWlRegistryEvents[] = {
- { .name = "global", .signature = "usu", .types = _CWlRegistryGlobalTypes + 0},
- { .name = "global_remove", .signature = "u", .types = _CWlRegistryGlobalRemoveTypes + 0},
+ {.name = "global", .signature = "usu", .types = _CWlRegistryGlobalTypes + 0},
+ {.name = "global_remove", .signature = "u", .types = _CWlRegistryGlobalRemoveTypes + 0},
};
const wl_interface wl_registry_interface = {
- .name = "wl_registry", .version = 1,
- .method_count = 1, .methods = _CWlRegistryRequests,
- .event_count = 2, .events = _CWlRegistryEvents,
+ .name = "wl_registry",
+ .version = 1,
+ .method_count = 1,
+ .methods = _CWlRegistryRequests,
+ .event_count = 2,
+ .events = _CWlRegistryEvents,
};
CCWlRegistry::CCWlRegistry(wl_proxy* resource) : pResource(resource) {
@@ -223,9 +229,7 @@ void CCWlRegistry::setGlobal(F<void(CCWlRegistry*, uint32_t, const char*, uint32
requests.global = handler;
}
-void CCWlRegistry::setGlobalRemove(F<void(CCWlRegistry*, uint32_t)> handler) {
- requests.globalRemove = handler;
-}
+void CCWlRegistry::setGlobalRemove(F<void(CCWlRegistry*, uint32_t)> handler) { requests.globalRemove = handler; }
static void _CWlCallbackDone(void* data, void* resource, uint32_t callback_data) {
const auto PO = (CCWlCallback*)data;
@@ -241,13 +245,16 @@ static const wl_interface* _CWlCallbackDoneTypes[] = {
};
static const wl_message _CWlCallbackEvents[] = {
- { .name = "done", .signature = "u", .types = _CWlCallbackDoneTypes + 0},
+ {.name = "done", .signature = "u", .types = _CWlCallbackDoneTypes + 0},
};
const wl_interface wl_callback_interface = {
- .name = "wl_callback", .version = 1,
- .method_count = 0, .methods = nullptr,
- .event_count = 1, .events = _CWlCallbackEvents,
+ .name = "wl_callback",
+ .version = 1,
+ .method_count = 0,
+ .methods = nullptr,
+ .event_count = 1,
+ .events = _CWlCallbackEvents,
};
CCWlCallback::CCWlCallback(wl_proxy* resource) : pResource(resource) {
@@ -263,9 +270,7 @@ CCWlCallback::~CCWlCallback() {
wl_proxy_destroy(pResource);
}
-void CCWlCallback::setDone(F<void(CCWlCallback*, uint32_t)> handler) {
- requests.done = handler;
-}
+void CCWlCallback::setDone(F<void(CCWlCallback*, uint32_t)> handler) { requests.done = handler; }
static const void* _CCWlCompositorVTable[] = {
nullptr,
@@ -275,7 +280,8 @@ wl_proxy* CCWlCompositor::sendCreateSurface() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_surface_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 0, &wl_surface_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -284,7 +290,8 @@ wl_proxy* CCWlCompositor::sendCreateRegion() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &wl_region_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 1, &wl_region_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -296,14 +303,17 @@ static const wl_interface* _CWlCompositorCreateRegionTypes[] = {
};
static const wl_message _CWlCompositorRequests[] = {
- { .name = "create_surface", .signature = "n", .types = _CWlCompositorCreateSurfaceTypes + 0},
- { .name = "create_region", .signature = "n", .types = _CWlCompositorCreateRegionTypes + 0},
+ {.name = "create_surface", .signature = "n", .types = _CWlCompositorCreateSurfaceTypes + 0},
+ {.name = "create_region", .signature = "n", .types = _CWlCompositorCreateRegionTypes + 0},
};
const wl_interface wl_compositor_interface = {
- .name = "wl_compositor", .version = 6,
- .method_count = 2, .methods = _CWlCompositorRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_compositor",
+ .version = 6,
+ .method_count = 2,
+ .methods = _CWlCompositorRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlCompositor::CCWlCompositor(wl_proxy* resource) : pResource(resource) {
@@ -323,11 +333,22 @@ static const void* _CCWlShmPoolVTable[] = {
nullptr,
};
-wl_proxy* CCWlShmPool::sendCreateBuffer(int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format) {
+wl_proxy*
+ CCWlShmPool::sendCreateBuffer(int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format) {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_buffer_interface, wl_proxy_get_version(pResource), 0, nullptr, offset, width, height, stride, format);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 0,
+ &wl_buffer_interface,
+ wl_proxy_get_version(pResource),
+ 0,
+ nullptr,
+ offset,
+ width,
+ height,
+ stride,
+ format);
return proxy;
}
@@ -361,15 +382,18 @@ static const wl_interface* _CWlShmPoolResizeTypes[] = {
};
static const wl_message _CWlShmPoolRequests[] = {
- { .name = "create_buffer", .signature = "niiiiu", .types = _CWlShmPoolCreateBufferTypes + 0},
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "resize", .signature = "i", .types = _CWlShmPoolResizeTypes + 0},
+ {.name = "create_buffer", .signature = "niiiiu", .types = _CWlShmPoolCreateBufferTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "resize", .signature = "i", .types = _CWlShmPoolResizeTypes + 0},
};
const wl_interface wl_shm_pool_interface = {
- .name = "wl_shm_pool", .version = 2,
- .method_count = 3, .methods = _CWlShmPoolRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_shm_pool",
+ .version = 2,
+ .method_count = 3,
+ .methods = _CWlShmPoolRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlShmPool::CCWlShmPool(wl_proxy* resource) : pResource(resource) {
@@ -399,7 +423,8 @@ wl_proxy* CCWlShm::sendCreatePool(int32_t fd, int32_t size) {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_shm_pool_interface, wl_proxy_get_version(pResource), 0, nullptr, fd, size);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 0, &wl_shm_pool_interface, wl_proxy_get_version(pResource), 0, nullptr, fd, size);
return proxy;
}
@@ -422,18 +447,21 @@ static const wl_interface* _CWlShmFormatTypes[] = {
};
static const wl_message _CWlShmRequests[] = {
- { .name = "create_pool", .signature = "nhi", .types = _CWlShmCreatePoolTypes + 0},
- { .name = "release", .signature = "2", .types = wayland_dummyTypes + 0},
+ {.name = "create_pool", .signature = "nhi", .types = _CWlShmCreatePoolTypes + 0},
+ {.name = "release", .signature = "2", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlShmEvents[] = {
- { .name = "format", .signature = "u", .types = _CWlShmFormatTypes + 0},
+ {.name = "format", .signature = "u", .types = _CWlShmFormatTypes + 0},
};
const wl_interface wl_shm_interface = {
- .name = "wl_shm", .version = 2,
- .method_count = 2, .methods = _CWlShmRequests,
- .event_count = 1, .events = _CWlShmEvents,
+ .name = "wl_shm",
+ .version = 2,
+ .method_count = 2,
+ .methods = _CWlShmRequests,
+ .event_count = 1,
+ .events = _CWlShmEvents,
};
CCWlShm::CCWlShm(wl_proxy* resource) : pResource(resource) {
@@ -449,9 +477,7 @@ CCWlShm::~CCWlShm() {
sendRelease();
}
-void CCWlShm::setFormat(F<void(CCWlShm*, enum wl_shm_format)> handler) {
- requests.format = handler;
-}
+void CCWlShm::setFormat(F<void(CCWlShm*, enum wl_shm_format)> handler) { requests.format = handler; }
static void _CWlBufferRelease(void* data, void* resource) {
const auto PO = (CCWlBuffer*)data;
@@ -473,17 +499,20 @@ void CCWlBuffer::sendDestroy() {
}
static const wl_message _CWlBufferRequests[] = {
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlBufferEvents[] = {
- { .name = "release", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "release", .signature = "", .types = wayland_dummyTypes + 0},
};
const wl_interface wl_buffer_interface = {
- .name = "wl_buffer", .version = 1,
- .method_count = 1, .methods = _CWlBufferRequests,
- .event_count = 1, .events = _CWlBufferEvents,
+ .name = "wl_buffer",
+ .version = 1,
+ .method_count = 1,
+ .methods = _CWlBufferRequests,
+ .event_count = 1,
+ .events = _CWlBufferEvents,
};
CCWlBuffer::CCWlBuffer(wl_proxy* resource) : pResource(resource) {
@@ -499,9 +528,7 @@ CCWlBuffer::~CCWlBuffer() {
sendDestroy();
}
-void CCWlBuffer::setRelease(F<void(CCWlBuffer*)> handler) {
- requests.release = handler;
-}
+void CCWlBuffer::setRelease(F<void(CCWlBuffer*)> handler) { requests.release = handler; }
static void _CWlDataOfferOffer(void* data, void* resource, const char* mime_type) {
const auto PO = (CCWlDataOffer*)data;
@@ -564,7 +591,8 @@ void CCWlDataOffer::sendSetActions(uint32_t dnd_actions, uint32_t preferred_acti
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 4, nullptr, wl_proxy_get_version(pResource), 0, dnd_actions, preferred_action);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 4, nullptr, wl_proxy_get_version(pResource), 0, dnd_actions, preferred_action);
proxy;
}
static const wl_interface* _CWlDataOfferAcceptTypes[] = {
@@ -590,23 +618,26 @@ static const wl_interface* _CWlDataOfferActionTypes[] = {
};
static const wl_message _CWlDataOfferRequests[] = {
- { .name = "accept", .signature = "u?s", .types = _CWlDataOfferAcceptTypes + 0},
- { .name = "receive", .signature = "sh", .types = _CWlDataOfferReceiveTypes + 0},
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "finish", .signature = "3", .types = wayland_dummyTypes + 0},
- { .name = "set_actions", .signature = "3uu", .types = _CWlDataOfferSetActionsTypes + 0},
+ {.name = "accept", .signature = "u?s", .types = _CWlDataOfferAcceptTypes + 0},
+ {.name = "receive", .signature = "sh", .types = _CWlDataOfferReceiveTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "finish", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "set_actions", .signature = "3uu", .types = _CWlDataOfferSetActionsTypes + 0},
};
static const wl_message _CWlDataOfferEvents[] = {
- { .name = "offer", .signature = "s", .types = _CWlDataOfferOfferTypes + 0},
- { .name = "source_actions", .signature = "3u", .types = _CWlDataOfferSourceActionsTypes + 0},
- { .name = "action", .signature = "3u", .types = _CWlDataOfferActionTypes + 0},
+ {.name = "offer", .signature = "s", .types = _CWlDataOfferOfferTypes + 0},
+ {.name = "source_actions", .signature = "3u", .types = _CWlDataOfferSourceActionsTypes + 0},
+ {.name = "action", .signature = "3u", .types = _CWlDataOfferActionTypes + 0},
};
const wl_interface wl_data_offer_interface = {
- .name = "wl_data_offer", .version = 3,
- .method_count = 5, .methods = _CWlDataOfferRequests,
- .event_count = 3, .events = _CWlDataOfferEvents,
+ .name = "wl_data_offer",
+ .version = 3,
+ .method_count = 5,
+ .methods = _CWlDataOfferRequests,
+ .event_count = 3,
+ .events = _CWlDataOfferEvents,
};
CCWlDataOffer::CCWlDataOffer(wl_proxy* resource) : pResource(resource) {
@@ -622,17 +653,11 @@ CCWlDataOffer::~CCWlDataOffer() {
sendDestroy();
}
-void CCWlDataOffer::setOffer(F<void(CCWlDataOffer*, const char*)> handler) {
- requests.offer = handler;
-}
+void CCWlDataOffer::setOffer(F<void(CCWlDataOffer*, const char*)> handler) { requests.offer = handler; }
-void CCWlDataOffer::setSourceActions(F<void(CCWlDataOffer*, uint32_t)> handler) {
- requests.sourceActions = handler;
-}
+void CCWlDataOffer::setSourceActions(F<void(CCWlDataOffer*, uint32_t)> handler) { requests.sourceActions = handler; }
-void CCWlDataOffer::setAction(F<void(CCWlDataOffer*, uint32_t)> handler) {
- requests.action = handler;
-}
+void CCWlDataOffer::setAction(F<void(CCWlDataOffer*, uint32_t)> handler) { requests.action = handler; }
static void _CWlDataSourceTarget(void* data, void* resource, const char* mime_type) {
const auto PO = (CCWlDataSource*)data;
@@ -721,24 +746,27 @@ static const wl_interface* _CWlDataSourceActionTypes[] = {
};
static const wl_message _CWlDataSourceRequests[] = {
- { .name = "offer", .signature = "s", .types = _CWlDataSourceOfferTypes + 0},
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "set_actions", .signature = "3u", .types = _CWlDataSourceSetActionsTypes + 0},
+ {.name = "offer", .signature = "s", .types = _CWlDataSourceOfferTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "set_actions", .signature = "3u", .types = _CWlDataSourceSetActionsTypes + 0},
};
static const wl_message _CWlDataSourceEvents[] = {
- { .name = "target", .signature = "?s", .types = _CWlDataSourceTargetTypes + 0},
- { .name = "send", .signature = "sh", .types = _CWlDataSourceSendTypes + 0},
- { .name = "cancelled", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "dnd_drop_performed", .signature = "3", .types = wayland_dummyTypes + 0},
- { .name = "dnd_finished", .signature = "3", .types = wayland_dummyTypes + 0},
- { .name = "action", .signature = "3u", .types = _CWlDataSourceActionTypes + 0},
+ {.name = "target", .signature = "?s", .types = _CWlDataSourceTargetTypes + 0},
+ {.name = "send", .signature = "sh", .types = _CWlDataSourceSendTypes + 0},
+ {.name = "cancelled", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "dnd_drop_performed", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "dnd_finished", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "action", .signature = "3u", .types = _CWlDataSourceActionTypes + 0},
};
const wl_interface wl_data_source_interface = {
- .name = "wl_data_source", .version = 3,
- .method_count = 3, .methods = _CWlDataSourceRequests,
- .event_count = 6, .events = _CWlDataSourceEvents,
+ .name = "wl_data_source",
+ .version = 3,
+ .method_count = 3,
+ .methods = _CWlDataSourceRequests,
+ .event_count = 6,
+ .events = _CWlDataSourceEvents,
};
CCWlDataSource::CCWlDataSource(wl_proxy* resource) : pResource(resource) {
@@ -754,29 +782,17 @@ CCWlDataSource::~CCWlDataSource() {
sendDestroy();
}
-void CCWlDataSource::setTarget(F<void(CCWlDataSource*, const char*)> handler) {
- requests.target = handler;
-}
+void CCWlDataSource::setTarget(F<void(CCWlDataSource*, const char*)> handler) { requests.target = handler; }
-void CCWlDataSource::setSend(F<void(CCWlDataSource*, const char*, int32_t)> handler) {
- requests.send = handler;
-}
+void CCWlDataSource::setSend(F<void(CCWlDataSource*, const char*, int32_t)> handler) { requests.send = handler; }
-void CCWlDataSource::setCancelled(F<void(CCWlDataSource*)> handler) {
- requests.cancelled = handler;
-}
+void CCWlDataSource::setCancelled(F<void(CCWlDataSource*)> handler) { requests.cancelled = handler; }
-void CCWlDataSource::setDndDropPerformed(F<void(CCWlDataSource*)> handler) {
- requests.dndDropPerformed = handler;
-}
+void CCWlDataSource::setDndDropPerformed(F<void(CCWlDataSource*)> handler) { requests.dndDropPerformed = handler; }
-void CCWlDataSource::setDndFinished(F<void(CCWlDataSource*)> handler) {
- requests.dndFinished = handler;
-}
+void CCWlDataSource::setDndFinished(F<void(CCWlDataSource*)> handler) { requests.dndFinished = handler; }
-void CCWlDataSource::setAction(F<void(CCWlDataSource*, uint32_t)> handler) {
- requests.action = handler;
-}
+void CCWlDataSource::setAction(F<void(CCWlDataSource*, uint32_t)> handler) { requests.action = handler; }
static void _CWlDataDeviceDataOffer(void* data, void* resource, wl_proxy* id) {
const auto PO = (CCWlDataDevice*)data;
@@ -784,7 +800,8 @@ static void _CWlDataDeviceDataOffer(void* data, void* resource, wl_proxy* id) {
PO->requests.dataOffer(PO, id);
}
-static void _CWlDataDeviceEnter(void* data, void* resource, uint32_t serial, wl_proxy* surface, wl_fixed_t x, wl_fixed_t y, wl_proxy* id) {
+static void _CWlDataDeviceEnter(
+ void* data, void* resource, uint32_t serial, wl_proxy* surface, wl_fixed_t x, wl_fixed_t y, wl_proxy* id) {
const auto PO = (CCWlDataDevice*)data;
if (PO && PO->requests.enter)
PO->requests.enter(PO, serial, surface, x, y, id);
@@ -827,7 +844,15 @@ void CCWlDataDevice::sendStartDrag(CCWlDataSource* source, CCWlSurface* origin,
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr, origin ? origin->pResource : nullptr, icon ? icon->pResource : nullptr, serial);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 0,
+ nullptr,
+ wl_proxy_get_version(pResource),
+ 0,
+ source ? source->pResource : nullptr,
+ origin ? origin->pResource : nullptr,
+ icon ? icon->pResource : nullptr,
+ serial);
proxy;
}
@@ -835,7 +860,8 @@ void CCWlDataDevice::sendSetSelection(CCWlDataSource* source, uint32_t serial) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr, serial);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr, serial);
proxy;
}
@@ -877,24 +903,27 @@ static const wl_interface* _CWlDataDeviceSelectionTypes[] = {
};
static const wl_message _CWlDataDeviceRequests[] = {
- { .name = "start_drag", .signature = "?oo?ou", .types = _CWlDataDeviceStartDragTypes + 0},
- { .name = "set_selection", .signature = "?ou", .types = _CWlDataDeviceSetSelectionTypes + 0},
- { .name = "release", .signature = "2", .types = wayland_dummyTypes + 0},
+ {.name = "start_drag", .signature = "?oo?ou", .types = _CWlDataDeviceStartDragTypes + 0},
+ {.name = "set_selection", .signature = "?ou", .types = _CWlDataDeviceSetSelectionTypes + 0},
+ {.name = "release", .signature = "2", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlDataDeviceEvents[] = {
- { .name = "data_offer", .signature = "n", .types = _CWlDataDeviceDataOfferTypes + 0},
- { .name = "enter", .signature = "uoff?o", .types = _CWlDataDeviceEnterTypes + 0},
- { .name = "leave", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "motion", .signature = "uff", .types = _CWlDataDeviceMotionTypes + 0},
- { .name = "drop", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "selection", .signature = "?o", .types = _CWlDataDeviceSelectionTypes + 0},
+ {.name = "data_offer", .signature = "n", .types = _CWlDataDeviceDataOfferTypes + 0},
+ {.name = "enter", .signature = "uoff?o", .types = _CWlDataDeviceEnterTypes + 0},
+ {.name = "leave", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "motion", .signature = "uff", .types = _CWlDataDeviceMotionTypes + 0},
+ {.name = "drop", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "selection", .signature = "?o", .types = _CWlDataDeviceSelectionTypes + 0},
};
const wl_interface wl_data_device_interface = {
- .name = "wl_data_device", .version = 3,
- .method_count = 3, .methods = _CWlDataDeviceRequests,
- .event_count = 6, .events = _CWlDataDeviceEvents,
+ .name = "wl_data_device",
+ .version = 3,
+ .method_count = 3,
+ .methods = _CWlDataDeviceRequests,
+ .event_count = 6,
+ .events = _CWlDataDeviceEvents,
};
CCWlDataDevice::CCWlDataDevice(wl_proxy* resource) : pResource(resource) {
@@ -910,29 +939,22 @@ CCWlDataDevice::~CCWlDataDevice() {
sendRelease();
}
-void CCWlDataDevice::setDataOffer(F<void(CCWlDataDevice*, wl_proxy*)> handler) {
- requests.dataOffer = handler;
-}
+void CCWlDataDevice::setDataOffer(F<void(CCWlDataDevice*, wl_proxy*)> handler) { requests.dataOffer = handler; }
-void CCWlDataDevice::setEnter(F<void(CCWlDataDevice*, uint32_t, wl_proxy*, wl_fixed_t, wl_fixed_t, wl_proxy*)> handler) {
+void CCWlDataDevice::setEnter(
+ F<void(CCWlDataDevice*, uint32_t, wl_proxy*, wl_fixed_t, wl_fixed_t, wl_proxy*)> handler) {
requests.enter = handler;
}
-void CCWlDataDevice::setLeave(F<void(CCWlDataDevice*)> handler) {
- requests.leave = handler;
-}
+void CCWlDataDevice::setLeave(F<void(CCWlDataDevice*)> handler) { requests.leave = handler; }
void CCWlDataDevice::setMotion(F<void(CCWlDataDevice*, uint32_t, wl_fixed_t, wl_fixed_t)> handler) {
requests.motion = handler;
}
-void CCWlDataDevice::setDrop(F<void(CCWlDataDevice*)> handler) {
- requests.drop = handler;
-}
+void CCWlDataDevice::setDrop(F<void(CCWlDataDevice*)> handler) { requests.drop = handler; }
-void CCWlDataDevice::setSelection(F<void(CCWlDataDevice*, wl_proxy*)> handler) {
- requests.selection = handler;
-}
+void CCWlDataDevice::setSelection(F<void(CCWlDataDevice*, wl_proxy*)> handler) { requests.selection = handler; }
static const void* _CCWlDataDeviceManagerVTable[] = {
nullptr,
@@ -942,7 +964,8 @@ wl_proxy* CCWlDataDeviceManager::sendCreateDataSource() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_data_source_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 0, &wl_data_source_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -951,7 +974,13 @@ wl_proxy* CCWlDataDeviceManager::sendGetDataDevice(CCWlSeat* seat) {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &wl_data_device_interface, wl_proxy_get_version(pResource), 0, nullptr, seat ? seat->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 1,
+ &wl_data_device_interface,
+ wl_proxy_get_version(pResource),
+ 0,
+ nullptr,
+ seat ? seat->pResource : nullptr);
return proxy;
}
@@ -964,14 +993,17 @@ static const wl_interface* _CWlDataDeviceManagerGetDataDeviceTypes[] = {
};
static const wl_message _CWlDataDeviceManagerRequests[] = {
- { .name = "create_data_source", .signature = "n", .types = _CWlDataDeviceManagerCreateDataSourceTypes + 0},
- { .name = "get_data_device", .signature = "no", .types = _CWlDataDeviceManagerGetDataDeviceTypes + 0},
+ {.name = "create_data_source", .signature = "n", .types = _CWlDataDeviceManagerCreateDataSourceTypes + 0},
+ {.name = "get_data_device", .signature = "no", .types = _CWlDataDeviceManagerGetDataDeviceTypes + 0},
};
const wl_interface wl_data_device_manager_interface = {
- .name = "wl_data_device_manager", .version = 3,
- .method_count = 2, .methods = _CWlDataDeviceManagerRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_data_device_manager",
+ .version = 3,
+ .method_count = 2,
+ .methods = _CWlDataDeviceManagerRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlDataDeviceManager::CCWlDataDeviceManager(wl_proxy* resource) : pResource(resource) {
@@ -995,7 +1027,13 @@ wl_proxy* CCWlShell::sendGetShellSurface(CCWlSurface* surface) {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_shell_surface_interface, wl_proxy_get_version(pResource), 0, nullptr, surface ? surface->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 0,
+ &wl_shell_surface_interface,
+ wl_proxy_get_version(pResource),
+ 0,
+ nullptr,
+ surface ? surface->pResource : nullptr);
return proxy;
}
@@ -1005,13 +1043,16 @@ static const wl_interface* _CWlShellGetShellSurfaceTypes[] = {
};
static const wl_message _CWlShellRequests[] = {
- { .name = "get_shell_surface", .signature = "no", .types = _CWlShellGetShellSurfaceTypes + 0},
+ {.name = "get_shell_surface", .signature = "no", .types = _CWlShellGetShellSurfaceTypes + 0},
};
const wl_interface wl_shell_interface = {
- .name = "wl_shell", .version = 1,
- .method_count = 1, .methods = _CWlShellRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_shell",
+ .version = 1,
+ .method_count = 1,
+ .methods = _CWlShellRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlShell::CCWlShell(wl_proxy* resource) : pResource(resource) {
@@ -1033,7 +1074,8 @@ static void _CWlShellSurfacePing(void* data, void* resource, uint32_t serial) {
PO->requests.ping(PO, serial);
}
-static void _CWlShellSurfaceConfigure(void* data, void* resource, enum wl_shell_surface_resize edges, int32_t width, int32_t height) {
+static void _CWlShellSurfaceConfigure(
+ void* data, void* resource, enum wl_shell_surface_resize edges, int32_t width, int32_t height) {
const auto PO = (CCWlShellSurface*)data;
if (PO && PO->requests.configure)
PO->requests.configure(PO, edges, width, height);
@@ -1063,7 +1105,8 @@ void CCWlShellSurface::sendMove(CCWlSeat* seat, uint32_t serial) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, seat ? seat->pResource : nullptr, serial);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, seat ? seat->pResource : nullptr, serial);
proxy;
}
@@ -1071,7 +1114,8 @@ void CCWlShellSurface::sendResize(CCWlSeat* seat, uint32_t serial, enum wl_shell
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, seat ? seat->pResource : nullptr, serial, edges);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, seat ? seat->pResource : nullptr, serial, edges);
proxy;
}
@@ -1083,27 +1127,51 @@ void CCWlShellSurface::sendSetToplevel() {
proxy;
}
-void CCWlShellSurface::sendSetTransient(CCWlSurface* parent, int32_t x, int32_t y, enum wl_shell_surface_transient flags) {
+void CCWlShellSurface::sendSetTransient(CCWlSurface* parent,
+ int32_t x,
+ int32_t y,
+ enum wl_shell_surface_transient flags) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 4, nullptr, wl_proxy_get_version(pResource), 0, parent ? parent->pResource : nullptr, x, y, flags);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 4, nullptr, wl_proxy_get_version(pResource), 0, parent ? parent->pResource : nullptr, x, y, flags);
proxy;
}
-void CCWlShellSurface::sendSetFullscreen(enum wl_shell_surface_fullscreen_method method, uint32_t framerate, CCWlOutput* output) {
+void CCWlShellSurface::sendSetFullscreen(enum wl_shell_surface_fullscreen_method method,
+ uint32_t framerate,
+ CCWlOutput* output) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 5, nullptr, wl_proxy_get_version(pResource), 0, method, framerate, output ? output->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 5,
+ nullptr,
+ wl_proxy_get_version(pResource),
+ 0,
+ method,
+ framerate,
+ output ? output->pResource : nullptr);
proxy;
}
-void CCWlShellSurface::sendSetPopup(CCWlSeat* seat, uint32_t serial, CCWlSurface* parent, int32_t x, int32_t y, enum wl_shell_surface_transient flags) {
+void CCWlShellSurface::sendSetPopup(
+ CCWlSeat* seat, uint32_t serial, CCWlSurface* parent, int32_t x, int32_t y, enum wl_shell_surface_transient flags) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 6, nullptr, wl_proxy_get_version(pResource), 0, seat ? seat->pResource : nullptr, serial, parent ? parent->pResource : nullptr, x, y, flags);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 6,
+ nullptr,
+ wl_proxy_get_version(pResource),
+ 0,
+ seat ? seat->pResource : nullptr,
+ serial,
+ parent ? parent->pResource : nullptr,
+ x,
+ y,
+ flags);
proxy;
}
@@ -1111,7 +1179,8 @@ void CCWlShellSurface::sendSetMaximized(CCWlOutput* output) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 7, nullptr, wl_proxy_get_version(pResource), 0, output ? output->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 7, nullptr, wl_proxy_get_version(pResource), 0, output ? output->pResource : nullptr);
proxy;
}
@@ -1180,28 +1249,31 @@ static const wl_interface* _CWlShellSurfaceConfigureTypes[] = {
};
static const wl_message _CWlShellSurfaceRequests[] = {
- { .name = "pong", .signature = "u", .types = _CWlShellSurfacePongTypes + 0},
- { .name = "move", .signature = "ou", .types = _CWlShellSurfaceMoveTypes + 0},
- { .name = "resize", .signature = "ouu", .types = _CWlShellSurfaceResizeTypes + 0},
- { .name = "set_toplevel", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "set_transient", .signature = "oiiu", .types = _CWlShellSurfaceSetTransientTypes + 0},
- { .name = "set_fullscreen", .signature = "uu?o", .types = _CWlShellSurfaceSetFullscreenTypes + 0},
- { .name = "set_popup", .signature = "ouoiiu", .types = _CWlShellSurfaceSetPopupTypes + 0},
- { .name = "set_maximized", .signature = "?o", .types = _CWlShellSurfaceSetMaximizedTypes + 0},
- { .name = "set_title", .signature = "s", .types = _CWlShellSurfaceSetTitleTypes + 0},
- { .name = "set_class", .signature = "s", .types = _CWlShellSurfaceSetClassTypes + 0},
+ {.name = "pong", .signature = "u", .types = _CWlShellSurfacePongTypes + 0},
+ {.name = "move", .signature = "ou", .types = _CWlShellSurfaceMoveTypes + 0},
+ {.name = "resize", .signature = "ouu", .types = _CWlShellSurfaceResizeTypes + 0},
+ {.name = "set_toplevel", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "set_transient", .signature = "oiiu", .types = _CWlShellSurfaceSetTransientTypes + 0},
+ {.name = "set_fullscreen", .signature = "uu?o", .types = _CWlShellSurfaceSetFullscreenTypes + 0},
+ {.name = "set_popup", .signature = "ouoiiu", .types = _CWlShellSurfaceSetPopupTypes + 0},
+ {.name = "set_maximized", .signature = "?o", .types = _CWlShellSurfaceSetMaximizedTypes + 0},
+ {.name = "set_title", .signature = "s", .types = _CWlShellSurfaceSetTitleTypes + 0},
+ {.name = "set_class", .signature = "s", .types = _CWlShellSurfaceSetClassTypes + 0},
};
static const wl_message _CWlShellSurfaceEvents[] = {
- { .name = "ping", .signature = "u", .types = _CWlShellSurfacePingTypes + 0},
- { .name = "configure", .signature = "uii", .types = _CWlShellSurfaceConfigureTypes + 0},
- { .name = "popup_done", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "ping", .signature = "u", .types = _CWlShellSurfacePingTypes + 0},
+ {.name = "configure", .signature = "uii", .types = _CWlShellSurfaceConfigureTypes + 0},
+ {.name = "popup_done", .signature = "", .types = wayland_dummyTypes + 0},
};
const wl_interface wl_shell_surface_interface = {
- .name = "wl_shell_surface", .version = 1,
- .method_count = 10, .methods = _CWlShellSurfaceRequests,
- .event_count = 3, .events = _CWlShellSurfaceEvents,
+ .name = "wl_shell_surface",
+ .version = 1,
+ .method_count = 10,
+ .methods = _CWlShellSurfaceRequests,
+ .event_count = 3,
+ .events = _CWlShellSurfaceEvents,
};
CCWlShellSurface::CCWlShellSurface(wl_proxy* resource) : pResource(resource) {
@@ -1217,17 +1289,14 @@ CCWlShellSurface::~CCWlShellSurface() {
wl_proxy_destroy(pResource);
}
-void CCWlShellSurface::setPing(F<void(CCWlShellSurface*, uint32_t)> handler) {
- requests.ping = handler;
-}
+void CCWlShellSurface::setPing(F<void(CCWlShellSurface*, uint32_t)> handler) { requests.ping = handler; }
-void CCWlShellSurface::setConfigure(F<void(CCWlShellSurface*, enum wl_shell_surface_resize, int32_t, int32_t)> handler) {
+void CCWlShellSurface::setConfigure(
+ F<void(CCWlShellSurface*, enum wl_shell_surface_resize, int32_t, int32_t)> handler) {
requests.configure = handler;
}
-void CCWlShellSurface::setPopupDone(F<void(CCWlShellSurface*)> handler) {
- requests.popupDone = handler;
-}
+void CCWlShellSurface::setPopupDone(F<void(CCWlShellSurface*)> handler) { requests.popupDone = handler; }
static void _CWlSurfaceEnter(void* data, void* resource, wl_proxy* output) {
const auto PO = (CCWlSurface*)data;
@@ -1273,7 +1342,8 @@ void CCWlSurface::sendAttach(CCWlBuffer* buffer, int32_t x, int32_t y) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, buffer ? buffer->pResource : nullptr, x, y);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, buffer ? buffer->pResource : nullptr, x, y);
proxy;
}
@@ -1289,7 +1359,8 @@ wl_proxy* CCWlSurface::sendFrame() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 3, &wl_callback_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 3, &wl_callback_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -1298,7 +1369,8 @@ void CCWlSurface::sendSetOpaqueRegion(CCWlRegion* region) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 4, nullptr, wl_proxy_get_version(pResource), 0, region ? region->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 4, nullptr, wl_proxy_get_version(pResource), 0, region ? region->pResource : nullptr);
proxy;
}
@@ -1306,7 +1378,8 @@ void CCWlSurface::sendSetInputRegion(CCWlRegion* region) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 5, nullptr, wl_proxy_get_version(pResource), 0, region ? region->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 5, nullptr, wl_proxy_get_version(pResource), 0, region ? region->pResource : nullptr);
proxy;
}
@@ -1399,30 +1472,33 @@ static const wl_interface* _CWlSurfacePreferredBufferTransformTypes[] = {
};
static const wl_message _CWlSurfaceRequests[] = {
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "attach", .signature = "?oii", .types = _CWlSurfaceAttachTypes + 0},
- { .name = "damage", .signature = "iiii", .types = _CWlSurfaceDamageTypes + 0},
- { .name = "frame", .signature = "n", .types = _CWlSurfaceFrameTypes + 0},
- { .name = "set_opaque_region", .signature = "?o", .types = _CWlSurfaceSetOpaqueRegionTypes + 0},
- { .name = "set_input_region", .signature = "?o", .types = _CWlSurfaceSetInputRegionTypes + 0},
- { .name = "commit", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "set_buffer_transform", .signature = "2i", .types = _CWlSurfaceSetBufferTransformTypes + 0},
- { .name = "set_buffer_scale", .signature = "3i", .types = _CWlSurfaceSetBufferScaleTypes + 0},
- { .name = "damage_buffer", .signature = "4iiii", .types = _CWlSurfaceDamageBufferTypes + 0},
- { .name = "offset", .signature = "5ii", .types = _CWlSurfaceOffsetTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "attach", .signature = "?oii", .types = _CWlSurfaceAttachTypes + 0},
+ {.name = "damage", .signature = "iiii", .types = _CWlSurfaceDamageTypes + 0},
+ {.name = "frame", .signature = "n", .types = _CWlSurfaceFrameTypes + 0},
+ {.name = "set_opaque_region", .signature = "?o", .types = _CWlSurfaceSetOpaqueRegionTypes + 0},
+ {.name = "set_input_region", .signature = "?o", .types = _CWlSurfaceSetInputRegionTypes + 0},
+ {.name = "commit", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "set_buffer_transform", .signature = "2i", .types = _CWlSurfaceSetBufferTransformTypes + 0},
+ {.name = "set_buffer_scale", .signature = "3i", .types = _CWlSurfaceSetBufferScaleTypes + 0},
+ {.name = "damage_buffer", .signature = "4iiii", .types = _CWlSurfaceDamageBufferTypes + 0},
+ {.name = "offset", .signature = "5ii", .types = _CWlSurfaceOffsetTypes + 0},
};
static const wl_message _CWlSurfaceEvents[] = {
- { .name = "enter", .signature = "o", .types = _CWlSurfaceEnterTypes + 0},
- { .name = "leave", .signature = "o", .types = _CWlSurfaceLeaveTypes + 0},
- { .name = "preferred_buffer_scale", .signature = "6i", .types = _CWlSurfacePreferredBufferScaleTypes + 0},
- { .name = "preferred_buffer_transform", .signature = "6u", .types = _CWlSurfacePreferredBufferTransformTypes + 0},
+ {.name = "enter", .signature = "o", .types = _CWlSurfaceEnterTypes + 0},
+ {.name = "leave", .signature = "o", .types = _CWlSurfaceLeaveTypes + 0},
+ {.name = "preferred_buffer_scale", .signature = "6i", .types = _CWlSurfacePreferredBufferScaleTypes + 0},
+ {.name = "preferred_buffer_transform", .signature = "6u", .types = _CWlSurfacePreferredBufferTransformTypes + 0},
};
const wl_interface wl_surface_interface = {
- .name = "wl_surface", .version = 6,
- .method_count = 11, .methods = _CWlSurfaceRequests,
- .event_count = 4, .events = _CWlSurfaceEvents,
+ .name = "wl_surface",
+ .version = 6,
+ .method_count = 11,
+ .methods = _CWlSurfaceRequests,
+ .event_count = 4,
+ .events = _CWlSurfaceEvents,
};
CCWlSurface::CCWlSurface(wl_proxy* resource) : pResource(resource) {
@@ -1438,13 +1514,9 @@ CCWlSurface::~CCWlSurface() {
sendDestroy();
}
-void CCWlSurface::setEnter(F<void(CCWlSurface*, wl_proxy*)> handler) {
- requests.enter = handler;
-}
+void CCWlSurface::setEnter(F<void(CCWlSurface*, wl_proxy*)> handler) { requests.enter = handler; }
-void CCWlSurface::setLeave(F<void(CCWlSurface*, wl_proxy*)> handler) {
- requests.leave = handler;
-}
+void CCWlSurface::setLeave(F<void(CCWlSurface*, wl_proxy*)> handler) { requests.leave = handler; }
void CCWlSurface::setPreferredBufferScale(F<void(CCWlSurface*, int32_t)> handler) {
requests.preferredBufferScale = handler;
@@ -1475,7 +1547,8 @@ wl_proxy* CCWlSeat::sendGetPointer() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &wl_pointer_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 0, &wl_pointer_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -1484,7 +1557,8 @@ wl_proxy* CCWlSeat::sendGetKeyboard() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &wl_keyboard_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy =
+ wl_proxy_marshal_flags(pResource, 1, &wl_keyboard_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -1523,21 +1597,24 @@ static const wl_interface* _CWlSeatNameTypes[] = {
};
static const wl_message _CWlSeatRequests[] = {
- { .name = "get_pointer", .signature = "n", .types = _CWlSeatGetPointerTypes + 0},
- { .name = "get_keyboard", .signature = "n", .types = _CWlSeatGetKeyboardTypes + 0},
- { .name = "get_touch", .signature = "n", .types = _CWlSeatGetTouchTypes + 0},
- { .name = "release", .signature = "5", .types = wayland_dummyTypes + 0},
+ {.name = "get_pointer", .signature = "n", .types = _CWlSeatGetPointerTypes + 0},
+ {.name = "get_keyboard", .signature = "n", .types = _CWlSeatGetKeyboardTypes + 0},
+ {.name = "get_touch", .signature = "n", .types = _CWlSeatGetTouchTypes + 0},
+ {.name = "release", .signature = "5", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlSeatEvents[] = {
- { .name = "capabilities", .signature = "u", .types = _CWlSeatCapabilitiesTypes + 0},
- { .name = "name", .signature = "2s", .types = _CWlSeatNameTypes + 0},
+ {.name = "capabilities", .signature = "u", .types = _CWlSeatCapabilitiesTypes + 0},
+ {.name = "name", .signature = "2s", .types = _CWlSeatNameTypes + 0},
};
const wl_interface wl_seat_interface = {
- .name = "wl_seat", .version = 10,
- .method_count = 4, .methods = _CWlSeatRequests,
- .event_count = 2, .events = _CWlSeatEvents,
+ .name = "wl_seat",
+ .version = 10,
+ .method_count = 4,
+ .methods = _CWlSeatRequests,
+ .event_count = 2,
+ .events = _CWlSeatEvents,
};
CCWlSeat::CCWlSeat(wl_proxy* resource) : pResource(resource) {
@@ -1553,15 +1630,12 @@ CCWlSeat::~CCWlSeat() {
sendRelease();
}
-void CCWlSeat::setCapabilities(F<void(CCWlSeat*, enum wl_seat_capability)> handler) {
- requests.capabilities = handler;
-}
+void CCWlSeat::setCapabilities(F<void(CCWlSeat*, enum wl_seat_capability)> handler) { requests.capabilities = handler; }
-void CCWlSeat::setName(F<void(CCWlSeat*, const char*)> handler) {
- requests.name = handler;
-}
+void CCWlSeat::setName(F<void(CCWlSeat*, const char*)> handler) { requests.name = handler; }
-static void _CWlPointerEnter(void* data, void* resource, uint32_t serial, wl_proxy* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
+static void _CWlPointerEnter(
+ void* data, void* resource, uint32_t serial, wl_proxy* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
const auto PO = (CCWlPointer*)data;
if (PO && PO->requests.enter)
PO->requests.enter(PO, serial, surface, surface_x, surface_y);
@@ -1579,7 +1653,8 @@ static void _CWlPointerMotion(void* data, void* resource, uint32_t time, wl_fixe
PO->requests.motion(PO, time, surface_x, surface_y);
}
-static void _CWlPointerButton(void* data, void* resource, uint32_t serial, uint32_t time, uint32_t button, enum wl_pointer_button_state state) {
+static void _CWlPointerButton(
+ void* data, void* resource, uint32_t serial, uint32_t time, uint32_t button, enum wl_pointer_button_state state) {
const auto PO = (CCWlPointer*)data;
if (PO && PO->requests.button)
PO->requests.button(PO, serial, time, button, state);
@@ -1621,7 +1696,10 @@ static void _CWlPointerAxisValue120(void* data, void* resource, enum wl_pointer_
PO->requests.axisValue120(PO, axis, value120);
}
-static void _CWlPointerAxisRelativeDirection(void* data, void* resource, enum wl_pointer_axis axis, enum wl_pointer_axis_relative_direction direction) {
+static void _CWlPointerAxisRelativeDirection(void* data,
+ void* resource,
+ enum wl_pointer_axis axis,
+ enum wl_pointer_axis_relative_direction direction) {
const auto PO = (CCWlPointer*)data;
if (PO && PO->requests.axisRelativeDirection)
PO->requests.axisRelativeDirection(PO, axis, direction);
@@ -1645,7 +1723,15 @@ void CCWlPointer::sendSetCursor(uint32_t serial, CCWlSurface* surface, int32_t h
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, nullptr, wl_proxy_get_version(pResource), 0, serial, surface ? surface->pResource : nullptr, hotspot_x, hotspot_y);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 0,
+ nullptr,
+ wl_proxy_get_version(pResource),
+ 0,
+ serial,
+ surface ? surface->pResource : nullptr,
+ hotspot_x,
+ hotspot_y);
proxy;
}
@@ -1710,28 +1796,31 @@ static const wl_interface* _CWlPointerAxisRelativeDirectionTypes[] = {
};
static const wl_message _CWlPointerRequests[] = {
- { .name = "set_cursor", .signature = "u?oii", .types = _CWlPointerSetCursorTypes + 0},
- { .name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "set_cursor", .signature = "u?oii", .types = _CWlPointerSetCursorTypes + 0},
+ {.name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlPointerEvents[] = {
- { .name = "enter", .signature = "uoff", .types = _CWlPointerEnterTypes + 0},
- { .name = "leave", .signature = "uo", .types = _CWlPointerLeaveTypes + 0},
- { .name = "motion", .signature = "uff", .types = _CWlPointerMotionTypes + 0},
- { .name = "button", .signature = "uuuu", .types = _CWlPointerButtonTypes + 0},
- { .name = "axis", .signature = "uuf", .types = _CWlPointerAxisTypes + 0},
- { .name = "frame", .signature = "5", .types = wayland_dummyTypes + 0},
- { .name = "axis_source", .signature = "5u", .types = _CWlPointerAxisSourceTypes + 0},
- { .name = "axis_stop", .signature = "5uu", .types = _CWlPointerAxisStopTypes + 0},
- { .name = "axis_discrete", .signature = "5ui", .types = _CWlPointerAxisDiscreteTypes + 0},
- { .name = "axis_value120", .signature = "8ui", .types = _CWlPointerAxisValue120Types + 0},
- { .name = "axis_relative_direction", .signature = "9uu", .types = _CWlPointerAxisRelativeDirectionTypes + 0},
+ {.name = "enter", .signature = "uoff", .types = _CWlPointerEnterTypes + 0},
+ {.name = "leave", .signature = "uo", .types = _CWlPointerLeaveTypes + 0},
+ {.name = "motion", .signature = "uff", .types = _CWlPointerMotionTypes + 0},
+ {.name = "button", .signature = "uuuu", .types = _CWlPointerButtonTypes + 0},
+ {.name = "axis", .signature = "uuf", .types = _CWlPointerAxisTypes + 0},
+ {.name = "frame", .signature = "5", .types = wayland_dummyTypes + 0},
+ {.name = "axis_source", .signature = "5u", .types = _CWlPointerAxisSourceTypes + 0},
+ {.name = "axis_stop", .signature = "5uu", .types = _CWlPointerAxisStopTypes + 0},
+ {.name = "axis_discrete", .signature = "5ui", .types = _CWlPointerAxisDiscreteTypes + 0},
+ {.name = "axis_value120", .signature = "8ui", .types = _CWlPointerAxisValue120Types + 0},
+ {.name = "axis_relative_direction", .signature = "9uu", .types = _CWlPointerAxisRelativeDirectionTypes + 0},
};
const wl_interface wl_pointer_interface = {
- .name = "wl_pointer", .version = 10,
- .method_count = 2, .methods = _CWlPointerRequests,
- .event_count = 11, .events = _CWlPointerEvents,
+ .name = "wl_pointer",
+ .version = 10,
+ .method_count = 2,
+ .methods = _CWlPointerRequests,
+ .event_count = 11,
+ .events = _CWlPointerEvents,
};
CCWlPointer::CCWlPointer(wl_proxy* resource) : pResource(resource) {
@@ -1751,9 +1840,7 @@ void CCWlPointer::setEnter(F<void(CCWlPointer*, uint32_t, wl_proxy*, wl_fixed_t,
requests.enter = handler;
}
-void CCWlPointer::setLeave(F<void(CCWlPointer*, uint32_t, wl_proxy*)> handler) {
- requests.leave = handler;
-}
+void CCWlPointer::setLeave(F<void(CCWlPointer*, uint32_t, wl_proxy*)> handler) { requests.leave = handler; }
void CCWlPointer::setMotion(F<void(CCWlPointer*, uint32_t, wl_fixed_t, wl_fixed_t)> handler) {
requests.motion = handler;
@@ -1767,9 +1854,7 @@ void CCWlPointer::setAxis(F<void(CCWlPointer*, uint32_t, enum wl_pointer_axis, w
requests.axis = handler;
}
-void CCWlPointer::setFrame(F<void(CCWlPointer*)> handler) {
- requests.frame = handler;
-}
+void CCWlPointer::setFrame(F<void(CCWlPointer*)> handler) { requests.frame = handler; }
void CCWlPointer::setAxisSource(F<void(CCWlPointer*, enum wl_pointer_axis_source)> handler) {
requests.axisSource = handler;
@@ -1787,11 +1872,13 @@ void CCWlPointer::setAxisValue120(F<void(CCWlPointer*, enum wl_pointer_axis, int
requests.axisValue120 = handler;
}
-void CCWlPointer::setAxisRelativeDirection(F<void(CCWlPointer*, enum wl_pointer_axis, enum wl_pointer_axis_relative_direction)> handler) {
+void CCWlPointer::setAxisRelativeDirection(
+ F<void(CCWlPointer*, enum wl_pointer_axis, enum wl_pointer_axis_relative_direction)> handler) {
requests.axisRelativeDirection = handler;
}
-static void _CWlKeyboardKeymap(void* data, void* resource, enum wl_keyboard_keymap_format format, int32_t fd, uint32_t size) {
+static void
+ _CWlKeyboardKeymap(void* data, void* resource, enum wl_keyboard_keymap_format format, int32_t fd, uint32_t size) {
const auto PO = (CCWlKeyboard*)data;
if (PO && PO->requests.keymap)
PO->requests.keymap(PO, format, fd, size);
@@ -1809,13 +1896,20 @@ static void _CWlKeyboardLeave(void* data, void* resource, uint32_t serial, wl_pr
PO->requests.leave(PO, serial, surface);
}
-static void _CWlKeyboardKey(void* data, void* resource, uint32_t serial, uint32_t time, uint32_t key, enum wl_keyboard_key_state state) {
+static void _CWlKeyboardKey(
+ void* data, void* resource, uint32_t serial, uint32_t time, uint32_t key, enum wl_keyboard_key_state state) {
const auto PO = (CCWlKeyboard*)data;
if (PO && PO->requests.key)
PO->requests.key(PO, serial, time, key, state);
}
-static void _CWlKeyboardModifiers(void* data, void* resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) {
+static void _CWlKeyboardModifiers(void* data,
+ void* resource,
+ uint32_t serial,
+ uint32_t mods_depressed,
+ uint32_t mods_latched,
+ uint32_t mods_locked,
+ uint32_t group) {
const auto PO = (CCWlKeyboard*)data;
if (PO && PO->requests.modifiers)
PO->requests.modifiers(PO, serial, mods_depressed, mods_latched, mods_locked, group);
@@ -1877,22 +1971,25 @@ static const wl_interface* _CWlKeyboardRepeatInfoTypes[] = {
};
static const wl_message _CWlKeyboardRequests[] = {
- { .name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlKeyboardEvents[] = {
- { .name = "keymap", .signature = "uhu", .types = _CWlKeyboardKeymapTypes + 0},
- { .name = "enter", .signature = "uoa", .types = _CWlKeyboardEnterTypes + 0},
- { .name = "leave", .signature = "uo", .types = _CWlKeyboardLeaveTypes + 0},
- { .name = "key", .signature = "uuuu", .types = _CWlKeyboardKeyTypes + 0},
- { .name = "modifiers", .signature = "uuuuu", .types = _CWlKeyboardModifiersTypes + 0},
- { .name = "repeat_info", .signature = "4ii", .types = _CWlKeyboardRepeatInfoTypes + 0},
+ {.name = "keymap", .signature = "uhu", .types = _CWlKeyboardKeymapTypes + 0},
+ {.name = "enter", .signature = "uoa", .types = _CWlKeyboardEnterTypes + 0},
+ {.name = "leave", .signature = "uo", .types = _CWlKeyboardLeaveTypes + 0},
+ {.name = "key", .signature = "uuuu", .types = _CWlKeyboardKeyTypes + 0},
+ {.name = "modifiers", .signature = "uuuuu", .types = _CWlKeyboardModifiersTypes + 0},
+ {.name = "repeat_info", .signature = "4ii", .types = _CWlKeyboardRepeatInfoTypes + 0},
};
const wl_interface wl_keyboard_interface = {
- .name = "wl_keyboard", .version = 10,
- .method_count = 1, .methods = _CWlKeyboardRequests,
- .event_count = 6, .events = _CWlKeyboardEvents,
+ .name = "wl_keyboard",
+ .version = 10,
+ .method_count = 1,
+ .methods = _CWlKeyboardRequests,
+ .event_count = 6,
+ .events = _CWlKeyboardEvents,
};
CCWlKeyboard::CCWlKeyboard(wl_proxy* resource) : pResource(resource) {
@@ -1916,9 +2013,7 @@ void CCWlKeyboard::setEnter(F<void(CCWlKeyboard*, uint32_t, wl_proxy*, wl_array*
requests.enter = handler;
}
-void CCWlKeyboard::setLeave(F<void(CCWlKeyboard*, uint32_t, wl_proxy*)> handler) {
- requests.leave = handler;
-}
+void CCWlKeyboard::setLeave(F<void(CCWlKeyboard*, uint32_t, wl_proxy*)> handler) { requests.leave = handler; }
void CCWlKeyboard::setKey(F<void(CCWlKeyboard*, uint32_t, uint32_t, uint32_t, enum wl_keyboard_key_state)> handler) {
requests.key = handler;
@@ -1928,11 +2023,16 @@ void CCWlKeyboard::setModifiers(F<void(CCWlKeyboard*, uint32_t, uint32_t, uint32
requests.modifiers = handler;
}
-void CCWlKeyboard::setRepeatInfo(F<void(CCWlKeyboard*, int32_t, int32_t)> handler) {
- requests.repeatInfo = handler;
-}
+void CCWlKeyboard::setRepeatInfo(F<void(CCWlKeyboard*, int32_t, int32_t)> handler) { requests.repeatInfo = handler; }
-static void _CWlTouchDown(void* data, void* resource, uint32_t serial, uint32_t time, wl_proxy* surface, int32_t id, wl_fixed_t x, wl_fixed_t y) {
+static void _CWlTouchDown(void* data,
+ void* resource,
+ uint32_t serial,
+ uint32_t time,
+ wl_proxy* surface,
+ int32_t id,
+ wl_fixed_t x,
+ wl_fixed_t y) {
const auto PO = (CCWlTouch*)data;
if (PO && PO->requests.down)
PO->requests.down(PO, serial, time, surface, id, x, y);
@@ -2022,23 +2122,26 @@ static const wl_interface* _CWlTouchOrientationTypes[] = {
};
static const wl_message _CWlTouchRequests[] = {
- { .name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlTouchEvents[] = {
- { .name = "down", .signature = "uuoiff", .types = _CWlTouchDownTypes + 0},
- { .name = "up", .signature = "uui", .types = _CWlTouchUpTypes + 0},
- { .name = "motion", .signature = "uiff", .types = _CWlTouchMotionTypes + 0},
- { .name = "frame", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "cancel", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "shape", .signature = "6iff", .types = _CWlTouchShapeTypes + 0},
- { .name = "orientation", .signature = "6if", .types = _CWlTouchOrientationTypes + 0},
+ {.name = "down", .signature = "uuoiff", .types = _CWlTouchDownTypes + 0},
+ {.name = "up", .signature = "uui", .types = _CWlTouchUpTypes + 0},
+ {.name = "motion", .signature = "uiff", .types = _CWlTouchMotionTypes + 0},
+ {.name = "frame", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "cancel", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "shape", .signature = "6iff", .types = _CWlTouchShapeTypes + 0},
+ {.name = "orientation", .signature = "6if", .types = _CWlTouchOrientationTypes + 0},
};
const wl_interface wl_touch_interface = {
- .name = "wl_touch", .version = 10,
- .method_count = 1, .methods = _CWlTouchRequests,
- .event_count = 7, .events = _CWlTouchEvents,
+ .name = "wl_touch",
+ .version = 10,
+ .method_count = 1,
+ .methods = _CWlTouchRequests,
+ .event_count = 7,
+ .events = _CWlTouchEvents,
};
CCWlTouch::CCWlTouch(wl_proxy* resource) : pResource(resource) {
@@ -2058,37 +2161,37 @@ void CCWlTouch::setDown(F<void(CCWlTouch*, uint32_t, uint32_t, wl_proxy*, int32_
requests.down = handler;
}
-void CCWlTouch::setUp(F<void(CCWlTouch*, uint32_t, uint32_t, int32_t)> handler) {
- requests.up = handler;
-}
+void CCWlTouch::setUp(F<void(CCWlTouch*, uint32_t, uint32_t, int32_t)> handler) { requests.up = handler; }
void CCWlTouch::setMotion(F<void(CCWlTouch*, uint32_t, int32_t, wl_fixed_t, wl_fixed_t)> handler) {
requests.motion = handler;
}
-void CCWlTouch::setFrame(F<void(CCWlTouch*)> handler) {
- requests.frame = handler;
-}
+void CCWlTouch::setFrame(F<void(CCWlTouch*)> handler) { requests.frame = handler; }
-void CCWlTouch::setCancel(F<void(CCWlTouch*)> handler) {
- requests.cancel = handler;
-}
+void CCWlTouch::setCancel(F<void(CCWlTouch*)> handler) { requests.cancel = handler; }
-void CCWlTouch::setShape(F<void(CCWlTouch*, int32_t, wl_fixed_t, wl_fixed_t)> handler) {
- requests.shape = handler;
-}
+void CCWlTouch::setShape(F<void(CCWlTouch*, int32_t, wl_fixed_t, wl_fixed_t)> handler) { requests.shape = handler; }
-void CCWlTouch::setOrientation(F<void(CCWlTouch*, int32_t, wl_fixed_t)> handler) {
- requests.orientation = handler;
-}
+void CCWlTouch::setOrientation(F<void(CCWlTouch*, int32_t, wl_fixed_t)> handler) { requests.orientation = handler; }
-static void _CWlOutputGeometry(void* data, void* resource, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char* make, const char* model, int32_t transform) {
+static void _CWlOutputGeometry(void* data,
+ void* resource,
+ int32_t x,
+ int32_t y,
+ int32_t physical_width,
+ int32_t physical_height,
+ int32_t subpixel,
+ const char* make,
+ const char* model,
+ int32_t transform) {
const auto PO = (CCWlOutput*)data;
if (PO && PO->requests.geometry)
PO->requests.geometry(PO, x, y, physical_width, physical_height, subpixel, make, model, transform);
}
-static void _CWlOutputMode(void* data, void* resource, enum wl_output_mode flags, int32_t width, int32_t height, int32_t refresh) {
+static void _CWlOutputMode(
+ void* data, void* resource, enum wl_output_mode flags, int32_t width, int32_t height, int32_t refresh) {
const auto PO = (CCWlOutput*)data;
if (PO && PO->requests.mode)
PO->requests.mode(PO, flags, width, height, refresh);
@@ -2162,22 +2265,25 @@ static const wl_interface* _CWlOutputDescriptionTypes[] = {
};
static const wl_message _CWlOutputRequests[] = {
- { .name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
+ {.name = "release", .signature = "3", .types = wayland_dummyTypes + 0},
};
static const wl_message _CWlOutputEvents[] = {
- { .name = "geometry", .signature = "iiiiissi", .types = _CWlOutputGeometryTypes + 0},
- { .name = "mode", .signature = "uiii", .types = _CWlOutputModeTypes + 0},
- { .name = "done", .signature = "2", .types = wayland_dummyTypes + 0},
- { .name = "scale", .signature = "2i", .types = _CWlOutputScaleTypes + 0},
- { .name = "name", .signature = "4s", .types = _CWlOutputNameTypes + 0},
- { .name = "description", .signature = "4s", .types = _CWlOutputDescriptionTypes + 0},
+ {.name = "geometry", .signature = "iiiiissi", .types = _CWlOutputGeometryTypes + 0},
+ {.name = "mode", .signature = "uiii", .types = _CWlOutputModeTypes + 0},
+ {.name = "done", .signature = "2", .types = wayland_dummyTypes + 0},
+ {.name = "scale", .signature = "2i", .types = _CWlOutputScaleTypes + 0},
+ {.name = "name", .signature = "4s", .types = _CWlOutputNameTypes + 0},
+ {.name = "description", .signature = "4s", .types = _CWlOutputDescriptionTypes + 0},
};
const wl_interface wl_output_interface = {
- .name = "wl_output", .version = 4,
- .method_count = 1, .methods = _CWlOutputRequests,
- .event_count = 6, .events = _CWlOutputEvents,
+ .name = "wl_output",
+ .version = 4,
+ .method_count = 1,
+ .methods = _CWlOutputRequests,
+ .event_count = 6,
+ .events = _CWlOutputEvents,
};
CCWlOutput::CCWlOutput(wl_proxy* resource) : pResource(resource) {
@@ -2193,7 +2299,8 @@ CCWlOutput::~CCWlOutput() {
sendRelease();
}
-void CCWlOutput::setGeometry(F<void(CCWlOutput*, int32_t, int32_t, int32_t, int32_t, int32_t, const char*, const char*, int32_t)> handler) {
+void CCWlOutput::setGeometry(
+ F<void(CCWlOutput*, int32_t, int32_t, int32_t, int32_t, int32_t, const char*, const char*, int32_t)> handler) {
requests.geometry = handler;
}
@@ -2201,21 +2308,13 @@ void CCWlOutput::setMode(F<void(CCWlOutput*, enum wl_output_mode, int32_t, int32
requests.mode = handler;
}
-void CCWlOutput::setDone(F<void(CCWlOutput*)> handler) {
- requests.done = handler;
-}
+void CCWlOutput::setDone(F<void(CCWlOutput*)> handler) { requests.done = handler; }
-void CCWlOutput::setScale(F<void(CCWlOutput*, int32_t)> handler) {
- requests.scale = handler;
-}
+void CCWlOutput::setScale(F<void(CCWlOutput*, int32_t)> handler) { requests.scale = handler; }
-void CCWlOutput::setName(F<void(CCWlOutput*, const char*)> handler) {
- requests.name = handler;
-}
+void CCWlOutput::setName(F<void(CCWlOutput*, const char*)> handler) { requests.name = handler; }
-void CCWlOutput::setDescription(F<void(CCWlOutput*, const char*)> handler) {
- requests.description = handler;
-}
+void CCWlOutput::setDescription(F<void(CCWlOutput*, const char*)> handler) { requests.description = handler; }
static const void* _CCWlRegionVTable[] = {
nullptr,
@@ -2259,15 +2358,18 @@ static const wl_interface* _CWlRegionSubtractTypes[] = {
};
static const wl_message _CWlRegionRequests[] = {
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "add", .signature = "iiii", .types = _CWlRegionAddTypes + 0},
- { .name = "subtract", .signature = "iiii", .types = _CWlRegionSubtractTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "add", .signature = "iiii", .types = _CWlRegionAddTypes + 0},
+ {.name = "subtract", .signature = "iiii", .types = _CWlRegionSubtractTypes + 0},
};
const wl_interface wl_region_interface = {
- .name = "wl_region", .version = 1,
- .method_count = 3, .methods = _CWlRegionRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_region",
+ .version = 1,
+ .method_count = 3,
+ .methods = _CWlRegionRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlRegion::CCWlRegion(wl_proxy* resource) : pResource(resource) {
@@ -2300,7 +2402,14 @@ wl_proxy* CCWlSubcompositor::sendGetSubsurface(CCWlSurface* surface, CCWlSurface
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &wl_subsurface_interface, wl_proxy_get_version(pResource), 0, nullptr, surface ? surface->pResource : nullptr, parent ? parent->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(pResource,
+ 1,
+ &wl_subsurface_interface,
+ wl_proxy_get_version(pResource),
+ 0,
+ nullptr,
+ surface ? surface->pResource : nullptr,
+ parent ? parent->pResource : nullptr);
return proxy;
}
@@ -2311,14 +2420,17 @@ static const wl_interface* _CWlSubcompositorGetSubsurfaceTypes[] = {
};
static const wl_message _CWlSubcompositorRequests[] = {
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "get_subsurface", .signature = "noo", .types = _CWlSubcompositorGetSubsurfaceTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "get_subsurface", .signature = "noo", .types = _CWlSubcompositorGetSubsurfaceTypes + 0},
};
const wl_interface wl_subcompositor_interface = {
- .name = "wl_subcompositor", .version = 1,
- .method_count = 2, .methods = _CWlSubcompositorRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_subcompositor",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CWlSubcompositorRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlSubcompositor::CCWlSubcompositor(wl_proxy* resource) : pResource(resource) {
@@ -2359,7 +2471,8 @@ void CCWlSubsurface::sendPlaceAbove(CCWlSurface* sibling) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, sibling ? sibling->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, sibling ? sibling->pResource : nullptr);
proxy;
}
@@ -2367,7 +2480,8 @@ void CCWlSubsurface::sendPlaceBelow(CCWlSurface* sibling) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 3, nullptr, wl_proxy_get_version(pResource), 0, sibling ? sibling->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 3, nullptr, wl_proxy_get_version(pResource), 0, sibling ? sibling->pResource : nullptr);
proxy;
}
@@ -2398,18 +2512,21 @@ static const wl_interface* _CWlSubsurfacePlaceBelowTypes[] = {
};
static const wl_message _CWlSubsurfaceRequests[] = {
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "set_position", .signature = "ii", .types = _CWlSubsurfaceSetPositionTypes + 0},
- { .name = "place_above", .signature = "o", .types = _CWlSubsurfacePlaceAboveTypes + 0},
- { .name = "place_below", .signature = "o", .types = _CWlSubsurfacePlaceBelowTypes + 0},
- { .name = "set_sync", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "set_desync", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "set_position", .signature = "ii", .types = _CWlSubsurfaceSetPositionTypes + 0},
+ {.name = "place_above", .signature = "o", .types = _CWlSubsurfacePlaceAboveTypes + 0},
+ {.name = "place_below", .signature = "o", .types = _CWlSubsurfacePlaceBelowTypes + 0},
+ {.name = "set_sync", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "set_desync", .signature = "", .types = wayland_dummyTypes + 0},
};
const wl_interface wl_subsurface_interface = {
- .name = "wl_subsurface", .version = 1,
- .method_count = 6, .methods = _CWlSubsurfaceRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_subsurface",
+ .version = 1,
+ .method_count = 6,
+ .methods = _CWlSubsurfaceRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlSubsurface::CCWlSubsurface(wl_proxy* resource) : pResource(resource) {
@@ -2442,7 +2559,8 @@ void CCWlFixes::sendDestroyRegistry(CCWlRegistry* registry) {
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, registry ? registry->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 1, nullptr, wl_proxy_get_version(pResource), 0, registry ? registry->pResource : nullptr);
proxy;
}
static const wl_interface* _CWlFixesDestroyRegistryTypes[] = {
@@ -2450,14 +2568,17 @@ static const wl_interface* _CWlFixesDestroyRegistryTypes[] = {
};
static const wl_message _CWlFixesRequests[] = {
- { .name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
- { .name = "destroy_registry", .signature = "o", .types = _CWlFixesDestroyRegistryTypes + 0},
+ {.name = "destroy", .signature = "", .types = wayland_dummyTypes + 0},
+ {.name = "destroy_registry", .signature = "o", .types = _CWlFixesDestroyRegistryTypes + 0},
};
const wl_interface wl_fixes_interface = {
- .name = "wl_fixes", .version = 1,
- .method_count = 2, .methods = _CWlFixesRequests,
- .event_count = 0, .events = nullptr,
+ .name = "wl_fixes",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CWlFixesRequests,
+ .event_count = 0,
+ .events = nullptr,
};
CCWlFixes::CCWlFixes(wl_proxy* resource) : pResource(resource) {
diff --git a/src/core/src/wayland_protocols/wlr-data-control-unstable-v1.cpp b/src/core/src/wayland_protocols/wlr-data-control-unstable-v1.cpp
index b37236a..21f0c13 100644
--- a/src/core/src/wayland_protocols/wlr-data-control-unstable-v1.cpp
+++ b/src/core/src/wayland_protocols/wlr-data-control-unstable-v1.cpp
@@ -28,7 +28,7 @@
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
-
+
*/
#define private public
@@ -37,7 +37,7 @@
#undef private
#define F std::function
-static const wl_interface* wlrDataControlUnstableV1_dummyTypes[] = { nullptr };
+static const wl_interface* wlrDataControlUnstableV1_dummyTypes[] = {nullptr};
// Reference all other interfaces.
// The reason why this is in snake is to
@@ -57,7 +57,8 @@ wl_proxy* CCZwlrDataControlManagerV1::sendCreateDataSource() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &zwlr_data_control_source_v1_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 0, &zwlr_data_control_source_v1_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -66,7 +67,8 @@ wl_proxy* CCZwlrDataControlManagerV1::sendGetDataDevice(wl_proxy* seat) {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &zwlr_data_control_device_v1_interface, wl_proxy_get_version(pResource), 0, nullptr, seat);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 1, &zwlr_data_control_device_v1_interface, wl_proxy_get_version(pResource), 0, nullptr, seat);
return proxy;
}
@@ -88,15 +90,18 @@ static const wl_interface* _CZwlrDataControlManagerV1GetDataDeviceTypes[] = {
};
static const wl_message _CZwlrDataControlManagerV1Requests[] = {
- { .name = "create_data_source", .signature = "n", .types = _CZwlrDataControlManagerV1CreateDataSourceTypes + 0},
- { .name = "get_data_device", .signature = "no", .types = _CZwlrDataControlManagerV1GetDataDeviceTypes + 0},
- { .name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
+ {.name = "create_data_source", .signature = "n", .types = _CZwlrDataControlManagerV1CreateDataSourceTypes + 0},
+ {.name = "get_data_device", .signature = "no", .types = _CZwlrDataControlManagerV1GetDataDeviceTypes + 0},
+ {.name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
};
const wl_interface zwlr_data_control_manager_v1_interface = {
- .name = "zwlr_data_control_manager_v1", .version = 2,
- .method_count = 3, .methods = _CZwlrDataControlManagerV1Requests,
- .event_count = 0, .events = nullptr,
+ .name = "zwlr_data_control_manager_v1",
+ .version = 2,
+ .method_count = 3,
+ .methods = _CZwlrDataControlManagerV1Requests,
+ .event_count = 0,
+ .events = nullptr,
};
CCZwlrDataControlManagerV1::CCZwlrDataControlManagerV1(wl_proxy* resource) : pResource(resource) {
@@ -147,7 +152,8 @@ void CCZwlrDataControlDeviceV1::sendSetSelection(CCZwlrDataControlSourceV1* sour
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 0, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
proxy;
}
@@ -164,7 +170,8 @@ void CCZwlrDataControlDeviceV1::sendSetPrimarySelection(CCZwlrDataControlSourceV
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
proxy;
}
static const wl_interface* _CZwlrDataControlDeviceV1SetSelectionTypes[] = {
@@ -184,22 +191,27 @@ static const wl_interface* _CZwlrDataControlDeviceV1PrimarySelectionTypes[] = {
};
static const wl_message _CZwlrDataControlDeviceV1Requests[] = {
- { .name = "set_selection", .signature = "?o", .types = _CZwlrDataControlDeviceV1SetSelectionTypes + 0},
- { .name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
- { .name = "set_primary_selection", .signature = "2?o", .types = _CZwlrDataControlDeviceV1SetPrimarySelectionTypes + 0},
+ {.name = "set_selection", .signature = "?o", .types = _CZwlrDataControlDeviceV1SetSelectionTypes + 0},
+ {.name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
+ {.name = "set_primary_selection",
+ .signature = "2?o",
+ .types = _CZwlrDataControlDeviceV1SetPrimarySelectionTypes + 0},
};
static const wl_message _CZwlrDataControlDeviceV1Events[] = {
- { .name = "data_offer", .signature = "n", .types = _CZwlrDataControlDeviceV1DataOfferTypes + 0},
- { .name = "selection", .signature = "?o", .types = _CZwlrDataControlDeviceV1SelectionTypes + 0},
- { .name = "finished", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
- { .name = "primary_selection", .signature = "2?o", .types = _CZwlrDataControlDeviceV1PrimarySelectionTypes + 0},
+ {.name = "data_offer", .signature = "n", .types = _CZwlrDataControlDeviceV1DataOfferTypes + 0},
+ {.name = "selection", .signature = "?o", .types = _CZwlrDataControlDeviceV1SelectionTypes + 0},
+ {.name = "finished", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
+ {.name = "primary_selection", .signature = "2?o", .types = _CZwlrDataControlDeviceV1PrimarySelectionTypes + 0},
};
const wl_interface zwlr_data_control_device_v1_interface = {
- .name = "zwlr_data_control_device_v1", .version = 2,
- .method_count = 3, .methods = _CZwlrDataControlDeviceV1Requests,
- .event_count = 4, .events = _CZwlrDataControlDeviceV1Events,
+ .name = "zwlr_data_control_device_v1",
+ .version = 2,
+ .method_count = 3,
+ .methods = _CZwlrDataControlDeviceV1Requests,
+ .event_count = 4,
+ .events = _CZwlrDataControlDeviceV1Events,
};
CCZwlrDataControlDeviceV1::CCZwlrDataControlDeviceV1(wl_proxy* resource) : pResource(resource) {
@@ -273,19 +285,22 @@ static const wl_interface* _CZwlrDataControlSourceV1SendTypes[] = {
};
static const wl_message _CZwlrDataControlSourceV1Requests[] = {
- { .name = "offer", .signature = "s", .types = _CZwlrDataControlSourceV1OfferTypes + 0},
- { .name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
+ {.name = "offer", .signature = "s", .types = _CZwlrDataControlSourceV1OfferTypes + 0},
+ {.name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
};
static const wl_message _CZwlrDataControlSourceV1Events[] = {
- { .name = "send", .signature = "sh", .types = _CZwlrDataControlSourceV1SendTypes + 0},
- { .name = "cancelled", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
+ {.name = "send", .signature = "sh", .types = _CZwlrDataControlSourceV1SendTypes + 0},
+ {.name = "cancelled", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
};
const wl_interface zwlr_data_control_source_v1_interface = {
- .name = "zwlr_data_control_source_v1", .version = 1,
- .method_count = 2, .methods = _CZwlrDataControlSourceV1Requests,
- .event_count = 2, .events = _CZwlrDataControlSourceV1Events,
+ .name = "zwlr_data_control_source_v1",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CZwlrDataControlSourceV1Requests,
+ .event_count = 2,
+ .events = _CZwlrDataControlSourceV1Events,
};
CCZwlrDataControlSourceV1::CCZwlrDataControlSourceV1(wl_proxy* resource) : pResource(resource) {
@@ -344,18 +359,21 @@ static const wl_interface* _CZwlrDataControlOfferV1OfferTypes[] = {
};
static const wl_message _CZwlrDataControlOfferV1Requests[] = {
- { .name = "receive", .signature = "sh", .types = _CZwlrDataControlOfferV1ReceiveTypes + 0},
- { .name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
+ {.name = "receive", .signature = "sh", .types = _CZwlrDataControlOfferV1ReceiveTypes + 0},
+ {.name = "destroy", .signature = "", .types = wlrDataControlUnstableV1_dummyTypes + 0},
};
static const wl_message _CZwlrDataControlOfferV1Events[] = {
- { .name = "offer", .signature = "s", .types = _CZwlrDataControlOfferV1OfferTypes + 0},
+ {.name = "offer", .signature = "s", .types = _CZwlrDataControlOfferV1OfferTypes + 0},
};
const wl_interface zwlr_data_control_offer_v1_interface = {
- .name = "zwlr_data_control_offer_v1", .version = 1,
- .method_count = 2, .methods = _CZwlrDataControlOfferV1Requests,
- .event_count = 1, .events = _CZwlrDataControlOfferV1Events,
+ .name = "zwlr_data_control_offer_v1",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CZwlrDataControlOfferV1Requests,
+ .event_count = 1,
+ .events = _CZwlrDataControlOfferV1Events,
};
CCZwlrDataControlOfferV1::CCZwlrDataControlOfferV1(wl_proxy* resource) : pResource(resource) {
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index 72ae161..694bc87 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -1,12 +1,12 @@
+#include "notification.hpp"
#include <csignal>
-#include <tether/log.hpp>
#include <nlohmann/json.hpp>
-#include "notification.hpp"
#include <tether/core.hpp>
#include <tether/crypto.hpp>
#include <tether/discovery.hpp>
#include <tether/event_loop.hpp>
#include <tether/file_transfer.hpp>
+#include <tether/log.hpp>
#include <tether/net.hpp>
#include <tether/wayland.hpp>
#include <unistd.h>
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
if (!discovery.publish(hostname, 5134, my_fp)) {
debug::log(ERR, "Warning: mDNS advertisement failed (is avahi-daemon running?)");
}
-
+
discovery.start_continuous_browse([](const std::vector<tether::DiscoveredDevice>& devices) {
nlohmann::json payload;
payload["command"] = "discovery_result";
diff --git a/src/daemon/notification.cpp b/src/daemon/notification.cpp
index ecb4acd..d07b7e8 100644
--- a/src/daemon/notification.cpp
+++ b/src/daemon/notification.cpp
@@ -4,183 +4,165 @@
#include <glib.h>
#include <libnotify/notify.h>
-#include <tether/log.hpp>
#include <string>
+#include <tether/log.hpp>
#include <thread>
namespace tether {
-namespace {
+ namespace {
-struct NotificationRequest {
- std::filesystem::path path;
-};
+ struct NotificationRequest {
+ std::filesystem::path path;
+ };
-struct NotificationActionData {
- std::string uri;
-};
+ struct NotificationActionData {
+ std::string uri;
+ };
-void free_request(gpointer data) {
- delete static_cast<NotificationRequest*>(data);
-}
+ void free_request(gpointer data) { delete static_cast<NotificationRequest*>(data); }
-void free_action_data(gpointer data) {
- delete static_cast<NotificationActionData*>(data);
-}
+ void free_action_data(gpointer data) { delete static_cast<NotificationActionData*>(data); }
-bool launch_uri(const std::string& uri) {
- GError* error = nullptr;
- gboolean ok = g_app_info_launch_default_for_uri(uri.c_str(), nullptr, &error);
- if (!ok) {
- debug::log(ERR, "Failed to open URI '{}'", uri);
- if (error) {
- debug::log(ERR, ": {}", error->message);
- g_error_free(error);
- }
- debug::log(ERR, "");
- return false;
- }
+ bool launch_uri(const std::string& uri) {
+ GError* error = nullptr;
+ gboolean ok = g_app_info_launch_default_for_uri(uri.c_str(), nullptr, &error);
+ if (!ok) {
+ debug::log(ERR, "Failed to open URI '{}'", uri);
+ if (error) {
+ debug::log(ERR, ": {}", error->message);
+ g_error_free(error);
+ }
+ debug::log(ERR, "");
+ return false;
+ }
- return true;
-}
+ return true;
+ }
-void on_notification_action(NotifyNotification*, char*, gpointer user_data) {
- auto* action = static_cast<NotificationActionData*>(user_data);
- if (!action) {
- return;
- }
+ void on_notification_action(NotifyNotification*, char*, gpointer user_data) {
+ auto* action = static_cast<NotificationActionData*>(user_data);
+ if (!action) {
+ return;
+ }
- launch_uri(action->uri);
-}
+ launch_uri(action->uri);
+ }
-void on_notification_closed(NotifyNotification* notification, gpointer) {
- g_object_unref(notification);
-}
+ void on_notification_closed(NotifyNotification* notification, gpointer) { g_object_unref(notification); }
+
+ gboolean show_notification_on_main(gpointer user_data) {
+ std::unique_ptr<NotificationRequest> request(static_cast<NotificationRequest*>(user_data));
+
+ auto file = std::filesystem::absolute(request->path);
+ auto file_string = file.string();
+ auto folder_string = file.parent_path().string();
+ auto file_uri = g_filename_to_uri(file_string.c_str(), nullptr, nullptr);
+ auto folder_uri = g_filename_to_uri(folder_string.c_str(), nullptr, nullptr);
+
+ if (!file_uri || !folder_uri) {
+ if (file_uri)
+ g_free(file_uri);
+ if (folder_uri)
+ g_free(folder_uri);
+ debug::log(ERR, "Failed to create notification URI for {}", file);
+ return G_SOURCE_REMOVE;
+ }
+
+ NotifyNotification* notification =
+ notify_notification_new("File arrived", file.filename().c_str(), "document-save");
+
+ notify_notification_set_hint(notification, "desktop-entry", g_variant_new_string("tether"));
+ notify_notification_set_hint(notification, "resident", g_variant_new_boolean(TRUE));
+ notify_notification_set_timeout(notification, 15000);
+
+ auto* open_file = new NotificationActionData{file_uri};
+ auto* open_folder = new NotificationActionData{folder_uri};
+
+ g_signal_connect(notification, "closed", G_CALLBACK(on_notification_closed), nullptr);
+ notify_notification_add_action(
+ notification, "open-file", "Open File", on_notification_action, open_file, free_action_data);
+ notify_notification_add_action(
+ notification, "open-folder", "Open Folder", on_notification_action, open_folder, free_action_data);
+
+ GError* error = nullptr;
+ gboolean shown = notify_notification_show(notification, &error);
+ if (!shown) {
+ debug::log(ERR, "Failed to show notification");
+ if (error) {
+ debug::log(ERR, ": {}", error->message);
+ g_error_free(error);
+ }
+ debug::log(ERR, "");
+ g_object_unref(notification);
+ }
+ g_free(file_uri);
+ g_free(folder_uri);
+ return G_SOURCE_REMOVE;
+ }
-gboolean show_notification_on_main(gpointer user_data) {
- std::unique_ptr<NotificationRequest> request(static_cast<NotificationRequest*>(user_data));
+ } // namespace
- auto file = std::filesystem::absolute(request->path);
- auto file_string = file.string();
- auto folder_string = file.parent_path().string();
- auto file_uri = g_filename_to_uri(file_string.c_str(), nullptr, nullptr);
- auto folder_uri = g_filename_to_uri(folder_string.c_str(), nullptr, nullptr);
+ struct FileArrivalNotifier::Impl {
+ GMainContext* context = nullptr;
+ GMainLoop* loop = nullptr;
+ std::thread thread;
+ bool initialized = false;
+ };
- if (!file_uri || !folder_uri) {
- if (file_uri) g_free(file_uri);
- if (folder_uri) g_free(folder_uri);
- debug::log(ERR, "Failed to create notification URI for {}", file);
- return G_SOURCE_REMOVE;
- }
+ FileArrivalNotifier::FileArrivalNotifier() : impl_(std::make_unique<Impl>()) {}
- NotifyNotification* notification = notify_notification_new(
- "File arrived",
- file.filename().c_str(),
- "document-save");
-
- notify_notification_set_hint(notification, "desktop-entry", g_variant_new_string("tether"));
- notify_notification_set_hint(notification, "resident", g_variant_new_boolean(TRUE));
- notify_notification_set_timeout(notification, 15000);
-
- auto* open_file = new NotificationActionData{file_uri};
- auto* open_folder = new NotificationActionData{folder_uri};
-
- g_signal_connect(notification, "closed", G_CALLBACK(on_notification_closed), nullptr);
- notify_notification_add_action(
- notification,
- "open-file",
- "Open File",
- on_notification_action,
- open_file,
- free_action_data);
- notify_notification_add_action(
- notification,
- "open-folder",
- "Open Folder",
- on_notification_action,
- open_folder,
- free_action_data);
-
- GError* error = nullptr;
- gboolean shown = notify_notification_show(notification, &error);
- if (!shown) {
- debug::log(ERR, "Failed to show notification");
- if (error) {
- debug::log(ERR, ": {}", error->message);
- g_error_free(error);
+ FileArrivalNotifier::~FileArrivalNotifier() {
+ if (!impl_->initialized) {
+ return;
}
- debug::log(ERR, "");
- g_object_unref(notification);
- }
- g_free(file_uri);
- g_free(folder_uri);
- return G_SOURCE_REMOVE;
-}
-} // namespace
-
-struct FileArrivalNotifier::Impl {
- GMainContext* context = nullptr;
- GMainLoop* loop = nullptr;
- std::thread thread;
- bool initialized = false;
-};
-
-FileArrivalNotifier::FileArrivalNotifier() : impl_(std::make_unique<Impl>()) {}
+ g_main_context_invoke(
+ impl_->context,
+ [](gpointer data) -> gboolean {
+ auto* loop = static_cast<GMainLoop*>(data);
+ g_main_loop_quit(loop);
+ return G_SOURCE_REMOVE;
+ },
+ impl_->loop);
+
+ if (impl_->thread.joinable()) {
+ impl_->thread.join();
+ }
-FileArrivalNotifier::~FileArrivalNotifier() {
- if (!impl_->initialized) {
- return;
+ g_main_loop_unref(impl_->loop);
+ g_main_context_unref(impl_->context);
+ notify_uninit();
}
- g_main_context_invoke(impl_->context, [](gpointer data) -> gboolean {
- auto* loop = static_cast<GMainLoop*>(data);
- g_main_loop_quit(loop);
- return G_SOURCE_REMOVE;
- }, impl_->loop);
-
- if (impl_->thread.joinable()) {
- impl_->thread.join();
- }
+ bool FileArrivalNotifier::init() {
+ if (impl_->initialized) {
+ return true;
+ }
- g_main_loop_unref(impl_->loop);
- g_main_context_unref(impl_->context);
- notify_uninit();
-}
+ if (!notify_init("tetherd")) {
+ debug::log(ERR, "Failed to initialize libnotify");
+ return false;
+ }
-bool FileArrivalNotifier::init() {
- if (impl_->initialized) {
+ impl_->context = g_main_context_new();
+ impl_->loop = g_main_loop_new(impl_->context, FALSE);
+ impl_->thread = std::thread([ctx = impl_->context, loop = impl_->loop]() {
+ g_main_context_push_thread_default(ctx);
+ g_main_loop_run(loop);
+ g_main_context_pop_thread_default(ctx);
+ });
+ impl_->initialized = true;
return true;
}
- if (!notify_init("tetherd")) {
- debug::log(ERR, "Failed to initialize libnotify");
- return false;
- }
+ void FileArrivalNotifier::notify_file_arrived(const std::filesystem::path& path) {
+ if (!impl_->initialized) {
+ return;
+ }
- impl_->context = g_main_context_new();
- impl_->loop = g_main_loop_new(impl_->context, FALSE);
- impl_->thread = std::thread([ctx = impl_->context, loop = impl_->loop]() {
- g_main_context_push_thread_default(ctx);
- g_main_loop_run(loop);
- g_main_context_pop_thread_default(ctx);
- });
- impl_->initialized = true;
- return true;
-}
-
-void FileArrivalNotifier::notify_file_arrived(const std::filesystem::path& path) {
- if (!impl_->initialized) {
- return;
+ auto* request = new NotificationRequest{path};
+ g_main_context_invoke_full(impl_->context, G_PRIORITY_DEFAULT, show_notification_on_main, request, nullptr);
}
- auto* request = new NotificationRequest{path};
- g_main_context_invoke_full(
- impl_->context,
- G_PRIORITY_DEFAULT,
- show_notification_on_main,
- request,
- nullptr);
-}
-
} // namespace tether
diff --git a/src/dialog/main.cpp b/src/dialog/main.cpp
index ad75ff0..29dcf7b 100644
--- a/src/dialog/main.cpp
+++ b/src/dialog/main.cpp
@@ -1,9 +1,9 @@
-#include <gtk/gtk.h>
#include <gtk-layer-shell.h>
+#include <gtk/gtk.h>
+#include "../core/include/tether/log.hpp"
#include <cstdlib>
#include <cstring>
-#include "../core/include/tether/log.hpp"
#include <string>
// Exit codes:
@@ -44,7 +44,9 @@ static gboolean on_key_press(GtkWidget*, GdkEventKey* event, gpointer has_reject
}
static void print_usage(const char* argv0) {
- debug::log(ERR, "Usage: {} --title <text> --body <text> --accept <label> [--reject <label>] [--timeout <seconds>]\n", argv0);
+ debug::log(ERR,
+ "Usage: {} --title <text> --body <text> --accept <label> [--reject <label>] [--timeout <seconds>]\n",
+ argv0);
}
static const char* CSS = R"(
@@ -135,9 +137,7 @@ int main(int argc, char** argv) {
GtkCssProvider* css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider, CSS, -1, NULL);
gtk_style_context_add_provider_for_screen(
- gdk_screen_get_default(),
- GTK_STYLE_PROVIDER(css_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gdk_screen_get_default(), GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref(css_provider);
// Create window
diff --git a/src/gtk/main.cpp b/src/gtk/main.cpp
index 0a08eae..d149cab 100644
--- a/src/gtk/main.cpp
+++ b/src/gtk/main.cpp
@@ -8,7 +8,6 @@
#include <cstdlib>
#include <ctime>
#include <filesystem>
-#include <tether/log.hpp>
#include <string>
#include <sys/socket.h>
#include <sys/un.h>
@@ -16,6 +15,7 @@
#include <tether/core.hpp>
#include <tether/crypto.hpp>
#include <tether/discovery.hpp>
+#include <tether/log.hpp>
#include <tether/net.hpp>
#include <unistd.h>
#include <vector>
@@ -180,7 +180,9 @@ namespace {
GtkWidget* box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_set_border_width(GTK_CONTAINER(box), 8);
GtkWidget* lbl = gtk_label_new(nullptr);
- gtk_label_set_markup(GTK_LABEL(lbl), ("<b><span size='small' color='gray'>" + escape_markup(title_text) + "</span></b>").c_str());
+ gtk_label_set_markup(
+ GTK_LABEL(lbl),
+ ("<b><span size='small' color='gray'>" + escape_markup(title_text) + "</span></b>").c_str());
gtk_label_set_xalign(GTK_LABEL(lbl), 0.0);
gtk_box_pack_start(GTK_BOX(box), lbl, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(row), box);
@@ -249,20 +251,23 @@ namespace {
GtkWidget* r = create_row(req.name, req.fingerprint, ip, port, false, false);
discovered_rows.push_back(r);
}
-
+
if (!connected_rows.empty()) {
gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), create_header_row("CONNECTED"), -1);
- for (auto* r : connected_rows) gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), r, -1);
+ for (auto* r : connected_rows)
+ gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), r, -1);
}
-
+
if (!remembered_rows.empty()) {
gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), create_header_row("REMEMBERED"), -1);
- for (auto* r : remembered_rows) gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), r, -1);
+ for (auto* r : remembered_rows)
+ gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), r, -1);
}
-
+
if (!discovered_rows.empty()) {
gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), create_header_row("DISCOVERED"), -1);
- for (auto* r : discovered_rows) gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), r, -1);
+ for (auto* r : discovered_rows)
+ gtk_list_box_insert(GTK_LIST_BOX(g_app.list_devices), r, -1);
}
gtk_widget_show_all(g_app.list_devices);
@@ -615,9 +620,12 @@ namespace {
std::filesystem::path self_path = std::filesystem::read_symlink("/proc/self/exe");
std::string daemon_path = (self_path.parent_path() / "tetherd").string();
if (fork() == 0) {
- if (freopen("/dev/null", "w", stdout) == nullptr) {}
- if (freopen("/dev/null", "w", stderr) == nullptr) {}
- if (freopen("/dev/null", "r", stdin) == nullptr) {}
+ if (freopen("/dev/null", "w", stdout) == nullptr) {
+ }
+ if (freopen("/dev/null", "w", stderr) == nullptr) {
+ }
+ if (freopen("/dev/null", "r", stdin) == nullptr) {
+ }
execl(daemon_path.c_str(), "tetherd", nullptr);
execlp("tetherd", "tetherd", nullptr);
exit(1);
@@ -738,12 +746,15 @@ namespace {
gtk_box_pack_start(GTK_BOX(btn_grid), btn_send_file, FALSE, FALSE, 0);
GtkWidget* btn_send_clip = gtk_button_new_with_label("Send Clipboard");
- g_signal_connect(btn_send_clip, "clicked", G_CALLBACK(+[](GtkWidget*, gpointer) {
- nlohmann::json j;
- j["command"] = "clipboard_set"; // triggers clipboard send
- send_async_daemon_message(j);
- set_status_action("Clipboard sync requested...");
- }), nullptr);
+ g_signal_connect(btn_send_clip,
+ "clicked",
+ G_CALLBACK(+[](GtkWidget*, gpointer) {
+ nlohmann::json j;
+ j["command"] = "clipboard_set"; // triggers clipboard send
+ send_async_daemon_message(j);
+ set_status_action("Clipboard sync requested...");
+ }),
+ nullptr);
gtk_box_pack_start(GTK_BOX(btn_grid), btn_send_clip, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(action_box), btn_grid, FALSE, FALSE, 0);