Skip to content
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

Don't rely on x11 when with_x11 is disabled #1500

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if is_unixy
dep_wayland_client = dependency('wayland-client',
required: get_option('with_wayland'), version : '>=1.11')
dbus_dep = dependency('dbus-1', required: get_option('with_dbus')).partial_dependency(compile_args : true, includes : true)
dep_xkb = dependency('xkbcommon', required: get_option('with_wayland'))
dep_xkb = dependency('xkbcommon', required: get_option('with_x11').enabled() or get_option('with_wayland').enabled())
else
dep_x11 = null_dep
dep_wayland_client = null_dep
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ int main(int, char**)
PropModeReplace, (unsigned char *)&value, 1);
// Main loop
while (!glfwWindowShouldClose(window)){
check_keybinds(params, vendorID);
check_keybinds(params);

if (!params.no_display){
if (mangoapp_paused){
Expand Down
7 changes: 5 additions & 2 deletions src/gl/gl_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#define GLX_RENDERER_VENDOR_ID_MESA 0x8183
#define GLX_RENDERER_DEVICE_ID_MESA 0x8184

#ifdef HAVE_X11
bool glx_mesa_queryInteger(int attrib, unsigned int *value);
#endif

namespace MangoHud { namespace GL {

Expand Down Expand Up @@ -148,9 +150,10 @@ void imgui_create(void *ctx, const gl_wsi plat)
HUDElements.vendorID = vendorID;

uint32_t device_id = 0;
#ifdef HAVE_X11
if (plat == gl_wsi::GL_WSI_GLX)
glx_mesa_queryInteger(GLX_RENDERER_DEVICE_ID_MESA, &device_id);

#endif
SPDLOG_DEBUG("GL device id: {:04X}", device_id);
sw_stats.gpuName = gpu = remove_parentheses(deviceName);
SPDLOG_DEBUG("gpu: {}", gpu);
Expand Down Expand Up @@ -214,7 +217,7 @@ void imgui_render(unsigned int width, unsigned int height)
process_control_socket(control_client, params);
}

check_keybinds(params, vendorID);
check_keybinds(params);
update_hud_info(sw_stats, params, vendorID);

ImGuiContext *saved_ctx = ImGui::GetCurrentContext();
Expand Down
15 changes: 9 additions & 6 deletions src/gl/inject_egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,16 @@ EXPORT_C_(void*) eglGetDisplay( void* native_display )
try
{
void** display_ptr = (void**)native_display;
wl_interface* iface = (wl_interface*)*display_ptr;
if(iface && strcmp(iface->name, wl_display_interface.name) == 0)
if (native_display)
{
wl_display_ptr = (struct wl_display*)native_display;
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
wl_handle = real_dlopen("libwayland-client.so", RTLD_LAZY);
init_wayland_data();
wl_interface* iface = (wl_interface*)*display_ptr;
if(iface && strcmp(iface->name, wl_display_interface.name) == 0)
{
wl_display_ptr = (struct wl_display*)native_display;
HUDElements.display_server = HUDElements.display_servers::WAYLAND;
wl_handle = real_dlopen("libwayland-client.so", RTLD_LAZY);
init_wayland_data();
}
}
}
catch(...)
Expand Down
2 changes: 1 addition & 1 deletion src/keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Clock::time_point last_f2_press, toggle_fps_limit_press, toggle_preset_press, last_f12_press, reload_cfg_press, last_upload_press;

void check_keybinds(struct overlay_params& params, uint32_t vendorID){
void check_keybinds(struct overlay_params& params){
using namespace std::chrono_literals;
auto now = Clock::now(); /* us */
auto elapsedF2 = now - last_f2_press;
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ if is_unixy
'loaders/loader_x11.cpp',
'shared_x11.cpp',
)
endif

opengl_files += files(
'loaders/loader_glx.cpp',
'gl/inject_glx.cpp',
)
endif

if get_option('with_wayland').enabled()
pre_args += '-DHAVE_WAYLAND'
Expand Down
2 changes: 1 addition & 1 deletion src/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void update_hud_info(struct swapchain_stats& sw_stats, const struct overlay_para
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns);
void update_hw_info(const struct overlay_params& params, uint32_t vendorID);
void init_cpu_stats(overlay_params& params);
void check_keybinds(overlay_params& params, uint32_t vendorID);
void check_keybinds(overlay_params& params);
void init_system_info(void);
void FpsLimiter(struct fps_limit& stats);
void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
Expand Down
46 changes: 21 additions & 25 deletions src/overlay_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
#include "mesa/util/os_socket.h"
#include "file_utils.h"

#ifdef HAVE_X11
#include <X11/keysym.h>
#include "loaders/loader_x11.h"
#if defined(HAVE_X11) || defined(HAVE_WAYLAND)
#include <xkbcommon/xkbcommon.h>
#endif

#include "dbus_info.h"
Expand Down Expand Up @@ -132,22 +131,19 @@ parse_float(const char *str)
return val;
}

#ifdef HAVE_X11
#if defined(HAVE_X11) || defined(HAVE_WAYLAND)
static std::vector<KeySym>
parse_string_to_keysym_vec(const char *str)
{
std::vector<KeySym> keys;
if(get_libx11()->IsLoaded())
{
auto keyStrings = str_tokenize(str);
for (auto& ks : keyStrings) {
trim(ks);
KeySym xk = get_libx11()->XStringToKeysym(ks.c_str());
if (xk)
keys.push_back(xk);
else
SPDLOG_ERROR("Unrecognized key: '{}'", ks);
}
auto keyStrings = str_tokenize(str);
for (auto& ks : keyStrings) {
trim(ks);
xkb_keysym_t xk = xkb_keysym_from_name(ks.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
if (xk != XKB_KEY_NoSymbol)
keys.push_back(xk);
else
SPDLOG_ERROR("Unrecognized key: '{}'", ks);
}
return keys;
}
Expand Down Expand Up @@ -785,16 +781,16 @@ parse_overlay_config(struct overlay_params *params,
current_preset = params->preset[0];
}

#ifdef HAVE_X11
params->toggle_hud = { XK_Shift_R, XK_F12 };
params->toggle_hud_position = { XK_Shift_R, XK_F11 };
params->toggle_preset = { XK_Shift_R, XK_F10 };
params->reset_fps_metrics = { XK_Shift_R, XK_F9};
params->toggle_fps_limit = { XK_Shift_L, XK_F1 };
params->toggle_logging = { XK_Shift_L, XK_F2 };
params->reload_cfg = { XK_Shift_L, XK_F4 };
params->upload_log = { XK_Shift_L, XK_F3 };
params->upload_logs = { XK_Control_L, XK_F3 };
#if defined(HAVE_X11) || defined(HAVE_WAYLAND)
params->toggle_hud = { XKB_KEY_Shift_R, XKB_KEY_F12 };
params->toggle_hud_position = { XKB_KEY_Shift_R, XKB_KEY_F11 };
params->toggle_preset = { XKB_KEY_Shift_R, XKB_KEY_F10 };
params->reset_fps_metrics = { XKB_KEY_Shift_R, XKB_KEY_F9};
params->toggle_fps_limit = { XKB_KEY_Shift_L, XKB_KEY_F1 };
params->toggle_logging = { XKB_KEY_Shift_L, XKB_KEY_F2 };
params->reload_cfg = { XKB_KEY_Shift_L, XKB_KEY_F4 };
params->upload_log = { XKB_KEY_Shift_L, XKB_KEY_F3 };
params->upload_logs = { XKB_KEY_Control_L, XKB_KEY_F3 };
#endif

#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
struct device_data *device_data = data->device;
struct instance_data *instance_data = device_data->instance;
update_hud_info(data->sw_stats, instance_data->params, device_data->properties.vendorID);
check_keybinds(instance_data->params, device_data->properties.vendorID);
check_keybinds(instance_data->params);
#ifdef __linux__
if (instance_data->params.control >= 0) {
control_client_check(instance_data->params.control, instance_data->control_client, gpu.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/win/d3d_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ void init_d3d_shared(){
}

void d3d_run(){
check_keybinds(params, vendorID);
check_keybinds(params);
update_hud_info(sw_stats, params, vendorID);
}
Loading