Skip to content

clutter/actor: Save key-focus state and unset it before destruction

When clutter actors with key focus are destroyed we emit ::key-focus-out on them just after their destruction. This is against our assumption that no signal should be emitted after "::destroy" (see !769 (merged) [1]), and in fact could cause the shell to do actions that we won't ever stop on destroy callback.

To avoid this to happen, connect each actor to its ::key-focus-in/out events and save its key-state (so we can avoid looking for the stage) and use this value in both clutter_actor_has_key_focus() and on destruction to unset the stage key focus before we emit the ::destroy signal.

As result of this, we can now avoid to unset the key focus on actor destruction in the stage.

[1] !769 (merged)

Fixes gnome-shell#1704 (closed)


Another way that we could use to handle this (with some benefits to handle similar cases in future) would be to define a destroy-internal signal that we emit earlier to stop anything like this, and just use it inside clutter-stage.

However, since I didn't find any other case where this could be the case so far (as for example clutter-input-device's on_cursor_actor_destroy that calls _clutter_actor_set_has_pointer don't use signals but prop notifications, which are frozen anyways), I used this implementation, but I can move to the other (that is indeed more flexible) if preferred.

Merge request reports