[fix] restore remote cursors on Windows without a physical mouse

This commit is contained in:
dijunkun
2026-09-16 22:20:36 +08:00
parent 1d9242515a
commit d9116200fe
13 changed files with 323 additions and 48 deletions
@@ -6,14 +6,16 @@
#include <windows.h>
#include "platform/windows/input/windows_cursor_shape.h"
#include "platform/windows/input/windows_cursor_state.h"
#include "platform/windows/screen_capturer/dxgi_cursor_state.h"
#include "platform/windows/screen_capturer/secure_desktop_cursor_state.h"
#include "runtime/cursor_position.h"
namespace crossdesk {
struct CursorStateProvider::Impl {};
struct CursorStateProvider::Impl {
WindowsCursorState cursor;
};
CursorStateProvider::CursorStateProvider() : impl_(std::make_unique<Impl>()) {}
CursorStateProvider::~CursorStateProvider() = default;
@@ -24,11 +26,17 @@ bool CursorStateProvider::Sample(const std::vector<DisplayInfo>& displays,
SecureDesktopCursorSnapshot secure_cursor{};
if (SharedSecureDesktopCursorState().Get(&secure_cursor)) {
if (!secure_cursor.valid) return false;
if (!secure_cursor.valid) {
state->hidden_reason = CursorHiddenReason::secure_desktop_pending;
return false;
}
state->seq = 0;
NormalizeCursorPosition(secure_cursor.x, secure_cursor.y, displays,
preferred_display, state);
state->visible = secure_cursor.visible != 0;
state->render_mode = static_cast<CursorRenderMode>(secure_cursor.render_mode);
state->hidden_reason =
static_cast<CursorHiddenReason>(secure_cursor.hidden_reason);
state->shape = state->visible
? static_cast<RemoteCursorShape>(secure_cursor.shape)
: RemoteCursorShape::none;
@@ -45,10 +53,9 @@ bool CursorStateProvider::Sample(const std::vector<DisplayInfo>& displays,
void* cursor_monitor = state->position_valid
? displays[state->display_id].handle
: nullptr;
state->visible = SharedDxgiCursorState().ShouldDrawCursor(
(info.flags & CURSOR_SHOWING) != 0, cursor_monitor);
state->shape = state->visible ? ShapeFromWindowsCursor(info.hCursor)
: RemoteCursorShape::none;
const bool embedded = (info.flags & CURSOR_SHOWING) != 0 &&
!SharedDxgiCursorState().ShouldDrawCursor(true, cursor_monitor);
impl_->cursor.Sample(info, embedded, state);
return true;
}