Weird Wayland -> XWayland monitor issue

I’ve recently switched from Mint to EndevourOS, and while at it I also moved from X11 to Wayland (Hyprland).

Everything works mostly flawlessly, however, there’s this one thing that is slowly driving me crazy.

I edit a ton of videos, and my editor of choice is DaVinci Resolve. I also happen to use a stacked monitor setup, where one screen is above the other. Unfortunately, DVR doesn’t have native Wayland support, so it runs through XWayland.

Generally it works great, except for the fact that XWayland sees the wrong monitor configuration.

Here is my real config in Wayland:

And this is what XWayland apps see:

No matter what I try, the DP-3 monitor refuses to go below DP-2 in X11 apps. This is a big issue, as when working in DVR’s dual screen mode, I cannot drag files from the bottom monitor to the top. If I’m on DP-3 and I drag the file to the left, the cursor appears on the vertical monitor (HDMI-A-1), while the file itself appears on DP-2.

It’s also probably worth mentioning that the same issue doesn’t appear when using an X11 session.

Welcome to the forum @NiHuShu !
Maybe I"m ignorant and do not understand your problem.
I Installed JaKool.. Hyprland alongside bpswm (X11).
I couldn’t start Xwayland from hyprland as X server was running.
I have only one external monitor and with
arandr
created this

cat .screenlayout/displays.sh

#!/bin/sh
xrandr --output eDP-1 --primary --mode 1920x1080 --pos 900x1075 --rotate normal --output HDMI-1 --mode 1600x900 --pos 0x0 --rotate left

In X11 you can use similar scripts.

When in Hyprland, it will not let me change any settings with xrandr, and as far as I know, this is on purpose.

I did some more digging, and it looks like what I’m experiencing is unfortunately the expected behavior of XWayland when using Hyperland.

I found this issue on GitHub: https://github.com/hyprwm/Hyprland/issues/6907, which led me to this code in Compositor.cpp:


 // reset maxXOffsetRight (reuse) 
 // and set xwayland positions aka auto for all 
 maxXOffsetRight = 0; 
 for (auto& m : m_vMonitors) { 
     Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {}]", m->szName, maxXOffsetRight, 0); 
     m->vecXWaylandPosition = {maxXOffsetRight, 0}; 
     maxXOffsetRight += (*PXWLFORCESCALEZERO ? m->vecTransformedSize.x : m->vecSize.x); 
  
     if (*PXWLFORCESCALEZERO) 
         m->xwaylandScale = m->scale; 
     else 
         m->xwaylandScale = 1.f; 
 } 

As you can see, it forces all monitors to be laid out from left to right, no matter what the “real” setup looks like.

So apparently my setup: Hyprland + stacked monitors + DaVinci Resolve running in dual-screen mode is extremely uncommon which is why this usually isn’t an issue. Looks like the only solution is to either move to a different WM or modify the code and recompile Hyprland.

In case someone else faces this issue:

Once you clone the main branch of Hyprland, go to /src/Compositor.cpp

At the time of writing this, this is the snippet that causes all monitors to be aligned in a single line:

    // reset maxXOffsetRight (reuse)
    // and set xwayland positions aka auto for all
    maxXOffsetRight = 0;
    for (auto const& m : m_monitors) {
        Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {}]", m->m_name, maxXOffsetRight, 0);
        m->m_xwaylandPosition = {maxXOffsetRight, 0};
        maxXOffsetRight += (*PXWLFORCESCALEZERO ? m->m_transformedSize.x : m->m_size.x);

        if (*PXWLFORCESCALEZERO)
            m->m_xwaylandScale = m->m_scale;
        else
            m->m_xwaylandScale = 1.f;
    }

Change it to:

    // reset maxXOffsetRight (reuse)
    // and set xwayland positions aka auto for all
    maxXOffsetRight = 0;
for (auto& m : m_vMonitors) {
    Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {}]", m->szName, m->vecPosition.x, m->vecPosition.y);
    m->vecXWaylandPosition = m->vecPosition;

    if (*PXWLFORCESCALEZERO)
        m->xwaylandScale = m->scale;
    else
        m->xwaylandScale = 1.f;
}

Then compile Hyprland using the official instructions.

After restarting the PC, arandr finally shows the correct configuration, and dragging objects/files between X11 apps works as expected:

Now, there is a reason as to why the original code placed them next to each other, and it’s possible that some X11 apps will freak out with such a configuration.

However, it does work for my use case, so maybe it will help those who’ll find this post in the future.