-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wayland Platform (Wayland, pt 2) #2482
Wayland Platform (Wayland, pt 2) #2482
Conversation
5707ede
to
a4c7f8e
Compare
fc52b06
to
0cf9955
Compare
c606fcd
to
392e923
Compare
392e923
to
a297698
Compare
b7681d6
to
df276d6
Compare
df276d6
to
43d047e
Compare
43d047e
to
448e179
Compare
448e179
to
d3dc76e
Compare
d3dc76e
to
abdb539
Compare
The code is generated by https://glad.dav1d.de/
This is in preparation for the future abstraction layer (gl-x11-*) and also to match the actual name of the windowing system. When running under X11, we can glue OpenGL through GLX or EGL, so the new file name matches that now.
Move the GLX-related code to gl-x11-glx, and introduce gl-nix as a winsys-agnostic abstraction layer. gl-nix serves as the runtime selector of which winsys going to be used. Only the X11/GLX winsys is available now, but later commits will introduce the X11/EGL winsys as well. The gl-nix code was originally written by Jason Francis <[email protected]>
Introduce the EGL/X11 winsys, and use it when the OBS_USE_EGL environment variable is defined. This variable is only temporary, for future commits will add a proper concept of platform. All the EGL/X11 code is authored by Ivan Avdeev <[email protected]>.
To keep consistency with the EGL line
List this dependency both under CI/install-dependencies-linux.sh, and .github/workflows/main.yml.
Currently, obs-nix.c is highly tied to the X11 display server. It includes X11 headers directly, and make use of X11 functions. Most of the code inside obs-nix.c that is X11-specific is related to hotkeys handling. Introduce a new vtable for hotkeys callbacks, that will used by X11 and Wayland to expose their specific routines. In this commit, only the X11 hotkeys vtable is implemented. Move all the X11-specific code to obs-nix-x11.c, and add a new function to retrieve the X11 hotkeys vtable.
This is a Unix-specific code. The only available platforms at this point are the X11/GLX and X11/EGL platforms. The concept of a platform display is also introduced. Again, the only display that is set right now is the X11 display.
Move the OBS_USE_EGL environment variable check to obs-app.cpp, and set the OBS platform to be either OBS_NIX_PLATFORM_X11_GLX or OBS_NIX_PLATFORM_X11_EGL.
Right now, linux-capture hard-depends on GLX. Disable it when running under EGL.
abdb539
to
536aad3
Compare
#include <QX11Info> | ||
|
||
#ifdef ENABLE_WAYLAND | ||
#include <qpa/qplatformnativeinterface.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This concerns me. Is there no way to do what you want to do without requiring private Qt headers? I feel like I've asked about this before but it's been a long time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm not aware of any replacement for that. This seems to be the documented way to retrieve the wl_surface
from a window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that documentation seems to be from the wayland site, not the Qt site, which is fine I suppose, but generally it requires the qtbase5-private-dev on debian-based, and that might cause problems for other distributions. If you feel confident that other distros won't have problems, then that's fine I suppose. I don't really mind it, but usually using private headers for any dependency is somewhat taboo because of potential for trouble compiling at best, ABI breakage at worst if they change the virtual function table. But that particular header seems to be a known thing that people tend to use, so ABI breakage is probably unlikely, and Qt5 is pretty much on its last legs anyway so it probably doesn't matter.
Anyway, I hit this roadblock at first, and the cmake files weren't able to detect whether the required file/package was available or not. It just errored compiling instead. I think that ideally, we should get cmake to detect whether the required files or packages are installed to ensure others don't have the same issue.
And if the package/file isn't detected/available, it should probably still build, but throw a cmake warning and disable building of wayland stuff or something. I'm not sure.
Ideally, I just want to make the build process cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean. I'll have a look at making CMake fail when that particular header is not there (it's the only header used from the private set, and I think it's safe to assume it'll be the only one too.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think this CMake change should work (haven't tested though). KDE folks pointed out this commit which does roughly the same, and I've replicated it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, detects it properly now. One question I might have is should we make it automatically compile without wayland support if the package isn't detected? Or should it be an explicit cmake option? I can't really decide. I think it's fine as is, but some people may be confused at first when they find that they can't compile OBS on Linux anymore. Might be good to have some sort of cmake warning at least telling them how to disable wayland support or something, or maybe just have it compile normally warning that wayland support was automatically disabled. I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving it as a dependency unless they explicitly turn off support seems best to me. At least this way downstream maintainers know they need to take action (be it removing functionality or adding dependencies).
536aad3
to
b502f2e
Compare
Introduce the OBS_NIX_PLATFORM_WAYLAND enum value, and try to detect it when OBS Studio runs by looking into the platform name.
We need to ensure we're running all X11 code on the same display.
b502f2e
to
137966e
Compare
Okay, the three pull requests look pretty good. Now the only problem is that they have merge conflicts between each of them (because I think they share commits). Should we create a single all-encompassing pull request for wayland support to solve this? |
I think if you merge the 3rd PR, all the commits from the previous ones will be merged too and they'll be automatically closed by GitHub as merged too. |
|
(This depends on #2478 and thus includes its commits)
This pull requests builds on top of @w23 and @cyclopsian's work, and their code (or code heavily inspired by them) is appropriately credited.
Description
Introduce the concept of platforms to
libobs
, add a default platform (which is X11 on Unix, default Windows, and default Mac), and add a Wayland platform (only available on Unix).Add a new
ENABLE_WAYLAND
build option to allow compiling OBS Studio with Wayland support. The Wayland platform (i.e theOBS_PLATFORM_WAYLAND
enum value, and related code) is only available when building with-DENABLE_WAYLAND=true
.Motivation and Context
This is the 2nd step of RFC #14.
The goal of this pull request is introduce the concept of platforms to OBS Studio, and properly isolate X11-only code paths.
How Has This Been Tested?
Under a Wayland desktop environment, run:
$ QT_QPA_PLATFORM=wayland OBS_USE_EGL=1 obs
Running OBS Studio with those environment variable will crash. This is expected. The crash will be gone with EGL/Wayland winsys in
libobs-opengl
. Because running OBS Studio withQT_QPA_PLATFORM=wayland
already results in segmentation faults, this shouldn't be considered a regression.My particular setup is Linux + GNOME + Wayland.
Types of changes
Checklist: