backend: add new property: BORDER_WIDTH

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2022-01-13 11:31:31 +00:00
parent ffe1b79881
commit b7df820ff2
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
5 changed files with 17 additions and 0 deletions

View File

@ -350,6 +350,17 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
ps->backend_data->ops->set_image_property(
ps->backend_data, IMAGE_PROPERTY_BORDER_COLOR,
w->win_image, &border_color);
int border_width = w->g.border_width;
if (border_width == 0) {
// Some WM has borders implemented as WM frames
border_width = min3(w->frame_extents.left,
w->frame_extents.right,
w->frame_extents.bottom);
}
ps->backend_data->ops->set_image_property(
ps->backend_data, IMAGE_PROPERTY_BORDER_WIDTH,
w->win_image, &border_width);
}
}

View File

@ -61,6 +61,9 @@ enum image_properties {
// Border color
// 1 struct color, default: black
IMAGE_PROPERTY_BORDER_COLOR,
// Border width
// 1 int, default: 0
IMAGE_PROPERTY_BORDER_WIDTH,
};
enum image_operations {

View File

@ -452,6 +452,7 @@ bool default_set_image_property(backend_t *base attr_unused, enum image_properti
case IMAGE_PROPERTY_CORNER_RADIUS: tex->corner_radius = dargs[0]; break;
case IMAGE_PROPERTY_MAX_BRIGHTNESS: tex->max_brightness = dargs[0]; break;
case IMAGE_PROPERTY_BORDER_COLOR: tex->border_color = *(struct color *)arg; break;
case IMAGE_PROPERTY_BORDER_WIDTH: tex->border_width = *(int *)arg; break;
}
return true;

View File

@ -42,6 +42,7 @@ struct backend_image {
int ewidth, eheight;
bool color_inverted;
struct color border_color;
int border_width;
};
bool build_shadow(xcb_connection_t *, xcb_drawable_t, double opacity, int width,

View File

@ -134,6 +134,7 @@ static inline int attr_const normalize_i_range(int i, int min, int max) {
#define min2(a, b) ((a) > (b) ? (b) : (a))
#define max2(a, b) ((a) > (b) ? (a) : (b))
#define min3(a, b, c) min2(a, min2(b, c))
/// clamp `val` into interval [min, max]
#define clamp(val, min, max) max2(min2(val, max), min)