Skip to content

Commit efe8d9d

Browse files
committed
Disable multi-viewports under WSL
1 parent 9d35e85 commit efe8d9d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/application.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,15 @@ int Application::run(int argc, char** argv) {
141141
ImGuiIO& io = ImGui::GetIO();
142142
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
143143
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
144+
145+
#ifdef _WIN32
144146
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
147+
#else
148+
// Multi-viewport doesn't work very well under WSL
149+
if (!Application::isRunningUnderWSL()) {
150+
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
151+
}
152+
#endif
145153

146154
m_iniFilename = (getConfigPath() / "nitroefx.ini").string();
147155
io.IniFilename = m_iniFilename.c_str();
@@ -2083,6 +2091,26 @@ std::optional<AppVersion> Application::findLatestVersion() {
20832091
return getNewestVersion(versions);
20842092
}
20852093

2094+
bool Application::isRunningUnderWSL() {
2095+
#ifdef _WIN32
2096+
return false;
2097+
#else
2098+
try {
2099+
std::ifstream osrelease("/proc/sys/kernel/osrelease");
2100+
if (!osrelease.is_open()) {
2101+
return false;
2102+
}
2103+
std::string line;
2104+
std::getline(osrelease, line);
2105+
osrelease.close();
2106+
2107+
return line.contains("microsoft") || line.contains("WSL");
2108+
} catch (...) {
2109+
return false;
2110+
}
2111+
#endif
2112+
}
2113+
20862114
void Application::applyUpdateNow(const std::filesystem::path& binaryPath, bool relaunch) {
20872115
const auto currentExecutable = getExecutablePath();
20882116

src/application.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Application {
7777

7878
static int update(const std::filesystem::path& srcPath, const std::filesystem::path& dstPath, unsigned long pid, bool relaunch);
7979

80-
static constexpr auto VERSION = "v1.2.2-rc3";
80+
static constexpr auto VERSION = "v1.2.2-rc4";
8181

8282
private:
8383
void pollEvents();
@@ -117,6 +117,8 @@ class Application {
117117

118118
std::optional<AppVersion> findLatestVersion();
119119

120+
static bool isRunningUnderWSL();
121+
120122
static size_t writeBodyCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
121123
static size_t writeHeaderCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
122124
static size_t writeFileCallback(char* ptr, size_t sz, size_t nm, void* ud);

0 commit comments

Comments
 (0)