[fix] fix cursor position when stream window initialization

This commit is contained in:
dijunkun
2024-11-21 10:34:04 +08:00
parent 2d2a578800
commit cf7ef89bf2

View File

@@ -41,7 +41,10 @@ int Render::ControlWindow() {
ImGui::SetNextWindowSize( ImGui::SetNextWindowSize(
ImVec2(control_window_width_, control_window_height_), ImGuiCond_Always); ImVec2(control_window_width_, control_window_height_), ImGuiCond_Always);
if (0 == control_winodw_pos_.x && 0 == control_winodw_pos_.y) {
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + 1), ImGuiCond_Once); ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + 1), ImGuiCond_Once);
}
if (reset_control_bar_pos_) { if (reset_control_bar_pos_) {
int new_control_window_pos_x, new_control_window_pos_y, new_cursor_pos_x, int new_control_window_pos_x, new_control_window_pos_y, new_cursor_pos_x,
@@ -88,7 +91,11 @@ int Render::ControlWindow() {
ImGui::SetNextWindowPos( ImGui::SetNextWindowPos(
ImVec2(new_control_window_pos_x, new_control_window_pos_y), ImVec2(new_control_window_pos_x, new_control_window_pos_y),
ImGuiCond_Always); ImGuiCond_Always);
if (0 != mouse_diff_control_bar_pos_x_ &&
0 != mouse_diff_control_bar_pos_y_) {
SDL_WarpMouseInWindow(stream_window_, new_cursor_pos_x, new_cursor_pos_y); SDL_WarpMouseInWindow(stream_window_, new_cursor_pos_x, new_cursor_pos_y);
}
reset_control_bar_pos_ = false; reset_control_bar_pos_ = false;
} else if (!reset_control_bar_pos_ && } else if (!reset_control_bar_pos_ &&
ImGui::IsMouseReleased(ImGuiPopupFlags_MouseButtonLeft) || ImGui::IsMouseReleased(ImGuiPopupFlags_MouseButtonLeft) ||