aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway')
-rw-r--r--include/sway/config.h4
-rw-r--r--include/sway/criteria.h2
-rw-r--r--include/sway/ipc-json.h2
-rw-r--r--include/sway/ipc-server.h4
-rw-r--r--include/sway/tree/container.h (renamed from include/sway/container.h)75
-rw-r--r--include/sway/tree/layout.h (renamed from include/sway/layout.h)12
-rw-r--r--include/sway/tree/view.h (renamed from include/sway/view.h)4
-rw-r--r--include/sway/tree/workspace.h (renamed from include/sway/workspace.h)8
8 files changed, 45 insertions, 66 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 48a8b0ab..48ebba3b 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -10,8 +10,8 @@
10#include <xkbcommon/xkbcommon.h> 10#include <xkbcommon/xkbcommon.h>
11#include <time.h> 11#include <time.h>
12#include "list.h" 12#include "list.h"
13#include "layout.h" 13#include "tree/layout.h"
14#include "container.h" 14#include "tree/container.h"
15 15
16/** 16/**
17 * Describes a variable created via the `set` command. 17 * Describes a variable created via the `set` command.
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index 9b4b4bef..431cfa3a 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -1,7 +1,7 @@
1#ifndef _SWAY_CRITERIA_H 1#ifndef _SWAY_CRITERIA_H
2#define _SWAY_CRITERIA_H 2#define _SWAY_CRITERIA_H
3 3
4#include "container.h" 4#include "tree/container.h"
5#include "list.h" 5#include "list.h"
6 6
7/** 7/**
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h
index eef5a018..76b7d45b 100644
--- a/include/sway/ipc-json.h
+++ b/include/sway/ipc-json.h
@@ -1,7 +1,7 @@
1#ifndef _SWAY_IPC_JSON_H 1#ifndef _SWAY_IPC_JSON_H
2#define _SWAY_IPC_JSON_H 2#define _SWAY_IPC_JSON_H
3#include <json-c/json.h> 3#include <json-c/json.h>
4#include "sway/container.h" 4#include "sway/tree/container.h"
5#include "sway/input/input-manager.h" 5#include "sway/input/input-manager.h"
6 6
7json_object *ipc_json_get_version(); 7json_object *ipc_json_get_version();
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h
index bcf1c433..db690b6e 100644
--- a/include/sway/ipc-server.h
+++ b/include/sway/ipc-server.h
@@ -1,13 +1,15 @@
1#ifndef _SWAY_IPC_SERVER_H 1#ifndef _SWAY_IPC_SERVER_H
2#define _SWAY_IPC_SERVER_H 2#define _SWAY_IPC_SERVER_H
3#include <sys/socket.h> 3#include <sys/socket.h>
4#include "sway/container.h" 4#include "sway/tree/container.h"
5#include "ipc.h" 5#include "ipc.h"
6 6
7struct sway_server; 7struct sway_server;
8 8
9void ipc_init(struct sway_server *server); 9void ipc_init(struct sway_server *server);
10
10void ipc_terminate(void); 11void ipc_terminate(void);
12
11struct sockaddr_un *ipc_user_sockaddr(void); 13struct sockaddr_un *ipc_user_sockaddr(void);
12 14
13void ipc_event_window(swayc_t *window, const char *change); 15void ipc_event_window(swayc_t *window, const char *change);
diff --git a/include/sway/container.h b/include/sway/tree/container.h
index f200a1a2..5a2ae349 100644
--- a/include/sway/container.h
+++ b/include/sway/tree/container.h
@@ -20,60 +20,43 @@ struct sway_seat;
20 * it on this list. 20 * it on this list.
21 */ 21 */
22enum swayc_types { 22enum swayc_types {
23 C_ROOT, /**< The root container. Only one of these ever exists. */ 23 C_ROOT,
24 C_OUTPUT, /**< An output (aka monitor, head, etc). */ 24 C_OUTPUT,
25 C_WORKSPACE, /**< A workspace. */ 25 C_WORKSPACE,
26 C_CONTAINER, /**< A manually created container. */ 26 C_CONTAINER,
27 C_VIEW, /**< A view (aka window). */ 27 C_VIEW,
28 28
29 C_TYPES, 29 C_TYPES,
30}; 30};
31 31
32/**
33 * Different ways to arrange a container.
34 */
35enum swayc_layouts { 32enum swayc_layouts {
36 L_NONE, /**< Used for containers that have no layout (views, root) */ 33 L_NONE,
37 L_HORIZ, 34 L_HORIZ,
38 L_VERT, 35 L_VERT,
39 L_STACKED, 36 L_STACKED,
40 L_TABBED, 37 L_TABBED,
41 L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */ 38 L_FLOATING,
42
43 /* Awesome/Monad style auto layouts */
44 L_AUTO_LEFT,
45 L_AUTO_RIGHT,
46 L_AUTO_TOP,
47 L_AUTO_BOTTOM,
48
49 L_AUTO_FIRST = L_AUTO_LEFT,
50 L_AUTO_LAST = L_AUTO_BOTTOM,
51 39
52 // Keep last 40 // Keep last
53 L_LAYOUTS, 41 L_LAYOUTS,
54}; 42};
55 43
56enum swayc_border_types { 44enum swayc_border_types {
57 B_NONE, /**< No border */ 45 B_NONE,
58 B_PIXEL, /**< 1px border */ 46 B_PIXEL,
59 B_NORMAL, /**< Normal border with title bar */ 47 B_NORMAL,
60}; 48};
61 49
62struct sway_root; 50struct sway_root;
63struct sway_output; 51struct sway_output;
64struct sway_view; 52struct sway_view;
65 53
66/**
67 * Stores information about a container.
68 *
69 * The tree is made of these. Views are containers that cannot have children.
70 */
71struct sway_container { 54struct sway_container {
72 union { 55 union {
73 // TODO: Encapsulate state for other node types as well like C_CONTAINER 56 // TODO: Encapsulate state for other node types as well like C_CONTAINER
74 struct sway_root *sway_root; // C_ROOT 57 struct sway_root *sway_root;
75 struct sway_output *sway_output; // C_OUTPUT 58 struct sway_output *sway_output;
76 struct sway_view *sway_view; // C_VIEW 59 struct sway_view *sway_view;
77 }; 60 };
78 61
79 /** 62 /**
@@ -89,38 +72,17 @@ struct sway_container {
89 enum swayc_layouts prev_layout; 72 enum swayc_layouts prev_layout;
90 enum swayc_layouts workspace_layout; 73 enum swayc_layouts workspace_layout;
91 74
92 /** 75 // TODO convert to layout coordinates
93 * The coordinates that this view appear at, relative to the output they
94 * are located on (output containers have absolute coordinates).
95 */
96 double x, y; 76 double x, y;
97 77
98 /** 78 // does not include borders or gaps.
99 * Width and height of this container, without borders or gaps.
100 */
101 double width, height; 79 double width, height;
102 80
103 list_t *children; 81 list_t *children;
104 82
105 /**
106 * The parent of this container. NULL for the root container.
107 */
108 struct sway_container *parent; 83 struct sway_container *parent;
109 84
110 /** 85 list_t *marks; // list of char*
111 * Number of master views in auto layouts.
112 */
113 size_t nb_master;
114
115 /**
116 * Number of slave groups (e.g. columns) in auto layouts.
117 */
118 size_t nb_slave_groups;
119
120 /**
121 * Marks applied to the container, list_t of char*.
122 */
123 list_t *marks;
124 86
125 struct { 87 struct {
126 struct wl_signal destroy; 88 struct wl_signal destroy;
@@ -130,8 +92,11 @@ struct sway_container {
130void swayc_descendants_of_type(swayc_t *root, enum swayc_types type, 92void swayc_descendants_of_type(swayc_t *root, enum swayc_types type,
131 void (*func)(swayc_t *item, void *data), void *data); 93 void (*func)(swayc_t *item, void *data), void *data);
132 94
95// TODO only one container create function and pass the type?
133swayc_t *new_output(struct sway_output *sway_output); 96swayc_t *new_output(struct sway_output *sway_output);
97
134swayc_t *new_workspace(swayc_t *output, const char *name); 98swayc_t *new_workspace(swayc_t *output, const char *name);
99
135swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view); 100swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view);
136 101
137swayc_t *destroy_output(swayc_t *output); 102swayc_t *destroy_output(swayc_t *output);
@@ -145,10 +110,12 @@ swayc_t *next_view_sibling(struct sway_seat *seat);
145 */ 110 */
146swayc_t *swayc_by_test(swayc_t *container, 111swayc_t *swayc_by_test(swayc_t *container,
147 bool (*test)(swayc_t *view, void *data), void *data); 112 bool (*test)(swayc_t *view, void *data), void *data);
113
148/** 114/**
149 * Finds a parent container with the given swayc_type. 115 * Finds a parent container with the given swayc_type.
150 */ 116 */
151swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type); 117swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type);
118
152/** 119/**
153 * Maps a container's children over a function. 120 * Maps a container's children over a function.
154 */ 121 */
diff --git a/include/sway/layout.h b/include/sway/tree/layout.h
index e82c4442..39b7fb24 100644
--- a/include/sway/layout.h
+++ b/include/sway/tree/layout.h
@@ -2,7 +2,7 @@
2#define _SWAY_LAYOUT_H 2#define _SWAY_LAYOUT_H
3 3
4#include <wlr/types/wlr_output_layout.h> 4#include <wlr/types/wlr_output_layout.h>
5#include "sway/container.h" 5#include "sway/tree/container.h"
6 6
7enum movement_direction { 7enum movement_direction {
8 MOVE_LEFT, 8 MOVE_LEFT,
@@ -31,12 +31,20 @@ struct sway_root {
31}; 31};
32 32
33void init_layout(void); 33void init_layout(void);
34
34void add_child(struct sway_container *parent, struct sway_container *child); 35void add_child(struct sway_container *parent, struct sway_container *child);
36
35swayc_t *add_sibling(swayc_t *parent, swayc_t *child); 37swayc_t *add_sibling(swayc_t *parent, swayc_t *child);
38
36struct sway_container *remove_child(struct sway_container *child); 39struct sway_container *remove_child(struct sway_container *child);
40
37enum swayc_layouts default_layout(struct sway_container *output); 41enum swayc_layouts default_layout(struct sway_container *output);
42
38void sort_workspaces(struct sway_container *output); 43void sort_workspaces(struct sway_container *output);
39void arrange_windows(struct sway_container *container, double width, double height); 44
45void arrange_windows(struct sway_container *container,
46 double width, double height);
47
40swayc_t *get_swayc_in_direction(swayc_t *container, 48swayc_t *get_swayc_in_direction(swayc_t *container,
41 struct sway_seat *seat, enum movement_direction dir); 49 struct sway_seat *seat, enum movement_direction dir);
42 50
diff --git a/include/sway/view.h b/include/sway/tree/view.h
index b2886211..e5f53f4e 100644
--- a/include/sway/view.h
+++ b/include/sway/tree/view.h
@@ -62,10 +62,6 @@ enum sway_view_prop {
62 VIEW_PROP_INSTANCE, 62 VIEW_PROP_INSTANCE,
63}; 63};
64 64
65/**
66 * sway_view is a state container for surfaces that are arranged in the sway
67 * tree (shell surfaces).
68 */
69struct sway_view { 65struct sway_view {
70 enum sway_view_type type; 66 enum sway_view_type type;
71 struct sway_container *swayc; 67 struct sway_container *swayc;
diff --git a/include/sway/workspace.h b/include/sway/tree/workspace.h
index fee54255..c8ce40d1 100644
--- a/include/sway/workspace.h
+++ b/include/sway/tree/workspace.h
@@ -1,20 +1,26 @@
1#ifndef _SWAY_WORKSPACE_H 1#ifndef _SWAY_WORKSPACE_H
2#define _SWAY_WORKSPACE_H 2#define _SWAY_WORKSPACE_H
3 3
4#include "sway/container.h" 4#include "sway/tree/container.h"
5 5
6extern char *prev_workspace_name; 6extern char *prev_workspace_name;
7 7
8char *workspace_next_name(const char *output_name); 8char *workspace_next_name(const char *output_name);
9
9swayc_t *workspace_create(const char *name); 10swayc_t *workspace_create(const char *name);
11
10bool workspace_switch(swayc_t *workspace); 12bool workspace_switch(swayc_t *workspace);
11 13
12struct sway_container *workspace_by_number(const char* name); 14struct sway_container *workspace_by_number(const char* name);
15
13swayc_t *workspace_by_name(const char*); 16swayc_t *workspace_by_name(const char*);
14 17
15struct sway_container *workspace_output_next(swayc_t *current); 18struct sway_container *workspace_output_next(swayc_t *current);
19
16struct sway_container *workspace_next(swayc_t *current); 20struct sway_container *workspace_next(swayc_t *current);
21
17struct sway_container *workspace_output_prev(swayc_t *current); 22struct sway_container *workspace_output_prev(swayc_t *current);
23
18struct sway_container *workspace_prev(swayc_t *current); 24struct sway_container *workspace_prev(swayc_t *current);
19 25
20#endif 26#endif