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.
137 lines
2.8 KiB
137 lines
2.8 KiB
7 years ago
|
#ifndef _SWAY_CONTAINER_H
|
||
|
#define _SWAY_CONTAINER_H
|
||
|
#include <stdint.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <wlr/types/wlr_box.h>
|
||
7 years ago
|
#include <wlr/types/wlr_surface.h>
|
||
7 years ago
|
#include "list.h"
|
||
|
|
||
|
typedef struct sway_container swayc_t;
|
||
|
|
||
|
extern swayc_t root_container;
|
||
|
|
||
|
struct sway_view;
|
||
7 years ago
|
struct sway_seat;
|
||
7 years ago
|
|
||
|
/**
|
||
|
* Different kinds of containers.
|
||
|
*
|
||
|
* This enum is in order. A container will never be inside of a container below
|
||
|
* it on this list.
|
||
|
*/
|
||
|
enum swayc_types {
|
||
7 years ago
|
C_ROOT,
|
||
|
C_OUTPUT,
|
||
|
C_WORKSPACE,
|
||
|
C_CONTAINER,
|
||
|
C_VIEW,
|
||
7 years ago
|
|
||
|
C_TYPES,
|
||
|
};
|
||
|
|
||
|
enum swayc_layouts {
|
||
7 years ago
|
L_NONE,
|
||
7 years ago
|
L_HORIZ,
|
||
|
L_VERT,
|
||
|
L_STACKED,
|
||
|
L_TABBED,
|
||
7 years ago
|
L_FLOATING,
|
||
7 years ago
|
|
||
|
// Keep last
|
||
|
L_LAYOUTS,
|
||
|
};
|
||
|
|
||
|
enum swayc_border_types {
|
||
7 years ago
|
B_NONE,
|
||
|
B_PIXEL,
|
||
|
B_NORMAL,
|
||
7 years ago
|
};
|
||
|
|
||
7 years ago
|
struct sway_root;
|
||
7 years ago
|
struct sway_output;
|
||
|
struct sway_view;
|
||
|
|
||
|
struct sway_container {
|
||
|
union {
|
||
|
// TODO: Encapsulate state for other node types as well like C_CONTAINER
|
||
7 years ago
|
struct sway_root *sway_root;
|
||
|
struct sway_output *sway_output;
|
||
|
struct sway_view *sway_view;
|
||
7 years ago
|
};
|
||
|
|
||
|
/**
|
||
|
* A unique ID to identify this container. Primarily used in the
|
||
|
* get_tree JSON output.
|
||
|
*/
|
||
|
size_t id;
|
||
|
|
||
|
char *name;
|
||
|
|
||
|
enum swayc_types type;
|
||
|
enum swayc_layouts layout;
|
||
|
enum swayc_layouts prev_layout;
|
||
|
enum swayc_layouts workspace_layout;
|
||
|
|
||
7 years ago
|
// TODO convert to layout coordinates
|
||
7 years ago
|
double x, y;
|
||
|
|
||
7 years ago
|
// does not include borders or gaps.
|
||
7 years ago
|
double width, height;
|
||
|
|
||
|
list_t *children;
|
||
|
|
||
|
struct sway_container *parent;
|
||
|
|
||
7 years ago
|
list_t *marks; // list of char*
|
||
7 years ago
|
|
||
|
struct {
|
||
|
struct wl_signal destroy;
|
||
|
} events;
|
||
7 years ago
|
};
|
||
|
|
||
7 years ago
|
void swayc_descendants_of_type(swayc_t *root, enum swayc_types type,
|
||
|
void (*func)(swayc_t *item, void *data), void *data);
|
||
|
|
||
7 years ago
|
// TODO only one container create function and pass the type?
|
||
7 years ago
|
swayc_t *new_output(struct sway_output *sway_output);
|
||
7 years ago
|
|
||
7 years ago
|
swayc_t *new_workspace(swayc_t *output, const char *name);
|
||
7 years ago
|
|
||
7 years ago
|
swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view);
|
||
7 years ago
|
|
||
7 years ago
|
swayc_t *destroy_output(swayc_t *output);
|
||
7 years ago
|
swayc_t *destroy_view(swayc_t *view);
|
||
|
|
||
7 years ago
|
swayc_t *next_view_sibling(struct sway_seat *seat);
|
||
|
|
||
|
/**
|
||
|
* Finds a container based on test criteria. Returns the first container that
|
||
|
* passes the test.
|
||
|
*/
|
||
|
swayc_t *swayc_by_test(swayc_t *container,
|
||
|
bool (*test)(swayc_t *view, void *data), void *data);
|
||
7 years ago
|
|
||
7 years ago
|
/**
|
||
|
* Finds a parent container with the given swayc_type.
|
||
|
*/
|
||
7 years ago
|
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type);
|
||
7 years ago
|
|
||
7 years ago
|
/**
|
||
|
* Maps a container's children over a function.
|
||
|
*/
|
||
|
void container_map(swayc_t *container,
|
||
|
void (*f)(swayc_t *view, void *data), void *data);
|
||
7 years ago
|
|
||
7 years ago
|
swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
|
||
|
struct wlr_surface **surface, double *sx, double *sy);
|
||
|
|
||
7 years ago
|
/**
|
||
7 years ago
|
* Apply the function for each child of the container breadth first.
|
||
7 years ago
|
*/
|
||
7 years ago
|
void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data),
|
||
|
void *data);
|
||
7 years ago
|
|
||
7 years ago
|
swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
|
||
|
|
||
7 years ago
|
#endif
|