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;
|
using namespace std::literals;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
window_system_e window_system;
|
||||||
|
|
||||||
namespace dyn {
|
namespace dyn {
|
||||||
void *handle(const std::vector<const char *> &libs) {
|
void *handle(const std::vector<const char *> &libs) {
|
||||||
void *handle;
|
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);
|
std::shared_ptr<display_t> wl_display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
|
||||||
|
|
||||||
bool verify_wl() {
|
bool verify_wl() {
|
||||||
return !wl_display_names().empty();
|
return window_system == window_system_e::WAYLAND && !wl_display_names().empty();
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
std::shared_ptr<display_t> x11_display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
|
||||||
|
|
||||||
bool verify_x11() {
|
bool verify_x11() {
|
||||||
return !x11_display_names().empty();
|
return window_system == window_system_e::X11 && !x11_display_names().empty();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -220,6 +222,22 @@ std::unique_ptr<deinit_t> init() {
|
|||||||
// These are allowed to fail.
|
// These are allowed to fail.
|
||||||
gbm::init();
|
gbm::init();
|
||||||
va::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
|
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||||
if(verify_wl()) {
|
if(verify_wl()) {
|
||||||
BOOST_LOG(info) << "Using Wayland for screencasting"sv;
|
BOOST_LOG(info) << "Using Wayland for screencasting"sv;
|
||||||
@ -229,6 +247,12 @@ std::unique_ptr<deinit_t> init() {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_DRM
|
#ifdef SUNSHINE_BUILD_DRM
|
||||||
if(verify_kms()) {
|
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;
|
BOOST_LOG(info) << "Using KMS for screencasting"sv;
|
||||||
source = source_e::KMS;
|
source = source_e::KMS;
|
||||||
goto found_source;
|
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 {
|
namespace dyn {
|
||||||
typedef void (*apiproc)(void);
|
typedef void (*apiproc)(void);
|
||||||
|
|
||||||
|
@ -756,7 +756,9 @@ int load_xcb() {
|
|||||||
|
|
||||||
int load_x11() {
|
int load_x11() {
|
||||||
// This will be called once only
|
// 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;
|
return x11_status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user