From a6185490e816ac4fa2abf9cc6dd55a2aa184a007 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Fri, 22 Oct 2021 18:57:09 +0200 Subject: [PATCH] c/direct: Fix direct display RandR leased output on multi-X-Screen. The old code assumes the HMD is always connected to a RandR output on X-Screen 0, but this is not neccessarily the case on multi-X-Screen setups. Use a loop to iterate over all X-Screens outputs until the HMD output is found. Tested on single and dual X-Screen setups, also with Oculus Rift CV1 connected to 2nd X-Screen. This is rather useful for porting applications from "OpenHMD Rift on separate X-Screen for performance" to OpenXR Monado direct mode, so one can quickly switch between Monado and OpenHMD native without cumbersome xorg.conf + logout + login games. Signed-off-by: Mario Kleiner --- src/xrt/compositor/main/comp_window_direct_randr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xrt/compositor/main/comp_window_direct_randr.c b/src/xrt/compositor/main/comp_window_direct_randr.c index d42e63438..ece8f05cc 100644 --- a/src/xrt/compositor/main/comp_window_direct_randr.c +++ b/src/xrt/compositor/main/comp_window_direct_randr.c @@ -190,9 +190,11 @@ comp_window_direct_randr_init(struct comp_target *ct) xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(connection)); - w_direct->screen = iter.data; - - comp_window_direct_randr_get_outputs(w_direct); + while (iter.rem > 0 && w_direct->num_displays == 0) { + w_direct->screen = iter.data; + comp_window_direct_randr_get_outputs(w_direct); + xcb_screen_next(&iter); + } if (w_direct->num_displays == 0) { COMP_ERROR(ct->c, "No non-desktop output available.");