[refactor] reorganize platform and wire sources

This commit is contained in:
dijunkun
2026-09-01 01:29:30 +08:00
parent fb0ab4f14e
commit 90184f5251
354 changed files with 2837 additions and 2456 deletions
+12 -10
View File
@@ -8,13 +8,15 @@
# Dependency manifests and local xmake package recipes are the only project # Dependency manifests and local xmake package recipes are the only project
# files needed while pre-warming the build image. # files needed while pre-warming the build image.
!xmake.lua !xmake.lua
!xmake/ !apps/
!xmake/** !apps/desktop/
!thirdparty/ !apps/desktop/xmake/
!thirdparty/** !apps/desktop/xmake/**
!submodules/ !deps/thirdparty/
!submodules/xmake.lua !deps/thirdparty/**
!submodules/minirtc/ !deps/submodules/
!submodules/minirtc/xmake.lua !deps/submodules/xmake.lua
!submodules/minirtc/thirdparty/ !deps/submodules/minirtc/
!submodules/minirtc/thirdparty/** !deps/submodules/minirtc/xmake.lua
!deps/submodules/minirtc/thirdparty/
!deps/submodules/minirtc/thirdparty/**
+5 -5
View File
@@ -11,11 +11,11 @@ on:
- docker/linux-build/** - docker/linux-build/**
- xmake.lua - xmake.lua
- xmake/** - xmake/**
- thirdparty/** - deps/thirdparty/**
- submodules/xmake.lua - deps/submodules/xmake.lua
- submodules/minirtc - deps/submodules/minirtc
- submodules/minirtc/xmake.lua - deps/submodules/minirtc/xmake.lua
- submodules/minirtc/thirdparty/** - deps/submodules/minirtc/thirdparty/**
workflow_dispatch: workflow_dispatch:
permissions: permissions:
+21 -12
View File
@@ -36,12 +36,12 @@ jobs:
- arch: amd64 - arch: amd64
runner: ubuntu-24.04 runner: ubuntu-24.04
image: crossdesk/ubuntu20.04:buildenv-cuda12.6.3-gcc10-cmake3.31.6-pipewire0.3.48-xmake3.0.9-rust1.92.0 image: crossdesk/ubuntu20.04:buildenv-cuda12.6.3-gcc10-cmake3.31.6-pipewire0.3.48-xmake3.0.9-rust1.92.0
package_script: ./scripts/linux/pkg_amd64.sh package_script: ./apps/desktop/scripts/linux/pkg_amd64.sh
- arch: arm64 - arch: arm64
runner: ubuntu-24.04-arm runner: ubuntu-24.04-arm
image: crossdesk/ubuntu20.04:buildenv-cuda12.6.3-gcc10-cmake3.31.6-pipewire0.3.48-xmake3.0.9-rust1.92.0 image: crossdesk/ubuntu20.04:buildenv-cuda12.6.3-gcc10-cmake3.31.6-pipewire0.3.48-xmake3.0.9-rust1.92.0
package_script: ./scripts/linux/pkg_arm64.sh package_script: ./apps/desktop/scripts/linux/pkg_arm64.sh
container: container:
image: ${{ matrix.image }} image: ${{ matrix.image }}
@@ -138,6 +138,15 @@ jobs:
--cc=gcc-10 --cxx=g++-10 --root -y --cc=gcc-10 --cxx=g++-10 --root -y
xmake b -vy --root crossdesk xmake b -vy --root crossdesk
- name: Verify repository and wire boundaries
env:
XMAKE_GLOBALDIR: /data
run: |
xmake b -vy --root repository_structure_test crossdesk_wire_test keyboard_state_wire_test
xmake run --root repository_structure_test
xmake run --root crossdesk_wire_test
xmake run --root keyboard_state_wire_test
- name: Package - name: Package
run: | run: |
chmod +x ${{ matrix.package_script }} chmod +x ${{ matrix.package_script }}
@@ -178,13 +187,13 @@ jobs:
runner: macos-26-intel runner: macos-26-intel
cache-key: intel-macos26-xcode26.6-min14 cache-key: intel-macos26-xcode26.6-min14
out-dir: ./build/macosx/x86_64/release/crossdesk out-dir: ./build/macosx/x86_64/release/crossdesk
package_script: ./scripts/macosx/pkg_x64.sh package_script: ./apps/desktop/scripts/macos/pkg_x64.sh
- arch: arm64 - arch: arm64
binary_arch: arm64 binary_arch: arm64
runner: macos-26 runner: macos-26
cache-key: arm-macos26-xcode26.6-min14 cache-key: arm-macos26-xcode26.6-min14
out-dir: ./build/macosx/arm64/release/crossdesk out-dir: ./build/macosx/arm64/release/crossdesk
package_script: ./scripts/macosx/pkg_arm64.sh package_script: ./apps/desktop/scripts/macos/pkg_arm64.sh
steps: steps:
- name: Extract version number - name: Extract version number
@@ -282,7 +291,7 @@ jobs:
exit 1 exit 1
fi fi
./scripts/macosx/verify_app.sh "${APP_PATH}" "${{ matrix.binary_arch }}" "${EXPECTED_MACOS_SDK}" ./apps/desktop/scripts/macos/verify_app.sh "${APP_PATH}" "${{ matrix.binary_arch }}" "${EXPECTED_MACOS_SDK}"
- name: Upload build artifacts - name: Upload build artifacts
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v6
@@ -364,7 +373,7 @@ jobs:
- name: Cache xmake dependencies - name: Cache xmake dependencies
uses: actions/cache@v5 uses: actions/cache@v5
with: with:
path: ios/.xmake/packages path: apps/ios/.xmake/packages
key: "${{ runner.os }}-xmake${{ env.XMAKE_VERSION }}-deps-ios-arm64-xcode26.6-xrepo1211093-min16-${{ github.run_id }}" key: "${{ runner.os }}-xmake${{ env.XMAKE_VERSION }}-deps-ios-arm64-xcode26.6-xrepo1211093-min16-${{ github.run_id }}"
restore-keys: | restore-keys: |
${{ runner.os }}-xmake${{ env.XMAKE_VERSION }}-deps-ios-arm64-xcode26.6-xrepo1211093-min16- ${{ runner.os }}-xmake${{ env.XMAKE_VERSION }}-deps-ios-arm64-xcode26.6-xrepo1211093-min16-
@@ -404,7 +413,7 @@ jobs:
DERIVED_DATA="${RUNNER_TEMP}/CrossDeskMobileDerivedData" DERIVED_DATA="${RUNNER_TEMP}/CrossDeskMobileDerivedData"
echo "DERIVED_DATA=${DERIVED_DATA}" >> "${GITHUB_ENV}" echo "DERIVED_DATA=${DERIVED_DATA}" >> "${GITHUB_ENV}"
xcodebuild \ xcodebuild \
-project ios/CrossDeskMobile.xcodeproj \ -project apps/ios/CrossDeskMobile.xcodeproj \
-scheme CrossDeskMobile \ -scheme CrossDeskMobile \
-configuration Release \ -configuration Release \
-destination 'generic/platform=iOS' \ -destination 'generic/platform=iOS' \
@@ -571,7 +580,7 @@ jobs:
- name: Copy nsProcess plugin to NSIS folder - name: Copy nsProcess plugin to NSIS folder
run: | run: |
$nsisPluginDir = "C:\Program Files (x86)\NSIS\Plugins\x86-unicode" $nsisPluginDir = "C:\Program Files (x86)\NSIS\Plugins\x86-unicode"
copy "${{ github.workspace }}\scripts\windows\nsProcess.dll" $nsisPluginDir copy "${{ github.workspace }}\apps\desktop\scripts\windows\nsProcess.dll" $nsisPluginDir
- name: Build CrossDesk - name: Build CrossDesk
run: | run: |
@@ -581,14 +590,14 @@ jobs:
- name: Package - name: Package
shell: pwsh shell: pwsh
run: | run: |
& "${{ github.workspace }}\scripts\windows\pkg_x64.ps1" $env:VERSION_NUM & "${{ github.workspace }}\apps\desktop\scripts\windows\pkg_x64.ps1" $env:VERSION_NUM
- name: Upload unsigned Windows installer for test signing - name: Upload unsigned Windows installer for test signing
if: github.event_name == 'workflow_dispatch' && inputs.sign_windows_test if: github.event_name == 'workflow_dispatch' && inputs.sign_windows_test
id: upload-unsigned-windows-installer id: upload-unsigned-windows-installer
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v7
with: with:
path: ${{ github.workspace }}/scripts/windows/crossdesk-win-x64-${{ env.VERSION_NUM }}.exe path: ${{ github.workspace }}/apps/desktop/scripts/windows/crossdesk-win-x64-${{ env.VERSION_NUM }}.exe
archive: false archive: false
if-no-files-found: error if-no-files-found: error
retention-days: 1 retention-days: 1
@@ -614,7 +623,7 @@ jobs:
run: | run: |
$installerName = "crossdesk-win-x64-${{ env.VERSION_NUM }}.exe" $installerName = "crossdesk-win-x64-${{ env.VERSION_NUM }}.exe"
$signedInstaller = Join-Path "${{ github.workspace }}\signpath\signed-installer" $installerName $signedInstaller = Join-Path "${{ github.workspace }}\signpath\signed-installer" $installerName
$destination = Join-Path "${{ github.workspace }}\scripts\windows" $installerName $destination = Join-Path "${{ github.workspace }}\apps\desktop\scripts\windows" $installerName
if (!(Test-Path $signedInstaller)) { if (!(Test-Path $signedInstaller)) {
throw "SignPath did not return the signed installer: $signedInstaller" throw "SignPath did not return the signed installer: $signedInstaller"
@@ -671,7 +680,7 @@ jobs:
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v6
with: with:
name: crossdesk-win-x64-${{ env.VERSION_NUM }} name: crossdesk-win-x64-${{ env.VERSION_NUM }}
path: ${{ github.workspace }}/scripts/windows/crossdesk-win-x64-${{ env.VERSION_NUM }}.exe path: ${{ github.workspace }}/apps/desktop/scripts/windows/crossdesk-win-x64-${{ env.VERSION_NUM }}.exe
- name: Upload portable artifact - name: Upload portable artifact
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v6
+3 -3
View File
@@ -1,9 +1,9 @@
# Xmake cache # Xmake cache
.xmake/ .xmake/
build/ build/
ios/Vendor/ apps/ios/Vendor/
ios/DerivedData/ apps/ios/DerivedData*/
ios/.xmake/ apps/ios/.xmake/
xcuserdata/ xcuserdata/
*.xcuserstate *.xcuserstate
+2 -2
View File
@@ -1,3 +1,3 @@
[submodule "submodules/minirtc"] [submodule "deps/submodules/minirtc"]
path = submodules/minirtc path = deps/submodules/minirtc
url = https://github.com/kunkundi/minirtc.git url = https://github.com/kunkundi/minirtc.git
+2 -2
View File
@@ -171,10 +171,10 @@ xmake b -vy crossdesk
```bash ```bash
# amd64 # amd64
./scripts/linux/pkg_amd64.sh 1.0.0 ./apps/desktop/scripts/linux/pkg_amd64.sh 1.0.0
# arm64 # arm64
./scripts/linux/pkg_arm64.sh 1.0.0 ./apps/desktop/scripts/linux/pkg_arm64.sh 1.0.0
``` ```
打包脚本会将 Slint 共享运行库安装到软件包私有目录 `/usr/lib/crossdesk`,无需用户另外安装 `libslint_cpp.so` 打包脚本会将 Slint 共享运行库安装到软件包私有目录 `/usr/lib/crossdesk`,无需用户另外安装 `libslint_cpp.so`
+2 -2
View File
@@ -179,10 +179,10 @@ Build a Debian package after compiling a release binary on the matching architec
```bash ```bash
# amd64 # amd64
./scripts/linux/pkg_amd64.sh 1.0.0 ./apps/desktop/scripts/linux/pkg_amd64.sh 1.0.0
# arm64 # arm64
./scripts/linux/pkg_arm64.sh 1.0.0 ./apps/desktop/scripts/linux/pkg_arm64.sh 1.0.0
``` ```
The package scripts install the shared Slint runtime in the private `/usr/lib/crossdesk` directory, so users do not need to install `libslint_cpp.so` separately. The package scripts install the shared Slint runtime in the private `/usr/lib/crossdesk` directory, so users do not need to install `libslint_cpp.so` separately.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 746 B

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

