mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
seat: fix focus policy logic
Fixes: https://github.com/swaywm/sway/issues/6978
This commit is contained in:
parent
519038a7e9
commit
7f6d1f9fae
1 changed files with 17 additions and 7 deletions
|
|
@ -120,7 +120,7 @@ void seat_idle_notify_activity(struct sway_seat *seat,
|
||||||
*/
|
*/
|
||||||
static void seat_send_activate(struct sway_node *node, struct sway_seat *seat) {
|
static void seat_send_activate(struct sway_node *node, struct sway_seat *seat) {
|
||||||
if (node_is_view(node)) {
|
if (node_is_view(node)) {
|
||||||
if (!seat_is_input_allowed(seat, node->sway_container->view->surface)) {
|
if (!seat_is_focus_allowed(seat, node->sway_container->view->surface)) {
|
||||||
sway_log(SWAY_DEBUG, "Refusing to set focus, input is inhibited");
|
sway_log(SWAY_DEBUG, "Refusing to set focus, input is inhibited");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -193,7 +193,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
|
||||||
struct sway_view *view = node->type == N_CONTAINER ?
|
struct sway_view *view = node->type == N_CONTAINER ?
|
||||||
node->sway_container->view : NULL;
|
node->sway_container->view : NULL;
|
||||||
|
|
||||||
if (view && seat_is_input_allowed(seat, view->surface)) {
|
if (view && seat_is_focus_allowed(seat, view->surface)) {
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
if (view->type == SWAY_VIEW_XWAYLAND) {
|
if (view->type == SWAY_VIEW_XWAYLAND) {
|
||||||
struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
|
struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
|
||||||
|
|
@ -1078,11 +1078,19 @@ void seat_configure_xcursor(struct sway_seat *seat) {
|
||||||
seat->cursor->cursor->y);
|
seat->cursor->cursor->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool seat_is_input_allowed(struct sway_seat *seat,
|
bool seat_is_focus_allowed(struct sway_seat *seat,
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface) {
|
||||||
struct wl_client *client = wl_resource_get_client(surface->resource);
|
if (seat->exclusive_client != NULL) {
|
||||||
return seat->exclusive_client == client ||
|
if (surface == NULL) {
|
||||||
(seat->exclusive_client == NULL && !server.session_lock.locked);
|
return false;
|
||||||
|
}
|
||||||
|
if (seat->exclusive_client != wl_resource_get_client(surface)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (server.session_lock.locked) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_unfocus(struct sway_container *con, void *data) {
|
static void send_unfocus(struct sway_container *con, void *data) {
|
||||||
|
|
@ -1172,6 +1180,8 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
|
||||||
node->sway_workspace : node->sway_container->pending.workspace;
|
node->sway_workspace : node->sway_container->pending.workspace;
|
||||||
struct sway_container *container = node->type == N_CONTAINER ?
|
struct sway_container *container = node->type == N_CONTAINER ?
|
||||||
node->sway_container : NULL;
|
node->sway_container : NULL;
|
||||||
|
struct wlr_surface *surface = node_is_view(node) ?
|
||||||
|
node->sway_container->view->surface : NULL;
|
||||||
|
|
||||||
// Deny setting focus to a view which is hidden by a fullscreen container or global
|
// Deny setting focus to a view which is hidden by a fullscreen container or global
|
||||||
if (container && container_obstructing_fullscreen_container(container)) {
|
if (container && container_obstructing_fullscreen_container(container)) {
|
||||||
|
|
@ -1184,7 +1194,7 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny setting focus when an input grab or lockscreen is active
|
// Deny setting focus when an input grab or lockscreen is active
|
||||||
if (container && !seat_is_input_allowed(seat, container->view->surface)) {
|
if (!seat_is_focus_allowed(seat, surface)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue