Module: wine Branch: master Commit: 5b8fdb97310f17396f496eea37bd5c0d27c7b337 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5b8fdb97310f17396f496eea37...
Author: Alexandre Julliard julliard@winehq.org Date: Tue May 17 21:19:22 2016 +0900
winecfg: Keep metrics in DPI-relative format when saving the theme.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
programs/winecfg/theme.c | 59 +++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-)
diff --git a/programs/winecfg/theme.c b/programs/winecfg/theme.c index 2b24dd9..1d915bc 100644 --- a/programs/winecfg/theme.c +++ b/programs/winecfg/theme.c @@ -1011,35 +1011,42 @@ static void read_sysparams(HWND hDlg)
static void apply_sysparams(void) { - NONCLIENTMETRICSW nonclient_metrics; + NONCLIENTMETRICSW ncm; int i, cnt = 0; int colors_idx[sizeof(metrics) / sizeof(metrics[0])]; COLORREF colors[sizeof(metrics) / sizeof(metrics[0])]; - - nonclient_metrics.cbSize = sizeof(nonclient_metrics); - SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(nonclient_metrics), &nonclient_metrics, 0); - - nonclient_metrics.iMenuWidth = nonclient_metrics.iMenuHeight = - metrics[IDC_SYSPARAMS_MENU - IDC_SYSPARAMS_BUTTON].size; - nonclient_metrics.iCaptionWidth = nonclient_metrics.iCaptionHeight = - metrics[IDC_SYSPARAMS_ACTIVE_TITLE - IDC_SYSPARAMS_BUTTON].size; - nonclient_metrics.iScrollWidth = nonclient_metrics.iScrollHeight = - metrics[IDC_SYSPARAMS_SCROLLBAR - IDC_SYSPARAMS_BUTTON].size; - - memcpy(&(nonclient_metrics.lfMenuFont), - &(metrics[IDC_SYSPARAMS_MENU_TEXT - IDC_SYSPARAMS_BUTTON].lf), - sizeof(LOGFONTW)); - memcpy(&(nonclient_metrics.lfCaptionFont), - &(metrics[IDC_SYSPARAMS_ACTIVE_TITLE_TEXT - IDC_SYSPARAMS_BUTTON].lf), - sizeof(LOGFONTW)); - memcpy(&(nonclient_metrics.lfStatusFont), - &(metrics[IDC_SYSPARAMS_TOOLTIP_TEXT - IDC_SYSPARAMS_BUTTON].lf), - sizeof(LOGFONTW)); - memcpy(&(nonclient_metrics.lfMessageFont), - &(metrics[IDC_SYSPARAMS_MSGBOX_TEXT - IDC_SYSPARAMS_BUTTON].lf), - sizeof(LOGFONTW)); - - SystemParametersInfoW(SPI_SETNONCLIENTMETRICS, sizeof(nonclient_metrics), &nonclient_metrics, + HDC hdc; + int dpi; + + hdc = GetDC( 0 ); + dpi = GetDeviceCaps( hdc, LOGPIXELSY ); + ReleaseDC( 0, hdc ); + + ncm.cbSize = sizeof(ncm); + SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0); + + /* convert metrics back to twips */ + ncm.iMenuWidth = ncm.iMenuHeight = + MulDiv( metrics[IDC_SYSPARAMS_MENU - IDC_SYSPARAMS_BUTTON].size, -1440, dpi ); + ncm.iCaptionWidth = ncm.iCaptionHeight = + MulDiv( metrics[IDC_SYSPARAMS_ACTIVE_TITLE - IDC_SYSPARAMS_BUTTON].size, -1440, dpi ); + ncm.iScrollWidth = ncm.iScrollHeight = + MulDiv( metrics[IDC_SYSPARAMS_SCROLLBAR - IDC_SYSPARAMS_BUTTON].size, -1440, dpi ); + ncm.iSmCaptionWidth = MulDiv( ncm.iSmCaptionWidth, -1440, dpi ); + ncm.iSmCaptionHeight = MulDiv( ncm.iSmCaptionHeight, -1440, dpi ); + + ncm.lfMenuFont = metrics[IDC_SYSPARAMS_MENU_TEXT - IDC_SYSPARAMS_BUTTON].lf; + ncm.lfCaptionFont = metrics[IDC_SYSPARAMS_ACTIVE_TITLE_TEXT - IDC_SYSPARAMS_BUTTON].lf; + ncm.lfStatusFont = metrics[IDC_SYSPARAMS_TOOLTIP_TEXT - IDC_SYSPARAMS_BUTTON].lf; + ncm.lfMessageFont = metrics[IDC_SYSPARAMS_MSGBOX_TEXT - IDC_SYSPARAMS_BUTTON].lf; + + ncm.lfMenuFont.lfHeight = MulDiv( ncm.lfMenuFont.lfHeight, -72, dpi ); + ncm.lfCaptionFont.lfHeight = MulDiv( ncm.lfCaptionFont.lfHeight, -72, dpi ); + ncm.lfStatusFont.lfHeight = MulDiv( ncm.lfStatusFont.lfHeight, -72, dpi ); + ncm.lfMessageFont.lfHeight = MulDiv( ncm.lfMessageFont.lfHeight, -72, dpi ); + ncm.lfSmCaptionFont.lfHeight = MulDiv( ncm.lfSmCaptionFont.lfHeight, -72, dpi ); + + SystemParametersInfoW(SPI_SETNONCLIENTMETRICS, sizeof(ncm), &ncm, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
for (i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++)