mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 00:11:28 +00:00
separate seat get focus and seat get focus inactive
This commit is contained in:
parent
7d8f2c52aa
commit
a7d49da239
|
@ -56,7 +56,9 @@ void sway_seat_configure_xcursor(struct sway_seat *seat);
|
||||||
|
|
||||||
void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container);
|
void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container);
|
||||||
|
|
||||||
swayc_t *sway_seat_get_focus(struct sway_seat *seat, swayc_t *container);
|
swayc_t *sway_seat_get_focus(struct sway_seat *seat);
|
||||||
|
|
||||||
|
swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container);
|
||||||
|
|
||||||
void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config);
|
void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config);
|
||||||
|
|
||||||
|
|
|
@ -282,9 +282,7 @@ struct cmd_results *handle_command(char *_exec) {
|
||||||
}
|
}
|
||||||
if (seat) {
|
if (seat) {
|
||||||
config->handler_context.current_container =
|
config->handler_context.current_container =
|
||||||
(seat->has_focus ?
|
sway_seat_get_focus(seat);
|
||||||
sway_seat_get_focus(seat, &root_container) :
|
|
||||||
NULL);
|
|
||||||
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
||||||
if (res->status != CMD_SUCCESS) {
|
if (res->status != CMD_SUCCESS) {
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
workspace_switch(ws);
|
workspace_switch(ws);
|
||||||
current_container =
|
current_container =
|
||||||
sway_seat_get_focus(config->handler_context.seat, &root_container);
|
sway_seat_get_focus(config->handler_context.seat);
|
||||||
swayc_t *new_output = swayc_parent_by_type(current_container, C_OUTPUT);
|
swayc_t *new_output = swayc_parent_by_type(current_container, C_OUTPUT);
|
||||||
|
|
||||||
if (config->mouse_warping && old_output != new_output) {
|
if (config->mouse_warping && old_output != new_output) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
|
wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
|
||||||
|
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
swayc_t *focus = sway_seat_get_focus(seat, &root_container);
|
swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||||
swayc_t *cont = new_view(focus, sway_view);
|
swayc_t *cont = new_view(focus, sway_view);
|
||||||
sway_view->swayc = cont;
|
sway_view->swayc = cont;
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ bool sway_input_manager_has_focus(struct sway_input_manager *input,
|
||||||
swayc_t *container) {
|
swayc_t *container) {
|
||||||
struct sway_seat *seat = NULL;
|
struct sway_seat *seat = NULL;
|
||||||
wl_list_for_each(seat, &input->seats, link) {
|
wl_list_for_each(seat, &input->seats, link) {
|
||||||
if (seat->has_focus && sway_seat_get_focus(seat, &root_container) == container) {
|
if (sway_seat_get_focus(seat) == container) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,16 +137,14 @@ static void seat_configure_keyboard(struct sway_seat *seat,
|
||||||
struct wlr_keyboard *wlr_keyboard = seat_device->input_device->wlr_device->keyboard;
|
struct wlr_keyboard *wlr_keyboard = seat_device->input_device->wlr_device->keyboard;
|
||||||
sway_keyboard_configure(seat_device->keyboard);
|
sway_keyboard_configure(seat_device->keyboard);
|
||||||
wlr_seat_set_keyboard(seat->wlr_seat,
|
wlr_seat_set_keyboard(seat->wlr_seat,
|
||||||
seat_device->input_device->wlr_device);
|
seat_device->input_device->wlr_device);
|
||||||
if (seat->has_focus) {
|
swayc_t *focus = sway_seat_get_focus(seat);
|
||||||
swayc_t *focus = sway_seat_get_focus(seat, &root_container);
|
if (focus && focus->type == C_VIEW) {
|
||||||
if (focus && focus->type == C_VIEW) {
|
// force notify reenter to pick up the new configuration
|
||||||
// force notify reenter to pick up the new configuration
|
wlr_seat_keyboard_clear_focus(seat->wlr_seat);
|
||||||
wlr_seat_keyboard_clear_focus(seat->wlr_seat);
|
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
||||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
focus->sway_view->surface, wlr_keyboard->keycodes,
|
||||||
focus->sway_view->surface, wlr_keyboard->keycodes,
|
wlr_keyboard->num_keycodes, &wlr_keyboard->modifiers);
|
||||||
wlr_keyboard->num_keycodes, &wlr_keyboard->modifiers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,12 +264,13 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
|
||||||
static void handle_focus_destroy(struct wl_listener *listener, void *data) {
|
static void handle_focus_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct sway_seat *seat = wl_container_of(listener, seat, focus_destroy);
|
struct sway_seat *seat = wl_container_of(listener, seat, focus_destroy);
|
||||||
swayc_t *container = data;
|
swayc_t *container = data;
|
||||||
|
// TODO dont set focus to the parent, set focus to the next focus inactive
|
||||||
|
// of the parent
|
||||||
sway_seat_set_focus(seat, container->parent);
|
sway_seat_set_focus(seat, container->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
|
void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
|
||||||
swayc_t *last_focus =
|
swayc_t *last_focus = sway_seat_get_focus(seat);
|
||||||
(seat->has_focus ? sway_seat_get_focus(seat, &root_container) : NULL);
|
|
||||||
|
|
||||||
if (container && last_focus == container) {
|
if (container && last_focus == container) {
|
||||||
return;
|
return;
|
||||||
|
@ -314,7 +313,7 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
swayc_t *sway_seat_get_focus(struct sway_seat *seat, swayc_t *container) {
|
swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container) {
|
||||||
struct sway_seat_container *current = NULL;
|
struct sway_seat_container *current = NULL;
|
||||||
swayc_t *parent = NULL;
|
swayc_t *parent = NULL;
|
||||||
wl_list_for_each(current, &seat->focus_stack, link) {
|
wl_list_for_each(current, &seat->focus_stack, link) {
|
||||||
|
@ -338,6 +337,13 @@ swayc_t *sway_seat_get_focus(struct sway_seat *seat, swayc_t *container) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swayc_t *sway_seat_get_focus(struct sway_seat *seat) {
|
||||||
|
if (!seat->has_focus) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return sway_seat_get_focus_inactive(seat, &root_container);
|
||||||
|
}
|
||||||
|
|
||||||
void sway_seat_set_config(struct sway_seat *seat,
|
void sway_seat_set_config(struct sway_seat *seat,
|
||||||
struct seat_config *seat_config) {
|
struct seat_config *seat_config) {
|
||||||
// clear configs
|
// clear configs
|
||||||
|
|
|
@ -63,8 +63,8 @@ static bool _workspace_by_name(swayc_t *view, void *data) {
|
||||||
swayc_t *workspace_by_name(const char *name) {
|
swayc_t *workspace_by_name(const char *name) {
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
swayc_t *current_workspace = NULL, *current_output = NULL;
|
swayc_t *current_workspace = NULL, *current_output = NULL;
|
||||||
if (seat->has_focus) {
|
swayc_t *focus = sway_seat_get_focus(seat);
|
||||||
swayc_t *focus = sway_seat_get_focus(seat, &root_container);
|
if (focus) {
|
||||||
current_workspace = swayc_parent_by_type(focus, C_WORKSPACE);
|
current_workspace = swayc_parent_by_type(focus, C_WORKSPACE);
|
||||||
current_output = swayc_parent_by_type(focus, C_OUTPUT);
|
current_output = swayc_parent_by_type(focus, C_OUTPUT);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ swayc_t *workspace_create(const char *name) {
|
||||||
}
|
}
|
||||||
// Otherwise create a new one
|
// Otherwise create a new one
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
swayc_t *focus = sway_seat_get_focus(seat, &root_container);
|
swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||||
parent = focus;
|
parent = focus;
|
||||||
parent = swayc_parent_by_type(parent, C_OUTPUT);
|
parent = swayc_parent_by_type(parent, C_OUTPUT);
|
||||||
return new_workspace(parent, name);
|
return new_workspace(parent, name);
|
||||||
|
@ -195,7 +195,7 @@ bool workspace_switch(swayc_t *workspace) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
swayc_t *focus = sway_seat_get_focus(seat, &root_container);
|
swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container);
|
||||||
if (!seat || !focus) {
|
if (!seat || !focus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue