diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-03-29 16:17:55 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-03-29 16:40:40 -0400 |
commit | b90099b4b7df8068446c658ab99b58ff83648954 (patch) | |
tree | a822ef3605ce98f9d8633c24f6927bb11effbdcc | |
parent | remove swayc_t typedef (diff) | |
download | sway-b90099b4b7df8068446c658ab99b58ff83648954.tar.gz sway-b90099b4b7df8068446c658ab99b58ff83648954.tar.zst sway-b90099b4b7df8068446c658ab99b58ff83648954.zip |
rename container functions
-rw-r--r-- | include/sway/config.h | 8 | ||||
-rw-r--r-- | include/sway/input/seat.h | 2 | ||||
-rw-r--r-- | include/sway/tree/container.h | 70 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 2 | ||||
-rw-r--r-- | sway/commands/focus.c | 4 | ||||
-rw-r--r-- | sway/commands/kill.c | 2 | ||||
-rw-r--r-- | sway/commands/layout.c | 4 | ||||
-rw-r--r-- | sway/commands/output.c | 2 | ||||
-rw-r--r-- | sway/commands/workspace.c | 12 | ||||
-rw-r--r-- | sway/config/output.c | 4 | ||||
-rw-r--r-- | sway/criteria.c | 12 | ||||
-rw-r--r-- | sway/desktop/output.c | 14 | ||||
-rw-r--r-- | sway/desktop/wl_shell.c | 6 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 6 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 18 | ||||
-rw-r--r-- | sway/input/cursor.c | 8 | ||||
-rw-r--r-- | sway/input/seat.c | 34 | ||||
-rw-r--r-- | sway/ipc-json.c | 14 | ||||
-rw-r--r-- | sway/ipc-server.c | 4 | ||||
-rw-r--r-- | sway/tree/container.c | 182 | ||||
-rw-r--r-- | sway/tree/layout.c | 86 | ||||
-rw-r--r-- | sway/tree/workspace.c | 70 | ||||
-rw-r--r-- | swaybar/ipc.c | 2 |
23 files changed, 287 insertions, 279 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index e9910be4..7fdd0be0 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -299,8 +299,8 @@ struct sway_config { | |||
299 | char *floating_scroll_down_cmd; | 299 | char *floating_scroll_down_cmd; |
300 | char *floating_scroll_left_cmd; | 300 | char *floating_scroll_left_cmd; |
301 | char *floating_scroll_right_cmd; | 301 | char *floating_scroll_right_cmd; |
302 | enum swayc_layouts default_orientation; | 302 | enum sway_container_layout default_orientation; |
303 | enum swayc_layouts default_layout; | 303 | enum sway_container_layout default_layout; |
304 | char *font; | 304 | char *font; |
305 | int font_height; | 305 | int font_height; |
306 | 306 | ||
@@ -324,8 +324,8 @@ struct sway_config { | |||
324 | list_t *config_chain; | 324 | list_t *config_chain; |
325 | const char *current_config; | 325 | const char *current_config; |
326 | 326 | ||
327 | enum swayc_border_types border; | 327 | enum sway_container_border border; |
328 | enum swayc_border_types floating_border; | 328 | enum sway_container_border floating_border; |
329 | int border_thickness; | 329 | int border_thickness; |
330 | int floating_border_thickness; | 330 | int floating_border_thickness; |
331 | enum edge_border_types hide_edge_borders; | 331 | enum edge_border_types hide_edge_borders; |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index e43e6fd4..496bfd5d 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -71,7 +71,7 @@ struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, | |||
71 | struct sway_container *container); | 71 | struct sway_container *container); |
72 | 72 | ||
73 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, | 73 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, |
74 | enum swayc_types type); | 74 | enum sway_container_type type); |
75 | 75 | ||
76 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); | 76 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); |
77 | 77 | ||
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 5def5e71..0dfed455 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -17,7 +17,7 @@ struct sway_seat; | |||
17 | * This enum is in order. A container will never be inside of a container below | 17 | * This enum is in order. A container will never be inside of a container below |
18 | * it on this list. | 18 | * it on this list. |
19 | */ | 19 | */ |
20 | enum swayc_types { | 20 | enum sway_container_type { |
21 | C_ROOT, | 21 | C_ROOT, |
22 | C_OUTPUT, | 22 | C_OUTPUT, |
23 | C_WORKSPACE, | 23 | C_WORKSPACE, |
@@ -27,7 +27,7 @@ enum swayc_types { | |||
27 | C_TYPES, | 27 | C_TYPES, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | enum swayc_layouts { | 30 | enum sway_container_layout { |
31 | L_NONE, | 31 | L_NONE, |
32 | L_HORIZ, | 32 | L_HORIZ, |
33 | L_VERT, | 33 | L_VERT, |
@@ -39,7 +39,7 @@ enum swayc_layouts { | |||
39 | L_LAYOUTS, | 39 | L_LAYOUTS, |
40 | }; | 40 | }; |
41 | 41 | ||
42 | enum swayc_border_types { | 42 | enum sway_container_border { |
43 | B_NONE, | 43 | B_NONE, |
44 | B_PIXEL, | 44 | B_PIXEL, |
45 | B_NORMAL, | 45 | B_NORMAL, |
@@ -65,10 +65,10 @@ struct sway_container { | |||
65 | 65 | ||
66 | char *name; | 66 | char *name; |
67 | 67 | ||
68 | enum swayc_types type; | 68 | enum sway_container_type type; |
69 | enum swayc_layouts layout; | 69 | enum sway_container_layout layout; |
70 | enum swayc_layouts prev_layout; | 70 | enum sway_container_layout prev_layout; |
71 | enum swayc_layouts workspace_layout; | 71 | enum sway_container_layout workspace_layout; |
72 | 72 | ||
73 | // TODO convert to layout coordinates | 73 | // TODO convert to layout coordinates |
74 | double x, y; | 74 | double x, y; |
@@ -87,53 +87,61 @@ struct sway_container { | |||
87 | } events; | 87 | } events; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | void swayc_descendants_of_type(struct sway_container *root, | ||
91 | enum swayc_types type, | ||
92 | void (*func)(struct sway_container *item, void *data), void *data); | ||
93 | |||
94 | // TODO only one container create function and pass the type? | 90 | // TODO only one container create function and pass the type? |
95 | struct sway_container *new_output(struct sway_output *sway_output); | 91 | struct sway_container *sway_container_output_create( |
92 | struct sway_output *sway_output); | ||
93 | |||
94 | struct sway_container *sway_container_workspace_create( | ||
95 | struct sway_container *output, const char *name); | ||
96 | 96 | ||
97 | struct sway_container *new_workspace(struct sway_container *output, | 97 | struct sway_container *sway_container_view_create( |
98 | const char *name); | 98 | struct sway_container *sibling, struct sway_view *sway_view); |
99 | 99 | ||
100 | struct sway_container *new_view(struct sway_container *sibling, | 100 | struct sway_container *sway_container_output_destroy( |
101 | struct sway_view *sway_view); | 101 | struct sway_container *output); |
102 | 102 | ||
103 | struct sway_container *destroy_output(struct sway_container *output); | 103 | struct sway_container *sway_container_view_destroy(struct sway_container *view); |
104 | struct sway_container *destroy_view(struct sway_container *view); | ||
105 | 104 | ||
105 | struct sway_container *sway_container_set_layout( | ||
106 | struct sway_container *container, enum sway_container_layout layout); | ||
107 | |||
108 | void sway_container_descendents(struct sway_container *root, | ||
109 | enum sway_container_type type, | ||
110 | void (*func)(struct sway_container *item, void *data), void *data); | ||
111 | |||
112 | // XXX: what is this? | ||
106 | struct sway_container *next_view_sibling(struct sway_seat *seat); | 113 | struct sway_container *next_view_sibling(struct sway_seat *seat); |
107 | 114 | ||
108 | /** | 115 | /** |
109 | * Finds a container based on test criteria. Returns the first container that | 116 | * Finds a container based on test criteria. Returns the first container that |
110 | * passes the test. | 117 | * passes the test. |
111 | */ | 118 | */ |
112 | struct sway_container *swayc_by_test(struct sway_container *container, | 119 | struct sway_container *sway_container_find(struct sway_container *container, |
113 | bool (*test)(struct sway_container *view, void *data), void *data); | 120 | bool (*test)(struct sway_container *view, void *data), void *data); |
114 | 121 | ||
115 | /** | 122 | /** |
116 | * Finds a parent container with the given swayc_type. | 123 | * Finds a parent container with the given struct sway_containerype. |
117 | */ | 124 | */ |
118 | struct sway_container *swayc_parent_by_type(struct sway_container *container, | 125 | struct sway_container *sway_container_parent(struct sway_container *container, |
119 | enum swayc_types type); | 126 | enum sway_container_type type); |
120 | 127 | ||
121 | /** | 128 | /** |
122 | * Maps a container's children over a function. | 129 | * Run a function for each child. |
123 | */ | 130 | */ |
124 | void container_map(struct sway_container *container, | 131 | void sway_container_for_each(struct sway_container *container, |
125 | void (*f)(struct sway_container *view, void *data), void *data); | 132 | void (*f)(struct sway_container *view, void *data), void *data); |
126 | 133 | ||
127 | struct sway_container *swayc_at(struct sway_container *parent, double lx, | 134 | /** |
128 | double ly, struct wlr_surface **surface, double *sx, double *sy); | 135 | * Find a container at the given coordinates. |
136 | */ | ||
137 | struct sway_container *sway_container_at(struct sway_container *parent, | ||
138 | double lx, double ly, struct wlr_surface **surface, | ||
139 | double *sx, double *sy); | ||
129 | 140 | ||
130 | /** | 141 | /** |
131 | * Apply the function for each child of the container breadth first. | 142 | * Apply the function for each child of the container breadth first. |
132 | */ | 143 | */ |
133 | void container_for_each_bfs(struct sway_container *con, void (*f)(struct | 144 | void sway_container_for_each_bfs(struct sway_container *container, |
134 | sway_container *con, void *data), void *data); | 145 | void (*f)(struct sway_container *container, void *data), void *data); |
135 | |||
136 | struct sway_container *swayc_change_layout(struct sway_container *container, | ||
137 | enum swayc_layouts layout); | ||
138 | 146 | ||
139 | #endif | 147 | #endif |
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 8bb9e075..f73b3880 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h | |||
@@ -39,7 +39,7 @@ struct sway_container *add_sibling(struct sway_container *parent, | |||
39 | 39 | ||
40 | struct sway_container *remove_child(struct sway_container *child); | 40 | struct sway_container *remove_child(struct sway_container *child); |
41 | 41 | ||
42 | enum swayc_layouts default_layout(struct sway_container *output); | 42 | enum sway_container_layout default_layout(struct sway_container *output); |
43 | 43 | ||
44 | void sort_workspaces(struct sway_container *output); | 44 | void sort_workspaces(struct sway_container *output); |
45 | 45 | ||
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 18e9e0bf..64b05904 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -32,7 +32,7 @@ static bool parse_movement_direction(const char *name, | |||
32 | } | 32 | } |
33 | 33 | ||
34 | struct cmd_results *cmd_focus(int argc, char **argv) { | 34 | struct cmd_results *cmd_focus(int argc, char **argv) { |
35 | swayc_t *con = config->handler_context.current_container; | 35 | struct sway_container *con = config->handler_context.current_container; |
36 | struct sway_seat *seat = config->handler_context.seat; | 36 | struct sway_seat *seat = config->handler_context.seat; |
37 | if (con->type < C_WORKSPACE) { | 37 | if (con->type < C_WORKSPACE) { |
38 | return cmd_results_new(CMD_FAILURE, "focus", | 38 | return cmd_results_new(CMD_FAILURE, "focus", |
@@ -51,7 +51,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { | |||
51 | "Expected 'focus <direction|parent|child|mode_toggle>' or 'focus output <direction|name>'"); | 51 | "Expected 'focus <direction|parent|child|mode_toggle>' or 'focus output <direction|name>'"); |
52 | } | 52 | } |
53 | 53 | ||
54 | swayc_t *next_focus = get_swayc_in_direction(con, seat, direction); | 54 | struct sway_container *next_focus = get_swayc_in_direction(con, seat, direction); |
55 | if (next_focus) { | 55 | if (next_focus) { |
56 | sway_seat_set_focus(seat, next_focus); | 56 | sway_seat_set_focus(seat, next_focus); |
57 | } | 57 | } |
diff --git a/sway/commands/kill.c b/sway/commands/kill.c index c0faed7a..f6774767 100644 --- a/sway/commands/kill.c +++ b/sway/commands/kill.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include "sway/commands.h" | 6 | #include "sway/commands.h" |
7 | 7 | ||
8 | struct cmd_results *cmd_kill(int argc, char **argv) { | 8 | struct cmd_results *cmd_kill(int argc, char **argv) { |
9 | enum swayc_types type = config->handler_context.current_container->type; | 9 | enum sway_container_type type = config->handler_context.current_container->type; |
10 | if (type != C_VIEW && type != C_CONTAINER) { | 10 | if (type != C_VIEW && type != C_CONTAINER) { |
11 | return cmd_results_new(CMD_INVALID, NULL, | 11 | return cmd_results_new(CMD_INVALID, NULL, |
12 | "Can only kill views and containers with this command"); | 12 | "Can only kill views and containers with this command"); |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 2b193136..e10334e2 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -10,7 +10,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
10 | if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) { | 10 | if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) { |
11 | return error; | 11 | return error; |
12 | } | 12 | } |
13 | swayc_t *parent = config->handler_context.current_container; | 13 | struct sway_container *parent = config->handler_context.current_container; |
14 | 14 | ||
15 | // TODO: floating | 15 | // TODO: floating |
16 | /* | 16 | /* |
@@ -28,7 +28,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
28 | if (strcasecmp(argv[0], "default") == 0) { | 28 | if (strcasecmp(argv[0], "default") == 0) { |
29 | swayc_change_layout(parent, parent->prev_layout); | 29 | swayc_change_layout(parent, parent->prev_layout); |
30 | if (parent->layout == L_NONE) { | 30 | if (parent->layout == L_NONE) { |
31 | swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT); | 31 | struct sway_container *output = sway_container_parent(parent, C_OUTPUT); |
32 | swayc_change_layout(parent, default_layout(output)); | 32 | swayc_change_layout(parent, default_layout(output)); |
33 | } | 33 | } |
34 | } else { | 34 | } else { |
diff --git a/sway/commands/output.c b/sway/commands/output.c index 35bc8099..f7e3372c 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c | |||
@@ -296,7 +296,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
296 | char identifier[128]; | 296 | char identifier[128]; |
297 | bool all = strcmp(output->name, "*") == 0; | 297 | bool all = strcmp(output->name, "*") == 0; |
298 | for (int i = 0; i < root_container.children->length; ++i) { | 298 | for (int i = 0; i < root_container.children->length; ++i) { |
299 | swayc_t *cont = root_container.children->items[i]; | 299 | struct sway_container *cont = root_container.children->items[i]; |
300 | if (cont->type != C_OUTPUT) { | 300 | if (cont->type != C_OUTPUT) { |
301 | continue; | 301 | continue; |
302 | } | 302 | } |
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 8751dffe..8b7139a9 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -17,15 +17,15 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
17 | 17 | ||
18 | int output_location = -1; | 18 | int output_location = -1; |
19 | 19 | ||
20 | swayc_t *current_container = config->handler_context.current_container; | 20 | struct sway_container *current_container = config->handler_context.current_container; |
21 | swayc_t *old_workspace = NULL, *old_output = NULL; | 21 | struct sway_container *old_workspace = NULL, *old_output = NULL; |
22 | if (current_container) { | 22 | if (current_container) { |
23 | if (current_container->type == C_WORKSPACE) { | 23 | if (current_container->type == C_WORKSPACE) { |
24 | old_workspace = current_container; | 24 | old_workspace = current_container; |
25 | } else { | 25 | } else { |
26 | old_workspace = swayc_parent_by_type(current_container, C_WORKSPACE); | 26 | old_workspace = sway_container_parent(current_container, C_WORKSPACE); |
27 | } | 27 | } |
28 | old_output = swayc_parent_by_type(current_container, C_OUTPUT); | 28 | old_output = sway_container_parent(current_container, C_OUTPUT); |
29 | } | 29 | } |
30 | 30 | ||
31 | for (int i = 0; i < argc; ++i) { | 31 | for (int i = 0; i < argc; ++i) { |
@@ -57,7 +57,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
57 | if (config->reading || !config->active) { | 57 | if (config->reading || !config->active) { |
58 | return cmd_results_new(CMD_DEFER, "workspace", NULL); | 58 | return cmd_results_new(CMD_DEFER, "workspace", NULL); |
59 | } | 59 | } |
60 | swayc_t *ws = NULL; | 60 | struct sway_container *ws = NULL; |
61 | if (strcasecmp(argv[0], "number") == 0) { | 61 | if (strcasecmp(argv[0], "number") == 0) { |
62 | if (!(ws = workspace_by_number(argv[1]))) { | 62 | if (!(ws = workspace_by_number(argv[1]))) { |
63 | char *name = join_args(argv + 1, argc - 1); | 63 | char *name = join_args(argv + 1, argc - 1); |
@@ -92,7 +92,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
92 | workspace_switch(ws); | 92 | workspace_switch(ws); |
93 | current_container = | 93 | current_container = |
94 | sway_seat_get_focus(config->handler_context.seat); | 94 | sway_seat_get_focus(config->handler_context.seat); |
95 | swayc_t *new_output = swayc_parent_by_type(current_container, C_OUTPUT); | 95 | struct sway_container *new_output = sway_container_parent(current_container, C_OUTPUT); |
96 | 96 | ||
97 | if (config->mouse_warping && old_output != new_output) { | 97 | if (config->mouse_warping && old_output != new_output) { |
98 | // TODO: Warp mouse | 98 | // TODO: Warp mouse |
diff --git a/sway/config/output.c b/sway/config/output.c index 9e211861..5763bd21 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -120,14 +120,14 @@ void terminate_swaybg(pid_t pid) { | |||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void apply_output_config(struct output_config *oc, swayc_t *output) { | 123 | void apply_output_config(struct output_config *oc, struct sway_container *output) { |
124 | assert(output->type == C_OUTPUT); | 124 | assert(output->type == C_OUTPUT); |
125 | 125 | ||
126 | struct wlr_output *wlr_output = output->sway_output->wlr_output; | 126 | struct wlr_output *wlr_output = output->sway_output->wlr_output; |
127 | if (oc && oc->enabled == 0) { | 127 | if (oc && oc->enabled == 0) { |
128 | wlr_output_layout_remove(root_container.sway_root->output_layout, | 128 | wlr_output_layout_remove(root_container.sway_root->output_layout, |
129 | wlr_output); | 129 | wlr_output); |
130 | destroy_output(output); | 130 | sway_container_output_destroy(output); |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | 133 | ||
diff --git a/sway/criteria.c b/sway/criteria.c index b8b581ed..70f8e305 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -272,7 +272,7 @@ static int regex_cmp(const char *item, const pcre *regex) { | |||
272 | } | 272 | } |
273 | 273 | ||
274 | // test a single view if it matches list of criteria tokens (all of them). | 274 | // test a single view if it matches list of criteria tokens (all of them). |
275 | static bool criteria_test(swayc_t *cont, list_t *tokens) { | 275 | static bool criteria_test(struct sway_container *cont, list_t *tokens) { |
276 | if (cont->type != C_VIEW) { | 276 | if (cont->type != C_VIEW) { |
277 | return false; | 277 | return false; |
278 | } | 278 | } |
@@ -398,7 +398,7 @@ void free_criteria(struct criteria *crit) { | |||
398 | free(crit); | 398 | free(crit); |
399 | } | 399 | } |
400 | 400 | ||
401 | bool criteria_any(swayc_t *cont, list_t *criteria) { | 401 | bool criteria_any(struct sway_container *cont, list_t *criteria) { |
402 | for (int i = 0; i < criteria->length; i++) { | 402 | for (int i = 0; i < criteria->length; i++) { |
403 | struct criteria *bc = criteria->items[i]; | 403 | struct criteria *bc = criteria->items[i]; |
404 | if (criteria_test(cont, bc->tokens)) { | 404 | if (criteria_test(cont, bc->tokens)) { |
@@ -408,7 +408,7 @@ bool criteria_any(swayc_t *cont, list_t *criteria) { | |||
408 | return false; | 408 | return false; |
409 | } | 409 | } |
410 | 410 | ||
411 | list_t *criteria_for(swayc_t *cont) { | 411 | list_t *criteria_for(struct sway_container *cont) { |
412 | list_t *criteria = config->criteria, *matches = create_list(); | 412 | list_t *criteria = config->criteria, *matches = create_list(); |
413 | for (int i = 0; i < criteria->length; i++) { | 413 | for (int i = 0; i < criteria->length; i++) { |
414 | struct criteria *bc = criteria->items[i]; | 414 | struct criteria *bc = criteria->items[i]; |
@@ -424,7 +424,7 @@ struct list_tokens { | |||
424 | list_t *tokens; | 424 | list_t *tokens; |
425 | }; | 425 | }; |
426 | 426 | ||
427 | static void container_match_add(swayc_t *container, | 427 | static void container_match_add(struct sway_container *container, |
428 | struct list_tokens *list_tokens) { | 428 | struct list_tokens *list_tokens) { |
429 | if (criteria_test(container, list_tokens->tokens)) { | 429 | if (criteria_test(container, list_tokens->tokens)) { |
430 | list_add(list_tokens->list, container); | 430 | list_add(list_tokens->list, container); |
@@ -435,8 +435,8 @@ list_t *container_for_crit_tokens(list_t *tokens) { | |||
435 | struct list_tokens list_tokens = | 435 | struct list_tokens list_tokens = |
436 | (struct list_tokens){create_list(), tokens}; | 436 | (struct list_tokens){create_list(), tokens}; |
437 | 437 | ||
438 | container_map(&root_container, | 438 | sway_container_for_each(&root_container, |
439 | (void (*)(swayc_t *, void *))container_match_add, | 439 | (void (*)(struct sway_container *, void *))container_match_add, |
440 | &list_tokens); | 440 | &list_tokens); |
441 | 441 | ||
442 | // TODO look in the scratchpad | 442 | // TODO look in the scratchpad |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index debda396..3e7d8509 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -145,7 +145,7 @@ struct render_data { | |||
145 | struct timespec *now; | 145 | struct timespec *now; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | static void output_frame_view(swayc_t *view, void *data) { | 148 | static void output_frame_view(struct sway_container *view, void *data) { |
149 | struct render_data *rdata = data; | 149 | struct render_data *rdata = data; |
150 | struct sway_output *output = rdata->output; | 150 | struct sway_output *output = rdata->output; |
151 | struct timespec *now = rdata->now; | 151 | struct timespec *now = rdata->now; |
@@ -218,16 +218,16 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { | |||
218 | &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); | 218 | &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); |
219 | 219 | ||
220 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 220 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
221 | swayc_t *focus = sway_seat_get_focus_inactive(seat, soutput->swayc); | 221 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, soutput->swayc); |
222 | swayc_t *workspace = (focus->type == C_WORKSPACE ? | 222 | struct sway_container *workspace = (focus->type == C_WORKSPACE ? |
223 | focus : | 223 | focus : |
224 | swayc_parent_by_type(focus, C_WORKSPACE)); | 224 | sway_container_parent(focus, C_WORKSPACE)); |
225 | 225 | ||
226 | struct render_data rdata = { | 226 | struct render_data rdata = { |
227 | .output = soutput, | 227 | .output = soutput, |
228 | .now = &now, | 228 | .now = &now, |
229 | }; | 229 | }; |
230 | swayc_descendants_of_type(workspace, C_VIEW, output_frame_view, &rdata); | 230 | sway_container_descendents(workspace, C_VIEW, output_frame_view, &rdata); |
231 | 231 | ||
232 | // render unmanaged views on top | 232 | // render unmanaged views on top |
233 | struct sway_view *view; | 233 | struct sway_view *view; |
@@ -258,7 +258,7 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) { | |||
258 | struct wlr_output *wlr_output = data; | 258 | struct wlr_output *wlr_output = data; |
259 | wlr_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name); | 259 | wlr_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name); |
260 | 260 | ||
261 | destroy_output(output->swayc); | 261 | sway_container_output_destroy(output->swayc); |
262 | } | 262 | } |
263 | 263 | ||
264 | static void handle_output_mode(struct wl_listener *listener, void *data) { | 264 | static void handle_output_mode(struct wl_listener *listener, void *data) { |
@@ -286,7 +286,7 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
286 | wlr_output_set_mode(wlr_output, mode); | 286 | wlr_output_set_mode(wlr_output, mode); |
287 | } | 287 | } |
288 | 288 | ||
289 | output->swayc = new_output(output); | 289 | output->swayc = sway_container_output_create(output); |
290 | if (!output->swayc) { | 290 | if (!output->swayc) { |
291 | free(output); | 291 | free(output); |
292 | return; | 292 | return; |
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index bb97fad4..bf41d7bf 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -74,7 +74,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
74 | wl_container_of(listener, sway_surface, destroy); | 74 | wl_container_of(listener, sway_surface, destroy); |
75 | wl_list_remove(&sway_surface->commit.link); | 75 | wl_list_remove(&sway_surface->commit.link); |
76 | wl_list_remove(&sway_surface->destroy.link); | 76 | wl_list_remove(&sway_surface->destroy.link); |
77 | swayc_t *parent = destroy_view(sway_surface->view->swayc); | 77 | struct sway_container *parent = sway_container_view_destroy(sway_surface->view->swayc); |
78 | free(sway_surface->view); | 78 | free(sway_surface->view); |
79 | free(sway_surface); | 79 | free(sway_surface); |
80 | arrange_windows(parent, -1, -1); | 80 | arrange_windows(parent, -1, -1); |
@@ -132,8 +132,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { | |||
132 | wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); | 132 | wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); |
133 | 133 | ||
134 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 134 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
135 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 135 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
136 | swayc_t *cont = new_view(focus, sway_view); | 136 | struct sway_container *cont = sway_container_view_create(focus, sway_view); |
137 | sway_view->swayc = cont; | 137 | sway_view->swayc = cont; |
138 | 138 | ||
139 | arrange_windows(cont->parent, -1, -1); | 139 | arrange_windows(cont->parent, -1, -1); |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 25ffacbb..6b50d470 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -83,7 +83,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
83 | wl_container_of(listener, sway_xdg_surface, destroy); | 83 | wl_container_of(listener, sway_xdg_surface, destroy); |
84 | wl_list_remove(&sway_xdg_surface->commit.link); | 84 | wl_list_remove(&sway_xdg_surface->commit.link); |
85 | wl_list_remove(&sway_xdg_surface->destroy.link); | 85 | wl_list_remove(&sway_xdg_surface->destroy.link); |
86 | swayc_t *parent = destroy_view(sway_xdg_surface->view->swayc); | 86 | struct sway_container *parent = sway_container_view_destroy(sway_xdg_surface->view->swayc); |
87 | free(sway_xdg_surface->view); | 87 | free(sway_xdg_surface->view); |
88 | free(sway_xdg_surface); | 88 | free(sway_xdg_surface); |
89 | arrange_windows(parent, -1, -1); | 89 | arrange_windows(parent, -1, -1); |
@@ -136,8 +136,8 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
136 | wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); | 136 | wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); |
137 | 137 | ||
138 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 138 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
139 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 139 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
140 | swayc_t *cont = new_view(focus, sway_view); | 140 | struct sway_container *cont = sway_container_view_create(focus, sway_view); |
141 | sway_view->swayc = cont; | 141 | sway_view->swayc = cont; |
142 | 142 | ||
143 | arrange_windows(cont->parent, -1, -1); | 143 | arrange_windows(cont->parent, -1, -1); |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 7f66f746..96edab51 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -49,11 +49,11 @@ static void set_position(struct sway_view *view, double ox, double oy) { | |||
49 | if (!assert_xwayland(view)) { | 49 | if (!assert_xwayland(view)) { |
50 | return; | 50 | return; |
51 | } | 51 | } |
52 | swayc_t *output = swayc_parent_by_type(view->swayc, C_OUTPUT); | 52 | struct sway_container *output = sway_container_parent(view->swayc, C_OUTPUT); |
53 | if (!sway_assert(output, "view must be within tree to set position")) { | 53 | if (!sway_assert(output, "view must be within tree to set position")) { |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | swayc_t *root = swayc_parent_by_type(output, C_ROOT); | 56 | struct sway_container *root = sway_container_parent(output, C_ROOT); |
57 | if (!sway_assert(root, "output must be within tree to set position")) { | 57 | if (!sway_assert(root, "output must be within tree to set position")) { |
58 | return; | 58 | return; |
59 | } | 59 | } |
@@ -114,7 +114,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | swayc_t *parent = destroy_view(sway_surface->view->swayc); | 117 | struct sway_container *parent = sway_container_view_destroy(sway_surface->view->swayc); |
118 | if (parent) { | 118 | if (parent) { |
119 | arrange_windows(parent, -1, -1); | 119 | arrange_windows(parent, -1, -1); |
120 | } | 120 | } |
@@ -132,7 +132,7 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) { | |||
132 | } | 132 | } |
133 | 133 | ||
134 | // take it out of the tree | 134 | // take it out of the tree |
135 | swayc_t *parent = destroy_view(sway_surface->view->swayc); | 135 | struct sway_container *parent = sway_container_view_destroy(sway_surface->view->swayc); |
136 | if (parent) { | 136 | if (parent) { |
137 | arrange_windows(parent, -1, -1); | 137 | arrange_windows(parent, -1, -1); |
138 | } | 138 | } |
@@ -155,12 +155,12 @@ static void handle_map_notify(struct wl_listener *listener, void *data) { | |||
155 | &sway_surface->view->unmanaged_view_link); | 155 | &sway_surface->view->unmanaged_view_link); |
156 | } else { | 156 | } else { |
157 | struct sway_view *view = sway_surface->view; | 157 | struct sway_view *view = sway_surface->view; |
158 | destroy_view(view->swayc); | 158 | sway_container_view_destroy(view->swayc); |
159 | 159 | ||
160 | swayc_t *parent = root_container.children->items[0]; | 160 | struct sway_container *parent = root_container.children->items[0]; |
161 | parent = parent->children->items[0]; // workspace | 161 | parent = parent->children->items[0]; // workspace |
162 | 162 | ||
163 | swayc_t *cont = new_view(parent, view); | 163 | struct sway_container *cont = sway_container_view_create(parent, view); |
164 | view->swayc = cont; | 164 | view->swayc = cont; |
165 | 165 | ||
166 | arrange_windows(cont->parent, -1, -1); | 166 | arrange_windows(cont->parent, -1, -1); |
@@ -238,8 +238,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
238 | } | 238 | } |
239 | 239 | ||
240 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 240 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
241 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 241 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
242 | swayc_t *cont = new_view(focus, sway_view); | 242 | struct sway_container *cont = sway_container_view_create(focus, sway_view); |
243 | sway_view->swayc = cont; | 243 | sway_view->swayc = cont; |
244 | 244 | ||
245 | arrange_windows(cont->parent, -1, -1); | 245 | arrange_windows(cont->parent, -1, -1); |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index c0e14265..a0e4b9be 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -49,8 +49,8 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | swayc_t *swayc = | 52 | struct sway_container *swayc = |
53 | swayc_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy); | 53 | sway_container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy); |
54 | if (swayc) { | 54 | if (swayc) { |
55 | wlr_seat_pointer_notify_enter(seat, surface, sx, sy); | 55 | wlr_seat_pointer_notify_enter(seat, surface, sx, sy); |
56 | wlr_seat_pointer_notify_motion(seat, time, sx, sy); | 56 | wlr_seat_pointer_notify_motion(seat, time, sx, sy); |
@@ -87,8 +87,8 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
87 | if (event->button == BTN_LEFT) { | 87 | if (event->button == BTN_LEFT) { |
88 | struct wlr_surface *surface = NULL; | 88 | struct wlr_surface *surface = NULL; |
89 | double sx, sy; | 89 | double sx, sy; |
90 | swayc_t *swayc = | 90 | struct sway_container *swayc = |
91 | swayc_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy); | 91 | sway_container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy); |
92 | 92 | ||
93 | sway_seat_set_focus(cursor->seat, swayc); | 93 | sway_seat_set_focus(cursor->seat, swayc); |
94 | } | 94 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 56b39766..f03a03b4 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -37,7 +37,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
37 | struct sway_seat_container *seat_con = | 37 | struct sway_seat_container *seat_con = |
38 | wl_container_of(listener, seat_con, destroy); | 38 | wl_container_of(listener, seat_con, destroy); |
39 | struct sway_seat *seat = seat_con->seat; | 39 | struct sway_seat *seat = seat_con->seat; |
40 | swayc_t *con = seat_con->container; | 40 | struct sway_container *con = seat_con->container; |
41 | 41 | ||
42 | bool is_focus = (sway_seat_get_focus(seat) == con); | 42 | bool is_focus = (sway_seat_get_focus(seat) == con); |
43 | 43 | ||
@@ -46,7 +46,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
46 | if (is_focus) { | 46 | if (is_focus) { |
47 | // pick next focus | 47 | // pick next focus |
48 | sway_seat_set_focus(seat, NULL); | 48 | sway_seat_set_focus(seat, NULL); |
49 | swayc_t *next = sway_seat_get_focus_inactive(seat, con->parent); | 49 | struct sway_container *next = sway_seat_get_focus_inactive(seat, con->parent); |
50 | if (next == NULL) { | 50 | if (next == NULL) { |
51 | next = con->parent; | 51 | next = con->parent; |
52 | } | 52 | } |
@@ -59,7 +59,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
59 | } | 59 | } |
60 | 60 | ||
61 | static struct sway_seat_container *seat_container_from_container( | 61 | static struct sway_seat_container *seat_container_from_container( |
62 | struct sway_seat *seat, swayc_t *con) { | 62 | struct sway_seat *seat, struct sway_container *con) { |
63 | if (con->type < C_WORKSPACE) { | 63 | if (con->type < C_WORKSPACE) { |
64 | // these don't get seat containers ever | 64 | // these don't get seat containers ever |
65 | return NULL; | 65 | return NULL; |
@@ -89,11 +89,11 @@ static struct sway_seat_container *seat_container_from_container( | |||
89 | 89 | ||
90 | static void handle_new_container(struct wl_listener *listener, void *data) { | 90 | static void handle_new_container(struct wl_listener *listener, void *data) { |
91 | struct sway_seat *seat = wl_container_of(listener, seat, new_container); | 91 | struct sway_seat *seat = wl_container_of(listener, seat, new_container); |
92 | swayc_t *con = data; | 92 | struct sway_container *con = data; |
93 | seat_container_from_container(seat, con); | 93 | seat_container_from_container(seat, con); |
94 | } | 94 | } |
95 | 95 | ||
96 | static void collect_focus_iter(swayc_t *con, void *data) { | 96 | static void collect_focus_iter(struct sway_container *con, void *data) { |
97 | struct sway_seat *seat = data; | 97 | struct sway_seat *seat = data; |
98 | if (con->type > C_WORKSPACE) { | 98 | if (con->type > C_WORKSPACE) { |
99 | return; | 99 | return; |
@@ -130,7 +130,7 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
130 | // init the focus stack | 130 | // init the focus stack |
131 | wl_list_init(&seat->focus_stack); | 131 | wl_list_init(&seat->focus_stack); |
132 | 132 | ||
133 | container_for_each_bfs(&root_container, collect_focus_iter, seat); | 133 | sway_container_for_each_bfs(&root_container, collect_focus_iter, seat); |
134 | 134 | ||
135 | wl_signal_add(&root_container.sway_root->events.new_container, | 135 | wl_signal_add(&root_container.sway_root->events.new_container, |
136 | &seat->new_container); | 136 | &seat->new_container); |
@@ -166,7 +166,7 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
166 | sway_keyboard_configure(seat_device->keyboard); | 166 | sway_keyboard_configure(seat_device->keyboard); |
167 | wlr_seat_set_keyboard(seat->wlr_seat, | 167 | wlr_seat_set_keyboard(seat->wlr_seat, |
168 | seat_device->input_device->wlr_device); | 168 | seat_device->input_device->wlr_device); |
169 | swayc_t *focus = sway_seat_get_focus(seat); | 169 | struct sway_container *focus = sway_seat_get_focus(seat); |
170 | if (focus && focus->type == C_VIEW) { | 170 | if (focus && focus->type == C_VIEW) { |
171 | // force notify reenter to pick up the new configuration | 171 | // force notify reenter to pick up the new configuration |
172 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | 172 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); |
@@ -270,7 +270,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
270 | } | 270 | } |
271 | 271 | ||
272 | for (int i = 0; i < root_container.children->length; ++i) { | 272 | for (int i = 0; i < root_container.children->length; ++i) { |
273 | swayc_t *output_container = root_container.children->items[i]; | 273 | struct sway_container *output_container = root_container.children->items[i]; |
274 | struct wlr_output *output = | 274 | struct wlr_output *output = |
275 | output_container->sway_output->wlr_output; | 275 | output_container->sway_output->wlr_output; |
276 | bool result = | 276 | bool result = |
@@ -289,8 +289,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
289 | seat->cursor->cursor->y); | 289 | seat->cursor->cursor->y); |
290 | } | 290 | } |
291 | 291 | ||
292 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | 292 | void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container) { |
293 | swayc_t *last_focus = sway_seat_get_focus(seat); | 293 | struct sway_container *last_focus = sway_seat_get_focus(seat); |
294 | 294 | ||
295 | if (container && last_focus == container) { | 295 | if (container && last_focus == container) { |
296 | return; | 296 | return; |
@@ -330,9 +330,9 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { | |||
330 | seat->has_focus = (container != NULL); | 330 | seat->has_focus = (container != NULL); |
331 | } | 331 | } |
332 | 332 | ||
333 | swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container) { | 333 | struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { |
334 | struct sway_seat_container *current = NULL; | 334 | struct sway_seat_container *current = NULL; |
335 | swayc_t *parent = NULL; | 335 | struct sway_container *parent = NULL; |
336 | wl_list_for_each(current, &seat->focus_stack, link) { | 336 | wl_list_for_each(current, &seat->focus_stack, link) { |
337 | parent = current->container->parent; | 337 | parent = current->container->parent; |
338 | 338 | ||
@@ -351,21 +351,21 @@ swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container | |||
351 | return NULL; | 351 | return NULL; |
352 | } | 352 | } |
353 | 353 | ||
354 | swayc_t *sway_seat_get_focus(struct sway_seat *seat) { | 354 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { |
355 | if (!seat->has_focus) { | 355 | if (!seat->has_focus) { |
356 | return NULL; | 356 | return NULL; |
357 | } | 357 | } |
358 | return sway_seat_get_focus_inactive(seat, &root_container); | 358 | return sway_seat_get_focus_inactive(seat, &root_container); |
359 | } | 359 | } |
360 | 360 | ||
361 | swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat, | 361 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, |
362 | enum swayc_types type) { | 362 | enum sway_container_type type) { |
363 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 363 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
364 | if (focus->type == type) { | 364 | if (focus->type == type) { |
365 | return focus; | 365 | return focus; |
366 | } | 366 | } |
367 | 367 | ||
368 | return swayc_parent_by_type(focus, type); | 368 | return sway_container_parent(focus, type); |
369 | } | 369 | } |
370 | 370 | ||
371 | void sway_seat_set_config(struct sway_seat *seat, | 371 | void sway_seat_set_config(struct sway_seat *seat, |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index ebd5e43a..7caa2457 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -25,7 +25,7 @@ json_object *ipc_json_get_version() { | |||
25 | return version; | 25 | return version; |
26 | } | 26 | } |
27 | 27 | ||
28 | static json_object *ipc_json_create_rect(swayc_t *c) { | 28 | static json_object *ipc_json_create_rect(struct sway_container *c) { |
29 | json_object *rect = json_object_new_object(); | 29 | json_object *rect = json_object_new_object(); |
30 | 30 | ||
31 | json_object_object_add(rect, "x", json_object_new_int((int32_t)c->x)); | 31 | json_object_object_add(rect, "x", json_object_new_int((int32_t)c->x)); |
@@ -36,7 +36,7 @@ static json_object *ipc_json_create_rect(swayc_t *c) { | |||
36 | return rect; | 36 | return rect; |
37 | } | 37 | } |
38 | 38 | ||
39 | static void ipc_json_describe_root(swayc_t *root, json_object *object) { | 39 | static void ipc_json_describe_root(struct sway_container *root, json_object *object) { |
40 | json_object_object_add(object, "type", json_object_new_string("root")); | 40 | json_object_object_add(object, "type", json_object_new_string("root")); |
41 | json_object_object_add(object, "layout", json_object_new_string("splith")); | 41 | json_object_object_add(object, "layout", json_object_new_string("splith")); |
42 | } | 42 | } |
@@ -63,7 +63,7 @@ static const char *ipc_json_get_output_transform(enum wl_output_transform transf | |||
63 | return NULL; | 63 | return NULL; |
64 | } | 64 | } |
65 | 65 | ||
66 | static void ipc_json_describe_output(swayc_t *container, json_object *object) { | 66 | static void ipc_json_describe_output(struct sway_container *container, json_object *object) { |
67 | struct wlr_output *wlr_output = container->sway_output->wlr_output; | 67 | struct wlr_output *wlr_output = container->sway_output->wlr_output; |
68 | json_object_object_add(object, "type", json_object_new_string("output")); | 68 | json_object_object_add(object, "type", json_object_new_string("output")); |
69 | json_object_object_add(object, "active", json_object_new_boolean(true)); | 69 | json_object_object_add(object, "active", json_object_new_boolean(true)); |
@@ -94,7 +94,7 @@ static void ipc_json_describe_output(swayc_t *container, json_object *object) { | |||
94 | json_object_object_add(object, "modes", modes_array); | 94 | json_object_object_add(object, "modes", modes_array); |
95 | } | 95 | } |
96 | 96 | ||
97 | static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { | 97 | static void ipc_json_describe_workspace(struct sway_container *workspace, json_object *object) { |
98 | int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1; | 98 | int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1; |
99 | 99 | ||
100 | json_object_object_add(object, "num", json_object_new_int(num)); | 100 | json_object_object_add(object, "num", json_object_new_int(num)); |
@@ -102,11 +102,11 @@ static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) | |||
102 | json_object_object_add(object, "type", json_object_new_string("workspace")); | 102 | json_object_object_add(object, "type", json_object_new_string("workspace")); |
103 | } | 103 | } |
104 | 104 | ||
105 | static void ipc_json_describe_view(swayc_t *c, json_object *object) { | 105 | static void ipc_json_describe_view(struct sway_container *c, json_object *object) { |
106 | json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL); | 106 | json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL); |
107 | } | 107 | } |
108 | 108 | ||
109 | json_object *ipc_json_describe_container(swayc_t *c) { | 109 | json_object *ipc_json_describe_container(struct sway_container *c) { |
110 | if (!(sway_assert(c, "Container must not be null."))) { | 110 | if (!(sway_assert(c, "Container must not be null."))) { |
111 | return NULL; | 111 | return NULL; |
112 | } | 112 | } |
@@ -147,7 +147,7 @@ json_object *ipc_json_describe_container(swayc_t *c) { | |||
147 | return object; | 147 | return object; |
148 | } | 148 | } |
149 | 149 | ||
150 | json_object *ipc_json_describe_container_recursive(swayc_t *c) { | 150 | json_object *ipc_json_describe_container_recursive(struct sway_container *c) { |
151 | json_object *object = ipc_json_describe_container(c); | 151 | json_object *object = ipc_json_describe_container(c); |
152 | int i; | 152 | int i; |
153 | 153 | ||
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 156de380..50d0bcf3 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -279,7 +279,7 @@ static void ipc_send_event(const char *json_string, enum ipc_command_type event) | |||
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | void ipc_event_window(swayc_t *window, const char *change) { | 282 | void ipc_event_window(struct sway_container *window, const char *change) { |
283 | wlr_log(L_DEBUG, "Sending window::%s event", change); | 283 | wlr_log(L_DEBUG, "Sending window::%s event", change); |
284 | json_object *obj = json_object_new_object(); | 284 | json_object *obj = json_object_new_object(); |
285 | json_object_object_add(obj, "change", json_object_new_string(change)); | 285 | json_object_object_add(obj, "change", json_object_new_string(change)); |
@@ -400,7 +400,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
400 | { | 400 | { |
401 | json_object *outputs = json_object_new_array(); | 401 | json_object *outputs = json_object_new_array(); |
402 | for (int i = 0; i < root_container.children->length; ++i) { | 402 | for (int i = 0; i < root_container.children->length; ++i) { |
403 | swayc_t *container = root_container.children->items[i]; | 403 | struct sway_container *container = root_container.children->items[i]; |
404 | if (container->type == C_OUTPUT) { | 404 | if (container->type == C_OUTPUT) { |
405 | json_object_array_add(outputs, | 405 | json_object_array_add(outputs, |
406 | ipc_json_describe_container(container)); | 406 | ipc_json_describe_container(container)); |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 805d5644..d31966b3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -33,48 +33,15 @@ static list_t *get_bfs_queue() { | |||
33 | return bfs_queue; | 33 | return bfs_queue; |
34 | } | 34 | } |
35 | 35 | ||
36 | static void notify_new_container(swayc_t *container) { | 36 | static void notify_new_container(struct sway_container *container) { |
37 | wl_signal_emit(&root_container.sway_root->events.new_container, container); | 37 | wl_signal_emit(&root_container.sway_root->events.new_container, container); |
38 | ipc_event_window(container, "new"); | 38 | ipc_event_window(container, "new"); |
39 | } | 39 | } |
40 | 40 | ||
41 | swayc_t *swayc_by_test(swayc_t *container, | 41 | static struct sway_container *new_swayc(enum sway_container_type type) { |
42 | bool (*test)(swayc_t *view, void *data), void *data) { | ||
43 | if (!container->children) { | ||
44 | return NULL; | ||
45 | } | ||
46 | // TODO: floating windows | ||
47 | for (int i = 0; i < container->children->length; ++i) { | ||
48 | swayc_t *child = container->children->items[i]; | ||
49 | if (test(child, data)) { | ||
50 | return child; | ||
51 | } else { | ||
52 | swayc_t *res = swayc_by_test(child, test, data); | ||
53 | if (res) { | ||
54 | return res; | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | return NULL; | ||
59 | } | ||
60 | |||
61 | void swayc_descendants_of_type(swayc_t *root, enum swayc_types type, | ||
62 | void (*func)(swayc_t *item, void *data), void *data) { | ||
63 | for (int i = 0; i < root->children->length; ++i) { | ||
64 | swayc_t *item = root->children->items[i]; | ||
65 | if (item->type == type) { | ||
66 | func(item, data); | ||
67 | } | ||
68 | if (item->children && item->children->length) { | ||
69 | swayc_descendants_of_type(item, type, func, data); | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | |||
74 | static swayc_t *new_swayc(enum swayc_types type) { | ||
75 | // next id starts at 1 because 0 is assigned to root_container in layout.c | 42 | // next id starts at 1 because 0 is assigned to root_container in layout.c |
76 | static size_t next_id = 1; | 43 | static size_t next_id = 1; |
77 | swayc_t *c = calloc(1, sizeof(swayc_t)); | 44 | struct sway_container *c = calloc(1, sizeof(struct sway_container)); |
78 | if (!c) { | 45 | if (!c) { |
79 | return NULL; | 46 | return NULL; |
80 | } | 47 | } |
@@ -91,7 +58,7 @@ static swayc_t *new_swayc(enum swayc_types type) { | |||
91 | return c; | 58 | return c; |
92 | } | 59 | } |
93 | 60 | ||
94 | static void free_swayc(swayc_t *cont) { | 61 | static void free_swayc(struct sway_container *cont) { |
95 | if (!sway_assert(cont, "free_swayc passed NULL")) { | 62 | if (!sway_assert(cont, "free_swayc passed NULL")) { |
96 | return; | 63 | return; |
97 | } | 64 | } |
@@ -119,7 +86,7 @@ static void free_swayc(swayc_t *cont) { | |||
119 | free(cont); | 86 | free(cont); |
120 | } | 87 | } |
121 | 88 | ||
122 | swayc_t *new_output(struct sway_output *sway_output) { | 89 | struct sway_container *sway_container_output_create(struct sway_output *sway_output) { |
123 | struct wlr_box size; | 90 | struct wlr_box size; |
124 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, | 91 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, |
125 | &size.height); | 92 | &size.height); |
@@ -154,7 +121,7 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
154 | return NULL; | 121 | return NULL; |
155 | } | 122 | } |
156 | 123 | ||
157 | swayc_t *output = new_swayc(C_OUTPUT); | 124 | struct sway_container *output = new_swayc(C_OUTPUT); |
158 | output->sway_output = sway_output; | 125 | output->sway_output = sway_output; |
159 | output->name = strdup(name); | 126 | output->name = strdup(name); |
160 | if (output->name == NULL) { | 127 | if (output->name == NULL) { |
@@ -169,7 +136,7 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
169 | // Create workspace | 136 | // Create workspace |
170 | char *ws_name = workspace_next_name(output->name); | 137 | char *ws_name = workspace_next_name(output->name); |
171 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); | 138 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); |
172 | swayc_t *ws = new_workspace(output, ws_name); | 139 | struct sway_container *ws = sway_container_workspace_create(output, ws_name); |
173 | // Set each seat's focus if not already set | 140 | // Set each seat's focus if not already set |
174 | struct sway_seat *seat = NULL; | 141 | struct sway_seat *seat = NULL; |
175 | wl_list_for_each(seat, &input_manager->seats, link) { | 142 | wl_list_for_each(seat, &input_manager->seats, link) { |
@@ -183,12 +150,12 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
183 | return output; | 150 | return output; |
184 | } | 151 | } |
185 | 152 | ||
186 | swayc_t *new_workspace(swayc_t *output, const char *name) { | 153 | struct sway_container *sway_container_workspace_create(struct sway_container *output, const char *name) { |
187 | if (!sway_assert(output, "new_workspace called with null output")) { | 154 | if (!sway_assert(output, "sway_container_workspace_create called with null output")) { |
188 | return NULL; | 155 | return NULL; |
189 | } | 156 | } |
190 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); | 157 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); |
191 | swayc_t *workspace = new_swayc(C_WORKSPACE); | 158 | struct sway_container *workspace = new_swayc(C_WORKSPACE); |
192 | 159 | ||
193 | workspace->x = output->x; | 160 | workspace->x = output->x; |
194 | workspace->y = output->y; | 161 | workspace->y = output->y; |
@@ -205,12 +172,12 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { | |||
205 | return workspace; | 172 | return workspace; |
206 | } | 173 | } |
207 | 174 | ||
208 | swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) { | 175 | struct sway_container *sway_container_view_create(struct sway_container *sibling, struct sway_view *sway_view) { |
209 | if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) { | 176 | if (!sway_assert(sibling, "sway_container_view_create called with NULL sibling/parent")) { |
210 | return NULL; | 177 | return NULL; |
211 | } | 178 | } |
212 | const char *title = view_get_title(sway_view); | 179 | const char *title = view_get_title(sway_view); |
213 | swayc_t *swayc = new_swayc(C_VIEW); | 180 | struct sway_container *swayc = new_swayc(C_VIEW); |
214 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s", | 181 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s", |
215 | swayc, title, sibling, sibling ? sibling->type : 0, sibling->name); | 182 | swayc, title, sibling, sibling ? sibling->type : 0, sibling->name); |
216 | // Setup values | 183 | // Setup values |
@@ -230,8 +197,8 @@ swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) { | |||
230 | return swayc; | 197 | return swayc; |
231 | } | 198 | } |
232 | 199 | ||
233 | swayc_t *destroy_output(swayc_t *output) { | 200 | struct sway_container *sway_container_output_destroy(struct sway_container *output) { |
234 | if (!sway_assert(output, "null output passed to destroy_output")) { | 201 | if (!sway_assert(output, "null output passed to sway_container_output_destroy")) { |
235 | return NULL; | 202 | return NULL; |
236 | } | 203 | } |
237 | 204 | ||
@@ -243,7 +210,7 @@ swayc_t *destroy_output(swayc_t *output) { | |||
243 | int p = root_container.children->items[0] == output; | 210 | int p = root_container.children->items[0] == output; |
244 | // Move workspace from this output to another output | 211 | // Move workspace from this output to another output |
245 | while (output->children->length) { | 212 | while (output->children->length) { |
246 | swayc_t *child = output->children->items[0]; | 213 | struct sway_container *child = output->children->items[0]; |
247 | remove_child(child); | 214 | remove_child(child); |
248 | add_child(root_container.children->items[p], child); | 215 | add_child(root_container.children->items[p], child); |
249 | } | 216 | } |
@@ -262,12 +229,12 @@ swayc_t *destroy_output(swayc_t *output) { | |||
262 | return &root_container; | 229 | return &root_container; |
263 | } | 230 | } |
264 | 231 | ||
265 | swayc_t *destroy_view(swayc_t *view) { | 232 | struct sway_container *sway_container_view_destroy(struct sway_container *view) { |
266 | if (!view) { | 233 | if (!view) { |
267 | return NULL; | 234 | return NULL; |
268 | } | 235 | } |
269 | wlr_log(L_DEBUG, "Destroying view '%s'", view->name); | 236 | wlr_log(L_DEBUG, "Destroying view '%s'", view->name); |
270 | swayc_t *parent = view->parent; | 237 | struct sway_container *parent = view->parent; |
271 | free_swayc(view); | 238 | free_swayc(view); |
272 | 239 | ||
273 | // TODO WLR: Destroy empty containers | 240 | // TODO WLR: Destroy empty containers |
@@ -279,7 +246,52 @@ swayc_t *destroy_view(swayc_t *view) { | |||
279 | return parent; | 246 | return parent; |
280 | } | 247 | } |
281 | 248 | ||
282 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { | 249 | struct sway_container *swayc_change_layout(struct sway_container *container, enum sway_container_layout layout) { |
250 | if (container->type == C_WORKSPACE) { | ||
251 | container->workspace_layout = layout; | ||
252 | if (layout == L_HORIZ || layout == L_VERT) { | ||
253 | container->layout = layout; | ||
254 | } | ||
255 | } else { | ||
256 | container->layout = layout; | ||
257 | } | ||
258 | return container; | ||
259 | } | ||
260 | |||
261 | void sway_container_descendents(struct sway_container *root, enum sway_container_type type, | ||
262 | void (*func)(struct sway_container *item, void *data), void *data) { | ||
263 | for (int i = 0; i < root->children->length; ++i) { | ||
264 | struct sway_container *item = root->children->items[i]; | ||
265 | if (item->type == type) { | ||
266 | func(item, data); | ||
267 | } | ||
268 | if (item->children && item->children->length) { | ||
269 | sway_container_descendents(item, type, func, data); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | struct sway_container *sway_container_find(struct sway_container *container, | ||
275 | bool (*test)(struct sway_container *view, void *data), void *data) { | ||
276 | if (!container->children) { | ||
277 | return NULL; | ||
278 | } | ||
279 | // TODO: floating windows | ||
280 | for (int i = 0; i < container->children->length; ++i) { | ||
281 | struct sway_container *child = container->children->items[i]; | ||
282 | if (test(child, data)) { | ||
283 | return child; | ||
284 | } else { | ||
285 | struct sway_container *res = sway_container_find(child, test, data); | ||
286 | if (res) { | ||
287 | return res; | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | return NULL; | ||
292 | } | ||
293 | |||
294 | struct sway_container *sway_container_parent(struct sway_container *container, enum sway_container_type type) { | ||
283 | if (!sway_assert(container, "container is NULL")) { | 295 | if (!sway_assert(container, "container is NULL")) { |
284 | return NULL; | 296 | return NULL; |
285 | } | 297 | } |
@@ -292,7 +304,29 @@ swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { | |||
292 | return container; | 304 | return container; |
293 | } | 305 | } |
294 | 306 | ||
295 | swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | 307 | void sway_container_for_each(struct sway_container *container, void (*f)(struct sway_container *view, void *data), void *data) { |
308 | if (container) { | ||
309 | int i; | ||
310 | if (container->children) { | ||
311 | for (i = 0; i < container->children->length; ++i) { | ||
312 | struct sway_container *child = container->children->items[i]; | ||
313 | sway_container_for_each(child, f, data); | ||
314 | } | ||
315 | } | ||
316 | // TODO | ||
317 | /* | ||
318 | if (container->floating) { | ||
319 | for (i = 0; i < container->floating->length; ++i) { | ||
320 | struct sway_container *child = container->floating->items[i]; | ||
321 | container_map(child, f, data); | ||
322 | } | ||
323 | } | ||
324 | */ | ||
325 | f(container, data); | ||
326 | } | ||
327 | } | ||
328 | |||
329 | struct sway_container *sway_container_at(struct sway_container *parent, double lx, double ly, | ||
296 | struct wlr_surface **surface, double *sx, double *sy) { | 330 | struct wlr_surface **surface, double *sx, double *sy) { |
297 | list_t *queue = get_bfs_queue(); | 331 | list_t *queue = get_bfs_queue(); |
298 | if (!queue) { | 332 | if (!queue) { |
@@ -301,13 +335,13 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | |||
301 | 335 | ||
302 | list_add(queue, parent); | 336 | list_add(queue, parent); |
303 | 337 | ||
304 | swayc_t *swayc = NULL; | 338 | struct sway_container *swayc = NULL; |
305 | while (queue->length) { | 339 | while (queue->length) { |
306 | swayc = queue->items[0]; | 340 | swayc = queue->items[0]; |
307 | list_del(queue, 0); | 341 | list_del(queue, 0); |
308 | if (swayc->type == C_VIEW) { | 342 | if (swayc->type == C_VIEW) { |
309 | struct sway_view *sview = swayc->sway_view; | 343 | struct sway_view *sview = swayc->sway_view; |
310 | swayc_t *soutput = swayc_parent_by_type(swayc, C_OUTPUT); | 344 | struct sway_container *soutput = sway_container_parent(swayc, C_OUTPUT); |
311 | struct wlr_box *output_box = | 345 | struct wlr_box *output_box = |
312 | wlr_output_layout_get_box( | 346 | wlr_output_layout_get_box( |
313 | root_container.sway_root->output_layout, | 347 | root_container.sway_root->output_layout, |
@@ -377,29 +411,7 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | |||
377 | return NULL; | 411 | return NULL; |
378 | } | 412 | } |
379 | 413 | ||
380 | void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) { | 414 | void sway_container_for_each_bfs(struct sway_container *con, void (*f)(struct sway_container *con, void *data), |
381 | if (container) { | ||
382 | int i; | ||
383 | if (container->children) { | ||
384 | for (i = 0; i < container->children->length; ++i) { | ||
385 | swayc_t *child = container->children->items[i]; | ||
386 | container_map(child, f, data); | ||
387 | } | ||
388 | } | ||
389 | // TODO | ||
390 | /* | ||
391 | if (container->floating) { | ||
392 | for (i = 0; i < container->floating->length; ++i) { | ||
393 | swayc_t *child = container->floating->items[i]; | ||
394 | container_map(child, f, data); | ||
395 | } | ||
396 | } | ||
397 | */ | ||
398 | f(container, data); | ||
399 | } | ||
400 | } | ||
401 | |||
402 | void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | ||
403 | void *data) { | 415 | void *data) { |
404 | list_t *queue = get_bfs_queue(); | 416 | list_t *queue = get_bfs_queue(); |
405 | if (!queue) { | 417 | if (!queue) { |
@@ -413,7 +425,7 @@ void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | |||
413 | 425 | ||
414 | list_add(queue, con); | 426 | list_add(queue, con); |
415 | 427 | ||
416 | swayc_t *current = NULL; | 428 | struct sway_container *current = NULL; |
417 | while (queue->length) { | 429 | while (queue->length) { |
418 | current = queue->items[0]; | 430 | current = queue->items[0]; |
419 | list_del(queue, 0); | 431 | list_del(queue, 0); |
@@ -422,15 +434,3 @@ void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | |||
422 | list_cat(queue, current->children); | 434 | list_cat(queue, current->children); |
423 | } | 435 | } |
424 | } | 436 | } |
425 | |||
426 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { | ||
427 | if (container->type == C_WORKSPACE) { | ||
428 | container->workspace_layout = layout; | ||
429 | if (layout == L_HORIZ || layout == L_VERT) { | ||
430 | container->layout = layout; | ||
431 | } | ||
432 | } else { | ||
433 | container->layout = layout; | ||
434 | } | ||
435 | return container; | ||
436 | } | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 5a15f3a2..068fb39c 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include "list.h" | 14 | #include "list.h" |
15 | #include "log.h" | 15 | #include "log.h" |
16 | 16 | ||
17 | swayc_t root_container; | 17 | struct sway_container root_container; |
18 | 18 | ||
19 | static void output_layout_change_notify(struct wl_listener *listener, void *data) { | 19 | static void output_layout_change_notify(struct wl_listener *listener, void *data) { |
20 | struct wlr_box *layout_box = wlr_output_layout_get_box( | 20 | struct wlr_box *layout_box = wlr_output_layout_get_box( |
@@ -23,7 +23,7 @@ static void output_layout_change_notify(struct wl_listener *listener, void *data | |||
23 | root_container.height = layout_box->height; | 23 | root_container.height = layout_box->height; |
24 | 24 | ||
25 | for (int i = 0 ; i < root_container.children->length; ++i) { | 25 | for (int i = 0 ; i < root_container.children->length; ++i) { |
26 | swayc_t *output_container = root_container.children->items[i]; | 26 | struct sway_container *output_container = root_container.children->items[i]; |
27 | if (output_container->type != C_OUTPUT) { | 27 | if (output_container->type != C_OUTPUT) { |
28 | continue; | 28 | continue; |
29 | } | 29 | } |
@@ -62,9 +62,9 @@ void init_layout(void) { | |||
62 | &root_container.sway_root->output_layout_change); | 62 | &root_container.sway_root->output_layout_change); |
63 | } | 63 | } |
64 | 64 | ||
65 | static int index_child(const swayc_t *child) { | 65 | static int index_child(const struct sway_container *child) { |
66 | // TODO handle floating | 66 | // TODO handle floating |
67 | swayc_t *parent = child->parent; | 67 | struct sway_container *parent = child->parent; |
68 | int i, len; | 68 | int i, len; |
69 | len = parent->children->length; | 69 | len = parent->children->length; |
70 | for (i = 0; i < len; ++i) { | 70 | for (i = 0; i < len; ++i) { |
@@ -79,16 +79,16 @@ static int index_child(const swayc_t *child) { | |||
79 | return i; | 79 | return i; |
80 | } | 80 | } |
81 | 81 | ||
82 | swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) { | 82 | struct sway_container *add_sibling(struct sway_container *fixed, struct sway_container *active) { |
83 | // TODO handle floating | 83 | // TODO handle floating |
84 | swayc_t *parent = fixed->parent; | 84 | struct sway_container *parent = fixed->parent; |
85 | int i = index_child(fixed); | 85 | int i = index_child(fixed); |
86 | list_insert(parent->children, i + 1, active); | 86 | list_insert(parent->children, i + 1, active); |
87 | active->parent = parent; | 87 | active->parent = parent; |
88 | return active->parent; | 88 | return active->parent; |
89 | } | 89 | } |
90 | 90 | ||
91 | void add_child(swayc_t *parent, swayc_t *child) { | 91 | void add_child(struct sway_container *parent, struct sway_container *child) { |
92 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", | 92 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", |
93 | child, child->type, child->width, child->height, | 93 | child, child->type, child->width, child->height, |
94 | parent, parent->type, parent->width, parent->height); | 94 | parent, parent->type, parent->width, parent->height); |
@@ -102,9 +102,9 @@ void add_child(swayc_t *parent, swayc_t *child) { | |||
102 | */ | 102 | */ |
103 | } | 103 | } |
104 | 104 | ||
105 | swayc_t *remove_child(swayc_t *child) { | 105 | struct sway_container *remove_child(struct sway_container *child) { |
106 | int i; | 106 | int i; |
107 | swayc_t *parent = child->parent; | 107 | struct sway_container *parent = child->parent; |
108 | for (i = 0; i < parent->children->length; ++i) { | 108 | for (i = 0; i < parent->children->length; ++i) { |
109 | if (parent->children->items[i] == child) { | 109 | if (parent->children->items[i] == child) { |
110 | list_del(parent->children, i); | 110 | list_del(parent->children, i); |
@@ -115,7 +115,7 @@ swayc_t *remove_child(swayc_t *child) { | |||
115 | return parent; | 115 | return parent; |
116 | } | 116 | } |
117 | 117 | ||
118 | enum swayc_layouts default_layout(swayc_t *output) { | 118 | enum sway_container_layout default_layout(struct sway_container *output) { |
119 | /* TODO WLR | 119 | /* TODO WLR |
120 | if (config->default_layout != L_NONE) { | 120 | if (config->default_layout != L_NONE) { |
121 | //return config->default_layout; | 121 | //return config->default_layout; |
@@ -129,8 +129,8 @@ enum swayc_layouts default_layout(swayc_t *output) { | |||
129 | } | 129 | } |
130 | 130 | ||
131 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | 131 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { |
132 | swayc_t *a = *(void **)_a; | 132 | struct sway_container *a = *(void **)_a; |
133 | swayc_t *b = *(void **)_b; | 133 | struct sway_container *b = *(void **)_b; |
134 | int retval = 0; | 134 | int retval = 0; |
135 | 135 | ||
136 | if (isdigit(a->name[0]) && isdigit(b->name[0])) { | 136 | if (isdigit(a->name[0]) && isdigit(b->name[0])) { |
@@ -146,21 +146,21 @@ static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | |||
146 | return retval; | 146 | return retval; |
147 | } | 147 | } |
148 | 148 | ||
149 | void sort_workspaces(swayc_t *output) { | 149 | void sort_workspaces(struct sway_container *output) { |
150 | list_stable_sort(output->children, sort_workspace_cmp_qsort); | 150 | list_stable_sort(output->children, sort_workspace_cmp_qsort); |
151 | } | 151 | } |
152 | 152 | ||
153 | static void apply_horiz_layout(swayc_t *container, const double x, | 153 | static void apply_horiz_layout(struct sway_container *container, const double x, |
154 | const double y, const double width, | 154 | const double y, const double width, |
155 | const double height, const int start, | 155 | const double height, const int start, |
156 | const int end); | 156 | const int end); |
157 | 157 | ||
158 | static void apply_vert_layout(swayc_t *container, const double x, | 158 | static void apply_vert_layout(struct sway_container *container, const double x, |
159 | const double y, const double width, | 159 | const double y, const double width, |
160 | const double height, const int start, | 160 | const double height, const int start, |
161 | const int end); | 161 | const int end); |
162 | 162 | ||
163 | void arrange_windows(swayc_t *container, double width, double height) { | 163 | void arrange_windows(struct sway_container *container, double width, double height) { |
164 | int i; | 164 | int i; |
165 | if (width == -1 || height == -1) { | 165 | if (width == -1 || height == -1) { |
166 | width = container->width; | 166 | width = container->width; |
@@ -181,7 +181,7 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
181 | case C_ROOT: | 181 | case C_ROOT: |
182 | // TODO: wlr_output_layout probably | 182 | // TODO: wlr_output_layout probably |
183 | for (i = 0; i < container->children->length; ++i) { | 183 | for (i = 0; i < container->children->length; ++i) { |
184 | swayc_t *output = container->children->items[i]; | 184 | struct sway_container *output = container->children->items[i]; |
185 | wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", | 185 | wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", |
186 | output->name, output->x, output->y); | 186 | output->name, output->x, output->y); |
187 | arrange_windows(output, -1, -1); | 187 | arrange_windows(output, -1, -1); |
@@ -197,13 +197,13 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
197 | } | 197 | } |
198 | // arrange all workspaces: | 198 | // arrange all workspaces: |
199 | for (i = 0; i < container->children->length; ++i) { | 199 | for (i = 0; i < container->children->length; ++i) { |
200 | swayc_t *child = container->children->items[i]; | 200 | struct sway_container *child = container->children->items[i]; |
201 | arrange_windows(child, -1, -1); | 201 | arrange_windows(child, -1, -1); |
202 | } | 202 | } |
203 | return; | 203 | return; |
204 | case C_WORKSPACE: | 204 | case C_WORKSPACE: |
205 | { | 205 | { |
206 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); | 206 | struct sway_container *output = sway_container_parent(container, C_OUTPUT); |
207 | struct wlr_box *area = &output->sway_output->usable_area; | 207 | struct wlr_box *area = &output->sway_output->usable_area; |
208 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", | 208 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", |
209 | area->width, area->height, area->x, area->y); | 209 | area->width, area->height, area->x, area->y); |
@@ -252,14 +252,14 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | static void apply_horiz_layout(swayc_t *container, | 255 | static void apply_horiz_layout(struct sway_container *container, |
256 | const double x, const double y, | 256 | const double x, const double y, |
257 | const double width, const double height, | 257 | const double width, const double height, |
258 | const int start, const int end) { | 258 | const int start, const int end) { |
259 | double scale = 0; | 259 | double scale = 0; |
260 | // Calculate total width | 260 | // Calculate total width |
261 | for (int i = start; i < end; ++i) { | 261 | for (int i = start; i < end; ++i) { |
262 | double *old_width = &((swayc_t *)container->children->items[i])->width; | 262 | double *old_width = &((struct sway_container *)container->children->items[i])->width; |
263 | if (*old_width <= 0) { | 263 | if (*old_width <= 0) { |
264 | if (end - start > 1) { | 264 | if (end - start > 1) { |
265 | *old_width = width / (end - start - 1); | 265 | *old_width = width / (end - start - 1); |
@@ -276,7 +276,7 @@ static void apply_horiz_layout(swayc_t *container, | |||
276 | if (scale > 0.1) { | 276 | if (scale > 0.1) { |
277 | wlr_log(L_DEBUG, "Arranging %p horizontally", container); | 277 | wlr_log(L_DEBUG, "Arranging %p horizontally", container); |
278 | for (int i = start; i < end; ++i) { | 278 | for (int i = start; i < end; ++i) { |
279 | swayc_t *child = container->children->items[i]; | 279 | struct sway_container *child = container->children->items[i]; |
280 | wlr_log(L_DEBUG, | 280 | wlr_log(L_DEBUG, |
281 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 281 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
282 | child, child->type, width, scale); | 282 | child, child->type, width, scale); |
@@ -301,7 +301,7 @@ static void apply_horiz_layout(swayc_t *container, | |||
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void apply_vert_layout(swayc_t *container, | 304 | void apply_vert_layout(struct sway_container *container, |
305 | const double x, const double y, | 305 | const double x, const double y, |
306 | const double width, const double height, const int start, | 306 | const double width, const double height, const int start, |
307 | const int end) { | 307 | const int end) { |
@@ -309,7 +309,7 @@ void apply_vert_layout(swayc_t *container, | |||
309 | double scale = 0; | 309 | double scale = 0; |
310 | // Calculate total height | 310 | // Calculate total height |
311 | for (i = start; i < end; ++i) { | 311 | for (i = start; i < end; ++i) { |
312 | double *old_height = &((swayc_t *)container->children->items[i])->height; | 312 | double *old_height = &((struct sway_container *)container->children->items[i])->height; |
313 | if (*old_height <= 0) { | 313 | if (*old_height <= 0) { |
314 | if (end - start > 1) { | 314 | if (end - start > 1) { |
315 | *old_height = height / (end - start - 1); | 315 | *old_height = height / (end - start - 1); |
@@ -326,7 +326,7 @@ void apply_vert_layout(swayc_t *container, | |||
326 | if (scale > 0.1) { | 326 | if (scale > 0.1) { |
327 | wlr_log(L_DEBUG, "Arranging %p vertically", container); | 327 | wlr_log(L_DEBUG, "Arranging %p vertically", container); |
328 | for (i = start; i < end; ++i) { | 328 | for (i = start; i < end; ++i) { |
329 | swayc_t *child = container->children->items[i]; | 329 | struct sway_container *child = container->children->items[i]; |
330 | wlr_log(L_DEBUG, | 330 | wlr_log(L_DEBUG, |
331 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 331 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
332 | child, child->type, height, scale); | 332 | child, child->type, height, scale); |
@@ -354,15 +354,15 @@ void apply_vert_layout(swayc_t *container, | |||
354 | /** | 354 | /** |
355 | * Get swayc in the direction of newly entered output. | 355 | * Get swayc in the direction of newly entered output. |
356 | */ | 356 | */ |
357 | static swayc_t *get_swayc_in_output_direction(swayc_t *output, | 357 | static struct sway_container *get_swayc_in_output_direction(struct sway_container *output, |
358 | enum movement_direction dir, struct sway_seat *seat) { | 358 | enum movement_direction dir, struct sway_seat *seat) { |
359 | if (!output) { | 359 | if (!output) { |
360 | return NULL; | 360 | return NULL; |
361 | } | 361 | } |
362 | 362 | ||
363 | swayc_t *ws = sway_seat_get_focus_inactive(seat, output); | 363 | struct sway_container *ws = sway_seat_get_focus_inactive(seat, output); |
364 | if (ws->type != C_WORKSPACE) { | 364 | if (ws->type != C_WORKSPACE) { |
365 | ws = swayc_parent_by_type(ws, C_WORKSPACE); | 365 | ws = sway_container_parent(ws, C_WORKSPACE); |
366 | } | 366 | } |
367 | 367 | ||
368 | if (ws == NULL) { | 368 | if (ws == NULL) { |
@@ -380,9 +380,9 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, | |||
380 | return ws->children->items[0]; | 380 | return ws->children->items[0]; |
381 | case MOVE_UP: | 381 | case MOVE_UP: |
382 | case MOVE_DOWN: { | 382 | case MOVE_DOWN: { |
383 | swayc_t *focused = sway_seat_get_focus_inactive(seat, ws); | 383 | struct sway_container *focused = sway_seat_get_focus_inactive(seat, ws); |
384 | if (focused && focused->parent) { | 384 | if (focused && focused->parent) { |
385 | swayc_t *parent = focused->parent; | 385 | struct sway_container *parent = focused->parent; |
386 | if (parent->layout == L_VERT) { | 386 | if (parent->layout == L_VERT) { |
387 | if (dir == MOVE_UP) { | 387 | if (dir == MOVE_UP) { |
388 | // get child furthest down on new output | 388 | // get child furthest down on new output |
@@ -404,13 +404,13 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, | |||
404 | return ws; | 404 | return ws; |
405 | } | 405 | } |
406 | 406 | ||
407 | static void get_layout_center_position(swayc_t *container, int *x, int *y) { | 407 | static void get_layout_center_position(struct sway_container *container, int *x, int *y) { |
408 | // FIXME view coords are inconsistently referred to in layout/output systems | 408 | // FIXME view coords are inconsistently referred to in layout/output systems |
409 | if (container->type == C_OUTPUT) { | 409 | if (container->type == C_OUTPUT) { |
410 | *x = container->x + container->width/2; | 410 | *x = container->x + container->width/2; |
411 | *y = container->y + container->height/2; | 411 | *y = container->y + container->height/2; |
412 | } else { | 412 | } else { |
413 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); | 413 | struct sway_container *output = sway_container_parent(container, C_OUTPUT); |
414 | if (container->type == C_WORKSPACE) { | 414 | if (container->type == C_WORKSPACE) { |
415 | // Workspace coordinates are actually wrong/arbitrary, but should | 415 | // Workspace coordinates are actually wrong/arbitrary, but should |
416 | // be same as output. | 416 | // be same as output. |
@@ -444,12 +444,12 @@ static bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out | |||
444 | return true; | 444 | return true; |
445 | } | 445 | } |
446 | 446 | ||
447 | static swayc_t *sway_output_from_wlr(struct wlr_output *output) { | 447 | static struct sway_container *sway_output_from_wlr(struct wlr_output *output) { |
448 | if (output == NULL) { | 448 | if (output == NULL) { |
449 | return NULL; | 449 | return NULL; |
450 | } | 450 | } |
451 | for (int i = 0; i < root_container.children->length; ++i) { | 451 | for (int i = 0; i < root_container.children->length; ++i) { |
452 | swayc_t *o = root_container.children->items[i]; | 452 | struct sway_container *o = root_container.children->items[i]; |
453 | if (o->type == C_OUTPUT && o->sway_output->wlr_output == output) { | 453 | if (o->type == C_OUTPUT && o->sway_output->wlr_output == output) { |
454 | return o; | 454 | return o; |
455 | } | 455 | } |
@@ -457,13 +457,13 @@ static swayc_t *sway_output_from_wlr(struct wlr_output *output) { | |||
457 | return NULL; | 457 | return NULL; |
458 | } | 458 | } |
459 | 459 | ||
460 | static swayc_t *get_swayc_in_direction_under(swayc_t *container, | 460 | static struct sway_container *get_swayc_in_direction_under(struct sway_container *container, |
461 | enum movement_direction dir, struct sway_seat *seat, swayc_t *limit) { | 461 | enum movement_direction dir, struct sway_seat *seat, struct sway_container *limit) { |
462 | if (dir == MOVE_CHILD) { | 462 | if (dir == MOVE_CHILD) { |
463 | return sway_seat_get_focus_inactive(seat, container); | 463 | return sway_seat_get_focus_inactive(seat, container); |
464 | } | 464 | } |
465 | 465 | ||
466 | swayc_t *parent = container->parent; | 466 | struct sway_container *parent = container->parent; |
467 | if (dir == MOVE_PARENT) { | 467 | if (dir == MOVE_PARENT) { |
468 | if (parent->type == C_OUTPUT) { | 468 | if (parent->type == C_OUTPUT) { |
469 | return NULL; | 469 | return NULL; |
@@ -496,9 +496,9 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
496 | /* | 496 | /* |
497 | if (container->type == C_VIEW && swayc_is_fullscreen(container)) { | 497 | if (container->type == C_VIEW && swayc_is_fullscreen(container)) { |
498 | wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); | 498 | wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); |
499 | container = swayc_parent_by_type(container, C_OUTPUT); | 499 | container = sway_container_parent(container, C_OUTPUT); |
500 | get_layout_center_position(container, &abs_pos); | 500 | get_layout_center_position(container, &abs_pos); |
501 | swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true); | 501 | struct sway_container *output = swayc_adjacent_output(container, dir, &abs_pos, true); |
502 | return get_swayc_in_output_direction(output, dir); | 502 | return get_swayc_in_output_direction(output, dir); |
503 | } | 503 | } |
504 | if (container->type == C_WORKSPACE && container->fullscreen) { | 504 | if (container->type == C_WORKSPACE && container->fullscreen) { |
@@ -507,7 +507,7 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
507 | } | 507 | } |
508 | */ | 508 | */ |
509 | 509 | ||
510 | swayc_t *wrap_candidate = NULL; | 510 | struct sway_container *wrap_candidate = NULL; |
511 | while (true) { | 511 | while (true) { |
512 | // Test if we can even make a difference here | 512 | // Test if we can even make a difference here |
513 | bool can_move = false; | 513 | bool can_move = false; |
@@ -525,12 +525,12 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
525 | struct wlr_output *wlr_adjacent = | 525 | struct wlr_output *wlr_adjacent = |
526 | wlr_output_layout_adjacent_output(layout, wlr_dir, | 526 | wlr_output_layout_adjacent_output(layout, wlr_dir, |
527 | container->sway_output->wlr_output, lx, ly); | 527 | container->sway_output->wlr_output, lx, ly); |
528 | swayc_t *adjacent = sway_output_from_wlr(wlr_adjacent); | 528 | struct sway_container *adjacent = sway_output_from_wlr(wlr_adjacent); |
529 | 529 | ||
530 | if (!adjacent || adjacent == container) { | 530 | if (!adjacent || adjacent == container) { |
531 | return wrap_candidate; | 531 | return wrap_candidate; |
532 | } | 532 | } |
533 | swayc_t *next = get_swayc_in_output_direction(adjacent, dir, seat); | 533 | struct sway_container *next = get_swayc_in_output_direction(adjacent, dir, seat); |
534 | if (next == NULL) { | 534 | if (next == NULL) { |
535 | return NULL; | 535 | return NULL; |
536 | } | 536 | } |
@@ -587,7 +587,7 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
587 | } | 587 | } |
588 | } | 588 | } |
589 | 589 | ||
590 | swayc_t *get_swayc_in_direction(swayc_t *container, struct sway_seat *seat, | 590 | struct sway_container *get_swayc_in_direction(struct sway_container *container, struct sway_seat *seat, |
591 | enum movement_direction dir) { | 591 | enum movement_direction dir) { |
592 | return get_swayc_in_direction_under(container, dir, seat, NULL); | 592 | return get_swayc_in_direction_under(container, dir, seat, NULL); |
593 | } | 593 | } |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 3da3fde6..32e82845 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -17,7 +17,7 @@ struct workspace_by_number_data { | |||
17 | const char *name; | 17 | const char *name; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | void next_name_map(swayc_t *ws, void *data) { | 20 | void next_name_map(struct sway_container *ws, void *data) { |
21 | int *count = data; | 21 | int *count = data; |
22 | ++count; | 22 | ++count; |
23 | } | 23 | } |
@@ -37,7 +37,7 @@ char *workspace_next_name(const char *output_name) { | |||
37 | return name; | 37 | return name; |
38 | } | 38 | } |
39 | 39 | ||
40 | static bool _workspace_by_number(swayc_t *view, void *data) { | 40 | static bool _workspace_by_number(struct sway_container *view, void *data) { |
41 | if (view->type != C_WORKSPACE) { | 41 | if (view->type != C_WORKSPACE) { |
42 | return false; | 42 | return false; |
43 | } | 43 | } |
@@ -46,27 +46,27 @@ static bool _workspace_by_number(swayc_t *view, void *data) { | |||
46 | return a == wbnd->len && strncmp(view->name, wbnd->name, a) == 0; | 46 | return a == wbnd->len && strncmp(view->name, wbnd->name, a) == 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | swayc_t *workspace_by_number(const char* name) { | 49 | struct sway_container *workspace_by_number(const char* name) { |
50 | struct workspace_by_number_data wbnd = {0, "1234567890", name}; | 50 | struct workspace_by_number_data wbnd = {0, "1234567890", name}; |
51 | wbnd.len = strspn(name, wbnd.cset); | 51 | wbnd.len = strspn(name, wbnd.cset); |
52 | if (wbnd.len <= 0) { | 52 | if (wbnd.len <= 0) { |
53 | return NULL; | 53 | return NULL; |
54 | } | 54 | } |
55 | return swayc_by_test(&root_container, _workspace_by_number, (void *) &wbnd); | 55 | return sway_container_find(&root_container, _workspace_by_number, (void *) &wbnd); |
56 | } | 56 | } |
57 | 57 | ||
58 | static bool _workspace_by_name(swayc_t *view, void *data) { | 58 | static bool _workspace_by_name(struct sway_container *view, void *data) { |
59 | return (view->type == C_WORKSPACE) && | 59 | return (view->type == C_WORKSPACE) && |
60 | (strcasecmp(view->name, (char *) data) == 0); | 60 | (strcasecmp(view->name, (char *) data) == 0); |
61 | } | 61 | } |
62 | 62 | ||
63 | swayc_t *workspace_by_name(const char *name) { | 63 | struct sway_container *workspace_by_name(const char *name) { |
64 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 64 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
65 | swayc_t *current_workspace = NULL, *current_output = NULL; | 65 | struct sway_container *current_workspace = NULL, *current_output = NULL; |
66 | swayc_t *focus = sway_seat_get_focus(seat); | 66 | struct sway_container *focus = sway_seat_get_focus(seat); |
67 | if (focus) { | 67 | if (focus) { |
68 | current_workspace = swayc_parent_by_type(focus, C_WORKSPACE); | 68 | current_workspace = sway_container_parent(focus, C_WORKSPACE); |
69 | current_output = swayc_parent_by_type(focus, C_OUTPUT); | 69 | current_output = sway_container_parent(focus, C_OUTPUT); |
70 | } | 70 | } |
71 | if (strcmp(name, "prev") == 0) { | 71 | if (strcmp(name, "prev") == 0) { |
72 | return workspace_prev(current_workspace); | 72 | return workspace_prev(current_workspace); |
@@ -79,12 +79,12 @@ swayc_t *workspace_by_name(const char *name) { | |||
79 | } else if (strcmp(name, "current") == 0) { | 79 | } else if (strcmp(name, "current") == 0) { |
80 | return current_workspace; | 80 | return current_workspace; |
81 | } else { | 81 | } else { |
82 | return swayc_by_test(&root_container, _workspace_by_name, (void *) name); | 82 | return sway_container_find(&root_container, _workspace_by_name, (void *) name); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | swayc_t *workspace_create(const char *name) { | 86 | struct sway_container *workspace_create(const char *name) { |
87 | swayc_t *parent; | 87 | struct sway_container *parent; |
88 | // Search for workspace<->output pair | 88 | // Search for workspace<->output pair |
89 | int i, e = config->workspace_outputs->length; | 89 | int i, e = config->workspace_outputs->length; |
90 | for (i = 0; i < e; ++i) { | 90 | for (i = 0; i < e; ++i) { |
@@ -95,7 +95,7 @@ swayc_t *workspace_create(const char *name) { | |||
95 | for (i = 0; i < e; ++i) { | 95 | for (i = 0; i < e; ++i) { |
96 | parent = root_container.children->items[i]; | 96 | parent = root_container.children->items[i]; |
97 | if (strcmp(parent->name, wso->output) == 0) { | 97 | if (strcmp(parent->name, wso->output) == 0) { |
98 | return new_workspace(parent, name); | 98 | return sway_container_workspace_create(parent, name); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | break; | 101 | break; |
@@ -103,10 +103,10 @@ swayc_t *workspace_create(const char *name) { | |||
103 | } | 103 | } |
104 | // Otherwise create a new one | 104 | // Otherwise create a new one |
105 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 105 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
106 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 106 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
107 | parent = focus; | 107 | parent = focus; |
108 | parent = swayc_parent_by_type(parent, C_OUTPUT); | 108 | parent = sway_container_parent(parent, C_OUTPUT); |
109 | return new_workspace(parent, name); | 109 | return sway_container_workspace_create(parent, name); |
110 | } | 110 | } |
111 | 111 | ||
112 | /** | 112 | /** |
@@ -114,17 +114,17 @@ swayc_t *workspace_create(const char *name) { | |||
114 | * the end and beginning. If next is false, the previous workspace is returned, | 114 | * the end and beginning. If next is false, the previous workspace is returned, |
115 | * otherwise the next one is returned. | 115 | * otherwise the next one is returned. |
116 | */ | 116 | */ |
117 | swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) { | 117 | struct sway_container *workspace_output_prev_next_impl(struct sway_container *output, bool next) { |
118 | if (!sway_assert(output->type == C_OUTPUT, | 118 | if (!sway_assert(output->type == C_OUTPUT, |
119 | "Argument must be an output, is %d", output->type)) { | 119 | "Argument must be an output, is %d", output->type)) { |
120 | return NULL; | 120 | return NULL; |
121 | } | 121 | } |
122 | 122 | ||
123 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 123 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
124 | swayc_t *focus = sway_seat_get_focus_inactive(seat, output); | 124 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, output); |
125 | swayc_t *workspace = (focus->type == C_WORKSPACE ? | 125 | struct sway_container *workspace = (focus->type == C_WORKSPACE ? |
126 | focus : | 126 | focus : |
127 | swayc_parent_by_type(focus, C_WORKSPACE)); | 127 | sway_container_parent(focus, C_WORKSPACE)); |
128 | 128 | ||
129 | int i; | 129 | int i; |
130 | for (i = 0; i < output->children->length; i++) { | 130 | for (i = 0; i < output->children->length; i++) { |
@@ -144,13 +144,13 @@ swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) { | |||
144 | * next is false, the previous workspace is returned, otherwise the next one is | 144 | * next is false, the previous workspace is returned, otherwise the next one is |
145 | * returned. | 145 | * returned. |
146 | */ | 146 | */ |
147 | swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) { | 147 | struct sway_container *workspace_prev_next_impl(struct sway_container *workspace, bool next) { |
148 | if (!sway_assert(workspace->type == C_WORKSPACE, | 148 | if (!sway_assert(workspace->type == C_WORKSPACE, |
149 | "Argument must be a workspace, is %d", workspace->type)) { | 149 | "Argument must be a workspace, is %d", workspace->type)) { |
150 | return NULL; | 150 | return NULL; |
151 | } | 151 | } |
152 | 152 | ||
153 | swayc_t *current_output = workspace->parent; | 153 | struct sway_container *current_output = workspace->parent; |
154 | int offset = next ? 1 : -1; | 154 | int offset = next ? 1 : -1; |
155 | int start = next ? 0 : 1; | 155 | int start = next ? 0 : 1; |
156 | int end; | 156 | int end; |
@@ -170,7 +170,7 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) { | |||
170 | int num_outputs = root_container.children->length; | 170 | int num_outputs = root_container.children->length; |
171 | for (i = 0; i < num_outputs; i++) { | 171 | for (i = 0; i < num_outputs; i++) { |
172 | if (root_container.children->items[i] == current_output) { | 172 | if (root_container.children->items[i] == current_output) { |
173 | swayc_t *next_output = root_container.children->items[ | 173 | struct sway_container *next_output = root_container.children->items[ |
174 | wrap(i + offset, num_outputs)]; | 174 | wrap(i + offset, num_outputs)]; |
175 | return workspace_output_prev_next_impl(next_output, next); | 175 | return workspace_output_prev_next_impl(next_output, next); |
176 | } | 176 | } |
@@ -180,40 +180,40 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) { | |||
180 | return NULL; | 180 | return NULL; |
181 | } | 181 | } |
182 | 182 | ||
183 | swayc_t *workspace_output_next(swayc_t *current) { | 183 | struct sway_container *workspace_output_next(struct sway_container *current) { |
184 | return workspace_output_prev_next_impl(current, true); | 184 | return workspace_output_prev_next_impl(current, true); |
185 | } | 185 | } |
186 | 186 | ||
187 | swayc_t *workspace_next(swayc_t *current) { | 187 | struct sway_container *workspace_next(struct sway_container *current) { |
188 | return workspace_prev_next_impl(current, true); | 188 | return workspace_prev_next_impl(current, true); |
189 | } | 189 | } |
190 | 190 | ||
191 | swayc_t *workspace_output_prev(swayc_t *current) { | 191 | struct sway_container *workspace_output_prev(struct sway_container *current) { |
192 | return workspace_output_prev_next_impl(current, false); | 192 | return workspace_output_prev_next_impl(current, false); |
193 | } | 193 | } |
194 | 194 | ||
195 | swayc_t *workspace_prev(swayc_t *current) { | 195 | struct sway_container *workspace_prev(struct sway_container *current) { |
196 | return workspace_prev_next_impl(current, false); | 196 | return workspace_prev_next_impl(current, false); |
197 | } | 197 | } |
198 | 198 | ||
199 | bool workspace_switch(swayc_t *workspace) { | 199 | bool workspace_switch(struct sway_container *workspace) { |
200 | if (!workspace) { | 200 | if (!workspace) { |
201 | return false; | 201 | return false; |
202 | } | 202 | } |
203 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 203 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
204 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 204 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
205 | if (!seat || !focus) { | 205 | if (!seat || !focus) { |
206 | return false; | 206 | return false; |
207 | } | 207 | } |
208 | swayc_t *active_ws = focus; | 208 | struct sway_container *active_ws = focus; |
209 | if (active_ws->type != C_WORKSPACE) { | 209 | if (active_ws->type != C_WORKSPACE) { |
210 | swayc_parent_by_type(focus, C_WORKSPACE); | 210 | sway_container_parent(focus, C_WORKSPACE); |
211 | } | 211 | } |
212 | 212 | ||
213 | if (config->auto_back_and_forth | 213 | if (config->auto_back_and_forth |
214 | && active_ws == workspace | 214 | && active_ws == workspace |
215 | && prev_workspace_name) { | 215 | && prev_workspace_name) { |
216 | swayc_t *new_ws = workspace_by_name(prev_workspace_name); | 216 | struct sway_container *new_ws = workspace_by_name(prev_workspace_name); |
217 | workspace = new_ws ? new_ws : workspace_create(prev_workspace_name); | 217 | workspace = new_ws ? new_ws : workspace_create(prev_workspace_name); |
218 | } | 218 | } |
219 | 219 | ||
@@ -231,12 +231,12 @@ bool workspace_switch(swayc_t *workspace) { | |||
231 | // TODO: Deal with sticky containers | 231 | // TODO: Deal with sticky containers |
232 | 232 | ||
233 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); | 233 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); |
234 | swayc_t *next = sway_seat_get_focus_inactive(seat, workspace); | 234 | struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); |
235 | if (next == NULL) { | 235 | if (next == NULL) { |
236 | next = workspace; | 236 | next = workspace; |
237 | } | 237 | } |
238 | sway_seat_set_focus(seat, next); | 238 | sway_seat_set_focus(seat, next); |
239 | swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT); | 239 | struct sway_container *output = sway_container_parent(workspace, C_OUTPUT); |
240 | arrange_windows(output, -1, -1); | 240 | arrange_windows(output, -1, -1); |
241 | return true; | 241 | return true; |
242 | } | 242 | } |
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 93d1219c..f9df0d10 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -352,7 +352,7 @@ void ipc_bar_init(struct bar *bar, const char *bar_id) { | |||
352 | } | 352 | } |
353 | 353 | ||
354 | // add bar to the output | 354 | // add bar to the output |
355 | struct output *bar_output = new_output(name); | 355 | struct output *bar_output = sway_container_output_create(name); |
356 | bar_output->idx = i; | 356 | bar_output->idx = i; |
357 | list_add(bar->outputs, bar_output); | 357 | list_add(bar->outputs, bar_output); |
358 | } | 358 | } |