aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-16 11:02:56 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-16 11:02:56 -0400
commit7f8ebb7d0dcb687574554b877a0e84f48718df37 (patch)
tree9a58f9276059d3c88cb3a92d8229a911b33b0faf /include
parentAdd split [h|v|horizontal|vertical] command (diff)
downloadsway-7f8ebb7d0dcb687574554b877a0e84f48718df37.tar.gz
sway-7f8ebb7d0dcb687574554b877a0e84f48718df37.tar.zst
sway-7f8ebb7d0dcb687574554b877a0e84f48718df37.zip
Move headers to include/
Diffstat (limited to 'include')
-rw-r--r--include/commands.h13
-rw-r--r--include/config.h44
-rw-r--r--include/container.h71
-rw-r--r--include/handlers.h12
-rw-r--r--include/layout.h25
-rw-r--r--include/list.h17
-rw-r--r--include/log.h16
-rw-r--r--include/movement.h17
-rw-r--r--include/readline.h8
-rw-r--r--include/stringop.h14
-rw-r--r--include/workspace.h16
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
6struct cmd_handler {
7 char *command;
8 bool (*handle)(struct sway_config *config, int argc, char **argv);
9};
10
11bool 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
8struct sway_variable {
9 char *name;
10 char *value;
11};
12
13struct sway_binding {
14 list_t *keys;
15 uint32_t modifiers;
16 char *command;
17};
18
19struct sway_mode {
20 char *name;
21 list_t *bindings;
22};
23
24struct 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
38bool load_config();
39bool read_config(FILE *file, bool is_active);
40char *do_var_replacement(struct sway_config *config, char *str);
41
42extern 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>
4typedef struct sway_container swayc_t;
5
6#include "layout.h"
7
8enum 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
18enum 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
29struct 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
54swayc_t *new_output(wlc_handle handle);
55swayc_t *new_workspace(swayc_t * output, const char *name);
56//Creates container Around child (parent child) -> (parent (container child))
57swayc_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
59swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
60
61
62swayc_t *destroy_output(swayc_t *output);
63//destroys workspace if empty and returns parent pointer, else returns NULL
64swayc_t *destroy_workspace(swayc_t *workspace);
65swayc_t *destroy_container(swayc_t *container);
66swayc_t *destroy_view(swayc_t *view);
67
68swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
69void 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
7extern struct wlc_interface interface;
8
9//set focus to current pointer location and return focused container
10swayc_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
8extern swayc_t root_container;
9
10void init_layout(void);
11
12void add_child(swayc_t *parent, swayc_t *child);
13//Returns parent container wihch needs to be rearranged.
14swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
15swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
16swayc_t *remove_child(swayc_t *parent, swayc_t *child);
17
18void unfocus_all(swayc_t *container);
19void focus_view(swayc_t *view);
20void arrange_windows(swayc_t *container, int width, int height);
21swayc_t *get_focused_container(swayc_t *parent);
22
23swayc_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
4typedef struct {
5 int capacity;
6 int length;
7 void **items;
8} list_t;
9
10list_t *create_list(void);
11void list_free(list_t *list);
12void list_add(list_t *list, void *item);
13void list_insert(list_t *list, int index, void *item);
14void list_del(list_t *list, int index);
15void 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
4typedef enum {
5 L_SILENT = 0,
6 L_ERROR = 1,
7 L_INFO = 2,
8 L_DEBUG = 3,
9} log_importance_t;
10
11void init_log(int verbosity);
12void sway_log_colors(int mode);
13void sway_log(int verbosity, char* format, ...);
14void 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
7enum movement_direction {
8 MOVE_LEFT,
9 MOVE_RIGHT,
10 MOVE_UP,
11 MOVE_DOWN,
12 MOVE_PARENT
13};
14
15bool 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
6char *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
5char *strip_whitespace(char *str, int *trimmed_start);
6char *strip_comments(char *str);
7list_t *split_string(const char *str, const char *delims);
8void free_flat_list(list_t *list);
9char *code_strchr(const char *string, char delimiter);
10char *code_strstr(const char *haystack, const char *needle);
11int unescape_string(char *string);
12char *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
8extern swayc_t *active_workspace;
9
10char *workspace_next_name(void);
11swayc_t *workspace_create(const char*);
12swayc_t *workspace_find_by_name(const char*);
13void workspace_switch(swayc_t*);
14void layout_log(const swayc_t *c, int depth);
15
16#endif