mamedev / mame

MAME
https://www.mamedev.org/
Other
8.06k stars 2.01k forks source link

Cannot make MAME to show on primary display (Linux, Gnome, MAME 0.226) #7532

Open TheCodeTherapy opened 3 years ago

TheCodeTherapy commented 3 years ago

MAME 0.226, compiled from source on PopOS 20.04 (Ubuntu-based distro). This is somehow related to #7309 but it doesn't work properly.

The setup used to reproduce is a triple-monitor setup, with 3 monitors connected by DisplayPort.

I tried the suggested command line parameters provided on #7309 however: -screen screen0 makes MAME appear on my right monitor -screen screen1 does the same (MAME appears on right monitor) -screen screen2 makes MAME appear on my left monitor

All other possible screenX provided make MAME appear on the right monitor, and so far I couldn't find a way for it to appear on my center monitor (which is the primary display on my distro configuration).

Worth mentioning that the issue only occurs on Gnome (on KDE Plasma, maybe due to differences in how KDE Plasma manages composition or display management, the issue does not occur, and MAME always appears on the primary display).

Worth mentioning as well that there's no information on MAME docs on how the OSD PER-WINDOW VIDEO OPTIONS should be configured on Linux machines. The docs only mention the \.\DISPLAYn, which is a Windows-only notation.

Important note: If I change my primary display to be the display on the left on my Linux configuration, then the following command makes MAME show up on my center screen:

mame64 -screen screen0

... that said, I presume there's some sort of conflict for MAME to run on the primary display, or maybe I'm providing the wrong config on my mame.ini

OSD PER-WINDOW VIDEO OPTIONS on mame.ini

screen                    auto
aspect                    auto
resolution                auto
view                      auto
screen0                   auto
aspect0                   auto
resolution0               auto
view0                     auto
screen1                   auto
aspect1                   auto
resolution1               auto
view1                     auto
screen2                   auto
aspect2                   auto
resolution2               auto
view2                     auto
screen3                   auto
aspect3                   auto
resolution3               auto
view3                     auto

mame64 -verbose:

Attempting load of mame.ini
Parsing mame.ini
Attempting load of mame.ini
Parsing mame.ini
Reading translation file English: 1 strings, original table at word offset 7, translated table at word offset 9
Loaded 0 translations from file English
Starting plugin data...
Attempting load of mame.ini
Parsing mame.ini
Attempting load of mame.ini
Parsing mame.ini
Available videodrivers: x11 wayland dummy 
Current Videodriver: x11
    Display #0
        Renderdrivers:
                opengl (0x0)
             opengles2 (0x0)
              software (0x0)
    Display #1
        Renderdrivers:
                opengl (0x0)
             opengles2 (0x0)
              software (0x0)
    Display #2
        Renderdrivers:
                opengl (0x0)
             opengles2 (0x0)
              software (0x0)
Available audio drivers: 
    pulseaudio          
    alsa                
    sndio               
    dsp                 
    disk                
    dummy               
Build version:      0.226 (mame0226-503-g3a955d2df8c)
Build architecure:  
Build defines 1:    SDLMAME_UNIX=1 SDLMAME_X11=1 SDLMAME_LINUX=1 
Build defines 1:    LSB_FIRST=1 PTR64=1 
SDL/OpenGL defines: SDL_COMPILEDVERSION=2010 USE_OPENGL=1 
Compiler defines A: __GNUC__=9 __GNUC_MINOR__=3 __GNUC_PATCHLEVEL__=0 __VERSION__="9.3.0" 
Compiler defines B: __amd64__=1 __x86_64__=1 __unix__=1 
Compiler defines C: __USE_FORTIFY_LEVEL=0 
Enter init_monitors
Adding monitor screen0 (1920 x 1080)
Adding monitor screen1 (1920 x 1080)
Adding monitor screen2 (1920 x 1080)
Leave init_monitors
Enter sdlwindow_init
Using SDL multi-window OpenGL driver (SDL 2.0+)

Hints:
    SDL_FRAMEBUFFER_ACCELERATION             (NULL)
    SDL_RENDER_DRIVER                        (NULL)
    SDL_RENDER_OPENGL_SHADERS                (NULL)
    SDL_RENDER_SCALE_QUALITY                 (NULL)
    SDL_RENDER_VSYNC                         (NULL)
    SDL_VIDEO_X11_XVIDMODE                   (NULL)
    SDL_VIDEO_X11_XINERAMA                   (NULL)
    SDL_VIDEO_X11_XRANDR                     (NULL)
    SDL_GRAB_KEYBOARD                        (NULL)
    SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS         (NULL)
    SDL_IOS_IDLE_TIMER_DISABLED              (NULL)
    SDL_IOS_ORIENTATIONS                     (NULL)
    SDL_XINPUT_ENABLED                       (NULL)
    SDL_GAMECONTROLLERCONFIG                 (NULL)
    SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS     (NULL)
    SDL_ALLOW_TOPMOST                        (NULL)
    SDL_TIMER_RESOLUTION                     (NULL)
    SDL_RENDER_DIRECT3D_THREADSAFE           (NULL)
    SDL_VIDEO_ALLOW_SCREENSAVER              (NULL)
    SDL_ACCELEROMETER_AS_JOYSTICK            (NULL)
    SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK   (NULL)
    SDL_VIDEO_WIN_D3DCOMPILER                (NULL)
    SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT      (NULL)
    SDL_VIDEO_MAC_FULLSCREEN_SPACES          (NULL)
    SDL_MOUSE_RELATIVE_MODE_WARP             (NULL)
    SDL_RENDER_DIRECT3D11_DEBUG              (NULL)
    SDL_VIDEO_HIGHDPI_DISABLED               (NULL)
    SDL_WINRT_PRIVACY_POLICY_URL             (NULL)
    SDL_WINRT_PRIVACY_POLICY_LABEL           (NULL)
    SDL_WINRT_HANDLE_BACK_BUTTON             (NULL)
