Closed Bug 1692119 Opened 4 years ago Closed 3 years ago

[wayland] Implement xdg_activation_v1

Categories

(Core :: Widget: Gtk, defect, P1)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: emilio, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The test-case from bug 1691214 does work on X11 (and all other platforms), but it doesn't seem to work on Wayland.

STR is opening the test-case, clicking one of those buttons, then once it's loaded switching back to the original tab and click on the other. The window should be focused again, but it doesn't.

Attached file Simpler test-case.

Ah, seems known: https://searchfox.org/mozilla-central/rev/04f921656dfd19a5afa503c9b9780a1a389f14c4/widget/gtk/nsWindow.cpp#2198-2205

Is this a GTK issue? Or something else? Is wayland really not supposed to have this capability?

Yes, Wayland does not support that. The xdg_activation protocol looks promising!

Priority: -- → P2
Blocks: wayland-tests
No longer blocks: wayland

Let's try to workaround it until xdg_activation protocol is ready.

Blocks: wayland
No longer blocks: wayland
Priority: P2 → P1
Summary: [wayland] Can't switch window focus programmatically → [wayland] Implement support for xdg_activation_v1
Summary: [wayland] Implement support for xdg_activation_v1 → [wayland] Implement xdg_activation_v1

The testcase here works with latest nightly & KDE on Fedora 35.
I'll also look at https://gitlab.gnome.org/GNOME/mutter/-/issues/2044#note_1326421 which seems to affect mutter.

For the record, Carlos Garnacho suggested that the usage here might be a bit unusual and Mutter maybe being overly strict. He send me a patch but the link has timed out, will ask him again for it and try if that fixes the xdg-activation issue.

Can you post the command you use to run a failing test?

(In reply to Robert Mader [:rmader] from comment #7)

For the record, Carlos Garnacho suggested that the usage here might be a bit unusual and Mutter maybe being overly strict. He send me a patch but the link has timed out, will ask him again for it and try if that fixes the xdg-activation issue.

Can you post the command you use to run a failing test?

I use this testcase:
https://bugzilla.mozilla.org/show_bug.cgi?id=1692119#c1

From my debugging done in mutter is fails at meta_wayland_seat_get_grab_info()
and here meta_wayland_pointer_can_grab_surface() fails because of different wl_surfaces.

To debug it put breakpoint to activation_activate() at meta-wayland-activation.c file (I run nested mutter compositor for the debugging purpose).
Another way how to run Firefox is just to run the testsuite from Firefox tree like:

WAYLAND_DISPLAY=wayland-1 MOZ_ENABLE_WAYLAND=1 ./mach mochitest toolkit

(where wayland-1 is display of the nested compositor)

Thanks! Here's a proposed patch that might make it work: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2137

However Carlos asks: "doing xdg_activation_token_v1_set_surface with the requester surface is hard to do on the Firefox side?" - you may want to talk to him on #gnome-shell, maybe this is solvable in Firefox.

Ah, that easy :)

Ok, I can confirm it works on plasma but not on Mutter - also with the MR linked above.

(In reply to Robert Mader [:rmader] from comment #9)

Thanks! Here's a proposed patch that might make it work: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2137

However Carlos asks: "doing xdg_activation_token_v1_set_surface with the requester surface is hard to do on the Firefox side?" - you may want to talk to him on #gnome-shell, maybe this is solvable in Firefox.

We already do that:
https://searchfox.org/mozilla-central/rev/3407e72ceb5039da514c03ae61bd279b1725c3b2/widget/gtk/nsWindow.cpp#2899

Dropping last comment from chat here:

hmm, it's not the surface, but the serial which is wrong. At https://hg.mozilla.org/mozilla-central/rev/19a1500c08e3#l1.116 that GetLastUserInputTime() should be the serial received on wl_pointer.button
which is awkward here, since gdk won't give you that
makes me wonder how does plasma do those checks

xdg_activation spec does not say anything about pointer button event time. If we need any user input there the protocol is useless as we can use gtk_window_present_with_time().

IIUC xdg_activation is used to transfer focus from one focused window to another one (to prevent focus stealing) but you don't need any particular time for that - important it the focused surface which is 'source' of the focus.

Also note according to doc set_serial call is optional (but we set that anyway).

Also mutter crashes when set_serial call is missing as it uses null wl_seat. From my testing KDE requests only focused source surface where the focus change is initiated.

Emilio, is there any possibility to extent the testcase to switch focus without user interaction? For instance open new window and pass focus back to main window. I tried so in timeout callback but the focus switch does not work even in X11. Is there any focus change protection so JS code can't operate with it?

Flags: needinfo?(emilio)

Yeah, we require user activation for focus generally (unless it's a privileged caller). I think dom.disable_window_flip=false should remove that requirement: https://searchfox.org/mozilla-central/rev/dfc0dea63a16b73078a46b6ae49b2a626b8c11b5/docshell/base/BrowsingContext.cpp#2310-2329

Flags: needinfo?(emilio)

According to https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2148 it should be working in mutter-41.3 so let's wait to it.

I can confirm the xdg-activation works with mutter-41.2-2.fc35.x86_64 so we can run the testsuite there.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: