Skip to content

Commit b24f151

Browse files
vkarehraveit65
authored and
raveit65
committed
Support background fallback on HiDPI
This change is a super hacky way of supporting the fallback desktop background (without caja) on HiDPI displays. It does this by doing two things: providing a function for scaled-up background surfaces using cairo_scale; and triggering a change signal when the entire background schema is re-loaded, and so triggering a redraw.
1 parent abaa1e4 commit b24f151

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

libmate-desktop/mate-bg.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ mate_bg_load_from_preferences (MateBG *bg)
276276

277277
mate_bg_load_from_gsettings (bg, settings);
278278
g_object_unref (settings);
279+
280+
/* Queue change to force background redraw */
281+
queue_changed (bg);
279282
}
280283

281284
/* This function loads default system settings */
@@ -1137,6 +1140,36 @@ mate_bg_create_surface (MateBG *bg,
11371140
int width,
11381141
int height,
11391142
gboolean root)
1143+
{
1144+
return mate_bg_create_surface_scale (bg,
1145+
window,
1146+
width,
1147+
height,
1148+
1,
1149+
root);
1150+
}
1151+
1152+
/**
1153+
* mate_bg_create_surface:
1154+
* @bg: MateBG
1155+
* @window:
1156+
* @width:
1157+
* @height:
1158+
* @scale:
1159+
* @root:
1160+
*
1161+
* Create a scaled surface that can be set as background for @window. If @is_root is
1162+
* TRUE, the surface created will be created by a temporary X server connection
1163+
* so that if someone calls XKillClient on it, it won't affect the application
1164+
* who created it.
1165+
**/
1166+
cairo_surface_t *
1167+
mate_bg_create_surface_scale (MateBG *bg,
1168+
GdkWindow *window,
1169+
int width,
1170+
int height,
1171+
int scale,
1172+
gboolean root)
11401173
{
11411174
int pm_width, pm_height;
11421175

@@ -1156,10 +1189,9 @@ mate_bg_create_surface (MateBG *bg,
11561189

11571190
mate_bg_get_pixmap_size (bg, width, height, &pm_width, &pm_height);
11581191

1159-
11601192
if (root)
11611193
{
1162-
surface = make_root_pixmap (window, pm_width, pm_height);
1194+
surface = make_root_pixmap (window, pm_width * scale, pm_height * scale);
11631195
}
11641196
else
11651197
{
@@ -1168,6 +1200,8 @@ mate_bg_create_surface (MateBG *bg,
11681200
}
11691201

11701202
cr = cairo_create (surface);
1203+
cairo_scale (cr, (double)scale, (double)scale);
1204+
11711205
if (!bg->filename && bg->color_type == MATE_BG_COLOR_SOLID) {
11721206
gdk_cairo_set_source_rgba (cr, &(bg->primary));
11731207
}

libmate-desktop/mate-bg.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ cairo_surface_t *mate_bg_create_surface (MateBG *bg,
127127
int height,
128128
gboolean root);
129129

130+
cairo_surface_t *mate_bg_create_surface_scale (MateBG *bg,
131+
GdkWindow *window,
132+
int width,
133+
int height,
134+
int scale,
135+
gboolean root);
136+
130137
gboolean mate_bg_get_image_size (MateBG *bg,
131138
MateDesktopThumbnailFactory *factory,
132139
int best_width,

0 commit comments

Comments
 (0)