diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2021-01-15 13:44:22 -0700 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-01-15 22:53:19 +0100 |
commit | 915ba01ff1388028a85156feb08e9296c356a696 (patch) | |
tree | b9b478283b6a34b0b8e88358b18b9b7c6e85f462 /sway/config | |
parent | swaymsg: use 3 digits for fractional part of the refresh rate (diff) | |
download | sway-915ba01ff1388028a85156feb08e9296c356a696.tar.gz sway-915ba01ff1388028a85156feb08e9296c356a696.tar.zst sway-915ba01ff1388028a85156feb08e9296c356a696.zip |
config/output: correct refresh rate rounding error
Diffstat (limited to 'sway/config')
-rw-r--r-- | sway/config/output.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index b59cabd4..c9ec6745 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -237,7 +237,10 @@ struct output_config *store_output_config(struct output_config *oc) { | |||
237 | 237 | ||
238 | static void set_mode(struct wlr_output *output, int width, int height, | 238 | static void set_mode(struct wlr_output *output, int width, int height, |
239 | float refresh_rate, bool custom) { | 239 | float refresh_rate, bool custom) { |
240 | int mhz = (int)(refresh_rate * 1000); | 240 | // Not all floating point integers can be represented exactly |
241 | // as (int)(1000 * mHz / 1000.f) | ||
242 | // round() the result to avoid any error | ||
243 | int mhz = (int)round(refresh_rate * 1000); | ||
241 | 244 | ||
242 | if (wl_list_empty(&output->modes) || custom) { | 245 | if (wl_list_empty(&output->modes) || custom) { |
243 | sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); | 246 | sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); |