joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.53k stars 369 forks source link

XQueryPointer starts to return constant values after mouse "lock" (cursor sticks to the screen edges) #5014

Closed rayrapetyan closed 1 week ago

rayrapetyan commented 1 month ago

Describe the bug

With any game/app, mouse sticks to the border of the visible area of the window when running dosbox-x in a headless environment.

Steps to reproduce the behaviour

In a headless mode (e.g. a docker container running on a remote server) run some app, e.g.:

dosbox-x -c "MOUNT C \"C\"" -c "IMGMOUNT D \"JACK.iso\" -t iso" -c "C:" -c "CD JACK_ORL" -c "GAMEMENU.EXE" -c "EXIT" -conf dosbox.conf -noconsole

Expected behavior

Mouse should be working and reaching any part of the screen. Instead mouse cursor sticks to the edges of the visible area and can move only along these borders. If you move mouse very slowly, you can position it on the screen, but it behaves line an extra-strong magnet - any fast move and mouse cursor is sent back to the edge.

What operating system(s) this bug have occurred on?

Debian Bookworm

What version(s) of DOSBox-X have this bug?

2024.03.01

Used configuration

[sdl]
autolock=true
fullscreen=true (same for false)
fulldouble=true
fullresolution=auto
windowresolution=auto
output=openglnb

[dosbox]
title=DOS
memsize=16

[dos]
hard drive data rate limit=0
floppy drive data rate limit=0

[cpu]
cputype=auto
core=normal

[pci]
voodoo=false

[ide, primary]
int13fakeio=true
int13fakev86io=false

[render]
scaler=none
aspect=false

[log]
logfile     = log.txt
debuggerrun = debugger

[autoexec]

Output log

Logging: opened logfile 'log.txt' successfully. All further logging will go to this file.
DOSBox-X version 2024.03.01 Commit 02f36ba (Linux SDL2 64-bit)
SDL: version 2.26.5, Video x11, Audio pulseaudio
Host keyboard layout is now  ()
Mapper keyboard layout is now  ()
SDL2 reports desktop display mode 640 x 480
Configured windowposition: -
SDL: Current window pixel format: SDL_PIXELFORMAT_RGB888
SDL: You are running in 24 bpp mode, this will slow down things!
X11 main window is 640 x 400 maximized=0
X11 extension XRANDR is available
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,40) size=(640,400) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
X11 main window is 640 x 400 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,40) size=(640,400) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
GetDesktopResolution reading X11 desktop resolution
Root window (ID 1332) is 640 x 480
INFO: switched to full screen mode
ISA BCLK: 8333333.333Hz (25000000/3)
monopal: green, 
Active save slot: 1 [Empty]
USING AVI+ZMBV
Max 3670016 sz 16384
Final 16384
SDLNet_TCP_Open: Couldn't connect to remote host
TiMidity: can't open control connection (host=127.0.0.1, port=7777)
MIDI:fluidsynth: SoundFont not specified, and no system SoundFont found
MIDI:synth: Specify .SF2 sound font file with midiconfig=
MT32: failed to locate ROMs.
MT32 emulation requires the PCM and CONTROL ROM files.
To eliminate this error message, check the DOSBox-X wiki.
The ROM files are: CM32L_CONTROL.ROM and CM32L_PCM.ROM or MT32_CONTROL.ROM and MT32_PCM.ROM
MIDI:Opened device:none
Pentium CMPXCHG8B emulation is enabled
VOODOO LFB now at d0000000
Serial1: BASE 3f8h
Serial2: BASE 2f8h
Parallel1: BASE 378h
MPU-401 Registering I/O ports as if IBM PC MPU-401 at base 330h
Memory I/O complexity optimization enabled aka option 'memory io optimization 1'. If the game or demo is unable to draw to the screen properly, set the option to false.
The 'scanline render on demand' option is available and may provide a modest boost in video render performance if set to true.
X11 main window is 640 x 400 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,40) size=(640,400) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
Allocated APM BIOS pm entry point at f000:ce40
Writing code to fce40
Writing code to fce60
X11 main window is 640 x 400 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,40) size=(640,400) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
ISA Plug & Play BIOS enabled
VGA ROM BIOS init callback
pixratio 1.000, dw false, dh false
Aspect ratio: 640 x 480  xToY=1.333 yToX=0.750
menuScale=1
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
font texture id=2 will make 128 x 256
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
Aspect ratio: 640 x 480  xToY=1.333 yToX=0.750
menuScale=1
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
font texture id=5 will make 128 x 256
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
WARNING: No translation support (to host) for code page 0
pixratio 1.350, dw false, dh false
Aspect ratio: 720 x 540  xToY=1.333 yToX=0.750
menuScale=1
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
font texture id=2 will make 128 x 256
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
   2985117 ERROR BIOS:Keyboard layout file auto not found
   2985117 ERROR BIOS:Keyboard layout file auto not found
