diff --git a/seat.c b/seat.c index 75a6a78..23fd593 100644 --- a/seat.c +++ b/seat.c @@ -1089,22 +1089,25 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) { } } - if(prev_view == view) { + if(seat->seat->keyboard_state.focused_surface == view->wlr_surface) { return; } #if CG_HAS_XWAYLAND - if(view->type == CG_XWAYLAND_VIEW) { + if(view->type == CG_XWAYLAND_VIEW && ! xwayland_view_should_manage(view)) { const struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view); if(!wlr_xwayland_or_surface_wants_focus( xwayland_view->xwayland_surface)) { return; } - } + } else #endif + { + if(prev_view != NULL) { + view_activate(prev_view, false); + } - if(prev_view != NULL) { - view_activate(prev_view, false); + seat->focused_view = view; } view_activate(view, true); @@ -1123,7 +1126,5 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) { NULL); } - seat->focused_view = view; - process_cursor_motion(seat, -1); } diff --git a/view.c b/view.c index f849761..95b6b8a 100644 --- a/view.c +++ b/view.c @@ -233,7 +233,7 @@ view_unmap(struct cg_view *view) { struct cg_view* prev = view_get_prev_view(view); struct cg_tile* view_tile = view_get_tile(view); wlr_output_damage_add_box(view_tile->workspace->output->damage, &view_tile->tile); - if(seat_get_focus(view->workspace->server->seat) == view) { + if(view->workspace->server->seat->seat->keyboard_state.focused_surface == NULL || view->workspace->server->seat->seat->keyboard_state.focused_surface == view->wlr_surface) { seat_set_focus(view->workspace->server->seat, prev); } else { view_tile->view = prev; @@ -246,6 +246,9 @@ view_unmap(struct cg_view *view) { #if CG_HAS_XWAYLAND else { view_damage_whole(view); + if(view->workspace->server->seat->seat->keyboard_state.focused_surface == NULL || view->workspace->server->seat->seat->keyboard_state.focused_surface == view->wlr_surface) { + seat_set_focus(view->workspace->server->seat, view->workspace->server->seat->focused_view); + } } #endif