aboutsummaryrefslogtreecommitdiffstats
path: root/include/container.h
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-09-13 19:46:16 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-09-13 19:46:16 -0400
commite505abfe75923d06098f6230e5a7ba39c091d3ce (patch)
treefc90bdf0afed21d725f6ee7a9245e397e1577517 /include/container.h
parentMerge pull request #179 from taiyu-len/master (diff)
downloadsway-e505abfe75923d06098f6230e5a7ba39c091d3ce.tar.gz
sway-e505abfe75923d06098f6230e5a7ba39c091d3ce.tar.zst
sway-e505abfe75923d06098f6230e5a7ba39c091d3ce.zip
Revert "new_workspace null behavior + testmap functions + regex"
This reverts commit e1d18e42a8f3a597b9bf5f1bb2ab6c346e4e7983. Fixes #180 cc @taiyu-len
Diffstat (limited to 'include/container.h')
-rw-r--r--include/container.h139
1 files changed, 45 insertions, 94 deletions
diff --git a/include/container.h b/include/container.h
index b164af95..ae9a9fc5 100644
--- a/include/container.h
+++ b/include/container.h
@@ -2,25 +2,29 @@
2#define _SWAY_CONTAINER_H 2#define _SWAY_CONTAINER_H
3#include <wlc/wlc.h> 3#include <wlc/wlc.h>
4typedef struct sway_container swayc_t; 4typedef struct sway_container swayc_t;
5
5#include "layout.h" 6#include "layout.h"
6 7
7enum swayc_types { 8enum swayc_types{
8 C_ROOT = 1 << 0, 9 C_ROOT,
9 C_OUTPUT = 1 << 1, 10 C_OUTPUT,
10 C_WORKSPACE = 1 << 2, 11 C_WORKSPACE,
11 C_CONTAINER = 1 << 3, 12 C_CONTAINER,
12 C_VIEW = 1 << 4, 13 C_VIEW,
13 C_TYPES = 5, 14 // Keep last
15 C_TYPES,
14}; 16};
15 17
16enum swayc_layouts { 18
17 L_NONE = 1 << 0, 19enum swayc_layouts{
18 L_HORIZ = 1 << 1, 20 L_NONE,
19 L_VERT = 1 << 2, 21 L_HORIZ,
20 L_STACKED = 1 << 3, 22 L_VERT,
21 L_TABBED = 1 << 4, 23 L_STACKED,
22 L_FLOATING = 1 << 5, 24 L_TABBED,
23 L_LAYOUTS = 6, 25 L_FLOATING,
26 // Keep last
27 L_LAYOUTS,
24}; 28};
25 29
26struct sway_container { 30struct sway_container {
@@ -31,16 +35,13 @@ struct sway_container {
31 35
32 // Not including borders or margins 36 // Not including borders or margins
33 double width, height; 37 double width, height;
34 double x, y;
35 38
36 // Used for setting floating geometry 39 // Used for setting floating geometry
37 int desired_width, desired_height; 40 int desired_width, desired_height;
38 41
39 enum visibility_mask { 42 double x, y;
40 INVISIBLE = false,
41 VISIBLE = true,
42 } visible;
43 43
44 bool visible;
44 bool is_floating; 45 bool is_floating;
45 bool is_focused; 46 bool is_focused;
46 47
@@ -55,120 +56,70 @@ struct sway_container {
55 struct sway_container *focused; 56 struct sway_container *focused;
56}; 57};
57 58
58// swayc Creation 59enum visibility_mask {
60 VISIBLE = true
61} visible;
59 62
60/* Creates and returns new, or an already created output. 63// Container Creation
61 * If it creates a new output, it also creates a workspace using
62 * `new_workspace(outputname, NULL);` */
63swayc_t *new_output(wlc_handle handle);
64 64
65/* Creates workspace with given name, under given output. 65swayc_t *new_output(wlc_handle handle);
66 * If workspace with that name already exists, returns that workspace
67 * If name is NULL, it will choose a name automatically.
68 * If output is NULL, it will choose an output automatically. */
69swayc_t *new_workspace(swayc_t *output, const char *name); 66swayc_t *new_workspace(swayc_t *output, const char *name);
70
71// Creates container Around child (parent child) -> (parent (container child)) 67// Creates container Around child (parent child) -> (parent (container child))
72swayc_t *new_container(swayc_t *child, enum swayc_layouts layout); 68swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
73
74// Creates view as a sibling of current focused container, or as child of a workspace 69// Creates view as a sibling of current focused container, or as child of a workspace
75swayc_t *new_view(swayc_t *sibling, wlc_handle handle); 70swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
76
77// Creates view as a new floating view which is in the active workspace 71// Creates view as a new floating view which is in the active workspace
78swayc_t *new_floating_view(wlc_handle handle); 72swayc_t *new_floating_view(wlc_handle handle);
79 73
80// Container Destroying 74// Container Destroying
81// Destroys output and moves workspaces to another output
82swayc_t *destroy_output(swayc_t *output);
83 75
76swayc_t *destroy_output(swayc_t *output);
84// Destroys workspace if empty and returns parent pointer, else returns NULL 77// Destroys workspace if empty and returns parent pointer, else returns NULL
85swayc_t *destroy_workspace(swayc_t *workspace); 78swayc_t *destroy_workspace(swayc_t *workspace);
86
87// Destroyes container and all parent container if they are empty, returns 79// Destroyes container and all parent container if they are empty, returns
88// topmost non-empty parent. returns NULL otherwise 80// topmost non-empty parent. returns NULL otherwise
89swayc_t *destroy_container(swayc_t *container); 81swayc_t *destroy_container(swayc_t *container);
90
91// Destroys view and all empty parent containers. return topmost non-empty 82// Destroys view and all empty parent containers. return topmost non-empty
92// parent 83// parent
93swayc_t *destroy_view(swayc_t *view); 84swayc_t *destroy_view(swayc_t *view);
94 85
95// Container Mapping and testing functions 86// Container Lookup
96typedef bool swayc_test_func(swayc_t *view, void *data);
97typedef void swayc_map_func(swayc_t *view, void *data);
98
99// Returns the first swayc that matches test()
100swayc_t *swayc_by_test_r(swayc_t *root, swayc_test_func test, void *data);
101swayc_t *swayc_by_test(swayc_test_func test, void *data);
102
103// Calls func for all children.
104void swayc_map_r(swayc_t *root, swayc_map_func func, void *data);
105void swayc_map(swayc_map_func func, void *data);
106
107
108// Call func on container if test passes
109void swayc_map_by_test_r(swayc_t *root,
110 swayc_map_func func, swayc_test_func test,
111 void *funcdata, void *testdata);
112void swayc_map_by_test(
113 swayc_map_func func, swayc_test_func test,
114 void *funcdata, void *testdata);
115
116// Map functions
117swayc_map_func set_gaps;
118swayc_map_func add_gaps;
119
120// Test functions
121// generic swayc tests
122swayc_test_func test_name;
123swayc_test_func test_name_regex;
124swayc_test_func test_layout;
125swayc_test_func test_type;
126swayc_test_func test_visibility;
127swayc_test_func test_handle;
128
129// C_VIEW tests
130// See wlc_view_*_bit enums
131swayc_test_func test_view_state;
132swayc_test_func test_view_type;
133swayc_test_func test_view_title;
134swayc_test_func test_view_class;
135swayc_test_func test_view_appid;
136swayc_test_func test_view_title_regex;
137swayc_test_func test_view_class_regex;
138swayc_test_func test_view_appid_regex;
139
140// functions for test_*_regex
141void *compile_regex(const char *regex);
142void free_regex(void *);
143
144// these take a NULL terminated array of test_list struct.
145struct test_list { swayc_test_func *test; void *data ; };
146swayc_test_func test_and;
147swayc_test_func test_or;
148 87
88swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
149swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types); 89swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
150swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts); 90swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
151// Follow focused until type/layout 91// Follow focused until type/layout
152swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types); 92swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
153swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts); 93swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
154 94
95
96swayc_t *swayc_by_handle(wlc_handle handle);
97swayc_t *swayc_by_name(const char *name);
155swayc_t *swayc_active_output(void); 98swayc_t *swayc_active_output(void);
156swayc_t *swayc_active_workspace(void); 99swayc_t *swayc_active_workspace(void);
157swayc_t *swayc_active_workspace_for(swayc_t *view); 100swayc_t *swayc_active_workspace_for(swayc_t *view);
158 101
159// Container information 102// Container information
160// if `parent` is the parent of `child` 103
104bool swayc_is_fullscreen(swayc_t *view);
105bool swayc_is_active(swayc_t *view);
106// Is `parent` the parent of `child`
161bool swayc_is_parent_of(swayc_t *parent, swayc_t *child); 107bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
162// If `child` is a child of `parent` 108// Is `child` a child of `parent`
163bool swayc_is_child_of(swayc_t *child, swayc_t *parent); 109bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
164// Return gap of specified container 110// Return gap of specified container
165int swayc_gap(swayc_t *container); 111int swayc_gap(swayc_t *container);
166 112
167bool swayc_is_fullscreen(swayc_t *view); 113// Mapping functions
168bool swayc_is_active(swayc_t *view); 114
115void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
169 116
117// Mappings
118void set_view_visibility(swayc_t *view, void *data);
119// Set or add to gaps
120void set_gaps(swayc_t *view, void *amount);
121void add_gaps(swayc_t *view, void *amount);
170 122
171// Specialized mapping functions
172void update_visibility(swayc_t *container); 123void update_visibility(swayc_t *container);
173 124
174#endif 125#endif