mirror of
https://github.com/brl/mutter.git
synced 2025-01-07 02:02:14 +00:00
cursor-tracker: Add API to keep the wayland pointer focus while hidden
Since commita2a8f0cda
we force the focus surface of the meta-wayland-pointer to NULL while the pointer is invisible. This introduced an issue with the a11y magnifier of the shell, which uses `meta_cursor_tracker_set_pointer_visible` to hide the real cursor and show its own magnified cursor at the correct position: Because the meta-wayland-pointer is still used to communicate with Wayland clients, the UI of the windows will not respond to mouse movement anymore as soon as the real cursor is hidden. Fix this issue for now by adding an additional method to the cursor-tracker which allows disabling the behavior commita2a8f0cda
introduced. https://gitlab.gnome.org/GNOME/mutter/merge_requests/832
This commit is contained in:
parent
06202c342b
commit
cbbffd1db7
@ -31,6 +31,7 @@ struct _MetaCursorTracker {
|
||||
GObject parent_instance;
|
||||
|
||||
gboolean is_showing;
|
||||
gboolean keep_focus_while_hidden;
|
||||
|
||||
MetaCursorSprite *effective_cursor; /* May be NULL when hidden */
|
||||
MetaCursorSprite *displayed_cursor;
|
||||
|
@ -136,6 +136,7 @@ static void
|
||||
meta_cursor_tracker_init (MetaCursorTracker *self)
|
||||
{
|
||||
self->is_showing = TRUE;
|
||||
self->keep_focus_while_hidden = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -457,6 +458,44 @@ meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker,
|
||||
g_signal_emit (tracker, signals[VISIBILITY_CHANGED], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_cursor_tracker_get_keep_focus_while_hidden:
|
||||
* @tracker: a #MetaCursorTracker object.
|
||||
*
|
||||
* Returns: %FALSE if the Wayland focus surface of the pointer will
|
||||
* be forced to NULL while the pointer is hidden, %TRUE otherwise.
|
||||
* This function is only meant to be used by the magnifier of the shell
|
||||
* and will be removed in a future release.
|
||||
*/
|
||||
gboolean
|
||||
meta_cursor_tracker_get_keep_focus_while_hidden (MetaCursorTracker *tracker)
|
||||
{
|
||||
return tracker->keep_focus_while_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_cursor_tracker_set_keep_focus_while_hidden:
|
||||
* @tracker: a #MetaCursorTracker object.
|
||||
* @keep_focus: whether to keep the cursor focus while hidden
|
||||
*
|
||||
* If this is set to %TRUE, the Wayland focus surface of the pointer will
|
||||
* not be forced to NULL while the pointer is hidden.
|
||||
* This function is only meant to be used by the magnifier of the shell
|
||||
* and will be removed in a future release.
|
||||
*/
|
||||
void
|
||||
meta_cursor_tracker_set_keep_focus_while_hidden (MetaCursorTracker *tracker,
|
||||
gboolean keep_focus)
|
||||
{
|
||||
if (keep_focus == tracker->keep_focus_while_hidden)
|
||||
return;
|
||||
tracker->keep_focus_while_hidden = keep_focus;
|
||||
|
||||
sync_cursor (tracker);
|
||||
|
||||
g_signal_emit (tracker, signals[VISIBILITY_CHANGED], 0);
|
||||
}
|
||||
|
||||
MetaCursorSprite *
|
||||
meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker)
|
||||
{
|
||||
|
@ -62,4 +62,11 @@ META_EXPORT
|
||||
void meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker,
|
||||
gboolean visible);
|
||||
|
||||
META_EXPORT
|
||||
gboolean meta_cursor_tracker_get_keep_focus_while_hidden (MetaCursorTracker *tracker);
|
||||
|
||||
META_EXPORT
|
||||
void meta_cursor_tracker_set_keep_focus_while_hidden (MetaCursorTracker *tracker,
|
||||
gboolean keep_focus);
|
||||
|
||||
#endif
|
||||
|
@ -228,7 +228,8 @@ sync_focus_surface (MetaWaylandPointer *pointer)
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||
|
||||
if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker))
|
||||
if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker) &&
|
||||
!meta_cursor_tracker_get_keep_focus_while_hidden (cursor_tracker))
|
||||
{
|
||||
meta_wayland_pointer_set_focus (pointer, NULL);
|
||||
return;
|
||||
@ -433,7 +434,8 @@ default_grab_focus (MetaWaylandPointerGrab *grab,
|
||||
if (!meta_wayland_seat_has_pointer (seat))
|
||||
return;
|
||||
|
||||
if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker))
|
||||
if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker) &&
|
||||
!meta_cursor_tracker_get_keep_focus_while_hidden (cursor_tracker))
|
||||
return;
|
||||
|
||||
if (pointer->button_count > 0)
|
||||
@ -898,7 +900,8 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
|
||||
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||
|
||||
g_return_if_fail (meta_cursor_tracker_get_pointer_visible (cursor_tracker) ||
|
||||
surface == NULL);
|
||||
meta_cursor_tracker_get_keep_focus_while_hidden (cursor_tracker) ||
|
||||
surface == NULL);
|
||||
|
||||
if (pointer->focus_surface == surface)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user