Skip to content

Commit

Permalink
remote: Simplify DPI: add SetFullDPISettings
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Apr 17, 2024
1 parent 6a332e6 commit 9a92952
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
16 changes: 1 addition & 15 deletions src/hello_imgui/internal/backend_impls/abstract_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,21 +474,7 @@ bool _CheckDpiAwareParamsChanges(HelloImGui::RunnerParams& params)
dpiAwareParams.fontRenderingScale = io.FontGlobalScale;
}

bool didDpiWindowSizeFactorChange = false;
#ifdef HELLOIMGUI_WITH_NETIMGUI
if (params.remoteParams.enableRemoting)
{
float newWindowDPISizeFactor = NetImgui::GetWindowDPISizeFactor();
didDpiWindowSizeFactorChange = dpiAwareParams.dpiWindowSizeFactor != newWindowDPISizeFactor;
if (didDpiWindowSizeFactorChange)
{
printf("Warning: didDpiWindowSizeFactorChange=:true (from netImgui)\n");
dpiAwareParams.dpiWindowSizeFactor = newWindowDPISizeFactor;
}
}
#endif

if (didDpiWindowSizeFactorChange || didFontGlobalScaleChange)
if (didFontGlobalScaleChange)
{
printf("New DpiAwareParams:\n");
_LogDpiParams("_CheckDpiAwareParamsChanges (changed!)", dpiAwareParams);
Expand Down
9 changes: 6 additions & 3 deletions src/netimgui_remote_display/netimgui_remote_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ int main(int argc, char **argv)

runnerParams.callbacks.PostInit = [&pass_cmd_line_args_to_server]() {
pass_cmd_line_args_to_server();
NetImguiServer::UI::SetUseServerDisplayDPISettings(true);
float windowDPISizeFactor = HelloImGui::GetRunnerParams()->dpiAwareParams.dpiWindowSizeFactor;
NetImguiServer::UI::SetWindowDPISizeFactor(windowDPISizeFactor);
// KK3 set font scale here
};

runnerParams.callbacks.PreNewFrame = []() {
// Request each client to update their drawing content
NetImguiServer::UI::SetFullDPISettings(
ImGui::GetIO().DisplayFramebufferScale,
1.f / HelloImGui::DpiFontLoadingFactor()
);

NetImguiServer::App::UpdateRemoteContent();
};

Expand Down

0 comments on commit 9a92952

Please sign in to comment.