aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/tree
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 23:29:29 -0400
committerLibravatar GitHub <noreply@github.com>2018-03-29 23:29:29 -0400
commitd0c7f66e950689b70196a890b62b82ff3c66e103 (patch)
treeb8b52173a9791e3b13a0316ab9d316a80a6adc20 /include/sway/tree
parentMerge pull request #1647 from acrisci/refactor-tree (diff)
downloadsway-d0c7f66e950689b70196a890b62b82ff3c66e103.tar.gz
sway-d0c7f66e950689b70196a890b62b82ff3c66e103.tar.zst
sway-d0c7f66e950689b70196a890b62b82ff3c66e103.zip
Revert "Refactor tree"
Diffstat (limited to 'include/sway/tree')
-rw-r--r--include/sway/tree/container.h137
-rw-r--r--include/sway/tree/layout.h52
-rw-r--r--include/sway/tree/view.h116
-rw-r--r--include/sway/tree/workspace.h26
4 files changed, 0 insertions, 331 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
deleted file mode 100644
index 16df3ee7..00000000
--- a/include/sway/tree/container.h
+++ /dev/null
@@ -1,137 +0,0 @@
1#ifndef _SWAY_CONTAINER_H
2#define _SWAY_CONTAINER_H
3#include <stdint.h>
4#include <sys/types.h>
5#include <wlr/types/wlr_box.h>
6#include <wlr/types/wlr_surface.h>
7#include "list.h"
8
9extern struct sway_container root_container;
10
11struct sway_view;
12struct sway_seat;
13
14/**
15 * Different kinds of containers.
16 *
17 * This enum is in order. A container will never be inside of a container below
18 * it on this list.
19 */
20enum sway_container_type {
21 C_ROOT,
22 C_OUTPUT,
23 C_WORKSPACE,
24 C_CONTAINER,
25 C_VIEW,
26
27 C_TYPES,
28};
29
30enum sway_container_layout {
31 L_NONE,
32 L_HORIZ,
33 L_VERT,
34 L_STACKED,
35 L_TABBED,
36 L_FLOATING,
37
38 // Keep last
39 L_LAYOUTS,
40};
41
42enum sway_container_border {
43 B_NONE,
44 B_PIXEL,
45 B_NORMAL,
46};
47
48struct sway_root;
49struct sway_output;
50struct sway_view;
51
52struct sway_container {
53 union {
54 // TODO: Encapsulate state for other node types as well like C_CONTAINER
55 struct sway_root *sway_root;
56 struct sway_output *sway_output;
57 struct sway_view *sway_view;
58 };
59
60 /**
61 * A unique ID to identify this container. Primarily used in the
62 * get_tree JSON output.
63 */
64 size_t id;
65
66 char *name;
67
68 enum sway_container_type type;
69 enum sway_container_layout layout;
70 enum sway_container_layout prev_layout;
71 enum sway_container_layout workspace_layout;
72
73 // TODO convert to layout coordinates
74 double x, y;
75
76 // does not include borders or gaps.
77 double width, height;
78
79 list_t *children;
80
81 struct sway_container *parent;
82
83 list_t *marks; // list of char*
84
85 struct {
86 struct wl_signal destroy;
87 } events;
88};
89
90// TODO only one container create function and pass the type?
91struct sway_container *container_output_create(
92 struct sway_output *sway_output);
93
94struct sway_container *container_workspace_create(
95 struct sway_container *output, const char *name);
96
97struct sway_container *container_view_create(
98 struct sway_container *sibling, struct sway_view *sway_view);
99
100struct sway_container *container_output_destroy(struct sway_container *output);
101
102struct sway_container *container_view_destroy(struct sway_container *view);
103
104struct sway_container *container_set_layout(struct sway_container *container,
105 enum sway_container_layout layout);
106
107void container_descendents(struct sway_container *root,
108 enum sway_container_type type,
109 void (*func)(struct sway_container *item, void *data), void *data);
110
111/**
112 * Finds a container based on test criteria. Returns the first container that
113 * passes the test.
114 */
115struct sway_container *container_find(struct sway_container *container,
116 bool (*test)(struct sway_container *view, void *data), void *data);
117
118/**
119 * Finds a parent container with the given struct sway_containerype.
120 */
121struct sway_container *container_parent(struct sway_container *container,
122 enum sway_container_type type);
123
124/**
125 * Find a container at the given coordinates.
126 */
127struct sway_container *container_at(struct sway_container *parent,
128 double lx, double ly, struct wlr_surface **surface,
129 double *sx, double *sy);
130
131/**
132 * Apply the function for each child of the container breadth first.
133 */
134void container_for_each_descendent(struct sway_container *container,
135 void (*f)(struct sway_container *container, void *data), void *data);
136
137#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
deleted file mode 100644
index ad52bdb0..00000000
--- a/include/sway/tree/layout.h
+++ /dev/null
@@ -1,52 +0,0 @@
1#ifndef _SWAY_LAYOUT_H
2#define _SWAY_LAYOUT_H
3
4#include <wlr/types/wlr_output_layout.h>
5#include "sway/tree/container.h"
6
7enum movement_direction {
8 MOVE_LEFT,
9 MOVE_RIGHT,
10 MOVE_UP,
11 MOVE_DOWN,
12 MOVE_PARENT,
13 MOVE_CHILD,
14 MOVE_NEXT,
15 MOVE_PREV,
16 MOVE_FIRST
17};
18
19struct sway_container;
20
21struct sway_root {
22 struct wlr_output_layout *output_layout;
23
24 struct wl_listener output_layout_change;
25
26 struct wl_list unmanaged_views; // sway_view::unmanaged_view_link
27
28 struct {
29 struct wl_signal new_container;
30 } events;
31};
32
33void layout_init(void);
34
35void container_add_child(struct sway_container *parent, struct sway_container *child);
36
37struct sway_container *container_add_sibling(struct sway_container *parent,
38 struct sway_container *child);
39
40struct sway_container *container_remove_child(struct sway_container *child);
41
42enum sway_container_layout container_get_default_layout(struct sway_container *output);
43
44void container_sort_workspaces(struct sway_container *output);
45
46void arrange_windows(struct sway_container *container,
47 double width, double height);
48
49struct sway_container *container_get_in_direction(struct sway_container
50 *container, struct sway_seat *seat, enum movement_direction dir);
51
52#endif
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
deleted file mode 100644
index e5f53f4e..00000000
--- a/include/sway/tree/view.h
+++ /dev/null
@@ -1,116 +0,0 @@
1#ifndef _SWAY_VIEW_H
2#define _SWAY_VIEW_H
3#include <wayland-server.h>
4#include <wlr/types/wlr_surface.h>
5#include <wlr/types/wlr_xdg_shell_v6.h>
6#include <wlr/xwayland.h>
7
8struct sway_container;
9struct sway_view;
10
11struct sway_xdg_surface_v6 {
12 struct sway_view *view;
13
14 struct wl_listener commit;
15 struct wl_listener request_move;
16 struct wl_listener request_resize;
17 struct wl_listener request_maximize;
18 struct wl_listener destroy;
19
20 int pending_width, pending_height;
21};
22
23struct sway_xwayland_surface {
24 struct sway_view *view;
25
26 struct wl_listener commit;
27 struct wl_listener request_move;
28 struct wl_listener request_resize;
29 struct wl_listener request_maximize;
30 struct wl_listener request_configure;
31 struct wl_listener unmap_notify;
32 struct wl_listener map_notify;
33 struct wl_listener destroy;
34
35 int pending_width, pending_height;
36};
37
38struct sway_wl_shell_surface {
39 struct sway_view *view;
40
41 struct wl_listener commit;
42 struct wl_listener request_move;
43 struct wl_listener request_resize;
44 struct wl_listener request_maximize;
45 struct wl_listener destroy;
46
47 int pending_width, pending_height;
48};
49
50enum sway_view_type {
51 SWAY_WL_SHELL_VIEW,
52 SWAY_XDG_SHELL_V6_VIEW,
53 SWAY_XWAYLAND_VIEW,
54 // Keep last
55 SWAY_VIEW_TYPES,
56};
57
58enum sway_view_prop {
59 VIEW_PROP_TITLE,
60 VIEW_PROP_APP_ID,
61 VIEW_PROP_CLASS,
62 VIEW_PROP_INSTANCE,
63};
64
65struct sway_view {
66 enum sway_view_type type;
67 struct sway_container *swayc;
68 struct wlr_surface *surface;
69 int width, height;
70
71 union {
72 struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
73 struct wlr_xwayland_surface *wlr_xwayland_surface;
74 struct wlr_wl_shell_surface *wlr_wl_shell_surface;
75 };
76
77 union {
78 struct sway_xdg_surface_v6 *sway_xdg_surface_v6;
79 struct sway_xwayland_surface *sway_xwayland_surface;
80 struct sway_wl_shell_surface *sway_wl_shell_surface;
81 };
82
83 struct {
84 const char *(*get_prop)(struct sway_view *view,
85 enum sway_view_prop prop);
86 void (*set_size)(struct sway_view *view,
87 int width, int height);
88 void (*set_position)(struct sway_view *view,
89 double ox, double oy);
90 void (*set_activated)(struct sway_view *view, bool activated);
91 void (*close)(struct sway_view *view);
92 } iface;
93
94 // only used for unmanaged views (shell specific)
95 struct wl_list unmanaged_view_link; // sway_root::unmanaged views
96};
97
98const char *view_get_title(struct sway_view *view);
99
100const char *view_get_app_id(struct sway_view *view);
101
102const char *view_get_class(struct sway_view *view);
103
104const char *view_get_instance(struct sway_view *view);
105
106void view_set_size(struct sway_view *view, int width, int height);
107
108void view_set_position(struct sway_view *view, double ox, double oy);
109
110void view_set_activated(struct sway_view *view, bool activated);
111
112void view_close(struct sway_view *view);
113
114void view_update_outputs(struct sway_view *view, const struct wlr_box *before);
115
116#endif
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
deleted file mode 100644
index d73b29c1..00000000
--- a/include/sway/tree/workspace.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef _SWAY_WORKSPACE_H
2#define _SWAY_WORKSPACE_H
3
4#include "sway/tree/container.h"
5
6extern char *prev_workspace_name;
7
8char *workspace_next_name(const char *output_name);
9
10struct sway_container *workspace_create(const char *name);
11
12bool workspace_switch(struct sway_container *workspace);
13
14struct sway_container *workspace_by_number(const char* name);
15
16struct sway_container *workspace_by_name(const char*);
17
18struct sway_container *workspace_output_next(struct sway_container *current);
19
20struct sway_container *workspace_next(struct sway_container *current);
21
22struct sway_container *workspace_output_prev(struct sway_container *current);
23
24struct sway_container *workspace_prev(struct sway_container *current);
25
26#endif