Added shadow config options
This commit is contained in:
parent
6d595669f1
commit
e65aceba67
14 changed files with 128 additions and 8 deletions
|
@ -14,6 +14,10 @@ Sway is an incredible window manager, and certainly one of the most well establi
|
||||||
|
|
||||||
+ Corner radius: `corner_radius <val>`
|
+ Corner radius: `corner_radius <val>`
|
||||||
+ Application saturation: `for_window [CRITERIA HERE] saturation <set|plus|minus> <val 0.0 <-> 2.0>`
|
+ Application saturation: `for_window [CRITERIA HERE] saturation <set|plus|minus> <val 0.0 <-> 2.0>`
|
||||||
|
+ Window shadows:
|
||||||
|
- `shadows on|off`
|
||||||
|
- `shadow_blur_radius <integer value 0 - 100>`
|
||||||
|
- `shadow_color <hex color with alpha> ex, #0000007F`
|
||||||
+ Dim unfocused windows:
|
+ Dim unfocused windows:
|
||||||
- `dim_inactive <float value 0.0 - 1.0>`
|
- `dim_inactive <float value 0.0 - 1.0>`
|
||||||
- `dim_inactive_colors.unfocused <hex color> ex, #000000FF`
|
- `dim_inactive_colors.unfocused <hex color> ex, #000000FF`
|
||||||
|
@ -23,7 +27,6 @@ Sway is an incredible window manager, and certainly one of the most well establi
|
||||||
|
|
||||||
+ fade in / out animations
|
+ fade in / out animations
|
||||||
+ window movement animations
|
+ window movement animations
|
||||||
+ drop shadows
|
|
||||||
+ blur
|
+ blur
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
|
@ -24,6 +24,10 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec --
|
||||||
# window corner radius in px
|
# window corner radius in px
|
||||||
corner_radius 10
|
corner_radius 10
|
||||||
|
|
||||||
|
shadows off
|
||||||
|
shadow_blur_radius 20
|
||||||
|
shadow_color #0000007F
|
||||||
|
|
||||||
# inactive window fade amount. 0.0 = no dimming, 1.0 = fully dimmed
|
# inactive window fade amount. 0.0 = no dimming, 1.0 = fully dimmed
|
||||||
dim_inactive 0.0
|
dim_inactive 0.0
|
||||||
dim_inactive_colors.unfocused #000000FF
|
dim_inactive_colors.unfocused #000000FF
|
||||||
|
|
|
@ -177,6 +177,9 @@ sway_cmd cmd_scratchpad;
|
||||||
sway_cmd cmd_seamless_mouse;
|
sway_cmd cmd_seamless_mouse;
|
||||||
sway_cmd cmd_set;
|
sway_cmd cmd_set;
|
||||||
sway_cmd cmd_shortcuts_inhibitor;
|
sway_cmd cmd_shortcuts_inhibitor;
|
||||||
|
sway_cmd cmd_shadow_blur_radius;
|
||||||
|
sway_cmd cmd_shadow_color;
|
||||||
|
sway_cmd cmd_shadows;
|
||||||
sway_cmd cmd_show_marks;
|
sway_cmd cmd_show_marks;
|
||||||
sway_cmd cmd_smart_borders;
|
sway_cmd cmd_smart_borders;
|
||||||
sway_cmd cmd_smart_gaps;
|
sway_cmd cmd_smart_gaps;
|
||||||
|
|
|
@ -474,6 +474,9 @@ struct sway_config {
|
||||||
float unfocused[4];
|
float unfocused[4];
|
||||||
float urgent[4];
|
float urgent[4];
|
||||||
} dim_inactive_colors;
|
} dim_inactive_colors;
|
||||||
|
bool shadow_enabled;
|
||||||
|
int shadow_blur_sigma;
|
||||||
|
float shadow_color[4];
|
||||||
|
|
||||||
char *swaynag_command;
|
char *swaynag_command;
|
||||||
struct swaynag_instance swaynag_config_errors;
|
struct swaynag_instance swaynag_config_errors;
|
||||||
|
|
|
@ -113,6 +113,8 @@ struct sway_container {
|
||||||
// Hidden scratchpad containers have a NULL parent.
|
// Hidden scratchpad containers have a NULL parent.
|
||||||
bool scratchpad;
|
bool scratchpad;
|
||||||
|
|
||||||
|
bool shadow_enabled;
|
||||||
|
|
||||||
float saturation;
|
float saturation;
|
||||||
|
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
|
@ -87,6 +87,9 @@ static const struct cmd_handler handlers[] = {
|
||||||
{ "popup_during_fullscreen", cmd_popup_during_fullscreen },
|
{ "popup_during_fullscreen", cmd_popup_during_fullscreen },
|
||||||
{ "seat", cmd_seat },
|
{ "seat", cmd_seat },
|
||||||
{ "set", cmd_set },
|
{ "set", cmd_set },
|
||||||
|
{ "shadow_blur_radius", cmd_shadow_blur_radius },
|
||||||
|
{ "shadow_color", cmd_shadow_color },
|
||||||
|
{ "shadows", cmd_shadows },
|
||||||
{ "show_marks", cmd_show_marks },
|
{ "show_marks", cmd_show_marks },
|
||||||
{ "smart_borders", cmd_smart_borders },
|
{ "smart_borders", cmd_smart_borders },
|
||||||
{ "smart_gaps", cmd_smart_gaps },
|
{ "smart_gaps", cmd_smart_gaps },
|
||||||
|
|
25
sway/commands/shadow_blur_radius.c
Normal file
25
sway/commands/shadow_blur_radius.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/tree/arrange.h"
|
||||||
|
#include "sway/tree/container.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
struct cmd_results *cmd_shadow_blur_radius(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "shadow_blur_radius", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *inv;
|
||||||
|
int value = strtol(argv[0], &inv, 10);
|
||||||
|
if (*inv != '\0' || value < 0 || value > 99) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "Invalid size specified");
|
||||||
|
}
|
||||||
|
|
||||||
|
config->shadow_blur_sigma = value;
|
||||||
|
|
||||||
|
arrange_root();
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
25
sway/commands/shadow_color.c
Normal file
25
sway/commands/shadow_color.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "log.h"
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/output.h"
|
||||||
|
#include "sway/tree/arrange.h"
|
||||||
|
#include "sway/tree/container.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
struct cmd_results *cmd_shadow_color(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "shadow_color", EXPECTED_AT_LEAST, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t color;
|
||||||
|
if (!parse_color(argv[0], &color)) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "Invalid %s color %s",
|
||||||
|
"shadow_color", argv[0]);
|
||||||
|
}
|
||||||
|
color_to_rgba(config->shadow_color, color);
|
||||||
|
|
||||||
|
arrange_root();
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
31
sway/commands/shadows.c
Normal file
31
sway/commands/shadows.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/tree/arrange.h"
|
||||||
|
#include "sway/tree/view.h"
|
||||||
|
#include "sway/tree/container.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "stringop.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
struct cmd_results *cmd_shadows(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = checkarg(argc, "shadows", EXPECTED_AT_LEAST, 1);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sway_container *con = config->handler_context.container;
|
||||||
|
|
||||||
|
bool result = parse_boolean(argv[0], config->shadow_enabled);
|
||||||
|
if (con == NULL) {
|
||||||
|
config->shadow_enabled = result;
|
||||||
|
} else {
|
||||||
|
con->shadow_enabled = result;
|
||||||
|
container_damage_whole(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
arrange_root();
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
|
@ -330,6 +330,9 @@ static void config_defaults(struct sway_config *config) {
|
||||||
config->dim_inactive = 0.0f;
|
config->dim_inactive = 0.0f;
|
||||||
color_to_rgba(config->dim_inactive_colors.unfocused, 0x000000FF);
|
color_to_rgba(config->dim_inactive_colors.unfocused, 0x000000FF);
|
||||||
color_to_rgba(config->dim_inactive_colors.urgent, 0x900000FF);
|
color_to_rgba(config->dim_inactive_colors.urgent, 0x900000FF);
|
||||||
|
config->shadow_enabled = false;
|
||||||
|
config->shadow_blur_sigma = 20.0f;
|
||||||
|
color_to_rgba(config->shadow_color, 0x0000007F);
|
||||||
|
|
||||||
// The keysym to keycode translation
|
// The keysym to keycode translation
|
||||||
struct xkb_rule_names rules = {0};
|
struct xkb_rule_names rules = {0};
|
||||||
|
|
|
@ -1008,12 +1008,15 @@ static void render_containers_linear(struct sway_output *output,
|
||||||
}
|
}
|
||||||
|
|
||||||
// render shadow
|
// render shadow
|
||||||
const float color[4] = {0.0, 0.0, 0.0, 0.5};
|
if (child->shadow_enabled
|
||||||
float blur_sigma = 20;
|
&& config->shadow_blur_sigma > 0
|
||||||
|
&& config->shadow_color[3] > 0.0) {
|
||||||
struct wlr_box box = { state->x, state->y, state->width, state->height };
|
struct wlr_box box = { state->x, state->y, state->width, state->height };
|
||||||
scale_box(&box, output->wlr_output->scale);
|
scale_box(&box, output->wlr_output->scale);
|
||||||
render_box_shadow(output, damage, &box, color, blur_sigma,
|
render_box_shadow(output, damage, &box, config->shadow_color,
|
||||||
deco_data.corner_radius, child->current.border_thickness);
|
config->shadow_blur_sigma, deco_data.corner_radius,
|
||||||
|
child->current.border_thickness);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
render_container(output, damage, child,
|
render_container(output, damage, child,
|
||||||
parent->focused || child->current.focused);
|
parent->focused || child->current.focused);
|
||||||
|
|
|
@ -103,6 +103,9 @@ sway_sources = files(
|
||||||
'commands/seat/shortcuts_inhibitor.c',
|
'commands/seat/shortcuts_inhibitor.c',
|
||||||
'commands/seat/xcursor_theme.c',
|
'commands/seat/xcursor_theme.c',
|
||||||
'commands/set.c',
|
'commands/set.c',
|
||||||
|
'commands/shadow_blur_radius.c',
|
||||||
|
'commands/shadow_color.c',
|
||||||
|
'commands/shadows.c',
|
||||||
'commands/show_marks.c',
|
'commands/show_marks.c',
|
||||||
'commands/shortcuts_inhibitor.c',
|
'commands/shortcuts_inhibitor.c',
|
||||||
'commands/smart_borders.c',
|
'commands/smart_borders.c',
|
||||||
|
|
|
@ -598,6 +598,17 @@ The default colors are:
|
||||||
*dim_inactive_colors.urgent* <hex color>
|
*dim_inactive_colors.urgent* <hex color>
|
||||||
The color to dim inactive urgent windows with. Example color: #900000FF
|
The color to dim inactive urgent windows with. Example color: #900000FF
|
||||||
|
|
||||||
|
*shadows* <value>
|
||||||
|
Adjusts if shadows should be enabled or not (on|off). Can also be set per
|
||||||
|
window with *for_window*.
|
||||||
|
|
||||||
|
*shadow_blur_radius* <value>
|
||||||
|
Adjusts the shadow blur radius of windows between 0 (disabled) and 100
|
||||||
|
while 20 is the default value.
|
||||||
|
|
||||||
|
*shadow_color* <hex color with alpha>
|
||||||
|
The shadow color. Default color: #0000007F
|
||||||
|
|
||||||
*default_border* normal|none|pixel [<n>]
|
*default_border* normal|none|pixel [<n>]
|
||||||
Set default border style for new tiled windows.
|
Set default border style for new tiled windows.
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
c->view = view;
|
c->view = view;
|
||||||
c->alpha = 1.0f;
|
c->alpha = 1.0f;
|
||||||
c->saturation = 1.0f;
|
c->saturation = 1.0f;
|
||||||
|
c->shadow_enabled = config->shadow_enabled;
|
||||||
c->corner_radius = config->corner_radius;
|
c->corner_radius = config->corner_radius;
|
||||||
|
|
||||||
if (!view) {
|
if (!view) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue