mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JRE-1142 [jdk11] hidpi is not detected since Ubuntu 18.04
(cherry picked from commit be4f8c0d9d)
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
58efca2d67
commit
275dc61155
@@ -37,6 +37,8 @@
|
||||
#include <sun_awt_X11GraphicsConfig.h>
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
#ifndef NO_XRANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
@@ -2063,6 +2065,26 @@ Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
|
||||
// in case of Xinerama individual screen scales are not supported
|
||||
char *name = get_output_screen_name(env, usingXinerama ? 0 : screen);
|
||||
double scale = getNativeScaleFactor(name, -1);
|
||||
|
||||
#ifndef HEADLESS
|
||||
// Ubuntu 18.04 introduced a new settings for a scale factor: Settings > Devices > Displays > Scale.
|
||||
// It is propagated to Xresource (and is read fine with 'xrdb' util) but is not propagated to GSettings
|
||||
// (gtk3 doesn't see it in 'gtk-xft-dpi'). So, retrieve "Xft.dpi" from Xresource via X11 API call.
|
||||
if (scale <= 0 && awt_display) {
|
||||
char *resource_manager = XResourceManagerString(awt_display);
|
||||
if (resource_manager) {
|
||||
XrmDatabase db = XrmGetStringDatabase(resource_manager);
|
||||
if (db) {
|
||||
XrmValue value;
|
||||
char *type;
|
||||
if (XrmGetResource(db, "Xft.dpi", "Xft.dpi", &type, &value)) {
|
||||
scale = (double)atoi(value.addr) / 96;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (name) {
|
||||
free(name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user