From 7f8ebb7d0dcb687574554b877a0e84f48718df37 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 16 Aug 2015 11:02:56 -0400 Subject: Move headers to include/ --- CMakeLists.txt | 2 +- include/commands.h | 13 ++++++++++ include/config.h | 44 +++++++++++++++++++++++++++++++++ include/container.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/handlers.h | 12 +++++++++ include/layout.h | 25 +++++++++++++++++++ include/list.h | 17 +++++++++++++ include/log.h | 16 ++++++++++++ include/movement.h | 17 +++++++++++++ include/readline.h | 8 ++++++ include/stringop.h | 14 +++++++++++ include/workspace.h | 16 ++++++++++++ sway/commands.h | 13 ---------- sway/config.h | 44 --------------------------------- sway/container.h | 71 ----------------------------------------------------- sway/handlers.h | 12 --------- sway/layout.h | 25 ------------------- sway/list.h | 17 ------------- sway/log.h | 16 ------------ sway/movement.h | 17 ------------- sway/readline.h | 8 ------ sway/stringop.h | 14 ----------- sway/workspace.h | 16 ------------ 23 files changed, 254 insertions(+), 254 deletions(-) create mode 100644 include/commands.h create mode 100644 include/config.h create mode 100644 include/container.h create mode 100644 include/handlers.h create mode 100644 include/layout.h create mode 100644 include/list.h create mode 100644 include/log.h create mode 100644 include/movement.h create mode 100644 include/readline.h create mode 100644 include/stringop.h create mode 100644 include/workspace.h delete mode 100644 sway/commands.h delete mode 100644 sway/config.h delete mode 100644 sway/container.h delete mode 100644 sway/handlers.h delete mode 100644 sway/layout.h delete mode 100644 sway/list.h delete mode 100644 sway/log.h delete mode 100644 sway/movement.h delete mode 100644 sway/readline.h delete mode 100644 sway/stringop.h delete mode 100644 sway/workspace.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b8c7b4f..27839b1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ FILE(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c) include_directories( ${WLC_INCLUDE_DIRS} - sway/ + include/ ) add_executable(sway 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 +#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 +#include +#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 +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 +#include + +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 +#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 +#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 + +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 +#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 diff --git a/sway/commands.h b/sway/commands.h deleted file mode 100644 index c2046e13..00000000 --- a/sway/commands.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _SWAY_COMMANDS_H -#define _SWAY_COMMANDS_H -#include -#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/sway/config.h b/sway/config.h deleted file mode 100644 index c9fd374c..00000000 --- a/sway/config.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _SWAY_CONFIG_H -#define _SWAY_CONFIG_H - -#include -#include -#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/sway/container.h b/sway/container.h deleted file mode 100644 index a54e016a..00000000 --- a/sway/container.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _SWAY_CONTAINER_H -#define _SWAY_CONTAINER_H -#include -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/sway/handlers.h b/sway/handlers.h deleted file mode 100644 index d1742cce..00000000 --- a/sway/handlers.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _SWAY_HANDLERS_H -#define _SWAY_HANDLERS_H - -#include -#include - -extern struct wlc_interface interface; - -//set focus to current pointer location and return focused container -swayc_t *focus_pointer(void); - -#endif diff --git a/sway/layout.h b/sway/layout.h deleted file mode 100644 index a136f917..00000000 --- a/sway/layout.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _SWAY_LAYOUT_H -#define _SWAY_LAYOUT_H - -#include -#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/sway/list.h b/sway/list.h deleted file mode 100644 index 29b988aa..00000000 --- a/sway/list.h +++ /dev/null @@ -1,17 +0,0 @@ -#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/sway/log.h b/sway/log.h deleted file mode 100644 index e5075a39..00000000 --- a/sway/log.h +++ /dev/null @@ -1,16 +0,0 @@ -#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/sway/movement.h b/sway/movement.h deleted file mode 100644 index dd701877..00000000 --- a/sway/movement.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _SWAY_MOVEMENT_H -#define _SWAY_MOVEMENT_H - -#include -#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/sway/readline.h b/sway/readline.h deleted file mode 100644 index dbe937c1..00000000 --- a/sway/readline.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _SWAY_READLINE_H -#define _SWAY_READLINE_H - -#include - -char *read_line(FILE *file); - -#endif diff --git a/sway/stringop.h b/sway/stringop.h deleted file mode 100644 index a5346829..00000000 --- a/sway/stringop.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/sway/workspace.h b/sway/workspace.h deleted file mode 100644 index 59a6d526..00000000 --- a/sway/workspace.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _SWAY_WORKSPACE_H -#define _SWAY_WORKSPACE_H - -#include -#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 -- cgit v1.2.3