view: fix some inconsistencies in view_ functions

... especially regarding whether a (view *) parameter may be NULL. It's
confusing when some functions accept NULL and others don't, and could
trip someone up.

I'm partly to blame for the inconsistency, since (if memory serves) I
added view_is_tiled() and view_is_floating(), which do accept NULL.

In detail:

- Make view_is_tiled() and view_is_floating() no longer accept NULL.

- Rename view_isfocusable -> view_is_focusable for consistency with
  other view_is_ functions.

- Eliminate view_inhibits_keybinds() as it only existed to safely accept
  NULL and check a single flag, which can be checked directly.

- Add assert(view) to remaining public view_ functions to catch
  accidentally passing NULL.

- Inline inhibit_keybinds() into view_toggle_keybinds(). It is closely
  related and not called from anywhere else; inlining it allows
  eliminating an extra assert() which is now impossible.
This commit is contained in:
John Lindgren 2023-09-25 22:42:06 -04:00 committed by Johan Malm
parent d00f76e562
commit 1f541be481
5 changed files with 27 additions and 33 deletions

View file

@ -114,7 +114,7 @@ first_view(struct server *server)
continue;
}
struct view *view = node_view_from_node(node);
if (view_isfocusable(view)) {
if (view_is_focusable(view)) {
return view;
}
}
@ -186,7 +186,7 @@ desktop_cycle_view(struct server *server, struct view *start_view,
view = node_view_from_node(node);
enum property skip = window_rules_get_property(view, "skipWindowSwitcher");
if (view_isfocusable(view) && skip != LAB_PROP_TRUE) {
if (view_is_focusable(view) && skip != LAB_PROP_TRUE) {
return view;
}
} while (view != start_view);
@ -208,7 +208,7 @@ desktop_topmost_focusable_view(struct server *server)
continue;
}
view = node_view_from_node(node);
if (view->mapped && view_isfocusable(view)) {
if (view->mapped && view_is_focusable(view)) {
return view;
}
}
@ -247,7 +247,7 @@ desktop_focus_output(struct output *output)
continue;
}
view = node_view_from_node(node);
if (!view_isfocusable(view)) {
if (!view_is_focusable(view)) {
continue;
}
if (wlr_output_layout_intersects(layout,