diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-16 11:02:56 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-16 11:02:56 -0400 |
commit | 7f8ebb7d0dcb687574554b877a0e84f48718df37 (patch) | |
tree | 9a58f9276059d3c88cb3a92d8229a911b33b0faf /include | |
parent | Add split [h|v|horizontal|vertical] command (diff) | |
download | sway-7f8ebb7d0dcb687574554b877a0e84f48718df37.tar.gz sway-7f8ebb7d0dcb687574554b877a0e84f48718df37.tar.zst sway-7f8ebb7d0dcb687574554b877a0e84f48718df37.zip |
Move headers to include/
Diffstat (limited to 'include')
-rw-r--r-- | include/commands.h | 13 | ||||
-rw-r--r-- | include/config.h | 44 | ||||
-rw-r--r-- | include/container.h | 71 | ||||
-rw-r--r-- | include/handlers.h | 12 | ||||
-rw-r--r-- | include/layout.h | 25 | ||||
-rw-r--r-- | include/list.h | 17 | ||||
-rw-r--r-- | include/log.h | 16 | ||||
-rw-r--r-- | include/movement.h | 17 | ||||
-rw-r--r-- | include/readline.h | 8 | ||||
-rw-r--r-- | include/stringop.h | 14 | ||||
-rw-r--r-- | include/workspace.h | 16 |
11 files changed, 253 insertions, 0 deletions
diff --git a/include/commands.h b/include/commands.h new file mode 100644 index 00000000..c2046e13 --- /dev/null +++ b/include/commands.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _SWAY_COMMANDS_H | ||
2 | #define _SWAY_COMMANDS_H | ||
3 | #include <stdbool.h> | ||
4 | #include "config.h" | ||
5 | |||
6 | struct cmd_handler { | ||
7 | char *command; | ||
8 | bool (*handle)(struct sway_config *config, int argc, char **argv); | ||
9 | }; | ||
10 | |||
11 | bool handle_command(struct sway_config *config, char *command); | ||
12 | |||
13 | #endif | ||
diff --git a/include/config.h b/include/config.h new file mode 100644 index 00000000..c9fd374c --- /dev/null +++ b/include/config.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef _SWAY_CONFIG_H | ||
2 | #define _SWAY_CONFIG_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | #include <wlc/wlc.h> | ||
6 | #include "list.h" | ||
7 | |||
8 | struct sway_variable { | ||
9 | char *name; | ||
10 | char *value; | ||
11 | }; | ||
12 | |||
13 | struct sway_binding { | ||
14 | list_t *keys; | ||
15 | uint32_t modifiers; | ||
16 | char *command; | ||
17 | }; | ||
18 | |||
19 | struct sway_mode { | ||
20 | char *name; | ||
21 | list_t *bindings; | ||
22 | }; | ||
23 | |||
24 | struct sway_config { | ||
25 | list_t *symbols; | ||
26 | list_t *modes; | ||
27 | list_t *cmd_queue; | ||
28 | struct sway_mode *current_mode; | ||
29 | |||
30 | // Flags | ||
31 | bool focus_follows_mouse; | ||
32 | bool mouse_warping; | ||
33 | bool active; | ||
34 | bool failed; | ||
35 | bool reloading; | ||
36 | }; | ||
37 | |||
38 | bool load_config(); | ||
39 | bool read_config(FILE *file, bool is_active); | ||
40 | char *do_var_replacement(struct sway_config *config, char *str); | ||
41 | |||
42 | extern struct sway_config *config; | ||
43 | |||
44 | #endif | ||
diff --git a/include/container.h b/include/container.h new file mode 100644 index 00000000..a54e016a --- /dev/null +++ b/include/container.h | |||
@@ -0,0 +1,71 @@ | |||
1 | #ifndef _SWAY_CONTAINER_H | ||
2 | #define _SWAY_CONTAINER_H | ||
3 | #include <wlc/wlc.h> | ||
4 | typedef struct sway_container swayc_t; | ||
5 | |||
6 | #include "layout.h" | ||
7 | |||
8 | enum swayc_types{ | ||
9 | C_ROOT, | ||
10 | C_OUTPUT, | ||
11 | C_WORKSPACE, | ||
12 | C_CONTAINER, | ||
13 | C_VIEW, | ||
14 | //Keep last | ||
15 | C_TYPES, | ||
16 | }; | ||
17 | |||
18 | enum swayc_layouts{ | ||
19 | L_NONE, | ||
20 | L_HORIZ, | ||
21 | L_VERT, | ||
22 | L_STACKED, | ||
23 | L_TABBED, | ||
24 | L_FLOATING, | ||
25 | //Keep last | ||
26 | L_LAYOUTS, | ||
27 | }; | ||
28 | |||
29 | struct sway_container { | ||
30 | wlc_handle handle; | ||
31 | |||
32 | enum swayc_types type; | ||
33 | |||
34 | enum swayc_layouts layout; | ||
35 | |||
36 | // Not including borders or margins | ||
37 | int width, height; | ||
38 | |||
39 | int x, y; | ||
40 | |||
41 | bool visible; | ||
42 | |||
43 | int weight; | ||
44 | |||
45 | char *name; | ||
46 | |||
47 | list_t *children; | ||
48 | |||
49 | struct sway_container *parent; | ||
50 | struct sway_container *focused; | ||
51 | }; | ||
52 | |||
53 | |||
54 | swayc_t *new_output(wlc_handle handle); | ||
55 | swayc_t *new_workspace(swayc_t * output, const char *name); | ||
56 | //Creates container Around child (parent child) -> (parent (container child)) | ||
57 | swayc_t *new_container(swayc_t *child, enum swayc_layouts layout); | ||
58 | //Creates view as a sibling of current focused container, or as child of a workspace | ||
59 | swayc_t *new_view(swayc_t *sibling, wlc_handle handle); | ||
60 | |||
61 | |||
62 | swayc_t *destroy_output(swayc_t *output); | ||
63 | //destroys workspace if empty and returns parent pointer, else returns NULL | ||
64 | swayc_t *destroy_workspace(swayc_t *workspace); | ||
65 | swayc_t *destroy_container(swayc_t *container); | ||
66 | swayc_t *destroy_view(swayc_t *view); | ||
67 | |||
68 | swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); | ||
69 | void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); | ||
70 | |||
71 | #endif | ||
diff --git a/include/handlers.h b/include/handlers.h new file mode 100644 index 00000000..d1742cce --- /dev/null +++ b/include/handlers.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _SWAY_HANDLERS_H | ||
2 | #define _SWAY_HANDLERS_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | #include <wlc/wlc.h> | ||
6 | |||
7 | extern struct wlc_interface interface; | ||
8 | |||
9 | //set focus to current pointer location and return focused container | ||
10 | swayc_t *focus_pointer(void); | ||
11 | |||
12 | #endif | ||
diff --git a/include/layout.h b/include/layout.h new file mode 100644 index 00000000..a136f917 --- /dev/null +++ b/include/layout.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _SWAY_LAYOUT_H | ||
2 | #define _SWAY_LAYOUT_H | ||
3 | |||
4 | #include <wlc/wlc.h> | ||
5 | #include "list.h" | ||
6 | #include "container.h" | ||
7 | |||
8 | extern swayc_t root_container; | ||
9 | |||
10 | void init_layout(void); | ||
11 | |||
12 | void add_child(swayc_t *parent, swayc_t *child); | ||
13 | //Returns parent container wihch needs to be rearranged. | ||
14 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); | ||
15 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child); | ||
16 | swayc_t *remove_child(swayc_t *parent, swayc_t *child); | ||
17 | |||
18 | void unfocus_all(swayc_t *container); | ||
19 | void focus_view(swayc_t *view); | ||
20 | void arrange_windows(swayc_t *container, int width, int height); | ||
21 | swayc_t *get_focused_container(swayc_t *parent); | ||
22 | |||
23 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); | ||
24 | |||
25 | #endif | ||
diff --git a/include/list.h b/include/list.h new file mode 100644 index 00000000..29b988aa --- /dev/null +++ b/include/list.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _SWAY_LIST_H | ||
2 | #define _SWAY_LIST_H | ||
3 | |||
4 | typedef struct { | ||
5 | int capacity; | ||
6 | int length; | ||
7 | void **items; | ||
8 | } list_t; | ||
9 | |||
10 | list_t *create_list(void); | ||
11 | void list_free(list_t *list); | ||
12 | void list_add(list_t *list, void *item); | ||
13 | void list_insert(list_t *list, int index, void *item); | ||
14 | void list_del(list_t *list, int index); | ||
15 | void list_cat(list_t *list, list_t *source); | ||
16 | |||
17 | #endif | ||
diff --git a/include/log.h b/include/log.h new file mode 100644 index 00000000..e5075a39 --- /dev/null +++ b/include/log.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _SWAY_LOG_H | ||
2 | #define _SWAY_LOG_H | ||
3 | |||
4 | typedef enum { | ||
5 | L_SILENT = 0, | ||
6 | L_ERROR = 1, | ||
7 | L_INFO = 2, | ||
8 | L_DEBUG = 3, | ||
9 | } log_importance_t; | ||
10 | |||
11 | void init_log(int verbosity); | ||
12 | void sway_log_colors(int mode); | ||
13 | void sway_log(int verbosity, char* format, ...); | ||
14 | void sway_abort(char* format, ...); | ||
15 | |||
16 | #endif | ||
diff --git a/include/movement.h b/include/movement.h new file mode 100644 index 00000000..dd701877 --- /dev/null +++ b/include/movement.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _SWAY_MOVEMENT_H | ||
2 | #define _SWAY_MOVEMENT_H | ||
3 | |||
4 | #include <wlc/wlc.h> | ||
5 | #include "list.h" | ||
6 | |||
7 | enum movement_direction { | ||
8 | MOVE_LEFT, | ||
9 | MOVE_RIGHT, | ||
10 | MOVE_UP, | ||
11 | MOVE_DOWN, | ||
12 | MOVE_PARENT | ||
13 | }; | ||
14 | |||
15 | bool move_focus(enum movement_direction direction); | ||
16 | |||
17 | #endif | ||
diff --git a/include/readline.h b/include/readline.h new file mode 100644 index 00000000..dbe937c1 --- /dev/null +++ b/include/readline.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _SWAY_READLINE_H | ||
2 | #define _SWAY_READLINE_H | ||
3 | |||
4 | #include <stdio.h> | ||
5 | |||
6 | char *read_line(FILE *file); | ||
7 | |||
8 | #endif | ||
diff --git a/include/stringop.h b/include/stringop.h new file mode 100644 index 00000000..a5346829 --- /dev/null +++ b/include/stringop.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _SWAY_STRINGOP_H | ||
2 | #define _SWAY_STRINGOP_H | ||
3 | #include "list.h" | ||
4 | |||
5 | char *strip_whitespace(char *str, int *trimmed_start); | ||
6 | char *strip_comments(char *str); | ||
7 | list_t *split_string(const char *str, const char *delims); | ||
8 | void free_flat_list(list_t *list); | ||
9 | char *code_strchr(const char *string, char delimiter); | ||
10 | char *code_strstr(const char *haystack, const char *needle); | ||
11 | int unescape_string(char *string); | ||
12 | char *join_args(char **argv, int argc); | ||
13 | |||
14 | #endif | ||
diff --git a/include/workspace.h b/include/workspace.h new file mode 100644 index 00000000..59a6d526 --- /dev/null +++ b/include/workspace.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _SWAY_WORKSPACE_H | ||
2 | #define _SWAY_WORKSPACE_H | ||
3 | |||
4 | #include <wlc/wlc.h> | ||
5 | #include "list.h" | ||
6 | #include "layout.h" | ||
7 | |||
8 | extern swayc_t *active_workspace; | ||
9 | |||
10 | char *workspace_next_name(void); | ||
11 | swayc_t *workspace_create(const char*); | ||
12 | swayc_t *workspace_find_by_name(const char*); | ||
13 | void workspace_switch(swayc_t*); | ||
14 | void layout_log(const swayc_t *c, int depth); | ||
15 | |||
16 | #endif | ||