mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
theme: round the corner button correctly
The rounded mask buffer to be applied to the corner button buffer should be resized and shifted when there's a vertical gap between the button and the window border.
This commit is contained in:
parent
707c188975
commit
2055e6d92c
1 changed files with 9 additions and 12 deletions
21
src/theme.c
21
src/theme.c
|
|
@ -174,14 +174,16 @@ create_rounded_buffer(struct theme *theme, enum corner corner,
|
|||
int height = theme->window_button_height;
|
||||
|
||||
/*
|
||||
* Round the hover overlay of corner buttons by
|
||||
* cropping the region within the window border.
|
||||
* Round the corner button by cropping the region within the window
|
||||
* border. See the picture in #2189 for reference.
|
||||
*/
|
||||
int margin_x = theme->window_titlebar_padding_width;
|
||||
int margin_y = (theme->title_height - theme->window_button_height) / 2;
|
||||
float white[4] = {1, 1, 1, 1};
|
||||
struct rounded_corner_ctx rounded_ctx = {
|
||||
.box = &(struct wlr_box){
|
||||
.width = theme->window_titlebar_padding_width + width,
|
||||
.height = height,
|
||||
.width = margin_x + width,
|
||||
.height = margin_y + height,
|
||||
},
|
||||
.radius = rc.corner_radius,
|
||||
.line_width = theme->border_width,
|
||||
|
|
@ -189,16 +191,11 @@ create_rounded_buffer(struct theme *theme, enum corner corner,
|
|||
.border_color = white,
|
||||
.corner = corner,
|
||||
};
|
||||
int mask_offset;
|
||||
if (corner == LAB_CORNER_TOP_LEFT) {
|
||||
mask_offset = -theme->window_titlebar_padding_width;
|
||||
} else {
|
||||
mask_offset = 0;
|
||||
}
|
||||
struct lab_data_buffer *mask_buffer = rounded_rect(&rounded_ctx);
|
||||
cairo_set_operator(cairo, CAIRO_OPERATOR_DEST_IN);
|
||||
cairo_set_source_surface(cairo,
|
||||
cairo_get_target(mask_buffer->cairo), mask_offset, 0);
|
||||
cairo_set_source_surface(cairo, cairo_get_target(mask_buffer->cairo),
|
||||
(corner == LAB_CORNER_TOP_LEFT) ? -margin_x : 0,
|
||||
-margin_y);
|
||||
cairo_paint(cairo);
|
||||
|
||||
cairo_surface_flush(cairo_get_target(cairo));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue