diff --git a/src/Compositor.cpp b/src/Compositor.cpp index dd098df24..ece6691a0 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2394,7 +2394,7 @@ PHLWINDOW CCompositor::getX11Parent(PHLWINDOW pWindow) { if (!w->m_isX11) continue; - if (w->m_xwaylandSurface == pWindow->m_xwaylandSurface->parent) + if (w->m_xwaylandSurface == pWindow->m_xwaylandSurface->m_parent) return w; } diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 6e6e51a10..c712e5ebf 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -100,18 +100,18 @@ CWindow::CWindow(SP resource) : m_xdgSurface(resource) { CWindow::CWindow(SP surface) : m_xwaylandSurface(surface) { m_wlSurface = CWLSurface::create(); - m_listeners.map = m_xwaylandSurface->events.map.registerListener([this](std::any d) { Events::listener_mapWindow(this, nullptr); }); - m_listeners.unmap = m_xwaylandSurface->events.unmap.registerListener([this](std::any d) { Events::listener_unmapWindow(this, nullptr); }); - m_listeners.destroy = m_xwaylandSurface->events.destroy.registerListener([this](std::any d) { Events::listener_destroyWindow(this, nullptr); }); - m_listeners.commit = m_xwaylandSurface->events.commit.registerListener([this](std::any d) { Events::listener_commitWindow(this, nullptr); }); - m_listeners.configureRequest = m_xwaylandSurface->events.configureRequest.registerListener([this](std::any d) { onX11ConfigureRequest(std::any_cast(d)); }); - m_listeners.updateState = m_xwaylandSurface->events.stateChanged.registerListener([this](std::any d) { onUpdateState(); }); - m_listeners.updateMetadata = m_xwaylandSurface->events.metadataChanged.registerListener([this](std::any d) { onUpdateMeta(); }); - m_listeners.resourceChange = m_xwaylandSurface->events.resourceChange.registerListener([this](std::any d) { onResourceChangeX11(); }); - m_listeners.activate = m_xwaylandSurface->events.activate.registerListener([this](std::any d) { Events::listener_activateX11(this, nullptr); }); + m_listeners.map = m_xwaylandSurface->m_events.map.registerListener([this](std::any d) { Events::listener_mapWindow(this, nullptr); }); + m_listeners.unmap = m_xwaylandSurface->m_events.unmap.registerListener([this](std::any d) { Events::listener_unmapWindow(this, nullptr); }); + m_listeners.destroy = m_xwaylandSurface->m_events.destroy.registerListener([this](std::any d) { Events::listener_destroyWindow(this, nullptr); }); + m_listeners.commit = m_xwaylandSurface->m_events.commit.registerListener([this](std::any d) { Events::listener_commitWindow(this, nullptr); }); + m_listeners.configureRequest = m_xwaylandSurface->m_events.configureRequest.registerListener([this](std::any d) { onX11ConfigureRequest(std::any_cast(d)); }); + m_listeners.updateState = m_xwaylandSurface->m_events.stateChanged.registerListener([this](std::any d) { onUpdateState(); }); + m_listeners.updateMetadata = m_xwaylandSurface->m_events.metadataChanged.registerListener([this](std::any d) { onUpdateMeta(); }); + m_listeners.resourceChange = m_xwaylandSurface->m_events.resourceChange.registerListener([this](std::any d) { onResourceChangeX11(); }); + m_listeners.activate = m_xwaylandSurface->m_events.activate.registerListener([this](std::any d) { Events::listener_activateX11(this, nullptr); }); - if (m_xwaylandSurface->overrideRedirect) - m_listeners.setGeometry = m_xwaylandSurface->events.setGeometry.registerListener([this](std::any d) { Events::listener_unmanagedSetGeometry(this, nullptr); }); + if (m_xwaylandSurface->m_overrideRedirect) + m_listeners.setGeometry = m_xwaylandSurface->m_events.setGeometry.registerListener([this](std::any d) { Events::listener_unmanagedSetGeometry(this, nullptr); }); } CWindow::~CWindow() { @@ -352,7 +352,7 @@ pid_t CWindow::getPID() { if (!m_xwaylandSurface) return -1; - PID = m_xwaylandSurface->pid; + PID = m_xwaylandSurface->m_pid; } return PID; @@ -471,10 +471,10 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) { } PHLWINDOW CWindow::x11TransientFor() { - if (!m_xwaylandSurface || !m_xwaylandSurface->parent) + if (!m_xwaylandSurface || !m_xwaylandSurface->m_parent) return nullptr; - auto s = m_xwaylandSurface->parent; + auto s = m_xwaylandSurface->m_parent; std::vector> visited; while (s) { // break loops. Some X apps make them, and it seems like it's valid behavior?!?!?! @@ -483,7 +483,7 @@ PHLWINDOW CWindow::x11TransientFor() { break; visited.emplace_back(s.lock()); - s = s->parent; + s = s->m_parent; } if (s == m_xwaylandSurface) @@ -1159,8 +1159,8 @@ bool CWindow::opaque() { if (PWORKSPACE->m_alpha->value() != 1.f) return false; - if (m_isX11 && m_xwaylandSurface && m_xwaylandSurface->surface && m_xwaylandSurface->surface->m_current.texture) - return m_xwaylandSurface->surface->m_current.texture->m_opaque; + if (m_isX11 && m_xwaylandSurface && m_xwaylandSurface->m_surface && m_xwaylandSurface->m_surface->m_current.texture) + return m_xwaylandSurface->m_surface->m_current.texture->m_opaque; if (!m_wlSurface->resource() || !m_wlSurface->resource()->m_current.texture) return false; @@ -1418,9 +1418,9 @@ void CWindow::activate(bool force) { } void CWindow::onUpdateState() { - std::optional requestsFS = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsFullscreen : m_xwaylandSurface->state.requestsFullscreen; + std::optional requestsFS = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsFullscreen : m_xwaylandSurface->m_state.requestsFullscreen; std::optional requestsID = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsFullscreenMonitor : MONITOR_INVALID; - std::optional requestsMX = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsMaximize : m_xwaylandSurface->state.requestsMaximize; + std::optional requestsMX = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsMaximize : m_xwaylandSurface->m_state.requestsMaximize; if (requestsFS.has_value() && !(m_suppressedEvents & SUPPRESS_FULLSCREEN)) { if (requestsID.has_value() && (requestsID.value() != MONITOR_INVALID) && !(m_suppressedEvents & SUPPRESS_FULLSCREEN_OUTPUT)) { @@ -1495,7 +1495,7 @@ std::string CWindow::fetchTitle() { return m_xdgSurface->m_toplevel->m_state.title; } else { if (m_xwaylandSurface) - return m_xwaylandSurface->state.title; + return m_xwaylandSurface->m_state.title; } return ""; @@ -1507,7 +1507,7 @@ std::string CWindow::fetchClass() { return m_xdgSurface->m_toplevel->m_state.appid; } else { if (m_xwaylandSurface) - return m_xwaylandSurface->state.appid; + return m_xwaylandSurface->m_state.appid; } return ""; @@ -1524,9 +1524,9 @@ void CWindow::onAck(uint32_t serial) { } void CWindow::onResourceChangeX11() { - if (m_xwaylandSurface->surface && !m_wlSurface->resource()) - m_wlSurface->assign(m_xwaylandSurface->surface.lock(), m_self.lock()); - else if (!m_xwaylandSurface->surface && m_wlSurface->resource()) + if (m_xwaylandSurface->m_surface && !m_wlSurface->resource()) + m_wlSurface->assign(m_xwaylandSurface->m_surface.lock(), m_self.lock()); + else if (!m_xwaylandSurface->m_surface && m_wlSurface->resource()) m_wlSurface->unassign(); // update metadata as well, @@ -1538,7 +1538,7 @@ void CWindow::onResourceChangeX11() { void CWindow::onX11ConfigureRequest(CBox box) { - if (!m_xwaylandSurface->surface || !m_xwaylandSurface->mapped || !m_isMapped) { + if (!m_xwaylandSurface->m_surface || !m_xwaylandSurface->m_mapped || !m_isMapped) { m_xwaylandSurface->configure(box); m_pendingReportedSize = box.size(); m_reportedSize = box.size(); @@ -1668,18 +1668,18 @@ void CWindow::unsetWindowData(eOverridePriority priority) { } bool CWindow::isX11OverrideRedirect() { - return m_xwaylandSurface && m_xwaylandSurface->overrideRedirect; + return m_xwaylandSurface && m_xwaylandSurface->m_overrideRedirect; } bool CWindow::isModal() { - return (m_xwaylandSurface && m_xwaylandSurface->modal); + return (m_xwaylandSurface && m_xwaylandSurface->m_modal); } Vector2D CWindow::requestedMinSize() { - if ((m_isX11 && !m_xwaylandSurface->sizeHints) || (!m_isX11 && !m_xdgSurface->m_toplevel)) + if ((m_isX11 && !m_xwaylandSurface->m_sizeHints) || (!m_isX11 && !m_xdgSurface->m_toplevel)) return Vector2D(1, 1); - Vector2D minSize = m_isX11 ? Vector2D(m_xwaylandSurface->sizeHints->min_width, m_xwaylandSurface->sizeHints->min_height) : m_xdgSurface->m_toplevel->layoutMinSize(); + Vector2D minSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->min_width, m_xwaylandSurface->m_sizeHints->min_height) : m_xdgSurface->m_toplevel->layoutMinSize(); minSize = minSize.clamp({1, 1}); @@ -1688,10 +1688,10 @@ Vector2D CWindow::requestedMinSize() { Vector2D CWindow::requestedMaxSize() { constexpr int NO_MAX_SIZE_LIMIT = 99999; - if (((m_isX11 && !m_xwaylandSurface->sizeHints) || (!m_isX11 && (!m_xdgSurface || !m_xdgSurface->m_toplevel)) || m_windowData.noMaxSize.valueOrDefault())) + if (((m_isX11 && !m_xwaylandSurface->m_sizeHints) || (!m_isX11 && (!m_xdgSurface || !m_xdgSurface->m_toplevel)) || m_windowData.noMaxSize.valueOrDefault())) return Vector2D(NO_MAX_SIZE_LIMIT, NO_MAX_SIZE_LIMIT); - Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->sizeHints->max_width, m_xwaylandSurface->sizeHints->max_height) : m_xdgSurface->m_toplevel->layoutMaxSize(); + Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->max_width, m_xwaylandSurface->m_sizeHints->max_height) : m_xdgSurface->m_toplevel->layoutMaxSize(); if (maxSize.x < 5) maxSize.x = NO_MAX_SIZE_LIMIT; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index d365e3763..240070a3e 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -136,7 +136,7 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_matchedRules = g_pConfigManager->getMatchingRules(PWINDOW, false); std::optional requestedInternalFSMode, requestedClientFSMode; std::optional requestedFSState; - if (PWINDOW->m_wantsInitialFullscreen || (PWINDOW->m_isX11 && PWINDOW->m_xwaylandSurface->fullscreen)) + if (PWINDOW->m_wantsInitialFullscreen || (PWINDOW->m_isX11 && PWINDOW->m_xwaylandSurface->m_fullscreen)) requestedClientFSMode = FSMODE_FULLSCREEN; MONITORID requestedFSMonitor = PWINDOW->m_wantsInitialFullscreenMonitor; @@ -975,13 +975,13 @@ void Events::listener_activateX11(void* owner, void* data) { void Events::listener_unmanagedSetGeometry(void* owner, void* data) { PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); - if (!PWINDOW->m_isMapped || !PWINDOW->m_xwaylandSurface || !PWINDOW->m_xwaylandSurface->overrideRedirect) + if (!PWINDOW->m_isMapped || !PWINDOW->m_xwaylandSurface || !PWINDOW->m_xwaylandSurface->m_overrideRedirect) return; const auto POS = PWINDOW->m_realPosition->goal(); const auto SIZ = PWINDOW->m_realSize->goal(); - if (PWINDOW->m_xwaylandSurface->geometry.size() > Vector2D{1, 1}) + if (PWINDOW->m_xwaylandSurface->m_geometry.size() > Vector2D{1, 1}) PWINDOW->setHidden(false); else PWINDOW->setHidden(true); @@ -994,17 +994,17 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) { static auto PXWLFORCESCALEZERO = CConfigValue("xwayland:force_zero_scaling"); - const auto LOGICALPOS = g_pXWaylandManager->xwaylandToWaylandCoords(PWINDOW->m_xwaylandSurface->geometry.pos()); + const auto LOGICALPOS = g_pXWaylandManager->xwaylandToWaylandCoords(PWINDOW->m_xwaylandSurface->m_geometry.pos()); - if (abs(std::floor(POS.x) - LOGICALPOS.x) > 2 || abs(std::floor(POS.y) - LOGICALPOS.y) > 2 || abs(std::floor(SIZ.x) - PWINDOW->m_xwaylandSurface->geometry.width) > 2 || - abs(std::floor(SIZ.y) - PWINDOW->m_xwaylandSurface->geometry.height) > 2) { - Debug::log(LOG, "Unmanaged window {} requests geometry update to {:j} {:j}", PWINDOW, LOGICALPOS, PWINDOW->m_xwaylandSurface->geometry.size()); + if (abs(std::floor(POS.x) - LOGICALPOS.x) > 2 || abs(std::floor(POS.y) - LOGICALPOS.y) > 2 || abs(std::floor(SIZ.x) - PWINDOW->m_xwaylandSurface->m_geometry.width) > 2 || + abs(std::floor(SIZ.y) - PWINDOW->m_xwaylandSurface->m_geometry.height) > 2) { + Debug::log(LOG, "Unmanaged window {} requests geometry update to {:j} {:j}", PWINDOW, LOGICALPOS, PWINDOW->m_xwaylandSurface->m_geometry.size()); g_pHyprRenderer->damageWindow(PWINDOW); PWINDOW->m_realPosition->setValueAndWarp(Vector2D(LOGICALPOS.x, LOGICALPOS.y)); - if (abs(std::floor(SIZ.x) - PWINDOW->m_xwaylandSurface->geometry.w) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_xwaylandSurface->geometry.h) > 2) - PWINDOW->m_realSize->setValueAndWarp(PWINDOW->m_xwaylandSurface->geometry.size()); + if (abs(std::floor(SIZ.x) - PWINDOW->m_xwaylandSurface->m_geometry.w) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_xwaylandSurface->m_geometry.h) > 2) + PWINDOW->m_realSize->setValueAndWarp(PWINDOW->m_xwaylandSurface->m_geometry.size()); if (*PXWLFORCESCALEZERO) { if (const auto PMONITOR = PWINDOW->m_monitor.lock(); PMONITOR) { diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 96dea1059..9919404a2 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -131,8 +131,8 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { if (pWindow->m_isX11 && pWindow->isX11OverrideRedirect()) { - if (pWindow->m_xwaylandSurface->geometry.x != 0 && pWindow->m_xwaylandSurface->geometry.y != 0) - *pWindow->m_realPosition = g_pXWaylandManager->xwaylandToWaylandCoords(pWindow->m_xwaylandSurface->geometry.pos()); + if (pWindow->m_xwaylandSurface->m_geometry.x != 0 && pWindow->m_xwaylandSurface->m_geometry.y != 0) + *pWindow->m_realPosition = g_pXWaylandManager->xwaylandToWaylandCoords(pWindow->m_xwaylandSurface->m_geometry.pos()); else *pWindow->m_realPosition = Vector2D(PMONITOR->m_position.x + (PMONITOR->m_size.x - pWindow->m_realSize->goal().x) / 2.f, PMONITOR->m_position.y + (PMONITOR->m_size.y - pWindow->m_realSize->goal().y) / 2.f); diff --git a/src/managers/ANRManager.cpp b/src/managers/ANRManager.cpp index eff5046b1..e4e62ea8a 100644 --- a/src/managers/ANRManager.cpp +++ b/src/managers/ANRManager.cpp @@ -218,7 +218,7 @@ pid_t CANRManager::SANRData::getPid() const { } if (xwaylandSurface) - return xwaylandSurface->pid; + return xwaylandSurface->m_pid; return 0; } diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index ec9e078c5..460e9ecdc 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -84,7 +84,7 @@ CBox CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow) { CBox box; if (pWindow->m_isX11) - box = pWindow->m_xwaylandSurface->geometry; + box = pWindow->m_xwaylandSurface->m_geometry; else if (pWindow->m_xdgSurface) box = pWindow->m_xdgSurface->m_current.geometry; @@ -100,7 +100,7 @@ void CHyprXWaylandManager::sendCloseWindow(PHLWINDOW pWindow) { bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) { if (pWindow->m_isX11) { - for (const auto& a : pWindow->m_xwaylandSurface->atoms) + for (const auto& a : pWindow->m_xwaylandSurface->m_atoms) if (a == HYPRATOMS["_NET_WM_WINDOW_TYPE_DIALOG"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"] || @@ -115,12 +115,12 @@ bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) { return true; } - if (pWindow->isModal() || pWindow->m_xwaylandSurface->transient || - (pWindow->m_xwaylandSurface->role.contains("task_dialog") || pWindow->m_xwaylandSurface->role.contains("pop-up")) || pWindow->m_xwaylandSurface->overrideRedirect) + if (pWindow->isModal() || pWindow->m_xwaylandSurface->m_transient || + (pWindow->m_xwaylandSurface->m_role.contains("task_dialog") || pWindow->m_xwaylandSurface->m_role.contains("pop-up")) || pWindow->m_xwaylandSurface->m_overrideRedirect) return true; - const auto SIZEHINTS = pWindow->m_xwaylandSurface->sizeHints.get(); - if (pWindow->m_xwaylandSurface->transient || pWindow->m_xwaylandSurface->parent || + const auto SIZEHINTS = pWindow->m_xwaylandSurface->m_sizeHints.get(); + if (pWindow->m_xwaylandSurface->m_transient || pWindow->m_xwaylandSurface->m_parent || (SIZEHINTS && (SIZEHINTS->min_width == SIZEHINTS->max_width) && (SIZEHINTS->min_height == SIZEHINTS->max_height))) return true; } else { @@ -140,7 +140,7 @@ void CHyprXWaylandManager::checkBorders(PHLWINDOW pWindow) { if (!pWindow->m_isX11) return; - for (auto const& a : pWindow->m_xwaylandSurface->atoms) { + for (auto const& a : pWindow->m_xwaylandSurface->m_atoms) { if (a == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_NOTIFICATION"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_COMBO"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] || a == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"]) { diff --git a/src/protocols/XDGOutput.cpp b/src/protocols/XDGOutput.cpp index 93ac1c378..ccb78e987 100644 --- a/src/protocols/XDGOutput.cpp +++ b/src/protocols/XDGOutput.cpp @@ -47,7 +47,7 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32 CXDGOutput* pXDGOutput = m_xdgOutputs.emplace_back(makeUnique(makeShared(CLIENT, mgr->version(), id), PMONITOR)).get(); #ifndef NO_XWAYLAND - if (g_pXWayland && g_pXWayland->pServer && g_pXWayland->pServer->xwaylandClient == CLIENT) + if (g_pXWayland && g_pXWayland->m_server && g_pXWayland->m_server->m_xwaylandClient == CLIENT) pXDGOutput->m_isXWayland = true; #endif pXDGOutput->m_client = CLIENT; diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index 67c16e43d..ad580ed19 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -420,8 +420,8 @@ void CWLDataDeviceProtocol::destroyResource(CWLDataOfferResource* resource) { SP CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) { #ifndef NO_XWAYLAND - if (g_pXWayland && g_pXWayland->pServer && c == g_pXWayland->pServer->xwaylandClient) - return g_pXWayland->pWM->getDataDevice(); + if (g_pXWayland && g_pXWayland->m_server && c == g_pXWayland->m_server->m_xwaylandClient) + return g_pXWayland->m_wm->getDataDevice(); #endif auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; }); @@ -451,7 +451,7 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP dev, SPgetX11(); X11) - offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), sel); + offer = g_pXWayland->m_wm->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), sel); #endif if UNLIKELY (!offer) { @@ -669,7 +669,7 @@ void CWLDataDeviceProtocol::updateDrag() { } #ifndef NO_XWAYLAND else if (const auto X11 = m_dnd.focusedDevice->getX11(); X11) - offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), m_dnd.currentSource.lock()); + offer = g_pXWayland->m_wm->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), m_dnd.currentSource.lock()); #endif if (!offer) { diff --git a/src/xwayland/Dnd.cpp b/src/xwayland/Dnd.cpp index 2cb8be57c..e4c609202 100644 --- a/src/xwayland/Dnd.cpp +++ b/src/xwayland/Dnd.cpp @@ -36,15 +36,15 @@ void CX11DataDevice::sendDndEvent(xcb_window_t targetWindow, xcb_atom_t type, xc .data = data, }; - xcb_send_event(g_pXWayland->pWM->connection, 0, targetWindow, XCB_EVENT_MASK_NO_EVENT, (const char*)&event); - xcb_flush(g_pXWayland->pWM->connection); + xcb_send_event(g_pXWayland->m_wm->m_connection, 0, targetWindow, XCB_EVENT_MASK_NO_EVENT, (const char*)&event); + xcb_flush(g_pXWayland->m_wm->m_connection); } xcb_window_t CX11DataDevice::getProxyWindow(xcb_window_t window) { xcb_window_t targetWindow = window; xcb_get_property_cookie_t proxyCookie = - xcb_get_property(g_pXWayland->pWM->connection, PROPERTY_OFFSET, window, HYPRATOMS["XdndProxy"], XCB_ATOM_WINDOW, PROPERTY_OFFSET, PROPERTY_LENGTH); - xcb_get_property_reply_t* proxyReply = xcb_get_property_reply(g_pXWayland->pWM->connection, proxyCookie, nullptr); + xcb_get_property(g_pXWayland->m_wm->m_connection, PROPERTY_OFFSET, window, HYPRATOMS["XdndProxy"], XCB_ATOM_WINDOW, PROPERTY_OFFSET, PROPERTY_LENGTH); + xcb_get_property_reply_t* proxyReply = xcb_get_property_reply(g_pXWayland->m_wm->m_connection, proxyCookie, nullptr); const auto isValidPropertyReply = [](xcb_get_property_reply_t* reply) { return reply && reply->type == XCB_ATOM_WINDOW && reply->format == PROPERTY_FORMAT_32BIT && xcb_get_property_value_length(reply) == sizeof(xcb_window_t); @@ -54,8 +54,8 @@ xcb_window_t CX11DataDevice::getProxyWindow(xcb_window_t window) { xcb_window_t proxyWindow = *(xcb_window_t*)xcb_get_property_value(proxyReply); xcb_get_property_cookie_t proxyVerifyCookie = - xcb_get_property(g_pXWayland->pWM->connection, PROPERTY_OFFSET, proxyWindow, HYPRATOMS["XdndProxy"], XCB_ATOM_WINDOW, PROPERTY_OFFSET, PROPERTY_LENGTH); - xcb_get_property_reply_t* proxyVerifyReply = xcb_get_property_reply(g_pXWayland->pWM->connection, proxyVerifyCookie, nullptr); + xcb_get_property(g_pXWayland->m_wm->m_connection, PROPERTY_OFFSET, proxyWindow, HYPRATOMS["XdndProxy"], XCB_ATOM_WINDOW, PROPERTY_OFFSET, PROPERTY_LENGTH); + xcb_get_property_reply_t* proxyVerifyReply = xcb_get_property_reply(g_pXWayland->m_wm->m_connection, proxyVerifyCookie, nullptr); if (isValidPropertyReply(proxyVerifyReply)) { xcb_window_t verifyWindow = *(xcb_window_t*)xcb_get_property_value(proxyVerifyReply); @@ -81,16 +81,16 @@ SP CX11DataOffer::getWayland() { } SP CX11DataOffer::getX11() { - return self.lock(); + return m_self.lock(); } SP CX11DataOffer::getSource() { - return source.lock(); + return m_source.lock(); } void CX11DataOffer::markDead() { #ifndef NO_XWAYLAND - std::erase(g_pXWayland->pWM->dndDataOffers, self); + std::erase(g_pXWayland->m_wm->m_dndDataOffers, m_self); #endif } @@ -100,7 +100,7 @@ void CX11DataDevice::sendDataOffer(SP offer) { void CX11DataDevice::sendEnter(uint32_t serial, SP surf, const Vector2D& local, SP offer) { #ifndef NO_XWAYLAND - auto XSURF = g_pXWayland->pWM->windowForWayland(surf); + auto XSURF = g_pXWayland->m_wm->windowForWayland(surf); if (!XSURF) { Debug::log(ERR, "CX11DataDevice::sendEnter: No xwayland surface for destination"); @@ -118,54 +118,54 @@ void CX11DataDevice::sendEnter(uint32_t serial, SP surf, con // reserve to avoid reallocations targets.reserve(SOURCE->mimes().size()); for (auto const& m : SOURCE->mimes()) { - targets.push_back(g_pXWayland->pWM->mimeToAtom(m)); + targets.push_back(g_pXWayland->m_wm->mimeToAtom(m)); } - xcb_change_property(g_pXWayland->pWM->connection, XCB_PROP_MODE_REPLACE, g_pXWayland->pWM->dndSelection.window, HYPRATOMS["XdndTypeList"], XCB_ATOM_ATOM, 32, targets.size(), - targets.data()); + xcb_change_property(g_pXWayland->m_wm->m_connection, XCB_PROP_MODE_REPLACE, g_pXWayland->m_wm->m_dndSelection.window, HYPRATOMS["XdndTypeList"], XCB_ATOM_ATOM, 32, + targets.size(), targets.data()); - xcb_set_selection_owner(g_pXWayland->pWM->connection, g_pXWayland->pWM->dndSelection.window, HYPRATOMS["XdndSelection"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); + xcb_set_selection_owner(g_pXWayland->m_wm->m_connection, g_pXWayland->m_wm->m_dndSelection.window, HYPRATOMS["XdndSelection"], XCB_TIME_CURRENT_TIME); + xcb_flush(g_pXWayland->m_wm->m_connection); - xcb_window_t targetWindow = getProxyWindow(XSURF->xID); + xcb_window_t targetWindow = getProxyWindow(XSURF->m_xID); xcb_client_message_data_t data = {{0}}; - data.data32[0] = g_pXWayland->pWM->dndSelection.window; + data.data32[0] = g_pXWayland->m_wm->m_dndSelection.window; data.data32[1] = XDND_VERSION << 24; data.data32[1] |= 1; sendDndEvent(targetWindow, HYPRATOMS["XdndEnter"], data); - lastSurface = XSURF; - lastOffer = offer; + m_lastSurface = XSURF; + m_lastOffer = offer; - auto hlSurface = XSURF->surface.lock(); + auto hlSurface = XSURF->m_surface.lock(); if (!hlSurface) { Debug::log(ERR, "CX11DataDevice::sendEnter: Non desktop x surface?!"); - lastSurfaceCoords = {}; + m_lastSurfaceCoords = {}; return; } - lastSurfaceCoords = g_pXWaylandManager->xwaylandToWaylandCoords(XSURF->geometry.pos()); + m_lastSurfaceCoords = g_pXWaylandManager->xwaylandToWaylandCoords(XSURF->m_geometry.pos()); #endif } void CX11DataDevice::cleanupState() { - lastSurface.reset(); - lastOffer.reset(); - lastSurfaceCoords = {}; - lastTime = 0; + m_lastSurface.reset(); + m_lastOffer.reset(); + m_lastSurfaceCoords = {}; + m_lastTime = 0; } void CX11DataDevice::sendLeave() { #ifndef NO_XWAYLAND - if (!lastSurface) + if (!m_lastSurface) return; - xcb_window_t targetWindow = getProxyWindow(lastSurface->xID); + xcb_window_t targetWindow = getProxyWindow(m_lastSurface->m_xID); xcb_client_message_data_t data = {{0}}; - data.data32[0] = g_pXWayland->pWM->dndSelection.window; + data.data32[0] = g_pXWayland->m_wm->m_dndSelection.window; sendDndEvent(targetWindow, HYPRATOMS["XdndLeave"], data); @@ -175,38 +175,38 @@ void CX11DataDevice::sendLeave() { void CX11DataDevice::sendMotion(uint32_t timeMs, const Vector2D& local) { #ifndef NO_XWAYLAND - if (!lastSurface || !lastOffer || !lastOffer->getSource()) + if (!m_lastSurface || !m_lastOffer || !m_lastOffer->getSource()) return; - xcb_window_t targetWindow = getProxyWindow(lastSurface->xID); + xcb_window_t targetWindow = getProxyWindow(m_lastSurface->m_xID); - const auto XCOORDS = g_pXWaylandManager->waylandToXWaylandCoords(lastSurfaceCoords + local); + const auto XCOORDS = g_pXWaylandManager->waylandToXWaylandCoords(m_lastSurfaceCoords + local); const uint32_t coords = ((uint32_t)XCOORDS.x << 16) | (uint32_t)XCOORDS.y; xcb_client_message_data_t data = {{0}}; - data.data32[0] = g_pXWayland->pWM->dndSelection.window; + data.data32[0] = g_pXWayland->m_wm->m_dndSelection.window; data.data32[2] = coords; data.data32[3] = timeMs; - data.data32[4] = dndActionToAtom(lastOffer->getSource()->actions()); + data.data32[4] = dndActionToAtom(m_lastOffer->getSource()->actions()); sendDndEvent(targetWindow, HYPRATOMS["XdndPosition"], data); - lastTime = timeMs; + m_lastTime = timeMs; #endif } void CX11DataDevice::sendDrop() { #ifndef NO_XWAYLAND - if (!lastSurface || !lastOffer) { + if (!m_lastSurface || !m_lastOffer) { Debug::log(ERR, "CX11DataDevice::sendDrop: No surface or offer"); return; } - xcb_window_t targetWindow = getProxyWindow(lastSurface->xID); + xcb_window_t targetWindow = getProxyWindow(m_lastSurface->m_xID); xcb_client_message_data_t data = {{0}}; - data.data32[0] = g_pXWayland->pWM->dndSelection.window; - data.data32[2] = lastTime; + data.data32[0] = g_pXWayland->m_wm->m_dndSelection.window; + data.data32[2] = m_lastTime; sendDndEvent(targetWindow, HYPRATOMS["XdndDrop"], data); @@ -227,11 +227,11 @@ SP CX11DataDevice::getWayland() { } SP CX11DataDevice::getX11() { - return self.lock(); + return m_self.lock(); } std::vector CX11DataSource::mimes() { - return mimeTypes; + return m_mimeTypes; } void CX11DataSource::send(const std::string& mime, CFileDescriptor fd) { @@ -243,30 +243,30 @@ void CX11DataSource::accepted(const std::string& mime) { } void CX11DataSource::cancelled() { - dndSuccess = false; - dropped = false; + m_dndSuccess = false; + m_dropped = false; } bool CX11DataSource::hasDnd() { - return dnd; + return m_dnd; } bool CX11DataSource::dndDone() { - return dropped; + return m_dropped; } void CX11DataSource::error(uint32_t code, const std::string& msg) { Debug::log(ERR, "CX11DataSource error: code {} msg {}", code, msg); - dndSuccess = false; - dropped = false; + m_dndSuccess = false; + m_dropped = false; } void CX11DataSource::sendDndFinished() { - dndSuccess = true; + m_dndSuccess = true; } uint32_t CX11DataSource::actions() { - return supportedActions; + return m_supportedActions; } eDataSourceType CX11DataSource::type() { @@ -274,7 +274,7 @@ eDataSourceType CX11DataSource::type() { } void CX11DataSource::sendDndDropPerformed() { - dropped = true; + m_dropped = true; } void CX11DataSource::sendDndAction(wl_data_device_manager_dnd_action a) { @@ -283,16 +283,16 @@ void CX11DataSource::sendDndAction(wl_data_device_manager_dnd_action a) { void CX11DataDevice::forceCleanupDnd() { #ifndef NO_XWAYLAND - if (lastOffer) { - auto source = lastOffer->getSource(); + if (m_lastOffer) { + auto source = m_lastOffer->getSource(); if (source) { source->cancelled(); source->sendDndFinished(); } } - xcb_set_selection_owner(g_pXWayland->pWM->connection, XCB_ATOM_NONE, HYPRATOMS["XdndSelection"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); + xcb_set_selection_owner(g_pXWayland->m_wm->m_connection, XCB_ATOM_NONE, HYPRATOMS["XdndSelection"], XCB_TIME_CURRENT_TIME); + xcb_flush(g_pXWayland->m_wm->m_connection); cleanupState(); diff --git a/src/xwayland/Dnd.hpp b/src/xwayland/Dnd.hpp index 1b97f5cc0..581297416 100644 --- a/src/xwayland/Dnd.hpp +++ b/src/xwayland/Dnd.hpp @@ -22,15 +22,9 @@ class CX11DataOffer : public IDataOffer { virtual SP getSource(); virtual void markDead(); - WP source; - WP self; - WP xwaylandSurface; - - bool dead = false; - bool accepted = false; - bool recvd = false; - - uint32_t actions = 0; + WP m_source; + WP m_self; + WP m_xwaylandSurface; }; class CX11DataSource : public IDataSource { @@ -51,15 +45,12 @@ class CX11DataSource : public IDataSource { virtual void sendDndDropPerformed(); virtual void sendDndAction(wl_data_device_manager_dnd_action a); - bool used = false; - bool dnd = true; - bool dndSuccess = false; - bool dropped = false; + bool m_dnd = true; + bool m_dndSuccess = false; + bool m_dropped = false; - WP self; - - std::vector mimeTypes; - uint32_t supportedActions = 0; + std::vector m_mimeTypes; + uint32_t m_supportedActions = 0; }; class CX11DataDevice : public IDataDevice { @@ -77,7 +68,7 @@ class CX11DataDevice : public IDataDevice { virtual eDataSourceType type(); void forceCleanupDnd(); - WP self; + WP m_self; private: void cleanupState(); @@ -85,8 +76,8 @@ class CX11DataDevice : public IDataDevice { xcb_window_t getProxyWindow(xcb_window_t window); void sendDndEvent(xcb_window_t targetWindow, xcb_atom_t type, xcb_client_message_data_t& data); #endif - WP lastSurface; - WP lastOffer; - Vector2D lastSurfaceCoords; - uint32_t lastTime = 0; + WP m_lastSurface; + WP m_lastOffer; + Vector2D m_lastSurfaceCoords; + uint32_t m_lastTime = 0; }; diff --git a/src/xwayland/Server.cpp b/src/xwayland/Server.cpp index a2e0e9fab..814bd20cc 100644 --- a/src/xwayland/Server.cpp +++ b/src/xwayland/Server.cpp @@ -172,12 +172,12 @@ static bool openSockets(std::array& sockets, int display) { } static void startServer(void* data) { - if (!g_pXWayland->pServer->start()) + if (!g_pXWayland->m_server->start()) Debug::log(ERR, "The XWayland server could not start! XWayland will not work..."); } static int xwaylandReady(int fd, uint32_t mask, void* data) { - return g_pXWayland->pServer->ready(fd, mask); + return g_pXWayland->m_server->ready(fd, mask); } static bool safeRemove(const std::string& path) { @@ -194,7 +194,7 @@ bool CXWaylandServer::tryOpenSockets() { CFileDescriptor fd{open(lockPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, LOCK_FILE_MODE)}; if (fd.isValid()) { // we managed to open the lock - if (!openSockets(xFDs, i)) { + if (!openSockets(m_xFDs, i)) { safeRemove(lockPath); continue; } @@ -205,8 +205,8 @@ bool CXWaylandServer::tryOpenSockets() { continue; } - display = i; - displayName = std::format(":{}", display); + m_display = i; + m_displayName = std::format(":{}", m_display); break; } @@ -230,12 +230,12 @@ bool CXWaylandServer::tryOpenSockets() { } } - if (display < 0) { + if (m_display < 0) { Debug::log(ERR, "Failed to find a suitable socket for XWayland"); return false; } - Debug::log(LOG, "XWayland found a suitable display socket at DISPLAY: {}", displayName); + Debug::log(LOG, "XWayland found a suitable display socket at DISPLAY: {}", m_displayName); return true; } @@ -245,63 +245,63 @@ CXWaylandServer::CXWaylandServer() { CXWaylandServer::~CXWaylandServer() { die(); - if (display < 0) + if (m_display < 0) return; - std::string lockPath = std::format("/tmp/.X{}-lock", display); + std::string lockPath = std::format("/tmp/.X{}-lock", m_display); safeRemove(lockPath); std::string path; for (bool isLinux : {true, false}) { - path = getSocketPath(display, isLinux); + path = getSocketPath(m_display, isLinux); safeRemove(path); } } void CXWaylandServer::die() { - if (display < 0) + if (m_display < 0) return; - if (xFDReadEvents[0]) { - wl_event_source_remove(xFDReadEvents[0]); - wl_event_source_remove(xFDReadEvents[1]); - xFDReadEvents = {nullptr, nullptr}; + if (m_xFDReadEvents[0]) { + wl_event_source_remove(m_xFDReadEvents[0]); + wl_event_source_remove(m_xFDReadEvents[1]); + m_xFDReadEvents = {nullptr, nullptr}; } - if (pipeSource) - wl_event_source_remove(pipeSource); + if (m_pipeSource) + wl_event_source_remove(m_pipeSource); // possible crash. Better to leak a bit. //if (xwaylandClient) // wl_client_destroy(xwaylandClient); - xwaylandClient = nullptr; + m_xwaylandClient = nullptr; } bool CXWaylandServer::create() { if (!tryOpenSockets()) return false; - setenv("DISPLAY", displayName.c_str(), true); + setenv("DISPLAY", m_displayName.c_str(), true); // TODO: lazy mode - idleSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, ::startServer, nullptr); + m_idleSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, ::startServer, nullptr); return true; } void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) { - if (!xFDs[0].setFlags(xFDs[0].getFlags() & ~FD_CLOEXEC) || !xFDs[1].setFlags(xFDs[1].getFlags() & ~FD_CLOEXEC) || - !waylandFDs[1].setFlags(waylandFDs[1].getFlags() & ~FD_CLOEXEC) || !xwmFDs[1].setFlags(xwmFDs[1].getFlags() & ~FD_CLOEXEC)) { + 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"); _exit(EXIT_FAILURE); } - auto cmd = - std::format("Xwayland {} -rootless -core -listenfd {} -listenfd {} -displayfd {} -wm {}", displayName, xFDs[0].get(), xFDs[1].get(), notifyFD.get(), xwmFDs[1].get()); + auto cmd = std::format("Xwayland {} -rootless -core -listenfd {} -listenfd {} -displayfd {} -wm {}", m_displayName, m_xFDs[0].get(), m_xFDs[1].get(), notifyFD.get(), + m_xwmFDs[1].get()); - auto waylandSocket = std::format("{}", waylandFDs[1].get()); + auto waylandSocket = std::format("{}", m_waylandFDs[1].get()); setenv("WAYLAND_SOCKET", waylandSocket.c_str(), true); Debug::log(LOG, "Starting XWayland with \"{}\", bon voyage!", cmd); @@ -313,17 +313,17 @@ void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) { } bool CXWaylandServer::start() { - idleSource = nullptr; + m_idleSource = nullptr; int wlPair[2] = {-1, -1}; if (socketpair(AF_UNIX, SOCK_STREAM, 0, wlPair) != 0) { Debug::log(ERR, "socketpair failed (1)"); die(); return false; } - waylandFDs[0] = CFileDescriptor{wlPair[0]}; - waylandFDs[1] = CFileDescriptor{wlPair[1]}; + m_waylandFDs[0] = CFileDescriptor{wlPair[0]}; + m_waylandFDs[1] = CFileDescriptor{wlPair[1]}; - if (!waylandFDs[0].setFlags(waylandFDs[0].getFlags() | FD_CLOEXEC) || !waylandFDs[1].setFlags(waylandFDs[1].getFlags() | FD_CLOEXEC)) { + 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)"); die(); return false; @@ -336,23 +336,23 @@ bool CXWaylandServer::start() { return false; } - xwmFDs[0] = CFileDescriptor{xwmPair[0]}; - xwmFDs[1] = CFileDescriptor{xwmPair[1]}; + m_xwmFDs[0] = CFileDescriptor{xwmPair[0]}; + m_xwmFDs[1] = CFileDescriptor{xwmPair[1]}; - if (!xwmFDs[0].setFlags(xwmFDs[0].getFlags() | FD_CLOEXEC) || !xwmFDs[1].setFlags(xwmFDs[1].getFlags() | FD_CLOEXEC)) { + 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)"); die(); return false; } - xwaylandClient = wl_client_create(g_pCompositor->m_wlDisplay, waylandFDs[0].get()); - if (!xwaylandClient) { + m_xwaylandClient = wl_client_create(g_pCompositor->m_wlDisplay, m_waylandFDs[0].get()); + if (!m_xwaylandClient) { Debug::log(ERR, "wl_client_create failed"); die(); return false; } - waylandFDs[0].take(); // wl_client owns this fd now + m_waylandFDs[0].take(); // wl_client owns this fd now int notify[2] = {-1, -1}; if (pipe(notify) < 0) { @@ -369,8 +369,8 @@ bool CXWaylandServer::start() { return false; } - pipeSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, notifyFds[0].get(), WL_EVENT_READABLE, ::xwaylandReady, nullptr); - pipeFd = std::move(notifyFds[0]); + m_pipeSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, notifyFds[0].get(), WL_EVENT_READABLE, ::xwaylandReady, nullptr); + m_pipeFd = std::move(notifyFds[0]); auto serverPID = fork(); if (serverPID < 0) { @@ -400,19 +400,19 @@ 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"); - g_pXWayland->pServer.reset(); + g_pXWayland->m_server.reset(); return 1; } Debug::log(LOG, "XWayland is ready"); - wl_event_source_remove(pipeSource); - pipeFd.reset(); - pipeSource = nullptr; + wl_event_source_remove(m_pipeSource); + m_pipeFd.reset(); + m_pipeSource = nullptr; // start the wm - if (!g_pXWayland->pWM) - g_pXWayland->pWM = makeUnique(); + if (!g_pXWayland->m_wm) + g_pXWayland->m_wm = makeUnique(); g_pCursorManager->setXWaylandCursor(); diff --git a/src/xwayland/Server.hpp b/src/xwayland/Server.hpp index 553d99ad3..7266a9b0c 100644 --- a/src/xwayland/Server.hpp +++ b/src/xwayland/Server.hpp @@ -20,29 +20,25 @@ class CXWaylandServer { bool start(); // called on ready - int ready(int fd, uint32_t mask); + int ready(int fd, uint32_t mask); - void die(); + void die(); - struct { - CSignal ready; - } events; - - wl_client* xwaylandClient = nullptr; + wl_client* m_xwaylandClient = nullptr; private: bool tryOpenSockets(); void runXWayland(Hyprutils::OS::CFileDescriptor& notifyFD); - std::string displayName; - int display = -1; - std::array xFDs; - std::array xFDReadEvents = {nullptr, nullptr}; - wl_event_source* idleSource = nullptr; - wl_event_source* pipeSource = nullptr; - Hyprutils::OS::CFileDescriptor pipeFd; - std::array xwmFDs; - std::array waylandFDs; + std::string m_displayName; + int m_display = -1; + std::array m_xFDs; + std::array m_xFDReadEvents = {nullptr, nullptr}; + wl_event_source* m_idleSource = nullptr; + wl_event_source* m_pipeSource = nullptr; + Hyprutils::OS::CFileDescriptor m_pipeFd; + std::array m_xwmFDs; + std::array m_waylandFDs; friend class CXWM; }; diff --git a/src/xwayland/XDataSource.cpp b/src/xwayland/XDataSource.cpp index 14656d8b1..ec06c9bc9 100644 --- a/src/xwayland/XDataSource.cpp +++ b/src/xwayland/XDataSource.cpp @@ -7,12 +7,12 @@ #include using namespace Hyprutils::OS; -CXDataSource::CXDataSource(SXSelection& sel_) : selection(sel_) { - xcb_get_property_cookie_t cookie = xcb_get_property(g_pXWayland->pWM->connection, +CXDataSource::CXDataSource(SXSelection& sel_) : m_selection(sel_) { + xcb_get_property_cookie_t cookie = xcb_get_property(g_pXWayland->m_wm->m_connection, 1, // delete - selection.window, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 4096); + m_selection.window, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 4096); - xcb_get_property_reply_t* reply = xcb_get_property_reply(g_pXWayland->pWM->connection, cookie, nullptr); + xcb_get_property_reply_t* reply = xcb_get_property_reply(g_pXWayland->m_wm->m_connection, cookie, nullptr); if (!reply) return; @@ -24,28 +24,28 @@ CXDataSource::CXDataSource(SXSelection& sel_) : selection(sel_) { auto value = (xcb_atom_t*)xcb_get_property_value(reply); for (uint32_t i = 0; i < reply->value_len; i++) { if (value[i] == HYPRATOMS["UTF8_STRING"]) - mimeTypes.emplace_back("text/plain;charset=utf-8"); + m_mimeTypes.emplace_back("text/plain;charset=utf-8"); else if (value[i] == HYPRATOMS["TEXT"]) - mimeTypes.emplace_back("text/plain"); + m_mimeTypes.emplace_back("text/plain"); else if (value[i] != HYPRATOMS["TARGETS"] && value[i] != HYPRATOMS["TIMESTAMP"]) { - auto type = g_pXWayland->pWM->mimeFromAtom(value[i]); + auto type = g_pXWayland->m_wm->mimeFromAtom(value[i]); if (type == "INVALID") continue; - mimeTypes.push_back(type); + m_mimeTypes.push_back(type); } else continue; - mimeAtoms.push_back(value[i]); + m_mimeAtoms.push_back(value[i]); } free(reply); } std::vector CXDataSource::mimes() { - return mimeTypes; + return m_mimeTypes; } void CXDataSource::send(const std::string& mime, CFileDescriptor fd) { @@ -56,9 +56,9 @@ void CXDataSource::send(const std::string& mime, CFileDescriptor fd) { else if (mime == "text/plain;charset=utf-8") mimeAtom = HYPRATOMS["UTF8_STRING"]; else { - for (size_t i = 0; i < mimeTypes.size(); ++i) { - if (mimeTypes[i] == mime) { - mimeAtom = mimeAtoms[i]; + for (size_t i = 0; i < m_mimeTypes.size(); ++i) { + if (m_mimeTypes[i] == mime) { + mimeAtom = m_mimeAtoms[i]; break; } } @@ -71,26 +71,26 @@ void CXDataSource::send(const std::string& mime, CFileDescriptor fd) { Debug::log(LOG, "[XDataSource] send with mime {} to fd {}", mime, fd.get()); - auto transfer = makeUnique(selection); - transfer->incomingWindow = xcb_generate_id(g_pXWayland->pWM->connection); + auto transfer = makeUnique(m_selection); + transfer->incomingWindow = xcb_generate_id(g_pXWayland->m_wm->m_connection); const uint32_t MASK = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE; - xcb_create_window(g_pXWayland->pWM->connection, XCB_COPY_FROM_PARENT, transfer->incomingWindow, g_pXWayland->pWM->screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, - g_pXWayland->pWM->screen->root_visual, XCB_CW_EVENT_MASK, &MASK); + xcb_create_window(g_pXWayland->m_wm->m_connection, XCB_COPY_FROM_PARENT, transfer->incomingWindow, g_pXWayland->m_wm->m_screen->root, 0, 0, 10, 10, 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, g_pXWayland->m_wm->m_screen->root_visual, XCB_CW_EVENT_MASK, &MASK); xcb_atom_t selection_atom = HYPRATOMS["CLIPBOARD"]; - if (&selection == &g_pXWayland->pWM->primarySelection) + if (&m_selection == &g_pXWayland->m_wm->m_primarySelection) selection_atom = HYPRATOMS["PRIMARY"]; - else if (&selection == &g_pXWayland->pWM->dndSelection) + else if (&m_selection == &g_pXWayland->m_wm->m_dndSelection) selection_atom = HYPRATOMS["XdndSelection"]; - xcb_convert_selection(g_pXWayland->pWM->connection, transfer->incomingWindow, selection_atom, mimeAtom, HYPRATOMS["_WL_SELECTION"], XCB_TIME_CURRENT_TIME); + xcb_convert_selection(g_pXWayland->m_wm->m_connection, transfer->incomingWindow, selection_atom, mimeAtom, HYPRATOMS["_WL_SELECTION"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); + xcb_flush(g_pXWayland->m_wm->m_connection); //TODO: make CFileDescriptor setflags take SETFL aswell fcntl(fd.get(), F_SETFL, O_WRONLY | O_NONBLOCK); transfer->wlFD = std::move(fd); - selection.transfers.emplace_back(std::move(transfer)); + m_selection.transfers.emplace_back(std::move(transfer)); } void CXDataSource::accepted(const std::string& mime) { diff --git a/src/xwayland/XDataSource.hpp b/src/xwayland/XDataSource.hpp index a61ffcc90..686991d54 100644 --- a/src/xwayland/XDataSource.hpp +++ b/src/xwayland/XDataSource.hpp @@ -17,7 +17,7 @@ class CXDataSource : public IDataSource { virtual eDataSourceType type(); private: - SXSelection& selection; - std::vector mimeTypes; // these two have shared idx - std::vector mimeAtoms; // + SXSelection& m_selection; + std::vector m_mimeTypes; // these two have shared idx + std::vector m_mimeAtoms; // }; diff --git a/src/xwayland/XSurface.cpp b/src/xwayland/XSurface.cpp index 89c654739..949649aec 100644 --- a/src/xwayland/XSurface.cpp +++ b/src/xwayland/XSurface.cpp @@ -9,19 +9,19 @@ #include -CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : xID(xID_), geometry(geometry_), overrideRedirect(OR) { +CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_xID(xID_), m_geometry(geometry_), m_overrideRedirect(OR) { xcb_res_query_client_ids_cookie_t client_id_cookie = {0}; - if (g_pXWayland->pWM->xres) { - xcb_res_client_id_spec_t spec = {.client = xID, .mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID}; - client_id_cookie = xcb_res_query_client_ids(g_pXWayland->pWM->connection, 1, &spec); + if (g_pXWayland->m_wm->m_xres) { + xcb_res_client_id_spec_t spec = {.client = m_xID, .mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID}; + client_id_cookie = xcb_res_query_client_ids(g_pXWayland->m_wm->m_connection, 1, &spec); } uint32_t values[1]; values[0] = XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE; - xcb_change_window_attributes(g_pXWayland->pWM->connection, xID, XCB_CW_EVENT_MASK, values); + xcb_change_window_attributes(g_pXWayland->m_wm->m_connection, m_xID, XCB_CW_EVENT_MASK, values); - if (g_pXWayland->pWM->xres) { - xcb_res_query_client_ids_reply_t* reply = xcb_res_query_client_ids_reply(g_pXWayland->pWM->connection, client_id_cookie, nullptr); + if (g_pXWayland->m_wm->m_xres) { + xcb_res_query_client_ids_reply_t* reply = xcb_res_query_client_ids_reply(g_pXWayland->m_wm->m_connection, client_id_cookie, nullptr); if (!reply) return; @@ -38,101 +38,101 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : xID free(reply); return; } - pid = *ppid; + m_pid = *ppid; free(reply); } - events.resourceChange.registerStaticListener([this](void* data, std::any d) { ensureListeners(); }, nullptr); + m_events.resourceChange.registerStaticListener([this](void* data, std::any d) { ensureListeners(); }, nullptr); } void CXWaylandSurface::ensureListeners() { - bool connected = listeners.destroySurface; + bool connected = m_listeners.destroySurface; - if (connected && !surface) { - listeners.destroySurface.reset(); - listeners.commitSurface.reset(); - } else if (!connected && surface) { - listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { - if (mapped) + if (connected && !m_surface) { + m_listeners.destroySurface.reset(); + m_listeners.commitSurface.reset(); + } else if (!connected && m_surface) { + m_listeners.destroySurface = m_surface->m_events.destroy.registerListener([this](std::any d) { + if (m_mapped) unmap(); - surface.reset(); - listeners.destroySurface.reset(); - listeners.commitSurface.reset(); - events.resourceChange.emit(); + m_surface.reset(); + m_listeners.destroySurface.reset(); + m_listeners.commitSurface.reset(); + m_events.resourceChange.emit(); }); - listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) { - if (surface->m_current.texture && !mapped) { + m_listeners.commitSurface = m_surface->m_events.commit.registerListener([this](std::any d) { + if (m_surface->m_current.texture && !m_mapped) { map(); return; } - if (!surface->m_current.texture && mapped) { + if (!m_surface->m_current.texture && m_mapped) { unmap(); return; } - events.commit.emit(); + m_events.commit.emit(); }); } - if (resource) { - listeners.destroyResource = resource->events.destroy.registerListener([this](std::any d) { + if (m_resource) { + m_listeners.destroyResource = m_resource->events.destroy.registerListener([this](std::any d) { unmap(); - surface.reset(); - events.resourceChange.emit(); + m_surface.reset(); + m_events.resourceChange.emit(); }); } } void CXWaylandSurface::map() { - if (mapped) + if (m_mapped) return; - ASSERT(surface); + ASSERT(m_surface); - g_pXWayland->pWM->mappedSurfaces.emplace_back(self); - g_pXWayland->pWM->mappedSurfacesStacking.emplace_back(self); + g_pXWayland->m_wm->m_mappedSurfaces.emplace_back(m_self); + g_pXWayland->m_wm->m_mappedSurfacesStacking.emplace_back(m_self); - mapped = true; - surface->map(); + m_mapped = true; + m_surface->map(); Debug::log(LOG, "XWayland surface {:x} mapping", (uintptr_t)this); - events.map.emit(); + m_events.map.emit(); - g_pXWayland->pWM->updateClientList(); + g_pXWayland->m_wm->updateClientList(); } void CXWaylandSurface::unmap() { - if (!mapped) + if (!m_mapped) return; - ASSERT(surface); + ASSERT(m_surface); - std::erase(g_pXWayland->pWM->mappedSurfaces, self); - std::erase(g_pXWayland->pWM->mappedSurfacesStacking, self); + std::erase(g_pXWayland->m_wm->m_mappedSurfaces, m_self); + std::erase(g_pXWayland->m_wm->m_mappedSurfacesStacking, m_self); - mapped = false; - events.unmap.emit(); - surface->unmap(); + m_mapped = false; + m_events.unmap.emit(); + m_surface->unmap(); Debug::log(LOG, "XWayland surface {:x} unmapping", (uintptr_t)this); - g_pXWayland->pWM->updateClientList(); + g_pXWayland->m_wm->updateClientList(); } void CXWaylandSurface::considerMap() { - if (mapped) + if (m_mapped) return; - if (!surface) { + if (!m_surface) { Debug::log(LOG, "XWayland surface: considerMap, nope, no surface"); return; } - if (surface->m_current.texture) { + if (m_surface->m_current.texture) { Debug::log(LOG, "XWayland surface: considerMap, sure, we have a buffer"); map(); return; @@ -142,7 +142,7 @@ void CXWaylandSurface::considerMap() { } bool CXWaylandSurface::wantsFocus() { - if (atoms.empty()) + if (m_atoms.empty()) return true; const std::array search = { @@ -153,7 +153,7 @@ bool CXWaylandSurface::wantsFocus() { }; for (auto const& searched : search) { - for (auto const& a : atoms) { + for (auto const& a : m_atoms) { if (a == searched) return false; } @@ -163,110 +163,110 @@ bool CXWaylandSurface::wantsFocus() { } void CXWaylandSurface::configure(const CBox& box) { - Vector2D oldSize = geometry.size(); + Vector2D oldSize = m_geometry.size(); - geometry = box; + m_geometry = box; uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH; uint32_t values[] = {box.x, box.y, box.width, box.height, 0}; - xcb_configure_window(g_pXWayland->pWM->connection, xID, mask, values); + xcb_configure_window(g_pXWayland->m_wm->m_connection, m_xID, mask, values); - if (geometry.width == box.width && geometry.height == box.height) { + if (m_geometry.width == box.width && m_geometry.height == box.height) { // ICCCM requires a synthetic event when window size is not changed xcb_configure_notify_event_t e; e.response_type = XCB_CONFIGURE_NOTIFY; - e.event = xID; - e.window = xID; + e.event = m_xID; + e.window = m_xID; e.x = box.x; e.y = box.y; e.width = box.width; e.height = box.height; e.border_width = 0; e.above_sibling = XCB_NONE; - e.override_redirect = overrideRedirect; - xcb_send_event(g_pXWayland->pWM->connection, false, xID, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char*)&e); + e.override_redirect = m_overrideRedirect; + xcb_send_event(g_pXWayland->m_wm->m_connection, false, m_xID, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char*)&e); } - g_pXWayland->pWM->updateClientList(); + g_pXWayland->m_wm->updateClientList(); - xcb_flush(g_pXWayland->pWM->connection); + xcb_flush(g_pXWayland->m_wm->m_connection); } void CXWaylandSurface::activate(bool activate) { - if (overrideRedirect && !activate) + if (m_overrideRedirect && !activate) return; - g_pXWayland->pWM->activateSurface(self.lock(), activate); + g_pXWayland->m_wm->activateSurface(m_self.lock(), activate); } void CXWaylandSurface::setFullscreen(bool fs) { - fullscreen = fs; - g_pXWayland->pWM->sendState(self.lock()); + m_fullscreen = fs; + g_pXWayland->m_wm->sendState(m_self.lock()); } void CXWaylandSurface::setMinimized(bool mz) { - minimized = mz; - g_pXWayland->pWM->sendState(self.lock()); + m_minimized = mz; + g_pXWayland->m_wm->sendState(m_self.lock()); } void CXWaylandSurface::restackToTop() { uint32_t values[1] = {XCB_STACK_MODE_ABOVE}; - xcb_configure_window(g_pXWayland->pWM->connection, xID, XCB_CONFIG_WINDOW_STACK_MODE, values); + xcb_configure_window(g_pXWayland->m_wm->m_connection, m_xID, XCB_CONFIG_WINDOW_STACK_MODE, values); - auto& stack = g_pXWayland->pWM->mappedSurfacesStacking; - auto it = std::find(stack.begin(), stack.end(), self); + auto& stack = g_pXWayland->m_wm->m_mappedSurfacesStacking; + auto it = std::find(stack.begin(), stack.end(), m_self); if (it != stack.end()) std::rotate(it, it + 1, stack.end()); - g_pXWayland->pWM->updateClientList(); + g_pXWayland->m_wm->updateClientList(); - xcb_flush(g_pXWayland->pWM->connection); + xcb_flush(g_pXWayland->m_wm->m_connection); } void CXWaylandSurface::close() { xcb_client_message_data_t msg = {}; msg.data32[0] = HYPRATOMS["WM_DELETE_WINDOW"]; msg.data32[1] = XCB_CURRENT_TIME; - g_pXWayland->pWM->sendWMMessage(self.lock(), &msg, XCB_EVENT_MASK_NO_EVENT); + g_pXWayland->m_wm->sendWMMessage(m_self.lock(), &msg, XCB_EVENT_MASK_NO_EVENT); } void CXWaylandSurface::setWithdrawn(bool withdrawn_) { - withdrawn = withdrawn_; + m_withdrawn = withdrawn_; std::vector props = {XCB_ICCCM_WM_STATE_NORMAL, XCB_WINDOW_NONE}; - if (withdrawn) + if (m_withdrawn) props[0] = XCB_ICCCM_WM_STATE_WITHDRAWN; - else if (minimized) + else if (m_minimized) props[0] = XCB_ICCCM_WM_STATE_ICONIC; else props[0] = XCB_ICCCM_WM_STATE_NORMAL; - xcb_change_property(g_pXWayland->pWM->connection, XCB_PROP_MODE_REPLACE, xID, HYPRATOMS["WM_STATE"], HYPRATOMS["WM_STATE"], 32, props.size(), props.data()); + xcb_change_property(g_pXWayland->m_wm->m_connection, XCB_PROP_MODE_REPLACE, m_xID, HYPRATOMS["WM_STATE"], HYPRATOMS["WM_STATE"], 32, props.size(), props.data()); } void CXWaylandSurface::ping() { - bool supportsPing = std::ranges::find(protocols, HYPRATOMS["_NET_WM_PING"]) != protocols.end(); + 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", xID); - g_pANRManager->onResponse(self.lock()); + Debug::log(TRACE, "CXWaylandSurface: XID {} does not support ping, just sending an instant reply", m_xID); + g_pANRManager->onResponse(m_self.lock()); return; } xcb_client_message_data_t msg = {}; msg.data32[0] = HYPRATOMS["_NET_WM_PING"]; msg.data32[1] = Time::millis(Time::steadyNow()); - msg.data32[2] = xID; + msg.data32[2] = m_xID; - lastPingSeq = msg.data32[1]; + m_lastPingSeq = msg.data32[1]; - g_pXWayland->pWM->sendWMMessage(self.lock(), &msg, XCB_EVENT_MASK_PROPERTY_CHANGE); + g_pXWayland->m_wm->sendWMMessage(m_self.lock(), &msg, XCB_EVENT_MASK_PROPERTY_CHANGE); } #else -CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : xID(xID_), geometry(geometry_), overrideRedirect(OR) { +CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_xID(xID_), m_geometry(geometry_), m_overrideRedirect(OR) { ; } diff --git a/src/xwayland/XSurface.hpp b/src/xwayland/XSurface.hpp index 53777c33f..dc43acbbe 100644 --- a/src/xwayland/XSurface.hpp +++ b/src/xwayland/XSurface.hpp @@ -39,8 +39,8 @@ typedef struct { class CXWaylandSurface { public: - WP surface; - WP resource; + WP m_surface; + WP m_resource; struct { CSignal stateChanged; // maximized, fs, minimized, etc. @@ -57,7 +57,7 @@ class CXWaylandSurface { CSignal commit; CSignal activate; - } events; + } m_events; struct { std::string title; @@ -67,31 +67,32 @@ class CXWaylandSurface { std::optional requestsMaximize; std::optional requestsFullscreen; std::optional requestsMinimize; - } state; + } m_state; - uint32_t xID = 0; - uint64_t wlID = 0; - uint64_t wlSerial = 0; - uint32_t lastPingSeq = 0; - pid_t pid = 0; - CBox geometry; - bool overrideRedirect = false; - bool withdrawn = false; - bool fullscreen = false; - bool maximized = false; - bool minimized = false; - bool mapped = false; - bool modal = false; + uint32_t m_xID = 0; + uint64_t m_wlID = 0; + uint64_t m_wlSerial = 0; + uint32_t m_lastPingSeq = 0; + pid_t m_pid = 0; + CBox m_geometry; + bool m_overrideRedirect = false; + bool m_withdrawn = false; + bool m_fullscreen = false; + bool m_maximized = false; + bool m_minimized = false; + bool m_mapped = false; + bool m_modal = false; - WP parent; - WP self; - std::vector> children; + WP m_parent; + WP m_self; + std::vector> m_children; - UP hints; - UP sizeHints; - std::vector atoms, protocols; - std::string role = ""; - bool transient = false; + UP m_hints; + UP m_sizeHints; + std::vector m_atoms; + std::vector m_protocols; + std::string m_role = ""; + bool m_transient = false; bool wantsFocus(); void configure(const CBox& box); @@ -115,7 +116,7 @@ class CXWaylandSurface { CHyprSignalListener destroyResource; CHyprSignalListener destroySurface; CHyprSignalListener commitSurface; - } listeners; + } m_listeners; friend class CXWM; }; diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index c62758c5e..8e4f9a87b 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -24,12 +24,12 @@ using namespace Hyprutils::OS; #define INCR_CHUNK_SIZE (64 * 1024) static int onX11Event(int fd, uint32_t mask, void* data) { - return g_pXWayland->pWM->onEvent(fd, mask); + return g_pXWayland->m_wm->onEvent(fd, mask); } SP CXWM::windowForXID(xcb_window_t wid) { - for (auto const& s : surfaces) { - if (s->xID == wid) + for (auto const& s : m_surfaces) { + if (s->m_xID == wid) return s; } @@ -40,8 +40,8 @@ void CXWM::handleCreate(xcb_create_notify_event_t* e) { if (isWMWindow(e->window)) return; - const auto XSURF = surfaces.emplace_back(SP(new CXWaylandSurface(e->window, CBox{e->x, e->y, e->width, e->height}, e->override_redirect))); - XSURF->self = XSURF; + const auto XSURF = m_surfaces.emplace_back(SP(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 {}", (uintptr_t)XSURF.get(), e->window); const auto WINDOW = CWindow::create(XSURF); @@ -56,8 +56,8 @@ void CXWM::handleDestroy(xcb_destroy_notify_event_t* e) { if (!XSURF) return; - XSURF->events.destroy.emit(); - std::erase_if(surfaces, [XSURF](const auto& other) { return XSURF == other; }); + XSURF->m_events.destroy.emit(); + std::erase_if(m_surfaces, [XSURF](const auto& other) { return XSURF == other; }); } void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) { @@ -71,9 +71,9 @@ void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) { if (!(MASK & GEOMETRY)) return; - XSURF->events.configureRequest.emit(CBox{MASK & XCB_CONFIG_WINDOW_X ? e->x : XSURF->geometry.x, MASK & XCB_CONFIG_WINDOW_Y ? e->y : XSURF->geometry.y, - MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->geometry.width, - MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->geometry.height}); + XSURF->m_events.configureRequest.emit(CBox{MASK & XCB_CONFIG_WINDOW_X ? e->x : XSURF->m_geometry.x, MASK & XCB_CONFIG_WINDOW_Y ? e->y : XSURF->m_geometry.y, + MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->m_geometry.width, + MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->m_geometry.height}); } void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) { @@ -82,12 +82,12 @@ void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) { if (!XSURF) return; - if (XSURF->geometry == CBox{e->x, e->y, e->width, e->height}) + if (XSURF->m_geometry == CBox{e->x, e->y, e->width, e->height}) return; - XSURF->geometry = {e->x, e->y, e->width, e->height}; + XSURF->m_geometry = {e->x, e->y, e->width, e->height}; updateOverrideRedirect(XSURF, e->override_redirect); - XSURF->events.setGeometry.emit(); + XSURF->m_events.setGeometry.emit(); } void CXWM::handleMapRequest(xcb_map_request_event_t* e) { @@ -96,20 +96,21 @@ void CXWM::handleMapRequest(xcb_map_request_event_t* e) { if (!XSURF) return; - xcb_map_window(connection, e->window); + xcb_map_window(m_connection, e->window); XSURF->restackToTop(); const bool SMALL = - XSURF->geometry.size() < Vector2D{2, 2} || (XSURF->sizeHints && XSURF->geometry.size() < Vector2D{XSURF->sizeHints->min_width, XSURF->sizeHints->min_height}); - const bool HAS_HINTS = XSURF->sizeHints && Vector2D{XSURF->sizeHints->base_width, XSURF->sizeHints->base_height} > Vector2D{5, 5}; - const auto DESIREDSIZE = HAS_HINTS ? Vector2D{XSURF->sizeHints->base_width, XSURF->sizeHints->base_height} : Vector2D{800, 800}; + XSURF->m_geometry.size() < Vector2D{2, 2} || (XSURF->m_sizeHints && XSURF->m_geometry.size() < Vector2D{XSURF->m_sizeHints->min_width, XSURF->m_sizeHints->min_height}); + const bool HAS_HINTS = XSURF->m_sizeHints && Vector2D{XSURF->m_sizeHints->base_width, XSURF->m_sizeHints->base_height} > Vector2D{5, 5}; + const auto DESIREDSIZE = HAS_HINTS ? Vector2D{XSURF->m_sizeHints->base_width, XSURF->m_sizeHints->base_height} : Vector2D{800, 800}; // if it's too small, configure it. - if (SMALL && !XSURF->overrideRedirect) // default to 800 x 800 - XSURF->configure({XSURF->geometry.pos(), DESIREDSIZE}); + 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->geometry.width, XSURF->geometry.height, XSURF->geometry.x, XSURF->geometry.y); + 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); // 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 @@ -126,12 +127,12 @@ void CXWM::handleMapNotify(xcb_map_notify_event_t* e) { updateOverrideRedirect(XSURF, e->override_redirect); - if (XSURF->overrideRedirect) + if (XSURF->m_overrideRedirect) return; XSURF->setWithdrawn(false); sendState(XSURF); - xcb_flush(connection); + xcb_flush(m_connection); XSURF->considerMap(); } @@ -145,23 +146,23 @@ void CXWM::handleUnmapNotify(xcb_unmap_notify_event_t* e) { XSURF->unmap(); dissociate(XSURF); - if (XSURF->overrideRedirect) + if (XSURF->m_overrideRedirect) return; XSURF->setWithdrawn(true); sendState(XSURF); - xcb_flush(connection); + xcb_flush(m_connection); } static bool lookupParentExists(SP XSURF, SP prospectiveChild) { std::vector> visited; - while (XSURF->parent) { - if (XSURF->parent == prospectiveChild) + while (XSURF->m_parent) { + if (XSURF->m_parent == prospectiveChild) return true; visited.emplace_back(XSURF); - XSURF = XSURF->parent.lock(); + XSURF = XSURF->m_parent.lock(); if (std::find(visited.begin(), visited.end(), XSURF) != visited.end()) return false; @@ -179,8 +180,8 @@ std::string CXWM::getAtomName(uint32_t atom) { } // Get the name of the atom - auto const atom_name_cookie = xcb_get_atom_name(connection, atom); - auto* atom_name_reply = xcb_get_atom_name_reply(connection, atom_name_cookie, nullptr); + auto const atom_name_cookie = xcb_get_atom_name(m_connection, atom); + auto* atom_name_reply = xcb_get_atom_name_reply(m_connection, atom_name_cookie, nullptr); if (!atom_name_reply) return "Unknown"; @@ -198,90 +199,90 @@ void CXWM::readProp(SP XSURF, uint32_t atom, xcb_get_property_ propName = getAtomName(atom); if (atom == XCB_ATOM_WM_CLASS) { - size_t len = xcb_get_property_value_length(reply); - char* string = (char*)xcb_get_property_value(reply); - XSURF->state.appid = std::string{string, len}; - if (std::count(XSURF->state.appid.begin(), XSURF->state.appid.end(), '\000') == 2) - XSURF->state.appid = XSURF->state.appid.substr(XSURF->state.appid.find_first_of('\000') + 1); // fuck you X - if (!XSURF->state.appid.empty()) - XSURF->state.appid.pop_back(); - XSURF->events.metadataChanged.emit(); + size_t len = xcb_get_property_value_length(reply); + char* string = (char*)xcb_get_property_value(reply); + XSURF->m_state.appid = std::string{string, len}; + if (std::count(XSURF->m_state.appid.begin(), XSURF->m_state.appid.end(), '\000') == 2) + XSURF->m_state.appid = XSURF->m_state.appid.substr(XSURF->m_state.appid.find_first_of('\000') + 1); // fuck you X + if (!XSURF->m_state.appid.empty()) + XSURF->m_state.appid.pop_back(); + XSURF->m_events.metadataChanged.emit(); } else if (atom == XCB_ATOM_WM_NAME || atom == HYPRATOMS["_NET_WM_NAME"]) { size_t len = xcb_get_property_value_length(reply); char* string = (char*)xcb_get_property_value(reply); if (reply->type != HYPRATOMS["UTF8_STRING"] && reply->type != HYPRATOMS["TEXT"] && reply->type != XCB_ATOM_STRING) return; - XSURF->state.title = std::string{string, len}; - XSURF->events.metadataChanged.emit(); + XSURF->m_state.title = std::string{string, len}; + XSURF->m_events.metadataChanged.emit(); } else if (atom == HYPRATOMS["_NET_WM_WINDOW_TYPE"]) { xcb_atom_t* atomsArr = (xcb_atom_t*)xcb_get_property_value(reply); size_t atomsNo = reply->value_len; - XSURF->atoms.clear(); + XSURF->m_atoms.clear(); for (size_t i = 0; i < atomsNo; ++i) { - XSURF->atoms.push_back(atomsArr[i]); + XSURF->m_atoms.push_back(atomsArr[i]); } } else if (atom == HYPRATOMS["_NET_WM_STATE"]) { xcb_atom_t* atoms = (xcb_atom_t*)xcb_get_property_value(reply); for (uint32_t i = 0; i < reply->value_len; i++) { if (atoms[i] == HYPRATOMS["_NET_WM_STATE_MODAL"]) - XSURF->modal = true; + XSURF->m_modal = true; } } else if (atom == HYPRATOMS["WM_HINTS"]) { if (reply->value_len != 0) { - XSURF->hints = makeUnique(); - xcb_icccm_get_wm_hints_from_reply(XSURF->hints.get(), reply); + XSURF->m_hints = makeUnique(); + xcb_icccm_get_wm_hints_from_reply(XSURF->m_hints.get(), reply); - if (!(XSURF->hints->flags & XCB_ICCCM_WM_HINT_INPUT)) - XSURF->hints->input = true; + if (!(XSURF->m_hints->flags & XCB_ICCCM_WM_HINT_INPUT)) + XSURF->m_hints->input = true; } } else if (atom == HYPRATOMS["WM_WINDOW_ROLE"]) { size_t len = xcb_get_property_value_length(reply); if (len <= 0) - XSURF->role = ""; + XSURF->m_role = ""; else { - XSURF->role = std::string{(char*)xcb_get_property_value(reply), len}; - XSURF->role = XSURF->role.substr(0, XSURF->role.find_first_of('\000')); + XSURF->m_role = std::string{(char*)xcb_get_property_value(reply), len}; + XSURF->m_role = XSURF->m_role.substr(0, XSURF->m_role.find_first_of('\000')); } } else if (atom == XCB_ATOM_WM_TRANSIENT_FOR) { if (reply->type == XCB_ATOM_WINDOW) { - const auto XID = (xcb_window_t*)xcb_get_property_value(reply); - XSURF->transient = XID; + const auto XID = (xcb_window_t*)xcb_get_property_value(reply); + XSURF->m_transient = XID; if (XID) { if (const auto NEWXSURF = windowForXID(*XID); NEWXSURF && !lookupParentExists(XSURF, NEWXSURF)) { - XSURF->parent = NEWXSURF; - NEWXSURF->children.emplace_back(XSURF); + XSURF->m_parent = NEWXSURF; + NEWXSURF->m_children.emplace_back(XSURF); } else Debug::log(LOG, "[xwm] Denying transient because it would create a loop"); } } } else if (atom == HYPRATOMS["WM_NORMAL_HINTS"]) { if (reply->type == HYPRATOMS["WM_SIZE_HINTS"] && reply->value_len > 0) { - XSURF->sizeHints = makeUnique(); - std::memset(XSURF->sizeHints.get(), 0, sizeof(xcb_size_hints_t)); + XSURF->m_sizeHints = makeUnique(); + std::memset(XSURF->m_sizeHints.get(), 0, sizeof(xcb_size_hints_t)); - xcb_icccm_get_wm_size_hints_from_reply(XSURF->sizeHints.get(), reply); + xcb_icccm_get_wm_size_hints_from_reply(XSURF->m_sizeHints.get(), reply); - const int32_t FLAGS = XSURF->sizeHints->flags; + const int32_t FLAGS = XSURF->m_sizeHints->flags; const bool HASMIN = (FLAGS & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE); const bool HASBASE = (FLAGS & XCB_ICCCM_SIZE_HINT_BASE_SIZE); if (!HASMIN && !HASBASE) { - XSURF->sizeHints->min_width = -1; - XSURF->sizeHints->min_height = -1; - XSURF->sizeHints->base_width = -1; - XSURF->sizeHints->base_height = -1; + XSURF->m_sizeHints->min_width = -1; + XSURF->m_sizeHints->min_height = -1; + XSURF->m_sizeHints->base_width = -1; + XSURF->m_sizeHints->base_height = -1; } else if (!HASBASE) { - XSURF->sizeHints->base_width = XSURF->sizeHints->min_width; - XSURF->sizeHints->base_height = XSURF->sizeHints->min_height; + XSURF->m_sizeHints->base_width = XSURF->m_sizeHints->min_width; + XSURF->m_sizeHints->base_height = XSURF->m_sizeHints->min_height; } else if (!HASMIN) { - XSURF->sizeHints->min_width = XSURF->sizeHints->base_width; - XSURF->sizeHints->min_height = XSURF->sizeHints->base_height; + XSURF->m_sizeHints->min_width = XSURF->m_sizeHints->base_width; + XSURF->m_sizeHints->min_height = XSURF->m_sizeHints->base_height; } if (!(FLAGS & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) { - XSURF->sizeHints->max_width = -1; - XSURF->sizeHints->max_height = -1; + XSURF->m_sizeHints->max_width = -1; + XSURF->m_sizeHints->max_height = -1; } } } else if (atom == HYPRATOMS["WM_PROTOCOLS"]) { @@ -292,7 +293,7 @@ void CXWM::readProp(SP XSURF, uint32_t atom, xcb_get_property_ for (size_t i = 0; i < reply->value_len; ++i) { vec.emplace_back(atoms[i]); } - XSURF->protocols = vec; + XSURF->m_protocols = vec; } } else { Debug::log(TRACE, "[xwm] Unhandled prop {} -> {}", atom, propName); @@ -308,8 +309,8 @@ void CXWM::handlePropertyNotify(xcb_property_notify_event_t* e) { if (!XSURF) return; - xcb_get_property_cookie_t cookie = xcb_get_property(connection, 0, XSURF->xID, e->atom, XCB_ATOM_ANY, 0, 2048); - xcb_get_property_reply_t* reply = xcb_get_property_reply(connection, cookie, nullptr); + xcb_get_property_cookie_t cookie = xcb_get_property(m_connection, 0, XSURF->m_xID, e->atom, XCB_ATOM_ANY, 0, 2048); + xcb_get_property_reply_t* reply = xcb_get_property_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Failed to read property notify cookie"); return; @@ -329,39 +330,39 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) { std::string propName = getAtomName(e->type); if (e->type == HYPRATOMS["WM_PROTOCOLS"]) { - if (e->data.data32[1] == XSURF->lastPingSeq && e->data.data32[0] == HYPRATOMS["_NET_WM_PING"]) { + if (e->data.data32[1] == XSURF->m_lastPingSeq && e->data.data32[0] == HYPRATOMS["_NET_WM_PING"]) { g_pANRManager->onResponse(XSURF); return; } } else if (e->type == HYPRATOMS["WL_SURFACE_ID"]) { - if (XSURF->surface) { + if (XSURF->m_surface) { Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_ID"); dissociate(XSURF); } auto id = e->data.data32[0]; - auto resource = wl_client_get_object(g_pXWayland->pServer->xwaylandClient, id); + auto resource = wl_client_get_object(g_pXWayland->m_server->m_xwaylandClient, id); if (resource) { auto surf = CWLSurfaceResource::fromResource(resource); associate(XSURF, surf); } } else if (e->type == HYPRATOMS["WL_SURFACE_SERIAL"]) { - if (XSURF->wlSerial) { + if (XSURF->m_wlSerial) { Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_SERIAL"); dissociate(XSURF); } uint32_t serialLow = e->data.data32[0]; uint32_t serialHigh = e->data.data32[1]; - XSURF->wlSerial = ((uint64_t)serialHigh << 32) | serialLow; + XSURF->m_wlSerial = ((uint64_t)serialHigh << 32) | serialLow; - Debug::log(LOG, "[xwm] surface {:x} requests serial {:x}", (uintptr_t)XSURF.get(), XSURF->wlSerial); + Debug::log(LOG, "[xwm] surface {:x} requests serial {:x}", (uintptr_t)XSURF.get(), XSURF->m_wlSerial); - for (auto const& res : shellResources) { + for (auto const& res : m_shellResources) { if (!res) continue; - if (res->m_serial != XSURF->wlSerial || !XSURF->wlSerial) + if (res->m_serial != XSURF->m_wlSerial || !XSURF->m_wlSerial) continue; associate(XSURF, res->m_surface.lock()); @@ -391,15 +392,15 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) { }; if (prop == HYPRATOMS["_NET_WM_STATE_FULLSCREEN"]) - XSURF->state.requestsFullscreen = updateState(action, XSURF->fullscreen); + XSURF->m_state.requestsFullscreen = updateState(action, XSURF->m_fullscreen); } - XSURF->events.stateChanged.emit(); + XSURF->m_events.stateChanged.emit(); } } else if (e->type == HYPRATOMS["_NET_ACTIVE_WINDOW"]) { - XSURF->events.activate.emit(); + XSURF->m_events.activate.emit(); } else if (e->type == HYPRATOMS["XdndStatus"]) { - if (dndDataOffers.empty() || !dndDataOffers.at(0)->getSource()) { + if (m_dndDataOffers.empty() || !m_dndDataOffers.at(0)->getSource()) { Debug::log(TRACE, "[xwm] Rejecting XdndStatus message: nothing to get"); return; } @@ -408,16 +409,16 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) { const bool ACCEPTED = data->data32[1] & 1; if (ACCEPTED) - dndDataOffers.at(0)->getSource()->accepted(""); + m_dndDataOffers.at(0)->getSource()->accepted(""); Debug::log(LOG, "[xwm] XdndStatus: accepted: {}"); } else if (e->type == HYPRATOMS["XdndFinished"]) { - if (dndDataOffers.empty() || !dndDataOffers.at(0)->getSource()) { + if (m_dndDataOffers.empty() || !m_dndDataOffers.at(0)->getSource()) { Debug::log(TRACE, "[xwm] Rejecting XdndFinished message: nothing to get"); return; } - dndDataOffers.at(0)->getSource()->sendDndFinished(); + m_dndDataOffers.at(0)->getSource()->sendDndFinished(); Debug::log(LOG, "[xwm] XdndFinished"); } else { @@ -437,10 +438,10 @@ void CXWM::handleFocusIn(xcb_focus_in_event_t* e) { if (!XSURF) return; - if (focusedSurface && focusedSurface->pid == XSURF->pid && e->sequence - lastFocusSeq <= 255) + if (m_focusedSurface && m_focusedSurface->m_pid == XSURF->m_pid && e->sequence - m_lastFocusSeq <= 255) focusWindow(XSURF); else - focusWindow(focusedSurface.lock()); + focusWindow(m_focusedSurface.lock()); } void CXWM::handleFocusOut(xcb_focus_out_event_t* e) { @@ -451,8 +452,8 @@ void CXWM::handleFocusOut(xcb_focus_out_event_t* e) { if (!XSURF) return; - Debug::log(TRACE, "[xwm] focusOut for {} {} {} surface {}", XSURF->mapped ? "mapped" : "unmapped", XSURF->fullscreen ? "fullscreen" : "windowed", - XSURF == focusedSurface ? "focused" : "unfocused", XSURF->state.title); + 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); // do something? } @@ -462,63 +463,63 @@ void CXWM::sendWMMessage(SP surf, xcb_client_message_data_t* d .response_type = XCB_CLIENT_MESSAGE, .format = 32, .sequence = 0, - .window = surf->xID, + .window = surf->m_xID, .type = HYPRATOMS["WM_PROTOCOLS"], .data = *data, }; - xcb_send_event(connection, 0, surf->xID, mask, (const char*)&event); - xcb_flush(connection); + xcb_send_event(m_connection, 0, surf->m_xID, mask, (const char*)&event); + xcb_flush(m_connection); } void CXWM::focusWindow(SP surf) { - if (surf == focusedSurface) + if (surf == m_focusedSurface) return; - focusedSurface = surf; + m_focusedSurface = surf; // send state to all toplevel surfaces, sometimes we might lose some // that could still stick with the focused atom - for (auto const& s : mappedSurfaces) { - if (!s || s->overrideRedirect) + for (auto const& s : m_mappedSurfaces) { + if (!s || s->m_overrideRedirect) continue; sendState(s.lock()); } if (!surf) { - xcb_set_input_focus_checked(connection, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_NONE, XCB_CURRENT_TIME); + xcb_set_input_focus_checked(m_connection, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_NONE, XCB_CURRENT_TIME); return; } - if (surf->overrideRedirect) + if (surf->m_overrideRedirect) return; xcb_client_message_data_t msg = {{0}}; msg.data32[0] = HYPRATOMS["WM_TAKE_FOCUS"]; msg.data32[1] = XCB_TIME_CURRENT_TIME; - if (surf->hints && !surf->hints->input) + if (surf->m_hints && !surf->m_hints->input) sendWMMessage(surf, &msg, XCB_EVENT_MASK_NO_EVENT); else { sendWMMessage(surf, &msg, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT); - xcb_void_cookie_t cookie = xcb_set_input_focus(connection, XCB_INPUT_FOCUS_POINTER_ROOT, surf->xID, XCB_CURRENT_TIME); - lastFocusSeq = cookie.sequence; + xcb_void_cookie_t cookie = xcb_set_input_focus(m_connection, XCB_INPUT_FOCUS_POINTER_ROOT, surf->m_xID, XCB_CURRENT_TIME); + m_lastFocusSeq = cookie.sequence; } } void CXWM::handleError(xcb_value_error_t* e) { - const char* major_name = xcb_errors_get_name_for_major_code(errors, e->major_opcode); + 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"); return; } - const char* minor_name = xcb_errors_get_name_for_minor_code(errors, e->major_opcode, e->minor_opcode); + const char* minor_name = xcb_errors_get_name_for_minor_code(m_errors, e->major_opcode, e->minor_opcode); const char* extension; - const char* error_name = xcb_errors_get_name_for_error(errors, e->error_code, &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"); return; @@ -539,8 +540,8 @@ void CXWM::selectionSendNotify(xcb_selection_request_event_t* e, bool success) { .property = success ? e->property : (uint32_t)XCB_ATOM_NONE, }; - xcb_send_event(connection, 0, e->requestor, XCB_EVENT_MASK_NO_EVENT, (const char*)&selection_notify); - xcb_flush(connection); + xcb_send_event(m_connection, 0, e->requestor, XCB_EVENT_MASK_NO_EVENT, (const char*)&selection_notify); + xcb_flush(m_connection); } xcb_atom_t CXWM::mimeToAtom(const std::string& mime) { @@ -549,8 +550,8 @@ xcb_atom_t CXWM::mimeToAtom(const std::string& mime) { if (mime == "text/plain") return HYPRATOMS["TEXT"]; - xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 0, mime.length(), mime.c_str()); - xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(connection, cookie, nullptr); + xcb_intern_atom_cookie_t cookie = xcb_intern_atom(m_connection, 0, mime.length(), mime.c_str()); + xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(m_connection, cookie, nullptr); if (!reply) return XCB_ATOM_NONE; xcb_atom_t atom = reply->atom; @@ -564,8 +565,8 @@ std::string CXWM::mimeFromAtom(xcb_atom_t atom) { if (atom == HYPRATOMS["TEXT"]) return "text/plain"; - xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(connection, atom); - xcb_get_atom_name_reply_t* reply = xcb_get_atom_name_reply(connection, cookie, nullptr); + xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(m_connection, atom); + xcb_get_atom_name_reply_t* reply = xcb_get_atom_name_reply(m_connection, cookie, nullptr); if (!reply) return "INVALID"; size_t len = xcb_get_atom_name_name_length(reply); @@ -587,7 +588,7 @@ void CXWM::handleSelectionNotify(xcb_selection_notify_event_t* e) { sel->transfers.erase(it); } } else if (e->target == HYPRATOMS["TARGETS"]) { - if (!focusedSurface) { + if (!m_focusedSurface) { Debug::log(TRACE, "[xwm] denying access to write to clipboard because no X client is in focus"); return; } @@ -601,7 +602,7 @@ bool CXWM::handleSelectionPropertyNotify(xcb_property_notify_event_t* e) { if (e->state != XCB_PROPERTY_DELETE) return false; - for (auto* sel : {&clipboard, &primarySelection}) { + for (auto* sel : {&m_clipboard, &m_primarySelection}) { auto it = std::ranges::find_if(sel->transfers, [e](const auto& t) { return t->incomingWindow == e->window; }); if (it != sel->transfers.end()) { if (!(*it)->getIncomingSelectionProp(true)) { @@ -618,11 +619,11 @@ bool CXWM::handleSelectionPropertyNotify(xcb_property_notify_event_t* e) { SXSelection* CXWM::getSelection(xcb_atom_t atom) { if (atom == HYPRATOMS["CLIPBOARD"]) - return &clipboard; + return &m_clipboard; else if (atom == HYPRATOMS["PRIMARY"]) - return &primarySelection; + return &m_primarySelection; else if (atom == HYPRATOMS["XdndSelection"]) - return &dndSelection; + return &m_dndSelection; return nullptr; } @@ -650,7 +651,7 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { return; } - if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->pServer->xwaylandClient) { + 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"); selectionSendNotify(e, false); return; @@ -659,10 +660,10 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { if (e->target == HYPRATOMS["TARGETS"]) { // send mime types std::vector mimes; - if (sel == &clipboard && g_pSeatManager->m_selection.currentSelection) + if (sel == &m_clipboard && g_pSeatManager->m_selection.currentSelection) mimes = g_pSeatManager->m_selection.currentSelection->mimes(); - else if (sel == &dndSelection && !dndDataOffers.empty() && dndDataOffers.at(0)->source) - mimes = dndDataOffers.at(0)->source->mimes(); + else if (sel == &m_dndSelection && !m_dndDataOffers.empty() && m_dndDataOffers.at(0)->m_source) + mimes = m_dndDataOffers.at(0)->m_source->mimes(); if (mimes.empty()) Debug::log(WARN, "[xwm] WARNING: No mimes in TARGETS?"); @@ -677,10 +678,10 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { atoms.push_back(mimeToAtom(m)); } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_ATOM, 32, atoms.size(), atoms.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_ATOM, 32, atoms.size(), atoms.data()); selectionSendNotify(e, true); } else if (e->target == HYPRATOMS["TIMESTAMP"]) { - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_INTEGER, 32, 1, &sel->timestamp); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_INTEGER, 32, 1, &sel->timestamp); selectionSendNotify(e, true); } else if (e->target == HYPRATOMS["DELETE"]) { selectionSendNotify(e, true); @@ -707,14 +708,14 @@ bool CXWM::handleSelectionXFixesNotify(xcb_xfixes_selection_notify_event_t* e) { // IMPORTANT: mind the g_pSeatManager below SXSelection* sel = getSelection(e->selection); - if (sel == &dndSelection) + if (sel == &m_dndSelection) return true; if (e->owner == XCB_WINDOW_NONE) { if (sel->owner != sel->window) { - if (sel == &clipboard) + if (sel == &m_clipboard) g_pSeatManager->setCurrentSelection(nullptr); - else if (sel == &primarySelection) + else if (sel == &m_primarySelection) g_pSeatManager->setCurrentPrimarySelection(nullptr); } @@ -729,11 +730,11 @@ bool CXWM::handleSelectionXFixesNotify(xcb_xfixes_selection_notify_event_t* e) { return true; } - if (sel == &clipboard) - xcb_convert_selection(connection, sel->window, HYPRATOMS["CLIPBOARD"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); - else if (sel == &primarySelection) - xcb_convert_selection(connection, sel->window, HYPRATOMS["PRIMARY"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); - xcb_flush(connection); + if (sel == &m_clipboard) + xcb_convert_selection(m_connection, sel->window, HYPRATOMS["CLIPBOARD"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); + else if (sel == &m_primarySelection) + xcb_convert_selection(m_connection, sel->window, HYPRATOMS["PRIMARY"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); + xcb_flush(m_connection); return true; } @@ -753,7 +754,7 @@ bool CXWM::handleSelectionEvent(xcb_generic_event_t* e) { } } - if (e->response_type - xfixes->first_event == XCB_XFIXES_SELECTION_NOTIFY) + if (e->response_type - m_xfixes->first_event == XCB_XFIXES_SELECTION_NOTIFY) return handleSelectionXFixesNotify((xcb_xfixes_selection_notify_event_t*)e); return 0; @@ -764,8 +765,8 @@ 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?!"); - g_pXWayland->pWM.reset(); - g_pXWayland->pServer.reset(); + g_pXWayland->m_wm.reset(); + g_pXWayland->m_server.reset(); // Attempt to create fresh instance g_pEventLoopManager->doLater([]() { g_pXWayland = makeUnique(true); }); return 0; @@ -774,7 +775,7 @@ int CXWM::onEvent(int fd, uint32_t mask) { int count = 0; while (42069) { - xcb_generic_event_t* event = xcb_poll_for_event(connection); + xcb_generic_event_t* event = xcb_poll_for_event(m_connection); if (!event) break; @@ -806,19 +807,19 @@ int CXWM::onEvent(int fd, uint32_t mask) { } if (count) - xcb_flush(connection); + xcb_flush(m_connection); return count; } void CXWM::gatherResources() { - xcb_prefetch_extension_data(connection, &xcb_xfixes_id); - xcb_prefetch_extension_data(connection, &xcb_composite_id); - xcb_prefetch_extension_data(connection, &xcb_res_id); + xcb_prefetch_extension_data(m_connection, &xcb_xfixes_id); + xcb_prefetch_extension_data(m_connection, &xcb_composite_id); + xcb_prefetch_extension_data(m_connection, &xcb_res_id); for (auto& ATOM : HYPRATOMS) { - xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 0, ATOM.first.length(), ATOM.first.c_str()); - xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(connection, cookie, nullptr); + xcb_intern_atom_cookie_t cookie = xcb_intern_atom(m_connection, 0, ATOM.first.length(), ATOM.first.c_str()); + xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Atom failed: {}", ATOM.first); @@ -829,33 +830,33 @@ void CXWM::gatherResources() { free(reply); } - xfixes = xcb_get_extension_data(connection, &xcb_xfixes_id); + m_xfixes = xcb_get_extension_data(m_connection, &xcb_xfixes_id); - if (!xfixes || !xfixes->present) + if (!m_xfixes || !m_xfixes->present) Debug::log(WARN, "XFixes not available"); xcb_xfixes_query_version_cookie_t xfixes_cookie; xcb_xfixes_query_version_reply_t* xfixes_reply; - xfixes_cookie = xcb_xfixes_query_version(connection, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION); - xfixes_reply = xcb_xfixes_query_version_reply(connection, xfixes_cookie, nullptr); + xfixes_cookie = xcb_xfixes_query_version(m_connection, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION); + xfixes_reply = xcb_xfixes_query_version_reply(m_connection, xfixes_cookie, nullptr); Debug::log(LOG, "xfixes version: {}.{}", xfixes_reply->major_version, xfixes_reply->minor_version); - xfixesMajor = xfixes_reply->major_version; + m_xfixesMajor = xfixes_reply->major_version; free(xfixes_reply); - const xcb_query_extension_reply_t* xresReply1 = xcb_get_extension_data(connection, &xcb_res_id); + const xcb_query_extension_reply_t* xresReply1 = xcb_get_extension_data(m_connection, &xcb_res_id); if (!xresReply1 || !xresReply1->present) return; - xcb_res_query_version_cookie_t xres_cookie = xcb_res_query_version(connection, XCB_RES_MAJOR_VERSION, XCB_RES_MINOR_VERSION); - xcb_res_query_version_reply_t* xres_reply = xcb_res_query_version_reply(connection, xres_cookie, nullptr); + xcb_res_query_version_cookie_t xres_cookie = xcb_res_query_version(m_connection, XCB_RES_MAJOR_VERSION, XCB_RES_MINOR_VERSION); + xcb_res_query_version_reply_t* xres_reply = xcb_res_query_version_reply(m_connection, xres_cookie, nullptr); if (xres_reply == nullptr) return; Debug::log(LOG, "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)) { - xres = xresReply1; + m_xres = xresReply1; } free(xres_reply); } @@ -865,7 +866,7 @@ void CXWM::getVisual() { xcb_visualtype_iterator_t vt_iter; xcb_visualtype_t* visualtype; - d_iter = xcb_screen_allowed_depths_iterator(screen); + d_iter = xcb_screen_allowed_depths_iterator(m_screen); visualtype = nullptr; while (d_iter.rem > 0) { if (d_iter.data->depth == 32) { @@ -882,14 +883,14 @@ void CXWM::getVisual() { return; } - visual_id = visualtype->visual_id; - colormap = xcb_generate_id(connection); - xcb_create_colormap(connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visual_id); + m_visualID = visualtype->visual_id; + m_colormap = xcb_generate_id(m_connection); + xcb_create_colormap(m_connection, XCB_COLORMAP_ALLOC_NONE, m_colormap, m_screen->root, m_visualID); } void CXWM::getRenderFormat() { - xcb_render_query_pict_formats_cookie_t cookie = xcb_render_query_pict_formats(connection); - xcb_render_query_pict_formats_reply_t* reply = xcb_render_query_pict_formats_reply(connection, cookie, nullptr); + xcb_render_query_pict_formats_cookie_t cookie = xcb_render_query_pict_formats(m_connection); + xcb_render_query_pict_formats_reply_t* reply = xcb_render_query_pict_formats_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(LOG, "xwm: No xcb_render_query_pict_formats_reply_t reply"); return; @@ -911,30 +912,30 @@ void CXWM::getRenderFormat() { return; } - render_format_id = format->id; + m_renderFormatID = format->id; free(reply); } -CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) { +CXWM::CXWM() : m_connection(g_pXWayland->m_server->m_xwmFDs[0].get()) { - if (connection.hasError()) { - Debug::log(ERR, "[xwm] Couldn't start, error {}", connection.hasError()); + if (m_connection.hasError()) { + Debug::log(ERR, "[xwm] Couldn't start, error {}", m_connection.hasError()); return; } - CXCBErrorContext xcbErrCtx(connection); + CXCBErrorContext xcbErrCtx(m_connection); if (!xcbErrCtx.isValid()) { Debug::log(ERR, "[xwm] Couldn't allocate errors context"); return; } - dndDataDevice->self = dndDataDevice; + m_dndDataDevice->m_self = m_dndDataDevice; - xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(connection)); - screen = screen_iterator.data; + xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(m_connection)); + m_screen = screen_iterator.data; - eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, g_pXWayland->pServer->xwmFDs[0].get(), WL_EVENT_READABLE, ::onX11Event, nullptr); - wl_event_source_check(eventSource); + m_eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, g_pXWayland->m_server->m_xwmFDs[0].get(), WL_EVENT_READABLE, ::onX11Event, nullptr); + wl_event_source_check(m_eventSource); gatherResources(); getVisual(); @@ -943,114 +944,115 @@ CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) { uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_PROPERTY_CHANGE, }; - xcb_change_window_attributes(connection, screen->root, XCB_CW_EVENT_MASK, values); + xcb_change_window_attributes(m_connection, m_screen->root, XCB_CW_EVENT_MASK, values); - xcb_composite_redirect_subwindows(connection, screen->root, XCB_COMPOSITE_REDIRECT_MANUAL); + xcb_composite_redirect_subwindows(m_connection, m_screen->root, XCB_COMPOSITE_REDIRECT_MANUAL); xcb_atom_t supported[] = { HYPRATOMS["_NET_WM_STATE"], HYPRATOMS["_NET_ACTIVE_WINDOW"], HYPRATOMS["_NET_WM_MOVERESIZE"], HYPRATOMS["_NET_WM_STATE_FOCUSED"], HYPRATOMS["_NET_WM_STATE_MODAL"], HYPRATOMS["_NET_WM_STATE_FULLSCREEN"], HYPRATOMS["_NET_WM_STATE_MAXIMIZED_VERT"], HYPRATOMS["_NET_WM_STATE_MAXIMIZED_HORZ"], HYPRATOMS["_NET_WM_STATE_HIDDEN"], HYPRATOMS["_NET_CLIENT_LIST"], HYPRATOMS["_NET_CLIENT_LIST_STACKING"], }; - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_SUPPORTED"], XCB_ATOM_ATOM, 32, sizeof(supported) / sizeof(*supported), supported); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_SUPPORTED"], XCB_ATOM_ATOM, 32, sizeof(supported) / sizeof(*supported), supported); setActiveWindow(XCB_WINDOW_NONE); initSelection(); - listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast>(d)); }); - listeners.newXShellSurface = PROTO::xwaylandShell->m_events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast>(d)); }); + m_listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast>(d)); }); + m_listeners.newXShellSurface = + PROTO::xwaylandShell->m_events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast>(d)); }); createWMWindow(); - xcb_flush(connection); + xcb_flush(m_connection); } CXWM::~CXWM() { - if (eventSource) - wl_event_source_remove(eventSource); + if (m_eventSource) + wl_event_source_remove(m_eventSource); - for (auto const& sr : surfaces) { - sr->events.destroy.emit(); + for (auto const& sr : m_surfaces) { + sr->m_events.destroy.emit(); } } void CXWM::setActiveWindow(xcb_window_t window) { - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_ACTIVE_WINDOW"], HYPRATOMS["WINDOW"], 32, 1, &window); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_ACTIVE_WINDOW"], HYPRATOMS["WINDOW"], 32, 1, &window); } void CXWM::createWMWindow() { constexpr const char* wmName = "Hyprland :D"; - wmWindow = xcb_generate_id(connection); - xcb_create_window(connection, XCB_COPY_FROM_PARENT, wmWindow, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, 0, nullptr); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, wmWindow, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"], + m_wmWindow = xcb_generate_id(m_connection); + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_wmWindow, m_screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_screen->root_visual, 0, nullptr); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_wmWindow, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"], 8, // format strlen(wmName), wmName); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, 32, // format - 1, &wmWindow); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, wmWindow, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, + 1, &m_wmWindow); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_wmWindow, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, 32, // format - 1, &wmWindow); - xcb_set_selection_owner(connection, wmWindow, HYPRATOMS["WM_S0"], XCB_CURRENT_TIME); - xcb_set_selection_owner(connection, wmWindow, HYPRATOMS["_NET_WM_CM_S0"], XCB_CURRENT_TIME); + 1, &m_wmWindow); + xcb_set_selection_owner(m_connection, m_wmWindow, HYPRATOMS["WM_S0"], XCB_CURRENT_TIME); + xcb_set_selection_owner(m_connection, m_wmWindow, HYPRATOMS["_NET_WM_CM_S0"], XCB_CURRENT_TIME); } void CXWM::activateSurface(SP surf, bool activate) { - if ((surf == focusedSurface && activate) || (surf && surf->overrideRedirect)) + if ((surf == m_focusedSurface && activate) || (surf && surf->m_overrideRedirect)) return; if (!surf || (!activate && g_pCompositor->m_lastWindow && !g_pCompositor->m_lastWindow->m_isX11)) { setActiveWindow((uint32_t)XCB_WINDOW_NONE); focusWindow(nullptr); } else { - setActiveWindow(surf ? surf->xID : (uint32_t)XCB_WINDOW_NONE); + setActiveWindow(surf ? surf->m_xID : (uint32_t)XCB_WINDOW_NONE); focusWindow(surf); } - xcb_flush(connection); + xcb_flush(m_connection); } void CXWM::sendState(SP surf) { - Debug::log(TRACE, "[xwm] sendState for {} {} {} surface {}", surf->mapped ? "mapped" : "unmapped", surf->fullscreen ? "fullscreen" : "windowed", - surf == focusedSurface ? "focused" : "unfocused", surf->state.title); - if (surf->fullscreen && surf->mapped && surf == focusedSurface) + 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); + if (surf->m_fullscreen && surf->m_mapped && surf == m_focusedSurface) surf->setWithdrawn(false); // resend normal state - if (surf->withdrawn) { - xcb_delete_property(connection, surf->xID, HYPRATOMS["_NET_WM_STATE"]); + if (surf->m_withdrawn) { + xcb_delete_property(m_connection, surf->m_xID, HYPRATOMS["_NET_WM_STATE"]); return; } std::vector props; // reserve to avoid reallocations props.reserve(6); // props below - if (surf->modal) + if (surf->m_modal) props.push_back(HYPRATOMS["_NET_WM_STATE_MODAL"]); - if (surf->fullscreen) + if (surf->m_fullscreen) props.push_back(HYPRATOMS["_NET_WM_STATE_FULLSCREEN"]); - if (surf->maximized) { + if (surf->m_maximized) { props.push_back(HYPRATOMS["NET_WM_STATE_MAXIMIZED_VERT"]); props.push_back(HYPRATOMS["NET_WM_STATE_MAXIMIZED_HORZ"]); } - if (surf->minimized) + if (surf->m_minimized) props.push_back(HYPRATOMS["_NET_WM_STATE_HIDDEN"]); - if (surf == focusedSurface) + if (surf == m_focusedSurface) props.push_back(HYPRATOMS["_NET_WM_STATE_FOCUSED"]); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, surf->xID, HYPRATOMS["_NET_WM_STATE"], XCB_ATOM_ATOM, 32, props.size(), props.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, surf->m_xID, HYPRATOMS["_NET_WM_STATE"], XCB_ATOM_ATOM, 32, props.size(), props.data()); } void CXWM::onNewSurface(SP surf) { - if (surf->client() != g_pXWayland->pServer->xwaylandClient) + if (surf->client() != g_pXWayland->m_server->m_xwaylandClient) return; Debug::log(LOG, "[xwm] New XWayland surface at {:x}", (uintptr_t)surf.get()); const auto WLID = surf->id(); - for (auto const& sr : surfaces) { - if (sr->surface || sr->wlID != WLID) + for (auto const& sr : m_surfaces) { + if (sr->m_surface || sr->m_wlID != WLID) continue; associate(sr, surf); @@ -1063,11 +1065,11 @@ void CXWM::onNewSurface(SP surf) { void CXWM::onNewResource(SP resource) { Debug::log(LOG, "[xwm] New XWayland resource at {:x}", (uintptr_t)resource.get()); - std::erase_if(shellResources, [](const auto& e) { return e.expired(); }); - shellResources.emplace_back(resource); + std::erase_if(m_shellResources, [](const auto& e) { return e.expired(); }); + m_shellResources.emplace_back(resource); - for (auto const& surf : surfaces) { - if (surf->resource || surf->wlSerial != resource->m_serial) + for (auto const& surf : m_surfaces) { + if (surf->m_resource || surf->m_wlSerial != resource->m_serial) continue; associate(surf, resource->m_surface.lock()); @@ -1083,8 +1085,8 @@ void CXWM::readWindowData(SP surf) { }; for (size_t i = 0; i < interestingProps.size(); i++) { - xcb_get_property_cookie_t cookie = xcb_get_property(connection, 0, surf->xID, interestingProps[i], XCB_ATOM_ANY, 0, 2048); - xcb_get_property_reply_t* reply = xcb_get_property_reply(connection, cookie, nullptr); + xcb_get_property_cookie_t cookie = xcb_get_property(m_connection, 0, surf->m_xID, interestingProps[i], XCB_ATOM_ANY, 0, 2048); + xcb_get_property_reply_t* reply = xcb_get_property_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Failed to get window property"); continue; @@ -1095,8 +1097,8 @@ void CXWM::readWindowData(SP surf) { } SP CXWM::windowForWayland(SP surf) { - for (auto& s : surfaces) { - if (s->surface == surf) + for (auto& s : m_surfaces) { + if (s->m_surface == surf) return s; } @@ -1104,100 +1106,100 @@ SP CXWM::windowForWayland(SP surf) { } void CXWM::associate(SP surf, SP wlSurf) { - if (surf->surface) + if (surf->m_surface) return; - auto existing = std::find_if(surfaces.begin(), surfaces.end(), [wlSurf](const auto& e) { return e->surface == wlSurf; }); + auto existing = std::find_if(m_surfaces.begin(), m_surfaces.end(), [wlSurf](const auto& e) { return e->m_surface == wlSurf; }); - if (existing != surfaces.end()) { + if (existing != m_surfaces.end()) { Debug::log(WARN, "[xwm] associate() called but surface is already associated to {:x}, ignoring...", (uintptr_t)surf.get()); return; } - surf->surface = wlSurf; + surf->m_surface = wlSurf; surf->ensureListeners(); readWindowData(surf); - surf->events.resourceChange.emit(); + surf->m_events.resourceChange.emit(); } void CXWM::dissociate(SP surf) { - if (!surf->surface) + if (!surf->m_surface) return; - if (surf->mapped) + if (surf->m_mapped) surf->unmap(); - surf->surface.reset(); - surf->events.resourceChange.emit(); + surf->m_surface.reset(); + surf->m_events.resourceChange.emit(); Debug::log(LOG, "Dissociate for {:x}", (uintptr_t)surf.get()); } void CXWM::updateClientList() { std::vector windows; - windows.reserve(mappedSurfaces.size()); + windows.reserve(m_mappedSurfaces.size()); - for (auto const& s : mappedSurfaces) { + for (auto const& s : m_mappedSurfaces) { if (auto surf = s.lock(); surf) - windows.push_back(surf->xID); + windows.push_back(surf->m_xID); } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_CLIENT_LIST"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_CLIENT_LIST"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); windows.clear(); - windows.reserve(mappedSurfacesStacking.size()); + windows.reserve(m_mappedSurfacesStacking.size()); - for (auto const& s : mappedSurfacesStacking) { + for (auto const& s : m_mappedSurfacesStacking) { if (auto surf = s.lock(); surf) - windows.push_back(surf->xID); + windows.push_back(surf->m_xID); } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_CLIENT_LIST_STACKING"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_CLIENT_LIST_STACKING"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); } bool CXWM::isWMWindow(xcb_window_t w) { - return w == wmWindow || w == clipboard.window || w == dndSelection.window; + return w == m_wmWindow || w == m_clipboard.window || w == m_dndSelection.window; } void CXWM::updateOverrideRedirect(SP surf, bool overrideRedirect) { - if (!surf || surf->overrideRedirect == overrideRedirect) + if (!surf || surf->m_overrideRedirect == overrideRedirect) return; - surf->overrideRedirect = overrideRedirect; + surf->m_overrideRedirect = overrideRedirect; } void CXWM::initSelection() { - clipboard.window = xcb_generate_id(connection); - uint32_t mask[1] = {XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE}; - xcb_create_window(connection, XCB_COPY_FROM_PARENT, clipboard.window, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, XCB_CW_EVENT_MASK, - mask); - xcb_set_selection_owner(connection, clipboard.window, HYPRATOMS["CLIPBOARD_MANAGER"], XCB_TIME_CURRENT_TIME); + m_clipboard.window = xcb_generate_id(m_connection); + uint32_t mask[1] = {XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE}; + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_clipboard.window, m_screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_screen->root_visual, + XCB_CW_EVENT_MASK, mask); + xcb_set_selection_owner(m_connection, m_clipboard.window, HYPRATOMS["CLIPBOARD_MANAGER"], XCB_TIME_CURRENT_TIME); uint32_t mask2 = XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE; - xcb_xfixes_select_selection_input(connection, clipboard.window, HYPRATOMS["CLIPBOARD"], mask2); + xcb_xfixes_select_selection_input(m_connection, m_clipboard.window, HYPRATOMS["CLIPBOARD"], mask2); - clipboard.listeners.setSelection = g_pSeatManager->m_events.setSelection.registerListener([this](std::any d) { clipboard.onSelection(); }); - clipboard.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { clipboard.onKeyboardFocus(); }); + m_clipboard.listeners.setSelection = g_pSeatManager->m_events.setSelection.registerListener([this](std::any d) { m_clipboard.onSelection(); }); + m_clipboard.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { m_clipboard.onKeyboardFocus(); }); - primarySelection.window = xcb_generate_id(connection); - xcb_create_window(connection, XCB_COPY_FROM_PARENT, primarySelection.window, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, + m_primarySelection.window = xcb_generate_id(m_connection); + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_primarySelection.window, m_screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_screen->root_visual, XCB_CW_EVENT_MASK, mask); - xcb_set_selection_owner(connection, primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); + xcb_set_selection_owner(m_connection, m_primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); - xcb_xfixes_select_selection_input(connection, primarySelection.window, HYPRATOMS["PRIMARY"], mask2); + xcb_xfixes_select_selection_input(m_connection, m_primarySelection.window, HYPRATOMS["PRIMARY"], mask2); - primarySelection.listeners.setSelection = g_pSeatManager->m_events.setPrimarySelection.registerListener([this](std::any d) { primarySelection.onSelection(); }); - primarySelection.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { primarySelection.onKeyboardFocus(); }); + m_primarySelection.listeners.setSelection = g_pSeatManager->m_events.setPrimarySelection.registerListener([this](std::any d) { m_primarySelection.onSelection(); }); + m_primarySelection.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { m_primarySelection.onKeyboardFocus(); }); - dndSelection.window = xcb_generate_id(connection); - xcb_create_window(connection, XCB_COPY_FROM_PARENT, dndSelection.window, screen->root, 0, 0, 8192, 8192, 0, XCB_WINDOW_CLASS_INPUT_ONLY, screen->root_visual, XCB_CW_EVENT_MASK, - mask); + m_dndSelection.window = xcb_generate_id(m_connection); + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_dndSelection.window, m_screen->root, 0, 0, 8192, 8192, 0, XCB_WINDOW_CLASS_INPUT_ONLY, m_screen->root_visual, + XCB_CW_EVENT_MASK, mask); uint32_t val1 = XDND_VERSION; - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, dndSelection.window, HYPRATOMS["XdndAware"], XCB_ATOM_ATOM, 32, 1, &val1); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_dndSelection.window, HYPRATOMS["XdndAware"], XCB_ATOM_ATOM, 32, 1, &val1); } void CXWM::setClipboardToWayland(SXSelection& sel) { @@ -1209,11 +1211,11 @@ void CXWM::setClipboardToWayland(SXSelection& sel) { sel.dataSource = source; - Debug::log(LOG, "[xwm] X selection at {:x} takes {}", (uintptr_t)sel.dataSource.get(), (&sel == &clipboard) ? "clipboard" : "primary selection"); + Debug::log(LOG, "[xwm] X selection at {:x} takes {}", (uintptr_t)sel.dataSource.get(), (&sel == &m_clipboard) ? "clipboard" : "primary selection"); - if (&sel == &clipboard) + if (&sel == &m_clipboard) g_pSeatManager->setCurrentSelection(sel.dataSource); - else if (&sel == &primarySelection) + else if (&sel == &m_primarySelection) g_pSeatManager->setCurrentPrimarySelection(sel.dataSource); } @@ -1274,40 +1276,40 @@ void CXWM::getTransferData(SXSelection& sel) { } void CXWM::setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& size, const Vector2D& hotspot) { - if (!render_format_id) { + if (!m_renderFormatID) { Debug::log(ERR, "[xwm] can't set cursor: no render format"); return; } - if (cursorXID) - xcb_free_cursor(connection, cursorXID); + if (m_cursorXID) + xcb_free_cursor(m_connection, m_cursorXID); constexpr int CURSOR_DEPTH = 32; - xcb_pixmap_t pix = xcb_generate_id(connection); - xcb_create_pixmap(connection, CURSOR_DEPTH, pix, screen->root, size.x, size.y); + xcb_pixmap_t pix = xcb_generate_id(m_connection); + xcb_create_pixmap(m_connection, CURSOR_DEPTH, pix, m_screen->root, size.x, size.y); - xcb_render_picture_t pic = xcb_generate_id(connection); - xcb_render_create_picture(connection, pic, pix, render_format_id, 0, 0); + xcb_render_picture_t pic = xcb_generate_id(m_connection); + xcb_render_create_picture(m_connection, pic, pix, m_renderFormatID, 0, 0); - xcb_gcontext_t gc = xcb_generate_id(connection); - xcb_create_gc(connection, gc, pix, 0, nullptr); + xcb_gcontext_t gc = xcb_generate_id(m_connection); + xcb_create_gc(m_connection, gc, pix, 0, nullptr); - xcb_put_image(connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, size.x, size.y, 0, 0, 0, CURSOR_DEPTH, stride * size.y * sizeof(uint8_t), pixData); - xcb_free_gc(connection, gc); + xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, size.x, size.y, 0, 0, 0, CURSOR_DEPTH, stride * size.y * sizeof(uint8_t), pixData); + xcb_free_gc(m_connection, gc); - cursorXID = xcb_generate_id(connection); - xcb_render_create_cursor(connection, cursorXID, pic, hotspot.x, hotspot.y); - xcb_free_pixmap(connection, pix); - xcb_render_free_picture(connection, pic); + m_cursorXID = xcb_generate_id(m_connection); + xcb_render_create_cursor(m_connection, m_cursorXID, pic, hotspot.x, hotspot.y); + xcb_free_pixmap(m_connection, pix); + xcb_render_free_picture(m_connection, pic); - uint32_t values[] = {cursorXID}; - xcb_change_window_attributes(connection, screen->root, XCB_CW_CURSOR, values); - xcb_flush(connection); + uint32_t values[] = {m_cursorXID}; + xcb_change_window_attributes(m_connection, m_screen->root, XCB_CW_CURSOR, values); + xcb_flush(m_connection); } SP CXWM::getDataDevice() { - return dndDataDevice; + return m_dndDataDevice; } SP CXWM::createX11DataOffer(SP surf, SP source) { @@ -1319,43 +1321,43 @@ SP CXWM::createX11DataOffer(SP surf, SPpWM->dndDataOffers.clear(); + g_pXWayland->m_wm->m_dndDataOffers.clear(); - auto offer = dndDataOffers.emplace_back(makeShared()); - offer->self = offer; - offer->xwaylandSurface = XSURF; - offer->source = source; + auto offer = m_dndDataOffers.emplace_back(makeShared()); + offer->m_self = offer; + offer->m_xwaylandSurface = XSURF; + offer->m_source = source; return offer; } void SXSelection::onSelection() { - if ((this == &g_pXWayland->pWM->clipboard && g_pSeatManager->m_selection.currentSelection && g_pSeatManager->m_selection.currentSelection->type() == DATA_SOURCE_TYPE_X11) || - (this == &g_pXWayland->pWM->primarySelection && g_pSeatManager->m_selection.currentPrimarySelection && + if ((this == &g_pXWayland->m_wm->m_clipboard && g_pSeatManager->m_selection.currentSelection && g_pSeatManager->m_selection.currentSelection->type() == DATA_SOURCE_TYPE_X11) || + (this == &g_pXWayland->m_wm->m_primarySelection && g_pSeatManager->m_selection.currentPrimarySelection && g_pSeatManager->m_selection.currentPrimarySelection->type() == DATA_SOURCE_TYPE_X11)) return; - if (this == &g_pXWayland->pWM->clipboard && g_pSeatManager->m_selection.currentSelection) { - xcb_set_selection_owner(g_pXWayland->pWM->connection, g_pXWayland->pWM->clipboard.window, HYPRATOMS["CLIPBOARD"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); - g_pXWayland->pWM->clipboard.notifyOnFocus = true; - } else if (this == &g_pXWayland->pWM->primarySelection && g_pSeatManager->m_selection.currentPrimarySelection) { - xcb_set_selection_owner(g_pXWayland->pWM->connection, g_pXWayland->pWM->primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); - g_pXWayland->pWM->primarySelection.notifyOnFocus = true; + if (this == &g_pXWayland->m_wm->m_clipboard && g_pSeatManager->m_selection.currentSelection) { + xcb_set_selection_owner(g_pXWayland->m_wm->m_connection, g_pXWayland->m_wm->m_clipboard.window, HYPRATOMS["CLIPBOARD"], XCB_TIME_CURRENT_TIME); + xcb_flush(g_pXWayland->m_wm->m_connection); + g_pXWayland->m_wm->m_clipboard.notifyOnFocus = true; + } else if (this == &g_pXWayland->m_wm->m_primarySelection && g_pSeatManager->m_selection.currentPrimarySelection) { + xcb_set_selection_owner(g_pXWayland->m_wm->m_connection, g_pXWayland->m_wm->m_primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); + xcb_flush(g_pXWayland->m_wm->m_connection); + g_pXWayland->m_wm->m_primarySelection.notifyOnFocus = true; } } void SXSelection::onKeyboardFocus() { - if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->pServer->xwaylandClient) + if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->m_server->m_xwaylandClient) return; - if (this == &g_pXWayland->pWM->clipboard && g_pXWayland->pWM->clipboard.notifyOnFocus) { + if (this == &g_pXWayland->m_wm->m_clipboard && g_pXWayland->m_wm->m_clipboard.notifyOnFocus) { onSelection(); - g_pXWayland->pWM->clipboard.notifyOnFocus = false; - } else if (this == &g_pXWayland->pWM->primarySelection && g_pXWayland->pWM->primarySelection.notifyOnFocus) { + g_pXWayland->m_wm->m_clipboard.notifyOnFocus = false; + } else if (this == &g_pXWayland->m_wm->m_primarySelection && g_pXWayland->m_wm->m_primarySelection.notifyOnFocus) { onSelection(); - g_pXWayland->pWM->primarySelection.notifyOnFocus = false; + g_pXWayland->m_wm->m_primarySelection.notifyOnFocus = false; } } @@ -1373,7 +1375,7 @@ int SXSelection::onRead(int fd, uint32_t mask) { auto len = read(fd, transfer->data.data() + pre, INCR_CHUNK_SIZE - 1); if (len < 0) { Debug::log(ERR, "[xwm] readDataSource died"); - g_pXWayland->pWM->selectionSendNotify(&transfer->request, false); + g_pXWayland->m_wm->selectionSendNotify(&transfer->request, false); transfers.erase(it); return 0; } @@ -1382,10 +1384,10 @@ int SXSelection::onRead(int fd, uint32_t mask) { if (len == 0) { Debug::log(LOG, "[xwm] Received all the bytes, final length {}", transfer->data.size()); - xcb_change_property(g_pXWayland->pWM->connection, XCB_PROP_MODE_REPLACE, transfer->request.requestor, transfer->request.property, transfer->request.target, 8, + xcb_change_property(g_pXWayland->m_wm->m_connection, XCB_PROP_MODE_REPLACE, transfer->request.requestor, transfer->request.property, transfer->request.target, 8, transfer->data.size(), transfer->data.data()); - xcb_flush(g_pXWayland->pWM->connection); - g_pXWayland->pWM->selectionSendNotify(&transfer->request, true); + xcb_flush(g_pXWayland->m_wm->m_connection); + g_pXWayland->m_wm->selectionSendNotify(&transfer->request, true); transfers.erase(it); } else Debug::log(LOG, "[xwm] Received {} bytes, waiting...", len); @@ -1403,12 +1405,12 @@ static int readDataSource(int fd, uint32_t mask, void* data) { bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) { WP selection; - if (this == &g_pXWayland->pWM->clipboard) + if (this == &g_pXWayland->m_wm->m_clipboard) selection = g_pSeatManager->m_selection.currentSelection; - else if (this == &g_pXWayland->pWM->primarySelection) + else if (this == &g_pXWayland->m_wm->m_primarySelection) selection = g_pSeatManager->m_selection.currentPrimarySelection; - else if (!g_pXWayland->pWM->dndDataOffers.empty()) - selection = g_pXWayland->pWM->dndDataOffers.at(0)->getSource(); + else if (!g_pXWayland->m_wm->m_dndDataOffers.empty()) + selection = g_pXWayland->m_wm->m_dndDataOffers.at(0)->getSource(); if (!selection) return false; @@ -1491,16 +1493,17 @@ SXTransfer::~SXTransfer() { if (eventSource) wl_event_source_remove(eventSource); if (incomingWindow) - xcb_destroy_window(g_pXWayland->pWM->connection, incomingWindow); + xcb_destroy_window(g_pXWayland->m_wm->m_connection, incomingWindow); if (propertyReply) free(propertyReply); } bool SXTransfer::getIncomingSelectionProp(bool erase) { - xcb_get_property_cookie_t cookie = xcb_get_property(g_pXWayland->pWM->connection, erase, incomingWindow, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 0x1fffffff); + xcb_get_property_cookie_t cookie = + xcb_get_property(g_pXWayland->m_wm->m_connection, erase, incomingWindow, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 0x1fffffff); propertyStart = 0; - propertyReply = xcb_get_property_reply(g_pXWayland->pWM->connection, cookie, nullptr); + 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"); diff --git a/src/xwayland/XWM.hpp b/src/xwayland/XWM.hpp index 25010b0b8..d6383bf46 100644 --- a/src/xwayland/XWM.hpp +++ b/src/xwayland/XWM.hpp @@ -63,45 +63,45 @@ struct SXSelection { class CXCBConnection { public: - CXCBConnection(int fd) : connection{xcb_connect_to_fd(fd, nullptr)} { + CXCBConnection(int fd) : m_connection{xcb_connect_to_fd(fd, nullptr)} { ; } ~CXCBConnection() { - if (connection) - xcb_disconnect(connection); + if (m_connection) + xcb_disconnect(m_connection); } bool hasError() const { - return xcb_connection_has_error(connection); + return xcb_connection_has_error(m_connection); } operator xcb_connection_t*() const { - return connection; + return m_connection; } private: - xcb_connection_t* connection = nullptr; + xcb_connection_t* m_connection = nullptr; }; class CXCBErrorContext { public: explicit CXCBErrorContext(xcb_connection_t* connection) { - if (xcb_errors_context_new(connection, &errors) != 0) - errors = nullptr; + if (xcb_errors_context_new(connection, &m_errors) != 0) + m_errors = nullptr; } ~CXCBErrorContext() { - if (errors) - xcb_errors_context_free(errors); + if (m_errors) + xcb_errors_context_free(m_errors); } bool isValid() const { - return errors != nullptr; + return m_errors != nullptr; } private: - xcb_errors_context_t* errors = nullptr; + xcb_errors_context_t* m_errors = nullptr; }; class CXWM { @@ -174,42 +174,42 @@ class CXWM { SXSelection* getSelection(xcb_atom_t atom); // - CXCBConnection connection; - xcb_errors_context_t* errors = nullptr; - xcb_screen_t* screen = nullptr; + CXCBConnection m_connection; + xcb_errors_context_t* m_errors = nullptr; + xcb_screen_t* m_screen = nullptr; - xcb_window_t wmWindow; + xcb_window_t m_wmWindow; - wl_event_source* eventSource = nullptr; + wl_event_source* m_eventSource = nullptr; - const xcb_query_extension_reply_t* xfixes = nullptr; - const xcb_query_extension_reply_t* xres = nullptr; - int xfixesMajor = 0; + const xcb_query_extension_reply_t* m_xfixes = nullptr; + const xcb_query_extension_reply_t* m_xres = nullptr; + int m_xfixesMajor = 0; - xcb_visualid_t visual_id; - xcb_colormap_t colormap; - uint32_t cursorXID = 0; + xcb_visualid_t m_visualID; + xcb_colormap_t m_colormap; + uint32_t m_cursorXID = 0; - xcb_render_pictformat_t render_format_id; + xcb_render_pictformat_t m_renderFormatID; - std::vector> shellResources; - std::vector> surfaces; - std::vector> mappedSurfaces; // ordered by map time - std::vector> mappedSurfacesStacking; // ordered by stacking + std::vector> m_shellResources; + std::vector> m_surfaces; + std::vector> m_mappedSurfaces; // ordered by map time + std::vector> m_mappedSurfacesStacking; // ordered by stacking - WP focusedSurface; - uint64_t lastFocusSeq = 0; + WP m_focusedSurface; + uint64_t m_lastFocusSeq = 0; - SXSelection clipboard; - SXSelection primarySelection; - SXSelection dndSelection; - SP dndDataDevice = makeShared(); - std::vector> dndDataOffers; + SXSelection m_clipboard; + SXSelection m_primarySelection; + SXSelection m_dndSelection; + SP m_dndDataDevice = makeShared(); + std::vector> m_dndDataOffers; struct { CHyprSignalListener newWLSurface; CHyprSignalListener newXShellSurface; - } listeners; + } m_listeners; friend class CXWaylandSurface; friend class CXWayland; diff --git a/src/xwayland/XWayland.cpp b/src/xwayland/XWayland.cpp index 1f78231f7..f7bdf1e6f 100644 --- a/src/xwayland/XWayland.cpp +++ b/src/xwayland/XWayland.cpp @@ -26,9 +26,9 @@ CXWayland::CXWayland(const bool wantsEnabled) { Debug::log(LOG, "Starting up the XWayland server"); - pServer = makeUnique(); + m_server = makeUnique(); - if (!pServer->create()) { + if (!m_server->create()) { Debug::log(ERR, "XWayland failed to start: it will not work."); return; } @@ -41,12 +41,12 @@ CXWayland::CXWayland(const bool wantsEnabled) { void CXWayland::setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& size, const Vector2D& hotspot) { #ifndef NO_XWAYLAND - if (!pWM) { + if (!m_wm) { Debug::log(ERR, "Couldn't set XCursor: no XWM yet"); return; } - pWM->setCursor(pixData, stride, size, hotspot); + m_wm->setCursor(pixData, stride, size, hotspot); #endif } diff --git a/src/xwayland/XWayland.hpp b/src/xwayland/XWayland.hpp index 9202f19ee..7fd6e3543 100644 --- a/src/xwayland/XWayland.hpp +++ b/src/xwayland/XWayland.hpp @@ -19,17 +19,13 @@ class CXWayland { CXWayland(const bool wantsEnabled); #ifndef NO_XWAYLAND - UP pServer; - UP pWM; + UP m_server; + UP m_wm; #endif bool enabled(); void setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& size, const Vector2D& hotspot); - struct { - CSignal newSurface; - } events; - private: bool m_enabled = false; };