1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

[Widget] Change scaling of background-image

This commit is contained in:
Dave Davenport 2021-06-13 20:59:28 +02:00 committed by Dave Davenport
parent 0b4d885894
commit d972280559
2 changed files with 6 additions and 8 deletions

View file

@ -187,8 +187,8 @@ typedef struct
/** Stop color */ /** Stop color */
ThemeColor stop; ThemeColor stop;
/** cached image */
uint32_t surface_id; uint32_t surface_id;
uint32_t surface_size;
} RofiImage; } RofiImage;

View file

@ -930,17 +930,15 @@ void rofi_theme_get_image ( const widget *widget, const char *property, cairo_t
return; return;
} }
if ( p->value.image.type == ROFI_IMAGE_URL ) { if ( p->value.image.type == ROFI_IMAGE_URL ) {
uint32_t maxs = MAX(widget->h, widget->w); if ( p->value.image.surface_id == 0 ) {
if ( p->value.image.surface_id == 0 || p->value.image.surface_size != maxs ) { p->value.image.surface_id = rofi_icon_fetcher_query ( p->value.image.url, -1 );
p->value.image.surface_id = rofi_icon_fetcher_query ( p->value.image.url, maxs );
p->value.image.surface_size = maxs;
} }
cairo_surface_t *img = rofi_icon_fetcher_get ( p->value.image.surface_id ); cairo_surface_t *img = rofi_icon_fetcher_get ( p->value.image.surface_id );
if ( img != NULL ) { if ( img != NULL ) {
cairo_surface_reference ( img ); cairo_pattern_t * pat = cairo_pattern_create_for_surface ( img );
cairo_set_source_surface ( d, img, 0.0, 0.0 ); cairo_set_source ( d, pat );
cairo_surface_destroy ( img ); cairo_pattern_destroy ( pat );
} }
} else if ( p->value.image.type == ROFI_IMAGE_LINEAR_GRADIENT ) { } else if ( p->value.image.type == ROFI_IMAGE_LINEAR_GRADIENT ) {
cairo_pattern_t * pat = cairo_pattern_create_linear (0.0,0.0, widget->w, 0.0); cairo_pattern_t * pat = cairo_pattern_create_linear (0.0,0.0, widget->w, 0.0);