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

@ -271,7 +271,7 @@ void view_array_append(struct server *server, struct wl_array *views,
enum lab_view_criteria criteria);
/**
* view_isfocusable() - Check whether or not a view can be focused
* view_is_focusable() - Check whether or not a view can be focused
* @view: view to be checked
*
* The purpose of this test is to filter out views (generally Xwayland) which
@ -282,9 +282,8 @@ void view_array_append(struct server *server, struct wl_array *views,
* The only views that are allowed to be focusd are those that have a surface
* and have been mapped at some point since creation.
*/
bool view_isfocusable(struct view *view);
bool view_is_focusable(struct view *view);
bool view_inhibits_keybinds(struct view *view);
void view_toggle_keybinds(struct view *view);
void view_set_activated(struct view *view, bool activated);