diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c index 33eed35d0..e50d5267f 100755 --- a/modules/engines/ms-windows/msw_style.c +++ b/modules/engines/ms-windows/msw_style.c @@ -461,11 +461,11 @@ msw_style_setup_system_settings (void) } g_object_set (settings, "gtk-double-click-distance", - GetSystemMetrics (SM_CXDOUBLECLK), NULL); + MAX (xp_theme_unscale (GetSystemMetrics (SM_CXDOUBLECLK)), 1), NULL); g_object_set (settings, "gtk-double-click-time", GetDoubleClickTime (), NULL); g_object_set (settings, "gtk-dnd-drag-threshold", - GetSystemMetrics (SM_CXDRAG), NULL); + MAX (xp_theme_unscale (GetSystemMetrics (SM_CXDRAG)), 1), NULL); setup_menu_settings (settings); @@ -516,7 +516,8 @@ get_system_metric (XpThemeClass klazz, int id) if (!xp_theme_get_system_metric (klazz, id, &rval)) rval = GetSystemMetrics (id); - return rval; + /* in pixels of GTK+ (HiDPI) */ + return xp_theme_unscale (rval); } static void @@ -710,7 +711,7 @@ setup_msw_rc_style (void) "GtkScrollbar::min-slider-length = 8\n" "}widget_class \"*VScrollbar*\" style \"msw-vscrollbar\"\n" "widget_class \"*VScale*\" style \"msw-vscrollbar\"\n", - GetSystemMetrics (SM_CYVTHUMB), + xp_theme_unscale (GetSystemMetrics (SM_CYVTHUMB)), get_system_metric (XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL), 11); gtk_rc_parse_string (buf); @@ -724,7 +725,7 @@ setup_msw_rc_style (void) "GtkScrollbar::min-slider-length = 8\n" "}widget_class \"*HScrollbar*\" style \"msw-hscrollbar\"\n" "widget_class \"*HScale*\" style \"msw-hscrollbar\"\n", - GetSystemMetrics (SM_CXHTHUMB), + xp_theme_unscale (GetSystemMetrics (SM_CXHTHUMB)), get_system_metric (XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL), 11); gtk_rc_parse_string (buf); @@ -764,8 +765,8 @@ setup_msw_rc_style (void) "ythickness = %d\n" "}\n" "class \"GtkComboBox\" style \"msw-combobox\"\n", - xp_theme_is_active()? 1 : GetSystemMetrics (SM_CXEDGE), - xp_theme_is_active()? 1 : GetSystemMetrics (SM_CYEDGE)); + xp_theme_is_active()? 1 : xp_theme_unscale (GetSystemMetrics (SM_CXEDGE)), + xp_theme_is_active()? 1 : xp_theme_unscale (GetSystemMetrics (SM_CYEDGE))); gtk_rc_parse_string (buf); /* size of tree view header */ @@ -1844,7 +1845,7 @@ draw_box (GtkStyle *style, && xp_theme_draw (window, XP_THEME_ELEMENT_COMBOBUTTON, style, x, y, width, height, state_type, area)) { - cx = GetSystemMetrics(SM_CXVSCROLL); + cx = xp_theme_unscale (GetSystemMetrics (SM_CXVSCROLL)); x += width - cx; width = cx; diff --git a/modules/engines/ms-windows/xp_theme.c b/modules/engines/ms-windows/xp_theme.c index 284bff9c5..74c2ca59b 100755 --- a/modules/engines/ms-windows/xp_theme.c +++ b/modules/engines/ms-windows/xp_theme.c @@ -892,6 +892,20 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state) return ret; } +gint +xp_theme_scale (void) +{ + return MAX (gdk_screen_get_monitor_scale_factor (gdk_screen_get_default (), 0), 1); +} + +gint +xp_theme_unscale (gint size) +{ + gint s = xp_theme_scale (); + + return size > 0 ? (size + s - 1) / s : size; +} + HDC get_window_dc (GtkStyle *style, GdkWindow *window, @@ -977,6 +991,27 @@ xp_theme_draw (GdkWindow *win, XpThemeElement element, GtkStyle *style, pClip = NULL; } + /* HiDPI: the theme draws in pixels of Windows, with its pictures for + * the resolution, sharp, rather than with GDK's enlarged; the DC gets + * its mapping back in release_window_dc () */ + if (xp_theme_scale () > 1) + { + gint s = xp_theme_scale (); + + SetMapMode (dc, MM_TEXT); + rect.left *= s; + rect.top *= s; + rect.right *= s; + rect.bottom *= s; + if (pClip) + { + clip.left *= s; + clip.top *= s; + clip.right *= s; + clip.bottom *= s; + } + } + part_state = xp_theme_map_gtk_state (element, state_type); /* Support transparency */ @@ -1052,6 +1087,10 @@ xp_theme_get_element_dimensions (XpThemeElement element, *cy += gutter_size.cy * 2; } + /* in pixels of GTK+ (HiDPI) */ + *cx = xp_theme_unscale (*cx); + *cy = xp_theme_unscale (*cy); + return TRUE; } diff --git a/modules/engines/ms-windows/xp_theme.h b/modules/engines/ms-windows/xp_theme.h index f6becaf2f..de45e0a61 100755 --- a/modules/engines/ms-windows/xp_theme.h +++ b/modules/engines/ms-windows/xp_theme.h @@ -134,6 +134,11 @@ HDC get_window_dc (GtkStyle *style, RECT *rect_out); void release_window_dc (XpDCInfo *dc_info); +/* HiDPI: pixels of Windows for one of GTK+, and sizes of Windows in + * those of GTK+ */ +gint xp_theme_scale (void); +gint xp_theme_unscale (gint size); + void xp_theme_init (void); void xp_theme_reset (void); void xp_theme_exit (void);