Compare commits

...

2 Commits

4 changed files with 19 additions and 17 deletions

View File

@@ -1060,13 +1060,18 @@ int Render::DestroyStreamWindow() {
if (stream_renderer_) { if (stream_renderer_) {
SDL_DestroyRenderer(stream_renderer_); SDL_DestroyRenderer(stream_renderer_);
stream_renderer_ = nullptr;
} }
if (stream_window_) { if (stream_window_) {
SDL_DestroyWindow(stream_window_); SDL_DestroyWindow(stream_window_);
stream_window_ = nullptr;
} }
stream_window_created_ = false; stream_window_created_ = false;
focus_on_stream_window_ = false;
stream_window_grabbed_ = false;
control_mouse_ = false;
return 0; return 0;
} }

View File

@@ -439,7 +439,7 @@ class Render {
bool screen_capturer_is_started_ = false; bool screen_capturer_is_started_ = false;
bool start_speaker_capturer_ = false; bool start_speaker_capturer_ = false;
bool speaker_capturer_is_started_ = false; bool speaker_capturer_is_started_ = false;
bool start_keyboard_capturer_ = true; bool start_keyboard_capturer_ = false;
bool show_cursor_ = false; bool show_cursor_ = false;
bool keyboard_capturer_is_started_ = false; bool keyboard_capturer_is_started_ = false;
bool foucs_on_main_window_ = false; bool foucs_on_main_window_ = false;

View File

@@ -72,17 +72,16 @@ int Render::SendKeyCommand(int key_code, bool is_down) {
} }
remote_action.k.key_value = key_code; remote_action.k.key_value = key_code;
if (!controlled_remote_id_.empty()) { std::string target_id = controlled_remote_id_.empty() ? focused_remote_id_
// std::shared_lock lock(client_properties_mutex_); : controlled_remote_id_;
if (client_properties_.find(controlled_remote_id_) != if (!target_id.empty()) {
client_properties_.end()) { if (client_properties_.find(target_id) != client_properties_.end()) {
auto props = client_properties_[controlled_remote_id_]; auto props = client_properties_[target_id];
if (props->connection_status_ == ConnectionStatus::Connected) { if (props->connection_status_ == ConnectionStatus::Connected &&
props->peer_) {
std::string msg = remote_action.to_json(); std::string msg = remote_action.to_json();
if (props->peer_) { SendDataFrame(props->peer_, msg.c_str(), msg.size(),
SendDataFrame(props->peer_, msg.c_str(), msg.size(), props->data_label_.c_str());
props->data_label_.c_str());
}
} }
} }
} }
@@ -758,6 +757,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
0, (int)render->title_bar_height_, 0, (int)render->title_bar_height_,
(int)render->stream_window_width_, (int)render->stream_window_width_,
(int)(render->stream_window_height_ - render->title_bar_height_)}; (int)(render->stream_window_height_ - render->title_bar_height_)};
render->start_keyboard_capturer_ = true;
break; break;
} }
case ConnectionStatus::Disconnected: case ConnectionStatus::Disconnected:
@@ -782,6 +782,8 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
event.user.data1 = props.get(); event.user.data1 = props.get();
SDL_PushEvent(&event); SDL_PushEvent(&event);
render->focus_on_stream_window_ = false;
break; break;
} }
case ConnectionStatus::IncorrectPassword: { case ConnectionStatus::IncorrectPassword: {
@@ -861,12 +863,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
render->start_screen_capturer_ = true; render->start_screen_capturer_ = true;
render->start_speaker_capturer_ = true; render->start_speaker_capturer_ = true;
render->remote_client_id_ = remote_id; render->remote_client_id_ = remote_id;
#ifdef CROSSDESK_DEBUG
render->start_mouse_controller_ = false;
render->start_keyboard_capturer_ = false;
#else
render->start_mouse_controller_ = true; render->start_mouse_controller_ = true;
#endif
if (std::all_of(render->connection_status_.begin(), if (std::all_of(render->connection_status_.begin(),
render->connection_status_.end(), [](const auto& kv) { render->connection_status_.end(), [](const auto& kv) {
return kv.first.find("web") != std::string::npos; return kv.first.find("web") != std::string::npos;