@@ -1,5 +1,5 @@
// Application icon resource; load by the resource name IDI_ICON1. // Application icon resource; load by the resource name IDI_ICON1.
IDI_ICON1 ICON "..\\..\\icons\\windows\\crossdesk.ico" IDI_ICON1 ICON "crossdesk.ico"
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define RT_MANIFEST 24 #define RT_MANIFEST 24
@@ -1,6 +1,6 @@
// Portable build resource. The app itself runs as the current user; service // Portable build resource. The app itself runs as the current user; service
// installation raises a separate UAC prompt only when the user chooses it. // installation raises a separate UAC prompt only when the user chooses it.
IDI_ICON1 ICON "..\\..\\icons\\windows\\crossdesk.ico" IDI_ICON1 ICON "crossdesk.ico"
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define RT_MANIFEST 24 #define RT_MANIFEST 24
@@ -1,5 +1,5 @@
// Session helper icon and manifest resources. // Session helper icon and manifest resources.
IDI_ICON1 ICON "..\\..\\icons\\windows\\crossdesk.ico" IDI_ICON1 ICON "crossdesk.ico"
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define RT_MANIFEST 24 #define RT_MANIFEST 24
@@ -20,7 +20,7 @@ PORTAL_RUNTIME_RECOMMENDS="xdg-desktop-portal, xdg-desktop-portal-gtk | xdg-desk
TRAY_RUNTIME_RECOMMENDS="libayatana-appindicator3-1 | libappindicator3-1" TRAY_RUNTIME_RECOMMENDS="libayatana-appindicator3-1 | libappindicator3-1"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
normalize_app_version() { normalize_app_version() {
local input="$1" local input="$1"
@@ -142,7 +142,7 @@ ln -s "$PKG_NAME" "$BIN_DIR/$APP_NAME"
for size in 16 24 32 48 64 96 128 256; do for size in 16 24 32 48 64 96 128 256; do
install -d "$ICON_BASE_DIR/${size}x${size}/apps" install -d "$ICON_BASE_DIR/${size}x${size}/apps"
install -m 0644 "$PROJECT_ROOT/icons/linux/crossdesk_${size}x${size}.png" \ install -m 0644 "$PROJECT_ROOT/apps/desktop/resources/linux/crossdesk_${size}x${size}.png" \
"$ICON_BASE_DIR/${size}x${size}/apps/${PKG_NAME}.png" "$ICON_BASE_DIR/${size}x${size}/apps/${PKG_NAME}.png"
done done
@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
APP_NAME="crossdesk" APP_NAME="crossdesk"
APP_NAME_UPPER="CrossDesk" APP_NAME_UPPER="CrossDesk"
EXECUTABLE_PATH="${PROJECT_ROOT}/build/macosx/arm64/release/crossdesk" EXECUTABLE_PATH="${PROJECT_ROOT}/build/macosx/arm64/release/crossdesk"
@@ -10,7 +10,7 @@ PLATFORM="macos"
ARCH="arm64" ARCH="arm64"
BINARY_ARCH="arm64" BINARY_ARCH="arm64"
IDENTIFIER="cn.crossdesk.app" IDENTIFIER="cn.crossdesk.app"
ICON_PATH="${PROJECT_ROOT}/icons/macos/crossdesk.icns" ICON_PATH="${PROJECT_ROOT}/apps/desktop/resources/macos/crossdesk.icns"
MACOS_MIN_VERSION="14.0" MACOS_MIN_VERSION="14.0"
cd "$PROJECT_ROOT" cd "$PROJECT_ROOT"
@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
APP_NAME="crossdesk" APP_NAME="crossdesk"
APP_NAME_UPPER="CrossDesk" APP_NAME_UPPER="CrossDesk"
EXECUTABLE_PATH="${PROJECT_ROOT}/build/macosx/x86_64/release/crossdesk" EXECUTABLE_PATH="${PROJECT_ROOT}/build/macosx/x86_64/release/crossdesk"
@@ -10,7 +10,7 @@ PLATFORM="macos"
ARCH="x64" ARCH="x64"
BINARY_ARCH="x86_64" BINARY_ARCH="x86_64"
IDENTIFIER="cn.crossdesk.app" IDENTIFIER="cn.crossdesk.app"
ICON_PATH="${PROJECT_ROOT}/icons/macos/crossdesk.icns" ICON_PATH="${PROJECT_ROOT}/apps/desktop/resources/macos/crossdesk.icns"
MACOS_MIN_VERSION="14.0" MACOS_MIN_VERSION="14.0"
cd "$PROJECT_ROOT" cd "$PROJECT_ROOT"
@@ -12,7 +12,7 @@
!define PRODUCT_SERVICE_NAME "CrossDeskService" !define PRODUCT_SERVICE_NAME "CrossDeskService"
; Installer icon path ; Installer icon path
!define MUI_ICON "${__FILEDIR__}\..\..\icons\windows\crossdesk.ico" !define MUI_ICON "${__FILEDIR__}\..\..\resources\windows\crossdesk.ico"
; Compression settings ; Compression settings
SetCompressor /FINAL lzma SetCompressor /FINAL lzma
@@ -84,12 +84,12 @@ installApp:
SetOverwrite ifnewer SetOverwrite ifnewer
; Main application executable path ; Main application executable path
File /oname=CrossDesk.exe "..\..\build\windows\x64\release\crossdesk.exe" File /oname=CrossDesk.exe "..\..\..\..\build\windows\x64\release\crossdesk.exe"
; Bundle service-side binaries required by the Windows service flow ; Bundle service-side binaries required by the Windows service flow
File "..\..\build\windows\x64\release\crossdesk_service.exe" File "..\..\..\..\build\windows\x64\release\crossdesk_service.exe"
File "..\..\build\windows\x64\release\crossdesk_session_helper.exe" File "..\..\..\..\build\windows\x64\release\crossdesk_session_helper.exe"
; Bundle runtime DLLs from the release output directory ; Bundle runtime DLLs from the release output directory
File "..\..\build\windows\x64\release\*.dll" File "..\..\..\..\build\windows\x64\release\*.dll"
Call RegisterInstalledService Call RegisterInstalledService
+76
View File
@@ -0,0 +1,76 @@
#include "daemon.h"
#include <chrono>
#include <iostream>
#include <thread>
#include <utility>
#include "platform/daemon_backend.h"
namespace {
constexpr int kRestartDelayMs = 1000;
} // namespace
Daemon::Daemon(const std::string& name) : name_(name), running_(false) {}
void Daemon::stop() {
running_.store(false);
crossdesk::platform::RequestDaemonStop();
}
bool Daemon::isRunning() const {
return running_.load() && !crossdesk::platform::DaemonStopRequested();
}
bool Daemon::start(MainLoopFunc loop) {
crossdesk::platform::ResetDaemonStop();
if (!crossdesk::platform::PrepareDaemon()) return false;
running_.store(true);
return runWithRestart(std::move(loop));
}
bool Daemon::runWithRestart(MainLoopFunc loop) {
int restart_count = 0;
const std::string executable_path =
crossdesk::platform::GetDaemonExecutablePath();
if (executable_path.empty()) {
std::cerr
<< "Failed to get executable path, falling back to direct execution"
<< std::endl;
while (isRunning()) {
try {
loop();
break;
} catch (...) {
++restart_count;
std::cerr << "Exception caught, restarting... (attempt "
<< restart_count << ")" << std::endl;
std::this_thread::sleep_for(
std::chrono::milliseconds(kRestartDelayMs));
}
}
return true;
}
while (isRunning()) {
const crossdesk::platform::DaemonChildResult result =
crossdesk::platform::RunDaemonChild(
executable_path, [this] { return isRunning(); });
if (!isRunning() || result.normal_exit) break;
++restart_count;
if (!result.started) {
std::cerr << "Failed to create child process";
} else if (result.terminated_by_signal) {
std::cerr << "Child process crashed with signal " << result.exit_code;
} else {
std::cerr << "Child process exited with code " << result.exit_code;
}
std::cerr << ", restarting... (attempt " << restart_count << ")"
<< std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(kRestartDelayMs));
}
return true;
}
@@ -8,7 +8,6 @@
#define _DAEMON_H_ #define _DAEMON_H_
#include <atomic> #include <atomic>
#include <csignal>
#include <functional> #include <functional>
#include <string> #include <string>
@@ -28,9 +27,6 @@ class Daemon {
std::string name_; std::string name_;
bool runWithRestart(MainLoopFunc loop); bool runWithRestart(MainLoopFunc loop);
#ifndef _WIN32
static volatile std::sig_atomic_t stop_requested_;
#endif
std::atomic<bool> running_; std::atomic<bool> running_;
}; };
+21
View File
@@ -0,0 +1,21 @@
#include "autostart.h"
#include "platform/autostart_backend.h"
namespace crossdesk {
bool EnableAutostart(const std::string& app_name) {
const std::string executable_path = platform::GetAutostartExecutablePath();
return !executable_path.empty() &&
platform::EnableAutostart(app_name, executable_path);
}
bool DisableAutostart(const std::string& app_name) {
return platform::DisableAutostart(app_name);
}
bool IsAutostartEnabled(const std::string& app_name) {
return platform::IsAutostartEnabled(app_name);
}
} // namespace crossdesk
@@ -7,7 +7,7 @@
#ifndef _PLATFORM_H_ #ifndef _PLATFORM_H_
#define _PLATFORM_H_ #define _PLATFORM_H_
#include <iostream> #include <string>
namespace crossdesk { namespace crossdesk {
@@ -1,5 +1,7 @@
#include "shared_cursor_state.h" #include "shared_cursor_state.h"
#include <remote_action.h>
#include <mutex> #include <mutex>
namespace crossdesk { namespace crossdesk {
@@ -3,7 +3,7 @@
#include <cstdint> #include <cstdint>
#include "remote_cursor_shape.h" #include <remote_cursor_shape.h>
namespace crossdesk { namespace crossdesk {
@@ -0,0 +1,52 @@
/*
* @Author: DI JUNKUN
* @Date: 2023-12-14
* Copyright (c) 2023 by DI JUNKUN, All Rights Reserved.
*/
#ifndef _DEVICE_CONTROLLER_H_
#define _DEVICE_CONTROLLER_H_
#include <cstdint>
#include <vector>
#include <remote_action.h>
#include "display_info.h"
namespace crossdesk {
// int key_code, bool is_down, uint32_t scan_code, bool extended
using OnKeyAction = void (*)(int, bool, uint32_t, bool, void*);
class DeviceController {
public:
virtual ~DeviceController() = default;
};
class MouseController : public DeviceController {
public:
~MouseController() override = default;
virtual int Init(std::vector<DisplayInfo> display_info_list) = 0;
virtual int Destroy() = 0;
virtual int SendMouseCommand(RemoteAction remote_action,
int display_index) = 0;
virtual void UpdateDisplayInfoList(
const std::vector<DisplayInfo>&) {}
};
class KeyboardCapturer : public DeviceController {
public:
~KeyboardCapturer() override = default;
virtual int Hook(OnKeyAction on_key_action, void* user_ptr) = 0;
virtual int Unhook() = 0;
virtual int SendKeyboardCommand(int key_code, bool is_down,
uint32_t scan_code = 0,
bool extended = false) = 0;
};
} // namespace crossdesk
#endif
@@ -8,8 +8,6 @@
#define _DEVICE_CONTROLLER_FACTORY_H_ #define _DEVICE_CONTROLLER_FACTORY_H_
#include "device_controller.h" #include "device_controller.h"
#include "keyboard_capturer.h"
#include "mouse_controller.h"
namespace crossdesk { namespace crossdesk {
@@ -21,16 +19,7 @@ class DeviceControllerFactory {
virtual ~DeviceControllerFactory() {} virtual ~DeviceControllerFactory() {}
public: public:
DeviceController* Create(Device device) { DeviceController* Create(Device device);
switch (device) {
case Mouse:
return new MouseController();
case Keyboard:
return new KeyboardCapturer();
default:
return nullptr;
}
}
}; };
} // namespace crossdesk } // namespace crossdesk
#endif #endif
@@ -1,5 +1,7 @@
#include "application/gui_application.h" #include "application/gui_application.h"
#include <remote_action.h>
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <slint.h> #include <slint.h>
#include <tinyfiledialogs.h> #include <tinyfiledialogs.h>
@@ -35,9 +37,9 @@
#if _WIN32 #if _WIN32
#include <windows.h> #include <windows.h>
#include "platform/tray/win_tray.h" #include "platform/windows/gui/tray/win_tray.h"
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include "platform/tray/mac_tray.h" #include "platform/macos/gui/tray/mac_tray.h"
#include "platform/window_drag.h" #include "platform/window_drag.h"
#elif defined(__linux__) #elif defined(__linux__)
#include <GL/gl.h> #include <GL/gl.h>
@@ -45,7 +47,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <unistd.h> #include <unistd.h>
#include "platform/tray/linux_tray.h" #include "platform/linux/gui/tray/linux_tray.h"
#endif #endif
#include "rd_log.h" #include "rd_log.h"
#include "server_window_state.h" #include "server_window_state.h"
@@ -6,6 +6,8 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <remote_action.h>
#include "runtime/cursor_state_provider.h" #include "runtime/cursor_state_provider.h"
#include "runtime/gui_runtime.h" #include "runtime/gui_runtime.h"
@@ -1,5 +1,7 @@
#include "application/gui_application.h" #include "application/gui_application.h"
#include <remote_action.h>
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <string> #include <string>
@@ -1,9 +1,11 @@
#include "features/devices/session_device_manager.h" #include "features/devices/session_device_manager.h"
#include <remote_action.h>
#include <chrono> #include <chrono>
#include <cstdlib> #include <cstdlib>
#include "display_stream_id.h" #include <display_stream_id.h>
#include "platform.h" #include "platform.h"
#include "rd_log.h" #include "rd_log.h"
#include "runtime/gui_runtime.h" #include "runtime/gui_runtime.h"
@@ -11,6 +11,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <remote_action.h>
#include "device_controller.h" #include "device_controller.h"
#include "device_controller_factory.h" #include "device_controller_factory.h"
#include "display_info.h" #include "display_info.h"
@@ -236,7 +236,7 @@ void FileTransferManager::Unregister(uint32_t file_id, bool per_peer) {
void FileTransferManager::HandleAck(const char *data, size_t size) { void FileTransferManager::HandleAck(const char *data, size_t size) {
FileTransferAck ack{}; FileTransferAck ack{};
if (!protocol::DecodeFileTransferAck(data, size, &ack)) { if (!DecodeFileTransferAck(data, size, &ack)) {
LOG_ERROR("FileTransferAck: invalid payload, size={}", size); LOG_ERROR("FileTransferAck: invalid payload, size={}", size);
return; return;
} }
@@ -1,5 +1,7 @@
#include "features/input/keyboard_controller.h" #include "features/input/keyboard_controller.h"
#include <remote_action.h>
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cstdint> #include <cstdint>
@@ -6,6 +6,8 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <remote_action.h>
#include "device_controller.h" #include "device_controller.h"
namespace crossdesk { namespace crossdesk {
@@ -14,14 +14,14 @@
#include "rd_log.h" #include "rd_log.h"
#if defined(__APPLE__) #if defined(__APPLE__)
#include "platform/metal_video_renderer.h" #include "platform/macos/gui/metal_video_renderer.h"
#else #else
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
#endif #endif
#include <GL/gl.h> #include <GL/gl.h>
#include "platform/opengl_video_renderer.h" #include "platform/common/gui/opengl_video_renderer.h"
#endif #endif
namespace crossdesk { namespace crossdesk {
@@ -8,7 +8,7 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "display_stream_id.h" #include <display_stream_id.h>
#include "localization.h" #include "localization.h"
#include "platform.h" #include "platform.h"
#include "platform/video_renderer.h" #include "platform/video_renderer.h"
@@ -4,7 +4,8 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "device_controller.h" #include <remote_action.h>
#include "display_info.h" #include "display_info.h"
namespace crossdesk { namespace crossdesk {
@@ -1,5 +1,7 @@
#include "runtime/cursor_state_provider.h" #include "runtime/cursor_state_provider.h"
#include <remote_action.h>
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
@@ -4,7 +4,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "device_controller.h" #include <remote_action.h>
#include "display_info.h" #include "display_info.h"
namespace crossdesk { namespace crossdesk {
@@ -10,7 +10,7 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "display_stream_id.h" #include <display_stream_id.h>
#include "localization.h" #include "localization.h"
#include "platform/video_renderer.h" #include "platform/video_renderer.h"
#include "rd_log.h" #include "rd_log.h"
@@ -1,5 +1,7 @@
#include "runtime/peer_event_handler.h" #include "runtime/peer_event_handler.h"
#include <remote_action.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <cstring> #include <cstring>
@@ -97,7 +99,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
} }
receiver.SetOnSendAck([runtime, receiver.SetOnSendAck([runtime,
remote_user_id](const FileTransferAck &ack) -> int { remote_user_id](const FileTransferAck &ack) -> int {
const auto encoded_ack = protocol::EncodeFileTransferAck(ack); const auto encoded_ack = EncodeFileTransferAck(ack);
bool is_server_sending = remote_user_id.rfind("C-", 0) != 0; bool is_server_sending = remote_user_id.rfind("C-", 0) != 0;
if (is_server_sending) { if (is_server_sending) {
auto props = auto props =
@@ -1,5 +1,7 @@
#include "runtime/peer_event_handler.h" #include "runtime/peer_event_handler.h"
#include <remote_action.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <cstring> #include <cstring>

Some files were not shown because too many files have changed in this diff Show More