diff --git a/brightray/browser/win/win32_desktop_notifications/common.h b/brightray/browser/win/win32_desktop_notifications/common.h index b978c82579a..49095b76d65 100644 --- a/brightray/browser/win/win32_desktop_notifications/common.h +++ b/brightray/browser/win/win32_desktop_notifications/common.h @@ -21,8 +21,8 @@ struct NotificationData { }; template -inline T ScaleForDpi(T value, unsigned dpi) { - return value * dpi / 96; +constexpr T ScaleForDpi(T value, unsigned dpi, unsigned source_dpi = 96) { + return value * dpi / source_dpi; } struct ScreenMetrics { diff --git a/brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.cc b/brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.cc index c63fd40ae48..8dea03f1fc6 100644 --- a/brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.cc +++ b/brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.cc @@ -137,19 +137,21 @@ void DesktopNotificationController::InitializeFonts() { if (!body_font_) { NONCLIENTMETRICS metrics = { sizeof(metrics) }; if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, 0)) { - auto baseHeight = metrics.lfMessageFont.lfHeight; + auto base_height = metrics.lfMessageFont.lfHeight; HDC hdc = GetDC(NULL); - auto dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); + auto base_dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); ReleaseDC(NULL, hdc); + ScreenMetrics scr; + metrics.lfMessageFont.lfHeight = - (LONG)ScaleForDpi(baseHeight * 1.1f, dpi_y); + (LONG)ScaleForDpi(base_height * 1.1f, scr.dpi_y, base_dpi_y); body_font_ = CreateFontIndirect(&metrics.lfMessageFont); if (caption_font_) DeleteFont(caption_font_); metrics.lfMessageFont.lfHeight = - (LONG)ScaleForDpi(baseHeight * 1.4f, dpi_y); + (LONG)ScaleForDpi(base_height * 1.4f, scr.dpi_y, base_dpi_y); caption_font_ = CreateFontIndirect(&metrics.lfMessageFont); } }