mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-16 04:02:15 +00:00
Make dpi_scale match original behavior (#1936)
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
This commit is contained in:
parent
6f98039492
commit
f2938d8d66
@ -184,21 +184,13 @@ static inline conky::display_output_base *display_output() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
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
|
#ifdef BUILD_GUI
|
||||||
auto output = display_output();
|
auto output = display_output();
|
||||||
if (output) {
|
if (output) {
|
||||||
if constexpr (std::is_integral_v<T>) {
|
return T(std::round(static_cast<double>(value) * output->get_dpi_scale()));
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* BUILD_GUI */
|
#endif /* BUILD_GUI */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user