mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
Merge pull request #1733 from acrisci/fix-focus-inactive
try to fix focus-inactive
This commit is contained in:
commit
891e1148be
@ -126,7 +126,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
|
|||||||
|
|
||||||
static struct sway_seat_container *seat_container_from_container(
|
static struct sway_seat_container *seat_container_from_container(
|
||||||
struct sway_seat *seat, struct sway_container *con) {
|
struct sway_seat *seat, struct sway_container *con) {
|
||||||
if (con->type < C_WORKSPACE) {
|
if (con->type == C_ROOT || con->type == C_OUTPUT) {
|
||||||
// these don't get seat containers ever
|
// these don't get seat containers ever
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -534,23 +534,19 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat) {
|
|||||||
|
|
||||||
struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
|
struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
|
||||||
struct sway_container *container, enum sway_container_type type) {
|
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;
|
struct sway_seat_container *current = NULL;
|
||||||
struct sway_container *parent = NULL;
|
|
||||||
wl_list_for_each(current, &seat->focus_stack, link) {
|
wl_list_for_each(current, &seat->focus_stack, link) {
|
||||||
parent = current->container->parent;
|
if (current->container->type != type && type != C_TYPES) {
|
||||||
|
continue;
|
||||||
if (current->container == container &&
|
|
||||||
(type == C_TYPES || container->type == type)) {
|
|
||||||
return current->container;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (parent) {
|
if (container_has_child(container, current->container)) {
|
||||||
if (parent == container && (type == C_TYPES ||
|
|
||||||
current->container->type == type)) {
|
|
||||||
return current->container;
|
return current->container;
|
||||||
}
|
}
|
||||||
parent = parent->parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -53,10 +53,16 @@ const char *container_type_to_str(enum sway_container_type type) {
|
|||||||
void container_create_notify(struct sway_container *container) {
|
void container_create_notify(struct sway_container *container) {
|
||||||
// TODO send ipc event type based on the container type
|
// TODO send ipc event type based on the container type
|
||||||
wl_signal_emit(&root_container.sway_root->events.new_container, container);
|
wl_signal_emit(&root_container.sway_root->events.new_container, container);
|
||||||
|
|
||||||
|
if (container->type == C_VIEW || container->type == C_CONTAINER) {
|
||||||
ipc_event_window(container, "new");
|
ipc_event_window(container, "new");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void container_close_notify(struct sway_container *container) {
|
static void container_close_notify(struct sway_container *container) {
|
||||||
|
if (container == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO send ipc event type based on the container type
|
// TODO send ipc event type based on the container type
|
||||||
ipc_event_window(container, "close");
|
ipc_event_window(container, "close");
|
||||||
}
|
}
|
||||||
@ -506,8 +512,8 @@ static bool find_child_func(struct sway_container *con, void *data) {
|
|||||||
|
|
||||||
bool container_has_child(struct sway_container *con,
|
bool container_has_child(struct sway_container *con,
|
||||||
struct sway_container *child) {
|
struct sway_container *child) {
|
||||||
if (child == NULL || child->type == C_VIEW ||
|
if (con == NULL || con->type == C_VIEW ||
|
||||||
child->children->length == 0) {
|
con->children->length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return container_find(con, find_child_func, child);
|
return container_find(con, find_child_func, child);
|
||||||
|
@ -638,16 +638,16 @@ struct sway_container *container_get_in_direction(
|
|||||||
wrap_candidate = parent->children->items[0];
|
wrap_candidate = parent->children->items[0];
|
||||||
}
|
}
|
||||||
if (config->force_focus_wrapping) {
|
if (config->force_focus_wrapping) {
|
||||||
return seat_get_focus_by_type(seat,
|
return wrap_candidate;
|
||||||
wrap_candidate, C_VIEW);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
struct sway_container *desired_con = parent->children->items[desired];
|
||||||
wlr_log(L_DEBUG,
|
wlr_log(L_DEBUG,
|
||||||
"cont %d-%p dir %i sibling %d: %p", idx,
|
"cont %d-%p dir %i sibling %d: %p", idx,
|
||||||
container, dir, desired, parent->children->items[desired]);
|
container, dir, desired, desired_con);
|
||||||
return seat_get_focus_by_type(seat,
|
struct sway_container *next = seat_get_focus_by_type(seat, desired_con, C_VIEW);
|
||||||
parent->children->items[desired], C_VIEW);
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user