mirror of
https://github.com/flightlessmango/MangoHud.git
synced 2024-11-11 19:10:55 +00:00
param: display_server
This option shows wether the app is native wayland, running under xwayland or regular X11
This commit is contained in:
parent
1abf530785
commit
7cfca3f8c2
@ -1475,6 +1475,20 @@ void HudElements::network() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void HudElements::_display_session() {
|
||||
ImGui::PushFont(HUDElements.sw_stats->font1);
|
||||
ImguiNextColumnFirstItem();
|
||||
HUDElements.TextColored(HUDElements.colors.engine, "%s", "display server");
|
||||
ImguiNextColumnOrNewRow();
|
||||
static std::map<display_servers, std::string> servers {
|
||||
{WAYLAND, {"WAYLAND"}},
|
||||
{XWAYLAND, {"XWAYLAND"}},
|
||||
{XORG, {"XORG"}}
|
||||
};
|
||||
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", servers[HUDElements.display_server].c_str());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
void HudElements::sort_elements(const std::pair<std::string, std::string>& option) {
|
||||
const auto& param = option.first;
|
||||
const auto& value = option.second;
|
||||
@ -1522,7 +1536,8 @@ void HudElements::sort_elements(const std::pair<std::string, std::string>& optio
|
||||
{"refresh_rate", {refresh_rate}},
|
||||
{"winesync", {winesync}},
|
||||
{"present_mode", {present_mode}},
|
||||
{"network", {network}}
|
||||
{"network", {network}},
|
||||
{"display_session", {_display_session}}
|
||||
|
||||
};
|
||||
|
||||
@ -1650,6 +1665,8 @@ void HudElements::legacy_elements(){
|
||||
ordered_functions.push_back({present_mode, "present_mode", value});
|
||||
if (params->enabled[OVERLAY_PARAM_ENABLED_refresh_rate])
|
||||
ordered_functions.push_back({refresh_rate, "refresh_rate", value});
|
||||
if (params->enabled[OVERLAY_PARAM_ENABLED_display_server])
|
||||
ordered_functions.push_back({_display_session, "display_session", value});
|
||||
}
|
||||
|
||||
void HudElements::update_exec(){
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "net.h"
|
||||
#include "overlay_params.h"
|
||||
#include "shell.h"
|
||||
#include "shared_x11.h"
|
||||
|
||||
struct Function {
|
||||
std::function<void()> run; // Using std::function instead of a raw function pointer for more flexibility
|
||||
@ -53,6 +54,15 @@ class HudElements{
|
||||
int hdr_status = 0;
|
||||
int refresh = 0;
|
||||
unsigned int vsync = 10;
|
||||
|
||||
enum display_servers {
|
||||
UNKNOWN,
|
||||
WAYLAND,
|
||||
XWAYLAND,
|
||||
XORG
|
||||
};
|
||||
|
||||
display_servers display_server = UNKNOWN;
|
||||
std::unique_ptr<WineSync> winesync_ptr = nullptr;
|
||||
std::unique_ptr<Net> net = nullptr;
|
||||
#ifdef __linux__
|
||||
@ -104,6 +114,7 @@ class HudElements{
|
||||
static void winesync();
|
||||
static void present_mode();
|
||||
static void network();
|
||||
static void _display_session();
|
||||
|
||||
void convert_colors(const struct overlay_params& params);
|
||||
void convert_colors(bool do_conv, const struct overlay_params& params);
|
||||
|
@ -77,6 +77,14 @@ bool libx11_loader::Load(const std::string& library_name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XQueryExtension =
|
||||
reinterpret_cast<decltype(this->XQueryExtension)>(
|
||||
dlsym(library_, "XQueryExtension"));
|
||||
if (!XQueryExtension) {
|
||||
CleanUp(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
loaded_ = true;
|
||||
return true;
|
||||
}
|
||||
@ -94,6 +102,7 @@ void libx11_loader::CleanUp(bool unload) {
|
||||
XKeysymToKeycode = NULL;
|
||||
XStringToKeysym = NULL;
|
||||
XGetGeometry = NULL;
|
||||
XQueryExtension = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ class libx11_loader {
|
||||
decltype(&::XKeysymToKeycode) XKeysymToKeycode;
|
||||
decltype(&::XStringToKeysym) XStringToKeysym;
|
||||
decltype(&::XGetGeometry) XGetGeometry;
|
||||
decltype(&::XQueryExtension) XQueryExtension;
|
||||
|
||||
|
||||
private:
|
||||
|
@ -114,6 +114,7 @@ typedef unsigned long KeySym;
|
||||
OVERLAY_PARAM_BOOL(winesync) \
|
||||
OVERLAY_PARAM_BOOL(present_mode) \
|
||||
OVERLAY_PARAM_BOOL(time_no_label) \
|
||||
OVERLAY_PARAM_BOOL(display_server) \
|
||||
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
|
||||
OVERLAY_PARAM_CUSTOM(output_folder) \
|
||||
OVERLAY_PARAM_CUSTOM(output_file) \
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include "shared_x11.h"
|
||||
#include "loaders/loader_x11.h"
|
||||
#include "hud_elements.h"
|
||||
|
||||
static std::unique_ptr<Display, std::function<void(Display*)>> display;
|
||||
|
||||
@ -41,6 +42,15 @@ bool init_x11() {
|
||||
if (!displayid)
|
||||
SPDLOG_DEBUG("DISPLAY env is not set");
|
||||
|
||||
if (display && HUDElements.display_server == HUDElements.display_servers::UNKNOWN) {
|
||||
int opcode, event, error;
|
||||
if (libx11->XQueryExtension(display.get(), "XWAYLAND", &opcode, &event, &error))
|
||||
HUDElements.display_server = HUDElements.display_servers::XWAYLAND;
|
||||
else
|
||||
HUDElements.display_server = HUDElements.display_servers::XORG;
|
||||
|
||||
}
|
||||
|
||||
return !!display;
|
||||
}
|
||||
|
||||
|
@ -2045,6 +2045,7 @@ static VkResult overlay_CreateWaylandSurfaceKHR(
|
||||
if (!wl_handle)
|
||||
wl_handle = real_dlopen("libwayland-client.so", RTLD_LAZY);
|
||||
wl_display_ptr = pCreateInfo->display;
|
||||
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
|
||||
init_wayland_data();
|
||||
return instance_data->vtable.CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <cstdio>
|
||||
#include "real_dlsym.h"
|
||||
#include "wayland_hook.h"
|
||||
#include "hud_elements.h"
|
||||
|
||||
EXPORT_C_(struct wl_display*) wl_display_connect(const char *name);
|
||||
EXPORT_C_(struct wl_display*) wl_display_connect_to_fd(int fd);
|
||||
@ -32,6 +33,7 @@ EXPORT_C_(struct wl_display*) wl_display_connect(const char *name)
|
||||
|
||||
if (!wl_display_ptr) {
|
||||
wl_display_ptr = ret;
|
||||
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
|
||||
init_wayland_data();
|
||||
}
|
||||
}
|
||||
@ -55,6 +57,7 @@ EXPORT_C_(struct wl_display*) wl_display_connect_to_fd(int fd)
|
||||
|
||||
if (!wl_display_ptr) {
|
||||
wl_display_ptr = ret;
|
||||
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
|
||||
init_wayland_data();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user