Compare commits

..

1 Commits

Author SHA1 Message Date
Julian Sparber
a8d45316c7 gdk/wayland: Always use toplevel surface when transferring focus
Xdg activation for other applications was fixed in
14d99bacbc
but not for transferring focus to a new window of the same application.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/6711
2024-05-16 13:34:05 +02:00
2 changed files with 18 additions and 5 deletions

View File

@@ -2191,6 +2191,21 @@ static const struct xdg_activation_token_v1_listener token_listener = {
token_done,
};
static struct wl_surface *
peek_launcher_toplevel (GdkSeat *seat)
{
struct wl_surface *wl_surface = NULL;
GdkSurface *focus_surface;
focus_surface = gdk_wayland_device_get_focus (gdk_seat_get_keyboard (seat));
while (focus_surface && focus_surface->parent)
focus_surface = focus_surface->parent;
if (focus_surface)
wl_surface = gdk_wayland_surface_get_wl_surface (focus_surface);
return wl_surface;
}
static void
gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
guint32 timestamp)
@@ -2216,7 +2231,6 @@ gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
struct xdg_activation_token_v1 *token;
struct wl_event_queue *event_queue;
struct wl_surface *wl_surface = NULL;
GdkSurface *focus_surface;
event_queue = wl_display_create_queue (display_wayland->wl_display);
@@ -2230,9 +2244,8 @@ gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
_gdk_wayland_seat_get_last_implicit_grab_serial (seat, NULL),
gdk_wayland_seat_get_wl_seat (GDK_SEAT (seat)));
focus_surface = gdk_wayland_device_get_focus (gdk_seat_get_keyboard (GDK_SEAT (seat)));
if (focus_surface)
wl_surface = gdk_wayland_surface_get_wl_surface (focus_surface);
wl_surface = peek_launcher_toplevel (GDK_SEAT (seat));
if (wl_surface)
xdg_activation_token_v1_set_surface (token, wl_surface);

View File

@@ -55,7 +55,7 @@ G_BEGIN_DECLS
* are interpreted relative to text direction.
*
* Baseline support is optional for containers and widgets, and is only available
* for vertical alignment. `GTK_ALIGN_BASELINE_CENTER` and `GTK_ALIGN_BASELINE_FILL`
* for vertical alignment. `GTK_ALIGN_BASELINE_CENTER and `GTK_ALIGN_BASELINE_FILL`
* are treated similar to `GTK_ALIGN_CENTER` and `GTK_ALIGN_FILL`, except that it
* positions the widget to line up the baselines, where that is supported.
*/