diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 5 | ||||
-rw-r--r-- | include/container.h | 22 | ||||
-rw-r--r-- | include/focus.h | 4 | ||||
-rw-r--r-- | include/input_state.h | 49 | ||||
-rw-r--r-- | include/ipc.h | 18 | ||||
-rw-r--r-- | include/layout.h | 6 | ||||
-rw-r--r-- | include/log.h | 9 | ||||
-rw-r--r-- | include/stringop.h | 5 | ||||
-rw-r--r-- | include/sway.h | 6 | ||||
-rw-r--r-- | include/workspace.h | 1 |
10 files changed, 113 insertions, 12 deletions
diff --git a/include/config.h b/include/config.h index 9243bf35..c23c3509 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -41,9 +41,12 @@ struct sway_config { | |||
41 | bool active; | 41 | bool active; |
42 | bool failed; | 42 | bool failed; |
43 | bool reloading; | 43 | bool reloading; |
44 | |||
45 | int gaps_inner; | ||
46 | int gaps_outer; | ||
44 | }; | 47 | }; |
45 | 48 | ||
46 | bool load_config(void); | 49 | bool load_config(const char *file); |
47 | bool read_config(FILE *file, bool is_active); | 50 | bool read_config(FILE *file, bool is_active); |
48 | char *do_var_replacement(struct sway_config *config, char *str); | 51 | char *do_var_replacement(struct sway_config *config, char *str); |
49 | 52 | ||
diff --git a/include/container.h b/include/container.h index 186ee8b6..79e023fe 100644 --- a/include/container.h +++ b/include/container.h | |||
@@ -11,10 +11,11 @@ enum swayc_types{ | |||
11 | C_WORKSPACE, | 11 | C_WORKSPACE, |
12 | C_CONTAINER, | 12 | C_CONTAINER, |
13 | C_VIEW, | 13 | C_VIEW, |
14 | //Keep last | 14 | // Keep last |
15 | C_TYPES, | 15 | C_TYPES, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | |||
18 | enum swayc_layouts{ | 19 | enum swayc_layouts{ |
19 | L_NONE, | 20 | L_NONE, |
20 | L_HORIZ, | 21 | L_HORIZ, |
@@ -22,7 +23,7 @@ enum swayc_layouts{ | |||
22 | L_STACKED, | 23 | L_STACKED, |
23 | L_TABBED, | 24 | L_TABBED, |
24 | L_FLOATING, | 25 | L_FLOATING, |
25 | //Keep last | 26 | // Keep last |
26 | L_LAYOUTS, | 27 | L_LAYOUTS, |
27 | }; | 28 | }; |
28 | 29 | ||
@@ -44,10 +45,10 @@ struct sway_container { | |||
44 | bool is_floating; | 45 | bool is_floating; |
45 | bool is_focused; | 46 | bool is_focused; |
46 | 47 | ||
47 | int weight; | ||
48 | |||
49 | char *name; | 48 | char *name; |
50 | 49 | ||
50 | int gaps; | ||
51 | |||
51 | list_t *children; | 52 | list_t *children; |
52 | list_t *floating; | 53 | list_t *floating; |
53 | 54 | ||
@@ -55,6 +56,7 @@ struct sway_container { | |||
55 | struct sway_container *focused; | 56 | struct sway_container *focused; |
56 | }; | 57 | }; |
57 | 58 | ||
59 | // Container Creation | ||
58 | 60 | ||
59 | swayc_t *new_output(wlc_handle handle); | 61 | swayc_t *new_output(wlc_handle handle); |
60 | swayc_t *new_workspace(swayc_t *output, const char *name); | 62 | swayc_t *new_workspace(swayc_t *output, const char *name); |
@@ -65,17 +67,29 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle); | |||
65 | // Creates view as a new floating view which is in the active workspace | 67 | // Creates view as a new floating view which is in the active workspace |
66 | swayc_t *new_floating_view(wlc_handle handle); | 68 | swayc_t *new_floating_view(wlc_handle handle); |
67 | 69 | ||
70 | // Container Destroying | ||
68 | 71 | ||
69 | swayc_t *destroy_output(swayc_t *output); | 72 | swayc_t *destroy_output(swayc_t *output); |
70 | // Destroys workspace if empty and returns parent pointer, else returns NULL | 73 | // Destroys workspace if empty and returns parent pointer, else returns NULL |
71 | swayc_t *destroy_workspace(swayc_t *workspace); | 74 | swayc_t *destroy_workspace(swayc_t *workspace); |
75 | // Destroyes container and all parent container if they are empty, returns | ||
76 | // topmost non-empty parent. returns NULL otherwise | ||
72 | swayc_t *destroy_container(swayc_t *container); | 77 | swayc_t *destroy_container(swayc_t *container); |
78 | // Destroys view and all empty parent containers. return topmost non-empty | ||
79 | // parent | ||
73 | swayc_t *destroy_view(swayc_t *view); | 80 | swayc_t *destroy_view(swayc_t *view); |
74 | 81 | ||
82 | // Container Lookup | ||
83 | |||
84 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types); | ||
85 | swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts); | ||
86 | |||
75 | swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); | 87 | swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); |
76 | void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); | 88 | void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); |
77 | 89 | ||
90 | |||
78 | // Mappings | 91 | // Mappings |
79 | void set_view_visibility(swayc_t *view, void *data); | 92 | void set_view_visibility(swayc_t *view, void *data); |
93 | void reset_gaps(swayc_t *view, void *data); | ||
80 | 94 | ||
81 | #endif | 95 | #endif |
diff --git a/include/focus.h b/include/focus.h index 410ed134..383993fa 100644 --- a/include/focus.h +++ b/include/focus.h | |||
@@ -1,7 +1,5 @@ | |||
1 | #ifndef _SWAY_FOCUS_H | 1 | #ifndef _SWAY_FOCUS_H |
2 | #define _SWAY_FOCUS_H | 2 | #define _SWAY_FOCUS_H |
3 | #include "container.h" | ||
4 | |||
5 | enum movement_direction { | 3 | enum movement_direction { |
6 | MOVE_LEFT, | 4 | MOVE_LEFT, |
7 | MOVE_RIGHT, | 5 | MOVE_RIGHT, |
@@ -10,6 +8,8 @@ enum movement_direction { | |||
10 | MOVE_PARENT | 8 | MOVE_PARENT |
11 | }; | 9 | }; |
12 | 10 | ||
11 | #include "container.h" | ||
12 | |||
13 | // focused_container - the container found by following the `focused` pointer | 13 | // focused_container - the container found by following the `focused` pointer |
14 | // from a given container to a container with `is_focused` boolean set | 14 | // from a given container to a container with `is_focused` boolean set |
15 | // --- | 15 | // --- |
diff --git a/include/input_state.h b/include/input_state.h new file mode 100644 index 00000000..782b4b19 --- /dev/null +++ b/include/input_state.h | |||
@@ -0,0 +1,49 @@ | |||
1 | #ifndef _SWAY_KEY_STATE_H | ||
2 | #define _SWAY_KEY_STATE_H | ||
3 | #include <stdbool.h> | ||
4 | #include <stdint.h> | ||
5 | #include "container.h" | ||
6 | |||
7 | /* Keyboard state */ | ||
8 | |||
9 | typedef uint32_t keycode; | ||
10 | |||
11 | // returns true if key has been pressed, otherwise false | ||
12 | bool check_key(keycode key); | ||
13 | |||
14 | // sets a key as pressed | ||
15 | void press_key(keycode key); | ||
16 | |||
17 | // unsets a key as pressed | ||
18 | void release_key(keycode key); | ||
19 | |||
20 | /* Pointer state */ | ||
21 | |||
22 | enum pointer_values { | ||
23 | M_LEFT_CLICK = 272, | ||
24 | M_RIGHT_CLICK = 273, | ||
25 | M_SCROLL_CLICK = 274, | ||
26 | M_SCROLL_UP = 275, | ||
27 | M_SCROLL_DOWN = 276, | ||
28 | }; | ||
29 | |||
30 | extern struct pointer_state { | ||
31 | bool l_held; | ||
32 | bool r_held; | ||
33 | struct pointer_floating { | ||
34 | bool drag; | ||
35 | bool resize; | ||
36 | } floating; | ||
37 | struct pointer_lock { | ||
38 | bool left; | ||
39 | bool right; | ||
40 | bool top; | ||
41 | bool bottom; | ||
42 | } lock; | ||
43 | } pointer_state; | ||
44 | |||
45 | void start_floating(swayc_t *view); | ||
46 | void reset_floating(swayc_t *view); | ||
47 | |||
48 | #endif | ||
49 | |||
diff --git a/include/ipc.h b/include/ipc.h new file mode 100644 index 00000000..0b6441f6 --- /dev/null +++ b/include/ipc.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _SWAY_IPC_H | ||
2 | #define _SWAY_IPC_H | ||
3 | |||
4 | enum ipc_command_type { | ||
5 | IPC_COMMAND = 0, | ||
6 | IPC_GET_WORKSPACES = 1, | ||
7 | IPC_SUBSCRIBE = 2, | ||
8 | IPC_GET_OUTPUTS = 3, | ||
9 | IPC_GET_TREE = 4, | ||
10 | IPC_GET_MARKS = 5, | ||
11 | IPC_GET_BAR_CONFIG = 6, | ||
12 | IPC_GET_VERSION = 7, | ||
13 | }; | ||
14 | |||
15 | void ipc_init(void); | ||
16 | void ipc_terminate(void); | ||
17 | |||
18 | #endif | ||
diff --git a/include/layout.h b/include/layout.h index 282f92ee..c1d7d8b4 100644 --- a/include/layout.h +++ b/include/layout.h | |||
@@ -4,17 +4,22 @@ | |||
4 | #include <wlc/wlc.h> | 4 | #include <wlc/wlc.h> |
5 | #include "list.h" | 5 | #include "list.h" |
6 | #include "container.h" | 6 | #include "container.h" |
7 | #include "focus.h" | ||
7 | 8 | ||
8 | extern swayc_t root_container; | 9 | extern swayc_t root_container; |
9 | 10 | ||
10 | void init_layout(void); | 11 | void init_layout(void); |
11 | 12 | ||
12 | void add_child(swayc_t *parent, swayc_t *child); | 13 | void add_child(swayc_t *parent, swayc_t *child); |
14 | void add_floating(swayc_t *ws, swayc_t *child); | ||
13 | // Returns parent container which needs to be rearranged. | 15 | // Returns parent container which needs to be rearranged. |
14 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); | 16 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); |
15 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child); | 17 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child); |
16 | swayc_t *remove_child(swayc_t *child); | 18 | swayc_t *remove_child(swayc_t *child); |
17 | 19 | ||
20 | void move_container(swayc_t* container,swayc_t* root,int direction); | ||
21 | |||
22 | |||
18 | // Layout | 23 | // Layout |
19 | void arrange_windows(swayc_t *container, int width, int height); | 24 | void arrange_windows(swayc_t *container, int width, int height); |
20 | 25 | ||
@@ -25,5 +30,6 @@ void focus_view_for(swayc_t *ancestor, swayc_t *container); | |||
25 | 30 | ||
26 | swayc_t *get_focused_container(swayc_t *parent); | 31 | swayc_t *get_focused_container(swayc_t *parent); |
27 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); | 32 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); |
33 | swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir); | ||
28 | 34 | ||
29 | #endif | 35 | #endif |
diff --git a/include/log.h b/include/log.h index d35b2a54..47a83321 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -1,5 +1,7 @@ | |||
1 | #ifndef _SWAY_LOG_H | 1 | #ifndef _SWAY_LOG_H |
2 | #define _SWAY_LOG_H | 2 | #define _SWAY_LOG_H |
3 | #include <stdbool.h> | ||
4 | #include "container.h" | ||
3 | 5 | ||
4 | typedef enum { | 6 | typedef enum { |
5 | L_SILENT = 0, | 7 | L_SILENT = 0, |
@@ -10,7 +12,10 @@ typedef enum { | |||
10 | 12 | ||
11 | void init_log(int verbosity); | 13 | void init_log(int verbosity); |
12 | void sway_log_colors(int mode); | 14 | void sway_log_colors(int mode); |
13 | void sway_log(int verbosity, char* format, ...) __attribute__((format(printf,2,3))); | 15 | void sway_log(int verbosity, const char* format, ...) __attribute__((format(printf,2,3))); |
14 | void sway_abort(char* format, ...)__attribute__((format(printf,1,2))); | 16 | void sway_log_errno(int verbosity, char* format, ...) __attribute__((format(printf,2,3))); |
17 | void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); | ||
18 | bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3))); | ||
15 | 19 | ||
20 | void layout_log(const swayc_t *c, int depth); | ||
16 | #endif | 21 | #endif |
diff --git a/include/stringop.h b/include/stringop.h index 03387345..4300f9ed 100644 --- a/include/stringop.h +++ b/include/stringop.h | |||
@@ -2,13 +2,14 @@ | |||
2 | #define _SWAY_STRINGOP_H | 2 | #define _SWAY_STRINGOP_H |
3 | #include "list.h" | 3 | #include "list.h" |
4 | 4 | ||
5 | void strip_whitespace(char *str); | 5 | char *strip_whitespace(char *str, int *trimmed_start); |
6 | void strip_comments(char *str); | 6 | char *strip_comments(char *str); |
7 | list_t *split_string(const char *str, const char *delims); | 7 | list_t *split_string(const char *str, const char *delims); |
8 | void free_flat_list(list_t *list); | 8 | void free_flat_list(list_t *list); |
9 | char *code_strchr(const char *string, char delimiter); | 9 | char *code_strchr(const char *string, char delimiter); |
10 | char *code_strstr(const char *haystack, const char *needle); | 10 | char *code_strstr(const char *haystack, const char *needle); |
11 | int unescape_string(char *string); | 11 | int unescape_string(char *string); |
12 | char *join_args(char **argv, int argc); | 12 | char *join_args(char **argv, int argc); |
13 | char *join_list(list_t *list, char *separator); | ||
13 | 14 | ||
14 | #endif | 15 | #endif |
diff --git a/include/sway.h b/include/sway.h new file mode 100644 index 00000000..6499c81d --- /dev/null +++ b/include/sway.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _SWAY_SWAY_H | ||
2 | #define _SWAY_SWAY_H | ||
3 | |||
4 | void sway_terminate(void); | ||
5 | |||
6 | #endif | ||
diff --git a/include/workspace.h b/include/workspace.h index 8ce39bbd..042a15d9 100644 --- a/include/workspace.h +++ b/include/workspace.h | |||
@@ -15,6 +15,5 @@ void workspace_output_next(); | |||
15 | void workspace_next(); | 15 | void workspace_next(); |
16 | void workspace_output_prev(); | 16 | void workspace_output_prev(); |
17 | void workspace_prev(); | 17 | void workspace_prev(); |
18 | void layout_log(const swayc_t *c, int depth); | ||
19 | 18 | ||
20 | #endif | 19 | #endif |