Skip to content
  • Hans de Goede's avatar
    window-xwayland: Add Xwayland fullscreen games workaround · dbb95cbe
    Hans de Goede authored
    This is a workaround for X11 games which use randr to change the resolution
    in combination with NET_WM_STATE_FULLSCREEN when going fullscreen.
    
    Newer versions of Xwayland support the randr part of this by supporting randr
    resolution change emulation in combination with using WPviewport to scale the
    app's window (at the emulated resolution) to fill the entire monitor.
    
    Apps using randr in combination with NET_WM_STATE_FULLSCREEN expect the
    fullscreen window to have the size of the emulated randr resolution since
    when running on regular Xorg the resolution will actually be changed and
    after that going fullscreen through NET_WM_STATE_FULLSCREEN will size
    the window to be equal to the new resolution.
    
    We need to emulate this behavior for these games to work correctly.
    
    Xwayland's emulated resolution is a per X11 client setting and Xwayland
    will set a special _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on the
    toplevel windows of a client (and only those of that client), which has
    changed the (emulated) resolution through a randr call.
    
    This commit checks for that property and if it is set adjusts the fullscreen
    monitor rect for this window to match the emulated resolution.
    
    Here is a step-by-step of such an app going fullscreen:
    1. App changes monitor resolution with randr.
    2. Xwayland sets the _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on all the
       apps current and future windows. This property contains the origin of the
       monitor for which the emulated resolution is set and the emulated
       resolution.
    3. App sets _NET_WM_FULLSCREEN.
    4. We check the property and adjust the app's fullscreen size to match
       the emulated resolution.
    5. Xwayland sees a Window at monitor origin fully covering the emulated
       monitor resolution. Xwayland sets a viewport making the emulated
       resolution sized window cover the full actual monitor resolution.
    
    !739
    dbb95cbe