[dev] [dwm] Possible bug in resizemouse function

From: Xu Lu <luxu.132749_AT_gmail.com>
Date: Sat, 16 Oct 2021 22:18:18 +0800

The related code is in line 1326-1332 in dwm.c (current git HEAD):

        if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
        && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
        {
                if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
                && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
                        togglefloating(NULL);
        }

This outer if statement dates back to 13 years ago in [1]. The changes
in movemouse in [1] got removed in [2]. The changes in resizemouse is
neither perfect. Width and height are compared with coordinates, which
is not a proper way. As a result, it does not work well, e.g., for
multi-monitor setup.


The expected behavior should be to constraint the resizing within the
window area of the current monitor.

Now, in a multi-monitor set-up, start two windows in one monitor. Try
resize the window in the stack. During resize, move the cursor directly
into the other monitor to the right(suppose it is set up that way).
This way, the window will be resized. But, if there was one window,
the same action won't resize it.


Possible solutions:

I am not a C developer, but I tried some changes and works for me (even
works with patches like resizecorners):

        if (ev.xmotion.x >= selmon->wx && ev.xmotion.x <= selmon->wx + selmon->ww
        && ev.xmotion.y >= selmon->wy && ev.xmotion.y <= selmon->wy + selmon->wh)

Or, with the help of 'INTERSECT' macro:

        if (INTERSECT(ev.xmotion.x, ev.xmotion.y, 1, 1, selmon) == 1)

The two are basically equivalent to each other. This tests whether the
cursor is inside the monitor's window area, not sure if that's still
the same intention as before.

Or, remove the outer if like in [2]. So the resizing is not constrained
by the window area.

[1]: https://git.suckless.org/dwm/commit/71365a524f67235024de7db277c63f8ac4f46569.html
[2]: https://git.suckless.org/dwm/commit/5b238c8dab945023b6a16a6c9f642b11137f2204.html
Received on Sat Oct 16 2021 - 16:18:18 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 16 2021 - 23:48:07 CEST