xwayland: add option to enable/disable xwayland (#7633)

* config: add xwayland enabled option to config

* xwayland: use DISPLAY env variable for enable/disable of new launches

* xwayland: close X11 windows when turning of XWayland

* clang: format fix

* config: add better description for xwayland:enabled

* xwayland: close X11 windows on disable without crashes

* xwayland: better method of informing CXWayland if xwayland enabled

* xwayland: prevent closing non-xwayland windows on disable

* misc: loop formatting
This commit is contained in:
trianta 2024-09-05 11:26:46 -05:00 committed by GitHub
parent 027140b731
commit bd6d6e7f33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 48 additions and 6 deletions

View file

@ -432,7 +432,8 @@ int CXWaylandServer::ready(int fd, uint32_t mask) {
pipeSource = nullptr;
// start the wm
g_pXWayland->pWM = std::make_unique<CXWM>();
if (!g_pXWayland->pWM)
g_pXWayland->pWM = std::make_unique<CXWM>();
g_pCursorManager->setXWaylandCursor();

View file

@ -890,6 +890,10 @@ CXWM::~CXWM() {
if (eventSource)
wl_event_source_remove(eventSource);
for (auto const& sr : surfaces) {
sr->events.destroy.emit();
}
}
void CXWM::setActiveWindow(xcb_window_t window) {

View file

@ -1,12 +1,17 @@
#include "XWayland.hpp"
#include "../debug/Log.hpp"
CXWayland::CXWayland() {
CXWayland::CXWayland(const bool enabled) {
#ifndef NO_XWAYLAND
Debug::log(LOG, "Starting up the XWayland server");
pServer = std::make_unique<CXWaylandServer>();
if (!enabled) {
unsetenv("DISPLAY");
return;
}
if (!pServer->create()) {
Debug::log(ERR, "XWayland failed to start: it will not work.");
return;
@ -25,4 +30,4 @@ void CXWayland::setCursor(unsigned char* pixData, uint32_t stride, const Vector2
pWM->setCursor(pixData, stride, size, hotspot);
#endif
}
}

View file

@ -17,7 +17,7 @@ class CXWM;
class CXWayland {
public:
CXWayland();
CXWayland(const bool enabled);
#ifndef NO_XWAYLAND
std::unique_ptr<CXWaylandServer> pServer;
@ -126,4 +126,4 @@ inline std::unordered_map<std::string, uint32_t> HYPRATOMS = {
HYPRATOM("DELETE"),
HYPRATOM("TEXT"),
HYPRATOM("INCR"),
};
};