mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-28 12:40:33 +00:00
Detect x11/wayland at runtime
This commit is contained in:
parent
10ca72f934
commit
d68b8138a5
@ -23,6 +23,8 @@
|
||||
using namespace std::literals;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
window_system_e window_system;
|
||||
|
||||
namespace dyn {
|
||||
void *handle(const std::vector<const char *> &libs) {
|
||||
void *handle;
|
||||
@ -156,7 +158,7 @@ std::vector<std::string> wl_display_names();
|
||||
std::shared_ptr<display_t> wl_display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
|
||||
|
||||
bool verify_wl() {
|
||||
return !wl_display_names().empty();
|
||||
return window_system == window_system_e::WAYLAND && !wl_display_names().empty();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -174,7 +176,7 @@ std::vector<std::string> x11_display_names();
|
||||
std::shared_ptr<display_t> x11_display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
|
||||
|
||||
bool verify_x11() {
|
||||
return !x11_display_names().empty();
|
||||
return window_system == window_system_e::X11 && !x11_display_names().empty();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -220,6 +222,22 @@ std::unique_ptr<deinit_t> init() {
|
||||
// These are allowed to fail.
|
||||
gbm::init();
|
||||
va::init();
|
||||
|
||||
window_system = window_system_e::NONE;
|
||||
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||
if(std::getenv("WAYLAND_DISPLAY")) {
|
||||
window_system = window_system_e::WAYLAND;
|
||||
}
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_X11
|
||||
if(std::getenv("DISPLAY") && window_system != window_system_e::WAYLAND) {
|
||||
if(std::getenv("WAYLAND_DISPLAY")) {
|
||||
BOOST_LOG(warning) << "Wayland detected, yet sunshine will use X11 for screencasting, screencasting will only work on XWayland applications"sv;
|
||||
}
|
||||
|
||||
window_system = window_system_e::X11;
|
||||
}
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||
if(verify_wl()) {
|
||||
BOOST_LOG(info) << "Using Wayland for screencasting"sv;
|
||||
@ -229,6 +247,12 @@ std::unique_ptr<deinit_t> init() {
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_DRM
|
||||
if(verify_kms()) {
|
||||
if(window_system == window_system_e::WAYLAND) {
|
||||
// On Wayland, using KMS, the cursor is unreliable.
|
||||
// Hide it by default
|
||||
display_cursor = false;
|
||||
}
|
||||
|
||||
BOOST_LOG(info) << "Using KMS for screencasting"sv;
|
||||
source = source_e::KMS;
|
||||
goto found_source;
|
||||
|
@ -12,6 +12,14 @@ KITTY_USING_MOVE_T(file_t, int, -1, {
|
||||
}
|
||||
});
|
||||
|
||||
enum class window_system_e {
|
||||
NONE,
|
||||
X11,
|
||||
WAYLAND,
|
||||
};
|
||||
|
||||
extern window_system_e window_system;
|
||||
|
||||
namespace dyn {
|
||||
typedef void (*apiproc)(void);
|
||||
|
||||
|
@ -756,7 +756,9 @@ int load_xcb() {
|
||||
|
||||
int load_x11() {
|
||||
// This will be called once only
|
||||
static int x11_status = x11::init() || x11::rr::init() || x11::fix::init();
|
||||
static int x11_status =
|
||||
window_system == window_system_e::NONE ||
|
||||
x11::init() || x11::rr::init() || x11::fix::init();
|
||||
|
||||
return x11_status;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user