clients/window: Allow rendering frame wihout shadow

Rendering the shadow currently renders some dark color near the border inside
the inner content.

Altough the content is on top of it, if the content has some transparency,
that dark color appears and this might be unwanted.

Add an option to not render the shadow to avoid that problem.

Signed-off-by: Joan Torres <joan.torres@suse.com>
This commit is contained in:
Joan Torres 2024-08-07 16:35:23 +02:00 committed by Leandro Ribeiro
parent e026fd6540
commit 53419eb991
5 changed files with 29 additions and 2 deletions

View File

@ -4937,6 +4937,20 @@ window_set_locked_pointer_motion_handler(struct window *window,
window->locked_pointer_motion_handler = handler;
}
void
window_set_shadow(struct window *window)
{
if (window->frame)
frame_unset_flag(window->frame->frame, FRAME_FLAG_NO_SHADOW);
}
void
window_unset_shadow(struct window *window)
{
if (window->frame)
frame_set_flag(window->frame->frame, FRAME_FLAG_NO_SHADOW);
}
void
window_set_title(struct window *window, const char *title)
{

View File

@ -530,6 +530,12 @@ void
window_set_locked_pointer_motion_handler(
struct window *window, window_locked_pointer_motion_handler_t handler);
void
window_set_shadow(struct window *window);
void
window_unset_shadow(struct window *window);
void
window_set_title(struct window *window, const char *title);

View File

@ -556,6 +556,8 @@ theme_render_frame(struct theme *t,
if (flags & THEME_FRAME_MAXIMIZED)
margin = 0;
else if (flags & THEME_FRAME_NO_SHADOW)
margin = t->margin;
else {
render_shadow(cr, t->shadow,
2, 2, width + 8, height + 8,

View File

@ -76,7 +76,8 @@ theme_destroy(struct theme *t);
enum {
THEME_FRAME_ACTIVE = 1,
THEME_FRAME_MAXIMIZED = 2,
THEME_FRAME_NO_TITLE = 4
THEME_FRAME_NO_TITLE = 4,
THEME_FRAME_NO_SHADOW = 8
};
void
@ -122,7 +123,8 @@ enum frame_status {
enum frame_flag {
FRAME_FLAG_ACTIVE = 0x1,
FRAME_FLAG_MAXIMIZED = 0x2
FRAME_FLAG_MAXIMIZED = 0x2,
FRAME_FLAG_NO_SHADOW = 0x4
};
enum {

View File

@ -1067,6 +1067,9 @@ frame_repaint(struct frame *frame, cairo_t *cr)
if (frame->flags & FRAME_FLAG_ACTIVE)
flags |= THEME_FRAME_ACTIVE;
if (frame->flags & FRAME_FLAG_NO_SHADOW)
flags |= THEME_FRAME_NO_SHADOW;
cairo_save(cr);
theme_render_frame(frame->theme, cr, frame->width, frame->height,
frame->title, &frame->title_rect,