refactor: rebuild desktop client with Slint

This commit is contained in:
dijunkun
2026-07-21 16:38:51 +08:00
parent eeb6a2a1ae
commit 59f77c2820
79 changed files with 7373 additions and 1009 deletions
-7
View File
@@ -200,8 +200,6 @@ int GuiRuntime::RequestSingleDevicePresence(const std::string &remote_id,
}
void GuiRuntime::CloseRemoteSession(std::shared_ptr<RemoteSession> props) {
SDL_FlushEvent(STREAM_REFRESH_EVENT);
std::shared_ptr<std::vector<unsigned char>> frame_snapshot;
int video_width = 0;
int video_height = 0;
@@ -290,11 +288,6 @@ void GuiRuntime::WaitForThumbnailSaveTasks() {
void GuiRuntime::ResetRemoteSessionResources(
std::shared_ptr<RemoteSession> props) {
if (props->stream_texture_) {
SDL_DestroyTexture(props->stream_texture_);
props->stream_texture_ = nullptr;
}
{
std::lock_guard<std::mutex> lock(props->video_frame_mutex_);
props->front_frame_.reset();
+2 -2
View File
@@ -168,10 +168,10 @@ void GuiRuntime::UpdateLabels() {
void GuiRuntime::HandleRecentConnections() {
if (reload_recent_connections_ && main_renderer_) {
if (reload_recent_connections_ && thumbnail_) {
uint32_t now_time = SDL_GetTicks();
if (now_time - recent_connection_image_save_time_ >= 50) {
int ret = thumbnail_->LoadThumbnail(main_renderer_, recent_connections_,
int ret = thumbnail_->LoadThumbnail(recent_connections_,
&recent_connection_image_width_,
&recent_connection_image_height_);
if (!ret) {
+2 -1
View File
@@ -14,6 +14,7 @@
#include "device_controller.h"
#include "file_transfer.h"
#include "localization.h"
#include "filesystem_utf8.h"
#include "platform.h"
#include "rd_log.h"
#include "runtime/gui_runtime.h"
@@ -90,7 +91,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
std::string configured_path =
runtime->config_center_->GetFileTransferSavePath();
if (!configured_path.empty()) {
receiver.SetOutputDir(std::filesystem::u8path(configured_path));
receiver.SetOutputDir(PathFromUtf8(configured_path));
} else if (receiver.OutputDir().empty()) {
receiver = FileReceiver(); // re-init with default desktop path
}
-11
View File
@@ -230,12 +230,6 @@ void PeerEventHandler::OnConnectionStatus(ConnectionStatus status,
runtime->need_to_create_stream_window_ = true;
}
props->connection_established_ = true;
props->stream_render_rect_ = {
0, (int)runtime->title_bar_height_, (int)runtime->stream_window_width_,
(int)(runtime->stream_window_height_ - runtime->title_bar_height_)};
props->stream_render_rect_f_ = {
0.0f, runtime->title_bar_height_, runtime->stream_window_width_,
runtime->stream_window_height_ - runtime->title_bar_height_};
runtime->start_keyboard_capturer_ = true;
break;
}
@@ -259,11 +253,6 @@ void PeerEventHandler::OnConnectionStatus(ConnectionStatus status,
props->stream_cleanup_pending_ = true;
}
SDL_Event event;
event.type = runtime->STREAM_REFRESH_EVENT;
event.user.data1 = props.get();
SDL_PushEvent(&event);
runtime->focus_on_stream_window_ = false;
break;
+1 -4
View File
@@ -70,12 +70,9 @@ void PeerEventHandler::OnReceiveVideoBuffer(
props->video_size_ = video_frame->size;
props->front_frame_.swap(props->back_frame_);
++props->video_frame_sequence_;
}
SDL_Event event;
event.type = runtime->STREAM_REFRESH_EVENT;
event.user.data1 = props;
SDL_PushEvent(&event);
props->streaming_ = true;
if (props->net_traffic_stats_button_pressed_) {
+3 -13
View File
@@ -1,8 +1,6 @@
#ifndef CROSSDESK_GUI_REMOTE_SESSION_H_
#define CROSSDESK_GUI_REMOTE_SESSION_H_
#include <SDL3/SDL.h>
#include <atomic>
#include <chrono>
#include <cstddef>
@@ -16,7 +14,6 @@
#include <vector>
#include "display_info.h"
#include "imgui.h"
#include "minirtc.h"
namespace crossdesk::gui_detail {
@@ -111,7 +108,7 @@ struct RemoteSession {
double control_bar_button_pressed_time_ = 0;
double net_traffic_stats_button_pressed_time_ = 0;
// Written by the decode callback thread and consumed by the SDL thread.
// Written by the decode callback thread and consumed by the UI thread.
std::mutex video_frame_mutex_;
std::shared_ptr<std::vector<unsigned char>> front_frame_;
std::shared_ptr<std::vector<unsigned char>> back_frame_;
@@ -129,6 +126,7 @@ struct RemoteSession {
int video_height_last_ = 0;
int selected_display_ = 0;
size_t video_size_ = 0;
uint64_t video_frame_sequence_ = 0;
bool tab_selected_ = false;
bool tab_opened_ = true;
std::optional<float> pos_x_before_docked_;
@@ -146,15 +144,7 @@ struct RemoteSession {
bool remote_service_available_ = false;
std::string remote_interactive_stage_;
std::vector<DisplayInfo> display_info_list_;
SDL_Texture *stream_texture_ = nullptr;
uint8_t *argb_buffer_ = nullptr;
int argb_buffer_size_ = 0;
SDL_FRect stream_render_rect_f_ = {0.0f, 0.0f, 0.0f, 0.0f};
SDL_Rect stream_render_rect_{};
SDL_Rect stream_render_rect_last_{};
ImVec2 control_window_pos_{};
// Shared by minirtc callbacks, SDL rendering and SDL audio callbacks.
// Shared by minirtc callbacks, Slint rendering and SDL audio callbacks.
std::atomic<ConnectionStatus> connection_status_ = ConnectionStatus::Closed;
TraversalMode traversal_mode_ = TraversalMode::UnknownMode;
int fps_ = 0;
+1
View File
@@ -91,6 +91,7 @@ struct PlatformIntegrationState {
bool show_portable_service_prompt_suppressed_window_ = false;
bool portable_service_do_not_remind_ = false;
bool portable_service_prompt_suppressed_ = false;
bool portable_service_installed_ = false;
std::atomic<PortableServiceInstallState> portable_service_install_state_{
PortableServiceInstallState::idle};
std::thread portable_service_install_thread_;