Skip to content

Commit ec38f43

Browse files
[linux/windows] Cap the minimum pixel ratio to 1 (#251)
Avoids generating a UI that is too small in high resolution monitors.
1 parent 61d651d commit ec38f43

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/common/glfw/embedder.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ static void GLFWFramebufferSizeCallback(GLFWwindow *window, int width_px,
9898

9999
double dpi = state->window_pixels_per_screen_coordinate *
100100
state->monitor_screen_coordinates_per_inch;
101+
// Limit the ratio to 1 to avoid rendering a smaller UI in standard resolution
102+
// monitors.
103+
double pixel_ratio = std::max(dpi / kDpPerInch, 1.0);
101104

102105
FlutterWindowMetricsEvent event = {};
103106
event.struct_size = sizeof(event);
104107
event.width = width_px;
105108
event.height = height_px;
106-
event.pixel_ratio = dpi / kDpPerInch;
109+
event.pixel_ratio = pixel_ratio;
107110
FlutterEngineSendWindowMetricsEvent(state->engine, &event);
108111
}
109112

0 commit comments

Comments
 (0)