Initial project snapshot
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
#include "rdp_worker/cursor/cursor_adapter.hpp"
|
||||
|
||||
namespace rdp_worker::cursor {
|
||||
|
||||
CursorUpdate CursorAdapter::MakePosition(std::uint64_t sequence,
|
||||
int desktop_width,
|
||||
int desktop_height,
|
||||
int x,
|
||||
int y,
|
||||
bool visible) const {
|
||||
CursorUpdate update;
|
||||
update.kind = CursorUpdateKind::kPosition;
|
||||
update.sequence = sequence;
|
||||
update.desktop_width = desktop_width;
|
||||
update.desktop_height = desktop_height;
|
||||
update.x = x;
|
||||
update.y = y;
|
||||
update.visible = visible;
|
||||
return update;
|
||||
}
|
||||
|
||||
CursorUpdate CursorAdapter::MakeSystem(std::uint64_t sequence,
|
||||
int desktop_width,
|
||||
int desktop_height,
|
||||
int x,
|
||||
int y,
|
||||
std::uint32_t system_type) const {
|
||||
CursorUpdate update = MakePosition(sequence, desktop_width, desktop_height, x, y, system_type != 0);
|
||||
update.kind = CursorUpdateKind::kSystem;
|
||||
update.shape_changed = true;
|
||||
update.system_type = system_type;
|
||||
return update;
|
||||
}
|
||||
|
||||
CursorUpdate CursorAdapter::MakeColor(std::uint64_t sequence,
|
||||
int desktop_width,
|
||||
int desktop_height,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int cache_index,
|
||||
std::uint64_t mask_bytes) const {
|
||||
CursorUpdate update = MakePosition(sequence, desktop_width, desktop_height, x, y, true);
|
||||
update.kind = CursorUpdateKind::kColor;
|
||||
update.shape_changed = true;
|
||||
update.width = width;
|
||||
update.height = height;
|
||||
update.cache_index = cache_index;
|
||||
update.mask_bytes = mask_bytes;
|
||||
return update;
|
||||
}
|
||||
|
||||
CursorUpdate CursorAdapter::MakeNew(std::uint64_t sequence,
|
||||
int desktop_width,
|
||||
int desktop_height,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int cache_index,
|
||||
int xor_bpp,
|
||||
std::uint64_t mask_bytes) const {
|
||||
CursorUpdate update = MakeColor(sequence, desktop_width, desktop_height, x, y, width, height, cache_index, mask_bytes);
|
||||
update.kind = CursorUpdateKind::kNew;
|
||||
update.xor_bpp = xor_bpp;
|
||||
return update;
|
||||
}
|
||||
|
||||
CursorUpdate CursorAdapter::MakeCached(std::uint64_t sequence,
|
||||
int desktop_width,
|
||||
int desktop_height,
|
||||
int x,
|
||||
int y,
|
||||
int cache_index) const {
|
||||
CursorUpdate update = MakePosition(sequence, desktop_width, desktop_height, x, y, true);
|
||||
update.kind = CursorUpdateKind::kCached;
|
||||
update.shape_changed = true;
|
||||
update.cache_index = cache_index;
|
||||
return update;
|
||||
}
|
||||
|
||||
CursorUpdate CursorAdapter::MakeLarge(std::uint64_t sequence,
|
||||
int desktop_width,
|
||||
int desktop_height,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int cache_index,
|
||||
int hot_spot_x,
|
||||
int hot_spot_y,
|
||||
int xor_bpp,
|
||||
std::uint64_t mask_bytes) const {
|
||||
CursorUpdate update = MakeNew(sequence, desktop_width, desktop_height, x, y, width, height, cache_index, xor_bpp, mask_bytes);
|
||||
update.kind = CursorUpdateKind::kLarge;
|
||||
update.hot_spot_x = hot_spot_x;
|
||||
update.hot_spot_y = hot_spot_y;
|
||||
return update;
|
||||
}
|
||||
|
||||
} // namespace rdp_worker::cursor
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "rdp_worker/cursor/cursor_update.hpp"
|
||||
|
||||
namespace rdp_worker::cursor {
|
||||
|
||||
const char* CursorUpdateKindName(CursorUpdateKind kind) {
|
||||
switch (kind) {
|
||||
case CursorUpdateKind::kPosition:
|
||||
return "position";
|
||||
case CursorUpdateKind::kSystem:
|
||||
return "system";
|
||||
case CursorUpdateKind::kColor:
|
||||
return "color";
|
||||
case CursorUpdateKind::kNew:
|
||||
return "new";
|
||||
case CursorUpdateKind::kCached:
|
||||
return "cached";
|
||||
case CursorUpdateKind::kLarge:
|
||||
return "large";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
common::JsonObject CursorUpdateToPayload(const CursorUpdate& update,
|
||||
const std::string& render_quality_profile) {
|
||||
return common::JsonObject{
|
||||
{"render_quality_profile", render_quality_profile},
|
||||
{"render_state", "cursor"},
|
||||
{"cursor_update_kind", CursorUpdateKindName(update.kind)},
|
||||
{"cursor_sequence", static_cast<double>(update.sequence)},
|
||||
{"width", update.desktop_width},
|
||||
{"height", update.desktop_height},
|
||||
{"cursor_x", update.x},
|
||||
{"cursor_y", update.y},
|
||||
{"cursor_visible", update.visible},
|
||||
{"cursor_shape_changed", update.shape_changed},
|
||||
{"cursor_cache_index", update.cache_index},
|
||||
{"cursor_hot_spot_x", update.hot_spot_x},
|
||||
{"cursor_hot_spot_y", update.hot_spot_y},
|
||||
{"cursor_width", update.width},
|
||||
{"cursor_height", update.height},
|
||||
{"cursor_xor_bpp", update.xor_bpp},
|
||||
{"cursor_mask_bytes", static_cast<double>(update.mask_bytes)},
|
||||
{"cursor_system_type", static_cast<double>(update.system_type)},
|
||||
{"dirty_rectangles", 0},
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace rdp_worker::cursor
|
||||
Reference in New Issue
Block a user