@@ -534,8 +534,18 @@ static void main_window(void)
534534 }
535535 }
536536
537- gui_main_window_width = w_corrected * scale_multiplier;
538- gui_main_window_height = h_corrected * scale_multiplier;
537+ float window_width = (float )(w_corrected * scale_multiplier);
538+ float window_height = (float )(h_corrected * scale_multiplier);
539+
540+ ImGuiIO& io = ImGui::GetIO ();
541+ float fb_scale_x = io.DisplayFramebufferScale .x > 0 .0f ? io.DisplayFramebufferScale .x : 1 .0f ;
542+ float fb_scale_y = io.DisplayFramebufferScale .y > 0 .0f ? io.DisplayFramebufferScale .y : 1 .0f ;
543+
544+ window_width = roundf (window_width * fb_scale_x) / fb_scale_x;
545+ window_height = roundf (window_height * fb_scale_y) / fb_scale_y;
546+
547+ gui_main_window_width = (int )roundf (window_width);
548+ gui_main_window_height = (int )roundf (window_height);
539549
540550 ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, ImVec2 (0 .0f , 0 .0f ));
541551 ImGui::PushStyleVar (ImGuiStyleVar_WindowRounding, 0 .0f );
@@ -554,11 +564,14 @@ static void main_window(void)
554564 }
555565 else
556566 {
557- int window_x = (w - (w_corrected * scale_multiplier)) / 2 ;
558- int window_y = ((h - (h_corrected * scale_multiplier)) / 2 ) + (application_show_menu ? gui_main_menu_height : 0 );
567+ float window_x = ((float )w - window_width) * 0 .5f ;
568+ float window_y = (((float )h - window_height) * 0 .5f ) + (application_show_menu ? (float )gui_main_menu_height : 0 .0f );
569+
570+ window_x = roundf (window_x * fb_scale_x) / fb_scale_x;
571+ window_y = roundf (window_y * fb_scale_y) / fb_scale_y;
559572
560- ImGui::SetNextWindowSize (ImVec2 (( float )gui_main_window_width, ( float )gui_main_window_height ));
561- ImGui::SetNextWindowPos (ImGui::GetMainViewport ()->Pos + ImVec2 (( float ) window_x, ( float ) window_y));
573+ ImGui::SetNextWindowSize (ImVec2 (window_width, window_height ));
574+ ImGui::SetNextWindowPos (ImGui::GetMainViewport ()->Pos + ImVec2 (window_x, window_y));
562575 ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 .0f );
563576
564577 flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBringToFrontOnFocus;
@@ -570,7 +583,7 @@ static void main_window(void)
570583 float tex_h = (float )runtime.screen_width / (float )(SYSTEM_TEXTURE_WIDTH);
571584 float tex_v = (float )runtime.screen_height / (float )(SYSTEM_TEXTURE_HEIGHT);
572585
573- ImGui::Image ((ImTextureID)(intptr_t )ogl_renderer_emu_texture, ImVec2 (( float )gui_main_window_width, ( float )gui_main_window_height ), ImVec2 (0 , 0 ), ImVec2 (tex_h, tex_v));
586+ ImGui::Image ((ImTextureID)(intptr_t )ogl_renderer_emu_texture, ImVec2 (window_width, window_height ), ImVec2 (0 , 0 ), ImVec2 (tex_h, tex_v));
574587
575588 if (config_video.fps )
576589 gui_show_fps ();
0 commit comments