quickshell/src/wayland/init.cpp

61 lines
1.6 KiB
C++
Raw Normal View History

#include <qguiapplication.h>
2024-10-31 01:28:06 -07:00
#include <qlist.h>
2024-05-20 02:16:44 -07:00
#include <qlogging.h>
#include <qqml.h>
2024-05-20 02:16:44 -07:00
#include <qtenvironmentvariables.h>
#include "../core/plugin.hpp"
#ifdef QS_WAYLAND_WLR_LAYERSHELL
#include "wlr_layershell.hpp"
#endif
void installPlatformMenuHook();
void installPopupPositioner();
namespace {
class WaylandPlugin: public QsEnginePlugin {
2024-10-31 01:28:06 -07:00
QList<QString> dependencies() override { return {"window"}; }
2024-05-20 02:16:44 -07:00
bool applies() override {
auto isWayland = QGuiApplication::platformName() == "wayland";
if (!isWayland && !qEnvironmentVariable("WAYLAND_DISPLAY").isEmpty()) {
qWarning() << "--- WARNING ---";
qWarning() << "WAYLAND_DISPLAY is present but QT_QPA_PLATFORM is"
<< QGuiApplication::platformName();
qWarning() << "If you are actually running wayland, set QT_QPA_PLATFORM to \"wayland\" or "
"most functionality will be broken.";
}
return isWayland;
}
void init() override {
installPlatformMenuHook();
installPopupPositioner();
}
void registerTypes() override {
#ifdef QS_WAYLAND_WLR_LAYERSHELL
2024-02-26 00:57:47 -08:00
qmlRegisterType<WaylandPanelInterface>("Quickshell._WaylandOverlay", 1, 0, "PanelWindow");
// If any types are defined inside a module using QML_ELEMENT then all QML_ELEMENT types
// will not be registered. This can be worked around with a module import which makes
// the QML_ELMENT module import the old register-type style module.
qmlRegisterModuleImport(
2024-02-26 00:57:47 -08:00
"Quickshell",
QQmlModuleImportModuleAny,
2024-02-26 00:57:47 -08:00
"Quickshell._WaylandOverlay",
QQmlModuleImportLatest
);
#endif
}
};
QS_REGISTER_PLUGIN(WaylandPlugin);
} // namespace