Commit 03ea666c authored by Oblomov's avatar Oblomov

X11 mixed dpi: get window scale factor from monitor

parent e97da503
......@@ -1971,13 +1971,19 @@ _gdk_x11_window_set_window_scale (GdkWindow *window,
}
else
{
int parent_abs_x = 0;
int parent_abs_y = 0;
if (window->parent) {
parent_abs_x = window->parent->abs_x;
parent_abs_y = window->parent->abs_y;
}
impl->unscaled_width = window->width * impl->window_scale;
impl->unscaled_height = window->height * impl->window_scale;
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
(window->x + window->parent->abs_x) * impl->window_scale,
(window->y + window->parent->abs_y) * impl->window_scale,
(window->x + parent_abs_x) * impl->window_scale,
(window->y + parent_abs_y) * impl->window_scale,
window->width * impl->window_scale,
window->height * impl->window_scale);
}
......@@ -5588,8 +5594,28 @@ gdk_x11_window_get_scale_factor (GdkWindow *window)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
GdkDisplay *display;
GdkMonitor *monitor;
int prev_scale = 1;
int monitor_scale = 1;
if (GDK_WINDOW_DESTROYED (window))
return 1;
return prev_scale;
/* We set the window scale factor to the scale factor
* of the monitor the window belongs to.
* TODO: this is a bit expensive to check every time
* get_scale_factor is invoked, a better approach would be
* to only recheck (1) if the window was moved or resized since
* the last time and (2) when the monitor layout changed.
*/
display = gdk_window_get_display (window);
monitor = gdk_display_get_monitor_at_window (display, window);
prev_scale = impl->window_scale;
monitor_scale = gdk_monitor_get_scale_factor (monitor);
if (monitor_scale != prev_scale) {
_gdk_x11_window_set_window_scale (window, monitor_scale);
}
return impl->window_scale;
}
......
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