diff options
author | 2018-07-25 19:26:12 +1000 | |
---|---|---|
committer | 2018-07-25 19:26:12 +1000 | |
commit | b14bd1b0b1536039e4f46fe94515c7c44e7afc61 (patch) | |
tree | 9c55f79248819337f9d5c4310896eb86c49a533c /sway | |
parent | Merge pull request #2352 from RedSoxFan/implement-2335 (diff) | |
download | sway-b14bd1b0b1536039e4f46fe94515c7c44e7afc61.tar.gz sway-b14bd1b0b1536039e4f46fe94515c7c44e7afc61.tar.zst sway-b14bd1b0b1536039e4f46fe94515c7c44e7afc61.zip |
Fix crash when closing last child of a tabbed container
The crash only occurs if the mouse cursor is above the tabbed container
when the last child is closed.
Introduced in 03d49490ccff3c5c81bea73622c8616fa61eb3dd, over a week ago
and unnoticed until now :O
The above commit changes the behaviour of a focus change. When you
change focus, it sends pointer motion which makes the client set a new
cursor image. We already had this behaviour for workspace switching, but
this commit adds it for view switching too, such as in a tabbed
container or when closing a view.
The sequence of events that leads to the crash is:
* The last child of a tabbed container unmaps, which triggers a
`destroy` event before we've cleaned up the child or reaped the tabbed
container.
* The seat code listens to the `destroy` event and removes the seat
container from the focus stack. As part of this, it decides to set focus
to the parent (my fix alters this decision).
* When setting focus to the new parent, the container motion is sent as
per the previously mentioned commit.
* The motion code uses `container_at`, which encounters the tabbed
container and its child in a half destroyed state, and everything blows
up from there.
`con->parent` is needed because scratchpad containers don't have parents
if they're hidden, so this probably fixes a crash when a hidden
scratchpad container closes too.
The `con->parent->children->length > 1` check should catch any cases
where the parent is about to be reaped.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/seat.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index fc9e54b6..8c634e5f 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -181,6 +181,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
181 | bool set_focus = | 181 | bool set_focus = |
182 | focus != NULL && | 182 | focus != NULL && |
183 | (focus == con || container_has_child(con, focus)) && | 183 | (focus == con || container_has_child(con, focus)) && |
184 | con->parent && con->parent->children->length > 1 && | ||
184 | con->type != C_WORKSPACE; | 185 | con->type != C_WORKSPACE; |
185 | 186 | ||
186 | seat_container_destroy(seat_con); | 187 | seat_container_destroy(seat_con); |