aboutsummaryrefslogtreecommitdiffstats
path: root/include
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
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')
-rw-r--r--include/commands.h16
-rw-r--r--include/config.h4
-rw-r--r--include/container.h139
-rw-r--r--include/stringop.h2
-rw-r--r--include/workspace.h16
5 files changed, 59 insertions, 118 deletions
diff --git a/include/commands.h b/include/commands.h
index 69ab1380..5c87be51 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -3,21 +3,19 @@
3#include <stdbool.h> 3#include <stdbool.h>
4#include "config.h" 4#include "config.h"
5 5
6typedef enum cmd_status {
7 CMD_SUCCESS,
8 CMD_FAILURE,
9 CMD_DEFER,
10} sway_cmd(char *criteria, int argc, char **argv);
11
12struct cmd_handler { 6struct cmd_handler {
13 const char*command; 7 char *command;
14 sway_cmd *handle; 8 enum cmd_status {
9 CMD_SUCCESS,
10 CMD_FAILURE,
11 CMD_DEFER,
12 } (*handle)(int argc, char **argv);
15}; 13};
16 14
17enum cmd_status handle_command(char *command); 15enum cmd_status handle_command(char *command);
18// Handles commands during config 16// Handles commands during config
19enum cmd_status config_command(char *command); 17enum cmd_status config_command(char *command);
20 18
21void remove_view_from_scratchpad(swayc_t *view); 19void remove_view_from_scratchpad();
22 20
23#endif 21#endif
diff --git a/include/config.h b/include/config.h
index 04db3e5c..676218c8 100644
--- a/include/config.h
+++ b/include/config.h
@@ -63,10 +63,6 @@ bool load_config(const char *file);
63bool read_config(FILE *file, bool is_active); 63bool read_config(FILE *file, bool is_active);
64char *do_var_replacement(char *str); 64char *do_var_replacement(char *str);
65 65
66// Find workspace_output from config by workspace or output name
67struct workspace_output *wsop_find_workspace(const char *);
68struct workspace_output *wsop_find_output(const char *);
69
70extern struct sway_config *config; 66extern struct sway_config *config;
71 67
72#endif 68#endif
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
diff --git a/include/stringop.h b/include/stringop.h
index 6e80e729..dde50f13 100644
--- a/include/stringop.h
+++ b/include/stringop.h
@@ -19,7 +19,7 @@ void free_argv(int argc, char **argv);
19char *code_strchr(const char *string, char delimiter); 19char *code_strchr(const char *string, char delimiter);
20char *code_strstr(const char *haystack, const char *needle); 20char *code_strstr(const char *haystack, const char *needle);
21int unescape_string(char *string); 21int unescape_string(char *string);
22char *join_args(int argc, char **argv); 22char *join_args(char **argv, int argc);
23char *join_list(list_t *list, char *separator); 23char *join_list(list_t *list, char *separator);
24 24
25char *strdup(const char *); 25char *strdup(const char *);
diff --git a/include/workspace.h b/include/workspace.h
index 3a63ea38..7343b055 100644
--- a/include/workspace.h
+++ b/include/workspace.h
@@ -7,17 +7,13 @@
7 7
8extern char *prev_workspace_name; 8extern char *prev_workspace_name;
9 9
10// Search for available workspace name on output from config 10char *workspace_next_name(void);
11const char *workspace_output_open_name(swayc_t *output); 11swayc_t *workspace_create(const char*);
12// Search for any available workspace name
13const char *workspace_next_name(void);
14
15
16swayc_t *workspace_by_name(const char*); 12swayc_t *workspace_by_name(const char*);
17void workspace_switch(swayc_t*); 13void workspace_switch(swayc_t*);
18swayc_t *workspace_output_next(void); 14swayc_t *workspace_output_next();
19swayc_t *workspace_next(void); 15swayc_t *workspace_next();
20swayc_t *workspace_output_prev(void); 16swayc_t *workspace_output_prev();
21swayc_t *workspace_prev(void); 17swayc_t *workspace_prev();
22 18
23#endif 19#endif