diff options
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 @@ +#ifndef _SWAY_COMMANDS_H +#define _SWAY_COMMANDS_H +#include <stdbool.h> +#include "config.h" + +struct cmd_handler { + char *command; + bool (*handle)(struct sway_config *config, int argc, char **argv); +}; + +bool handle_command(struct sway_config *config, char *command); + +#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 @@ +#ifndef _SWAY_CONFIG_H +#define _SWAY_CONFIG_H + +#include <stdint.h> +#include <wlc/wlc.h> +#include "list.h" + +struct sway_variable { + char *name; + char *value; +}; + +struct sway_binding { + list_t *keys; + uint32_t modifiers; + char *command; +}; + +struct sway_mode { + char *name; + list_t *bindings; +}; + +struct sway_config { + list_t *symbols; + list_t *modes; + list_t *cmd_queue; + struct sway_mode *current_mode; + + // Flags + bool focus_follows_mouse; + bool mouse_warping; + bool active; + bool failed; + bool reloading; +}; + +bool load_config(); +bool read_config(FILE *file, bool is_active); +char *do_var_replacement(struct sway_config *config, char *str); + +extern struct sway_config *config; + +#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 @@ +#ifndef _SWAY_CONTAINER_H +#define _SWAY_CONTAINER_H +#include <wlc/wlc.h> +typedef struct sway_container swayc_t; + +#include "layout.h" + +enum swayc_types{ + C_ROOT, + C_OUTPUT, + C_WORKSPACE, + C_CONTAINER, + C_VIEW, + //Keep last + C_TYPES, +}; + +enum swayc_layouts{ + L_NONE, + L_HORIZ, + L_VERT, + L_STACKED, + L_TABBED, + L_FLOATING, + //Keep last + L_LAYOUTS, +}; + +struct sway_container { + wlc_handle handle; + + enum swayc_types type; + + enum swayc_layouts layout; + + // Not including borders or margins + int width, height; + + int x, y; + + bool visible; + + int weight; + + char *name; + + list_t *children; + + struct sway_container *parent; + struct sway_container *focused; +}; + + +swayc_t *new_output(wlc_handle handle); +swayc_t *new_workspace(swayc_t * output, const char *name); +//Creates container Around child (parent child) -> (parent (container child)) +swayc_t *new_container(swayc_t *child, enum swayc_layouts layout); +//Creates view as a sibling of current focused container, or as child of a workspace +swayc_t *new_view(swayc_t *sibling, wlc_handle handle); + + +swayc_t *destroy_output(swayc_t *output); +//destroys workspace if empty and returns parent pointer, else returns NULL +swayc_t *destroy_workspace(swayc_t *workspace); +swayc_t *destroy_container(swayc_t *container); +swayc_t *destroy_view(swayc_t *view); + +swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); +void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); + +#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 @@ +#ifndef _SWAY_HANDLERS_H +#define _SWAY_HANDLERS_H + +#include <stdbool.h> +#include <wlc/wlc.h> + +extern struct wlc_interface interface; + +//set focus to current pointer location and return focused container +swayc_t *focus_pointer(void); + +#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 @@ +#ifndef _SWAY_LAYOUT_H +#define _SWAY_LAYOUT_H + +#include <wlc/wlc.h> +#include "list.h" +#include "container.h" + +extern swayc_t root_container; + +void init_layout(void); + +void add_child(swayc_t *parent, swayc_t *child); +//Returns parent container wihch needs to be rearranged. +swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); +swayc_t *replace_child(swayc_t *child, swayc_t *new_child); +swayc_t *remove_child(swayc_t *parent, swayc_t *child); + +void unfocus_all(swayc_t *container); +void focus_view(swayc_t *view); +void arrange_windows(swayc_t *container, int width, int height); +swayc_t *get_focused_container(swayc_t *parent); + +swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); + +#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 @@ +#ifndef _SWAY_LIST_H +#define _SWAY_LIST_H + +typedef struct { + int capacity; + int length; + void **items; +} list_t; + +list_t *create_list(void); +void list_free(list_t *list); +void list_add(list_t *list, void *item); +void list_insert(list_t *list, int index, void *item); +void list_del(list_t *list, int index); +void list_cat(list_t *list, list_t *source); + +#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 @@ +#ifndef _SWAY_LOG_H +#define _SWAY_LOG_H + +typedef enum { + L_SILENT = 0, + L_ERROR = 1, + L_INFO = 2, + L_DEBUG = 3, +} log_importance_t; + +void init_log(int verbosity); +void sway_log_colors(int mode); +void sway_log(int verbosity, char* format, ...); +void sway_abort(char* format, ...); + +#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 @@ +#ifndef _SWAY_MOVEMENT_H +#define _SWAY_MOVEMENT_H + +#include <wlc/wlc.h> +#include "list.h" + +enum movement_direction { + MOVE_LEFT, + MOVE_RIGHT, + MOVE_UP, + MOVE_DOWN, + MOVE_PARENT +}; + +bool move_focus(enum movement_direction direction); + +#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 @@ +#ifndef _SWAY_READLINE_H +#define _SWAY_READLINE_H + +#include <stdio.h> + +char *read_line(FILE *file); + +#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 @@ +#ifndef _SWAY_STRINGOP_H +#define _SWAY_STRINGOP_H +#include "list.h" + +char *strip_whitespace(char *str, int *trimmed_start); +char *strip_comments(char *str); +list_t *split_string(const char *str, const char *delims); +void free_flat_list(list_t *list); +char *code_strchr(const char *string, char delimiter); +char *code_strstr(const char *haystack, const char *needle); +int unescape_string(char *string); +char *join_args(char **argv, int argc); + +#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 @@ +#ifndef _SWAY_WORKSPACE_H +#define _SWAY_WORKSPACE_H + +#include <wlc/wlc.h> +#include "list.h" +#include "layout.h" + +extern swayc_t *active_workspace; + +char *workspace_next_name(void); +swayc_t *workspace_create(const char*); +swayc_t *workspace_find_by_name(const char*); +void workspace_switch(swayc_t*); +void layout_log(const swayc_t *c, int depth); + +#endif |