From 102e6de7a99536ef9567f7f2b502561bd5f1f553 Mon Sep 17 00:00:00 2001 From: lbonn Date: Thu, 30 Nov 2023 14:31:15 +0100 Subject: [PATCH] Revert "[IconFetcher] Apply scaling when loading images and icons" This reverts commit 2c0fcf9da94f562f7b7bc73ffcb9d2848ac72d87. --- include/mode-private.h | 4 +--- include/mode.h | 3 +-- include/modes/dmenuscriptshared.h | 1 - include/rofi-icon-fetcher.h | 11 ++++------- include/rofi-types.h | 1 - include/theme.h | 10 ---------- source/mode.c | 6 +++--- source/modes/combi.c | 6 +++--- source/modes/dmenu.c | 16 +++++----------- source/modes/drun.c | 13 ++++--------- source/modes/filebrowser.c | 14 ++++---------- source/modes/recursivebrowser.c | 4 ++-- source/modes/run.c | 12 ++++-------- source/modes/script.c | 9 +++------ source/modes/wayland-window.c | 9 +++------ source/modes/window.c | 15 +++++---------- source/rofi-icon-fetcher.c | 27 +++++++-------------------- source/rofi.c | 1 - source/theme.c | 14 +++----------- source/view.c | 8 ++++---- source/widgets/icon.c | 3 ++- source/xcb/display.c | 3 --- test/box-test.c | 6 ++---- test/helper-config-cmdline-parser.c | 6 ++---- test/helper-expand.c | 6 ++---- test/helper-pidfile.c | 6 ++---- test/helper-test.c | 6 ++---- test/helper-tokenize.c | 6 ++---- test/mode-test.c | 6 ++---- test/scrollbar-test.c | 6 ++---- test/textbox-test.c | 6 ++---- test/theme-parser-test.c | 11 +++++------ test/widget-test.c | 6 ++---- 33 files changed, 83 insertions(+), 178 deletions(-) diff --git a/include/mode-private.h b/include/mode-private.h index 7903df5a..56d4623d 100644 --- a/include/mode-private.h +++ b/include/mode-private.h @@ -76,7 +76,6 @@ typedef char *(*_mode_get_display_value)(const Mode *sw, * @param sw The #Mode pointer * @param selected_line The selected line * @param height The height of the icon - * @param scale The scale of the icon * * Obtains the icon if available * @@ -84,8 +83,7 @@ typedef char *(*_mode_get_display_value)(const Mode *sw, */ typedef cairo_surface_t *(*_mode_get_icon)(const Mode *sw, unsigned int selected_line, - unsigned int height, - guint scale); + unsigned int height); /** * @param sw The #Mode pointer diff --git a/include/mode.h b/include/mode.h index 18032d61..55ef750d 100644 --- a/include/mode.h +++ b/include/mode.h @@ -133,14 +133,13 @@ char *mode_get_display_value(const Mode *mode, unsigned int selected_line, * @param mode The mode to query * @param selected_line The entry to query * @param height The desired height of the icon. - * @param scale The desired scale of the icon. * * Returns the icon for the selected_line * * @returns allocated new cairo_surface_t if applicable */ cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line, - unsigned int height, guint scale); + unsigned int height); /** * @param mode The mode to query diff --git a/include/modes/dmenuscriptshared.h b/include/modes/dmenuscriptshared.h index e9747b90..e40e2954 100644 --- a/include/modes/dmenuscriptshared.h +++ b/include/modes/dmenuscriptshared.h @@ -13,7 +13,6 @@ typedef struct { /** Async icon fetch handler. */ uint32_t icon_fetch_uid; uint32_t icon_fetch_size; - guint icon_fetch_scale; /** Hidden meta keywords. */ char *meta; diff --git a/include/rofi-icon-fetcher.h b/include/rofi-icon-fetcher.h index 351f1ad7..34f9cfd2 100644 --- a/include/rofi-icon-fetcher.h +++ b/include/rofi-icon-fetcher.h @@ -26,9 +26,8 @@ void rofi_icon_fetcher_destroy(void); /** * @param name The name of the icon to fetch. * @param size The size of the icon to fetch. - * @param scale The scale of the icon to fetch. * - * Query the icon-theme for icon with name, size, and scale. + * Query the icon-theme for icon with name and size. * The returned icon will be the best match for the requested size, it should * still be resized to the actual size. * @@ -36,16 +35,14 @@ void rofi_icon_fetcher_destroy(void); * * @returns the uid identifying the request. */ -uint32_t rofi_icon_fetcher_query(const char *name, const int size, - const guint scale); +uint32_t rofi_icon_fetcher_query(const char *name, const int size); /** * @param name The name of the icon to fetch. * @param wsize The width of the icon to fetch. * @param hsize The height of the icon to fetch. - * @param scale The scale of the icon to fetch. * - * Query the icon-theme for icon with name, size, and scale. + * Query the icon-theme for icon with name and size. * The returned icon will be the best match for the requested size, it should * still be resized to the actual size. For icons it will take the min of wsize * and hsize. @@ -55,7 +52,7 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size, * @returns the uid identifying the request. */ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, - const int hsize, const guint scale); + const int hsize); /** * @param uid The unique id representing the matching request. diff --git a/include/rofi-types.h b/include/rofi-types.h index 07d21f78..4fc878d4 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -192,7 +192,6 @@ typedef struct { RofiScaleType scaling; int wsize; int hsize; - guint scale; RofiDirection dir; double angle; diff --git a/include/theme.h b/include/theme.h index 12dae2d2..f24a8854 100644 --- a/include/theme.h +++ b/include/theme.h @@ -402,14 +402,4 @@ GList *rofi_theme_get_list_distance(const widget *widget, const char *property); * @returns a GList of strings. */ GList *rofi_theme_get_list_strings(const widget *widget, const char *property); - -/** - * Display scale function type - */ -typedef guint (*disp_scale_func)(void); - -/** - * @param func The function pointer to scale getter. - */ -void rofi_theme_set_disp_scale_func(disp_scale_func func); #endif diff --git a/source/mode.c b/source/mode.c index da1debc6..7cb070de 100644 --- a/source/mode.c +++ b/source/mode.c @@ -85,11 +85,11 @@ char *mode_get_display_value(const Mode *mode, unsigned int selected_line, } cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line, - unsigned int height, guint scale) { + unsigned int height) { g_assert(mode != NULL); if (mode->_get_icon != NULL) { - cairo_surface_t *icon = mode->_get_icon(mode, selected_line, height, scale); + cairo_surface_t *icon = mode->_get_icon(mode, selected_line, height); if (icon) { return icon; } @@ -110,7 +110,7 @@ cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line, rofi_theme_find_property(wid, P_STRING, "fallback-icon", TRUE); if (p != NULL && (p->type == P_STRING && p->value.s)) { mode->fallback_icon_fetch_uid = - rofi_icon_fetcher_query(p->value.s, height, scale); + rofi_icon_fetcher_query(p->value.s, height); return NULL; } } diff --git a/source/modes/combi.c b/source/modes/combi.c index a87f8352..25b6ce85 100644 --- a/source/modes/combi.c +++ b/source/modes/combi.c @@ -286,12 +286,12 @@ static char *combi_get_completion(const Mode *sw, unsigned int index) { } static cairo_surface_t *combi_get_icon(const Mode *sw, unsigned int index, - unsigned int height, guint scale) { + unsigned int height) { CombiModePrivateData *pd = mode_get_private_data(sw); for (unsigned i = 0; i < pd->num_switchers; i++) { if (index >= pd->starts[i] && index < (pd->starts[i] + pd->lengths[i])) { - cairo_surface_t *icon = mode_get_icon( - pd->switchers[i].mode, index - pd->starts[i], height, scale); + cairo_surface_t *icon = + mode_get_icon(pd->switchers[i].mode, index - pd->starts[i], height); return icon; } } diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c index d82d49fa..41841074 100644 --- a/source/modes/dmenu.c +++ b/source/modes/dmenu.c @@ -57,9 +57,8 @@ static int dmenu_mode_init(Mode *sw); static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index); -static cairo_surface_t *dmenu_get_icon(const Mode *sw, - unsigned int selected_line, - unsigned int height, guint scale); +static cairo_surface_t * +dmenu_get_icon(const Mode *sw, unsigned int selected_line, unsigned int height); static char *dmenu_get_message(const Mode *sw); static inline unsigned int bitget(uint32_t const *const array, @@ -136,7 +135,6 @@ static void read_add_block(DmenuModePrivateData *pd, Block **block, char *data, // Init. (*block)->values[(*block)->length].icon_fetch_uid = 0; (*block)->values[(*block)->length].icon_fetch_size = 0; - (*block)->values[(*block)->length].icon_fetch_scale = 0; (*block)->values[(*block)->length].icon_name = NULL; (*block)->values[(*block)->length].meta = NULL; (*block)->values[(*block)->length].info = NULL; @@ -167,7 +165,6 @@ static void read_add(DmenuModePrivateData *pd, char *data, gsize len) { // Init. pd->cmd_list[pd->cmd_list_length].icon_fetch_uid = 0; pd->cmd_list[pd->cmd_list_length].icon_fetch_size = 0; - pd->cmd_list[pd->cmd_list_length].icon_fetch_scale = 0; pd->cmd_list[pd->cmd_list_length].icon_name = NULL; pd->cmd_list[pd->cmd_list_length].meta = NULL; pd->cmd_list[pd->cmd_list_length].info = NULL; @@ -698,8 +695,7 @@ static char *dmenu_get_message(const Mode *sw) { } static cairo_surface_t *dmenu_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int height, - guint scale) { + unsigned int height) { DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw); g_return_val_if_fail(pd->cmd_list != NULL, NULL); @@ -707,14 +703,12 @@ static cairo_surface_t *dmenu_get_icon(const Mode *sw, if (dr->icon_name == NULL) { return NULL; } - if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height && - dr->icon_fetch_scale == scale) { + if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height) { return rofi_icon_fetcher_get(dr->icon_fetch_uid); } uint32_t uid = dr->icon_fetch_uid = - rofi_icon_fetcher_query(dr->icon_name, height, scale); + rofi_icon_fetcher_query(dr->icon_name, height); dr->icon_fetch_size = height; - dr->icon_fetch_scale = scale; return rofi_icon_fetcher_get(uid); } diff --git a/source/modes/drun.c b/source/modes/drun.c index 265a4ad4..71322678 100644 --- a/source/modes/drun.c +++ b/source/modes/drun.c @@ -130,7 +130,6 @@ typedef struct { /* UID for the icon to display */ uint32_t icon_fetch_uid; uint32_t icon_fetch_size; - guint icon_fetch_scale; /* Type of desktop file */ DRunDesktopEntryType type; } DRunModeEntry; @@ -624,7 +623,6 @@ static void read_desktop_file(DRunModePrivateData *pd, const char *root, pd->entry_list[pd->cmd_list_length].icon_size = 0; pd->entry_list[pd->cmd_list_length].icon_fetch_uid = 0; pd->entry_list[pd->cmd_list_length].icon_fetch_size = 0; - pd->entry_list[pd->cmd_list_length].icon_fetch_scale = 0; pd->entry_list[pd->cmd_list_length].root = g_strdup(root); pd->entry_list[pd->cmd_list_length].path = g_strdup(path); pd->entry_list[pd->cmd_list_length].desktop_id = g_strdup(id); @@ -1349,23 +1347,20 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, } static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int height, guint scale) { + unsigned int height) { DRunModePrivateData *pd = (DRunModePrivateData *)mode_get_private_data(sw); if (pd->file_complete) { - return pd->completer->_get_icon(pd->completer, selected_line, height, - scale); + return pd->completer->_get_icon(pd->completer, selected_line, height); } g_return_val_if_fail(pd->entry_list != NULL, NULL); DRunModeEntry *dr = &(pd->entry_list[selected_line]); if (dr->icon_name != NULL) { - if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height && - dr->icon_fetch_scale == scale) { + if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height) { cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid); return icon; } - dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->icon_name, height, scale); + dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->icon_name, height); dr->icon_fetch_size = height; - dr->icon_fetch_scale = scale; cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid); return icon; } diff --git a/source/modes/filebrowser.c b/source/modes/filebrowser.c index 782390b3..47df4588 100644 --- a/source/modes/filebrowser.c +++ b/source/modes/filebrowser.c @@ -94,7 +94,6 @@ typedef struct { enum FBFileType type; uint32_t icon_fetch_uid; uint32_t icon_fetch_size; - guint icon_fetch_scale; gboolean link; time_t time; } FBFile; @@ -250,7 +249,6 @@ static void get_file_browser(Mode *sw) { pd->array[pd->array_length].type = UP; pd->array[pd->array_length].icon_fetch_uid = 0; pd->array[pd->array_length].icon_fetch_size = 0; - pd->array[pd->array_length].icon_fetch_scale = 0; pd->array[pd->array_length].link = FALSE; pd->array[pd->array_length].time = -1; pd->array_length++; @@ -286,7 +284,6 @@ static void get_file_browser(Mode *sw) { (rd->d_type == DT_DIR) ? DIRECTORY : RFILE; pd->array[pd->array_length].icon_fetch_uid = 0; pd->array[pd->array_length].icon_fetch_size = 0; - pd->array[pd->array_length].icon_fetch_scale = 0; pd->array[pd->array_length].link = FALSE; if (file_browser_config.sorting_method == FB_SORT_TIME) { @@ -307,7 +304,6 @@ static void get_file_browser(Mode *sw) { g_build_filename(cdir, rd->d_name, NULL); pd->array[pd->array_length].icon_fetch_uid = 0; pd->array[pd->array_length].icon_fetch_size = 0; - pd->array[pd->array_length].icon_fetch_scale = 0; pd->array[pd->array_length].link = TRUE; // Default to file. pd->array[pd->array_length].type = RFILE; @@ -608,22 +604,20 @@ static int file_browser_token_match(const Mode *sw, rofi_int_matcher **tokens, } static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int height, guint scale) { + unsigned int height) { FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *)mode_get_private_data(sw); g_return_val_if_fail(pd->array != NULL, NULL); FBFile *dr = &(pd->array[selected_line]); - if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height && - dr->icon_fetch_scale == scale) { + if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height) { return rofi_icon_fetcher_get(dr->icon_fetch_uid); } if (rofi_icon_fetcher_file_is_image(dr->path)) { - dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->path, height, scale); + dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->path, height); } else { - dr->icon_fetch_uid = rofi_icon_fetcher_query(icon_name[dr->type], height, scale); + dr->icon_fetch_uid = rofi_icon_fetcher_query(icon_name[dr->type], height); } dr->icon_fetch_size = height; - dr->icon_fetch_scale = scale; return rofi_icon_fetcher_get(dr->icon_fetch_uid); } diff --git a/source/modes/recursivebrowser.c b/source/modes/recursivebrowser.c index 40308796..fe0808ca 100644 --- a/source/modes/recursivebrowser.c +++ b/source/modes/recursivebrowser.c @@ -449,10 +449,10 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, return rofi_icon_fetcher_get(dr->icon_fetch_uid); } if (rofi_icon_fetcher_file_is_image(dr->path)) { - dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->path, height, scale); + dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->path, height); } else { dr->icon_fetch_uid = - rofi_icon_fetcher_query(rb_icon_name[dr->type], height, scale); + rofi_icon_fetcher_query(rb_icon_name[dr->type], height); } dr->icon_fetch_size = height; return rofi_icon_fetcher_get(dr->icon_fetch_uid); diff --git a/source/modes/run.c b/source/modes/run.c index 73821413..4bc5ec03 100644 --- a/source/modes/run.c +++ b/source/modes/run.c @@ -66,7 +66,6 @@ typedef struct { char *entry; uint32_t icon_fetch_uid; uint32_t icon_fetch_size; - guint icon_fetch_scale; /* Surface holding the icon. */ cairo_surface_t *icon; } RunEntry; @@ -538,26 +537,23 @@ static char *run_get_message(const Mode *sw) { return NULL; } static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int height, guint scale) { + unsigned int height) { RunModePrivateData *pd = (RunModePrivateData *)mode_get_private_data(sw); if (pd->file_complete) { - return pd->completer->_get_icon(pd->completer, selected_line, height, - scale); + return pd->completer->_get_icon(pd->completer, selected_line, height); } g_return_val_if_fail(pd->cmd_list != NULL, NULL); RunEntry *dr = &(pd->cmd_list[selected_line]); - if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height && - dr->icon_fetch_scale == scale) { + if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height) { cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid); return icon; } /** lookup icon */ char **str = g_strsplit(dr->entry, " ", 2); if (str) { - dr->icon_fetch_uid = rofi_icon_fetcher_query(str[0], height, scale); + dr->icon_fetch_uid = rofi_icon_fetcher_query(str[0], height); dr->icon_fetch_size = height; - dr->icon_fetch_scale = scale; g_strfreev(str); cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid); return icon; diff --git a/source/modes/script.c b/source/modes/script.c index f91bf444..2bf60286 100644 --- a/source/modes/script.c +++ b/source/modes/script.c @@ -248,7 +248,6 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg, retv[(*length)].urgent = FALSE; retv[(*length)].icon_fetch_uid = 0; retv[(*length)].icon_fetch_size = 0; - retv[(*length)].icon_fetch_scale = 0; retv[(*length)].nonselectable = FALSE; if (buf_length > 0 && (read_length > (ssize_t)buf_length)) { dmenuscript_parse_entry_extras(sw, &(retv[(*length)]), @@ -481,7 +480,7 @@ static char *script_get_message(const Mode *sw) { } static cairo_surface_t *script_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int height, guint scale) { + unsigned int height) { ScriptModePrivateData *pd = (ScriptModePrivateData *)mode_get_private_data(sw); g_return_val_if_fail(pd->cmd_list != NULL, NULL); @@ -489,13 +488,11 @@ static cairo_surface_t *script_get_icon(const Mode *sw, if (dr->icon_name == NULL) { return NULL; } - if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height && - dr->icon_fetch_scale == scale) { + if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height) { return rofi_icon_fetcher_get(dr->icon_fetch_uid); } - dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->icon_name, height, scale); + dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->icon_name, height); dr->icon_fetch_size = height; - dr->icon_fetch_scale = scale; return rofi_icon_fetcher_get(dr->icon_fetch_uid); } diff --git a/source/modes/wayland-window.c b/source/modes/wayland-window.c index fe7177b1..d48ff4a7 100644 --- a/source/modes/wayland-window.c +++ b/source/modes/wayland-window.c @@ -95,7 +95,6 @@ typedef struct { unsigned int cached_icon_uid; unsigned int cached_icon_size; - guint cached_icon_scale; } ForeignToplevelHandle; static void foreign_toplevel_handle_free(ForeignToplevelHandle *self) { @@ -572,7 +571,7 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, } static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int height, guint scale) { + unsigned int height) { WaylandWindowModePrivateData *pd = (WaylandWindowModePrivateData *)mode_get_private_data(sw); @@ -587,8 +586,7 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, return NULL; } - if (toplevel->cached_icon_uid > 0 && toplevel->cached_icon_size == height && - toplevel->cached_icon_scale == scale) { + if (toplevel->cached_icon_uid > 0 && toplevel->cached_icon_size == height) { return rofi_icon_fetcher_get(toplevel->cached_icon_uid); } @@ -599,8 +597,7 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, */ gchar *app_id_lower = g_utf8_strdown(toplevel->app_id, -1); toplevel->cached_icon_size = height; - toplevel->cached_icon_scale = scale; - toplevel->cached_icon_uid = rofi_icon_fetcher_query(app_id_lower, height, scale); + toplevel->cached_icon_uid = rofi_icon_fetcher_query(app_id_lower, height); g_free(app_id_lower); return rofi_icon_fetcher_get(toplevel->cached_icon_uid); diff --git a/source/modes/window.c b/source/modes/window.c index 062d6bb7..1d93e957 100644 --- a/source/modes/window.c +++ b/source/modes/window.c @@ -126,7 +126,6 @@ typedef struct { gboolean icon_checked; uint32_t icon_fetch_uid; uint32_t icon_fetch_size; - guint icon_fetch_scale; gboolean thumbnail_checked; gboolean icon_theme_checked; } client; @@ -1065,13 +1064,13 @@ static cairo_surface_t *get_net_wm_icon(xcb_window_t xid, return surface; } static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, - unsigned int size, guint scale) { + unsigned int size) { WindowModePrivateData *rmpd = mode_get_private_data(sw); client *c = window_client(rmpd, rmpd->ids->array[selected_line]); if (c == NULL) { return NULL; } - if (c->icon_fetch_size != size || c->icon_fetch_scale != scale) { + if (c->icon_fetch_size != size) { if (c->icon) { cairo_surface_destroy(c->icon); c->icon = NULL; @@ -1080,7 +1079,6 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, c->icon_checked = FALSE; c->icon_theme_checked = FALSE; } - // TODO: apply scaling to the following two routines if (config.window_thumbnail && c->thumbnail_checked == FALSE) { c->icon = x11_helper_get_screenshot_surface_window(c->window, size); c->thumbnail_checked = TRUE; @@ -1093,7 +1091,7 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, if (c->icon == NULL && c->class && c->icon_theme_checked == FALSE) { if (c->icon_fetch_uid == 0) { char *class_lower = g_utf8_strdown(c->class, -1); - c->icon_fetch_uid = rofi_icon_fetcher_query(class_lower, size, scale); + c->icon_fetch_uid = rofi_icon_fetcher_query(class_lower, size); g_free(class_lower); c->icon_fetch_size = size; } @@ -1105,13 +1103,11 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, } } else { if (c->icon == NULL && c->class && c->icon_theme_checked == FALSE) { - if (c->icon_fetch_uid == 0 || c->icon_fetch_size != size || - c->icon_fetch_size != scale) { + if (c->icon_fetch_uid == 0) { char *class_lower = g_utf8_strdown(c->class, -1); - c->icon_fetch_uid = rofi_icon_fetcher_query(class_lower, size, scale); + c->icon_fetch_uid = rofi_icon_fetcher_query(class_lower, size); g_free(class_lower); c->icon_fetch_size = size; - c->icon_fetch_scale = scale; } c->icon_theme_checked = rofi_icon_fetcher_get_ex(c->icon_fetch_uid, &(c->icon)); @@ -1126,7 +1122,6 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line, } } c->icon_fetch_size = size; - c->icon_fetch_scale = scale; return c->icon; } diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index bf6efc43..b39dda32 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -38,7 +38,6 @@ #include #include -#include "display.h" #include "keyb.h" #include "view.h" @@ -79,7 +78,6 @@ typedef struct { uint32_t uid; int wsize; int hsize; - guint scale; cairo_surface_t *surface; gboolean query_done; @@ -325,7 +323,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, } else { icon_path = icon_path_ = nk_xdg_theme_get_icon( rofi_icon_fetcher_data->xdg_context, themes, NULL, sentry->entry->name, - MIN(sentry->wsize, sentry->hsize), sentry->scale, TRUE); + MIN(sentry->wsize, sentry->hsize), 1, TRUE); if (icon_path_ == NULL) { g_debug("failed to get icon %s(%dx%d): n/a", sentry->entry->name, sentry->wsize, sentry->hsize); @@ -356,15 +354,9 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, return; } - int width = sentry->wsize, height = sentry->hsize; - if (width > 0) - width *= sentry->scale; - if (height > 0) - height *= sentry->scale; - GError *error = NULL; - GdkPixbuf *pb = - gdk_pixbuf_new_from_file_at_scale(icon_path, width, height, TRUE, &error); + GdkPixbuf *pb = gdk_pixbuf_new_from_file_at_scale( + icon_path, sentry->wsize, sentry->hsize, TRUE, &error); if (error != NULL) { g_warning("Failed to load image: %s", error->message); g_error_free(error); @@ -383,7 +375,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, } uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, - const int hsize, const guint scale) { + const int hsize) { g_debug("Query: %s(%dx%d)", name, wsize, hsize); IconFetcherNameEntry *entry = g_hash_table_lookup(rofi_icon_fetcher_data->icon_cache, name); @@ -396,8 +388,7 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, for (GList *iter = g_list_first(entry->sizes); iter; iter = g_list_next(iter)) { sentry = iter->data; - if (sentry->wsize == wsize && sentry->hsize == hsize && - sentry->scale == scale) { + if (sentry->wsize == wsize && sentry->hsize == hsize) { return sentry->uid; } } @@ -407,7 +398,6 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, sentry->uid = ++(rofi_icon_fetcher_data->last_uid); sentry->wsize = wsize; sentry->hsize = hsize; - sentry->scale = scale; sentry->entry = entry; sentry->query_done = FALSE; sentry->surface = NULL; @@ -422,8 +412,7 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, return sentry->uid; } -uint32_t rofi_icon_fetcher_query(const char *name, const int size, - const guint scale) { +uint32_t rofi_icon_fetcher_query(const char *name, const int size) { g_debug("Query: %s(%d)", name, size); IconFetcherNameEntry *entry = g_hash_table_lookup(rofi_icon_fetcher_data->icon_cache, name); @@ -436,8 +425,7 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size, for (GList *iter = g_list_first(entry->sizes); iter; iter = g_list_next(iter)) { sentry = iter->data; - if (sentry->wsize == size && sentry->hsize == size && - sentry->scale == scale) { + if (sentry->wsize == size && sentry->hsize == size) { return sentry->uid; } } @@ -447,7 +435,6 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size, sentry->uid = ++(rofi_icon_fetcher_data->last_uid); sentry->wsize = size; sentry->hsize = size; - sentry->scale = scale; sentry->entry = entry; sentry->surface = NULL; diff --git a/source/rofi.c b/source/rofi.c index 536aa74d..e25652c3 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1233,7 +1233,6 @@ int main(int argc, char *argv[]) { } TICK_N("Setup late Display"); - rofi_theme_set_disp_scale_func(display_scale); rofi_theme_parse_process_conditionals(); rofi_theme_parse_process_links(); TICK_N("Theme setup"); diff --git a/source/theme.c b/source/theme.c index b9f3a1b2..700c14d9 100644 --- a/source/theme.c +++ b/source/theme.c @@ -51,7 +51,6 @@ * list of config files we parsed. */ GList *parsed_config_files = NULL; -static disp_scale_func disp_scale = NULL; /** cleanup (free) the list of parsed config files. */ void rofi_theme_free_parsed_files(void) { @@ -1084,7 +1083,6 @@ void rofi_theme_get_color(const widget *widget, const char *property, static gboolean rofi_theme_get_image_inside(Property *p, const widget *widget, const char *property, cairo_t *d) { - const guint scale = disp_scale ? disp_scale() : 1; if (p) { if (p->type == P_INHERIT) { if (widget->parent) { @@ -1115,18 +1113,16 @@ static gboolean rofi_theme_get_image_inside(Property *p, const widget *widget, break; } if (p->value.image.surface_id == 0 || p->value.image.wsize != wsize || - p->value.image.hsize != hsize || p->value.image.scale != scale) { - p->value.image.surface_id = rofi_icon_fetcher_query_advanced( - p->value.image.url, wsize, hsize, scale); + p->value.image.hsize != hsize) { + p->value.image.surface_id = + rofi_icon_fetcher_query_advanced(p->value.image.url, wsize, hsize); p->value.image.wsize = wsize; p->value.image.hsize = hsize; - p->value.image.scale = scale; } cairo_surface_t *img = rofi_icon_fetcher_get(p->value.image.surface_id); if (img != NULL) { cairo_pattern_t *pat = cairo_pattern_create_for_surface(img); - cairo_surface_set_device_scale(img, scale, scale); cairo_pattern_set_extend(pat, CAIRO_EXTEND_REPEAT); cairo_set_source(d, pat); cairo_pattern_destroy(pat); @@ -1680,7 +1676,3 @@ gboolean rofi_theme_has_property(const widget *widget, const char *property) { Property *p = rofi_theme_find_property(wid, P_STRING, property, FALSE); return rofi_theme_has_property_inside(p, widget, property); } - -void rofi_theme_set_disp_scale_func(disp_scale_func func) { - disp_scale = func; -} diff --git a/source/view.c b/source/view.c index 6686cb47..38cca1c2 100644 --- a/source/view.c +++ b/source/view.c @@ -566,8 +566,8 @@ static void selection_changed_callback(G_GNUC_UNUSED listview *lv, int icon_height = widget_get_desired_height(WIDGET(state->icon_current_entry), WIDGET(state->icon_current_entry)->w); - cairo_surface_t *icon = mode_get_icon(state->sw, state->line_map[index], - icon_height, display_scale()); + cairo_surface_t *icon = + mode_get_icon(state->sw, state->line_map[index], icon_height); icon_set_surface(state->icon_current_entry, icon); } else { icon_set_surface(state->icon_current_entry, NULL); @@ -586,8 +586,8 @@ static void update_callback(textbox *t, icon *ico, unsigned int index, if (ico) { int icon_height = widget_get_desired_height(WIDGET(ico), WIDGET(ico)->w); - cairo_surface_t *icon = mode_get_icon(state->sw, state->line_map[index], - icon_height, display_scale()); + cairo_surface_t *icon = + mode_get_icon(state->sw, state->line_map[index], icon_height); icon_set_surface(ico, icon); } if (t) { diff --git a/source/widgets/icon.c b/source/widgets/icon.c index 12e5a4c8..186de3d0 100644 --- a/source/widgets/icon.c +++ b/source/widgets/icon.c @@ -31,6 +31,7 @@ #include "display.h" +#include "widgets/icon.h" #include "theme.h" #include "widgets/icon.h" #include "widgets/widget-internal.h" @@ -172,7 +173,7 @@ icon *icon_create(widget *parent, const char *name) { const char *filename = rofi_theme_get_string(WIDGET(b), "filename", NULL); if (filename) { - b->icon_fetch_id = rofi_icon_fetcher_query(filename, b->size, display_scale()); + b->icon_fetch_id = rofi_icon_fetcher_query(filename, b->size); } b->yalign = rofi_theme_get_double(WIDGET(b), "vertical-align", 0.5); b->yalign = MAX(0, MIN(1.0, b->yalign)); diff --git a/source/xcb/display.c b/source/xcb/display.c index a0c49bb8..7b8d05a5 100644 --- a/source/xcb/display.c +++ b/source/xcb/display.c @@ -2028,8 +2028,6 @@ static void xcb_display_revert_input_focus(void) { xcb_flush(xcb->connection); } -static guint xcb_display_scale(void) { return 1; } - static const struct _view_proxy *xcb_display_view_proxy(void) { return xcb_view_proxy; } @@ -2044,7 +2042,6 @@ static display_proxy display_ = { .monitor_active = xcb_display_monitor_active, .set_input_focus = xcb_display_set_input_focus, .revert_input_focus = xcb_display_revert_input_focus, - .scale = xcb_display_scale, .view = xcb_display_view_proxy, }; diff --git a/test/box-test.c b/test/box-test.c index 2696e380..5025a163 100644 --- a/test/box-test.c +++ b/test/box-test.c @@ -72,14 +72,12 @@ unsigned int test = 0; ThemeWidget *rofi_configuration = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/helper-config-cmdline-parser.c b/test/helper-config-cmdline-parser.c index e6d97fbb..7f091bc8 100644 --- a/test/helper-config-cmdline-parser.c +++ b/test/helper-config-cmdline-parser.c @@ -57,14 +57,12 @@ static int test = 0; #include "theme.h" ThemeWidget *rofi_theme = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/helper-expand.c b/test/helper-expand.c index e6098549..24cf96cb 100644 --- a/test/helper-expand.c +++ b/test/helper-expand.c @@ -58,14 +58,12 @@ ThemeWidget *rofi_theme = NULL; void rofi_clear_error_messages(void) {} void rofi_clear_warning_messages(void) {} uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/helper-pidfile.c b/test/helper-pidfile.c index e2a3dc57..b7a397ec 100644 --- a/test/helper-pidfile.c +++ b/test/helper-pidfile.c @@ -48,14 +48,12 @@ static int test = 0; ThemeWidget *rofi_theme = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/helper-test.c b/test/helper-test.c index d3584c8a..ce63e303 100644 --- a/test/helper-test.c +++ b/test/helper-test.c @@ -74,16 +74,14 @@ gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) { } uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } void rofi_clear_error_messages(void) {} void rofi_clear_warning_messages(void) {} uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/helper-tokenize.c b/test/helper-tokenize.c index c8624d38..21b0ae4e 100644 --- a/test/helper-tokenize.c +++ b/test/helper-tokenize.c @@ -44,14 +44,12 @@ ThemeWidget *rofi_theme = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } void rofi_clear_error_messages(void) {} diff --git a/test/mode-test.c b/test/mode-test.c index 5458fe55..4ba7548d 100644 --- a/test/mode-test.c +++ b/test/mode-test.c @@ -49,14 +49,12 @@ ThemeWidget *rofi_theme = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } void rofi_clear_error_messages(void) {} diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c index a6a69851..7782e130 100644 --- a/test/scrollbar-test.c +++ b/test/scrollbar-test.c @@ -63,14 +63,12 @@ unsigned int test = 0; ThemeWidget *rofi_configuration = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/textbox-test.c b/test/textbox-test.c index cad5d3ab..5208f260 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -59,14 +59,12 @@ unsigned int normal_window_mode = 0; ThemeWidget *rofi_configuration = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 1518e9d0..33c9aa68 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -45,16 +45,15 @@ #define REAL_COMPARE_DELTA 0.001 uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } void rofi_clear_error_messages(void) {} void rofi_clear_warning_messages(void) {} -uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { +uint32_t +rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, + G_GNUC_UNUSED G_GNUC_UNUSED const int wsize, + G_GNUC_UNUSED const int hsize) { return 0; } diff --git a/test/widget-test.c b/test/widget-test.c index b58cd49a..de12d6f9 100644 --- a/test/widget-test.c +++ b/test/widget-test.c @@ -48,14 +48,12 @@ unsigned int test = 0; ThemeWidget *rofi_configuration = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, - G_GNUC_UNUSED const int size, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int size) { return 0; } uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int wsize, - G_GNUC_UNUSED const int hsize, - G_GNUC_UNUSED const guint scale) { + G_GNUC_UNUSED const int hsize) { return 0; }