Remove constraint that con->view != NULL to use __focused__ criteria

To use something like:

  [con_id=__focused__] mark --add --toggle foo

The container must currently have a view. However, it is possible to
focus parent containers that do not have a view. For example, via:

  focus parent

Since containers without views can be the focused (meaning the container
is marked "focused": true in the output of: swaymsg -t get_tree), it
seems reasonable that a view is not required to target a container via
__focused__.
This commit is contained in:
Chris Perl 2025-03-07 10:55:52 -05:00 committed by Simon Ser
parent e3d9cc2aa5
commit 048e304b8a

View file

@ -630,8 +630,7 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
if (strcmp(value, "__focused__") == 0) {
struct sway_seat *seat = input_manager_current_seat();
struct sway_container *focus = seat_get_focused_container(seat);
struct sway_view *view = focus ? focus->view : NULL;
criteria->con_id = view ? view->container->node.id : 0;
criteria->con_id = focus ? focus->node.id : 0;
} else {
criteria->con_id = strtoul(value, &endptr, 10);
if (*endptr != 0) {