[fix] fix render resolution

This commit is contained in:
dijunkun
2025-04-14 16:31:46 +08:00
parent 700fb2ec14
commit b7ce8b6299
3 changed files with 48 additions and 47 deletions

View File

@@ -1034,6 +1034,7 @@ void Render::ProcessSdlEvent() {
is_client_mode_ = false; is_client_mode_ = false;
reload_recent_connections_ = true; reload_recent_connections_ = true;
fullscreen_button_pressed_ = false; fullscreen_button_pressed_ = false;
just_created_ = false;
recent_connection_image_save_time_ = SDL_GetTicks(); recent_connection_image_save_time_ = SDL_GetTicks();
} else { } else {
LOG_INFO("Quit program"); LOG_INFO("Quit program");
@@ -1048,16 +1049,16 @@ void Render::ProcessSdlEvent() {
} else if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED && } else if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
stream_window_created_ && stream_window_created_ &&
event.window.windowID == SDL_GetWindowID(stream_window_)) { event.window.windowID == SDL_GetWindowID(stream_window_)) {
if (just_created_) {
just_created_ = false;
} else {
for (auto& [_, props] : client_properties_) { for (auto& [_, props] : client_properties_) {
if (!props->reset_control_bar_pos_) { if (!props->reset_control_bar_pos_) {
props->mouse_diff_control_bar_pos_x_ = 0; props->mouse_diff_control_bar_pos_x_ = 0;
props->mouse_diff_control_bar_pos_y_ = 0; props->mouse_diff_control_bar_pos_y_ = 0;
} }
if (!just_created_) {
props->reset_control_bar_pos_ = true; props->reset_control_bar_pos_ = true;
}
int stream_window_width, stream_window_height; int stream_window_width, stream_window_height;
SDL_GetWindowSize(stream_window_, &stream_window_width, SDL_GetWindowSize(stream_window_, &stream_window_width,
&stream_window_height); &stream_window_height);
@@ -1066,8 +1067,7 @@ void Render::ProcessSdlEvent() {
float video_ratio = (float)props->original_display_width_ / float video_ratio = (float)props->original_display_width_ /
(float)props->original_display_height_; (float)props->original_display_height_;
float video_ratio_reverse = float video_ratio_reverse = (float)props->original_display_height_ /
(float)props->original_display_height_ /
(float)props->original_display_width_; (float)props->original_display_width_;
float render_area_width = stream_window_width_; float render_area_width = stream_window_width_;
@@ -1099,7 +1099,7 @@ void Render::ProcessSdlEvent() {
(int)render_area_width, (int)render_area_height}; (int)render_area_width, (int)render_area_height};
} }
} }
}
} else if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED || } else if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED ||
event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
bool focus_gained = bool focus_gained =

View File

@@ -50,7 +50,6 @@ class Render {
bool control_window_width_is_changing_ = false; bool control_window_width_is_changing_ = false;
bool control_window_height_is_changing_ = false; bool control_window_height_is_changing_ = false;
bool p2p_mode_ = true; bool p2p_mode_ = true;
bool hostname_sent_ = false;
bool remember_password_ = false; bool remember_password_ = false;
char remote_password_[7] = ""; char remote_password_[7] = "";
float sub_stream_window_width_ = 1280; float sub_stream_window_width_ = 1280;

View File

@@ -357,9 +357,11 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
render->start_mouse_controller_ = false; render->start_mouse_controller_ = false;
render->start_keyboard_capturer_ = false; render->start_keyboard_capturer_ = false;
render->control_mouse_ = false; render->control_mouse_ = false;
render->hostname_sent_ = false;
render->original_display_width_ = 0;
render->original_display_height_ = 0;
props->connection_established_ = false; props->connection_established_ = false;
props->mouse_control_button_pressed_ = false; props->mouse_control_button_pressed_ = false;
props->hostname_sent_ = false;
if (render->audio_capture_) { if (render->audio_capture_) {
render->StopSpeakerCapturer(); render->StopSpeakerCapturer();
render->audio_capture_ = false; render->audio_capture_ = false;