swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.69k stars 1.11k forks source link

mouse and dropdown issues in Reaper after sway 1.6 [wlroots 13] in XWayland. #6324

Closed salkin-mada closed 2 years ago

salkin-mada commented 3 years ago

Sway Version: 1.6

Debug Log: sway -d2>sway.log

Configuration File: Default.

Reproduce

  1. Open Reaper DAW.
  2. Mouse to top drop down menu.
  3. Click Options (drop down appears).
  4. Hover mouse downwards on drop down list.
  5. Drop down disappears suddenly without cause. This makes it impossible to select (hover and click) an item "further" down in the list.

Description: Recently, something has broken drop downs when running Reaper in Sway (XWayland that is).

The symptom is: When you click something that produces a drop down, after scrolling/hovering past the first few items with the mouse, the drop down disappears, making it impossible to use them. This seems to affect all drop downs in Reaper.

The bug is caused by something that was introduced in Sway version 1.6 and the accompanying wlroots 0.13. Downgrading to Sway version 1.5 and wlroots 0.12 and the issue is gone.

@madskjeldgaard and @kflak, please elaborate on these findings if needed.

madskjeldgaard commented 3 years ago

We confirmed it is a Sway problem by downgrading but just FYI also tested by downgrading Reaper, which did not help, and tried it in Gnome under Wayland where it seems to work fine according to @kflak.

Though, not all dropdowns work fine on sway 1.5 and wlroots 0.12.

For example:

  1. Open reaper
  2. Add track
  3. Open track fx by clicking track fx button
  4. Add some plugin (any plugin)
  5. Click the preset dropdown (the one that says Default). Sometimes this works, sometimes not. The dropdown itself is unresponsive to mouser hovers sometimes (though keeping the mouse button used to open up the drop down pressed down seems to sometimes make it work). Pressing the + button to the right of it causes another strange dropdown bug where it sometimes freezes the dropdown.
madskjeldgaard commented 3 years ago

There is an accompanying thread on the Reaper forum about this bug by the way (even though this is an xwayland/sway issue) https://forum.cockos.com/showthread.php?p=2453632#post2453632

salkin-mada commented 3 years ago

parts of the Debug Log mentioning xcb error: op ChangeProperty and unhandled X11 property (_NET_WM_ICON_NAME) is found in this wlroots commit:

https://github.com/swaywm/wlroots/commit/be1e7647c3250d67041947d77350488ae00bc3e3#diff-fac25d668c25a18b3be00771f203bfaf9546ce39ab1eed0dbc591174728519fa

kflak commented 3 years ago

In addition to working fine on Gnome wayland, the issue is not present when running on i3.

yrhki commented 3 years ago

Commit https://github.com/swaywm/sway/commit/7ca9ef12f8b6a00b8020a500433fabc6b645d85c broke drop-downs from working. Adding it back makes drop-downs work again.

salkin-mada commented 3 years ago

Great catch! ldd /bin/reaper does not show any shared objects in regards to GUI base. So what ever it is using it is statically linked. Anyone here knows what its based on? GDK?

cfillion commented 3 years ago

GDK 3. The system's libgdk-3.so.0 is loaded at runtime using dlopen in libSwell.so.

salkin-mada commented 3 years ago

Commit 7ca9ef1 broke drop-downs from working. Adding it back makes drop-downs work again.

I am compiling as a subproject. Even with master. Adding back what was removed in the commit @yrhki referred to does not seem to change any drop down focus behavior on my system. Maybe I am missing something? A couple of commits after 7ca9ef1 has also changed things in `void unmanaged_handle_unmap.

For me what fixes the drop down focus in reaper is to just comment out https://github.com/swaywm/sway/blob/bb3fd0abc56f39e35dc7f4e86f25da1b4a6efbd7/sway/desktop/xwayland.c#L118

So why would the focus be set to NULL before being set to previous. ? At least in reaper this seems to close the the drop down or just loose focus when there is a "sub" drop down menu in a drop down menu - that is :).

salkin-mada commented 3 years ago

Will try and see if other X app bugs arise when not setting to NULL if *previous. https://github.com/salkin-mada/sway/tree/drop_down_menu_focus

At least I can use Reaper on sway again.

yrhki commented 3 years ago

@salkin-mada does this work for you?

static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
    struct sway_xwayland_unmanaged *surface =
        wl_container_of(listener, surface, unmap);
    struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
    desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true);
    wl_list_remove(&surface->link);
    wl_list_remove(&surface->set_geometry.link);
    wl_list_remove(&surface->commit.link);

    struct sway_seat *seat = input_manager_current_seat();
    if (seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface) {
        // This simply returns focus to the parent surface if there's one available.
        // This seems to handle JetBrains issues.
        if (xsurface->parent && xsurface->parent->surface
                && wlr_xwayland_or_surface_wants_focus(xsurface->parent)) {
            seat_set_focus_surface(seat, xsurface->parent->surface, false);
            return;
        }

        // Try to find another unmanaged surface from the same process to pass
        // focus to. This is necessary because some applications (e.g. Jetbrains
        // IDEs) represent their multi-level menus as unmanaged surfaces, and
        // when closing a submenu, the main menu should get input focus.
        struct sway_xwayland_unmanaged *current;
        wl_list_for_each(current, &root->xwayland_unmanaged, link) {
            struct wlr_xwayland_surface *prev_xsurface =
                    current->wlr_xwayland_surface;
            if (prev_xsurface->pid == xsurface->pid &&
                    wlr_xwayland_or_surface_wants_focus(prev_xsurface)) {
                seat_set_focus_surface(seat, prev_xsurface->surface, false);
                return;
            }
        }

        // Restore focus
        struct sway_node *previous = seat_get_focus_inactive(seat, &root->node);
        if (previous) {
            // Hack to get seat to re-focus the return value of get_focus
            seat_set_focus(seat, NULL);
            seat_set_focus(seat, previous);
        }
    }
}
salkin-mada commented 3 years ago

@yrhki Yes! Its works even better with Reaper. Esc will now close the menu's fully downwards (when having several opened submenu's). Though still having some quite easily discoverable bugs in the VST preset drop downs.

And again vscode running Xwayland still seems to act nice with its drop downs. - Just as a minimal impact test.

salkin-mada commented 3 years ago

@yrhki . No actually its seems very robust in Reaper. Ok with you to change the title of #6461 and change the commit as a Co-authored-by? Or you want to do something else? test more?

yrhki commented 3 years ago

@salkin-mada ok

yrhki commented 3 years ago

When VST preset drop down is created and is frozen I noticed that VST window is still in focus. You can see this by trying to interact with the VST over the preset drop down (I used Cobalt to do this).

salkin-mada commented 3 years ago

Should we try and address this somehow? How do you test this with Cobalt?

I am using yabridge. But the mouse hidden behind a VST (GUI - not Reaper UI) param bug is possibly more a "bridge" and wine version issue.