Skip to content

[feature] [RFC] universal window rules #1284

Closed
@yshui

Description

@yshui

Problem

picom has many rules that allow the user to customize how each windows are rendered. The way it is implemented currently, we basically have one rule per point of customize. Such as blur-background-exclude for background blurring, fade-exclude for fading, etc. This does not scale well as we introduce more customization possibilities. Look at this:

picom/src/options.c

Lines 955 to 973 in 05c764c

void options_postprocess_c2_lists(struct c2_state *state, struct x_connection *c,
struct options *option) {
if (!(c2_list_postprocess(state, c->c, option->unredir_if_possible_blacklist) &&
c2_list_postprocess(state, c->c, option->paint_blacklist) &&
c2_list_postprocess(state, c->c, option->shadow_blacklist) &&
c2_list_postprocess(state, c->c, option->shadow_clip_list) &&
c2_list_postprocess(state, c->c, option->fade_blacklist) &&
c2_list_postprocess(state, c->c, option->blur_background_blacklist) &&
c2_list_postprocess(state, c->c, option->invert_color_list) &&
c2_list_postprocess(state, c->c, option->window_shader_fg_rules) &&
c2_list_postprocess(state, c->c, option->opacity_rules) &&
c2_list_postprocess(state, c->c, option->rounded_corners_blacklist) &&
c2_list_postprocess(state, c->c, option->corner_radius_rules) &&
c2_list_postprocess(state, c->c, option->focus_blacklist) &&
c2_list_postprocess(state, c->c, option->transparent_clipping_blacklist))) {
log_error("Post-processing of conditionals failed, some of your "
"rules might not work");
}
}

This list will keep getting longer if we don't find a better approach. Besides that, it is also:

  • difficult to implement rules for non-trivial options such as animations
  • difficult to not repeating yourself, if you want to set multiple options for the same group of windows
  • confusing to have both inclusion and exclusion rules for the same option
  • confusing to have both rules, and the wintypes option

Proposal

Introducing a new rules option as the unified way to set per-window options. The design is simple:

rules = ({
    # you write a rule
    match = "class_i = 'firefox'";

    # ... and you set options
    blur-background = false;
},
{
    # ... any number of rules can be created
}, )

Supported options

All options that make sense as a per-window option will be supported. Such as fading, blur-background, shadow, shadow-color, shadow-radius, corner-radius, opacity, animations, full-shadow, redir-ignored, etc.

Multiple matching rules

This style of rules naturally comes with the question of what should happen if multiple rules match. Simply stopping at the first match doesn't really work for us, because that forces user to write very specific rules so they don't overlap. This is difficult and can be confusing.

So instead, picom will always try all of the rules, and combine the options. If the same options is set multiple times in different rule blocks, then the one encountered first in the order of how they appear in the configuration file will be used.

Deprecation plan

No deprecation is planned. All the old rule options, as well as wintypes, will continue to work. But users are encouraged to use the new rules option instead of the old ones. When both styles of rules are present in the configuration, the new rules will be matched first, and only when none of the new rules matches, will picom try any of the old rules.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions