clutter/backend: Allow unsetting input method

This is needed by GNOME Shell to remove itself as a input method
implementation during its shutdown sequence. We can't do it ourself
later because at mutters own shutdowns equence, the GNOME Shell
Javascript context has by that time already been teared down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2934>
This commit is contained in:
Jonas Ådahl 2023-03-24 11:35:38 +01:00
parent db24557e40
commit 429cc9a674

View File

@ -688,7 +688,7 @@ clutter_backend_get_input_method (ClutterBackend *backend)
/** /**
* clutter_backend_set_input_method: * clutter_backend_set_input_method:
* @backend: the #ClutterBackend * @backend: the #ClutterBackend
* @method: the input method * @method: (nullable): the input method
* *
* Sets the input method to be used by Clutter * Sets the input method to be used by Clutter
**/ **/
@ -696,6 +696,12 @@ void
clutter_backend_set_input_method (ClutterBackend *backend, clutter_backend_set_input_method (ClutterBackend *backend,
ClutterInputMethod *method) ClutterInputMethod *method)
{ {
if (backend->input_method == method)
return;
if (backend->input_method)
clutter_input_method_focus_out (backend->input_method);
g_set_object (&backend->input_method, method); g_set_object (&backend->input_method, method);
} }