You are not logged in.

#1 2019-05-09 04:12:01

TAAPAye
Member
Registered: 2017-08-06
Posts: 11

Create a fake monitor in a virtual X server [SOLVED]

I was trying to figure out a way to create fake monitors so I could simulate having multiple displays. Following this answer, I managed to accomplish my goal in a normal X11 environment.

#splitting the monitor
xrandr --setmonitor HDMI2~1 960/254x1080/286+0+0 HDMI2
xrandr --setmonitor HDMI2~2 960/255x1080/286+960+0 none
#hack refresh xrandr
xrandr --fb 1921x1080
xrandr --fb 1920x1080

However, my tests for my project run in a virtual X server, and the above solution doesn't seem work for some unknown reason. When I used Xvfb, I couldn't change the frame buffer (the default monitor is at the max and couldn't be lowered). I also couldn't apply transformations.

My goal is to be able to create fake monitors inside a virtual X server (I have tried Xvfb and Xephyr to no avail).

Xvfb

$ xrandr
xrandr: Failed to get size of gamma for output screen
Screen 0: minimum 1 x 1, current 640 x 480, maximum 640 x 480
screen connected 640x480+0+0 0mm x 0mm
   640x480        0.00* 

Xephyr (truncated for clarity)

$ xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 160 x 160, current 640 x 480, maximum 1600 x 1200
default connected 640x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1600x1200      0.00
   640x480        0.00* 
   640x400        0.00  
   160x160        0.00 

Regular X server (for comparison)

$ xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
VGA-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
LVDS connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1366x768      59.97*+
   1280x720      59.97  

Looking at the outputs, the items that are immediately different are the dimensions in mm and the refresh rate. I don't seem to be able to change either in the virtual X servers. Also the RANDR extension is present.

I'm open to suggestions.

*EDIT*
A requirement is to dynamically create fake monitors, so a static solution like "fakexinerama" is not desired.

Last edited by TAAPAye (2019-06-11 02:54:26)

Offline

#2 2019-05-11 02:26:36

alfalfa
Member
Registered: 2017-06-30
Posts: 63
Website

Re: Create a fake monitor in a virtual X server [SOLVED]

Perhaps you can simply add dummy monitors in xorg.conf. Not sure of what you are trying to do, but this works to VNC into a headless machine.

Section "Device"    Identifier  "Configured Video Device"
    Driver      "dummy"
    VideoRam 256000
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 5.0 - 1000.0
    VertRefresh 5.0 - 200.0
    Modeline "1360x710" 78.32 1360 1424 1568 1776 710 711 714 735 -HSync +Vsync
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1360x710"
    EndSubSection
EndSection

Offline

#3 2019-05-12 06:46:06

TAAPAye
Member
Registered: 2017-08-06
Posts: 11

Re: Create a fake monitor in a virtual X server [SOLVED]

I'm trying to dynamically (after the virtual X server is running) create fake monitors. For better context I'm writing a WM and I wanted to have to handle correct behavior when a monitor is plugged/unplugged.

The solution you proposed seems to be more static in nature as I wouldn't be able to dynamically add/remove monitors without restarting.

Offline

#4 2019-06-11 02:53:38

TAAPAye
Member
Registered: 2017-08-06
Posts: 11

Re: Create a fake monitor in a virtual X server [SOLVED]

So I found a solution in Xvnc (part of TigerVNC). TigerVNC has a totally different use case and does way more than I would need/want it to, but Xvnc is conveniently installed along with it as a separate executable.

So if I run

Xvnc :1 &

then the above code examples work.

Offline

Board footer

Powered by FluxBB