From cd72d4b9e3273c0d2db520270ae3158cb714f1f6 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 6 Oct 2015 00:21:48 +0200 Subject: early hidpi support --- libmdock/thumbnailer.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libmdock/thumbnailer.c b/libmdock/thumbnailer.c index 0e3d44c..f5030db 100644 --- a/libmdock/thumbnailer.c +++ b/libmdock/thumbnailer.c @@ -73,6 +73,7 @@ void thumbnailer_schedule_update(WnckWindow *window) void thumbnailer_update_thumbnail(WnckWindow *window) { GdkDisplay *display = gdk_display_get_default(); + GdkScreen *screen = gdk_display_get_default_screen(display); ThumbnailData *tdata = g_object_get_qdata(G_OBJECT(window), mdock_thumbnail_data_quark()); g_return_if_fail(tdata); @@ -80,17 +81,21 @@ void thumbnailer_update_thumbnail(WnckWindow *window) GdkWindow *root = gdk_get_default_root_window(); + gdouble scale = MAX(gdk_screen_get_resolution(screen), 96.0) / 96.0; + const gint max_w = THUMBNAIL_MAX_WIDTH * scale, + max_h = THUMBNAIL_MAX_HEIGHT * scale; + int screen_x, screen_y, win_x, win_y, win_w, win_h, thumb_w, thumb_h, cur_w, cur_h; gdk_window_get_origin(root, &screen_x, &screen_y); wnck_window_get_client_window_geometry(window, &win_x, &win_y, &win_w, &win_h); - if (win_w > THUMBNAIL_MAX_WIDTH || win_h > THUMBNAIL_MAX_HEIGHT) { + if (win_w > max_w || win_h > max_h) { if (win_h > win_w) { - thumb_w = (THUMBNAIL_MAX_HEIGHT * win_w) / win_h; - thumb_h = THUMBNAIL_MAX_HEIGHT; + thumb_w = (max_h * win_w) / win_h; + thumb_h = max_h; } else { - thumb_w = THUMBNAIL_MAX_WIDTH; - thumb_h = (THUMBNAIL_MAX_WIDTH * win_h) / win_w; + thumb_w = max_w; + thumb_h = (max_w * win_h) / win_w; } } else { thumb_w = win_w; -- cgit v1.2.3