Commit ba3e309c authored by Oblomov's avatar Oblomov

X11 mixed dpi: set monitor scale factor from reported DPI

parent dd0aa5cb
......@@ -444,6 +444,9 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
GdkRectangle newgeo;
char *name;
int refresh_rate = 0;
double dpi = 96;
int rotated = 0;
int scale = 1;
gdk_x11_display_error_trap_push (display);
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
......@@ -469,6 +472,8 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
{
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
int j;
if (crtc->rotation & (RR_Rotate_90 | RR_Rotate_270))
rotated = 1;
for (j = 0; j < resources->nmode; j++)
{
......@@ -500,6 +505,11 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
name = g_strndup (output_info->name, output_info->nameLen);
dpi = (double)rr_monitors[i].height * 25.4 /
(rotated ? output_info->mm_width : output_info->mm_height);
scale = (int)(dpi/96);
if (scale < 1) scale = 1;
newgeo.x = rr_monitors[i].x / x11_screen->window_scale;
newgeo.y = rr_monitors[i].y / x11_screen->window_scale;
newgeo.width = rr_monitors[i].width / x11_screen->window_scale;
......@@ -522,7 +532,7 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
gdk_monitor_set_subpixel_layout (GDK_MONITOR (monitor),
translate_subpixel_order (output_info->subpixel_order));
gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh_rate);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->window_scale);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), scale);
gdk_monitor_set_model (GDK_MONITOR (monitor), name);
g_free (name);
......@@ -633,6 +643,9 @@ init_randr13 (GdkScreen *screen, gboolean *changed)
RROutput output = resources->outputs[i];
XRROutputInfo *output_info =
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
double dpi = 96;
int rotated = 0;
int scale = 1;
/* Non RandR1.2+ X driver have output name "default" */
randr12_compat |= !g_strcmp0 (output_info->name, "default");
......@@ -652,6 +665,8 @@ init_randr13 (GdkScreen *screen, gboolean *changed)
GdkRectangle newgeo;
int j;
int refresh_rate = 0;
if (crtc->rotation & (RR_Rotate_90 | RR_Rotate_270))
rotated = 1;
for (j = 0; j < resources->nmode; j++)
{
......@@ -680,6 +695,11 @@ init_randr13 (GdkScreen *screen, gboolean *changed)
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
name = g_strndup (output_info->name, output_info->nameLen);
dpi = (double)crtc->height * 25.4 /
(rotated ? output_info->mm_width : output_info->mm_height);
scale = (int)(dpi/96);
if (scale < 1) scale = 1;
newgeo.x = crtc->x / x11_screen->window_scale;
newgeo.y = crtc->y / x11_screen->window_scale;
newgeo.width = crtc->width / x11_screen->window_scale;
......@@ -702,7 +722,7 @@ init_randr13 (GdkScreen *screen, gboolean *changed)
gdk_monitor_set_subpixel_layout (GDK_MONITOR (monitor),
translate_subpixel_order (output_info->subpixel_order));
gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh_rate);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->window_scale);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), scale);
gdk_monitor_set_model (GDK_MONITOR (monitor), name);
g_free (name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment