sway-patched-tray-menu/include/sway/tree/root.h
Ryan Dwyer d6cd79c342 Implement iterators per container type
This introduces the following `for_each` functions:

* root_for_each_workspace
* root_for_each_container
* output_for_each_workspace
* output_for_each_container
* workspace_for_each_container

And introduces the following `find` functions:

* root_find_output
* root_find_workspace
* root_find_container
* output_find_workspace
* output_find_container
* workspace_find_container
* container_find_child

And removes the following functions:

* container_descendants
* container_for_each_descendant
* container_find

This change is preparing the way for demoting sway_container. Eventually
these functions will accept and return sway_outputs, sway_workspaces and
sway_containers (meaning a C_CONTAINER or C_VIEW).

This change also makes it easy to handle abnormalities like the
workspace floating list, root's scratchpad list and (once implemented)
root's saved workspaces list for when there's no connected outputs.
2018-08-18 23:38:54 +10:00

76 lines
1.8 KiB
C

#ifndef _SWAY_ROOT_H
#define _SWAY_ROOT_H
#include <wayland-server-core.h>
#include <wayland-util.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/render/wlr_texture.h>
#include "sway/tree/container.h"
#include "config.h"
#include "list.h"
extern struct sway_container root_container;
struct sway_root {
struct wlr_output_layout *output_layout;
struct wl_listener output_layout_change;
#ifdef HAVE_XWAYLAND
struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
#endif
struct wl_list drag_icons; // sway_drag_icon::link
struct wlr_texture *debug_tree;
struct wl_list outputs; // sway_output::link
list_t *scratchpad; // struct sway_container
struct {
struct wl_signal new_container;
} events;
};
void root_create(void);
void root_destroy(void);
/**
* Move a container to the scratchpad.
*/
void root_scratchpad_add_container(struct sway_container *con);
/**
* Remove a container from the scratchpad.
*/
void root_scratchpad_remove_container(struct sway_container *con);
/**
* Show a single scratchpad container.
*/
void root_scratchpad_show(struct sway_container *con);
/**
* Hide a single scratchpad container.
*/
void root_scratchpad_hide(struct sway_container *con);
struct sway_container *root_workspace_for_pid(pid_t pid);
void root_record_workspace_pid(pid_t pid);
void root_for_each_workspace(void (*f)(struct sway_container *con, void *data),
void *data);
void root_for_each_container(void (*f)(struct sway_container *con, void *data),
void *data);
struct sway_container *root_find_output(
bool (*test)(struct sway_container *con, void *data), void *data);
struct sway_container *root_find_workspace(
bool (*test)(struct sway_container *con, void *data), void *data);
struct sway_container *root_find_container(
bool (*test)(struct sway_container *con, void *data), void *data);
#endif