Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Window Placement with Monitors at Different Vertical Positions #204

Open
mattestanka opened this issue Jan 2, 2025 · 0 comments

Comments

@mattestanka
Copy link

I have two displays, one positioned lower than the other. To make swapping between the two monitors flawless, I configured them with the following xrandr command:

xrandr --output DP-1 --primary --mode 2560x1440 --pos 1920x0 --rotate normal --output DP-2 --mode 1920x1080 --pos 0x300 --rotate normal --output DP-3 --off --output HDMI-1 --off

This configuration adds a 300-pixel vertical offset for the second monitor. While the bar is correctly positioned, windows on the second monitor are not respecting the offset and are shifted up by 300 px exceeding the screen size.

After inspecting dwm.c, I found that the arrangemon function had an incorrect wy value for the second monitor. To address this, I implemented a quick fix that excludes the monocle layout (as full-sized windows work correctly) and temporarily adjusts m->wy during the arrangement process.

Temporary Fix

Here’s my updated arrangemon function:

void arrangemon(Monitor *m) {
    updatebarpos(m);
    updatesystray();

    XMoveResizeWindow(dpy, m->tabwin, m->wx + m->gappov, m->ty, m->ww - 2 * m->gappov, th);
    XMoveWindow(dpy, m->tagwin, m->wx + m->gappov, m->by + (m->topbar ? (bh + m->gappoh) : (- (m->mh / scalepreview) - m->gappoh)));

    strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);

    if (m->mh == 1080 && m->lt[m->sellt]->arrange != monocle) {
        m->wy -= 300;
    }

    if (m->lt[m->sellt]->arrange) {
        m->lt[m->sellt]->arrange(m);
    }

    // Restore wy to its original value after arrangement
    if (m->mh == 1080 && m->lt[m->sellt]->arrange != monocle) {
        m->wy += 300;
    }
}

I suspect the root cause lies in how the Monitor struct (m) is handled, as the values appear correct in updategeom.

I don’t really have the time or the technical knowledge to implement a proper fix myself, so I’m sharing this quick fix as an example in case someone else encounters the same problem. Hopefully, this can serve as a starting point for a more robust solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant