mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix dpi scaling
This commit is contained in:
@@ -729,6 +729,15 @@ int Render::SetupMainWindow() {
|
|||||||
|
|
||||||
SetupFontAndStyle();
|
SetupFontAndStyle();
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(main_window_, &main_window_width_real_,
|
||||||
|
&main_window_height_real_);
|
||||||
|
main_window_dpi_scaling_w_ = main_window_width_real_ / main_window_width_;
|
||||||
|
main_window_dpi_scaling_h_ = main_window_width_real_ / main_window_width_;
|
||||||
|
SDL_SetRenderScale(main_renderer_, main_window_dpi_scaling_w_,
|
||||||
|
main_window_dpi_scaling_h_);
|
||||||
|
LOG_INFO("Use dpi scaling [{}x{}] for main window",
|
||||||
|
main_window_dpi_scaling_w_, main_window_dpi_scaling_h_);
|
||||||
|
|
||||||
ImGui_ImplSDL3_InitForSDLRenderer(main_window_, main_renderer_);
|
ImGui_ImplSDL3_InitForSDLRenderer(main_window_, main_renderer_);
|
||||||
ImGui_ImplSDLRenderer3_Init(main_renderer_);
|
ImGui_ImplSDLRenderer3_Init(main_renderer_);
|
||||||
|
|
||||||
@@ -758,6 +767,19 @@ int Render::SetupStreamWindow() {
|
|||||||
|
|
||||||
SetupFontAndStyle();
|
SetupFontAndStyle();
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(stream_window_, &stream_window_width_real_,
|
||||||
|
&stream_window_height_real_);
|
||||||
|
|
||||||
|
stream_window_dpi_scaling_w_ =
|
||||||
|
stream_window_width_real_ / stream_window_width_;
|
||||||
|
stream_window_dpi_scaling_h_ =
|
||||||
|
stream_window_width_real_ / stream_window_width_;
|
||||||
|
|
||||||
|
SDL_SetRenderScale(stream_renderer_, stream_window_dpi_scaling_w_,
|
||||||
|
stream_window_dpi_scaling_h_);
|
||||||
|
LOG_INFO("Use dpi scaling [{}x{}] for stream window",
|
||||||
|
stream_window_dpi_scaling_w_, stream_window_dpi_scaling_h_);
|
||||||
|
|
||||||
ImGui_ImplSDL3_InitForSDLRenderer(stream_window_, stream_renderer_);
|
ImGui_ImplSDL3_InitForSDLRenderer(stream_window_, stream_renderer_);
|
||||||
ImGui_ImplSDLRenderer3_Init(stream_renderer_);
|
ImGui_ImplSDLRenderer3_Init(stream_renderer_);
|
||||||
|
|
||||||
|
|||||||
@@ -301,6 +301,10 @@ class Render {
|
|||||||
bool foucs_on_main_window_ = false;
|
bool foucs_on_main_window_ = false;
|
||||||
bool foucs_on_stream_window_ = false;
|
bool foucs_on_stream_window_ = false;
|
||||||
bool audio_capture_ = false;
|
bool audio_capture_ = false;
|
||||||
|
int main_window_width_real_ = 720;
|
||||||
|
int main_window_height_real_ = 540;
|
||||||
|
float main_window_dpi_scaling_w_ = 1.0f;
|
||||||
|
float main_window_dpi_scaling_h_ = 1.0f;
|
||||||
float main_window_width_default_ = 640;
|
float main_window_width_default_ = 640;
|
||||||
float main_window_height_default_ = 480;
|
float main_window_height_default_ = 480;
|
||||||
float main_window_width_ = 640;
|
float main_window_width_ = 640;
|
||||||
@@ -364,6 +368,10 @@ class Render {
|
|||||||
float stream_window_width_ = 1280;
|
float stream_window_width_ = 1280;
|
||||||
float stream_window_height_ = 720;
|
float stream_window_height_ = 720;
|
||||||
SDL_PixelFormat stream_pixformat_ = SDL_PIXELFORMAT_NV12;
|
SDL_PixelFormat stream_pixformat_ = SDL_PIXELFORMAT_NV12;
|
||||||
|
int stream_window_width_real_ = 1280;
|
||||||
|
int stream_window_height_real_ = 720;
|
||||||
|
float stream_window_dpi_scaling_w_ = 1.0f;
|
||||||
|
float stream_window_dpi_scaling_h_ = 1.0f;
|
||||||
|
|
||||||
bool label_inited_ = false;
|
bool label_inited_ = false;
|
||||||
bool connect_button_pressed_ = false;
|
bool connect_button_pressed_ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user