Revert "[IconFetcher] Apply scaling when loading images and icons"

This reverts commit 2c0fcf9da9.
This commit is contained in:
lbonn 2023-11-30 14:31:15 +01:00 committed by lbonn
parent 78888dd80d
commit 102e6de7a9
33 changed files with 83 additions and 178 deletions

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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.

View file

@ -192,7 +192,6 @@ typedef struct {
RofiScaleType scaling;
int wsize;
int hsize;
guint scale;
RofiDirection dir;
double angle;

View file

@ -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

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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;

View file

@ -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);
}

View file

@ -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);

View file

@ -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;
}

View file

@ -38,7 +38,6 @@
#include <cairo.h>
#include <pango/pangocairo.h>
#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;

View file

@ -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");

View file

@ -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;
}

View file

@ -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) {

View file

@ -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));

View file

@ -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,
};

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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) {}

View file

@ -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) {}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}