mirror of
https://github.com/swaywm/sway.git
synced 2025-03-18 20:39:33 +00:00
Change container_get_first_view signature
This will have the function stop the recusive calls as soon as the first view is found - unlike before
This commit is contained in:
parent
c2eaf01767
commit
88fb849e59
3 changed files with 15 additions and 8 deletions
|
@ -164,8 +164,7 @@ struct sway_container *tiling_container_at(
|
||||||
struct sway_node *parent, double lx, double ly,
|
struct sway_node *parent, double lx, double ly,
|
||||||
struct wlr_surface **surface, double *sx, double *sy);
|
struct wlr_surface **surface, double *sx, double *sy);
|
||||||
|
|
||||||
void container_get_first_view(struct sway_container *container,
|
struct sway_container *container_get_first_view(struct sway_container *container);
|
||||||
struct sway_container **view);
|
|
||||||
|
|
||||||
void container_for_each_child(struct sway_container *container,
|
void container_for_each_child(struct sway_container *container,
|
||||||
void (*f)(struct sway_container *container, void *data), void *data);
|
void (*f)(struct sway_container *container, void *data), void *data);
|
||||||
|
|
|
@ -90,10 +90,13 @@ static void set_new_focus(struct sway_workspace *ws, struct sway_seat *seat) {
|
||||||
if (ws->tiling->length) {
|
if (ws->tiling->length) {
|
||||||
// this needs to be more specific (focus not just every container,
|
// this needs to be more specific (focus not just every container,
|
||||||
// but single windows
|
// but single windows
|
||||||
struct sway_container *first_view;
|
|
||||||
struct sway_container *container = ws->tiling->items[0];
|
struct sway_container *container = ws->tiling->items[0];
|
||||||
|
struct sway_container *first_view = container_get_first_view(container);
|
||||||
|
|
||||||
|
if (!first_view) {
|
||||||
|
seat_set_focus(seat, &ws->node);
|
||||||
|
}
|
||||||
|
|
||||||
container_get_first_view(container, &first_view);
|
|
||||||
seat_set_focus(seat, &first_view->node);
|
seat_set_focus(seat, &first_view->node);
|
||||||
} else if (ws->floating->length) {
|
} else if (ws->floating->length) {
|
||||||
seat_set_focus(seat, ws->floating->items[0]);
|
seat_set_focus(seat, ws->floating->items[0]);
|
||||||
|
|
|
@ -430,18 +430,23 @@ struct sway_container *container_at(struct sway_workspace *workspace,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void container_get_first_view(struct sway_container *container,
|
struct sway_container *container_get_first_view(struct sway_container *container) {
|
||||||
struct sway_container **view) {
|
|
||||||
if (container->view) {
|
if (container->view) {
|
||||||
*view = container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container->pending.children) {
|
if (container->pending.children) {
|
||||||
for (int i = 0; i < container->pending.children->length; ++i) {
|
for (int i = 0; i < container->pending.children->length; ++i) {
|
||||||
struct sway_container *child = container->pending.children->items[i];
|
struct sway_container *child = container->pending.children->items[i];
|
||||||
container_get_first_view(child, view);
|
struct sway_container *view = container_get_first_view(child);
|
||||||
|
|
||||||
|
if (view) {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void container_for_each_child(struct sway_container *container,
|
void container_for_each_child(struct sway_container *container,
|
||||||
|
|
Loading…
Add table
Reference in a new issue