aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-03-30 00:02:29 -0400
committerDrew DeVault <sir@cmpwn.com>2018-03-30 00:04:04 -0400
commitf26ecd9f58bb672fe107660ce9b37f4bf0777a8c (patch)
tree997658454de40db3f8b76b68d658efaf2b686188 /include
parentd8104db8f1820bd3d4db8bf4f1ee51ae334ee6e7 (diff)
parent7162b9bea4d66d61376ad3605e23e2d83bb95201 (diff)
Merge remote-tracking branch 'origin/wlroots' into swaybar-layers
Diffstat (limited to 'include')
-rw-r--r--include/sway/config.h17
-rw-r--r--include/sway/container.h169
-rw-r--r--include/sway/criteria.h6
-rw-r--r--include/sway/input/input-manager.h4
-rw-r--r--include/sway/input/seat.h13
-rw-r--r--include/sway/ipc-json.h6
-rw-r--r--include/sway/ipc-server.h9
-rw-r--r--include/sway/layout.h43
-rw-r--r--include/sway/tree/container.h143
-rw-r--r--include/sway/tree/layout.h52
-rw-r--r--include/sway/tree/view.h (renamed from include/sway/view.h)4
-rw-r--r--include/sway/tree/workspace.h26
-rw-r--r--include/sway/workspace.h20
13 files changed, 251 insertions, 261 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index b7820128..ac1105b4 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -8,8 +8,8 @@
#include <wlr/types/wlr_box.h>
#include <xkbcommon/xkbcommon.h>
#include "list.h"
-#include "layout.h"
-#include "container.h"
+#include "tree/layout.h"
+#include "tree/container.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
// TODO: Refactor this shit
@@ -290,8 +290,8 @@ struct sway_config {
char *floating_scroll_down_cmd;
char *floating_scroll_left_cmd;
char *floating_scroll_right_cmd;
- enum swayc_layouts default_orientation;
- enum swayc_layouts default_layout;
+ enum sway_container_layout default_orientation;
+ enum sway_container_layout default_layout;
char *font;
int font_height;
@@ -315,8 +315,8 @@ struct sway_config {
list_t *config_chain;
const char *current_config;
- enum swayc_border_types border;
- enum swayc_border_types floating_border;
+ enum sway_container_border border;
+ enum sway_container_border floating_border;
int border_thickness;
int floating_border_thickness;
enum edge_border_types hide_edge_borders;
@@ -347,7 +347,7 @@ struct sway_config {
struct input_config *input_config;
struct seat_config *seat_config;
struct sway_seat *seat;
- swayc_t *current_container;
+ struct sway_container *current_container;
} handler_context;
};
@@ -407,7 +407,8 @@ void output_get_identifier(char *identifier, size_t len,
struct sway_output *output);
struct output_config *new_output_config(const char *name);
void merge_output_config(struct output_config *dst, struct output_config *src);
-void apply_output_config(struct output_config *oc, swayc_t *output);
+void apply_output_config(struct output_config *oc,
+ struct sway_container *output);
void free_output_config(struct output_config *oc);
int workspace_output_cmp_workspace(const void *a, const void *b);
diff --git a/include/sway/container.h b/include/sway/container.h
deleted file mode 100644
index f200a1a2..00000000
--- a/include/sway/container.h
+++ /dev/null
@@ -1,169 +0,0 @@
-#ifndef _SWAY_CONTAINER_H
-#define _SWAY_CONTAINER_H
-#include <stdint.h>
-#include <sys/types.h>
-#include <wlr/types/wlr_box.h>
-#include <wlr/types/wlr_surface.h>
-#include "list.h"
-
-typedef struct sway_container swayc_t;
-
-extern swayc_t root_container;
-
-struct sway_view;
-struct sway_seat;
-
-/**
- * Different kinds of containers.
- *
- * This enum is in order. A container will never be inside of a container below
- * it on this list.
- */
-enum swayc_types {
- C_ROOT, /**< The root container. Only one of these ever exists. */
- C_OUTPUT, /**< An output (aka monitor, head, etc). */
- C_WORKSPACE, /**< A workspace. */
- C_CONTAINER, /**< A manually created container. */
- C_VIEW, /**< A view (aka window). */
-
- C_TYPES,
-};
-
-/**
- * Different ways to arrange a container.
- */
-enum swayc_layouts {
- L_NONE, /**< Used for containers that have no layout (views, root) */
- L_HORIZ,
- L_VERT,
- L_STACKED,
- L_TABBED,
- L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
-
- /* Awesome/Monad style auto layouts */
- L_AUTO_LEFT,
- L_AUTO_RIGHT,
- L_AUTO_TOP,
- L_AUTO_BOTTOM,
-
- L_AUTO_FIRST = L_AUTO_LEFT,
- L_AUTO_LAST = L_AUTO_BOTTOM,
-
- // Keep last
- L_LAYOUTS,
-};
-
-enum swayc_border_types {
- B_NONE, /**< No border */
- B_PIXEL, /**< 1px border */
- B_NORMAL, /**< Normal border with title bar */
-};
-
-struct sway_root;
-struct sway_output;
-struct sway_view;
-
-/**
- * Stores information about a container.
- *
- * The tree is made of these. Views are containers that cannot have children.
- */
-struct sway_container {
- union {
- // TODO: Encapsulate state for other node types as well like C_CONTAINER
- struct sway_root *sway_root; // C_ROOT
- struct sway_output *sway_output; // C_OUTPUT
- struct sway_view *sway_view; // C_VIEW
- };
-
- /**
- * A unique ID to identify this container. Primarily used in the
- * get_tree JSON output.
- */
- size_t id;
-
- char *name;
-
- enum swayc_types type;
- enum swayc_layouts layout;
- enum swayc_layouts prev_layout;
- enum swayc_layouts workspace_layout;
-
- /**
- * The coordinates that this view appear at, relative to the output they
- * are located on (output containers have absolute coordinates).
- */
- double x, y;
-
- /**
- * Width and height of this container, without borders or gaps.
- */
- double width, height;
-
- list_t *children;
-
- /**
- * The parent of this container. NULL for the root container.
- */
- struct sway_container *parent;
-
- /**
- * Number of master views in auto layouts.
- */
- size_t nb_master;
-
- /**
- * Number of slave groups (e.g. columns) in auto layouts.
- */
- size_t nb_slave_groups;
-
- /**
- * Marks applied to the container, list_t of char*.
- */
- list_t *marks;
-
- struct {
- struct wl_signal destroy;
- } events;
-};
-
-void swayc_descendants_of_type(swayc_t *root, enum swayc_types type,
- void (*func)(swayc_t *item, void *data), void *data);
-
-swayc_t *new_output(struct sway_output *sway_output);
-swayc_t *new_workspace(swayc_t *output, const char *name);
-swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view);
-
-swayc_t *destroy_output(swayc_t *output);
-swayc_t *destroy_view(swayc_t *view);
-
-swayc_t *next_view_sibling(struct sway_seat *seat);
-
-/**
- * Finds a container based on test criteria. Returns the first container that
- * passes the test.
- */
-swayc_t *swayc_by_test(swayc_t *container,
- bool (*test)(swayc_t *view, void *data), void *data);
-/**
- * Finds a parent container with the given swayc_type.
- */
-swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type);
-/**
- * Maps a container's children over a function.
- */
-void container_map(swayc_t *container,
- void (*f)(swayc_t *view, void *data), void *data);
-
-swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
- struct wlr_surface **surface, double *sx, double *sy);
-
-/**
- * Apply the function for each child of the container breadth first.
- */
-void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data),
- void *data);
-
-swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
-
-#endif
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index 9b4b4bef..ec256ddb 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -1,7 +1,7 @@
#ifndef _SWAY_CRITERIA_H
#define _SWAY_CRITERIA_H
-#include "container.h"
+#include "tree/container.h"
#include "list.h"
/**
@@ -31,12 +31,12 @@ char *extract_crit_tokens(list_t *tokens, const char *criteria);
// Returns list of criteria that match given container. These criteria have
// been set with `for_window` commands and have an associated cmdlist.
-list_t *criteria_for(swayc_t *cont);
+list_t *criteria_for(struct sway_container *cont);
// Returns a list of all containers that match the given list of tokens.
list_t *container_for_crit_tokens(list_t *tokens);
// Returns true if any criteria in the given list matches this container
-bool criteria_any(swayc_t *cont, list_t *criteria);
+bool criteria_any(struct sway_container *cont, list_t *criteria);
#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index eab7dc90..c6c73dba 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -31,10 +31,10 @@ struct sway_input_manager *sway_input_manager_create(
struct sway_server *server);
bool sway_input_manager_has_focus(struct sway_input_manager *input,
- swayc_t *container);
+ struct sway_container *container);
void sway_input_manager_set_focus(struct sway_input_manager *input,
- swayc_t *container);
+ struct sway_container *container);
void sway_input_manager_configure_xcursor(struct sway_input_manager *input);
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 1d55bec7..496bfd5d 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -14,7 +14,7 @@ struct sway_seat_device {
struct sway_seat_container {
struct sway_seat *seat;
- swayc_t *container;
+ struct sway_container *container;
struct wl_list link; // sway_seat::focus_stack
@@ -54,9 +54,9 @@ void sway_seat_remove_device(struct sway_seat *seat,
void sway_seat_configure_xcursor(struct sway_seat *seat);
-void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container);
+void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container);
-swayc_t *sway_seat_get_focus(struct sway_seat *seat);
+struct sway_container *sway_seat_get_focus(struct sway_seat *seat);
/**
* Return the last container to be focused for the seat (or the most recently
@@ -67,10 +67,11 @@ swayc_t *sway_seat_get_focus(struct sway_seat *seat);
* is destroyed, or focus moves to a container with children and we need to
* descend into the next leaf in focus order.
*/
-swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container);
+struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat,
+ struct sway_container *container);
-swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat,
- enum swayc_types type);
+struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat,
+ enum sway_container_type type);
void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config);
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h
index 19c5b5bc..7d87d377 100644
--- a/include/sway/ipc-json.h
+++ b/include/sway/ipc-json.h
@@ -1,13 +1,13 @@
#ifndef _SWAY_IPC_JSON_H
#define _SWAY_IPC_JSON_H
#include <json-c/json.h>
-#include "sway/container.h"
+#include "sway/tree/container.h"
#include "sway/input/input-manager.h"
json_object *ipc_json_get_version();
-json_object *ipc_json_describe_container(swayc_t *c);
-json_object *ipc_json_describe_container_recursive(swayc_t *c);
+json_object *ipc_json_describe_container(struct sway_container *c);
+json_object *ipc_json_describe_container_recursive(struct sway_container *c);
json_object *ipc_json_describe_input(struct sway_input_device *device);
json_object *ipc_json_describe_bar_config(struct bar_config *bar);
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h
index b4db75c3..c3389fe8 100644
--- a/include/sway/ipc-server.h
+++ b/include/sway/ipc-server.h
@@ -1,17 +1,20 @@
#ifndef _SWAY_IPC_SERVER_H
#define _SWAY_IPC_SERVER_H
#include <sys/socket.h>
-#include "sway/container.h"
+#include "sway/tree/container.h"
#include "ipc.h"
struct sway_server;
void ipc_init(struct sway_server *server);
+
void ipc_terminate(void);
+
struct sockaddr_un *ipc_user_sockaddr(void);
-void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change);
-void ipc_event_window(swayc_t *window, const char *change);
+void ipc_event_workspace(struct sway_container *old,
+ struct sway_container *new, const char *change);
+void ipc_event_window(struct sway_container *window, const char *change);
void ipc_event_barconfig_update(struct bar_config *bar);
void ipc_event_mode(const char *mode);
diff --git a/include/sway/layout.h b/include/sway/layout.h
deleted file mode 100644
index e82c4442..00000000
--- a/include/sway/layout.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef _SWAY_LAYOUT_H
-#define _SWAY_LAYOUT_H
-
-#include <wlr/types/wlr_output_layout.h>
-#include "sway/container.h"
-
-enum movement_direction {
- MOVE_LEFT,
- MOVE_RIGHT,
- MOVE_UP,
- MOVE_DOWN,
- MOVE_PARENT,
- MOVE_CHILD,
- MOVE_NEXT,
- MOVE_PREV,
- MOVE_FIRST
-};
-
-struct sway_container;
-
-struct sway_root {
- struct wlr_output_layout *output_layout;
-
- struct wl_listener output_layout_change;
-
- struct wl_list unmanaged_views; // sway_view::unmanaged_view_link
-
- struct {
- struct wl_signal new_container;
- } events;
-};
-
-void init_layout(void);
-void add_child(struct sway_container *parent, struct sway_container *child);
-swayc_t *add_sibling(swayc_t *parent, swayc_t *child);
-struct sway_container *remove_child(struct sway_container *child);
-enum swayc_layouts default_layout(struct sway_container *output);
-void sort_workspaces(struct sway_container *output);
-void arrange_windows(struct sway_container *container, double width, double height);
-swayc_t *get_swayc_in_direction(swayc_t *container,
- struct sway_seat *seat, enum movement_direction dir);
-
-#endif
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
new file mode 100644
index 00000000..3bb497db
--- /dev/null
+++ b/include/sway/tree/container.h
@@ -0,0 +1,143 @@
+#ifndef _SWAY_CONTAINER_H
+#define _SWAY_CONTAINER_H
+#include <stdint.h>
+#include <sys/types.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_surface.h>
+#include "list.h"
+
+extern struct sway_container root_container;
+
+struct sway_view;
+struct sway_seat;
+
+/**
+ * Different kinds of containers.
+ *
+ * This enum is in order. A container will never be inside of a container below
+ * it on this list.
+ */
+enum sway_container_type {
+ C_ROOT,
+ C_OUTPUT,
+ C_WORKSPACE,
+ C_CONTAINER,
+ C_VIEW,
+
+ C_TYPES,
+};
+
+enum sway_container_layout {
+ L_NONE,
+ L_HORIZ,
+ L_VERT,
+ L_STACKED,
+ L_TABBED,
+ L_FLOATING,
+
+ // Keep last
+ L_LAYOUTS,
+};
+
+enum sway_container_border {
+ B_NONE,
+ B_PIXEL,
+ B_NORMAL,
+};
+
+struct sway_root;
+struct sway_output;
+struct sway_view;
+
+struct sway_container {
+ union {
+ // TODO: Encapsulate state for other node types as well like C_CONTAINER
+ struct sway_root *sway_root;
+ struct sway_output *sway_output;
+ struct sway_view *sway_view;
+ };
+
+ /**
+ * A unique ID to identify this container. Primarily used in the
+ * get_tree JSON output.
+ */
+ size_t id;
+
+ char *name;
+
+ enum sway_container_type type;
+ enum sway_container_layout layout;
+ enum sway_container_layout prev_layout;
+ enum sway_container_layout workspace_layout;
+
+ // TODO convert to layout coordinates
+ double x, y;
+
+ // does not include borders or gaps.
+ double width, height;
+
+ list_t *children;
+
+ struct sway_container *parent;
+
+ list_t *marks; // list of char*
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+};
+
+// TODO only one container create function and pass the type?
+struct sway_container *container_output_create(
+ struct sway_output *sway_output);
+
+struct sway_container *container_workspace_create(
+ struct sway_container *output, const char *name);
+
+struct sway_container *container_view_create(
+ struct sway_container *sibling, struct sway_view *sway_view);
+
+struct sway_container *container_output_destroy(struct sway_container *output);
+
+struct sway_container *container_view_destroy(struct sway_container *view);
+
+struct sway_container *container_set_layout(struct sway_container *container,
+ enum sway_container_layout layout);
+
+void container_descendants(struct sway_container *root,
+ enum sway_container_type type,
+ void (*func)(struct sway_container *item, void *data), void *data);
+
+/**
+ * Finds a container based on test criteria. Returns the first container that
+ * passes the test.
+ */
+struct sway_container *container_find(struct sway_container *container,
+ bool (*test)(struct sway_container *view, void *data), void *data);
+
+/**
+ * Finds a parent container with the given struct sway_containerype.
+ */
+struct sway_container *container_parent(struct sway_container *container,
+ enum sway_container_type type);
+
+/**
+ * Find a container at the given coordinates.
+ */
+struct sway_container *container_at(struct sway_container *parent,
+ double lx, double ly, struct wlr_surface **surface,
+ double *sx, double *sy);
+
+/**
+ * Apply the function for each child of the container breadth first.
+ */
+void container_for_each_descendant_bfs(struct sway_container *container,
+ void (*f)(struct sway_container *container, void *data), void *data);
+
+/**
+ * Apply the function for each child of the container depth first.
+ */
+void container_for_each_descendant_dfs(struct sway_container *container,
+ void (*f)(struct sway_container *container, void *data), void *data);
+
+#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
new file mode 100644
index 00000000..ad52bdb0
--- /dev/null
+++ b/include/sway/tree/layout.h
@@ -0,0 +1,52 @@
+#ifndef _SWAY_LAYOUT_H
+#define _SWAY_LAYOUT_H
+
+#include <wlr/types/wlr_output_layout.h>
+#include "sway/tree/container.h"
+
+enum movement_direction {
+ MOVE_LEFT,
+ MOVE_RIGHT,
+ MOVE_UP,
+ MOVE_DOWN,
+ MOVE_PARENT,
+ MOVE_CHILD,
+ MOVE_NEXT,
+ MOVE_PREV,
+ MOVE_FIRST
+};
+
+struct sway_container;
+
+struct sway_root {
+ struct wlr_output_layout *output_layout;
+
+ struct wl_listener output_layout_change;
+
+ struct wl_list unmanaged_views; // sway_view::unmanaged_view_link
+
+ struct {
+ struct wl_signal new_container;
+ } events;
+};
+
+void layout_init(void);
+
+void container_add_child(struct sway_container *parent, struct sway_container *child);
+
+struct sway_container *container_add_sibling(struct sway_container *parent,
+ struct sway_container *child);
+
+struct sway_container *container_remove_child(struct sway_container *child);
+
+enum sway_container_layout container_get_default_layout(struct sway_container *output);
+
+void container_sort_workspaces(struct sway_container *output);
+
+void arrange_windows(struct sway_container *container,
+ double width, double height);
+
+struct sway_container *container_get_in_direction(struct sway_container
+ *container, struct sway_seat *seat, enum movement_direction dir);
+
+#endif
diff --git a/include/sway/view.h b/include/sway/tree/view.h
index b2886211..e5f53f4e 100644
--- a/include/sway/view.h
+++ b/include/sway/tree/view.h
@@ -62,10 +62,6 @@ enum sway_view_prop {
VIEW_PROP_INSTANCE,
};
-/**
- * sway_view is a state container for surfaces that are arranged in the sway
- * tree (shell surfaces).
- */
struct sway_view {
enum sway_view_type type;
struct sway_container *swayc;
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
new file mode 100644
index 00000000..d73b29c1
--- /dev/null
+++ b/include/sway/tree/workspace.h
@@ -0,0 +1,26 @@
+#ifndef _SWAY_WORKSPACE_H
+#define _SWAY_WORKSPACE_H
+
+#include "sway/tree/container.h"
+
+extern char *prev_workspace_name;
+
+char *workspace_next_name(const char *output_name);
+
+struct sway_container *workspace_create(const char *name);
+
+bool workspace_switch(struct sway_container *workspace);
+
+struct sway_container *workspace_by_number(const char* name);
+
+struct sway_container *workspace_by_name(const char*);
+
+struct sway_container *workspace_output_next(struct sway_container *current);
+
+struct sway_container *workspace_next(struct sway_container *current);
+
+struct sway_container *workspace_output_prev(struct sway_container *current);
+
+struct sway_container *workspace_prev(struct sway_container *current);
+
+#endif
diff --git a/include/sway/workspace.h b/include/sway/workspace.h
deleted file mode 100644
index fee54255..00000000
--- a/include/sway/workspace.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _SWAY_WORKSPACE_H
-#define _SWAY_WORKSPACE_H
-
-#include "sway/container.h"
-
-extern char *prev_workspace_name;
-
-char *workspace_next_name(const char *output_name);
-swayc_t *workspace_create(const char *name);
-bool workspace_switch(swayc_t *workspace);
-
-struct sway_container *workspace_by_number(const char* name);
-swayc_t *workspace_by_name(const char*);
-
-struct sway_container *workspace_output_next(swayc_t *current);
-struct sway_container *workspace_next(swayc_t *current);
-struct sway_container *workspace_output_prev(swayc_t *current);
-struct sway_container *workspace_prev(swayc_t *current);
-
-#endif