You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
363 lines
8.8 KiB
363 lines
8.8 KiB
10 years ago
|
#ifndef _SWAY_CONTAINER_H
|
||
|
#define _SWAY_CONTAINER_H
|
||
9 years ago
|
#include <sys/types.h>
|
||
10 years ago
|
#include <wlc/wlc.h>
|
||
7 years ago
|
#include <wlr/types/wlr_output.h>
|
||
8 years ago
|
#include <stdint.h>
|
||
9 years ago
|
#include "list.h"
|
||
|
|
||
10 years ago
|
typedef struct sway_container swayc_t;
|
||
9 years ago
|
|
||
9 years ago
|
extern swayc_t root_container;
|
||
8 years ago
|
extern swayc_t *current_focus;
|
||
10 years ago
|
|
||
7 years ago
|
struct sway_view;
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Different kinds of containers.
|
||
9 years ago
|
*
|
||
9 years ago
|
* This enum is in order. A container will never be inside of a container below
|
||
|
* it on this list.
|
||
|
*/
|
||
|
enum swayc_types {
|
||
8 years ago
|
C_ROOT, /**< The root container. Only one of these ever exists. */
|
||
|
C_OUTPUT, /**< An output (aka monitor, head, etc). */
|
||
|
C_WORKSPACE, /**< A workspace. */
|
||
|
C_CONTAINER, /**< A manually created container. */
|
||
|
C_VIEW, /**< A view (aka window). */
|
||
9 years ago
|
// Keep last
|
||
|
C_TYPES,
|
||
10 years ago
|
};
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Different ways to arrange a container.
|
||
|
*/
|
||
|
enum swayc_layouts {
|
||
8 years ago
|
L_NONE, /**< Used for containers that have no layout (views, root) */
|
||
9 years ago
|
L_HORIZ,
|
||
|
L_VERT,
|
||
|
L_STACKED,
|
||
|
L_TABBED,
|
||
8 years ago
|
L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
|
||
8 years ago
|
|
||
|
/* Awesome/Monad style auto layouts */
|
||
|
L_AUTO_LEFT,
|
||
|
L_AUTO_RIGHT,
|
||
|
L_AUTO_TOP,
|
||
|
L_AUTO_BOTTOM,
|
||
|
|
||
8 years ago
|
L_AUTO_FIRST = L_AUTO_LEFT,
|
||
|
L_AUTO_LAST = L_AUTO_BOTTOM,
|
||
|
|
||
9 years ago
|
// Keep last
|
||
|
L_LAYOUTS,
|
||
10 years ago
|
};
|
||
|
|
||
9 years ago
|
enum swayc_border_types {
|
||
8 years ago
|
B_NONE, /**< No border */
|
||
|
B_PIXEL, /**< 1px border */
|
||
|
B_NORMAL /**< Normal border with title bar */
|
||
9 years ago
|
};
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Stores information about a container.
|
||
|
*
|
||
|
* The tree is made of these. Views are containers that cannot have children.
|
||
|
*/
|
||
10 years ago
|
struct sway_container {
|
||
7 years ago
|
// TODO WLR: reconcile these
|
||
10 years ago
|
wlc_handle handle;
|
||
|
|
||
7 years ago
|
union {
|
||
7 years ago
|
struct sway_output *output;
|
||
7 years ago
|
struct sway_view *view;
|
||
7 years ago
|
} _handle;
|
||
|
|
||
8 years ago
|
/**
|
||
|
* A unique ID to identify this container. Primarily used in the
|
||
|
* get_tree JSON output.
|
||
|
*/
|
||
|
size_t id;
|
||
|
|
||
10 years ago
|
enum swayc_types type;
|
||
|
enum swayc_layouts layout;
|
||
9 years ago
|
enum swayc_layouts prev_layout;
|
||
8 years ago
|
enum swayc_layouts workspace_layout;
|
||
10 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Width and height of this container, without borders or gaps.
|
||
|
*/
|
||
9 years ago
|
double width, height;
|
||
10 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Views may request geometry, which is stored in this and ignored until
|
||
|
* the views are floated.
|
||
|
*/
|
||
9 years ago
|
int desired_width, desired_height;
|
||
9 years ago
|
|
||
9 years ago
|
/**
|
||
|
* The coordinates that this view appear at, relative to the output they
|
||
9 years ago
|
* are located on (output containers have absolute coordinates).
|
||
9 years ago
|
*/
|
||
9 years ago
|
double x, y;
|
||
10 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Cached geometry used to store view/container geometry when switching
|
||
|
* between tabbed/stacked and horizontal/vertical layouts.
|
||
|
*/
|
||
|
struct wlc_geometry cached_geometry;
|
||
|
|
||
9 years ago
|
/**
|
||
|
* False if this view is invisible. It could be in the scratchpad or on a
|
||
|
* workspace that is not shown.
|
||
|
*/
|
||
9 years ago
|
bool visible;
|
||
9 years ago
|
bool is_floating;
|
||
9 years ago
|
bool is_focused;
|
||
9 years ago
|
bool sticky; // floating view always visible on its output
|
||
9 years ago
|
|
||
9 years ago
|
// Attributes that mostly views have.
|
||
10 years ago
|
char *name;
|
||
9 years ago
|
char *class;
|
||
8 years ago
|
char *instance;
|
||
9 years ago
|
char *app_id;
|
||
10 years ago
|
|
||
9 years ago
|
// Used by output containers to keep track of swaybg child processes.
|
||
9 years ago
|
pid_t bg_pid;
|
||
|
|
||
9 years ago
|
int gaps;
|
||
|
|
||
10 years ago
|
list_t *children;
|
||
9 years ago
|
/**
|
||
|
* Children of this container that are floated.
|
||
|
*/
|
||
10 years ago
|
list_t *floating;
|
||
9 years ago
|
/**
|
||
|
* Unmanaged view handles in this container.
|
||
|
*/
|
||
|
list_t *unmanaged;
|
||
10 years ago
|
|
||
9 years ago
|
/**
|
||
|
* The parent of this container. NULL for the root container.
|
||
|
*/
|
||
10 years ago
|
struct sway_container *parent;
|
||
9 years ago
|
/**
|
||
|
* Which of this container's children has focus.
|
||
|
*/
|
||
10 years ago
|
struct sway_container *focused;
|
||
9 years ago
|
/**
|
||
|
* If this container's children include a fullscreen view, this is that view.
|
||
|
*/
|
||
|
struct sway_container *fullscreen;
|
||
9 years ago
|
/**
|
||
|
* If this container is a view, this may be set to the window's decoration
|
||
|
* buffer (or NULL).
|
||
|
*/
|
||
9 years ago
|
struct border *border;
|
||
9 years ago
|
enum swayc_border_types border_type;
|
||
9 years ago
|
struct wlc_geometry border_geometry;
|
||
9 years ago
|
struct wlc_geometry title_bar_geometry;
|
||
|
struct wlc_geometry actual_geometry;
|
||
|
int border_thickness;
|
||
8 years ago
|
|
||
|
/**
|
||
|
* Number of master views in auto layouts.
|
||
|
*/
|
||
8 years ago
|
size_t nb_master;
|
||
8 years ago
|
|
||
|
/**
|
||
|
* Number of slave groups (e.g. columns) in auto layouts.
|
||
|
*/
|
||
8 years ago
|
size_t nb_slave_groups;
|
||
8 years ago
|
|
||
|
/**
|
||
|
* Marks applied to the container, list_t of char*.
|
||
|
*/
|
||
|
list_t *marks;
|
||
10 years ago
|
};
|
||
|
|
||
9 years ago
|
enum visibility_mask {
|
||
|
VISIBLE = true
|
||
|
} visible;
|
||
10 years ago
|
|
||
7 years ago
|
struct sway_output;
|
||
9 years ago
|
/**
|
||
|
* Allocates a new output container.
|
||
|
*/
|
||
7 years ago
|
swayc_t *new_output(struct sway_output *sway_output);
|
||
9 years ago
|
/**
|
||
|
* Allocates a new workspace container.
|
||
|
*/
|
||
9 years ago
|
swayc_t *new_workspace(swayc_t *output, const char *name);
|
||
9 years ago
|
/**
|
||
|
* Allocates a new container and places a child into it.
|
||
|
*
|
||
|
* This is used from the split command, which creates a new container with the
|
||
|
* requested layout and replaces the focused container in the tree with the new
|
||
|
* one. Then the removed container is added as a child of the new container.
|
||
|
*/
|
||
10 years ago
|
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
|
||
9 years ago
|
/**
|
||
|
* Allocates a new view container.
|
||
|
*
|
||
|
* Pass in a sibling view, or a workspace to become this container's parent.
|
||
|
*/
|
||
7 years ago
|
swayc_t *new_view(swayc_t *sibling, struct sway_view *view);
|
||
9 years ago
|
/**
|
||
|
* Allocates a new floating view in the active workspace.
|
||
|
*/
|
||
9 years ago
|
swayc_t *new_floating_view(wlc_handle handle);
|
||
10 years ago
|
|
||
9 years ago
|
void floating_view_sane_size(swayc_t *view);
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Frees an output's container.
|
||
|
*/
|
||
9 years ago
|
swayc_t *destroy_output(swayc_t *output);
|
||
9 years ago
|
/**
|
||
|
* Destroys a workspace container and returns the parent pointer, or NULL.
|
||
|
*/
|
||
10 years ago
|
swayc_t *destroy_workspace(swayc_t *workspace);
|
||
9 years ago
|
/**
|
||
|
* Destroys a container and all empty parents. Returns the topmost non-empty
|
||
|
* parent container, or NULL.
|
||
|
*/
|
||
10 years ago
|
swayc_t *destroy_container(swayc_t *container);
|
||
9 years ago
|
/**
|
||
|
* Destroys a view container and all empty parents. Returns the topmost
|
||
|
* non-empty parent container, or NULL.
|
||
|
*/
|
||
10 years ago
|
swayc_t *destroy_view(swayc_t *view);
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Finds a container based on test criteria. Returns the first container that
|
||
|
* passes the test.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
|
||
9 years ago
|
/**
|
||
|
* Finds a parent container with the given swayc_type.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
|
||
9 years ago
|
/**
|
||
|
* Finds a parent with the given swayc_layout.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
|
||
9 years ago
|
/**
|
||
|
* Finds the bottom-most focused container of a type.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
|
||
9 years ago
|
/**
|
||
|
* Finds the bottom-most focused container of a layout.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Gets the swayc_t associated with a wlc_handle.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_by_handle(wlc_handle handle);
|
||
9 years ago
|
/**
|
||
|
* Gets the named swayc_t.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_by_name(const char *name);
|
||
9 years ago
|
/**
|
||
|
* Gets the active output's container.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_active_output(void);
|
||
9 years ago
|
/**
|
||
|
* Gets the active workspace's container.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_active_workspace(void);
|
||
9 years ago
|
/**
|
||
|
* Gets the workspace for the given view container.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_active_workspace_for(swayc_t *view);
|
||
9 years ago
|
/**
|
||
|
* Finds the container currently underneath the pointer.
|
||
|
*/
|
||
9 years ago
|
swayc_t *container_under_pointer(void);
|
||
8 years ago
|
/**
|
||
|
* Finds the first container following a callback.
|
||
|
*/
|
||
|
swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *), const void *data);
|
||
9 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Returns true if a container is fullscreen.
|
||
|
*/
|
||
9 years ago
|
bool swayc_is_fullscreen(swayc_t *view);
|
||
9 years ago
|
/**
|
||
|
* Returns true if this view is focused.
|
||
|
*/
|
||
9 years ago
|
bool swayc_is_active(swayc_t *view);
|
||
9 years ago
|
/**
|
||
|
* Returns true if the parent is an ancestor of the child.
|
||
|
*/
|
||
9 years ago
|
bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
|
||
9 years ago
|
/**
|
||
|
* Returns true if the child is a desecendant of the parent.
|
||
|
*/
|
||
9 years ago
|
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
|
||
9 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Returns true if this container is an empty workspace.
|
||
|
*/
|
||
|
bool swayc_is_empty_workspace(swayc_t *container);
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Returns the top most tabbed or stacked parent container. Returns NULL if
|
||
|
* view is not in a tabbed/stacked layout.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view);
|
||
|
|
||
|
/**
|
||
|
* Returns the immediate tabbed or stacked parent container. Returns NULL if
|
||
|
* view is not directly in a tabbed/stacked layout.
|
||
|
*/
|
||
9 years ago
|
swayc_t *swayc_tabbed_stacked_parent(swayc_t *view);
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Returns the gap (padding) of the container.
|
||
|
*
|
||
|
* This returns the inner gaps for a view, the outer gaps for a workspace, and
|
||
|
* 0 otherwise.
|
||
|
*/
|
||
9 years ago
|
int swayc_gap(swayc_t *container);
|
||
10 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Maps a container's children over a function.
|
||
|
*/
|
||
9 years ago
|
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
||
9 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Set a view as visible or invisible.
|
||
|
*
|
||
|
* This will perform the required wlc calls as well; it is not sufficient to
|
||
|
* simply toggle the boolean in swayc_t.
|
||
|
*/
|
||
9 years ago
|
void set_view_visibility(swayc_t *view, void *data);
|
||
9 years ago
|
/**
|
||
|
* Set the gaps value for a view.
|
||
|
*/
|
||
9 years ago
|
void set_gaps(swayc_t *view, void *amount);
|
||
9 years ago
|
/**
|
||
|
* Add to the gaps value for a view.
|
||
|
*/
|
||
9 years ago
|
void add_gaps(swayc_t *view, void *amount);
|
||
10 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Issue wlc calls to make the visibility of a container consistent.
|
||
|
*/
|
||
9 years ago
|
void update_visibility(swayc_t *container);
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Close all child views of container
|
||
|
*/
|
||
|
void close_views(swayc_t *container);
|
||
|
|
||
8 years ago
|
/**
|
||
|
* Assign layout to a container. Needed due to workspace container specifics.
|
||
8 years ago
|
* Workspace should always have either L_VERT or L_HORIZ layout.
|
||
8 years ago
|
*/
|
||
|
swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
|
||
|
|
||
10 years ago
|
#endif
|