view: add view_array_append()

...to reduce code duplication.

The function populates an array with views which meet any set of critera
from:

  - current-workspace
  - no-always-on-top
  - no-skipWindowSwitcher (window-rule)

Make src/osd.c use this new interface. Note that always-on-top views are
still filtered out from the window-switcher and that desktop_cycle_view()
needs to be re-worked before always-on-top views can be opted in.
This commit is contained in:
Johan Malm 2023-08-10 15:46:00 +01:00 committed by Johan Malm
parent 58b33fb0c9
commit 57b9efeb45
4 changed files with 103 additions and 35 deletions

View file

@ -168,6 +168,36 @@ struct xdg_toplevel_view {
struct wl_listener new_popup;
};
enum lab_view_criteria {
LAB_VIEW_CRITERIA_ALL = 0,
LAB_VIEW_CRITERIA_CURRENT_WORKSPACE = 1 << 0,
LAB_VIEW_CRITERIA_NO_ALWAYS_ON_TOP = 1 << 1,
LAB_VIEW_CRITERIA_NO_SKIP_WINDOW_SWITCHER = 1 << 2,
};
/**
* view_array_append - append views that match criteria to array
* @server: server context
* @views: arrays to append to
* @criteria: criteria to match against
*
* Note: This array has a very short shelf-life so it is intended to be used
* with a single-use-throw-away approach.
*
* Example usage:
*
* struct view **view;
* struct wl_array views;
* wl_array_init(&views);
* view_array_append(server, &views, LAB_VIEW_CRITERIA_CURRENT_WORKSPACE);
* wl_array_for_each(view, &views) {
* // Do something with *view
* }
* wl_array_release(&views);
*/
void view_array_append(struct server *server, struct wl_array *views,
enum lab_view_criteria criteria);
bool view_inhibits_keybinds(struct view *view);
void view_toggle_keybinds(struct view *view);