IDEA-153474 let JDK detect Xft.dpi value on non-GTK Linux DEs

Use the GTK method:

https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-object-get

to retrieve "gtk-xft-dpi" integer property of the X settings.

Add the property to JDK's GtkEngine & gtk2-interface.
Then read the property via GtkEngine from GTK LaF when "gnome.Xft/dpi" is undefined. It's assumed GTK LaF is forcedly installed.

(cherry picked from commit e05fc391ae0a3cc389e836441f882c0cf6ab3b99)
(cherry picked from commit fd615a5b45)
This commit is contained in:
Anton Tarasov
2016-03-22 21:55:51 +03:00
committed by alexey.ushakov@jetbrains.com
parent 1378c3fbc8
commit 7f1868ad70
4 changed files with 8 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ class GTKEngine {
static enum Settings {
GTK_FONT_NAME,
GTK_ICON_SIZES,
GTK_XFT_DPI,
GTK_CURSOR_BLINK,
GTK_CURSOR_BLINK_TIME
}

View File

@@ -163,6 +163,10 @@ class PangoFonts {
int dpi = 96;
Object value =
Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI");
if (!(value instanceof Integer)) {
value = GTKEngine.INSTANCE.getSetting(GTKEngine.Settings.GTK_XFT_DPI);
}
if (value instanceof Integer) {
dpi = ((Integer)value).intValue() / 1024;
if (dpi == -1) {

View File

@@ -2479,6 +2479,8 @@ static jobject gtk2_get_setting(JNIEnv *env, Setting property)
return get_string_property(env, settings, "gtk-font-name");
case GTK_ICON_SIZES:
return get_string_property(env, settings, "gtk-icon-sizes");
case GTK_XFT_DPI:
return get_integer_property(env, settings, "gtk-xft-dpi");
case GTK_CURSOR_BLINK:
return get_boolean_property(env, settings, "gtk-cursor-blink");
case GTK_CURSOR_BLINK_TIME:

View File

@@ -316,6 +316,7 @@ typedef enum
{
GTK_FONT_NAME,
GTK_ICON_SIZES,
GTK_XFT_DPI,
GTK_CURSOR_BLINK,
GTK_CURSOR_BLINK_TIME
} Setting;