options: add corner-radius

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Samuel Hand
2020-09-30 16:39:47 +01:00
committed by Yuxuan Shui
parent fb38bf021e
commit e20b187912
8 changed files with 29 additions and 1 deletions

View File

@@ -103,6 +103,9 @@ OPTIONS
*--inactive-dim* 'VALUE'::
Dim inactive windows. (0.0 - 1.0, defaults to 0.0)
*--corner-radius* 'VALUE'::
Sets the radius of rounded window corners. When > 0, the compositor will round the corners of windows. (defaults to 0).
*--mark-wmwin-focused*::
Try to detect WM windows (a non-override-redirect window with no child that has 'WM_STATE') and mark them as active.

View File

@@ -537,6 +537,8 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.shadow_ignore_shaped = false,
.xinerama_shadow_crop = false,
.corner_radius = 0,
.fade_in_step = 0.028,
.fade_out_step = 0.03,
.fade_delta = 10,

View File

@@ -217,6 +217,8 @@ typedef struct options {
c2_lptr_t *opacity_rules;
/// Limit window brightness
double max_brightness;
// Radius of rounded window corners
int corner_radius;
// === Focus related ===
/// Whether to try to detect WM windows and mark them as focused.

View File

@@ -374,6 +374,8 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// --active_opacity
if (config_lookup_float(&cfg, "active-opacity", &dval))
opt->active_opacity = normalize_d(dval);
// --corner-radius
config_lookup_int(&cfg, "corner-radius", &opt->corner_radius);
// -e (frame_opacity)
config_lookup_float(&cfg, "frame-opacity", &opt->frame_opacity);
// -c (shadow_enable)

View File

@@ -117,6 +117,10 @@ static void usage(const char *argv0, int ret) {
"--active-opacity opacity\n"
" Default opacity for active windows. (0.0 - 1.0)\n"
"\n"
"--corner-radius value\n"
" Sets the radius of rounded window corners. When > 0, the compositor\n"
" will round the corners of windows. (defaults to 0).\n"
"\n"
"--mark-wmwin-focused\n"
" Try to detect WM windows and mark them as active.\n"
"\n"
@@ -440,6 +444,7 @@ static const struct option longopts[] = {
{"blur-deviation", required_argument, NULL, 330},
{"blur-strength", required_argument, NULL, 331},
{"shadow-color", required_argument, NULL, 332},
{"corner-radius", required_argument, NULL, 333},
{"experimental-backends", no_argument, NULL, 733},
{"monitor-repaint", no_argument, NULL, 800},
{"diagnostics", no_argument, NULL, 801},
@@ -859,7 +864,10 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
// --blur-strength
opt->blur_strength = atoi(optarg);
break;
case 333:
// --cornor-radius
opt->corner_radius = atoi(optarg);
break;
P_CASEBOOL(733, experimental_backends);
P_CASEBOOL(800, monitor_repaint);
case 801: opt->print_diagnostics = true; break;
@@ -986,6 +994,10 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
"properly under X Render backend.");
}
if (opt->corner_radius > 0) {
log_warn("Rounded corner is not implemented yet.");
}
return true;
}

View File

@@ -669,6 +669,8 @@ static struct managed_win *paint_preprocess(session_t *ps, bool *fade_running) {
w->frame_opacity = 1.0;
}
w->corner_radius = ps->o.corner_radius;
// Update window mode
w->mode = win_calc_mode(w);

View File

@@ -1413,6 +1413,8 @@ struct win *fill_win(session_t *ps, struct win *w) {
// Initialized during paint
.paint = PAINT_INIT,
.shadow_paint = PAINT_INIT,
.corner_radius = 0,
};
assert(!w->destroyed);

View File

@@ -208,6 +208,9 @@ struct managed_win {
/// Last window opacity value set by the rules.
double opacity_set;
/// Radius of rounded window corners
int corner_radius;
// Fading-related members
/// Override value of window fade state. Set by D-Bus method calls.
switch_t fade_force;