fvwm3 icon indicating copy to clipboard operation
fvwm3 copied to clipboard

FVWM does not track global monitor size correctly during RandR changes

Open farblos opened this issue 1 year ago • 3 comments

Upfront Information

Please provide the following information by running the command and providing the output.

  • Fvwm3 version (run: fvwm3 --version)

      [~]$ /home/farblos/fvwm3/bin/fvwm3 --version
      fvwm3 1.1.3 (7b901c04)
      with support for:  ReadLine, XPM, PNG, SVG, Shape, XShm, SM, Bidi text, XRandR, XRender, XCursor, XFT, XFixes, NLS
    
      fvwm3 comes with NO WARRANTY, to the extent permitted by law. You may
      redistribute copies of fvwm under the terms of the GNU General Public License.
      For more information about these matters, see the file named COPYING.
    
  • Linux distribution or BSD name/version

      Debian testing
    
  • Platform (run: uname -sp)

      Linux unknown
    

Reproducer

Scale down display resolution with:

xrandr --output eDP-1 --primary --auto --scale 0.75

Restart FVWM with default configuration, open an XTerm, move it to the bottom right corner with:

echo 'Next ("xterm") Move -2p -2p ewmhiwa' | nc -U $FVWMMFL_SOCKET

Remove display scale so that the XTerm now is some 25% away from the bottom right corner:

xrandr --output eDP-1 --primary --auto --transform none

Try to move the XTerm again to new bottom right corner:

echo 'Next ("xterm") Move -2p -2p ewmhiwa' | nc -U $FVWMMFL_SOCKET

Expected Behaviour

XTerm moves to the new bottom right corner.

Actual Behaviour

XTerm does not change position.

Enabling logging

In the state after above reproducer, dump the monitor state with

echo 'BugOpts DebugRandR True' | nc -U $FVWMMFL_SOCKET

This results for me in:

fvwm3[36486]: [1739643857.113858] monitor_dump_state: Monitor Debug
fvwm3[36486]: [1739643857.113870] monitor_dump_state:         number of outputs: 1
fvwm3[36486]: [1739643857.113878] monitor_dump_state:         Number:        0
fvwm3[36486]:         Name:        eDP-1
fvwm3[36486]:         Disabled:        false
fvwm3[36486]:         Is Primary:        yes
fvwm3[36486]:         Is Current:        yes
fvwm3[36486]:         Is Previous:        no
fvwm3[36486]:         Output:        66
fvwm3[36486]:         Coords:        {x: 0, y: 0, w: 2256, h: 1504}
fvwm3[36486]:         VirtScr: {
fvwm3[36486]:                 VxMax: 1504, VyMax: 1002, Vx: 0, Vy: 0
fvwm3[36486]:                 EdgeScrollX: 1504, EdgeScrollY: 1002
fvwm3[36486]:                 CurrentDesk: 0
fvwm3[36486]:                 CurrentPage: {x: 0, y: 0}
fvwm3[36486]:                 MyDisplayWidth: 1504, MyDisplayHeight: 1002
fvwm3[36486]:         }
fvwm3[36486]:         EWMH: {
fvwm3[36486]:                 BaseStrut Top:    0
fvwm3[36486]:                 BaseStrut Bottom: 0
fvwm3[36486]:                 BaseStrut Left:   0
fvwm3[36486]:                 BaseStrut Right:  120
fvwm3[36486]:         }
fvwm3[36486]:         Desktops:        yes
fvwm3[36486]:         Flags:global

Notice the difference in dimensions shown by parameters Coords (untransformed monitor dimensions) and VirtScr (still showing dimensions scaled by 75%).

More Information

My educated guess is that the Xlib macros DisplayWidth and DisplayHeight, which FVWM uses to determine the global monitor size, are not suitable when using RandR. See also the following test program:

/* gcc -o randrinfo randrinfo.c -lX11 -lXrandr */
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <unistd.h>

int main(void) {
    Display *d = XOpenDisplay(getenv("DISPLAY"));
    Window   w = DefaultRootWindow(d);
    XRRScreenResources *xrrr;
    XRRCrtcInfo *xrrci;
    while ( 1 ) {
        printf("display size is %d x %d\n",
               DisplayWidth(d, DefaultScreen(d)),
               DisplayHeight(d, DefaultScreen(d)));

        xrrr = XRRGetScreenResources(d, w);
        for (int i = 0; i < xrrr->ncrtc; ++i) {
            xrrci = XRRGetCrtcInfo(d, xrrr, xrrr->crtcs[i]);
            if (xrrci->mode != None)
                printf("%dx%d+%d+%d\n", xrrci->width, xrrci->height, xrrci->x, xrrci->y);
            XRRFreeCrtcInfo(xrrci);
        }
        XRRFreeScreenResources(xrrr);
        sleep(10);
    }
    return 0;
}

When executing that, the display resolution determined by DisplayWidth and DisplayHeight does not change when changing display scale with xrandr.

farblos avatar Feb 15 '25 18:02 farblos

I can try to come up with a PR but would need some guidance while doing so...

farblos avatar Feb 15 '25 19:02 farblos

Hi @farblos

Yep -- this is a known problem, and I already have a patch for this.

ThomasAdam avatar Feb 15 '25 19:02 ThomasAdam

Hi @ThomasAdam,

Yep -- this is a known problem, and I already have a patch for this.

great! Is that patch available on some branch? Should I test ist?

Thanks!

farblos avatar Feb 15 '25 19:02 farblos

Hi @ThomasAdam,

I just repeated above test case on released 1.1.3, which recently hit Debian testing. The problem does not reproduce. Can it be that you fixed this issue with #1207?

Thanks either way!

farblos avatar Oct 16 '25 14:10 farblos

Hi @farblos

Ah, yes, it's quite likely. I think'll make this as closed in that case.

ThomasAdam avatar Oct 16 '25 14:10 ThomasAdam