mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
- 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().
37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef LABWC_SCALED_IMG_BUFFER_H
|
|
#define LABWC_SCALED_IMG_BUFFER_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
struct wlr_scene_tree;
|
|
struct wlr_scene_node;
|
|
struct wlr_scene_buffer;
|
|
struct lab_img;
|
|
|
|
struct scaled_img_buffer {
|
|
struct scaled_scene_buffer *scaled_buffer;
|
|
struct wlr_scene_buffer *scene_buffer;
|
|
struct lab_img *img;
|
|
int width;
|
|
int height;
|
|
int padding;
|
|
};
|
|
|
|
/*
|
|
* Create an auto scaling image buffer, providing a wlr_scene_buffer node for
|
|
* display. It gets destroyed automatically when the backing scaled_scene_buffer
|
|
* is being destroyed which in turn happens automatically when the backing
|
|
* wlr_scene_buffer (or one of its parents) is being destroyed.
|
|
*/
|
|
struct scaled_img_buffer *scaled_img_buffer_create(struct wlr_scene_tree *parent,
|
|
struct lab_img *img, int width, int height, int padding);
|
|
|
|
/* Update image, width, height and padding of the scaled_img_buffer */
|
|
void scaled_img_buffer_update(struct scaled_img_buffer *self,
|
|
struct lab_img *img, int width, int height, int padding);
|
|
|
|
/* Obtain scaled_img_buffer from wlr_scene_node */
|
|
struct scaled_img_buffer *scaled_img_buffer_from_node(struct wlr_scene_node *node);
|
|
|
|
#endif /* LABWC_SCALED_IMG_BUFFER_H */
|