aboutsummaryrefslogtreecommitdiffstats
path: root/sway/layout.h
blob: 08f3f78b5d965036d33747509ae12a2c382ffa4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef _SWAY_LAYOUT_H
#define _SWAY_LAYOUT_H

#include <wlc/wlc.h>
#include "list.h"

struct sway_container {
    wlc_handle handle;

    enum {
        C_ROOT,
        C_OUTPUT,
        C_WORKSPACE,
        C_CONTAINER,
        C_VIEW
    } type;

    enum {
        L_NONE,
        L_HORIZ,
        L_VERT,
        L_STACKED,
        L_TABBED,
        L_FLOATING
    } layout;

    // Not including borders or margins
    int width, height;

    int x, y;

    int weight;

    char *name;

    list_t *children;

    struct sway_container *parent;
    struct sway_container *focused;
};

typedef struct sway_container swayc_t;

extern swayc_t root_container;

void init_layout();
void add_child(swayc_t *parent, swayc_t *child);
void add_output(wlc_handle output);
void destroy_output(wlc_handle output);
void destroy_view(swayc_t *view);
void add_view(wlc_handle view);
void focus_view(swayc_t *view);
void arrange_windows(swayc_t *container, int width, int height);
swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
swayc_t *get_focused_container(swayc_t *parent);
int remove_container_from_parent(swayc_t *parent, swayc_t *container);
swayc_t *create_container(swayc_t *parent, wlc_handle handle);
swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent);

#endif