debug: move to hyprutils' logger (#12673)
This commit is contained in:
parent
f88deb928a
commit
6175ecd4c4
147 changed files with 1696 additions and 1709 deletions
|
|
@ -61,7 +61,7 @@ xcb_window_t CX11DataDevice::getProxyWindow(xcb_window_t window) {
|
|||
xcb_window_t verifyWindow = *sc<xcb_window_t*>(xcb_get_property_value(proxyVerifyReply));
|
||||
if (verifyWindow == proxyWindow) {
|
||||
targetWindow = proxyWindow;
|
||||
Debug::log(LOG, "Using XdndProxy window {:x} for window {:x}", proxyWindow, window);
|
||||
Log::logger->log(Log::DEBUG, "Using XdndProxy window {:x} for window {:x}", proxyWindow, window);
|
||||
}
|
||||
}
|
||||
free(proxyVerifyReply); // NOLINT(cppcoreguidelines-no-malloc)
|
||||
|
|
@ -103,14 +103,14 @@ void CX11DataDevice::sendEnter(uint32_t serial, SP<CWLSurfaceResource> surf, con
|
|||
auto XSURF = g_pXWayland->m_wm->windowForWayland(surf);
|
||||
|
||||
if (!XSURF) {
|
||||
Debug::log(ERR, "CX11DataDevice::sendEnter: No xwayland surface for destination");
|
||||
Log::logger->log(Log::ERR, "CX11DataDevice::sendEnter: No xwayland surface for destination");
|
||||
return;
|
||||
}
|
||||
|
||||
auto SOURCE = offer->getSource();
|
||||
|
||||
if (!SOURCE) {
|
||||
Debug::log(ERR, "CX11DataDevice::sendEnter: No source");
|
||||
Log::logger->log(Log::ERR, "CX11DataDevice::sendEnter: No source");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ void CX11DataDevice::sendEnter(uint32_t serial, SP<CWLSurfaceResource> surf, con
|
|||
|
||||
auto hlSurface = XSURF->m_surface.lock();
|
||||
if (!hlSurface) {
|
||||
Debug::log(ERR, "CX11DataDevice::sendEnter: Non desktop x surface?!");
|
||||
Log::logger->log(Log::ERR, "CX11DataDevice::sendEnter: Non desktop x surface?!");
|
||||
m_lastSurfaceCoords = {};
|
||||
return;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ void CX11DataDevice::sendMotion(uint32_t timeMs, const Vector2D& local) {
|
|||
void CX11DataDevice::sendDrop() {
|
||||
#ifndef NO_XWAYLAND
|
||||
if (!m_lastSurface || !m_lastOffer) {
|
||||
Debug::log(ERR, "CX11DataDevice::sendDrop: No surface or offer");
|
||||
Log::logger->log(Log::ERR, "CX11DataDevice::sendDrop: No surface or offer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ bool CX11DataSource::dndDone() {
|
|||
}
|
||||
|
||||
void CX11DataSource::error(uint32_t code, const std::string& msg) {
|
||||
Debug::log(ERR, "CX11DataSource error: code {} msg {}", code, msg);
|
||||
Log::logger->log(Log::ERR, "CX11DataSource error: code {} msg {}", code, msg);
|
||||
m_dndSuccess = false;
|
||||
m_dropped = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include "Server.hpp"
|
||||
#include "XWayland.hpp"
|
||||
#include "config/ConfigValue.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "debug/log/Logger.hpp"
|
||||
#include "../defines.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../managers/CursorManager.hpp"
|
||||
|
|
@ -41,12 +41,12 @@ static CFileDescriptor createSocket(struct sockaddr_un* addr, size_t pathSize) {
|
|||
socklen_t size = offsetof(struct sockaddr_un, sun_path) + pathSize + 1;
|
||||
CFileDescriptor fd{socket(AF_UNIX, SOCK_STREAM, 0)};
|
||||
if (!fd.isValid()) {
|
||||
Debug::log(ERR, "Failed to create socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
Log::logger->log(Log::ERR, "Failed to create socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!fd.setFlags(fd.getFlags() | FD_CLOEXEC)) {
|
||||
Debug::log(ERR, "Failed to set flags for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
Log::logger->log(Log::ERR, "Failed to set flags for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ static CFileDescriptor createSocket(struct sockaddr_un* addr, size_t pathSize) {
|
|||
unlink(addr->sun_path);
|
||||
|
||||
if (bind(fd.get(), rc<struct sockaddr*>(addr), size) < 0) {
|
||||
Debug::log(ERR, "Failed to bind socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
Log::logger->log(Log::ERR, "Failed to bind socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
if (isRegularSocket)
|
||||
unlink(addr->sun_path);
|
||||
return {};
|
||||
|
|
@ -66,11 +66,11 @@ static CFileDescriptor createSocket(struct sockaddr_un* addr, size_t pathSize) {
|
|||
if (isRegularSocket && chmod(addr->sun_path, 0666) < 0) {
|
||||
// We are only extending the default permissions,
|
||||
// and I don't see the reason to make a full stop in case of a failed operation.
|
||||
Debug::log(ERR, "Failed to set permission mode for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
Log::logger->log(Log::ERR, "Failed to set permission mode for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
}
|
||||
|
||||
if (listen(fd.get(), SOCKET_BACKLOG) < 0) {
|
||||
Debug::log(ERR, "Failed to listen to socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
Log::logger->log(Log::ERR, "Failed to listen to socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
|
||||
if (isRegularSocket)
|
||||
unlink(addr->sun_path);
|
||||
return {};
|
||||
|
|
@ -83,23 +83,23 @@ static bool checkPermissionsForSocketDir() {
|
|||
struct stat buf;
|
||||
|
||||
if (lstat("/tmp/.X11-unix", &buf)) {
|
||||
Debug::log(ERR, "Failed to stat X11 socket dir");
|
||||
Log::logger->log(Log::ERR, "Failed to stat X11 socket dir");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(buf.st_mode & S_IFDIR)) {
|
||||
Debug::log(ERR, "X11 socket dir is not a directory");
|
||||
Log::logger->log(Log::ERR, "X11 socket dir is not a directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((buf.st_uid != 0) && (buf.st_uid != getuid())) {
|
||||
Debug::log(ERR, "X11 socket dir is not owned by root or current user");
|
||||
Log::logger->log(Log::ERR, "X11 socket dir is not owned by root or current user");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(buf.st_mode & S_ISVTX)) {
|
||||
if ((buf.st_mode & (S_IWGRP | S_IWOTH))) {
|
||||
Debug::log(ERR, "X11 socket dir is writable by others");
|
||||
Log::logger->log(Log::ERR, "X11 socket dir is writable by others");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ static bool ensureSocketDirExists() {
|
|||
if (errno == EEXIST)
|
||||
return checkPermissionsForSocketDir();
|
||||
else {
|
||||
Debug::log(ERR, "XWayland: Couldn't create socket dir");
|
||||
Log::logger->log(Log::ERR, "XWayland: Couldn't create socket dir");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ static bool openSockets(std::array<CFileDescriptor, 2>& sockets, int display) {
|
|||
}
|
||||
#else
|
||||
if (*CREATEABSTRACTSOCKET) {
|
||||
Debug::log(WARN, "The abstract XWayland Unix domain socket might be used only on Linux systems. A regular one'll be created instead.");
|
||||
Log::logger->log(Log::WARN, "The abstract XWayland Unix domain socket might be used only on Linux systems. A regular one'll be created instead.");
|
||||
}
|
||||
path = getSocketPath(display, false);
|
||||
strncpy(addr.sun_path, path.c_str(), path.length() + 1);
|
||||
|
|
@ -173,7 +173,7 @@ static bool openSockets(std::array<CFileDescriptor, 2>& sockets, int display) {
|
|||
|
||||
static void startServer(void* data) {
|
||||
if (!g_pXWayland->m_server->start())
|
||||
Debug::log(ERR, "The XWayland server could not start! XWayland will not work...");
|
||||
Log::logger->log(Log::ERR, "The XWayland server could not start! XWayland will not work...");
|
||||
}
|
||||
|
||||
static int xwaylandReady(int fd, uint32_t mask, void* data) {
|
||||
|
|
@ -183,7 +183,7 @@ static int xwaylandReady(int fd, uint32_t mask, void* data) {
|
|||
static bool safeRemove(const std::string& path) {
|
||||
try {
|
||||
return std::filesystem::remove(path);
|
||||
} catch (const std::exception& e) { Debug::log(ERR, "[XWayland] Failed to remove {}", path); }
|
||||
} catch (const std::exception& e) { Log::logger->log(Log::ERR, "[XWayland] Failed to remove {}", path); }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -232,11 +232,11 @@ bool CXWaylandServer::tryOpenSockets() {
|
|||
}
|
||||
|
||||
if (m_display < 0) {
|
||||
Debug::log(ERR, "Failed to find a suitable socket for XWayland");
|
||||
Log::logger->log(Log::ERR, "Failed to find a suitable socket for XWayland");
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "XWayland found a suitable display socket at DISPLAY: {}", m_displayName);
|
||||
Log::logger->log(Log::DEBUG, "XWayland found a suitable display socket at DISPLAY: {}", m_displayName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ bool CXWaylandServer::create() {
|
|||
void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) {
|
||||
if (!m_xFDs[0].setFlags(m_xFDs[0].getFlags() & ~FD_CLOEXEC) || !m_xFDs[1].setFlags(m_xFDs[1].getFlags() & ~FD_CLOEXEC) ||
|
||||
!m_waylandFDs[1].setFlags(m_waylandFDs[1].getFlags() & ~FD_CLOEXEC) || !m_xwmFDs[1].setFlags(m_xwmFDs[1].getFlags() & ~FD_CLOEXEC)) {
|
||||
Debug::log(ERR, "Failed to unset cloexec on fds");
|
||||
Log::logger->log(Log::ERR, "Failed to unset cloexec on fds");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -305,11 +305,11 @@ void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) {
|
|||
auto waylandSocket = std::format("{}", m_waylandFDs[1].get());
|
||||
setenv("WAYLAND_SOCKET", waylandSocket.c_str(), true);
|
||||
|
||||
Debug::log(LOG, "Starting XWayland with \"{}\", bon voyage!", cmd);
|
||||
Log::logger->log(Log::DEBUG, "Starting XWayland with \"{}\", bon voyage!", cmd);
|
||||
|
||||
execl("/bin/sh", "/bin/sh", "-c", cmd.c_str(), nullptr);
|
||||
|
||||
Debug::log(ERR, "XWayland failed to open");
|
||||
Log::logger->log(Log::ERR, "XWayland failed to open");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ bool CXWaylandServer::start() {
|
|||
m_idleSource = nullptr;
|
||||
int wlPair[2] = {-1, -1};
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, wlPair) != 0) {
|
||||
Debug::log(ERR, "socketpair failed (1)");
|
||||
Log::logger->log(Log::ERR, "socketpair failed (1)");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -325,14 +325,14 @@ bool CXWaylandServer::start() {
|
|||
m_waylandFDs[1] = CFileDescriptor{wlPair[1]};
|
||||
|
||||
if (!m_waylandFDs[0].setFlags(m_waylandFDs[0].getFlags() | FD_CLOEXEC) || !m_waylandFDs[1].setFlags(m_waylandFDs[1].getFlags() | FD_CLOEXEC)) {
|
||||
Debug::log(ERR, "set_cloexec failed (1)");
|
||||
Log::logger->log(Log::ERR, "set_cloexec failed (1)");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
||||
int xwmPair[2] = {-1, -1};
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, xwmPair) != 0) {
|
||||
Debug::log(ERR, "socketpair failed (2)");
|
||||
Log::logger->log(Log::ERR, "socketpair failed (2)");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -341,14 +341,14 @@ bool CXWaylandServer::start() {
|
|||
m_xwmFDs[1] = CFileDescriptor{xwmPair[1]};
|
||||
|
||||
if (!m_xwmFDs[0].setFlags(m_xwmFDs[0].getFlags() | FD_CLOEXEC) || !m_xwmFDs[1].setFlags(m_xwmFDs[1].getFlags() | FD_CLOEXEC)) {
|
||||
Debug::log(ERR, "set_cloexec failed (2)");
|
||||
Log::logger->log(Log::ERR, "set_cloexec failed (2)");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_xwaylandClient = wl_client_create(g_pCompositor->m_wlDisplay, m_waylandFDs[0].get());
|
||||
if (!m_xwaylandClient) {
|
||||
Debug::log(ERR, "wl_client_create failed");
|
||||
Log::logger->log(Log::ERR, "wl_client_create failed");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ bool CXWaylandServer::start() {
|
|||
|
||||
int notify[2] = {-1, -1};
|
||||
if (pipe(notify) < 0) {
|
||||
Debug::log(ERR, "pipe failed");
|
||||
Log::logger->log(Log::ERR, "pipe failed");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -365,7 +365,7 @@ bool CXWaylandServer::start() {
|
|||
CFileDescriptor notifyFds[2] = {CFileDescriptor{notify[0]}, CFileDescriptor{notify[1]}};
|
||||
|
||||
if (!notifyFds[0].setFlags(notifyFds[0].getFlags() | FD_CLOEXEC)) {
|
||||
Debug::log(ERR, "set_cloexec failed (3)");
|
||||
Log::logger->log(Log::ERR, "set_cloexec failed (3)");
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -375,7 +375,7 @@ bool CXWaylandServer::start() {
|
|||
|
||||
auto serverPID = fork();
|
||||
if (serverPID < 0) {
|
||||
Debug::log(ERR, "fork failed");
|
||||
Log::logger->log(Log::ERR, "fork failed");
|
||||
die();
|
||||
return false;
|
||||
} else if (serverPID == 0) {
|
||||
|
|
@ -392,7 +392,7 @@ int CXWaylandServer::ready(int fd, uint32_t mask) {
|
|||
char buf[64];
|
||||
ssize_t n = read(fd, buf, sizeof(buf));
|
||||
if (n < 0 && errno != EINTR) {
|
||||
Debug::log(ERR, "Xwayland: read from displayFd failed");
|
||||
Log::logger->log(Log::ERR, "Xwayland: read from displayFd failed");
|
||||
mask = 0;
|
||||
} else if (n <= 0 || buf[n - 1] != '\n')
|
||||
return 1;
|
||||
|
|
@ -400,12 +400,12 @@ int CXWaylandServer::ready(int fd, uint32_t mask) {
|
|||
|
||||
// if we don't have readable here, it failed
|
||||
if (!(mask & WL_EVENT_READABLE)) {
|
||||
Debug::log(ERR, "Xwayland: startup failed, not setting up xwm");
|
||||
Log::logger->log(Log::ERR, "Xwayland: startup failed, not setting up xwm");
|
||||
g_pXWayland->m_server.reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "XWayland is ready");
|
||||
Log::logger->log(Log::DEBUG, "XWayland is ready");
|
||||
|
||||
wl_event_source_remove(m_pipeSource);
|
||||
m_pipeFd.reset();
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ void CXDataSource::send(const std::string& mime, CFileDescriptor fd) {
|
|||
}
|
||||
|
||||
if (!mimeAtom) {
|
||||
Debug::log(ERR, "[XDataSource] mime atom not found");
|
||||
Log::logger->log(Log::ERR, "[XDataSource] mime atom not found");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "[XDataSource] send with mime {} to fd {}", mime, fd.get());
|
||||
Log::logger->log(Log::DEBUG, "[XDataSource] send with mime {} to fd {}", mime, fd.get());
|
||||
|
||||
auto transfer = makeUnique<SXTransfer>(m_selection);
|
||||
transfer->incomingWindow = xcb_generate_id(g_pXWayland->m_wm->getConnection());
|
||||
|
|
@ -94,15 +94,15 @@ void CXDataSource::send(const std::string& mime, CFileDescriptor fd) {
|
|||
}
|
||||
|
||||
void CXDataSource::accepted(const std::string& mime) {
|
||||
Debug::log(LOG, "[XDataSource] accepted is a stub");
|
||||
Log::logger->log(Log::DEBUG, "[XDataSource] accepted is a stub");
|
||||
}
|
||||
|
||||
void CXDataSource::cancelled() {
|
||||
Debug::log(LOG, "[XDataSource] cancelled is a stub");
|
||||
Log::logger->log(Log::DEBUG, "[XDataSource] cancelled is a stub");
|
||||
}
|
||||
|
||||
void CXDataSource::error(uint32_t code, const std::string& msg) {
|
||||
Debug::log(LOG, "[XDataSource] error is a stub: err {}: {}", code, msg);
|
||||
Log::logger->log(Log::DEBUG, "[XDataSource] error is a stub: err {}: {}", code, msg);
|
||||
}
|
||||
|
||||
eDataSourceType CXDataSource::type() {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void CXWaylandSurface::map() {
|
|||
m_mapped = true;
|
||||
m_surface->map();
|
||||
|
||||
Debug::log(LOG, "XWayland surface {:x} mapping", rc<uintptr_t>(this));
|
||||
Log::logger->log(Log::DEBUG, "XWayland surface {:x} mapping", rc<uintptr_t>(this));
|
||||
|
||||
m_events.map.emit();
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ void CXWaylandSurface::unmap() {
|
|||
m_events.unmap.emit();
|
||||
m_surface->unmap();
|
||||
|
||||
Debug::log(LOG, "XWayland surface {:x} unmapping", rc<uintptr_t>(this));
|
||||
Log::logger->log(Log::DEBUG, "XWayland surface {:x} unmapping", rc<uintptr_t>(this));
|
||||
|
||||
g_pXWayland->m_wm->updateClientList();
|
||||
}
|
||||
|
|
@ -128,17 +128,17 @@ void CXWaylandSurface::considerMap() {
|
|||
return;
|
||||
|
||||
if (!m_surface) {
|
||||
Debug::log(LOG, "XWayland surface: considerMap, nope, no surface");
|
||||
Log::logger->log(Log::DEBUG, "XWayland surface: considerMap, nope, no surface");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_surface->m_current.texture) {
|
||||
Debug::log(LOG, "XWayland surface: considerMap, sure, we have a buffer");
|
||||
Log::logger->log(Log::DEBUG, "XWayland surface: considerMap, sure, we have a buffer");
|
||||
map();
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "XWayland surface: considerMap, nope, we don't have a buffer");
|
||||
Log::logger->log(Log::DEBUG, "XWayland surface: considerMap, nope, we don't have a buffer");
|
||||
}
|
||||
|
||||
bool CXWaylandSurface::wantsFocus() {
|
||||
|
|
@ -250,7 +250,7 @@ void CXWaylandSurface::ping() {
|
|||
bool supportsPing = std::ranges::find(m_protocols, HYPRATOMS["_NET_WM_PING"]) != m_protocols.end();
|
||||
|
||||
if (!supportsPing) {
|
||||
Debug::log(TRACE, "CXWaylandSurface: XID {} does not support ping, just sending an instant reply", m_xID);
|
||||
Log::logger->log(Log::TRACE, "CXWaylandSurface: XID {} does not support ping, just sending an instant reply", m_xID);
|
||||
g_pANRManager->onResponse(m_self.lock());
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../managers/SeatManager.hpp"
|
||||
#include "../managers/ANRManager.hpp"
|
||||
#include "../helpers/env/Env.hpp"
|
||||
#include "../protocols/XWaylandShell.hpp"
|
||||
#include "../protocols/core/Compositor.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
|
|
@ -56,12 +57,12 @@ void CXWM::handleCreate(xcb_create_notify_event_t* e) {
|
|||
|
||||
const auto XSURF = m_surfaces.emplace_back(SP<CXWaylandSurface>(new CXWaylandSurface(e->window, CBox{e->x, e->y, e->width, e->height}, e->override_redirect)));
|
||||
XSURF->m_self = XSURF;
|
||||
Debug::log(LOG, "[xwm] New XSurface at {:x} with xid of {}", rc<uintptr_t>(XSURF.get()), e->window);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] New XSurface at {:x} with xid of {}", rc<uintptr_t>(XSURF.get()), e->window);
|
||||
|
||||
const auto WINDOW = Desktop::View::CWindow::create(XSURF);
|
||||
g_pCompositor->m_windows.emplace_back(WINDOW);
|
||||
WINDOW->m_self = WINDOW;
|
||||
Debug::log(LOG, "[xwm] New XWayland window at {:x} for surf {:x}", rc<uintptr_t>(WINDOW.get()), rc<uintptr_t>(XSURF.get()));
|
||||
Log::logger->log(Log::DEBUG, "[xwm] New XWayland window at {:x} for surf {:x}", rc<uintptr_t>(WINDOW.get()), rc<uintptr_t>(XSURF.get()));
|
||||
}
|
||||
|
||||
void CXWM::handleDestroy(xcb_destroy_notify_event_t* e) {
|
||||
|
|
@ -123,8 +124,8 @@ void CXWM::handleMapRequest(xcb_map_request_event_t* e) {
|
|||
if (SMALL && !XSURF->m_overrideRedirect) // default to 800 x 800
|
||||
XSURF->configure({XSURF->m_geometry.pos(), DESIREDSIZE});
|
||||
|
||||
Debug::log(LOG, "[xwm] Mapping window {} in X (geometry {}x{} at {}x{}))", e->window, XSURF->m_geometry.width, XSURF->m_geometry.height, XSURF->m_geometry.x,
|
||||
XSURF->m_geometry.y);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] Mapping window {} in X (geometry {}x{} at {}x{}))", e->window, XSURF->m_geometry.width, XSURF->m_geometry.height, XSURF->m_geometry.x,
|
||||
XSURF->m_geometry.y);
|
||||
|
||||
// read data again. Some apps for some reason fail to send WINDOW_TYPE
|
||||
// this shouldn't happen but does, I prolly fucked up somewhere, this is a band-aid
|
||||
|
|
@ -208,7 +209,7 @@ std::string CXWM::getAtomName(uint32_t atom) {
|
|||
|
||||
void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_reply_t* reply) {
|
||||
std::string propName;
|
||||
if (Debug::m_trace)
|
||||
if (Env::isTrace())
|
||||
propName = getAtomName(atom);
|
||||
|
||||
const auto valueLen = xcb_get_property_value_length(reply);
|
||||
|
|
@ -274,7 +275,7 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
|
|||
XSURF->m_parent = NEWXSURF;
|
||||
NEWXSURF->m_children.emplace_back(XSURF);
|
||||
} else
|
||||
Debug::log(LOG, "[xwm] Denying transient because it would create a loop");
|
||||
Log::logger->log(Log::DEBUG, "[xwm] Denying transient because it would create a loop");
|
||||
};
|
||||
|
||||
auto handleSizeHints = [&]() {
|
||||
|
|
@ -330,11 +331,11 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
|
|||
else if (atom == HYPRATOMS["WM_PROTOCOLS"])
|
||||
handleWMProtocols();
|
||||
else {
|
||||
Debug::log(TRACE, "[xwm] Unhandled prop {} -> {}", atom, propName);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Unhandled prop {} -> {}", atom, propName);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::log(TRACE, "[xwm] Handled prop {} -> {}", atom, propName);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Handled prop {} -> {}", atom, propName);
|
||||
}
|
||||
|
||||
void CXWM::handlePropertyNotify(xcb_property_notify_event_t* e) {
|
||||
|
|
@ -347,7 +348,7 @@ void CXWM::handlePropertyNotify(xcb_property_notify_event_t* e) {
|
|||
XCBReplyPtr<xcb_get_property_reply_t> reply(xcb_get_property_reply(getConnection(), cookie, nullptr));
|
||||
|
||||
if (!reply) {
|
||||
Debug::log(ERR, "[xwm] Failed to read property notify cookie");
|
||||
Log::logger->log(Log::ERR, "[xwm] Failed to read property notify cookie");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -369,7 +370,7 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
|
|||
}
|
||||
} else if (e->type == HYPRATOMS["WL_SURFACE_ID"]) {
|
||||
if (XSURF->m_surface) {
|
||||
Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_ID");
|
||||
Log::logger->log(Log::WARN, "[xwm] Re-assignment of WL_SURFACE_ID");
|
||||
dissociate(XSURF);
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +382,7 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
|
|||
}
|
||||
} else if (e->type == HYPRATOMS["WL_SURFACE_SERIAL"]) {
|
||||
if (XSURF->m_wlSerial) {
|
||||
Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_SERIAL");
|
||||
Log::logger->log(Log::WARN, "[xwm] Re-assignment of WL_SURFACE_SERIAL");
|
||||
dissociate(XSURF);
|
||||
}
|
||||
|
||||
|
|
@ -389,7 +390,7 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
|
|||
uint32_t serialHigh = e->data.data32[1];
|
||||
XSURF->m_wlSerial = (sc<uint64_t>(serialHigh) << 32) | serialLow;
|
||||
|
||||
Debug::log(LOG, "[xwm] surface {:x} requests serial {:x}", rc<uintptr_t>(XSURF.get()), XSURF->m_wlSerial);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] surface {:x} requests serial {:x}", rc<uintptr_t>(XSURF.get()), XSURF->m_wlSerial);
|
||||
|
||||
for (auto const& res : m_shellResources) {
|
||||
if (!res)
|
||||
|
|
@ -445,7 +446,7 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
|
|||
XSURF->m_events.activate.emit();
|
||||
} else if (e->type == HYPRATOMS["XdndStatus"]) {
|
||||
if (m_dndDataOffers.empty() || !m_dndDataOffers.at(0)->getSource()) {
|
||||
Debug::log(TRACE, "[xwm] Rejecting XdndStatus message: nothing to get");
|
||||
Log::logger->log(Log::TRACE, "[xwm] Rejecting XdndStatus message: nothing to get");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -455,22 +456,22 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
|
|||
if (ACCEPTED)
|
||||
m_dndDataOffers.at(0)->getSource()->accepted("");
|
||||
|
||||
Debug::log(LOG, "[xwm] XdndStatus: accepted: {}");
|
||||
Log::logger->log(Log::DEBUG, "[xwm] XdndStatus: accepted: {}");
|
||||
} else if (e->type == HYPRATOMS["XdndFinished"]) {
|
||||
if (m_dndDataOffers.empty() || !m_dndDataOffers.at(0)->getSource()) {
|
||||
Debug::log(TRACE, "[xwm] Rejecting XdndFinished message: nothing to get");
|
||||
Log::logger->log(Log::TRACE, "[xwm] Rejecting XdndFinished message: nothing to get");
|
||||
return;
|
||||
}
|
||||
|
||||
m_dndDataOffers.at(0)->getSource()->sendDndFinished();
|
||||
|
||||
Debug::log(LOG, "[xwm] XdndFinished");
|
||||
Log::logger->log(Log::DEBUG, "[xwm] XdndFinished");
|
||||
} else {
|
||||
Debug::log(TRACE, "[xwm] Unhandled message prop {} -> {}", e->type, propName);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Unhandled message prop {} -> {}", e->type, propName);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::log(TRACE, "[xwm] Handled message prop {} -> {}", e->type, propName);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Handled message prop {} -> {}", e->type, propName);
|
||||
}
|
||||
|
||||
void CXWM::handleFocusIn(xcb_focus_in_event_t* e) {
|
||||
|
|
@ -489,15 +490,15 @@ void CXWM::handleFocusIn(xcb_focus_in_event_t* e) {
|
|||
}
|
||||
|
||||
void CXWM::handleFocusOut(xcb_focus_out_event_t* e) {
|
||||
Debug::log(TRACE, "[xwm] focusOut mode={}, detail={}, event={}", e->mode, e->detail, e->event);
|
||||
Log::logger->log(Log::TRACE, "[xwm] focusOut mode={}, detail={}, event={}", e->mode, e->detail, e->event);
|
||||
|
||||
const auto XSURF = windowForXID(e->event);
|
||||
|
||||
if (!XSURF)
|
||||
return;
|
||||
|
||||
Debug::log(TRACE, "[xwm] focusOut for {} {} {} surface {}", XSURF->m_mapped ? "mapped" : "unmapped", XSURF->m_fullscreen ? "fullscreen" : "windowed",
|
||||
XSURF == m_focusedSurface ? "focused" : "unfocused", XSURF->m_state.title);
|
||||
Log::logger->log(Log::TRACE, "[xwm] focusOut for {} {} {} surface {}", XSURF->m_mapped ? "mapped" : "unmapped", XSURF->m_fullscreen ? "fullscreen" : "windowed",
|
||||
XSURF == m_focusedSurface ? "focused" : "unfocused", XSURF->m_state.title);
|
||||
|
||||
// do something?
|
||||
}
|
||||
|
|
@ -556,7 +557,7 @@ void CXWM::focusWindow(SP<CXWaylandSurface> surf) {
|
|||
void CXWM::handleError(xcb_value_error_t* e) {
|
||||
const char* major_name = xcb_errors_get_name_for_major_code(m_errors, e->major_opcode);
|
||||
if (!major_name) {
|
||||
Debug::log(ERR, "xcb error happened, but could not get major name");
|
||||
Log::logger->log(Log::ERR, "xcb error happened, but could not get major name");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -565,12 +566,12 @@ void CXWM::handleError(xcb_value_error_t* e) {
|
|||
const char* extension;
|
||||
const char* error_name = xcb_errors_get_name_for_error(m_errors, e->error_code, &extension);
|
||||
if (!error_name) {
|
||||
Debug::log(ERR, "xcb error happened, but could not get error name");
|
||||
Log::logger->log(Log::ERR, "xcb error happened, but could not get error name");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::log(ERR, "[xwm] xcb error: {} ({}), code {} ({}), seq {}, val {}", major_name, minor_name ? minor_name : "no minor", error_name, extension ? extension : "no extension",
|
||||
e->sequence, e->bad_value);
|
||||
Log::logger->log(Log::ERR, "[xwm] xcb error: {} ({}), code {} ({}), seq {}, val {}", major_name, minor_name ? minor_name : "no minor", error_name,
|
||||
extension ? extension : "no extension", e->sequence, e->bad_value);
|
||||
}
|
||||
|
||||
void CXWM::selectionSendNotify(xcb_selection_request_event_t* e, bool success) {
|
||||
|
|
@ -620,19 +621,19 @@ std::string CXWM::mimeFromAtom(xcb_atom_t atom) {
|
|||
}
|
||||
|
||||
void CXWM::handleSelectionNotify(xcb_selection_notify_event_t* e) {
|
||||
Debug::log(TRACE, "[xwm] Selection notify for {} prop {} target {}", e->selection, e->property, e->target);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Selection notify for {} prop {} target {}", e->selection, e->property, e->target);
|
||||
|
||||
SXSelection* sel = getSelection(e->selection);
|
||||
|
||||
if (e->property == XCB_ATOM_NONE) {
|
||||
auto it = std::ranges::find_if(sel->transfers, [](const auto& t) { return !t->propertyReply; });
|
||||
if (it != sel->transfers.end()) {
|
||||
Debug::log(TRACE, "[xwm] converting selection failed");
|
||||
Log::logger->log(Log::TRACE, "[xwm] converting selection failed");
|
||||
sel->transfers.erase(it);
|
||||
}
|
||||
} else if (e->target == HYPRATOMS["TARGETS"]) {
|
||||
if (!m_focusedSurface) {
|
||||
Debug::log(TRACE, "[xwm] denying access to write to clipboard because no X client is in focus");
|
||||
Log::logger->log(Log::TRACE, "[xwm] denying access to write to clipboard because no X client is in focus");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -672,13 +673,13 @@ SXSelection* CXWM::getSelection(xcb_atom_t atom) {
|
|||
}
|
||||
|
||||
void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) {
|
||||
Debug::log(TRACE, "[xwm] Selection request for {} prop {} target {} time {} requestor {} selection {}", e->selection, e->property, e->target, e->time, e->requestor,
|
||||
e->selection);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Selection request for {} prop {} target {} time {} requestor {} selection {}", e->selection, e->property, e->target, e->time, e->requestor,
|
||||
e->selection);
|
||||
|
||||
SXSelection* sel = getSelection(e->selection);
|
||||
|
||||
if (!sel) {
|
||||
Debug::log(ERR, "[xwm] No selection");
|
||||
Log::logger->log(Log::ERR, "[xwm] No selection");
|
||||
selectionSendNotify(e, false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -689,13 +690,13 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) {
|
|||
}
|
||||
|
||||
if (sel->window != e->owner && e->time != XCB_CURRENT_TIME && e->time < sel->timestamp) {
|
||||
Debug::log(ERR, "[xwm] outdated selection request. Time {} < {}", e->time, sel->timestamp);
|
||||
Log::logger->log(Log::ERR, "[xwm] outdated selection request. Time {} < {}", e->time, sel->timestamp);
|
||||
selectionSendNotify(e, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->m_server->m_xwaylandClient) {
|
||||
Debug::log(TRACE, "[xwm] Ignoring clipboard access: xwayland not in focus");
|
||||
Log::logger->log(Log::TRACE, "[xwm] Ignoring clipboard access: xwayland not in focus");
|
||||
selectionSendNotify(e, false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -709,7 +710,7 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) {
|
|||
mimes = m_dndDataOffers.at(0)->m_source->mimes();
|
||||
|
||||
if (mimes.empty())
|
||||
Debug::log(WARN, "[xwm] WARNING: No mimes in TARGETS?");
|
||||
Log::logger->log(Log::WARN, "[xwm] WARNING: No mimes in TARGETS?");
|
||||
|
||||
std::vector<xcb_atom_t> atoms;
|
||||
// reserve to avoid reallocations
|
||||
|
|
@ -732,13 +733,13 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) {
|
|||
std::string mime = mimeFromAtom(e->target);
|
||||
|
||||
if (mime == "INVALID") {
|
||||
Debug::log(LOG, "[xwm] Ignoring clipboard access: invalid mime atom {}", e->target);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] Ignoring clipboard access: invalid mime atom {}", e->target);
|
||||
selectionSendNotify(e, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sel->sendData(e, mime)) {
|
||||
Debug::log(LOG, "[xwm] Failed to send selection :(");
|
||||
Log::logger->log(Log::DEBUG, "[xwm] Failed to send selection :(");
|
||||
selectionSendNotify(e, false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -746,7 +747,7 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) {
|
|||
}
|
||||
|
||||
bool CXWM::handleSelectionXFixesNotify(xcb_xfixes_selection_notify_event_t* e) {
|
||||
Debug::log(TRACE, "[xwm] Selection xfixes notify for {}", e->selection);
|
||||
Log::logger->log(Log::TRACE, "[xwm] Selection xfixes notify for {}", e->selection);
|
||||
|
||||
// IMPORTANT: mind the g_pSeatManager below
|
||||
SXSelection* sel = getSelection(e->selection);
|
||||
|
|
@ -806,8 +807,8 @@ bool CXWM::handleSelectionEvent(xcb_generic_event_t* e) {
|
|||
int CXWM::onEvent(int fd, uint32_t mask) {
|
||||
|
||||
if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
|
||||
Debug::log(ERR, "XWayland has yeeten the xwm off?!");
|
||||
Debug::log(CRIT, "XWayland has yeeten the xwm off?!");
|
||||
Log::logger->log(Log::ERR, "XWayland has yeeten the xwm off?!");
|
||||
Log::logger->log(Log::CRIT, "XWayland has yeeten the xwm off?!");
|
||||
// Attempt to create fresh instance
|
||||
g_pEventLoopManager->doLater([]() {
|
||||
g_pXWayland->m_wm.reset();
|
||||
|
|
@ -843,7 +844,7 @@ int CXWM::onEvent(int fd, uint32_t mask) {
|
|||
case XCB_FOCUS_OUT: handleFocusOut(rc<xcb_focus_out_event_t*>(event.get())); break;
|
||||
case 0: handleError(rc<xcb_value_error_t*>(event.get())); break;
|
||||
default: {
|
||||
Debug::log(TRACE, "[xwm] unhandled event {}", event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK);
|
||||
Log::logger->log(Log::TRACE, "[xwm] unhandled event {}", event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -864,7 +865,7 @@ void CXWM::gatherResources() {
|
|||
XCBReplyPtr<xcb_intern_atom_reply_t> reply(xcb_intern_atom_reply(getConnection(), cookie, nullptr));
|
||||
|
||||
if (!reply) {
|
||||
Debug::log(ERR, "[xwm] Atom failed: {}", ATOM.first);
|
||||
Log::logger->log(Log::ERR, "[xwm] Atom failed: {}", ATOM.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -874,13 +875,13 @@ void CXWM::gatherResources() {
|
|||
m_xfixes = xcb_get_extension_data(getConnection(), &xcb_xfixes_id);
|
||||
|
||||
if (!m_xfixes || !m_xfixes->present)
|
||||
Debug::log(WARN, "XFixes not available");
|
||||
Log::logger->log(Log::WARN, "XFixes not available");
|
||||
|
||||
auto xfixes_cookie = xcb_xfixes_query_version(getConnection(), XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION);
|
||||
XCBReplyPtr<xcb_xfixes_query_version_reply_t> xfixes_reply(xcb_xfixes_query_version_reply(getConnection(), xfixes_cookie, nullptr));
|
||||
|
||||
if (xfixes_reply) {
|
||||
Debug::log(LOG, "xfixes version: {}.{}", xfixes_reply->major_version, xfixes_reply->minor_version);
|
||||
Log::logger->log(Log::DEBUG, "xfixes version: {}.{}", xfixes_reply->major_version, xfixes_reply->minor_version);
|
||||
m_xfixesMajor = xfixes_reply->major_version;
|
||||
}
|
||||
|
||||
|
|
@ -893,7 +894,7 @@ void CXWM::gatherResources() {
|
|||
if (!xres_reply)
|
||||
return;
|
||||
|
||||
Debug::log(LOG, "xres version: {}.{}", xres_reply->server_major, xres_reply->server_minor);
|
||||
Log::logger->log(Log::DEBUG, "xres version: {}.{}", xres_reply->server_major, xres_reply->server_minor);
|
||||
if (xres_reply->server_major > 1 || (xres_reply->server_major == 1 && xres_reply->server_minor >= 2)) {
|
||||
m_xres = xresReply1;
|
||||
}
|
||||
|
|
@ -917,7 +918,7 @@ void CXWM::getVisual() {
|
|||
}
|
||||
|
||||
if (visualtype == nullptr) {
|
||||
Debug::log(LOG, "xwm: No 32-bit visualtype");
|
||||
Log::logger->log(Log::DEBUG, "xwm: No 32-bit visualtype");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -931,7 +932,7 @@ void CXWM::getRenderFormat() {
|
|||
XCBReplyPtr<xcb_render_query_pict_formats_reply_t> reply(xcb_render_query_pict_formats_reply(getConnection(), cookie, nullptr));
|
||||
|
||||
if (!reply) {
|
||||
Debug::log(LOG, "xwm: No xcb_render_query_pict_formats_reply_t reply");
|
||||
Log::logger->log(Log::DEBUG, "xwm: No xcb_render_query_pict_formats_reply_t reply");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -947,7 +948,7 @@ void CXWM::getRenderFormat() {
|
|||
}
|
||||
|
||||
if (format == nullptr) {
|
||||
Debug::log(LOG, "xwm: No 32-bit render format");
|
||||
Log::logger->log(Log::DEBUG, "xwm: No 32-bit render format");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -957,13 +958,13 @@ void CXWM::getRenderFormat() {
|
|||
CXWM::CXWM() : m_connection(makeUnique<CXCBConnection>(g_pXWayland->m_server->m_xwmFDs[0].get())) {
|
||||
|
||||
if (m_connection->hasError()) {
|
||||
Debug::log(ERR, "[xwm] Couldn't start, error {}", m_connection->hasError());
|
||||
Log::logger->log(Log::ERR, "[xwm] Couldn't start, error {}", m_connection->hasError());
|
||||
return;
|
||||
}
|
||||
|
||||
CXCBErrorContext xcbErrCtx(getConnection());
|
||||
if (!xcbErrCtx.isValid()) {
|
||||
Debug::log(ERR, "[xwm] Couldn't allocate errors context");
|
||||
Log::logger->log(Log::ERR, "[xwm] Couldn't allocate errors context");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1050,8 +1051,8 @@ void CXWM::activateSurface(SP<CXWaylandSurface> surf, bool activate) {
|
|||
}
|
||||
|
||||
void CXWM::sendState(SP<CXWaylandSurface> surf) {
|
||||
Debug::log(TRACE, "[xwm] sendState for {} {} {} surface {}", surf->m_mapped ? "mapped" : "unmapped", surf->m_fullscreen ? "fullscreen" : "windowed",
|
||||
surf == m_focusedSurface ? "focused" : "unfocused", surf->m_state.title);
|
||||
Log::logger->log(Log::TRACE, "[xwm] sendState for {} {} {} surface {}", surf->m_mapped ? "mapped" : "unmapped", surf->m_fullscreen ? "fullscreen" : "windowed",
|
||||
surf == m_focusedSurface ? "focused" : "unfocused", surf->m_state.title);
|
||||
if (surf->m_fullscreen && surf->m_mapped && surf == m_focusedSurface)
|
||||
surf->setWithdrawn(false); // resend normal state
|
||||
|
||||
|
|
@ -1083,7 +1084,7 @@ void CXWM::onNewSurface(SP<CWLSurfaceResource> surf) {
|
|||
if (surf->client() != g_pXWayland->m_server->m_xwaylandClient)
|
||||
return;
|
||||
|
||||
Debug::log(LOG, "[xwm] New XWayland surface at {:x}", rc<uintptr_t>(surf.get()));
|
||||
Log::logger->log(Log::DEBUG, "[xwm] New XWayland surface at {:x}", rc<uintptr_t>(surf.get()));
|
||||
|
||||
const auto WLID = surf->id();
|
||||
|
||||
|
|
@ -1095,11 +1096,11 @@ void CXWM::onNewSurface(SP<CWLSurfaceResource> surf) {
|
|||
return;
|
||||
}
|
||||
|
||||
Debug::log(WARN, "[xwm] CXWM::onNewSurface: no matching xwaylandSurface");
|
||||
Log::logger->log(Log::WARN, "[xwm] CXWM::onNewSurface: no matching xwaylandSurface");
|
||||
}
|
||||
|
||||
void CXWM::onNewResource(SP<CXWaylandSurfaceResource> resource) {
|
||||
Debug::log(LOG, "[xwm] New XWayland resource at {:x}", rc<uintptr_t>(resource.get()));
|
||||
Log::logger->log(Log::DEBUG, "[xwm] New XWayland resource at {:x}", rc<uintptr_t>(resource.get()));
|
||||
|
||||
std::erase_if(m_shellResources, [](const auto& e) { return e.expired(); });
|
||||
m_shellResources.emplace_back(resource);
|
||||
|
|
@ -1124,7 +1125,7 @@ void CXWM::readWindowData(SP<CXWaylandSurface> surf) {
|
|||
xcb_get_property_cookie_t cookie = xcb_get_property(getConnection(), 0, surf->m_xID, interestingProps[i], XCB_ATOM_ANY, 0, 2048);
|
||||
XCBReplyPtr<xcb_get_property_reply_t> reply(xcb_get_property_reply(getConnection(), cookie, nullptr));
|
||||
if (!reply) {
|
||||
Debug::log(ERR, "[xwm] Failed to get window property");
|
||||
Log::logger->log(Log::ERR, "[xwm] Failed to get window property");
|
||||
continue;
|
||||
}
|
||||
readProp(surf, interestingProps[i], reply.get());
|
||||
|
|
@ -1147,7 +1148,7 @@ void CXWM::associate(SP<CXWaylandSurface> surf, SP<CWLSurfaceResource> wlSurf) {
|
|||
auto existing = std::ranges::find_if(m_surfaces, [wlSurf](const auto& e) { return e->m_surface == wlSurf; });
|
||||
|
||||
if (existing != m_surfaces.end()) {
|
||||
Debug::log(WARN, "[xwm] associate() called but surface is already associated to {:x}, ignoring...", rc<uintptr_t>(surf.get()));
|
||||
Log::logger->log(Log::WARN, "[xwm] associate() called but surface is already associated to {:x}, ignoring...", rc<uintptr_t>(surf.get()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1169,7 +1170,7 @@ void CXWM::dissociate(SP<CXWaylandSurface> surf) {
|
|||
surf->m_surface.reset();
|
||||
surf->m_events.resourceChange.emit();
|
||||
|
||||
Debug::log(LOG, "Dissociate for {:x}", rc<uintptr_t>(surf.get()));
|
||||
Log::logger->log(Log::DEBUG, "Dissociate for {:x}", rc<uintptr_t>(surf.get()));
|
||||
}
|
||||
|
||||
void CXWM::updateClientList() {
|
||||
|
|
@ -1259,13 +1260,13 @@ void CXWM::initSelection() {
|
|||
void CXWM::setClipboardToWayland(SXSelection& sel) {
|
||||
auto source = makeShared<CXDataSource>(sel);
|
||||
if (source->mimes().empty()) {
|
||||
Debug::log(ERR, "[xwm] can't set selection: no MIMEs");
|
||||
Log::logger->log(Log::ERR, "[xwm] can't set selection: no MIMEs");
|
||||
return;
|
||||
}
|
||||
|
||||
sel.dataSource = source;
|
||||
|
||||
Debug::log(LOG, "[xwm] X selection at {:x} takes {}", rc<uintptr_t>(sel.dataSource.get()), (&sel == &m_clipboard) ? "clipboard" : "primary selection");
|
||||
Log::logger->log(Log::DEBUG, "[xwm] X selection at {:x} takes {}", rc<uintptr_t>(sel.dataSource.get()), (&sel == &m_clipboard) ? "clipboard" : "primary selection");
|
||||
|
||||
if (&sel == &m_clipboard)
|
||||
g_pSeatManager->setCurrentSelection(sel.dataSource);
|
||||
|
|
@ -1279,29 +1280,29 @@ static int writeDataSource(int fd, uint32_t mask, void* data) {
|
|||
}
|
||||
|
||||
void CXWM::getTransferData(SXSelection& sel) {
|
||||
Debug::log(LOG, "[xwm] getTransferData");
|
||||
Log::logger->log(Log::DEBUG, "[xwm] getTransferData");
|
||||
|
||||
auto it = std::ranges::find_if(sel.transfers, [](const auto& t) { return !t->propertyReply; });
|
||||
if (it == sel.transfers.end()) {
|
||||
Debug::log(ERR, "[xwm] No pending transfer found");
|
||||
Log::logger->log(Log::ERR, "[xwm] No pending transfer found");
|
||||
return;
|
||||
}
|
||||
|
||||
auto& transfer = *it;
|
||||
if (!transfer || !transfer->incomingWindow) {
|
||||
Debug::log(ERR, "[xwm] Invalid transfer state");
|
||||
Log::logger->log(Log::ERR, "[xwm] Invalid transfer state");
|
||||
sel.transfers.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transfer->getIncomingSelectionProp(true)) {
|
||||
Debug::log(ERR, "[xwm] Failed to get property data");
|
||||
Log::logger->log(Log::ERR, "[xwm] Failed to get property data");
|
||||
sel.transfers.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transfer->propertyReply) {
|
||||
Debug::log(ERR, "[xwm] No property reply");
|
||||
Log::logger->log(Log::ERR, "[xwm] No property reply");
|
||||
sel.transfers.erase(it);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1335,7 +1336,7 @@ void CXWM::getTransferData(SXSelection& sel) {
|
|||
|
||||
void CXWM::setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& size, const Vector2D& hotspot) {
|
||||
if (!m_renderFormatID) {
|
||||
Debug::log(ERR, "[xwm] can't set cursor: no render format");
|
||||
Log::logger->log(Log::ERR, "[xwm] can't set cursor: no render format");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1374,7 +1375,7 @@ SP<IDataOffer> CXWM::createX11DataOffer(SP<CWLSurfaceResource> surf, SP<IDataSou
|
|||
auto XSURF = windowForWayland(surf);
|
||||
|
||||
if (!XSURF) {
|
||||
Debug::log(ERR, "[xwm] No xwayland surface for destination in createX11DataOffer");
|
||||
Log::logger->log(Log::ERR, "[xwm] No xwayland surface for destination in createX11DataOffer");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -1432,7 +1433,7 @@ int SXSelection::onRead(int fd, uint32_t mask) {
|
|||
auto it = std::ranges::find_if(transfers, [fd](const auto& t) { return t->wlFD.get() == fd; });
|
||||
|
||||
if (it == transfers.end()) {
|
||||
Debug::log(ERR, "[xwm] No transfer found for fd {}", fd);
|
||||
Log::logger->log(Log::ERR, "[xwm] No transfer found for fd {}", fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1443,7 +1444,7 @@ int SXSelection::onRead(int fd, uint32_t mask) {
|
|||
ssize_t bytesRead = read(fd, transfer->data.data() + oldSize, INCR_CHUNK_SIZE - 1);
|
||||
|
||||
if (bytesRead < 0) {
|
||||
Debug::log(ERR, "[xwm] readDataSource died");
|
||||
Log::logger->log(Log::ERR, "[xwm] readDataSource died");
|
||||
g_pXWayland->m_wm->selectionSendNotify(&transfer->request, false);
|
||||
transfers.erase(it);
|
||||
return 0;
|
||||
|
|
@ -1453,13 +1454,13 @@ int SXSelection::onRead(int fd, uint32_t mask) {
|
|||
|
||||
if (bytesRead == 0) {
|
||||
if (transfer->data.empty()) {
|
||||
Debug::log(WARN, "[xwm] Transfer ended with zero bytes — rejecting");
|
||||
Log::logger->log(Log::WARN, "[xwm] Transfer ended with zero bytes — rejecting");
|
||||
g_pXWayland->m_wm->selectionSendNotify(&transfer->request, false);
|
||||
transfers.erase(it);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "[xwm] Transfer complete, total size: {}", transfer->data.size());
|
||||
Log::logger->log(Log::DEBUG, "[xwm] Transfer complete, total size: {}", transfer->data.size());
|
||||
auto conn = g_pXWayland->m_wm->getConnection();
|
||||
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, transfer->request.requestor, transfer->request.property, transfer->request.target, 8, transfer->data.size(),
|
||||
transfer->data.data());
|
||||
|
|
@ -1468,13 +1469,13 @@ int SXSelection::onRead(int fd, uint32_t mask) {
|
|||
g_pXWayland->m_wm->selectionSendNotify(&transfer->request, true);
|
||||
transfers.erase(it);
|
||||
} else
|
||||
Debug::log(LOG, "[xwm] Received {} bytes, awaiting more...", bytesRead);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] Received {} bytes, awaiting more...", bytesRead);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int readDataSource(int fd, uint32_t mask, void* data) {
|
||||
Debug::log(LOG, "[xwm] readDataSource on fd {}", fd);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] readDataSource on fd {}", fd);
|
||||
|
||||
auto selection = sc<SXSelection*>(data);
|
||||
|
||||
|
|
@ -1491,30 +1492,30 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
selection = g_pXWayland->m_wm->m_dndDataOffers.at(0)->getSource();
|
||||
|
||||
if (!selection) {
|
||||
Debug::log(ERR, "[xwm] sendData: no selection source available");
|
||||
Log::logger->log(Log::ERR, "[xwm] sendData: no selection source available");
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto MIMES = selection->mimes();
|
||||
|
||||
if (MIMES.empty()) {
|
||||
Debug::log(ERR, "[xwm] sendData: selection source has no mimes");
|
||||
Log::logger->log(Log::ERR, "[xwm] sendData: selection source has no mimes");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::ranges::find(MIMES, mime) == MIMES.end()) {
|
||||
// try to guess mime, don't just blindly send random-ass shit that the app will have no fucking
|
||||
// clue what to do with
|
||||
Debug::log(ERR, "[xwm] X client asked for MIME '{}' that this selection doesn't support, guessing.", mime);
|
||||
Log::logger->log(Log::ERR, "[xwm] X client asked for MIME '{}' that this selection doesn't support, guessing.", mime);
|
||||
|
||||
auto needle = mime;
|
||||
auto selectedMime = *MIMES.begin();
|
||||
if (mime.contains('/'))
|
||||
needle = mime.substr(0, mime.find('/'));
|
||||
|
||||
Debug::log(TRACE, "[xwm] X MIME needle '{}'", needle);
|
||||
Log::logger->log(Log::TRACE, "[xwm] X MIME needle '{}'", needle);
|
||||
|
||||
if (Debug::m_trace) {
|
||||
if (Env::isTrace()) {
|
||||
std::string mimeList = "";
|
||||
for (const auto& m : MIMES) {
|
||||
mimeList += "'" + m + "', ";
|
||||
|
|
@ -1523,7 +1524,7 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
if (!MIMES.empty())
|
||||
mimeList = mimeList.substr(0, mimeList.size() - 2);
|
||||
|
||||
Debug::log(TRACE, "[xwm] X MIME supported: {}", mimeList);
|
||||
Log::logger->log(Log::TRACE, "[xwm] X MIME supported: {}", mimeList);
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
|
|
@ -1531,7 +1532,7 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
for (const auto& m : MIMES) {
|
||||
if (m.starts_with(needle)) {
|
||||
selectedMime = m;
|
||||
Debug::log(TRACE, "[xwm] X MIME needle found type '{}'", m);
|
||||
Log::logger->log(Log::TRACE, "[xwm] X MIME needle found type '{}'", m);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1541,14 +1542,14 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
for (const auto& m : MIMES) {
|
||||
if (m.contains(needle)) {
|
||||
selectedMime = m;
|
||||
Debug::log(TRACE, "[xwm] X MIME needle found type '{}'", m);
|
||||
Log::logger->log(Log::TRACE, "[xwm] X MIME needle found type '{}'", m);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug::log(ERR, "[xwm] Guessed mime: '{}'. Hopefully we're right enough.", selectedMime);
|
||||
Log::logger->log(Log::ERR, "[xwm] Guessed mime: '{}'. Hopefully we're right enough.", selectedMime);
|
||||
|
||||
mime = selectedMime;
|
||||
}
|
||||
|
|
@ -1558,7 +1559,7 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
|
||||
int p[2];
|
||||
if (pipe(p) == -1) {
|
||||
Debug::log(ERR, "[xwm] sendData: pipe() failed");
|
||||
Log::logger->log(Log::ERR, "[xwm] sendData: pipe() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1569,7 +1570,7 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
|
||||
transfer->wlFD = CFileDescriptor{p[0]};
|
||||
|
||||
Debug::log(LOG, "[xwm] sending wayland selection to xwayland with mime {}, target {}, fds {} {}", mime, e->target, p[0], p[1]);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] sending wayland selection to xwayland with mime {}, target {}, fds {} {}", mime, e->target, p[0], p[1]);
|
||||
|
||||
selection->send(mime, CFileDescriptor{p[1]});
|
||||
|
||||
|
|
@ -1582,7 +1583,7 @@ bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) {
|
|||
int SXSelection::onWrite() {
|
||||
auto it = std::ranges::find_if(transfers, [](const auto& t) { return t->propertyReply; });
|
||||
if (it == transfers.end()) {
|
||||
Debug::log(ERR, "[xwm] No transfer with property data found");
|
||||
Log::logger->log(Log::ERR, "[xwm] No transfer with property data found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1594,16 +1595,16 @@ int SXSelection::onWrite() {
|
|||
if (len == -1) {
|
||||
if (errno == EAGAIN)
|
||||
return 1;
|
||||
Debug::log(ERR, "[xwm] write died in transfer get");
|
||||
Log::logger->log(Log::ERR, "[xwm] write died in transfer get");
|
||||
transfers.erase(it);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len < remainder) {
|
||||
transfer->propertyStart += len;
|
||||
Debug::log(LOG, "[xwm] wl client read partially: len {}", len);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] wl client read partially: len {}", len);
|
||||
} else {
|
||||
Debug::log(LOG, "[xwm] cb transfer to wl client complete, read {} bytes", len);
|
||||
Log::logger->log(Log::DEBUG, "[xwm] cb transfer to wl client complete, read {} bytes", len);
|
||||
if (!transfer->incremental) {
|
||||
transfers.erase(it);
|
||||
} else {
|
||||
|
|
@ -1633,7 +1634,7 @@ bool SXTransfer::getIncomingSelectionProp(bool erase) {
|
|||
propertyReply = xcb_get_property_reply(*g_pXWayland->m_wm->m_connection, cookie, nullptr);
|
||||
|
||||
if (!propertyReply) {
|
||||
Debug::log(ERR, "[SXTransfer] couldn't get a prop reply");
|
||||
Log::logger->log(Log::ERR, "[SXTransfer] couldn't get a prop reply");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ class CXCBConnection {
|
|||
|
||||
~CXCBConnection() {
|
||||
if (m_connection) {
|
||||
Debug::log(LOG, "Disconnecting XCB connection {:x}", rc<uintptr_t>(m_connection));
|
||||
Log::logger->log(Log::DEBUG, "Disconnecting XCB connection {:x}", rc<uintptr_t>(m_connection));
|
||||
xcb_disconnect(m_connection);
|
||||
m_connection = nullptr;
|
||||
} else
|
||||
Debug::log(ERR, "Double xcb_disconnect attempt");
|
||||
Log::logger->log(Log::ERR, "Double xcb_disconnect attempt");
|
||||
}
|
||||
|
||||
bool hasError() const {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#include "XWayland.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../debug/Log.hpp"
|
||||
#include "../debug/log/Logger.hpp"
|
||||
#include "../helpers/fs/FsUtils.hpp"
|
||||
|
||||
CXWayland::CXWayland(const bool wantsEnabled) {
|
||||
#ifndef NO_XWAYLAND
|
||||
// Disable Xwayland and clean up if the user disabled it.
|
||||
if (!wantsEnabled) {
|
||||
Debug::log(LOG, "XWayland has been disabled, cleaning up...");
|
||||
Log::logger->log(Log::DEBUG, "XWayland has been disabled, cleaning up...");
|
||||
for (auto& w : g_pCompositor->m_windows) {
|
||||
if (!w->m_isX11)
|
||||
continue;
|
||||
|
|
@ -20,29 +20,29 @@ CXWayland::CXWayland(const bool wantsEnabled) {
|
|||
|
||||
if (!NFsUtils::executableExistsInPath("Xwayland")) {
|
||||
// If Xwayland doesn't exist, don't try to start it.
|
||||
Debug::log(LOG, "Unable to find XWayland; not starting it.");
|
||||
Log::logger->log(Log::DEBUG, "Unable to find XWayland; not starting it.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Starting up the XWayland server");
|
||||
Log::logger->log(Log::DEBUG, "Starting up the XWayland server");
|
||||
|
||||
m_server = makeUnique<CXWaylandServer>();
|
||||
|
||||
if (!m_server->create()) {
|
||||
Debug::log(ERR, "XWayland failed to start: it will not work.");
|
||||
Log::logger->log(Log::ERR, "XWayland failed to start: it will not work.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_enabled = true;
|
||||
#else
|
||||
Debug::log(LOG, "Not starting XWayland: disabled at compile time");
|
||||
Log::logger->log(Log::DEBUG, "Not starting XWayland: disabled at compile time");
|
||||
#endif
|
||||
}
|
||||
|
||||
void CXWayland::setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& size, const Vector2D& hotspot) {
|
||||
#ifndef NO_XWAYLAND
|
||||
if (!m_wm) {
|
||||
Debug::log(ERR, "Couldn't set XCursor: no XWM yet");
|
||||
Log::logger->log(Log::ERR, "Couldn't set XCursor: no XWM yet");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue