Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Sway is an incredible window manager, and certainly one of the most well establi
blur_xray enable;
blur_ignore_transparent enable;
shadows enable;
use_drop_shadow enable;
corner_radius 20;
}
```
Expand All @@ -61,6 +62,7 @@ Sway is an incredible window manager, and certainly one of the most well establi
- `blur_xray <enable|disable>`
- `blur_ignore_transparent <enable|disable>`
- `shadows <enable|disable>`
- `use_drop_shadow <enable|disable>`
- `corner_radius <int>`
- `reset`: To reset/disable all previously applied effects to the layer application
+ Dim unfocused windows:
Expand Down
1 change: 1 addition & 0 deletions include/sway/layer_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct layer_criteria {
char *cmdlist;

bool shadow_enabled;
bool use_drop_shadow;
bool blur_enabled;
bool blur_xray;
bool blur_ignore_transparent;
Expand Down
1 change: 1 addition & 0 deletions include/sway/layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct sway_layer_surface {
struct wlr_layer_surface_v1 *layer_surface;

bool shadow_enabled;
bool use_drop_shadow;
bool blur_enabled;
bool blur_xray;
bool blur_ignore_transparent;
Expand Down
44 changes: 24 additions & 20 deletions sway/desktop/layer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ void layer_apply_criteria(struct sway_layer_surface *surface, struct layer_crite
surface->blur_xray = criteria->blur_xray;
surface->blur_ignore_transparent = criteria->blur_ignore_transparent;
surface->shadow_enabled = criteria->shadow_enabled;
surface->use_drop_shadow = criteria->use_drop_shadow;
} else {
// Reset
surface->corner_radius = 0;
surface->blur_enabled = false;
surface->blur_xray = false;
surface->blur_ignore_transparent = false;
surface->shadow_enabled = false;
surface->use_drop_shadow = false;
}
}

Expand Down Expand Up @@ -99,26 +101,27 @@ static void arrange_surface(struct sway_output *output, const struct wlr_box *fu
}

wlr_scene_node_set_enabled(&surface->shadow_node->node, surface->shadow_enabled);
if (surface->shadow_enabled) {
// Adjust the size and position of the shadow node
wlr_scene_shadow_set_size(surface->shadow_node,
surface->layer_surface->surface->current.width + config->shadow_blur_sigma * 2,
surface->layer_surface->surface->current.height + config->shadow_blur_sigma * 2);
int x = config->shadow_offset_x - config->shadow_blur_sigma;
int y = config->shadow_offset_y - config->shadow_blur_sigma;
wlr_scene_node_set_position(&surface->shadow_node->node, x, y);

wlr_scene_shadow_set_clipped_region(surface->shadow_node, (struct clipped_region) {
.corner_radius = surface->corner_radius,
.corners = CORNER_LOCATION_ALL,
.area = {
.x = -x,
.y = -y,
.width = surface->layer_surface->surface->current.width,
.height = surface->layer_surface->surface->current.height,
},
});
}
wlr_scene_shadow_set_type(surface->shadow_node,
surface->use_drop_shadow ? WLR_SCENE_SHADOW_TYPE_DROP : WLR_SCENE_SHADOW_TYPE_BOX);
// Adjust the size and position of the shadow node
const int shadow_size = wlr_scene_shadow_get_offset(surface->shadow_node);
wlr_scene_shadow_set_size(surface->shadow_node,
surface->layer_surface->surface->current.width + shadow_size * 2,
surface->layer_surface->surface->current.height + shadow_size * 2);
int x = config->shadow_offset_x - shadow_size;
int y = config->shadow_offset_y - shadow_size;
wlr_scene_node_set_position(&surface->shadow_node->node, x, y);

wlr_scene_shadow_set_clipped_region(surface->shadow_node, (struct clipped_region) {
.corner_radius = surface->corner_radius,
.corners = CORNER_LOCATION_ALL,
.area = {
.x = -x,
.y = -y,
.width = surface->layer_surface->surface->current.width,
.height = surface->layer_surface->surface->current.height,
},
});

wlr_scene_layer_surface_v1_configure(surface->scene, full_area, usable_area);
}
Expand Down Expand Up @@ -240,6 +243,7 @@ static struct sway_layer_surface *sway_layer_surface_create(
surface->blur_xray = false;
surface->blur_ignore_transparent = false;
surface->shadow_enabled = false;
surface->use_drop_shadow = false;

bool failed = false;
surface->shadow_node = alloc_scene_shadow(surface->tree, 0, 0,
Expand Down
3 changes: 3 additions & 0 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ void output_configure_scene(struct sway_output *output, struct wlr_scene_node *n
wlr_scene_buffer_set_corner_radius(buffer, surface->corner_radius, CORNER_LOCATION_ALL);
wlr_scene_shadow_set_blur_sigma(surface->shadow_node, config->shadow_blur_sigma);
wlr_scene_shadow_set_corner_radius(surface->shadow_node, surface->corner_radius);
if (surface->shadow_node->type == WLR_SCENE_SHADOW_TYPE_DROP) {
wlr_scene_shadow_set_reference_buffer(surface->shadow_node, buffer);
}
wlr_scene_buffer_set_backdrop_blur(buffer, surface->blur_enabled);
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, surface->blur_ignore_transparent);
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, surface->blur_xray);
Expand Down
8 changes: 4 additions & 4 deletions sway/desktop/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ static void arrange_container(struct sway_container *con,
corner_radius = con->corner_radius + config->border_thickness;
}

const int shadow_size = wlr_scene_shadow_get_offset(con->shadow);
wlr_scene_shadow_set_size(con->shadow,
width + config->shadow_blur_sigma * 2,
height + config->shadow_blur_sigma * 2);
width + shadow_size * 2, height + shadow_size * 2);

int x = config->shadow_offset_x - config->shadow_blur_sigma;
int y = config->shadow_offset_y - config->shadow_blur_sigma;
int x = config->shadow_offset_x - shadow_size;
int y = config->shadow_offset_y - shadow_size;
wlr_scene_node_set_position(&con->shadow->node, x, y);

wlr_scene_shadow_set_clipped_region(con->shadow, (struct clipped_region) {
Expand Down
5 changes: 5 additions & 0 deletions sway/layer_criteria.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static void init_criteria_effects(struct layer_criteria *criteria) {
criteria->blur_xray = false;
criteria->blur_ignore_transparent = false;
criteria->shadow_enabled = false;
criteria->use_drop_shadow = false;
}

static void copy_criteria_effects(struct layer_criteria *dst, struct layer_criteria *src) {
Expand All @@ -21,6 +22,7 @@ static void copy_criteria_effects(struct layer_criteria *dst, struct layer_crite
dst->blur_xray = src->blur_xray;
dst->blur_ignore_transparent = src->blur_ignore_transparent;
dst->shadow_enabled = src->shadow_enabled;
dst->use_drop_shadow = src->use_drop_shadow;
}

static bool layer_criteria_find(char *namespace,
Expand Down Expand Up @@ -81,6 +83,9 @@ static bool layer_criteria_parse(struct layer_criteria *criteria) {
} else if (strcmp(argv[0], "shadows") == 0) {
criteria->shadow_enabled = parse_boolean(argv[1], true);
continue;
} else if (strcmp(argv[0], "use_drop_shadow") == 0) {
criteria->use_drop_shadow = parse_boolean(argv[1], true);
continue;
} else if (strcmp(argv[0], "corner_radius") == 0) {
int value;
if (cmd_corner_radius_parse_value(argv[1], &value)) {
Expand Down
2 changes: 2 additions & 0 deletions sway/sway.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ The default colors are:
- *blur_xray* <enable|disable>
- *blur_ignore_transparent* <enable|disable>
- *shadows* <enable|disable>
- *use_drop_shadow* <enable|disable>
- *corner_radius* <integer>
- *reset* Resets all previously applied effects
- *reset* To reset/disable all previously applied effects to the layer application
Expand All @@ -873,6 +874,7 @@ The default colors are:
blur_xray enable;
blur_ignore_transparent enable;
shadows enable;
use_drop_shadow enable;
corner_radius 6;
}

Expand Down