summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2017-02-22 01:52:27 +0000
committerBileto Bot <ci-train-bot@canonical.com>2017-02-22 01:52:27 +0000
commit3ad92c9e8f5ecac4256b8c8fa04c564da283b1d1 (patch)
treedf854789d40386c045bf22d114759af6338ea901
parentbb11475ecd3599fbf9124ebfc1a039cddfb6a7e9 (diff)
parent3236b22100cb05fd2a16725abc926ab0602b7123 (diff)
BackgroundSettings: use gnome-bg to generate textures with proper scaling
When using non-user background, we ensure that the texture size matches the screen size, and also we now generate the background using an high quality pixmap, instead of stretching a non-scaled one. (LP: #1666359) (bzr r4221)
-rw-r--r--lockscreen/BackgroundSettings.cpp17
-rw-r--r--lockscreen/LockScreenBaseShield.cpp1
2 files changed, 13 insertions, 5 deletions
diff --git a/lockscreen/BackgroundSettings.cpp b/lockscreen/BackgroundSettings.cpp
index 7ffcee98d..d5ec73cea 100644
--- a/lockscreen/BackgroundSettings.cpp
+++ b/lockscreen/BackgroundSettings.cpp
@@ -53,23 +53,28 @@ BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor)
auto& settings = Settings::Instance();
nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);
- cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale);
cairo_t* c = cairo_graphics.GetInternalContext();
+ glib::Object<GnomeBG> gnome_bg;
double s_width = geo.width / scale;
double s_height = geo.height / scale;
cairo_surface_t* bg_surface = nullptr;
if (settings.use_user_background())
{
- bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), s_width, s_height, FALSE);
+ gnome_bg = gnome_bg_;
}
else if (!settings.background().empty())
{
- glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), s_width, s_height, FALSE, NULL));
+ gnome_bg = gnome_bg_new();
+ gnome_bg_set_filename(gnome_bg, settings.background().c_str());
+ gnome_bg_set_placement(gnome_bg, G_DESKTOP_BACKGROUND_STYLE_ZOOM);
+ }
- if (pixbuf)
- bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
+ if (gnome_bg)
+ {
+ auto *root_window = gdk_get_default_root_window();
+ bg_surface = gnome_bg_create_surface(gnome_bg, root_window, geo.width, geo.height, FALSE);
}
if (bg_surface)
@@ -85,6 +90,8 @@ BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor)
cairo_paint(c);
}
+ cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale);
+
if (!settings.logo().empty())
{
int grid_x_offset = GetGridOffset(s_width);
diff --git a/lockscreen/LockScreenBaseShield.cpp b/lockscreen/LockScreenBaseShield.cpp
index cfd56814c..f4c591fb8 100644
--- a/lockscreen/LockScreenBaseShield.cpp
+++ b/lockscreen/LockScreenBaseShield.cpp
@@ -145,6 +145,7 @@ void BaseShield::UpdateBackgroundTexture()
{
auto background_texture = bg_settings_->GetBackgroundTexture(monitor);
background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true));
+ background_layer_->SetGeometry(monitor_geo);
SetBackgroundLayer(background_layer_.get());
}
}