Skip to content

Commit

Permalink
c2: add new pre-defined target "group_focused"
Browse files Browse the repository at this point in the history
This matches when the focused window is in the same window group as the
window being matched.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Aug 1, 2024
1 parent 68f357e commit 9fae4e3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Marginally improve performance when resizing/opening/closing windows. (#1190)
* Type and format specifiers are no longer used in rules. These specifiers are what you put after the colon (':') in rules, e.g. the `:32c` in `"_GTK_FRAME_EXTENTS@:32c"`. Now this information is ignored and the property is matched regardless of format or type.
* `backend` is now a required option. picom will not start if one is not specified explicitly.
* New predefined target for conditions: `group_focused`. This target indicate whether the focused window is in the same window group as the window being matched.

## Deprecated features

Expand Down
2 changes: 1 addition & 1 deletion man/picom.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ With greater-than/less-than operators it looks like:
_NEGATION_ (optional) is one or more exclamation marks;
_TARGET_ is either a predefined target name, or the name of a window property to match. Supported predefined targets are `x`, `y`, `x2` (`x` + `widthb`), `y2` (like `x2`), `width`, `height`, `widthb` (`width` + 2 * `border_width`), `heightb` (like `widthb`), `border_width`, `fullscreen`, `override_redirect`, `argb` (whether the window has an ARGB visual), `focused`, `wmwin` (whether the window looks like a WM window, i.e. has no child window with `WM_STATE` and is not override-redirected), `bounding_shaped`, `rounded_corners` (requires *--detect-rounded-corners*, note this has no relation to *--corner-radius*), `window_type` (window type in string), `name`, `class_g` (= `WM_CLASS[1]`), `class_i` (= `WM_CLASS[0]`), and `role`.
_TARGET_ is either a predefined target name, or the name of a window property to match. Supported predefined targets are `x`, `y`, `x2` (`x` + `widthb`), `y2` (like `x2`), `width`, `height`, `widthb` (`width` + 2 * `border_width`), `heightb` (like `widthb`), `border_width`, `fullscreen`, `override_redirect`, `argb` (whether the window has an ARGB visual), `focused`, `group_focused` (whether the window belongs to the focused window group), `wmwin` (whether the window looks like a WM window, i.e. has no child window with `WM_STATE` and is not override-redirected), `bounding_shaped`, `rounded_corners` (requires *--detect-rounded-corners*, note this has no relation to *--corner-radius*), `window_type` (window type in string), `name`, `class_g` (= `WM_CLASS[1]`), `class_i` (= `WM_CLASS[0]`), and `role`.
_CLIENT/FRAME_ is a single `@` if the window attribute should be be looked up on client window, nothing if on frame window;
Expand Down
54 changes: 30 additions & 24 deletions src/c2.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct _c2_l {
C2_L_POVREDIR,
C2_L_PARGB,
C2_L_PFOCUSED,
C2_L_PGROUPFOCUSED,
C2_L_PWMWIN,
C2_L_PBSHAPED,
C2_L_PROUNDED,
Expand Down Expand Up @@ -235,30 +236,31 @@ static struct {
bool is_string;
bool deprecated;
} C2_PREDEFS[] = {
[C2_L_PID] = { "id", false, true },
[C2_L_PX] = { "x", false, },
[C2_L_PY] = { "y", false, },
[C2_L_PX2] = { "x2", false, },
[C2_L_PY2] = { "y2", false, },
[C2_L_PWIDTH] = { "width", false, },
[C2_L_PHEIGHT] = { "height", false, },
[C2_L_PWIDTHB] = { "widthb", false, },
[C2_L_PHEIGHTB] = { "heightb", false, },
[C2_L_PBDW] = { "border_width", false, },
[C2_L_PFULLSCREEN] = { "fullscreen", false, },
[C2_L_POVREDIR] = { "override_redirect", false, },
[C2_L_PARGB] = { "argb", false, },
[C2_L_PFOCUSED] = { "focused", false, },
[C2_L_PWMWIN] = { "wmwin", false, },
[C2_L_PBSHAPED] = { "bounding_shaped", false, },
[C2_L_PROUNDED] = { "rounded_corners", false, },
[C2_L_PCLIENT] = { "client", false, true },
[C2_L_PWINDOWTYPE] = { "window_type", true, },
[C2_L_PLEADER] = { "leader", false, true },
[C2_L_PNAME] = { "name", true, },
[C2_L_PCLASSG] = { "class_g", true, },
[C2_L_PCLASSI] = { "class_i", true, },
[C2_L_PROLE] = { "role", true, },
[C2_L_PID] = { "id", false, true },
[C2_L_PX] = { "x", false, },
[C2_L_PY] = { "y", false, },
[C2_L_PX2] = { "x2", false, },
[C2_L_PY2] = { "y2", false, },
[C2_L_PWIDTH] = { "width", false, },
[C2_L_PHEIGHT] = { "height", false, },
[C2_L_PWIDTHB] = { "widthb", false, },
[C2_L_PHEIGHTB] = { "heightb", false, },
[C2_L_PBDW] = { "border_width", false, },
[C2_L_PFULLSCREEN] = { "fullscreen", false, },
[C2_L_POVREDIR] = { "override_redirect", false, },
[C2_L_PARGB] = { "argb", false, },
[C2_L_PFOCUSED] = { "focused", false, },
[C2_L_PGROUPFOCUSED] = { "group_focused", false, },
[C2_L_PWMWIN] = { "wmwin", false, },
[C2_L_PBSHAPED] = { "bounding_shaped", false, },
[C2_L_PROUNDED] = { "rounded_corners", false, },
[C2_L_PCLIENT] = { "client", false, true },
[C2_L_PWINDOWTYPE] = { "window_type", true, },
[C2_L_PLEADER] = { "leader", false, true },
[C2_L_PNAME] = { "name", true, },
[C2_L_PCLASSG] = { "class_g", true, },
[C2_L_PCLASSI] = { "class_i", true, },
[C2_L_PROLE] = { "role", true, },
};
// clang-format on

Expand Down Expand Up @@ -1610,6 +1612,10 @@ static bool c2_match_once_leaf_int(const struct win *w, const c2_l_t *leaf) {
predef_target =
w->a.map_state == XCB_MAP_STATE_VIEWABLE && w->is_focused;
break;
case C2_L_PGROUPFOCUSED:
predef_target = w->a.map_state == XCB_MAP_STATE_VIEWABLE &&
w->is_group_focused;
break;
case C2_L_PWMWIN: predef_target = win_is_wmwin(w); break;
case C2_L_PBSHAPED: predef_target = w->bounding_shaped; break;
case C2_L_PROUNDED: predef_target = w->rounded_corners; break;
Expand Down

0 comments on commit 9fae4e3

Please sign in to comment.