mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] cursor mapping in different displays supported
This commit is contained in:
@@ -369,8 +369,11 @@ int Render::StartMouseController() {
|
||||
}
|
||||
mouse_controller_ = (MouseController*)device_controller_factory_->Create(
|
||||
DeviceControllerFactory::Device::Mouse);
|
||||
int mouse_controller_init_ret =
|
||||
mouse_controller_->Init(screen_width_, screen_height_);
|
||||
|
||||
if (screen_capturer_ && display_info_list_.empty()) {
|
||||
display_info_list_ = screen_capturer_->GetDisplayInfoList();
|
||||
}
|
||||
int mouse_controller_init_ret = mouse_controller_->Init(display_info_list_);
|
||||
if (0 != mouse_controller_init_ret) {
|
||||
LOG_INFO("Destroy mouse controller")
|
||||
mouse_controller_->Destroy();
|
||||
@@ -937,11 +940,11 @@ void Render::MainLoop() {
|
||||
}
|
||||
|
||||
if (need_to_send_host_info_) {
|
||||
RemoteAction remote_action;
|
||||
if (screen_capturer_) {
|
||||
if (screen_capturer_ && display_info_list_.empty()) {
|
||||
display_info_list_ = screen_capturer_->GetDisplayInfoList();
|
||||
}
|
||||
|
||||
RemoteAction remote_action;
|
||||
remote_action.i.display_num = display_info_list_.size();
|
||||
remote_action.i.display_list =
|
||||
(char**)malloc(remote_action.i.display_num * sizeof(char*));
|
||||
|
||||
@@ -83,7 +83,7 @@ class Render {
|
||||
int video_height_ = 0;
|
||||
int video_width_last_ = 0;
|
||||
int video_height_last_ = 0;
|
||||
int selected_display_ = 1;
|
||||
int selected_display_ = 0;
|
||||
size_t video_size_ = 0;
|
||||
bool tab_selected_ = false;
|
||||
bool tab_opened_ = true;
|
||||
@@ -98,7 +98,7 @@ class Render {
|
||||
std::string mouse_control_button_label_ = "Mouse Control";
|
||||
std::string audio_capture_button_label_ = "Audio Capture";
|
||||
std::string remote_host_name_ = "";
|
||||
std::vector<ScreenCapturer::DisplayInfo> display_info_list_;
|
||||
std::vector<DisplayInfo> display_info_list_;
|
||||
SDL_Texture *stream_texture_ = nullptr;
|
||||
SDL_Rect stream_render_rect_;
|
||||
SDL_Rect stream_render_rect_last_;
|
||||
@@ -316,6 +316,7 @@ class Render {
|
||||
float about_window_height_ = 150;
|
||||
int screen_width_ = 1280;
|
||||
int screen_height_ = 720;
|
||||
int selected_display_ = 0;
|
||||
std::string connect_button_label_ = "Connect";
|
||||
char input_password_tmp_[7] = "";
|
||||
char input_password_[7] = "";
|
||||
@@ -398,7 +399,7 @@ class Render {
|
||||
DeviceControllerFactory *device_controller_factory_ = nullptr;
|
||||
MouseController *mouse_controller_ = nullptr;
|
||||
KeyboardCapturer *keyboard_capturer_ = nullptr;
|
||||
std::vector<ScreenCapturer::DisplayInfo> display_info_list_;
|
||||
std::vector<DisplayInfo> display_info_list_;
|
||||
uint64_t last_frame_time_;
|
||||
char client_id_[10] = "";
|
||||
char client_id_display_[12] = "";
|
||||
|
||||
@@ -63,13 +63,9 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
|
||||
last_mouse_event.button.y = event.button.y;
|
||||
|
||||
remote_action.m.x =
|
||||
(float)(event.button.x - props->stream_render_rect_.x +
|
||||
props->display_info_list_[props->selected_display_ - 1]
|
||||
.left) /
|
||||
render_width;
|
||||
(float)(event.button.x - props->stream_render_rect_.x) / render_width;
|
||||
remote_action.m.y =
|
||||
(float)(event.button.y - props->stream_render_rect_.y +
|
||||
props->display_info_list_[props->selected_display_ - 1].top) /
|
||||
(float)(event.button.y - props->stream_render_rect_.y) /
|
||||
render_height;
|
||||
|
||||
if (SDL_MOUSEBUTTONDOWN == event.type) {
|
||||
@@ -297,10 +293,9 @@ void Render::OnReceiveDataBufferCb(const char *data, size_t size,
|
||||
LOG_INFO("Remote hostname: [{}]", props->remote_host_name_);
|
||||
|
||||
for (int i = 0; i < host_info.i.display_num; i++) {
|
||||
props->display_info_list_.push_back(
|
||||
{std::string(host_info.i.display_list[i]), host_info.i.left[i],
|
||||
host_info.i.top[i], host_info.i.right[i],
|
||||
host_info.i.bottom[i]});
|
||||
props->display_info_list_.push_back(DisplayInfo(
|
||||
std::string(host_info.i.display_list[i]), host_info.i.left[i],
|
||||
host_info.i.top[i], host_info.i.right[i], host_info.i.bottom[i]));
|
||||
LOG_INFO("Remote display [{}:{}], bound [({}, {}) ({}, {})]", i + 1,
|
||||
props->display_info_list_[i].name,
|
||||
props->display_info_list_[i].left,
|
||||
@@ -319,7 +314,8 @@ void Render::OnReceiveDataBufferCb(const char *data, size_t size,
|
||||
} else {
|
||||
// remote
|
||||
if (ControlType::mouse == remote_action.type && render->mouse_controller_) {
|
||||
render->mouse_controller_->SendMouseCommand(remote_action);
|
||||
render->mouse_controller_->SendMouseCommand(remote_action,
|
||||
render->selected_display_);
|
||||
} else if (ControlType::audio_capture == remote_action.type) {
|
||||
if (remote_action.a) {
|
||||
render->StartSpeakerCapturer();
|
||||
@@ -335,6 +331,7 @@ void Render::OnReceiveDataBufferCb(const char *data, size_t size,
|
||||
remote_action.k.flag == KeyFlag::key_down);
|
||||
} else if (ControlType::display_id == remote_action.type) {
|
||||
if (render->screen_capturer_) {
|
||||
render->selected_display_ = remote_action.d;
|
||||
render->screen_capturer_->SwitchTo(remote_action.d);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user