mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Fix potential null accesses
This commit is contained in:
parent
e7d6b8ec3e
commit
913445e112
2 changed files with 54 additions and 48 deletions
|
@ -311,37 +311,39 @@ static bool container_move_in_direction(struct sway_container *container,
|
||||||
|
|
||||||
while (current) {
|
while (current) {
|
||||||
list_t *siblings = container_get_siblings(current);
|
list_t *siblings = container_get_siblings(current);
|
||||||
enum sway_container_layout layout = container_parent_layout(current);
|
if (siblings) {
|
||||||
int index = list_find(siblings, current);
|
enum sway_container_layout layout = container_parent_layout(current);
|
||||||
int desired = index + offs;
|
int index = list_find(siblings, current);
|
||||||
|
int desired = index + offs;
|
||||||
|
|
||||||
// Don't allow containers to move out of their
|
// Don't allow containers to move out of their
|
||||||
// fullscreen or floating parent
|
// fullscreen or floating parent
|
||||||
if (current->fullscreen_mode || container_is_floating(current)) {
|
if (current->fullscreen_mode || container_is_floating(current)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_parallel(layout, move_dir)) {
|
if (is_parallel(layout, move_dir)) {
|
||||||
if (desired == -1 || desired == siblings->length) {
|
if (desired == -1 || desired == siblings->length) {
|
||||||
if (current->parent == container->parent) {
|
if (current->parent == container->parent) {
|
||||||
current = current->parent;
|
current = current->parent;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
// Reparenting
|
|
||||||
if (current->parent) {
|
|
||||||
container_insert_child(current->parent, container,
|
|
||||||
index + (offs < 0 ? 0 : 1));
|
|
||||||
} else {
|
} else {
|
||||||
workspace_insert_tiling(current->workspace, container,
|
// Reparenting
|
||||||
index + (offs < 0 ? 0 : 1));
|
if (current->parent) {
|
||||||
|
container_insert_child(current->parent, container,
|
||||||
|
index + (offs < 0 ? 0 : 1));
|
||||||
|
} else {
|
||||||
|
workspace_insert_tiling(current->workspace, container,
|
||||||
|
index + (offs < 0 ? 0 : 1));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Container can move within its siblings
|
||||||
|
container_move_to_container_from_direction(container,
|
||||||
|
siblings->items[desired], move_dir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Container can move within its siblings
|
|
||||||
container_move_to_container_from_direction(container,
|
|
||||||
siblings->items[desired], move_dir);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,26 +352,28 @@ static bool container_move_in_direction(struct sway_container *container,
|
||||||
|
|
||||||
// Maybe rejigger the workspace
|
// Maybe rejigger the workspace
|
||||||
struct sway_workspace *ws = container->workspace;
|
struct sway_workspace *ws = container->workspace;
|
||||||
if (!is_parallel(ws->layout, move_dir)) {
|
if (ws) {
|
||||||
workspace_rejigger(ws, container, move_dir);
|
if (!is_parallel(ws->layout, move_dir)) {
|
||||||
return true;
|
workspace_rejigger(ws, container, move_dir);
|
||||||
} else if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
|
return true;
|
||||||
workspace_rejigger(ws, container, move_dir);
|
} else if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
|
||||||
return true;
|
workspace_rejigger(ws, container, move_dir);
|
||||||
}
|
return true;
|
||||||
|
|
||||||
// Try adjacent output
|
|
||||||
struct sway_output *output =
|
|
||||||
output_get_in_direction(container->workspace->output, move_dir);
|
|
||||||
if (output) {
|
|
||||||
struct sway_workspace *ws = output_get_active_workspace(output);
|
|
||||||
if (!sway_assert(ws, "Expected output to have a workspace")) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
container_move_to_workspace_from_direction(container, ws, move_dir);
|
|
||||||
return true;
|
// Try adjacent output
|
||||||
|
struct sway_output *output =
|
||||||
|
output_get_in_direction(container->workspace->output, move_dir);
|
||||||
|
if (output) {
|
||||||
|
struct sway_workspace *ws = output_get_active_workspace(output);
|
||||||
|
if (!sway_assert(ws, "Expected output to have a workspace")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
container_move_to_workspace_from_direction(container, ws, move_dir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sway_log(SWAY_DEBUG, "Hit edge of output, nowhere else to go");
|
||||||
}
|
}
|
||||||
sway_log(SWAY_DEBUG, "Hit edge of output, nowhere else to go");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1194,11 +1194,13 @@ void seat_consider_warp_to_focus(struct sway_seat *seat) {
|
||||||
}
|
}
|
||||||
if (config->mouse_warping == WARP_OUTPUT) {
|
if (config->mouse_warping == WARP_OUTPUT) {
|
||||||
struct sway_output *output = node_get_output(focus);
|
struct sway_output *output = node_get_output(focus);
|
||||||
struct wlr_box box;
|
if (output) {
|
||||||
output_get_box(output, &box);
|
struct wlr_box box;
|
||||||
if (wlr_box_contains_point(&box,
|
output_get_box(output, &box);
|
||||||
seat->cursor->cursor->x, seat->cursor->cursor->y)) {
|
if (wlr_box_contains_point(&box,
|
||||||
return;
|
seat->cursor->cursor->x, seat->cursor->cursor->y)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue