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
|
#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) {
|
void HudElements::sort_elements(const std::pair<std::string, std::string>& option) {
|
||||||
const auto& param = option.first;
|
const auto& param = option.first;
|
||||||
const auto& value = option.second;
|
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}},
|
{"refresh_rate", {refresh_rate}},
|
||||||
{"winesync", {winesync}},
|
{"winesync", {winesync}},
|
||||||
{"present_mode", {present_mode}},
|
{"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});
|
ordered_functions.push_back({present_mode, "present_mode", value});
|
||||||
if (params->enabled[OVERLAY_PARAM_ENABLED_refresh_rate])
|
if (params->enabled[OVERLAY_PARAM_ENABLED_refresh_rate])
|
||||||
ordered_functions.push_back({refresh_rate, "refresh_rate", value});
|
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(){
|
void HudElements::update_exec(){
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "overlay_params.h"
|
#include "overlay_params.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
#include "shared_x11.h"
|
||||||
|
|
||||||
struct Function {
|
struct Function {
|
||||||
std::function<void()> run; // Using std::function instead of a raw function pointer for more flexibility
|
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 hdr_status = 0;
|
||||||
int refresh = 0;
|
int refresh = 0;
|
||||||
unsigned int vsync = 10;
|
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<WineSync> winesync_ptr = nullptr;
|
||||||
std::unique_ptr<Net> net = nullptr;
|
std::unique_ptr<Net> net = nullptr;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -104,6 +114,7 @@ class HudElements{
|
|||||||
static void winesync();
|
static void winesync();
|
||||||
static void present_mode();
|
static void present_mode();
|
||||||
static void network();
|
static void network();
|
||||||
|
static void _display_session();
|
||||||
|
|
||||||
void convert_colors(const struct overlay_params& params);
|
void convert_colors(const struct overlay_params& params);
|
||||||
void convert_colors(bool do_conv, 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XQueryExtension =
|
||||||
|
reinterpret_cast<decltype(this->XQueryExtension)>(
|
||||||
|
dlsym(library_, "XQueryExtension"));
|
||||||
|
if (!XQueryExtension) {
|
||||||
|
CleanUp(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
loaded_ = true;
|
loaded_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -94,6 +102,7 @@ void libx11_loader::CleanUp(bool unload) {
|
|||||||
XKeysymToKeycode = NULL;
|
XKeysymToKeycode = NULL;
|
||||||
XStringToKeysym = NULL;
|
XStringToKeysym = NULL;
|
||||||
XGetGeometry = NULL;
|
XGetGeometry = NULL;
|
||||||
|
XQueryExtension = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class libx11_loader {
|
|||||||
decltype(&::XKeysymToKeycode) XKeysymToKeycode;
|
decltype(&::XKeysymToKeycode) XKeysymToKeycode;
|
||||||
decltype(&::XStringToKeysym) XStringToKeysym;
|
decltype(&::XStringToKeysym) XStringToKeysym;
|
||||||
decltype(&::XGetGeometry) XGetGeometry;
|
decltype(&::XGetGeometry) XGetGeometry;
|
||||||
|
decltype(&::XQueryExtension) XQueryExtension;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -114,6 +114,7 @@ typedef unsigned long KeySym;
|
|||||||
OVERLAY_PARAM_BOOL(winesync) \
|
OVERLAY_PARAM_BOOL(winesync) \
|
||||||
OVERLAY_PARAM_BOOL(present_mode) \
|
OVERLAY_PARAM_BOOL(present_mode) \
|
||||||
OVERLAY_PARAM_BOOL(time_no_label) \
|
OVERLAY_PARAM_BOOL(time_no_label) \
|
||||||
|
OVERLAY_PARAM_BOOL(display_server) \
|
||||||
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
|
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
|
||||||
OVERLAY_PARAM_CUSTOM(output_folder) \
|
OVERLAY_PARAM_CUSTOM(output_folder) \
|
||||||
OVERLAY_PARAM_CUSTOM(output_file) \
|
OVERLAY_PARAM_CUSTOM(output_file) \
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include "shared_x11.h"
|
#include "shared_x11.h"
|
||||||
#include "loaders/loader_x11.h"
|
#include "loaders/loader_x11.h"
|
||||||
|
#include "hud_elements.h"
|
||||||
|
|
||||||
static std::unique_ptr<Display, std::function<void(Display*)>> display;
|
static std::unique_ptr<Display, std::function<void(Display*)>> display;
|
||||||
|
|
||||||
@ -41,6 +42,15 @@ bool init_x11() {
|
|||||||
if (!displayid)
|
if (!displayid)
|
||||||
SPDLOG_DEBUG("DISPLAY env is not set");
|
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;
|
return !!display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2045,6 +2045,7 @@ static VkResult overlay_CreateWaylandSurfaceKHR(
|
|||||||
if (!wl_handle)
|
if (!wl_handle)
|
||||||
wl_handle = real_dlopen("libwayland-client.so", RTLD_LAZY);
|
wl_handle = real_dlopen("libwayland-client.so", RTLD_LAZY);
|
||||||
wl_display_ptr = pCreateInfo->display;
|
wl_display_ptr = pCreateInfo->display;
|
||||||
|
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
|
||||||
init_wayland_data();
|
init_wayland_data();
|
||||||
return instance_data->vtable.CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
|
return instance_data->vtable.CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "real_dlsym.h"
|
#include "real_dlsym.h"
|
||||||
#include "wayland_hook.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(const char *name);
|
||||||
EXPORT_C_(struct wl_display*) wl_display_connect_to_fd(int fd);
|
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) {
|
if (!wl_display_ptr) {
|
||||||
wl_display_ptr = ret;
|
wl_display_ptr = ret;
|
||||||
|
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
|
||||||
init_wayland_data();
|
init_wayland_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,6 +57,7 @@ EXPORT_C_(struct wl_display*) wl_display_connect_to_fd(int fd)
|
|||||||
|
|
||||||
if (!wl_display_ptr) {
|
if (!wl_display_ptr) {
|
||||||
wl_display_ptr = ret;
|
wl_display_ptr = ret;
|
||||||
|
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
|
||||||
init_wayland_data();
|
init_wayland_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user