XMS: 50 handles allocated for use by the DOS environment
EMS page frame at 0xe000-0xefff
COMMAND.COM env size:             720 bytes
COMMAND.COM environment block:    0x0701 sz=0x002d
COMMAND.COM main body (PSP):      0x072f sz=0x009a
COMMAND.COM stack:                0x0749
IMGMOUNT: CD-ROM image mounted to drive D (IDE Secondary Master)
   3028015 ERROR BIOS:INT15:Unknown call ax=BFDE
   3028093 ERROR BIOS:INT15:Unknown call ax=BFDE
DOSBox-X has switched to max cycles, because of the setting: cycles=auto.
If the game runs too fast, try a fixed cycles amount in DOSBox-X's options.
   3039984 ERROR BIOS:INT15:Unknown call ax=BF01
   8066809 ERROR MOUSE:Unhandled videomode 79 on reset
pixratio 1.000, dw false, dh false
Aspect ratio: 640 x 480  xToY=1.333 yToX=0.750
menuScale=1
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
font texture id=2 will make 128 x 256
X11 main window is 640 x 480 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
  17728777 ERROR MOUSE:Unhandled videomode 79 on reset
2278593627 ERROR MOUSE:Unhandled videomode 79 on reset
INFO: switched to window mode
Aspect ratio: 640 x 480  xToY=1.333 yToX=0.750
menuScale=1
X11 main window is 640 x 497 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,497) match=(320,248)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
font texture id=2 will make 128 x 256
X11 main window is 640 x 497 maximized=0
XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
Our window lies on this CRTC display (window pos=(0,0) size=(640,497) match=(320,248)).
  Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)
--END OF LOG--

Additional information

Using mouse emulation=integration in win 3.11 fixes the issue in the headless mode. Using standard env (non-headless) works with no issues.

Have you checked that no similar bug report(s) exist?

Code of Conduct & Contributing Guidelines

rayrapetyan commented 3 weeks ago

Update: When running Windows 9x in DOSBox-X in headless mode, the mouse doesn't work properly in any mode. It sticks to the border of the screen, and you can only move it across the screen very slowly. The screen behaves like a magnet, and any careless movement sends the mouse back to the border.

rayrapetyan commented 2 weeks ago

UPD:

XTestFakeMotionEvent and XWarpPointer behave the same way, mouse cursor jumps all over the screen.

XTestFakeRelativeMotionEvent works properly, mouse moves smoothly and as expected.

I've tried to use XQueryPointer before XTestFakeRelativeMotionEvent to find deltas, and mouse cursor started to jump exactly as it did with XTestFakeMotionEvent/XWarpPointer! So It turns out, XQueryPointer returns valid coordinates only when mouse is not locked. Once mouse is locked (after the click or with the autolock=true), XQueryPointer constantly returns 320,240. I believe 320,240 comes from this:

LOG: XRandR CRTC 0: pos=(0,0) size=(640,480) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,0) size=(640,480) match=(320,240)).
LOG:   Goes to output 0: name='DUMMY0' size_mm=(0 x 0)
LOG: Screen report: Method 'XRandR' (640.000 x 480.000 pixels) at (0.000 x 0.000) (0.000 x 0.000 mm) (0.000 x 0.000 in) (-1.000 x -1.000 DPI)

So to summarize, the root cause of the described mouse issue relies within XQueryPointer - somehow it breaks after the mouse lock, XQueryPointer thinks mouse never moves (probably it performs checks on the wrong window?). I've checked and there is only one screen attached to my display and I'm taking a root window on this single screen:

RootWindowOfScreen(screen)

so not sure which other window dosbox-x switches to on mouse lock... Anyway it's a dosbox-x only issue, there are no any problems like that in scummvm or wine, they properly handle XTestFakeMotionEvent and XWarpPointer and don't "lock" the pointer the way dosbox-x does.

rayrapetyan commented 2 weeks ago

@aybe, I see you did some mouse-related fixes, could you look into the described issue and provide your thoughts?

rayrapetyan commented 1 week ago

Cursor behaves like this when absolute coordinates are being sent while app is waiting for relative coordinates. There are other conditions causing same behavior, too many to put into the same issue, closing.