feat: add shadow color for inactive windows (#230)
This commit is contained in:
parent
d89c365106
commit
2d6944dc14
|
@ -36,6 +36,7 @@ Sway is an incredible window manager, and certainly one of the most well establi
|
||||||
- `shadows_on_csd enable|disable` (**Note**: The shadow might not fit some windows)
|
- `shadows_on_csd enable|disable` (**Note**: The shadow might not fit some windows)
|
||||||
- `shadow_blur_radius <integer value 0 - 100>`
|
- `shadow_blur_radius <integer value 0 - 100>`
|
||||||
- `shadow_color <hex color with alpha> ex, #0000007F`
|
- `shadow_color <hex color with alpha> ex, #0000007F`
|
||||||
|
- `shadow_inactive_color <hex color with alpha> ex, #0000007F`
|
||||||
+ LayerShell effects (to blur panels / notifications etc):
|
+ LayerShell effects (to blur panels / notifications etc):
|
||||||
- `layer_effects <layer namespace> <effects>`
|
- `layer_effects <layer namespace> <effects>`
|
||||||
- The current layer namespaces can be shown with `swaymsg -r -t get_outputs | jq '.[0].layer_shell_surfaces | .[] | .namespace'`
|
- The current layer namespaces can be shown with `swaymsg -r -t get_outputs | jq '.[0].layer_shell_surfaces | .[] | .namespace'`
|
||||||
|
|
|
@ -192,6 +192,7 @@ sway_cmd cmd_set;
|
||||||
sway_cmd cmd_shortcuts_inhibitor;
|
sway_cmd cmd_shortcuts_inhibitor;
|
||||||
sway_cmd cmd_shadow_blur_radius;
|
sway_cmd cmd_shadow_blur_radius;
|
||||||
sway_cmd cmd_shadow_color;
|
sway_cmd cmd_shadow_color;
|
||||||
|
sway_cmd cmd_shadow_inactive_color;
|
||||||
sway_cmd cmd_shadows;
|
sway_cmd cmd_shadows;
|
||||||
sway_cmd cmd_shadows_on_csd;
|
sway_cmd cmd_shadows_on_csd;
|
||||||
sway_cmd cmd_show_marks;
|
sway_cmd cmd_show_marks;
|
||||||
|
|
|
@ -492,6 +492,7 @@ struct sway_config {
|
||||||
bool shadows_on_csd_enabled;
|
bool shadows_on_csd_enabled;
|
||||||
int shadow_blur_sigma;
|
int shadow_blur_sigma;
|
||||||
float shadow_color[4];
|
float shadow_color[4];
|
||||||
|
float shadow_inactive_color[4];
|
||||||
|
|
||||||
bool blur_enabled;
|
bool blur_enabled;
|
||||||
bool blur_xray;
|
bool blur_xray;
|
||||||
|
|
|
@ -96,6 +96,7 @@ static const struct cmd_handler handlers[] = {
|
||||||
{ "set", cmd_set },
|
{ "set", cmd_set },
|
||||||
{ "shadow_blur_radius", cmd_shadow_blur_radius },
|
{ "shadow_blur_radius", cmd_shadow_blur_radius },
|
||||||
{ "shadow_color", cmd_shadow_color },
|
{ "shadow_color", cmd_shadow_color },
|
||||||
|
{ "shadow_inactive_color", cmd_shadow_inactive_color },
|
||||||
{ "shadows", cmd_shadows },
|
{ "shadows", cmd_shadows },
|
||||||
{ "shadows_on_csd", cmd_shadows_on_csd },
|
{ "shadows_on_csd", cmd_shadows_on_csd },
|
||||||
{ "show_marks", cmd_show_marks },
|
{ "show_marks", cmd_show_marks },
|
||||||
|
|
|
@ -17,6 +17,9 @@ struct cmd_results *cmd_shadow_color(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_INVALID, "Invalid %s color %s",
|
return cmd_results_new(CMD_INVALID, "Invalid %s color %s",
|
||||||
"shadow_color", argv[0]);
|
"shadow_color", argv[0]);
|
||||||
}
|
}
|
||||||
|
if (memcmp(config->shadow_color, config->shadow_inactive_color, sizeof(config->shadow_color)) == 0) {
|
||||||
|
color_to_rgba(config->shadow_inactive_color, color);
|
||||||
|
}
|
||||||
color_to_rgba(config->shadow_color, color);
|
color_to_rgba(config->shadow_color, color);
|
||||||
|
|
||||||
arrange_root();
|
arrange_root();
|
||||||
|
|
25
sway/commands/shadow_inactive_color.c
Normal file
25
sway/commands/shadow_inactive_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_inactive_color(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "shadow_inactive_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_inactive_color", argv[0]);
|
||||||
|
}
|
||||||
|
color_to_rgba(config->shadow_inactive_color, color);
|
||||||
|
|
||||||
|
arrange_root();
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
|
@ -352,6 +352,7 @@ static void config_defaults(struct sway_config *config) {
|
||||||
config->shadows_on_csd_enabled = false;
|
config->shadows_on_csd_enabled = false;
|
||||||
config->shadow_blur_sigma = 20.0f;
|
config->shadow_blur_sigma = 20.0f;
|
||||||
color_to_rgba(config->shadow_color, 0x0000007F);
|
color_to_rgba(config->shadow_color, 0x0000007F);
|
||||||
|
color_to_rgba(config->shadow_inactive_color, 0x0000007F);
|
||||||
|
|
||||||
config->blur_enabled = false;
|
config->blur_enabled = false;
|
||||||
config->blur_xray = false;
|
config->blur_xray = false;
|
||||||
|
|
|
@ -884,7 +884,9 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
|
||||||
scale_box(&box, output_scale);
|
scale_box(&box, output_scale);
|
||||||
int scaled_corner_radius = deco_data.corner_radius == 0 ?
|
int scaled_corner_radius = deco_data.corner_radius == 0 ?
|
||||||
0 : (deco_data.corner_radius + state->border_thickness) * output_scale;
|
0 : (deco_data.corner_radius + state->border_thickness) * output_scale;
|
||||||
render_box_shadow(output, damage, &box, config->shadow_color, config->shadow_blur_sigma,
|
float* shadow_color = view_is_urgent(view) || state->focused ?
|
||||||
|
config->shadow_color : config->shadow_inactive_color;
|
||||||
|
render_box_shadow(output, damage, &box, shadow_color, config->shadow_blur_sigma,
|
||||||
scaled_corner_radius);
|
scaled_corner_radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ sway_sources = files(
|
||||||
'commands/set.c',
|
'commands/set.c',
|
||||||
'commands/shadow_blur_radius.c',
|
'commands/shadow_blur_radius.c',
|
||||||
'commands/shadow_color.c',
|
'commands/shadow_color.c',
|
||||||
|
'commands/shadow_inactive_color.c',
|
||||||
'commands/shadows.c',
|
'commands/shadows.c',
|
||||||
'commands/shadows_on_csd.c',
|
'commands/shadows_on_csd.c',
|
||||||
'commands/show_marks.c',
|
'commands/show_marks.c',
|
||||||
|
|
|
@ -686,6 +686,9 @@ The default colors are:
|
||||||
*shadow_color* <hex color with alpha>
|
*shadow_color* <hex color with alpha>
|
||||||
The shadow color. Default color: #0000007F
|
The shadow color. Default color: #0000007F
|
||||||
|
|
||||||
|
*shadow_inactive_color* <hex color with alpha>
|
||||||
|
The shadow color for inactive windows. Default value: *shadow_color*
|
||||||
|
|
||||||
*blur* enable|disable
|
*blur* enable|disable
|
||||||
Sets whether blur should be drawn. Can also be set per window with
|
Sets whether blur should be drawn. Can also be set per window with
|
||||||
*for_window*.
|
*for_window*.
|
||||||
|
|
Loading…
Reference in a new issue