mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
core: Untangle input focus management
In all places (including src/wayland) we tap into meta_x11_display* focus API, which then calls meta_display* API. This relation is backwards, so rework input focus management so it's the other way around. We now have high-level meta_display_(un)set_input_focus functions, which perform the backend-independent maintenance, and calls into the X11 functions where relevant. These functions are what callers should use. https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
This commit is contained in:

committed by
Jonas Ådahl

parent
1d77641f0b
commit
86de79cfc5
@ -779,10 +779,12 @@ meta_display_open (void)
|
||||
if (old_active_window)
|
||||
meta_window_focus (old_active_window, timestamp);
|
||||
else
|
||||
meta_x11_display_focus_the_no_focus_window (display->x11_display, timestamp);
|
||||
meta_display_unset_input_focus (display, timestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_display_unset_input_focus (display, timestamp);
|
||||
}
|
||||
else if (display->x11_display)
|
||||
meta_x11_display_focus_the_no_focus_window (display->x11_display, timestamp);
|
||||
|
||||
meta_idle_monitor_init_dbus ();
|
||||
|
||||
@ -1307,6 +1309,51 @@ meta_display_timestamp_too_old (MetaDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_set_input_focus (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
gboolean focus_frame,
|
||||
guint32 timestamp)
|
||||
{
|
||||
if (meta_display_timestamp_too_old (display, ×tamp))
|
||||
return;
|
||||
|
||||
if (display->x11_display)
|
||||
{
|
||||
MetaX11Display *x11_display = display->x11_display;
|
||||
Window xwindow;
|
||||
gulong serial;
|
||||
|
||||
meta_x11_error_trap_push (x11_display);
|
||||
|
||||
if (window)
|
||||
xwindow = focus_frame ? window->frame->xwindow : window->xwindow;
|
||||
else
|
||||
xwindow = x11_display->no_focus_window;
|
||||
|
||||
meta_x11_display_set_input_focus (x11_display, xwindow, timestamp);
|
||||
serial = XNextRequest (x11_display->xdisplay);
|
||||
|
||||
meta_x11_display_update_focus_window (x11_display, xwindow, serial, TRUE);
|
||||
|
||||
meta_x11_error_trap_pop (display->x11_display);
|
||||
}
|
||||
|
||||
meta_display_update_focus_window (display, window);
|
||||
|
||||
display->last_focus_time = timestamp;
|
||||
|
||||
if (window == NULL || window != display->autoraise_window)
|
||||
meta_display_remove_autoraise_callback (display);
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_unset_input_focus (MetaDisplay *display,
|
||||
guint32 timestamp)
|
||||
{
|
||||
meta_display_set_input_focus (display, NULL, FALSE, timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_register_wayland_window (MetaDisplay *display,
|
||||
MetaWindow *window)
|
||||
|
@ -8088,8 +8088,7 @@ mouse_mode_focus (MetaWindow *window,
|
||||
"Unsetting focus from %s due to mouse entering "
|
||||
"the DESKTOP window\n",
|
||||
display->focus_window->desc);
|
||||
meta_x11_display_focus_the_no_focus_window (display->x11_display,
|
||||
timestamp);
|
||||
meta_display_unset_input_focus (display, timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1308,8 +1308,7 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
||||
meta_topic (META_DEBUG_FOCUS,
|
||||
"Setting focus to no_focus_window, since no valid "
|
||||
"window to focus found.\n");
|
||||
meta_x11_display_focus_the_no_focus_window (workspace->display->x11_display,
|
||||
timestamp);
|
||||
meta_display_unset_input_focus (workspace->display, timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1381,8 +1380,7 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace,
|
||||
else
|
||||
{
|
||||
meta_topic (META_DEBUG_FOCUS, "No MRU window to focus found; focusing no_focus_window.\n");
|
||||
meta_x11_display_focus_the_no_focus_window (workspace->display->x11_display,
|
||||
timestamp);
|
||||
meta_display_unset_input_focus (workspace->display, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user