mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
refactor: simplify WM detection and exclusive fullscreen default
Removed WindowManager enum; detect_wm() now returns string directly. Default exclusive fullscreen based on platform (true on Linux). Added WM info to debug overlay.
This commit is contained in:
@@ -5,40 +5,23 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
namespace Cubed {
|
||||
enum class WindowManager { WINDOWS, UNKNOWN, NIRI, SWAY, HYPRLAND, KDE, GNOME };
|
||||
|
||||
namespace Tools {
|
||||
inline WindowManager detect_wm() {
|
||||
inline std::string detect_wm() {
|
||||
#ifdef _WIN32
|
||||
return WindowManager::WINDOWS;
|
||||
return "Windows";
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
|
||||
const char* desktop = getenv("XDG_CURRENT_DESKTOP");
|
||||
|
||||
if (!desktop)
|
||||
return WindowManager::UNKNOWN;
|
||||
Logger::info("XDG_CURRENT_DESKTOP {}", desktop);
|
||||
std::string wm(desktop);
|
||||
|
||||
if (wm.find("niri") != std::string::npos)
|
||||
return WindowManager::NIRI;
|
||||
|
||||
if (wm.find("sway") != std::string::npos)
|
||||
return WindowManager::SWAY;
|
||||
|
||||
if (wm.find("Hyprland") != std::string::npos)
|
||||
return WindowManager::HYPRLAND;
|
||||
|
||||
if (wm.find("KDE") != std::string::npos)
|
||||
return WindowManager::KDE;
|
||||
|
||||
if (wm.find("GNOME") != std::string::npos)
|
||||
return WindowManager::GNOME;
|
||||
|
||||
if (!desktop) {
|
||||
return "Unknown";
|
||||
}
|
||||
Logger::info("XDG_CURRENT_DESKTOP: {}", desktop);
|
||||
return std::string(desktop);
|
||||
#endif
|
||||
|
||||
return WindowManager::UNKNOWN;
|
||||
return "Unknown";
|
||||
}
|
||||
} // namespace Tools
|
||||
|
||||
|
||||
Reference in New Issue
Block a user