feat: smart smart_corner_radius (#101)
This commit is contained in:
parent
dbe2be6a36
commit
9e6901264b
|
@ -12,6 +12,7 @@ Sway is an incredible window manager, and certainly one of the most well establi
|
||||||
## New Configuration Options
|
## New Configuration Options
|
||||||
|
|
||||||
+ Corner radius: `corner_radius <val>`
|
+ Corner radius: `corner_radius <val>`
|
||||||
|
+ Smart corner radius: `smart_corner_radius on|off`
|
||||||
+ 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: *ONLY ON SWAYFX-GIT, NOT YET RELEASED*
|
+ Window shadows: *ONLY ON SWAYFX-GIT, NOT YET RELEASED*
|
||||||
- `shadows on|off`
|
- `shadows on|off`
|
||||||
|
|
|
@ -183,6 +183,7 @@ sway_cmd cmd_shadow_color;
|
||||||
sway_cmd cmd_shadows;
|
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_corner_radius;
|
||||||
sway_cmd cmd_smart_gaps;
|
sway_cmd cmd_smart_gaps;
|
||||||
sway_cmd cmd_split;
|
sway_cmd cmd_split;
|
||||||
sway_cmd cmd_splith;
|
sway_cmd cmd_splith;
|
||||||
|
|
|
@ -476,6 +476,7 @@ enum xwayland_mode {
|
||||||
struct sway_config {
|
struct sway_config {
|
||||||
// SwayFX config options
|
// SwayFX config options
|
||||||
int corner_radius;
|
int corner_radius;
|
||||||
|
bool smart_corner_radius;
|
||||||
float dim_inactive;
|
float dim_inactive;
|
||||||
// dim_inactive colors
|
// dim_inactive colors
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -93,6 +93,7 @@ static const struct cmd_handler handlers[] = {
|
||||||
{ "shadows", cmd_shadows },
|
{ "shadows", cmd_shadows },
|
||||||
{ "show_marks", cmd_show_marks },
|
{ "show_marks", cmd_show_marks },
|
||||||
{ "smart_borders", cmd_smart_borders },
|
{ "smart_borders", cmd_smart_borders },
|
||||||
|
{ "smart_corner_radius", cmd_smart_corner_radius },
|
||||||
{ "smart_gaps", cmd_smart_gaps },
|
{ "smart_gaps", cmd_smart_gaps },
|
||||||
{ "tiling_drag", cmd_tiling_drag },
|
{ "tiling_drag", cmd_tiling_drag },
|
||||||
{ "tiling_drag_threshold", cmd_tiling_drag_threshold },
|
{ "tiling_drag_threshold", cmd_tiling_drag_threshold },
|
||||||
|
|
17
sway/commands/smart_corner_radius.c
Normal file
17
sway/commands/smart_corner_radius.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/tree/arrange.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
struct cmd_results *cmd_smart_corner_radius(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "smart_corner_radius", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
config->smart_corner_radius = parse_boolean(argv[0], true);
|
||||||
|
|
||||||
|
arrange_root();
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
|
@ -335,6 +335,7 @@ static void config_defaults(struct sway_config *config) {
|
||||||
|
|
||||||
// SwayFX defaults
|
// SwayFX defaults
|
||||||
config->corner_radius = 0;
|
config->corner_radius = 0;
|
||||||
|
config->smart_corner_radius = true;
|
||||||
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);
|
||||||
|
|
|
@ -1003,6 +1003,9 @@ static void render_containers_linear(struct sway_output *output,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_titlebar = state->border == B_NORMAL;
|
bool has_titlebar = state->border == B_NORMAL;
|
||||||
|
int corner_radius = config->smart_corner_radius &&
|
||||||
|
output->current.active_workspace->current_gaps.top == 0
|
||||||
|
? 0 : child->corner_radius;
|
||||||
struct decoration_data deco_data = {
|
struct decoration_data deco_data = {
|
||||||
.alpha = child->alpha,
|
.alpha = child->alpha,
|
||||||
.dim_color = view_is_urgent(view)
|
.dim_color = view_is_urgent(view)
|
||||||
|
@ -1010,8 +1013,7 @@ static void render_containers_linear(struct sway_output *output,
|
||||||
: config->dim_inactive_colors.unfocused,
|
: config->dim_inactive_colors.unfocused,
|
||||||
.dim = child->current.focused || parent->focused ? 0.0f: config->dim_inactive,
|
.dim = child->current.focused || parent->focused ? 0.0f: config->dim_inactive,
|
||||||
// no corner radius if no gaps (allows smart_gaps to work as expected)
|
// no corner radius if no gaps (allows smart_gaps to work as expected)
|
||||||
.corner_radius = output->current.active_workspace->current_gaps.top == 0
|
.corner_radius = corner_radius,
|
||||||
? 0 : child->corner_radius,
|
|
||||||
.saturation = child->saturation,
|
.saturation = child->saturation,
|
||||||
.has_titlebar = has_titlebar,
|
.has_titlebar = has_titlebar,
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,6 +49,7 @@ sway_sources = files(
|
||||||
'commands/border.c',
|
'commands/border.c',
|
||||||
'commands/client.c',
|
'commands/client.c',
|
||||||
'commands/corner_radius.c',
|
'commands/corner_radius.c',
|
||||||
|
'commands/smart_corner_radius.c',
|
||||||
'commands/create_output.c',
|
'commands/create_output.c',
|
||||||
'commands/default_border.c',
|
'commands/default_border.c',
|
||||||
'commands/default_floating_border.c',
|
'commands/default_floating_border.c',
|
||||||
|
|
|
@ -649,6 +649,9 @@ The default colors are:
|
||||||
*corner_radius* <radius>
|
*corner_radius* <radius>
|
||||||
Set corner radius for new windows.
|
Set corner radius for new windows.
|
||||||
|
|
||||||
|
*smart_corner_radius* on|off
|
||||||
|
Set corner radius only if there are gaps around the window.
|
||||||
|
|
||||||
*dim_inactive* <value>
|
*dim_inactive* <value>
|
||||||
Adjusts the dimming of inactive windows between 0.0 (no dimming) and 1.0
|
Adjusts the dimming of inactive windows between 0.0 (no dimming) and 1.0
|
||||||
(fully dimmed) while 0.0 is the default value.
|
(fully dimmed) while 0.0 is the default value.
|
||||||
|
|
Loading…
Reference in a new issue