HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
547 stars 44 forks source link

Ubuntu: getScreens might not find primary screens #201

Closed tonsky closed 2 years ago

tonsky commented 2 years ago

https://github.com/HumbleUI/HumbleUI/issues/17

tonsky commented 2 years ago

@igorhub

Related code: https://github.com/HumbleUI/JWM/blob/a3c6e47e87646e460f69e6f37497af488badf386/linux/cc/AppX11.cc#L50-L97

igorhub commented 2 years ago

So, I found the problem: The primaryOutput we get at the start of getScreens has different ID than the (single) output we get at info->outputs[o]. Other than ID they seem to be identical:

primaryOutput ID: 445
timestamp: 7820
crtc: 0
name: DP-0
nameLen: 4
mm_width: 0
mm_height: 0
connection: 1
subpixel_order: 0
ncrtc: 4
nclone: 0
nmode: 0
npreferred: 0

output ID: 447
timestamp: 7820
crtc: 0
name: DP-0
nameLen: 4
mm_width: 0
mm_height: 0
connection: 1
subpixel_order: 0
ncrtc: 4
nclone: 0
nmode: 0
npreferred: 0

I'm not sure what the proper solution is. Perhaps, we should compare names instead of IDs?

tonsky commented 2 years ago

Chrome: https://github.com/chromium/chromium/blob/c4d3c31083a2e1481253ff2d24298a1dfe19c754/ui/base/x/x11_display_util.cc#L195-L334

Gecko: https://github.com/mozilla/gecko-dev/blob/f7eeca4e34daea900fbedbc392c8c99f90923143/toolkit/xre/glxtest.cpp#L649-L697

I guess the answer is just use first monitor in that case