mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
compositor: Remove dead code
When grabbing the devices, there's no error paths that would quit late enough that both pointer and keyboard would need ungrabbing, so the keyboard checks were dead code. Fix this by dropping the boolean variable checks, and adding goto labels to unroll the operation properly at every stage. CID: #1418254 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
This commit is contained in:
parent
0a7547a195
commit
8ede36b2ef
@ -353,33 +353,24 @@ grab_devices (MetaModalOptions options,
|
|||||||
guint32 timestamp)
|
guint32 timestamp)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = META_BACKEND (meta_get_backend ());
|
MetaBackend *backend = META_BACKEND (meta_get_backend ());
|
||||||
gboolean pointer_grabbed = FALSE;
|
|
||||||
gboolean keyboard_grabbed = FALSE;
|
|
||||||
|
|
||||||
if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
|
if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
|
||||||
{
|
{
|
||||||
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp))
|
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
pointer_grabbed = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
|
if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
|
||||||
{
|
{
|
||||||
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp))
|
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp))
|
||||||
goto fail;
|
goto ungrab_pointer;
|
||||||
|
|
||||||
keyboard_grabbed = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
fail:
|
ungrab_pointer:
|
||||||
if (pointer_grabbed)
|
|
||||||
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
|
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
|
||||||
if (keyboard_grabbed)
|
fail:
|
||||||
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user