Leave sdlwindow_init
Enter sdl_info::create
OpenGL: NVIDIA Corporation
OpenGL: GeForce RTX 2080 Ti/PCIe/SSE2
OpenGL: 4.6.0 NVIDIA 455.38
OpenGL: texture rectangle supported
OpenGL: non-power-of-2 textures supported (new method)
OpenGL: vertex buffer supported
OpenGL: pixel buffers supported
OpenGL: framebuffer object supported
OpenGL: GLSL supported
OpenGL: max texture size 32768 x 32768
Leave renderer_ogl::create
Audio: Start initialization
Audio: Driver is pulseaudio
Audio: frequency: 48000, channels: 2, samples: 256
sdl_create_buffers: creating stream buffer of 25600 bytes
Audio: End initialization
Keyboard: Start initialization
Input: Adding keyboard #0: System keyboard (device id: System keyboard)
Keyboard: Registered System keyboard
Keyboard: End initialization
Mouse: Start initialization
Input: Adding mouse #0: System mouse (device id: System mouse)
Mouse: Registered System mouse
Mouse: End initialization
Lightgun: Begin initialization
Lightgun: End initialization
Joystick: Start initialization
Joystick: End initialization
Searching font Liberation Sans in -. path/s
Matching font: 0x558440ff1850
OpenGL: VBO supported
OpenGL: PBO supported
OpenGL: FBO supported
OpenGL: GLSL using mame bitmap shader filter 0: './osd/shader/glsl_plain'
OpenGL: GLSL using mame bitmap shader filter 1: './osd/mame-psgs'
Optional memory region ':screen' not found
Starting No Driver Loaded ':'
  (missing dependencies; rescheduling)
Starting Video Screen ':screen'
Starting No Driver Loaded ':'
Checking for icons in directory icons
No candidate icons found for machines
Attempting to parse: default.cfg
Attempting to parse: ___empty.cfg
sdl_kill: closing audio
Enter sdlwindow_exit
Leave sdlwindow_exit

xrandr | grep ' connected':

DP-0 connected 1920x1080+3840+0 (normal left inverted right x axis y axis) 527mm x 297mm
DP-2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 297mm
DP-4 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 527mm x 297mm

The bug was identified trying to make MAME show on DP-4, which is my primary display.

....

vgambier commented 2 years ago

I have two displays (laptop screen + external monitor) and I cannot get MAME to show up on anything but the laptop screen, no matter what arguments I pass or what configuration I have in mame.ini - I am also using Pop OS

Davidian1024 commented 1 year ago

I'm on Ubuntu 20.04 running MAME 0.258 installed via flatpak. I also cannot for the life of me get MAME to come up on my primary monitor in fullscreen. I've tried all the -screen settings, both at the command line and the mame.ini file. None of these make any difference.

One aside here. I can launch MAME and then move it to my primary monitor with GNOME's help. If I press alt+space and then select "move to monitor right" it will move there. But then switching away from it with alt+tab causes it to minimize and then come back up on my secondary monitor when I unminimize it.

Davidian1024 commented 1 year ago

I managed to find a fix that works for me. But it involves modifying the source. Lines 595 and 596 of src/osd/sdl/window.cpp are: 595: m_extra_flags |= (fullscreen() ? 596: SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);

I found that removing the SDL_WINDOW_BORDERLESS flag seems to completely correct the problem.

I'll mention this as well. The monitor I have marked as primary through my OS is HDMI-1. My secondary monitor is HDMI-0. That's how xranr describes them. I think this issue might only affect people who have a setup similar to mine. The monitor they're using as their primary is not their first monitor physically. People who are running MAME on laptops with an external display as their primary and the built-in laptop monitor as their secondary for example.

So, this might be a bug in SDL2, or maybe the particular version of SDL2 that's shipping with Ubuntu 20.04.6. I tested this further by creating a simple test program that creates a fullscreen window using SDL2. I can reproduce this behavior there as well. Any combination of flags I tried that included SDL_WINDOW_BORDERLESS caused the window to come up on my second monitor.

I proposed a change: https://github.com/mamedev/mame/compare/master...Davidian1024:mame:patch-1

Davidian1024 commented 1 year ago

As of 0.259 this is fixed for me on Ubuntu 20.04.