phillipberndt/fakexrandr

[Question] Adding extra outputs?

Opened this issue · 1 comments

Not sure if this is possible, hence marking it as a question.

I am running a VNC session which does have a screen but doesn't have any outputs:

[root@machine] xrandr --verbose -d :1
 SZ:    Pixels          Physical       Refresh
*0   3840 x 1080   (1016mm x 286mm )   60  
Current rotation - normal
Current reflection - none
Rotations possible - normal 
Reflections possible - none
Setting size to 0, rotation to normal
Setting reflection on neither axis

This causes the window manager to treat the whole screen as a single window, hence when I maximize an application, it gets maximized over both monitors.
I was trying to use fakerandr to fix this, but it only seems to do splitting if there already is an output.
Do you think it's technically possible to modify fakerandr to inject fake outputs, in order to fix this problem?

This shouldn't be a problem. The general idea is as follows: XRandR information is centered around a XRRScreenResources structure that contains arrays of XIDs that point to the available outputs and associated CRTCs. You'll have to add two outputs and crtcs to these lists, and make sure that calls that obtain information on these XIDs (XRRGetOutputInfo returns a XRROutputInfo, XRRGetCrtcInfo a XRRCrtcInfo) return the correct structures. The modes are included in the XRRScreenResources as an array of XRRModeInfo structures, but also have XIDs each.

Code-wise, the configurable branch is better suited for this, because it already has the functionality to dynamically add new outputs. There's a function called augment_resources. It loads a configuration file, loops over the available outputs and if one of the outputs is to be replaced with a different one, adds information on the fake outputs to three FakeInfo structures (they are single-linked lists). The remainder of the function then assembles a XRRScreenResources for RandR applications from this. What you need to do is to replace the configuration loading and looping part (between a comment stating Fill the FakeInfo structures and three lines defining ncrtc, noutput and nmodes) with some code that populates the FakeInfo lists with the desired outputs. You can use the function _config_foreach_split as a template for this. Since your output/crtc/mode doesn't have a corresponding real XID, you'll have to make one up, or use the XAllocID(display) macro. You'll also have to replace the loop (still in augment_resources) that creates the outputs array of XIDs: It currently tries to sort the fake outputs to the position where the original output was. Replace this by a loop that just copies the XIDs from your fake outputs, the same way the CRTC XIDs are copied.