mirror of
https://github.com/swaywm/sway.git
synced 2025-11-17 06:59:48 -05:00
rename container functions
This commit is contained in:
parent
83d09cf594
commit
b90099b4b7
23 changed files with 290 additions and 282 deletions
|
|
@ -33,48 +33,15 @@ static list_t *get_bfs_queue() {
|
|||
return bfs_queue;
|
||||
}
|
||||
|
||||
static void notify_new_container(swayc_t *container) {
|
||||
static void notify_new_container(struct sway_container *container) {
|
||||
wl_signal_emit(&root_container.sway_root->events.new_container, container);
|
||||
ipc_event_window(container, "new");
|
||||
}
|
||||
|
||||
swayc_t *swayc_by_test(swayc_t *container,
|
||||
bool (*test)(swayc_t *view, void *data), void *data) {
|
||||
if (!container->children) {
|
||||
return NULL;
|
||||
}
|
||||
// TODO: floating windows
|
||||
for (int i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = container->children->items[i];
|
||||
if (test(child, data)) {
|
||||
return child;
|
||||
} else {
|
||||
swayc_t *res = swayc_by_test(child, test, data);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void swayc_descendants_of_type(swayc_t *root, enum swayc_types type,
|
||||
void (*func)(swayc_t *item, void *data), void *data) {
|
||||
for (int i = 0; i < root->children->length; ++i) {
|
||||
swayc_t *item = root->children->items[i];
|
||||
if (item->type == type) {
|
||||
func(item, data);
|
||||
}
|
||||
if (item->children && item->children->length) {
|
||||
swayc_descendants_of_type(item, type, func, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static swayc_t *new_swayc(enum swayc_types type) {
|
||||
static struct sway_container *new_swayc(enum sway_container_type type) {
|
||||
// next id starts at 1 because 0 is assigned to root_container in layout.c
|
||||
static size_t next_id = 1;
|
||||
swayc_t *c = calloc(1, sizeof(swayc_t));
|
||||
struct sway_container *c = calloc(1, sizeof(struct sway_container));
|
||||
if (!c) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -91,7 +58,7 @@ static swayc_t *new_swayc(enum swayc_types type) {
|
|||
return c;
|
||||
}
|
||||
|
||||
static void free_swayc(swayc_t *cont) {
|
||||
static void free_swayc(struct sway_container *cont) {
|
||||
if (!sway_assert(cont, "free_swayc passed NULL")) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -119,7 +86,7 @@ static void free_swayc(swayc_t *cont) {
|
|||
free(cont);
|
||||
}
|
||||
|
||||
swayc_t *new_output(struct sway_output *sway_output) {
|
||||
struct sway_container *sway_container_output_create(struct sway_output *sway_output) {
|
||||
struct wlr_box size;
|
||||
wlr_output_effective_resolution(sway_output->wlr_output, &size.width,
|
||||
&size.height);
|
||||
|
|
@ -154,7 +121,7 @@ swayc_t *new_output(struct sway_output *sway_output) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
swayc_t *output = new_swayc(C_OUTPUT);
|
||||
struct sway_container *output = new_swayc(C_OUTPUT);
|
||||
output->sway_output = sway_output;
|
||||
output->name = strdup(name);
|
||||
if (output->name == NULL) {
|
||||
|
|
@ -169,7 +136,7 @@ swayc_t *new_output(struct sway_output *sway_output) {
|
|||
// Create workspace
|
||||
char *ws_name = workspace_next_name(output->name);
|
||||
wlr_log(L_DEBUG, "Creating default workspace %s", ws_name);
|
||||
swayc_t *ws = new_workspace(output, ws_name);
|
||||
struct sway_container *ws = sway_container_workspace_create(output, ws_name);
|
||||
// Set each seat's focus if not already set
|
||||
struct sway_seat *seat = NULL;
|
||||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
|
|
@ -183,12 +150,12 @@ swayc_t *new_output(struct sway_output *sway_output) {
|
|||
return output;
|
||||
}
|
||||
|
||||
swayc_t *new_workspace(swayc_t *output, const char *name) {
|
||||
if (!sway_assert(output, "new_workspace called with null output")) {
|
||||
struct sway_container *sway_container_workspace_create(struct sway_container *output, const char *name) {
|
||||
if (!sway_assert(output, "sway_container_workspace_create called with null output")) {
|
||||
return NULL;
|
||||
}
|
||||
wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name);
|
||||
swayc_t *workspace = new_swayc(C_WORKSPACE);
|
||||
struct sway_container *workspace = new_swayc(C_WORKSPACE);
|
||||
|
||||
workspace->x = output->x;
|
||||
workspace->y = output->y;
|
||||
|
|
@ -205,12 +172,12 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
|
|||
return workspace;
|
||||
}
|
||||
|
||||
swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) {
|
||||
if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) {
|
||||
struct sway_container *sway_container_view_create(struct sway_container *sibling, struct sway_view *sway_view) {
|
||||
if (!sway_assert(sibling, "sway_container_view_create called with NULL sibling/parent")) {
|
||||
return NULL;
|
||||
}
|
||||
const char *title = view_get_title(sway_view);
|
||||
swayc_t *swayc = new_swayc(C_VIEW);
|
||||
struct sway_container *swayc = new_swayc(C_VIEW);
|
||||
wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s",
|
||||
swayc, title, sibling, sibling ? sibling->type : 0, sibling->name);
|
||||
// Setup values
|
||||
|
|
@ -230,8 +197,8 @@ swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) {
|
|||
return swayc;
|
||||
}
|
||||
|
||||
swayc_t *destroy_output(swayc_t *output) {
|
||||
if (!sway_assert(output, "null output passed to destroy_output")) {
|
||||
struct sway_container *sway_container_output_destroy(struct sway_container *output) {
|
||||
if (!sway_assert(output, "null output passed to sway_container_output_destroy")) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +210,7 @@ swayc_t *destroy_output(swayc_t *output) {
|
|||
int p = root_container.children->items[0] == output;
|
||||
// Move workspace from this output to another output
|
||||
while (output->children->length) {
|
||||
swayc_t *child = output->children->items[0];
|
||||
struct sway_container *child = output->children->items[0];
|
||||
remove_child(child);
|
||||
add_child(root_container.children->items[p], child);
|
||||
}
|
||||
|
|
@ -262,12 +229,12 @@ swayc_t *destroy_output(swayc_t *output) {
|
|||
return &root_container;
|
||||
}
|
||||
|
||||
swayc_t *destroy_view(swayc_t *view) {
|
||||
struct sway_container *sway_container_view_destroy(struct sway_container *view) {
|
||||
if (!view) {
|
||||
return NULL;
|
||||
}
|
||||
wlr_log(L_DEBUG, "Destroying view '%s'", view->name);
|
||||
swayc_t *parent = view->parent;
|
||||
struct sway_container *parent = view->parent;
|
||||
free_swayc(view);
|
||||
|
||||
// TODO WLR: Destroy empty containers
|
||||
|
|
@ -279,7 +246,52 @@ swayc_t *destroy_view(swayc_t *view) {
|
|||
return parent;
|
||||
}
|
||||
|
||||
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) {
|
||||
struct sway_container *swayc_change_layout(struct sway_container *container, enum sway_container_layout layout) {
|
||||
if (container->type == C_WORKSPACE) {
|
||||
container->workspace_layout = layout;
|
||||
if (layout == L_HORIZ || layout == L_VERT) {
|
||||
container->layout = layout;
|
||||
}
|
||||
} else {
|
||||
container->layout = layout;
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
void sway_container_descendents(struct sway_container *root, enum sway_container_type type,
|
||||
void (*func)(struct sway_container *item, void *data), void *data) {
|
||||
for (int i = 0; i < root->children->length; ++i) {
|
||||
struct sway_container *item = root->children->items[i];
|
||||
if (item->type == type) {
|
||||
func(item, data);
|
||||
}
|
||||
if (item->children && item->children->length) {
|
||||
sway_container_descendents(item, type, func, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct sway_container *sway_container_find(struct sway_container *container,
|
||||
bool (*test)(struct sway_container *view, void *data), void *data) {
|
||||
if (!container->children) {
|
||||
return NULL;
|
||||
}
|
||||
// TODO: floating windows
|
||||
for (int i = 0; i < container->children->length; ++i) {
|
||||
struct sway_container *child = container->children->items[i];
|
||||
if (test(child, data)) {
|
||||
return child;
|
||||
} else {
|
||||
struct sway_container *res = sway_container_find(child, test, data);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_container *sway_container_parent(struct sway_container *container, enum sway_container_type type) {
|
||||
if (!sway_assert(container, "container is NULL")) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -292,7 +304,29 @@ swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) {
|
|||
return container;
|
||||
}
|
||||
|
||||
swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
|
||||
void sway_container_for_each(struct sway_container *container, void (*f)(struct sway_container *view, void *data), void *data) {
|
||||
if (container) {
|
||||
int i;
|
||||
if (container->children) {
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
struct sway_container *child = container->children->items[i];
|
||||
sway_container_for_each(child, f, data);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
/*
|
||||
if (container->floating) {
|
||||
for (i = 0; i < container->floating->length; ++i) {
|
||||
struct sway_container *child = container->floating->items[i];
|
||||
container_map(child, f, data);
|
||||
}
|
||||
}
|
||||
*/
|
||||
f(container, data);
|
||||
}
|
||||
}
|
||||
|
||||
struct sway_container *sway_container_at(struct sway_container *parent, double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx, double *sy) {
|
||||
list_t *queue = get_bfs_queue();
|
||||
if (!queue) {
|
||||
|
|
@ -301,13 +335,13 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
|
|||
|
||||
list_add(queue, parent);
|
||||
|
||||
swayc_t *swayc = NULL;
|
||||
struct sway_container *swayc = NULL;
|
||||
while (queue->length) {
|
||||
swayc = queue->items[0];
|
||||
list_del(queue, 0);
|
||||
if (swayc->type == C_VIEW) {
|
||||
struct sway_view *sview = swayc->sway_view;
|
||||
swayc_t *soutput = swayc_parent_by_type(swayc, C_OUTPUT);
|
||||
struct sway_container *soutput = sway_container_parent(swayc, C_OUTPUT);
|
||||
struct wlr_box *output_box =
|
||||
wlr_output_layout_get_box(
|
||||
root_container.sway_root->output_layout,
|
||||
|
|
@ -377,29 +411,7 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) {
|
||||
if (container) {
|
||||
int i;
|
||||
if (container->children) {
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = container->children->items[i];
|
||||
container_map(child, f, data);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
/*
|
||||
if (container->floating) {
|
||||
for (i = 0; i < container->floating->length; ++i) {
|
||||
swayc_t *child = container->floating->items[i];
|
||||
container_map(child, f, data);
|
||||
}
|
||||
}
|
||||
*/
|
||||
f(container, data);
|
||||
}
|
||||
}
|
||||
|
||||
void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data),
|
||||
void sway_container_for_each_bfs(struct sway_container *con, void (*f)(struct sway_container *con, void *data),
|
||||
void *data) {
|
||||
list_t *queue = get_bfs_queue();
|
||||
if (!queue) {
|
||||
|
|
@ -413,7 +425,7 @@ void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data),
|
|||
|
||||
list_add(queue, con);
|
||||
|
||||
swayc_t *current = NULL;
|
||||
struct sway_container *current = NULL;
|
||||
while (queue->length) {
|
||||
current = queue->items[0];
|
||||
list_del(queue, 0);
|
||||
|
|
@ -422,15 +434,3 @@ void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data),
|
|||
list_cat(queue, current->children);
|
||||
}
|
||||
}
|
||||
|
||||
swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) {
|
||||
if (container->type == C_WORKSPACE) {
|
||||
container->workspace_layout = layout;
|
||||
if (layout == L_HORIZ || layout == L_VERT) {
|
||||
container->layout = layout;
|
||||
}
|
||||
} else {
|
||||
container->layout = layout;
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include "list.h"
|
||||
#include "log.h"
|
||||
|
||||
swayc_t root_container;
|
||||
struct sway_container root_container;
|
||||
|
||||
static void output_layout_change_notify(struct wl_listener *listener, void *data) {
|
||||
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
|
|||
root_container.height = layout_box->height;
|
||||
|
||||
for (int i = 0 ; i < root_container.children->length; ++i) {
|
||||
swayc_t *output_container = root_container.children->items[i];
|
||||
struct sway_container *output_container = root_container.children->items[i];
|
||||
if (output_container->type != C_OUTPUT) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ void init_layout(void) {
|
|||
&root_container.sway_root->output_layout_change);
|
||||
}
|
||||
|
||||
static int index_child(const swayc_t *child) {
|
||||
static int index_child(const struct sway_container *child) {
|
||||
// TODO handle floating
|
||||
swayc_t *parent = child->parent;
|
||||
struct sway_container *parent = child->parent;
|
||||
int i, len;
|
||||
len = parent->children->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
|
|
@ -79,16 +79,16 @@ static int index_child(const swayc_t *child) {
|
|||
return i;
|
||||
}
|
||||
|
||||
swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) {
|
||||
struct sway_container *add_sibling(struct sway_container *fixed, struct sway_container *active) {
|
||||
// TODO handle floating
|
||||
swayc_t *parent = fixed->parent;
|
||||
struct sway_container *parent = fixed->parent;
|
||||
int i = index_child(fixed);
|
||||
list_insert(parent->children, i + 1, active);
|
||||
active->parent = parent;
|
||||
return active->parent;
|
||||
}
|
||||
|
||||
void add_child(swayc_t *parent, swayc_t *child) {
|
||||
void add_child(struct sway_container *parent, struct sway_container *child) {
|
||||
wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)",
|
||||
child, child->type, child->width, child->height,
|
||||
parent, parent->type, parent->width, parent->height);
|
||||
|
|
@ -102,9 +102,9 @@ void add_child(swayc_t *parent, swayc_t *child) {
|
|||
*/
|
||||
}
|
||||
|
||||
swayc_t *remove_child(swayc_t *child) {
|
||||
struct sway_container *remove_child(struct sway_container *child) {
|
||||
int i;
|
||||
swayc_t *parent = child->parent;
|
||||
struct sway_container *parent = child->parent;
|
||||
for (i = 0; i < parent->children->length; ++i) {
|
||||
if (parent->children->items[i] == child) {
|
||||
list_del(parent->children, i);
|
||||
|
|
@ -115,7 +115,7 @@ swayc_t *remove_child(swayc_t *child) {
|
|||
return parent;
|
||||
}
|
||||
|
||||
enum swayc_layouts default_layout(swayc_t *output) {
|
||||
enum sway_container_layout default_layout(struct sway_container *output) {
|
||||
/* TODO WLR
|
||||
if (config->default_layout != L_NONE) {
|
||||
//return config->default_layout;
|
||||
|
|
@ -129,8 +129,8 @@ enum swayc_layouts default_layout(swayc_t *output) {
|
|||
}
|
||||
|
||||
static int sort_workspace_cmp_qsort(const void *_a, const void *_b) {
|
||||
swayc_t *a = *(void **)_a;
|
||||
swayc_t *b = *(void **)_b;
|
||||
struct sway_container *a = *(void **)_a;
|
||||
struct sway_container *b = *(void **)_b;
|
||||
int retval = 0;
|
||||
|
||||
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) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
void sort_workspaces(swayc_t *output) {
|
||||
void sort_workspaces(struct sway_container *output) {
|
||||
list_stable_sort(output->children, sort_workspace_cmp_qsort);
|
||||
}
|
||||
|
||||
static void apply_horiz_layout(swayc_t *container, const double x,
|
||||
static void apply_horiz_layout(struct sway_container *container, const double x,
|
||||
const double y, const double width,
|
||||
const double height, const int start,
|
||||
const int end);
|
||||
|
||||
static void apply_vert_layout(swayc_t *container, const double x,
|
||||
static void apply_vert_layout(struct sway_container *container, const double x,
|
||||
const double y, const double width,
|
||||
const double height, const int start,
|
||||
const int end);
|
||||
|
||||
void arrange_windows(swayc_t *container, double width, double height) {
|
||||
void arrange_windows(struct sway_container *container, double width, double height) {
|
||||
int i;
|
||||
if (width == -1 || height == -1) {
|
||||
width = container->width;
|
||||
|
|
@ -181,7 +181,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
|
|||
case C_ROOT:
|
||||
// TODO: wlr_output_layout probably
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *output = container->children->items[i];
|
||||
struct sway_container *output = container->children->items[i];
|
||||
wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f",
|
||||
output->name, output->x, output->y);
|
||||
arrange_windows(output, -1, -1);
|
||||
|
|
@ -197,13 +197,13 @@ void arrange_windows(swayc_t *container, double width, double height) {
|
|||
}
|
||||
// arrange all workspaces:
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = container->children->items[i];
|
||||
struct sway_container *child = container->children->items[i];
|
||||
arrange_windows(child, -1, -1);
|
||||
}
|
||||
return;
|
||||
case C_WORKSPACE:
|
||||
{
|
||||
swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
|
||||
struct sway_container *output = sway_container_parent(container, C_OUTPUT);
|
||||
struct wlr_box *area = &output->sway_output->usable_area;
|
||||
wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
||||
area->width, area->height, area->x, area->y);
|
||||
|
|
@ -252,14 +252,14 @@ void arrange_windows(swayc_t *container, double width, double height) {
|
|||
}
|
||||
}
|
||||
|
||||
static void apply_horiz_layout(swayc_t *container,
|
||||
static void apply_horiz_layout(struct sway_container *container,
|
||||
const double x, const double y,
|
||||
const double width, const double height,
|
||||
const int start, const int end) {
|
||||
double scale = 0;
|
||||
// Calculate total width
|
||||
for (int i = start; i < end; ++i) {
|
||||
double *old_width = &((swayc_t *)container->children->items[i])->width;
|
||||
double *old_width = &((struct sway_container *)container->children->items[i])->width;
|
||||
if (*old_width <= 0) {
|
||||
if (end - start > 1) {
|
||||
*old_width = width / (end - start - 1);
|
||||
|
|
@ -276,7 +276,7 @@ static void apply_horiz_layout(swayc_t *container,
|
|||
if (scale > 0.1) {
|
||||
wlr_log(L_DEBUG, "Arranging %p horizontally", container);
|
||||
for (int i = start; i < end; ++i) {
|
||||
swayc_t *child = container->children->items[i];
|
||||
struct sway_container *child = container->children->items[i];
|
||||
wlr_log(L_DEBUG,
|
||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||
child, child->type, width, scale);
|
||||
|
|
@ -301,7 +301,7 @@ static void apply_horiz_layout(swayc_t *container,
|
|||
}
|
||||
}
|
||||
|
||||
void apply_vert_layout(swayc_t *container,
|
||||
void apply_vert_layout(struct sway_container *container,
|
||||
const double x, const double y,
|
||||
const double width, const double height, const int start,
|
||||
const int end) {
|
||||
|
|
@ -309,7 +309,7 @@ void apply_vert_layout(swayc_t *container,
|
|||
double scale = 0;
|
||||
// Calculate total height
|
||||
for (i = start; i < end; ++i) {
|
||||
double *old_height = &((swayc_t *)container->children->items[i])->height;
|
||||
double *old_height = &((struct sway_container *)container->children->items[i])->height;
|
||||
if (*old_height <= 0) {
|
||||
if (end - start > 1) {
|
||||
*old_height = height / (end - start - 1);
|
||||
|
|
@ -326,7 +326,7 @@ void apply_vert_layout(swayc_t *container,
|
|||
if (scale > 0.1) {
|
||||
wlr_log(L_DEBUG, "Arranging %p vertically", container);
|
||||
for (i = start; i < end; ++i) {
|
||||
swayc_t *child = container->children->items[i];
|
||||
struct sway_container *child = container->children->items[i];
|
||||
wlr_log(L_DEBUG,
|
||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||
child, child->type, height, scale);
|
||||
|
|
@ -354,15 +354,15 @@ void apply_vert_layout(swayc_t *container,
|
|||
/**
|
||||
* Get swayc in the direction of newly entered output.
|
||||
*/
|
||||
static swayc_t *get_swayc_in_output_direction(swayc_t *output,
|
||||
static struct sway_container *get_swayc_in_output_direction(struct sway_container *output,
|
||||
enum movement_direction dir, struct sway_seat *seat) {
|
||||
if (!output) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
swayc_t *ws = sway_seat_get_focus_inactive(seat, output);
|
||||
struct sway_container *ws = sway_seat_get_focus_inactive(seat, output);
|
||||
if (ws->type != C_WORKSPACE) {
|
||||
ws = swayc_parent_by_type(ws, C_WORKSPACE);
|
||||
ws = sway_container_parent(ws, C_WORKSPACE);
|
||||
}
|
||||
|
||||
if (ws == NULL) {
|
||||
|
|
@ -380,9 +380,9 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output,
|
|||
return ws->children->items[0];
|
||||
case MOVE_UP:
|
||||
case MOVE_DOWN: {
|
||||
swayc_t *focused = sway_seat_get_focus_inactive(seat, ws);
|
||||
struct sway_container *focused = sway_seat_get_focus_inactive(seat, ws);
|
||||
if (focused && focused->parent) {
|
||||
swayc_t *parent = focused->parent;
|
||||
struct sway_container *parent = focused->parent;
|
||||
if (parent->layout == L_VERT) {
|
||||
if (dir == MOVE_UP) {
|
||||
// get child furthest down on new output
|
||||
|
|
@ -404,13 +404,13 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output,
|
|||
return ws;
|
||||
}
|
||||
|
||||
static void get_layout_center_position(swayc_t *container, int *x, int *y) {
|
||||
static void get_layout_center_position(struct sway_container *container, int *x, int *y) {
|
||||
// FIXME view coords are inconsistently referred to in layout/output systems
|
||||
if (container->type == C_OUTPUT) {
|
||||
*x = container->x + container->width/2;
|
||||
*y = container->y + container->height/2;
|
||||
} else {
|
||||
swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
|
||||
struct sway_container *output = sway_container_parent(container, C_OUTPUT);
|
||||
if (container->type == C_WORKSPACE) {
|
||||
// Workspace coordinates are actually wrong/arbitrary, but should
|
||||
// be same as output.
|
||||
|
|
@ -444,12 +444,12 @@ static bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out
|
|||
return true;
|
||||
}
|
||||
|
||||
static swayc_t *sway_output_from_wlr(struct wlr_output *output) {
|
||||
static struct sway_container *sway_output_from_wlr(struct wlr_output *output) {
|
||||
if (output == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *o = root_container.children->items[i];
|
||||
struct sway_container *o = root_container.children->items[i];
|
||||
if (o->type == C_OUTPUT && o->sway_output->wlr_output == output) {
|
||||
return o;
|
||||
}
|
||||
|
|
@ -457,13 +457,13 @@ static swayc_t *sway_output_from_wlr(struct wlr_output *output) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static swayc_t *get_swayc_in_direction_under(swayc_t *container,
|
||||
enum movement_direction dir, struct sway_seat *seat, swayc_t *limit) {
|
||||
static struct sway_container *get_swayc_in_direction_under(struct sway_container *container,
|
||||
enum movement_direction dir, struct sway_seat *seat, struct sway_container *limit) {
|
||||
if (dir == MOVE_CHILD) {
|
||||
return sway_seat_get_focus_inactive(seat, container);
|
||||
}
|
||||
|
||||
swayc_t *parent = container->parent;
|
||||
struct sway_container *parent = container->parent;
|
||||
if (dir == MOVE_PARENT) {
|
||||
if (parent->type == C_OUTPUT) {
|
||||
return NULL;
|
||||
|
|
@ -496,9 +496,9 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container,
|
|||
/*
|
||||
if (container->type == C_VIEW && swayc_is_fullscreen(container)) {
|
||||
wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output");
|
||||
container = swayc_parent_by_type(container, C_OUTPUT);
|
||||
container = sway_container_parent(container, C_OUTPUT);
|
||||
get_layout_center_position(container, &abs_pos);
|
||||
swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true);
|
||||
struct sway_container *output = swayc_adjacent_output(container, dir, &abs_pos, true);
|
||||
return get_swayc_in_output_direction(output, dir);
|
||||
}
|
||||
if (container->type == C_WORKSPACE && container->fullscreen) {
|
||||
|
|
@ -507,7 +507,7 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container,
|
|||
}
|
||||
*/
|
||||
|
||||
swayc_t *wrap_candidate = NULL;
|
||||
struct sway_container *wrap_candidate = NULL;
|
||||
while (true) {
|
||||
// Test if we can even make a difference here
|
||||
bool can_move = false;
|
||||
|
|
@ -525,12 +525,12 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container,
|
|||
struct wlr_output *wlr_adjacent =
|
||||
wlr_output_layout_adjacent_output(layout, wlr_dir,
|
||||
container->sway_output->wlr_output, lx, ly);
|
||||
swayc_t *adjacent = sway_output_from_wlr(wlr_adjacent);
|
||||
struct sway_container *adjacent = sway_output_from_wlr(wlr_adjacent);
|
||||
|
||||
if (!adjacent || adjacent == container) {
|
||||
return wrap_candidate;
|
||||
}
|
||||
swayc_t *next = get_swayc_in_output_direction(adjacent, dir, seat);
|
||||
struct sway_container *next = get_swayc_in_output_direction(adjacent, dir, seat);
|
||||
if (next == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container,
|
|||
}
|
||||
}
|
||||
|
||||
swayc_t *get_swayc_in_direction(swayc_t *container, struct sway_seat *seat,
|
||||
struct sway_container *get_swayc_in_direction(struct sway_container *container, struct sway_seat *seat,
|
||||
enum movement_direction dir) {
|
||||
return get_swayc_in_direction_under(container, dir, seat, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct workspace_by_number_data {
|
|||
const char *name;
|
||||
};
|
||||
|
||||
void next_name_map(swayc_t *ws, void *data) {
|
||||
void next_name_map(struct sway_container *ws, void *data) {
|
||||
int *count = data;
|
||||
++count;
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ char *workspace_next_name(const char *output_name) {
|
|||
return name;
|
||||
}
|
||||
|
||||
static bool _workspace_by_number(swayc_t *view, void *data) {
|
||||
static bool _workspace_by_number(struct sway_container *view, void *data) {
|
||||
if (view->type != C_WORKSPACE) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -46,27 +46,27 @@ static bool _workspace_by_number(swayc_t *view, void *data) {
|
|||
return a == wbnd->len && strncmp(view->name, wbnd->name, a) == 0;
|
||||
}
|
||||
|
||||
swayc_t *workspace_by_number(const char* name) {
|
||||
struct sway_container *workspace_by_number(const char* name) {
|
||||
struct workspace_by_number_data wbnd = {0, "1234567890", name};
|
||||
wbnd.len = strspn(name, wbnd.cset);
|
||||
if (wbnd.len <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
return swayc_by_test(&root_container, _workspace_by_number, (void *) &wbnd);
|
||||
return sway_container_find(&root_container, _workspace_by_number, (void *) &wbnd);
|
||||
}
|
||||
|
||||
static bool _workspace_by_name(swayc_t *view, void *data) {
|
||||
static bool _workspace_by_name(struct sway_container *view, void *data) {
|
||||
return (view->type == C_WORKSPACE) &&
|
||||
(strcasecmp(view->name, (char *) data) == 0);
|
||||
}
|
||||
|
||||
swayc_t *workspace_by_name(const char *name) {
|
||||
struct sway_container *workspace_by_name(const char *name) {
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
swayc_t *current_workspace = NULL, *current_output = NULL;
|
||||
swayc_t *focus = sway_seat_get_focus(seat);
|
||||
struct sway_container *current_workspace = NULL, *current_output = NULL;
|
||||
struct sway_container *focus = sway_seat_get_focus(seat);
|
||||
if (focus) {
|
||||
current_workspace = swayc_parent_by_type(focus, C_WORKSPACE);
|
||||
current_output = swayc_parent_by_type(focus, C_OUTPUT);
|
||||
current_workspace = sway_container_parent(focus, C_WORKSPACE);
|
||||
current_output = sway_container_parent(focus, C_OUTPUT);
|
||||
}
|
||||
if (strcmp(name, "prev") == 0) {
|
||||
return workspace_prev(current_workspace);
|
||||
|
|
@ -79,12 +79,12 @@ swayc_t *workspace_by_name(const char *name) {
|
|||
} else if (strcmp(name, "current") == 0) {
|
||||
return current_workspace;
|
||||
} else {
|
||||
return swayc_by_test(&root_container, _workspace_by_name, (void *) name);
|
||||
return sway_container_find(&root_container, _workspace_by_name, (void *) name);
|
||||
}
|
||||
}
|
||||
|
||||
swayc_t *workspace_create(const char *name) {
|
||||
swayc_t *parent;
|
||||
struct sway_container *workspace_create(const char *name) {
|
||||
struct sway_container *parent;
|
||||
// Search for workspace<->output pair
|
||||
int i, e = config->workspace_outputs->length;
|
||||
for (i = 0; i < e; ++i) {
|
||||
|
|
@ -95,7 +95,7 @@ swayc_t *workspace_create(const char *name) {
|
|||
for (i = 0; i < e; ++i) {
|
||||
parent = root_container.children->items[i];
|
||||
if (strcmp(parent->name, wso->output) == 0) {
|
||||
return new_workspace(parent, name);
|
||||
return sway_container_workspace_create(parent, name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -103,10 +103,10 @@ swayc_t *workspace_create(const char *name) {
|
|||
}
|
||||
// Otherwise create a new one
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||
struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||
parent = focus;
|
||||
parent = swayc_parent_by_type(parent, C_OUTPUT);
|
||||
return new_workspace(parent, name);
|
||||
parent = sway_container_parent(parent, C_OUTPUT);
|
||||
return sway_container_workspace_create(parent, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,17 +114,17 @@ swayc_t *workspace_create(const char *name) {
|
|||
* the end and beginning. If next is false, the previous workspace is returned,
|
||||
* otherwise the next one is returned.
|
||||
*/
|
||||
swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) {
|
||||
struct sway_container *workspace_output_prev_next_impl(struct sway_container *output, bool next) {
|
||||
if (!sway_assert(output->type == C_OUTPUT,
|
||||
"Argument must be an output, is %d", output->type)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
swayc_t *focus = sway_seat_get_focus_inactive(seat, output);
|
||||
swayc_t *workspace = (focus->type == C_WORKSPACE ?
|
||||
struct sway_container *focus = sway_seat_get_focus_inactive(seat, output);
|
||||
struct sway_container *workspace = (focus->type == C_WORKSPACE ?
|
||||
focus :
|
||||
swayc_parent_by_type(focus, C_WORKSPACE));
|
||||
sway_container_parent(focus, C_WORKSPACE));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < output->children->length; i++) {
|
||||
|
|
@ -144,13 +144,13 @@ swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) {
|
|||
* next is false, the previous workspace is returned, otherwise the next one is
|
||||
* returned.
|
||||
*/
|
||||
swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) {
|
||||
struct sway_container *workspace_prev_next_impl(struct sway_container *workspace, bool next) {
|
||||
if (!sway_assert(workspace->type == C_WORKSPACE,
|
||||
"Argument must be a workspace, is %d", workspace->type)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
swayc_t *current_output = workspace->parent;
|
||||
struct sway_container *current_output = workspace->parent;
|
||||
int offset = next ? 1 : -1;
|
||||
int start = next ? 0 : 1;
|
||||
int end;
|
||||
|
|
@ -170,7 +170,7 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) {
|
|||
int num_outputs = root_container.children->length;
|
||||
for (i = 0; i < num_outputs; i++) {
|
||||
if (root_container.children->items[i] == current_output) {
|
||||
swayc_t *next_output = root_container.children->items[
|
||||
struct sway_container *next_output = root_container.children->items[
|
||||
wrap(i + offset, num_outputs)];
|
||||
return workspace_output_prev_next_impl(next_output, next);
|
||||
}
|
||||
|
|
@ -180,40 +180,40 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
swayc_t *workspace_output_next(swayc_t *current) {
|
||||
struct sway_container *workspace_output_next(struct sway_container *current) {
|
||||
return workspace_output_prev_next_impl(current, true);
|
||||
}
|
||||
|
||||
swayc_t *workspace_next(swayc_t *current) {
|
||||
struct sway_container *workspace_next(struct sway_container *current) {
|
||||
return workspace_prev_next_impl(current, true);
|
||||
}
|
||||
|
||||
swayc_t *workspace_output_prev(swayc_t *current) {
|
||||
struct sway_container *workspace_output_prev(struct sway_container *current) {
|
||||
return workspace_output_prev_next_impl(current, false);
|
||||
}
|
||||
|
||||
swayc_t *workspace_prev(swayc_t *current) {
|
||||
struct sway_container *workspace_prev(struct sway_container *current) {
|
||||
return workspace_prev_next_impl(current, false);
|
||||
}
|
||||
|
||||
bool workspace_switch(swayc_t *workspace) {
|
||||
bool workspace_switch(struct sway_container *workspace) {
|
||||
if (!workspace) {
|
||||
return false;
|
||||
}
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||
struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||
if (!seat || !focus) {
|
||||
return false;
|
||||
}
|
||||
swayc_t *active_ws = focus;
|
||||
struct sway_container *active_ws = focus;
|
||||
if (active_ws->type != C_WORKSPACE) {
|
||||
swayc_parent_by_type(focus, C_WORKSPACE);
|
||||
sway_container_parent(focus, C_WORKSPACE);
|
||||
}
|
||||
|
||||
if (config->auto_back_and_forth
|
||||
&& active_ws == workspace
|
||||
&& prev_workspace_name) {
|
||||
swayc_t *new_ws = workspace_by_name(prev_workspace_name);
|
||||
struct sway_container *new_ws = workspace_by_name(prev_workspace_name);
|
||||
workspace = new_ws ? new_ws : workspace_create(prev_workspace_name);
|
||||
}
|
||||
|
||||
|
|
@ -231,12 +231,12 @@ bool workspace_switch(swayc_t *workspace) {
|
|||
// TODO: Deal with sticky containers
|
||||
|
||||
wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);
|
||||
swayc_t *next = sway_seat_get_focus_inactive(seat, workspace);
|
||||
struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace);
|
||||
if (next == NULL) {
|
||||
next = workspace;
|
||||
}
|
||||
sway_seat_set_focus(seat, next);
|
||||
swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT);
|
||||
struct sway_container *output = sway_container_parent(workspace, C_OUTPUT);
|
||||
arrange_windows(output, -1, -1);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue