diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2017-02-22 01:43:38 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2017-02-22 01:43:38 +0100 |
| commit | ab44fd32ebe1a298a0f5af2ca7da79f91944aeed (patch) | |
| tree | 1cac2c9c009fa116861c8fd1fabbe69a82ee3f02 | |
| parent | 94e1f1b3f623d98626c34d2ca2e1dc331a423bb1 (diff) | |
BackgroundSettings: use root_scaling to get proper bg size
(bzr r4220.1.2)
| -rw-r--r-- | lockscreen/BackgroundSettings.cpp | 27 | ||||
| -rw-r--r-- | lockscreen/BackgroundSettings.h | 2 |
2 files changed, 8 insertions, 21 deletions
diff --git a/lockscreen/BackgroundSettings.cpp b/lockscreen/BackgroundSettings.cpp index 61dfdad38..8ae7ca1b5 100644 --- a/lockscreen/BackgroundSettings.cpp +++ b/lockscreen/BackgroundSettings.cpp @@ -46,16 +46,6 @@ BackgroundSettings::BackgroundSettings() gnome_bg_load_from_preferences(gnome_bg_, settings); } -void BackgroundSettings::SetBackgroundFilename(std::string const& filename) -{ - if (filename.empty()) - return; - - gnome_bg_set_filename(gnome_bg_, filename.c_str()); - g_object_set_data(glib::object_cast<GObject>(gnome_bg_), - "ignore-pending-change", GINT_TO_POINTER(TRUE)); -} - BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor) { nux::Geometry const& geo = UScreen::GetDefault()->GetMonitorGeometry(monitor); @@ -69,18 +59,17 @@ BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor) double s_height = geo.height / scale; cairo_surface_t* bg_surface = nullptr; - if (settings.use_user_background() || !settings.background().empty()) + if (settings.use_user_background()) { - std::string old_bg; - if (!settings.use_user_background()) - { - old_bg = glib::gchar_to_string(gnome_bg_get_filename(gnome_bg_)); - SetBackgroundFilename(settings.background()); - } - bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), geo.width, geo.height, FALSE); + } + else if (!settings.background().empty()) + { + double root_scale = gdk_window_get_scale_factor(gdk_get_default_root_window()); + glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), geo.width * root_scale, geo.height * root_scale, FALSE, NULL)); - SetBackgroundFilename(old_bg); + if (pixbuf) + bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL); } if (bg_surface) diff --git a/lockscreen/BackgroundSettings.h b/lockscreen/BackgroundSettings.h index ad16f3388..2176cb33a 100644 --- a/lockscreen/BackgroundSettings.h +++ b/lockscreen/BackgroundSettings.h @@ -45,8 +45,6 @@ public: BaseTexturePtr GetBackgroundTexture(int monitor); private: - void SetBackgroundFilename(std::string const&); - glib::Object<_GnomeBG> gnome_bg_; }; |
