sway-patched-tray-menu/include/sway/tree/container.h

138 lines
3.1 KiB
C
Raw Normal View History

2017-11-19 23:04:28 +01:00
#ifndef _SWAY_CONTAINER_H
#define _SWAY_CONTAINER_H
#include <stdint.h>
#include <sys/types.h>
#include <wlr/types/wlr_box.h>
2017-12-10 14:48:44 +01:00
#include <wlr/types/wlr_surface.h>
2017-11-19 23:04:28 +01:00
#include "list.h"
2018-03-29 20:31:10 +02:00
extern struct sway_container root_container;
2017-11-19 23:04:28 +01:00
struct sway_view;
2018-01-31 05:09:21 +01:00
struct sway_seat;
2017-11-19 23:04:28 +01:00
/**
* Different kinds of containers.
*
* This enum is in order. A container will never be inside of a container below
* it on this list.
*/
2018-03-29 22:17:55 +02:00
enum sway_container_type {
C_ROOT,
C_OUTPUT,
C_WORKSPACE,
C_CONTAINER,
C_VIEW,
2017-11-19 23:04:28 +01:00
C_TYPES,
};
2018-03-29 22:17:55 +02:00
enum sway_container_layout {
L_NONE,
2017-11-19 23:04:28 +01:00
L_HORIZ,
L_VERT,
L_STACKED,
L_TABBED,
L_FLOATING,
2017-11-19 23:04:28 +01:00
// Keep last
L_LAYOUTS,
};
2018-03-29 22:17:55 +02:00
enum sway_container_border {
B_NONE,
B_PIXEL,
B_NORMAL,
2017-11-19 23:04:28 +01:00
};
2017-12-12 20:02:01 +01:00
struct sway_root;
2017-11-19 23:04:28 +01:00
struct sway_output;
struct sway_view;
struct sway_container {
union {
// TODO: Encapsulate state for other node types as well like C_CONTAINER
struct sway_root *sway_root;
struct sway_output *sway_output;
struct sway_view *sway_view;
2017-11-19 23:04:28 +01:00
};
/**
* A unique ID to identify this container. Primarily used in the
* get_tree JSON output.
*/
size_t id;
char *name;
2018-03-29 22:17:55 +02:00
enum sway_container_type type;
enum sway_container_layout layout;
enum sway_container_layout prev_layout;
enum sway_container_layout workspace_layout;
2017-11-19 23:04:28 +01:00
2018-03-30 03:19:57 +02:00
// TODO convert to layout coordinates
2017-11-19 23:04:28 +01:00
double x, y;
2018-03-30 03:19:57 +02:00
// does not include borders or gaps.
2017-11-19 23:04:28 +01:00
double width, height;
list_t *children;
struct sway_container *parent;
list_t *marks; // list of char*
2017-12-10 17:11:47 +01:00
struct {
struct wl_signal destroy;
} events;
2017-11-19 23:04:28 +01:00
};
// TODO only one container create function and pass the type?
2018-03-29 23:06:29 +02:00
struct sway_container *container_output_create(
2018-03-29 22:17:55 +02:00
struct sway_output *sway_output);
2018-03-29 23:06:29 +02:00
struct sway_container *container_workspace_create(
2018-03-29 22:17:55 +02:00
struct sway_container *output, const char *name);
2018-03-29 23:06:29 +02:00
struct sway_container *container_view_create(
2018-03-29 22:17:55 +02:00
struct sway_container *sibling, struct sway_view *sway_view);
2018-03-30 00:17:31 +02:00
struct sway_container *container_output_destroy(struct sway_container *output);
2017-11-19 23:04:28 +01:00
2018-03-29 23:06:29 +02:00
struct sway_container *container_view_destroy(struct sway_container *view);
2017-11-25 22:30:15 +01:00
2018-03-30 00:17:31 +02:00
struct sway_container *container_set_layout(struct sway_container *container,
enum sway_container_layout layout);
2018-03-29 22:17:55 +02:00
2018-03-29 23:06:29 +02:00
void container_descendents(struct sway_container *root,
2018-03-29 22:17:55 +02:00
enum sway_container_type type,
void (*func)(struct sway_container *item, void *data), void *data);
2018-01-31 05:09:21 +01:00
/**
* Finds a container based on test criteria. Returns the first container that
* passes the test.
*/
2018-03-29 23:06:29 +02:00
struct sway_container *container_find(struct sway_container *container,
2018-03-29 20:31:10 +02:00
bool (*test)(struct sway_container *view, void *data), void *data);
2018-01-31 05:09:21 +01:00
/**
2018-03-29 22:17:55 +02:00
* Finds a parent container with the given struct sway_containerype.
2018-01-31 05:09:21 +01:00
*/
2018-03-29 23:06:29 +02:00
struct sway_container *container_parent(struct sway_container *container,
2018-03-29 22:17:55 +02:00
enum sway_container_type type);
2018-03-29 22:17:55 +02:00
/**
* Find a container at the given coordinates.
*/
2018-03-30 03:19:57 +02:00
struct sway_container *container_at(struct sway_container *parent,
2018-03-29 22:17:55 +02:00
double lx, double ly, struct wlr_surface **surface,
double *sx, double *sy);
2017-12-10 14:48:44 +01:00
2018-02-04 19:39:10 +01:00
/**
* Apply the function for each child of the container breadth first.
2018-02-04 19:39:10 +01:00
*/
2018-03-30 03:19:57 +02:00
void container_for_each(struct sway_container *container,
2018-03-29 22:17:55 +02:00
void (*f)(struct sway_container *container, void *data), void *data);
2018-02-23 00:03:46 +01:00
2017-11-19 23:04:28 +01:00
#endif