mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
ssd: rework titlebar button rendering
- fix that icons for normal/hovered/rounded buttons are not placed exactly the same position - fix blurry window button icons in scaled outputs This commit introduces lab_img and scaled_img_buffer and uses them for rendering icons in the window titlebar. Now the process of rendering button icons are split into 2 phases: loading with lab_img_load() and creating scene-nodes for them with scaled_img_buffer_create(). This might incur some additional overhead since we no longer preload icon textures, but the rendering of icon only happens for the first window as backing buffers are shared and the overhead won't be noticeable. This commit also simplifies the process of centering icon buffer in the button, by creating icon buffers in a fixed geometry via lab_img_render().
This commit is contained in:
parent
9a3412324d
commit
16dbdc64e5
25 changed files with 647 additions and 391 deletions
|
|
@ -8,14 +8,8 @@
|
|||
#include "common/macros.h"
|
||||
#include "common/mem.h"
|
||||
#include "common/string-helpers.h"
|
||||
#include "config.h"
|
||||
#include "desktop-entry.h"
|
||||
#include "img/img-png.h"
|
||||
#include "img/img-xpm.h"
|
||||
|
||||
#if HAVE_RSVG
|
||||
#include "img/img-svg.h"
|
||||
#endif
|
||||
#include "img/img.h"
|
||||
|
||||
#include "labwc.h"
|
||||
|
||||
|
|
@ -267,7 +261,22 @@ get_desktop_entry(struct sfdo *sfdo, const char *app_id)
|
|||
return entry;
|
||||
}
|
||||
|
||||
struct lab_data_buffer *
|
||||
static enum lab_img_type
|
||||
convert_img_type(enum sfdo_icon_file_format fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
case SFDO_ICON_FILE_FORMAT_PNG:
|
||||
return LAB_IMG_PNG;
|
||||
case SFDO_ICON_FILE_FORMAT_SVG:
|
||||
return LAB_IMG_SVG;
|
||||
case SFDO_ICON_FILE_FORMAT_XPM:
|
||||
return LAB_IMG_XPM;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
struct lab_img *
|
||||
desktop_entry_icon_lookup(struct server *server, const char *app_id, int size,
|
||||
float scale)
|
||||
{
|
||||
|
|
@ -308,26 +317,12 @@ desktop_entry_icon_lookup(struct server *server, const char *app_id, int size,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct lab_data_buffer *icon_buffer = NULL;
|
||||
|
||||
wlr_log(WLR_DEBUG, "loading icon file %s", ctx.path);
|
||||
|
||||
switch (ctx.format) {
|
||||
case SFDO_ICON_FILE_FORMAT_PNG:
|
||||
img_png_load(ctx.path, &icon_buffer, size, scale);
|
||||
break;
|
||||
case SFDO_ICON_FILE_FORMAT_SVG:
|
||||
#if HAVE_RSVG
|
||||
img_svg_load(ctx.path, &icon_buffer, size, scale);
|
||||
#endif
|
||||
break;
|
||||
case SFDO_ICON_FILE_FORMAT_XPM:
|
||||
img_xpm_load(ctx.path, &icon_buffer, size, scale);
|
||||
break;
|
||||
}
|
||||
struct lab_img *img = lab_img_load(convert_img_type(ctx.format), ctx.path, NULL);
|
||||
|
||||
free(ctx.path);
|
||||
return icon_buffer;
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue