Compile SDL with wayland support

This commit is contained in:
Yousef Khadadeh 2026-06-11 22:35:54 +03:00
parent 40fcc634ef
commit ad7add9bec
7 changed files with 36 additions and 29 deletions

View file

@ -55,6 +55,9 @@ nlohmann::json GlobalConfig::get_config_json(const InputManager& input) const {
toRet["dragZoomSpeed"] = dragZoomSpeed;
toRet["scrollZoomSpeed"] = scrollZoomSpeed;
toRet["vsync"] = vsyncValue;
#ifdef ADD_PREFER_X11_OPTION
toRet["preferX11"] = preferX11;
#endif
#ifndef __EMSCRIPTEN__
toRet["applyDisplayScale"] = applyDisplayScale;
#endif
@ -126,6 +129,9 @@ void GlobalConfig::set_config_json(InputManager& input, const nlohmann::json& j,
try{j.at("mainCallbackRateBackground").get_to(mainCallbackRateBackground);} catch(...) {}
if(version >= VersionNumber(0, 6, 0))
try{j.at("vsync").get_to(vsyncValue);} catch(...) {}
#ifdef ADD_PREFER_X11_OPTION
try{j.at("preferX11").get_to(preferX11);} catch(...) {}
#endif
#ifndef __EMSCRIPTEN__
try{j.at("applyDisplayScale").get_to(applyDisplayScale);} catch(...) {}
#endif

View file

@ -119,6 +119,11 @@ class GlobalConfig {
#ifndef __EMSCRIPTEN__
bool applyDisplayScale = true;
#endif
#ifdef ADD_PREFER_X11_OPTION
bool preferX11 = false;
#endif
private:
void load_default_palette();
};

View file

@ -1529,6 +1529,9 @@ void Toolbar::general_settings_inner_gui() {
checkbox_boolean_field(gui, "real time eraser", "Eraser works in real time", &main.conf.realTimeEraser);
checkbox_boolean_field(gui, "force extension on path", "Force extension on path when saving files", &main.conf.forceExtensionOnPath);
#ifdef ADD_PREFER_X11_OPTION
checkbox_boolean_field(gui, "prefer x11", "Prefer X11 over Wayland (Requires restart)", &main.conf.preferX11);
#endif
});
break;
}

View file

@ -227,6 +227,10 @@ void initialize_sdl(MainStruct& mS) {
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
SDL_SetHint(SDL_HINT_ANDROID_TRAP_BACK_BUTTON, "1");
SDL_SetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT, "#canvas"); // Ensures that SDL only grabs input when browser is focused on canvas
#ifdef ADD_PREFER_X11_OPTION
if(mS.m->conf.preferX11)
SDL_SetHint(SDL_HINT_VIDEO_DRIVER, "x11,wayland");
#endif
if(!SDL_Init(SDL_INIT_VIDEO))
throw std::runtime_error("[SDL_Init] " + std::string(SDL_GetError()));