mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
address feedback
This commit is contained in:
parent
4ec8bf4cee
commit
4c394a0e9e
|
@ -121,23 +121,17 @@ struct sway_container *container_find(struct sway_container *container,
|
|||
struct sway_container *container_parent(struct sway_container *container,
|
||||
enum sway_container_type type);
|
||||
|
||||
/**
|
||||
* Run a function for each child.
|
||||
*/
|
||||
void sway_container_for_each(struct sway_container *container,
|
||||
void (*f)(struct sway_container *view, void *data), void *data);
|
||||
|
||||
/**
|
||||
* Find a container at the given coordinates.
|
||||
*/
|
||||
struct sway_container *sway_container_at(struct sway_container *parent,
|
||||
struct sway_container *container_at(struct sway_container *parent,
|
||||
double lx, double ly, struct wlr_surface **surface,
|
||||
double *sx, double *sy);
|
||||
|
||||
/**
|
||||
* Apply the function for each child of the container breadth first.
|
||||
*/
|
||||
void sway_container_for_each_bfs(struct sway_container *container,
|
||||
void container_for_each(struct sway_container *container,
|
||||
void (*f)(struct sway_container *container, void *data), void *data);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -435,7 +435,7 @@ list_t *container_for_crit_tokens(list_t *tokens) {
|
|||
struct list_tokens list_tokens =
|
||||
(struct list_tokens){create_list(), tokens};
|
||||
|
||||
sway_container_for_each(&root_container,
|
||||
container_for_each(&root_container,
|
||||
(void (*)(struct sway_container *, void *))container_match_add,
|
||||
&list_tokens);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor,
|
|||
}
|
||||
|
||||
struct sway_container *swayc =
|
||||
sway_container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
|
||||
container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
|
||||
if (swayc) {
|
||||
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
||||
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
|
||||
|
@ -88,7 +88,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
|||
struct wlr_surface *surface = NULL;
|
||||
double sx, sy;
|
||||
struct sway_container *swayc =
|
||||
sway_container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
|
||||
container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
|
||||
|
||||
sway_seat_set_focus(cursor->seat, swayc);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input,
|
|||
// init the focus stack
|
||||
wl_list_init(&seat->focus_stack);
|
||||
|
||||
sway_container_for_each_bfs(&root_container, collect_focus_iter, seat);
|
||||
container_for_each(&root_container, collect_focus_iter, seat);
|
||||
|
||||
wl_signal_add(&root_container.sway_root->events.new_container,
|
||||
&seat->new_container);
|
||||
|
|
|
@ -38,7 +38,7 @@ static void notify_new_container(struct sway_container *container) {
|
|||
ipc_event_window(container, "new");
|
||||
}
|
||||
|
||||
static struct sway_container *new_swayc(enum sway_container_type type) {
|
||||
static struct sway_container *container_create(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;
|
||||
struct sway_container *c = calloc(1, sizeof(struct sway_container));
|
||||
|
@ -122,7 +122,7 @@ struct sway_container *container_output_create(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_container *output = new_swayc(C_OUTPUT);
|
||||
struct sway_container *output = container_create(C_OUTPUT);
|
||||
output->sway_output = sway_output;
|
||||
output->name = strdup(name);
|
||||
if (output->name == NULL) {
|
||||
|
@ -151,14 +151,14 @@ struct sway_container *container_output_create(
|
|||
return output;
|
||||
}
|
||||
|
||||
struct sway_container *container_workspace_create(struct sway_container
|
||||
*output, const char *name) {
|
||||
struct sway_container *container_workspace_create(
|
||||
struct sway_container *output, const char *name) {
|
||||
if (!sway_assert(output,
|
||||
"container_workspace_create called with null output")) {
|
||||
return NULL;
|
||||
}
|
||||
wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name);
|
||||
struct sway_container *workspace = new_swayc(C_WORKSPACE);
|
||||
struct sway_container *workspace = container_create(C_WORKSPACE);
|
||||
|
||||
workspace->x = output->x;
|
||||
workspace->y = output->y;
|
||||
|
@ -182,7 +182,7 @@ struct sway_container *container_view_create(struct sway_container *sibling,
|
|||
return NULL;
|
||||
}
|
||||
const char *title = view_get_title(sway_view);
|
||||
struct sway_container *swayc = new_swayc(C_VIEW);
|
||||
struct sway_container *swayc = container_create(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
|
||||
|
@ -314,30 +314,7 @@ struct sway_container *container_parent(struct sway_container *container,
|
|||
return container;
|
||||
}
|
||||
|
||||
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,
|
||||
struct sway_container *container_at(struct sway_container *parent,
|
||||
double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx, double *sy) {
|
||||
list_t *queue = get_bfs_queue();
|
||||
|
@ -423,7 +400,7 @@ struct sway_container *sway_container_at(struct sway_container *parent,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void sway_container_for_each_bfs(struct sway_container *con,
|
||||
void container_for_each(struct sway_container *con,
|
||||
void (*f)(struct sway_container *con, void *data), void *data) {
|
||||
list_t *queue = get_bfs_queue();
|
||||
if (!queue) {
|
||||
|
|
Loading…
Reference in a new issue