summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-09-12 02:38:03 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-09-12 02:38:03 -0700
commite1d18e42a8f3a597b9bf5f1bb2ab6c346e4e7983 (patch)
tree8a8ac30c539f4a63bb249b8c5e27e724a4241c9f /include
parentMerge pull request #177 from taiyu-len/master (diff)
downloadsway-e1d18e42a8f3a597b9bf5f1bb2ab6c346e4e7983.tar.gz
sway-e1d18e42a8f3a597b9bf5f1bb2ab6c346e4e7983.tar.zst
sway-e1d18e42a8f3a597b9bf5f1bb2ab6c346e4e7983.zip
new_workspace null behavior + testmap functions + regex
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, 118 insertions, 59 deletions
diff --git a/include/commands.h b/include/commands.h
index 5c87be51..69ab1380 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -3,19 +3,21 @@
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
6struct cmd_handler { 12struct cmd_handler {
7 char *command; 13 const char*command;
8 enum cmd_status { 14 sway_cmd *handle;
9 CMD_SUCCESS,
10 CMD_FAILURE,
11 CMD_DEFER,
12 } (*handle)(int argc, char **argv);
13}; 15};
14 16
15enum cmd_status handle_command(char *command); 17enum cmd_status handle_command(char *command);
16// Handles commands during config 18// Handles commands during config
17enum cmd_status config_command(char *command); 19enum cmd_status config_command(char *command);
18 20
19void remove_view_from_scratchpad(); 21void remove_view_from_scratchpad(swayc_t *view);
20 22
21#endif 23#endif
diff --git a/include/config.h b/include/config.h
index 676218c8..04db3e5c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -63,6 +63,10 @@ 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
66extern struct sway_config *config; 70extern struct sway_config *config;
67 71
68#endif 72#endif
diff --git a/include/container.h b/include/container.h
index a9b95229..d8590149 100644
--- a/include/container.h
+++ b/include/container.h
@@ -2,29 +2,25 @@
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
6#include "layout.h" 5#include "layout.h"
7 6
8enum swayc_types{ 7enum swayc_types {
9 C_ROOT, 8 C_ROOT = 1 << 0,
10 C_OUTPUT, 9 C_OUTPUT = 1 << 1,
11 C_WORKSPACE, 10 C_WORKSPACE = 1 << 2,
12 C_CONTAINER, 11 C_CONTAINER = 1 << 3,
13 C_VIEW, 12 C_VIEW = 1 << 4,
14 // Keep last 13 C_TYPES = 5,
15 C_TYPES,
16}; 14};
17 15
18 16enum swayc_layouts {
19enum swayc_layouts{ 17 L_NONE = 1 << 0,
20 L_NONE, 18 L_HORIZ = 1 << 1,
21 L_HORIZ, 19 L_VERT = 1 << 2,
22 L_VERT, 20 L_STACKED = 1 << 3,
23 L_STACKED, 21 L_TABBED = 1 << 4,
24 L_TABBED, 22 L_FLOATING = 1 << 5,
25 L_FLOATING, 23 L_LAYOUTS = 6,
26 // Keep last
27 L_LAYOUTS,
28}; 24};
29 25
30struct sway_container { 26struct sway_container {
@@ -35,13 +31,16 @@ struct sway_container {
35 31
36 // Not including borders or margins 32 // Not including borders or margins
37 double width, height; 33 double width, height;
34 double x, y;
38 35
39 // Used for setting floating geometry 36 // Used for setting floating geometry
40 int desired_width, desired_height; 37 int desired_width, desired_height;
41 38
42 double x, y; 39 enum visibility_mask {
40 INVISIBLE = 0,
41 VISIBLE = 1,
42 } visible;
43 43
44 bool visible;
45 bool is_floating; 44 bool is_floating;
46 bool is_focused; 45 bool is_focused;
47 46
@@ -56,70 +55,120 @@ struct sway_container {
56 struct sway_container *focused; 55 struct sway_container *focused;
57}; 56};
58 57
59enum visibility_mask { 58// swayc Creation
60 VISIBLE = 1
61};
62
63// Container Creation
64 59
60/* Creates and returns new, or an already created output.
61 * If it creates a new output, it also creates a workspace using
62 * `new_workspace(outputname, NULL);` */
65swayc_t *new_output(wlc_handle handle); 63swayc_t *new_output(wlc_handle handle);
64
65/* Creates workspace with given name, under given output.
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. */
66swayc_t *new_workspace(swayc_t *output, const char *name); 69swayc_t *new_workspace(swayc_t *output, const char *name);
70
67// Creates container Around child (parent child) -> (parent (container child)) 71// Creates container Around child (parent child) -> (parent (container child))
68swayc_t *new_container(swayc_t *child, enum swayc_layouts layout); 72swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
73
69// Creates view as a sibling of current focused container, or as child of a workspace 74// Creates view as a sibling of current focused container, or as child of a workspace
70swayc_t *new_view(swayc_t *sibling, wlc_handle handle); 75swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
76
71// Creates view as a new floating view which is in the active workspace 77// Creates view as a new floating view which is in the active workspace
72swayc_t *new_floating_view(wlc_handle handle); 78swayc_t *new_floating_view(wlc_handle handle);
73 79
74// Container Destroying 80// Container Destroying
75 81// Destroys output and moves workspaces to another output
76swayc_t *destroy_output(swayc_t *output); 82swayc_t *destroy_output(swayc_t *output);
83
77// Destroys workspace if empty and returns parent pointer, else returns NULL 84// Destroys workspace if empty and returns parent pointer, else returns NULL
78swayc_t *destroy_workspace(swayc_t *workspace); 85swayc_t *destroy_workspace(swayc_t *workspace);
86
79// Destroyes container and all parent container if they are empty, returns 87// Destroyes container and all parent container if they are empty, returns
80// topmost non-empty parent. returns NULL otherwise 88// topmost non-empty parent. returns NULL otherwise
81swayc_t *destroy_container(swayc_t *container); 89swayc_t *destroy_container(swayc_t *container);
90
82// Destroys view and all empty parent containers. return topmost non-empty 91// Destroys view and all empty parent containers. return topmost non-empty
83// parent 92// parent
84swayc_t *destroy_view(swayc_t *view); 93swayc_t *destroy_view(swayc_t *view);
85 94
86// Container Lookup 95// Container Mapping and testing functions
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;
87 148
88swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
89swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types); 149swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
90swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts); 150swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
91// Follow focused until type/layout 151// Follow focused until type/layout
92swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types); 152swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
93swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts); 153swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
94 154
95
96swayc_t *swayc_by_handle(wlc_handle handle);
97swayc_t *swayc_by_name(const char *name);
98swayc_t *swayc_active_output(void); 155swayc_t *swayc_active_output(void);
99swayc_t *swayc_active_workspace(void); 156swayc_t *swayc_active_workspace(void);
100swayc_t *swayc_active_workspace_for(swayc_t *view); 157swayc_t *swayc_active_workspace_for(swayc_t *view);
101 158
102// Container information 159// Container information
103 160// if `parent` is the parent of `child`
104bool swayc_is_fullscreen(swayc_t *view);
105bool swayc_is_active(swayc_t *view);
106// Is `parent` the parent of `child`
107bool swayc_is_parent_of(swayc_t *parent, swayc_t *child); 161bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
108// Is `child` a child of `parent` 162// If `child` is a child of `parent`
109bool swayc_is_child_of(swayc_t *child, swayc_t *parent); 163bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
110// Return gap of specified container 164// Return gap of specified container
111int swayc_gap(swayc_t *container); 165int swayc_gap(swayc_t *container);
112 166
113// Mapping functions 167bool swayc_is_fullscreen(swayc_t *view);
114 168bool swayc_is_active(swayc_t *view);
115void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
116 169
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);
122 170
171// Specialized mapping functions
123void update_visibility(swayc_t *container); 172void update_visibility(swayc_t *container);
124 173
125#endif 174#endif
diff --git a/include/stringop.h b/include/stringop.h
index dde50f13..6e80e729 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(char **argv, int argc); 22char *join_args(int argc, char **argv);
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 7343b055..3a63ea38 100644
--- a/include/workspace.h
+++ b/include/workspace.h
@@ -7,13 +7,17 @@
7 7
8extern char *prev_workspace_name; 8extern char *prev_workspace_name;
9 9
10char *workspace_next_name(void); 10// Search for available workspace name on output from config
11swayc_t *workspace_create(const char*); 11const char *workspace_output_open_name(swayc_t *output);
12// Search for any available workspace name
13const char *workspace_next_name(void);
14
15
12swayc_t *workspace_by_name(const char*); 16swayc_t *workspace_by_name(const char*);
13void workspace_switch(swayc_t*); 17void workspace_switch(swayc_t*);
14swayc_t *workspace_output_next(); 18swayc_t *workspace_output_next(void);
15swayc_t *workspace_next(); 19swayc_t *workspace_next(void);
16swayc_t *workspace_output_prev(); 20swayc_t *workspace_output_prev(void);
17swayc_t *workspace_prev(); 21swayc_t *workspace_prev(void);
18 22
19#endif 23#endif