mirror of
https://github.com/swaywm/sway.git
synced 2026-03-19 05:34:00 -04:00
Fix scratchpad fullscreen behavior and crash
When setting fullscreen on a hidden scratchpad container, there was a check to see if there was an existing fullscreen container on the workspace so it could be fullscreen disabled first. Since the workspace is NULL, it would cause a SIGSEGV. This adds a NULL check to avoid the crash. This also changes the behavior of how fullscreen is handled when adding a container to the scratchpad or changing visibility of a scratchpad container to match i3's. The behavior is as follows: - When adding a container to the scratchpad or hiding a container back into the scratchpad, there is an implicit fullscreen disable - When setting fullscreen on a container that is hidden in the scratchpad, it will be fullscreen when shown (and fullscreen disabled when hidden as stated above) - When setting fullscreen global on a container that is hidden in the scratchpad, it will be shown immediately as fullscreen global. The container is not moved to a workspace and remains in the scratchpad. The container will be visible until fullscreen disabled or killed. Since the container is in the scratchpad, running `scratchpad show` or `move container to scratchpad` will have no effect This also changes `container_replace` to transfer fullscreen and scratchpad status.
This commit is contained in:
parent
913445e112
commit
69a1a0ff99
14 changed files with 220 additions and 57 deletions
|
|
@ -197,10 +197,11 @@ static bool gaps_to_edge(struct sway_view *view) {
|
|||
|
||||
void view_autoconfigure(struct sway_view *view) {
|
||||
struct sway_container *con = view->container;
|
||||
if (container_is_scratchpad_hidden(con)) {
|
||||
if (container_is_scratchpad_hidden(con) &&
|
||||
con->fullscreen_mode != FULLSCREEN_GLOBAL) {
|
||||
return;
|
||||
}
|
||||
struct sway_output *output = con->workspace->output;
|
||||
struct sway_output *output = con->workspace ? con->workspace->output : NULL;
|
||||
|
||||
if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
|
||||
con->content_x = output->lx;
|
||||
|
|
@ -226,19 +227,21 @@ void view_autoconfigure(struct sway_view *view) {
|
|||
|
||||
con->border_top = con->border_bottom = true;
|
||||
con->border_left = con->border_right = true;
|
||||
if (config->hide_edge_borders == E_BOTH
|
||||
|| config->hide_edge_borders == E_VERTICAL
|
||||
|| (smart && !other_views && no_gaps)) {
|
||||
con->border_left = con->x - con->current_gaps.left != ws->x;
|
||||
int right_x = con->x + con->width + con->current_gaps.right;
|
||||
con->border_right = right_x != ws->x + ws->width;
|
||||
}
|
||||
if (config->hide_edge_borders == E_BOTH
|
||||
|| config->hide_edge_borders == E_HORIZONTAL
|
||||
|| (smart && !other_views && no_gaps)) {
|
||||
con->border_top = con->y - con->current_gaps.top != ws->y;
|
||||
int bottom_y = con->y + con->height + con->current_gaps.bottom;
|
||||
con->border_bottom = bottom_y != ws->y + ws->height;
|
||||
if (ws) {
|
||||
if (config->hide_edge_borders == E_BOTH
|
||||
|| config->hide_edge_borders == E_VERTICAL
|
||||
|| (smart && !other_views && no_gaps)) {
|
||||
con->border_left = con->x - con->current_gaps.left != ws->x;
|
||||
int right_x = con->x + con->width + con->current_gaps.right;
|
||||
con->border_right = right_x != ws->x + ws->width;
|
||||
}
|
||||
if (config->hide_edge_borders == E_BOTH
|
||||
|| config->hide_edge_borders == E_HORIZONTAL
|
||||
|| (smart && !other_views && no_gaps)) {
|
||||
con->border_top = con->y - con->current_gaps.top != ws->y;
|
||||
int bottom_y = con->y + con->height + con->current_gaps.bottom;
|
||||
con->border_bottom = bottom_y != ws->y + ws->height;
|
||||
}
|
||||
}
|
||||
|
||||
double y_offset = 0;
|
||||
|
|
@ -247,7 +250,8 @@ void view_autoconfigure(struct sway_view *view) {
|
|||
// title area. We have to offset the surface y by the height of the title,
|
||||
// bar, and disable any top border because we'll always have the title bar.
|
||||
list_t *siblings = container_get_siblings(con);
|
||||
bool show_titlebar = siblings->length > 1 || !config->hide_lone_tab;
|
||||
bool show_titlebar = (siblings && siblings->length > 1)
|
||||
|| !config->hide_lone_tab;
|
||||
if (show_titlebar && !container_is_floating(con)) {
|
||||
enum sway_container_layout layout = container_parent_layout(con);
|
||||
if (layout == L_TABBED) {
|
||||
|
|
@ -538,6 +542,10 @@ static bool should_focus(struct sway_view *view) {
|
|||
struct sway_workspace *prev_ws = seat_get_focused_workspace(seat);
|
||||
struct sway_workspace *map_ws = view->container->workspace;
|
||||
|
||||
if (view->container->fullscreen_mode == FULLSCREEN_GLOBAL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Views can only take focus if they are mapped into the active workspace
|
||||
if (prev_ws != map_ws) {
|
||||
return false;
|
||||
|
|
@ -581,7 +589,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
|||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
struct sway_node *node = seat_get_focus_inactive(seat, &ws->node);
|
||||
struct sway_node *node = ws ? seat_get_focus_inactive(seat, &ws->node)
|
||||
: seat_get_focus_inactive(seat, &root->node);
|
||||
struct sway_container *target_sibling = node->type == N_CONTAINER ?
|
||||
node->sway_container : NULL;
|
||||
|
||||
|
|
@ -589,12 +598,13 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
|||
// launch it as a tiled view in the root of the workspace instead.
|
||||
if (target_sibling && container_is_floating(target_sibling)) {
|
||||
target_sibling = NULL;
|
||||
ws = seat_get_last_known_workspace(seat);
|
||||
}
|
||||
|
||||
view->container = container_create(view);
|
||||
if (target_sibling) {
|
||||
container_add_sibling(target_sibling, view->container, 1);
|
||||
} else {
|
||||
} else if (ws) {
|
||||
workspace_add_tiling(ws, view->container);
|
||||
}
|
||||
ipc_event_window(view->container, "new");
|
||||
|
|
@ -1032,8 +1042,18 @@ bool view_is_visible(struct sway_view *view) {
|
|||
return false;
|
||||
}
|
||||
struct sway_workspace *workspace = view->container->workspace;
|
||||
if (!workspace) {
|
||||
return false;
|
||||
if (!workspace && view->container->fullscreen_mode != FULLSCREEN_GLOBAL) {
|
||||
bool fs_global_descendant = false;
|
||||
struct sway_container *parent = view->container->parent;
|
||||
while (parent) {
|
||||
if (parent->fullscreen_mode == FULLSCREEN_GLOBAL) {
|
||||
fs_global_descendant = true;
|
||||
}
|
||||
parent = parent->parent;
|
||||
}
|
||||
if (!fs_global_descendant) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Determine if view is nested inside a floating container which is sticky
|
||||
struct sway_container *floater = view->container;
|
||||
|
|
@ -1041,7 +1061,7 @@ bool view_is_visible(struct sway_view *view) {
|
|||
floater = floater->parent;
|
||||
}
|
||||
bool is_sticky = container_is_floating(floater) && floater->is_sticky;
|
||||
if (!is_sticky && !workspace_is_visible(workspace)) {
|
||||
if (!is_sticky && workspace && !workspace_is_visible(workspace)) {
|
||||
return false;
|
||||
}
|
||||
// Check view isn't in a tabbed or stacked container on an inactive tab
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue