Re: [dev] [dwm] Possible bug in resizemouse function

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 17 Oct 2021 15:26:54 +0200

On Sat, Oct 16, 2021 at 10:18:18PM +0800, Xu Lu wrote:
> 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
>

Hi,

Thank you for the feedback. I've looked at it on a multi-monitor setup and also
discussed it on IRC with other people and the current behaviour seems expected.

Unless I misunderstand the issue I think it is not a bug.

-- 
Kind regards,
Hiltjo
Received on Sun Oct 17 2021 - 15:26:54 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 17 2021 - 15:36:07 CEST