From 9388ee6491dd582622c4235fa487c84075d773f0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Sep 2018 12:47:37 +0200 Subject: [PATCH 1/4] Start pont for smother icons in HiDPI screens --- src/helper/icon-loader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index 2e65ae019c..e19e55ee8d 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -35,6 +35,10 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) icon_theme->prepend_search_path(get_path_ustring(SYSTEM, ICONS)); icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); } + Glib::RefPtr< Gdk::Screen > screen = Gdk::Screen::get_default(); + Glib::RefPtr< Gdk::Window > window = Gdk::Window::get_default_root_window(); + double scale = screen->get_monitor_scale_factor(screen->get_monitor_at_window(window)); + size *= scale; try { if (prefs->getBool("/theme/symbolicIcons", false)) { gchar colornamed[64]; -- GitLab From f5d28c4af6f8d4ef285fdaa3230e700ab7ba6823 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Sep 2018 13:00:04 +0200 Subject: [PATCH 2/4] Increase icons DPI --- src/helper/icon-loader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index e19e55ee8d..13fcae41b7 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -59,6 +59,10 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) else { _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); } + double xdpi = atof(Gdk::Pixbuf::get_option("x-dpi")) * scale; + double ydpi = atof(Gdk::Pixbuf::get_option("y-dpi")) * scale; + Gdk::Pixbuf::set_option("x-dpi", Glib::ustring.format(xdpi).c_str()); + Gdk::Pixbuf::set_option("y-dpi", Glib::ustring.format(ydpi).c_str()); } catch (const Gtk::IconThemeError &e) { std::cout << "Icon Loader: " << e.what() << std::endl; -- GitLab From 00ef9fa9e7667f7f2ea49101f21318dfbc0211e6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Sep 2018 13:04:03 +0200 Subject: [PATCH 3/4] Increase icons DPI II --- src/helper/icon-loader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index 13fcae41b7..7c7dd11eca 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -59,10 +59,10 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) else { _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); } - double xdpi = atof(Gdk::Pixbuf::get_option("x-dpi")) * scale; - double ydpi = atof(Gdk::Pixbuf::get_option("y-dpi")) * scale; - Gdk::Pixbuf::set_option("x-dpi", Glib::ustring.format(xdpi).c_str()); - Gdk::Pixbuf::set_option("y-dpi", Glib::ustring.format(ydpi).c_str()); + double xdpi = atof(_icon_pixbuf->get_option("x-dpi").c_str()) * scale; + double ydpi = atof(_icon_pixbuf->get_option("y-dpi").c_str()) * scale; + _icon_pixbuf->set_option("x-dpi", Glib::ustring::format(xdpi)); + _icon_pixbuf->set_option("y-dpi", Glib::ustring::format(ydpi)); } catch (const Gtk::IconThemeError &e) { std::cout << "Icon Loader: " << e.what() << std::endl; -- GitLab From 0fc6b54da15c5f929eaf130521fc8e76bc89fafd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Sep 2018 17:30:13 +0200 Subject: [PATCH 4/4] Nore on fixing icon preview --- src/helper/icon-loader.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index 7c7dd11eca..9ee0faa60b 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -35,34 +35,31 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) icon_theme->prepend_search_path(get_path_ustring(SYSTEM, ICONS)); icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); } - Glib::RefPtr< Gdk::Screen > screen = Gdk::Screen::get_default(); Glib::RefPtr< Gdk::Window > window = Gdk::Window::get_default_root_window(); - double scale = screen->get_monitor_scale_factor(screen->get_monitor_at_window(window)); - size *= scale; + double scale = window->get_scale_factor(); try { if (prefs->getBool("/theme/symbolicIcons", false)) { gchar colornamed[64]; sp_svg_write_color(colornamed, sizeof(colornamed), prefs->getInt("/theme/symbolicColor", 0x000000ff)); Gdk::RGBA color; color.set(colornamed); + // TODO: migrate to "lookup_by_gicon_for_scale" as documentations says about HiDPI. + // Currenlty docs couldent be followed + // broken, missing or incomplete Gtk::IconInfo iconinfo = - icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); + icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, scale, Gtk::ICON_LOOKUP_FORCE_SIZE); if (bool(iconinfo)) { // TODO: view if we need parametrice other colors bool was_symbolic = false; _icon_pixbuf = iconinfo.load_symbolic(color, color, color, color, was_symbolic); } else { - _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); + _icon_pixbuf = icon_theme->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_FORCE_SIZE); } } else { - _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); + _icon_pixbuf = icon_theme->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_FORCE_SIZE); } - double xdpi = atof(_icon_pixbuf->get_option("x-dpi").c_str()) * scale; - double ydpi = atof(_icon_pixbuf->get_option("y-dpi").c_str()) * scale; - _icon_pixbuf->set_option("x-dpi", Glib::ustring::format(xdpi)); - _icon_pixbuf->set_option("y-dpi", Glib::ustring::format(ydpi)); } catch (const Gtk::IconThemeError &e) { std::cout << "Icon Loader: " << e.what() << std::endl; -- GitLab