# \[Linux\]\[VR\]How to place window on DISPLAY 0.1?

**URL:** <https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764>\
**Category:** Platform & Builds\
**Tags:** Oculus, Linux, unreal-engine, UE4, question\
**Created:** [June 5, 2015, 3:10am UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764 "2015-06-05T03:10:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_61cf48131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61cf48131](https://forums.unrealengine.com/u/anonymous_user_61cf48131)\
**Post date:** [June 5, 2015, 3:10am UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764/1 "2015-06-05T03:10:06Z")

</div>

I used nvidia-settings to edit my X11/xorg.conf such that I have two screens: My primary monitor at DISPLAY 0.0 (1080p, 144 Hz), and my DK2 at DISPLAY 0.1. This works perfectly when I:

```
DISPLAY=:0.1 /usr/local/bin/OculusWorldDemo

```

There’s no judder, the scene isn’t vsync’d to the primary monitor, it’s great!

I’ve made some changes to the 4.8 branch of UE4, mostly following amigo’s changes for 4.7, and I can get a rotated window with a distorted stereo image to show up at the right edge of my primary monitor and the content of window responds to the rotation of the HMD. (Side note: there is a large black rectangle in the middle of the left eye view in this Window. I suspect this is a separate problem).

Instead of showing up on the right of the primary monitor, I would like this window to show up on the second screen, on DISPLAY 0.1. How can I find this display? Or, more correctly, how can I find the display containing the rift?

Additional info:

-When I have the rift as an extended part of the first screen (i.e., at position x= +1920 on DISPLAY 0.0) then HMDLog reports that it found the rift at position 1920,0. When I have the rift on the second screen, as I would like, then HMDLog reports that it found the rift at position 0,0 with no mention of the screen.

-When I have the rift as an extended part of the first screen, then the window gets placed in the rift but it looks entirely wrong. The viewports are cropped and misaligned.

-Reading the code, I’ve drilled down from the Preview in VR button to the [creation of the PieWindow](https://.com/EpicGames/UnrealEngine/blob/4.8/Engine/Source/Editor/UnrealEd/Private/PlayLevel.cpp#L2781-L2787) in Engine/Source/Editor/UnrealEd/Private/PlayLevel.cpp, and a few lines below that is the creation of the PieViewportWidget. Unfortunately this code uses slate-specific macros that I don’t understand so I can only guess that SNew( SWindow ) ends up calling [SWindow::Construct](https://.com/EpicGames/UnrealEngine/blob/4.8/Engine/Source/Runtime/SlateCore/Private/Widgets/SWindow.cpp#L180), but I can’t be sure. If I’m correct, then I think the call to GetDisplayMetrics is part of what I am interested in. That seems to be platform specific; the Linux version can be found [here](https://.com/EpicGames/UnrealEngine/blob/4.8/Engine/Source/Runtime/Core/Private/Linux/LinuxApplication.cpp#L1278). Therein, it uses SDL to get info about the monitors, and it does seem to enumerate the displays. I will play around with SDL to see how it represents multiple screens, and to see if the GetDisplayMetrics captures that properly.

Also, I’m slightly worried that I’m just reading the code about the mirrored preview, as happens in Windows when the HMD direct mode. Can someone verify that this code path I’m heading down is indeed for the window that should be displayed in the HMD?

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [June 5, 2015, 11:51am UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764/2 "2015-06-05T11:51:39Z")

</div>

There’s no support for virtual displays (as implemented on Linux) in UE. At some point we will add this by representing them as additional monitors (which is in line with the virtual dsiplays on other platforms - e.g. Spaces).

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61cf48131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61cf48131](https://forums.unrealengine.com/u/anonymous_user_61cf48131)\
**Post date:** [June 5, 2015, 12:53pm UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764/3 "2015-06-05T12:53:14Z")

</div>

I find it a little bit dismissive that this `answer` was auto-marked as ‘accepted’. It certainly does not answer my question.

Is what I’m talking about really considered a ‘virtual display’? It is a physical display, just configured to use a [separate X screen](http://us.download.nvidia.com/XFree86/Linux-x86_64/304.43/README/configmultxscreens.html).

I’m willing to put in the work to get this working on my machine, and I’ll do a pull request if/when I get something working, but a little guidance would help. Am I even on the right track?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61cf48131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61cf48131](https://forums.unrealengine.com/u/anonymous_user_61cf48131)\
**Post date:** [June 5, 2015, 8:28pm UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764/4 "2015-06-05T20:28:49Z")

</div>

I’ve been playing around with SDL2. When my DK2 is on a separate X display, SDL\_GetDisplayBounds returns x=0, y=0, w=1080, h=1920. When it is part of the main display everything is the same except x=1920 (as my primary monitor has a w=1920).  
It seems that there is no way to get SDL\_CreateWindow to create a window on a secondary display. Adding an x-offset to place the window where it WOULD be in extended mode simply places the window at the right edge of the first display, which is what I observed in UE4Editor.  
It might be necessary to create the window first using OpenGL then to use SDL\_CreateWindowFrom, but then I wonder if SDL is even necessary anymore?

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [June 6, 2015, 2:24am UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764/5 "2015-06-06T02:24:15Z")

</div>

Ah, sorry, I mistook it for virtual desktops. There’s no support for placing windows on a separate X screen either. That perhaps requires some changes in SDL as well (as you note above). Feel free to submit a pull request if you make it work, but please remember that things should remain cross-compilable without presence of X headers.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61cf48131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61cf48131](https://forums.unrealengine.com/u/anonymous_user_61cf48131)\
**Post date:** [June 24, 2015, 2:37pm UTC](https://forums.unrealengine.com/t/linux-vr-how-to-place-window-on-display-0-1/320764/6 "2015-06-24T14:37:44Z")

</div>

I [posted a related question on the SDL board](http://forums.libsdl.org/viewtopic.php?t=11273&sid=189dead0bc4537f09b251bc7d652b52a) a few weeks ago but no replies. I will come back to this in the future.
