mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 00:11:28 +00:00
seat get focus inactive view
This commit is contained in:
parent
4b200869b2
commit
c0f9ee7bd1
|
@ -87,8 +87,12 @@ struct sway_container *seat_get_focus(struct sway_seat *seat);
|
|||
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
|
||||
struct sway_container *container);
|
||||
|
||||
struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
|
||||
struct sway_container *container, enum sway_container_type type);
|
||||
/**
|
||||
* Descend into the focus stack to find the focus-inactive view. Useful for
|
||||
* container placement when they change position in the tree.
|
||||
*/
|
||||
struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
|
||||
struct sway_container *container);
|
||||
|
||||
void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
|
||||
|
||||
|
|
|
@ -86,6 +86,31 @@ static void seat_send_focus(struct sway_seat *seat,
|
|||
}
|
||||
}
|
||||
|
||||
static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
|
||||
struct sway_container *container, enum sway_container_type type) {
|
||||
if (container->type == C_VIEW || container->children->length == 0) {
|
||||
return container;
|
||||
}
|
||||
|
||||
struct sway_seat_container *current = NULL;
|
||||
wl_list_for_each(current, &seat->focus_stack, link) {
|
||||
if (current->container->type != type && type != C_TYPES) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (container_has_child(container, current->container)) {
|
||||
return current->container;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
|
||||
struct sway_container *container) {
|
||||
return seat_get_focus_by_type(seat, container, C_VIEW);
|
||||
}
|
||||
|
||||
static void handle_seat_container_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct sway_seat_container *seat_con =
|
||||
|
@ -549,26 +574,6 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat) {
|
|||
return seat_get_focus_inactive(seat, &root_container);
|
||||
}
|
||||
|
||||
struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
|
||||
struct sway_container *container, enum sway_container_type type) {
|
||||
if (container->type == C_VIEW || container->children->length == 0) {
|
||||
return container;
|
||||
}
|
||||
|
||||
struct sway_seat_container *current = NULL;
|
||||
wl_list_for_each(current, &seat->focus_stack, link) {
|
||||
if (current->container->type != type && type != C_TYPES) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (container_has_child(container, current->container)) {
|
||||
return current->container;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_container *seat_get_focus(struct sway_seat *seat) {
|
||||
if (!seat->has_focus) {
|
||||
return NULL;
|
||||
|
|
|
@ -872,7 +872,7 @@ struct sway_container *container_get_in_direction(
|
|||
}
|
||||
if (next->children && next->children->length) {
|
||||
// TODO consider floating children as well
|
||||
return seat_get_focus_by_type(seat, next, C_VIEW);
|
||||
return seat_get_focus_inactive_view(seat, next);
|
||||
} else {
|
||||
return next;
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ struct sway_container *container_get_in_direction(
|
|||
wlr_log(L_DEBUG,
|
||||
"cont %d-%p dir %i sibling %d: %p", idx,
|
||||
container, dir, desired, desired_con);
|
||||
struct sway_container *next = seat_get_focus_by_type(seat, desired_con, C_VIEW);
|
||||
struct sway_container *next = seat_get_focus_inactive_view(seat, desired_con);
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue