mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
Add control/release mouse button
This commit is contained in:
@@ -21,6 +21,8 @@ static std::vector<std::string> disconnect = {u8"断开连接", "Disconnect"};
|
|||||||
static std::vector<std::string> fullscreen = {u8"全屏", "Fullscreen"};
|
static std::vector<std::string> fullscreen = {u8"全屏", "Fullscreen"};
|
||||||
static std::vector<std::string> exit_fullscreen = {u8"退出全屏",
|
static std::vector<std::string> exit_fullscreen = {u8"退出全屏",
|
||||||
"Exit fullscreen"};
|
"Exit fullscreen"};
|
||||||
|
static std::vector<std::string> control_mouse = {u8"控制鼠标", "Mouse Control"};
|
||||||
|
static std::vector<std::string> release_mouse = {u8"释放鼠标", "Release Mouse"};
|
||||||
static std::vector<float> settings_window_width = {188.0f, 228.0f};
|
static std::vector<float> settings_window_width = {188.0f, 228.0f};
|
||||||
static std::vector<std::string> settings = {u8"设置", "Settings"};
|
static std::vector<std::string> settings = {u8"设置", "Settings"};
|
||||||
static std::vector<std::string> language = {u8"语言:", "Language:"};
|
static std::vector<std::string> language = {u8"语言:", "Language:"};
|
||||||
|
|||||||
@@ -314,6 +314,7 @@ int MainWindow::Run() {
|
|||||||
LOG_INFO("Connected with signal server, create p2p connection");
|
LOG_INFO("Connected with signal server, create p2p connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!inited_) {
|
||||||
connect_button_label_ =
|
connect_button_label_ =
|
||||||
connect_button_pressed_
|
connect_button_pressed_
|
||||||
? localization::disconnect[localization_language_index_]
|
? localization::disconnect[localization_language_index_]
|
||||||
@@ -323,8 +324,15 @@ int MainWindow::Run() {
|
|||||||
? localization::exit_fullscreen[localization_language_index_]
|
? localization::exit_fullscreen[localization_language_index_]
|
||||||
: localization::fullscreen[localization_language_index_];
|
: localization::fullscreen[localization_language_index_];
|
||||||
|
|
||||||
|
mouse_control_button_label_ =
|
||||||
|
mouse_control_button_pressed_
|
||||||
|
? localization::release_mouse[localization_language_index_]
|
||||||
|
: localization::control_mouse[localization_language_index_];
|
||||||
|
|
||||||
settings_button_label_ =
|
settings_button_label_ =
|
||||||
localization::settings[localization_language_index_];
|
localization::settings[localization_language_index_];
|
||||||
|
inited_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (start_screen_capture_ && !screen_capture_is_started_) {
|
if (start_screen_capture_ && !screen_capture_is_started_) {
|
||||||
StartScreenCapture();
|
StartScreenCapture();
|
||||||
@@ -347,7 +355,7 @@ int MainWindow::Run() {
|
|||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
if (connection_established_ && !subwindow_hovered_) {
|
if (connection_established_ && !subwindow_hovered_ && control_mouse_) {
|
||||||
ImGui::SetMouseCursor(ImGuiMouseCursor_None);
|
ImGui::SetMouseCursor(ImGuiMouseCursor_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,9 +364,9 @@ int MainWindow::Run() {
|
|||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Once);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Once);
|
||||||
|
|
||||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
ImGui::SetNextWindowSize(ImVec2(160, 210));
|
ImGui::SetNextWindowSize(ImVec2(160, 245));
|
||||||
} else {
|
} else {
|
||||||
ImGui::SetNextWindowSize(ImVec2(180, 210));
|
ImGui::SetNextWindowSize(ImVec2(190, 245));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connection_established_) {
|
if (!connection_established_) {
|
||||||
@@ -525,28 +533,44 @@ int MainWindow::Run() {
|
|||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
if (ImGui::Button(mouse_control_button_label_.c_str())) {
|
||||||
|
if (mouse_control_button_label_ ==
|
||||||
|
localization::control_mouse[localization_language_index_]) {
|
||||||
|
mouse_control_button_pressed_ = true;
|
||||||
|
control_mouse_ = true;
|
||||||
|
mouse_control_button_label_ =
|
||||||
|
localization::release_mouse[localization_language_index_];
|
||||||
|
} else {
|
||||||
|
control_mouse_ = false;
|
||||||
|
mouse_control_button_label_ =
|
||||||
|
localization::control_mouse[localization_language_index_];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Button(fullscreen_button_label_.c_str())) {
|
if (ImGui::Button(fullscreen_button_label_.c_str())) {
|
||||||
if (fullscreen_button_label_ ==
|
if (fullscreen_button_label_ ==
|
||||||
localization::fullscreen[localization_language_index_]) {
|
localization::fullscreen[localization_language_index_]) {
|
||||||
main_window_width_before_fullscreen_ = main_window_width_;
|
main_window_width_before_fullscreen_ = main_window_width_;
|
||||||
main_window_height_before_fullscreen_ = main_window_height_;
|
main_window_height_before_fullscreen_ = main_window_height_;
|
||||||
SDL_SetWindowFullscreen(main_window_, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(main_window_, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
fullscreen_button_pressed_ = true;
|
fullscreen_button_label_ =
|
||||||
|
localization::exit_fullscreen[localization_language_index_];
|
||||||
} else {
|
} else {
|
||||||
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
|
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
|
||||||
SDL_SetWindowSize(main_window_, main_window_width_before_fullscreen_,
|
SDL_SetWindowSize(main_window_, main_window_width_before_fullscreen_,
|
||||||
main_window_height_before_fullscreen_);
|
main_window_height_before_fullscreen_);
|
||||||
}
|
|
||||||
fullscreen_button_pressed_ = !fullscreen_button_pressed_;
|
|
||||||
fullscreen_button_label_ =
|
fullscreen_button_label_ =
|
||||||
fullscreen_button_pressed_
|
localization::fullscreen[localization_language_index_];
|
||||||
? localization::exit_fullscreen[localization_language_index_]
|
}
|
||||||
|
|
||||||
: localization::fullscreen[localization_language_index_];
|
|
||||||
fullscreen_button_pressed_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
if (ImGui::Button(settings_button_label_.c_str())) {
|
if (ImGui::Button(settings_button_label_.c_str())) {
|
||||||
settings_button_pressed_ = !settings_button_pressed_;
|
settings_button_pressed_ = !settings_button_pressed_;
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class MainWindow {
|
|||||||
std::string mac_addr_str_ = "";
|
std::string mac_addr_str_ = "";
|
||||||
std::string connect_button_label_ = "Connect";
|
std::string connect_button_label_ = "Connect";
|
||||||
std::string fullscreen_button_label_ = "Fullscreen";
|
std::string fullscreen_button_label_ = "Fullscreen";
|
||||||
|
std::string mouse_control_button_label_ = "Mouse Control";
|
||||||
std::string settings_button_label_ = "Setting";
|
std::string settings_button_label_ = "Setting";
|
||||||
char input_password_tmp_[7] = "";
|
char input_password_tmp_[7] = "";
|
||||||
char input_password_[7] = "";
|
char input_password_[7] = "";
|
||||||
@@ -118,16 +119,19 @@ class MainWindow {
|
|||||||
SDL_Window *main_window_;
|
SDL_Window *main_window_;
|
||||||
uint32_t pixformat_ = 0;
|
uint32_t pixformat_ = 0;
|
||||||
|
|
||||||
|
bool inited_ = false;
|
||||||
bool exit_ = false;
|
bool exit_ = false;
|
||||||
bool connection_established_ = false;
|
bool connection_established_ = false;
|
||||||
bool subwindow_hovered_ = false;
|
bool subwindow_hovered_ = false;
|
||||||
bool connect_button_pressed_ = false;
|
bool connect_button_pressed_ = false;
|
||||||
bool fullscreen_button_pressed_ = false;
|
bool fullscreen_button_pressed_ = false;
|
||||||
|
bool mouse_control_button_pressed_ = false;
|
||||||
bool settings_button_pressed_ = false;
|
bool settings_button_pressed_ = false;
|
||||||
bool received_frame_ = false;
|
bool received_frame_ = false;
|
||||||
bool is_create_connection_ = false;
|
bool is_create_connection_ = false;
|
||||||
bool audio_buffer_fresh_ = false;
|
bool audio_buffer_fresh_ = false;
|
||||||
bool rejoin_ = false;
|
bool rejoin_ = false;
|
||||||
|
bool control_mouse_ = false;
|
||||||
|
|
||||||
int fps_ = 0;
|
int fps_ = 0;
|
||||||
uint32_t start_time_;
|
uint32_t start_time_;
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int MainWindow::ProcessMouseKeyEven(SDL_Event &ev) {
|
int MainWindow::ProcessMouseKeyEven(SDL_Event &ev) {
|
||||||
|
if (!control_mouse_) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
float ratio = (float)(1280.0 / main_window_width_);
|
float ratio = (float)(1280.0 / main_window_width_);
|
||||||
|
|
||||||
RemoteAction remote_action;
|
RemoteAction remote_action;
|
||||||
@@ -178,6 +182,7 @@ void MainWindow::OnConnectionStatusCb(ConnectionStatus status,
|
|||||||
main_window->start_screen_capture_ = false;
|
main_window->start_screen_capture_ = false;
|
||||||
main_window->start_mouse_control_ = false;
|
main_window->start_mouse_control_ = false;
|
||||||
main_window->connection_established_ = false;
|
main_window->connection_established_ = false;
|
||||||
|
main_window->control_mouse_ = false;
|
||||||
if (main_window->dst_buffer_) {
|
if (main_window->dst_buffer_) {
|
||||||
memset(main_window->dst_buffer_, 0, 1280 * 720 * 3);
|
memset(main_window->dst_buffer_, 0, 1280 * 720 * 3);
|
||||||
SDL_UpdateTexture(main_window->sdl_texture_, NULL,
|
SDL_UpdateTexture(main_window->sdl_texture_, NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user