2015-08-10 22:31:23 +02:00
|
|
|
#ifndef _SWAY_CONTAINER_H
|
|
|
|
#define _SWAY_CONTAINER_H
|
2015-12-18 17:43:03 +01:00
|
|
|
#include <sys/types.h>
|
2015-08-14 21:42:19 +02:00
|
|
|
#include <wlc/wlc.h>
|
2016-04-20 00:22:15 +02:00
|
|
|
|
|
|
|
#include "list.h"
|
|
|
|
|
2015-08-14 21:42:19 +02:00
|
|
|
typedef struct sway_container swayc_t;
|
2015-09-14 01:46:16 +02:00
|
|
|
|
2016-04-20 00:22:15 +02:00
|
|
|
extern swayc_t root_container;
|
2015-08-10 22:31:23 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Different kinds of containers.
|
2016-03-29 14:40:25 +02:00
|
|
|
*
|
2015-11-08 18:06:12 +01:00
|
|
|
* This enum is in order. A container will never be inside of a container below
|
|
|
|
* it on this list.
|
|
|
|
*/
|
|
|
|
enum swayc_types {
|
|
|
|
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). */
|
2015-09-14 01:46:16 +02:00
|
|
|
// Keep last
|
|
|
|
C_TYPES,
|
2015-08-14 21:42:19 +02:00
|
|
|
};
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Different ways to arrange a container.
|
|
|
|
*/
|
|
|
|
enum swayc_layouts {
|
|
|
|
L_NONE, /**< Used for containers that have no layout (views, root) */
|
2015-09-14 01:46:16 +02:00
|
|
|
L_HORIZ,
|
|
|
|
L_VERT,
|
|
|
|
L_STACKED,
|
|
|
|
L_TABBED,
|
2015-11-08 18:06:12 +01:00
|
|
|
L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
|
2015-09-14 01:46:16 +02:00
|
|
|
// Keep last
|
|
|
|
L_LAYOUTS,
|
2015-08-14 21:42:19 +02:00
|
|
|
};
|
|
|
|
|
2016-03-14 02:10:46 +01:00
|
|
|
enum swayc_border_types {
|
2016-03-29 14:40:25 +02:00
|
|
|
B_NONE, /**< No border */
|
|
|
|
B_PIXEL, /**< 1px border */
|
|
|
|
B_NORMAL /**< Normal border with title bar */
|
2016-03-14 02:10:46 +01:00
|
|
|
};
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Stores information about a container.
|
|
|
|
*
|
|
|
|
* The tree is made of these. Views are containers that cannot have children.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
struct sway_container {
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* If this container maps to a WLC object, this is set to that object's
|
|
|
|
* handle. Otherwise, NULL.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
wlc_handle handle;
|
|
|
|
|
|
|
|
enum swayc_types type;
|
|
|
|
enum swayc_layouts layout;
|
2016-04-02 16:29:31 +02:00
|
|
|
enum swayc_layouts prev_layout;
|
2015-08-14 21:42:19 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Width and height of this container, without borders or gaps.
|
|
|
|
*/
|
2015-08-21 04:37:59 +02:00
|
|
|
double width, height;
|
2015-08-14 21:42:19 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Views may request geometry, which is stored in this and ignored until
|
|
|
|
* the views are floated.
|
|
|
|
*/
|
2015-08-17 17:34:39 +02:00
|
|
|
int desired_width, desired_height;
|
2015-08-17 17:18:06 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* The coordinates that this view appear at, relative to the output they
|
2015-11-16 00:35:25 +01:00
|
|
|
* are located on (output containers have absolute coordinates).
|
2015-11-08 18:06:12 +01:00
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
double x, y;
|
2015-08-14 21:42:19 +02:00
|
|
|
|
2016-04-20 00:22:15 +02:00
|
|
|
/**
|
|
|
|
* Cached geometry used to store view/container geometry when switching
|
|
|
|
* between tabbed/stacked and horizontal/vertical layouts.
|
|
|
|
*/
|
|
|
|
struct wlc_geometry cached_geometry;
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* False if this view is invisible. It could be in the scratchpad or on a
|
|
|
|
* workspace that is not shown.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
bool visible;
|
2015-08-17 17:34:39 +02:00
|
|
|
bool is_floating;
|
2015-08-18 09:28:44 +02:00
|
|
|
bool is_focused;
|
2015-11-26 23:53:20 +01:00
|
|
|
bool sticky; // floating view always visible on its output
|
2015-08-18 09:28:44 +02:00
|
|
|
|
2015-11-22 22:05:00 +01:00
|
|
|
// Attributes that mostly views have.
|
2015-08-14 21:42:19 +02:00
|
|
|
char *name;
|
2015-11-22 22:05:00 +01:00
|
|
|
char *class;
|
2015-11-22 22:09:33 +01:00
|
|
|
char *app_id;
|
2015-08-14 21:42:19 +02:00
|
|
|
|
2016-02-23 14:25:09 +01:00
|
|
|
// Used by output containers to keep track of swaybg child processes.
|
2015-12-18 17:43:03 +01:00
|
|
|
pid_t bg_pid;
|
|
|
|
|
2015-08-18 23:53:57 +02:00
|
|
|
int gaps;
|
|
|
|
|
2015-08-14 21:42:19 +02:00
|
|
|
list_t *children;
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Children of this container that are floated.
|
|
|
|
*/
|
2015-08-17 07:38:34 +02:00
|
|
|
list_t *floating;
|
2015-12-17 01:20:34 +01:00
|
|
|
/**
|
|
|
|
* Unmanaged view handles in this container.
|
|
|
|
*/
|
|
|
|
list_t *unmanaged;
|
2015-08-17 07:38:34 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* The parent of this container. NULL for the root container.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
struct sway_container *parent;
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Which of this container's children has focus.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
struct sway_container *focused;
|
2015-12-13 13:58:00 +01:00
|
|
|
/**
|
|
|
|
* If this container's children include a fullscreen view, this is that view.
|
|
|
|
*/
|
|
|
|
struct sway_container *fullscreen;
|
2016-03-29 14:47:30 +02:00
|
|
|
/**
|
|
|
|
* If this container is a view, this may be set to the window's decoration
|
|
|
|
* buffer (or NULL).
|
|
|
|
*/
|
2016-04-20 00:22:15 +02:00
|
|
|
struct border *border;
|
2016-03-29 14:47:30 +02:00
|
|
|
enum swayc_border_types border_type;
|
2016-03-14 02:10:46 +01:00
|
|
|
struct wlc_geometry border_geometry;
|
2016-03-29 14:47:30 +02:00
|
|
|
struct wlc_geometry title_bar_geometry;
|
|
|
|
struct wlc_geometry actual_geometry;
|
|
|
|
int border_thickness;
|
2015-08-14 21:42:19 +02:00
|
|
|
};
|
|
|
|
|
2015-09-14 01:46:16 +02:00
|
|
|
enum visibility_mask {
|
|
|
|
VISIBLE = true
|
|
|
|
} visible;
|
2015-08-14 21:42:19 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Allocates a new output container.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
swayc_t *new_output(wlc_handle handle);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Allocates a new workspace container.
|
|
|
|
*/
|
2015-08-18 13:19:20 +02:00
|
|
|
swayc_t *new_workspace(swayc_t *output, const char *name);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Allocates a new view container.
|
|
|
|
*
|
|
|
|
* Pass in a sibling view, or a workspace to become this container's parent.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Allocates a new floating view in the active workspace.
|
|
|
|
*/
|
2015-08-17 17:18:06 +02:00
|
|
|
swayc_t *new_floating_view(wlc_handle handle);
|
2015-08-14 21:42:19 +02:00
|
|
|
|
2016-05-31 14:59:33 +02:00
|
|
|
void floating_view_sane_size(swayc_t *view);
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Frees an output's container.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
swayc_t *destroy_output(swayc_t *output);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Destroys a workspace container and returns the parent pointer, or NULL.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
swayc_t *destroy_workspace(swayc_t *workspace);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Destroys a container and all empty parents. Returns the topmost non-empty
|
|
|
|
* parent container, or NULL.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
swayc_t *destroy_container(swayc_t *container);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Destroys a view container and all empty parents. Returns the topmost
|
|
|
|
* non-empty parent container, or NULL.
|
|
|
|
*/
|
2015-08-14 21:42:19 +02:00
|
|
|
swayc_t *destroy_view(swayc_t *view);
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Finds a container based on test criteria. Returns the first container that
|
|
|
|
* passes the test.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Finds a parent container with the given swayc_type.
|
|
|
|
*/
|
2015-08-20 18:52:54 +02:00
|
|
|
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Finds a parent with the given swayc_layout.
|
|
|
|
*/
|
2015-08-20 18:52:54 +02:00
|
|
|
swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Finds the bottom-most focused container of a type.
|
|
|
|
*/
|
2015-08-24 10:11:21 +02:00
|
|
|
swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Finds the bottom-most focused container of a layout.
|
|
|
|
*/
|
2015-08-24 10:11:21 +02:00
|
|
|
swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Gets the swayc_t associated with a wlc_handle.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
swayc_t *swayc_by_handle(wlc_handle handle);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Gets the named swayc_t.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
swayc_t *swayc_by_name(const char *name);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Gets the active output's container.
|
|
|
|
*/
|
2015-08-21 19:28:37 +02:00
|
|
|
swayc_t *swayc_active_output(void);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Gets the active workspace's container.
|
|
|
|
*/
|
2015-08-21 19:28:37 +02:00
|
|
|
swayc_t *swayc_active_workspace(void);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Gets the workspace for the given view container.
|
|
|
|
*/
|
2015-08-21 19:28:37 +02:00
|
|
|
swayc_t *swayc_active_workspace_for(swayc_t *view);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Finds the container currently underneath the pointer.
|
|
|
|
*/
|
2015-10-28 00:22:52 +01:00
|
|
|
swayc_t *container_under_pointer(void);
|
2015-08-20 18:52:54 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Returns true if a container is fullscreen.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
bool swayc_is_fullscreen(swayc_t *view);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this view is focused.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
bool swayc_is_active(swayc_t *view);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Returns true if the parent is an ancestor of the child.
|
|
|
|
*/
|
2015-08-28 08:18:28 +02:00
|
|
|
bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Returns true if the child is a desecendant of the parent.
|
|
|
|
*/
|
2015-08-28 08:18:28 +02:00
|
|
|
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
|
2016-04-01 13:36:36 +02:00
|
|
|
|
2016-04-20 00:22:15 +02:00
|
|
|
/**
|
|
|
|
* Returns the top most tabbed or stacked parent container. Returns NULL if
|
|
|
|
* view is not in a tabbed/stacked layout.
|
|
|
|
*/
|
|
|
|
swayc_t *swayc_tabbed_stacked_parent(swayc_t *view);
|
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Returns the gap (padding) of the container.
|
|
|
|
*
|
|
|
|
* This returns the inner gaps for a view, the outer gaps for a workspace, and
|
|
|
|
* 0 otherwise.
|
|
|
|
*/
|
2015-09-05 01:14:59 +02:00
|
|
|
int swayc_gap(swayc_t *container);
|
2015-08-10 22:31:23 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Maps a container's children over a function.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
2015-08-20 22:27:38 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
void set_view_visibility(swayc_t *view, void *data);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Set the gaps value for a view.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
void set_gaps(swayc_t *view, void *amount);
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Add to the gaps value for a view.
|
|
|
|
*/
|
2015-09-14 01:46:16 +02:00
|
|
|
void add_gaps(swayc_t *view, void *amount);
|
2015-08-17 04:06:31 +02:00
|
|
|
|
2015-11-08 18:06:12 +01:00
|
|
|
/**
|
|
|
|
* Issue wlc calls to make the visibility of a container consistent.
|
|
|
|
*/
|
2015-08-25 18:24:15 +02:00
|
|
|
void update_visibility(swayc_t *container);
|
|
|
|
|
2015-12-29 13:00:35 +01:00
|
|
|
/**
|
|
|
|
* Close all child views of container
|
|
|
|
*/
|
|
|
|
void close_views(swayc_t *container);
|
|
|
|
|
2015-08-10 22:31:23 +02:00
|
|
|
#endif
|