diff --git a/include/labwc.h b/include/labwc.h index a4729178..da922422 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -245,10 +245,14 @@ struct server { uint32_t resize_edges; /* - * Currently focused view. Updated with each "focus change" - * event. This view is drawn with "active" SSD coloring. + * 'active_view' is generally the view with keyboard-focus, updated with + * each "focus change". This view is drawn with "active" SSD coloring. + * + * The exception is when a layer-shell client takes keyboard-focus in + * which case the currently active view stays active. This is important + * for foreign-toplevel protocol. */ - struct view *focused_view; + struct view *active_view; /* * Most recently raised view. Used to avoid unnecessarily * raising the same view over and over. diff --git a/src/action.c b/src/action.c index 7762bc92..fb442ac6 100644 --- a/src/action.c +++ b/src/action.c @@ -599,7 +599,7 @@ view_for_action(struct view *activator, struct server *server, return ctx.view; } default: - return server->focused_view; + return server->active_view; } } diff --git a/src/desktop.c b/src/desktop.c index 66b1372b..08f8ff59 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -173,7 +173,7 @@ desktop_cycle_view(struct server *server, struct view *start_view, if (!start_view) { start_view = first_view(server); - if (!start_view || start_view != server->focused_view) { + if (!start_view || start_view != server->active_view) { return start_view; /* may be NULL */ } } diff --git a/src/input/cursor.c b/src/input/cursor.c index 22680461..da48c12b 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -585,7 +585,7 @@ static void warp_cursor_to_constraint_hint(struct seat *seat, struct wlr_pointer_constraint_v1 *constraint) { - if (!seat->server->focused_view) { + if (!seat->server->active_view) { return; } @@ -594,8 +594,8 @@ warp_cursor_to_constraint_hint(struct seat *seat, double sx = constraint->current.cursor_hint.x; double sy = constraint->current.cursor_hint.y; wlr_cursor_warp(seat->cursor, NULL, - seat->server->focused_view->current.x + sx, - seat->server->focused_view->current.y + sy); + seat->server->active_view->current.x + sx, + seat->server->active_view->current.y + sy); /* Make sure we are not sending unnecessary surface movements */ wlr_seat_pointer_warp(seat->seat, sx, sy); @@ -645,7 +645,7 @@ create_constraint(struct wl_listener *listener, void *data) constraint->destroy.notify = destroy_constraint; wl_signal_add(&wlr_constraint->events.destroy, &constraint->destroy); - struct view *view = server->focused_view; + struct view *view = server->active_view; if (view && view->surface == wlr_constraint->surface) { constrain_cursor(server, wlr_constraint); } @@ -693,8 +693,8 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub double sx = seat->cursor->x; double sy = seat->cursor->y; - sx -= seat->server->focused_view->current.x; - sy -= seat->server->focused_view->current.y; + sx -= seat->server->active_view->current.x; + sy -= seat->server->active_view->current.y; double sx_confined, sy_confined; if (!wlr_region_confine(&seat->current_constraint->region, sx, sy, diff --git a/src/input/keyboard.c b/src/input/keyboard.c index 8c0fe1d3..b9d01ac5 100644 --- a/src/input/keyboard.c +++ b/src/input/keyboard.c @@ -104,8 +104,8 @@ match_keybinding_for_sym(struct server *server, uint32_t modifiers, continue; } if (server->seat.nr_inhibited_keybind_views - && server->focused_view - && server->focused_view->inhibits_keybinds + && server->active_view + && server->active_view->inhibits_keybinds && !actions_contain_toggle_keybinds(&keybind->actions)) { continue; } diff --git a/src/seat.c b/src/seat.c index cc170da5..36aa3151 100644 --- a/src/seat.c +++ b/src/seat.c @@ -358,20 +358,20 @@ focus_change_notify(struct wl_listener *listener, void *data) * active. This fixes an issue with menus immediately closing in * some X11 apps (try LibreOffice with SAL_USE_VCLPLUGIN=gen). */ - if (!view && server->focused_view && event->new_surface - && view_is_related(server->focused_view, + if (!view && server->active_view && event->new_surface + && view_is_related(server->active_view, event->new_surface)) { return; } - if (view != server->focused_view) { - if (server->focused_view) { - view_set_activated(server->focused_view, false); + if (view != server->active_view) { + if (server->active_view) { + view_set_activated(server->active_view, false); } if (view) { view_set_activated(view, true); } - server->focused_view = view; + server->active_view = view; } } diff --git a/src/view-impl-common.c b/src/view-impl-common.c index ede58bf1..6e6ae5c9 100644 --- a/src/view-impl-common.c +++ b/src/view-impl-common.c @@ -56,7 +56,7 @@ void view_impl_unmap(struct view *view) { struct server *server = view->server; - if (view == server->focused_view) { + if (view == server->active_view) { desktop_focus_topmost_view(server); } if (view == server->last_raised_view) { diff --git a/src/view.c b/src/view.c index 97675cf0..58d77e10 100644 --- a/src/view.c +++ b/src/view.c @@ -1071,7 +1071,7 @@ decorate(struct view *view) { if (!view->ssd) { view->ssd = ssd_create(view, - view == view->server->focused_view); + view == view->server->active_view); } } @@ -1797,8 +1797,8 @@ view_destroy(struct view *view) regions_hide_overlay(&server->seat); } - if (server->focused_view == view) { - server->focused_view = NULL; + if (server->active_view == view) { + server->active_view = NULL; need_cursor_update = true; } diff --git a/src/workspaces.c b/src/workspaces.c index 2ca5f9f1..92656ee8 100644 --- a/src/workspaces.c +++ b/src/workspaces.c @@ -310,7 +310,7 @@ workspaces_switch_to(struct workspace *target, bool update_focus) * Only refocus if the focus is not already on an always-on-top view. */ if (update_focus) { - struct view *view = server->focused_view; + struct view *view = server->active_view; if (!view || !view_is_always_on_top(view)) { desktop_focus_topmost_view(server); }