Skip to content

Commit

Permalink
Make dpi_scale match original behavior (#1936)
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
  • Loading branch information
Caellian committed May 26, 2024
1 parent 6f98039 commit f2938d8
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/display-output.hh
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,13 @@ static inline conky::display_output_base *display_output() {
}

template <typename T>
inline std::enable_if_t<std::is_arithmetic<T>::value, T> dpi_scale(T value) {
inline T dpi_scale(T value) {
static_assert(std::is_arithmetic_v<T>,
"dpi_scale value type must be a number");
#ifdef BUILD_GUI
auto output = display_output();
if (output) {
if constexpr (std::is_integral_v<T>) {
if (value > 0) {
return static_cast<T>(
std::ceil(static_cast<float>(value) * output->get_dpi_scale()));
} else {
return static_cast<T>(
std::floor(static_cast<float>(value) * output->get_dpi_scale()));
}
} else {
return value * output->get_dpi_scale();
}
return T(std::round(static_cast<double>(value) * output->get_dpi_scale()));
}
#endif /* BUILD_GUI */

Expand Down

0 comments on commit f2938d8

Please sign in to comment.