Do not send mouse click event when cursor hovers over subwindows

This commit is contained in:
dijunkun
2024-06-13 16:56:03 +08:00
parent 053a0f86ad
commit 2906d05a4b
3 changed files with 12 additions and 3 deletions

View File

@@ -347,7 +347,7 @@ int MainWindow::Run() {
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
if (connection_established_ && !menu_hovered_) {
if (connection_established_ && !subwindow_hovered_) {
ImGui::SetMouseCursor(ImGuiMouseCursor_None);
}
@@ -374,7 +374,7 @@ int MainWindow::Run() {
}
{
menu_hovered_ = ImGui::IsWindowHovered();
subwindow_hovered_ = ImGui::IsWindowHovered();
// local
{
@@ -569,6 +569,7 @@ int MainWindow::Run() {
settings_window_pos_reset_ = false;
}
// Settings
ImGui::Begin(
localization::settings[localization_language_index_].c_str(),
nullptr,
@@ -576,6 +577,8 @@ int MainWindow::Run() {
ImGuiWindowFlags_NoSavedSettings);
{
subwindow_hovered_ = ImGui::IsWindowHovered();
const char *language_items[] = {
localization::language_zh[localization_language_index_].c_str(),
localization::language_en[localization_language_index_].c_str()};

View File

@@ -120,7 +120,7 @@ class MainWindow {
bool exit_ = false;
bool connection_established_ = false;
bool menu_hovered_ = false;
bool subwindow_hovered_ = false;
bool connect_button_pressed_ = false;
bool fullscreen_button_pressed_ = false;
bool settings_button_pressed_ = false;

View File

@@ -40,6 +40,9 @@ int MainWindow::ProcessMouseKeyEven(SDL_Event &ev) {
} else if (SDL_BUTTON_RIGHT == ev.button.button) {
remote_action.m.flag = MouseFlag::right_down;
}
if (subwindow_hovered_) {
remote_action.m.flag = MouseFlag::move;
}
SendData(peer_, DATA_TYPE::DATA, (const char *)&remote_action,
sizeof(remote_action));
} else if (SDL_MOUSEBUTTONUP == ev.type) {
@@ -49,6 +52,9 @@ int MainWindow::ProcessMouseKeyEven(SDL_Event &ev) {
} else if (SDL_BUTTON_RIGHT == ev.button.button) {
remote_action.m.flag = MouseFlag::right_up;
}
if (subwindow_hovered_) {
remote_action.m.flag = MouseFlag::move;
}
SendData(peer_, DATA_TYPE::DATA, (const char *)&remote_action,
sizeof(remote_action));
} else if (SDL_MOUSEMOTION == ev.type) {